4 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 #include <sys/cdefs.h>
27 static const char rcsid
[] _U_
=
28 "@(#) Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.4 2006/12/12 14:33:20 hannes Exp (LBL)";
30 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
38 #include <tcpdump-stdinc.h>
43 #include "interface.h"
44 #include "addrtoname.h"
45 #include "extract.h" /* must come after interface.h */
53 * Interface Control Message Protocol Definitions.
54 * Per RFC 792, September 1981.
58 * Structure of an icmp header.
61 u_int8_t icmp_type
; /* type of message, see below */
62 u_int8_t icmp_code
; /* type sub code */
63 u_int16_t icmp_cksum
; /* ones complement cksum of struct */
65 u_int8_t ih_pptr
; /* ICMP_PARAMPROB */
66 struct in_addr ih_gwaddr
; /* ICMP_REDIRECT */
73 #define icmp_pptr icmp_hun.ih_pptr
74 #define icmp_gwaddr icmp_hun.ih_gwaddr
75 #define icmp_id icmp_hun.ih_idseq.icd_id
76 #define icmp_seq icmp_hun.ih_idseq.icd_seq
77 #define icmp_void icmp_hun.ih_void
86 /* options and then 64 bits of data */
91 #define icmp_otime icmp_dun.id_ts.its_otime
92 #define icmp_rtime icmp_dun.id_ts.its_rtime
93 #define icmp_ttime icmp_dun.id_ts.its_ttime
94 #define icmp_ip icmp_dun.id_ip.idi_ip
95 #define icmp_mask icmp_dun.id_mask
96 #define icmp_data icmp_dun.id_data
99 #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
100 #define ICMP_MPLS_EXT_VERSION 2
103 * Lower bounds on packet lengths for various types.
104 * For the error advice packets must first insure that the
105 * packet is large enought to contain the returned ip header.
106 * Only then can we do the check to see if 64 bits of packet
107 * data have been returned, since we need to check the returned
110 #define ICMP_MINLEN 8 /* abs minimum */
111 #define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-internet-icmp-08 */
112 #define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
113 #define ICMP_MASKLEN 12 /* address mask */
114 #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
115 #define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
116 /* N.B.: must separately check that ip_hl >= 5 */
119 * Definition of type and code field values.
121 #define ICMP_ECHOREPLY 0 /* echo reply */
122 #define ICMP_UNREACH 3 /* dest unreachable, codes: */
123 #define ICMP_UNREACH_NET 0 /* bad net */
124 #define ICMP_UNREACH_HOST 1 /* bad host */
125 #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
126 #define ICMP_UNREACH_PORT 3 /* bad port */
127 #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
128 #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
129 #define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
130 #define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
131 #define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
132 #define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
133 #define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
134 #define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
135 #define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
136 #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
137 #define ICMP_REDIRECT 5 /* shorter route, codes: */
138 #define ICMP_REDIRECT_NET 0 /* for network */
139 #define ICMP_REDIRECT_HOST 1 /* for host */
140 #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
141 #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
142 #define ICMP_ECHO 8 /* echo service */
143 #define ICMP_ROUTERADVERT 9 /* router advertisement */
144 #define ICMP_ROUTERSOLICIT 10 /* router solicitation */
145 #define ICMP_TIMXCEED 11 /* time exceeded, code: */
146 #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
147 #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
148 #define ICMP_PARAMPROB 12 /* ip header bad */
149 #define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
150 #define ICMP_TSTAMP 13 /* timestamp request */
151 #define ICMP_TSTAMPREPLY 14 /* timestamp reply */
152 #define ICMP_IREQ 15 /* information request */
153 #define ICMP_IREQREPLY 16 /* information reply */
154 #define ICMP_MASKREQ 17 /* address mask request */
155 #define ICMP_MASKREPLY 18 /* address mask reply */
157 #define ICMP_MAXTYPE 18
159 #define ICMP_INFOTYPE(type) \
160 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
161 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
162 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
163 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
164 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
165 #define ICMP_MPLS_EXT_TYPE(type) \
166 ((type) == ICMP_UNREACH || \
167 (type) == ICMP_TIMXCEED || \
168 (type) == ICMP_PARAMPROB)
170 #ifndef ICMP_UNREACH_NET_UNKNOWN
171 #define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
173 #ifndef ICMP_UNREACH_HOST_UNKNOWN
174 #define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */
176 #ifndef ICMP_UNREACH_ISOLATED
177 #define ICMP_UNREACH_ISOLATED 8 /* source host isolated */
179 #ifndef ICMP_UNREACH_NET_PROHIB
180 #define ICMP_UNREACH_NET_PROHIB 9 /* admin prohibited net */
182 #ifndef ICMP_UNREACH_HOST_PROHIB
183 #define ICMP_UNREACH_HOST_PROHIB 10 /* admin prohibited host */
185 #ifndef ICMP_UNREACH_TOSNET
186 #define ICMP_UNREACH_TOSNET 11 /* tos prohibited net */
188 #ifndef ICMP_UNREACH_TOSHOST
189 #define ICMP_UNREACH_TOSHOST 12 /* tos prohibited host */
193 #ifndef ICMP_UNREACH_FILTER_PROHIB
194 #define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohibited filter */
196 #ifndef ICMP_UNREACH_HOST_PRECEDENCE
197 #define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */
199 #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
200 #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
203 /* Most of the icmp types */
204 static struct tok icmp2str
[] = {
205 { ICMP_ECHOREPLY
, "echo reply" },
206 { ICMP_SOURCEQUENCH
, "source quench" },
207 { ICMP_ECHO
, "echo request" },
208 { ICMP_ROUTERSOLICIT
, "router solicitation" },
209 { ICMP_TSTAMP
, "time stamp request" },
210 { ICMP_TSTAMPREPLY
, "time stamp reply" },
211 { ICMP_IREQ
, "information request" },
212 { ICMP_IREQREPLY
, "information reply" },
213 { ICMP_MASKREQ
, "address mask request" },
217 /* Formats for most of the ICMP_UNREACH codes */
218 static struct tok unreach2str
[] = {
219 { ICMP_UNREACH_NET
, "net %s unreachable" },
220 { ICMP_UNREACH_HOST
, "host %s unreachable" },
221 { ICMP_UNREACH_SRCFAIL
,
222 "%s unreachable - source route failed" },
223 { ICMP_UNREACH_NET_UNKNOWN
, "net %s unreachable - unknown" },
224 { ICMP_UNREACH_HOST_UNKNOWN
, "host %s unreachable - unknown" },
225 { ICMP_UNREACH_ISOLATED
,
226 "%s unreachable - source host isolated" },
227 { ICMP_UNREACH_NET_PROHIB
,
228 "net %s unreachable - admin prohibited" },
229 { ICMP_UNREACH_HOST_PROHIB
,
230 "host %s unreachable - admin prohibited" },
231 { ICMP_UNREACH_TOSNET
,
232 "net %s unreachable - tos prohibited" },
233 { ICMP_UNREACH_TOSHOST
,
234 "host %s unreachable - tos prohibited" },
235 { ICMP_UNREACH_FILTER_PROHIB
,
236 "host %s unreachable - admin prohibited filter" },
237 { ICMP_UNREACH_HOST_PRECEDENCE
,
238 "host %s unreachable - host precedence violation" },
239 { ICMP_UNREACH_PRECEDENCE_CUTOFF
,
240 "host %s unreachable - precedence cutoff" },
244 /* Formats for the ICMP_REDIRECT codes */
245 static struct tok type2str
[] = {
246 { ICMP_REDIRECT_NET
, "redirect %s to net %s" },
247 { ICMP_REDIRECT_HOST
, "redirect %s to host %s" },
248 { ICMP_REDIRECT_TOSNET
, "redirect-tos %s to net %s" },
249 { ICMP_REDIRECT_TOSHOST
, "redirect-tos %s to host %s" },
254 struct mtu_discovery
{
256 u_int16_t nexthopmtu
;
260 struct ih_rdiscovery
{
261 u_int8_t ird_addrnum
;
262 u_int8_t ird_addrsiz
;
263 u_int16_t ird_lifetime
;
266 struct id_rdiscovery
{
272 * draft-bonica-internet-icmp-08
274 * The Destination Unreachable, Time Exceeded
275 * and Parameter Problem messages are slighly changed as per
276 * the above draft. A new Length field gets added to give
277 * the caller an idea about the length of the piggypacked
278 * IP packet before the MPLS extension header starts.
280 * The Length field represents length of the padded "original datagram"
281 * field measured in 32-bit words.
284 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
285 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
286 * | Type | Code | Checksum |
287 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
288 * | unused | Length | unused |
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | Internet Header + leading octets of original datagram |
294 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
300 u_int8_t icmp_checksum
[2];
301 u_int8_t icmp_reserved
;
302 u_int8_t icmp_length
;
303 u_int8_t icmp_reserved2
[2];
304 u_int8_t icmp_ext_legacy_header
[128]; /* extension header starts 128 bytes after ICMP header */
305 u_int8_t icmp_ext_version_res
[2];
306 u_int8_t icmp_ext_checksum
[2];
307 u_int8_t icmp_ext_data
[1];
310 struct icmp_mpls_ext_common_header_t
{
313 struct icmp_mpls_ext_object_header_t
{
319 static const struct tok icmp_mpls_ext_obj_values
[] = {
320 { 1, "MPLS Stack Entry" },
321 { 2, "Extended Payload" },
326 const char *icmp_tstamp_print(u_int
);
328 /* print the milliseconds since midnight UTC */
330 icmp_tstamp_print(u_int tstamp
) {
331 u_int msec
,sec
,min
,hrs
;
335 msec
= tstamp
% 1000;
337 min
= sec
/ 60; sec
-= min
* 60;
338 hrs
= min
/ 60; min
-= hrs
* 60;
339 snprintf(buf
, sizeof(buf
), "%02u:%02u:%02u.%03u",hrs
,min
,sec
,msec
);
344 icmp_print(const u_char
*bp
, u_int plen
, const u_char
*bp2
, int fragmented
)
347 const struct icmp
*dp
;
348 const struct icmp_ext_t
*ext_dp
;
350 const char *str
, *fmt
;
351 const struct ip
*oip
;
352 const struct udphdr
*ouh
;
353 const u_int8_t
*obj_tptr
;
355 const u_char
*snapend_save
;
356 const struct icmp_mpls_ext_object_header_t
*icmp_mpls_ext_object_header
;
357 u_int hlen
, dport
, mtu
, obj_tlen
, obj_class_num
, obj_ctype
;
358 char buf
[MAXHOSTNAMELEN
+ 100];
360 dp
= (struct icmp
*)bp
;
361 ext_dp
= (struct icmp_ext_t
*)bp
;
362 ip
= (struct ip
*)bp2
;
365 TCHECK(dp
->icmp_code
);
366 switch (dp
->icmp_type
) {
370 TCHECK(dp
->icmp_seq
);
371 (void)snprintf(buf
, sizeof(buf
), "echo %s, id %u, seq %u",
372 dp
->icmp_type
== ICMP_ECHO
?
374 EXTRACT_16BITS(&dp
->icmp_id
),
375 EXTRACT_16BITS(&dp
->icmp_seq
));
379 TCHECK(dp
->icmp_ip
.ip_dst
);
380 switch (dp
->icmp_code
) {
382 case ICMP_UNREACH_PROTOCOL
:
383 TCHECK(dp
->icmp_ip
.ip_p
);
384 (void)snprintf(buf
, sizeof(buf
),
385 "%s protocol %d unreachable",
386 ipaddr_string(&dp
->icmp_ip
.ip_dst
),
390 case ICMP_UNREACH_PORT
:
391 TCHECK(dp
->icmp_ip
.ip_p
);
393 hlen
= IP_HL(oip
) * 4;
394 ouh
= (struct udphdr
*)(((u_char
*)oip
) + hlen
);
395 TCHECK(ouh
->uh_dport
);
396 dport
= EXTRACT_16BITS(&ouh
->uh_dport
);
400 (void)snprintf(buf
, sizeof(buf
),
401 "%s tcp port %s unreachable",
402 ipaddr_string(&oip
->ip_dst
),
403 tcpport_string(dport
));
407 (void)snprintf(buf
, sizeof(buf
),
408 "%s udp port %s unreachable",
409 ipaddr_string(&oip
->ip_dst
),
410 udpport_string(dport
));
414 (void)snprintf(buf
, sizeof(buf
),
415 "%s protocol %d port %d unreachable",
416 ipaddr_string(&oip
->ip_dst
),
422 case ICMP_UNREACH_NEEDFRAG
:
424 register const struct mtu_discovery
*mp
;
425 mp
= (struct mtu_discovery
*)&dp
->icmp_void
;
426 mtu
= EXTRACT_16BITS(&mp
->nexthopmtu
);
428 (void)snprintf(buf
, sizeof(buf
),
429 "%s unreachable - need to frag (mtu %d)",
430 ipaddr_string(&dp
->icmp_ip
.ip_dst
), mtu
);
432 (void)snprintf(buf
, sizeof(buf
),
433 "%s unreachable - need to frag",
434 ipaddr_string(&dp
->icmp_ip
.ip_dst
));
440 fmt
= tok2str(unreach2str
, "#%d %%s unreachable",
442 (void)snprintf(buf
, sizeof(buf
), fmt
,
443 ipaddr_string(&dp
->icmp_ip
.ip_dst
));
449 TCHECK(dp
->icmp_ip
.ip_dst
);
450 fmt
= tok2str(type2str
, "redirect-#%d %%s to net %%s",
452 (void)snprintf(buf
, sizeof(buf
), fmt
,
453 ipaddr_string(&dp
->icmp_ip
.ip_dst
),
454 ipaddr_string(&dp
->icmp_gwaddr
));
457 case ICMP_ROUTERADVERT
:
459 register const struct ih_rdiscovery
*ihp
;
460 register const struct id_rdiscovery
*idp
;
461 u_int lifetime
, num
, size
;
463 (void)snprintf(buf
, sizeof(buf
), "router advertisement");
464 cp
= buf
+ strlen(buf
);
466 ihp
= (struct ih_rdiscovery
*)&dp
->icmp_void
;
468 (void)strncpy(cp
, " lifetime ", sizeof(buf
) - (cp
- buf
));
469 cp
= buf
+ strlen(buf
);
470 lifetime
= EXTRACT_16BITS(&ihp
->ird_lifetime
);
472 (void)snprintf(cp
, sizeof(buf
) - (cp
- buf
), "%u",
474 } else if (lifetime
< 60 * 60) {
475 (void)snprintf(cp
, sizeof(buf
) - (cp
- buf
), "%u:%02u",
476 lifetime
/ 60, lifetime
% 60);
478 (void)snprintf(cp
, sizeof(buf
) - (cp
- buf
),
481 (lifetime
% 3600) / 60,
484 cp
= buf
+ strlen(buf
);
486 num
= ihp
->ird_addrnum
;
487 (void)snprintf(cp
, sizeof(buf
) - (cp
- buf
), " %d:", num
);
488 cp
= buf
+ strlen(buf
);
490 size
= ihp
->ird_addrsiz
;
492 (void)snprintf(cp
, sizeof(buf
) - (cp
- buf
),
496 idp
= (struct id_rdiscovery
*)&dp
->icmp_data
;
499 (void)snprintf(cp
, sizeof(buf
) - (cp
- buf
), " {%s %u}",
500 ipaddr_string(&idp
->ird_addr
),
501 EXTRACT_32BITS(&idp
->ird_pref
));
502 cp
= buf
+ strlen(buf
);
509 TCHECK(dp
->icmp_ip
.ip_dst
);
510 switch (dp
->icmp_code
) {
512 case ICMP_TIMXCEED_INTRANS
:
513 str
= "time exceeded in-transit";
516 case ICMP_TIMXCEED_REASS
:
517 str
= "ip reassembly time exceeded";
521 (void)snprintf(buf
, sizeof(buf
), "time exceeded-#%d",
529 (void)snprintf(buf
, sizeof(buf
),
530 "parameter problem - code %d", dp
->icmp_code
);
532 TCHECK(dp
->icmp_pptr
);
533 (void)snprintf(buf
, sizeof(buf
),
534 "parameter problem - octet %d", dp
->icmp_pptr
);
539 TCHECK(dp
->icmp_mask
);
540 (void)snprintf(buf
, sizeof(buf
), "address mask is 0x%08x",
541 EXTRACT_32BITS(&dp
->icmp_mask
));
545 TCHECK(dp
->icmp_seq
);
546 (void)snprintf(buf
, sizeof(buf
),
547 "time stamp query id %u seq %u",
548 EXTRACT_16BITS(&dp
->icmp_id
),
549 EXTRACT_16BITS(&dp
->icmp_seq
));
552 case ICMP_TSTAMPREPLY
:
553 TCHECK(dp
->icmp_ttime
);
554 (void)snprintf(buf
, sizeof(buf
),
555 "time stamp reply id %u seq %u: org %s",
556 EXTRACT_16BITS(&dp
->icmp_id
),
557 EXTRACT_16BITS(&dp
->icmp_seq
),
558 icmp_tstamp_print(EXTRACT_32BITS(&dp
->icmp_otime
)));
560 (void)snprintf(buf
+strlen(buf
),sizeof(buf
)-strlen(buf
),", recv %s",
561 icmp_tstamp_print(EXTRACT_32BITS(&dp
->icmp_rtime
)));
562 (void)snprintf(buf
+strlen(buf
),sizeof(buf
)-strlen(buf
),", xmit %s",
563 icmp_tstamp_print(EXTRACT_32BITS(&dp
->icmp_ttime
)));
567 str
= tok2str(icmp2str
, "type-#%d", dp
->icmp_type
);
570 (void)printf("ICMP %s, length %u", str
, plen
);
571 if (vflag
&& !fragmented
) { /* don't attempt checksumming if this is a frag */
572 u_int16_t sum
, icmp_sum
;
573 if (TTEST2(*bp
, plen
)) {
574 sum
= in_cksum((u_short
*)dp
, plen
, 0);
576 icmp_sum
= EXTRACT_16BITS(&dp
->icmp_cksum
);
577 (void)printf(" (wrong icmp cksum %x (->%x)!)",
579 in_cksum_shouldbe(icmp_sum
, sum
));
585 * print the remnants of the IP packet.
586 * save the snaplength as this may get overidden in the IP printer.
588 if (vflag
>= 1 && !ICMP_INFOTYPE(dp
->icmp_type
)) {
590 (void)printf("\n\t");
591 ip
= (struct ip
*)bp
;
592 snaplen
= snapend
- bp
;
593 snapend_save
= snapend
;
594 ip_print(gndo
, bp
, EXTRACT_16BITS(&ip
->ip_len
));
595 snapend
= snapend_save
;
599 * Attempt to decode the MPLS extensions only for some ICMP types.
601 if (vflag
>= 1 && plen
> ICMP_EXTD_MINLEN
&& ICMP_MPLS_EXT_TYPE(dp
->icmp_type
)) {
606 * Check first if the mpls extension header shows a non-zero length.
607 * If the length field is not set then silently verify the checksum
608 * to check if an extension header is present. This is expedient,
609 * however not all implementations set the length field proper.
611 if (!ext_dp
->icmp_length
&&
612 in_cksum((const u_short
*)&ext_dp
->icmp_ext_version_res
,
613 plen
- ICMP_EXTD_MINLEN
, 0)) {
617 printf("\n\tMPLS extension v%u",
618 ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp
->icmp_ext_version_res
)));
621 * Sanity checking of the header.
623 if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp
->icmp_ext_version_res
)) !=
624 ICMP_MPLS_EXT_VERSION
) {
625 printf(" packet not supported");
629 hlen
= plen
- ICMP_EXTD_MINLEN
;
630 printf(", checksum 0x%04x (%scorrect), length %u",
631 EXTRACT_16BITS(ext_dp
->icmp_ext_checksum
),
632 in_cksum((const u_short
*)&ext_dp
->icmp_ext_version_res
,
633 plen
- ICMP_EXTD_MINLEN
, 0) ? "in" : "",
636 hlen
-= 4; /* subtract common header size */
637 obj_tptr
= (u_int8_t
*)ext_dp
->icmp_ext_data
;
639 while (hlen
> sizeof(struct icmp_mpls_ext_object_header_t
)) {
641 icmp_mpls_ext_object_header
= (struct icmp_mpls_ext_object_header_t
*)obj_tptr
;
642 TCHECK(*icmp_mpls_ext_object_header
);
643 obj_tlen
= EXTRACT_16BITS(icmp_mpls_ext_object_header
->length
);
644 obj_class_num
= icmp_mpls_ext_object_header
->class_num
;
645 obj_ctype
= icmp_mpls_ext_object_header
->ctype
;
646 obj_tptr
+= sizeof(struct icmp_mpls_ext_object_header_t
);
648 printf("\n\t %s Object (%u), Class-Type: %u, length %u",
649 tok2str(icmp_mpls_ext_obj_values
,"unknown",obj_class_num
),
654 hlen
-=sizeof(struct icmp_mpls_ext_object_header_t
); /* length field includes tlv header */
656 /* infinite loop protection */
657 if ((obj_class_num
== 0) ||
658 (obj_tlen
< sizeof(struct icmp_mpls_ext_object_header_t
))) {
661 obj_tlen
-=sizeof(struct icmp_mpls_ext_object_header_t
);
663 switch (obj_class_num
) {
667 TCHECK2(*obj_tptr
, 4);
668 raw_label
= EXTRACT_32BITS(obj_tptr
);
669 printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label
), MPLS_EXP(raw_label
));
670 if (MPLS_STACK(raw_label
))
672 printf(", ttl %u", MPLS_TTL(raw_label
));
675 print_unknown_data(obj_tptr
, "\n\t ", obj_tlen
);
680 * FIXME those are the defined objects that lack a decoder
681 * you are welcome to contribute code ;-)
685 print_unknown_data(obj_tptr
, "\n\t ", obj_tlen
);
691 obj_tptr
+= obj_tlen
;
697 fputs("[|icmp]", stdout
);