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"
14 #include "../rx/rx_kcommon.h"
17 osi_NetReceive(osi_socket asocket
, struct sockaddr_in
*addr
,
18 struct iovec
*dvec
, int nvecs
, int *alength
)
22 struct iovec iov
[RX_MAXIOVECS
];
23 struct mbuf
*nam
= NULL
;
25 int glocked
= ISAFS_GLOCK();
27 memset(&u
, 0, sizeof(u
));
28 memset(&iov
, 0, sizeof(iov
));
30 if (nvecs
> RX_MAXIOVECS
)
31 osi_Panic("osi_NetReceive: %d: too many iovecs\n", nvecs
);
33 for (i
= 0; i
< nvecs
; i
++)
39 u
.uio_resid
= *alength
;
40 UIO_SETUP_SYSSPACE(&u
);
47 code
= soreceive(asocket
, (addr
? &nam
: NULL
), &u
, NULL
, NULL
, NULL
);
53 printf("rx code %d termState %d\n", code
, afs_termState
);
55 while (afs_termState
== AFSOP_STOP_RXEVENT
)
56 afs_osi_Sleep(&afs_termState
);
60 *alength
-= u
.uio_resid
;
62 memcpy(addr
, mtod(nam
, caddr_t
), nam
->m_len
);
69 extern int rxk_ListenerPid
;
71 osi_StopListener(void)
76 soshutdown(rx_socket
, SHUT_RDWR
);
78 mutex_enter(proc_lock
);
79 p
= proc_find(rxk_ListenerPid
);
80 mutex_exit(proc_lock
);
87 * rx_NetSend - send asize bytes at adata from asocket to host at addr.
91 osi_NetSend(osi_socket asocket
, struct sockaddr_in
*addr
, struct iovec
*dvec
,
92 int nvecs
, afs_int32 alength
, int istack
)
95 struct iovec iov
[RX_MAXIOVECS
];
98 int glocked
= ISAFS_GLOCK();
100 memset(&u
, 0, sizeof(u
));
101 memset(&iov
, 0, sizeof(iov
));
103 AFS_STATCNT(osi_NetSend
);
104 if (nvecs
> RX_MAXIOVECS
)
105 osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs
);
107 for (i
= 0; i
< nvecs
; i
++)
111 u
.uio_iovcnt
= nvecs
;
113 u
.uio_resid
= alength
;
114 UIO_SETUP_SYSSPACE(&u
);
115 u
.uio_rw
= UIO_WRITE
;
119 nam
= m_get(M_DONTWAIT
, MT_SONAME
);
122 nam
->m_len
= addr
->sin_len
= sizeof(struct sockaddr_in
);
123 memcpy(mtod(nam
, caddr_t
), addr
, addr
->sin_len
);
127 code
= sosend(asocket
, nam
, &u
, NULL
, NULL
, 0, osi_curproc());