JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 | * |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 15 | * Original code by Hannes Gredler (hannes@juniper.net) |
| 16 | */ |
| 17 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 18 | /* \summary: IEEE 802.1ag Connectivity Fault Management (CFM) protocols printer */ |
| 19 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 20 | #ifdef HAVE_CONFIG_H |
| 21 | #include "config.h" |
| 22 | #endif |
| 23 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 24 | #include <netdissect-stdinc.h> |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 25 | |
| 26 | #include <stdio.h> |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 27 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 28 | #include "netdissect.h" |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 29 | #include "extract.h" |
| 30 | #include "ether.h" |
| 31 | #include "addrtoname.h" |
| 32 | #include "oui.h" |
| 33 | #include "af.h" |
| 34 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 35 | struct cfm_common_header_t { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 36 | uint8_t mdlevel_version; |
| 37 | uint8_t opcode; |
| 38 | uint8_t flags; |
| 39 | uint8_t first_tlv_offset; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 65 | uint8_t sequence[4]; |
| 66 | uint8_t ma_epi[2]; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 67 | uint8_t names[48]; |
| 68 | uint8_t itu_t_y_1731[16]; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * Timer Bases for the CCM Interval field. |
| 73 | * Expressed in units of seconds. |
| 74 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 75 | static const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600}; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 113 | uint8_t transaction_id[4]; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | struct cfm_ltm_t { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 117 | uint8_t transaction_id[4]; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 118 | uint8_t ttl; |
| 119 | uint8_t original_mac[ETHER_ADDR_LEN]; |
| 120 | uint8_t target_mac[ETHER_ADDR_LEN]; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 129 | uint8_t transaction_id[4]; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 130 | uint8_t ttl; |
| 131 | uint8_t replay_action; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | static const struct tok cfm_ltr_flag_values[] = { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 135 | { 0x80, "UseFDB Only"}, |
| 136 | { 0x40, "FwdYes"}, |
| 137 | { 0x20, "Terminal MEP"}, |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 175 | uint8_t type; |
| 176 | uint8_t length[2]; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 218 | static int |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 219 | cfm_network_addr_print(netdissect_options *ndo, |
| 220 | register const u_char *tptr) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 221 | { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 222 | u_int network_addr_type; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 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)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 234 | |
| 235 | /* |
| 236 | * Resolve the passed in Address. |
| 237 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 238 | switch(network_addr_type) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 239 | case AFNUM_INET: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 240 | ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 241 | break; |
| 242 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 243 | case AFNUM_INET6: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 244 | ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 245 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 246 | |
| 247 | default: |
| 248 | hexdump = TRUE; |
| 249 | break; |
| 250 | } |
| 251 | |
| 252 | return hexdump; |
| 253 | } |
| 254 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 255 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 256 | cfm_print(netdissect_options *ndo, |
| 257 | register const u_char *pptr, register u_int length) |
| 258 | { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 259 | const struct cfm_common_header_t *cfm_common_header; |
| 260 | const struct cfm_tlv_header_t *cfm_tlv_header; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 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; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 280 | if (length < sizeof(*cfm_common_header)) |
| 281 | goto tooshort; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 282 | ND_TCHECK(*cfm_common_header); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 283 | |
| 284 | /* |
| 285 | * Sanity checking of the header. |
| 286 | */ |
| 287 | if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 288 | ND_PRINT((ndo, "CFMv%u not supported, length %u", |
| 289 | CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 290 | return; |
| 291 | } |
| 292 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 293 | ND_PRINT((ndo, "CFMv%u %s, MD Level %u, length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 297 | length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 298 | |
| 299 | /* |
| 300 | * In non-verbose mode just print the opcode and md-level. |
| 301 | */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 302 | if (ndo->ndo_vflag < 1) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 303 | return; |
| 304 | } |
| 305 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 306 | ND_PRINT((ndo, "\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 307 | |
| 308 | tptr += sizeof(const struct cfm_common_header_t); |
| 309 | tlen = length - sizeof(struct cfm_common_header_t); |
| 310 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 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 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 319 | switch (cfm_common_header->opcode) { |
| 320 | case CFM_OPCODE_CCM: |
| 321 | msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 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); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 330 | |
| 331 | ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 332 | ND_PRINT((ndo, ", Flags [CCM Interval %u%s]", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 333 | ccm_interval, |
| 334 | cfm_common_header->flags & CFM_CCM_RDI_FLAG ? |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 335 | ", RDI" : "")); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 336 | |
| 337 | /* |
| 338 | * Resolve the CCM interval field. |
| 339 | */ |
| 340 | if (ccm_interval) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 341 | ND_PRINT((ndo, "\n\t CCM Interval %.3fs" |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 345 | ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 346 | } |
| 347 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 348 | ND_PRINT((ndo, "\n\t Sequence Number 0x%08x, MA-End-Point-ID 0x%04x", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 349 | EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 350 | EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 351 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 352 | namesp = msg_ptr.cfm_ccm->names; |
| 353 | names_data_remaining = sizeof(msg_ptr.cfm_ccm->names); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 354 | |
| 355 | /* |
| 356 | * Resolve the MD fields. |
| 357 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 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)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 370 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 371 | /* -2 for the MA short name format and length */ |
| 372 | if (md_namelength > names_data_remaining - 2) { |
| 373 | ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining - 2)); |
| 374 | return; |
| 375 | } |
| 376 | |
| 377 | md_name = namesp; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 378 | ND_PRINT((ndo, "\n\t MD Name: ")); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 379 | switch (md_nameformat) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 380 | case CFM_CCM_MD_FORMAT_DNS: |
| 381 | case CFM_CCM_MD_FORMAT_CHAR: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 382 | safeputs(ndo, md_name, md_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 383 | break; |
| 384 | |
| 385 | case CFM_CCM_MD_FORMAT_MAC: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 386 | if (md_namelength == 6) { |
| 387 | ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, |
| 388 | md_name))); |
| 389 | } else { |
| 390 | ND_PRINT((ndo, "\n\t MAC (length invalid)")); |
| 391 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 392 | break; |
| 393 | |
| 394 | /* FIXME add printers for those MD formats - hexdump for now */ |
| 395 | case CFM_CCM_MA_FORMAT_8021: |
| 396 | default: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 397 | print_unknown_data(ndo, md_name, "\n\t ", |
| 398 | md_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 399 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 400 | namesp += md_namelength; |
| 401 | names_data_remaining -= md_namelength; |
| 402 | } else { |
| 403 | ND_PRINT((ndo, "\n\t MD Name Format %s (%u)", |
| 404 | tok2str(cfm_md_nameformat_values, "Unknown", |
| 405 | md_nameformat), |
| 406 | md_nameformat)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | |
| 410 | /* |
| 411 | * Resolve the MA fields. |
| 412 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 413 | ma_nameformat = *namesp; |
| 414 | namesp++; |
| 415 | names_data_remaining--; /* We know this is != 0 */ |
| 416 | ma_namelength = *namesp; |
| 417 | namesp++; |
| 418 | names_data_remaining--; /* We know this is != 0 */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 419 | ND_PRINT((ndo, "\n\t MA Name-Format %s (%u), MA name length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 420 | tok2str(cfm_ma_nameformat_values, "Unknown", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 421 | ma_nameformat), |
| 422 | ma_nameformat, |
| 423 | ma_namelength)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 424 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 425 | if (ma_namelength > names_data_remaining) { |
| 426 | ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining)); |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | ma_name = namesp; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 431 | ND_PRINT((ndo, "\n\t MA Name: ")); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 432 | switch (ma_nameformat) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 433 | case CFM_CCM_MA_FORMAT_CHAR: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 434 | safeputs(ndo, ma_name, ma_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 435 | break; |
| 436 | |
| 437 | /* FIXME add printers for those MA formats - hexdump for now */ |
| 438 | case CFM_CCM_MA_FORMAT_8021: |
| 439 | case CFM_CCM_MA_FORMAT_VID: |
| 440 | case CFM_CCM_MA_FORMAT_INT: |
| 441 | case CFM_CCM_MA_FORMAT_VPN: |
| 442 | default: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 443 | print_unknown_data(ndo, ma_name, "\n\t ", ma_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 444 | } |
| 445 | break; |
| 446 | |
| 447 | case CFM_OPCODE_LTM: |
| 448 | msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 449 | if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltm)) { |
| 450 | ND_PRINT((ndo, " (too small 4, must be >= %lu)", |
| 451 | (unsigned long) sizeof(*msg_ptr.cfm_ltm))); |
| 452 | return; |
| 453 | } |
| 454 | if (tlen < sizeof(*msg_ptr.cfm_ltm)) |
| 455 | goto tooshort; |
| 456 | ND_TCHECK(*msg_ptr.cfm_ltm); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 457 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 458 | ND_PRINT((ndo, ", Flags [%s]", |
| 459 | bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 460 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 461 | ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 462 | EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 463 | msg_ptr.cfm_ltm->ttl)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 464 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 465 | ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s", |
| 466 | etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac), |
| 467 | etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 468 | break; |
| 469 | |
| 470 | case CFM_OPCODE_LTR: |
| 471 | msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 472 | if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltr)) { |
| 473 | ND_PRINT((ndo, " (too small 5, must be >= %lu)", |
| 474 | (unsigned long) sizeof(*msg_ptr.cfm_ltr))); |
| 475 | return; |
| 476 | } |
| 477 | if (tlen < sizeof(*msg_ptr.cfm_ltr)) |
| 478 | goto tooshort; |
| 479 | ND_TCHECK(*msg_ptr.cfm_ltr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 480 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 481 | ND_PRINT((ndo, ", Flags [%s]", |
| 482 | bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 483 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 484 | ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 485 | EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 486 | msg_ptr.cfm_ltr->ttl)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 487 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 488 | ND_PRINT((ndo, "\n\t Replay-Action %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 489 | tok2str(cfm_ltr_replay_action_values, |
| 490 | "Unknown", |
| 491 | msg_ptr.cfm_ltr->replay_action), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 492 | msg_ptr.cfm_ltr->replay_action)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 493 | break; |
| 494 | |
| 495 | /* |
| 496 | * No message decoder yet. |
| 497 | * Hexdump everything up until the start of the TLVs |
| 498 | */ |
| 499 | case CFM_OPCODE_LBR: |
| 500 | case CFM_OPCODE_LBM: |
| 501 | default: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 502 | print_unknown_data(ndo, tptr, "\n\t ", |
| 503 | tlen - cfm_common_header->first_tlv_offset); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 504 | break; |
| 505 | } |
| 506 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 507 | tptr += cfm_common_header->first_tlv_offset; |
| 508 | tlen -= cfm_common_header->first_tlv_offset; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 509 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 510 | while (tlen > 0) { |
| 511 | cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr; |
| 512 | |
| 513 | /* Enough to read the tlv type ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 514 | ND_TCHECK2(*tptr, 1); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 515 | cfm_tlv_type=cfm_tlv_header->type; |
| 516 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 517 | ND_PRINT((ndo, "\n\t%s TLV (0x%02x)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 518 | tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 519 | cfm_tlv_type)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 520 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 521 | if (cfm_tlv_type == CFM_TLV_END) { |
| 522 | /* Length is "Not present if the Type field is 0." */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 523 | return; |
| 524 | } |
| 525 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 526 | /* do we have the full tlv header ? */ |
| 527 | if (tlen < sizeof(struct cfm_tlv_header_t)) |
| 528 | goto tooshort; |
| 529 | ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t)); |
| 530 | cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length); |
| 531 | |
| 532 | ND_PRINT((ndo, ", length %u", cfm_tlv_len)); |
| 533 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 534 | tptr += sizeof(struct cfm_tlv_header_t); |
| 535 | tlen -= sizeof(struct cfm_tlv_header_t); |
| 536 | tlv_ptr = tptr; |
| 537 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 538 | /* do we have the full tlv ? */ |
| 539 | if (tlen < cfm_tlv_len) |
| 540 | goto tooshort; |
| 541 | ND_TCHECK2(*tptr, cfm_tlv_len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 542 | hexdump = FALSE; |
| 543 | |
| 544 | switch(cfm_tlv_type) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 545 | case CFM_TLV_PORT_STATUS: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 546 | if (cfm_tlv_len < 1) { |
| 547 | ND_PRINT((ndo, " (too short, must be >= 1)")); |
| 548 | return; |
| 549 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 550 | ND_PRINT((ndo, ", Status: %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 551 | tok2str(cfm_tlv_port_status_values, "Unknown", *tptr), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 552 | *tptr)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 553 | break; |
| 554 | |
| 555 | case CFM_TLV_INTERFACE_STATUS: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 556 | if (cfm_tlv_len < 1) { |
| 557 | ND_PRINT((ndo, " (too short, must be >= 1)")); |
| 558 | return; |
| 559 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 560 | ND_PRINT((ndo, ", Status: %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 561 | tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 562 | *tptr)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 563 | break; |
| 564 | |
| 565 | case CFM_TLV_PRIVATE: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 566 | if (cfm_tlv_len < 4) { |
| 567 | ND_PRINT((ndo, " (too short, must be >= 4)")); |
| 568 | return; |
| 569 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 570 | ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 571 | tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)), |
| 572 | EXTRACT_24BITS(tptr), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 573 | *(tptr + 3))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 574 | hexdump = TRUE; |
| 575 | break; |
| 576 | |
| 577 | case CFM_TLV_SENDER_ID: |
| 578 | { |
| 579 | u_int chassis_id_type, chassis_id_length; |
| 580 | u_int mgmt_addr_length; |
| 581 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 582 | if (cfm_tlv_len < 1) { |
| 583 | ND_PRINT((ndo, " (too short, must be >= 1)")); |
| 584 | return; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 585 | } |
| 586 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 587 | /* |
| 588 | * Get the Chassis ID length and check it. |
| 589 | */ |
| 590 | chassis_id_length = *tptr; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 591 | tptr++; |
| 592 | tlen--; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 593 | cfm_tlv_len--; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 594 | |
| 595 | if (chassis_id_length) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 596 | if (cfm_tlv_len < 1) { |
| 597 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
| 598 | return; |
| 599 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 600 | chassis_id_type = *tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 601 | cfm_tlv_len--; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 602 | ND_PRINT((ndo, "\n\t Chassis-ID Type %s (%u), Chassis-ID length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 603 | tok2str(cfm_tlv_senderid_chassisid_values, |
| 604 | "Unknown", |
| 605 | chassis_id_type), |
| 606 | chassis_id_type, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 607 | chassis_id_length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 608 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 609 | if (cfm_tlv_len < chassis_id_length) { |
| 610 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
| 611 | return; |
| 612 | } |
| 613 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 614 | switch (chassis_id_type) { |
| 615 | case CFM_CHASSIS_ID_MAC_ADDRESS: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 616 | ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 617 | break; |
| 618 | |
| 619 | case CFM_CHASSIS_ID_NETWORK_ADDRESS: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 620 | hexdump |= cfm_network_addr_print(ndo, tptr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 621 | break; |
| 622 | |
| 623 | case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */ |
| 624 | case CFM_CHASSIS_ID_INTERFACE_ALIAS: |
| 625 | case CFM_CHASSIS_ID_LOCAL: |
| 626 | case CFM_CHASSIS_ID_CHASSIS_COMPONENT: |
| 627 | case CFM_CHASSIS_ID_PORT_COMPONENT: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 628 | safeputs(ndo, tptr + 1, chassis_id_length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 629 | break; |
| 630 | |
| 631 | default: |
| 632 | hexdump = TRUE; |
| 633 | break; |
| 634 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 635 | cfm_tlv_len -= chassis_id_length; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 636 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 637 | tptr += 1 + chassis_id_length; |
| 638 | tlen -= 1 + chassis_id_length; |
| 639 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 640 | |
| 641 | /* |
| 642 | * Check if there is a Management Address. |
| 643 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 644 | if (cfm_tlv_len == 0) { |
| 645 | /* No, there isn't; we're done. */ |
| 646 | return; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 647 | } |
| 648 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 649 | mgmt_addr_length = *tptr; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 650 | tptr++; |
| 651 | tlen--; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 652 | cfm_tlv_len--; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 653 | if (mgmt_addr_length) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 654 | if (cfm_tlv_len < mgmt_addr_length) { |
| 655 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
| 656 | return; |
| 657 | } |
| 658 | cfm_tlv_len -= mgmt_addr_length; |
| 659 | /* |
| 660 | * XXX - this is an OID; print it as such. |
| 661 | */ |
| 662 | tptr += mgmt_addr_length; |
| 663 | tlen -= mgmt_addr_length; |
| 664 | |
| 665 | if (cfm_tlv_len < 1) { |
| 666 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
| 667 | return; |
| 668 | } |
| 669 | |
| 670 | mgmt_addr_length = *tptr; |
| 671 | tptr++; |
| 672 | tlen--; |
| 673 | cfm_tlv_len--; |
| 674 | if (mgmt_addr_length) { |
| 675 | if (cfm_tlv_len < mgmt_addr_length) { |
| 676 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
| 677 | return; |
| 678 | } |
| 679 | cfm_tlv_len -= mgmt_addr_length; |
| 680 | /* |
| 681 | * XXX - this is a TransportDomain; print it as such. |
| 682 | */ |
| 683 | tptr += mgmt_addr_length; |
| 684 | tlen -= mgmt_addr_length; |
| 685 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 686 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 687 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 688 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 689 | |
| 690 | /* |
| 691 | * FIXME those are the defined TLVs that lack a decoder |
| 692 | * you are welcome to contribute code ;-) |
| 693 | */ |
| 694 | |
| 695 | case CFM_TLV_DATA: |
| 696 | case CFM_TLV_REPLY_INGRESS: |
| 697 | case CFM_TLV_REPLY_EGRESS: |
| 698 | default: |
| 699 | hexdump = TRUE; |
| 700 | break; |
| 701 | } |
| 702 | /* do we want to see an additional hexdump ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 703 | if (hexdump || ndo->ndo_vflag > 1) |
| 704 | print_unknown_data(ndo, tlv_ptr, "\n\t ", cfm_tlv_len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 705 | |
| 706 | tptr+=cfm_tlv_len; |
| 707 | tlen-=cfm_tlv_len; |
| 708 | } |
| 709 | return; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame^] | 710 | |
| 711 | tooshort: |
| 712 | ND_PRINT((ndo, "\n\t\t packet is too short")); |
| 713 | return; |
| 714 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 715 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 716 | ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 717 | } |