RCSID("$Header$");
#ifdef AFS_FBSD40_ENV
+#include <sys/malloc.h>
#include "rx/rx_kcommon.h"
-
#ifdef RXK_LISTENER_ENV
-int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
- int nvecs, int *alength)
-{
+int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
+ int nvecs, int *alength)
+{
struct socket *asocket = (struct socket *)so;
struct uio u;
int i;
struct iovec iov[RX_MAXIOVECS];
- struct sockaddr *sa;
+ struct sockaddr *sa = NULL;
int code;
int haveGlock = ISAFS_GLOCK();
/*AFS_STATCNT(osi_NetReceive);*/
- if (nvecs > RX_MAXIOVECS) {
+ if (nvecs > RX_MAXIOVECS)
osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs);
- }
- for (i = 0 ; i < nvecs ; i++) {
- iov[i].iov_base = dvec[i].iov_base;
- iov[i].iov_len = dvec[i].iov_len;
- }
+ for (i = 0 ; i < nvecs ; i++)
+ iov[i] = dvec[i];
- u.uio_iov=&iov[0];
- u.uio_iovcnt=nvecs;
- u.uio_offset=0;
- u.uio_resid=*alength;
- u.uio_segflg=UIO_SYSSPACE;
- u.uio_rw=UIO_READ;
- u.uio_procp=NULL;
+ u.uio_iov = &iov[0];
+ u.uio_iovcnt = nvecs;
+ u.uio_offset = 0;
+ u.uio_resid = *alength;
+ u.uio_segflg = UIO_SYSSPACE;
+ u.uio_rw = UIO_READ;
+ u.uio_procp = NULL;
- if (haveGlock) {
+ if (haveGlock)
AFS_GUNLOCK();
- }
code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
-#if KNET_DEBUG
+ if (haveGlock)
+ AFS_GLOCK();
+
if (code) {
+#if KNET_DEBUG
if (code == EINVAL)
- Debugger("afs NetReceive busted");
+ Debugger("afs NetReceive busted");
else
- printf("y");
- }
+ printf("y");
+#else
+ return code;
#endif
- if (haveGlock) {
- AFS_GLOCK();
}
- *alength=*alength-u.uio_resid;
+ *alength -= u.uio_resid;
if (sa) {
- if (sa->sa_family == AF_INET) {
- if (addr) *addr=*(struct sockaddr_in *)sa;
- } else {
- printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
- }
+ if (sa->sa_family == AF_INET) {
+ if (addr)
+ *addr = *(struct sockaddr_in *) sa;
+ } else
+ printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
+ FREE(sa, M_SONAME);
}
return code;
}
extern int rxk_ListenerPid;
void osi_StopListener(void)
{
- struct proc *p;
+ struct proc *p;
- soclose(rx_socket);
- p=pfind(rxk_ListenerPid);
- if (p)
- psignal(p, SIGUSR1);
+ soclose(rx_socket);
+ p = pfind(rxk_ListenerPid);
+ if (p)
+ psignal(p, SIGUSR1);
}
-int
+int
osi_NetSend(osi_socket asocket, struct sockaddr_in *addr,
struct iovec *dvec, int nvecs, afs_int32 alength, int istack)
{
register afs_int32 code;
- int s;
- int len;
int i;
struct iovec iov[RX_MAXIOVECS];
- char *tdata;
struct uio u;
int haveGlock = ISAFS_GLOCK();
AFS_STATCNT(osi_NetSend);
- if (nvecs > RX_MAXIOVECS) {
+ if (nvecs > RX_MAXIOVECS)
osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
- }
- for (i = 0 ; i < nvecs ; i++) {
- iov[i].iov_base = dvec[i].iov_base;
- iov[i].iov_len = dvec[i].iov_len;
- }
+ for (i = 0 ; i < nvecs ; i++)
+ iov[i] = dvec[i];
- u.uio_iov=&iov[0];
- u.uio_iovcnt=nvecs;
- u.uio_offset=0;
- u.uio_resid=alength;
- u.uio_segflg=UIO_SYSSPACE;
- u.uio_rw=UIO_WRITE;
- u.uio_procp=NULL;
+ u.uio_iov = &iov[0];
+ u.uio_iovcnt = nvecs;
+ u.uio_offset = 0;
+ u.uio_resid = alength;
+ u.uio_segflg = UIO_SYSSPACE;
+ u.uio_rw = UIO_WRITE;
+ u.uio_procp = NULL;
- addr->sin_len=sizeof(struct sockaddr_in);
+ addr->sin_len = sizeof(struct sockaddr_in);
- if (haveGlock) {
+ if (haveGlock)
AFS_GUNLOCK();
- }
#if KNET_DEBUG
printf("+");
#endif
- code = sosend(asocket, addr, &u, NULL, NULL, 0, curproc);
+ code = sosend(asocket, (struct sockaddr *) addr, &u, NULL, NULL, 0, curproc);
#if KNET_DEBUG
if (code) {
if (code == EINVAL)
- Debugger("afs NetSend busted");
+ Debugger("afs NetSend busted");
else
- printf("z");
+ printf("z");
}
#endif
- if (haveGlock) {
+ if (haveGlock)
AFS_GLOCK();
- }
return code;
}
#else