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];
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, (struct sockaddr_in *) &sa, &u, NULL, NULL, NULL);
49 *alength = *alength - u.uio_resid;
50 if (sa != NULL && sa->sa_family == AF_INET && addr != NULL)
51 *addr = *(struct sockaddr_in *)sa;
56 extern int rxk_ListenerPid;
57 void osi_StopListener(void)
62 p = pfind(rxk_ListenerPid);
67 /* rx_NetSend - send asize bytes at adata from asocket to host at addr.
69 * Now, why do we allocate a new buffer when we could theoretically use the one
70 * pointed to by adata? Because PRU_SEND returns after queueing the message,
71 * not after sending it. If the sender changes the data after queueing it,
72 * we'd see the already-queued data change. One attempt to fix this without
73 * adding a copy would be to have this function wait until the datagram is
74 * sent; however this doesn't work well. In particular, if a host is down, and
75 * an ARP fails to that host, this packet will be queued until the ARP request
76 * comes back, which could be hours later. We can't block in this routine that
77 * long, since it prevents RPC timeouts from happening.
79 /* XXX In the brave new world, steal the data bufs out of the rx_packet iovec,
80 * and just queue those. XXX
84 int osi_NetSend(osi_socket asocket, struct sockaddr_in *addr,
85 struct iovec *dvec, int nvecs, afs_int32 alength, int istack)
88 struct iovec iov[RX_MAXIOVECS];
91 int haveGlock = ISAFS_GLOCK();
93 AFS_STATCNT(osi_NetSend);
94 if (nvecs > RX_MAXIOVECS)
95 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
97 for (i = 0; i < nvecs; i++) {
98 iov[i].iov_base = dvec[i].iov_base;
99 iov[i].iov_len = dvec[i].iov_len;
103 u.uio_iovcnt = nvecs;
105 u.uio_resid = alength;
106 u.uio_segflg = UIO_SYSSPACE;
107 u.uio_rw = UIO_WRITE;
112 nam = m_get(M_DONTWAIT, MT_SONAME);
117 nam->m_len = addr->sin_len = sizeof(struct sockaddr_in);
118 memcpy(mtod(nam, caddr_t), (caddr_t)addr, addr->sin_len);
119 code = sosend(asocket, mtod(nam, struct sockaddr_in *), &u, NULL, NULL, 0);