before carry to calder
[unix-history] / usr / src / sys / deprecated / netimp / if_imp.c
CommitLineData
7dfb87a5 1/* if_imp.c 4.34 82/06/14 */
6c73ade6
BJ
2
3#include "imp.h"
4#if NIMP > 0
5/*
72e4f44e 6 * ARPANET IMP interface driver.
6c73ade6
BJ
7 *
8 * The IMP-host protocol is handled here, leaving
9 * hardware specifics to the lower level interface driver.
10 */
11#include "../h/param.h"
12#include "../h/systm.h"
13#include "../h/mbuf.h"
14#include "../h/pte.h"
15#include "../h/buf.h"
16#include "../h/protosw.h"
17#include "../h/socket.h"
18#include "../h/ubareg.h"
19#include "../h/ubavar.h"
20#include "../h/cpu.h"
21#include "../h/mtpr.h"
22#include "../h/vmmac.h"
23#include "../net/in.h"
24#include "../net/in_systm.h"
25#include "../net/if.h"
7dfb87a5 26#define IMPLEADERS
6c73ade6 27#include "../net/if_imp.h"
41e530c7 28#include "../net/if_imphost.h"
6c73ade6
BJ
29#include "../net/ip.h"
30#include "../net/ip_var.h"
f6311fb6 31#include "../net/route.h"
8a2f82db 32#include <errno.h>
6c73ade6
BJ
33
34/*
35 * IMP software status per interface.
36 * (partially shared with the hardware specific module)
37 *
38 * Each interface is referenced by a network interface structure,
39 * imp_if, which the routing code uses to locate the interface.
40 * This structure contains the output queue for the interface, its
41 * address, ... IMP specific structures used in connecting the
42 * IMP software modules to the hardware specific interface routines
a2cd4df7
BJ
43 * are stored here. The common structures are made visible to the
44 * interface driver by passing a pointer to the hardware routine
45 * at "attach" time.
6c73ade6
BJ
46 *
47 * NOTE: imp_if and imp_cb are assumed adjacent in hardware code.
48 */
49struct imp_softc {
50 struct ifnet imp_if; /* network visible interface */
51 struct impcb imp_cb; /* hooks to hardware module */
52 u_char imp_state; /* current state of IMP */
53 char imp_dropcnt; /* used during initialization */
6c73ade6
BJ
54} imp_softc[NIMP];
55
56/*
57 * Messages from IMP regarding why
58 * it's going down.
59 */
e33b5b1a 60static char *impmessage[] = {
6c73ade6
BJ
61 "in 30 seconds",
62 "for hardware PM",
63 "to reload software",
64 "for emergency reset"
65};
66
a2cd4df7
BJ
67int impdown(), impinit(), impoutput();
68
6c73ade6
BJ
69/*
70 * IMP attach routine. Called from hardware device attach routine
71 * at configuration time with a pointer to the UNIBUS device structure.
72 * Sets up local state and returns pointer to base of ifnet+impcb
73 * structures. This is then used by the device's attach routine
74 * set up its back pointers.
75 */
76impattach(ui)
77 struct uba_device *ui;
78{
79 struct imp_softc *sc = &imp_softc[ui->ui_unit];
80 register struct ifnet *ifp = &sc->imp_if;
ee787340 81 struct sockaddr_in *sin;
6c73ade6
BJ
82
83COUNT(IMPATTACH);
84 /* UNIT COULD BE AMBIGUOUS */
85 ifp->if_unit = ui->ui_unit;
86 ifp->if_name = "imp";
e431883e 87 ifp->if_mtu = IMPMTU - sizeof(struct imp_leader);
6c73ade6 88 ifp->if_net = ui->ui_flags;
aee8ddf8 89 /* the host and imp fields will be filled in by the imp */
ee787340
SL
90 sin = (struct sockaddr_in *)&ifp->if_addr;
91 sin->sin_family = AF_INET;
92 sin->sin_addr = if_makeaddr(ifp->if_net, 0);
a2cd4df7
BJ
93 ifp->if_init = impinit;
94 ifp->if_output = impoutput;
95 /* reset is handled at the hardware level */
6c73ade6 96 if_attach(ifp);
6c73ade6
BJ
97 return ((int)&sc->imp_if);
98}
99
100/*
101 * IMP initialization routine: call hardware module to
102 * setup UNIBUS resources, init state and get ready for
103 * NOOPs the IMP should send us, and that we want to drop.
104 */
105impinit(unit)
106 int unit;
107{
98b6195e 108 int s = splimp();
6c73ade6
BJ
109 register struct imp_softc *sc = &imp_softc[unit];
110
98b6195e 111COUNT(IMPINIT);
a2cd4df7
BJ
112 if ((*sc->imp_cb.ic_init)(unit) == 0) {
113 sc->imp_state = IMPS_DOWN;
ee787340 114 sc->imp_if.if_flags &= ~IFF_UP;
98b6195e 115 splx(s);
a2cd4df7
BJ
116 return;
117 }
6c73ade6 118 sc->imp_state = IMPS_INIT;
a2cd4df7 119 impnoops(sc);
a13c006d 120 if_rtinit(&sc->imp_if, RTF_UP);
98b6195e 121 splx(s);
6c73ade6
BJ
122}
123
124struct sockproto impproto = { PF_IMPLINK };
faad37c0
SL
125struct sockaddr_in impdst = { AF_IMPLINK };
126struct sockaddr_in impsrc = { AF_IMPLINK };
7dfb87a5 127int impprintfs = 0;
6c73ade6
BJ
128
129/*
130 * ARPAnet 1822 input routine.
131 * Called from hardware input interrupt routine to handle 1822
132 * IMP-host messages. Type 0 messages (non-control) are
133 * passed to higher level protocol processors on the basis
134 * of link number. Other type messages (control) are handled here.
135 */
a2cd4df7 136impinput(unit, m)
6c73ade6 137 int unit;
a2cd4df7 138 register struct mbuf *m;
6c73ade6 139{
6c73ade6
BJ
140 register struct imp_leader *ip;
141 register struct imp_softc *sc = &imp_softc[unit];
142 register struct host *hp;
143 register struct ifqueue *inq;
a2cd4df7 144 struct control_leader *cp;
6c73ade6 145 struct in_addr addr;
e33b5b1a 146 struct mbuf *next;
ee787340 147 struct sockaddr_in *sin;
6c73ade6 148
5cda82aa 149COUNT(IMPINPUT);
34c22ab5 150 /* verify leader length. */
a2cd4df7
BJ
151 if (m->m_len < sizeof(struct control_leader) &&
152 (m = m_pullup(m, sizeof(struct control_leader))) == 0)
153 return;
154 cp = mtod(m, struct control_leader *);
155 if (cp->dl_mtype == IMPTYPE_DATA)
156 if (m->m_len < sizeof(struct imp_leader) &&
157 (m = m_pullup(m, sizeof(struct imp_leader))) == 0)
158 return;
6c73ade6 159 ip = mtod(m, struct imp_leader *);
7dfb87a5
SL
160 if (impprintfs)
161 printleader("impinput", ip);
6c73ade6 162
34c22ab5 163 /* check leader type */
a2cd4df7
BJ
164 if (ip->il_format != IMP_NFF) {
165 sc->imp_if.if_collisions++; /* XXX */
6c73ade6 166 goto drop;
a2cd4df7 167 }
6c73ade6 168
ba45553a 169 if (ip->il_mtype != IMPTYPE_DATA) {
41e530c7 170#ifdef notdef
a2cd4df7 171 addr.s_net = ip->il_network;
41e530c7 172#else
ba45553a 173 addr.s_net = sc->imp_if.if_net;
41e530c7 174#endif
a2cd4df7
BJ
175 addr.s_imp = ip->il_imp;
176 addr.s_host = ip->il_host;
6c73ade6 177 }
6c73ade6
BJ
178 switch (ip->il_mtype) {
179
6c73ade6 180 case IMPTYPE_DATA:
6c73ade6
BJ
181 break;
182
183 /*
184 * IMP leader error. Reset the IMP and discard the packet.
185 */
186 case IMPTYPE_BADLEADER:
a0b7c7fb
SL
187 /*
188 * According to 1822 document, this message
189 * will be generated in response to the
190 * first noop sent to the IMP after
191 * the host resets the IMP interface.
192 */
a2cd4df7 193 if (sc->imp_state != IMPS_INIT) {
e33b5b1a 194 impmsg(sc, "leader error");
72e4f44e 195 hostreset(sc->imp_if.if_net);
a0b7c7fb
SL
196 impnoops(sc);
197 }
72e4f44e 198 goto drop;
6c73ade6
BJ
199
200 /*
201 * IMP going down. Print message, and if not immediate,
202 * set off a timer to insure things will be reset at the
203 * appropriate time.
204 */
205 case IMPTYPE_DOWN:
f32a85bb 206 if (sc->imp_state < IMPS_INIT)
47e51140 207 goto drop;
6c73ade6
BJ
208 if ((ip->il_link & IMP_DMASK) == 0) {
209 sc->imp_state = IMPS_GOINGDOWN;
668cc26d 210 timeout(impdown, (caddr_t)sc, 30 * hz);
6c73ade6 211 }
668cc26d
SL
212 impmsg(sc, "going down %s",
213 (u_int)impmessage[ip->il_link&IMP_DMASK]);
72e4f44e 214 goto drop;
6c73ade6
BJ
215
216 /*
217 * A NOP usually seen during the initialization sequence.
218 * Compare the local address with that in the message.
219 * Reset the local address notion if it doesn't match.
220 */
ee787340 221 case IMPTYPE_NOOP:
a0b7c7fb
SL
222 if (sc->imp_state == IMPS_DOWN) {
223 sc->imp_state = IMPS_INIT;
224 sc->imp_dropcnt = IMP_DROPCNT;
225 }
98b6195e 226 if (sc->imp_state == IMPS_INIT && --sc->imp_dropcnt > 0)
e431883e 227 goto drop;
98b6195e
SL
228 sin = (struct sockaddr_in *)&sc->imp_if.if_addr;
229 if (sin->sin_addr.s_host != ip->il_host ||
230 sin->sin_addr.s_imp != ip->il_imp) {
231 sc->imp_if.if_host[0] =
232 sin->sin_addr.s_host = ip->il_host;
233 sin->sin_addr.s_imp = ip->il_imp;
234 impmsg(sc, "reset (host %d/imp %d)", (u_int)ip->il_host,
235 ntohs(ip->il_imp));
236 }
a2cd4df7 237 sc->imp_state = IMPS_UP;
ee787340 238 sc->imp_if.if_flags |= IFF_UP;
7dfb87a5 239#ifdef notdef
a2cd4df7 240 /* restart output in case something was q'd */
7dfb87a5
SL
241 if (sc->imp_cb.ic_oactive == 0)
242 (*sc->imp_cb.ic_start)(sc->imp_if.if_unit);
243#endif
e431883e 244 goto drop;
6c73ade6
BJ
245
246 /*
72e4f44e
SL
247 * RFNM or INCOMPLETE message, send next
248 * message on the q. We could pass incomplete's
249 * up to the next level, but this currently isn't
250 * needed.
6c73ade6
BJ
251 */
252 case IMPTYPE_RFNM:
253 case IMPTYPE_INCOMPLETE:
ba45553a
SL
254 if (hp = hostlookup(addr)) {
255 if (hp->h_rfnm == 0)
256 hp->h_flags &= ~HF_INUSE;
257 else if (next = hostdeque(hp))
258 (void) impsnd(&sc->imp_if, next);
259 }
e431883e 260 goto drop;
6c73ade6
BJ
261
262 /*
263 * Host or IMP can't be reached. Flush any packets
264 * awaiting transmission and release the host structure.
6c73ade6
BJ
265 */
266 case IMPTYPE_HOSTDEAD:
ba45553a
SL
267 case IMPTYPE_HOSTUNREACH: {
268 int s = splnet();
269 impnotify(ip->il_mtype, ip, hostlookup(addr));
270 splx(s);
41e530c7 271 goto rawlinkin;
ba45553a 272 }
6c73ade6
BJ
273
274 /*
275 * Error in data. Clear RFNM status for this host and send
276 * noops to the IMP to clear the interface.
277 */
ba45553a
SL
278 case IMPTYPE_BADDATA: {
279 int s;
280
e33b5b1a 281 impmsg(sc, "data error");
ba45553a
SL
282 s = splnet();
283 if (hp = hostlookup(addr))
6c73ade6 284 hp->h_rfnm = 0;
ba45553a 285 splx(s);
6c73ade6 286 impnoops(sc);
72e4f44e 287 goto drop;
ba45553a 288 }
6c73ade6
BJ
289
290 /*
a0b7c7fb 291 * Interface reset.
6c73ade6
BJ
292 */
293 case IMPTYPE_RESET:
e33b5b1a 294 impmsg(sc, "interface reset");
a0b7c7fb 295 impnoops(sc);
72e4f44e 296 goto drop;
6c73ade6
BJ
297
298 default:
299 sc->imp_if.if_collisions++; /* XXX */
72e4f44e 300 goto drop;
6c73ade6
BJ
301 }
302
303 /*
34c22ab5
BJ
304 * Data for a protocol. Dispatch to the appropriate
305 * protocol routine (running at software interrupt).
306 * If this isn't a raw interface, advance pointer
307 * into mbuf past leader.
6c73ade6
BJ
308 */
309 switch (ip->il_link) {
310
311#ifdef INET
312 case IMPLINK_IP:
313 m->m_len -= sizeof(struct imp_leader);
314 m->m_off += sizeof(struct imp_leader);
9c8692e9 315 schednetisr(NETISR_IP);
6c73ade6
BJ
316 inq = &ipintrq;
317 break;
318#endif
319
320 default:
654fef96 321 rawlinkin:
6c73ade6 322 impproto.sp_protocol = ip->il_link;
ee787340
SL
323 sin = (struct sockaddr_in *)&sc->imp_if.if_addr;
324 impdst.sin_addr = sin->sin_addr;;
faad37c0
SL
325 impsrc.sin_addr.s_net = ip->il_network;
326 impsrc.sin_addr.s_host = ip->il_host;
327 impsrc.sin_addr.s_imp = ip->il_imp;
57aa3090
SL
328 raw_input(m, &impproto, (struct sockaddr *)&impsrc,
329 (struct sockaddr *)&impdst);
6c73ade6
BJ
330 return;
331 }
1e977657
BJ
332 if (IF_QFULL(inq)) {
333 IF_DROP(inq);
334 goto drop;
335 }
6c73ade6
BJ
336 IF_ENQUEUE(inq, m);
337 return;
338
339drop:
340 m_freem(m);
341}
342
a0b7c7fb
SL
343/*
344 * Bring the IMP down after notification.
345 */
346impdown(sc)
347 struct imp_softc *sc;
348{
1e977657 349
ba45553a 350COUNT(IMPDOWN);
a0b7c7fb 351 sc->imp_state = IMPS_DOWN;
e33b5b1a 352 impmsg(sc, "marked down");
ba45553a 353 hostreset(sc->imp_if.if_net);
72e4f44e 354 if_down(&sc->imp_if);
a0b7c7fb
SL
355}
356
6c73ade6 357/*VARARGS*/
e33b5b1a 358impmsg(sc, fmt, a1, a2)
6c73ade6
BJ
359 struct imp_softc *sc;
360 char *fmt;
668cc26d 361 u_int a1;
6c73ade6 362{
1e977657 363
ba45553a 364COUNT(IMPMSG);
6c73ade6
BJ
365 printf("imp%d: ", sc->imp_if.if_unit);
366 printf(fmt, a1, a2);
367 printf("\n");
368}
369
72e4f44e
SL
370/*
371 * Process an IMP "error" message, passing this
372 * up to the higher level protocol.
373 */
374impnotify(what, cp, hp)
375 int what;
376 struct control_leader *cp;
377 struct host *hp;
378{
379 struct in_addr in;
380
ba45553a 381COUNT(IMPNOTIFY);
72e4f44e
SL
382#ifdef notdef
383 in.s_net = cp->dl_network;
384#else
ba45553a 385 in.s_net = 10; /* XXX */
72e4f44e
SL
386#endif
387 in.s_host = cp->dl_host;
388 in.s_imp = cp->dl_imp;
389 if (cp->dl_link != IMPLINK_IP)
390 raw_ctlinput(what, (caddr_t)&in);
391 else
392 ip_ctlinput(what, (caddr_t)&in);
ba45553a
SL
393 if (hp) {
394 hp->h_flags |= (1 << what);
72e4f44e 395 hostfree(hp);
ba45553a 396 }
72e4f44e
SL
397}
398
6c73ade6
BJ
399/*
400 * ARPAnet 1822 output routine.
401 * Called from higher level protocol routines to set up messages for
402 * transmission to the imp. Sets up the header and calls impsnd to
403 * enqueue the message for this IMP's hardware driver.
404 */
ee787340 405impoutput(ifp, m0, dst)
6c73ade6
BJ
406 register struct ifnet *ifp;
407 struct mbuf *m0;
ee787340 408 struct sockaddr *dst;
6c73ade6
BJ
409{
410 register struct imp_leader *imp;
411 register struct mbuf *m = m0;
1e63a6ab 412 int x, dhost, dimp, dlink, len, dnet;
8a2f82db 413 int error = 0;
6c73ade6 414
a2cd4df7 415COUNT(IMPOUTPUT);
6c73ade6
BJ
416 /*
417 * Don't even try if the IMP is unavailable.
418 */
8a2f82db
SL
419 if (imp_softc[ifp->if_unit].imp_state != IMPS_UP) {
420 error = ENETDOWN;
a0b7c7fb 421 goto drop;
8a2f82db 422 }
6c73ade6 423
ee787340 424 switch (dst->sa_family) {
6c73ade6
BJ
425
426#ifdef INET
ee787340
SL
427 case AF_INET: {
428 struct ip *ip = mtod(m0, struct ip *);
429 struct sockaddr_in *sin = (struct sockaddr_in *)dst;
6c73ade6 430
ee787340
SL
431 dhost = sin->sin_addr.s_host;
432 dimp = sin->sin_addr.s_impno;
6c73ade6 433 dlink = IMPLINK_IP;
1e63a6ab 434 dnet = 0;
668cc26d 435 len = ntohs((u_short)ip->ip_len);
6c73ade6
BJ
436 break;
437 }
438#endif
ee787340 439 case AF_IMPLINK:
6c73ade6
BJ
440 goto leaderexists;
441
442 default:
ee787340
SL
443 printf("imp%d: can't handle af%d\n", ifp->if_unit,
444 dst->sa_family);
8a2f82db 445 error = EAFNOSUPPORT;
a0b7c7fb 446 goto drop;
6c73ade6
BJ
447 }
448
449 /*
450 * Add IMP leader. If there's not enough space in the
451 * first mbuf, allocate another. If that should fail, we
452 * drop this sucker.
453 */
454 if (m->m_off > MMAXOFF ||
455 MMINOFF + sizeof(struct imp_leader) > m->m_off) {
456 m = m_get(M_DONTWAIT);
8a2f82db
SL
457 if (m == 0) {
458 error = ENOBUFS;
a0b7c7fb 459 goto drop;
8a2f82db 460 }
6c73ade6
BJ
461 m->m_next = m0;
462 m->m_off = MMINOFF;
463 m->m_len = sizeof(struct imp_leader);
464 } else {
465 m->m_off -= sizeof(struct imp_leader);
466 m->m_len += sizeof(struct imp_leader);
467 }
468 imp = mtod(m, struct imp_leader *);
469 imp->il_format = IMP_NFF;
41e530c7 470 imp->il_mtype = IMPTYPE_DATA;
1e63a6ab 471 imp->il_network = dnet;
6c73ade6 472 imp->il_host = dhost;
1e63a6ab 473 imp->il_imp = htons((u_short)dimp);
668cc26d
SL
474 imp->il_length =
475 htons((u_short)(len + sizeof(struct imp_leader)) << 3);
6c73ade6 476 imp->il_link = dlink;
41e530c7 477 imp->il_flags = imp->il_htype = imp->il_subtype = 0;
6c73ade6
BJ
478
479leaderexists:
6c73ade6 480 return (impsnd(ifp, m));
a0b7c7fb
SL
481drop:
482 m_freem(m0);
8a2f82db 483 return (error);
6c73ade6
BJ
484}
485
486/*
487 * Put a message on an interface's output queue.
488 * Perform RFNM counting: no more than 8 message may be
489 * in flight to any one host.
490 */
491impsnd(ifp, m)
492 struct ifnet *ifp;
493 struct mbuf *m;
494{
495 register struct imp_leader *ip;
496 register struct host *hp;
497 struct impcb *icp;
ba45553a 498 int s, error;
6c73ade6 499
a2cd4df7 500COUNT(IMPSND);
6c73ade6
BJ
501 ip = mtod(m, struct imp_leader *);
502
503 /*
504 * Do RFNM counting for data messages
505 * (no more than 8 outstanding to any host)
506 */
ba45553a 507 s = splimp();
6c73ade6
BJ
508 if (ip->il_mtype == IMPTYPE_DATA) {
509 struct in_addr addr;
510
41e530c7 511#ifdef notdef
a2cd4df7 512 addr.s_net = ip->il_network;
41e530c7 513#else
ba45553a 514 addr.s_net = ifp->if_net; /* XXX */
41e530c7 515#endif
6c73ade6
BJ
516 addr.s_host = ip->il_host;
517 addr.s_imp = ip->il_imp;
a2cd4df7
BJ
518 if ((hp = hostlookup(addr)) == 0)
519 hp = hostenter(addr);
ba45553a 520 if (hp && (hp->h_flags & (HF_DEAD|HF_UNREACH))) {
67387c9c 521 error = hp->h_flags&HF_DEAD ? EHOSTDOWN : EHOSTUNREACH;
ba45553a
SL
522 hp->h_timer = HOSTTIMER;
523 hp->h_flags &= ~HF_INUSE;
524 goto bad;
ba45553a 525 }
6c73ade6
BJ
526
527 /*
a0b7c7fb 528 * If IMP would block, queue until RFNM
6c73ade6
BJ
529 */
530 if (hp) {
6c73ade6
BJ
531 if (hp->h_rfnm < 8) {
532 hp->h_rfnm++;
533 goto enque;
534 }
fcd78660
BJ
535 if (hp->h_qcnt < 8) { /* high water mark */
536 HOST_ENQUE(hp, m);
537 goto start;
538 }
6c73ade6 539 }
ba45553a
SL
540 error = ENOBUFS;
541 goto bad;
6c73ade6
BJ
542 }
543enque:
1e977657
BJ
544 if (IF_QFULL(&ifp->if_snd)) {
545 IF_DROP(&ifp->if_snd);
ba45553a
SL
546 error = ENOBUFS;
547bad:
1e977657 548 m_freem(m);
ba45553a
SL
549 splx(s);
550 return (error);
1e977657 551 }
6c73ade6 552 IF_ENQUEUE(&ifp->if_snd, m);
6c73ade6
BJ
553start:
554 icp = &imp_softc[ifp->if_unit].imp_cb;
555 if (icp->ic_oactive == 0)
556 (*icp->ic_start)(ifp->if_unit);
70e3101c 557 splx(s);
8a2f82db 558 return (0);
6c73ade6
BJ
559}
560
561/*
562 * Put three 1822 NOOPs at the head of the output queue.
563 * Part of host-IMP initialization procedure.
564 * (Should return success/failure, but noone knows
565 * what to do with this, so why bother?)
0dc78444
SL
566 * This routine is always called at splimp, so we don't
567 * protect the call to IF_PREPEND.
6c73ade6
BJ
568 */
569impnoops(sc)
570 register struct imp_softc *sc;
571{
572 register i;
573 register struct mbuf *m;
a2cd4df7 574 register struct control_leader *cp;
6c73ade6
BJ
575 int x;
576
a2cd4df7 577COUNT(IMPNOOPS);
6c73ade6 578 sc->imp_dropcnt = IMP_DROPCNT;
a2cd4df7 579 for (i = 0; i < IMP_DROPCNT + 1; i++ ) {
6c73ade6
BJ
580 if ((m = m_getclr(M_DONTWAIT)) == 0)
581 return;
582 m->m_off = MMINOFF;
a2cd4df7
BJ
583 m->m_len = sizeof(struct control_leader);
584 cp = mtod(m, struct control_leader *);
585 cp->dl_format = IMP_NFF;
586 cp->dl_link = i;
587 cp->dl_mtype = IMPTYPE_NOOP;
6c73ade6 588 IF_PREPEND(&sc->imp_if.if_snd, m);
6c73ade6
BJ
589 }
590 if (sc->imp_cb.ic_oactive == 0)
591 (*sc->imp_cb.ic_start)(sc->imp_if.if_unit);
592}
7dfb87a5
SL
593
594#ifdef IMPLEADERS
595printleader(routine, ip)
596 char *routine;
597 register struct imp_leader *ip;
598{
599 printf("%s: ", routine);
600 printbyte((char *)ip, 12);
601 printf("<fmt=%x,net=%x,flags=%x,mtype=", ip->il_format, ip->il_network,
602 ip->il_flags);
603 if (ip->il_mtype <= IMPTYPE_READY)
604 printf("%s,", impleaders[ip->il_mtype]);
605 else
606 printf("%x,", ip->il_mtype);
607 printf("htype=%x,host=%x,imp=%x,link=", ip->il_htype, ip->il_host,
608 ntohs(ip->il_imp));
609 if (ip->il_link == IMPLINK_IP)
610 printf("ip,");
611 else
612 printf("%x,", ip->il_link);
613 printf("subtype=%x,len=%x>\n",ip->il_subtype,ntohs(ip->il_length)>>3);
614}
615
616printbyte(cp, n)
617 register char *cp;
618 int n;
619{
620 register i, j, c;
621
622 for (i=0; i<n; i++) {
623 c = *cp++;
624 for (j=0; j<2; j++)
625 putchar("0123456789abcdef"[(c>>((1-j)*4))&0xf]);
626 putchar(' ');
627 }
628 putchar('\n');
629}
630#endif
41e530c7 631#endif