X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/71fb71a3fe36c1ebff1dd0593f15215d20f15789..5c723b90ceb41c125105d2a818e372ee31f2e522:/usr/src/sys/net/raw_usrreq.c diff --git a/usr/src/sys/net/raw_usrreq.c b/usr/src/sys/net/raw_usrreq.c index 36d2c83405..cff9e6c7ce 100644 --- a/usr/src/sys/net/raw_usrreq.c +++ b/usr/src/sys/net/raw_usrreq.c @@ -1,16 +1,23 @@ -/* raw_usrreq.c 4.29 83/06/30 */ +/* + * Copyright (c) 1980, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)raw_usrreq.c 7.1 (Berkeley) %G% + */ -#include "../h/param.h" -#include "../h/mbuf.h" -#include "../h/protosw.h" -#include "../h/socket.h" -#include "../h/socketvar.h" -#include "../h/errno.h" +#include "param.h" +#include "mbuf.h" +#include "domain.h" +#include "protosw.h" +#include "socket.h" +#include "socketvar.h" +#include "errno.h" -#include "../net/if.h" -#include "../net/route.h" -#include "../net/netisr.h" -#include "../net/raw_cb.h" +#include "if.h" +#include "route.h" +#include "netisr.h" +#include "raw_cb.h" #include "../vax/mtpr.h" @@ -77,7 +84,6 @@ rawintr() int s; struct mbuf *m; register struct rawcb *rp; - register struct protosw *lproto; register struct raw_header *rh; struct socket *last; @@ -90,11 +96,10 @@ next: rh = mtod(m, struct raw_header *); last = 0; for (rp = rawcb.rcb_next; rp != &rawcb; rp = rp->rcb_next) { - lproto = rp->rcb_socket->so_proto; - if (lproto->pr_family != rh->raw_proto.sp_family) + if (rp->rcb_proto.sp_family != rh->raw_proto.sp_family) continue; - if (lproto->pr_protocol && - lproto->pr_protocol != rh->raw_proto.sp_protocol) + if (rp->rcb_proto.sp_protocol && + rp->rcb_proto.sp_protocol != rh->raw_proto.sp_protocol) continue; /* * We assume the lower level routines have @@ -111,36 +116,33 @@ next: continue; if (last) { struct mbuf *n; - if ((n = m_copy(m->m_next, 0, (int)M_COPYALL)) == 0) - goto nospace; - if (sbappendaddr(&last->so_rcv, &rh->raw_src, - n, (struct mbuf *)0) == 0) { - /* should notify about lost packet */ - m_freem(n); - goto nospace; + if (n = m_copy(m->m_next, 0, (int)M_COPYALL)) { + if (sbappendaddr(&last->so_rcv, &rh->raw_src, + n, (struct mbuf *)0) == 0) + /* should notify about lost packet */ + m_freem(n); + else + sorwakeup(last); } - sorwakeup(last); } -nospace: last = rp->rcb_socket; } if (last) { - m = m_free(m); /* header */ if (sbappendaddr(&last->so_rcv, &rh->raw_src, - m, (struct mbuf *)0) == 0) - goto drop; - sorwakeup(last); - goto next; - } -drop: - m_freem(m); + m->m_next, (struct mbuf *)0) == 0) + m_freem(m->m_next); + else + sorwakeup(last); + (void) m_free(m); /* header */ + } else + m_freem(m); goto next; } /*ARGSUSED*/ raw_ctlinput(cmd, arg) int cmd; - caddr_t arg; + struct sockaddr *arg; { if (cmd < 0 || cmd > PRC_NCMDS) @@ -157,6 +159,8 @@ raw_usrreq(so, req, m, nam, rights) register struct rawcb *rp = sotorawcb(so); register int error = 0; + if (req == PRU_CONTROL) + return (EOPNOTSUPP); if (rights && rights->m_len) { error = EOPNOTSUPP; goto release; @@ -181,7 +185,7 @@ raw_usrreq(so, req, m, nam, rights) error = EINVAL; break; } - error = raw_attach(so); + error = raw_attach(so, (int)nam); break; /* @@ -228,8 +232,6 @@ raw_usrreq(so, req, m, nam, rights) error = ENOTCONN; break; } - if (rp->rcb_route.ro_rt) - rtfree(rp->rcb_route.ro_rt); raw_disconnect(rp); soisdisconnected(so); break; @@ -256,22 +258,6 @@ raw_usrreq(so, req, m, nam, rights) error = ENOTCONN; break; } -#ifdef notdef - /* - * Check for routing. If new foreign address, or - * no route presently in use, try to allocate new - * route. On failure, just hand packet to output - * routine anyway in case it can handle it. - */ - if ((rp->rcb_flags & RAW_DONTROUTE) == 0) - if (!equal(rp->rcb_faddr, rp->rcb_route.ro_dst) || - rp->rcb_route.ro_rt == 0) { - if (rp->rcb_route.ro_rt) - rtfree(rp->rcb_route.ro_rt); - rp->rcb_route.ro_dst = rp->rcb_faddr; - rtalloc(&rp->rcb_route); - } -#endif error = (*so->so_proto->pr_output)(m, so); m = NULL; if (nam) @@ -284,18 +270,21 @@ raw_usrreq(so, req, m, nam, rights) soisdisconnected(so); break; - case PRU_CONTROL: - m = NULL; - error = EOPNOTSUPP; - break; + case PRU_SENSE: + /* + * stat: don't bother with a blocksize. + */ + return (0); /* * Not supported. */ - case PRU_ACCEPT: - case PRU_RCVD: - case PRU_SENSE: case PRU_RCVOOB: + case PRU_RCVD: + return(EOPNOTSUPP); + + case PRU_LISTEN: + case PRU_ACCEPT: case PRU_SENDOOB: error = EOPNOTSUPP; break; @@ -306,6 +295,12 @@ raw_usrreq(so, req, m, nam, rights) nam->m_len = sizeof (struct sockaddr); break; + case PRU_PEERADDR: + bcopy((caddr_t)&rp->rcb_faddr, mtod(nam, caddr_t), + sizeof (struct sockaddr)); + nam->m_len = sizeof (struct sockaddr); + break; + default: panic("raw_usrreq"); }