]> The Tcpdump Group git mirrors - tcpdump/blob - print-ip.c
Use more the EXTRACT_U_1() macro (53/n)
[tcpdump] / print-ip.c
1 /*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22 /* \summary: IP printer */
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <netdissect-stdinc.h>
29
30 #include <string.h>
31
32 #include "netdissect.h"
33 #include "addrtoname.h"
34 #include "extract.h"
35
36 #include "ip.h"
37 #include "ipproto.h"
38
39 static const char tstr[] = "[|ip]";
40
41 static const struct tok ip_option_values[] = {
42 { IPOPT_EOL, "EOL" },
43 { IPOPT_NOP, "NOP" },
44 { IPOPT_TS, "timestamp" },
45 { IPOPT_SECURITY, "security" },
46 { IPOPT_RR, "RR" },
47 { IPOPT_SSRR, "SSRR" },
48 { IPOPT_LSRR, "LSRR" },
49 { IPOPT_RA, "RA" },
50 { IPOPT_RFC1393, "traceroute" },
51 { 0, NULL }
52 };
53
54 /*
55 * print the recorded route in an IP RR, LSRR or SSRR option.
56 */
57 static int
58 ip_printroute(netdissect_options *ndo,
59 register const u_char *cp, u_int length)
60 {
61 register u_int ptr;
62 register u_int len;
63
64 if (length < 3) {
65 ND_PRINT((ndo, " [bad length %u]", length));
66 return (0);
67 }
68 if ((length + 1) & 3)
69 ND_PRINT((ndo, " [bad length %u]", length));
70 ND_TCHECK_1(cp + 2);
71 ptr = EXTRACT_U_1(cp + 2) - 1;
72 if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
73 ND_PRINT((ndo, " [bad ptr %u]", EXTRACT_U_1(cp + 2)));
74
75 for (len = 3; len < length; len += 4) {
76 ND_TCHECK_4(cp + len);
77 ND_PRINT((ndo, " %s", ipaddr_string(ndo, cp + len)));
78 if (ptr > len)
79 ND_PRINT((ndo, ","));
80 }
81 return (0);
82
83 trunc:
84 return (-1);
85 }
86
87 /*
88 * If source-routing is present and valid, return the final destination.
89 * Otherwise, return IP destination.
90 *
91 * This is used for UDP and TCP pseudo-header in the checksum
92 * calculation.
93 */
94 static uint32_t
95 ip_finddst(netdissect_options *ndo,
96 const struct ip *ip)
97 {
98 int length;
99 int len;
100 const u_char *cp;
101 uint32_t retval;
102
103 cp = (const u_char *)(ip + 1);
104 length = (IP_HL(ip) << 2) - sizeof(struct ip);
105
106 for (; length > 0; cp += len, length -= len) {
107 int tt;
108
109 ND_TCHECK_1(cp);
110 tt = EXTRACT_U_1(cp);
111 if (tt == IPOPT_EOL)
112 break;
113 else if (tt == IPOPT_NOP)
114 len = 1;
115 else {
116 ND_TCHECK_1(cp + 1);
117 len = EXTRACT_U_1(cp + 1);
118 if (len < 2)
119 break;
120 }
121 ND_TCHECK2(*cp, len);
122 switch (tt) {
123
124 case IPOPT_SSRR:
125 case IPOPT_LSRR:
126 if (len < 7)
127 break;
128 UNALIGNED_MEMCPY(&retval, cp + len - 4, 4);
129 return retval;
130 }
131 }
132 trunc:
133 UNALIGNED_MEMCPY(&retval, &ip->ip_dst, sizeof(uint32_t));
134 return retval;
135 }
136
137 /*
138 * Compute a V4-style checksum by building a pseudoheader.
139 */
140 int
141 nextproto4_cksum(netdissect_options *ndo,
142 const struct ip *ip, const uint8_t *data,
143 u_int len, u_int covlen, u_int next_proto)
144 {
145 struct phdr {
146 uint32_t src;
147 uint32_t dst;
148 u_char mbz;
149 u_char proto;
150 uint16_t len;
151 } ph;
152 struct cksum_vec vec[2];
153
154 /* pseudo-header.. */
155 ph.len = htons((uint16_t)len);
156 ph.mbz = 0;
157 ph.proto = next_proto;
158 UNALIGNED_MEMCPY(&ph.src, &ip->ip_src, sizeof(uint32_t));
159 if (IP_HL(ip) == 5)
160 UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst, sizeof(uint32_t));
161 else
162 ph.dst = ip_finddst(ndo, ip);
163
164 vec[0].ptr = (const uint8_t *)(void *)&ph;
165 vec[0].len = sizeof(ph);
166 vec[1].ptr = data;
167 vec[1].len = covlen;
168 return (in_cksum(vec, 2));
169 }
170
171 static int
172 ip_printts(netdissect_options *ndo,
173 register const u_char *cp, u_int length)
174 {
175 register u_int ptr;
176 register u_int len;
177 int hoplen;
178 const char *type;
179
180 if (length < 4) {
181 ND_PRINT((ndo, "[bad length %u]", length));
182 return (0);
183 }
184 ND_PRINT((ndo, " TS{"));
185 ND_TCHECK_1(cp + 3);
186 hoplen = ((EXTRACT_U_1(cp + 3) & 0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
187 if ((length - 4) & (hoplen-1))
188 ND_PRINT((ndo, "[bad length %u]", length));
189 ND_TCHECK_1(cp + 2);
190 ptr = EXTRACT_U_1(cp + 2) - 1;
191 len = 0;
192 if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
193 ND_PRINT((ndo, "[bad ptr %u]", EXTRACT_U_1(cp + 2)));
194 ND_TCHECK_1(cp + 3);
195 switch (EXTRACT_U_1(cp + 3)&0xF) {
196 case IPOPT_TS_TSONLY:
197 ND_PRINT((ndo, "TSONLY"));
198 break;
199 case IPOPT_TS_TSANDADDR:
200 ND_PRINT((ndo, "TS+ADDR"));
201 break;
202 /*
203 * prespecified should really be 3, but some ones might send 2
204 * instead, and the IPOPT_TS_PRESPEC constant can apparently
205 * have both values, so we have to hard-code it here.
206 */
207
208 case 2:
209 ND_PRINT((ndo, "PRESPEC2.0"));
210 break;
211 case 3: /* IPOPT_TS_PRESPEC */
212 ND_PRINT((ndo, "PRESPEC"));
213 break;
214 default:
215 ND_PRINT((ndo, "[bad ts type %d]", EXTRACT_U_1(cp + 3)&0xF));
216 goto done;
217 }
218
219 type = " ";
220 for (len = 4; len < length; len += hoplen) {
221 if (ptr == len)
222 type = " ^ ";
223 ND_TCHECK2(cp[len], hoplen);
224 ND_PRINT((ndo, "%s%d@%s", type, EXTRACT_BE_U_4(cp + len + hoplen - 4),
225 hoplen!=8 ? "" : ipaddr_string(ndo, cp + len)));
226 type = " ";
227 }
228
229 done:
230 ND_PRINT((ndo, "%s", ptr == len ? " ^ " : ""));
231
232 if (EXTRACT_U_1(cp + 3) >> 4)
233 ND_PRINT((ndo, " [%d hops not recorded]} ", EXTRACT_U_1(cp + 3)>>4));
234 else
235 ND_PRINT((ndo, "}"));
236 return (0);
237
238 trunc:
239 return (-1);
240 }
241
242 /*
243 * print IP options.
244 */
245 static void
246 ip_optprint(netdissect_options *ndo,
247 register const u_char *cp, u_int length)
248 {
249 register u_int option_len;
250 const char *sep = "";
251
252 for (; length > 0; cp += option_len, length -= option_len) {
253 u_int option_code;
254
255 ND_PRINT((ndo, "%s", sep));
256 sep = ",";
257
258 ND_TCHECK_1(cp);
259 option_code = EXTRACT_U_1(cp);
260
261 ND_PRINT((ndo, "%s",
262 tok2str(ip_option_values,"unknown %u",option_code)));
263
264 if (option_code == IPOPT_NOP ||
265 option_code == IPOPT_EOL)
266 option_len = 1;
267
268 else {
269 ND_TCHECK_1(cp + 1);
270 option_len = EXTRACT_U_1(cp + 1);
271 if (option_len < 2) {
272 ND_PRINT((ndo, " [bad length %u]", option_len));
273 return;
274 }
275 }
276
277 if (option_len > length) {
278 ND_PRINT((ndo, " [bad length %u]", option_len));
279 return;
280 }
281
282 ND_TCHECK2(*cp, option_len);
283
284 switch (option_code) {
285 case IPOPT_EOL:
286 return;
287
288 case IPOPT_TS:
289 if (ip_printts(ndo, cp, option_len) == -1)
290 goto trunc;
291 break;
292
293 case IPOPT_RR: /* fall through */
294 case IPOPT_SSRR:
295 case IPOPT_LSRR:
296 if (ip_printroute(ndo, cp, option_len) == -1)
297 goto trunc;
298 break;
299
300 case IPOPT_RA:
301 if (option_len < 4) {
302 ND_PRINT((ndo, " [bad length %u]", option_len));
303 break;
304 }
305 ND_TCHECK_1(cp + 3);
306 if (EXTRACT_BE_U_2(cp + 2) != 0)
307 ND_PRINT((ndo, " value %u", EXTRACT_BE_U_2(cp + 2)));
308 break;
309
310 case IPOPT_NOP: /* nothing to print - fall through */
311 case IPOPT_SECURITY:
312 default:
313 break;
314 }
315 }
316 return;
317
318 trunc:
319 ND_PRINT((ndo, "%s", tstr));
320 }
321
322 #define IP_RES 0x8000
323
324 static const struct tok ip_frag_values[] = {
325 { IP_MF, "+" },
326 { IP_DF, "DF" },
327 { IP_RES, "rsvd" }, /* The RFC3514 evil ;-) bit */
328 { 0, NULL }
329 };
330
331 struct ip_print_demux_state {
332 const struct ip *ip;
333 const u_char *cp;
334 u_int len, off;
335 u_char nh;
336 int advance;
337 };
338
339 static void
340 ip_print_demux(netdissect_options *ndo,
341 struct ip_print_demux_state *ipds)
342 {
343 const char *p_name;
344
345 again:
346 switch (ipds->nh) {
347
348 case IPPROTO_AH:
349 if (!ND_TTEST(*ipds->cp)) {
350 ND_PRINT((ndo, "[|AH]"));
351 break;
352 }
353 ipds->nh = EXTRACT_U_1(ipds->cp);
354 ipds->advance = ah_print(ndo, ipds->cp);
355 if (ipds->advance <= 0)
356 break;
357 ipds->cp += ipds->advance;
358 ipds->len -= ipds->advance;
359 goto again;
360
361 case IPPROTO_ESP:
362 {
363 u_int enh, padlen;
364 ipds->advance = esp_print(ndo, ipds->cp, ipds->len,
365 (const u_char *)ipds->ip,
366 &enh, &padlen);
367 if (ipds->advance <= 0)
368 break;
369 ipds->cp += ipds->advance;
370 ipds->len -= ipds->advance + padlen;
371 ipds->nh = enh & 0xff;
372 goto again;
373 }
374
375 case IPPROTO_IPCOMP:
376 {
377 ipcomp_print(ndo, ipds->cp);
378 /*
379 * Either this has decompressed the payload and
380 * printed it, in which case there's nothing more
381 * to do, or it hasn't, in which case there's
382 * nothing more to do.
383 */
384 break;
385 }
386
387 case IPPROTO_SCTP:
388 sctp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
389 break;
390
391 case IPPROTO_DCCP:
392 dccp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
393 break;
394
395 case IPPROTO_TCP:
396 /* pass on the MF bit plus the offset to detect fragments */
397 tcp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
398 ipds->off & (IP_MF|IP_OFFMASK));
399 break;
400
401 case IPPROTO_UDP:
402 /* pass on the MF bit plus the offset to detect fragments */
403 udp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
404 ipds->off & (IP_MF|IP_OFFMASK));
405 break;
406
407 case IPPROTO_ICMP:
408 /* pass on the MF bit plus the offset to detect fragments */
409 icmp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
410 ipds->off & (IP_MF|IP_OFFMASK));
411 break;
412
413 case IPPROTO_PIGP:
414 /*
415 * XXX - the current IANA protocol number assignments
416 * page lists 9 as "any private interior gateway
417 * (used by Cisco for their IGRP)" and 88 as
418 * "EIGRP" from Cisco.
419 *
420 * Recent BSD <netinet/in.h> headers define
421 * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
422 * We define IP_PROTO_PIGP as 9 and
423 * IP_PROTO_EIGRP as 88; those names better
424 * match was the current protocol number
425 * assignments say.
426 */
427 igrp_print(ndo, ipds->cp, ipds->len);
428 break;
429
430 case IPPROTO_EIGRP:
431 eigrp_print(ndo, ipds->cp, ipds->len);
432 break;
433
434 case IPPROTO_ND:
435 ND_PRINT((ndo, " nd %d", ipds->len));
436 break;
437
438 case IPPROTO_EGP:
439 egp_print(ndo, ipds->cp, ipds->len);
440 break;
441
442 case IPPROTO_OSPF:
443 ospf_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
444 break;
445
446 case IPPROTO_IGMP:
447 igmp_print(ndo, ipds->cp, ipds->len);
448 break;
449
450 case IPPROTO_IPV4:
451 /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
452 ip_print(ndo, ipds->cp, ipds->len);
453 if (! ndo->ndo_vflag) {
454 ND_PRINT((ndo, " (ipip-proto-4)"));
455 return;
456 }
457 break;
458
459 case IPPROTO_IPV6:
460 /* ip6-in-ip encapsulation */
461 ip6_print(ndo, ipds->cp, ipds->len);
462 break;
463
464 case IPPROTO_RSVP:
465 rsvp_print(ndo, ipds->cp, ipds->len);
466 break;
467
468 case IPPROTO_GRE:
469 /* do it */
470 gre_print(ndo, ipds->cp, ipds->len);
471 break;
472
473 case IPPROTO_MOBILE:
474 mobile_print(ndo, ipds->cp, ipds->len);
475 break;
476
477 case IPPROTO_PIM:
478 pim_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
479 break;
480
481 case IPPROTO_VRRP:
482 if (ndo->ndo_packettype == PT_CARP) {
483 if (ndo->ndo_vflag)
484 ND_PRINT((ndo, "carp %s > %s: ",
485 ipaddr_string(ndo, &ipds->ip->ip_src),
486 ipaddr_string(ndo, &ipds->ip->ip_dst)));
487 carp_print(ndo, ipds->cp, ipds->len, ipds->ip->ip_ttl);
488 } else {
489 if (ndo->ndo_vflag)
490 ND_PRINT((ndo, "vrrp %s > %s: ",
491 ipaddr_string(ndo, &ipds->ip->ip_src),
492 ipaddr_string(ndo, &ipds->ip->ip_dst)));
493 vrrp_print(ndo, ipds->cp, ipds->len,
494 (const u_char *)ipds->ip, ipds->ip->ip_ttl);
495 }
496 break;
497
498 case IPPROTO_PGM:
499 pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
500 break;
501
502 default:
503 if (ndo->ndo_nflag==0 && (p_name = netdb_protoname(ipds->nh)) != NULL)
504 ND_PRINT((ndo, " %s", p_name));
505 else
506 ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
507 ND_PRINT((ndo, " %d", ipds->len));
508 break;
509 }
510 }
511
512 void
513 ip_print_inner(netdissect_options *ndo,
514 const u_char *bp,
515 u_int length, u_int nh,
516 const u_char *bp2)
517 {
518 struct ip_print_demux_state ipd;
519
520 ipd.ip = (const struct ip *)bp2;
521 ipd.cp = bp;
522 ipd.len = length;
523 ipd.off = 0;
524 ipd.nh = nh;
525 ipd.advance = 0;
526
527 ip_print_demux(ndo, &ipd);
528 }
529
530
531 /*
532 * print an IP datagram.
533 */
534 void
535 ip_print(netdissect_options *ndo,
536 const u_char *bp,
537 u_int length)
538 {
539 struct ip_print_demux_state ipd;
540 struct ip_print_demux_state *ipds=&ipd;
541 const u_char *ipend;
542 u_int hlen;
543 struct cksum_vec vec[1];
544 uint16_t sum, ip_sum;
545 const char *p_name;
546
547 ipds->ip = (const struct ip *)bp;
548 ND_TCHECK(ipds->ip->ip_vhl);
549 if (IP_V(ipds->ip) != 4) { /* print version and fail if != 4 */
550 if (IP_V(ipds->ip) == 6)
551 ND_PRINT((ndo, "IP6, wrong link-layer encapsulation "));
552 else
553 ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
554 return;
555 }
556 if (!ndo->ndo_eflag)
557 ND_PRINT((ndo, "IP "));
558
559 ND_TCHECK(*ipds->ip);
560 if (length < sizeof (struct ip)) {
561 ND_PRINT((ndo, "truncated-ip %u", length));
562 return;
563 }
564 hlen = IP_HL(ipds->ip) * 4;
565 if (hlen < sizeof (struct ip)) {
566 ND_PRINT((ndo, "bad-hlen %u", hlen));
567 return;
568 }
569
570 ipds->len = EXTRACT_BE_U_2(&ipds->ip->ip_len);
571 if (length < ipds->len)
572 ND_PRINT((ndo, "truncated-ip - %u bytes missing! ",
573 ipds->len - length));
574 if (ipds->len < hlen) {
575 #ifdef GUESS_TSO
576 if (ipds->len) {
577 ND_PRINT((ndo, "bad-len %u", ipds->len));
578 return;
579 }
580 else {
581 /* we guess that it is a TSO send */
582 ipds->len = length;
583 }
584 #else
585 ND_PRINT((ndo, "bad-len %u", ipds->len));
586 return;
587 #endif /* GUESS_TSO */
588 }
589
590 /*
591 * Cut off the snapshot length to the end of the IP payload.
592 */
593 ipend = bp + ipds->len;
594 if (ipend < ndo->ndo_snapend)
595 ndo->ndo_snapend = ipend;
596
597 ipds->len -= hlen;
598
599 ipds->off = EXTRACT_BE_U_2(&ipds->ip->ip_off);
600
601 if (ndo->ndo_vflag) {
602 ND_PRINT((ndo, "(tos 0x%x", ipds->ip->ip_tos));
603 /* ECN bits */
604 switch (ipds->ip->ip_tos & 0x03) {
605
606 case 0:
607 break;
608
609 case 1:
610 ND_PRINT((ndo, ",ECT(1)"));
611 break;
612
613 case 2:
614 ND_PRINT((ndo, ",ECT(0)"));
615 break;
616
617 case 3:
618 ND_PRINT((ndo, ",CE"));
619 break;
620 }
621
622 if (ipds->ip->ip_ttl >= 1)
623 ND_PRINT((ndo, ", ttl %u", ipds->ip->ip_ttl));
624
625 /*
626 * for the firewall guys, print id, offset.
627 * On all but the last stick a "+" in the flags portion.
628 * For unfragmented datagrams, note the don't fragment flag.
629 */
630
631 ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
632 EXTRACT_BE_U_2(&ipds->ip->ip_id),
633 (ipds->off & 0x1fff) * 8,
634 bittok2str(ip_frag_values, "none", ipds->off&0xe000),
635 tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
636 ipds->ip->ip_p));
637
638 ND_PRINT((ndo, ", length %u", EXTRACT_BE_U_2(&ipds->ip->ip_len)));
639
640 if ((hlen - sizeof(struct ip)) > 0) {
641 ND_PRINT((ndo, ", options ("));
642 ip_optprint(ndo, (const u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
643 ND_PRINT((ndo, ")"));
644 }
645
646 if (!ndo->ndo_Kflag && (const u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
647 vec[0].ptr = (const uint8_t *)(const void *)ipds->ip;
648 vec[0].len = hlen;
649 sum = in_cksum(vec, 1);
650 if (sum != 0) {
651 ip_sum = EXTRACT_BE_U_2(&ipds->ip->ip_sum);
652 ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
653 in_cksum_shouldbe(ip_sum, sum)));
654 }
655 }
656
657 ND_PRINT((ndo, ")\n "));
658 }
659
660 /*
661 * If this is fragment zero, hand it to the next higher
662 * level protocol.
663 */
664 if ((ipds->off & 0x1fff) == 0) {
665 ipds->cp = (const u_char *)ipds->ip + hlen;
666 ipds->nh = ipds->ip->ip_p;
667
668 if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
669 ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) {
670 ND_PRINT((ndo, "%s > %s: ",
671 ipaddr_string(ndo, &ipds->ip->ip_src),
672 ipaddr_string(ndo, &ipds->ip->ip_dst)));
673 }
674 ip_print_demux(ndo, ipds);
675 } else {
676 /*
677 * Ultra quiet now means that all this stuff should be
678 * suppressed.
679 */
680 if (ndo->ndo_qflag > 1)
681 return;
682
683 /*
684 * This isn't the first frag, so we're missing the
685 * next level protocol header. print the ip addr
686 * and the protocol.
687 */
688 ND_PRINT((ndo, "%s > %s:", ipaddr_string(ndo, &ipds->ip->ip_src),
689 ipaddr_string(ndo, &ipds->ip->ip_dst)));
690 if (!ndo->ndo_nflag && (p_name = netdb_protoname(ipds->ip->ip_p)) != NULL)
691 ND_PRINT((ndo, " %s", p_name));
692 else
693 ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
694 }
695 return;
696
697 trunc:
698 ND_PRINT((ndo, "%s", tstr));
699 return;
700 }
701
702 void
703 ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
704 {
705 if (length < 1) {
706 ND_PRINT((ndo, "truncated-ip %d", length));
707 return;
708 }
709
710 ND_TCHECK_1(bp);
711 switch (EXTRACT_U_1(bp) & 0xF0) {
712 case 0x40:
713 ip_print (ndo, bp, length);
714 break;
715 case 0x60:
716 ip6_print (ndo, bp, length);
717 break;
718 default:
719 ND_PRINT((ndo, "unknown ip %d", (EXTRACT_U_1(bp) & 0xF0) >> 4));
720 break;
721 }
722 return;
723
724 trunc:
725 ND_PRINT((ndo, "%s", tstr));
726 return;
727 }
728
729 /*
730 * Local Variables:
731 * c-style: whitesmith
732 * c-basic-offset: 8
733 * End:
734 */
735
736