#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.78 2003-03-30 01:21:13 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.82 2003-05-01 18:04:41 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
}
}
-/* allocate space for the following string
- * xxxx.xxxx.xxxx
- * 14 bytes plus one termination byte */
-static char *
-isis_print_sysid(const u_int8_t *cp, int sysid_len)
-{
- int i;
- static char sysid[15];
- char *pos = sysid;
-
- for (i = 1; i <= sysid_len; i++) {
- if (!TTEST2(*cp, 1))
- return (0);
- sprintf(pos, "%02x", *cp++);
- pos += strlen(pos);
- if ((i==2)^(i==4)) {
- *pos++ = '.';
- }
- }
- *(pos) = '\0';
- return (sysid);
-}
-
-
-/* allocate space for the following string
- * xxxx.xxxx.xxxx.yy
- * 17 bytes plus one termination byte */
-static char *
-isis_print_nodeid(const u_int8_t *cp)
-{
- int i;
- static char nodeid[18];
- char *pos = nodeid;
-
- for (i = 1; i <= 7; i++) {
- if (!TTEST2(*cp, 1))
- return (0);
- sprintf(pos, "%02x", *cp++);
- pos += strlen(pos);
- if ((i & 1) == 0) {
- *pos++ = '.';
- }
- }
- *(pos) = '\0';
- return (nodeid);
-}
-
-/* allocate space for the following string
+/* 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 */
static char *
-isis_print_lspid(const u_int8_t *cp)
+isis_print_id(const u_int8_t *cp, int id_len)
{
- int i;
- static char lspid[21];
- char *pos = lspid;
-
- for (i = 1; i <= 7; i++) {
- sprintf(pos, "%02x", *cp++);
- pos += strlen(pos);
- if ((i & 1) == 0)
- *pos++ = '.';
+ int i;
+ static char id[21];
+ char *pos = id;
+
+ for (i = 1; i <= SYSTEM_ID_LEN; i++) {
+ sprintf(pos, "%02x", *cp++);
+ pos += strlen(pos);
+ if (i == 2 || i == 4)
+ *pos++ = '.';
}
- sprintf(pos, "-%02x", *cp);
- return (lspid);
+ if (id_len == NODE_ID_LEN) {
+ sprintf(pos, ".%02x", *cp++);
+ pos += strlen(pos);
+ }
+ if (id_len == LSP_ID_LEN)
+ sprintf(pos, "-%02x", *cp);
+ return (id);
}
/* print the 4-byte metric block which is common found in the old-style TLVs */
-
static int
isis_print_metric_block (const struct isis_metric_block *isis_metric_block)
{
*/
static int
-isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident) {
+isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv) {
char ident_buffer[20];
int subt,subl,tslen;
if (!TTEST2(*tptr, NODE_ID_LEN))
return(0);
- printf("%sIS Neighbor: %s", ident, isis_print_nodeid(tptr));
+ printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
tptr+=(NODE_ID_LEN);
-
- if (!TTEST2(*tptr, 3))
- return(0);
- printf(", Metric: %d",EXTRACT_24BITS(tptr));
- tptr+=3;
+
+ if (tlv != TLV_IS_ALIAS_ID) {
+ if (!TTEST2(*tptr, 3))
+ return(0);
+ printf(", Metric: %d",EXTRACT_24BITS(tptr));
+ tptr+=3;
+ }
if (!TTEST2(*tptr, 1))
return(0);
bit_length);
#ifdef INET6
if (afi == IPV6)
- printf("%sIPv6 prefix: %39s/%u",
+ printf("%sIPv6 prefix: %s/%u",
ident,
ip6addr_string(prefix),
bit_length);
const struct isis_tlv_is_reach *tlv_is_reach;
const struct isis_tlv_es_reach *tlv_es_reach;
- u_int8_t pdu_type, max_area, id_length, type, len, tmp, alen, lan_alen, prefix_len;
+ u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
u_int8_t ext_is_len, ext_ip_len, mt_len;
const u_int8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len,time_remain;
TCHECK(*header_iih_lan);
printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
- isis_print_sysid(header_iih_lan->source_id,SYSTEM_ID_LEN),
+ isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
EXTRACT_16BITS(header_iih_lan->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
header_iih_lan->circuit_type));
printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
- isis_print_nodeid(header_iih_lan->lan_id),
+ isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
(header_iih_lan->priority) & PRIORITY_MASK,
pdu_len);
TCHECK(*header_iih_ptp);
printf("\n\t source-id: %s, holding time: %us, circuit-id: 0x%02x, %s, PDU length: %u",
- isis_print_sysid(header_iih_ptp->source_id,SYSTEM_ID_LEN),
+ 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,
TCHECK(*header_lsp);
printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us",
- isis_print_lspid(header_lsp->lsp_id),
+ 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 -
TCHECK(*header_csnp);
printf("\n\t source-id: %s, PDU length: %u",
- isis_print_nodeid(header_csnp->source_id),
+ isis_print_id(header_csnp->source_id, NODE_ID_LEN),
pdu_len);
printf("\n\t start lsp-id: %s",
- isis_print_lspid(header_csnp->start_lsp_id));
+ isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
printf("\n\t end lsp-id: %s",
- isis_print_lspid(header_csnp->end_lsp_id));
+ isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
if (vflag > 1) {
if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
TCHECK(*header_psnp);
printf("\n\t source-id: %s",
- isis_print_nodeid(header_psnp->source_id));
+ isis_print_id(header_psnp->source_id, NODE_ID_LEN));
if (vflag > 1) {
if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE))
(long)(pptr-snapend));
return (1);
}
- type = *pptr++;
- len = *pptr++;
- tmp =len; /* copy temporary len & pointer to packet data */
+ tlv_type = *pptr++;
+ tlv_len = *pptr++;
+ tmp =tlv_len; /* copy temporary len & pointer to packet data */
tptr = pptr;
packet_len -= 2;
- if (len > packet_len) {
+ if (tlv_len > packet_len) {
break;
}
printf("\n\t %s TLV #%u, length: %u",
tok2str(isis_tlv_values,
"unknown",
- type),
- type,
- len);
+ tlv_type),
+ tlv_type,
+ tlv_len);
/* now check if we have a decoder otherwise do a hexdump at the end*/
- switch (type) {
+ switch (tlv_type) {
case TLV_AREA_ADDR:
if (!TTEST2(*tptr, 1))
goto trunctlv;
while (tmp >= ETHER_ADDR_LEN) {
if (!TTEST2(*tptr, ETHER_ADDR_LEN))
goto trunctlv;
- printf("\n\t IS Neighbor: %s",isis_print_sysid(tptr,ETHER_ADDR_LEN));
+ printf("\n\t IS Neighbor: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
tmp -= ETHER_ADDR_LEN;
tptr += ETHER_ADDR_LEN;
}
while (tmp >= lan_alen) {
if (!TTEST2(*tptr, lan_alen))
goto trunctlv;
- printf("\n\t\tIS Neighbor: %s",isis_print_sysid(tptr,lan_alen));
+ printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
tmp -= lan_alen;
tptr +=lan_alen;
}
tptr+=mt_len;
tmp-=mt_len;
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ");
+ ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
break;
case TLV_IS_ALIAS_ID:
- while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ");
- if (ext_is_len == 0) /* did something go wrong ? */
- goto trunctlv;
- tmp-=ext_is_len;
- tptr+=ext_is_len;
- }
- break;
+ while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
+ ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ if (ext_is_len == 0) /* did something go wrong ? */
+ goto trunctlv;
+ tmp-=ext_is_len;
+ tptr+=ext_is_len;
+ }
+ break;
case TLV_EXT_IS_REACH:
while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ");
+ ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
tmp-=ext_is_len;
while (tmp >= sizeof(struct isis_tlv_is_reach)) {
if (!TTEST(*tlv_is_reach))
goto trunctlv;
- printf("\n\t IS Neighbor: %s", isis_print_nodeid(tlv_is_reach->neighbor_nodeid));
+ printf("\n\t IS Neighbor: %s",
+ isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
isis_print_metric_block(&tlv_is_reach->isis_metric_block);
tmp -= sizeof(struct isis_tlv_is_reach);
tlv_is_reach++;
if (!TTEST(*tlv_es_reach))
goto trunctlv;
printf("\n\t ES Neighbor: %s",
- isis_print_sysid(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
+ isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
isis_print_metric_block(&tlv_es_reach->isis_metric_block);
tmp -= sizeof(struct isis_tlv_es_reach);
tlv_es_reach++;
/* those two TLVs share the same format */
case TLV_IP_REACH:
case TLV_IP_REACH_EXT:
- if (!isis_print_tlv_ip_reach(pptr, "\n\t ", len))
+ if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
return (1);
break;
switch (*tptr) {
case SUBTLV_AUTH_SIMPLE:
- for(i=1;i<len;i++) {
+ for(i=1;i<tlv_len;i++) {
if (!TTEST2(*(tptr+i), 1))
goto trunctlv;
printf("%c",*(tptr+i));
}
break;
case SUBTLV_AUTH_MD5:
- for(i=1;i<len;i++) {
+ for(i=1;i<tlv_len;i++) {
if (!TTEST2(*(tptr+i), 1))
goto trunctlv;
printf("%02x",*(tptr+i));
}
- if (len != SUBTLV_AUTH_MD5_LEN+1)
+ if (tlv_len != SUBTLV_AUTH_MD5_LEN+1)
printf(", (malformed subTLV) ");
break;
case SUBTLV_AUTH_PRIVATE:
default:
- if(!print_unknown_data(tptr+1,"\n\t\t ",len-1))
+ if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
return(0);
break;
}
if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
goto trunctlv;
printf("\n\t Neighbor SystemID: %s",
- isis_print_sysid(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
+ isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
tmp-=SYSTEM_ID_LEN;
}
if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
case TLV_SHARED_RISK_GROUP:
if (!TTEST2(*tptr, NODE_ID_LEN))
goto trunctlv;
- printf("\n\t IS Neighbor: %s", isis_print_nodeid(tptr));
+ printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
tptr+=(NODE_ID_LEN);
- len-=(NODE_ID_LEN);
+ tmp-=(NODE_ID_LEN);
if (!TTEST2(*tptr, 1))
goto trunctlv;
printf(", %s", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
- len--;
+ tmp--;
if (!TTEST2(*tptr,4))
goto trunctlv;
printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
tptr+=4;
- len-=4;
+ tmp-=4;
if (!TTEST2(*tptr,4))
goto trunctlv;
printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr));
tptr+=4;
- len-=4;
+ tmp-=4;
while (tmp>0) {
if (!TTEST2(*tptr, 4))
goto trunctlv;
printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
tptr+=4;
- len-=4;
+ tmp-=4;
}
break;
case TLV_LSP:
tlv_lsp = (const struct isis_tlv_lsp *)tptr;
while(tmp>0) {
- printf("\n\t lsp-id: %s",
- isis_print_nodeid(tlv_lsp->lsp_id));
- if (!TTEST((tlv_lsp->lsp_id)[NODE_ID_LEN]))
+ if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN]))
goto trunctlv;
- printf("-%02x",(tlv_lsp->lsp_id)[NODE_ID_LEN]);
+ printf("\n\t lsp-id: %s",
+ isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
if (!TTEST2(tlv_lsp->sequence_number, 4))
goto trunctlv;
printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
case SUBTLV_IDRP_LOCAL:
case SUBTLV_IDRP_RES:
default:
- if(!print_unknown_data(tptr,"\n\t ",len-1))
+ if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
return(0);
break;
}
while (tmp >= SYSTEM_ID_LEN) {
if (!TTEST2(*tptr, SYSTEM_ID_LEN))
goto trunctlv;
- printf("\n\t %s",isis_print_sysid(tptr,SYSTEM_ID_LEN));
+ printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
tptr+=SYSTEM_ID_LEN;
tmp-=SYSTEM_ID_LEN;
}
default:
if (vflag <= 1) {
- if(!print_unknown_data(pptr,"\n\t\t",len))
+ if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
return(0);
}
break;
}
/* do we want to see an additionally hexdump ? */
if (vflag> 1) {
- if(!print_unknown_data(pptr,"\n\t ",len))
+ if(!print_unknown_data(pptr,"\n\t ",tlv_len))
return(0);
}
- pptr += len;
- packet_len -= len;
+ pptr += tlv_len;
+ packet_len -= tlv_len;
}
if (packet_len != 0) {