]> The Tcpdump Group git mirrors - tcpdump/blob - print-icmp.c
add a .pcap sample to test MPLS/ICMP extensions
[tcpdump] / print-icmp.c
1 /*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
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 #ifndef lint
23 static const char rcsid[] _U_ =
24 "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.77 2004-06-14 15:08:08 hannes Exp $ (LBL)";
25 #endif
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <tcpdump-stdinc.h>
32
33 #include <stdio.h>
34 #include <string.h>
35
36 #include "interface.h"
37 #include "addrtoname.h"
38 #include "extract.h" /* must come after interface.h */
39
40 #include "ip.h"
41 #include "udp.h"
42 #include "ipproto.h"
43 #include "mpls.h"
44
45 /*
46 * Interface Control Message Protocol Definitions.
47 * Per RFC 792, September 1981.
48 */
49
50 /*
51 * Structure of an icmp header.
52 */
53 struct icmp {
54 u_int8_t icmp_type; /* type of message, see below */
55 u_int8_t icmp_code; /* type sub code */
56 u_int16_t icmp_cksum; /* ones complement cksum of struct */
57 union {
58 u_int8_t ih_pptr; /* ICMP_PARAMPROB */
59 struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
60 struct ih_idseq {
61 u_int16_t icd_id;
62 u_int16_t icd_seq;
63 } ih_idseq;
64 u_int32_t ih_void;
65
66 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
67 struct ih_pmtu {
68 u_int16_t ipm_void;
69 u_int16_t ipm_nextmtu;
70 } ih_pmtu;
71 } icmp_hun;
72 #define icmp_pptr icmp_hun.ih_pptr
73 #define icmp_gwaddr icmp_hun.ih_gwaddr
74 #define icmp_id icmp_hun.ih_idseq.icd_id
75 #define icmp_seq icmp_hun.ih_idseq.icd_seq
76 #define icmp_void icmp_hun.ih_void
77 #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
78 #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
79 union {
80 struct id_ts {
81 u_int32_t its_otime;
82 u_int32_t its_rtime;
83 u_int32_t its_ttime;
84 } id_ts;
85 struct id_ip {
86 struct ip idi_ip;
87 /* options and then 64 bits of data */
88 } id_ip;
89 struct mpls_ext {
90 u_int8_t legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
91 u_int8_t version_res[2];
92 u_int8_t checksum[2];
93 u_int8_t data[1];
94 } mpls_ext;
95 u_int32_t id_mask;
96 u_int8_t id_data[1];
97 } icmp_dun;
98 #define icmp_otime icmp_dun.id_ts.its_otime
99 #define icmp_rtime icmp_dun.id_ts.its_rtime
100 #define icmp_ttime icmp_dun.id_ts.its_ttime
101 #define icmp_ip icmp_dun.id_ip.idi_ip
102 #define icmp_mask icmp_dun.id_mask
103 #define icmp_data icmp_dun.id_data
104 #define icmp_mpls_ext_version icmp_dun.mpls_ext.version_res
105 #define icmp_mpls_ext_checksum icmp_dun.mpls_ext.checksum
106 #define icmp_mpls_ext_data icmp_dun.mpls_ext.data
107 };
108
109 #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
110
111 /*
112 * Lower bounds on packet lengths for various types.
113 * For the error advice packets must first insure that the
114 * packet is large enought to contain the returned ip header.
115 * Only then can we do the check to see if 64 bits of packet
116 * data have been returned, since we need to check the returned
117 * ip header length.
118 */
119 #define ICMP_MINLEN 8 /* abs minimum */
120 #define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-icmp-mpls-02 */
121 #define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
122 #define ICMP_MASKLEN 12 /* address mask */
123 #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
124 #define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
125 /* N.B.: must separately check that ip_hl >= 5 */
126
127 /*
128 * Definition of type and code field values.
129 */
130 #define ICMP_ECHOREPLY 0 /* echo reply */
131 #define ICMP_UNREACH 3 /* dest unreachable, codes: */
132 #define ICMP_UNREACH_NET 0 /* bad net */
133 #define ICMP_UNREACH_HOST 1 /* bad host */
134 #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
135 #define ICMP_UNREACH_PORT 3 /* bad port */
136 #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
137 #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
138 #define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
139 #define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
140 #define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
141 #define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
142 #define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
143 #define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
144 #define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
145 #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
146 #define ICMP_REDIRECT 5 /* shorter route, codes: */
147 #define ICMP_REDIRECT_NET 0 /* for network */
148 #define ICMP_REDIRECT_HOST 1 /* for host */
149 #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
150 #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
151 #define ICMP_ECHO 8 /* echo service */
152 #define ICMP_ROUTERADVERT 9 /* router advertisement */
153 #define ICMP_ROUTERSOLICIT 10 /* router solicitation */
154 #define ICMP_TIMXCEED 11 /* time exceeded, code: */
155 #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
156 #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
157 #define ICMP_PARAMPROB 12 /* ip header bad */
158 #define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
159 #define ICMP_TSTAMP 13 /* timestamp request */
160 #define ICMP_TSTAMPREPLY 14 /* timestamp reply */
161 #define ICMP_IREQ 15 /* information request */
162 #define ICMP_IREQREPLY 16 /* information reply */
163 #define ICMP_MASKREQ 17 /* address mask request */
164 #define ICMP_MASKREPLY 18 /* address mask reply */
165
166 #define ICMP_MAXTYPE 18
167
168 #define ICMP_INFOTYPE(type) \
169 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
170 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
171 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
172 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
173 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
174 /* rfc1700 */
175 #ifndef ICMP_UNREACH_NET_UNKNOWN
176 #define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
177 #endif
178 #ifndef ICMP_UNREACH_HOST_UNKNOWN
179 #define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */
180 #endif
181 #ifndef ICMP_UNREACH_ISOLATED
182 #define ICMP_UNREACH_ISOLATED 8 /* source host isolated */
183 #endif
184 #ifndef ICMP_UNREACH_NET_PROHIB
185 #define ICMP_UNREACH_NET_PROHIB 9 /* admin prohibited net */
186 #endif
187 #ifndef ICMP_UNREACH_HOST_PROHIB
188 #define ICMP_UNREACH_HOST_PROHIB 10 /* admin prohibited host */
189 #endif
190 #ifndef ICMP_UNREACH_TOSNET
191 #define ICMP_UNREACH_TOSNET 11 /* tos prohibited net */
192 #endif
193 #ifndef ICMP_UNREACH_TOSHOST
194 #define ICMP_UNREACH_TOSHOST 12 /* tos prohibited host */
195 #endif
196
197 /* rfc1716 */
198 #ifndef ICMP_UNREACH_FILTER_PROHIB
199 #define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohibited filter */
200 #endif
201 #ifndef ICMP_UNREACH_HOST_PRECEDENCE
202 #define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */
203 #endif
204 #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
205 #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
206 #endif
207
208 /* Most of the icmp types */
209 static struct tok icmp2str[] = {
210 { ICMP_ECHOREPLY, "echo reply" },
211 { ICMP_SOURCEQUENCH, "source quench" },
212 { ICMP_ECHO, "echo request" },
213 { ICMP_ROUTERSOLICIT, "router solicitation" },
214 { ICMP_TSTAMP, "time stamp request" },
215 { ICMP_TSTAMPREPLY, "time stamp reply" },
216 { ICMP_IREQ, "information request" },
217 { ICMP_IREQREPLY, "information reply" },
218 { ICMP_MASKREQ, "address mask request" },
219 { 0, NULL }
220 };
221
222 /* Formats for most of the ICMP_UNREACH codes */
223 static struct tok unreach2str[] = {
224 { ICMP_UNREACH_NET, "net %s unreachable" },
225 { ICMP_UNREACH_HOST, "host %s unreachable" },
226 { ICMP_UNREACH_SRCFAIL,
227 "%s unreachable - source route failed" },
228 { ICMP_UNREACH_NET_UNKNOWN, "net %s unreachable - unknown" },
229 { ICMP_UNREACH_HOST_UNKNOWN, "host %s unreachable - unknown" },
230 { ICMP_UNREACH_ISOLATED,
231 "%s unreachable - source host isolated" },
232 { ICMP_UNREACH_NET_PROHIB,
233 "net %s unreachable - admin prohibited" },
234 { ICMP_UNREACH_HOST_PROHIB,
235 "host %s unreachable - admin prohibited" },
236 { ICMP_UNREACH_TOSNET,
237 "net %s unreachable - tos prohibited" },
238 { ICMP_UNREACH_TOSHOST,
239 "host %s unreachable - tos prohibited" },
240 { ICMP_UNREACH_FILTER_PROHIB,
241 "host %s unreachable - admin prohibited filter" },
242 { ICMP_UNREACH_HOST_PRECEDENCE,
243 "host %s unreachable - host precedence violation" },
244 { ICMP_UNREACH_PRECEDENCE_CUTOFF,
245 "host %s unreachable - precedence cutoff" },
246 { 0, NULL }
247 };
248
249 /* Formats for the ICMP_REDIRECT codes */
250 static struct tok type2str[] = {
251 { ICMP_REDIRECT_NET, "redirect %s to net %s" },
252 { ICMP_REDIRECT_HOST, "redirect %s to host %s" },
253 { ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" },
254 { ICMP_REDIRECT_TOSHOST, "redirect-tos %s to host %s" },
255 { 0, NULL }
256 };
257
258 /* rfc1191 */
259 struct mtu_discovery {
260 u_int16_t unused;
261 u_int16_t nexthopmtu;
262 };
263
264 /* rfc1256 */
265 struct ih_rdiscovery {
266 u_int8_t ird_addrnum;
267 u_int8_t ird_addrsiz;
268 u_int16_t ird_lifetime;
269 };
270
271 struct id_rdiscovery {
272 u_int32_t ird_addr;
273 u_int32_t ird_pref;
274 };
275
276 /* draft-bonica-icmp-mpls-02 */
277 struct icmp_mpls_ext_object_header_t {
278 u_int8_t length[2];
279 u_int8_t class_num;
280 u_int8_t ctype;
281 };
282
283 static const struct tok icmp_mpls_ext_obj_values[] = {
284 { 1, "MPLS Stack Entry" },
285 { 2, "Extended Payload" },
286 { 0, NULL}
287 };
288
289 void
290 icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
291 {
292 char *cp;
293 const struct icmp *dp;
294 const struct ip *ip;
295 const char *str, *fmt;
296 const struct ip *oip;
297 const struct udphdr *ouh;
298 const u_int8_t *obj_tptr;
299 u_int32_t raw_label;
300 const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
301 u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
302 char buf[MAXHOSTNAMELEN + 100];
303
304 dp = (struct icmp *)bp;
305 ip = (struct ip *)bp2;
306 str = buf;
307
308 TCHECK(dp->icmp_code);
309 switch (dp->icmp_type) {
310
311 case ICMP_ECHO:
312 case ICMP_ECHOREPLY:
313 TCHECK(dp->icmp_seq);
314 (void)snprintf(buf, sizeof(buf), "echo %s seq %u",
315 dp->icmp_type == ICMP_ECHO ?
316 "request" : "reply",
317 EXTRACT_16BITS(&dp->icmp_seq));
318 break;
319
320 case ICMP_UNREACH:
321 TCHECK(dp->icmp_ip.ip_dst);
322 switch (dp->icmp_code) {
323
324 case ICMP_UNREACH_PROTOCOL:
325 TCHECK(dp->icmp_ip.ip_p);
326 (void)snprintf(buf, sizeof(buf),
327 "%s protocol %d unreachable",
328 ipaddr_string(&dp->icmp_ip.ip_dst),
329 dp->icmp_ip.ip_p);
330 break;
331
332 case ICMP_UNREACH_PORT:
333 TCHECK(dp->icmp_ip.ip_p);
334 oip = &dp->icmp_ip;
335 hlen = IP_HL(oip) * 4;
336 ouh = (struct udphdr *)(((u_char *)oip) + hlen);
337 TCHECK(ouh->uh_dport);
338 dport = EXTRACT_16BITS(&ouh->uh_dport);
339 switch (oip->ip_p) {
340
341 case IPPROTO_TCP:
342 (void)snprintf(buf, sizeof(buf),
343 "%s tcp port %s unreachable",
344 ipaddr_string(&oip->ip_dst),
345 tcpport_string(dport));
346 break;
347
348 case IPPROTO_UDP:
349 (void)snprintf(buf, sizeof(buf),
350 "%s udp port %s unreachable",
351 ipaddr_string(&oip->ip_dst),
352 udpport_string(dport));
353 break;
354
355 default:
356 (void)snprintf(buf, sizeof(buf),
357 "%s protocol %d port %d unreachable",
358 ipaddr_string(&oip->ip_dst),
359 oip->ip_p, dport);
360 break;
361 }
362 break;
363
364 case ICMP_UNREACH_NEEDFRAG:
365 {
366 register const struct mtu_discovery *mp;
367 mp = (struct mtu_discovery *)&dp->icmp_void;
368 mtu = EXTRACT_16BITS(&mp->nexthopmtu);
369 if (mtu) {
370 (void)snprintf(buf, sizeof(buf),
371 "%s unreachable - need to frag (mtu %d)",
372 ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
373 } else {
374 (void)snprintf(buf, sizeof(buf),
375 "%s unreachable - need to frag",
376 ipaddr_string(&dp->icmp_ip.ip_dst));
377 }
378 }
379 break;
380
381 default:
382 fmt = tok2str(unreach2str, "#%d %%s unreachable",
383 dp->icmp_code);
384 (void)snprintf(buf, sizeof(buf), fmt,
385 ipaddr_string(&dp->icmp_ip.ip_dst));
386 break;
387 }
388 break;
389
390 case ICMP_REDIRECT:
391 TCHECK(dp->icmp_ip.ip_dst);
392 fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
393 dp->icmp_code);
394 (void)snprintf(buf, sizeof(buf), fmt,
395 ipaddr_string(&dp->icmp_ip.ip_dst),
396 ipaddr_string(&dp->icmp_gwaddr));
397 break;
398
399 case ICMP_ROUTERADVERT:
400 {
401 register const struct ih_rdiscovery *ihp;
402 register const struct id_rdiscovery *idp;
403 u_int lifetime, num, size;
404
405 (void)snprintf(buf, sizeof(buf), "router advertisement");
406 cp = buf + strlen(buf);
407
408 ihp = (struct ih_rdiscovery *)&dp->icmp_void;
409 TCHECK(*ihp);
410 (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
411 cp = buf + strlen(buf);
412 lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
413 if (lifetime < 60) {
414 (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
415 lifetime);
416 } else if (lifetime < 60 * 60) {
417 (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
418 lifetime / 60, lifetime % 60);
419 } else {
420 (void)snprintf(cp, sizeof(buf) - (cp - buf),
421 "%u:%02u:%02u",
422 lifetime / 3600,
423 (lifetime % 3600) / 60,
424 lifetime % 60);
425 }
426 cp = buf + strlen(buf);
427
428 num = ihp->ird_addrnum;
429 (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num);
430 cp = buf + strlen(buf);
431
432 size = ihp->ird_addrsiz;
433 if (size != 2) {
434 (void)snprintf(cp, sizeof(buf) - (cp - buf),
435 " [size %d]", size);
436 break;
437 }
438 idp = (struct id_rdiscovery *)&dp->icmp_data;
439 while (num-- > 0) {
440 TCHECK(*idp);
441 (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
442 ipaddr_string(&idp->ird_addr),
443 EXTRACT_32BITS(&idp->ird_pref));
444 cp = buf + strlen(buf);
445 ++idp;
446 }
447 }
448 break;
449
450 case ICMP_TIMXCEED:
451 TCHECK(dp->icmp_ip.ip_dst);
452 switch (dp->icmp_code) {
453
454 case ICMP_TIMXCEED_INTRANS:
455 str = "time exceeded in-transit";
456 break;
457
458 case ICMP_TIMXCEED_REASS:
459 str = "ip reassembly time exceeded";
460 break;
461
462 default:
463 (void)snprintf(buf, sizeof(buf), "time exceeded-#%d",
464 dp->icmp_code);
465 break;
466 }
467 break;
468
469 case ICMP_PARAMPROB:
470 if (dp->icmp_code)
471 (void)snprintf(buf, sizeof(buf),
472 "parameter problem - code %d", dp->icmp_code);
473 else {
474 TCHECK(dp->icmp_pptr);
475 (void)snprintf(buf, sizeof(buf),
476 "parameter problem - octet %d", dp->icmp_pptr);
477 }
478 break;
479
480 case ICMP_MASKREPLY:
481 TCHECK(dp->icmp_mask);
482 (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
483 EXTRACT_32BITS(&dp->icmp_mask));
484 break;
485
486 case ICMP_TSTAMP:
487 TCHECK(dp->icmp_seq);
488 (void)snprintf(buf, sizeof(buf),
489 "time stamp query id %u seq %u",
490 EXTRACT_16BITS(&dp->icmp_id),
491 EXTRACT_16BITS(&dp->icmp_seq));
492 break;
493
494 case ICMP_TSTAMPREPLY:
495 TCHECK(dp->icmp_ttime);
496 (void)snprintf(buf, sizeof(buf),
497 "time stamp reply id %u seq %u : org 0x%x recv 0x%x xmit 0x%x",
498 EXTRACT_16BITS(&dp->icmp_id),
499 EXTRACT_16BITS(&dp->icmp_seq),
500 EXTRACT_32BITS(&dp->icmp_otime),
501 EXTRACT_32BITS(&dp->icmp_rtime),
502 EXTRACT_32BITS(&dp->icmp_ttime));
503 break;
504
505 default:
506 str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
507 break;
508 }
509 (void)printf("ICMP %s, length %u", str, plen);
510 if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
511 u_int16_t sum, icmp_sum;
512 if (TTEST2(*bp, plen)) {
513 sum = in_cksum((u_short*)dp, plen, 0);
514 if (sum != 0) {
515 icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
516 (void)printf(" (wrong icmp cksum %x (->%x)!)",
517 icmp_sum,
518 in_cksum_shouldbe(icmp_sum, sum));
519 }
520 }
521 }
522 if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
523 bp += 8;
524 (void)printf("\n\t");
525 ip = (struct ip *)bp;
526 snaplen = snapend - bp;
527 ip_print(bp, EXTRACT_16BITS(&ip->ip_len));
528 }
529
530 if (vflag >= 1 && plen > ICMP_EXTD_MINLEN) {
531 hlen = plen - ICMP_EXTD_MINLEN;
532 printf("\n\tMPLS extension v%u, checksum 0x%04x (unverified), length %u", /* FIXME */
533 ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version)),
534 EXTRACT_16BITS(dp->icmp_mpls_ext_checksum),
535 hlen);
536 hlen -= 4; /* subtract common header size */
537
538 obj_tptr = (u_int8_t *)dp->icmp_mpls_ext_data;
539
540 while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
541
542 icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr;
543 obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length);
544 obj_class_num = icmp_mpls_ext_object_header->class_num;
545 obj_ctype = icmp_mpls_ext_object_header->ctype;
546 obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t);
547
548 printf("\n\t %s Object (%u), Class-Type: %u, length %u",
549 tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num),
550 obj_class_num,
551 obj_ctype,
552 obj_tlen);
553
554 hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
555 obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t);
556
557 switch (obj_class_num) {
558 case 1:
559 switch(obj_ctype) {
560 case 1:
561 raw_label = EXTRACT_32BITS(obj_tptr);
562 printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label));
563 if (MPLS_STACK(raw_label))
564 printf(", [S]");
565 printf(", ttl %u", MPLS_TTL(raw_label));
566 break;
567 default:
568 print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
569 }
570 break;
571
572 /*
573 * FIXME those are the defined objects that lack a decoder
574 * you are welcome to contribute code ;-)
575 */
576 case 2:
577 default:
578 print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
579 break;
580 }
581 hlen -= obj_tlen;
582 obj_tptr += obj_tlen;
583 }
584 }
585
586 return;
587 trunc:
588 fputs("[|icmp]", stdout);
589 }