rm bbnnet
[unix-history] / usr / src / sys / net / raw_cb.c
index f63c47b..e6af036 100644 (file)
@@ -1,17 +1,27 @@
-/*     raw_cb.c        4.20    83/06/30        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../h/socketvar.h"
-#include "../h/errno.h"
-
-#include "../net/if.h"
-#include "../net/route.h"
-#include "../net/raw_cb.h"
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)raw_cb.c    6.8 (Berkeley) %G%
+ */
+
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "socket.h"
+#include "socketvar.h"
+#include "domain.h"
+#include "protosw.h"
+#include "errno.h"
+
+#include "if.h"
+#include "route.h"
+#include "raw_cb.h"
 #include "../netinet/in.h"
 #include "../netinet/in.h"
+#ifdef PUP
 #include "../netpup/pup.h"
 #include "../netpup/pup.h"
+#endif
 
 #include "../vax/mtpr.h"
 
 
 #include "../vax/mtpr.h"
 
@@ -28,8 +38,9 @@
  * Allocate a control block and a nominal amount
  * of buffer space for the socket.
  */
  * Allocate a control block and a nominal amount
  * of buffer space for the socket.
  */
-raw_attach(so)
+raw_attach(so, proto)
        register struct socket *so;
        register struct socket *so;
+       int proto;
 {
        struct mbuf *m;
        register struct rawcb *rp;
 {
        struct mbuf *m;
        register struct rawcb *rp;
@@ -43,9 +54,11 @@ raw_attach(so)
                goto bad2;
        rp = mtod(m, struct rawcb *);
        rp->rcb_socket = so;
                goto bad2;
        rp = mtod(m, struct rawcb *);
        rp->rcb_socket = so;
-       insque(rp, &rawcb);
        so->so_pcb = (caddr_t)rp;
        rp->rcb_pcb = 0;
        so->so_pcb = (caddr_t)rp;
        rp->rcb_pcb = 0;
+       rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
+       rp->rcb_proto.sp_protocol = proto;
+       insque(rp, &rawcb);
        return (0);
 bad2:
        sbrelease(&so->so_snd);
        return (0);
 bad2:
        sbrelease(&so->so_snd);
@@ -63,6 +76,8 @@ raw_detach(rp)
 {
        struct socket *so = rp->rcb_socket;
 
 {
        struct socket *so = rp->rcb_socket;
 
+       if (rp->rcb_route.ro_rt)
+               rtfree(rp->rcb_route.ro_rt);
        so->so_pcb = 0;
        sofree(so);
        remque(rp);
        so->so_pcb = 0;
        sofree(so);
        remque(rp);
@@ -101,29 +116,7 @@ raw_bind(so, nam)
        case AF_IMPLINK:
        case AF_INET: {
                if (((struct sockaddr_in *)addr)->sin_addr.s_addr &&
        case AF_IMPLINK:
        case AF_INET: {
                if (((struct sockaddr_in *)addr)->sin_addr.s_addr &&
-                   if_ifwithaddr(addr) == 0)
-                       return (EADDRNOTAVAIL);
-               break;
-       }
-#endif
-
-#ifdef PUP
-       /*
-        * Curious, we convert PUP address format to internet
-        * to allow us to verify we're asking for an Ethernet
-        * interface.  This is wrong, but things are heavily
-        * oriented towards the internet addressing scheme, and
-        * converting internet to PUP would be very expensive.
-        */
-       case AF_PUP: {
-               struct sockaddr_pup *spup = (struct sockaddr_pup *)addr;
-               struct sockaddr_in inpup;
-
-               bzero((caddr_t)&inpup, (unsigned)sizeof(inpup));
-               inpup.sin_family = AF_INET;
-               inpup.sin_addr = if_makeaddr(spup->spup_net, spup->spup_host);
-               if (inpup.sin_addr.s_addr &&
-                   if_ifwithaddr((struct sockaddr *)&inpup) == 0)
+                   ifa_ifwithaddr(addr) == 0)
                        return (EADDRNOTAVAIL);
                break;
        }
                        return (EADDRNOTAVAIL);
                break;
        }