localize header files
[unix-history] / usr / src / sys / deprecated / netpup / raw_pup.c
index 65963da..455e1ae 100644 (file)
@@ -1,28 +1,19 @@
-/*     raw_pup.c       4.6     82/03/05        */
+/*     raw_pup.c       4.14    82/10/09        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 #include "../h/socket.h"
 #include "../h/protosw.h"
 #include "../h/socketvar.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 #include "../h/socket.h"
 #include "../h/protosw.h"
 #include "../h/socketvar.h"
-#include "../net/in.h"
-#include "../net/in_systm.h"
-#include "../net/pup.h"
+#include "../netpup/pup.h"
 #include "../net/raw_cb.h"
 #include "../net/if.h"
 #include "../net/raw_cb.h"
 #include "../net/if.h"
-#include "../errno.h"
+#include <errno.h>
 
 /*
  * Raw PUP protocol interface.
  */
 
 
 /*
  * Raw PUP protocol interface.
  */
 
-/*ARGSUSED*/
-rpup_ctlinput(m)
-       struct mbuf *m;
-{
-COUNT(RPUP_CTLINPUT);
-}
-
 /*
  * Encapsulate packet in PUP header which is supplied by the
  * user.  This is done to allow user to specify PUP identifier.
 /*
  * Encapsulate packet in PUP header which is supplied by the
  * user.  This is done to allow user to specify PUP identifier.
@@ -33,46 +24,54 @@ rpup_output(m, so)
 {
        register struct rawcb *rp = sotorawcb(so);
        register struct pup_header *pup;
 {
        register struct rawcb *rp = sotorawcb(so);
        register struct pup_header *pup;
-       int len;
+       int len, error = 0;
        struct mbuf *n;
        struct mbuf *n;
-       struct sockaddr_pup *spup;
+       struct sockaddr_pup *dst;
        struct ifnet *ifp;
 
        struct ifnet *ifp;
 
-COUNT(RPUP_OUTPUT);
        /*
         * Verify user has supplied necessary space
         * for the header and check parameters in it.
         */
        if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct pup_header)) &&
        /*
         * Verify user has supplied necessary space
         * for the header and check parameters in it.
         */
        if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct pup_header)) &&
-           (m = m_pullup(m, sizeof(struct pup_header))) == 0)
+           (m = m_pullup(m, sizeof(struct pup_header))) == 0) {
+               error = EMSGSIZE;       /* XXX */
                goto bad;
                goto bad;
+       }
        pup = mtod(m, struct pup_header *);
        pup = mtod(m, struct pup_header *);
-       if (pup->pup_type == 0)
+       if (pup->pup_type == 0) {
+               error = EPERM;          /* XXX */
                goto bad;
                goto bad;
-       if (pup->pup_tcontrol && (pup->pup_tcontrol & ~PUP_TRACE))
+       }
+       if (pup->pup_tcontrol && (pup->pup_tcontrol & ~PUP_TRACE)) {
+               error = EPERM;          /* XXX */
                goto bad;
                goto bad;
+       }
        for (len = 0, n = m; n; n = n->m_next)
                len += n->m_len;
        pup->pup_length = len;
        for (len = 0, n = m; n; n = n->m_next)
                len += n->m_len;
        pup->pup_length = len;
-       spup = (struct sockaddr_pup *)&rp->rcb_addr;
-       pup->pup_dport = spup->spup_addr;
+#if vax || pdp11
+       pup->pup_length = htons(pup->pup_length);
+#endif
+       /* assume user generates PUP checksum. */
+       dst = (struct sockaddr_pup *)&rp->rcb_faddr;
+       pup->pup_dport = dst->spup_addr;
+       ifp = if_ifonnetof(pup->pup_dnet);
+       if (ifp) {
+               if (rp->rcb_flags & RAW_LADDR) {
+                       register struct sockaddr_pup *src;
 
 
-       /*
-        * Insure proper source address is included.
-        */
-       spup = (struct sockadrr_pup *)&(rp->rcb_socket->so_addr);
-       pup->pup_sport = spup->spup_addr;
-       /* for now, assume user generates PUP checksum. */
-
-       ifp = if_ifonnetof(&rp->rcb_addr);
-       if (ifp == 0) {
-               ifp = if_gatewayfor(&rp->rcb_addr);
-               if (ifp == 0)
-                       goto bad;
+                       src = (struct sockaddr_pup *)&rp->rcb_laddr;
+                       pup->pup_sport = src->spup_addr;
+               } else {
+                       pup->pup_snet = ifp->if_net;
+                       pup->pup_shost = ifp->if_host[0];
+                       /* socket is specified by user */
+               }
+               return ((*ifp->if_output)(ifp, m, (struct sockaddr *)dst));
        }
        }
-       return (enoutput((struct ifnet *)rp->rcb_pcb, m, PF_PUP));
-
+       error = ENETUNREACH;
 bad:
        m_freem(m);
 bad:
        m_freem(m);
-       return (0);
+       return (error);
 }
 }