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 so, struct sockaddr_in *addr, struct iovec *dvec,
18 int nvecs, int *alength)
20 struct socket *asocket = (struct socket *)so;
23 struct iovec iov[RX_MAXIOVECS];
24 struct sockaddr *sa = NULL;
27 int haveGlock = ISAFS_GLOCK();
28 /*AFS_STATCNT(osi_NetReceive);*/
30 if (nvecs > RX_MAXIOVECS)
31 osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs);
33 for (i = 0 ; i < nvecs ; i++)
39 u.uio_resid = *alength;
40 u.uio_segflg = UIO_SYSSPACE;
46 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
47 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
49 code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
50 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
51 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
58 *alength -= u.uio_resid;
60 if (sa->sa_family == AF_INET) {
62 *addr = *(struct sockaddr_in *) sa;
64 printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
70 extern int rxk_ListenerPid;
71 void osi_StopListener(void)
75 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
76 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
79 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
80 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
82 p=pfind(rxk_ListenerPid);
88 osi_NetSend(osi_socket asocket, struct sockaddr_in *addr,
89 struct iovec *dvec, int nvecs, afs_int32 alength, int istack)
91 register afs_int32 code;
93 struct iovec iov[RX_MAXIOVECS];
95 int haveGlock = ISAFS_GLOCK();
97 AFS_STATCNT(osi_NetSend);
98 if (nvecs > RX_MAXIOVECS)
99 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
101 for (i = 0 ; i < nvecs ; i++)
105 u.uio_iovcnt = nvecs;
107 u.uio_resid = alength;
108 u.uio_segflg = UIO_SYSSPACE;
109 u.uio_rw = UIO_WRITE;
112 addr->sin_len = sizeof(struct sockaddr_in);
116 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
117 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
119 code = sosend(asocket, (struct sockaddr *) addr, &u, NULL, NULL, 0);
120 #if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
121 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);