2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * Original code by Matt Thomas, Digital Equipment Corporation
23 * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
24 * complete IS-IS support.
28 static const char rcsid
[] =
29 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.31 2001-11-10 21:35:04 guy Exp $ (LBL)";
36 #include <sys/types.h>
38 #include <sys/socket.h>
40 #include <netinet/in.h>
45 #include "interface.h"
46 #include "addrtoname.h"
47 #include "ethertype.h"
51 #define NLPID_CLNS 129 /* 0x81 */
52 #define NLPID_ESIS 130 /* 0x82 */
53 #define NLPID_ISIS 131 /* 0x83 */
54 #define NLPID_IP6 0x8e
56 #define NLPID_NULLNS 0
59 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
62 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
63 #define ISIS_VERSION 1
64 #define PDU_TYPE_MASK 0x1F
65 #define PRIORITY_MASK 0x7F
79 * A TLV is a tuple of a type, length and a value and is normally used for
80 * encoding information in all sorts of places. This is an enumeration of
81 * the well known types.
84 #define TLV_AREA_ADDR 1
85 #define TLV_IS_REACH 2
86 #define TLV_ES_REACH 3
92 #define TLV_CHECKSUM 12
93 #define TLV_EXT_IS_REACH 22
94 #define TLV_IP_REACH 128
95 #define TLV_PROTOCOLS 129
96 #define TLV_IP_REACH_EXT 130
97 #define TLV_IDRP_INFO 131
98 #define TLV_IPADDR 132
99 #define TLV_IPAUTH 133
100 #define TLV_TE_ROUTER_ID 134
101 #define TLV_EXT_IP_REACH 135
102 #define TLV_HOSTNAME 137
103 #define TLV_MT_IS_REACH 222
104 #define TLV_MT_SUPPORTED 229
105 #define TLV_IP6ADDR 232
106 #define TLV_MT_REACH 235
107 #define TLV_IP6_REACH 236
108 #define TLV_PTP_ADJ 240
110 #define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3
111 #define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6
112 #define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8
113 #define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9
114 #define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10
115 #define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11
116 #define SUBTLV_EXT_IS_REACH_TE_METRIC 18
118 #define SUBTLV_AUTH_SIMPLE 1
119 #define SUBTLV_AUTH_MD5 54
121 #define ISIS_MASK_LEVEL_BITS(x) ((x)&0x1)
122 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
123 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
124 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
125 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
126 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
127 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
128 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
129 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
130 #define ISIS_MASK_TLV_EXT_IP_UPDOWN(x) ((x)&0x80)
131 #define ISIS_MASK_TLV_EXT_IP_SUBTLV(x) ((x)&0x40)
133 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
134 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
135 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
136 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
138 #define ISIS_LSP_TYPE_UNUSED0 0
139 #define ISIS_LSP_TYPE_LEVEL_1 1
140 #define ISIS_LSP_TYPE_UNUSED2 2
141 #define ISIS_LSP_TYPE_LEVEL_2 3
143 static struct tok isis_lsp_istype_values
[] = {
144 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
145 { ISIS_LSP_TYPE_LEVEL_1
, "Level 1 IS"},
146 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
147 { ISIS_LSP_TYPE_LEVEL_2
, "Level 2 IS"},
151 static struct tok isis_nlpid_values
[] = {
152 { NLPID_CLNS
, "CLNS"},
154 { NLPID_IP6
, "IPv6"},
159 * Katz's point to point adjacency TLV uses codes to tell us the state of
160 * the remote adjacency. Enumerate them.
163 #define ISIS_PTP_ADJ_UP 0
164 #define ISIS_PTP_ADJ_INIT 1
165 #define ISIS_PTP_ADJ_DOWN 2
167 static int osi_cksum(const u_char
*, u_int
, u_char
*);
168 static void esis_print(const u_char
*, u_int
);
169 static int isis_print(const u_char
*, u_int
);
172 static struct tok isis_ptp_adjancey_values
[] = {
173 { ISIS_PTP_ADJ_UP
, "Up" },
174 { ISIS_PTP_ADJ_INIT
, "Initializing" },
175 { ISIS_PTP_ADJ_DOWN
, "Down" }
178 struct isis_tlv_ptp_adj
{
179 u_char adjacency_state
;
180 u_char ext_local_circuit_id
[4];
181 u_char neighbor_sysid
[SYSTEM_ID_LEN
];
182 u_char neighbor_ext_local_circuit_id
[4];
185 struct isis_tlv_ip_reach
{
186 u_char metric_default
;
188 u_char metric_expense
;
194 struct isis_tlv_is_reach
{
196 u_char metric_default
;
198 u_char metric_expense
;
200 u_char neighbor_nodeid
[SYSTEM_ID_LEN
+1];
204 struct isis_common_header
{
207 u_char version
; /* Protocol version? */
209 u_char pdu_type
; /* 3 MSbs are reserved */
210 u_char pkt_version
; /* Packet format version? */
215 struct isis_iih_lan_header
{
217 u_char source_id
[SYSTEM_ID_LEN
];
218 u_char holding_time
[2];
219 u_char packet_len
[2];
221 u_char lan_id
[SYSTEM_ID_LEN
+1];
224 struct isis_iih_ptp_header
{
226 u_char source_id
[SYSTEM_ID_LEN
];
227 u_char holding_time
[2];
228 u_char packet_len
[2];
232 struct isis_lsp_header
{
234 u_char remaining_lifetime
[2];
235 u_char lsp_id
[SYSTEM_ID_LEN
+2];
236 u_char sequence_number
[4];
241 struct isis_csnp_header
{
243 u_char source_id
[SYSTEM_ID_LEN
+1];
244 u_char start_lsp_id
[SYSTEM_ID_LEN
+2];
245 u_char end_lsp_id
[SYSTEM_ID_LEN
+2];
248 struct isis_psnp_header
{
250 u_char source_id
[SYSTEM_ID_LEN
+1];
253 struct isis_tlv_lsp
{
254 u_char remaining_lifetime
[2];
255 u_char lsp_id
[SYSTEM_ID_LEN
+2];
256 u_char sequence_number
[4];
260 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
261 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
262 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
263 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
264 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
265 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
267 void isoclns_print(const u_char
*p
, u_int length
, u_int caplen
,
268 const u_char
*esrc
, const u_char
*edst
)
271 const struct isis_common_header
*header
;
273 header
= (const struct isis_common_header
*)p
;
274 pdu_type
= header
->pdu_type
& PDU_TYPE_MASK
;
277 printf("[|iso-clns] ");
278 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
280 etheraddr_string(esrc
),
281 etheraddr_string(edst
));
288 (void)printf("CLNS(%d)", length
);
289 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
290 (void)printf(", %s > %s",
291 etheraddr_string(esrc
),
292 etheraddr_string(edst
));
296 (void)printf("ESIS");
297 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
298 (void)printf(", %s > %s",
299 etheraddr_string(esrc
),
300 etheraddr_string(edst
));
301 esis_print(p
, length
);
305 (void)printf("ISIS(%d)", length
);
306 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
307 (void)printf(", %s > %s",
308 etheraddr_string(esrc
),
309 etheraddr_string(edst
));
310 if (!isis_print(p
, length
))
311 default_print_unaligned(p
, caplen
);
315 (void)printf("ISO NULLNS(%d)", length
);
316 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
317 (void)printf(", %s > %s",
318 etheraddr_string(esrc
),
319 etheraddr_string(edst
));
323 (void)printf("CLNS %02x(%d)", p
[0], length
);
324 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
325 (void)printf(", %s > %s",
326 etheraddr_string(esrc
),
327 etheraddr_string(edst
));
329 default_print_unaligned(p
, caplen
);
334 #define ESIS_REDIRECT 6
347 esis_print(const u_char
*p
, u_int length
)
351 const struct esis_hdr
*eh
;
358 printf(" no header at all!");
362 eh
= (const struct esis_hdr
*) &p
[2];
368 printf(" LI(%d) > PDU size (%d)!", li
, length
);
371 if (li
< sizeof(struct esis_hdr
) + 2) {
375 printf(" too short for esis header %d:", li
);
376 while (--length
!= 0)
377 printf("%02X", *p
++);
381 switch (eh
->type
& 0x1f) {
396 printf(" type %d", eh
->type
& 0x1f);
399 off
[0] = eh
->cksum
[0];
400 off
[1] = eh
->cksum
[1];
401 if (vflag
&& osi_cksum(p
, li
, off
)) {
402 printf(" bad cksum (got %02x%02x)",
403 eh
->cksum
[1], eh
->cksum
[0]);
404 default_print(p
, length
);
407 if (eh
->version
!= 1) {
408 printf(" unsupported version %d", eh
->version
);
411 p
+= sizeof(*eh
) + 2;
412 li
-= sizeof(*eh
) + 2; /* protoid * li */
414 switch (eh
->type
& 0x1f) {
415 case ESIS_REDIRECT
: {
416 const u_char
*dst
, *snpa
, *is
;
418 dst
= p
; p
+= *p
+ 1;
421 printf("\n\t\t\t %s", isonsap_string(dst
));
422 snpa
= p
; p
+= *p
+ 1;
431 printf(" > %s", etheraddr_string(&snpa
[1]));
433 printf(" > %s", isonsap_string(is
));
453 printf("\n\t\t\t %s", isonsap_string(is
));
459 (void)printf(" len=%d", length
);
460 if (length
&& p
< snapend
) {
461 length
= snapend
- p
;
462 default_print(p
, length
);
467 while (p
< ep
&& li
) {
474 printf(" bad opts/li");
481 printf(" opt (%d) too long", op
);
489 if (op
== 198 && opli
== 2) {
490 printf(" tmo=%d", q
[0] * 256 + q
[1]);
493 printf (" %d:<", op
);
495 printf("%02x", *q
++);
505 print_nsap(register const u_char
*cp
, register int length
)
509 for (i
= 0; i
< length
; i
++) {
512 printf("%02x", *cp
++);
513 if (((i
& 1) == 0) && (i
+ 1 < length
)) {
521 isis_print_sysid(const u_char
*cp
)
525 for (i
= 1; i
<= 6; i
++) {
528 printf("%02x", *cp
++);
537 isis_print_nodeid(const u_char
*cp
)
541 for (i
= 1; i
<= 7; i
++) {
544 printf("%02x", *cp
++);
553 isis_print_lspid(const u_char
*cp
)
557 for (i
= 1; i
<= 7; i
++) {
558 printf("%02x", *cp
++);
562 printf("-%02x", *cp
);
566 isis_print_tlv_ip_reach (const u_char
*cp
, int length
)
570 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
571 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
572 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
573 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
574 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000,
575 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
576 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0,
577 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff
579 int mask
, prefix_len
;
580 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
582 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
585 if (length
< sizeof(*tlv_ip_reach
)) {
586 printf("short IP reachability (%d vs %lu)", length
,
587 (unsigned long)sizeof(*tlv_ip_reach
));
591 if (!TTEST(*tlv_ip_reach
))
594 mask
= EXTRACT_32BITS(tlv_ip_reach
->mask
);
597 while (prefix_len
<= 33) {
598 if (bitmasks
[prefix_len
++] == mask
) {
605 * 34 indicates no match -> must be a discontiguous netmask
606 * lets dump the mask, otherwise print the prefix_len
608 if (prefix_len
== 34)
609 printf("\n\t\t\tIPv4 prefix: %u.%u.%u.%u mask %u.%u.%u.%u",
610 (tlv_ip_reach
->prefix
)[0],
611 (tlv_ip_reach
->prefix
)[1],
612 (tlv_ip_reach
->prefix
)[2],
613 (tlv_ip_reach
->prefix
)[3],
614 (tlv_ip_reach
->mask
)[0], (tlv_ip_reach
->mask
)[1],
615 (tlv_ip_reach
->mask
)[2], (tlv_ip_reach
->mask
)[3]);
617 printf("\n\t\t\tIPv4 prefix: %u.%u.%u.%u/%u",
618 (tlv_ip_reach
->prefix
)[0],
619 (tlv_ip_reach
->prefix
)[1],
620 (tlv_ip_reach
->prefix
)[2],
621 (tlv_ip_reach
->prefix
)[3], prefix_len
);
623 printf("\n\t\t\t Default Metric: %02d, %s, Distribution: %s",
624 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->metric_default
),
625 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->metric_default
) ? "External" : "Internal",
626 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->metric_default
) ? "down" : "up");
628 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->metric_delay
))
629 printf("\n\t\t\t Delay Metric: %02d, %s",
630 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->metric_delay
),
631 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->metric_delay
) ? "External" : "Internal");
633 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->metric_expense
))
634 printf("\n\t\t\t Expense Metric: %02d, %s",
635 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->metric_expense
),
636 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->metric_expense
) ? "External" : "Internal");
638 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->metric_error
))
639 printf("\n\t\t\t Error Metric: %02d, %s",
640 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->metric_error
),
641 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->metric_error
) ? "External" : "Internal");
643 length
-= sizeof(struct isis_tlv_ip_reach
);
651 * Decode IS-IS packets. Return 0 on error.
654 static int isis_print (const u_char
*p
, u_int length
)
656 const struct isis_common_header
*header
;
658 const struct isis_iih_lan_header
*header_iih_lan
;
659 const struct isis_iih_ptp_header
*header_iih_ptp
;
660 const struct isis_lsp_header
*header_lsp
;
661 const struct isis_csnp_header
*header_csnp
;
662 const struct isis_psnp_header
*header_psnp
;
664 const struct isis_tlv_lsp
*tlv_lsp
;
665 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
666 const struct isis_tlv_is_reach
*tlv_is_reach
;
668 u_char pdu_type
, max_area
, type
, len
, tmp
, alen
, subl
, subt
, tslen
, ttslen
;
669 const u_char
*optr
, *pptr
, *tptr
;
671 u_int i
,j
,bit_length
,byte_length
,metric
;
677 optr
= p
; /* initialize the _o_riginal pointer - need it for parsing the checksum TLV */
678 header
= (const struct isis_common_header
*)p
;
680 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
681 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
682 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
683 header_lsp
= (const struct isis_lsp_header
*)pptr
;
684 header_csnp
= (const struct isis_csnp_header
*)pptr
;
685 header_psnp
= (const struct isis_psnp_header
*)pptr
;
688 * Sanity checking of the header.
690 if (header
->nlpid
!= NLPID_ISIS
) {
691 printf(", coding error!");
695 if (header
->version
!= ISIS_VERSION
) {
696 printf(", version %d packet not supported", header
->version
);
700 if ((header
->id_length
!= SYSTEM_ID_LEN
) && (header
->id_length
!= 0)) {
701 printf(", system ID length of %d is not supported",
706 if (header
->pkt_version
!= ISIS_VERSION
) {
707 printf(", version %d packet not supported", header
->pkt_version
);
711 max_area
= header
->max_area
;
714 max_area
= 3; /* silly shit */
717 printf(", bad packet -- 255 areas");
723 printf(", hlen: %u, v: %u, sys-id-len: 6 (0), max-area: %u (%u)",
729 pdu_type
=header
->pdu_type
;
735 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
736 printf(", bogus fixed header length %u should be %lu",
737 header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
740 printf(", L%s Lan IIH",
741 ISIS_MASK_LEVEL_BITS(pdu_type
) ? "2" : "1");
742 TCHECK(*header_iih_lan
);
743 printf("\n\t\t source-id: ");
744 isis_print_sysid(header_iih_lan
->source_id
);
745 printf(", holding time: %us",EXTRACT_16BITS(header_iih_lan
->holding_time
));
746 switch(header_iih_lan
->circuit_type
) {
749 printf(", Level 1 only");
753 printf(", Level 2 only");
757 printf(", Level 1, Level 2");
761 printf(", unknown 0x%02x", header_iih_lan
->circuit_type
);
764 printf("\n\t\t lan-id: ");
765 isis_print_nodeid(header_iih_lan
->lan_id
);
766 printf(", Priority: %u",(header_iih_lan
->priority
) & PRIORITY_MASK
);
768 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
769 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
773 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
774 printf(", bogus fixed header length %u should be %lu",
775 header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
779 TCHECK(*header_iih_ptp
);
780 printf("\n\t\t source-id: ");
781 isis_print_sysid(header_iih_ptp
->source_id
);
782 printf(", holding time: %us",EXTRACT_16BITS(header_iih_ptp
->holding_time
));
783 printf(", circuit-id: 0x%02x", header_iih_ptp
->circuit_id
);
784 switch(header_iih_ptp
->circuit_type
) {
787 printf(", Level 1 only");
791 printf(", Level 2 only");
795 printf(", Level 1, Level 2");
799 printf(", unknown 0x%02x", header_iih_ptp
->circuit_type
);
803 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
804 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
809 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
810 printf(", bogus fixed header length %u should be %lu",
811 header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
814 if (pdu_type
== L1_LSP
)
816 else if (pdu_type
== L2_LSP
)
820 printf("\n\t\t lsp-id: ");
821 isis_print_lspid(header_lsp
->lsp_id
);
822 printf(", sequence number: 0x%08x",EXTRACT_32BITS(header_lsp
->sequence_number
));
823 printf(", lifetime: %5us",EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
824 printf("\n\t\t checksum: 0x%04x",EXTRACT_16BITS(header_lsp
->checksum
));
826 printf(", %s", ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
828 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
829 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
830 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
831 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
832 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
833 printf("ATT bit set, ");
835 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
836 printf("%s", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
838 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
839 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
844 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
845 printf(", bogus fixed header length %u should be %lu",
846 header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
849 printf(", L%s CSNP", ISIS_MASK_LEVEL_BITS(pdu_type
) ? "2" : "1");
850 TCHECK(*header_csnp
);
851 printf("\n\t\t source-id: ");
852 isis_print_nodeid(header_csnp
->source_id
);
853 printf("\n\t\t start lsp-id: ");
854 isis_print_lspid(header_csnp
->start_lsp_id
);
855 printf("\n\t\t end lsp-id: ");
856 isis_print_lspid(header_csnp
->end_lsp_id
);
858 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
859 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
864 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
865 printf("- bogus fixed header length %u should be %lu",
866 header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
869 printf(", L%s PSNP", ISIS_MASK_LEVEL_BITS(pdu_type
) ? "2" : "1");
870 TCHECK(*header_psnp
);
871 printf("\n\t\t source-id: ");
872 isis_print_nodeid(header_psnp
->source_id
);
874 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
875 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
879 printf(", PDU type (0x%02x) not supported", pdu_type
);
884 * Now print the TLV's.
887 while (packet_len
>= 2) {
888 if (pptr
== snapend
) {
892 if (!TTEST2(*pptr
, 2)) {
893 printf("\n\t\t\t packet exceeded snapshot (%ld) bytes",
894 (long)(pptr
-snapend
));
900 if (len
> packet_len
) {
907 printf("Area address(es) (%u)",len
);
910 if (!TTEST2(*tptr
, 1))
913 while (tmp
&& alen
< tmp
) {
914 printf("\n\t\t\tArea address (%u): ",alen
);
915 if (!print_nsap(tptr
, alen
))
919 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
921 if (!TTEST2(*tptr
, 1))
927 printf("IS Neighbor(s) (%u)",len
);
930 while (tmp
>= ETHER_ADDR_LEN
) {
931 printf("\n\t\t\tIS Neighbor: ");
932 if (!isis_print_sysid(tptr
))
934 tmp
-= ETHER_ADDR_LEN
;
935 tptr
+= ETHER_ADDR_LEN
;
940 printf("Padding (%u)", len
);
943 case TLV_MT_IS_REACH
:
944 printf("Multi Topology IS Reachability (%u)",len
);
949 if (!TTEST2(*tptr
, 2))
951 switch(EXTRACT_16BITS(tptr
)&0x0fff) {
954 printf("IPv4 unicast");
958 printf("In-Band Management");
962 printf("IPv6 unicast");
970 printf("Development, Experimental or Proprietary");
974 printf("Reserved for IETF Consensus");
977 printf(" Topology (0x%03x)",EXTRACT_16BITS(tptr
)&0x0fff);
979 printf("\n\t\t\t IS Neighbor: ");
980 if (!isis_print_nodeid(tptr
))
982 tptr
+=(SYSTEM_ID_LEN
+1);
983 if (!TTEST2(*tptr
, 3))
985 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
987 if (!TTEST2(*tptr
, 1))
990 printf(", %ssub-TLVs present",tslen
? "" : "no ");
997 case TLV_EXT_IS_REACH
:
998 printf("Extended IS Reachability (%u)",len
);
1002 printf("\n\t\t\tIS Neighbor: ");
1003 if (!isis_print_nodeid(tptr
))
1005 tptr
+=(SYSTEM_ID_LEN
+1);
1006 if (!TTEST2(*tptr
, 3))
1008 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1010 if (!TTEST2(*tptr
, 1))
1013 printf(", %ssub-TLVs present",tslen
? "" : "no ");
1015 printf(" (%u)",tslen
);
1018 if (!TTEST2(*tptr
,2))
1020 printf("\n\t\t\t ");
1024 case SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1025 printf("Administrative groups: 0x%08x", EXTRACT_32BITS(tptr
));
1027 case SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1028 if (!TTEST2(*tptr
,4))
1030 j
= EXTRACT_32BITS(tptr
);
1031 memcpy (&bw
, &j
, 4);
1032 printf("Maximum link bandwidth : %.3f Mbps",
1035 case SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1036 if (!TTEST2(*tptr
,4))
1038 j
= EXTRACT_32BITS(tptr
);
1039 memcpy (&bw
, &j
, 4);
1040 printf("Reservable link bandwidth: %.3f Mbps",
1043 case SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1044 printf("Unreserved bandwidth:");
1045 for (i
= 0; i
< 8; i
++) {
1046 if (!TTEST2(*tptr
,4))
1048 j
= EXTRACT_32BITS(tptr
);
1049 memcpy (&bw
, &j
, 4);
1050 printf("\n\t\t\t priority level %d: %.3f Mbps",
1056 case SUBTLV_EXT_IS_REACH_TE_METRIC
:
1057 if (!TTEST2(*tptr
,3))
1059 printf("Traffic Engineering Metric: %d", EXTRACT_24BITS(tptr
));
1061 case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1062 if (!TTEST2(*tptr
,4))
1064 printf("IPv4 interface address: %s", ipaddr_string(tptr
));
1066 case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1067 if (!TTEST2(*tptr
,4))
1069 printf("IPv4 neighbor address: %s", ipaddr_string(tptr
));
1076 printf("Reserved for cisco specific extensions, type %d, length %d", subt
, subl
);
1079 printf("Reserved for future expansion, type %d, length %d", subt
, subl
);
1082 printf("unknown subTLV, type %d, length %d", subt
, subl
);
1093 printf("IS Reachability (%u)",len
);
1094 tlv_is_reach
= (const struct isis_tlv_is_reach
*)pptr
;
1095 if (!TTEST(*tlv_is_reach
))
1097 printf("\n\t\t\tIS Neighbor: ");
1098 isis_print_nodeid(tlv_is_reach
->neighbor_nodeid
);
1101 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1102 if (!TTEST(*tlv_is_reach
))
1105 printf(", Default Metric: %d, %s",
1106 ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach
->metric_default
),
1107 ISIS_LSP_TLV_METRIC_IE(tlv_is_reach
->metric_default
) ? "External" : "Internal");
1109 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_is_reach
->metric_delay
))
1110 printf("\n\t\t\t Delay Metric: %d, %s",
1111 ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach
->metric_delay
),
1112 ISIS_LSP_TLV_METRIC_IE(tlv_is_reach
->metric_delay
) ? "External" : "Internal");
1114 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_is_reach
->metric_expense
))
1115 printf("\n\t\t\t Expense Metric: %d, %s",
1116 ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach
->metric_expense
),
1117 ISIS_LSP_TLV_METRIC_IE(tlv_is_reach
->metric_expense
) ? "External" : "Internal");
1119 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_is_reach
->metric_error
))
1120 printf("\n\t\t\t Error Metric: %d, %s",
1121 ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach
->metric_error
),
1122 ISIS_LSP_TLV_METRIC_IE(tlv_is_reach
->metric_error
) ? "External" : "Internal");
1124 switch (tlv_is_reach
->virtual_flag
) {
1126 printf(", IsNotVirtual");
1129 printf(", IsVirtual");
1132 printf(", bogus virtual flag 0x%02x",tlv_is_reach
->virtual_flag
);
1136 tmp
-= sizeof(struct isis_tlv_is_reach
);
1142 printf("IP Internal reachability (%u)",len
);
1143 if (!isis_print_tlv_ip_reach(pptr
, len
))
1147 case TLV_IP_REACH_EXT
:
1148 printf("IP External reachability (%u)",len
);
1149 if (!isis_print_tlv_ip_reach(pptr
, len
))
1153 case TLV_EXT_IP_REACH
:
1154 printf("Extended IP reachability (%u)",len
);
1159 memset (prefix
, 0, 4);
1160 if (!TTEST2(*tptr
, 4))
1162 metric
= EXTRACT_32BITS(tptr
);
1165 if (!TTEST2(*tptr
, 1))
1168 bit_length
= (*(tptr
)++&0x3f);
1169 byte_length
= (bit_length
+ 7) / 8;
1170 if (!TTEST2(*tptr
, byte_length
))
1172 memcpy(prefix
,tptr
,byte_length
);
1174 printf("\n\t\t\tIPv4 prefix: %u.%u.%u.%u/%d",
1181 printf("\n\t\t\t Metric: %u, Distribution: %s",
1183 ISIS_MASK_TLV_EXT_IP_UPDOWN(j
) ? "down" : "up");
1185 printf(", %ssub-TLVs present",
1186 ISIS_MASK_TLV_EXT_IP_SUBTLV(j
) ? "" : "no ");
1194 if (!TTEST2(*pptr
, 1))
1196 printf("Authentication (%u)",len
);
1197 if (*pptr
==SUBTLV_AUTH_SIMPLE
) {
1198 printf("\n\t\t\tsimple text password: ");
1199 for(i
=1;i
<len
;i
++) {
1200 if (!TTEST2(*(pptr
+i
), 1))
1202 printf("%c",*(pptr
+i
));
1205 if (!TTEST2(*pptr
, 1))
1207 if (*pptr
==SUBTLV_AUTH_MD5
) {
1208 printf("\n\t\t\tMD5 password: ");
1209 for(i
=1;i
<len
;i
++) {
1210 if (!TTEST2(*(pptr
+i
), 1))
1212 printf("%02x",*(pptr
+i
));
1218 printf("Point-to-point Adjacency State (%u)",len
);
1219 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)pptr
;
1222 if (!TTEST2(*pptr
, 1))
1224 printf("\n\t\t\tAdjacency State: %s",
1225 tok2str(isis_ptp_adjancey_values
, "#0x%x", *pptr
));
1229 if (!TTEST2(tlv_ptp_adj
->ext_local_circuit_id
, 4))
1231 printf("\n\t\t\tExtended Local circuit ID: 0x%08x",
1232 EXTRACT_32BITS(tlv_ptp_adj
->ext_local_circuit_id
));
1236 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, 6))
1238 printf("\n\t\t\tNeighbor SystemID: ");
1239 isis_print_sysid(tlv_ptp_adj
->neighbor_sysid
);
1243 if (!TTEST2(tlv_ptp_adj
->neighbor_ext_local_circuit_id
, 4))
1245 printf("\n\t\t\tNeighbor Extended Local circuit ID: 0x%08x",
1246 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_ext_local_circuit_id
));
1251 printf("Protocols supported (%u)", len
);
1252 printf("\n\t\t\tNLPID(s): ");
1253 for (i
= 0; i
< len
; i
++) {
1254 if (!TTEST2(*(pptr
+i
), 1))
1256 printf("%s (0x%02x)",tok2str(isis_nlpid_values
, "Unknown", *(pptr
+i
)),*(pptr
+i
));
1262 case TLV_TE_ROUTER_ID
:
1263 printf("Traffic Engineering Router ID (%u)",len
);
1264 if (!TTEST2(*pptr
, 4))
1266 printf("\n\t\t\tTraffic Engineering Router ID: %s", ipaddr_string(pptr
));
1270 printf("IP Interface address(es) (%u)",len
);
1274 if (!TTEST2(*tptr
, 4))
1276 printf("\n\t\t\tIPv4 interface address: %s", ipaddr_string(tptr
));
1283 printf("Hostname (%u)", len
);
1284 printf("\n\t\t\tHostname: ");
1285 for(i
= 0; i
< len
; i
++) {
1286 if (!TTEST2(*(pptr
+i
), 1))
1288 printf("%c",*(pptr
+i
));
1293 tlv_lsp
= (const struct isis_tlv_lsp
*)pptr
;
1294 printf("LSP entries (%u)", len
);
1297 printf("\n\t\t\tlsp-id: ");
1298 if (!isis_print_nodeid(tlv_lsp
->lsp_id
))
1300 if (!TTEST((tlv_lsp
->lsp_id
)[SYSTEM_ID_LEN
+1]))
1302 printf("-%02x",(tlv_lsp
->lsp_id
)[SYSTEM_ID_LEN
+1]);
1303 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
1305 printf("\n\t\t\t sequence number: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
1306 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
1308 printf("\n\t\t\t Remaining lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
1309 if (!TTEST2(tlv_lsp
->checksum
, 2))
1311 printf("\n\t\t\t checksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
1312 i
+=sizeof(struct isis_tlv_lsp
);
1318 if (!TTEST2(*pptr
, 2))
1320 printf("Checksum (%u)", len
);
1321 printf("\n\t\t\tchecksum: 0x%04x",
1322 EXTRACT_16BITS(pptr
));
1324 if (osi_cksum(optr
, length
, off
))
1325 printf(" (incorrect)");
1327 printf(" (correct)");
1330 case TLV_MT_SUPPORTED
:
1331 printf("Multi Topology (%u)",len
);
1335 /* length can only be a multiple of 2, otherwise there is
1336 something broken -> so decode down until length is 1 */
1338 if (!TTEST2(*tptr
, 2))
1341 switch(EXTRACT_16BITS(tptr
)&0x0fff) {
1344 printf("IPv4 unicast");
1348 printf("In-Band Management");
1352 printf("IPv6 unicast");
1356 printf("Multicast");
1360 printf("Development, Experimental or Proprietary");
1364 printf("Reserved for IETF Consensus");
1367 printf(" Topology (0x%03x)%s%s",
1368 EXTRACT_16BITS(tptr
)&0xfff,
1369 (EXTRACT_16BITS(tptr
)&0x8000) ? "" : ", no sub-TLVs present",
1370 (EXTRACT_16BITS(tptr
)&0x4000) ? ", ATT bit set" : "" );
1372 printf("\n\t\t\tmalformed MT-ID");
1381 printf("unknown TLV, type %d, length %d", type
, len
);
1389 if (packet_len
!= 0) {
1390 printf("\n\t\t\t %d straggler bytes", packet_len
);
1395 fputs("[|isis]", stdout
);
1399 printf("\n\t\t\t packet exceeded snapshot");
1404 * Verify the checksum. See 8473-1, Appendix C, section C.4.
1408 osi_cksum(register const u_char
*p
, register u_int len
, u_char
*off
)
1410 int32_t c0
= 0, c1
= 0;
1412 if ((off
[0] == 0) && (off
[1] == 0))
1415 off
[0] = off
[1] = 0;
1416 while ((int)--len
>= 0) {