-/* if_imp.c 4.30 82/05/02 */
+/* if_imp.c 4.46 82/12/17 */
#include "imp.h"
#if NIMP > 0
* 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/pte.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 "../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_imp.h"
-#include "../net/if_imphost.h"
-#include "../net/ip.h"
-#include "../net/ip_var.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>
/*
* 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;
+ int (*reset)();
{
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;
+ 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;
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;
}
sc->imp_state = IMPS_INIT;
impnoops(sc);
- if_rtinit(&sc->imp_if, RTF_DIRECT|RTF_UP);
splx(s);
}
struct sockproto impproto = { PF_IMPLINK };
struct sockaddr_in impdst = { AF_IMPLINK };
struct sockaddr_in impsrc = { AF_IMPLINK };
+#ifdef IMPLEADERS
+int impprintfs = 0;
+#endif
/*
* ARPAnet 1822 input routine.
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)
(m = m_pullup(m, sizeof(struct imp_leader))) == 0)
return;
ip = mtod(m, struct imp_leader *);
+#ifdef IMPLEADERS
+ if (impprintfs)
+ printleader("impinput", ip);
+#endif
/* check leader type */
if (ip->il_format != IMP_NFF) {
}
sc->imp_state = IMPS_UP;
sc->imp_if.if_flags |= IFF_UP;
- /* restart output in case something was q'd */
- (*sc->imp_cb.ic_start)(sc->imp_if.if_unit);
+ if_rtinit(&sc->imp_if, RTF_UP);
goto drop;
/*
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;
}
struct imp_softc *sc;
{
-COUNT(IMPDOWN);
sc->imp_state = IMPS_DOWN;
impmsg(sc, "marked down");
hostreset(sc->imp_if.if_net);
u_int a1;
{
-COUNT(IMPMSG);
printf("imp%d: ", sc->imp_if.if_unit);
printf(fmt, a1, a2);
printf("\n");
{
struct in_addr in;
-COUNT(IMPNOTIFY);
#ifdef notdef
in.s_net = cp->dl_network;
#else
{
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;
-COUNT(IMPOUTPUT);
/*
* Don't even try if the IMP is unavailable.
*/
*/
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;
- m->m_off = MMINOFF;
m->m_len = sizeof(struct imp_leader);
} else {
m->m_off -= sizeof(struct imp_leader);
struct impcb *icp;
int s, error;
-COUNT(IMPSND);
ip = mtod(m, struct imp_leader *);
/*
}
IF_ENQUEUE(&ifp->if_snd, m);
start:
- splx(s);
icp = &imp_softc[ifp->if_unit].imp_cb;
if (icp->ic_oactive == 0)
(*icp->ic_start)(ifp->if_unit);
+ splx(s);
return (0);
}
* Part of host-IMP initialization procedure.
* (Should return success/failure, but noone knows
* what to do with this, so why bother?)
+ * This routine is always called at splimp, so we don't
+ * protect the call to IF_PREPEND.
*/
impnoops(sc)
register struct imp_softc *sc;
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++ ) {
- if ((m = m_getclr(M_DONTWAIT)) == 0)
+ if ((m = m_getclr(M_DONTWAIT, MT_HEADER)) == 0)
return;
- m->m_off = MMINOFF;
m->m_len = sizeof(struct control_leader);
cp = mtod(m, struct control_leader *);
cp->dl_format = IMP_NFF;
cp->dl_link = i;
cp->dl_mtype = IMPTYPE_NOOP;
- x = splimp();
IF_PREPEND(&sc->imp_if.if_snd, m);
- splx(x);
}
if (sc->imp_cb.ic_oactive == 0)
(*sc->imp_cb.ic_start)(sc->imp_if.if_unit);
}
+
+#ifdef IMPLEADERS
+printleader(routine, ip)
+ char *routine;
+ register struct imp_leader *ip;
+{
+ printf("%s: ", routine);
+ printbyte((char *)ip, 12);
+ printf("<fmt=%x,net=%x,flags=%x,mtype=", ip->il_format, ip->il_network,
+ ip->il_flags);
+ if (ip->il_mtype <= IMPTYPE_READY)
+ printf("%s,", impleaders[ip->il_mtype]);
+ else
+ printf("%x,", ip->il_mtype);
+ printf("htype=%x,host=%x,imp=%x,link=", ip->il_htype, ip->il_host,
+ ntohs(ip->il_imp));
+ if (ip->il_link == IMPLINK_IP)
+ printf("ip,");
+ else
+ printf("%x,", ip->il_link);
+ printf("subtype=%x,len=%x>\n",ip->il_subtype,ntohs(ip->il_length)>>3);
+}
+
+printbyte(cp, n)
+ register char *cp;
+ int n;
+{
+ register i, j, c;
+
+ for (i=0; i<n; i++) {
+ c = *cp++;
+ for (j=0; j<2; j++)
+ putchar("0123456789abcdef"[(c>>((1-j)*4))&0xf]);
+ putchar(' ');
+ }
+ putchar('\n');
+}
+#endif
#endif