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>
18 #if defined(AFS_NT40_ENV) || defined(AFS_DJGPP_ENV)
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <netinet/in.h>
34 #include "rx_packet.h"
35 #include "rx_globals.h"
36 #include "rx_xmit_nt.h"
42 int recvmsg(int socket, struct msghdr *msgP, int flags)
44 char rbuf[RX_MAX_PACKET_SIZE];
51 size = rx_maxJumboRecvSize;
52 code = recvfrom((SOCKET)socket, rbuf, size, flags,
53 (struct sockaddr*)(msgP->msg_name),
54 &(msgP->msg_namelen));
59 for (off = i = 0; size > 0 && i<msgP->msg_iovlen; i++) {
60 if (msgP->msg_iov[i].iov_len) {
61 if (msgP->msg_iov[i].iov_len < size) {
62 n = msgP->msg_iov[i].iov_len;
67 memcpy(msgP->msg_iov[i].iov_base, &rbuf[off], n);
73 /* Accounts for any we didn't copy in to iovecs. */
83 int sendmsg(int socket, struct msghdr *msgP, int flags)
85 char buf[RX_MAX_PACKET_SIZE];
92 for (size = i = 0; i<msgP->msg_iovlen; i++)
93 size += msgP->msg_iov[i].iov_len;
95 if (msgP->msg_iovlen <= 2) {
96 sbuf = msgP->msg_iov[0].iov_base;
99 /* Pack data into array from iovecs */
101 for (off = i = 0; tmp > 0 && i<msgP->msg_iovlen; i++) {
102 if (msgP->msg_iov[i].iov_len > 0 ) {
103 if (tmp > msgP->msg_iov[i].iov_len)
104 n = msgP->msg_iov[i].iov_len;
107 memcpy(&sbuf[off], msgP->msg_iov[i].iov_base, n);
114 code = sendto((SOCKET)socket, sbuf, size, flags,
115 (struct sockaddr*)(msgP->msg_name), msgP->msg_namelen);
118 if (code == SOCKET_ERROR) {
119 code = WSAGetLastError();
133 #endif /* AFS_NT40_ENV */
147 #endif /* AFS_NT40_ENV || AFS_DJGPP_ENV */