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.90 2003-07-01 08:34:30 guy Exp $ (LBL)";
36 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
43 #include "ethertype.h"
48 #define NLPID_CLNS 129 /* 0x81 */
49 #define NLPID_ESIS 130 /* 0x82 */
50 #define NLPID_ISIS 131 /* 0x83 */
51 #define NLPID_IP6 0x8e
53 #define NLPID_NULLNS 0
55 #define IPV4 1 /* AFI value */
56 #define IPV6 2 /* AFI value */
59 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
62 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
63 #define NODE_ID_LEN SYSTEM_ID_LEN+1
64 #define LSP_ID_LEN SYSTEM_ID_LEN+2
66 #define ISIS_VERSION 1
67 #define PDU_TYPE_MASK 0x1F
68 #define PRIORITY_MASK 0x7F
80 static struct tok isis_pdu_values
[] = {
81 { L1_LAN_IIH
, "L1 Lan IIH"},
82 { L2_LAN_IIH
, "L2 Lan IIH"},
83 { PTP_IIH
, "p2p IIH"},
86 { L1_CSNP
, "L1 CSNP"},
87 { L2_CSNP
, "L2 CSNP"},
88 { L1_PSNP
, "L1 PSNP"},
89 { L2_PSNP
, "L2 PSNP"},
94 * A TLV is a tuple of a type, length and a value and is normally used for
95 * encoding information in all sorts of places. This is an enumeration of
96 * the well known types.
98 * list taken from rfc3359 plus some memory from veterans ;-)
101 #define TLV_AREA_ADDR 1 /* iso10589 */
102 #define TLV_IS_REACH 2 /* iso10589 */
103 #define TLV_ESNEIGH 3 /* iso10589 */
104 #define TLV_PART_DIS 4 /* iso10589 */
105 #define TLV_PREFIX_NEIGH 5 /* iso10589 */
106 #define TLV_ISNEIGH 6 /* iso10589 */
107 #define TLV_ISNEIGH_VARLEN 7 /* iso10589 */
108 #define TLV_PADDING 8 /* iso10589 */
109 #define TLV_LSP 9 /* iso10589 */
110 #define TLV_AUTH 10 /* iso10589, draft-ietf-isis-hmac-03 */
111 #define TLV_CHECKSUM 12 /* rfc3358 */
112 #define TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
113 #define TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-04 */
114 #define TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
115 #define TLV_DECNET_PHASE4 42
116 #define TLV_LUCENT_PRIVATE 66
117 #define TLV_IP_REACH 128 /* rfc1195, rfc2966 */
118 #define TLV_PROTOCOLS 129 /* rfc1195 */
119 #define TLV_IP_REACH_EXT 130 /* rfc1195, rfc2966 */
120 #define TLV_IDRP_INFO 131 /* rfc1195 */
121 #define TLV_IPADDR 132 /* rfc1195 */
122 #define TLV_IPAUTH 133 /* rfc1195 */
123 #define TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-04 */
124 #define TLV_EXT_IP_REACH 135 /* draft-ietf-isis-traffic-04 */
125 #define TLV_HOSTNAME 137 /* rfc2763 */
126 #define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions-14 */
127 #define TLV_NORTEL_PRIVATE1 176
128 #define TLV_NORTEL_PRIVATE2 177
129 #define TLV_HOLDTIME 198 /* ES-IS */
130 #define TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
131 #define TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
132 #define TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
133 #define TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
134 #define TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
135 #define TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
136 #define TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
137 #define TLV_PTP_ADJ 240 /* rfc3373 */
138 #define TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
139 #define TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-proprietary-tlv-00 */
141 static struct tok isis_tlv_values
[] = {
142 { TLV_AREA_ADDR
, "Area address(es)"},
143 { TLV_IS_REACH
, "IS Reachability"},
144 { TLV_ESNEIGH
, "ES Neighbor(s)"},
145 { TLV_PART_DIS
, "Partition DIS"},
146 { TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
147 { TLV_ISNEIGH
, "IS Neighbor(s)"},
148 { TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
149 { TLV_PADDING
, "Padding"},
150 { TLV_LSP
, "LSP entries"},
151 { TLV_AUTH
, "Authentication"},
152 { TLV_CHECKSUM
, "Checksum"},
153 { TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
154 { TLV_EXT_IS_REACH
, "Extended IS Reachability"},
155 { TLV_IS_ALIAS_ID
, "IS Alias ID"},
156 { TLV_DECNET_PHASE4
, "DECnet Phase IV"},
157 { TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
158 { TLV_IP_REACH
, "IPv4 Internal reachability"},
159 { TLV_PROTOCOLS
, "Protocols supported"},
160 { TLV_IP_REACH_EXT
, "IPv4 External reachability"},
161 { TLV_IDRP_INFO
, "Inter-Domain Information Type"},
162 { TLV_IPADDR
, "IPv4 Interface address(es)"},
163 { TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
164 { TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
165 { TLV_EXT_IP_REACH
, "Extended IPv4 reachability"},
166 { TLV_HOSTNAME
, "Hostname"},
167 { TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
168 { TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
169 { TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
170 { TLV_HOLDTIME
, "Holdtime"},
171 { TLV_RESTART_SIGNALING
, "Restart Signaling"},
172 { TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
173 { TLV_MT_SUPPORTED
, "Multi Topology"},
174 { TLV_IP6ADDR
, "IPv6 Interface address(es)"},
175 { TLV_MT_IP_REACH
, "Multi-Topology IPv4 reachability"},
176 { TLV_IP6_REACH
, "IPv6 reachability"},
177 { TLV_MT_IP6_REACH
, "Multi-Topology IP6 reachability"},
178 { TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
179 { TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
180 { TLV_VENDOR_PRIVATE
, "Vendor Private"},
184 #define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3
185 #define SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID 4
186 #define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5
187 #define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6
188 #define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8
189 #define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9
190 #define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10
191 #define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11
192 #define SUBTLV_EXT_IS_REACH_TE_METRIC 18
193 #define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20
194 #define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21
196 #define SUBTLV_IP_REACH_ADMIN_TAG32 1
197 #define SUBTLV_IP_REACH_ADMIN_TAG64 2
199 #define SUBTLV_AUTH_SIMPLE 1
200 #define SUBTLV_AUTH_MD5 54
201 #define SUBTLV_AUTH_MD5_LEN 16
202 #define SUBTLV_AUTH_PRIVATE 255
204 static struct tok isis_subtlv_auth_values
[] = {
205 { SUBTLV_AUTH_SIMPLE
, "simple text password"},
206 { SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
207 { SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
211 #define SUBTLV_IDRP_RES 0
212 #define SUBTLV_IDRP_LOCAL 1
213 #define SUBTLV_IDRP_ASN 2
215 static struct tok isis_subtlv_idrp_values
[] = {
216 { SUBTLV_IDRP_RES
, "Reserved"},
217 { SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
218 { SUBTLV_IDRP_ASN
, "AS Number Tag"},
222 #define ISIS_8BIT_MASK(x) ((x)&0xff)
224 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
225 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
226 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
227 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
228 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
229 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
230 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
231 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
233 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
234 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
236 static struct tok isis_mt_flag_values
[] = {
237 { 0x4000, "sub-TLVs present"},
238 { 0x8000, "ATT bit set"},
242 #define ISIS_MASK_TLV_EXT_IP_UPDOWN(x) ((x)&0x80)
243 #define ISIS_MASK_TLV_EXT_IP_SUBTLV(x) ((x)&0x40)
245 #define ISIS_MASK_TLV_EXT_IP6_IE(x) ((x)&0x40)
246 #define ISIS_MASK_TLV_EXT_IP6_SUBTLV(x) ((x)&0x20)
248 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
249 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
250 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
251 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
253 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
255 static struct tok isis_mt_values
[] = {
256 { 0, "IPv4 unicast"},
257 { 1, "In-Band Management"},
258 { 2, "IPv6 unicast"},
260 { 4095, "Development, Experimental or Proprietary"},
264 static struct tok isis_iih_circuit_type_values
[] = {
265 { 1, "Level 1 only"},
266 { 2, "Level 2 only"},
267 { 3, "Level 1, Level 2"},
271 #define ISIS_LSP_TYPE_UNUSED0 0
272 #define ISIS_LSP_TYPE_LEVEL_1 1
273 #define ISIS_LSP_TYPE_UNUSED2 2
274 #define ISIS_LSP_TYPE_LEVEL_2 3
276 static struct tok isis_lsp_istype_values
[] = {
277 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
278 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
279 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
280 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
284 static struct tok osi_nlpid_values
[] = {
285 { NLPID_CLNS
, "CLNS"},
287 { NLPID_IP6
, "IPv6"},
292 * Katz's point to point adjacency TLV uses codes to tell us the state of
293 * the remote adjacency. Enumerate them.
296 #define ISIS_PTP_ADJ_UP 0
297 #define ISIS_PTP_ADJ_INIT 1
298 #define ISIS_PTP_ADJ_DOWN 2
301 static struct tok isis_ptp_adjancey_values
[] = {
302 { ISIS_PTP_ADJ_UP
, "Up" },
303 { ISIS_PTP_ADJ_INIT
, "Initializing" },
304 { ISIS_PTP_ADJ_DOWN
, "Down" },
308 struct isis_tlv_ptp_adj
{
309 u_int8_t adjacency_state
;
310 u_int8_t extd_local_circuit_id
[4];
311 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
312 u_int8_t neighbor_extd_local_circuit_id
[4];
315 static int osi_cksum(const u_int8_t
*, u_int
);
316 static void esis_print(const u_int8_t
*, u_int
);
317 static int isis_print(const u_int8_t
*, u_int
);
319 struct isis_metric_block
{
320 u_int8_t metric_default
;
321 u_int8_t metric_delay
;
322 u_int8_t metric_expense
;
323 u_int8_t metric_error
;
326 struct isis_tlv_is_reach
{
327 struct isis_metric_block isis_metric_block
;
328 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
331 struct isis_tlv_es_reach
{
332 struct isis_metric_block isis_metric_block
;
333 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
336 struct isis_tlv_ip_reach
{
337 struct isis_metric_block isis_metric_block
;
342 static struct tok isis_is_reach_virtual_values
[] = {
343 { 0, "IsNotVirtual"},
348 static struct tok isis_restart_flag_values
[] = {
349 { 0x1, "Restart Request"},
350 { 0x2, "Restart Acknowledgement"},
354 struct isis_common_header
{
357 u_int8_t version
; /* Protocol version */
359 u_int8_t pdu_type
; /* 3 MSbits are reserved */
360 u_int8_t pdu_version
; /* Packet format version */
365 struct isis_iih_lan_header
{
366 u_int8_t circuit_type
;
367 u_int8_t source_id
[SYSTEM_ID_LEN
];
368 u_int8_t holding_time
[2];
371 u_int8_t lan_id
[NODE_ID_LEN
];
374 struct isis_iih_ptp_header
{
375 u_int8_t circuit_type
;
376 u_int8_t source_id
[SYSTEM_ID_LEN
];
377 u_int8_t holding_time
[2];
382 struct isis_lsp_header
{
384 u_int8_t remaining_lifetime
[2];
385 u_int8_t lsp_id
[LSP_ID_LEN
];
386 u_int8_t sequence_number
[4];
387 u_int8_t checksum
[2];
391 struct isis_csnp_header
{
393 u_int8_t source_id
[NODE_ID_LEN
];
394 u_int8_t start_lsp_id
[LSP_ID_LEN
];
395 u_int8_t end_lsp_id
[LSP_ID_LEN
];
398 struct isis_psnp_header
{
400 u_int8_t source_id
[NODE_ID_LEN
];
403 struct isis_tlv_lsp
{
404 u_int8_t remaining_lifetime
[2];
405 u_int8_t lsp_id
[LSP_ID_LEN
];
406 u_int8_t sequence_number
[4];
407 u_int8_t checksum
[2];
411 /* allocate space for the following string
412 * xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx
413 * 50 bytes plus one termination byte */
415 print_nsap(register const u_int8_t
*pptr
, register int nsap_length
)
418 static char nsap_ascii_output
[51];
419 char *junk_buf
= nsap_ascii_output
;
421 if (nsap_length
< 1 || nsap_length
> 20) {
422 sprintf(junk_buf
, "illegal length");
423 return (nsap_ascii_output
);
426 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
427 if (!TTEST2(*pptr
, 1))
429 sprintf(junk_buf
, "%02x", *pptr
++);
430 junk_buf
+= strlen(junk_buf
);
431 if (((nsap_idx
& 1) == 0) &&
432 (nsap_idx
+ 1 < nsap_length
)) {
437 return (nsap_ascii_output
);
440 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
441 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
442 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
443 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
444 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
445 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
447 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
450 const struct isis_common_header
*header
;
452 header
= (const struct isis_common_header
*)p
;
453 pdu_type
= header
->pdu_type
& PDU_TYPE_MASK
;
455 printf("%sOSI", caplen
< 1 ? "|" : "");
457 if (caplen
< 1) /* enough bytes on the wire ? */
463 (void)printf(", CLNS, length %u", length
);
467 esis_print(p
, length
);
471 if (!isis_print(p
, length
))
472 print_unknown_data(p
,"\n\t",caplen
);
476 (void)printf(", ISO NULLNS, length: %u", length
);
480 (void)printf(", Unknown NLPID 0x%02x, length: %u", p
[0], length
);
482 print_unknown_data(p
,"\n\t",caplen
);
487 #define ESIS_REDIRECT 6
491 static struct tok esis_values
[] = {
492 { ESIS_REDIRECT
, "redirect"},
507 esis_print(const u_int8_t
*p
, u_int length
)
511 const struct esis_hdr
*eh
;
517 printf(" no header at all!");
521 eh
= (const struct esis_hdr
*) &p
[2];
527 printf(" LI(%d) > PDU size (%d)!", li
, length
);
530 if (li
< sizeof(struct esis_hdr
) + 2) {
534 printf(" too short for esis header %d:", li
);
535 while (--length
!= 0)
536 printf("%02X", *p
++);
541 printf(", ES-IS, %s, length %u",
542 tok2str(esis_values
,"unknown type: %u",eh
->type
& 0x1f),
548 if (vflag
&& osi_cksum(p
, li
)) {
549 printf(" bad cksum (got 0x%02x%02x)",
550 eh
->cksum
[1], eh
->cksum
[0]);
551 default_print(p
, length
);
554 if (eh
->version
!= 1) {
555 printf(" unsupported version %d", eh
->version
);
558 p
+= sizeof(*eh
) + 2;
559 li
-= sizeof(*eh
) + 2; /* protoid * li */
561 switch (eh
->type
& 0x1f) {
562 case ESIS_REDIRECT
: {
563 const u_int8_t
*dst
, *snpa
, *is
;
565 dst
= p
; p
+= *p
+ 1;
568 printf("\n\t\t %s", isonsap_string(dst
));
569 snpa
= p
; p
+= *p
+ 1;
578 printf(" > %s", etheraddr_string(&snpa
[1]));
580 printf(" > %s", isonsap_string(is
));
599 printf("\n\tNET: %s", print_nsap(is
+1,*is
));
607 print_unknown_data(p
,"\n\t ",snapend
-p
);
612 /* hexdump - FIXME ? */
615 print_unknown_data(p
,"\n\t ",snapend
-p
);
618 while (p
< ep
&& li
) {
625 printf(", bad opts/li");
632 printf(", opt (%d) too long", op
);
642 if (op
== TLV_HOLDTIME
&& opli
== 2) {
643 printf("\n\tholdtime: %us", EXTRACT_16BITS(q
));
647 if (op
== TLV_PROTOCOLS
&& opli
>= 1) {
648 printf("\n\t%s (length: %u): %s",
649 tok2str(isis_tlv_values
, "unknown", op
),
651 tok2str(osi_nlpid_values
,"Unknown 0x%02x",*q
));
655 print_unknown_data(q
,"\n\t ",opli
);
659 /* shared routine for printing system, node and lsp-ids
660 * allocate space for the worst-case string
661 * xxxx.xxxx.xxxx.yy-zz
662 * 20 bytes plus one termination byte */
664 isis_print_id(const u_int8_t
*cp
, int id_len
)
670 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
671 sprintf(pos
, "%02x", *cp
++);
673 if (i
== 2 || i
== 4)
676 if (id_len
== NODE_ID_LEN
) {
677 sprintf(pos
, ".%02x", *cp
++);
680 if (id_len
== LSP_ID_LEN
)
681 sprintf(pos
, "-%02x", *cp
);
685 /* print the 4-byte metric block which is common found in the old-style TLVs */
687 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
689 printf(", Default Metric: %d, %s",
690 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
691 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
692 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
693 printf("\n\t\t Delay Metric: %d, %s",
694 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
695 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
696 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
697 printf("\n\t\t Expense Metric: %d, %s",
698 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
699 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
700 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
701 printf("\n\t\t Error Metric: %d, %s",
702 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
703 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
705 return(1); /* everything is ok */
709 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
712 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
714 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
717 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
718 printf("short IPv4 reachability (%d vs %lu)",
720 (unsigned long)sizeof(*tlv_ip_reach
));
724 if (!TTEST(*tlv_ip_reach
))
727 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
729 if (prefix_len
== -1)
730 printf("%sIPv4 prefix: %s mask %s",
732 ipaddr_string((tlv_ip_reach
->prefix
)),
733 ipaddr_string((tlv_ip_reach
->mask
)));
735 printf("%sIPv4 prefix: %15s/%u",
737 ipaddr_string((tlv_ip_reach
->prefix
)),
740 printf(", Distribution: %s, Metric: %u, %s",
741 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
742 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
743 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
745 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
746 printf("%s Delay Metric: %u, %s",
748 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
749 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
751 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
752 printf("%s Expense Metric: %u, %s",
754 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
755 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
757 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
758 printf("%s Error Metric: %u, %s",
760 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
761 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
763 length
-= sizeof(struct isis_tlv_ip_reach
);
770 * this is the common IP-REACH subTLV decoder it is called
771 * from various EXTD-IP REACH TLVs (135,235,236,237)
775 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
778 case SUBTLV_IP_REACH_ADMIN_TAG32
:
780 if (!TTEST2(*tptr
,4))
782 printf("%s32-Bit Administrative tag: 0x%08x (=%u)",
784 EXTRACT_32BITS(tptr
),
785 EXTRACT_32BITS(tptr
));
790 case SUBTLV_IP_REACH_ADMIN_TAG64
:
792 if (!TTEST2(*tptr
,8))
794 printf("%s64-Bit Administrative tag: 0x%08x%08x",
796 EXTRACT_32BITS(tptr
),
797 EXTRACT_32BITS(tptr
+4));
803 printf("%sunknown subTLV, type %d, length %d",
807 if(!print_unknown_data(tptr
,"\n\t\t ",
815 printf("%spacket exceeded snapshot",ident
);
820 * this is the common IS-REACH subTLV decoder it is called
821 * from isis_print_ext_is_reach()
825 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
828 union { /* int to float conversion buffer for several subTLVs */
834 case SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
835 if (!TTEST2(*tptr
,4))
837 printf("%sAdministrative groups: 0x%08x",
839 EXTRACT_32BITS(tptr
));
841 case SUBTLV_EXT_IS_REACH_LINK_LOCAL_ID
:
842 if (!TTEST2(*tptr
,4))
844 printf("%sLink Local Identifier: 0x%08x",
846 EXTRACT_32BITS(tptr
));
848 case SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
849 if (!TTEST2(*tptr
,4))
851 printf("%sLink Remote Identifier: 0x%08x",
853 EXTRACT_32BITS(tptr
));
855 case SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
856 if (!TTEST2(*tptr
,4))
858 bw
.i
= EXTRACT_32BITS(tptr
);
859 printf("%sMaximum link bandwidth : %.3f Mbps",
863 case SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
864 if (!TTEST2(*tptr
,4))
866 bw
.i
= EXTRACT_32BITS(tptr
);
867 printf("%sReservable link bandwidth: %.3f Mbps",
871 case SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
872 printf("%sUnreserved bandwidth:",ident
);
873 for (i
= 0; i
< 8; i
++) {
874 if (!TTEST2(*(tptr
+i
*4),4))
876 bw
.i
= EXTRACT_32BITS(tptr
);
877 printf("%s priority level %d: %.3f Mbps",
883 case SUBTLV_EXT_IS_REACH_TE_METRIC
:
884 if (!TTEST2(*tptr
,3))
886 printf("%sTraffic Engineering Metric: %d",
888 EXTRACT_24BITS(tptr
));
890 case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
891 if (!TTEST2(*tptr
,4))
893 printf("%sIPv4 interface address: %s",
895 ipaddr_string(tptr
));
897 case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
898 if (!TTEST2(*tptr
,4))
900 printf("%sIPv4 neighbor address: %s",
902 ipaddr_string(tptr
));
904 case SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
905 if (!TTEST2(*tptr
,2))
907 printf("%sLink Protection Type: %s, Priority %u",
909 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
912 case SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
913 printf("%sInterface Switching Capability",ident
);
915 if (!TTEST2(*tptr
,1))
917 printf("%s Interface Switching Capability:%s",
919 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
921 if (!TTEST2(*(tptr
+1),1))
923 printf(", LSP Encoding: %s",
924 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
926 if (!TTEST2(*(tptr
+2),2)) /* skip 2 res. bytes */
929 printf("%s Max LSP Bandwidth:",ident
);
930 for (i
= 0; i
< 8; i
++) {
931 if (!TTEST2(*(tptr
+(i
*4)+4),4))
933 bw
.i
= EXTRACT_32BITS(tptr
);
934 printf("%s priority level %d: %.3f Mbps",
940 /* there is some optional stuff left to decode but this is as of yet
941 not specified so just lets hexdump what is left */
943 if(!print_unknown_data(tptr
,"\n\t\t ",
953 printf("%sReserved for cisco specific extensions, type %d, length %d",
959 printf("%sReserved for future expansion, type %d, length %d",
965 printf("%sunknown subTLV, type %d, length %d",
969 if(!print_unknown_data(tptr
,"\n\t\t ",
977 printf("%spacket exceeded snapshot",ident
);
983 * this is the common IS-REACH decoder it is called
984 * from various EXTD-IS REACH style TLVs (22,24,222)
988 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv
) {
990 char ident_buffer
[20];
992 int proc_bytes
= 0; /* how many bytes did we process ? */
994 if (!TTEST2(*tptr
, NODE_ID_LEN
))
997 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1000 if (tlv
!= TLV_IS_ALIAS_ID
) {
1001 if (!TTEST2(*tptr
, 3))
1003 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1007 if (!TTEST2(*tptr
, 1))
1009 tslen
=*(tptr
++); /* read out subTLV length */
1010 proc_bytes
=NODE_ID_LEN
+3+1;
1011 printf(", %ssub-TLVs present",tslen
? "" : "no ");
1013 printf(" (%u)",tslen
);
1015 if (!TTEST2(*tptr
,2))
1019 /* prepend the ident string */
1020 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1021 if(!isis_print_is_reach_subtlv(tptr
,subt
,subl
,ident_buffer
))
1025 proc_bytes
+=(subl
+2);
1032 * this is the common Multi Topology ID decoder
1033 * it is called from various MT-TLVs (222,229,235,237)
1037 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1039 if (!TTEST2(*tptr
, 2))
1044 tok2str(isis_mt_values
,
1045 "Reserved for IETF Consensus",
1046 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1048 printf(" Topology (0x%03x), Flags: [%s]",
1049 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1050 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1056 * this is the common extended IP reach decoder
1057 * it is called from TLVs (135,235,236,237)
1058 * we process the TLV and optional subTLVs and return
1059 * the amount of processed bytes
1063 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1065 char ident_buffer
[20];
1066 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1067 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1069 if (!TTEST2(*tptr
, 4))
1071 metric
= EXTRACT_32BITS(tptr
);
1076 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1078 status_byte
=*(tptr
++);
1079 bit_length
= status_byte
&0x3f;
1082 } else if (afi
== IPV6
) {
1083 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1085 status_byte
=*(tptr
++);
1086 bit_length
=*(tptr
++);
1090 return (0); /* somebody is fooling us */
1092 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1094 if (!TTEST2(*tptr
, byte_length
))
1096 memset(prefix
, 0, 16); /* clear the copy buffer */
1097 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1099 processed
+=byte_length
;
1102 printf("%sIPv4 prefix: %15s/%u",
1104 ipaddr_string(prefix
),
1108 printf("%sIPv6 prefix: %s/%u",
1110 ip6addr_string(prefix
),
1114 printf(", Distribution: %s, Metric: %u",
1115 ISIS_MASK_TLV_EXT_IP_UPDOWN(status_byte
) ? "down" : "up",
1118 if (afi
== IPV4
&& ISIS_MASK_TLV_EXT_IP_SUBTLV(status_byte
))
1119 printf(", sub-TLVs present");
1123 ISIS_MASK_TLV_EXT_IP6_IE(status_byte
) ? "External" : "Internal",
1124 ISIS_MASK_TLV_EXT_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1127 if ((ISIS_MASK_TLV_EXT_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1128 (ISIS_MASK_TLV_EXT_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1129 /* assume that one prefix can hold more
1130 than one subTLV - therefore the first byte must reflect
1131 the aggregate bytecount of the subTLVs for this prefix
1133 if (!TTEST2(*tptr
, 1))
1136 processed
+=sublen
+1;
1137 printf(" (%u)",sublen
); /* print out subTLV length */
1140 if (!TTEST2(*tptr
,2))
1142 subtlvtype
=*(tptr
++);
1143 subtlvlen
=*(tptr
++);
1144 /* prepend the ident string */
1145 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1146 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1149 sublen
-=(subtlvlen
+2);
1157 * Decode IS-IS packets. Return 0 on error.
1160 static int isis_print (const u_int8_t
*p
, u_int length
)
1162 const struct isis_common_header
*header
;
1164 const struct isis_iih_lan_header
*header_iih_lan
;
1165 const struct isis_iih_ptp_header
*header_iih_ptp
;
1166 const struct isis_lsp_header
*header_lsp
;
1167 const struct isis_csnp_header
*header_csnp
;
1168 const struct isis_psnp_header
*header_psnp
;
1170 const struct isis_tlv_lsp
*tlv_lsp
;
1171 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1172 const struct isis_tlv_is_reach
*tlv_is_reach
;
1173 const struct isis_tlv_es_reach
*tlv_es_reach
;
1175 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1176 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1177 const u_int8_t
*optr
, *pptr
, *tptr
;
1178 u_short packet_len
,pdu_len
;
1182 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1183 need it for parsing the checksum TLV */
1184 header
= (const struct isis_common_header
*)p
;
1186 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1187 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1188 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1189 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1190 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1191 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1194 * Sanity checking of the header.
1197 if (header
->version
!= ISIS_VERSION
) {
1198 printf(", version %d packet not supported", header
->version
);
1202 if ((header
->id_length
!= SYSTEM_ID_LEN
) && (header
->id_length
!= 0)) {
1203 printf(", system ID length of %d is not supported",
1208 if (header
->pdu_version
!= ISIS_VERSION
) {
1209 printf(", version %d packet not supported", header
->pdu_version
);
1213 max_area
= header
->max_area
;
1216 max_area
= 3; /* silly shit */
1219 printf(", bad packet -- 255 areas");
1225 id_length
= header
->id_length
;
1228 id_length
= 6; /* silly shit again */
1230 case 1: /* 1-8 are valid sys-ID lenghts */
1240 id_length
= 0; /* entirely useless */
1246 /* toss any non 6-byte sys-ID len PDUs */
1247 if (id_length
!= 6 ) {
1248 printf(", bad packet -- illegal sys-ID length (%u)", id_length
);
1252 pdu_type
=header
->pdu_type
;
1254 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1256 printf(", IS-IS, %s",
1257 tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1263 printf(", source-id %s", isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1266 printf(", source-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1270 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1271 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1272 EXTRACT_32BITS(header_lsp
->sequence_number
),
1273 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1277 printf(", source-id %s", isis_print_id(header_csnp
->source_id
,SYSTEM_ID_LEN
));
1281 printf(", source-id %s", isis_print_id(header_psnp
->source_id
,SYSTEM_ID_LEN
));
1285 printf(", length %u", length
);
1290 /* ok they seem to want to know everything - lets fully decode it */
1291 printf(", IS-IS, length: %u",length
);
1293 printf("\n\thlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1296 header
->pdu_version
,
1302 /* first lets see if we know the PDU name*/
1303 printf(", pdu-type: %s",
1304 tok2str(isis_pdu_values
,
1309 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1310 return(0); /* for optionally debugging the common header */
1317 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1318 printf(", bogus fixed header length %u should be %lu",
1319 header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1323 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1324 if (packet_len
>pdu_len
) {
1325 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1329 TCHECK(*header_iih_lan
);
1330 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1331 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1332 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1333 tok2str(isis_iih_circuit_type_values
,
1334 "unknown circuit type 0x%02x",
1335 header_iih_lan
->circuit_type
));
1337 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1338 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1339 (header_iih_lan
->priority
) & PRIORITY_MASK
,
1343 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1347 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1348 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1352 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1353 printf(", bogus fixed header length %u should be %lu",
1354 header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1358 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1359 if (packet_len
>pdu_len
) {
1360 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1364 TCHECK(*header_iih_ptp
);
1365 printf("\n\t source-id: %s, holding time: %us, circuit-id: 0x%02x, %s, PDU length: %u",
1366 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1367 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1368 header_iih_ptp
->circuit_id
,
1369 tok2str(isis_iih_circuit_type_values
,
1370 "unknown circuit type 0x%02x",
1371 header_iih_ptp
->circuit_type
),
1375 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1379 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1380 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1385 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1386 printf(", bogus fixed header length %u should be %lu",
1387 header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1391 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1392 if (packet_len
>pdu_len
) {
1393 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1397 TCHECK(*header_lsp
);
1398 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us",
1399 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1400 EXTRACT_32BITS(header_lsp
->sequence_number
),
1401 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1402 /* verify the checksum -
1403 * checking starts at the lsp-id field
1404 * which is 12 bytes after the packet start*/
1405 printf("\n\t chksum: 0x%04x (%s), PDU length: %u",
1406 EXTRACT_16BITS(header_lsp
->checksum
),
1407 (osi_cksum(optr
+12, length
-12)) ? "incorrect" : "correct",
1410 printf(", %s", ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1412 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1413 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1414 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1415 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1416 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1417 printf("ATT bit set, ");
1419 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1420 printf("%s", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1423 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1427 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1428 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1433 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1434 printf(", bogus fixed header length %u should be %lu",
1435 header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1439 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1440 if (packet_len
>pdu_len
) {
1441 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1445 TCHECK(*header_csnp
);
1446 printf("\n\t source-id: %s, PDU length: %u",
1447 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
1449 printf("\n\t start lsp-id: %s",
1450 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
1451 printf("\n\t end lsp-id: %s",
1452 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
1455 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1459 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1460 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1465 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1466 printf("- bogus fixed header length %u should be %lu",
1467 header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1471 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1472 if (packet_len
>pdu_len
) {
1473 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1477 TCHECK(*header_psnp
);
1478 printf("\n\t source-id: %s",
1479 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
));
1482 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1486 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1487 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1491 if(!print_unknown_data(pptr
,"\n\t ",length
))
1497 * Now print the TLV's.
1500 while (packet_len
>= 2) {
1501 if (pptr
== snapend
) {
1505 if (!TTEST2(*pptr
, 2)) {
1506 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1507 (long)(pptr
-snapend
));
1512 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
1515 if (tlv_len
> packet_len
) {
1519 /* first lets see if we know the TLVs name*/
1520 printf("\n\t %s TLV #%u, length: %u",
1521 tok2str(isis_tlv_values
,
1527 /* now check if we have a decoder otherwise do a hexdump at the end*/
1530 if (!TTEST2(*tptr
, 1))
1533 while (tmp
&& alen
< tmp
) {
1534 printf("\n\t Area address (length: %u): %s",
1536 print_nsap(tptr
, alen
));
1539 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1541 if (!TTEST2(*tptr
, 1))
1547 while (tmp
>= ETHER_ADDR_LEN
) {
1548 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1550 printf("\n\t IS Neighbor: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
1551 tmp
-= ETHER_ADDR_LEN
;
1552 tptr
+= ETHER_ADDR_LEN
;
1556 case TLV_ISNEIGH_VARLEN
:
1557 if (!TTEST2(*tptr
, 1))
1559 lan_alen
= *tptr
++; /* LAN adress length */
1561 printf("\n\t LAN address length %u bytes ",lan_alen
);
1562 while (tmp
>= lan_alen
) {
1563 if (!TTEST2(*tptr
, lan_alen
))
1565 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
1574 case TLV_MT_IS_REACH
:
1575 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1576 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1577 if (mt_len
== 0) /* did something go wrong ? */
1582 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1583 if (ext_is_len
== 0) /* did something go wrong ? */
1591 case TLV_IS_ALIAS_ID
:
1592 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
1593 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1594 if (ext_is_len
== 0) /* did something go wrong ? */
1601 case TLV_EXT_IS_REACH
:
1602 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1603 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1604 if (ext_is_len
== 0) /* did something go wrong ? */
1611 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1614 tok2str(isis_is_reach_virtual_values
,
1615 "bogus virtual flag 0x%02x",
1617 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1618 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1619 if (!TTEST(*tlv_is_reach
))
1621 printf("\n\t IS Neighbor: %s",
1622 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
1623 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1624 tmp
-= sizeof(struct isis_tlv_is_reach
);
1630 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1631 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1632 if (!TTEST(*tlv_es_reach
))
1634 printf("\n\t ES Neighbor: %s",
1635 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1636 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1637 tmp
-= sizeof(struct isis_tlv_es_reach
);
1642 /* those two TLVs share the same format */
1644 case TLV_IP_REACH_EXT
:
1645 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
1649 case TLV_EXT_IP_REACH
:
1651 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1652 if (ext_ip_len
== 0) /* did something go wrong ? */
1659 case TLV_MT_IP_REACH
:
1661 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1662 if (mt_len
== 0) /* did something go wrong ? */
1667 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1668 if (ext_ip_len
== 0) /* did something go wrong ? */
1678 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1679 if (ext_ip_len
== 0) /* did something go wrong ? */
1686 case TLV_MT_IP6_REACH
:
1688 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1689 if (mt_len
== 0) /* did something go wrong ? */
1694 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1695 if (ext_ip_len
== 0) /* did something go wrong ? */
1704 if (!TTEST2(*tptr
, 16))
1707 printf("\n\t IPv6 interface address: %s",
1708 ip6addr_string(tptr
));
1716 if (!TTEST2(*tptr
, 1))
1720 tok2str(isis_subtlv_auth_values
,
1721 "unknown Authentication type 0x%02x",
1725 case SUBTLV_AUTH_SIMPLE
:
1726 for(i
=1;i
<tlv_len
;i
++) {
1727 if (!TTEST2(*(tptr
+i
), 1))
1729 printf("%c",*(tptr
+i
));
1732 case SUBTLV_AUTH_MD5
:
1733 for(i
=1;i
<tlv_len
;i
++) {
1734 if (!TTEST2(*(tptr
+i
), 1))
1736 printf("%02x",*(tptr
+i
));
1738 if (tlv_len
!= SUBTLV_AUTH_MD5_LEN
+1)
1739 printf(", (malformed subTLV) ");
1741 case SUBTLV_AUTH_PRIVATE
:
1743 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
1750 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
1752 if (!TTEST2(*tptr
, 1))
1754 printf("\n\t Adjacency State: %s",
1755 tok2str(isis_ptp_adjancey_values
, "0x%02x", *tptr
));
1758 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
1759 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
1760 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
1762 printf("\n\t Extended Local circuit ID: 0x%08x",
1763 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
1764 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
1766 if(tmp
>=SYSTEM_ID_LEN
) {
1767 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
1769 printf("\n\t Neighbor SystemID: %s",
1770 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
1773 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
1774 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
1775 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
1777 printf("\n\t Neighbor Extended Local circuit ID: 0x%08x",
1778 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
1783 printf("\n\t NLPID(s): ");
1785 if (!TTEST2(*(tptr
), 1))
1788 tok2str(osi_nlpid_values
,
1791 if (tmp
>1) /* further NPLIDs ? - put comma */
1797 case TLV_TE_ROUTER_ID
:
1798 if (!TTEST2(*pptr
, 4))
1800 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
1805 if (!TTEST2(*tptr
, 4))
1807 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1814 printf("\n\t Hostname: ");
1816 if (!TTEST2(*tptr
, 1))
1818 printf("%c",*tptr
++);
1823 case TLV_SHARED_RISK_GROUP
:
1824 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1826 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
1827 tptr
+=(NODE_ID_LEN
);
1830 if (!TTEST2(*tptr
, 1))
1832 printf(", %s", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
1835 if (!TTEST2(*tptr
,4))
1837 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1841 if (!TTEST2(*tptr
,4))
1843 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
1848 if (!TTEST2(*tptr
, 4))
1850 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
1857 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
1859 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
]))
1861 printf("\n\t lsp-id: %s",
1862 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
1863 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
1865 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
1866 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
1868 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
1869 if (!TTEST2(tlv_lsp
->checksum
, 2))
1871 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
1872 tmp
-=sizeof(struct isis_tlv_lsp
);
1878 if (!TTEST2(*tptr
, 2))
1880 printf("\n\t checksum: 0x%04x (%s)",
1881 EXTRACT_16BITS(tptr
),
1882 (osi_cksum(optr
, length
)) ? "incorrect" : "correct");
1885 case TLV_MT_SUPPORTED
:
1887 /* length can only be a multiple of 2, otherwise there is
1888 something broken -> so decode down until length is 1 */
1890 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1891 if (mt_len
== 0) /* did something go wrong ? */
1896 printf("\n\t malformed MT-ID");
1902 case TLV_RESTART_SIGNALING
:
1903 if (!TTEST2(*tptr
, 3))
1905 printf("\n\t Flags [%s], Remaining holding time %us",
1906 bittok2str(isis_restart_flag_values
, "none", *tptr
),
1907 EXTRACT_16BITS(tptr
+1));
1912 if (!TTEST2(*tptr
, 1))
1914 printf("\n\t Inter-Domain Information Type: %s",
1915 tok2str(isis_subtlv_idrp_values
,
1919 case SUBTLV_IDRP_ASN
:
1920 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
1922 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
1924 case SUBTLV_IDRP_LOCAL
:
1925 case SUBTLV_IDRP_RES
:
1927 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
1933 case TLV_LSP_BUFFERSIZE
:
1934 if (!TTEST2(*tptr
, 2))
1936 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
1940 while (tmp
>= SYSTEM_ID_LEN
) {
1941 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
1943 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
1944 tptr
+=SYSTEM_ID_LEN
;
1949 case TLV_PREFIX_NEIGH
:
1950 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
1952 printf("\n\t Metric Block");
1953 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
1954 tptr
+=sizeof(struct isis_metric_block
);
1955 tmp
-=sizeof(struct isis_metric_block
);
1958 if (!TTEST2(*tptr
, 1))
1960 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
1962 if (!TTEST2(*tptr
, prefix_len
/2))
1964 printf("\n\t\tAddress: %s/%u",
1965 print_nsap(tptr
,prefix_len
/2),
1973 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
1975 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
1978 case TLV_VENDOR_PRIVATE
:
1979 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
1981 printf("\n\t Vendor OUI Code: 0x%06x", EXTRACT_24BITS(tptr
) );
1984 if (tmp
> 0) /* hexdump the rest */
1985 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
1989 * FIXME those are the defined TLVs that lack a decoder
1990 * you are welcome to contribute code ;-)
1993 case TLV_DECNET_PHASE4
:
1994 case TLV_LUCENT_PRIVATE
:
1996 case TLV_NORTEL_PRIVATE1
:
1997 case TLV_NORTEL_PRIVATE2
:
2001 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
2006 /* do we want to see an additionally hexdump ? */
2008 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2013 packet_len
-= tlv_len
;
2016 if (packet_len
!= 0) {
2017 printf("\n\t %u straggler bytes", packet_len
);
2022 fputs("[|isis]", stdout
);
2026 printf("\n\t\t packet exceeded snapshot");
2031 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2035 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2037 int32_t c0
= 0, c1
= 0;
2039 while ((int)--len
>= 0) {