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 <afs/param.h>
23 #include "rx_packet.h"
24 #include "rx_globals.h"
25 #include "rx_xmit_nt.h"
29 int recvmsg(int socket, struct msghdr *msgP, int flags)
31 char rbuf[RX_MAX_PACKET_SIZE];
38 size = rx_maxJumboRecvSize;
39 code = recvfrom((SOCKET)socket, rbuf, size, flags,
40 (struct sockaddr*)(msgP->msg_name),
41 &(msgP->msg_namelen));
46 for (off = i = 0; size > 0 && i<msgP->msg_iovlen; i++) {
47 if (msgP->msg_iov[i].iov_len) {
48 if (msgP->msg_iov[i].iov_len < size) {
49 n = msgP->msg_iov[i].iov_len;
54 memcpy(msgP->msg_iov[i].iov_base, &rbuf[off], n);
60 /* Accounts for any we didn't copy in to iovecs. */
70 int sendmsg(int socket, struct msghdr *msgP, int flags)
72 char buf[RX_MAX_PACKET_SIZE];
79 for (size = i = 0; i<msgP->msg_iovlen; i++)
80 size += msgP->msg_iov[i].iov_len;
82 if (msgP->msg_iovlen <= 2) {
83 sbuf = msgP->msg_iov[0].iov_base;
86 /* Pack data into array from iovecs */
88 for (off = i = 0; tmp > 0 && i<msgP->msg_iovlen; i++) {
89 if (msgP->msg_iov[i].iov_len > 0 ) {
90 if (tmp > msgP->msg_iov[i].iov_len)
91 n = msgP->msg_iov[i].iov_len;
94 memcpy(&sbuf[off], msgP->msg_iov[i].iov_base, n);
101 code = sendto((SOCKET)socket, sbuf, size, flags,
102 (struct sockaddr*)(msgP->msg_name), msgP->msg_namelen);
104 if (code == SOCKET_ERROR) {
105 code = WSAGetLastError();