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
[] _U_
=
29 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.106.2.5 2004-03-24 01:45:26 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, rfc3567 */
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-05 */
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_INT_IP_REACH 128 /* rfc1195, rfc2966 */
118 #define TLV_PROTOCOLS 129 /* rfc1195 */
119 #define TLV_EXT_IP_REACH 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-05 */
124 #define TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
125 #define TLV_HOSTNAME 137 /* rfc2763 */
126 #define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
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_INT_IP_REACH
, "IPv4 Internal Reachability"},
159 { TLV_PROTOCOLS
, "Protocols supported"},
160 { TLV_EXT_IP_REACH
, "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_EXTD_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 /* draft-ietf-isis-traffic-05 */
185 #define SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
186 #define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
187 #define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
188 #define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
189 #define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
190 #define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
191 #define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
192 #define SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
193 #define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
194 #define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
196 static struct tok isis_ext_is_reach_subtlv_values
[] = {
197 { SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
198 { SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
199 { SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
200 { SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
201 { SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
202 { SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
203 { SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
204 { SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
205 { SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
206 { SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
207 { SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
208 { 250, "Reserved for cisco specific extensions" },
209 { 251, "Reserved for cisco specific extensions" },
210 { 252, "Reserved for cisco specific extensions" },
211 { 253, "Reserved for cisco specific extensions" },
212 { 254, "Reserved for cisco specific extensions" },
213 { 255, "Reserved for future expansion" },
217 #define SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1
218 #define SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2
220 static struct tok isis_ext_ip_reach_subtlv_values
[] = {
221 { SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
222 { SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
226 #define SUBTLV_AUTH_SIMPLE 1
227 #define SUBTLV_AUTH_MD5 54
228 #define SUBTLV_AUTH_MD5_LEN 16
229 #define SUBTLV_AUTH_PRIVATE 255
231 static struct tok isis_subtlv_auth_values
[] = {
232 { SUBTLV_AUTH_SIMPLE
, "simple text password"},
233 { SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
234 { SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
238 #define SUBTLV_IDRP_RES 0
239 #define SUBTLV_IDRP_LOCAL 1
240 #define SUBTLV_IDRP_ASN 2
242 static struct tok isis_subtlv_idrp_values
[] = {
243 { SUBTLV_IDRP_RES
, "Reserved"},
244 { SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
245 { SUBTLV_IDRP_ASN
, "AS Number Tag"},
249 #define ISIS_8BIT_MASK(x) ((x)&0xff)
251 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
252 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
253 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
254 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
255 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
256 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
257 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
258 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
260 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
261 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
263 static struct tok isis_mt_flag_values
[] = {
264 { 0x4000, "sub-TLVs present"},
265 { 0x8000, "ATT bit set"},
269 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
270 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
272 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
273 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
275 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
276 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
277 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
278 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
280 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
282 static struct tok isis_mt_values
[] = {
283 { 0, "IPv4 unicast"},
284 { 1, "In-Band Management"},
285 { 2, "IPv6 unicast"},
287 { 4095, "Development, Experimental or Proprietary"},
291 static struct tok isis_iih_circuit_type_values
[] = {
292 { 1, "Level 1 only"},
293 { 2, "Level 2 only"},
294 { 3, "Level 1, Level 2"},
298 #define ISIS_LSP_TYPE_UNUSED0 0
299 #define ISIS_LSP_TYPE_LEVEL_1 1
300 #define ISIS_LSP_TYPE_UNUSED2 2
301 #define ISIS_LSP_TYPE_LEVEL_2 3
303 static struct tok isis_lsp_istype_values
[] = {
304 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
305 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
306 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
307 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
311 static struct tok osi_nlpid_values
[] = {
312 { NLPID_CLNS
, "CLNS"},
314 { NLPID_IP6
, "IPv6"},
319 * Katz's point to point adjacency TLV uses codes to tell us the state of
320 * the remote adjacency. Enumerate them.
323 #define ISIS_PTP_ADJ_UP 0
324 #define ISIS_PTP_ADJ_INIT 1
325 #define ISIS_PTP_ADJ_DOWN 2
328 static struct tok isis_ptp_adjancey_values
[] = {
329 { ISIS_PTP_ADJ_UP
, "Up" },
330 { ISIS_PTP_ADJ_INIT
, "Initializing" },
331 { ISIS_PTP_ADJ_DOWN
, "Down" },
335 struct isis_tlv_ptp_adj
{
336 u_int8_t adjacency_state
;
337 u_int8_t extd_local_circuit_id
[4];
338 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
339 u_int8_t neighbor_extd_local_circuit_id
[4];
342 static int osi_cksum(const u_int8_t
*, u_int
);
343 static void esis_print(const u_int8_t
*, u_int
);
344 static int isis_print(const u_int8_t
*, u_int
);
346 struct isis_metric_block
{
347 u_int8_t metric_default
;
348 u_int8_t metric_delay
;
349 u_int8_t metric_expense
;
350 u_int8_t metric_error
;
353 struct isis_tlv_is_reach
{
354 struct isis_metric_block isis_metric_block
;
355 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
358 struct isis_tlv_es_reach
{
359 struct isis_metric_block isis_metric_block
;
360 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
363 struct isis_tlv_ip_reach
{
364 struct isis_metric_block isis_metric_block
;
369 static struct tok isis_is_reach_virtual_values
[] = {
370 { 0, "IsNotVirtual"},
375 static struct tok isis_restart_flag_values
[] = {
376 { 0x1, "Restart Request"},
377 { 0x2, "Restart Acknowledgement"},
381 struct isis_common_header
{
384 u_int8_t version
; /* Protocol version */
386 u_int8_t pdu_type
; /* 3 MSbits are reserved */
387 u_int8_t pdu_version
; /* Packet format version */
392 struct isis_iih_lan_header
{
393 u_int8_t circuit_type
;
394 u_int8_t source_id
[SYSTEM_ID_LEN
];
395 u_int8_t holding_time
[2];
398 u_int8_t lan_id
[NODE_ID_LEN
];
401 struct isis_iih_ptp_header
{
402 u_int8_t circuit_type
;
403 u_int8_t source_id
[SYSTEM_ID_LEN
];
404 u_int8_t holding_time
[2];
409 struct isis_lsp_header
{
411 u_int8_t remaining_lifetime
[2];
412 u_int8_t lsp_id
[LSP_ID_LEN
];
413 u_int8_t sequence_number
[4];
414 u_int8_t checksum
[2];
418 struct isis_csnp_header
{
420 u_int8_t source_id
[NODE_ID_LEN
];
421 u_int8_t start_lsp_id
[LSP_ID_LEN
];
422 u_int8_t end_lsp_id
[LSP_ID_LEN
];
425 struct isis_psnp_header
{
427 u_int8_t source_id
[NODE_ID_LEN
];
430 struct isis_tlv_lsp
{
431 u_int8_t remaining_lifetime
[2];
432 u_int8_t lsp_id
[LSP_ID_LEN
];
433 u_int8_t sequence_number
[4];
434 u_int8_t checksum
[2];
438 print_nsap(register const u_int8_t
*pptr
, register int nsap_length
)
441 static char nsap_ascii_output
[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")];
442 char *junk_buf
= nsap_ascii_output
;
444 if (nsap_length
< 1 || nsap_length
> 20) {
445 snprintf(nsap_ascii_output
, sizeof(nsap_ascii_output
),
447 return (nsap_ascii_output
);
450 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
451 if (!TTEST2(*pptr
, 1))
454 sizeof(nsap_ascii_output
) - (junk_buf
- nsap_ascii_output
),
456 junk_buf
+= strlen(junk_buf
);
457 if (((nsap_idx
& 1) == 0) &&
458 (nsap_idx
+ 1 < nsap_length
)) {
463 return (nsap_ascii_output
);
466 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
467 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
468 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
469 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
470 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
471 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
473 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
475 const struct isis_common_header
*header
;
477 header
= (const struct isis_common_header
*)p
;
479 printf("%sOSI", caplen
< 1 ? "|" : "");
481 if (caplen
< 1) /* enough bytes on the wire ? */
487 (void)printf(", CLNS, length %u", length
);
491 esis_print(p
, length
);
495 if (!isis_print(p
, length
))
496 print_unknown_data(p
,"\n\t",caplen
);
500 (void)printf(", ISO NULLNS, length: %u", length
);
504 (void)printf(", Unknown NLPID 0x%02x, length: %u", p
[0], length
);
506 print_unknown_data(p
,"\n\t",caplen
);
511 #define ESIS_REDIRECT 6
515 static struct tok esis_values
[] = {
516 { ESIS_REDIRECT
, "redirect"},
531 esis_print(const u_int8_t
*p
, u_int length
)
535 const struct esis_hdr
*eh
;
541 printf(" no header at all!");
545 eh
= (const struct esis_hdr
*) &p
[2];
551 printf(" LI(%d) > PDU size (%d)!", li
, length
);
554 if (li
< sizeof(struct esis_hdr
) + 2) {
558 printf(" too short for esis header %d:", li
);
559 while (--length
!= 0)
560 printf("%02X", *p
++);
565 printf(", ES-IS, %s, length %u",
566 tok2str(esis_values
,"unknown type: %u",eh
->type
& 0x1f),
572 if (vflag
&& osi_cksum(p
, li
)) {
573 printf(" bad cksum (got 0x%02x%02x)",
574 eh
->cksum
[1], eh
->cksum
[0]);
575 default_print(p
, length
);
578 if (eh
->version
!= 1) {
579 printf(" unsupported version %d", eh
->version
);
582 p
+= sizeof(*eh
) + 2;
583 li
-= sizeof(*eh
) + 2; /* protoid * li */
585 switch (eh
->type
& 0x1f) {
586 case ESIS_REDIRECT
: {
587 const u_int8_t
*dst
, *snpa
, *is
;
589 dst
= p
; p
+= *p
+ 1;
592 printf("\n\t\t %s", isonsap_string(dst
));
593 snpa
= p
; p
+= *p
+ 1;
602 printf(" > %s", etheraddr_string(&snpa
[1]));
604 printf(" > %s", isonsap_string(is
));
623 printf("\n\tNET: %s", print_nsap(is
+1,*is
));
631 print_unknown_data(p
,"\n\t ",snapend
-p
);
636 /* hexdump - FIXME ? */
639 print_unknown_data(p
,"\n\t ",snapend
-p
);
642 while (p
< ep
&& li
) {
649 printf(", bad opts/li");
656 printf(", opt (%d) too long", op
);
666 if (op
== TLV_HOLDTIME
&& opli
== 2) {
667 printf("\n\tholdtime: %us", EXTRACT_16BITS(q
));
671 if (op
== TLV_PROTOCOLS
&& opli
>= 1) {
672 printf("\n\t%s (length: %u): %s",
673 tok2str(isis_tlv_values
, "unknown", op
),
675 tok2str(osi_nlpid_values
,"Unknown 0x%02x",*q
));
679 print_unknown_data(q
,"\n\t ",opli
);
683 /* shared routine for printing system, node and lsp-ids */
685 isis_print_id(const u_int8_t
*cp
, int id_len
)
688 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
691 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
692 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
694 if (i
== 2 || i
== 4)
697 if (id_len
>= NODE_ID_LEN
) {
698 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
701 if (id_len
== LSP_ID_LEN
)
702 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
706 /* print the 4-byte metric block which is common found in the old-style TLVs */
708 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
710 printf(", Default Metric: %d, %s",
711 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
712 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
713 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
714 printf("\n\t\t Delay Metric: %d, %s",
715 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
716 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
717 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
718 printf("\n\t\t Expense Metric: %d, %s",
719 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
720 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
721 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
722 printf("\n\t\t Error Metric: %d, %s",
723 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
724 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
726 return(1); /* everything is ok */
730 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
733 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
735 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
738 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
739 printf("short IPv4 Reachability (%d vs %lu)",
741 (unsigned long)sizeof(*tlv_ip_reach
));
745 if (!TTEST(*tlv_ip_reach
))
748 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
750 if (prefix_len
== -1)
751 printf("%sIPv4 prefix: %s mask %s",
753 ipaddr_string((tlv_ip_reach
->prefix
)),
754 ipaddr_string((tlv_ip_reach
->mask
)));
756 printf("%sIPv4 prefix: %15s/%u",
758 ipaddr_string((tlv_ip_reach
->prefix
)),
761 printf(", Distribution: %s, Metric: %u, %s",
762 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
763 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
764 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
766 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
767 printf("%s Delay Metric: %u, %s",
769 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
770 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
772 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
773 printf("%s Expense Metric: %u, %s",
775 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
776 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
778 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
779 printf("%s Error Metric: %u, %s",
781 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
782 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
784 length
-= sizeof(struct isis_tlv_ip_reach
);
791 * this is the common IP-REACH subTLV decoder it is called
792 * from various EXTD-IP REACH TLVs (135,235,236,237)
796 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
798 /* first lets see if we know the subTLVs name*/
799 printf("%s%s subTLV #%u, length: %u",
801 tok2str(isis_ext_ip_reach_subtlv_values
,
807 if (!TTEST2(*tptr
,subl
))
811 case SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
813 printf(", 0x%08x (=%u)",
814 EXTRACT_32BITS(tptr
),
815 EXTRACT_32BITS(tptr
));
820 case SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
822 printf(", 0x%08x%08x",
823 EXTRACT_32BITS(tptr
),
824 EXTRACT_32BITS(tptr
+4));
830 if(!print_unknown_data(tptr
,"\n\t\t ",
838 printf("%spacket exceeded snapshot",ident
);
843 * this is the common IS-REACH subTLV decoder it is called
844 * from isis_print_ext_is_reach()
848 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
851 union { /* int to float conversion buffer for several subTLVs */
856 /* first lets see if we know the subTLVs name*/
857 printf("%s%s subTLV #%u, length: %u",
859 tok2str(isis_ext_is_reach_subtlv_values
,
865 if (!TTEST2(*tptr
,subl
))
869 case SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
870 case SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
871 case SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
873 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
874 if (subl
== 8) /* draft-ietf-isis-gmpls-extensions */
875 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
878 case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
879 case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
881 printf(", %s", ipaddr_string(tptr
));
883 case SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
884 case SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
886 bw
.i
= EXTRACT_32BITS(tptr
);
887 printf(", %.3f Mbps", bw
.f
*8/1000000 );
890 case SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
892 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
893 bw
.i
= EXTRACT_32BITS(tptr
);
894 printf("%s priority level %d: %.3f Mbps",
902 case SUBTLV_EXT_IS_REACH_TE_METRIC
:
904 printf(", %u", EXTRACT_24BITS(tptr
));
906 case SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
908 printf(", %s, Priority %u",
909 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
913 case SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
915 printf("%s Interface Switching Capability:%s",
917 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
918 printf(", LSP Encoding: %s",
919 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
921 printf("%s Max LSP Bandwidth:",ident
);
922 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
923 bw
.i
= EXTRACT_32BITS(tptr
);
924 printf("%s priority level %d: %.3f Mbps",
931 /* there is some optional stuff left to decode but this is as of yet
932 not specified so just lets hexdump what is left */
934 if(!print_unknown_data(tptr
,"\n\t\t ",
941 if(!print_unknown_data(tptr
,"\n\t\t ",
949 printf("%spacket exceeded snapshot",ident
);
955 * this is the common IS-REACH decoder it is called
956 * from various EXTD-IS REACH style TLVs (22,24,222)
960 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
962 char ident_buffer
[20];
963 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
964 int proc_bytes
= 0; /* how many bytes did we process ? */
966 if (!TTEST2(*tptr
, NODE_ID_LEN
))
969 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
972 if (tlv_type
!= TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
973 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
975 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
979 if (!TTEST2(*tptr
, 1))
981 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
982 proc_bytes
=NODE_ID_LEN
+3+1;
983 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
984 if (subtlv_sum_len
) {
985 printf(" (%u)",subtlv_sum_len
);
986 while (subtlv_sum_len
>0) {
987 if (!TTEST2(*tptr
,2))
989 subtlv_type
=*(tptr
++);
990 subtlv_len
=*(tptr
++);
991 /* prepend the ident string */
992 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
993 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
996 subtlv_sum_len
-=(subtlv_len
+2);
997 proc_bytes
+=(subtlv_len
+2);
1004 * this is the common Multi Topology ID decoder
1005 * it is called from various MT-TLVs (222,229,235,237)
1009 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1011 if (!TTEST2(*tptr
, 2))
1016 tok2str(isis_mt_values
,
1017 "Reserved for IETF Consensus",
1018 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1020 printf(" Topology (0x%03x), Flags: [%s]",
1021 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1022 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1028 * this is the common extended IP reach decoder
1029 * it is called from TLVs (135,235,236,237)
1030 * we process the TLV and optional subTLVs and return
1031 * the amount of processed bytes
1035 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1037 char ident_buffer
[20];
1038 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1039 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1041 if (!TTEST2(*tptr
, 4))
1043 metric
= EXTRACT_32BITS(tptr
);
1048 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1050 status_byte
=*(tptr
++);
1051 bit_length
= status_byte
&0x3f;
1054 } else if (afi
== IPV6
) {
1055 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1057 status_byte
=*(tptr
++);
1058 bit_length
=*(tptr
++);
1062 return (0); /* somebody is fooling us */
1064 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1066 if (!TTEST2(*tptr
, byte_length
))
1068 memset(prefix
, 0, 16); /* clear the copy buffer */
1069 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1071 processed
+=byte_length
;
1074 printf("%sIPv4 prefix: %15s/%u",
1076 ipaddr_string(prefix
),
1080 printf("%sIPv6 prefix: %s/%u",
1082 ip6addr_string(prefix
),
1086 printf(", Distribution: %s, Metric: %u",
1087 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
1090 if (afi
== IPV4
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
1091 printf(", sub-TLVs present");
1095 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
1096 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1099 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1100 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1101 /* assume that one prefix can hold more
1102 than one subTLV - therefore the first byte must reflect
1103 the aggregate bytecount of the subTLVs for this prefix
1105 if (!TTEST2(*tptr
, 1))
1108 processed
+=sublen
+1;
1109 printf(" (%u)",sublen
); /* print out subTLV length */
1112 if (!TTEST2(*tptr
,2))
1114 subtlvtype
=*(tptr
++);
1115 subtlvlen
=*(tptr
++);
1116 /* prepend the ident string */
1117 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1118 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1121 sublen
-=(subtlvlen
+2);
1129 * Decode IS-IS packets. Return 0 on error.
1132 static int isis_print (const u_int8_t
*p
, u_int length
)
1134 const struct isis_common_header
*header
;
1136 const struct isis_iih_lan_header
*header_iih_lan
;
1137 const struct isis_iih_ptp_header
*header_iih_ptp
;
1138 const struct isis_lsp_header
*header_lsp
;
1139 const struct isis_csnp_header
*header_csnp
;
1140 const struct isis_psnp_header
*header_psnp
;
1142 const struct isis_tlv_lsp
*tlv_lsp
;
1143 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1144 const struct isis_tlv_is_reach
*tlv_is_reach
;
1145 const struct isis_tlv_es_reach
*tlv_es_reach
;
1147 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1148 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1149 const u_int8_t
*optr
, *pptr
, *tptr
;
1150 u_short packet_len
,pdu_len
;
1154 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1155 need it for parsing the checksum TLV */
1156 header
= (const struct isis_common_header
*)p
;
1158 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1159 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1160 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1161 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1162 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1163 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1166 * Sanity checking of the header.
1169 if (header
->version
!= ISIS_VERSION
) {
1170 printf(", version %d packet not supported", header
->version
);
1174 if ((header
->id_length
!= SYSTEM_ID_LEN
) && (header
->id_length
!= 0)) {
1175 printf(", system ID length of %d is not supported",
1180 if (header
->pdu_version
!= ISIS_VERSION
) {
1181 printf(", version %d packet not supported", header
->pdu_version
);
1185 max_area
= header
->max_area
;
1188 max_area
= 3; /* silly shit */
1191 printf(", bad packet -- 255 areas");
1197 id_length
= header
->id_length
;
1200 id_length
= 6; /* silly shit again */
1202 case 1: /* 1-8 are valid sys-ID lenghts */
1212 id_length
= 0; /* entirely useless */
1218 /* toss any non 6-byte sys-ID len PDUs */
1219 if (id_length
!= 6 ) {
1220 printf(", bad packet -- illegal sys-ID length (%u)", id_length
);
1224 pdu_type
=header
->pdu_type
;
1226 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1228 printf(", IS-IS, %s",
1229 tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1235 printf(", src-id %s",
1236 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1237 printf(", lan-id %s, prio %u",
1238 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
1239 header_iih_lan
->priority
);
1242 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1246 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1247 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1248 EXTRACT_32BITS(header_lsp
->sequence_number
),
1249 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1253 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,SYSTEM_ID_LEN
));
1257 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,SYSTEM_ID_LEN
));
1261 printf(", length %u", length
);
1266 /* ok they seem to want to know everything - lets fully decode it */
1267 printf(", IS-IS, length: %u",length
);
1269 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1270 tok2str(isis_pdu_values
,
1275 header
->pdu_version
,
1282 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1283 return(0); /* for optionally debugging the common header */
1290 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1291 printf(", bogus fixed header length %u should be %lu",
1292 header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1296 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1297 if (packet_len
>pdu_len
) {
1298 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1302 TCHECK(*header_iih_lan
);
1303 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1304 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1305 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1306 tok2str(isis_iih_circuit_type_values
,
1307 "unknown circuit type 0x%02x",
1308 header_iih_lan
->circuit_type
));
1310 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1311 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1312 (header_iih_lan
->priority
) & PRIORITY_MASK
,
1316 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1320 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1321 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1325 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1326 printf(", bogus fixed header length %u should be %lu",
1327 header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1331 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1332 if (packet_len
>pdu_len
) {
1333 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1337 TCHECK(*header_iih_ptp
);
1338 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1339 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1340 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1341 tok2str(isis_iih_circuit_type_values
,
1342 "unknown circuit type 0x%02x",
1343 header_iih_ptp
->circuit_type
));
1345 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1346 header_iih_ptp
->circuit_id
,
1350 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1354 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1355 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1360 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1361 printf(", bogus fixed header length %u should be %lu",
1362 header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1366 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1367 if (packet_len
>pdu_len
) {
1368 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1372 TCHECK(*header_lsp
);
1373 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1374 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1375 EXTRACT_32BITS(header_lsp
->sequence_number
),
1376 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
1377 EXTRACT_16BITS(header_lsp
->checksum
));
1379 /* if this is a purge do not attempt to verify the checksum */
1380 if ( EXTRACT_16BITS(header_lsp
->remaining_lifetime
) == 0 &&
1381 EXTRACT_16BITS(header_lsp
->checksum
) == 0)
1382 printf(" (purged)");
1384 /* verify the checksum -
1385 * checking starts at the lsp-id field at byte position [12]
1386 * hence the length needs to be reduced by 12 bytes */
1387 printf(" (%s)", (osi_cksum((u_int8_t
*)header_lsp
->lsp_id
, length
-12)) ? "incorrect" : "correct");
1389 printf(", PDU length: %u, Flags: [ %s",
1391 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1393 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1394 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1395 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1396 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1397 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1398 printf("ATT bit set, ");
1400 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1401 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1404 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1408 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1409 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1414 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1415 printf(", bogus fixed header length %u should be %lu",
1416 header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1420 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1421 if (packet_len
>pdu_len
) {
1422 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1426 TCHECK(*header_csnp
);
1427 printf("\n\t source-id: %s, PDU length: %u",
1428 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
1430 printf("\n\t start lsp-id: %s",
1431 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
1432 printf("\n\t end lsp-id: %s",
1433 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
1436 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1440 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1441 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1446 if (header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1447 printf("- bogus fixed header length %u should be %lu",
1448 header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1452 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1453 if (packet_len
>pdu_len
) {
1454 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1458 TCHECK(*header_psnp
);
1459 printf("\n\t source-id: %s, PDU length: %u",
1460 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
1464 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1468 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1469 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1473 if(!print_unknown_data(pptr
,"\n\t ",length
))
1479 * Now print the TLV's.
1482 while (packet_len
>= 2) {
1483 if (pptr
== snapend
) {
1487 if (!TTEST2(*pptr
, 2)) {
1488 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1489 (long)(pptr
-snapend
));
1494 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
1497 if (tlv_len
> packet_len
) {
1501 /* first lets see if we know the TLVs name*/
1502 printf("\n\t %s TLV #%u, length: %u",
1503 tok2str(isis_tlv_values
,
1509 /* now check if we have a decoder otherwise do a hexdump at the end*/
1512 if (!TTEST2(*tptr
, 1))
1515 while (tmp
&& alen
< tmp
) {
1516 printf("\n\t Area address (length: %u): %s",
1518 print_nsap(tptr
, alen
));
1521 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1523 if (!TTEST2(*tptr
, 1))
1529 while (tmp
>= ETHER_ADDR_LEN
) {
1530 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1532 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
1533 tmp
-= ETHER_ADDR_LEN
;
1534 tptr
+= ETHER_ADDR_LEN
;
1538 case TLV_ISNEIGH_VARLEN
:
1539 if (!TTEST2(*tptr
, 1))
1541 lan_alen
= *tptr
++; /* LAN adress length */
1543 printf("\n\t LAN address length %u bytes ",lan_alen
);
1544 while (tmp
>= lan_alen
) {
1545 if (!TTEST2(*tptr
, lan_alen
))
1547 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
1556 case TLV_MT_IS_REACH
:
1557 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1558 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1559 if (mt_len
== 0) /* did something go wrong ? */
1564 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1565 if (ext_is_len
== 0) /* did something go wrong ? */
1573 case TLV_IS_ALIAS_ID
:
1574 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
1575 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1576 if (ext_is_len
== 0) /* did something go wrong ? */
1583 case TLV_EXT_IS_REACH
:
1584 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1585 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1586 if (ext_is_len
== 0) /* did something go wrong ? */
1593 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1596 tok2str(isis_is_reach_virtual_values
,
1597 "bogus virtual flag 0x%02x",
1599 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1600 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1601 if (!TTEST(*tlv_is_reach
))
1603 printf("\n\t IS Neighbor: %s",
1604 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
1605 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1606 tmp
-= sizeof(struct isis_tlv_is_reach
);
1612 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1613 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1614 if (!TTEST(*tlv_es_reach
))
1616 printf("\n\t ES Neighbor: %s",
1617 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1618 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1619 tmp
-= sizeof(struct isis_tlv_es_reach
);
1624 /* those two TLVs share the same format */
1625 case TLV_INT_IP_REACH
:
1626 case TLV_EXT_IP_REACH
:
1627 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
1631 case TLV_EXTD_IP_REACH
:
1633 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1634 if (ext_ip_len
== 0) /* did something go wrong ? */
1641 case TLV_MT_IP_REACH
:
1643 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1644 if (mt_len
== 0) /* did something go wrong ? */
1649 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1650 if (ext_ip_len
== 0) /* did something go wrong ? */
1660 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1661 if (ext_ip_len
== 0) /* did something go wrong ? */
1668 case TLV_MT_IP6_REACH
:
1670 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1671 if (mt_len
== 0) /* did something go wrong ? */
1676 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1677 if (ext_ip_len
== 0) /* did something go wrong ? */
1686 if (!TTEST2(*tptr
, 16))
1689 printf("\n\t IPv6 interface address: %s",
1690 ip6addr_string(tptr
));
1698 if (!TTEST2(*tptr
, 1))
1702 tok2str(isis_subtlv_auth_values
,
1703 "unknown Authentication type 0x%02x",
1707 case SUBTLV_AUTH_SIMPLE
:
1708 for(i
=1;i
<tlv_len
;i
++) {
1709 if (!TTEST2(*(tptr
+i
), 1))
1711 printf("%c",*(tptr
+i
));
1714 case SUBTLV_AUTH_MD5
:
1715 for(i
=1;i
<tlv_len
;i
++) {
1716 if (!TTEST2(*(tptr
+i
), 1))
1718 printf("%02x",*(tptr
+i
));
1720 if (tlv_len
!= SUBTLV_AUTH_MD5_LEN
+1)
1721 printf(", (malformed subTLV) ");
1723 case SUBTLV_AUTH_PRIVATE
:
1725 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
1732 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
1734 if (!TTEST2(*tptr
, 1))
1736 printf("\n\t Adjacency State: %s (%u)",
1737 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
1741 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
1742 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
1743 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
1745 printf("\n\t Extended Local circuit-ID: 0x%08x",
1746 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
1747 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
1749 if(tmp
>=SYSTEM_ID_LEN
) {
1750 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
1752 printf("\n\t Neighbor System-ID: %s",
1753 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
1756 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
1757 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
1758 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
1760 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
1761 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
1766 printf("\n\t NLPID(s): ");
1768 if (!TTEST2(*(tptr
), 1))
1770 printf("%s (0x%02x)",
1771 tok2str(osi_nlpid_values
,
1775 if (tmp
>1) /* further NPLIDs ? - put comma */
1782 case TLV_TE_ROUTER_ID
:
1783 if (!TTEST2(*pptr
, 4))
1785 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
1790 if (!TTEST2(*tptr
, 4))
1792 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1799 printf("\n\t Hostname: ");
1801 if (!TTEST2(*tptr
, 1))
1803 printf("%c",*tptr
++);
1808 case TLV_SHARED_RISK_GROUP
:
1809 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1811 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
1812 tptr
+=(NODE_ID_LEN
);
1815 if (!TTEST2(*tptr
, 1))
1817 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
1820 if (!TTEST2(*tptr
,4))
1822 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1826 if (!TTEST2(*tptr
,4))
1828 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
1833 if (!TTEST2(*tptr
, 4))
1835 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
1842 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
1844 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
1846 printf("\n\t lsp-id: %s",
1847 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
1848 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
1850 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
1851 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
1853 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
1854 if (!TTEST2(tlv_lsp
->checksum
, 2))
1856 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
1857 tmp
-=sizeof(struct isis_tlv_lsp
);
1863 if (!TTEST2(*tptr
, 2))
1865 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
1866 /* do not attempt to verify the checksum if it is zero
1867 * most likely a HMAC-MD5 TLV is also present and
1868 * to avoid conflicts the checksum TLV is zeroed.
1869 * see rfc3358 for details
1871 if (EXTRACT_16BITS(tptr
) == 0)
1872 printf("(unverified)");
1873 else printf("(%s)", osi_cksum(optr
, length
) ? "incorrect" : "correct");
1876 case TLV_MT_SUPPORTED
:
1878 /* length can only be a multiple of 2, otherwise there is
1879 something broken -> so decode down until length is 1 */
1881 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1882 if (mt_len
== 0) /* did something go wrong ? */
1887 printf("\n\t malformed MT-ID");
1893 case TLV_RESTART_SIGNALING
:
1894 if (!TTEST2(*tptr
, 3))
1896 printf("\n\t Flags [%s], Remaining holding time %us",
1897 bittok2str(isis_restart_flag_values
, "none", *tptr
),
1898 EXTRACT_16BITS(tptr
+1));
1903 if (!TTEST2(*tptr
, 1))
1905 printf("\n\t Inter-Domain Information Type: %s",
1906 tok2str(isis_subtlv_idrp_values
,
1910 case SUBTLV_IDRP_ASN
:
1911 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
1913 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
1915 case SUBTLV_IDRP_LOCAL
:
1916 case SUBTLV_IDRP_RES
:
1918 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
1924 case TLV_LSP_BUFFERSIZE
:
1925 if (!TTEST2(*tptr
, 2))
1927 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
1931 while (tmp
>= SYSTEM_ID_LEN
) {
1932 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
1934 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
1935 tptr
+=SYSTEM_ID_LEN
;
1940 case TLV_PREFIX_NEIGH
:
1941 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
1943 printf("\n\t Metric Block");
1944 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
1945 tptr
+=sizeof(struct isis_metric_block
);
1946 tmp
-=sizeof(struct isis_metric_block
);
1949 if (!TTEST2(*tptr
, 1))
1951 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
1953 if (!TTEST2(*tptr
, prefix_len
/2))
1955 printf("\n\t\tAddress: %s/%u",
1956 print_nsap(tptr
,prefix_len
/2),
1964 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
1966 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
1969 case TLV_VENDOR_PRIVATE
:
1970 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
1972 printf("\n\t Vendor OUI Code: 0x%06x", EXTRACT_24BITS(tptr
) );
1975 if (tmp
> 0) /* hexdump the rest */
1976 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
1980 * FIXME those are the defined TLVs that lack a decoder
1981 * you are welcome to contribute code ;-)
1984 case TLV_DECNET_PHASE4
:
1985 case TLV_LUCENT_PRIVATE
:
1987 case TLV_NORTEL_PRIVATE1
:
1988 case TLV_NORTEL_PRIVATE2
:
1992 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
1997 /* do we want to see an additionally hexdump ? */
1999 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2004 packet_len
-= tlv_len
;
2007 if (packet_len
!= 0) {
2008 printf("\n\t %u straggler bytes", packet_len
);
2013 fputs("[|isis]", stdout
);
2017 printf("\n\t\t packet exceeded snapshot");
2022 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2026 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2028 int32_t c0
= 0, c1
= 0;
2030 while ((int)--len
>= 0) {