BSD 4_3_Tahoe release
[unix-history] / usr / src / sys / net / raw_cb.c
index 46d1436..e1e5929 100644 (file)
@@ -1,19 +1,37 @@
-/*     raw_cb.c        6.3     85/03/19        */
+/*
+ * Copyright (c) 1980, 1986 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)raw_cb.c    7.6 (Berkeley) 6/27/88
+ */
 
 #include "param.h"
 #include "systm.h"
 #include "mbuf.h"
 #include "socket.h"
 #include "socketvar.h"
 
 #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 "errno.h"
 
 #include "if.h"
 #include "route.h"
 #include "raw_cb.h"
 #include "../netinet/in.h"
-#include "../netpup/pup.h"
 
 
-#include "../vax/mtpr.h"
+#include "../machine/mtpr.h"
 
 /*
  * Routines to manage the raw protocol control blocks. 
 
 /*
  * Routines to manage the raw protocol control blocks. 
@@ -28,8 +46,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;
@@ -37,15 +56,17 @@ raw_attach(so)
        m = m_getclr(M_DONTWAIT, MT_PCB);
        if (m == 0)
                return (ENOBUFS);
        m = m_getclr(M_DONTWAIT, MT_PCB);
        if (m == 0)
                return (ENOBUFS);
-       if (sbreserve(&so->so_snd, RAWSNDQ) == 0)
+       if (sbreserve(&so->so_snd, (u_long) RAWSNDQ) == 0)
                goto bad;
                goto bad;
-       if (sbreserve(&so->so_rcv, RAWRCVQ) == 0)
+       if (sbreserve(&so->so_rcv, (u_long) RAWRCVQ) == 0)
                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,9 +84,13 @@ 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);
+       if (rp->rcb_options)
+               m_freem(rp->rcb_options);
        m_freem(dtom(rp));
 }
 
        m_freem(dtom(rp));
 }
 
@@ -107,28 +132,6 @@ raw_bind(so, nam)
        }
 #endif
 
        }
 #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 = in_makeaddr(spup->spup_net, spup->spup_host);
-               if (inpup.sin_addr.s_addr &&
-                   ifa_ifwithaddr((struct sockaddr *)&inpup) == 0)
-                       return (EADDRNOTAVAIL);
-               break;
-       }
-#endif
-
        default:
                return (EAFNOSUPPORT);
        }
        default:
                return (EAFNOSUPPORT);
        }