Home | History | Annotate | Line # | Download | only in dist
print-cfm.c revision 1.1.1.6
      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  * Support for the IEEE Connectivity Fault Management Protocols as per 802.1ag.
     16  *
     17  * Original code by Hannes Gredler (hannes (at) juniper.net)
     18  */
     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, "Continouity 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 md_nameformat;
     68     uint8_t md_namelength;
     69     uint8_t md_name[46]; /* md name and short ma name */
     70     uint8_t reserved_itu[16];
     71     uint8_t reserved[6];
     72 };
     73 
     74 /*
     75  * Timer Bases for the CCM Interval field.
     76  * Expressed in units of seconds.
     77  */
     78 const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600};
     79 #define CCM_INTERVAL_MIN_MULTIPLIER 3.25
     80 #define CCM_INTERVAL_MAX_MULTIPLIER 3.5
     81 
     82 #define CFM_CCM_RDI_FLAG 0x80
     83 #define CFM_EXTRACT_CCM_INTERVAL(x) (((x)&0x07))
     84 
     85 #define CFM_CCM_MD_FORMAT_8021 0
     86 #define CFM_CCM_MD_FORMAT_NONE 1
     87 #define CFM_CCM_MD_FORMAT_DNS  2
     88 #define CFM_CCM_MD_FORMAT_MAC  3
     89 #define CFM_CCM_MD_FORMAT_CHAR 4
     90 
     91 static const struct tok cfm_md_nameformat_values[] = {
     92     { CFM_CCM_MD_FORMAT_8021, "IEEE 802.1"},
     93     { CFM_CCM_MD_FORMAT_NONE, "No MD Name present"},
     94     { CFM_CCM_MD_FORMAT_DNS, "DNS string"},
     95     { CFM_CCM_MD_FORMAT_MAC, "MAC + 16Bit Integer"},
     96     { CFM_CCM_MD_FORMAT_CHAR, "Character string"},
     97     { 0, NULL}
     98 };
     99 
    100 #define CFM_CCM_MA_FORMAT_8021 0
    101 #define CFM_CCM_MA_FORMAT_VID  1
    102 #define CFM_CCM_MA_FORMAT_CHAR 2
    103 #define CFM_CCM_MA_FORMAT_INT  3
    104 #define CFM_CCM_MA_FORMAT_VPN  4
    105 
    106 static const struct tok cfm_ma_nameformat_values[] = {
    107     { CFM_CCM_MA_FORMAT_8021, "IEEE 802.1"},
    108     { CFM_CCM_MA_FORMAT_VID, "Primary VID"},
    109     { CFM_CCM_MA_FORMAT_CHAR, "Character string"},
    110     { CFM_CCM_MA_FORMAT_INT, "16Bit Integer"},
    111     { CFM_CCM_MA_FORMAT_VPN, "RFC2685 VPN-ID"},
    112     { 0, NULL}
    113 };
    114 
    115 struct cfm_lbm_t {
    116     uint8_t transaction_id[4];
    117     uint8_t reserved[4];
    118 };
    119 
    120 struct cfm_ltm_t {
    121     uint8_t transaction_id[4];
    122     uint8_t egress_id[8];
    123     uint8_t ttl;
    124     uint8_t original_mac[ETHER_ADDR_LEN];
    125     uint8_t target_mac[ETHER_ADDR_LEN];
    126     uint8_t reserved[3];
    127 };
    128 
    129 static const struct tok cfm_ltm_flag_values[] = {
    130     { 0x80, "Use Forwarding-DB only"},
    131     { 0, NULL}
    132 };
    133 
    134 struct cfm_ltr_t {
    135     uint8_t transaction_id[4];
    136     uint8_t last_egress_id[8];
    137     uint8_t next_egress_id[8];
    138     uint8_t ttl;
    139     uint8_t replay_action;
    140     uint8_t reserved[6];
    141 };
    142 
    143 static const struct tok cfm_ltr_flag_values[] = {
    144     { 0x80, "UseFDB Only"},
    145     { 0x40, "FwdYes"},
    146     { 0x20, "Terminal MEP"},
    147     { 0, NULL}
    148 };
    149 
    150 static const struct tok cfm_ltr_replay_action_values[] = {
    151     { 1, "Exact Match"},
    152     { 2, "Filtering DB"},
    153     { 3, "MIP CCM DB"},
    154     { 0, NULL}
    155 };
    156 
    157 
    158 #define CFM_TLV_END 0
    159 #define CFM_TLV_SENDER_ID 1
    160 #define CFM_TLV_PORT_STATUS 2
    161 #define CFM_TLV_INTERFACE_STATUS 3
    162 #define CFM_TLV_DATA 4
    163 #define CFM_TLV_REPLY_INGRESS 5
    164 #define CFM_TLV_REPLY_EGRESS 6
    165 #define CFM_TLV_PRIVATE 31
    166 
    167 static const struct tok cfm_tlv_values[] = {
    168     { CFM_TLV_END, "End"},
    169     { CFM_TLV_SENDER_ID, "Sender ID"},
    170     { CFM_TLV_PORT_STATUS, "Port status"},
    171     { CFM_TLV_INTERFACE_STATUS, "Interface status"},
    172     { CFM_TLV_DATA, "Data"},
    173     { CFM_TLV_REPLY_INGRESS, "Reply Ingress"},
    174     { CFM_TLV_REPLY_EGRESS, "Reply Egress"},
    175     { CFM_TLV_PRIVATE, "Organization Specific"},
    176     { 0, NULL}
    177 };
    178 
    179 /*
    180  * TLVs
    181  */
    182 
    183 struct cfm_tlv_header_t {
    184     uint8_t type;
    185     uint8_t length[2];
    186 };
    187 
    188 /* FIXME define TLV formats */
    189 
    190 static const struct tok cfm_tlv_port_status_values[] = {
    191     { 1, "Blocked"},
    192     { 2, "Up"},
    193     { 0, NULL}
    194 };
    195 
    196 static const struct tok cfm_tlv_interface_status_values[] = {
    197     { 1, "Up"},
    198     { 2, "Down"},
    199     { 3, "Testing"},
    200     { 5, "Dormant"},
    201     { 6, "not present"},
    202     { 7, "lower Layer down"},
    203     { 0, NULL}
    204 };
    205 
    206 #define CFM_CHASSIS_ID_CHASSIS_COMPONENT 1
    207 #define CFM_CHASSIS_ID_INTERFACE_ALIAS 2
    208 #define CFM_CHASSIS_ID_PORT_COMPONENT 3
    209 #define CFM_CHASSIS_ID_MAC_ADDRESS 4
    210 #define CFM_CHASSIS_ID_NETWORK_ADDRESS 5
    211 #define CFM_CHASSIS_ID_INTERFACE_NAME 6
    212 #define CFM_CHASSIS_ID_LOCAL 7
    213 
    214 static const struct tok cfm_tlv_senderid_chassisid_values[] = {
    215     { 0, "Reserved"},
    216     { CFM_CHASSIS_ID_CHASSIS_COMPONENT, "Chassis component"},
    217     { CFM_CHASSIS_ID_INTERFACE_ALIAS, "Interface alias"},
    218     { CFM_CHASSIS_ID_PORT_COMPONENT, "Port component"},
    219     { CFM_CHASSIS_ID_MAC_ADDRESS, "MAC address"},
    220     { CFM_CHASSIS_ID_NETWORK_ADDRESS, "Network address"},
    221     { CFM_CHASSIS_ID_INTERFACE_NAME, "Interface name"},
    222     { CFM_CHASSIS_ID_LOCAL, "Locally assigned"},
    223     { 0, NULL}
    224 };
    225 
    226 
    227 static int
    228 cfm_mgmt_addr_print(netdissect_options *ndo,
    229                     register const u_char *tptr)
    230 {
    231     u_int mgmt_addr_type;
    232     u_int hexdump =  FALSE;
    233 
    234     /*
    235      * Altough AFIs are tpically 2 octects wide,
    236      * 802.1ab specifies that this field width
    237      * is only once octet
    238      */
    239     mgmt_addr_type = *tptr;
    240     ND_PRINT((ndo, "\n\t  Management Address Type %s (%u)",
    241            tok2str(af_values, "Unknown", mgmt_addr_type),
    242            mgmt_addr_type));
    243 
    244     /*
    245      * Resolve the passed in Address.
    246      */
    247     switch(mgmt_addr_type) {
    248     case AFNUM_INET:
    249         ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
    250         break;
    251 
    252     case AFNUM_INET6:
    253         ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
    254         break;
    255 
    256     default:
    257         hexdump = TRUE;
    258         break;
    259     }
    260 
    261     return hexdump;
    262 }
    263 
    264 /*
    265  * The egress-ID string is a 16-Bit string plus a MAC address.
    266  */
    267 static const char *
    268 cfm_egress_id_string(netdissect_options *ndo, register const u_char *tptr)
    269 {
    270     static char egress_id_buffer[80];
    271 
    272     snprintf(egress_id_buffer, sizeof(egress_id_buffer),
    273              "MAC 0x%4x-%s",
    274              EXTRACT_16BITS(tptr),
    275              etheraddr_string(ndo, tptr+2));
    276 
    277     return egress_id_buffer;
    278 }
    279 
    280 void
    281 cfm_print(netdissect_options *ndo,
    282           register const u_char *pptr, register u_int length)
    283 {
    284     const struct cfm_common_header_t *cfm_common_header;
    285     const struct cfm_tlv_header_t *cfm_tlv_header;
    286     const uint8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
    287     u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
    288 
    289 
    290     union {
    291         const struct cfm_ccm_t *cfm_ccm;
    292         const struct cfm_lbm_t *cfm_lbm;
    293         const struct cfm_ltm_t *cfm_ltm;
    294         const struct cfm_ltr_t *cfm_ltr;
    295     } msg_ptr;
    296 
    297     tptr=pptr;
    298     cfm_common_header = (const struct cfm_common_header_t *)pptr;
    299     ND_TCHECK(*cfm_common_header);
    300 
    301     /*
    302      * Sanity checking of the header.
    303      */
    304     if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) {
    305 	ND_PRINT((ndo, "CFMv%u not supported, length %u",
    306                CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length));
    307 	return;
    308     }
    309 
    310     ND_PRINT((ndo, "CFMv%u %s, MD Level %u, length %u",
    311            CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version),
    312            tok2str(cfm_opcode_values, "unknown (%u)", cfm_common_header->opcode),
    313            CFM_EXTRACT_MD_LEVEL(cfm_common_header->mdlevel_version),
    314            length));
    315 
    316     /*
    317      * In non-verbose mode just print the opcode and md-level.
    318      */
    319     if (ndo->ndo_vflag < 1) {
    320         return;
    321     }
    322 
    323     ND_PRINT((ndo, "\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset));
    324 
    325     tptr += sizeof(const struct cfm_common_header_t);
    326     tlen = length - sizeof(struct cfm_common_header_t);
    327 
    328     switch (cfm_common_header->opcode) {
    329     case CFM_OPCODE_CCM:
    330         msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr;
    331 
    332         ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags);
    333         ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
    334                ccm_interval,
    335                cfm_common_header->flags & CFM_CCM_RDI_FLAG ?
    336                ", RDI" : ""));
    337 
    338         /*
    339          * Resolve the CCM interval field.
    340          */
    341         if (ccm_interval) {
    342             ND_PRINT((ndo, "\n\t  CCM Interval %.3fs"
    343                    ", min CCM Lifetime %.3fs, max CCM Lifetime %.3fs",
    344                    ccm_interval_base[ccm_interval],
    345                    ccm_interval_base[ccm_interval] * CCM_INTERVAL_MIN_MULTIPLIER,
    346                    ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER));
    347         }
    348 
    349         ND_PRINT((ndo, "\n\t  Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
    350                EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence),
    351                EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)));
    352 
    353 
    354         /*
    355          * Resolve the MD fields.
    356          */
    357         ND_PRINT((ndo, "\n\t  MD Name Format %s (%u), MD Name length %u",
    358                tok2str(cfm_md_nameformat_values, "Unknown",
    359                        msg_ptr.cfm_ccm->md_nameformat),
    360                msg_ptr.cfm_ccm->md_nameformat,
    361                msg_ptr.cfm_ccm->md_namelength));
    362 
    363         if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
    364             ND_PRINT((ndo, "\n\t  MD Name: "));
    365             switch (msg_ptr.cfm_ccm->md_nameformat) {
    366             case CFM_CCM_MD_FORMAT_DNS:
    367             case CFM_CCM_MD_FORMAT_CHAR:
    368                 safeputs(ndo, msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength);
    369                 break;
    370 
    371             case CFM_CCM_MD_FORMAT_MAC:
    372                 ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(ndo,
    373                            msg_ptr.cfm_ccm->md_name)));
    374                 break;
    375 
    376                 /* FIXME add printers for those MD formats - hexdump for now */
    377             case CFM_CCM_MA_FORMAT_8021:
    378             default:
    379                 print_unknown_data(ndo, msg_ptr.cfm_ccm->md_name, "\n\t    ",
    380                                    msg_ptr.cfm_ccm->md_namelength);
    381             }
    382         }
    383 
    384 
    385         /*
    386          * Resolve the MA fields.
    387          */
    388         ma_nameformat = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength;
    389         ma_namelength = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 1;
    390         ma_name = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 2;
    391 
    392         ND_PRINT((ndo, "\n\t  MA Name-Format %s (%u), MA name length %u",
    393                tok2str(cfm_ma_nameformat_values, "Unknown",
    394                        *ma_nameformat),
    395                *ma_nameformat,
    396                *ma_namelength));
    397 
    398         ND_PRINT((ndo, "\n\t  MA Name: "));
    399         switch (*ma_nameformat) {
    400         case CFM_CCM_MA_FORMAT_CHAR:
    401             safeputs(ndo, ma_name, *ma_namelength);
    402             break;
    403 
    404             /* FIXME add printers for those MA formats - hexdump for now */
    405         case CFM_CCM_MA_FORMAT_8021:
    406         case CFM_CCM_MA_FORMAT_VID:
    407         case CFM_CCM_MA_FORMAT_INT:
    408         case CFM_CCM_MA_FORMAT_VPN:
    409         default:
    410             print_unknown_data(ndo, ma_name, "\n\t    ", *ma_namelength);
    411         }
    412         break;
    413 
    414     case CFM_OPCODE_LTM:
    415         msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr;
    416 
    417         ND_PRINT((ndo, ", Flags [%s]",
    418                bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
    419 
    420         ND_PRINT((ndo, "\n\t  Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
    421                EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id),
    422                cfm_egress_id_string(ndo, msg_ptr.cfm_ltm->egress_id),
    423                msg_ptr.cfm_ltm->ttl));
    424 
    425         ND_PRINT((ndo, "\n\t  Original-MAC %s, Target-MAC %s",
    426                etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
    427                etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac)));
    428         break;
    429 
    430     case CFM_OPCODE_LTR:
    431         msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
    432 
    433         ND_PRINT((ndo, ", Flags [%s]",
    434                bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
    435 
    436         ND_PRINT((ndo, "\n\t  Transaction-ID 0x%08x, Last-Egress-ID %s",
    437                EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id),
    438                cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->last_egress_id)));
    439 
    440         ND_PRINT((ndo, "\n\t  Next-Egress-ID %s, ttl %u",
    441                cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->next_egress_id),
    442                msg_ptr.cfm_ltr->ttl));
    443 
    444         ND_PRINT((ndo, "\n\t  Replay-Action %s (%u)",
    445                tok2str(cfm_ltr_replay_action_values,
    446                        "Unknown",
    447                        msg_ptr.cfm_ltr->replay_action),
    448                msg_ptr.cfm_ltr->replay_action));
    449         break;
    450 
    451         /*
    452          * No message decoder yet.
    453          * Hexdump everything up until the start of the TLVs
    454          */
    455     case CFM_OPCODE_LBR:
    456     case CFM_OPCODE_LBM:
    457     default:
    458         if (tlen > cfm_common_header->first_tlv_offset) {
    459             print_unknown_data(ndo, tptr, "\n\t  ",
    460                                tlen -  cfm_common_header->first_tlv_offset);
    461         }
    462         break;
    463     }
    464 
    465     /*
    466      * Sanity check for not walking off.
    467      */
    468     if (tlen <= cfm_common_header->first_tlv_offset) {
    469         return;
    470     }
    471 
    472     tptr += cfm_common_header->first_tlv_offset;
    473     tlen -= cfm_common_header->first_tlv_offset;
    474 
    475     while (tlen > 0) {
    476         cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr;
    477 
    478         /* Enough to read the tlv type ? */
    479         ND_TCHECK2(*tptr, 1);
    480         cfm_tlv_type=cfm_tlv_header->type;
    481 
    482         if (cfm_tlv_type != CFM_TLV_END) {
    483             /* did we capture enough for fully decoding the object header ? */
    484             ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
    485             cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
    486         } else {
    487             cfm_tlv_len = 0;
    488         }
    489 
    490         ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
    491                tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type),
    492                cfm_tlv_type,
    493                cfm_tlv_len));
    494 
    495         /* sanity check for not walking off and infinite loop check. */
    496         if ((cfm_tlv_type != CFM_TLV_END) &&
    497             ((cfm_tlv_len + sizeof(struct cfm_tlv_header_t) > tlen) ||
    498              (!cfm_tlv_len))) {
    499             print_unknown_data(ndo, tptr, "\n\t  ", tlen);
    500             return;
    501         }
    502 
    503         tptr += sizeof(struct cfm_tlv_header_t);
    504         tlen -= sizeof(struct cfm_tlv_header_t);
    505         tlv_ptr = tptr;
    506 
    507         /* did we capture enough for fully decoding the object ? */
    508         if (cfm_tlv_type != CFM_TLV_END) {
    509             ND_TCHECK2(*tptr, cfm_tlv_len);
    510         }
    511         hexdump = FALSE;
    512 
    513         switch(cfm_tlv_type) {
    514         case CFM_TLV_END:
    515             /* we are done - bail out */
    516             return;
    517 
    518         case CFM_TLV_PORT_STATUS:
    519             ND_PRINT((ndo, ", Status: %s (%u)",
    520                    tok2str(cfm_tlv_port_status_values, "Unknown", *tptr),
    521                    *tptr));
    522             break;
    523 
    524         case CFM_TLV_INTERFACE_STATUS:
    525             ND_PRINT((ndo, ", Status: %s (%u)",
    526                    tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr),
    527                    *tptr));
    528             break;
    529 
    530         case CFM_TLV_PRIVATE:
    531             ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u",
    532                    tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)),
    533                    EXTRACT_24BITS(tptr),
    534                    *(tptr + 3)));
    535             hexdump = TRUE;
    536             break;
    537 
    538         case CFM_TLV_SENDER_ID:
    539         {
    540             u_int chassis_id_type, chassis_id_length;
    541             u_int mgmt_addr_length;
    542 
    543             /*
    544              * Check if there is a Chassis-ID.
    545              */
    546             chassis_id_length = *tptr;
    547             if (chassis_id_length > tlen) {
    548                 hexdump = TRUE;
    549                 break;
    550             }
    551 
    552             tptr++;
    553             tlen--;
    554 
    555             if (chassis_id_length) {
    556                 chassis_id_type = *tptr;
    557                 ND_PRINT((ndo, "\n\t  Chassis-ID Type %s (%u), Chassis-ID length %u",
    558                        tok2str(cfm_tlv_senderid_chassisid_values,
    559                                "Unknown",
    560                                chassis_id_type),
    561                        chassis_id_type,
    562                        chassis_id_length));
    563 
    564                 switch (chassis_id_type) {
    565                 case CFM_CHASSIS_ID_MAC_ADDRESS:
    566                     ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(ndo, tptr + 1)));
    567                     break;
    568 
    569                 case CFM_CHASSIS_ID_NETWORK_ADDRESS:
    570                     hexdump |= cfm_mgmt_addr_print(ndo, tptr);
    571                     break;
    572 
    573                 case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
    574                 case CFM_CHASSIS_ID_INTERFACE_ALIAS:
    575                 case CFM_CHASSIS_ID_LOCAL:
    576                 case CFM_CHASSIS_ID_CHASSIS_COMPONENT:
    577                 case CFM_CHASSIS_ID_PORT_COMPONENT:
    578                     safeputs(ndo, tptr + 1, chassis_id_length);
    579                     break;
    580 
    581                 default:
    582                     hexdump = TRUE;
    583                     break;
    584                 }
    585             }
    586 
    587             tptr += chassis_id_length;
    588             tlen -= chassis_id_length;
    589 
    590             /*
    591              * Check if there is a Management Address.
    592              */
    593             mgmt_addr_length = *tptr;
    594             if (mgmt_addr_length > tlen) {
    595                 hexdump = TRUE;
    596                 break;
    597             }
    598 
    599             tptr++;
    600             tlen--;
    601 
    602             if (mgmt_addr_length) {
    603                 hexdump |= cfm_mgmt_addr_print(ndo, tptr);
    604             }
    605 
    606             tptr += mgmt_addr_length;
    607             tlen -= mgmt_addr_length;
    608 
    609         }
    610         break;
    611 
    612             /*
    613              * FIXME those are the defined TLVs that lack a decoder
    614              * you are welcome to contribute code ;-)
    615              */
    616 
    617         case CFM_TLV_DATA:
    618         case CFM_TLV_REPLY_INGRESS:
    619         case CFM_TLV_REPLY_EGRESS:
    620         default:
    621             hexdump = TRUE;
    622             break;
    623         }
    624         /* do we want to see an additional hexdump ? */
    625         if (hexdump || ndo->ndo_vflag > 1)
    626             print_unknown_data(ndo, tlv_ptr, "\n\t  ", cfm_tlv_len);
    627 
    628         tptr+=cfm_tlv_len;
    629         tlen-=cfm_tlv_len;
    630     }
    631     return;
    632 trunc:
    633     ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
    634 }
    635