sun merge
[unix-history] / usr / src / sys / deprecated / netimp / if_imp.c
index 52f97d1..7e39b50 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_imp.c        4.35    82/06/15        */
+/*     if_imp.c        4.46    82/12/17        */
 
 #include "imp.h"
 #if NIMP > 0
 
 #include "imp.h"
 #if NIMP > 0
@@ -8,27 +8,31 @@
  * The IMP-host protocol is handled here, leaving
  * hardware specifics to the lower level interface driver.
  */
  * The IMP-host protocol is handled here, leaving
  * hardware specifics to the lower level interface driver.
  */
+#include "../machine/pte.h"
+
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/mbuf.h"
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/mbuf.h"
-#include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/buf.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
-#include "../h/ubareg.h"
-#include "../h/ubavar.h"
-#include "../h/cpu.h"
-#include "../h/mtpr.h"
 #include "../h/vmmac.h"
 #include "../h/vmmac.h"
-#include "../net/in.h"
-#include "../net/in_systm.h"
+
+#include "../vax/cpu.h"
+#include "../vax/mtpr.h"
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/ubavar.h"
+
 #include "../net/if.h"
 #include "../net/if.h"
-/* define IMPLEADERS here to get leader printing code */
-#include "../net/if_imp.h"
-#include "../net/if_imphost.h"
-#include "../net/ip.h"
-#include "../net/ip_var.h"
 #include "../net/route.h"
 #include "../net/route.h"
+#include "../net/netisr.h"
+#include "../netinet/in.h"
+#include "../netinet/in_systm.h"
+#include "../netinet/ip.h"
+#include "../netinet/ip_var.h"
+/* define IMPLEADERS here to get leader printing code */
+#include "../netimp/if_imp.h"
+#include "../netimp/if_imphost.h"
 #include <errno.h>
 
 /*
 #include <errno.h>
 
 /*
@@ -73,19 +77,20 @@ int impdown(), impinit(), impoutput();
  * structures.  This is then used by the device's attach routine
  * set up its back pointers. 
  */
  * structures.  This is then used by the device's attach routine
  * set up its back pointers. 
  */
-impattach(ui)
+impattach(ui, reset)
        struct uba_device *ui;
        struct uba_device *ui;
+       int (*reset)();
 {
        struct imp_softc *sc = &imp_softc[ui->ui_unit];
        register struct ifnet *ifp = &sc->imp_if;
        struct sockaddr_in *sin;
 
 {
        struct imp_softc *sc = &imp_softc[ui->ui_unit];
        register struct ifnet *ifp = &sc->imp_if;
        struct sockaddr_in *sin;
 
-COUNT(IMPATTACH);
        /* UNIT COULD BE AMBIGUOUS */
        ifp->if_unit = ui->ui_unit;
        ifp->if_name = "imp";
        ifp->if_mtu = IMPMTU - sizeof(struct imp_leader);
        ifp->if_net = ui->ui_flags;
        /* UNIT COULD BE AMBIGUOUS */
        ifp->if_unit = ui->ui_unit;
        ifp->if_name = "imp";
        ifp->if_mtu = IMPMTU - sizeof(struct imp_leader);
        ifp->if_net = ui->ui_flags;
+       ifp->if_reset = reset;
        /* the host and imp fields will be filled in by the imp */
        sin = (struct sockaddr_in *)&ifp->if_addr;
        sin->sin_family = AF_INET;
        /* the host and imp fields will be filled in by the imp */
        sin = (struct sockaddr_in *)&ifp->if_addr;
        sin->sin_family = AF_INET;
@@ -108,7 +113,6 @@ impinit(unit)
        int s = splimp();
        register struct imp_softc *sc = &imp_softc[unit];
 
        int s = splimp();
        register struct imp_softc *sc = &imp_softc[unit];
 
-COUNT(IMPINIT);
        if ((*sc->imp_cb.ic_init)(unit) == 0) {
                sc->imp_state = IMPS_DOWN;
                sc->imp_if.if_flags &= ~IFF_UP;
        if ((*sc->imp_cb.ic_init)(unit) == 0) {
                sc->imp_state = IMPS_DOWN;
                sc->imp_if.if_flags &= ~IFF_UP;
@@ -117,7 +121,6 @@ COUNT(IMPINIT);
        }
        sc->imp_state = IMPS_INIT;
        impnoops(sc);
        }
        sc->imp_state = IMPS_INIT;
        impnoops(sc);
-       if_rtinit(&sc->imp_if, RTF_UP);
        splx(s);
 }
 
        splx(s);
 }
 
@@ -148,7 +151,6 @@ impinput(unit, m)
        struct mbuf *next;
        struct sockaddr_in *sin;
 
        struct mbuf *next;
        struct sockaddr_in *sin;
 
-COUNT(IMPINPUT);
        /* verify leader length. */
        if (m->m_len < sizeof(struct control_leader) &&
            (m = m_pullup(m, sizeof(struct control_leader))) == 0)
        /* verify leader length. */
        if (m->m_len < sizeof(struct control_leader) &&
            (m = m_pullup(m, sizeof(struct control_leader))) == 0)
@@ -240,6 +242,7 @@ COUNT(IMPINPUT);
                }
                sc->imp_state = IMPS_UP;
                sc->imp_if.if_flags |= IFF_UP;
                }
                sc->imp_state = IMPS_UP;
                sc->imp_if.if_flags |= IFF_UP;
+               if_rtinit(&sc->imp_if, RTF_UP);
                goto drop;
 
        /*
                goto drop;
 
        /*
@@ -265,7 +268,8 @@ COUNT(IMPINPUT);
        case IMPTYPE_HOSTDEAD:
        case IMPTYPE_HOSTUNREACH: {
                int s = splnet();
        case IMPTYPE_HOSTDEAD:
        case IMPTYPE_HOSTUNREACH: {
                int s = splnet();
-               impnotify(ip->il_mtype, ip, hostlookup(addr));
+               impnotify((int)ip->il_mtype, (struct control_leader *)ip,
+                   hostlookup(addr));
                splx(s);
                goto rawlinkin;
        }
                splx(s);
                goto rawlinkin;
        }
@@ -346,7 +350,6 @@ impdown(sc)
        struct imp_softc *sc;
 {
 
        struct imp_softc *sc;
 {
 
-COUNT(IMPDOWN);
        sc->imp_state = IMPS_DOWN;
        impmsg(sc, "marked down");
        hostreset(sc->imp_if.if_net);
        sc->imp_state = IMPS_DOWN;
        impmsg(sc, "marked down");
        hostreset(sc->imp_if.if_net);
@@ -360,7 +363,6 @@ impmsg(sc, fmt, a1, a2)
        u_int a1;
 {
 
        u_int a1;
 {
 
-COUNT(IMPMSG);
        printf("imp%d: ", sc->imp_if.if_unit);
        printf(fmt, a1, a2);
        printf("\n");
        printf("imp%d: ", sc->imp_if.if_unit);
        printf(fmt, a1, a2);
        printf("\n");
@@ -377,7 +379,6 @@ impnotify(what, cp, hp)
 {
        struct in_addr in;
 
 {
        struct in_addr in;
 
-COUNT(IMPNOTIFY);
 #ifdef notdef
        in.s_net = cp->dl_network;
 #else
 #ifdef notdef
        in.s_net = cp->dl_network;
 #else
@@ -408,10 +409,9 @@ impoutput(ifp, m0, dst)
 {
        register struct imp_leader *imp;
        register struct mbuf *m = m0;
 {
        register struct imp_leader *imp;
        register struct mbuf *m = m0;
-       int x, dhost, dimp, dlink, len, dnet;
+       int dhost, dimp, dlink, len, dnet;
        int error = 0;
 
        int error = 0;
 
-COUNT(IMPOUTPUT);
        /*
         * Don't even try if the IMP is unavailable.
         */
        /*
         * Don't even try if the IMP is unavailable.
         */
@@ -452,13 +452,12 @@ COUNT(IMPOUTPUT);
         */
        if (m->m_off > MMAXOFF ||
            MMINOFF + sizeof(struct imp_leader) > m->m_off) {
         */
        if (m->m_off > MMAXOFF ||
            MMINOFF + sizeof(struct imp_leader) > m->m_off) {
-               m = m_get(M_DONTWAIT);
+               m = m_get(M_DONTWAIT, MT_HEADER);
                if (m == 0) {
                        error = ENOBUFS;
                        goto drop;
                }
                m->m_next = m0;
                if (m == 0) {
                        error = ENOBUFS;
                        goto drop;
                }
                m->m_next = m0;
-               m->m_off = MMINOFF;
                m->m_len = sizeof(struct imp_leader);
        } else {
                m->m_off -= sizeof(struct imp_leader);
                m->m_len = sizeof(struct imp_leader);
        } else {
                m->m_off -= sizeof(struct imp_leader);
@@ -496,7 +495,6 @@ impsnd(ifp, m)
        struct impcb *icp;
        int s, error;
 
        struct impcb *icp;
        int s, error;
 
-COUNT(IMPSND);
        ip = mtod(m, struct imp_leader *);
 
        /*
        ip = mtod(m, struct imp_leader *);
 
        /*
@@ -571,14 +569,11 @@ impnoops(sc)
        register i;
        register struct mbuf *m;
        register struct control_leader *cp;
        register i;
        register struct mbuf *m;
        register struct control_leader *cp;
-       int x;
 
 
-COUNT(IMPNOOPS);
        sc->imp_dropcnt = IMP_DROPCNT;
        for (i = 0; i < IMP_DROPCNT + 1; i++ ) { 
        sc->imp_dropcnt = IMP_DROPCNT;
        for (i = 0; i < IMP_DROPCNT + 1; i++ ) { 
-               if ((m = m_getclr(M_DONTWAIT)) == 0) 
+               if ((m = m_getclr(M_DONTWAIT, MT_HEADER)) == 0) 
                        return;
                        return;
-               m->m_off = MMINOFF;
                m->m_len = sizeof(struct control_leader);
                cp = mtod(m, struct control_leader *);
                cp->dl_format = IMP_NFF;
                m->m_len = sizeof(struct control_leader);
                cp = mtod(m, struct control_leader *);
                cp->dl_format = IMP_NFF;