2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "../afs/param.h"
15 #include "../rx/rx_kcommon.h"
17 int osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
18 int nvecs, int *alength)
22 struct iovec iov[RX_MAXIOVECS];
23 struct mbuf *nam = NULL;
25 int haveGlock = ISAFS_GLOCK();
27 if (nvecs > RX_MAXIOVECS)
28 osi_Panic("osi_NetReceive: %d: too many iovecs\n", nvecs);
30 for (i = 0 ; i < nvecs ; i++)
36 u.uio_resid = *alength;
37 u.uio_segflg = UIO_SYSSPACE;
43 code = soreceive(asocket, (addr ? &nam : NULL), &u, NULL, NULL, NULL);
49 printf("rx code %d termState %d\n", code, afs_termState);
51 while (afs_termState == AFSOP_STOP_RXEVENT)
52 afs_osi_Sleep(&afs_termState);
56 *alength -= u.uio_resid;
58 memcpy(addr, mtod(nam, caddr_t), nam->m_len);
65 extern int rxk_ListenerPid;
66 void osi_StopListener(void)
71 p = pfind(rxk_ListenerPid);
76 /* rx_NetSend - send asize bytes at adata from asocket to host at addr.
78 * Now, why do we allocate a new buffer when we could theoretically use the one
79 * pointed to by adata? Because PRU_SEND returns after queueing the message,
80 * not after sending it. If the sender changes the data after queueing it,
81 * we'd see the already-queued data change. One attempt to fix this without
82 * adding a copy would be to have this function wait until the datagram is
83 * sent; however this doesn't work well. In particular, if a host is down, and
84 * an ARP fails to that host, this packet will be queued until the ARP request
85 * comes back, which could be hours later. We can't block in this routine that
86 * long, since it prevents RPC timeouts from happening.
88 /* XXX In the brave new world, steal the data bufs out of the rx_packet iovec,
89 * and just queue those. XXX
93 int osi_NetSend(osi_socket asocket, struct sockaddr_in *addr,
94 struct iovec *dvec, int nvecs, afs_int32 alength, int istack)
97 struct iovec iov[RX_MAXIOVECS];
100 int haveGlock = ISAFS_GLOCK();
102 AFS_STATCNT(osi_NetSend);
103 if (nvecs > RX_MAXIOVECS)
104 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
106 for (i = 0; i < nvecs; i++)
110 u.uio_iovcnt = nvecs;
112 u.uio_resid = alength;
113 u.uio_segflg = UIO_SYSSPACE;
114 u.uio_rw = UIO_WRITE;
117 nam = m_get(M_DONTWAIT, MT_SONAME);
120 nam->m_len = addr->sin_len = sizeof(struct sockaddr_in);
121 memcpy(mtod(nam, caddr_t), addr, addr->sin_len);
125 code = sosend(asocket, nam, &u, NULL, NULL, 0);