1*6271Sroot /* if_imp.c 4.19 82/03/19 */ 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 * rethink coupling between this module and device driver 135771Swnj * pass more error indications up to protocol modules 145640Sroot */ 155640Sroot #include "../h/param.h" 165640Sroot #include "../h/systm.h" 175640Sroot #include "../h/mbuf.h" 185640Sroot #include "../h/pte.h" 195640Sroot #include "../h/buf.h" 205640Sroot #include "../h/protosw.h" 215640Sroot #include "../h/socket.h" 225640Sroot #include "../h/ubareg.h" 235640Sroot #include "../h/ubavar.h" 245640Sroot #include "../h/cpu.h" 255640Sroot #include "../h/mtpr.h" 265640Sroot #include "../h/vmmac.h" 275640Sroot #include "../net/in.h" 285640Sroot #include "../net/in_systm.h" 295640Sroot #include "../net/if.h" 305640Sroot #include "../net/if_imp.h" 315859Sroot #include "../net/if_imphost.h" 325640Sroot #include "../net/ip.h" 335640Sroot #include "../net/ip_var.h" 345640Sroot 355640Sroot /* 365640Sroot * IMP software status per interface. 375640Sroot * (partially shared with the hardware specific module) 385640Sroot * 395640Sroot * Each interface is referenced by a network interface structure, 405640Sroot * imp_if, which the routing code uses to locate the interface. 415640Sroot * This structure contains the output queue for the interface, its 425640Sroot * address, ... IMP specific structures used in connecting the 435640Sroot * IMP software modules to the hardware specific interface routines 445771Swnj * are stored here. The common structures are made visible to the 455771Swnj * interface driver by passing a pointer to the hardware routine 465771Swnj * at "attach" time. 475640Sroot * 485640Sroot * NOTE: imp_if and imp_cb are assumed adjacent in hardware code. 495640Sroot */ 505640Sroot struct imp_softc { 515640Sroot struct ifnet imp_if; /* network visible interface */ 525640Sroot struct impcb imp_cb; /* hooks to hardware module */ 535640Sroot u_char imp_state; /* current state of IMP */ 545640Sroot char imp_dropcnt; /* used during initialization */ 555640Sroot } imp_softc[NIMP]; 565640Sroot 575640Sroot /* 585640Sroot * Messages from IMP regarding why 595640Sroot * it's going down. 605640Sroot */ 615924Sroot static char *impmessage[] = { 625640Sroot "in 30 seconds", 635640Sroot "for hardware PM", 645640Sroot "to reload software", 655640Sroot "for emergency reset" 665640Sroot }; 675640Sroot 685771Swnj int impdown(), impinit(), impoutput(); 695771Swnj 705640Sroot /* 715640Sroot * IMP attach routine. Called from hardware device attach routine 725640Sroot * at configuration time with a pointer to the UNIBUS device structure. 735640Sroot * Sets up local state and returns pointer to base of ifnet+impcb 745640Sroot * structures. This is then used by the device's attach routine 755640Sroot * set up its back pointers. 765640Sroot */ 775640Sroot impattach(ui) 785640Sroot struct uba_device *ui; 795640Sroot { 805640Sroot struct imp_softc *sc = &imp_softc[ui->ui_unit]; 815640Sroot register struct ifnet *ifp = &sc->imp_if; 825640Sroot 835640Sroot COUNT(IMPATTACH); 845640Sroot /* UNIT COULD BE AMBIGUOUS */ 855640Sroot ifp->if_unit = ui->ui_unit; 865640Sroot ifp->if_name = "imp"; 87*6271Sroot 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 */ 906044Swnj ifp->if_addr = if_makeaddr(ifp->if_net, 0); 915771Swnj ifp->if_init = impinit; 925771Swnj ifp->if_output = impoutput; 935771Swnj /* reset is handled at the hardware level */ 945640Sroot if_attach(ifp); 955640Sroot /* kludge to hand pointers back to hardware attach routine */ 965640Sroot return ((int)&sc->imp_if); 975640Sroot } 985640Sroot 996208Swnj #ifdef notdef 1005640Sroot /* 1016208Swnj * Timer routine to keep priming the IMP until it sends 1026208Swnj * us the noops we need. Since we depend on the host and 1036208Swnj * imp values returned in the noop messages, we must wait 1046208Swnj * for them before we allow any outgoing traffic. 1056208Swnj */ 1066208Swnj imptimer(sc) 1076208Swnj register struct imp_softc *sc; 1086208Swnj { 1096208Swnj int s = splimp(); 1106208Swnj 1116208Swnj if (sc->imp_state != IMPS_INIT) { 1126208Swnj splx(s); 1136208Swnj return; 1146208Swnj } 1156208Swnj sc->imp_dropcnt = IMP_DROPCNT; 1166208Swnj impnoops(sc); 1176208Swnj timeout(imptimer, (caddr_t)sc, 30 * hz); 1186208Swnj splx(s); 1196208Swnj } 1206208Swnj #endif 1216208Swnj 1226208Swnj /* 1235640Sroot * IMP initialization routine: call hardware module to 1245640Sroot * setup UNIBUS resources, init state and get ready for 1255640Sroot * NOOPs the IMP should send us, and that we want to drop. 1265640Sroot */ 1275640Sroot impinit(unit) 1285640Sroot int unit; 1295640Sroot { 1305640Sroot register struct imp_softc *sc = &imp_softc[unit]; 1315640Sroot 1325771Swnj if ((*sc->imp_cb.ic_init)(unit) == 0) { 1335771Swnj sc->imp_state = IMPS_DOWN; 1345771Swnj return; 1355771Swnj } 1365640Sroot sc->imp_state = IMPS_INIT; 1376208Swnj #ifdef notdef 1386208Swnj imptimer(sc); 1396208Swnj #else 1405640Sroot sc->imp_dropcnt = IMP_DROPCNT; 1415771Swnj impnoops(sc); 1426208Swnj #endif 1435640Sroot } 1445640Sroot 1455640Sroot struct sockproto impproto = { PF_IMPLINK }; 1465645Ssam struct sockaddr_in impdst = { AF_IMPLINK }; 1475645Ssam struct sockaddr_in impsrc = { AF_IMPLINK }; 1485640Sroot 1495640Sroot /* 1505640Sroot * ARPAnet 1822 input routine. 1515640Sroot * Called from hardware input interrupt routine to handle 1822 1525640Sroot * IMP-host messages. Type 0 messages (non-control) are 1535640Sroot * passed to higher level protocol processors on the basis 1545640Sroot * of link number. Other type messages (control) are handled here. 1555640Sroot */ 1565771Swnj impinput(unit, m) 1575640Sroot int unit; 1585771Swnj register struct mbuf *m; 1595640Sroot { 1605640Sroot register struct imp_leader *ip; 1615640Sroot register struct imp_softc *sc = &imp_softc[unit]; 1625640Sroot register struct host *hp; 1635640Sroot register struct ifqueue *inq; 1645771Swnj struct control_leader *cp; 1655640Sroot struct in_addr addr; 1665924Sroot struct mbuf *next; 1675640Sroot 1685932Sroot COUNT(IMPINPUT); 1696257Sroot /* verify leader length. */ 1705771Swnj if (m->m_len < sizeof(struct control_leader) && 1715771Swnj (m = m_pullup(m, sizeof(struct control_leader))) == 0) 1725771Swnj return; 1735771Swnj cp = mtod(m, struct control_leader *); 1745771Swnj if (cp->dl_mtype == IMPTYPE_DATA) 1755771Swnj if (m->m_len < sizeof(struct imp_leader) && 1765771Swnj (m = m_pullup(m, sizeof(struct imp_leader))) == 0) 1775771Swnj return; 1785640Sroot ip = mtod(m, struct imp_leader *); 1795640Sroot 1806257Sroot /* check leader type */ 1815771Swnj if (ip->il_format != IMP_NFF) { 1825771Swnj sc->imp_if.if_collisions++; /* XXX */ 1835640Sroot goto drop; 1845771Swnj } 1855640Sroot 1865640Sroot /* 1875640Sroot * Certain messages require a host structure. 1885640Sroot * Do this in one shot here. 1895640Sroot */ 1905640Sroot switch (ip->il_mtype) { 1915640Sroot 1925640Sroot case IMPTYPE_RFNM: 1935640Sroot case IMPTYPE_INCOMPLETE: 1945640Sroot case IMPTYPE_HOSTDEAD: 1955640Sroot case IMPTYPE_HOSTUNREACH: 1965640Sroot case IMPTYPE_BADDATA: 1975859Sroot #ifdef notdef 1985771Swnj addr.s_net = ip->il_network; 1995859Sroot #else 2005859Sroot addr.s_net = 0; 2015859Sroot #endif 2025771Swnj addr.s_imp = ip->il_imp; 2035771Swnj addr.s_host = ip->il_host; 2045771Swnj hp = hostlookup(addr); 2055640Sroot break; 2065640Sroot } 2075640Sroot 2085640Sroot switch (ip->il_mtype) { 2095640Sroot 2105640Sroot case IMPTYPE_DATA: 2115640Sroot break; 2125640Sroot 2135640Sroot /* 2145640Sroot * IMP leader error. Reset the IMP and discard the packet. 2155640Sroot */ 2165640Sroot case IMPTYPE_BADLEADER: 2175647Ssam /* 2185647Ssam * According to 1822 document, this message 2195647Ssam * will be generated in response to the 2205647Ssam * first noop sent to the IMP after 2215647Ssam * the host resets the IMP interface. 2225647Ssam */ 2235771Swnj if (sc->imp_state != IMPS_INIT) { 2245924Sroot impmsg(sc, "leader error"); 2255771Swnj hostreset(sc->imp_if.if_net); /* XXX */ 2265647Ssam impnoops(sc); 2275647Ssam } 2286044Swnj goto rawlinkin; 2295640Sroot 2305640Sroot /* 2315640Sroot * IMP going down. Print message, and if not immediate, 2325640Sroot * set off a timer to insure things will be reset at the 2335640Sroot * appropriate time. 2345640Sroot */ 2355640Sroot case IMPTYPE_DOWN: 2365640Sroot if ((ip->il_link & IMP_DMASK) == 0) { 2375640Sroot sc->imp_state = IMPS_GOINGDOWN; 2386160Ssam timeout(impdown, (caddr_t)sc, 30 * hz); 2395640Sroot } 2406160Ssam impmsg(sc, "going down %s", 2416160Ssam (u_int)impmessage[ip->il_link&IMP_DMASK]); 2426044Swnj goto rawlinkin; 2435640Sroot 2445640Sroot /* 2455640Sroot * A NOP usually seen during the initialization sequence. 2465640Sroot * Compare the local address with that in the message. 2475640Sroot * Reset the local address notion if it doesn't match. 2485640Sroot */ 2495771Swnj case IMPTYPE_NOOP: { 2505771Swnj register struct in_addr *sin; 2515771Swnj 2525647Ssam if (sc->imp_state == IMPS_DOWN) { 2535647Ssam sc->imp_state = IMPS_INIT; 2545647Ssam sc->imp_dropcnt = IMP_DROPCNT; 2555647Ssam } 2566095Swnj if (sc->imp_state != IMPS_INIT || --sc->imp_dropcnt > 0) 257*6271Sroot goto drop; 2585771Swnj sc->imp_state = IMPS_UP; 2595771Swnj sin = &sc->imp_if.if_addr; 2605771Swnj sc->imp_if.if_host[0] = sin->s_host = ip->il_host; 2615771Swnj sin->s_imp = ip->il_imp; 2626160Ssam impmsg(sc, "reset (host %d/imp %d)", (u_int)ip->il_host, 2635771Swnj ntohs(ip->il_imp)); 2645771Swnj /* restart output in case something was q'd */ 2655771Swnj (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 266*6271Sroot goto drop; 2675989Sroot } 2685640Sroot 2695640Sroot /* 2705640Sroot * RFNM or INCOMPLETE message, record in 2715640Sroot * host table and prime output routine. 2725640Sroot * 2735647Ssam * SHOULD NOTIFY PROTOCOL ABOUT INCOMPLETES. 2745640Sroot */ 2755640Sroot case IMPTYPE_RFNM: 2765640Sroot case IMPTYPE_INCOMPLETE: 2775924Sroot if (hp && hp->h_rfnm) 2785924Sroot if (next = hostdeque(hp)) 2796160Ssam (void) impsnd(&sc->imp_if, next); 280*6271Sroot goto drop; 2815640Sroot 2825640Sroot /* 2835640Sroot * Host or IMP can't be reached. Flush any packets 2845640Sroot * awaiting transmission and release the host structure. 2855640Sroot * 2865771Swnj * TODO: NOTIFY THE PROTOCOL 2875640Sroot */ 2885640Sroot case IMPTYPE_HOSTDEAD: 2895924Sroot impmsg(sc, "host dead"); /* XXX */ 2905771Swnj goto common; /* XXX */ 2915771Swnj 2925771Swnj /* SHOULD SIGNAL ROUTING DAEMON */ 2935640Sroot case IMPTYPE_HOSTUNREACH: 2945924Sroot impmsg(sc, "host unreachable"); /* XXX */ 2955771Swnj common: 2965640Sroot if (hp) 2975771Swnj hostfree(hp); /* won't work right */ 2985859Sroot goto rawlinkin; 2995640Sroot 3005640Sroot /* 3015640Sroot * Error in data. Clear RFNM status for this host and send 3025640Sroot * noops to the IMP to clear the interface. 3035640Sroot */ 3045640Sroot case IMPTYPE_BADDATA: 3055924Sroot impmsg(sc, "data error"); 3065640Sroot if (hp) 3075640Sroot hp->h_rfnm = 0; 3085640Sroot impnoops(sc); 3095859Sroot goto rawlinkin; 3105640Sroot 3115640Sroot /* 3125647Ssam * Interface reset. 3135640Sroot */ 3145640Sroot case IMPTYPE_RESET: 3155924Sroot impmsg(sc, "interface reset"); 3165647Ssam impnoops(sc); 3176044Swnj goto rawlinkin; 3185640Sroot 3195640Sroot default: 3205640Sroot sc->imp_if.if_collisions++; /* XXX */ 3216044Swnj goto rawlinkin; 3225640Sroot } 3235640Sroot 3245640Sroot /* 3256257Sroot * Data for a protocol. Dispatch to the appropriate 3266257Sroot * protocol routine (running at software interrupt). 3276257Sroot * If this isn't a raw interface, advance pointer 3286257Sroot * into mbuf past leader. 3295640Sroot */ 3305640Sroot switch (ip->il_link) { 3315640Sroot 3325640Sroot #ifdef INET 3335640Sroot case IMPLINK_IP: 3345640Sroot m->m_len -= sizeof(struct imp_leader); 3355640Sroot m->m_off += sizeof(struct imp_leader); 3366261Swnj schednetisr(NETISR_IP); 3375640Sroot inq = &ipintrq; 3385640Sroot break; 3395640Sroot #endif 3405640Sroot 3415640Sroot default: 3425868Sroot rawlinkin: 3435640Sroot impproto.sp_protocol = ip->il_link; 3445645Ssam impdst.sin_addr = sc->imp_if.if_addr; 3455645Ssam impsrc.sin_addr.s_net = ip->il_network; 3465645Ssam impsrc.sin_addr.s_host = ip->il_host; 3475645Ssam impsrc.sin_addr.s_imp = ip->il_imp; 3486160Ssam raw_input(m, &impproto, (struct sockaddr *)&impdst, 3496160Ssam (struct sockaddr *)&impsrc); 3505640Sroot return; 3515640Sroot } 3526208Swnj if (IF_QFULL(inq)) { 3536208Swnj IF_DROP(inq); 3546208Swnj goto drop; 3556208Swnj } 3565640Sroot IF_ENQUEUE(inq, m); 3575640Sroot return; 3585640Sroot 3595640Sroot drop: 3605640Sroot m_freem(m); 3615640Sroot } 3625640Sroot 3635647Ssam /* 3645647Ssam * Bring the IMP down after notification. 3655647Ssam */ 3665647Ssam impdown(sc) 3675647Ssam struct imp_softc *sc; 3685647Ssam { 3696208Swnj 3705647Ssam sc->imp_state = IMPS_DOWN; 3715924Sroot impmsg(sc, "marked down"); 3725647Ssam /* notify protocols with messages waiting? */ 3735647Ssam } 3745647Ssam 3755640Sroot /*VARARGS*/ 3765924Sroot impmsg(sc, fmt, a1, a2) 3775640Sroot struct imp_softc *sc; 3785640Sroot char *fmt; 3796160Ssam u_int a1; 3805640Sroot { 3816208Swnj 3825640Sroot printf("imp%d: ", sc->imp_if.if_unit); 3835640Sroot printf(fmt, a1, a2); 3845640Sroot printf("\n"); 3855640Sroot } 3865640Sroot 3875640Sroot /* 3885640Sroot * ARPAnet 1822 output routine. 3895640Sroot * Called from higher level protocol routines to set up messages for 3905640Sroot * transmission to the imp. Sets up the header and calls impsnd to 3915640Sroot * enqueue the message for this IMP's hardware driver. 3925640Sroot */ 3935640Sroot impoutput(ifp, m0, pf) 3945640Sroot register struct ifnet *ifp; 3955640Sroot struct mbuf *m0; 3965640Sroot { 3975640Sroot register struct imp_leader *imp; 3985640Sroot register struct mbuf *m = m0; 3996244Sroot int x, dhost, dimp, dlink, len, dnet; 4005640Sroot 4015771Swnj COUNT(IMPOUTPUT); 4025640Sroot /* 4035640Sroot * Don't even try if the IMP is unavailable. 4045640Sroot */ 4055647Ssam x = imp_softc[ifp->if_unit].imp_state; 4065647Ssam if (x == IMPS_DOWN || x == IMPS_GOINGDOWN) 4075647Ssam goto drop; 4085640Sroot 4095640Sroot switch (pf) { 4105640Sroot 4115640Sroot #ifdef INET 4125640Sroot case PF_INET: { 4135640Sroot register struct ip *ip = mtod(m0, struct ip *); 4145640Sroot 4155640Sroot dhost = ip->ip_dst.s_host; 4166244Sroot dimp = ip->ip_dst.s_impno; 4175640Sroot dlink = IMPLINK_IP; 4186244Sroot dnet = 0; 4196160Ssam len = ntohs((u_short)ip->ip_len); 4205640Sroot break; 4215640Sroot } 4225640Sroot #endif 4235640Sroot case PF_IMPLINK: 4245640Sroot goto leaderexists; 4255640Sroot 4265640Sroot default: 4275640Sroot printf("imp%d: can't encapsulate pf%d\n", ifp->if_unit, pf); 4285647Ssam goto drop; 4295640Sroot } 4305640Sroot 4315640Sroot /* 4325640Sroot * Add IMP leader. If there's not enough space in the 4335640Sroot * first mbuf, allocate another. If that should fail, we 4345640Sroot * drop this sucker. 4355640Sroot */ 4365640Sroot if (m->m_off > MMAXOFF || 4375640Sroot MMINOFF + sizeof(struct imp_leader) > m->m_off) { 4385640Sroot m = m_get(M_DONTWAIT); 4395647Ssam if (m == 0) 4405647Ssam goto drop; 4415640Sroot m->m_next = m0; 4425640Sroot m->m_off = MMINOFF; 4435640Sroot m->m_len = sizeof(struct imp_leader); 4445640Sroot } else { 4455640Sroot m->m_off -= sizeof(struct imp_leader); 4465640Sroot m->m_len += sizeof(struct imp_leader); 4475640Sroot } 4485640Sroot imp = mtod(m, struct imp_leader *); 4495640Sroot imp->il_format = IMP_NFF; 4505859Sroot imp->il_mtype = IMPTYPE_DATA; 4516244Sroot imp->il_network = dnet; 4525640Sroot imp->il_host = dhost; 4536244Sroot imp->il_imp = htons((u_short)dimp); 4546160Ssam imp->il_length = 4556160Ssam htons((u_short)(len + sizeof(struct imp_leader)) << 3); 4565640Sroot imp->il_link = dlink; 4575859Sroot imp->il_flags = imp->il_htype = imp->il_subtype = 0; 4585640Sroot 4595640Sroot leaderexists: 4605640Sroot /* 4615640Sroot * Hand message to impsnd to perform RFNM counting 4625640Sroot * and eventual transmission. 4635640Sroot */ 4645640Sroot return (impsnd(ifp, m)); 4655647Ssam drop: 4665647Ssam m_freem(m0); 4675647Ssam return (0); 4685640Sroot } 4695640Sroot 4705640Sroot /* 4715640Sroot * Put a message on an interface's output queue. 4725640Sroot * Perform RFNM counting: no more than 8 message may be 4735640Sroot * in flight to any one host. 4745640Sroot */ 4755640Sroot impsnd(ifp, m) 4765640Sroot struct ifnet *ifp; 4775640Sroot struct mbuf *m; 4785640Sroot { 4795640Sroot register struct imp_leader *ip; 4805640Sroot register struct host *hp; 4815640Sroot struct impcb *icp; 4825640Sroot int x; 4835640Sroot 4845771Swnj COUNT(IMPSND); 4855640Sroot ip = mtod(m, struct imp_leader *); 4865640Sroot 4875640Sroot /* 4885640Sroot * Do RFNM counting for data messages 4895640Sroot * (no more than 8 outstanding to any host) 4905640Sroot */ 4916095Swnj x = splimp(); 4925640Sroot if (ip->il_mtype == IMPTYPE_DATA) { 4935640Sroot struct in_addr addr; 4945640Sroot 4955859Sroot #ifdef notdef 4965771Swnj addr.s_net = ip->il_network; 4975859Sroot #else 4985859Sroot addr.s_net = 0; 4995859Sroot #endif 5005640Sroot addr.s_host = ip->il_host; 5015640Sroot addr.s_imp = ip->il_imp; 5025771Swnj if ((hp = hostlookup(addr)) == 0) 5035771Swnj hp = hostenter(addr); 5045640Sroot 5055640Sroot /* 5065647Ssam * If IMP would block, queue until RFNM 5075640Sroot */ 5085640Sroot if (hp) { 5095640Sroot if (hp->h_rfnm < 8) { 5105640Sroot hp->h_rfnm++; 5115640Sroot goto enque; 5125640Sroot } 5136095Swnj if (hp->h_qcnt < 8) { /* high water mark */ 5146095Swnj HOST_ENQUE(hp, m); 5156095Swnj goto start; 5166095Swnj } 5175640Sroot } 5185640Sroot m_freem(m); 5195859Sroot splx(x); 5205640Sroot return (0); 5215640Sroot } 5225640Sroot enque: 5236208Swnj if (IF_QFULL(&ifp->if_snd)) { 5246208Swnj IF_DROP(&ifp->if_snd); 5256208Swnj m_freem(m); 5266208Swnj splx(x); 5276208Swnj return (0); 5286208Swnj } 5295640Sroot IF_ENQUEUE(&ifp->if_snd, m); 5306095Swnj start: 5315640Sroot splx(x); 5325640Sroot icp = &imp_softc[ifp->if_unit].imp_cb; 5335640Sroot if (icp->ic_oactive == 0) 5345640Sroot (*icp->ic_start)(ifp->if_unit); 5355640Sroot return (1); 5365640Sroot } 5375640Sroot 5385640Sroot /* 5395640Sroot * Put three 1822 NOOPs at the head of the output queue. 5405640Sroot * Part of host-IMP initialization procedure. 5415640Sroot * (Should return success/failure, but noone knows 5425640Sroot * what to do with this, so why bother?) 5435640Sroot */ 5445640Sroot impnoops(sc) 5455640Sroot register struct imp_softc *sc; 5465640Sroot { 5475640Sroot register i; 5485640Sroot register struct mbuf *m; 5495771Swnj register struct control_leader *cp; 5505640Sroot int x; 5515640Sroot 5525771Swnj COUNT(IMPNOOPS); 5535640Sroot sc->imp_state = IMPS_INIT; 5545640Sroot sc->imp_dropcnt = IMP_DROPCNT; 5555771Swnj for (i = 0; i < IMP_DROPCNT + 1; i++ ) { 5565640Sroot if ((m = m_getclr(M_DONTWAIT)) == 0) 5575640Sroot return; 5585640Sroot m->m_off = MMINOFF; 5595771Swnj m->m_len = sizeof(struct control_leader); 5605771Swnj cp = mtod(m, struct control_leader *); 5615771Swnj cp->dl_format = IMP_NFF; 5625771Swnj cp->dl_link = i; 5635771Swnj cp->dl_mtype = IMPTYPE_NOOP; 5645640Sroot x = splimp(); 5655640Sroot IF_PREPEND(&sc->imp_if.if_snd, m); 5665640Sroot splx(x); 5675640Sroot } 5685640Sroot if (sc->imp_cb.ic_oactive == 0) 5695640Sroot (*sc->imp_cb.ic_start)(sc->imp_if.if_unit); 5705640Sroot } 5715771Swnj 5725859Sroot #ifdef IMPLEADERS 5735771Swnj printleader(routine, ip) 5745771Swnj char *routine; 5755771Swnj register struct imp_leader *ip; 5765771Swnj { 5775771Swnj printf("%s: ", routine); 5785771Swnj printbyte((char *)ip, 12); 5795771Swnj printf("<fmt=%x,net=%x,flags=%x,mtype=", ip->il_format, ip->il_network, 5805771Swnj ip->il_flags); 5815771Swnj if (ip->il_mtype <= IMPTYPE_READY) 5825771Swnj printf("%s,", impleaders[ip->il_mtype]); 5835771Swnj else 5845771Swnj printf("%x,", ip->il_mtype); 5855771Swnj printf("htype=%x,host=%x,imp=%x,link=", ip->il_htype, ip->il_host, 5866244Sroot ntohs(ip->il_imp)); 5875771Swnj if (ip->il_link == IMPLINK_IP) 5885771Swnj printf("ip,"); 5895771Swnj else 5905771Swnj printf("%x,", ip->il_link); 5915771Swnj printf("subtype=%x,len=%x>\n",ip->il_subtype,ntohs(ip->il_length)>>3); 5925771Swnj } 5935771Swnj 5945771Swnj printbyte(cp, n) 5955771Swnj register char *cp; 5965771Swnj int n; 5975771Swnj { 5985771Swnj register i, j, c; 5995771Swnj 6005771Swnj for (i=0; i<n; i++) { 6015771Swnj c = *cp++; 6025771Swnj for (j=0; j<2; j++) 6035771Swnj putchar("0123456789abcdef"[(c>>((1-j)*4))&0xf]); 6045771Swnj putchar(' '); 6055771Swnj } 6065771Swnj putchar('\n'); 6075771Swnj } 6085640Sroot #endif 6095859Sroot #endif 610