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"
14 #include "rx/rx_kcommon.h"
16 #ifdef AFS_DARWIN80_ENV
17 #define soclose sock_close
21 osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
22 int nvecs, int *alength)
24 #ifdef AFS_DARWIN80_ENV
25 socket_t asocket = (socket_t)so;
27 struct sockaddr_storage ss;
31 struct socket *asocket = (struct socket *)so;
35 struct iovec iov[RX_MAXIOVECS];
36 struct sockaddr *sa = NULL;
40 int haveGlock = ISAFS_GLOCK();
41 /*AFS_STATCNT(osi_NetReceive); */
43 if (nvecs > RX_MAXIOVECS)
44 osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs);
46 for (i = 0; i < nvecs; i++)
49 if ((afs_termState == AFSOP_STOP_RXK_LISTENER) ||
50 (afs_termState == AFSOP_STOP_COMPLETE))
55 #if defined(KERNEL_FUNNEL)
56 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
58 #ifdef AFS_DARWIN80_ENV
60 memset(&msg, 0, sizeof(struct msghdr));
62 msg.msg_namelen = sizeof(struct sockaddr_storage);
63 sa =(struct sockaddr *) &ss;
64 code = sock_receivembuf(asocket, &msg, &m, 0, alength);
68 for (i=0;i<nvecs && resid;i++) {
69 sz=MIN(resid, iov[i].iov_len);
70 code = mbuf_copydata(m, offset, sz, iov[i].iov_base);
83 u.uio_resid = *alength;
84 u.uio_segflg = UIO_SYSSPACE;
87 code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
91 #if defined(KERNEL_FUNNEL)
92 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
101 if (sa->sa_family == AF_INET) {
103 *addr = *(struct sockaddr_in *)sa;
105 printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
106 #ifndef AFS_DARWIN80_ENV
113 extern int rxk_ListenerPid;
115 osi_StopListener(void)
119 #if defined(KERNEL_FUNNEL)
120 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
123 #if defined(KERNEL_FUNNEL)
124 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
126 #ifndef AFS_DARWIN80_ENV
127 p = pfind(rxk_ListenerPid);
134 osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
135 int nvecs, afs_int32 alength, int istack)
137 #ifdef AFS_DARWIN80_ENV
138 socket_t asocket = (socket_t)so;
142 struct socket *asocket = (struct socket *)so;
147 struct iovec iov[RX_MAXIOVECS];
148 int haveGlock = ISAFS_GLOCK();
150 AFS_STATCNT(osi_NetSend);
151 if (nvecs > RX_MAXIOVECS)
152 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
154 for (i = 0; i < nvecs; i++)
157 addr->sin_len = sizeof(struct sockaddr_in);
159 if ((afs_termState == AFSOP_STOP_RXK_LISTENER) ||
160 (afs_termState == AFSOP_STOP_COMPLETE))
166 #if defined(KERNEL_FUNNEL)
167 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
169 #ifdef AFS_DARWIN80_ENV
170 memset(&msg, 0, sizeof(struct msghdr));
172 msg.msg_namelen = ((struct sockaddr *)addr)->sa_len;
173 msg.msg_iov = &iov[0];
174 msg.msg_iovlen = nvecs;
175 code = sock_send(asocket, &msg, 0, &slen);
178 u.uio_iovcnt = nvecs;
180 u.uio_resid = alength;
181 u.uio_segflg = UIO_SYSSPACE;
182 u.uio_rw = UIO_WRITE;
184 code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0);
187 #if defined(KERNEL_FUNNEL)
188 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);