[prev in list] [next in list] [prev in thread] [next in thread]
List: tcpdump-workers
Subject: [tcpdump-workers] IS-IS - support for dumping unknown TLV & subTLV data & misc cleanups
From: Hannes Gredler <hannes () juniper ! net>
Date: 2002-03-19 23:09:08
[Download RAW message or body]
hi all,
pls disregard the last patch; [its all contained in theis as well]
pls find attached a patch to better display [hexdump]
the content of unknown TLV and subTLV data;
plus misc cleanups;
/hannes
Index: print-isoclns.c
===================================================================
RCS file: /tcpdump/master/tcpdump/print-isoclns.c,v
retrieving revision 1.38
diff -u -r1.38 print-isoclns.c
--- print-isoclns.c 2002/03/14 05:59:53 1.38
+++ print-isoclns.c 2002/03/19 23:01:01
@@ -620,7 +620,39 @@
printf("-%02x", *cp);
}
+/*
+ * this is a generic routine for printing unknown data;
+ * as it is called from various places (TLV and subTLV parsing routines)
+ * we pass on the linefeed plus identation string to
+ * get a proper output
+ */
+
static int
+isis_print_unknown_data(const u_char *cp,const u_char *lf,int len)
+{
+ int i;
+
+ printf("%s0x0000: ",lf);
+ for(i=0;i<len;i++) {
+ if (!TTEST2(*(cp+i), 1))
+ goto trunctlv;
+ printf("%02x",*(cp+i));
+ if (i%2)
+ printf(" ");
+ if (i/16!=(i+1)/16) {
+ if (i<(len-1))
+ printf("%s0x%04x: ",lf,i);
+ }
+ }
+ return(0); /* everything is ok */
+
+trunctlv:
+ printf("%spacket exceeded snapshot",lf);
+ return(1);
+
+}
+
+static int
isis_print_tlv_ip_reach (const u_char *cp, int length)
{
u_int bitmasks[33] = {
@@ -724,7 +756,7 @@
const struct isis_tlv_ptp_adj *tlv_ptp_adj;
const struct isis_tlv_is_reach *tlv_is_reach;
- u_char pdu_type, max_area, type, len, tmp, alen, subl, subt, tslen, ttslen;
+ u_char pdu_type, max_area, id_length, type, len, tmp, alen, subl, subt, tslen, ttslen;
const u_char *optr, *pptr, *tptr;
u_short packet_len,pdu_len;
u_int i,j,bit_length,byte_length,metric;
@@ -773,7 +805,7 @@
max_area = header->max_area;
switch(max_area) {
case 0:
- max_area = 3; /* silly shit */
+ max_area = 3; /* silly shit */
break;
case 255:
printf(", bad packet -- 255 areas");
@@ -781,10 +813,35 @@
default:
break;
}
+
+ id_length = header->id_length;
+ switch(id_length) {
+ case 0:
+ id_length = 6; /* silly shit again */
+ break;
+ case 1: /* 1-8 are valid sys-ID lenghts */
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ break;
+ case 255:
+ id_length = 0; /* entirely useless */
+ break;
+ default:
+ printf(", bad packet -- illegal sys-ID length (%u)", id_length);
+ return (0);
+ break;
+ }
- printf(", hlen: %u, v: %u, sys-id-len: 6 (0), max-area: %u (%u)",
+ printf(", hlen: %u, v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
header->fixed_len,
- header->pkt_version,
+ header->version,
+ id_length,
+ header->id_length,
max_area,
header->max_area);
@@ -976,6 +1033,8 @@
default:
printf(", PDU type (0x%02x) not supported", pdu_type);
+ if(isis_print_unknown_data(pptr,"\n\t\t ",length))
+ return(1);
return (1);
}
@@ -1087,7 +1146,13 @@
goto trunctlv;
tslen=*(tptr++);
printf(", %ssub-TLVs present",tslen ? "" : "no ");
-
+ /* so far no decoding of subTLVs is supported
+ * so lets print out a hexdump of the unknown subTLV data
+ */
+ if(!tslen){
+ if(isis_print_unknown_data(tptr,"\n\t\t\t ",tslen))
+ return(1);
+ }
tptr+=tslen;
tmp-=(13+tslen);
}
@@ -1207,16 +1272,19 @@
printf("\n\t\t\t Interface Switching Capability:%s",
tok2str(isis_gmpls_sw_cap_values, "Unknown", *(tptr++)));
tptr++;
+ subl--;
if (!TTEST2(*tptr,1))
goto trunctlv;
printf(", LSP Encoding: %s",
tok2str(isis_gmpls_lsp_enc_values, "Unknown", *(tptr++)));
tptr++;
+ subl--;
if (!TTEST2(*tptr,2)) /* skip 2 res. bytes */
goto trunctlv;
tptr+=2;
+ subl-=2;
printf("\n\t\t\t Max LSP Bandwidth:");
for (i = 0; i < 8; i++) {
@@ -1227,9 +1295,14 @@
printf("\n\t\t\t priority level %d: %.3f Mbps",
i, bw*8/1000000 );
tptr+=4;
+ subl-=4;
}
/* there is some optional stuff left to decode but this is as of yet
- not specified */
+ not specified so just lets hexdump what is left */
+ if(!subl){
+ if(isis_print_unknown_data(tptr,"\n\t\t\t ",subl))
+ return(1);
+ }
break;
case 250:
case 251:
@@ -1243,6 +1316,9 @@
break;
default:
printf("unknown subTLV, type %d, length %d", subt, subl);
+ if(isis_print_unknown_data(tptr,"\n\t\t\t ",subl))
+ return(1);
+ break;
}
tptr+=subl;
ttslen-=(subl+2);
@@ -1359,7 +1435,14 @@
if (ISIS_MASK_TLV_EXT_IP_SUBTLV(j)) {
if (!TTEST2(*tptr, 1))
return (1);
- printf(" (%u)",*tptr); /* no subTLV decoder supported - just print out subTLV length */
+ printf(" (%u)",*tptr); /* print out subTLV length */
+
+ /* so far no decoding of subTLVs is supported
+ * so lets print out a hexdump of the unknown subTLV data
+ */
+ if(isis_print_unknown_data(tptr,"\n\t\t\t ",*tptr))
+ return(1);
+
i-=*tptr;
tptr+=*tptr++;
}
@@ -1406,7 +1489,14 @@
if (ISIS_MASK_TLV_IP6_SUBTLV(j)) {
if (!TTEST2(*tptr, 1))
return (1);
- printf(" (%u)",*tptr); /* no subTLV decoder supported - just print out subTLV length */
+ printf(" (%u)",*tptr); /* print out subTLV length */
+
+ /* so far no decoding of subTLVs is supported
+ * so lets print out a hexdump of the unknown subTLV data
+ */
+ if(isis_print_unknown_tlv(tptr,"\n\t\t\t ",*tptr))
+ return(1);
+
i-=*tptr;
tptr+=*tptr++;
}
@@ -1461,22 +1551,13 @@
break;
case SUBTLV_AUTH_PRIVATE:
printf("\n\t\t\tRouting Domain private password: ");
- tptr=pptr+1;
- len--;
- for(i=0;i<len;i++) {
- if (!TTEST2(*(tptr+i), 1))
- goto trunctlv;
- printf("%02x",*(tptr+i)); /* formatted hex output of unknown data */
- if (i%2)
- printf(" ");
- if (i/16!=(i+1)/16) {
- if (i<(len-1))
- printf("\n\t\t\t ");
- }
- }
+ if(isis_print_unknown_data(pptr+1,"\n\t\t\t ",len-1))
+ return(1);
break;
default:
printf("\n\t\t\tunknown Authentication method");
+ if(isis_print_unknown_data(pptr+1,"\n\t\t\t ",len-1))
+ return(1);
break;
}
break;
@@ -1608,13 +1689,13 @@
printf("-%02x",(tlv_lsp->lsp_id)[SYSTEM_ID_LEN+1]);
if (!TTEST2(tlv_lsp->sequence_number, 4))
goto trunctlv;
- printf("\n\t\t\t sequence number: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
+ printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
if (!TTEST2(tlv_lsp->remaining_lifetime, 2))
goto trunctlv;
- printf("\n\t\t\t Remaining lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
+ printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
if (!TTEST2(tlv_lsp->checksum, 2))
goto trunctlv;
- printf("\n\t\t\t checksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
+ printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
i+=sizeof(struct isis_tlv_lsp);
tlv_lsp++;
}
@@ -1697,20 +1778,9 @@
break;
default:
- printf("unknown TLV, type %d, length %d\n\t\t\t", type, len);
- tptr=pptr;
-
- for(i=0;i<len;i++) {
- if (!TTEST2(*(tptr+i), 1))
- goto trunctlv;
- printf("%02x",*(tptr+i)); /* formatted hex output of unknown TLV data */
- if (i%2)
- printf(" ");
- if (i/16!=(i+1)/16) {
- if (i<(len-1))
- printf("\n\t\t\t");
- }
- }
+ printf("unknown TLV, type %d, length %d", type, len);
+ if(isis_print_unknown_data(pptr,"\n\t\t\t",len))
+ return(1);
break;
}
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request@tcpdump.org?body=unsubscribe
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic