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 | * |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 15 | * Original code by Hannes Gredler (hannes@gredler.at) |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 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, |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 220 | register const u_char *tptr, const u_int length) |
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 | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 230 | if (length < 1) { |
| 231 | ND_PRINT((ndo, "\n\t Network Address Type (invalid, no data")); |
| 232 | return hexdump; |
| 233 | } |
| 234 | /* The calling function must make any due ND_TCHECK calls. */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 235 | network_addr_type = *tptr; |
| 236 | ND_PRINT((ndo, "\n\t Network Address Type %s (%u)", |
| 237 | tok2str(af_values, "Unknown", network_addr_type), |
| 238 | network_addr_type)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 239 | |
| 240 | /* |
| 241 | * Resolve the passed in Address. |
| 242 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 243 | switch(network_addr_type) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 244 | case AFNUM_INET: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 245 | if (length != 1 + 4) { |
| 246 | ND_PRINT((ndo, "(invalid IPv4 address length %u)", length - 1)); |
| 247 | hexdump = TRUE; |
| 248 | break; |
| 249 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 250 | ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 251 | break; |
| 252 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 253 | case AFNUM_INET6: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 254 | if (length != 1 + 16) { |
| 255 | ND_PRINT((ndo, "(invalid IPv6 address length %u)", length - 1)); |
| 256 | hexdump = TRUE; |
| 257 | break; |
| 258 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 259 | ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 260 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 261 | |
| 262 | default: |
| 263 | hexdump = TRUE; |
| 264 | break; |
| 265 | } |
| 266 | |
| 267 | return hexdump; |
| 268 | } |
| 269 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 270 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 271 | cfm_print(netdissect_options *ndo, |
| 272 | register const u_char *pptr, register u_int length) |
| 273 | { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 274 | const struct cfm_common_header_t *cfm_common_header; |
| 275 | const struct cfm_tlv_header_t *cfm_tlv_header; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 276 | const uint8_t *tptr, *tlv_ptr; |
| 277 | const uint8_t *namesp; |
| 278 | u_int names_data_remaining; |
| 279 | uint8_t md_nameformat, md_namelength; |
| 280 | const uint8_t *md_name; |
| 281 | uint8_t ma_nameformat, ma_namelength; |
| 282 | const uint8_t *ma_name; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 283 | u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval; |
| 284 | |
| 285 | |
| 286 | union { |
| 287 | const struct cfm_ccm_t *cfm_ccm; |
| 288 | const struct cfm_lbm_t *cfm_lbm; |
| 289 | const struct cfm_ltm_t *cfm_ltm; |
| 290 | const struct cfm_ltr_t *cfm_ltr; |
| 291 | } msg_ptr; |
| 292 | |
| 293 | tptr=pptr; |
| 294 | cfm_common_header = (const struct cfm_common_header_t *)pptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 295 | if (length < sizeof(*cfm_common_header)) |
| 296 | goto tooshort; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 297 | ND_TCHECK(*cfm_common_header); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 298 | |
| 299 | /* |
| 300 | * Sanity checking of the header. |
| 301 | */ |
| 302 | if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 303 | ND_PRINT((ndo, "CFMv%u not supported, length %u", |
| 304 | CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 305 | return; |
| 306 | } |
| 307 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 308 | ND_PRINT((ndo, "CFMv%u %s, MD Level %u, length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 309 | CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), |
| 310 | tok2str(cfm_opcode_values, "unknown (%u)", cfm_common_header->opcode), |
| 311 | CFM_EXTRACT_MD_LEVEL(cfm_common_header->mdlevel_version), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 312 | length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 313 | |
| 314 | /* |
| 315 | * In non-verbose mode just print the opcode and md-level. |
| 316 | */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 317 | if (ndo->ndo_vflag < 1) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 318 | return; |
| 319 | } |
| 320 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 321 | 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] | 322 | |
| 323 | tptr += sizeof(const struct cfm_common_header_t); |
| 324 | tlen = length - sizeof(struct cfm_common_header_t); |
| 325 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 326 | /* |
| 327 | * Sanity check the first TLV offset. |
| 328 | */ |
| 329 | if (cfm_common_header->first_tlv_offset > tlen) { |
| 330 | ND_PRINT((ndo, " (too large, must be <= %u)", tlen)); |
| 331 | return; |
| 332 | } |
| 333 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 334 | switch (cfm_common_header->opcode) { |
| 335 | case CFM_OPCODE_CCM: |
| 336 | msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 337 | if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ccm)) { |
| 338 | ND_PRINT((ndo, " (too small 1, must be >= %lu)", |
| 339 | (unsigned long) sizeof(*msg_ptr.cfm_ccm))); |
| 340 | return; |
| 341 | } |
| 342 | if (tlen < sizeof(*msg_ptr.cfm_ccm)) |
| 343 | goto tooshort; |
| 344 | ND_TCHECK(*msg_ptr.cfm_ccm); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 345 | |
| 346 | ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 347 | ND_PRINT((ndo, ", Flags [CCM Interval %u%s]", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 348 | ccm_interval, |
| 349 | cfm_common_header->flags & CFM_CCM_RDI_FLAG ? |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 350 | ", RDI" : "")); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 351 | |
| 352 | /* |
| 353 | * Resolve the CCM interval field. |
| 354 | */ |
| 355 | if (ccm_interval) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 356 | ND_PRINT((ndo, "\n\t CCM Interval %.3fs" |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 357 | ", min CCM Lifetime %.3fs, max CCM Lifetime %.3fs", |
| 358 | ccm_interval_base[ccm_interval], |
| 359 | ccm_interval_base[ccm_interval] * CCM_INTERVAL_MIN_MULTIPLIER, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 360 | ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 363 | 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] | 364 | EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 365 | EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 366 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 367 | namesp = msg_ptr.cfm_ccm->names; |
| 368 | names_data_remaining = sizeof(msg_ptr.cfm_ccm->names); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 369 | |
| 370 | /* |
| 371 | * Resolve the MD fields. |
| 372 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 373 | md_nameformat = *namesp; |
| 374 | namesp++; |
| 375 | names_data_remaining--; /* We know this is != 0 */ |
| 376 | if (md_nameformat != CFM_CCM_MD_FORMAT_NONE) { |
| 377 | md_namelength = *namesp; |
| 378 | namesp++; |
| 379 | names_data_remaining--; /* We know this is !=0 */ |
| 380 | ND_PRINT((ndo, "\n\t MD Name Format %s (%u), MD Name length %u", |
| 381 | tok2str(cfm_md_nameformat_values, "Unknown", |
| 382 | md_nameformat), |
| 383 | md_nameformat, |
| 384 | md_namelength)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 385 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 386 | /* |
| 387 | * -3 for the MA short name format and length and one byte |
| 388 | * of MA short name. |
| 389 | */ |
| 390 | if (md_namelength > names_data_remaining - 3) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 391 | ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining - 2)); |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | md_name = namesp; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 396 | ND_PRINT((ndo, "\n\t MD Name: ")); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 397 | switch (md_nameformat) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 398 | case CFM_CCM_MD_FORMAT_DNS: |
| 399 | case CFM_CCM_MD_FORMAT_CHAR: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 400 | safeputs(ndo, md_name, md_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 401 | break; |
| 402 | |
| 403 | case CFM_CCM_MD_FORMAT_MAC: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 404 | if (md_namelength == 6) { |
| 405 | ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, |
| 406 | md_name))); |
| 407 | } else { |
| 408 | ND_PRINT((ndo, "\n\t MAC (length invalid)")); |
| 409 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 410 | break; |
| 411 | |
| 412 | /* FIXME add printers for those MD formats - hexdump for now */ |
| 413 | case CFM_CCM_MA_FORMAT_8021: |
| 414 | default: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 415 | print_unknown_data(ndo, md_name, "\n\t ", |
| 416 | md_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 417 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 418 | namesp += md_namelength; |
| 419 | names_data_remaining -= md_namelength; |
| 420 | } else { |
| 421 | ND_PRINT((ndo, "\n\t MD Name Format %s (%u)", |
| 422 | tok2str(cfm_md_nameformat_values, "Unknown", |
| 423 | md_nameformat), |
| 424 | md_nameformat)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | |
| 428 | /* |
| 429 | * Resolve the MA fields. |
| 430 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 431 | ma_nameformat = *namesp; |
| 432 | namesp++; |
| 433 | names_data_remaining--; /* We know this is != 0 */ |
| 434 | ma_namelength = *namesp; |
| 435 | namesp++; |
| 436 | names_data_remaining--; /* We know this is != 0 */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 437 | 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] | 438 | tok2str(cfm_ma_nameformat_values, "Unknown", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 439 | ma_nameformat), |
| 440 | ma_nameformat, |
| 441 | ma_namelength)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 442 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 443 | if (ma_namelength > names_data_remaining) { |
| 444 | ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining)); |
| 445 | return; |
| 446 | } |
| 447 | |
| 448 | ma_name = namesp; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 449 | ND_PRINT((ndo, "\n\t MA Name: ")); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 450 | switch (ma_nameformat) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 451 | case CFM_CCM_MA_FORMAT_CHAR: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 452 | safeputs(ndo, ma_name, ma_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 453 | break; |
| 454 | |
| 455 | /* FIXME add printers for those MA formats - hexdump for now */ |
| 456 | case CFM_CCM_MA_FORMAT_8021: |
| 457 | case CFM_CCM_MA_FORMAT_VID: |
| 458 | case CFM_CCM_MA_FORMAT_INT: |
| 459 | case CFM_CCM_MA_FORMAT_VPN: |
| 460 | default: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 461 | print_unknown_data(ndo, ma_name, "\n\t ", ma_namelength); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 462 | } |
| 463 | break; |
| 464 | |
| 465 | case CFM_OPCODE_LTM: |
| 466 | msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 467 | if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltm)) { |
| 468 | ND_PRINT((ndo, " (too small 4, must be >= %lu)", |
| 469 | (unsigned long) sizeof(*msg_ptr.cfm_ltm))); |
| 470 | return; |
| 471 | } |
| 472 | if (tlen < sizeof(*msg_ptr.cfm_ltm)) |
| 473 | goto tooshort; |
| 474 | ND_TCHECK(*msg_ptr.cfm_ltm); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 475 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 476 | ND_PRINT((ndo, ", Flags [%s]", |
| 477 | bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 478 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 479 | ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 480 | EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 481 | msg_ptr.cfm_ltm->ttl)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 482 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 483 | ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s", |
| 484 | etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac), |
| 485 | etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 486 | break; |
| 487 | |
| 488 | case CFM_OPCODE_LTR: |
| 489 | msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 490 | if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltr)) { |
| 491 | ND_PRINT((ndo, " (too small 5, must be >= %lu)", |
| 492 | (unsigned long) sizeof(*msg_ptr.cfm_ltr))); |
| 493 | return; |
| 494 | } |
| 495 | if (tlen < sizeof(*msg_ptr.cfm_ltr)) |
| 496 | goto tooshort; |
| 497 | ND_TCHECK(*msg_ptr.cfm_ltr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 498 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 499 | ND_PRINT((ndo, ", Flags [%s]", |
| 500 | bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 501 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 502 | ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 503 | EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 504 | msg_ptr.cfm_ltr->ttl)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 505 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 506 | ND_PRINT((ndo, "\n\t Replay-Action %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 507 | tok2str(cfm_ltr_replay_action_values, |
| 508 | "Unknown", |
| 509 | msg_ptr.cfm_ltr->replay_action), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 510 | msg_ptr.cfm_ltr->replay_action)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 511 | break; |
| 512 | |
| 513 | /* |
| 514 | * No message decoder yet. |
| 515 | * Hexdump everything up until the start of the TLVs |
| 516 | */ |
| 517 | case CFM_OPCODE_LBR: |
| 518 | case CFM_OPCODE_LBM: |
| 519 | default: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 520 | print_unknown_data(ndo, tptr, "\n\t ", |
| 521 | tlen - cfm_common_header->first_tlv_offset); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 522 | break; |
| 523 | } |
| 524 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 525 | tptr += cfm_common_header->first_tlv_offset; |
| 526 | tlen -= cfm_common_header->first_tlv_offset; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 527 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 528 | while (tlen > 0) { |
| 529 | cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr; |
| 530 | |
| 531 | /* Enough to read the tlv type ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 532 | ND_TCHECK2(*tptr, 1); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 533 | cfm_tlv_type=cfm_tlv_header->type; |
| 534 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 535 | ND_PRINT((ndo, "\n\t%s TLV (0x%02x)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 536 | tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type), |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 537 | cfm_tlv_type)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 538 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 539 | if (cfm_tlv_type == CFM_TLV_END) { |
| 540 | /* Length is "Not present if the Type field is 0." */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 541 | return; |
| 542 | } |
| 543 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 544 | /* do we have the full tlv header ? */ |
| 545 | if (tlen < sizeof(struct cfm_tlv_header_t)) |
| 546 | goto tooshort; |
| 547 | ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t)); |
| 548 | cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length); |
| 549 | |
| 550 | ND_PRINT((ndo, ", length %u", cfm_tlv_len)); |
| 551 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 552 | tptr += sizeof(struct cfm_tlv_header_t); |
| 553 | tlen -= sizeof(struct cfm_tlv_header_t); |
| 554 | tlv_ptr = tptr; |
| 555 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 556 | /* do we have the full tlv ? */ |
| 557 | if (tlen < cfm_tlv_len) |
| 558 | goto tooshort; |
| 559 | ND_TCHECK2(*tptr, cfm_tlv_len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 560 | hexdump = FALSE; |
| 561 | |
| 562 | switch(cfm_tlv_type) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 563 | case CFM_TLV_PORT_STATUS: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 564 | if (cfm_tlv_len < 1) { |
| 565 | ND_PRINT((ndo, " (too short, must be >= 1)")); |
| 566 | return; |
| 567 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 568 | ND_PRINT((ndo, ", Status: %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 569 | tok2str(cfm_tlv_port_status_values, "Unknown", *tptr), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 570 | *tptr)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 571 | break; |
| 572 | |
| 573 | case CFM_TLV_INTERFACE_STATUS: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 574 | if (cfm_tlv_len < 1) { |
| 575 | ND_PRINT((ndo, " (too short, must be >= 1)")); |
| 576 | return; |
| 577 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 578 | ND_PRINT((ndo, ", Status: %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 579 | tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 580 | *tptr)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 581 | break; |
| 582 | |
| 583 | case CFM_TLV_PRIVATE: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 584 | if (cfm_tlv_len < 4) { |
| 585 | ND_PRINT((ndo, " (too short, must be >= 4)")); |
| 586 | return; |
| 587 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 588 | ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 589 | tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)), |
| 590 | EXTRACT_24BITS(tptr), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 591 | *(tptr + 3))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 592 | hexdump = TRUE; |
| 593 | break; |
| 594 | |
| 595 | case CFM_TLV_SENDER_ID: |
| 596 | { |
| 597 | u_int chassis_id_type, chassis_id_length; |
| 598 | u_int mgmt_addr_length; |
| 599 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 600 | if (cfm_tlv_len < 1) { |
| 601 | ND_PRINT((ndo, " (too short, must be >= 1)")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 602 | goto next_tlv; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 603 | } |
| 604 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 605 | /* |
| 606 | * Get the Chassis ID length and check it. |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 607 | * IEEE 802.1Q-2014 Section 21.5.3.1 |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 608 | */ |
| 609 | chassis_id_length = *tptr; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 610 | tptr++; |
| 611 | tlen--; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 612 | cfm_tlv_len--; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 613 | |
| 614 | if (chassis_id_length) { |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 615 | /* |
| 616 | * IEEE 802.1Q-2014 Section 21.5.3.2: Chassis ID Subtype, references |
| 617 | * IEEE 802.1AB-2005 Section 9.5.2.2, subsequently |
| 618 | * IEEE 802.1AB-2016 Section 8.5.2.2: chassis ID subtype |
| 619 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 620 | if (cfm_tlv_len < 1) { |
| 621 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 622 | goto next_tlv; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 623 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 624 | chassis_id_type = *tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 625 | cfm_tlv_len--; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 626 | 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] | 627 | tok2str(cfm_tlv_senderid_chassisid_values, |
| 628 | "Unknown", |
| 629 | chassis_id_type), |
| 630 | chassis_id_type, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 631 | chassis_id_length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 632 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 633 | if (cfm_tlv_len < chassis_id_length) { |
| 634 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 635 | goto next_tlv; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 636 | } |
| 637 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 638 | /* IEEE 802.1Q-2014 Section 21.5.3.3: Chassis ID */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 639 | switch (chassis_id_type) { |
| 640 | case CFM_CHASSIS_ID_MAC_ADDRESS: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 641 | if (chassis_id_length != ETHER_ADDR_LEN) { |
| 642 | ND_PRINT((ndo, " (invalid MAC address length)")); |
| 643 | hexdump = TRUE; |
| 644 | break; |
| 645 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 646 | ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 647 | break; |
| 648 | |
| 649 | case CFM_CHASSIS_ID_NETWORK_ADDRESS: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 650 | hexdump |= cfm_network_addr_print(ndo, tptr + 1, chassis_id_length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 651 | break; |
| 652 | |
| 653 | case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */ |
| 654 | case CFM_CHASSIS_ID_INTERFACE_ALIAS: |
| 655 | case CFM_CHASSIS_ID_LOCAL: |
| 656 | case CFM_CHASSIS_ID_CHASSIS_COMPONENT: |
| 657 | case CFM_CHASSIS_ID_PORT_COMPONENT: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 658 | safeputs(ndo, tptr + 1, chassis_id_length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 659 | break; |
| 660 | |
| 661 | default: |
| 662 | hexdump = TRUE; |
| 663 | break; |
| 664 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 665 | cfm_tlv_len -= chassis_id_length; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 666 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 667 | tptr += 1 + chassis_id_length; |
| 668 | tlen -= 1 + chassis_id_length; |
| 669 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 670 | |
| 671 | /* |
| 672 | * Check if there is a Management Address. |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 673 | * IEEE 802.1Q-2014 Section 21.5.3.4: Management Address Domain Length |
| 674 | * This and all subsequent fields are not present if the TLV length |
| 675 | * allows only the above fields. |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 676 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 677 | if (cfm_tlv_len == 0) { |
| 678 | /* No, there isn't; we're done. */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 679 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 680 | } |
| 681 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 682 | /* Here mgmt_addr_length stands for the management domain length. */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 683 | mgmt_addr_length = *tptr; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 684 | tptr++; |
| 685 | tlen--; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 686 | cfm_tlv_len--; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 687 | ND_PRINT((ndo, "\n\t Management Address Domain Length %u", mgmt_addr_length)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 688 | if (mgmt_addr_length) { |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 689 | /* IEEE 802.1Q-2014 Section 21.5.3.5: Management Address Domain */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 690 | if (cfm_tlv_len < mgmt_addr_length) { |
| 691 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 692 | goto next_tlv; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 693 | } |
| 694 | cfm_tlv_len -= mgmt_addr_length; |
| 695 | /* |
| 696 | * XXX - this is an OID; print it as such. |
| 697 | */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 698 | hex_print(ndo, "\n\t Management Address Domain: ", tptr, mgmt_addr_length); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 699 | tptr += mgmt_addr_length; |
| 700 | tlen -= mgmt_addr_length; |
| 701 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 702 | /* |
| 703 | * IEEE 802.1Q-2014 Section 21.5.3.6: Management Address Length |
| 704 | * This field is present if Management Address Domain Length is not 0. |
| 705 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 706 | if (cfm_tlv_len < 1) { |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 707 | ND_PRINT((ndo, " (Management Address Length is missing)")); |
| 708 | hexdump = TRUE; |
| 709 | break; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 710 | } |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 711 | |
| 712 | /* Here mgmt_addr_length stands for the management address length. */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 713 | mgmt_addr_length = *tptr; |
| 714 | tptr++; |
| 715 | tlen--; |
| 716 | cfm_tlv_len--; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 717 | ND_PRINT((ndo, "\n\t Management Address Length %u", mgmt_addr_length)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 718 | if (mgmt_addr_length) { |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 719 | /* IEEE 802.1Q-2014 Section 21.5.3.7: Management Address */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 720 | if (cfm_tlv_len < mgmt_addr_length) { |
| 721 | ND_PRINT((ndo, "\n\t (TLV too short)")); |
| 722 | return; |
| 723 | } |
| 724 | cfm_tlv_len -= mgmt_addr_length; |
| 725 | /* |
| 726 | * XXX - this is a TransportDomain; print it as such. |
| 727 | */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 728 | hex_print(ndo, "\n\t Management Address: ", tptr, mgmt_addr_length); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 729 | tptr += mgmt_addr_length; |
| 730 | tlen -= mgmt_addr_length; |
| 731 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 732 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 733 | break; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 734 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 735 | |
| 736 | /* |
| 737 | * FIXME those are the defined TLVs that lack a decoder |
| 738 | * you are welcome to contribute code ;-) |
| 739 | */ |
| 740 | |
| 741 | case CFM_TLV_DATA: |
| 742 | case CFM_TLV_REPLY_INGRESS: |
| 743 | case CFM_TLV_REPLY_EGRESS: |
| 744 | default: |
| 745 | hexdump = TRUE; |
| 746 | break; |
| 747 | } |
| 748 | /* do we want to see an additional hexdump ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 749 | if (hexdump || ndo->ndo_vflag > 1) |
| 750 | print_unknown_data(ndo, tlv_ptr, "\n\t ", cfm_tlv_len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 751 | |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 752 | next_tlv: |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 753 | tptr+=cfm_tlv_len; |
| 754 | tlen-=cfm_tlv_len; |
| 755 | } |
| 756 | return; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 757 | |
| 758 | tooshort: |
| 759 | ND_PRINT((ndo, "\n\t\t packet is too short")); |
| 760 | return; |
| 761 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 762 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 763 | ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 764 | } |