The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 2 | * Copyright (c) 1998-2006 The TCPDUMP project |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 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 "slow protocols" LACP, MARKER as per 802.3ad |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 16 | * OAM as per 802.3ah |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 17 | * |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 18 | * Original code by Hannes Gredler (hannes@gredler.at) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 21 | /* \summary: IEEE "slow protocols" (802.3ad/802.3ah) printer */ |
| 22 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 23 | #ifdef HAVE_CONFIG_H |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 24 | #include <config.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 25 | #endif |
| 26 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 27 | #include "netdissect-stdinc.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 28 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 29 | #define ND_LONGJMP_FROM_TCHECK |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 30 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 31 | #include "extract.h" |
| 32 | #include "addrtoname.h" |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 33 | #include "oui.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 34 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 35 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 36 | #define SLOW_PROTO_LACP 1 |
| 37 | #define SLOW_PROTO_MARKER 2 |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 38 | #define SLOW_PROTO_OAM 3 |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 39 | |
| 40 | #define LACP_VERSION 1 |
| 41 | #define MARKER_VERSION 1 |
| 42 | |
| 43 | static const struct tok slow_proto_values[] = { |
| 44 | { SLOW_PROTO_LACP, "LACP" }, |
| 45 | { SLOW_PROTO_MARKER, "MARKER" }, |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 46 | { SLOW_PROTO_OAM, "OAM" }, |
| 47 | { 0, NULL} |
| 48 | }; |
| 49 | |
| 50 | static const struct tok slow_oam_flag_values[] = { |
| 51 | { 0x0001, "Link Fault" }, |
| 52 | { 0x0002, "Dying Gasp" }, |
| 53 | { 0x0004, "Critical Event" }, |
| 54 | { 0x0008, "Local Evaluating" }, |
| 55 | { 0x0010, "Local Stable" }, |
| 56 | { 0x0020, "Remote Evaluating" }, |
| 57 | { 0x0040, "Remote Stable" }, |
| 58 | { 0, NULL} |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 59 | }; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 60 | |
| 61 | #define SLOW_OAM_CODE_INFO 0x00 |
| 62 | #define SLOW_OAM_CODE_EVENT_NOTIF 0x01 |
| 63 | #define SLOW_OAM_CODE_VAR_REQUEST 0x02 |
| 64 | #define SLOW_OAM_CODE_VAR_RESPONSE 0x03 |
| 65 | #define SLOW_OAM_CODE_LOOPBACK_CTRL 0x04 |
| 66 | #define SLOW_OAM_CODE_PRIVATE 0xfe |
| 67 | |
| 68 | static const struct tok slow_oam_code_values[] = { |
| 69 | { SLOW_OAM_CODE_INFO, "Information" }, |
| 70 | { SLOW_OAM_CODE_EVENT_NOTIF, "Event Notification" }, |
| 71 | { SLOW_OAM_CODE_VAR_REQUEST, "Variable Request" }, |
| 72 | { SLOW_OAM_CODE_VAR_RESPONSE, "Variable Response" }, |
| 73 | { SLOW_OAM_CODE_LOOPBACK_CTRL, "Loopback Control" }, |
| 74 | { SLOW_OAM_CODE_PRIVATE, "Vendor Private" }, |
| 75 | { 0, NULL} |
| 76 | }; |
| 77 | |
| 78 | struct slow_oam_info_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 79 | nd_uint8_t info_type; |
| 80 | nd_uint8_t info_length; |
| 81 | nd_uint8_t oam_version; |
| 82 | nd_uint16_t revision; |
| 83 | nd_uint8_t state; |
| 84 | nd_uint8_t oam_config; |
| 85 | nd_uint16_t oam_pdu_config; |
| 86 | nd_uint24_t oui; |
| 87 | nd_uint32_t vendor_private; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | #define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00 |
| 91 | #define SLOW_OAM_INFO_TYPE_LOCAL 0x01 |
| 92 | #define SLOW_OAM_INFO_TYPE_REMOTE 0x02 |
| 93 | #define SLOW_OAM_INFO_TYPE_ORG_SPECIFIC 0xfe |
| 94 | |
| 95 | static const struct tok slow_oam_info_type_values[] = { |
| 96 | { SLOW_OAM_INFO_TYPE_END_OF_TLV, "End of TLV marker" }, |
| 97 | { SLOW_OAM_INFO_TYPE_LOCAL, "Local" }, |
| 98 | { SLOW_OAM_INFO_TYPE_REMOTE, "Remote" }, |
| 99 | { SLOW_OAM_INFO_TYPE_ORG_SPECIFIC, "Organization specific" }, |
| 100 | { 0, NULL} |
| 101 | }; |
| 102 | |
| 103 | #define OAM_INFO_TYPE_PARSER_MASK 0x3 |
| 104 | static const struct tok slow_oam_info_type_state_parser_values[] = { |
| 105 | { 0x00, "forwarding" }, |
| 106 | { 0x01, "looping back" }, |
| 107 | { 0x02, "discarding" }, |
| 108 | { 0x03, "reserved" }, |
| 109 | { 0, NULL} |
| 110 | }; |
| 111 | |
| 112 | #define OAM_INFO_TYPE_MUX_MASK 0x4 |
| 113 | static const struct tok slow_oam_info_type_state_mux_values[] = { |
| 114 | { 0x00, "forwarding" }, |
| 115 | { 0x04, "discarding" }, |
| 116 | { 0, NULL} |
| 117 | }; |
| 118 | |
| 119 | static const struct tok slow_oam_info_type_oam_config_values[] = { |
| 120 | { 0x01, "Active" }, |
| 121 | { 0x02, "Unidirectional" }, |
| 122 | { 0x04, "Remote-Loopback" }, |
| 123 | { 0x08, "Link-Events" }, |
| 124 | { 0x10, "Variable-Retrieval" }, |
| 125 | { 0, NULL} |
| 126 | }; |
| 127 | |
| 128 | /* 11 Bits */ |
| 129 | #define OAM_INFO_TYPE_PDU_SIZE_MASK 0x7ff |
| 130 | |
| 131 | #define SLOW_OAM_LINK_EVENT_END_OF_TLV 0x00 |
| 132 | #define SLOW_OAM_LINK_EVENT_ERR_SYM_PER 0x01 |
| 133 | #define SLOW_OAM_LINK_EVENT_ERR_FRM 0x02 |
| 134 | #define SLOW_OAM_LINK_EVENT_ERR_FRM_PER 0x03 |
| 135 | #define SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM 0x04 |
| 136 | #define SLOW_OAM_LINK_EVENT_ORG_SPECIFIC 0xfe |
| 137 | |
| 138 | static const struct tok slow_oam_link_event_values[] = { |
| 139 | { SLOW_OAM_LINK_EVENT_END_OF_TLV, "End of TLV marker" }, |
| 140 | { SLOW_OAM_LINK_EVENT_ERR_SYM_PER, "Errored Symbol Period Event" }, |
| 141 | { SLOW_OAM_LINK_EVENT_ERR_FRM, "Errored Frame Event" }, |
| 142 | { SLOW_OAM_LINK_EVENT_ERR_FRM_PER, "Errored Frame Period Event" }, |
| 143 | { SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM, "Errored Frame Seconds Summary Event" }, |
| 144 | { SLOW_OAM_LINK_EVENT_ORG_SPECIFIC, "Organization specific" }, |
| 145 | { 0, NULL} |
| 146 | }; |
| 147 | |
| 148 | struct slow_oam_link_event_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 149 | nd_uint8_t event_type; |
| 150 | nd_uint8_t event_length; |
| 151 | nd_uint16_t time_stamp; |
| 152 | nd_uint64_t window; |
| 153 | nd_uint64_t threshold; |
| 154 | nd_uint64_t errors; |
| 155 | nd_uint64_t errors_running_total; |
| 156 | nd_uint32_t event_running_total; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | struct slow_oam_variablerequest_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 160 | nd_uint8_t branch; |
| 161 | nd_uint16_t leaf; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | struct slow_oam_variableresponse_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 165 | nd_uint8_t branch; |
| 166 | nd_uint16_t leaf; |
| 167 | nd_uint8_t length; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | struct slow_oam_loopbackctrl_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 171 | nd_uint8_t command; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | static const struct tok slow_oam_loopbackctrl_cmd_values[] = { |
| 175 | { 0x01, "Enable OAM Remote Loopback" }, |
| 176 | { 0x02, "Disable OAM Remote Loopback" }, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 177 | { 0, NULL} |
| 178 | }; |
| 179 | |
| 180 | struct tlv_header_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 181 | nd_uint8_t type; |
| 182 | nd_uint8_t length; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 183 | }; |
| 184 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 185 | #define LACP_MARKER_TLV_TERMINATOR 0x00 /* same code for LACP and Marker */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 186 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 187 | #define LACP_TLV_ACTOR_INFO 0x01 |
| 188 | #define LACP_TLV_PARTNER_INFO 0x02 |
| 189 | #define LACP_TLV_COLLECTOR_INFO 0x03 |
| 190 | |
| 191 | #define MARKER_TLV_MARKER_INFO 0x01 |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 192 | |
| 193 | static const struct tok slow_tlv_values[] = { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 194 | { (SLOW_PROTO_LACP << 8) + LACP_MARKER_TLV_TERMINATOR, "Terminator"}, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 195 | { (SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO, "Actor Information"}, |
| 196 | { (SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO, "Partner Information"}, |
| 197 | { (SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO, "Collector Information"}, |
| 198 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 199 | { (SLOW_PROTO_MARKER << 8) + LACP_MARKER_TLV_TERMINATOR, "Terminator"}, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 200 | { (SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO, "Marker Information"}, |
| 201 | { 0, NULL} |
| 202 | }; |
| 203 | |
| 204 | struct lacp_tlv_actor_partner_info_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 205 | nd_uint16_t sys_pri; |
| 206 | nd_mac_addr sys; |
| 207 | nd_uint16_t key; |
| 208 | nd_uint16_t port_pri; |
| 209 | nd_uint16_t port; |
| 210 | nd_uint8_t state; |
| 211 | nd_byte pad[3]; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 212 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 213 | |
| 214 | static const struct tok lacp_tlv_actor_partner_info_state_values[] = { |
| 215 | { 0x01, "Activity"}, |
| 216 | { 0x02, "Timeout"}, |
| 217 | { 0x04, "Aggregation"}, |
| 218 | { 0x08, "Synchronization"}, |
| 219 | { 0x10, "Collecting"}, |
| 220 | { 0x20, "Distributing"}, |
| 221 | { 0x40, "Default"}, |
| 222 | { 0x80, "Expired"}, |
| 223 | { 0, NULL} |
| 224 | }; |
| 225 | |
| 226 | struct lacp_tlv_collector_info_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 227 | nd_uint16_t max_delay; |
| 228 | nd_byte pad[12]; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 229 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 230 | |
| 231 | struct marker_tlv_marker_info_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 232 | nd_uint16_t req_port; |
| 233 | nd_mac_addr req_sys; |
| 234 | nd_uint32_t req_trans_id; |
| 235 | nd_byte pad[2]; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 236 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 237 | |
| 238 | struct lacp_marker_tlv_terminator_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 239 | nd_byte pad[50]; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 240 | }; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 241 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 242 | static void slow_marker_lacp_print(netdissect_options *, const u_char *, u_int, u_int); |
| 243 | static void slow_oam_print(netdissect_options *, const u_char *, u_int); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 244 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 245 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 246 | slow_print(netdissect_options *ndo, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 247 | const u_char *pptr, u_int len) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 248 | { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 249 | int print_version; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 250 | u_int subtype; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 251 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 252 | ndo->ndo_protocol = "slow"; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 253 | if (len < 1) |
| 254 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 255 | subtype = GET_U_1(pptr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 256 | |
| 257 | /* |
| 258 | * Sanity checking of the header. |
| 259 | */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 260 | switch (subtype) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 261 | case SLOW_PROTO_LACP: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 262 | if (len < 2) |
| 263 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 264 | if (GET_U_1(pptr + 1) != LACP_VERSION) { |
| 265 | ND_PRINT("LACP version %u packet not supported", |
| 266 | GET_U_1(pptr + 1)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 267 | return; |
| 268 | } |
| 269 | print_version = 1; |
| 270 | break; |
| 271 | |
| 272 | case SLOW_PROTO_MARKER: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 273 | if (len < 2) |
| 274 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 275 | if (GET_U_1(pptr + 1) != MARKER_VERSION) { |
| 276 | ND_PRINT("MARKER version %u packet not supported", |
| 277 | GET_U_1(pptr + 1)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 278 | return; |
| 279 | } |
| 280 | print_version = 1; |
| 281 | break; |
| 282 | |
| 283 | case SLOW_PROTO_OAM: /* fall through */ |
| 284 | print_version = 0; |
| 285 | break; |
| 286 | |
| 287 | default: |
| 288 | /* print basic information and exit */ |
| 289 | print_version = -1; |
| 290 | break; |
| 291 | } |
| 292 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 293 | if (print_version == 1) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 294 | ND_PRINT("%sv%u, length %u", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 295 | tok2str(slow_proto_values, "unknown (%u)", subtype), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 296 | GET_U_1((pptr + 1)), |
| 297 | len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 298 | } else { |
| 299 | /* some slow protos don't have a version number in the header */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 300 | ND_PRINT("%s, length %u", |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 301 | tok2str(slow_proto_values, "unknown (%u)", subtype), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 302 | len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /* unrecognized subtype */ |
| 306 | if (print_version == -1) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 307 | print_unknown_data(ndo, pptr, "\n\t", len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 308 | return; |
| 309 | } |
| 310 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 311 | if (!ndo->ndo_vflag) |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 312 | return; |
| 313 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 314 | switch (subtype) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 315 | default: /* should not happen */ |
| 316 | break; |
| 317 | |
| 318 | case SLOW_PROTO_OAM: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 319 | /* skip subtype */ |
| 320 | len -= 1; |
| 321 | pptr += 1; |
| 322 | slow_oam_print(ndo, pptr, len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 323 | break; |
| 324 | |
| 325 | case SLOW_PROTO_LACP: /* LACP and MARKER share the same semantics */ |
| 326 | case SLOW_PROTO_MARKER: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 327 | /* skip subtype and version */ |
| 328 | len -= 2; |
| 329 | pptr += 2; |
| 330 | slow_marker_lacp_print(ndo, pptr, len, subtype); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 331 | break; |
| 332 | } |
| 333 | return; |
| 334 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 335 | tooshort: |
| 336 | if (!ndo->ndo_vflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 337 | ND_PRINT(" (packet is too short)"); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 338 | else |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 339 | ND_PRINT("\n\t\t packet is too short"); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 340 | } |
| 341 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 342 | static void |
| 343 | slow_marker_lacp_print(netdissect_options *ndo, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 344 | const u_char *tptr, u_int tlen, |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 345 | u_int proto_subtype) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 346 | { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 347 | const struct tlv_header_t *tlv_header; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 348 | const u_char *tlv_tptr; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 349 | u_int tlv_type, tlv_len, tlv_tlen; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 350 | |
| 351 | union { |
| 352 | const struct lacp_marker_tlv_terminator_t *lacp_marker_tlv_terminator; |
| 353 | const struct lacp_tlv_actor_partner_info_t *lacp_tlv_actor_partner_info; |
| 354 | const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info; |
| 355 | const struct marker_tlv_marker_info_t *marker_tlv_marker_info; |
| 356 | } tlv_ptr; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 357 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 358 | while(tlen>0) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 359 | /* is the packet big enough to include the tlv header ? */ |
| 360 | if (tlen < sizeof(struct tlv_header_t)) |
| 361 | goto tooshort; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 362 | /* did we capture enough for fully decoding the tlv header ? */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 363 | tlv_header = (const struct tlv_header_t *)tptr; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 364 | tlv_type = GET_U_1(tlv_header->type); |
| 365 | tlv_len = GET_U_1(tlv_header->length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 366 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 367 | ND_PRINT("\n\t%s TLV (0x%02x), length %u", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 368 | tok2str(slow_tlv_values, |
| 369 | "Unknown", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 370 | (proto_subtype << 8) + tlv_type), |
| 371 | tlv_type, |
| 372 | tlv_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 373 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 374 | if (tlv_type == LACP_MARKER_TLV_TERMINATOR) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 375 | /* |
| 376 | * This TLV has a length of zero, and means there are no |
| 377 | * more TLVs to process. |
| 378 | */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 379 | return; |
| 380 | } |
| 381 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 382 | /* length includes the type and length fields */ |
| 383 | if (tlv_len < sizeof(struct tlv_header_t)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 384 | ND_PRINT("\n\t ERROR: illegal length - should be >= %zu", |
| 385 | sizeof(struct tlv_header_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 386 | return; |
| 387 | } |
| 388 | |
| 389 | /* is the packet big enough to include the tlv ? */ |
| 390 | if (tlen < tlv_len) |
| 391 | goto tooshort; |
| 392 | /* did we capture enough for fully decoding the tlv ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 393 | ND_TCHECK_LEN(tptr, tlv_len); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 394 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 395 | tlv_tptr=tptr+sizeof(struct tlv_header_t); |
| 396 | tlv_tlen=tlv_len-sizeof(struct tlv_header_t); |
| 397 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 398 | switch((proto_subtype << 8) + tlv_type) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 399 | |
| 400 | /* those two TLVs have the same structure -> fall through */ |
| 401 | case ((SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO): |
| 402 | case ((SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO): |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 403 | if (tlv_tlen != |
| 404 | sizeof(struct lacp_tlv_actor_partner_info_t)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 405 | ND_PRINT("\n\t ERROR: illegal length - should be %zu", |
| 406 | sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_actor_partner_info_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 407 | goto badlength; |
| 408 | } |
| 409 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 410 | tlv_ptr.lacp_tlv_actor_partner_info = (const struct lacp_tlv_actor_partner_info_t *)tlv_tptr; |
| 411 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 412 | ND_PRINT("\n\t System %s, System Priority %u, Key %u" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 413 | ", Port %u, Port Priority %u\n\t State Flags [%s]", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 414 | GET_ETHERADDR_STRING(tlv_ptr.lacp_tlv_actor_partner_info->sys), |
| 415 | GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri), |
| 416 | GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->key), |
| 417 | GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->port), |
| 418 | GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->port_pri), |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 419 | bittok2str(lacp_tlv_actor_partner_info_state_values, |
| 420 | "none", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 421 | GET_U_1(tlv_ptr.lacp_tlv_actor_partner_info->state))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 422 | |
| 423 | break; |
| 424 | |
| 425 | case ((SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO): |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 426 | if (tlv_tlen != |
| 427 | sizeof(struct lacp_tlv_collector_info_t)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 428 | ND_PRINT("\n\t ERROR: illegal length - should be %zu", |
| 429 | sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_collector_info_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 430 | goto badlength; |
| 431 | } |
| 432 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 433 | tlv_ptr.lacp_tlv_collector_info = (const struct lacp_tlv_collector_info_t *)tlv_tptr; |
| 434 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 435 | ND_PRINT("\n\t Max Delay %u", |
| 436 | GET_BE_U_2(tlv_ptr.lacp_tlv_collector_info->max_delay)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 437 | |
| 438 | break; |
| 439 | |
| 440 | case ((SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO): |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 441 | if (tlv_tlen != |
| 442 | sizeof(struct marker_tlv_marker_info_t)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 443 | ND_PRINT("\n\t ERROR: illegal length - should be %zu", |
| 444 | sizeof(struct tlv_header_t) + sizeof(struct marker_tlv_marker_info_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 445 | goto badlength; |
| 446 | } |
| 447 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 448 | tlv_ptr.marker_tlv_marker_info = (const struct marker_tlv_marker_info_t *)tlv_tptr; |
| 449 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 450 | ND_PRINT("\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x", |
| 451 | GET_ETHERADDR_STRING(tlv_ptr.marker_tlv_marker_info->req_sys), |
| 452 | GET_BE_U_2(tlv_ptr.marker_tlv_marker_info->req_port), |
| 453 | GET_BE_U_4(tlv_ptr.marker_tlv_marker_info->req_trans_id)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 454 | |
| 455 | break; |
| 456 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 457 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 458 | if (ndo->ndo_vflag <= 1) |
| 459 | print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 460 | break; |
| 461 | } |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 462 | |
| 463 | badlength: |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 464 | /* do we want to see an additional hexdump ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 465 | if (ndo->ndo_vflag > 1) { |
| 466 | print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 467 | tlv_len-sizeof(struct tlv_header_t)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 468 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 469 | |
| 470 | tptr+=tlv_len; |
| 471 | tlen-=tlv_len; |
| 472 | } |
| 473 | return; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 474 | |
| 475 | tooshort: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 476 | ND_PRINT("\n\t\t packet is too short"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 477 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 478 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 479 | static void |
| 480 | slow_oam_print(netdissect_options *ndo, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 481 | const u_char *tptr, u_int tlen) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 482 | { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 483 | uint8_t code; |
| 484 | uint8_t type, length; |
| 485 | uint8_t state; |
| 486 | uint8_t command; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 487 | u_int hexdump; |
| 488 | |
| 489 | struct slow_oam_common_header_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 490 | nd_uint16_t flags; |
| 491 | nd_uint8_t code; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 492 | }; |
| 493 | |
| 494 | struct slow_oam_tlv_header_t { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 495 | nd_uint8_t type; |
| 496 | nd_uint8_t length; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 497 | }; |
| 498 | |
| 499 | union { |
| 500 | const struct slow_oam_common_header_t *slow_oam_common_header; |
| 501 | const struct slow_oam_tlv_header_t *slow_oam_tlv_header; |
| 502 | } ptr; |
| 503 | |
| 504 | union { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 505 | const struct slow_oam_info_t *slow_oam_info; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 506 | const struct slow_oam_link_event_t *slow_oam_link_event; |
| 507 | const struct slow_oam_variablerequest_t *slow_oam_variablerequest; |
| 508 | const struct slow_oam_variableresponse_t *slow_oam_variableresponse; |
| 509 | const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl; |
| 510 | } tlv; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 511 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 512 | ptr.slow_oam_common_header = (const struct slow_oam_common_header_t *)tptr; |
| 513 | if (tlen < sizeof(*ptr.slow_oam_common_header)) |
| 514 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 515 | ND_TCHECK_SIZE(ptr.slow_oam_common_header); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 516 | tptr += sizeof(struct slow_oam_common_header_t); |
| 517 | tlen -= sizeof(struct slow_oam_common_header_t); |
| 518 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 519 | code = GET_U_1(ptr.slow_oam_common_header->code); |
| 520 | ND_PRINT("\n\tCode %s OAM PDU, Flags [%s]", |
| 521 | tok2str(slow_oam_code_values, "Unknown (%u)", code), |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 522 | bittok2str(slow_oam_flag_values, |
| 523 | "none", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 524 | GET_BE_U_2(ptr.slow_oam_common_header->flags))); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 525 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 526 | switch (code) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 527 | case SLOW_OAM_CODE_INFO: |
| 528 | while (tlen > 0) { |
| 529 | ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 530 | if (tlen < sizeof(*ptr.slow_oam_tlv_header)) |
| 531 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 532 | ND_TCHECK_SIZE(ptr.slow_oam_tlv_header); |
| 533 | type = GET_U_1(ptr.slow_oam_tlv_header->type); |
| 534 | length = GET_U_1(ptr.slow_oam_tlv_header->length); |
| 535 | ND_PRINT("\n\t %s Information Type (%u), length %u", |
| 536 | tok2str(slow_oam_info_type_values, "Reserved", type), |
| 537 | type, |
| 538 | length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 539 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 540 | if (type == SLOW_OAM_INFO_TYPE_END_OF_TLV) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 541 | /* |
| 542 | * As IEEE Std 802.3-2015 says for the End of TLV Marker, |
| 543 | * "(the length and value of the Type 0x00 TLV can be ignored)". |
| 544 | */ |
| 545 | return; |
| 546 | } |
| 547 | |
| 548 | /* length includes the type and length fields */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 549 | if (length < sizeof(struct slow_oam_tlv_header_t)) { |
| 550 | ND_PRINT("\n\t ERROR: illegal length - should be >= %zu", |
| 551 | sizeof(struct slow_oam_tlv_header_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 552 | return; |
| 553 | } |
| 554 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 555 | if (tlen < length) |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 556 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 557 | ND_TCHECK_LEN(tptr, length); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 558 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 559 | hexdump = FALSE; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 560 | switch (type) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 561 | case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */ |
| 562 | case SLOW_OAM_INFO_TYPE_REMOTE: |
| 563 | tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 564 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 565 | if (GET_U_1(tlv.slow_oam_info->info_length) != |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 566 | sizeof(struct slow_oam_info_t)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 567 | ND_PRINT("\n\t ERROR: illegal length - should be %zu", |
| 568 | sizeof(struct slow_oam_info_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 569 | hexdump = TRUE; |
| 570 | goto badlength_code_info; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 571 | } |
| 572 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 573 | ND_PRINT("\n\t OAM-Version %u, Revision %u", |
| 574 | GET_U_1(tlv.slow_oam_info->oam_version), |
| 575 | GET_BE_U_2(tlv.slow_oam_info->revision)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 576 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 577 | state = GET_U_1(tlv.slow_oam_info->state); |
| 578 | ND_PRINT("\n\t State-Parser-Action %s, State-MUX-Action %s", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 579 | tok2str(slow_oam_info_type_state_parser_values, "Reserved", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 580 | state & OAM_INFO_TYPE_PARSER_MASK), |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 581 | tok2str(slow_oam_info_type_state_mux_values, "Reserved", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 582 | state & OAM_INFO_TYPE_MUX_MASK)); |
| 583 | ND_PRINT("\n\t OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 584 | bittok2str(slow_oam_info_type_oam_config_values, "none", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 585 | GET_U_1(tlv.slow_oam_info->oam_config)), |
| 586 | GET_BE_U_2(tlv.slow_oam_info->oam_pdu_config) & |
| 587 | OAM_INFO_TYPE_PDU_SIZE_MASK); |
| 588 | ND_PRINT("\n\t OUI %s (0x%06x), Vendor-Private 0x%08x", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 589 | tok2str(oui_values, "Unknown", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 590 | GET_BE_U_3(tlv.slow_oam_info->oui)), |
| 591 | GET_BE_U_3(tlv.slow_oam_info->oui), |
| 592 | GET_BE_U_4(tlv.slow_oam_info->vendor_private)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 593 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 594 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 595 | case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC: |
| 596 | hexdump = TRUE; |
| 597 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 598 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 599 | default: |
| 600 | hexdump = TRUE; |
| 601 | break; |
| 602 | } |
| 603 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 604 | badlength_code_info: |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 605 | /* do we also want to see a hex dump ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 606 | if (ndo->ndo_vflag > 1 || hexdump==TRUE) { |
| 607 | print_unknown_data(ndo, tptr, "\n\t ", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 608 | length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 609 | } |
| 610 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 611 | tlen -= length; |
| 612 | tptr += length; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 613 | } |
| 614 | break; |
| 615 | |
| 616 | case SLOW_OAM_CODE_EVENT_NOTIF: |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 617 | /* Sequence number */ |
| 618 | if (tlen < 2) |
| 619 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 620 | ND_PRINT("\n\t Sequence Number %u", GET_BE_U_2(tptr)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 621 | tlen -= 2; |
| 622 | tptr += 2; |
| 623 | |
| 624 | /* TLVs */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 625 | while (tlen > 0) { |
| 626 | ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 627 | if (tlen < sizeof(*ptr.slow_oam_tlv_header)) |
| 628 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 629 | type = GET_U_1(ptr.slow_oam_tlv_header->type); |
| 630 | length = GET_U_1(ptr.slow_oam_tlv_header->length); |
| 631 | ND_PRINT("\n\t %s Link Event Type (%u), length %u", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 632 | tok2str(slow_oam_link_event_values, "Reserved", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 633 | type), |
| 634 | type, |
| 635 | length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 636 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 637 | if (type == SLOW_OAM_INFO_TYPE_END_OF_TLV) { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 638 | /* |
| 639 | * As IEEE Std 802.3-2015 says for the End of TLV Marker, |
| 640 | * "(the length and value of the Type 0x00 TLV can be ignored)". |
| 641 | */ |
| 642 | return; |
| 643 | } |
| 644 | |
| 645 | /* length includes the type and length fields */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 646 | if (length < sizeof(struct slow_oam_tlv_header_t)) { |
| 647 | ND_PRINT("\n\t ERROR: illegal length - should be >= %zu", |
| 648 | sizeof(struct slow_oam_tlv_header_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 649 | return; |
| 650 | } |
| 651 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 652 | if (tlen < length) |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 653 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 654 | ND_TCHECK_LEN(tptr, length); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 655 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 656 | hexdump = FALSE; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 657 | switch (type) { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 658 | case SLOW_OAM_LINK_EVENT_ERR_SYM_PER: /* identical format - fall through */ |
| 659 | case SLOW_OAM_LINK_EVENT_ERR_FRM: |
| 660 | case SLOW_OAM_LINK_EVENT_ERR_FRM_PER: |
| 661 | case SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM: |
| 662 | tlv.slow_oam_link_event = (const struct slow_oam_link_event_t *)tptr; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 663 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 664 | if (GET_U_1(tlv.slow_oam_link_event->event_length) != |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 665 | sizeof(struct slow_oam_link_event_t)) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 666 | ND_PRINT("\n\t ERROR: illegal length - should be %zu", |
| 667 | sizeof(struct slow_oam_link_event_t)); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 668 | hexdump = TRUE; |
| 669 | goto badlength_event_notif; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 670 | } |
| 671 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 672 | ND_PRINT("\n\t Timestamp %u ms, Errored Window %" PRIu64 |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 673 | "\n\t Errored Threshold %" PRIu64 |
| 674 | "\n\t Errors %" PRIu64 |
| 675 | "\n\t Error Running Total %" PRIu64 |
| 676 | "\n\t Event Running Total %u", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 677 | GET_BE_U_2(tlv.slow_oam_link_event->time_stamp)*100, |
| 678 | GET_BE_U_8(tlv.slow_oam_link_event->window), |
| 679 | GET_BE_U_8(tlv.slow_oam_link_event->threshold), |
| 680 | GET_BE_U_8(tlv.slow_oam_link_event->errors), |
| 681 | GET_BE_U_8(tlv.slow_oam_link_event->errors_running_total), |
| 682 | GET_BE_U_4(tlv.slow_oam_link_event->event_running_total)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 683 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 684 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 685 | case SLOW_OAM_LINK_EVENT_ORG_SPECIFIC: |
| 686 | hexdump = TRUE; |
| 687 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 688 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 689 | default: |
| 690 | hexdump = TRUE; |
| 691 | break; |
| 692 | } |
| 693 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 694 | badlength_event_notif: |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 695 | /* do we also want to see a hex dump ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 696 | if (ndo->ndo_vflag > 1 || hexdump==TRUE) { |
| 697 | print_unknown_data(ndo, tptr, "\n\t ", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 698 | length); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 699 | } |
| 700 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 701 | tlen -= length; |
| 702 | tptr += length; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 703 | } |
| 704 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 705 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 706 | case SLOW_OAM_CODE_LOOPBACK_CTRL: |
| 707 | tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 708 | if (tlen < sizeof(*tlv.slow_oam_loopbackctrl)) |
| 709 | goto tooshort; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 710 | command = GET_U_1(tlv.slow_oam_loopbackctrl->command); |
| 711 | ND_PRINT("\n\t Command %s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 712 | tok2str(slow_oam_loopbackctrl_cmd_values, |
| 713 | "Unknown", |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 714 | command), |
| 715 | command); |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 716 | tptr ++; |
| 717 | tlen --; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 718 | break; |
| 719 | |
| 720 | /* |
| 721 | * FIXME those are the defined codes that lack a decoder |
| 722 | * you are welcome to contribute code ;-) |
| 723 | */ |
| 724 | case SLOW_OAM_CODE_VAR_REQUEST: |
| 725 | case SLOW_OAM_CODE_VAR_RESPONSE: |
| 726 | case SLOW_OAM_CODE_PRIVATE: |
| 727 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 728 | if (ndo->ndo_vflag <= 1) { |
| 729 | print_unknown_data(ndo, tptr, "\n\t ", tlen); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 730 | } |
| 731 | break; |
| 732 | } |
| 733 | return; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 734 | |
| 735 | tooshort: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 736 | ND_PRINT("\n\t\t packet is too short"); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 737 | } |