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