print-slow.c revision 1.7 1 /*
2 * Copyright (c) 1998-2006 The TCPDUMP project
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
14 *
15 * support for the IEEE "slow protocols" LACP, MARKER as per 802.3ad
16 * OAM as per 802.3ah
17 *
18 * Original code by Hannes Gredler (hannes (at) juniper.net)
19 */
20
21 #include <sys/cdefs.h>
22 #ifndef lint
23 __RCSID("$NetBSD: print-slow.c,v 1.7 2017/01/24 23:29:14 christos Exp $");
24 #endif
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <netdissect-stdinc.h>
31
32 #include "netdissect.h"
33 #include "extract.h"
34 #include "addrtoname.h"
35 #include "ether.h"
36 #include "oui.h"
37
38 struct slow_common_header_t {
39 uint8_t proto_subtype;
40 uint8_t version;
41 };
42
43 #define SLOW_PROTO_LACP 1
44 #define SLOW_PROTO_MARKER 2
45 #define SLOW_PROTO_OAM 3
46
47 #define LACP_VERSION 1
48 #define MARKER_VERSION 1
49
50 static const struct tok slow_proto_values[] = {
51 { SLOW_PROTO_LACP, "LACP" },
52 { SLOW_PROTO_MARKER, "MARKER" },
53 { SLOW_PROTO_OAM, "OAM" },
54 { 0, NULL}
55 };
56
57 static const struct tok slow_oam_flag_values[] = {
58 { 0x0001, "Link Fault" },
59 { 0x0002, "Dying Gasp" },
60 { 0x0004, "Critical Event" },
61 { 0x0008, "Local Evaluating" },
62 { 0x0010, "Local Stable" },
63 { 0x0020, "Remote Evaluating" },
64 { 0x0040, "Remote Stable" },
65 { 0, NULL}
66 };
67
68 #define SLOW_OAM_CODE_INFO 0x00
69 #define SLOW_OAM_CODE_EVENT_NOTIF 0x01
70 #define SLOW_OAM_CODE_VAR_REQUEST 0x02
71 #define SLOW_OAM_CODE_VAR_RESPONSE 0x03
72 #define SLOW_OAM_CODE_LOOPBACK_CTRL 0x04
73 #define SLOW_OAM_CODE_PRIVATE 0xfe
74
75 static const struct tok slow_oam_code_values[] = {
76 { SLOW_OAM_CODE_INFO, "Information" },
77 { SLOW_OAM_CODE_EVENT_NOTIF, "Event Notification" },
78 { SLOW_OAM_CODE_VAR_REQUEST, "Variable Request" },
79 { SLOW_OAM_CODE_VAR_RESPONSE, "Variable Response" },
80 { SLOW_OAM_CODE_LOOPBACK_CTRL, "Loopback Control" },
81 { SLOW_OAM_CODE_PRIVATE, "Vendor Private" },
82 { 0, NULL}
83 };
84
85 struct slow_oam_info_t {
86 uint8_t info_type;
87 uint8_t info_length;
88 uint8_t oam_version;
89 uint8_t revision[2];
90 uint8_t state;
91 uint8_t oam_config;
92 uint8_t oam_pdu_config[2];
93 uint8_t oui[3];
94 uint8_t vendor_private[4];
95 };
96
97 #define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00
98 #define SLOW_OAM_INFO_TYPE_LOCAL 0x01
99 #define SLOW_OAM_INFO_TYPE_REMOTE 0x02
100 #define SLOW_OAM_INFO_TYPE_ORG_SPECIFIC 0xfe
101
102 static const struct tok slow_oam_info_type_values[] = {
103 { SLOW_OAM_INFO_TYPE_END_OF_TLV, "End of TLV marker" },
104 { SLOW_OAM_INFO_TYPE_LOCAL, "Local" },
105 { SLOW_OAM_INFO_TYPE_REMOTE, "Remote" },
106 { SLOW_OAM_INFO_TYPE_ORG_SPECIFIC, "Organization specific" },
107 { 0, NULL}
108 };
109
110 #define OAM_INFO_TYPE_PARSER_MASK 0x3
111 static const struct tok slow_oam_info_type_state_parser_values[] = {
112 { 0x00, "forwarding" },
113 { 0x01, "looping back" },
114 { 0x02, "discarding" },
115 { 0x03, "reserved" },
116 { 0, NULL}
117 };
118
119 #define OAM_INFO_TYPE_MUX_MASK 0x4
120 static const struct tok slow_oam_info_type_state_mux_values[] = {
121 { 0x00, "forwarding" },
122 { 0x04, "discarding" },
123 { 0, NULL}
124 };
125
126 static const struct tok slow_oam_info_type_oam_config_values[] = {
127 { 0x01, "Active" },
128 { 0x02, "Unidirectional" },
129 { 0x04, "Remote-Loopback" },
130 { 0x08, "Link-Events" },
131 { 0x10, "Variable-Retrieval" },
132 { 0, NULL}
133 };
134
135 /* 11 Bits */
136 #define OAM_INFO_TYPE_PDU_SIZE_MASK 0x7ff
137
138 #define SLOW_OAM_LINK_EVENT_END_OF_TLV 0x00
139 #define SLOW_OAM_LINK_EVENT_ERR_SYM_PER 0x01
140 #define SLOW_OAM_LINK_EVENT_ERR_FRM 0x02
141 #define SLOW_OAM_LINK_EVENT_ERR_FRM_PER 0x03
142 #define SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM 0x04
143 #define SLOW_OAM_LINK_EVENT_ORG_SPECIFIC 0xfe
144
145 static const struct tok slow_oam_link_event_values[] = {
146 { SLOW_OAM_LINK_EVENT_END_OF_TLV, "End of TLV marker" },
147 { SLOW_OAM_LINK_EVENT_ERR_SYM_PER, "Errored Symbol Period Event" },
148 { SLOW_OAM_LINK_EVENT_ERR_FRM, "Errored Frame Event" },
149 { SLOW_OAM_LINK_EVENT_ERR_FRM_PER, "Errored Frame Period Event" },
150 { SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM, "Errored Frame Seconds Summary Event" },
151 { SLOW_OAM_LINK_EVENT_ORG_SPECIFIC, "Organization specific" },
152 { 0, NULL}
153 };
154
155 struct slow_oam_link_event_t {
156 uint8_t event_type;
157 uint8_t event_length;
158 uint8_t time_stamp[2];
159 uint8_t window[8];
160 uint8_t threshold[8];
161 uint8_t errors[8];
162 uint8_t errors_running_total[8];
163 uint8_t event_running_total[4];
164 };
165
166 struct slow_oam_variablerequest_t {
167 uint8_t branch;
168 uint8_t leaf[2];
169 };
170
171 struct slow_oam_variableresponse_t {
172 uint8_t branch;
173 uint8_t leaf[2];
174 uint8_t length;
175 };
176
177 struct slow_oam_loopbackctrl_t {
178 uint8_t command;
179 };
180
181 static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
182 { 0x01, "Enable OAM Remote Loopback" },
183 { 0x02, "Disable OAM Remote Loopback" },
184 { 0, NULL}
185 };
186
187 struct tlv_header_t {
188 uint8_t type;
189 uint8_t length;
190 };
191
192 #define LACP_TLV_TERMINATOR 0x00
193 #define LACP_TLV_ACTOR_INFO 0x01
194 #define LACP_TLV_PARTNER_INFO 0x02
195 #define LACP_TLV_COLLECTOR_INFO 0x03
196
197 #define MARKER_TLV_TERMINATOR 0x00
198 #define MARKER_TLV_MARKER_INFO 0x01
199
200 static const struct tok slow_tlv_values[] = {
201 { (SLOW_PROTO_LACP << 8) + LACP_TLV_TERMINATOR, "Terminator"},
202 { (SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO, "Actor Information"},
203 { (SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO, "Partner Information"},
204 { (SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO, "Collector Information"},
205
206 { (SLOW_PROTO_MARKER << 8) + MARKER_TLV_TERMINATOR, "Terminator"},
207 { (SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO, "Marker Information"},
208 { 0, NULL}
209 };
210
211 struct lacp_tlv_actor_partner_info_t {
212 uint8_t sys_pri[2];
213 uint8_t sys[ETHER_ADDR_LEN];
214 uint8_t key[2];
215 uint8_t port_pri[2];
216 uint8_t port[2];
217 uint8_t state;
218 uint8_t pad[3];
219 };
220
221 static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
222 { 0x01, "Activity"},
223 { 0x02, "Timeout"},
224 { 0x04, "Aggregation"},
225 { 0x08, "Synchronization"},
226 { 0x10, "Collecting"},
227 { 0x20, "Distributing"},
228 { 0x40, "Default"},
229 { 0x80, "Expired"},
230 { 0, NULL}
231 };
232
233 struct lacp_tlv_collector_info_t {
234 uint8_t max_delay[2];
235 uint8_t pad[12];
236 };
237
238 struct marker_tlv_marker_info_t {
239 uint8_t req_port[2];
240 uint8_t req_sys[ETHER_ADDR_LEN];
241 uint8_t req_trans_id[4];
242 uint8_t pad[2];
243 };
244
245 struct lacp_marker_tlv_terminator_t {
246 uint8_t pad[50];
247 };
248
249 static void slow_marker_lacp_print(netdissect_options *, register const u_char *, register u_int);
250 static void slow_oam_print(netdissect_options *, register const u_char *, register u_int);
251
252 const struct slow_common_header_t *slow_com_header;
253
254 void
255 slow_print(netdissect_options *ndo,
256 register const u_char *pptr, register u_int len)
257 {
258 int print_version;
259
260 slow_com_header = (const struct slow_common_header_t *)pptr;
261 ND_TCHECK(*slow_com_header);
262
263 /*
264 * Sanity checking of the header.
265 */
266 switch (slow_com_header->proto_subtype) {
267 case SLOW_PROTO_LACP:
268 if (slow_com_header->version != LACP_VERSION) {
269 ND_PRINT((ndo, "LACP version %u packet not supported",slow_com_header->version));
270 return;
271 }
272 print_version = 1;
273 break;
274
275 case SLOW_PROTO_MARKER:
276 if (slow_com_header->version != MARKER_VERSION) {
277 ND_PRINT((ndo, "MARKER version %u packet not supported",slow_com_header->version));
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
293 if (print_version) {
294 ND_PRINT((ndo, "%sv%u, length %u",
295 tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
296 slow_com_header->version,
297 len));
298 } else {
299 /* some slow protos don't have a version number in the header */
300 ND_PRINT((ndo, "%s, length %u",
301 tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
302 len));
303 }
304
305 /* unrecognized subtype */
306 if (print_version == -1) {
307 print_unknown_data(ndo, pptr, "\n\t", len);
308 return;
309 }
310
311 if (!ndo->ndo_vflag)
312 return;
313
314 switch (slow_com_header->proto_subtype) {
315 default: /* should not happen */
316 break;
317
318 case SLOW_PROTO_OAM:
319 /* skip proto_subtype */
320 slow_oam_print(ndo, pptr+1, len-1);
321 break;
322
323 case SLOW_PROTO_LACP: /* LACP and MARKER share the same semantics */
324 case SLOW_PROTO_MARKER:
325 /* skip slow_common_header */
326 len -= sizeof(const struct slow_common_header_t);
327 pptr += sizeof(const struct slow_common_header_t);
328 slow_marker_lacp_print(ndo, pptr, len);
329 break;
330 }
331 return;
332
333 trunc:
334 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
335 }
336
337 static void
338 slow_marker_lacp_print(netdissect_options *ndo,
339 register const u_char *tptr, register u_int tlen)
340 {
341 const struct tlv_header_t *tlv_header;
342 const u_char *tlv_tptr;
343 u_int tlv_len, tlv_tlen;
344
345 union {
346 const struct lacp_marker_tlv_terminator_t *lacp_marker_tlv_terminator;
347 const struct lacp_tlv_actor_partner_info_t *lacp_tlv_actor_partner_info;
348 const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info;
349 const struct marker_tlv_marker_info_t *marker_tlv_marker_info;
350 } tlv_ptr;
351
352 while(tlen>0) {
353 /* did we capture enough for fully decoding the tlv header ? */
354 ND_TCHECK2(*tptr, sizeof(struct tlv_header_t));
355 tlv_header = (const struct tlv_header_t *)tptr;
356 tlv_len = tlv_header->length;
357
358 ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
359 tok2str(slow_tlv_values,
360 "Unknown",
361 (slow_com_header->proto_subtype << 8) + tlv_header->type),
362 tlv_header->type,
363 tlv_len));
364
365 if ((tlv_len < sizeof(struct tlv_header_t) ||
366 tlv_len > tlen) &&
367 tlv_header->type != LACP_TLV_TERMINATOR &&
368 tlv_header->type != MARKER_TLV_TERMINATOR) {
369 ND_PRINT((ndo, "\n\t-----trailing data-----"));
370 print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ", tlen);
371 return;
372 }
373
374 tlv_tptr=tptr+sizeof(struct tlv_header_t);
375 tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
376
377 /* did we capture enough for fully decoding the tlv ? */
378 ND_TCHECK2(*tptr, tlv_len);
379
380 switch((slow_com_header->proto_subtype << 8) + tlv_header->type) {
381
382 /* those two TLVs have the same structure -> fall through */
383 case ((SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO):
384 case ((SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO):
385 tlv_ptr.lacp_tlv_actor_partner_info = (const struct lacp_tlv_actor_partner_info_t *)tlv_tptr;
386
387 ND_PRINT((ndo, "\n\t System %s, System Priority %u, Key %u" \
388 ", Port %u, Port Priority %u\n\t State Flags [%s]",
389 etheraddr_string(ndo, tlv_ptr.lacp_tlv_actor_partner_info->sys),
390 EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri),
391 EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->key),
392 EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port),
393 EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port_pri),
394 bittok2str(lacp_tlv_actor_partner_info_state_values,
395 "none",
396 tlv_ptr.lacp_tlv_actor_partner_info->state)));
397
398 break;
399
400 case ((SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO):
401 tlv_ptr.lacp_tlv_collector_info = (const struct lacp_tlv_collector_info_t *)tlv_tptr;
402
403 ND_PRINT((ndo, "\n\t Max Delay %u",
404 EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay)));
405
406 break;
407
408 case ((SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO):
409 tlv_ptr.marker_tlv_marker_info = (const struct marker_tlv_marker_info_t *)tlv_tptr;
410
411 ND_PRINT((ndo, "\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x",
412 etheraddr_string(ndo, tlv_ptr.marker_tlv_marker_info->req_sys),
413 EXTRACT_16BITS(tlv_ptr.marker_tlv_marker_info->req_port),
414 EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id)));
415
416 break;
417
418 /* those two TLVs have the same structure -> fall through */
419 case ((SLOW_PROTO_LACP << 8) + LACP_TLV_TERMINATOR):
420 case ((SLOW_PROTO_MARKER << 8) + LACP_TLV_TERMINATOR):
421 tlv_ptr.lacp_marker_tlv_terminator = (const struct lacp_marker_tlv_terminator_t *)tlv_tptr;
422 if (tlv_len == 0) {
423 tlv_len = sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad) +
424 sizeof(struct tlv_header_t);
425 /* tell the user that we modified the length field */
426 if (ndo->ndo_vflag>1)
427 ND_PRINT((ndo, " (=%u)", tlv_len));
428 /* we have messed around with the length field - now we need to check
429 * again if there are enough bytes on the wire for the hexdump */
430 ND_TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
431 sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad));
432 }
433
434 break;
435
436 default:
437 if (ndo->ndo_vflag <= 1)
438 print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
439 break;
440 }
441 /* do we want to see an additional hexdump ? */
442 if (ndo->ndo_vflag > 1) {
443 print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ",
444 tlv_len-sizeof(struct tlv_header_t));
445 }
446
447 tptr+=tlv_len;
448 tlen-=tlv_len;
449 }
450 return;
451 trunc:
452 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
453 }
454
455 static void
456 slow_oam_print(netdissect_options *ndo,
457 register const u_char *tptr, register u_int tlen)
458 {
459 u_int hexdump;
460
461 struct slow_oam_common_header_t {
462 uint8_t flags[2];
463 uint8_t code;
464 };
465
466 struct slow_oam_tlv_header_t {
467 uint8_t type;
468 uint8_t length;
469 };
470
471 union {
472 const struct slow_oam_common_header_t *slow_oam_common_header;
473 const struct slow_oam_tlv_header_t *slow_oam_tlv_header;
474 } ptr;
475
476 union {
477 const struct slow_oam_info_t *slow_oam_info;
478 const struct slow_oam_link_event_t *slow_oam_link_event;
479 const struct slow_oam_variablerequest_t *slow_oam_variablerequest;
480 const struct slow_oam_variableresponse_t *slow_oam_variableresponse;
481 const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl;
482 } tlv;
483
484 ptr.slow_oam_common_header = (const struct slow_oam_common_header_t *)tptr;
485 tptr += sizeof(struct slow_oam_common_header_t);
486 tlen -= sizeof(struct slow_oam_common_header_t);
487
488 ND_PRINT((ndo, "\n\tCode %s OAM PDU, Flags [%s]",
489 tok2str(slow_oam_code_values, "Unknown (%u)", ptr.slow_oam_common_header->code),
490 bittok2str(slow_oam_flag_values,
491 "none",
492 EXTRACT_16BITS(&ptr.slow_oam_common_header->flags))));
493
494 switch (ptr.slow_oam_common_header->code) {
495 case SLOW_OAM_CODE_INFO:
496 while (tlen > 0) {
497 ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
498 ND_PRINT((ndo, "\n\t %s Information Type (%u), length %u",
499 tok2str(slow_oam_info_type_values, "Reserved",
500 ptr.slow_oam_tlv_header->type),
501 ptr.slow_oam_tlv_header->type,
502 ptr.slow_oam_tlv_header->length));
503
504 hexdump = FALSE;
505 switch (ptr.slow_oam_tlv_header->type) {
506 case SLOW_OAM_INFO_TYPE_END_OF_TLV:
507 if (ptr.slow_oam_tlv_header->length != 0) {
508 ND_PRINT((ndo, "\n\t ERROR: illegal length - should be 0"));
509 }
510 return;
511
512 case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */
513 case SLOW_OAM_INFO_TYPE_REMOTE:
514 tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;
515
516 if (tlv.slow_oam_info->info_length !=
517 sizeof(struct slow_oam_info_t)) {
518 ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
519 (unsigned long) sizeof(struct slow_oam_info_t)));
520 return;
521 }
522
523 ND_PRINT((ndo, "\n\t OAM-Version %u, Revision %u",
524 tlv.slow_oam_info->oam_version,
525 EXTRACT_16BITS(&tlv.slow_oam_info->revision)));
526
527 ND_PRINT((ndo, "\n\t State-Parser-Action %s, State-MUX-Action %s",
528 tok2str(slow_oam_info_type_state_parser_values, "Reserved",
529 tlv.slow_oam_info->state & OAM_INFO_TYPE_PARSER_MASK),
530 tok2str(slow_oam_info_type_state_mux_values, "Reserved",
531 tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)));
532 ND_PRINT((ndo, "\n\t OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",
533 bittok2str(slow_oam_info_type_oam_config_values, "none",
534 tlv.slow_oam_info->oam_config),
535 EXTRACT_16BITS(&tlv.slow_oam_info->oam_pdu_config) &
536 OAM_INFO_TYPE_PDU_SIZE_MASK));
537 ND_PRINT((ndo, "\n\t OUI %s (0x%06x), Vendor-Private 0x%08x",
538 tok2str(oui_values, "Unknown",
539 EXTRACT_24BITS(&tlv.slow_oam_info->oui)),
540 EXTRACT_24BITS(&tlv.slow_oam_info->oui),
541 EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private)));
542 break;
543
544 case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC:
545 hexdump = TRUE;
546 break;
547
548 default:
549 hexdump = TRUE;
550 break;
551 }
552
553 /* infinite loop check */
554 if (!ptr.slow_oam_tlv_header->length) {
555 return;
556 }
557
558 /* do we also want to see a hex dump ? */
559 if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
560 print_unknown_data(ndo, tptr, "\n\t ",
561 ptr.slow_oam_tlv_header->length);
562 }
563
564 tlen -= ptr.slow_oam_tlv_header->length;
565 tptr += ptr.slow_oam_tlv_header->length;
566 }
567 break;
568
569 case SLOW_OAM_CODE_EVENT_NOTIF:
570 while (tlen > 0) {
571 ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
572 ND_PRINT((ndo, "\n\t %s Link Event Type (%u), length %u",
573 tok2str(slow_oam_link_event_values, "Reserved",
574 ptr.slow_oam_tlv_header->type),
575 ptr.slow_oam_tlv_header->type,
576 ptr.slow_oam_tlv_header->length));
577
578 hexdump = FALSE;
579 switch (ptr.slow_oam_tlv_header->type) {
580 case SLOW_OAM_LINK_EVENT_END_OF_TLV:
581 if (ptr.slow_oam_tlv_header->length != 0) {
582 ND_PRINT((ndo, "\n\t ERROR: illegal length - should be 0"));
583 }
584 return;
585
586 case SLOW_OAM_LINK_EVENT_ERR_SYM_PER: /* identical format - fall through */
587 case SLOW_OAM_LINK_EVENT_ERR_FRM:
588 case SLOW_OAM_LINK_EVENT_ERR_FRM_PER:
589 case SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM:
590 tlv.slow_oam_link_event = (const struct slow_oam_link_event_t *)tptr;
591
592 if (tlv.slow_oam_link_event->event_length !=
593 sizeof(struct slow_oam_link_event_t)) {
594 ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
595 (unsigned long) sizeof(struct slow_oam_link_event_t)));
596 return;
597 }
598
599 ND_PRINT((ndo, "\n\t Timestamp %u ms, Errored Window %" PRIu64
600 "\n\t Errored Threshold %" PRIu64
601 "\n\t Errors %" PRIu64
602 "\n\t Error Running Total %" PRIu64
603 "\n\t Event Running Total %u",
604 EXTRACT_16BITS(&tlv.slow_oam_link_event->time_stamp)*100,
605 EXTRACT_64BITS(&tlv.slow_oam_link_event->window),
606 EXTRACT_64BITS(&tlv.slow_oam_link_event->threshold),
607 EXTRACT_64BITS(&tlv.slow_oam_link_event->errors),
608 EXTRACT_64BITS(&tlv.slow_oam_link_event->errors_running_total),
609 EXTRACT_32BITS(&tlv.slow_oam_link_event->event_running_total)));
610 break;
611
612 case SLOW_OAM_LINK_EVENT_ORG_SPECIFIC:
613 hexdump = TRUE;
614 break;
615
616 default:
617 hexdump = TRUE;
618 break;
619 }
620
621 /* infinite loop check */
622 if (!ptr.slow_oam_tlv_header->length) {
623 return;
624 }
625
626 /* do we also want to see a hex dump ? */
627 if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
628 print_unknown_data(ndo, tptr, "\n\t ",
629 ptr.slow_oam_tlv_header->length);
630 }
631
632 tlen -= ptr.slow_oam_tlv_header->length;
633 tptr += ptr.slow_oam_tlv_header->length;
634 }
635 break;
636
637 case SLOW_OAM_CODE_LOOPBACK_CTRL:
638 tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr;
639 ND_PRINT((ndo, "\n\t Command %s (%u)",
640 tok2str(slow_oam_loopbackctrl_cmd_values,
641 "Unknown",
642 tlv.slow_oam_loopbackctrl->command),
643 tlv.slow_oam_loopbackctrl->command));
644 tptr ++;
645 tlen --;
646 break;
647
648 /*
649 * FIXME those are the defined codes that lack a decoder
650 * you are welcome to contribute code ;-)
651 */
652 case SLOW_OAM_CODE_VAR_REQUEST:
653 case SLOW_OAM_CODE_VAR_RESPONSE:
654 case SLOW_OAM_CODE_PRIVATE:
655 default:
656 if (ndo->ndo_vflag <= 1) {
657 print_unknown_data(ndo, tptr, "\n\t ", tlen);
658 }
659 break;
660 }
661 return;
662 }
663