3939#define LACP_VERSION 1
4040#define MARKER_VERSION 1
4141
42- static const struct tok slow_proto_values [] = {
43- { SLOW_PROTO_LACP , "LACP" },
44- { SLOW_PROTO_MARKER , "MARKER" },
45- { SLOW_PROTO_OAM , "OAM" },
46- { SLOW_PROTO_OSSP , "OSSP" },
47- { 0 , NULL }
48- };
49-
5042static const struct tok slow_oam_flag_values [] = {
5143 { 0x0001 , "Link Fault" },
5244 { 0x0002 , "Dying Gasp" },
@@ -239,104 +231,49 @@ struct lacp_marker_tlv_terminator_t {
239231 nd_byte pad [50 ];
240232};
241233
242- static void slow_marker_lacp_print (netdissect_options * , const u_char * , u_int , u_int );
234+ static void slow_lacp_print (netdissect_options * , const u_char * , u_int );
235+ static void slow_marker_print (netdissect_options * , const u_char * , u_int );
243236static void slow_oam_print (netdissect_options * , const u_char * , u_int );
244237static void slow_ossp_print (netdissect_options * , const u_char * , u_int );
245238
239+ /*
240+ * Print Slow Protocol. (802.3 Annex 57A)
241+ */
246242void
247243slow_print (netdissect_options * ndo ,
248244 const u_char * pptr , u_int len )
249245{
250- int print_version ;
251246 u_int subtype ;
252247
253248 ndo -> ndo_protocol = "slow" ;
249+
254250 if (len < 1 )
255251 goto tooshort ;
256252 subtype = GET_U_1 (pptr );
253+ len -= 1 ;
254+ pptr += 1 ;
257255
258- /*
259- * Sanity checking of the header.
260- */
261256 switch (subtype ) {
262257 case SLOW_PROTO_LACP :
263- if (len < 2 )
264- goto tooshort ;
265- if (GET_U_1 (pptr + 1 ) != LACP_VERSION ) {
266- ND_PRINT ("LACP version %u packet not supported" ,
267- GET_U_1 (pptr + 1 ));
268- return ;
269- }
270- print_version = 1 ;
258+ slow_lacp_print (ndo , pptr , len );
271259 break ;
272260
273261 case SLOW_PROTO_MARKER :
274- if (len < 2 )
275- goto tooshort ;
276- if (GET_U_1 (pptr + 1 ) != MARKER_VERSION ) {
277- ND_PRINT ("MARKER version %u packet not supported" ,
278- GET_U_1 (pptr + 1 ));
279- return ;
280- }
281- print_version = 1 ;
262+ slow_marker_print (ndo , pptr , len );
282263 break ;
283264
284265 case SLOW_PROTO_OAM :
285- case SLOW_PROTO_OSSP :
286- print_version = 0 ;
287- break ;
288-
289- default :
290- /* print basic information and exit */
291- print_version = -1 ;
292- break ;
293- }
294-
295- if (print_version == 1 ) {
296- ND_PRINT ("%sv%u, length %u" ,
297- tok2str (slow_proto_values , "unknown (%u)" , subtype ),
298- GET_U_1 ((pptr + 1 )),
299- len );
300- } else {
301- /* some slow protos don't have a version number in the header */
302- ND_PRINT ("%s, length %u" ,
303- tok2str (slow_proto_values , "unknown (%u)" , subtype ),
304- len );
305- }
306-
307- /* unrecognized subtype */
308- if (print_version == -1 ) {
309- print_unknown_data (ndo , pptr , "\n\t" , len );
310- return ;
311- }
312-
313- if (!ndo -> ndo_vflag )
314- return ;
315-
316- switch (subtype ) {
317- default : /* should not happen */
266+ slow_oam_print (ndo , pptr , len );
318267 break ;
319268
320269 case SLOW_PROTO_OSSP :
321- /* skip subtype */
322- len -= 1 ;
323- pptr += 1 ;
324270 slow_ossp_print (ndo , pptr , len );
325271 break ;
326272
327- case SLOW_PROTO_OAM :
328- /* skip subtype */
329- len -= 1 ;
330- pptr += 1 ;
331- slow_oam_print (ndo , pptr , len );
332- break ;
333-
334- case SLOW_PROTO_LACP : /* LACP and MARKER share the same semantics */
335- case SLOW_PROTO_MARKER :
336- /* skip subtype and version */
337- len -= 2 ;
338- pptr += 2 ;
339- slow_marker_lacp_print (ndo , pptr , len , subtype );
273+ default :
274+ ND_PRINT ("unknown (%u), length %u" , subtype , len + 1 );
275+ if (ndo -> ndo_vflag )
276+ print_unknown_data (ndo , pptr , "\n\t" , len );
340277 break ;
341278 }
342279 return ;
@@ -348,6 +285,9 @@ slow_print(netdissect_options *ndo,
348285 ND_PRINT ("\n\t\t packet is too short" );
349286}
350287
288+ /*
289+ * Common tlv logic for LACPv1 and Marker.
290+ */
351291static void
352292slow_marker_lacp_print (netdissect_options * ndo ,
353293 const u_char * tptr , u_int tlen ,
@@ -485,6 +425,83 @@ slow_marker_lacp_print(netdissect_options *ndo,
485425 ND_PRINT ("\n\t\t packet is too short" );
486426}
487427
428+ /*
429+ * Print Link Aggregation Control Protocol. (802.3ad / 802.1AX)
430+ */
431+ static void
432+ slow_lacp_print (netdissect_options * ndo ,
433+ const u_char * tptr , u_int tlen )
434+ {
435+ u_int version ;
436+
437+ if (tlen < 1 )
438+ goto tooshort ;
439+
440+ version = GET_U_1 (tptr );
441+ tlen -= 1 ;
442+ tptr += 1 ;
443+
444+ ND_PRINT ("LACPv%u, length %u" , version , tlen + 2 );
445+
446+ if (!ndo -> ndo_vflag )
447+ return ;
448+
449+ switch (version ) {
450+ case LACP_VERSION :
451+ slow_marker_lacp_print (ndo , tptr , tlen , SLOW_PROTO_LACP );
452+ break ;
453+
454+ /* TODO LACPv2 */
455+
456+ default :
457+ print_unknown_data (ndo , tptr , "\n\t" , tlen );
458+ break ;
459+ }
460+ return ;
461+
462+ tooshort :
463+ ND_PRINT ("\n\t\t packet is too short" );
464+ }
465+
466+ /*
467+ * Print Marker protocol. (802.3ad / 802.1ax)
468+ */
469+ static void
470+ slow_marker_print (netdissect_options * ndo ,
471+ const u_char * tptr , u_int tlen )
472+ {
473+ u_int version ;
474+
475+ if (tlen < 1 )
476+ goto tooshort ;
477+
478+ version = GET_U_1 (tptr );
479+ tlen -= 1 ;
480+ tptr += 1 ;
481+
482+ ND_PRINT ("MARKERv%u, length %u" , version , tlen + 2 );
483+
484+ if (!ndo -> ndo_vflag )
485+ return ;
486+
487+ switch (version ) {
488+ case MARKER_VERSION :
489+ slow_marker_lacp_print (ndo , tptr , tlen , SLOW_PROTO_MARKER );
490+ break ;
491+
492+ default :
493+ print_unknown_data (ndo , tptr , "\n\t" , tlen );
494+ break ;
495+ }
496+ return ;
497+
498+ tooshort :
499+ ND_PRINT ("\n\t\t packet is too short" );
500+ }
501+
502+ /*
503+ * Print Operations, Administration, and Maintenance. (802.3)
504+ */
488505static void
489506slow_oam_print (netdissect_options * ndo ,
490507 const u_char * tptr , u_int tlen )
@@ -518,6 +535,11 @@ slow_oam_print(netdissect_options *ndo,
518535 const struct slow_oam_loopbackctrl_t * slow_oam_loopbackctrl ;
519536 } tlv ;
520537
538+ ND_PRINT ("OAM, length %u" , tlen + 1 );
539+
540+ if (!ndo -> ndo_vflag )
541+ return ;
542+
521543 ptr .slow_oam_common_header = (const struct slow_oam_common_header_t * )tptr ;
522544 if (tlen < sizeof (* ptr .slow_oam_common_header ))
523545 goto tooshort ;
@@ -754,6 +776,11 @@ slow_ossp_print(netdissect_options *ndo,
754776{
755777 uint32_t oui ;
756778
779+ ND_PRINT ("OSSP, length %u" , tlen + 1 );
780+
781+ if (!ndo -> ndo_vflag )
782+ return ;
783+
757784 ND_ICHECKMSG_U ("length" , tlen , < , 3 );
758785
759786 oui = GET_BE_U_3 (tptr );
0 commit comments