From: hannes Date: Fri, 3 Oct 2003 13:00:33 +0000 (+0000) Subject: show opaque-LSA specific fields of the LSA header X-Git-Tag: tcpdump-3.8-bp~42 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/c1fa2c99cc0099a655ca175630181b2594b2b32a show opaque-LSA specific fields of the LSA header --- diff --git a/ospf.h b/ospf.h index 08e4e095..6da06a06 100644 --- a/ospf.h +++ b/ospf.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.8 2003-10-02 13:35:52 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.9 2003-10-03 13:00:33 hannes Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -107,7 +107,13 @@ struct lsa_hdr { u_int16_t ls_age; u_int8_t ls_options; u_int8_t ls_type; - struct in_addr ls_stateid; + union { + struct in_addr ls_stateid; + struct { /* opaque LSAs change the LSA-ID field */ + u_int8_t opaque_type; + u_int8_t opaque_id[3]; + }; + }; struct in_addr ls_router; u_int32_t ls_seq; u_int16_t ls_chksum; @@ -162,16 +168,6 @@ struct lsa { struct in_addr mcla_vid; } un_mcla[1]; - /* Opaque LSA */ - struct opaque { - u_int8_t opaque_type; - u_int8_t opaque_id[3]; - struct in_addr adv_router; - struct in_addr sequence_num; - u_int16_t chksum; - u_int16_t length; - } un_opaque[1]; - /* Unknown LSA */ struct unknown { u_int8_t data[1]; /* may repeat */ diff --git a/print-ospf.c b/print-ospf.c index 6cb6f98d..eaf0bb3e 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.37 2003-10-02 13:35:52 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.38 2003-10-03 13:00:33 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -144,13 +144,36 @@ ospf_print_lsa(register const struct lsa *lsap) register const u_int32_t *lp; register int j, k; - printf("\n\t %s LSA (%d), LSA-ID: %s, Advertising Router: %s, seq 0x%08x, age %us", - tok2str(lsa_values,"unknown",lsap->ls_hdr.ls_type), - lsap->ls_hdr.ls_type, - ipaddr_string(&lsap->ls_hdr.ls_stateid), - ipaddr_string(&lsap->ls_hdr.ls_router), - EXTRACT_32BITS(&lsap->ls_hdr.ls_seq), - EXTRACT_16BITS(&lsap->ls_hdr.ls_age)); + switch (lsap->ls_hdr.ls_type) { + + /* the LSA header for opaque LSAs was slightly changed */ + case LS_TYPE_OPAQUE_LL: + case LS_TYPE_OPAQUE_AL: + case LS_TYPE_OPAQUE_DW: + + printf("\n\t %s LSA (%d), Opaque-Type: %u, Opaque-ID: %u, Adv. Router: %s, seq 0x%08x, age %us", + tok2str(lsa_values,"unknown",lsap->ls_hdr.ls_type), + (lsap->ls_hdr.ls_type), + *(&lsap->ls_hdr.opaque_type), + EXTRACT_24BITS(&lsap->ls_hdr.opaque_id), + ipaddr_string(&lsap->ls_hdr.ls_router), + EXTRACT_32BITS(&lsap->ls_hdr.ls_seq), + EXTRACT_16BITS(&lsap->ls_hdr.ls_age)); + + break; + + /* all other LSA types use regular style LSA headers */ + default: + printf("\n\t %s LSA (%d), LSA-ID: %s, Adv. Router: %s, seq 0x%08x, age %us", + tok2str(lsa_values,"unknown",lsap->ls_hdr.ls_type), + lsap->ls_hdr.ls_type, + ipaddr_string(&lsap->ls_hdr.ls_stateid), + ipaddr_string(&lsap->ls_hdr.ls_router), + EXTRACT_32BITS(&lsap->ls_hdr.ls_seq), + EXTRACT_16BITS(&lsap->ls_hdr.ls_age)); + break; + } + printf("\n\t Options: %s", bittok2str(ospf_option_values,"none",lsap->ls_hdr.ls_options)); TCHECK(lsap->ls_hdr.ls_length);