]> The Tcpdump Group git mirrors - tcpdump/blob - print-cfm.c
Remove some trailing spaces
[tcpdump] / print-cfm.c
1 /*
2 * Copyright (c) 1998-2006 The TCPDUMP project
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
14 *
15 * Original code by Hannes Gredler (hannes@gredler.at)
16 */
17
18 /* \summary: IEEE 802.1ag Connectivity Fault Management (CFM) protocols printer */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <netdissect-stdinc.h>
25
26 #include <stdio.h>
27
28 #include "netdissect.h"
29 #include "extract.h"
30 #include "ether.h"
31 #include "addrtoname.h"
32 #include "oui.h"
33 #include "af.h"
34
35 struct cfm_common_header_t {
36 uint8_t mdlevel_version;
37 uint8_t opcode;
38 uint8_t flags;
39 uint8_t first_tlv_offset;
40 };
41
42 #define CFM_VERSION 0
43 #define CFM_EXTRACT_VERSION(x) (((x)&0x1f))
44 #define CFM_EXTRACT_MD_LEVEL(x) (((x)&0xe0)>>5)
45
46 #define CFM_OPCODE_CCM 1
47 #define CFM_OPCODE_LBR 2
48 #define CFM_OPCODE_LBM 3
49 #define CFM_OPCODE_LTR 4
50 #define CFM_OPCODE_LTM 5
51
52 static const struct tok cfm_opcode_values[] = {
53 { CFM_OPCODE_CCM, "Continuity Check Message"},
54 { CFM_OPCODE_LBR, "Loopback Reply"},
55 { CFM_OPCODE_LBM, "Loopback Message"},
56 { CFM_OPCODE_LTR, "Linktrace Reply"},
57 { CFM_OPCODE_LTM, "Linktrace Message"},
58 { 0, NULL}
59 };
60
61 /*
62 * Message Formats.
63 */
64 struct cfm_ccm_t {
65 uint8_t sequence[4];
66 uint8_t ma_epi[2];
67 uint8_t names[48];
68 uint8_t itu_t_y_1731[16];
69 };
70
71 /*
72 * Timer Bases for the CCM Interval field.
73 * Expressed in units of seconds.
74 */
75 static const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600};
76 #define CCM_INTERVAL_MIN_MULTIPLIER 3.25
77 #define CCM_INTERVAL_MAX_MULTIPLIER 3.5
78
79 #define CFM_CCM_RDI_FLAG 0x80
80 #define CFM_EXTRACT_CCM_INTERVAL(x) (((x)&0x07))
81
82 #define CFM_CCM_MD_FORMAT_8021 0
83 #define CFM_CCM_MD_FORMAT_NONE 1
84 #define CFM_CCM_MD_FORMAT_DNS 2
85 #define CFM_CCM_MD_FORMAT_MAC 3
86 #define CFM_CCM_MD_FORMAT_CHAR 4
87
88 static const struct tok cfm_md_nameformat_values[] = {
89 { CFM_CCM_MD_FORMAT_8021, "IEEE 802.1"},
90 { CFM_CCM_MD_FORMAT_NONE, "No MD Name present"},
91 { CFM_CCM_MD_FORMAT_DNS, "DNS string"},
92 { CFM_CCM_MD_FORMAT_MAC, "MAC + 16Bit Integer"},
93 { CFM_CCM_MD_FORMAT_CHAR, "Character string"},
94 { 0, NULL}
95 };
96
97 #define CFM_CCM_MA_FORMAT_8021 0
98 #define CFM_CCM_MA_FORMAT_VID 1
99 #define CFM_CCM_MA_FORMAT_CHAR 2
100 #define CFM_CCM_MA_FORMAT_INT 3
101 #define CFM_CCM_MA_FORMAT_VPN 4
102
103 static const struct tok cfm_ma_nameformat_values[] = {
104 { CFM_CCM_MA_FORMAT_8021, "IEEE 802.1"},
105 { CFM_CCM_MA_FORMAT_VID, "Primary VID"},
106 { CFM_CCM_MA_FORMAT_CHAR, "Character string"},
107 { CFM_CCM_MA_FORMAT_INT, "16Bit Integer"},
108 { CFM_CCM_MA_FORMAT_VPN, "RFC2685 VPN-ID"},
109 { 0, NULL}
110 };
111
112 struct cfm_lbm_t {
113 uint8_t transaction_id[4];
114 };
115
116 struct cfm_ltm_t {
117 uint8_t transaction_id[4];
118 uint8_t ttl;
119 uint8_t original_mac[ETHER_ADDR_LEN];
120 uint8_t target_mac[ETHER_ADDR_LEN];
121 };
122
123 static const struct tok cfm_ltm_flag_values[] = {
124 { 0x80, "Use Forwarding-DB only"},
125 { 0, NULL}
126 };
127
128 struct cfm_ltr_t {
129 uint8_t transaction_id[4];
130 uint8_t ttl;
131 uint8_t replay_action;
132 };
133
134 static const struct tok cfm_ltr_flag_values[] = {
135 { 0x80, "UseFDB Only"},
136 { 0x40, "FwdYes"},
137 { 0x20, "Terminal MEP"},
138 { 0, NULL}
139 };
140
141 static const struct tok cfm_ltr_replay_action_values[] = {
142 { 1, "Exact Match"},
143 { 2, "Filtering DB"},
144 { 3, "MIP CCM DB"},
145 { 0, NULL}
146 };
147
148
149 #define CFM_TLV_END 0
150 #define CFM_TLV_SENDER_ID 1
151 #define CFM_TLV_PORT_STATUS 2
152 #define CFM_TLV_INTERFACE_STATUS 3
153 #define CFM_TLV_DATA 4
154 #define CFM_TLV_REPLY_INGRESS 5
155 #define CFM_TLV_REPLY_EGRESS 6
156 #define CFM_TLV_PRIVATE 31
157
158 static const struct tok cfm_tlv_values[] = {
159 { CFM_TLV_END, "End"},
160 { CFM_TLV_SENDER_ID, "Sender ID"},
161 { CFM_TLV_PORT_STATUS, "Port status"},
162 { CFM_TLV_INTERFACE_STATUS, "Interface status"},
163 { CFM_TLV_DATA, "Data"},
164 { CFM_TLV_REPLY_INGRESS, "Reply Ingress"},
165 { CFM_TLV_REPLY_EGRESS, "Reply Egress"},
166 { CFM_TLV_PRIVATE, "Organization Specific"},
167 { 0, NULL}
168 };
169
170 /*
171 * TLVs
172 */
173
174 struct cfm_tlv_header_t {
175 uint8_t type;
176 uint8_t length[2];
177 };
178
179 /* FIXME define TLV formats */
180
181 static const struct tok cfm_tlv_port_status_values[] = {
182 { 1, "Blocked"},
183 { 2, "Up"},
184 { 0, NULL}
185 };
186
187 static const struct tok cfm_tlv_interface_status_values[] = {
188 { 1, "Up"},
189 { 2, "Down"},
190 { 3, "Testing"},
191 { 5, "Dormant"},
192 { 6, "not present"},
193 { 7, "lower Layer down"},
194 { 0, NULL}
195 };
196
197 #define CFM_CHASSIS_ID_CHASSIS_COMPONENT 1
198 #define CFM_CHASSIS_ID_INTERFACE_ALIAS 2
199 #define CFM_CHASSIS_ID_PORT_COMPONENT 3
200 #define CFM_CHASSIS_ID_MAC_ADDRESS 4
201 #define CFM_CHASSIS_ID_NETWORK_ADDRESS 5
202 #define CFM_CHASSIS_ID_INTERFACE_NAME 6
203 #define CFM_CHASSIS_ID_LOCAL 7
204
205 static const struct tok cfm_tlv_senderid_chassisid_values[] = {
206 { 0, "Reserved"},
207 { CFM_CHASSIS_ID_CHASSIS_COMPONENT, "Chassis component"},
208 { CFM_CHASSIS_ID_INTERFACE_ALIAS, "Interface alias"},
209 { CFM_CHASSIS_ID_PORT_COMPONENT, "Port component"},
210 { CFM_CHASSIS_ID_MAC_ADDRESS, "MAC address"},
211 { CFM_CHASSIS_ID_NETWORK_ADDRESS, "Network address"},
212 { CFM_CHASSIS_ID_INTERFACE_NAME, "Interface name"},
213 { CFM_CHASSIS_ID_LOCAL, "Locally assigned"},
214 { 0, NULL}
215 };
216
217
218 static int
219 cfm_network_addr_print(netdissect_options *ndo,
220 register const u_char *tptr)
221 {
222 u_int network_addr_type;
223 u_int hexdump = FALSE;
224
225 /*
226 * Altough AFIs are tpically 2 octects wide,
227 * 802.1ab specifies that this field width
228 * is only once octet
229 */
230 network_addr_type = *tptr;
231 ND_PRINT((ndo, "\n\t Network Address Type %s (%u)",
232 tok2str(af_values, "Unknown", network_addr_type),
233 network_addr_type));
234
235 /*
236 * Resolve the passed in Address.
237 */
238 switch(network_addr_type) {
239 case AFNUM_INET:
240 ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
241 break;
242
243 case AFNUM_INET6:
244 ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
245 break;
246
247 default:
248 hexdump = TRUE;
249 break;
250 }
251
252 return hexdump;
253 }
254
255 void
256 cfm_print(netdissect_options *ndo,
257 register const u_char *pptr, register u_int length)
258 {
259 const struct cfm_common_header_t *cfm_common_header;
260 const struct cfm_tlv_header_t *cfm_tlv_header;
261 const uint8_t *tptr, *tlv_ptr;
262 const uint8_t *namesp;
263 u_int names_data_remaining;
264 uint8_t md_nameformat, md_namelength;
265 const uint8_t *md_name;
266 uint8_t ma_nameformat, ma_namelength;
267 const uint8_t *ma_name;
268 u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
269
270
271 union {
272 const struct cfm_ccm_t *cfm_ccm;
273 const struct cfm_lbm_t *cfm_lbm;
274 const struct cfm_ltm_t *cfm_ltm;
275 const struct cfm_ltr_t *cfm_ltr;
276 } msg_ptr;
277
278 tptr=pptr;
279 cfm_common_header = (const struct cfm_common_header_t *)pptr;
280 if (length < sizeof(*cfm_common_header))
281 goto tooshort;
282 ND_TCHECK(*cfm_common_header);
283
284 /*
285 * Sanity checking of the header.
286 */
287 if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) {
288 ND_PRINT((ndo, "CFMv%u not supported, length %u",
289 CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length));
290 return;
291 }
292
293 ND_PRINT((ndo, "CFMv%u %s, MD Level %u, length %u",
294 CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version),
295 tok2str(cfm_opcode_values, "unknown (%u)", cfm_common_header->opcode),
296 CFM_EXTRACT_MD_LEVEL(cfm_common_header->mdlevel_version),
297 length));
298
299 /*
300 * In non-verbose mode just print the opcode and md-level.
301 */
302 if (ndo->ndo_vflag < 1) {
303 return;
304 }
305
306 ND_PRINT((ndo, "\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset));
307
308 tptr += sizeof(const struct cfm_common_header_t);
309 tlen = length - sizeof(struct cfm_common_header_t);
310
311 /*
312 * Sanity check the first TLV offset.
313 */
314 if (cfm_common_header->first_tlv_offset > tlen) {
315 ND_PRINT((ndo, " (too large, must be <= %u)", tlen));
316 return;
317 }
318
319 switch (cfm_common_header->opcode) {
320 case CFM_OPCODE_CCM:
321 msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr;
322 if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ccm)) {
323 ND_PRINT((ndo, " (too small 1, must be >= %lu)",
324 (unsigned long) sizeof(*msg_ptr.cfm_ccm)));
325 return;
326 }
327 if (tlen < sizeof(*msg_ptr.cfm_ccm))
328 goto tooshort;
329 ND_TCHECK(*msg_ptr.cfm_ccm);
330
331 ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags);
332 ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
333 ccm_interval,
334 cfm_common_header->flags & CFM_CCM_RDI_FLAG ?
335 ", RDI" : ""));
336
337 /*
338 * Resolve the CCM interval field.
339 */
340 if (ccm_interval) {
341 ND_PRINT((ndo, "\n\t CCM Interval %.3fs"
342 ", min CCM Lifetime %.3fs, max CCM Lifetime %.3fs",
343 ccm_interval_base[ccm_interval],
344 ccm_interval_base[ccm_interval] * CCM_INTERVAL_MIN_MULTIPLIER,
345 ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER));
346 }
347
348 ND_PRINT((ndo, "\n\t Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
349 EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence),
350 EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)));
351
352 namesp = msg_ptr.cfm_ccm->names;
353 names_data_remaining = sizeof(msg_ptr.cfm_ccm->names);
354
355 /*
356 * Resolve the MD fields.
357 */
358 md_nameformat = *namesp;
359 namesp++;
360 names_data_remaining--; /* We know this is != 0 */
361 if (md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
362 md_namelength = *namesp;
363 namesp++;
364 names_data_remaining--; /* We know this is !=0 */
365 ND_PRINT((ndo, "\n\t MD Name Format %s (%u), MD Name length %u",
366 tok2str(cfm_md_nameformat_values, "Unknown",
367 md_nameformat),
368 md_nameformat,
369 md_namelength));
370
371 /*
372 * -3 for the MA short name format and length and one byte
373 * of MA short name.
374 */
375 if (md_namelength > names_data_remaining - 3) {
376 ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining - 2));
377 return;
378 }
379
380 md_name = namesp;
381 ND_PRINT((ndo, "\n\t MD Name: "));
382 switch (md_nameformat) {
383 case CFM_CCM_MD_FORMAT_DNS:
384 case CFM_CCM_MD_FORMAT_CHAR:
385 safeputs(ndo, md_name, md_namelength);
386 break;
387
388 case CFM_CCM_MD_FORMAT_MAC:
389 if (md_namelength == 6) {
390 ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo,
391 md_name)));
392 } else {
393 ND_PRINT((ndo, "\n\t MAC (length invalid)"));
394 }
395 break;
396
397 /* FIXME add printers for those MD formats - hexdump for now */
398 case CFM_CCM_MA_FORMAT_8021:
399 default:
400 print_unknown_data(ndo, md_name, "\n\t ",
401 md_namelength);
402 }
403 namesp += md_namelength;
404 names_data_remaining -= md_namelength;
405 } else {
406 ND_PRINT((ndo, "\n\t MD Name Format %s (%u)",
407 tok2str(cfm_md_nameformat_values, "Unknown",
408 md_nameformat),
409 md_nameformat));
410 }
411
412
413 /*
414 * Resolve the MA fields.
415 */
416 ma_nameformat = *namesp;
417 namesp++;
418 names_data_remaining--; /* We know this is != 0 */
419 ma_namelength = *namesp;
420 namesp++;
421 names_data_remaining--; /* We know this is != 0 */
422 ND_PRINT((ndo, "\n\t MA Name-Format %s (%u), MA name length %u",
423 tok2str(cfm_ma_nameformat_values, "Unknown",
424 ma_nameformat),
425 ma_nameformat,
426 ma_namelength));
427
428 if (ma_namelength > names_data_remaining) {
429 ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining));
430 return;
431 }
432
433 ma_name = namesp;
434 ND_PRINT((ndo, "\n\t MA Name: "));
435 switch (ma_nameformat) {
436 case CFM_CCM_MA_FORMAT_CHAR:
437 safeputs(ndo, ma_name, ma_namelength);
438 break;
439
440 /* FIXME add printers for those MA formats - hexdump for now */
441 case CFM_CCM_MA_FORMAT_8021:
442 case CFM_CCM_MA_FORMAT_VID:
443 case CFM_CCM_MA_FORMAT_INT:
444 case CFM_CCM_MA_FORMAT_VPN:
445 default:
446 print_unknown_data(ndo, ma_name, "\n\t ", ma_namelength);
447 }
448 break;
449
450 case CFM_OPCODE_LTM:
451 msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr;
452 if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltm)) {
453 ND_PRINT((ndo, " (too small 4, must be >= %lu)",
454 (unsigned long) sizeof(*msg_ptr.cfm_ltm)));
455 return;
456 }
457 if (tlen < sizeof(*msg_ptr.cfm_ltm))
458 goto tooshort;
459 ND_TCHECK(*msg_ptr.cfm_ltm);
460
461 ND_PRINT((ndo, ", Flags [%s]",
462 bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
463
464 ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u",
465 EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id),
466 msg_ptr.cfm_ltm->ttl));
467
468 ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s",
469 etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
470 etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac)));
471 break;
472
473 case CFM_OPCODE_LTR:
474 msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
475 if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltr)) {
476 ND_PRINT((ndo, " (too small 5, must be >= %lu)",
477 (unsigned long) sizeof(*msg_ptr.cfm_ltr)));
478 return;
479 }
480 if (tlen < sizeof(*msg_ptr.cfm_ltr))
481 goto tooshort;
482 ND_TCHECK(*msg_ptr.cfm_ltr);
483
484 ND_PRINT((ndo, ", Flags [%s]",
485 bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
486
487 ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u",
488 EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id),
489 msg_ptr.cfm_ltr->ttl));
490
491 ND_PRINT((ndo, "\n\t Replay-Action %s (%u)",
492 tok2str(cfm_ltr_replay_action_values,
493 "Unknown",
494 msg_ptr.cfm_ltr->replay_action),
495 msg_ptr.cfm_ltr->replay_action));
496 break;
497
498 /*
499 * No message decoder yet.
500 * Hexdump everything up until the start of the TLVs
501 */
502 case CFM_OPCODE_LBR:
503 case CFM_OPCODE_LBM:
504 default:
505 print_unknown_data(ndo, tptr, "\n\t ",
506 tlen - cfm_common_header->first_tlv_offset);
507 break;
508 }
509
510 tptr += cfm_common_header->first_tlv_offset;
511 tlen -= cfm_common_header->first_tlv_offset;
512
513 while (tlen > 0) {
514 cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr;
515
516 /* Enough to read the tlv type ? */
517 ND_TCHECK2(*tptr, 1);
518 cfm_tlv_type=cfm_tlv_header->type;
519
520 ND_PRINT((ndo, "\n\t%s TLV (0x%02x)",
521 tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type),
522 cfm_tlv_type));
523
524 if (cfm_tlv_type == CFM_TLV_END) {
525 /* Length is "Not present if the Type field is 0." */
526 return;
527 }
528
529 /* do we have the full tlv header ? */
530 if (tlen < sizeof(struct cfm_tlv_header_t))
531 goto tooshort;
532 ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
533 cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
534
535 ND_PRINT((ndo, ", length %u", cfm_tlv_len));
536
537 tptr += sizeof(struct cfm_tlv_header_t);
538 tlen -= sizeof(struct cfm_tlv_header_t);
539 tlv_ptr = tptr;
540
541 /* do we have the full tlv ? */
542 if (tlen < cfm_tlv_len)
543 goto tooshort;
544 ND_TCHECK2(*tptr, cfm_tlv_len);
545 hexdump = FALSE;
546
547 switch(cfm_tlv_type) {
548 case CFM_TLV_PORT_STATUS:
549 if (cfm_tlv_len < 1) {
550 ND_PRINT((ndo, " (too short, must be >= 1)"));
551 return;
552 }
553 ND_PRINT((ndo, ", Status: %s (%u)",
554 tok2str(cfm_tlv_port_status_values, "Unknown", *tptr),
555 *tptr));
556 break;
557
558 case CFM_TLV_INTERFACE_STATUS:
559 if (cfm_tlv_len < 1) {
560 ND_PRINT((ndo, " (too short, must be >= 1)"));
561 return;
562 }
563 ND_PRINT((ndo, ", Status: %s (%u)",
564 tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr),
565 *tptr));
566 break;
567
568 case CFM_TLV_PRIVATE:
569 if (cfm_tlv_len < 4) {
570 ND_PRINT((ndo, " (too short, must be >= 4)"));
571 return;
572 }
573 ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u",
574 tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)),
575 EXTRACT_24BITS(tptr),
576 *(tptr + 3)));
577 hexdump = TRUE;
578 break;
579
580 case CFM_TLV_SENDER_ID:
581 {
582 u_int chassis_id_type, chassis_id_length;
583 u_int mgmt_addr_length;
584
585 if (cfm_tlv_len < 1) {
586 ND_PRINT((ndo, " (too short, must be >= 1)"));
587 return;
588 }
589
590 /*
591 * Get the Chassis ID length and check it.
592 */
593 chassis_id_length = *tptr;
594 tptr++;
595 tlen--;
596 cfm_tlv_len--;
597
598 if (chassis_id_length) {
599 if (cfm_tlv_len < 1) {
600 ND_PRINT((ndo, "\n\t (TLV too short)"));
601 return;
602 }
603 chassis_id_type = *tptr;
604 cfm_tlv_len--;
605 ND_PRINT((ndo, "\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
606 tok2str(cfm_tlv_senderid_chassisid_values,
607 "Unknown",
608 chassis_id_type),
609 chassis_id_type,
610 chassis_id_length));
611
612 if (cfm_tlv_len < chassis_id_length) {
613 ND_PRINT((ndo, "\n\t (TLV too short)"));
614 return;
615 }
616
617 switch (chassis_id_type) {
618 case CFM_CHASSIS_ID_MAC_ADDRESS:
619 ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1)));
620 break;
621
622 case CFM_CHASSIS_ID_NETWORK_ADDRESS:
623 hexdump |= cfm_network_addr_print(ndo, tptr);
624 break;
625
626 case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
627 case CFM_CHASSIS_ID_INTERFACE_ALIAS:
628 case CFM_CHASSIS_ID_LOCAL:
629 case CFM_CHASSIS_ID_CHASSIS_COMPONENT:
630 case CFM_CHASSIS_ID_PORT_COMPONENT:
631 safeputs(ndo, tptr + 1, chassis_id_length);
632 break;
633
634 default:
635 hexdump = TRUE;
636 break;
637 }
638 cfm_tlv_len -= chassis_id_length;
639
640 tptr += 1 + chassis_id_length;
641 tlen -= 1 + chassis_id_length;
642 }
643
644 /*
645 * Check if there is a Management Address.
646 */
647 if (cfm_tlv_len == 0) {
648 /* No, there isn't; we're done. */
649 return;
650 }
651
652 mgmt_addr_length = *tptr;
653 tptr++;
654 tlen--;
655 cfm_tlv_len--;
656 if (mgmt_addr_length) {
657 if (cfm_tlv_len < mgmt_addr_length) {
658 ND_PRINT((ndo, "\n\t (TLV too short)"));
659 return;
660 }
661 cfm_tlv_len -= mgmt_addr_length;
662 /*
663 * XXX - this is an OID; print it as such.
664 */
665 tptr += mgmt_addr_length;
666 tlen -= mgmt_addr_length;
667
668 if (cfm_tlv_len < 1) {
669 ND_PRINT((ndo, "\n\t (TLV too short)"));
670 return;
671 }
672
673 mgmt_addr_length = *tptr;
674 tptr++;
675 tlen--;
676 cfm_tlv_len--;
677 if (mgmt_addr_length) {
678 if (cfm_tlv_len < mgmt_addr_length) {
679 ND_PRINT((ndo, "\n\t (TLV too short)"));
680 return;
681 }
682 cfm_tlv_len -= mgmt_addr_length;
683 /*
684 * XXX - this is a TransportDomain; print it as such.
685 */
686 tptr += mgmt_addr_length;
687 tlen -= mgmt_addr_length;
688 }
689 }
690 break;
691 }
692
693 /*
694 * FIXME those are the defined TLVs that lack a decoder
695 * you are welcome to contribute code ;-)
696 */
697
698 case CFM_TLV_DATA:
699 case CFM_TLV_REPLY_INGRESS:
700 case CFM_TLV_REPLY_EGRESS:
701 default:
702 hexdump = TRUE;
703 break;
704 }
705 /* do we want to see an additional hexdump ? */
706 if (hexdump || ndo->ndo_vflag > 1)
707 print_unknown_data(ndo, tlv_ptr, "\n\t ", cfm_tlv_len);
708
709 tptr+=cfm_tlv_len;
710 tlen-=cfm_tlv_len;
711 }
712 return;
713
714 tooshort:
715 ND_PRINT((ndo, "\n\t\t packet is too short"));
716 return;
717
718 trunc:
719 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
720 }