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.77 2003-02-24 09:36:56 hannes Exp $ (LBL)";
36 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
43 #include "ethertype.h"
47 #define NLPID_CLNS 129 /* 0x81 */
48 #define NLPID_ESIS 130 /* 0x82 */
49 #define NLPID_ISIS 131 /* 0x83 */
50 #define NLPID_IP6 0x8e
52 #define NLPID_NULLNS 0
54 #define IPV4 1 /* AFI value */
55 #define IPV6 2 /* AFI value */
58 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
61 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
62 #define NODE_ID_LEN SYSTEM_ID_LEN+1
63 #define LSP_ID_LEN SYSTEM_ID_LEN+2
65 #define ISIS_VERSION 1
66 #define PDU_TYPE_MASK 0x1F
67 #define PRIORITY_MASK 0x7F
79 static struct tok isis_pdu_values
[] = {
80 { L1_LAN_IIH
, "L1 Lan IIH"},
81 { L2_LAN_IIH
, "L2 Lan IIH"},
82 { PTP_IIH
, "p2p IIH"},
85 { L1_CSNP
, "L1 CSNP"},
86 { L2_CSNP
, "L2 CSNP"},
87 { L1_PSNP
, "L1 PSNP"},
88 { L2_PSNP
, "L2 PSNP"},
93 * A TLV is a tuple of a type, length and a value and is normally used for
94 * encoding information in all sorts of places. This is an enumeration of
95 * the well known types.
97 * list taken from rfc3359 plus some memory from veterans ;-)
100 #define TLV_AREA_ADDR 1 /* iso10589 */
101 #define TLV_IS_REACH 2 /* iso10589 */
102 #define TLV_ESNEIGH 3 /* iso10589 */
103 #define TLV_PART_DIS 4 /* iso10589 */
104 #define TLV_PREFIX_NEIGH 5 /* iso10589 */
105 #define TLV_ISNEIGH 6 /* iso10589 */
106 #define TLV_ISNEIGH_VARLEN 7 /* iso10589 */
107 #define TLV_PADDING 8 /* iso10589 */
108 #define TLV_LSP 9 /* iso10589 */
109 #define TLV_AUTH 10 /* iso10589, draft-ietf-isis-hmac-03 */
110 #define TLV_CHECKSUM 12 /* rfc3358 */
111 #define TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
112 #define TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-04 */
113 #define TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
114 #define TLV_DECNET_PHASE4 42
115 #define TLV_LUCENT_PRIVATE 66
116 #define TLV_IP_REACH 128 /* rfc1195, rfc2966 */
117 #define TLV_PROTOCOLS 129 /* rfc1195 */
118 #define TLV_IP_REACH_EXT 130 /* rfc1195, rfc2966 */
119 #define TLV_IDRP_INFO 131 /* rfc1195 */
120 #define TLV_IPADDR 132 /* rfc1195 */
121 #define TLV_IPAUTH 133 /* rfc1195 */
122 #define TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-04 */
123 #define TLV_EXT_IP_REACH 135 /* draft-ietf-isis-traffic-04 */
124 #define TLV_HOSTNAME 137 /* rfc2763 */
125 #define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions-14 */
126 #define TLV_NORTEL_PRIVATE1 176
127 #define TLV_NORTEL_PRIVATE2 177
128 #define TLV_HOLDTIME 198 /* ES-IS */
129 #define TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
130 #define TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
131 #define TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
132 #define TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
133 #define TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
134 #define TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
135 #define TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
136 #define TLV_PTP_ADJ 240 /* rfc3373 */
137 #define TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
138 #define TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-proprietary-tlv-00 */
140 static struct tok isis_tlv_values
[] = {
141 { TLV_AREA_ADDR
, "Area address(es)"},
142 { TLV_IS_REACH
, "IS Reachability"},
143 { TLV_ESNEIGH
, "ES Neighbor(s)"},
144 { TLV_PART_DIS
, "Partition DIS"},
145 { TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
146 { TLV_ISNEIGH
, "IS Neighbor(s)"},
147 { TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
148 { TLV_PADDING
, "Padding"},
149 { TLV_LSP
, "LSP entries"},
150 { TLV_AUTH
, "Authentication"},
151 { TLV_CHECKSUM
, "Checksum"},
152 { TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
153 { TLV_EXT_IS_REACH
, "Extended IS Reachability"},
154 { TLV_IS_ALIAS_ID
, "IS Alias ID"},
155 { TLV_DECNET_PHASE4
, "DECnet Phase IV"},
156 { TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
157 { TLV_IP_REACH
, "IPv4 Internal reachability"},
158 { TLV_PROTOCOLS
, "Protocols supported"},
159 { TLV_IP_REACH_EXT
, "IPv4 External reachability"},
160 { TLV_IDRP_INFO
, "Inter-Domain Information Type"},
161 { TLV_IPADDR
, "IPv4 Interface address(es)"},
162 { TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
163 { TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
164 { TLV_EXT_IP_REACH
, "Extended IPv4 reachability"},
165 { TLV_HOSTNAME
, "Hostname"},
166 { TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
167 { TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
168 { TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
169 { TLV_HOLDTIME
, "Holdtime"},
170 { TLV_RESTART_SIGNALING
, "Restart Signaling"},
171 { TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
172 { TLV_MT_SUPPORTED
, "Multi Topology"},
173 { TLV_IP6ADDR
, "IPv6 Interface address(es)"},
174 { TLV_MT_IP_REACH
, "Multi-Topology IPv4 reachability"},
175 { TLV_IP6_REACH
, "IPv6 reachability"},
176 { TLV_MT_IP6_REACH
, "Multi-Topology IP6 reachability"},
177 { TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
178 { TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
179 { TLV_VENDOR_PRIVATE
, "Vendor Private"},
183 #define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3
184 #define SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID 4
185 #define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5
186 #define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6
187 #define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8
188 #define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9
189 #define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10
190 #define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11
191 #define SUBTLV_EXT_IS_REACH_TE_METRIC 18
192 #define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20
193 #define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21
195 #define SUBTLV_IP_REACH_ADMIN_TAG32 1
196 #define SUBTLV_IP_REACH_ADMIN_TAG64 2
198 #define SUBTLV_AUTH_SIMPLE 1
199 #define SUBTLV_AUTH_MD5 54
200 #define SUBTLV_AUTH_MD5_LEN 16
201 #define SUBTLV_AUTH_PRIVATE 255
203 static struct tok isis_subtlv_auth_values
[] = {
204 { SUBTLV_AUTH_SIMPLE
, "simple text password"},
205 { SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
206 { SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
210 #define SUBTLV_IDRP_RES 0
211 #define SUBTLV_IDRP_LOCAL 1
212 #define SUBTLV_IDRP_ASN 2
214 static struct tok isis_subtlv_idrp_values
[] = {
215 { SUBTLV_IDRP_RES
, "Reserved"},
216 { SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
217 { SUBTLV_IDRP_ASN
, "AS Number Tag"},
221 #define ISIS_8BIT_MASK(x) ((x)&0xff)
223 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
224 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
225 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
226 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
227 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
228 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
229 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
230 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
232 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
233 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
235 static struct tok isis_mt_flag_values
[] = {
236 { 0x4000, "sub-TLVs present"},
237 { 0x8000, "ATT bit set"},
241 #define ISIS_MASK_TLV_EXT_IP_UPDOWN(x) ((x)&0x80)
242 #define ISIS_MASK_TLV_EXT_IP_SUBTLV(x) ((x)&0x40)
244 #define ISIS_MASK_TLV_EXT_IP6_IE(x) ((x)&0x40)
245 #define ISIS_MASK_TLV_EXT_IP6_SUBTLV(x) ((x)&0x20)
247 #define ISIS_MASK_TLV_RESTART_RR(x) ((x)&0x1)
248 #define ISIS_MASK_TLV_RESTART_RA(x) ((x)&0x2)
250 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
251 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
252 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
253 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
255 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
257 static struct tok isis_gmpls_link_prot_values
[] = {
258 { 0x01, "Extra Traffic"},
259 { 0x02, "Unprotected"},
261 { 0x08, "Dedicated 1:1"},
262 { 0x10, "Dedicated 1+1"},
269 static struct tok isis_gmpls_sw_cap_values
[] = {
270 { 1, "Packet-Switch Capable-1"},
271 { 2, "Packet-Switch Capable-2"},
272 { 3, "Packet-Switch Capable-3"},
273 { 4, "Packet-Switch Capable-4"},
274 { 51, "Layer-2 Switch Capable"},
275 { 100, "Time-Division-Multiplex"},
276 { 150, "Lambda-Switch Capable"},
277 { 200, "Fiber-Switch Capable"},
281 static struct tok isis_gmpls_lsp_enc_values
[] = {
283 { 2, "Ethernet V2/DIX"},
286 { 5, "SDH ITU-T G.707"},
287 { 6, "SONET ANSI T1.105"},
288 { 7, "Digital Wrapper"},
289 { 8, "Lambda (photonic)"},
291 { 10, "Ethernet 802.3"},
292 { 11, "FiberChannel"},
296 static struct tok isis_mt_values
[] = {
297 { 0, "IPv4 unicast"},
298 { 1, "In-Band Management"},
299 { 2, "IPv6 unicast"},
301 { 4095, "Development, Experimental or Proprietary"},
305 static struct tok isis_iih_circuit_type_values
[] = {
306 { 1, "Level 1 only"},
307 { 2, "Level 2 only"},
308 { 3, "Level 1, Level 2"},
312 #define ISIS_LSP_TYPE_UNUSED0 0
313 #define ISIS_LSP_TYPE_LEVEL_1 1
314 #define ISIS_LSP_TYPE_UNUSED2 2
315 #define ISIS_LSP_TYPE_LEVEL_2 3
317 static struct tok isis_lsp_istype_values
[] = {
318 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
319 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
320 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
321 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
325 static struct tok osi_nlpid_values
[] = {
326 { NLPID_CLNS
, "CLNS"},
328 { NLPID_IP6
, "IPv6"},
333 * Katz's point to point adjacency TLV uses codes to tell us the state of
334 * the remote adjacency. Enumerate them.
337 #define ISIS_PTP_ADJ_UP 0
338 #define ISIS_PTP_ADJ_INIT 1
339 #define ISIS_PTP_ADJ_DOWN 2
342 static struct tok isis_ptp_adjancey_values
[] = {
343 { ISIS_PTP_ADJ_UP
, "Up" },
344 { ISIS_PTP_ADJ_INIT
, "Initializing" },
345 { ISIS_PTP_ADJ_DOWN
, "Down" },
349 struct isis_tlv_ptp_adj
{
350 u_int8_t adjacency_state
;
351 u_int8_t extd_local_circuit_id
[4];
352 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
353 u_int8_t neighbor_extd_local_circuit_id
[4];
356 static int osi_cksum(const u_int8_t
*, u_int
);
357 static void esis_print(const u_int8_t
*, u_int
);
358 static int isis_print(const u_int8_t
*, u_int
);
360 struct isis_metric_block
{
361 u_int8_t metric_default
;
362 u_int8_t metric_delay
;
363 u_int8_t metric_expense
;
364 u_int8_t metric_error
;
367 struct isis_tlv_is_reach
{
368 struct isis_metric_block isis_metric_block
;
369 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
372 struct isis_tlv_es_reach
{
373 struct isis_metric_block isis_metric_block
;
374 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
377 struct isis_tlv_ip_reach
{
378 struct isis_metric_block isis_metric_block
;
383 static struct tok isis_is_reach_virtual_values
[] = {
384 { 0, "IsNotVirtual"},
389 struct isis_common_header
{
392 u_int8_t version
; /* Protocol version */
394 u_int8_t pdu_type
; /* 3 MSbits are reserved */
395 u_int8_t pdu_version
; /* Packet format version */
400 struct isis_iih_lan_header
{
401 u_int8_t circuit_type
;
402 u_int8_t source_id
[SYSTEM_ID_LEN
];
403 u_int8_t holding_time
[2];
406 u_int8_t lan_id
[NODE_ID_LEN
];
409 struct isis_iih_ptp_header
{
410 u_int8_t circuit_type
;
411 u_int8_t source_id
[SYSTEM_ID_LEN
];
412 u_int8_t holding_time
[2];
417 struct isis_lsp_header
{
419 u_int8_t remaining_lifetime
[2];
420 u_int8_t lsp_id
[LSP_ID_LEN
];
421 u_int8_t sequence_number
[4];
422 u_int8_t checksum
[2];
426 struct isis_csnp_header
{
428 u_int8_t source_id
[NODE_ID_LEN
];
429 u_int8_t start_lsp_id
[LSP_ID_LEN
];
430 u_int8_t end_lsp_id
[LSP_ID_LEN
];
433 struct isis_psnp_header
{
435 u_int8_t source_id
[NODE_ID_LEN
];
438 struct isis_tlv_lsp
{
439 u_int8_t remaining_lifetime
[2];
440 u_int8_t lsp_id
[LSP_ID_LEN
];
441 u_int8_t sequence_number
[4];
442 u_int8_t checksum
[2];
446 /* allocate space for the following string
447 * xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx
448 * 32 bytes plus one termination byte */
450 print_nsap(register const u_int8_t
*pptr
, register int nsap_length
)
453 static char nsap_ascii_output
[33];
454 char *junk_buf
= nsap_ascii_output
;
456 if (nsap_length
< 1 || nsap_length
> 13) {
457 sprintf(junk_buf
, "illegal length");
458 return (nsap_ascii_output
);
461 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
462 if (!TTEST2(*pptr
, 1))
464 sprintf(junk_buf
, "%02x", *pptr
++);
465 junk_buf
+= strlen(junk_buf
);
466 if (((nsap_idx
& 1) == 0) &&
467 (nsap_idx
+ 1 < nsap_length
)) {
472 return (nsap_ascii_output
);
475 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
476 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
477 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
478 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
479 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
480 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
482 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
,
483 const u_int8_t
*esrc
, const u_int8_t
*edst
)
486 const struct isis_common_header
*header
;
488 header
= (const struct isis_common_header
*)p
;
489 pdu_type
= header
->pdu_type
& PDU_TYPE_MASK
;
491 printf("%sOSI ", caplen
< 1 ? "|" : "");
492 if (!eflag
&& esrc
!= NULL
&& edst
!= NULL
)
493 (void)printf("%s > %s, ",
494 etheraddr_string(esrc
),
495 etheraddr_string(edst
));
497 if (caplen
< 1) /* enough bytes on the wire ? */
503 (void)printf("CLNS, length: %u", length
);
507 esis_print(p
, length
);
511 if (!isis_print(p
, length
))
512 print_unknown_data(p
,"\n\t",caplen
);
516 (void)printf("ISO NULLNS, length: %u", length
);
520 (void)printf("Unknown NLPID 0x%02x, length: %u", p
[0], length
);
522 print_unknown_data(p
,"\n\t",caplen
);
527 #define ESIS_REDIRECT 6
531 static struct tok esis_values
[] = {
532 { ESIS_REDIRECT
, "redirect"},
547 esis_print(const u_int8_t
*p
, u_int length
)
551 const struct esis_hdr
*eh
;
557 printf(" no header at all!");
561 eh
= (const struct esis_hdr
*) &p
[2];
567 printf(" LI(%d) > PDU size (%d)!", li
, length
);
570 if (li
< sizeof(struct esis_hdr
) + 2) {
574 printf(" too short for esis header %d:", li
);
575 while (--length
!= 0)
576 printf("%02X", *p
++);
581 printf("ES-IS, %s, length: %u",
582 tok2str(esis_values
,"unknown type: %u",eh
->type
& 0x1f),
588 if (vflag
&& osi_cksum(p
, li
)) {
589 printf(" bad cksum (got 0x%02x%02x)",
590 eh
->cksum
[1], eh
->cksum
[0]);
591 default_print(p
, length
);
594 if (eh
->version
!= 1) {
595 printf(" unsupported version %d", eh
->version
);
598 p
+= sizeof(*eh
) + 2;
599 li
-= sizeof(*eh
) + 2; /* protoid * li */
601 switch (eh
->type
& 0x1f) {
602 case ESIS_REDIRECT
: {
603 const u_int8_t
*dst
, *snpa
, *is
;
605 dst
= p
; p
+= *p
+ 1;
608 printf("\n\t\t %s", isonsap_string(dst
));
609 snpa
= p
; p
+= *p
+ 1;
618 printf(" > %s", etheraddr_string(&snpa
[1]));
620 printf(" > %s", isonsap_string(is
));
639 printf("\n\tNET: %s", print_nsap(is
+1,*is
));
647 print_unknown_data(p
,"\n\t ",snapend
-p
);
652 /* hexdump - FIXME ? */
655 print_unknown_data(p
,"\n\t ",snapend
-p
);
658 while (p
< ep
&& li
) {
665 printf(", bad opts/li");
672 printf(", opt (%d) too long", op
);
682 if (op
== TLV_HOLDTIME
&& opli
== 2) {
683 printf("\n\tholdtime: %us", EXTRACT_16BITS(q
));
687 if (op
== TLV_PROTOCOLS
&& opli
>= 1) {
688 printf("\n\t%s (length: %u): %s",
689 tok2str(isis_tlv_values
, "unknown", op
),
691 tok2str(osi_nlpid_values
,"Unknown 0x%02x",*q
));
695 print_unknown_data(q
,"\n\t ",opli
);
699 /* allocate space for the following string
701 * 14 bytes plus one termination byte */
703 isis_print_sysid(const u_int8_t
*cp
, int sysid_len
)
706 static char sysid
[15];
709 for (i
= 1; i
<= sysid_len
; i
++) {
712 sprintf(pos
, "%02x", *cp
++);
723 /* allocate space for the following string
725 * 17 bytes plus one termination byte */
727 isis_print_nodeid(const u_int8_t
*cp
)
730 static char nodeid
[18];
733 for (i
= 1; i
<= 7; i
++) {
736 sprintf(pos
, "%02x", *cp
++);
746 /* allocate space for the following string
747 * xxxx.xxxx.xxxx.yy-zz
748 * 20 bytes plus one termination byte */
750 isis_print_lspid(const u_int8_t
*cp
)
753 static char lspid
[21];
756 for (i
= 1; i
<= 7; i
++) {
757 sprintf(pos
, "%02x", *cp
++);
762 sprintf(pos
, "-%02x", *cp
);
766 /* print the 4-byte metric block which is common found in the old-style TLVs */
769 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
771 printf(", Default Metric: %d, %s",
772 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
773 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
774 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
775 printf("\n\t\t Delay Metric: %d, %s",
776 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
777 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
778 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
779 printf("\n\t\t Expense Metric: %d, %s",
780 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
781 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
782 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
783 printf("\n\t\t Error Metric: %d, %s",
784 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
785 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
787 return(1); /* everything is ok */
791 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
794 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
796 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
799 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
800 printf("short IPv4 reachability (%d vs %lu)",
802 (unsigned long)sizeof(*tlv_ip_reach
));
806 if (!TTEST(*tlv_ip_reach
))
809 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
811 if (prefix_len
== -1)
812 printf("%sIPv4 prefix: %s mask %s",
814 ipaddr_string((tlv_ip_reach
->prefix
)),
815 ipaddr_string((tlv_ip_reach
->mask
)));
817 printf("%sIPv4 prefix: %15s/%u",
819 ipaddr_string((tlv_ip_reach
->prefix
)),
822 printf(", Distribution: %s, Metric: %u, %s",
823 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
824 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
825 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
827 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
828 printf("%s Delay Metric: %u, %s",
830 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
831 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
833 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
834 printf("%s Expense Metric: %u, %s",
836 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
837 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
839 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
840 printf("%s Error Metric: %u, %s",
842 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
843 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
845 length
-= sizeof(struct isis_tlv_ip_reach
);
852 * this is the common IP-REACH subTLV decoder it is called
853 * from various EXTD-IP REACH TLVs (135,235,236,237)
857 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
860 case SUBTLV_IP_REACH_ADMIN_TAG32
:
861 if (!TTEST2(*tptr
,4))
863 printf("%s32-Bit Administrative tag: 0x%08x (=%u)",
865 EXTRACT_32BITS(tptr
),
866 EXTRACT_32BITS(tptr
));
868 case SUBTLV_IP_REACH_ADMIN_TAG64
:
869 if (!TTEST2(*tptr
,8))
871 printf("%s64-Bit Administrative tag: 0x%08x%08x",
873 EXTRACT_32BITS(tptr
),
874 EXTRACT_32BITS(tptr
+4));
877 printf("%sunknown subTLV, type %d, length %d",
881 if(!print_unknown_data(tptr
,"\n\t\t ",
889 printf("%spacket exceeded snapshot",ident
);
894 * this is the common IS-REACH subTLV decoder it is called
895 * from isis_print_ext_is_reach()
899 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
902 union { /* int to float conversion buffer for several subTLVs */
908 case SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
909 if (!TTEST2(*tptr
,4))
911 printf("%sAdministrative groups: 0x%08x",
913 EXTRACT_32BITS(tptr
));
915 case SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID
:
916 if (!TTEST2(*tptr
,4))
918 printf("%sLink Local Identifier: 0x%08x",
920 EXTRACT_32BITS(tptr
));
922 case SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
923 if (!TTEST2(*tptr
,4))
925 printf("%sLink Remote Identifier: 0x%08x",
927 EXTRACT_32BITS(tptr
));
929 case SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
930 if (!TTEST2(*tptr
,4))
932 bw
.i
= EXTRACT_32BITS(tptr
);
933 printf("%sMaximum link bandwidth : %.3f Mbps",
937 case SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
938 if (!TTEST2(*tptr
,4))
940 bw
.i
= EXTRACT_32BITS(tptr
);
941 printf("%sReservable link bandwidth: %.3f Mbps",
945 case SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
946 printf("%sUnreserved bandwidth:",ident
);
947 for (i
= 0; i
< 8; i
++) {
948 if (!TTEST2(*(tptr
+i
*4),4))
950 bw
.i
= EXTRACT_32BITS(tptr
);
951 printf("%s priority level %d: %.3f Mbps",
957 case SUBTLV_EXT_IS_REACH_TE_METRIC
:
958 if (!TTEST2(*tptr
,3))
960 printf("%sTraffic Engineering Metric: %d",
962 EXTRACT_24BITS(tptr
));
964 case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
965 if (!TTEST2(*tptr
,4))
967 printf("%sIPv4 interface address: %s",
969 ipaddr_string(tptr
));
971 case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
972 if (!TTEST2(*tptr
,4))
974 printf("%sIPv4 neighbor address: %s",
976 ipaddr_string(tptr
));
978 case SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
979 if (!TTEST2(*tptr
,2))
981 printf("%sLink Protection Type: %s, Priority %u",
983 bittok2str(isis_gmpls_link_prot_values
, "none", *tptr
),
986 case SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
987 printf("%sInterface Switching Capability",ident
);
989 if (!TTEST2(*tptr
,1))
991 printf("%s Interface Switching Capability:%s",
993 tok2str(isis_gmpls_sw_cap_values
, "Unknown", *(tptr
)));
995 if (!TTEST2(*(tptr
+1),1))
997 printf(", LSP Encoding: %s",
998 tok2str(isis_gmpls_lsp_enc_values
, "Unknown", *(tptr
+1)));
1000 if (!TTEST2(*(tptr
+2),2)) /* skip 2 res. bytes */
1003 printf("%s Max LSP Bandwidth:",ident
);
1004 for (i
= 0; i
< 8; i
++) {
1005 if (!TTEST2(*(tptr
+(i
*4)+4),4))
1007 bw
.i
= EXTRACT_32BITS(tptr
);
1008 printf("%s priority level %d: %.3f Mbps",
1014 /* there is some optional stuff left to decode but this is as of yet
1015 not specified so just lets hexdump what is left */
1017 if(!print_unknown_data(tptr
,"\n\t\t ",
1027 printf("%sReserved for cisco specific extensions, type %d, length %d",
1033 printf("%sReserved for future expansion, type %d, length %d",
1039 printf("%sunknown subTLV, type %d, length %d",
1043 if(!print_unknown_data(tptr
,"\n\t\t ",
1051 printf("%spacket exceeded snapshot",ident
);
1057 * this is the common IS-REACH decoder it is called
1058 * from various EXTD-IS REACH style TLVs (22,24,222)
1062 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
) {
1064 char ident_buffer
[20];
1065 int subt
,subl
,tslen
;
1066 int proc_bytes
= 0; /* how many bytes did we process ? */
1068 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1071 printf("%sIS Neighbor: %s", ident
, isis_print_nodeid(tptr
));
1072 tptr
+=(NODE_ID_LEN
);
1074 if (!TTEST2(*tptr
, 3))
1076 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1079 if (!TTEST2(*tptr
, 1))
1081 tslen
=*(tptr
++); /* read out subTLV length */
1082 proc_bytes
=NODE_ID_LEN
+3+1;
1083 printf(", %ssub-TLVs present",tslen
? "" : "no ");
1085 printf(" (%u)",tslen
);
1087 if (!TTEST2(*tptr
,2))
1091 /* prepend the ident string */
1092 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1093 if(!isis_print_is_reach_subtlv(tptr
,subt
,subl
,ident_buffer
))
1097 proc_bytes
+=(subl
+2);
1104 * this is the common Multi Topology ID decoder
1105 * it is called from various MT-TLVs (222,229,235,237)
1109 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1111 if (!TTEST2(*tptr
, 2))
1116 tok2str(isis_mt_values
,
1117 "Reserved for IETF Consensus",
1118 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1120 printf(" Topology (0x%03x), Flags: [%s]",
1121 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1122 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1128 * this is the common extended IP reach decoder
1129 * it is called from TLVs (135,235,236,237)
1130 * we process the TLV and optional subTLVs and return
1131 * the amount of processed bytes
1135 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1137 char ident_buffer
[20];
1138 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1139 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1141 if (!TTEST2(*tptr
, 4))
1143 metric
= EXTRACT_32BITS(tptr
);
1148 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1150 status_byte
=*(tptr
++);
1151 bit_length
= status_byte
&0x3f;
1154 } else if (afi
== IPV6
) {
1155 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1157 status_byte
=*(tptr
++);
1158 bit_length
=*(tptr
++);
1162 return (0); /* somebody is fooling us */
1164 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1166 if (!TTEST2(*tptr
, byte_length
))
1168 memset(prefix
, 0, 16); /* clear the copy buffer */
1169 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1171 processed
+=byte_length
;
1174 printf("%sIPv4 prefix: %15s/%u",
1176 ipaddr_string(prefix
),
1180 printf("%sIPv6 prefix: %39s/%u",
1182 ip6addr_string(prefix
),
1186 printf(", Distribution: %s, Metric: %u",
1187 ISIS_MASK_TLV_EXT_IP_UPDOWN(status_byte
) ? "down" : "up",
1190 if (afi
== IPV4
&& ISIS_MASK_TLV_EXT_IP_SUBTLV(status_byte
))
1191 printf(", sub-TLVs present");
1195 ISIS_MASK_TLV_EXT_IP6_IE(status_byte
) ? "External" : "Internal",
1196 ISIS_MASK_TLV_EXT_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1199 if ((ISIS_MASK_TLV_EXT_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1200 (ISIS_MASK_TLV_EXT_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1201 /* assume that one prefix can hold more
1202 than one subTLV - therefore the first byte must reflect
1203 the aggregate bytecount of the subTLVs for this prefix
1205 if (!TTEST2(*tptr
, 1))
1208 processed
+=sublen
+1;
1209 printf(" (%u)",sublen
); /* print out subTLV length */
1212 if (!TTEST2(*tptr
,2))
1214 subtlvtype
=*(tptr
++);
1215 subtlvlen
=*(tptr
++);
1216 /* prepend the ident string */
1217 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1218 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1221 sublen
-=(subtlvlen
+2);
1229 * Decode IS-IS packets. Return 0 on error.
1232 static int isis_print (const u_int8_t
*p
, u_int length
)
1234 const struct isis_common_header
*header
;
1236 const struct isis_iih_lan_header
*header_iih_lan
;
1237 const struct isis_iih_ptp_header
*header_iih_ptp
;
1238 const struct isis_lsp_header
*header_lsp
;
1239 const struct isis_csnp_header
*header_csnp
;
1240 const struct isis_psnp_header
*header_psnp
;
1242 const struct isis_tlv_lsp
*tlv_lsp
;
1243 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1244 const struct isis_tlv_is_reach
*tlv_is_reach
;
1245 const struct isis_tlv_es_reach
*tlv_es_reach
;
1247 u_int8_t pdu_type
, max_area
, id_length
, type
, len
, tmp
, alen
, lan_alen
, prefix_len
;
1248 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1249 const u_int8_t
*optr
, *pptr
, *tptr
;
1250 u_short packet_len
,pdu_len
,time_remain
;
1254 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1255 need it for parsing the checksum TLV */
1256 header
= (const struct isis_common_header
*)p
;
1258 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1259 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1260 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1261 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1262 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1263 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1266 * Sanity checking of the header.
1269 if (header
->version
!= ISIS_VERSION
) {
1270 printf(", version %d packet not supported", header
->version
);
1274 if ((header
->id_length
!= SYSTEM_ID_LEN
) && (header
->id_length
!= 0)) {
1275 printf(", system ID length of %d is not supported",
1280 if (header
->pdu_version
!= ISIS_VERSION
) {
1281 printf(", version %d packet not supported", header
->pdu_version
);
1285 max_area
= header
->max_area
;
1288 max_area
= 3; /* silly shit */
1291 printf(", bad packet -- 255 areas");
1297 id_length
= header
->id_length
;
1300 id_length
= 6; /* silly shit again */
1302 case 1: /* 1-8 are valid sys-ID lenghts */
1312 id_length
= 0; /* entirely useless */
1318 /* toss any non 6-byte sys-ID len PDUs */
1319 if (id_length
!= 6 ) {
1320 printf(", bad packet -- illegal sys-ID length (%u)", id_length
);
1324 pdu_type
=header
->pdu_type
;
1326 /* in non-verbose mode just lets print the basic PDU Type*/
1328 printf("IS-IS, %s, length: %u",
1329 tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
),
1334 /* ok they seem to want to know everything - lets fully decode it */
1335 printf("IS-IS, length: %u",length
);
1337 printf("\n\thlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1340 header
->pdu_version
,
1346 /* first lets see if we know the PDU name*/
1347 printf(", pdu-type: %s",
1348 tok2str(isis_pdu_values
,
1353 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1354 return(0); /* for optionally debugging the common header */
1361 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1362 printf(", bogus fixed header length %u should be %lu",
1363 header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1367 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1368 if (packet_len
>pdu_len
) {
1369 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1373 TCHECK(*header_iih_lan
);
1374 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1375 isis_print_sysid(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1376 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1377 tok2str(isis_iih_circuit_type_values
,
1378 "unknown circuit type 0x%02x",
1379 header_iih_lan
->circuit_type
));
1381 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1382 isis_print_nodeid(header_iih_lan
->lan_id
),
1383 (header_iih_lan
->priority
) & PRIORITY_MASK
,
1387 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1391 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1392 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1396 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1397 printf(", bogus fixed header length %u should be %lu",
1398 header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1402 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1403 if (packet_len
>pdu_len
) {
1404 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1408 TCHECK(*header_iih_ptp
);
1409 printf("\n\t source-id: %s, holding time: %us, circuit-id: 0x%02x, %s, PDU length: %u",
1410 isis_print_sysid(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1411 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1412 header_iih_ptp
->circuit_id
,
1413 tok2str(isis_iih_circuit_type_values
,
1414 "unknown circuit type 0x%02x",
1415 header_iih_ptp
->circuit_type
),
1419 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1423 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1424 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1429 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1430 printf(", bogus fixed header length %u should be %lu",
1431 header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1435 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1436 if (packet_len
>pdu_len
) {
1437 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1441 TCHECK(*header_lsp
);
1442 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us",
1443 isis_print_lspid(header_lsp
->lsp_id
),
1444 EXTRACT_32BITS(header_lsp
->sequence_number
),
1445 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1446 /* verify the checksum -
1447 * checking starts at the lsp-id field
1448 * which is 12 bytes after the packet start*/
1449 printf("\n\t chksum: 0x%04x (%s), PDU length: %u",
1450 EXTRACT_16BITS(header_lsp
->checksum
),
1451 (osi_cksum(optr
+12, length
-12)) ? "incorrect" : "correct",
1454 printf(", %s", ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1456 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1457 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1458 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1459 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1460 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1461 printf("ATT bit set, ");
1463 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1464 printf("%s", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1467 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1471 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1472 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1477 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1478 printf(", bogus fixed header length %u should be %lu",
1479 header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1483 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1484 if (packet_len
>pdu_len
) {
1485 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1489 TCHECK(*header_csnp
);
1490 printf("\n\t source-id: %s, PDU length: %u",
1491 isis_print_nodeid(header_csnp
->source_id
),
1493 printf("\n\t start lsp-id: %s",
1494 isis_print_lspid(header_csnp
->start_lsp_id
));
1495 printf("\n\t end lsp-id: %s",
1496 isis_print_lspid(header_csnp
->end_lsp_id
));
1499 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1503 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1504 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1509 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1510 printf("- bogus fixed header length %u should be %lu",
1511 header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1515 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1516 if (packet_len
>pdu_len
) {
1517 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1521 TCHECK(*header_psnp
);
1522 printf("\n\t source-id: %s",
1523 isis_print_nodeid(header_psnp
->source_id
));
1526 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1530 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1531 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1535 if(!print_unknown_data(pptr
,"\n\t ",length
))
1541 * Now print the TLV's.
1544 while (packet_len
>= 2) {
1545 if (pptr
== snapend
) {
1549 if (!TTEST2(*pptr
, 2)) {
1550 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1551 (long)(pptr
-snapend
));
1556 tmp
=len
; /* copy temporary len & pointer to packet data */
1559 if (len
> packet_len
) {
1563 /* first lets see if we know the TLVs name*/
1564 printf("\n\t %s TLV #%u, length: %u",
1565 tok2str(isis_tlv_values
,
1571 /* now check if we have a decoder otherwise do a hexdump at the end*/
1574 if (!TTEST2(*tptr
, 1))
1577 while (tmp
&& alen
< tmp
) {
1578 printf("\n\t Area address (length: %u): %s",
1580 print_nsap(tptr
, alen
));
1583 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1585 if (!TTEST2(*tptr
, 1))
1591 while (tmp
>= ETHER_ADDR_LEN
) {
1592 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1594 printf("\n\t IS Neighbor: %s",isis_print_sysid(tptr
,ETHER_ADDR_LEN
));
1595 tmp
-= ETHER_ADDR_LEN
;
1596 tptr
+= ETHER_ADDR_LEN
;
1600 case TLV_ISNEIGH_VARLEN
:
1601 if (!TTEST2(*tptr
, 1))
1603 lan_alen
= *tptr
++; /* LAN adress length */
1605 printf("\n\t LAN address length %u bytes ",lan_alen
);
1606 while (tmp
>= lan_alen
) {
1607 if (!TTEST2(*tptr
, lan_alen
))
1609 printf("\n\t\tIS Neighbor: %s",isis_print_sysid(tptr
,lan_alen
));
1618 case TLV_MT_IS_REACH
:
1619 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1620 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1621 if (mt_len
== 0) /* did something go wrong ? */
1626 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ");
1627 if (ext_is_len
== 0) /* did something go wrong ? */
1635 case TLV_IS_ALIAS_ID
:
1636 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1637 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ");
1638 if (ext_is_len
== 0) /* did something go wrong ? */
1645 case TLV_EXT_IS_REACH
:
1646 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1647 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ");
1648 if (ext_is_len
== 0) /* did something go wrong ? */
1655 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1658 tok2str(isis_is_reach_virtual_values
,
1659 "bogus virtual flag 0x%02x",
1661 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1662 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1663 if (!TTEST(*tlv_is_reach
))
1665 printf("\n\t IS Neighbor: %s", isis_print_nodeid(tlv_is_reach
->neighbor_nodeid
));
1666 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1667 tmp
-= sizeof(struct isis_tlv_is_reach
);
1673 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1674 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1675 if (!TTEST(*tlv_es_reach
))
1677 printf("\n\t ES Neighbor: %s",
1678 isis_print_sysid(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1679 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1680 tmp
-= sizeof(struct isis_tlv_es_reach
);
1685 /* those two TLVs share the same format */
1687 case TLV_IP_REACH_EXT
:
1688 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", len
))
1692 case TLV_EXT_IP_REACH
:
1694 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1695 if (ext_ip_len
== 0) /* did something go wrong ? */
1702 case TLV_MT_IP_REACH
:
1704 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1705 if (mt_len
== 0) /* did something go wrong ? */
1710 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1711 if (ext_ip_len
== 0) /* did something go wrong ? */
1721 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1722 if (ext_ip_len
== 0) /* did something go wrong ? */
1729 case TLV_MT_IP6_REACH
:
1731 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1732 if (mt_len
== 0) /* did something go wrong ? */
1737 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1738 if (ext_ip_len
== 0) /* did something go wrong ? */
1747 if (!TTEST2(*tptr
, 16))
1750 printf("\n\t IPv6 interface address: %s",
1751 ip6addr_string(tptr
));
1759 if (!TTEST2(*tptr
, 1))
1763 tok2str(isis_subtlv_auth_values
,
1764 "unknown Authentication type 0x%02x",
1768 case SUBTLV_AUTH_SIMPLE
:
1769 for(i
=1;i
<len
;i
++) {
1770 if (!TTEST2(*(tptr
+i
), 1))
1772 printf("%c",*(tptr
+i
));
1775 case SUBTLV_AUTH_MD5
:
1776 for(i
=1;i
<len
;i
++) {
1777 if (!TTEST2(*(tptr
+i
), 1))
1779 printf("%02x",*(tptr
+i
));
1781 if (len
!= SUBTLV_AUTH_MD5_LEN
+1)
1782 printf(", (malformed subTLV) ");
1784 case SUBTLV_AUTH_PRIVATE
:
1786 if(!print_unknown_data(tptr
+1,"\n\t\t ",len
-1))
1793 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
1795 if (!TTEST2(*tptr
, 1))
1797 printf("\n\t Adjacency State: %s",
1798 tok2str(isis_ptp_adjancey_values
, "0x%02x", *tptr
));
1801 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
1802 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
1803 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
1805 printf("\n\t Extended Local circuit ID: 0x%08x",
1806 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
1807 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
1809 if(tmp
>=SYSTEM_ID_LEN
) {
1810 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
1812 printf("\n\t Neighbor SystemID: %s",
1813 isis_print_sysid(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
1816 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
1817 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
1818 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
1820 printf("\n\t Neighbor Extended Local circuit ID: 0x%08x",
1821 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
1826 printf("\n\t NLPID(s): ");
1828 if (!TTEST2(*(tptr
), 1))
1831 tok2str(osi_nlpid_values
,
1834 if (tmp
>1) /* further NPLIDs ? - put comma */
1840 case TLV_TE_ROUTER_ID
:
1841 if (!TTEST2(*pptr
, 4))
1843 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
1848 if (!TTEST2(*tptr
, 4))
1850 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1857 printf("\n\t Hostname: ");
1859 if (!TTEST2(*tptr
, 1))
1861 printf("%c",*tptr
++);
1866 case TLV_SHARED_RISK_GROUP
:
1867 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1869 printf("\n\t IS Neighbor: %s", isis_print_nodeid(tptr
));
1870 tptr
+=(NODE_ID_LEN
);
1873 if (!TTEST2(*tptr
, 1))
1875 printf(", %s", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
1878 if (!TTEST2(*tptr
,4))
1880 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1884 if (!TTEST2(*tptr
,4))
1886 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
1891 if (!TTEST2(*tptr
, 4))
1893 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
1900 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
1902 printf("\n\t lsp-id: %s",
1903 isis_print_nodeid(tlv_lsp
->lsp_id
));
1904 if (!TTEST((tlv_lsp
->lsp_id
)[NODE_ID_LEN
]))
1906 printf("-%02x",(tlv_lsp
->lsp_id
)[NODE_ID_LEN
]);
1907 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
1909 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
1910 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
1912 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
1913 if (!TTEST2(tlv_lsp
->checksum
, 2))
1915 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
1916 tmp
-=sizeof(struct isis_tlv_lsp
);
1922 if (!TTEST2(*tptr
, 2))
1924 printf("\n\t checksum: 0x%04x (%s)",
1925 EXTRACT_16BITS(tptr
),
1926 (osi_cksum(optr
, length
)) ? "incorrect" : "correct");
1929 case TLV_MT_SUPPORTED
:
1931 /* length can only be a multiple of 2, otherwise there is
1932 something broken -> so decode down until length is 1 */
1934 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1935 if (mt_len
== 0) /* did something go wrong ? */
1940 printf("\n\t malformed MT-ID");
1946 case TLV_RESTART_SIGNALING
:
1947 if (!TTEST2(*tptr
, 3))
1949 rr
= ISIS_MASK_TLV_RESTART_RR(*tptr
);
1950 ra
= ISIS_MASK_TLV_RESTART_RA(*tptr
);
1952 time_remain
= EXTRACT_16BITS(tptr
);
1953 printf("\n\t Restart Request bit %s, Restart Acknowledgement bit %s\n\t Remaining holding time: %us",
1954 rr
? "set" : "clear", ra
? "set" : "clear", time_remain
);
1958 if (!TTEST2(*tptr
, 1))
1960 printf("\n\t Inter-Domain Information Type: %s",
1961 tok2str(isis_subtlv_idrp_values
,
1965 case SUBTLV_IDRP_ASN
:
1966 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
1968 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
1970 case SUBTLV_IDRP_LOCAL
:
1971 case SUBTLV_IDRP_RES
:
1973 if(!print_unknown_data(tptr
,"\n\t ",len
-1))
1979 case TLV_LSP_BUFFERSIZE
:
1980 if (!TTEST2(*tptr
, 2))
1982 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
1986 while (tmp
>= SYSTEM_ID_LEN
) {
1987 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
1989 printf("\n\t %s",isis_print_sysid(tptr
,SYSTEM_ID_LEN
));
1990 tptr
+=SYSTEM_ID_LEN
;
1995 case TLV_PREFIX_NEIGH
:
1996 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
1998 printf("\n\t Metric Block");
1999 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2000 tptr
+=sizeof(struct isis_metric_block
);
2001 tmp
-=sizeof(struct isis_metric_block
);
2004 if (!TTEST2(*tptr
, 1))
2006 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2008 if (!TTEST2(*tptr
, prefix_len
/2))
2010 printf("\n\t\tAddress: %s/%u",
2011 print_nsap(tptr
,prefix_len
/2),
2019 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
2021 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
2024 case TLV_VENDOR_PRIVATE
:
2025 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
2027 printf("\n\t Vendor OUI Code: 0x%06x", EXTRACT_24BITS(tptr
) );
2030 if (tmp
> 0) /* hexdump the rest */
2031 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
2035 * FIXME those are the defined TLVs that lack a decoder
2036 * you are welcome to contribute code ;-)
2039 case TLV_DECNET_PHASE4
:
2040 case TLV_LUCENT_PRIVATE
:
2042 case TLV_NORTEL_PRIVATE1
:
2043 case TLV_NORTEL_PRIVATE2
:
2047 if(!print_unknown_data(pptr
,"\n\t\t",len
))
2052 /* do we want to see an additionally hexdump ? */
2054 if(!print_unknown_data(pptr
,"\n\t ",len
))
2062 if (packet_len
!= 0) {
2063 printf("\n\t %u straggler bytes", packet_len
);
2068 fputs("[|isis]", stdout
);
2072 printf("\n\t\t packet exceeded snapshot");
2077 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2081 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2083 int32_t c0
= 0, c1
= 0;
2085 while ((int)--len
>= 0) {