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++) {
31 iov[i].iov_base = dvec[i].iov_base;
32 iov[i].iov_len = dvec[i].iov_len;
38 u.uio_resid = *alength;
39 u.uio_segflg = UIO_SYSSPACE;
45 code = soreceive(asocket, (addr ? &nam : NULL), &u, NULL, NULL, NULL);
49 if (code && afs_termState != AFSOP_STOP_RXK_LISTENER) {
50 afs_osi_Sleep(&afs_termState);
54 *alength -= u.uio_resid;
56 memcpy(addr, mtod(nam, caddr_t), nam->m_len);
63 extern int rxk_ListenerPid;
64 void osi_StopListener(void)
69 p = pfind(rxk_ListenerPid);
74 /* rx_NetSend - send asize bytes at adata from asocket to host at addr.
76 * Now, why do we allocate a new buffer when we could theoretically use the one
77 * pointed to by adata? Because PRU_SEND returns after queueing the message,
78 * not after sending it. If the sender changes the data after queueing it,
79 * we'd see the already-queued data change. One attempt to fix this without
80 * adding a copy would be to have this function wait until the datagram is
81 * sent; however this doesn't work well. In particular, if a host is down, and
82 * an ARP fails to that host, this packet will be queued until the ARP request
83 * comes back, which could be hours later. We can't block in this routine that
84 * long, since it prevents RPC timeouts from happening.
86 /* XXX In the brave new world, steal the data bufs out of the rx_packet iovec,
87 * and just queue those. XXX
91 int osi_NetSend(osi_socket asocket, struct sockaddr_in *addr,
92 struct iovec *dvec, int nvecs, afs_int32 alength, int istack)
95 struct iovec iov[RX_MAXIOVECS];
98 int haveGlock = ISAFS_GLOCK();
100 AFS_STATCNT(osi_NetSend);
101 if (nvecs > RX_MAXIOVECS)
102 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
104 for (i = 0; i < nvecs; i++) {
105 iov[i].iov_base = dvec[i].iov_base;
106 iov[i].iov_len = dvec[i].iov_len;
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);