localize header files
[unix-history] / usr / src / sys / deprecated / netimp / raw_imp.c
index ec93c5a..02b7532 100644 (file)
@@ -1,22 +1,21 @@
-/*     raw_imp.c       4.9     82/03/28        */
+/*     raw_imp.c       4.13    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 "../netinet/in.h"
+#include "../netinet/in_systm.h"
 #include "../net/if.h"
 #include "../net/if.h"
-#include "../net/if_imp.h"
+#include "../netimp/if_imp.h"
 #include "../net/raw_cb.h"
 #include "../net/raw_cb.h"
-#include "../errno.h"
+#include <errno.h>
 
 /*
  * Raw interface to IMP.
  */
 
 
 /*
  * Raw interface to IMP.
  */
 
-struct sockaddr_in rawimpaddr = { AF_IMPLINK };
 /*
  * Generate IMP leader and pass packet to impoutput.
  * The user must create a skeletal leader in order to
 /*
  * Generate IMP leader and pass packet to impoutput.
  * The user must create a skeletal leader in order to
@@ -29,33 +28,40 @@ rimp_output(m, so)
        struct socket *so;
 {
        struct mbuf *n;
        struct socket *so;
 {
        struct mbuf *n;
-       int len;
+       int len, error = 0;
        register struct imp_leader *ip;
        register struct sockaddr_in *sin;
        register struct rawcb *rp = sotorawcb(so);
        struct ifnet *ifp;
        struct control_leader *cp;
 
        register struct imp_leader *ip;
        register struct sockaddr_in *sin;
        register struct rawcb *rp = sotorawcb(so);
        struct ifnet *ifp;
        struct control_leader *cp;
 
-COUNT(RIMP_OUTPUT);
        /*
         * Verify user has supplied necessary space
         * for the leader and check parameters in it.
         */
        if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct control_leader)) &&
        /*
         * Verify user has supplied necessary space
         * for the leader and check parameters in it.
         */
        if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct control_leader)) &&
-           (m = m_pullup(m, sizeof(struct control_leader))) == 0)
-               return (0);
+           (m = m_pullup(m, sizeof(struct control_leader))) == 0) {
+               error = EMSGSIZE;       /* XXX */
+               goto bad;
+       }
        cp = mtod(m, struct control_leader *);
        if (cp->dl_mtype == IMPTYPE_DATA)
                if (m->m_len < sizeof(struct imp_leader) &&
        cp = mtod(m, struct control_leader *);
        if (cp->dl_mtype == IMPTYPE_DATA)
                if (m->m_len < sizeof(struct imp_leader) &&
-                   (m = m_pullup(m, sizeof(struct imp_leader))) == 0)
-                       return (0);
+                   (m = m_pullup(m, sizeof(struct imp_leader))) == 0) {
+                       error = EMSGSIZE;       /* XXX */
+                       goto bad;
+               }
        ip = mtod(m, struct imp_leader *);
        ip = mtod(m, struct imp_leader *);
-       if (ip->il_format != IMP_NFF)
+       if (ip->il_format != IMP_NFF) {
+               error = EMSGSIZE;               /* XXX */
                goto bad;
                goto bad;
+       }
 #ifdef notdef
        if (ip->il_link != IMPLINK_IP &&
 #ifdef notdef
        if (ip->il_link != IMPLINK_IP &&
-           (ip->il_link < IMPLINK_LOWEXPER || ip->il_link > IMPLINK_HIGHEXPER))
+           (ip->il_link<IMPLINK_LOWEXPER || ip->il_link>IMPLINK_HIGHEXPER)) {
+               error = EPERM;
                goto bad;
                goto bad;
+       }
 #endif
 
        /*
 #endif
 
        /*
@@ -66,17 +72,20 @@ COUNT(RIMP_OUTPUT);
        for (len = 0, n = m; n; n = n->m_next)
                len += n->m_len;
        ip->il_length = htons((u_short)(len << 3));
        for (len = 0, n = m; n; n = n->m_next)
                len += n->m_len;
        ip->il_length = htons((u_short)(len << 3));
-       sin = (struct sockaddr_in *)&rp->rcb_addr;
+       sin = (struct sockaddr_in *)&rp->rcb_faddr;
+#ifdef notdef
        ip->il_network = sin->sin_addr.s_net;
        ip->il_network = sin->sin_addr.s_net;
+#else
+       ip->il_network = 0;
+#endif
        ip->il_host = sin->sin_addr.s_host;
        ip->il_imp = sin->sin_addr.s_imp;
        /* no routing here */
        ip->il_host = sin->sin_addr.s_host;
        ip->il_imp = sin->sin_addr.s_imp;
        /* no routing here */
-       ifp = if_ifonnetof(ip->il_network);
-       if (ifp == 0)
-               goto bad;
-       return (impoutput(ifp, m, (struct sockaddr *)&rawimpaddr));
-
+       ifp = if_ifonnetof(sin->sin_addr.s_net);
+       if (ifp)
+               return (impoutput(ifp, m, (struct sockaddr *)sin));
+       error = ENETUNREACH;
 bad:
        m_freem(m);
 bad:
        m_freem(m);
-       return (0);
+       return (error);
 }
 }