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 /* NT does not have uio structs, so we roll our own sendmsg and recvmsg.
12 * The dangerous part of this code is that it assumes that iovecs 0 and 1
13 * are contiguous and that all of 0 is used before any of 1.
14 * This is true if rx_packets are being sent, so we should be ok.
17 #include <afsconfig.h>
18 #include <afs/param.h>
23 #if defined(AFS_NT40_ENV)
28 #include "rx_packet.h"
29 #include "rx_globals.h"
30 #include "rx_xmit_nt.h"
37 recvmsg(osi_socket socket, struct msghdr *msgP, int flags)
39 char rbuf[RX_MAX_PACKET_SIZE];
46 size = rx_maxJumboRecvSize;
48 recvfrom((SOCKET) socket, rbuf, size, flags,
49 (struct sockaddr *)(msgP->msg_name), &(msgP->msg_namelen));
54 for (off = i = 0; size > 0 && i < msgP->msg_iovlen; i++) {
55 if (msgP->msg_iov[i].iov_len) {
56 if (msgP->msg_iov[i].iov_len < size) {
57 n = msgP->msg_iov[i].iov_len;
61 memcpy(msgP->msg_iov[i].iov_base, &rbuf[off], n);
67 /* Accounts for any we didn't copy in to iovecs. */
71 if (code == SOCKET_ERROR)
72 code = WSAGetLastError();
73 if (code == WSAEWOULDBLOCK || code == WSAECONNRESET)
74 errno = WSAEWOULDBLOCK;
77 #endif /* AFS_NT40_ENV */
85 sendmsg(osi_socket socket, struct msghdr *msgP, int flags)
87 char buf[RX_MAX_PACKET_SIZE];
94 for (size = i = 0; i < msgP->msg_iovlen; i++)
95 size += msgP->msg_iov[i].iov_len;
97 if (msgP->msg_iovlen <= 2) {
98 sbuf = msgP->msg_iov[0].iov_base;
100 /* Pack data into array from iovecs */
102 for (off = i = 0; tmp > 0 && i < msgP->msg_iovlen; i++) {
103 if (msgP->msg_iov[i].iov_len > 0) {
104 if (tmp > msgP->msg_iov[i].iov_len)
105 n = msgP->msg_iov[i].iov_len;
108 memcpy(&sbuf[off], msgP->msg_iov[i].iov_base, n);
116 sendto((SOCKET) socket, sbuf, size, flags,
117 (struct sockaddr *)(msgP->msg_name), msgP->msg_namelen);
120 if (code == SOCKET_ERROR) {
121 code = WSAGetLastError();
130 errno = WSAEWOULDBLOCK;
132 case WSAEHOSTUNREACH:
133 errno = WSAEHOSTUNREACH;
141 #endif /* AFS_NT40_ENV */
151 #endif /* AFS_NT40_ENV */