]> The Tcpdump Group git mirrors - tcpdump/blob - print-ip.c
Make nd_uint8_t and nd_int8_t arrays, to catch direct references.
[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,
488 EXTRACT_U_1(ipds->ip->ip_ttl));
489 } else {
490 if (ndo->ndo_vflag)
491 ND_PRINT((ndo, "vrrp %s > %s: ",
492 ipaddr_string(ndo, &ipds->ip->ip_src),
493 ipaddr_string(ndo, &ipds->ip->ip_dst)));
494 vrrp_print(ndo, ipds->cp, ipds->len,
495 (const u_char *)ipds->ip,
496 EXTRACT_U_1(ipds->ip->ip_ttl));
497 }
498 break;
499
500 case IPPROTO_PGM:
501 pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
502 break;
503
504 default:
505 if (ndo->ndo_nflag==0 && (p_name = netdb_protoname(ipds->nh)) != NULL)
506 ND_PRINT((ndo, " %s", p_name));
507 else
508 ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
509 ND_PRINT((ndo, " %d", ipds->len));
510 break;
511 }
512 }
513
514 void
515 ip_print_inner(netdissect_options *ndo,
516 const u_char *bp,
517 u_int length, u_int nh,
518 const u_char *bp2)
519 {
520 struct ip_print_demux_state ipd;
521
522 ipd.ip = (const struct ip *)bp2;
523 ipd.cp = bp;
524 ipd.len = length;
525 ipd.off = 0;
526 ipd.nh = nh;
527 ipd.advance = 0;
528
529 ip_print_demux(ndo, &ipd);
530 }
531
532
533 /*
534 * print an IP datagram.
535 */
536 void
537 ip_print(netdissect_options *ndo,
538 const u_char *bp,
539 u_int length)
540 {
541 struct ip_print_demux_state ipd;
542 struct ip_print_demux_state *ipds=&ipd;
543 const u_char *ipend;
544 u_int hlen;
545 struct cksum_vec vec[1];
546 uint8_t ip_tos, ip_ttl, ip_proto;
547 uint16_t sum, ip_sum;
548 const char *p_name;
549
550 ipds->ip = (const struct ip *)bp;
551 ND_TCHECK(ipds->ip->ip_vhl);
552 if (IP_V(ipds->ip) != 4) { /* print version and fail if != 4 */
553 if (IP_V(ipds->ip) == 6)
554 ND_PRINT((ndo, "IP6, wrong link-layer encapsulation "));
555 else
556 ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
557 return;
558 }
559 if (!ndo->ndo_eflag)
560 ND_PRINT((ndo, "IP "));
561
562 ND_TCHECK(*ipds->ip);
563 if (length < sizeof (struct ip)) {
564 ND_PRINT((ndo, "truncated-ip %u", length));
565 return;
566 }
567 hlen = IP_HL(ipds->ip) * 4;
568 if (hlen < sizeof (struct ip)) {
569 ND_PRINT((ndo, "bad-hlen %u", hlen));
570 return;
571 }
572
573 ipds->len = EXTRACT_BE_U_2(&ipds->ip->ip_len);
574 if (length < ipds->len)
575 ND_PRINT((ndo, "truncated-ip - %u bytes missing! ",
576 ipds->len - length));
577 if (ipds->len < hlen) {
578 #ifdef GUESS_TSO
579 if (ipds->len) {
580 ND_PRINT((ndo, "bad-len %u", ipds->len));
581 return;
582 }
583 else {
584 /* we guess that it is a TSO send */
585 ipds->len = length;
586 }
587 #else
588 ND_PRINT((ndo, "bad-len %u", ipds->len));
589 return;
590 #endif /* GUESS_TSO */
591 }
592
593 /*
594 * Cut off the snapshot length to the end of the IP payload.
595 */
596 ipend = bp + ipds->len;
597 if (ipend < ndo->ndo_snapend)
598 ndo->ndo_snapend = ipend;
599
600 ipds->len -= hlen;
601
602 ipds->off = EXTRACT_BE_U_2(&ipds->ip->ip_off);
603
604 ip_proto = EXTRACT_U_1(ipds->ip->ip_p);
605
606 if (ndo->ndo_vflag) {
607 ip_tos = EXTRACT_U_1(ipds->ip->ip_tos);
608 ND_PRINT((ndo, "(tos 0x%x", ip_tos));
609 /* ECN bits */
610 switch (ip_tos & 0x03) {
611
612 case 0:
613 break;
614
615 case 1:
616 ND_PRINT((ndo, ",ECT(1)"));
617 break;
618
619 case 2:
620 ND_PRINT((ndo, ",ECT(0)"));
621 break;
622
623 case 3:
624 ND_PRINT((ndo, ",CE"));
625 break;
626 }
627
628 ip_ttl = EXTRACT_U_1(ipds->ip->ip_ttl);
629 if (ip_ttl >= 1)
630 ND_PRINT((ndo, ", ttl %u", ip_ttl));
631
632 /*
633 * for the firewall guys, print id, offset.
634 * On all but the last stick a "+" in the flags portion.
635 * For unfragmented datagrams, note the don't fragment flag.
636 */
637 ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
638 EXTRACT_BE_U_2(&ipds->ip->ip_id),
639 (ipds->off & 0x1fff) * 8,
640 bittok2str(ip_frag_values, "none", ipds->off&0xe000),
641 tok2str(ipproto_values, "unknown", ip_proto),
642 ip_proto));
643
644 ND_PRINT((ndo, ", length %u", EXTRACT_BE_U_2(ipds->ip->ip_len)));
645
646 if ((hlen - sizeof(struct ip)) > 0) {
647 ND_PRINT((ndo, ", options ("));
648 ip_optprint(ndo, (const u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
649 ND_PRINT((ndo, ")"));
650 }
651
652 if (!ndo->ndo_Kflag && (const u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
653 vec[0].ptr = (const uint8_t *)(const void *)ipds->ip;
654 vec[0].len = hlen;
655 sum = in_cksum(vec, 1);
656 if (sum != 0) {
657 ip_sum = EXTRACT_BE_U_2(ipds->ip->ip_sum);
658 ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
659 in_cksum_shouldbe(ip_sum, sum)));
660 }
661 }
662
663 ND_PRINT((ndo, ")\n "));
664 }
665
666 /*
667 * If this is fragment zero, hand it to the next higher
668 * level protocol.
669 */
670 if ((ipds->off & 0x1fff) == 0) {
671 ipds->cp = (const u_char *)ipds->ip + hlen;
672 ipds->nh = EXTRACT_U_1(ipds->ip->ip_p);
673
674 if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
675 ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) {
676 ND_PRINT((ndo, "%s > %s: ",
677 ipaddr_string(ndo, &ipds->ip->ip_src),
678 ipaddr_string(ndo, &ipds->ip->ip_dst)));
679 }
680 ip_print_demux(ndo, ipds);
681 } else {
682 /*
683 * Ultra quiet now means that all this stuff should be
684 * suppressed.
685 */
686 if (ndo->ndo_qflag > 1)
687 return;
688
689 /*
690 * This isn't the first frag, so we're missing the
691 * next level protocol header. print the ip addr
692 * and the protocol.
693 */
694 ND_PRINT((ndo, "%s > %s:", ipaddr_string(ndo, &ipds->ip->ip_src),
695 ipaddr_string(ndo, &ipds->ip->ip_dst)));
696 if (!ndo->ndo_nflag && (p_name = netdb_protoname(ip_proto)) != NULL)
697 ND_PRINT((ndo, " %s", p_name));
698 else
699 ND_PRINT((ndo, " ip-proto-%u", ip_proto));
700 }
701 return;
702
703 trunc:
704 ND_PRINT((ndo, "%s", tstr));
705 return;
706 }
707
708 void
709 ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
710 {
711 if (length < 1) {
712 ND_PRINT((ndo, "truncated-ip %d", length));
713 return;
714 }
715
716 ND_TCHECK_1(bp);
717 switch (EXTRACT_U_1(bp) & 0xF0) {
718 case 0x40:
719 ip_print (ndo, bp, length);
720 break;
721 case 0x60:
722 ip6_print (ndo, bp, length);
723 break;
724 default:
725 ND_PRINT((ndo, "unknown ip %u", (EXTRACT_U_1(bp) & 0xF0) >> 4));
726 break;
727 }
728 return;
729
730 trunc:
731 ND_PRINT((ndo, "%s", tstr));
732 return;
733 }
734
735 /*
736 * Local Variables:
737 * c-style: whitesmith
738 * c-basic-offset: 8
739 * End:
740 */
741
742