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"
16 #include "rx/rx_kcommon.h"
19 osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
20 int nvecs, int *alength)
22 struct socket *asocket = (struct socket *)so;
25 struct iovec iov[RX_MAXIOVECS];
26 struct sockaddr *sa = NULL;
29 int haveGlock = ISAFS_GLOCK();
30 /*AFS_STATCNT(osi_NetReceive); */
32 if (nvecs > RX_MAXIOVECS)
33 osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs);
35 for (i = 0; i < nvecs; i++)
41 u.uio_resid = *alength;
42 u.uio_segflg = UIO_SYSSPACE;
48 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
49 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
51 code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
52 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
53 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
60 *alength -= u.uio_resid;
62 if (sa->sa_family == AF_INET) {
64 *addr = *(struct sockaddr_in *)sa;
66 printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
72 extern int rxk_ListenerPid;
74 osi_StopListener(void)
78 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
79 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
82 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
83 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
85 p = pfind(rxk_ListenerPid);
91 osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
92 int nvecs, afs_int32 alength, int istack)
94 register afs_int32 code;
96 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++)
108 u.uio_iovcnt = nvecs;
110 u.uio_resid = alength;
111 u.uio_segflg = UIO_SYSSPACE;
112 u.uio_rw = UIO_WRITE;
115 addr->sin_len = sizeof(struct sockaddr_in);
119 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
120 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
122 code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0);
123 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
124 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);