X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/58b83f6ad4e1b8538a266528af742f97b69ee63a..fe0fcd92e3ae841f7ccf84b250df1ec4afdaecbc:/print-isoclns.c diff --git a/print-isoclns.c b/print-isoclns.c index 4ceebcc0..16cedfc4 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -25,8 +25,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.94 2003-08-13 02:26:52 itojun Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.108 2003-11-16 09:36:25 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -110,20 +110,20 @@ static struct tok isis_pdu_values[] = { #define TLV_AUTH 10 /* iso10589, rfc3567 */ #define TLV_CHECKSUM 12 /* rfc3358 */ #define TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */ -#define TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-04 */ +#define TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */ #define TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */ #define TLV_DECNET_PHASE4 42 #define TLV_LUCENT_PRIVATE 66 -#define TLV_IP_REACH 128 /* rfc1195, rfc2966 */ +#define TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */ #define TLV_PROTOCOLS 129 /* rfc1195 */ -#define TLV_IP_REACH_EXT 130 /* rfc1195, rfc2966 */ +#define TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */ #define TLV_IDRP_INFO 131 /* rfc1195 */ #define TLV_IPADDR 132 /* rfc1195 */ #define TLV_IPAUTH 133 /* rfc1195 */ -#define TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-04 */ -#define TLV_EXT_IP_REACH 135 /* draft-ietf-isis-traffic-04 */ +#define TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */ +#define TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */ #define TLV_HOSTNAME 137 /* rfc2763 */ -#define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions-14 */ +#define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */ #define TLV_NORTEL_PRIVATE1 176 #define TLV_NORTEL_PRIVATE2 177 #define TLV_HOLDTIME 198 /* ES-IS */ @@ -155,14 +155,14 @@ static struct tok isis_tlv_values[] = { { TLV_IS_ALIAS_ID, "IS Alias ID"}, { TLV_DECNET_PHASE4, "DECnet Phase IV"}, { TLV_LUCENT_PRIVATE, "Lucent Proprietary"}, - { TLV_IP_REACH, "IPv4 Internal reachability"}, + { TLV_INT_IP_REACH, "IPv4 Internal Reachability"}, { TLV_PROTOCOLS, "Protocols supported"}, - { TLV_IP_REACH_EXT, "IPv4 External reachability"}, + { TLV_EXT_IP_REACH, "IPv4 External Reachability"}, { TLV_IDRP_INFO, "Inter-Domain Information Type"}, { TLV_IPADDR, "IPv4 Interface address(es)"}, { TLV_IPAUTH, "IPv4 authentication (deprecated)"}, { TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"}, - { TLV_EXT_IP_REACH, "Extended IPv4 reachability"}, + { TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"}, { TLV_HOSTNAME, "Hostname"}, { TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"}, { TLV_NORTEL_PRIVATE1, "Nortel Proprietary"}, @@ -172,30 +172,30 @@ static struct tok isis_tlv_values[] = { { TLV_MT_IS_REACH, "Multi Topology IS Reachability"}, { TLV_MT_SUPPORTED, "Multi Topology"}, { TLV_IP6ADDR, "IPv6 Interface address(es)"}, - { TLV_MT_IP_REACH, "Multi-Topology IPv4 reachability"}, + { TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"}, { TLV_IP6_REACH, "IPv6 reachability"}, - { TLV_MT_IP6_REACH, "Multi-Topology IP6 reachability"}, + { TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"}, { TLV_PTP_ADJ, "Point-to-point Adjacency State"}, { TLV_IIH_SEQNR, "Hello PDU Sequence Number"}, { TLV_VENDOR_PRIVATE, "Vendor Private"}, { 0, NULL } }; -#define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 -#define SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID 4 -#define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 -#define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 -#define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 -#define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 -#define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 -#define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 -#define SUBTLV_EXT_IS_REACH_TE_METRIC 18 -#define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 -#define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 +#define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */ +#define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */ +#define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */ +#define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */ static struct tok isis_ext_is_reach_subtlv_values[] = { { SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" }, - { SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID, "Link Local Identifier" }, + { SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, { SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" }, { SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" }, { SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" }, @@ -214,12 +214,12 @@ static struct tok isis_ext_is_reach_subtlv_values[] = { { 0, NULL } }; -#define SUBTLV_IP_REACH_ADMIN_TAG32 1 -#define SUBTLV_IP_REACH_ADMIN_TAG64 2 +#define SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 +#define SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 static struct tok isis_ext_ip_reach_subtlv_values[] = { - { SUBTLV_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" }, - { SUBTLV_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" }, + { SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" }, + { SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" }, { 0, NULL } }; @@ -266,11 +266,11 @@ static struct tok isis_mt_flag_values[] = { { 0, NULL} }; -#define ISIS_MASK_TLV_EXT_IP_UPDOWN(x) ((x)&0x80) -#define ISIS_MASK_TLV_EXT_IP_SUBTLV(x) ((x)&0x40) +#define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80) +#define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40) -#define ISIS_MASK_TLV_EXT_IP6_IE(x) ((x)&0x40) -#define ISIS_MASK_TLV_EXT_IP6_SUBTLV(x) ((x)&0x20) +#define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40) +#define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20) #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80) #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40) @@ -434,15 +434,11 @@ struct isis_tlv_lsp { u_int8_t checksum[2]; }; - -/* allocate space for the following string - * xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx - * 50 bytes plus one termination byte */ static char * print_nsap(register const u_int8_t *pptr, register int nsap_length) { int nsap_idx; - static char nsap_ascii_output[51]; + static char nsap_ascii_output[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")]; char *junk_buf = nsap_ascii_output; if (nsap_length < 1 || nsap_length > 20) { @@ -686,15 +682,12 @@ esis_print(const u_int8_t *p, u_int length) } } -/* shared routine for printing system, node and lsp-ids - * allocate space for the worst-case string - * xxxx.xxxx.xxxx.yy-zz - * 20 bytes plus one termination byte */ +/* shared routine for printing system, node and lsp-ids */ static char * isis_print_id(const u_int8_t *cp, int id_len) { int i; - static char id[21]; + static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")]; char *pos = id; for (i = 1; i <= SYSTEM_ID_LEN; i++) { @@ -745,7 +738,7 @@ isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length) while (length > 0) { if ((size_t)length < sizeof(*tlv_ip_reach)) { - printf("short IPv4 reachability (%d vs %lu)", + printf("short IPv4 Reachability (%d vs %lu)", length, (unsigned long)sizeof(*tlv_ip_reach)); return (0); @@ -805,7 +798,7 @@ static int isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) { /* first lets see if we know the subTLVs name*/ - printf("%s%s (subTLV #%u), length: %u", + printf("%s%s subTLV #%u, length: %u", ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", @@ -817,7 +810,7 @@ isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i goto trunctlv; switch(subt) { - case SUBTLV_IP_REACH_ADMIN_TAG32: + case SUBTLV_EXTD_IP_REACH_ADMIN_TAG32: while (subl >= 4) { printf(", 0x%08x (=%u)", EXTRACT_32BITS(tptr), @@ -826,7 +819,7 @@ isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i subl-=4; } break; - case SUBTLV_IP_REACH_ADMIN_TAG64: + case SUBTLV_EXTD_IP_REACH_ADMIN_TAG64: while (subl >= 8) { printf(", 0x%08x%08x", EXTRACT_32BITS(tptr), @@ -856,14 +849,14 @@ trunctlv: static int isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) { - int i; + int priority_level; union { /* int to float conversion buffer for several subTLVs */ float f; u_int32_t i; } bw; /* first lets see if we know the subTLVs name*/ - printf("%s%s (subTLV #%u), length: %u", + printf("%s%s subTLV #%u, length: %u", ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", @@ -876,9 +869,11 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i switch(subt) { case SUBTLV_EXT_IS_REACH_ADMIN_GROUP: - case SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID: + case SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID: case SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID: printf(", 0x%08x", EXTRACT_32BITS(tptr)); + if (subl == 8) /* draft-ietf-isis-gmpls-extensions */ + printf(", 0x%08x", EXTRACT_32BITS(tptr+4)); break; case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: @@ -890,12 +885,13 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i printf(", %.3f Mbps", bw.f*8/1000000 ); break; case SUBTLV_EXT_IS_REACH_UNRESERVED_BW : - for (i = 0; i < 8; i++) { + for (priority_level = 0; priority_level < 8; priority_level++) { bw.i = EXTRACT_32BITS(tptr); printf("%s priority level %d: %.3f Mbps", ident, - i, + priority_level, bw.f*8/1000000 ); + tptr+=4; } break; case SUBTLV_EXT_IS_REACH_TE_METRIC: @@ -912,13 +908,15 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))); printf(", LSP Encoding: %s", tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); + tptr+=4; printf("%s Max LSP Bandwidth:",ident); - for (i = 0; i < 8; i++) { + for (priority_level = 0; priority_level < 8; priority_level++) { bw.i = EXTRACT_32BITS(tptr); printf("%s priority level %d: %.3f Mbps", ident, - i, + priority_level, bw.f*8/1000000 ); + tptr+=4; } subl-=36; /* there is some optional stuff left to decode but this is as of yet @@ -949,10 +947,10 @@ trunctlv: */ static int -isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv) { +isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) { char ident_buffer[20]; - int subt,subl,tslen; + int subtlv_type,subtlv_len,subtlv_sum_len; int proc_bytes = 0; /* how many bytes did we process ? */ if (!TTEST2(*tptr, NODE_ID_LEN)) @@ -961,8 +959,8 @@ isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv) { printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)); tptr+=(NODE_ID_LEN); - if (tlv != TLV_IS_ALIAS_ID) { - if (!TTEST2(*tptr, 3)) + if (tlv_type != TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */ + if (!TTEST2(*tptr, 3)) /* and is therefore skipped */ return(0); printf(", Metric: %d",EXTRACT_24BITS(tptr)); tptr+=3; @@ -970,23 +968,23 @@ isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv) { if (!TTEST2(*tptr, 1)) return(0); - tslen=*(tptr++); /* read out subTLV length */ + subtlv_sum_len=*(tptr++); /* read out subTLV length */ proc_bytes=NODE_ID_LEN+3+1; - printf(", %ssub-TLVs present",tslen ? "" : "no "); - if (tslen) { - printf(" (%u)",tslen); - while (tslen>0) { + printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no "); + if (subtlv_sum_len) { + printf(" (%u)",subtlv_sum_len); + while (subtlv_sum_len>0) { if (!TTEST2(*tptr,2)) return(0); - subt=*(tptr++); - subl=*(tptr++); + subtlv_type=*(tptr++); + subtlv_len=*(tptr++); /* prepend the ident string */ snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); - if(!isis_print_is_reach_subtlv(tptr,subt,subl,ident_buffer)) + if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer)) return(0); - tptr+=subl; - tslen-=(subl+2); - proc_bytes+=(subl+2); + tptr+=subtlv_len; + subtlv_sum_len-=(subtlv_len+2); + proc_bytes+=(subtlv_len+2); } } return(proc_bytes); @@ -1076,20 +1074,20 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi #endif printf(", Distribution: %s, Metric: %u", - ISIS_MASK_TLV_EXT_IP_UPDOWN(status_byte) ? "down" : "up", + ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up", metric); - if (afi == IPV4 && ISIS_MASK_TLV_EXT_IP_SUBTLV(status_byte)) + if (afi == IPV4 && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) printf(", sub-TLVs present"); #ifdef INET6 if (afi == IPV6) printf(", %s%s", - ISIS_MASK_TLV_EXT_IP6_IE(status_byte) ? "External" : "Internal", - ISIS_MASK_TLV_EXT_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""); + ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal", + ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""); #endif - if ((ISIS_MASK_TLV_EXT_IP_SUBTLV(status_byte) && afi == IPV4) || - (ISIS_MASK_TLV_EXT_IP6_SUBTLV(status_byte) && afi == IPV6)) { + if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte) && afi == IPV4) || + (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == IPV6)) { /* assume that one prefix can hold more than one subTLV - therefore the first byte must reflect the aggregate bytecount of the subTLVs for this prefix @@ -1224,10 +1222,14 @@ static int isis_print (const u_int8_t *p, u_int length) case L1_LAN_IIH: case L2_LAN_IIH: - printf(", source-id %s", isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN)); + printf(", src-id %s", + isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN)); + printf(", lan-id %s, prio %u", + isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN), + header_iih_lan->priority); break; case PTP_IIH: - printf(", source-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN)); + printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN)); break; case L1_LSP: case L2_LSP: @@ -1238,11 +1240,11 @@ static int isis_print (const u_int8_t *p, u_int length) break; case L1_CSNP: case L2_CSNP: - printf(", source-id %s", isis_print_id(header_csnp->source_id,SYSTEM_ID_LEN)); + printf(", src-id %s", isis_print_id(header_csnp->source_id,SYSTEM_ID_LEN)); break; case L1_PSNP: case L2_PSNP: - printf(", source-id %s", isis_print_id(header_psnp->source_id,SYSTEM_ID_LEN)); + printf(", src-id %s", isis_print_id(header_psnp->source_id,SYSTEM_ID_LEN)); break; } @@ -1254,7 +1256,10 @@ static int isis_print (const u_int8_t *p, u_int length) /* ok they seem to want to know everything - lets fully decode it */ printf(", IS-IS, length: %u",length); - printf("\n\thlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)", + printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)", + tok2str(isis_pdu_values, + "unknown, type %u", + pdu_type), header->fixed_len, header->version, header->pdu_version, @@ -1263,12 +1268,6 @@ static int isis_print (const u_int8_t *p, u_int length) max_area, header->max_area); - /* first lets see if we know the PDU name*/ - printf(", pdu-type: %s", - tok2str(isis_pdu_values, - "unknown, type %u", - pdu_type)); - if (vflag > 1) { if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */ return(0); /* for optionally debugging the common header */ @@ -1326,13 +1325,15 @@ static int isis_print (const u_int8_t *p, u_int length) } TCHECK(*header_iih_ptp); - printf("\n\t source-id: %s, holding time: %us, circuit-id: 0x%02x, %s, PDU length: %u", + printf("\n\t source-id: %s, holding time: %us, Flags: [%s]", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN), EXTRACT_16BITS(header_iih_ptp->holding_time), - header_iih_ptp->circuit_id, tok2str(isis_iih_circuit_type_values, "unknown circuit type 0x%02x", - header_iih_ptp->circuit_type), + header_iih_ptp->circuit_type)); + + printf("\n\t circuit-id: 0x%02x, PDU length: %u", + header_iih_ptp->circuit_id, pdu_len); if (vflag > 1) { @@ -1359,19 +1360,25 @@ static int isis_print (const u_int8_t *p, u_int length) } TCHECK(*header_lsp); - printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us", + printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x", isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), EXTRACT_32BITS(header_lsp->sequence_number), - EXTRACT_16BITS(header_lsp->remaining_lifetime)); - /* verify the checksum - - * checking starts at the lsp-id field - * which is 12 bytes after the packet start*/ - printf("\n\t chksum: 0x%04x (%s), PDU length: %u", - EXTRACT_16BITS(header_lsp->checksum), - (osi_cksum(optr+12, length-12)) ? "incorrect" : "correct", - pdu_len); - - printf(", %s", ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""); + EXTRACT_16BITS(header_lsp->remaining_lifetime), + EXTRACT_16BITS(header_lsp->checksum)); + + /* if this is a purge do not attempt to verify the checksum */ + if ( EXTRACT_16BITS(header_lsp->remaining_lifetime) == 0 && + EXTRACT_16BITS(header_lsp->checksum) == 0) + printf(" (purged)"); + else + /* verify the checksum - + * checking starts at the lsp-id field at byte position [12] + * hence the length needs to be reduced by 12 bytes */ + printf(" (%s)", (osi_cksum((u_int8_t *)header_lsp->lsp_id, length-12)) ? "incorrect" : "correct"); + + printf(", PDU length: %u, Flags: [ %s", + pdu_len, + ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""); if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""); @@ -1381,7 +1388,7 @@ static int isis_print (const u_int8_t *p, u_int length) printf("ATT bit set, "); } printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""); - printf("%s", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))); + printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))); if (vflag > 1) { if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE)) @@ -1439,8 +1446,9 @@ static int isis_print (const u_int8_t *p, u_int length) } TCHECK(*header_psnp); - printf("\n\t source-id: %s", - isis_print_id(header_psnp->source_id, NODE_ID_LEN)); + printf("\n\t source-id: %s, PDU length: %u", + isis_print_id(header_psnp->source_id, NODE_ID_LEN), + pdu_len); if (vflag > 1) { if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE)) @@ -1511,7 +1519,7 @@ static int isis_print (const u_int8_t *p, u_int length) while (tmp >= ETHER_ADDR_LEN) { if (!TTEST2(*tptr, ETHER_ADDR_LEN)) goto trunctlv; - printf("\n\t IS Neighbor: %s",isis_print_id(tptr,ETHER_ADDR_LEN)); + printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN)); tmp -= ETHER_ADDR_LEN; tptr += ETHER_ADDR_LEN; } @@ -1604,13 +1612,13 @@ static int isis_print (const u_int8_t *p, u_int length) break; /* those two TLVs share the same format */ - case TLV_IP_REACH: - case TLV_IP_REACH_EXT: + case TLV_INT_IP_REACH: + case TLV_EXT_IP_REACH: if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len)) return (1); break; - case TLV_EXT_IP_REACH: + case TLV_EXTD_IP_REACH: while (tmp>0) { ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); if (ext_ip_len == 0) /* did something go wrong ? */ @@ -1715,22 +1723,23 @@ static int isis_print (const u_int8_t *p, u_int length) if(tmp>=1) { if (!TTEST2(*tptr, 1)) goto trunctlv; - printf("\n\t Adjacency State: %s", - tok2str(isis_ptp_adjancey_values, "0x%02x", *tptr)); + printf("\n\t Adjacency State: %s (%u)", + tok2str(isis_ptp_adjancey_values, "unknown", *tptr), + *tptr); tmp--; } if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) { if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id, sizeof(tlv_ptp_adj->extd_local_circuit_id))) goto trunctlv; - printf("\n\t Extended Local circuit ID: 0x%08x", + printf("\n\t Extended Local circuit-ID: 0x%08x", EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)); tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id); } if(tmp>=SYSTEM_ID_LEN) { if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)) goto trunctlv; - printf("\n\t Neighbor SystemID: %s", + printf("\n\t Neighbor System-ID: %s", isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN)); tmp-=SYSTEM_ID_LEN; } @@ -1738,7 +1747,7 @@ static int isis_print (const u_int8_t *p, u_int length) if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id, sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id))) goto trunctlv; - printf("\n\t Neighbor Extended Local circuit ID: 0x%08x", + printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x", EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)); } break; @@ -1748,12 +1757,14 @@ static int isis_print (const u_int8_t *p, u_int length) while (tmp>0) { if (!TTEST2(*(tptr), 1)) goto trunctlv; - printf("%s", + printf("%s (0x%02x)", tok2str(osi_nlpid_values, - "Unknown 0x%02x", - *tptr++)); + "unknown", + *tptr), + *tptr); if (tmp>1) /* further NPLIDs ? - put comma */ printf(", "); + tptr++; tmp--; } break; @@ -1793,7 +1804,7 @@ static int isis_print (const u_int8_t *p, u_int length) if (!TTEST2(*tptr, 1)) goto trunctlv; - printf(", %s", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"); + printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"); tmp--; if (!TTEST2(*tptr,4)) @@ -1841,9 +1852,15 @@ static int isis_print (const u_int8_t *p, u_int length) case TLV_CHECKSUM: if (!TTEST2(*tptr, 2)) goto trunctlv; - printf("\n\t checksum: 0x%04x (%s)", - EXTRACT_16BITS(tptr), - (osi_cksum(optr, length)) ? "incorrect" : "correct"); + printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)); + /* do not attempt to verify the checksum if it is zero + * most likely a HMAC-MD5 TLV is also present and + * to avoid conflicts the checksum TLV is zeroed. + * see rfc3358 for details + */ + if (EXTRACT_16BITS(tptr) == 0) + printf("(unverified)"); + else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct"); break; case TLV_MT_SUPPORTED: