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);
126 #ifndef AFS_DARWIN80_ENV
133 extern int rxk_ListenerPid;
135 osi_StopListener(void)
139 #if defined(KERNEL_FUNNEL)
140 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
143 #if defined(KERNEL_FUNNEL)
144 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
146 #ifndef AFS_DARWIN80_ENV
147 p = pfind(rxk_ListenerPid);
154 osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
155 int nvecs, afs_int32 alength, int istack)
157 #ifdef AFS_DARWIN80_ENV
158 socket_t asocket = (socket_t)so;
162 struct socket *asocket = (struct socket *)so;
165 register afs_int32 code;
167 struct iovec iov[RX_MAXIOVECS];
168 int haveGlock = ISAFS_GLOCK();
170 AFS_STATCNT(osi_NetSend);
171 if (nvecs > RX_MAXIOVECS)
172 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
174 for (i = 0; i < nvecs; i++)
177 addr->sin_len = sizeof(struct sockaddr_in);
181 #if defined(KERNEL_FUNNEL)
182 thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
184 #ifdef AFS_DARWIN80_ENV
185 memset(&msg, 0, sizeof(struct msghdr));
187 msg.msg_namelen = ((struct sockaddr *)addr)->sa_len;
188 msg.msg_iov = &iov[0];
189 msg.msg_iovlen = nvecs;
190 code = sock_send(asocket, &msg, 0, &slen);
193 u.uio_iovcnt = nvecs;
195 u.uio_resid = alength;
196 u.uio_segflg = UIO_SYSSPACE;
197 u.uio_rw = UIO_WRITE;
199 code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0);
202 #if defined(KERNEL_FUNNEL)
203 thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);