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"
18 #ifdef AFS_DARWIN80_ENV
19 #define soclose sock_close
23 osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
24 int nvecs, int *alength)
26 #ifdef AFS_DARWIN80_ENV
27 socket_t asocket = (socket_t)so;
29 struct sockaddr_storage ss;
33 struct socket *asocket = (struct socket *)so;
37 struct iovec iov[RX_MAXIOVECS];
38 struct sockaddr *sa = NULL;
42 int haveGlock = ISAFS_GLOCK();
43 /*AFS_STATCNT(osi_NetReceive); */
45 if (nvecs > RX_MAXIOVECS)
46 osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs);
48 for (i = 0; i < nvecs; i++)
52 #if defined(KERNEL_FUNNEL)
53 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
55 #ifdef AFS_DARWIN80_ENV
58 memset(&msg, 0, sizeof(struct msghdr));
60 msg.msg_namelen = sizeof(struct sockaddr_storage);
61 sa =(struct sockaddr *) &ss;
62 code = sock_receivembuf(asocket, &msg, &m, 0, alength);
66 for (i=0;i<nvecs && resid;i++) {
67 sz=MIN(resid, iov[i].iov_len);
68 code = mbuf_copydata(m, offset, sz, iov[i].iov_base);
78 printf("Want to read %d bytes...", resid);
79 for (i=0; i < nvecs && resid; i++) {
80 if (resid < iov[i].iov_len)
81 iov[0].iov_len = resid;
82 resid -= iov[i].iov_len;
84 printf("Using %d/%d iovs\n", i, nvecs);
87 memset(&msg, 0, sizeof(struct msghdr));
89 msg.msg_namelen = sizeof(struct sockaddr_storage);
90 msg.msg_iov = &iov[0];
91 msg.msg_iovlen = nvecs;
92 sa =(struct sockaddr_in *) &ss;
93 code = sock_receive(asocket, &msg, 0, &rlen);
96 printf("recieved %d bytes\n", rlen);
105 u.uio_iovcnt = nvecs;
107 u.uio_resid = *alength;
108 u.uio_segflg = UIO_SYSSPACE;
111 code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
115 #if defined(KERNEL_FUNNEL)
116 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
125 if (sa->sa_family == AF_INET) {
127 *addr = *(struct sockaddr_in *)sa;
129 printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
135 extern int rxk_ListenerPid;
137 osi_StopListener(void)
141 #if defined(KERNEL_FUNNEL)
142 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
145 #if defined(KERNEL_FUNNEL)
146 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
148 #ifndef AFS_DARWIN80_ENV
149 p = pfind(rxk_ListenerPid);
156 osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
157 int nvecs, afs_int32 alength, int istack)
159 #ifdef AFS_DARWIN80_ENV
160 socket_t asocket = (socket_t)so;
164 struct socket *asocket = (struct socket *)so;
167 register afs_int32 code;
169 struct iovec iov[RX_MAXIOVECS];
170 int haveGlock = ISAFS_GLOCK();
172 AFS_STATCNT(osi_NetSend);
173 if (nvecs > RX_MAXIOVECS)
174 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
176 for (i = 0; i < nvecs; i++)
179 addr->sin_len = sizeof(struct sockaddr_in);
183 #if defined(KERNEL_FUNNEL)
184 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
186 #ifdef AFS_DARWIN80_ENV
187 memset(&msg, 0, sizeof(struct msghdr));
189 msg.msg_namelen = ((struct sockaddr *)addr)->sa_len;
190 msg.msg_iov = &iov[0];
191 msg.msg_iovlen = nvecs;
192 code = sock_send(asocket, &msg, 0, &slen);
195 u.uio_iovcnt = nvecs;
197 u.uio_resid = alength;
198 u.uio_segflg = UIO_SYSSPACE;
199 u.uio_rw = UIO_WRITE;
201 code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0);
204 #if defined(KERNEL_FUNNEL)
205 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);