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) || defined(AFS_DJGPP_ENV)
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <netinet/in.h>
39 #include "rx_packet.h"
40 #include "rx_globals.h"
41 #include "rx_xmit_nt.h"
48 recvmsg(osi_socket socket, struct msghdr *msgP, int flags)
50 char rbuf[RX_MAX_PACKET_SIZE];
57 size = rx_maxJumboRecvSize;
59 recvfrom((SOCKET) socket, rbuf, size, flags,
60 (struct sockaddr *)(msgP->msg_name), &(msgP->msg_namelen));
65 for (off = i = 0; size > 0 && i < msgP->msg_iovlen; i++) {
66 if (msgP->msg_iov[i].iov_len) {
67 if (msgP->msg_iov[i].iov_len < size) {
68 n = msgP->msg_iov[i].iov_len;
72 memcpy(msgP->msg_iov[i].iov_base, &rbuf[off], n);
78 /* Accounts for any we didn't copy in to iovecs. */
82 if (code == SOCKET_ERROR)
83 code = WSAGetLastError();
84 if (code == WSAEWOULDBLOCK || code == WSAECONNRESET)
85 errno = WSAEWOULDBLOCK;
88 #endif /* AFS_NT40_ENV */
96 sendmsg(osi_socket socket, struct msghdr *msgP, int flags)
98 char buf[RX_MAX_PACKET_SIZE];
105 for (size = i = 0; i < msgP->msg_iovlen; i++)
106 size += msgP->msg_iov[i].iov_len;
108 if (msgP->msg_iovlen <= 2) {
109 sbuf = msgP->msg_iov[0].iov_base;
111 /* Pack data into array from iovecs */
113 for (off = i = 0; tmp > 0 && i < msgP->msg_iovlen; i++) {
114 if (msgP->msg_iov[i].iov_len > 0) {
115 if (tmp > msgP->msg_iov[i].iov_len)
116 n = msgP->msg_iov[i].iov_len;
119 memcpy(&sbuf[off], msgP->msg_iov[i].iov_base, n);
127 sendto((SOCKET) socket, sbuf, size, flags,
128 (struct sockaddr *)(msgP->msg_name), msgP->msg_namelen);
131 if (code == SOCKET_ERROR) {
132 code = WSAGetLastError();
141 errno = WSAEWOULDBLOCK;
143 case WSAEHOSTUNREACH:
144 errno = WSAEHOSTUNREACH;
152 #endif /* AFS_NT40_ENV */
162 #endif /* AFS_NT40_ENV || AFS_DJGPP_ENV */