1*6336Ssam /* if_imp.c 4.20 82/03/28 */ 25640Sroot 35640Sroot #include "imp.h" 45640Sroot #if NIMP > 0 55640Sroot /* 65640Sroot * ARPAnet IMP interface driver. 75640Sroot * 85640Sroot * The IMP-host protocol is handled here, leaving 95640Sroot * hardware specifics to the lower level interface driver. 105771Swnj * 115771Swnj * TODO: 125771Swnj * pass more error indications up to protocol modules 135640Sroot */ 145640Sroot #include "../h/param.h" 155640Sroot #include "../h/systm.h" 165640Sroot #include "../h/mbuf.h" 175640Sroot #include "../h/pte.h" 185640Sroot #include "../h/buf.h" 195640Sroot #include "../h/protosw.h" 205640Sroot #include "../h/socket.h" 215640Sroot #include "../h/ubareg.h" 225640Sroot #include "../h/ubavar.h" 235640Sroot #include "../h/cpu.h" 245640Sroot #include "../h/mtpr.h" 255640Sroot #include "../h/vmmac.h" 265640Sroot #include "../net/in.h" 275640Sroot #include "../net/in_systm.h" 285640Sroot #include "../net/if.h" 295640Sroot #include "../net/if_imp.h" 305859Sroot #include "../net/if_imphost.h" 315640Sroot #include "../net/ip.h" 325640Sroot #include "../net/ip_var.h" 335640Sroot 345640Sroot /* 355640Sroot * IMP software status per interface. 365640Sroot * (partially shared with the hardware specific module) 375640Sroot * 385640Sroot * Each interface is referenced by a network interface structure, 395640Sroot * imp_if, which the routing code uses to locate the interface. 405640Sroot * This structure contains the output queue for the interface, its 415640Sroot * address, ... IMP specific structures used in connecting the 425640Sroot * IMP software modules to the hardware specific interface routines 435771Swnj * are stored here. The common structures are made visible to the 445771Swnj * interface driver by passing a pointer to the hardware routine 455771Swnj * at "attach" time. 465640Sroot * 475640Sroot * NOTE: imp_if and imp_cb are assumed adjacent in hardware code. 485640Sroot */ 495640Sroot struct imp_softc { 505640Sroot struct ifnet imp_if; /* network visible interface */ 515640Sroot struct impcb imp_cb; /* hooks to hardware module */ 525640Sroot u_char imp_state; /* current state of IMP */ 535640Sroot char imp_dropcnt; /* used during initialization */ 545640Sroot } imp_softc[NIMP]; 555640Sroot 565640Sroot /* 575640Sroot * Messages from IMP regarding why 585640Sroot * it's going down. 595640Sroot */ 605924Sroot static char *impmessage[] = { 615640Sroot "in 30 seconds", 625640Sroot "for hardware PM", 635640Sroot "to reload software", 645640Sroot "for emergency reset" 655640Sroot }; 665640Sroot 675771Swnj int impdown(), impinit(), impoutput(); 685771Swnj 695640Sroot /* 705640Sroot * IMP attach routine. Called from hardware device attach routine 715640Sroot * at configuration time with a pointer to the UNIBUS device structure. 725640Sroot * Sets up local state and returns pointer to base of ifnet+impcb 735640Sroot * structures. This is then used by the device's attach routine 745640Sroot * set up its back pointers. 755640Sroot */ 765640Sroot impattach(ui) 775640Sroot struct uba_device *ui; 785640Sroot { 795640Sroot struct imp_softc *sc = &imp_softc[ui->ui_unit]; 805640Sroot register struct ifnet *ifp = &sc->imp_if; 81*6336Ssam struct sockaddr_in *sin; 825640Sroot 835640Sroot COUNT(IMPATTACH); 845640Sroot /* UNIT COULD BE AMBIGUOUS */ 855640Sroot ifp->if_unit = ui->ui_unit; 865640Sroot ifp->if_name = "imp"; 876271Sroot ifp->if_mtu = IMPMTU - sizeof(struct imp_leader); 885640Sroot ifp->if_net = ui->ui_flags; 895989Sroot /* the host and imp fields will be filled in by the imp */ 90*6336Ssam sin = (struct sockaddr_in *)&ifp->if_addr; 91*6336Ssam sin->sin_family = AF_INET; 92*6336Ssam sin->sin_addr = if_makeaddr(ifp->if_net, 0); 935771Swnj ifp->if_init = impinit; 945771Swnj ifp->if_output = impoutput; 955771Swnj /* reset is handled at the hardware level */ 965640Sroot if_attach(ifp); 975640Sroot return ((int)&sc->imp_if); 985640Sroot } 995640Sroot 1005640Sroot /* 1015640Sroot * IMP initialization routine: call hardware module to 1025640Sroot * setup UNIBUS resources, init state and get ready for 1035640Sroot * NOOPs the IMP should send us, and that we want to drop. 1045640Sroot */ 1055640Sroot impinit(unit) 1065640Sroot int unit; 1075640Sroot { 1085640Sroot register struct imp_softc *sc = &imp_softc[unit]; 1095640Sroot 1105771Swnj if ((*sc->imp_cb.ic_init)(unit) == 0) { 1115771Swnj sc->imp_state = IMPS_DOWN; 112*6336Ssam sc->imp_if.if_flags &= ~IFF_UP; 1135771Swnj return; 1145771Swnj } 1155640Sroot sc->imp_state = IMPS_INIT; 1165640Sroot sc->imp_dropcnt = IMP_DROPCNT; 1175771Swnj impnoops(sc); 1185640Sroot } 1195640Sroot 1205640Sroot struct sockproto impproto = { PF_IMPLINK }; 1215645Ssam struct sockaddr_in impdst = { AF_IMPLINK }; 1225645Ssam struct sockaddr_in impsrc = { AF_IMPLINK }; 1235640Sroot 1245640Sroot /* 1255640Sroot * ARPAnet 1822 input routine. 1265640Sroot * Called from hardware input interrupt routine to handle 1822 1275640Sroot * IMP-host messages. Type 0 messages (non-control) are 1285640Sroot * passed to higher level protocol processors on the basis 1295640Sroot * of link number. Other type messages (control) are handled here. 1305640Sroot */ 1315771Swnj impinput(unit, m) 1325640Sroot int unit; 1335771Swnj register struct mbuf *m; 1345640Sroot { 1355640Sroot register struct imp_leader *ip; 1365640Sroot register struct imp_softc *sc = &imp_softc[unit]; 1375640Sroot register struct host *hp; 1385640Sroot register struct ifqueue *inq; 1395771Swnj struct control_leader *cp; 1405640Sroot struct in_addr addr; 1415924Sroot struct mbuf *next; 142*6336Ssam struct sockaddr_in *sin; 1435640Sroot 1445932Sroot COUNT(IMPINPUT); 1456257Sroot /* verify leader length. */ 1465771Swnj if (m->m_len < sizeof(struct control_leader) && 1475771Swnj (m = m_pullup(m, sizeof(struct control_leader))) == 0) 1485771Swnj return; 1495771Swnj cp = mtod(m, struct control_leader *); 1505771Swnj if (cp->dl_mtype == IMPTYPE_DATA) 1515771Swnj if (m->m_len < sizeof(struct imp_leader) && 1525771Swnj (m = m_pullup(m, sizeof(struct imp_leader))) == 0) 1535771Swnj return; 1545640Sroot ip = mtod(m, struct imp_leader *); 1555640Sroot 1566257Sroot /* check leader type */ 1575771Swnj if (ip->il_format != IMP_NFF) { 1585771Swnj sc->imp_if.if_collisions++; /* XXX */ 1595640Sroot goto drop; 1605771Swnj } 1615640Sroot 1625640Sroot /* 1635640Sroot * Certain messages require a host structure. 1645640Sroot * Do this in one shot here. 1655640Sroot */ 1665640Sroot switch (ip->il_mtype) { 1675640Sroot 1685640Sroot case IMPTYPE_RFNM: 1695640Sroot case IMPTYPE_INCOMPLETE: 1705640Sroot case IMPTYPE_HOSTDEAD: 1715640Sroot case IMPTYPE_HOSTUNREACH: 1725640Sroot case IMPTYPE_BADDATA: 1735859Sroot #ifdef notdef 1745771Swnj addr.s_net = ip->il_network; 1755859Sroot #else 1765859Sroot addr.s_net = 0; 1775859Sroot #endif 1785771Swnj addr.s_imp = ip->il_imp; 1795771Swnj addr.s_host = ip->il_host; 1805771Swnj hp = hostlookup(addr); 1815640Sroot break; 1825640Sroot } 1835640Sroot 1845640Sroot switch (ip->il_mtype) { 1855640Sroot 1865640Sroot case IMPTYPE_DATA: 1875640Sroot break; 1885640Sroot 1895640Sroot /* 1905640Sroot * IMP leader error. Reset the IMP and discard the packet. 1915640Sroot */ 1925640Sroot case IMPTYPE_BADLEADER: 1935647Ssam /* 1945647Ssam * According to 1822 document, this message 1955647Ssam * will be generated in response to the 1965647Ssam * first noop sent to the IMP after 1975647Ssam * the host resets the IMP interface. 1985647Ssam */ 1995771Swnj if (sc->imp_state != IMPS_INIT) { 2005924Sroot impmsg(sc, "leader error"); 2015771Swnj hostreset(sc->imp_if.if_net); /* XXX */ 2025647Ssam impnoops(sc); 2035647Ssam } 2046044Swnj goto rawlinkin; 2055640Sroot 2065640Sroot /* 2075640Sroot * IMP going down. Print message, and if not immediate, 2085640Sroot * set off a timer to insure things will be reset at the 2095640Sroot * appropriate time. 2105640Sroot */ 2115640Sroot case IMPTYPE_DOWN: 2125640Sroot if ((ip->il_link & IMP_DMASK) == 0) { 2135640Sroot sc->imp_state = IMPS_GOINGDOWN; 2146160Ssam timeout(impdown, (caddr_t)sc, 30 * hz); 2155640Sroot } 2166160Ssam impmsg(sc, "going down %s", 2176160Ssam (u_int)impmessage[ip->il_link&IMP_DMASK]); 2186044Swnj goto rawlinkin; 2195640Sroot 2205640Sroot /* 2215640Sroot * A NOP usually seen during the initialization sequence. 2225640Sroot * Compare the local address with that in the message. 2235640Sroot * Reset the local address notion if it doesn't match. 2245640Sroot */ 225*6336Ssam case IMPTYPE_NOOP: 2265647Ssam if (sc->imp_state == IMPS_DOWN) { 2275647Ssam sc->imp_state = IMPS_INIT; 2285647Ssam sc->imp_dropcnt = IMP_DROPCNT; 2295647Ssam } 2306095Swnj if (sc->imp_state != IMPS_INIT || --sc->imp_dropcnt > 0) 2316271Sroot goto drop; 2325771Swnj sc->imp_state = IMPS_UP; 233*6336Ssam sc->imp_if.if_flags |= IFF_UP; 234*6336Ssam sin = (struct sockaddr_in *)&sc->imp_if.if_addr; 235*6336Ssam sc->imp_if.if_host[0] = sin->sin_addr.s_host = ip->il_host; 236*6336Ssam sin->sin_addr.s_imp = ip->il_imp; 2376160Ssam impmsg(sc, "reset (host %d/imp %d)", (u_int)ip->il_host, 2385771Swnj ntohs(ip->il_imp)); 2395771Swnj /* restart output in case something was q'd */ 2405771Swnj (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 2416271Sroot goto drop; 2425640Sroot 2435640Sroot /* 2445640Sroot * RFNM or INCOMPLETE message, record in 2455640Sroot * host table and prime output routine. 2465640Sroot * 2475647Ssam * SHOULD NOTIFY PROTOCOL ABOUT INCOMPLETES. 2485640Sroot */ 2495640Sroot case IMPTYPE_RFNM: 2505640Sroot case IMPTYPE_INCOMPLETE: 2515924Sroot if (hp && hp->h_rfnm) 2525924Sroot if (next = hostdeque(hp)) 2536160Ssam (void) impsnd(&sc->imp_if, next); 2546271Sroot goto drop; 2555640Sroot 2565640Sroot /* 2575640Sroot * Host or IMP can't be reached. Flush any packets 2585640Sroot * awaiting transmission and release the host structure. 2595640Sroot * 2605771Swnj * TODO: NOTIFY THE PROTOCOL 2615640Sroot */ 2625640Sroot case IMPTYPE_HOSTDEAD: 2635924Sroot impmsg(sc, "host dead"); /* XXX */ 2645771Swnj goto common; /* XXX */ 2655771Swnj 2665771Swnj /* SHOULD SIGNAL ROUTING DAEMON */ 2675640Sroot case IMPTYPE_HOSTUNREACH: 2685924Sroot impmsg(sc, "host unreachable"); /* XXX */ 2695771Swnj common: 2705640Sroot if (hp) 2715771Swnj hostfree(hp); /* won't work right */ 2725859Sroot goto rawlinkin; 2735640Sroot 2745640Sroot /* 2755640Sroot * Error in data. Clear RFNM status for this host and send 2765640Sroot * noops to the IMP to clear the interface. 2775640Sroot */ 2785640Sroot case IMPTYPE_BADDATA: 2795924Sroot impmsg(sc, "data error"); 2805640Sroot if (hp) 2815640Sroot hp->h_rfnm = 0; 2825640Sroot impnoops(sc); 2835859Sroot goto rawlinkin; 2845640Sroot 2855640Sroot /* 2865647Ssam * Interface reset. 2875640Sroot */ 2885640Sroot case IMPTYPE_RESET: 2895924Sroot impmsg(sc, "interface reset"); 2905647Ssam impnoops(sc); 2916044Swnj goto rawlinkin; 2925640Sroot 2935640Sroot default: 2945640Sroot sc->imp_if.if_collisions++; /* XXX */ 2956044Swnj goto rawlinkin; 2965640Sroot } 2975640Sroot 2985640Sroot /* 2996257Sroot * Data for a protocol. Dispatch to the appropriate 3006257Sroot * protocol routine (running at software interrupt). 3016257Sroot * If this isn't a raw interface, advance pointer 3026257Sroot * into mbuf past leader. 3035640Sroot */ 3045640Sroot switch (ip->il_link) { 3055640Sroot 3065640Sroot #ifdef INET 3075640Sroot case IMPLINK_IP: 3085640Sroot m->m_len -= sizeof(struct imp_leader); 3095640Sroot m->m_off += sizeof(struct imp_leader); 3106261Swnj schednetisr(NETISR_IP); 3115640Sroot inq = &ipintrq; 3125640Sroot break; 3135640Sroot #endif 3145640Sroot 3155640Sroot default: 3165868Sroot rawlinkin: 3175640Sroot impproto.sp_protocol = ip->il_link; 318*6336Ssam sin = (struct sockaddr_in *)&sc->imp_if.if_addr; 319*6336Ssam impdst.sin_addr = sin->sin_addr;; 3205645Ssam impsrc.sin_addr.s_net = ip->il_network; 3215645Ssam impsrc.sin_addr.s_host = ip->il_host; 3225645Ssam impsrc.sin_addr.s_imp = ip->il_imp; 3236160Ssam raw_input(m, &impproto, (struct sockaddr *)&impdst, 3246160Ssam (struct sockaddr *)&impsrc); 3255640Sroot return; 3265640Sroot } 3276208Swnj if (IF_QFULL(inq)) { 3286208Swnj IF_DROP(inq); 3296208Swnj goto drop; 3306208Swnj } 3315640Sroot IF_ENQUEUE(inq, m); 3325640Sroot return; 3335640Sroot 3345640Sroot drop: 3355640Sroot m_freem(m); 3365640Sroot } 3375640Sroot 3385647Ssam /* 3395647Ssam * Bring the IMP down after notification. 3405647Ssam */ 3415647Ssam impdown(sc) 3425647Ssam struct imp_softc *sc; 3435647Ssam { 3446208Swnj 3455647Ssam sc->imp_state = IMPS_DOWN; 346*6336Ssam sc->imp_if.if_flags &= ~IFF_UP; 3475924Sroot impmsg(sc, "marked down"); 3485647Ssam /* notify protocols with messages waiting? */ 3495647Ssam } 3505647Ssam 3515640Sroot /*VARARGS*/ 3525924Sroot impmsg(sc, fmt, a1, a2) 3535640Sroot struct imp_softc *sc; 3545640Sroot char *fmt; 3556160Ssam u_int a1; 3565640Sroot { 3576208Swnj 3585640Sroot printf("imp%d: ", sc->imp_if.if_unit); 3595640Sroot printf(fmt, a1, a2); 3605640Sroot printf("\n"); 3615640Sroot } 3625640Sroot 3635640Sroot /* 3645640Sroot * ARPAnet 1822 output routine. 3655640Sroot * Called from higher level protocol routines to set up messages for 3665640Sroot * transmission to the imp. Sets up the header and calls impsnd to 3675640Sroot * enqueue the message for this IMP's hardware driver. 3685640Sroot */ 369*6336Ssam impoutput(ifp, m0, dst) 3705640Sroot register struct ifnet *ifp; 3715640Sroot struct mbuf *m0; 372*6336Ssam struct sockaddr *dst; 3735640Sroot { 3745640Sroot register struct imp_leader *imp; 3755640Sroot register struct mbuf *m = m0; 3766244Sroot int x, dhost, dimp, dlink, len, dnet; 3775640Sroot 3785771Swnj COUNT(IMPOUTPUT); 3795640Sroot /* 3805640Sroot * Don't even try if the IMP is unavailable. 3815640Sroot */ 3825647Ssam x = imp_softc[ifp->if_unit].imp_state; 3835647Ssam if (x == IMPS_DOWN || x == IMPS_GOINGDOWN) 3845647Ssam goto drop; 3855640Sroot 386*6336Ssam switch (dst->sa_family) { 3875640Sroot 3885640Sroot #ifdef INET 389*6336Ssam case AF_INET: { 390*6336Ssam struct ip *ip = mtod(m0, struct ip *); 391*6336Ssam struct sockaddr_in *sin = (struct sockaddr_in *)dst; 3925640Sroot 393*6336Ssam dhost = sin->sin_addr.s_host; 394*6336Ssam dimp = sin->sin_addr.s_impno; 3955640Sroot dlink = IMPLINK_IP; 3966244Sroot dnet = 0; 3976160Ssam len = ntohs((u_short)ip->ip_len); 3985640Sroot break; 3995640Sroot } 4005640Sroot #endif 401*6336Ssam case AF_IMPLINK: 4025640Sroot goto leaderexists; 4035640Sroot 4045640Sroot default: 405*6336Ssam printf("imp%d: can't handle af%d\n", ifp->if_unit, 406*6336Ssam dst->sa_family); 4075647Ssam goto drop; 4085640Sroot } 4095640Sroot 4105640Sroot /* 4115640Sroot * Add IMP leader. If there's not enough space in the 4125640Sroot * first mbuf, allocate another. If that should fail, we 4135640Sroot * drop this sucker. 4145640Sroot */ 4155640Sroot if (m->m_off > MMAXOFF || 4165640Sroot MMINOFF + sizeof(struct imp_leader) > m->m_off) { 4175640Sroot m = m_get(M_DONTWAIT); 4185647Ssam if (m == 0) 4195647Ssam goto drop; 4205640Sroot m->m_next = m0; 4215640Sroot m->m_off = MMINOFF; 4225640Sroot m->m_len = sizeof(struct imp_leader); 4235640Sroot } else { 4245640Sroot m->m_off -= sizeof(struct imp_leader); 4255640Sroot m->m_len += sizeof(struct imp_leader); 4265640Sroot } 4275640Sroot imp = mtod(m, struct imp_leader *); 4285640Sroot imp->il_format = IMP_NFF; 4295859Sroot imp->il_mtype = IMPTYPE_DATA; 4306244Sroot imp->il_network = dnet; 4315640Sroot imp->il_host = dhost; 4326244Sroot imp->il_imp = htons((u_short)dimp); 4336160Ssam imp->il_length = 4346160Ssam htons((u_short)(len + sizeof(struct imp_leader)) << 3); 4355640Sroot imp->il_link = dlink; 4365859Sroot imp->il_flags = imp->il_htype = imp->il_subtype = 0; 4375640Sroot 4385640Sroot leaderexists: 4395640Sroot /* 4405640Sroot * Hand message to impsnd to perform RFNM counting 4415640Sroot * and eventual transmission. 4425640Sroot */ 4435640Sroot return (impsnd(ifp, m)); 4445647Ssam drop: 4455647Ssam m_freem(m0); 4465647Ssam return (0); 4475640Sroot } 4485640Sroot 4495640Sroot /* 4505640Sroot * Put a message on an interface's output queue. 4515640Sroot * Perform RFNM counting: no more than 8 message may be 4525640Sroot * in flight to any one host. 4535640Sroot */ 4545640Sroot impsnd(ifp, m) 4555640Sroot struct ifnet *ifp; 4565640Sroot struct mbuf *m; 4575640Sroot { 4585640Sroot register struct imp_leader *ip; 4595640Sroot register struct host *hp; 4605640Sroot struct impcb *icp; 4615640Sroot int x; 4625640Sroot 4635771Swnj COUNT(IMPSND); 4645640Sroot ip = mtod(m, struct imp_leader *); 4655640Sroot 4665640Sroot /* 4675640Sroot * Do RFNM counting for data messages 4685640Sroot * (no more than 8 outstanding to any host) 4695640Sroot */ 4706095Swnj x = splimp(); 4715640Sroot if (ip->il_mtype == IMPTYPE_DATA) { 4725640Sroot struct in_addr addr; 4735640Sroot 4745859Sroot #ifdef notdef 4755771Swnj addr.s_net = ip->il_network; 4765859Sroot #else 4775859Sroot addr.s_net = 0; 4785859Sroot #endif 4795640Sroot addr.s_host = ip->il_host; 4805640Sroot addr.s_imp = ip->il_imp; 4815771Swnj if ((hp = hostlookup(addr)) == 0) 4825771Swnj hp = hostenter(addr); 4835640Sroot 4845640Sroot /* 4855647Ssam * If IMP would block, queue until RFNM 4865640Sroot */ 4875640Sroot if (hp) { 4885640Sroot if (hp->h_rfnm < 8) { 4895640Sroot hp->h_rfnm++; 4905640Sroot goto enque; 4915640Sroot } 4926095Swnj if (hp->h_qcnt < 8) { /* high water mark */ 4936095Swnj HOST_ENQUE(hp, m); 4946095Swnj goto start; 4956095Swnj } 4965640Sroot } 4975640Sroot m_freem(m); 4985859Sroot splx(x); 4995640Sroot return (0); 5005640Sroot } 5015640Sroot enque: 5026208Swnj if (IF_QFULL(&ifp->if_snd)) { 5036208Swnj IF_DROP(&ifp->if_snd); 5046208Swnj m_freem(m); 5056208Swnj splx(x); 5066208Swnj return (0); 5076208Swnj } 5085640Sroot IF_ENQUEUE(&ifp->if_snd, m); 5096095Swnj start: 5105640Sroot splx(x); 5115640Sroot icp = &imp_softc[ifp->if_unit].imp_cb; 5125640Sroot if (icp->ic_oactive == 0) 5135640Sroot (*icp->ic_start)(ifp->if_unit); 5145640Sroot return (1); 5155640Sroot } 5165640Sroot 5175640Sroot /* 5185640Sroot * Put three 1822 NOOPs at the head of the output queue. 5195640Sroot * Part of host-IMP initialization procedure. 5205640Sroot * (Should return success/failure, but noone knows 5215640Sroot * what to do with this, so why bother?) 5225640Sroot */ 5235640Sroot impnoops(sc) 5245640Sroot register struct imp_softc *sc; 5255640Sroot { 5265640Sroot register i; 5275640Sroot register struct mbuf *m; 5285771Swnj register struct control_leader *cp; 5295640Sroot int x; 5305640Sroot 5315771Swnj COUNT(IMPNOOPS); 5325640Sroot sc->imp_state = IMPS_INIT; 5335640Sroot sc->imp_dropcnt = IMP_DROPCNT; 5345771Swnj for (i = 0; i < IMP_DROPCNT + 1; i++ ) { 5355640Sroot if ((m = m_getclr(M_DONTWAIT)) == 0) 5365640Sroot return; 5375640Sroot m->m_off = MMINOFF; 5385771Swnj m->m_len = sizeof(struct control_leader); 5395771Swnj cp = mtod(m, struct control_leader *); 5405771Swnj cp->dl_format = IMP_NFF; 5415771Swnj cp->dl_link = i; 5425771Swnj cp->dl_mtype = IMPTYPE_NOOP; 5435640Sroot x = splimp(); 5445640Sroot IF_PREPEND(&sc->imp_if.if_snd, m); 5455640Sroot splx(x); 5465640Sroot } 5475640Sroot if (sc->imp_cb.ic_oactive == 0) 5485640Sroot (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 5495640Sroot } 5505771Swnj 5515859Sroot #ifdef IMPLEADERS 5525771Swnj printleader(routine, ip) 5535771Swnj char *routine; 5545771Swnj register struct imp_leader *ip; 5555771Swnj { 5565771Swnj printf("%s: ", routine); 5575771Swnj printbyte((char *)ip, 12); 5585771Swnj printf("<fmt=%x,net=%x,flags=%x,mtype=", ip->il_format, ip->il_network, 5595771Swnj ip->il_flags); 5605771Swnj if (ip->il_mtype <= IMPTYPE_READY) 5615771Swnj printf("%s,", impleaders[ip->il_mtype]); 5625771Swnj else 5635771Swnj printf("%x,", ip->il_mtype); 5645771Swnj printf("htype=%x,host=%x,imp=%x,link=", ip->il_htype, ip->il_host, 5656244Sroot ntohs(ip->il_imp)); 5665771Swnj if (ip->il_link == IMPLINK_IP) 5675771Swnj printf("ip,"); 5685771Swnj else 5695771Swnj printf("%x,", ip->il_link); 5705771Swnj printf("subtype=%x,len=%x>\n",ip->il_subtype,ntohs(ip->il_length)>>3); 5715771Swnj } 5725771Swnj 5735771Swnj printbyte(cp, n) 5745771Swnj register char *cp; 5755771Swnj int n; 5765771Swnj { 5775771Swnj register i, j, c; 5785771Swnj 5795771Swnj for (i=0; i<n; i++) { 5805771Swnj c = *cp++; 5815771Swnj for (j=0; j<2; j++) 5825771Swnj putchar("0123456789abcdef"[(c>>((1-j)*4))&0xf]); 5835771Swnj putchar(' '); 5845771Swnj } 5855771Swnj putchar('\n'); 5865771Swnj } 5875640Sroot #endif 5885859Sroot #endif 589