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 & CLNP support.
28 static const char rcsid
[] _U_
=
29 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.155 2006-02-21 10:27:40 hannes Exp $ (LBL)";
36 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
43 #include "ethertype.h"
51 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
54 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
55 #define NODE_ID_LEN SYSTEM_ID_LEN+1
56 #define LSP_ID_LEN SYSTEM_ID_LEN+2
58 #define ISIS_VERSION 1
59 #define ESIS_VERSION 1
60 #define CLNP_VERSION 1
62 #define ISIS_PDU_TYPE_MASK 0x1F
63 #define ESIS_PDU_TYPE_MASK 0x1F
64 #define CLNP_PDU_TYPE_MASK 0x1F
65 #define CLNP_FLAG_MASK 0xE0
66 #define ISIS_LAN_PRIORITY_MASK 0x7F
68 #define ISIS_PDU_L1_LAN_IIH 15
69 #define ISIS_PDU_L2_LAN_IIH 16
70 #define ISIS_PDU_PTP_IIH 17
71 #define ISIS_PDU_L1_LSP 18
72 #define ISIS_PDU_L2_LSP 20
73 #define ISIS_PDU_L1_CSNP 24
74 #define ISIS_PDU_L2_CSNP 25
75 #define ISIS_PDU_L1_PSNP 26
76 #define ISIS_PDU_L2_PSNP 27
78 static struct tok isis_pdu_values
[] = {
79 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
80 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
81 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
82 { ISIS_PDU_L1_LSP
, "L1 LSP"},
83 { ISIS_PDU_L2_LSP
, "L2 LSP"},
84 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
85 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
86 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
87 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
92 * A TLV is a tuple of a type, length and a value and is normally used for
93 * encoding information in all sorts of places. This is an enumeration of
94 * the well known types.
96 * list taken from rfc3359 plus some memory from veterans ;-)
99 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
100 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
101 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
102 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
103 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
104 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
105 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
106 #define ISIS_TLV_PADDING 8 /* iso10589 */
107 #define ISIS_TLV_LSP 9 /* iso10589 */
108 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
109 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
110 #define ISIS_TLV_CHECKSUM_MINLEN 2
111 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
112 #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
113 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
114 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
115 #define ISIS_TLV_DECNET_PHASE4 42
116 #define ISIS_TLV_LUCENT_PRIVATE 66
117 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
118 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
119 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
120 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
121 #define ISIS_TLV_IDRP_INFO_MINLEN 1
122 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
123 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
124 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
125 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
126 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
127 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
128 #define ISIS_TLV_NORTEL_PRIVATE1 176
129 #define ISIS_TLV_NORTEL_PRIVATE2 177
130 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
131 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
132 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
133 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
134 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
135 #define ISIS_TLV_MT_SUPPORTED_MINLEN 2
136 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
137 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
138 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
139 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
140 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
141 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
142 #define ISIS_TLV_IIH_SEQNR_MINLEN 4
143 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
144 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
146 static struct tok isis_tlv_values
[] = {
147 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
148 { ISIS_TLV_IS_REACH
, "IS Reachability"},
149 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
150 { ISIS_TLV_PART_DIS
, "Partition DIS"},
151 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
152 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
153 { ISIS_TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
154 { ISIS_TLV_PADDING
, "Padding"},
155 { ISIS_TLV_LSP
, "LSP entries"},
156 { ISIS_TLV_AUTH
, "Authentication"},
157 { ISIS_TLV_CHECKSUM
, "Checksum"},
158 { ISIS_TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
159 { ISIS_TLV_EXT_IS_REACH
, "Extended IS Reachability"},
160 { ISIS_TLV_IS_ALIAS_ID
, "IS Alias ID"},
161 { ISIS_TLV_DECNET_PHASE4
, "DECnet Phase IV"},
162 { ISIS_TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
163 { ISIS_TLV_INT_IP_REACH
, "IPv4 Internal Reachability"},
164 { ISIS_TLV_PROTOCOLS
, "Protocols supported"},
165 { ISIS_TLV_EXT_IP_REACH
, "IPv4 External Reachability"},
166 { ISIS_TLV_IDRP_INFO
, "Inter-Domain Information Type"},
167 { ISIS_TLV_IPADDR
, "IPv4 Interface address(es)"},
168 { ISIS_TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
169 { ISIS_TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
170 { ISIS_TLV_EXTD_IP_REACH
, "Extended IPv4 Reachability"},
171 { ISIS_TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
172 { ISIS_TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
173 { ISIS_TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
174 { ISIS_TLV_HOSTNAME
, "Hostname"},
175 { ISIS_TLV_RESTART_SIGNALING
, "Restart Signaling"},
176 { ISIS_TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
177 { ISIS_TLV_MT_SUPPORTED
, "Multi Topology"},
178 { ISIS_TLV_IP6ADDR
, "IPv6 Interface address(es)"},
179 { ISIS_TLV_MT_IP_REACH
, "Multi-Topology IPv4 Reachability"},
180 { ISIS_TLV_IP6_REACH
, "IPv6 reachability"},
181 { ISIS_TLV_MT_IP6_REACH
, "Multi-Topology IP6 Reachability"},
182 { ISIS_TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
183 { ISIS_TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
184 { ISIS_TLV_VENDOR_PRIVATE
, "Vendor Private"},
188 #define ESIS_OPTION_PROTOCOLS 129
189 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
190 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
191 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
192 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
193 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
194 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
196 static struct tok esis_option_values
[] = {
197 { ESIS_OPTION_PROTOCOLS
, "Protocols supported"},
198 { ESIS_OPTION_QOS_MAINTENANCE
, "QoS Maintenance" },
199 { ESIS_OPTION_SECURITY
, "Security" },
200 { ESIS_OPTION_ES_CONF_TIME
, "ES Configuration Time" },
201 { ESIS_OPTION_PRIORITY
, "Priority" },
202 { ESIS_OPTION_ADDRESS_MASK
, "Addressk Mask" },
203 { ESIS_OPTION_SNPA_MASK
, "SNPA Mask" },
207 #define CLNP_OPTION_DISCARD_REASON 193
208 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
209 #define CLNP_OPTION_SECURITY 197 /* iso8473 */
210 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
211 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
212 #define CLNP_OPTION_PADDING 204 /* iso8473 */
213 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
215 static struct tok clnp_option_values
[] = {
216 { CLNP_OPTION_DISCARD_REASON
, "Discard Reason"},
217 { CLNP_OPTION_PRIORITY
, "Priority"},
218 { CLNP_OPTION_QOS_MAINTENANCE
, "QoS Maintenance"},
219 { CLNP_OPTION_SECURITY
, "Security"},
220 { CLNP_OPTION_SOURCE_ROUTING
, "Source Routing"},
221 { CLNP_OPTION_ROUTE_RECORDING
, "Route Recording"},
222 { CLNP_OPTION_PADDING
, "Padding"},
226 static struct tok clnp_option_rfd_class_values
[] = {
229 { 0x9, "Source Routeing"},
231 { 0xb, "PDU Discarded"},
232 { 0xc, "Reassembly"},
236 static struct tok clnp_option_rfd_general_values
[] = {
237 { 0x0, "Reason not specified"},
238 { 0x1, "Protocol procedure error"},
239 { 0x2, "Incorrect checksum"},
240 { 0x3, "PDU discarded due to congestion"},
241 { 0x4, "Header syntax error (cannot be parsed)"},
242 { 0x5, "Segmentation needed but not permitted"},
243 { 0x6, "Incomplete PDU received"},
244 { 0x7, "Duplicate option"},
248 static struct tok clnp_option_rfd_address_values
[] = {
249 { 0x0, "Destination address unreachable"},
250 { 0x1, "Destination address unknown"},
254 static struct tok clnp_option_rfd_source_routeing_values
[] = {
255 { 0x0, "Unspecified source routeing error"},
256 { 0x1, "Syntax error in source routeing field"},
257 { 0x2, "Unknown address in source routeing field"},
258 { 0x3, "Path not acceptable"},
262 static struct tok clnp_option_rfd_lifetime_values
[] = {
263 { 0x0, "Lifetime expired while data unit in transit"},
264 { 0x1, "Lifetime expired during reassembly"},
268 static struct tok clnp_option_rfd_pdu_discard_values
[] = {
269 { 0x0, "Unsupported option not specified"},
270 { 0x1, "Unsupported protocol version"},
271 { 0x2, "Unsupported security option"},
272 { 0x3, "Unsupported source routeing option"},
273 { 0x4, "Unsupported recording of route option"},
277 static struct tok clnp_option_rfd_reassembly_values
[] = {
278 { 0x0, "Reassembly interference"},
282 /* array of 16 error-classes */
283 static struct tok
*clnp_option_rfd_error_class
[] = {
284 clnp_option_rfd_general_values
,
292 clnp_option_rfd_address_values
,
293 clnp_option_rfd_source_routeing_values
,
294 clnp_option_rfd_lifetime_values
,
295 clnp_option_rfd_pdu_discard_values
,
296 clnp_option_rfd_reassembly_values
,
302 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
303 #define CLNP_OPTION_SCOPE_MASK 0xc0
304 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
305 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
306 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
308 static struct tok clnp_option_scope_values
[] = {
309 { CLNP_OPTION_SCOPE_SA_SPEC
, "Source Address Specific"},
310 { CLNP_OPTION_SCOPE_DA_SPEC
, "Destination Address Specific"},
311 { CLNP_OPTION_SCOPE_GLOBAL
, "Globally unique"},
315 static struct tok clnp_option_sr_rr_values
[] = {
321 static struct tok clnp_option_sr_rr_string_values
[] = {
322 { CLNP_OPTION_SOURCE_ROUTING
, "source routing"},
323 { CLNP_OPTION_ROUTE_RECORDING
, "recording of route in progress"},
327 static struct tok clnp_option_qos_global_values
[] = {
329 { 0x10, "sequencing vs. delay"},
330 { 0x08, "congested"},
331 { 0x04, "delay vs. cost"},
332 { 0x02, "error vs. delay"},
333 { 0x01, "error vs. cost"},
337 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
338 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
339 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
340 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
341 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
342 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
343 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
344 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
345 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
346 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
347 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
348 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
349 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
351 static struct tok isis_ext_is_reach_subtlv_values
[] = {
352 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
353 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
354 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
355 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
356 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
357 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
358 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
359 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
360 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
361 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
362 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
363 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
, "Bandwidth Constraints (old)" },
364 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
, "Bandwidth Constraints" },
365 { 250, "Reserved for cisco specific extensions" },
366 { 251, "Reserved for cisco specific extensions" },
367 { 252, "Reserved for cisco specific extensions" },
368 { 253, "Reserved for cisco specific extensions" },
369 { 254, "Reserved for cisco specific extensions" },
370 { 255, "Reserved for future expansion" },
374 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
375 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
376 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
378 static struct tok isis_ext_ip_reach_subtlv_values
[] = {
379 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
380 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
381 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
385 #define ISIS_SUBTLV_AUTH_SIMPLE 1
386 #define ISIS_SUBTLV_AUTH_MD5 54
387 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
388 #define ISIS_SUBTLV_AUTH_PRIVATE 255
390 static struct tok isis_subtlv_auth_values
[] = {
391 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
392 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
393 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
397 #define ISIS_SUBTLV_IDRP_RES 0
398 #define ISIS_SUBTLV_IDRP_LOCAL 1
399 #define ISIS_SUBTLV_IDRP_ASN 2
401 static struct tok isis_subtlv_idrp_values
[] = {
402 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
403 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
404 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
408 #define CLNP_SEGMENT_PART 0x80
409 #define CLNP_MORE_SEGMENTS 0x40
410 #define CLNP_REQUEST_ER 0x20
412 static struct tok clnp_flag_values
[] = {
413 { CLNP_SEGMENT_PART
, "Segmentation permitted"},
414 { CLNP_MORE_SEGMENTS
, "more Segments"},
415 { CLNP_REQUEST_ER
, "request Error Report"},
419 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
420 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
421 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
422 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
423 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
424 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
425 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
426 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
428 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
429 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
431 static struct tok isis_mt_flag_values
[] = {
432 { 0x4000, "sub-TLVs present"},
433 { 0x8000, "ATT bit set"},
437 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
438 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
440 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
441 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
443 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
444 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
445 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
446 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
448 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
450 static struct tok isis_mt_values
[] = {
451 { 0, "IPv4 unicast"},
452 { 1, "In-Band Management"},
453 { 2, "IPv6 unicast"},
455 { 4095, "Development, Experimental or Proprietary"},
459 static struct tok isis_iih_circuit_type_values
[] = {
460 { 1, "Level 1 only"},
461 { 2, "Level 2 only"},
462 { 3, "Level 1, Level 2"},
466 #define ISIS_LSP_TYPE_UNUSED0 0
467 #define ISIS_LSP_TYPE_LEVEL_1 1
468 #define ISIS_LSP_TYPE_UNUSED2 2
469 #define ISIS_LSP_TYPE_LEVEL_2 3
471 static struct tok isis_lsp_istype_values
[] = {
472 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
473 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
474 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
475 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
480 * Katz's point to point adjacency TLV uses codes to tell us the state of
481 * the remote adjacency. Enumerate them.
484 #define ISIS_PTP_ADJ_UP 0
485 #define ISIS_PTP_ADJ_INIT 1
486 #define ISIS_PTP_ADJ_DOWN 2
488 static struct tok isis_ptp_adjancey_values
[] = {
489 { ISIS_PTP_ADJ_UP
, "Up" },
490 { ISIS_PTP_ADJ_INIT
, "Initializing" },
491 { ISIS_PTP_ADJ_DOWN
, "Down" },
495 struct isis_tlv_ptp_adj
{
496 u_int8_t adjacency_state
;
497 u_int8_t extd_local_circuit_id
[4];
498 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
499 u_int8_t neighbor_extd_local_circuit_id
[4];
502 static int osi_cksum(const u_int8_t
*, u_int
);
503 static int clnp_print(const u_int8_t
*, u_int
);
504 static void esis_print(const u_int8_t
*, u_int
);
505 static int isis_print(const u_int8_t
*, u_int
);
507 struct isis_metric_block
{
508 u_int8_t metric_default
;
509 u_int8_t metric_delay
;
510 u_int8_t metric_expense
;
511 u_int8_t metric_error
;
514 struct isis_tlv_is_reach
{
515 struct isis_metric_block isis_metric_block
;
516 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
519 struct isis_tlv_es_reach
{
520 struct isis_metric_block isis_metric_block
;
521 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
524 struct isis_tlv_ip_reach
{
525 struct isis_metric_block isis_metric_block
;
530 static struct tok isis_is_reach_virtual_values
[] = {
531 { 0, "IsNotVirtual"},
536 static struct tok isis_restart_flag_values
[] = {
537 { 0x1, "Restart Request"},
538 { 0x2, "Restart Acknowledgement"},
539 { 0x4, "Suppress adjacency advertisement"},
543 struct isis_common_header
{
546 u_int8_t version
; /* Protocol version */
548 u_int8_t pdu_type
; /* 3 MSbits are reserved */
549 u_int8_t pdu_version
; /* Packet format version */
554 struct isis_iih_lan_header
{
555 u_int8_t circuit_type
;
556 u_int8_t source_id
[SYSTEM_ID_LEN
];
557 u_int8_t holding_time
[2];
560 u_int8_t lan_id
[NODE_ID_LEN
];
563 struct isis_iih_ptp_header
{
564 u_int8_t circuit_type
;
565 u_int8_t source_id
[SYSTEM_ID_LEN
];
566 u_int8_t holding_time
[2];
571 struct isis_lsp_header
{
573 u_int8_t remaining_lifetime
[2];
574 u_int8_t lsp_id
[LSP_ID_LEN
];
575 u_int8_t sequence_number
[4];
576 u_int8_t checksum
[2];
580 struct isis_csnp_header
{
582 u_int8_t source_id
[NODE_ID_LEN
];
583 u_int8_t start_lsp_id
[LSP_ID_LEN
];
584 u_int8_t end_lsp_id
[LSP_ID_LEN
];
587 struct isis_psnp_header
{
589 u_int8_t source_id
[NODE_ID_LEN
];
592 struct isis_tlv_lsp
{
593 u_int8_t remaining_lifetime
[2];
594 u_int8_t lsp_id
[LSP_ID_LEN
];
595 u_int8_t sequence_number
[4];
596 u_int8_t checksum
[2];
599 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
600 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
601 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
602 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
603 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
604 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
606 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
608 const struct isis_common_header
*header
;
610 header
= (const struct isis_common_header
*)p
;
612 if (caplen
<= 1) { /* enough bytes on the wire ? */
618 printf("OSI NLPID %s (0x%02x): ",
619 tok2str(nlpid_values
,"Unknown",*p
),
625 if (!clnp_print(p
, length
))
626 print_unknown_data(p
,"\n\t",caplen
);
630 esis_print(p
, length
);
634 if (!isis_print(p
, length
))
635 print_unknown_data(p
,"\n\t",caplen
);
639 (void)printf("%slength: %u",
645 q933_print(p
+1, length
-1);
649 ip_print(gndo
, p
+1, length
-1);
654 ip6_print(p
+1, length
-1);
659 ppp_print(p
+1, length
-1);
664 printf("OSI NLPID 0x%02x unknown",*p
);
665 (void)printf("%slength: %u",
669 print_unknown_data(p
,"\n\t",caplen
);
674 #define CLNP_PDU_ER 1
675 #define CLNP_PDU_DT 28
676 #define CLNP_PDU_MD 29
677 #define CLNP_PDU_ERQ 30
678 #define CLNP_PDU_ERP 31
680 static struct tok clnp_pdu_values
[] = {
681 { CLNP_PDU_ER
, "Error Report"},
682 { CLNP_PDU_MD
, "MD"},
683 { CLNP_PDU_DT
, "Data"},
684 { CLNP_PDU_ERQ
, "Echo Request"},
685 { CLNP_PDU_ERP
, "Echo Response"},
689 struct clnp_header_t
{
691 u_int8_t length_indicator
;
693 u_int8_t lifetime
; /* units of 500ms */
695 u_int8_t segment_length
[2];
699 struct clnp_segment_header_t
{
700 u_int8_t data_unit_id
[2];
701 u_int8_t segment_offset
[2];
702 u_int8_t total_length
[2];
707 * Decode CLNP packets. Return 0 on error.
710 static int clnp_print (const u_int8_t
*pptr
, u_int length
)
712 const u_int8_t
*optr
,*source_address
,*dest_address
;
713 u_int li
,tlen
,nsap_offset
,source_address_length
,dest_address_length
, clnp_pdu_type
, clnp_flags
;
714 const struct clnp_header_t
*clnp_header
;
715 const struct clnp_segment_header_t
*clnp_segment_header
;
716 u_int8_t rfd_error_major
,rfd_error_minor
;
718 clnp_header
= (const struct clnp_header_t
*) pptr
;
719 TCHECK(*clnp_header
);
721 li
= clnp_header
->length_indicator
;
728 * Sanity checking of the header.
731 if (clnp_header
->version
!= CLNP_VERSION
) {
732 printf("version %d packet not supported", clnp_header
->version
);
736 /* FIXME further header sanity checking */
738 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
739 clnp_flags
= clnp_header
->type
& CLNP_FLAG_MASK
;
741 pptr
+= sizeof(struct clnp_header_t
);
742 li
-= sizeof(struct clnp_header_t
);
743 dest_address_length
= *pptr
;
744 dest_address
= pptr
+ 1;
746 pptr
+= (1 + dest_address_length
);
747 li
-= (1 + dest_address_length
);
748 source_address_length
= *pptr
;
749 source_address
= pptr
+1;
751 pptr
+= (1 + source_address_length
);
752 li
-= (1 + source_address_length
);
755 printf("%s%s > %s, %s, length %u",
757 isonsap_string(source_address
, source_address_length
),
758 isonsap_string(dest_address
, dest_address_length
),
759 tok2str(clnp_pdu_values
,"unknown (%u)",clnp_pdu_type
),
763 printf("%slength %u",eflag
? "" : ", ",length
);
765 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ",
766 tok2str(clnp_pdu_values
, "unknown (%u)",clnp_pdu_type
),
767 clnp_header
->length_indicator
,
768 clnp_header
->version
,
769 clnp_header
->lifetime
/2,
770 (clnp_header
->lifetime
%2)*5,
771 EXTRACT_16BITS(clnp_header
->segment_length
),
772 EXTRACT_16BITS(clnp_header
->cksum
));
774 /* do not attempt to verify the checksum if it is zero */
775 if (EXTRACT_16BITS(clnp_header
->cksum
) == 0)
776 printf("(unverified)");
777 else printf("(%s)", osi_cksum(optr
, clnp_header
->length_indicator
) ? "incorrect" : "correct");
779 printf("\n\tFlags [%s]",
780 bittok2str(clnp_flag_values
,"none",clnp_flags
));
782 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
783 source_address_length
,
784 isonsap_string(source_address
, source_address_length
),
786 isonsap_string(dest_address
,dest_address_length
));
788 if (clnp_flags
& CLNP_SEGMENT_PART
) {
789 clnp_segment_header
= (const struct clnp_segment_header_t
*) pptr
;
790 TCHECK(*clnp_segment_header
);
791 printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
792 EXTRACT_16BITS(clnp_segment_header
->data_unit_id
),
793 EXTRACT_16BITS(clnp_segment_header
->segment_offset
),
794 EXTRACT_16BITS(clnp_segment_header
->total_length
));
795 pptr
+=sizeof(const struct clnp_segment_header_t
);
796 li
-=sizeof(const struct clnp_segment_header_t
);
799 /* now walk the options */
802 const u_int8_t
*tptr
;
806 printf(", bad opts/li");
812 TCHECK2(*pptr
, opli
);
814 printf(", opt (%d) too long", op
);
821 printf("\n\t %s Option #%u, length %u, value: ",
822 tok2str(clnp_option_values
,"Unknown",op
),
829 case CLNP_OPTION_ROUTE_RECORDING
: /* those two options share the format */
830 case CLNP_OPTION_SOURCE_ROUTING
:
832 tok2str(clnp_option_sr_rr_values
,"Unknown",*tptr
),
833 tok2str(clnp_option_sr_rr_string_values
,"Unknown Option %u",op
));
834 nsap_offset
=*(tptr
+1);
835 if (nsap_offset
== 0) {
836 printf(" Bad NSAP offset (0)");
839 nsap_offset
-=1; /* offset to nsap list */
840 if (nsap_offset
> tlen
) {
841 printf(" Bad NSAP offset (past end of option)");
847 source_address_length
=*tptr
;
848 if (tlen
< source_address_length
+1) {
849 printf("\n\t NSAP address goes past end of option");
852 if (source_address_length
> 0) {
853 source_address
=(tptr
+1);
854 TCHECK2(*source_address
, source_address_length
);
855 printf("\n\t NSAP address (length %u): %s",
856 source_address_length
,
857 isonsap_string(source_address
, source_address_length
));
859 tlen
-=source_address_length
+1;
863 case CLNP_OPTION_PRIORITY
:
864 printf("0x%1x", *tptr
&0x0f);
867 case CLNP_OPTION_QOS_MAINTENANCE
:
868 printf("\n\t Format Code: %s",
869 tok2str(clnp_option_scope_values
,"Reserved",*tptr
&CLNP_OPTION_SCOPE_MASK
));
871 if ((*tptr
&CLNP_OPTION_SCOPE_MASK
) == CLNP_OPTION_SCOPE_GLOBAL
)
872 printf("\n\t QoS Flags [%s]",
873 bittok2str(clnp_option_qos_global_values
,
875 *tptr
&CLNP_OPTION_OPTION_QOS_MASK
));
878 case CLNP_OPTION_SECURITY
:
879 printf("\n\t Format Code: %s, Security-Level %u",
880 tok2str(clnp_option_scope_values
,"Reserved",*tptr
&CLNP_OPTION_SCOPE_MASK
),
884 case CLNP_OPTION_DISCARD_REASON
:
885 rfd_error_major
= (*tptr
&0xf0) >> 4;
886 rfd_error_minor
= *tptr
&0x0f;
887 printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
888 tok2str(clnp_option_rfd_class_values
,"Unknown",rfd_error_major
),
890 tok2str(clnp_option_rfd_error_class
[rfd_error_major
],"Unknown",rfd_error_minor
),
894 case CLNP_OPTION_PADDING
:
895 printf("padding data");
899 * FIXME those are the defined Options that lack a decoder
900 * you are welcome to contribute code ;-)
904 print_unknown_data(tptr
,"\n\t ",opli
);
908 print_unknown_data(pptr
,"\n\t ",opli
);
912 switch (clnp_pdu_type
) {
914 case CLNP_PDU_ER
: /* fall through */
917 if (*(pptr
) == NLPID_CLNP
) {
918 printf("\n\t-----original packet-----\n\t");
919 /* FIXME recursion protection */
920 clnp_print(pptr
, length
-clnp_header
->length_indicator
);
929 /* dump the PDU specific data */
930 if (length
-(pptr
-optr
) > 0) {
931 printf("\n\t undecoded non-header data, length %u",length
-clnp_header
->length_indicator
);
932 print_unknown_data(pptr
,"\n\t ",length
-(pptr
-optr
));
939 fputs("[|clnp]", stdout
);
945 #define ESIS_PDU_REDIRECT 6
946 #define ESIS_PDU_ESH 2
947 #define ESIS_PDU_ISH 4
949 static struct tok esis_pdu_values
[] = {
950 { ESIS_PDU_REDIRECT
, "redirect"},
951 { ESIS_PDU_ESH
, "ESH"},
952 { ESIS_PDU_ISH
, "ISH"},
956 struct esis_header_t
{
958 u_int8_t length_indicator
;
962 u_int8_t holdtime
[2];
967 esis_print(const u_int8_t
*pptr
, u_int length
)
969 const u_int8_t
*optr
;
970 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
971 const struct esis_header_t
*esis_header
;
980 printf("no header at all!");
984 esis_header
= (const struct esis_header_t
*) pptr
;
985 TCHECK(*esis_header
);
986 li
= esis_header
->length_indicator
;
990 * Sanity checking of the header.
993 if (esis_header
->nlpid
!= NLPID_ESIS
) {
994 printf(" nlpid 0x%02x packet not supported", esis_header
->nlpid
);
998 if (esis_header
->version
!= ESIS_VERSION
) {
999 printf(" version %d packet not supported", esis_header
->version
);
1004 printf(" length indicator(%d) > PDU size (%d)!", li
, length
);
1008 if (li
< sizeof(struct esis_header_t
) + 2) {
1009 printf(" length indicator < min PDU size %d:", li
);
1010 while (--length
!= 0)
1011 printf("%02X", *pptr
++);
1015 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
1018 printf("%s%s, length %u",
1020 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
1024 printf("%slength %u\n\t%s (%u)",
1027 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
1030 printf(", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" );
1031 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header
->cksum
));
1032 /* do not attempt to verify the checksum if it is zero */
1033 if (EXTRACT_16BITS(esis_header
->cksum
) == 0)
1034 printf("(unverified)");
1036 printf("(%s)", osi_cksum(pptr
, li
) ? "incorrect" : "correct");
1038 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header
->holdtime
),li
);
1041 print_unknown_data(optr
,"\n\t",sizeof(struct esis_header_t
));
1043 pptr
+= sizeof(struct esis_header_t
);
1044 li
-= sizeof(struct esis_header_t
);
1046 switch (esis_pdu_type
) {
1047 case ESIS_PDU_REDIRECT
: {
1048 const u_int8_t
*dst
, *snpa
, *neta
;
1049 u_int dstl
, snpal
, netal
;
1053 printf(", bad redirect/li");
1059 TCHECK2(*pptr
, dstl
);
1061 printf(", bad redirect/li");
1067 printf("\n\t %s", isonsap_string(dst
,dstl
));
1071 printf(", bad redirect/li");
1077 TCHECK2(*pptr
, snpal
);
1079 printf(", bad redirect/li");
1087 printf(", bad redirect/li");
1092 TCHECK2(*pptr
, netal
);
1094 printf(", bad redirect/li");
1102 printf("\n\t %s", etheraddr_string(snpa
));
1104 printf("\n\t %s", isonsap_string(neta
,netal
));
1111 printf(", bad esh/li");
1114 source_address_number
= *pptr
;
1118 printf("\n\t Number of Source Addresses: %u", source_address_number
);
1120 while (source_address_number
> 0) {
1123 printf(", bad esh/li");
1126 source_address_length
= *pptr
;
1130 TCHECK2(*pptr
, source_address_length
);
1131 if (li
< source_address_length
) {
1132 printf(", bad esh/li");
1135 printf("\n\t NET (length: %u): %s",
1136 source_address_length
,
1137 isonsap_string(pptr
,source_address_length
));
1138 pptr
+= source_address_length
;
1139 li
-= source_address_length
;
1140 source_address_number
--;
1145 case ESIS_PDU_ISH
: {
1148 printf(", bad ish/li");
1151 source_address_length
= *pptr
;
1154 TCHECK2(*pptr
, source_address_length
);
1155 if (li
< source_address_length
) {
1156 printf(", bad ish/li");
1159 printf("\n\t NET (length: %u): %s", source_address_length
, isonsap_string(pptr
, source_address_length
));
1160 pptr
+= source_address_length
;
1161 li
-= source_address_length
;
1168 print_unknown_data(pptr
,"\n\t ",snapend
-pptr
);
1173 /* now walk the options */
1176 const u_int8_t
*tptr
;
1180 printf(", bad opts/li");
1187 printf(", opt (%d) too long", op
);
1193 printf("\n\t %s Option #%u, length %u, value: ",
1194 tok2str(esis_option_values
,"Unknown",op
),
1200 case ESIS_OPTION_ES_CONF_TIME
:
1202 printf("%us", EXTRACT_16BITS(tptr
));
1205 case ESIS_OPTION_PROTOCOLS
:
1208 printf("%s (0x%02x)",
1209 tok2str(nlpid_values
,
1213 if (opli
>1) /* further NPLIDs ? - put comma */
1221 * FIXME those are the defined Options that lack a decoder
1222 * you are welcome to contribute code ;-)
1225 case ESIS_OPTION_QOS_MAINTENANCE
:
1226 case ESIS_OPTION_SECURITY
:
1227 case ESIS_OPTION_PRIORITY
:
1228 case ESIS_OPTION_ADDRESS_MASK
:
1229 case ESIS_OPTION_SNPA_MASK
:
1232 print_unknown_data(tptr
,"\n\t ",opli
);
1236 print_unknown_data(pptr
,"\n\t ",opli
);
1243 /* shared routine for printing system, node and lsp-ids */
1245 isis_print_id(const u_int8_t
*cp
, int id_len
)
1248 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1251 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
1252 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
1254 if (i
== 2 || i
== 4)
1257 if (id_len
>= NODE_ID_LEN
) {
1258 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
1261 if (id_len
== LSP_ID_LEN
)
1262 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
1266 /* print the 4-byte metric block which is common found in the old-style TLVs */
1268 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
1270 printf(", Default Metric: %d, %s",
1271 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
1272 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
1273 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
1274 printf("\n\t\t Delay Metric: %d, %s",
1275 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
1276 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
1277 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
1278 printf("\n\t\t Expense Metric: %d, %s",
1279 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
1280 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
1281 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
1282 printf("\n\t\t Error Metric: %d, %s",
1283 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
1284 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
1286 return(1); /* everything is ok */
1290 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
1293 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
1295 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
1297 while (length
> 0) {
1298 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
1299 printf("short IPv4 Reachability (%d vs %lu)",
1301 (unsigned long)sizeof(*tlv_ip_reach
));
1305 if (!TTEST(*tlv_ip_reach
))
1308 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
1310 if (prefix_len
== -1)
1311 printf("%sIPv4 prefix: %s mask %s",
1313 ipaddr_string((tlv_ip_reach
->prefix
)),
1314 ipaddr_string((tlv_ip_reach
->mask
)));
1316 printf("%sIPv4 prefix: %15s/%u",
1318 ipaddr_string((tlv_ip_reach
->prefix
)),
1321 printf(", Distribution: %s, Metric: %u, %s",
1322 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
1323 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
1324 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
1326 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
1327 printf("%s Delay Metric: %u, %s",
1329 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
1330 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
1332 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
1333 printf("%s Expense Metric: %u, %s",
1335 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
1336 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
1338 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
1339 printf("%s Error Metric: %u, %s",
1341 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
1342 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
1344 length
-= sizeof(struct isis_tlv_ip_reach
);
1351 * this is the common IP-REACH subTLV decoder it is called
1352 * from various EXTD-IP REACH TLVs (135,235,236,237)
1356 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
1358 /* first lets see if we know the subTLVs name*/
1359 printf("%s%s subTLV #%u, length: %u",
1361 tok2str(isis_ext_ip_reach_subtlv_values
,
1367 if (!TTEST2(*tptr
,subl
))
1371 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1372 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1374 printf(", 0x%08x (=%u)",
1375 EXTRACT_32BITS(tptr
),
1376 EXTRACT_32BITS(tptr
));
1381 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1383 printf(", 0x%08x%08x",
1384 EXTRACT_32BITS(tptr
),
1385 EXTRACT_32BITS(tptr
+4));
1391 if(!print_unknown_data(tptr
,"\n\t\t ",
1399 printf("%spacket exceeded snapshot",ident
);
1404 * this is the common IS-REACH subTLV decoder it is called
1405 * from isis_print_ext_is_reach()
1409 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,u_int subt
,u_int subl
,const char *ident
) {
1411 u_int te_class
,priority_level
;
1412 union { /* int to float conversion buffer for several subTLVs */
1417 /* first lets see if we know the subTLVs name*/
1418 printf("%s%s subTLV #%u, length: %u",
1420 tok2str(isis_ext_is_reach_subtlv_values
,
1426 if (!TTEST2(*tptr
,subl
))
1430 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1431 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1432 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1434 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
1435 if (subl
== 8) /* draft-ietf-isis-gmpls-extensions */
1436 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
1439 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1440 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1441 if (subl
>= sizeof(struct in_addr
))
1442 printf(", %s", ipaddr_string(tptr
));
1444 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1445 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1447 bw
.i
= EXTRACT_32BITS(tptr
);
1448 printf(", %.3f Mbps", bw
.f
*8/1000000 );
1451 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1453 for (te_class
= 0; te_class
< 8; te_class
++) {
1454 bw
.i
= EXTRACT_32BITS(tptr
);
1455 printf("%s TE-Class %u: %.3f Mbps",
1463 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
: /* fall through */
1464 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
:
1465 printf("%sBandwidth Constraints Model ID: %s (%u)",
1467 tok2str(diffserv_te_bc_values
, "unknown", *tptr
),
1470 /* decode BCs until the subTLV ends */
1471 for (te_class
= 0; te_class
< (subl
-1)/4; te_class
++) {
1472 bw
.i
= EXTRACT_32BITS(tptr
);
1473 printf("%s Bandwidth constraint CT%u: %.3f Mbps",
1480 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1482 printf(", %u", EXTRACT_24BITS(tptr
));
1484 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1486 printf(", %s, Priority %u",
1487 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1491 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1493 printf("%s Interface Switching Capability:%s",
1495 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
1496 printf(", LSP Encoding: %s",
1497 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
1499 printf("%s Max LSP Bandwidth:",ident
);
1500 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1501 bw
.i
= EXTRACT_32BITS(tptr
);
1502 printf("%s priority level %d: %.3f Mbps",
1509 /* there is some optional stuff left to decode but this is as of yet
1510 not specified so just lets hexdump what is left */
1512 if(!print_unknown_data(tptr
,"\n\t\t ",
1519 if(!print_unknown_data(tptr
,"\n\t\t ",
1527 printf("%spacket exceeded snapshot",ident
);
1533 * this is the common IS-REACH decoder it is called
1534 * from various EXTD-IS REACH style TLVs (22,24,222)
1538 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
1540 char ident_buffer
[20];
1541 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1542 int proc_bytes
= 0; /* how many bytes did we process ? */
1544 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1547 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1548 tptr
+=(NODE_ID_LEN
);
1550 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1551 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
1553 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1557 if (!TTEST2(*tptr
, 1))
1559 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1560 proc_bytes
=NODE_ID_LEN
+3+1;
1561 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1562 if (subtlv_sum_len
) {
1563 printf(" (%u)",subtlv_sum_len
);
1564 while (subtlv_sum_len
>0) {
1565 if (!TTEST2(*tptr
,2))
1567 subtlv_type
=*(tptr
++);
1568 subtlv_len
=*(tptr
++);
1569 /* prepend the ident string */
1570 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1571 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
1574 subtlv_sum_len
-=(subtlv_len
+2);
1575 proc_bytes
+=(subtlv_len
+2);
1582 * this is the common Multi Topology ID decoder
1583 * it is called from various MT-TLVs (222,229,235,237)
1587 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1589 if (!TTEST2(*tptr
, 2))
1594 tok2str(isis_mt_values
,
1595 "Reserved for IETF Consensus",
1596 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1598 printf(" Topology (0x%03x), Flags: [%s]",
1599 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1600 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1606 * this is the common extended IP reach decoder
1607 * it is called from TLVs (135,235,236,237)
1608 * we process the TLV and optional subTLVs and return
1609 * the amount of processed bytes
1613 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1615 char ident_buffer
[20];
1617 u_int8_t prefix
[sizeof(struct in6_addr
)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1619 u_int8_t prefix
[sizeof(struct in_addr
)]; /* shared copy buffer for IPv4 prefixes */
1621 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1623 if (!TTEST2(*tptr
, 4))
1625 metric
= EXTRACT_32BITS(tptr
);
1629 if (afi
== AF_INET
) {
1630 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1632 status_byte
=*(tptr
++);
1633 bit_length
= status_byte
&0x3f;
1634 if (bit_length
> 32) {
1635 printf("%sIPv4 prefix: bad bit length %u",
1642 } else if (afi
== AF_INET6
) {
1643 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1645 status_byte
=*(tptr
++);
1646 bit_length
=*(tptr
++);
1647 if (bit_length
> 128) {
1648 printf("%sIPv6 prefix: bad bit length %u",
1656 return (0); /* somebody is fooling us */
1658 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1660 if (!TTEST2(*tptr
, byte_length
))
1662 memset(prefix
, 0, sizeof prefix
); /* clear the copy buffer */
1663 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1665 processed
+=byte_length
;
1668 printf("%sIPv4 prefix: %15s/%u",
1670 ipaddr_string(prefix
),
1673 if (afi
== AF_INET6
)
1674 printf("%sIPv6 prefix: %s/%u",
1676 ip6addr_string(prefix
),
1680 printf(", Distribution: %s, Metric: %u",
1681 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
1684 if (afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
1685 printf(", sub-TLVs present");
1687 if (afi
== AF_INET6
)
1689 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
1690 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1693 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
) && afi
== AF_INET
) ||
1694 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) && afi
== AF_INET6
)) {
1695 /* assume that one prefix can hold more
1696 than one subTLV - therefore the first byte must reflect
1697 the aggregate bytecount of the subTLVs for this prefix
1699 if (!TTEST2(*tptr
, 1))
1702 processed
+=sublen
+1;
1703 printf(" (%u)",sublen
); /* print out subTLV length */
1706 if (!TTEST2(*tptr
,2))
1708 subtlvtype
=*(tptr
++);
1709 subtlvlen
=*(tptr
++);
1710 /* prepend the ident string */
1711 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1712 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1715 sublen
-=(subtlvlen
+2);
1723 * Decode IS-IS packets. Return 0 on error.
1726 static int isis_print (const u_int8_t
*p
, u_int length
)
1728 const struct isis_common_header
*isis_header
;
1730 const struct isis_iih_lan_header
*header_iih_lan
;
1731 const struct isis_iih_ptp_header
*header_iih_ptp
;
1732 const struct isis_lsp_header
*header_lsp
;
1733 const struct isis_csnp_header
*header_csnp
;
1734 const struct isis_psnp_header
*header_psnp
;
1736 const struct isis_tlv_lsp
*tlv_lsp
;
1737 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1738 const struct isis_tlv_is_reach
*tlv_is_reach
;
1739 const struct isis_tlv_es_reach
*tlv_es_reach
;
1741 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1742 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1743 const u_int8_t
*optr
, *pptr
, *tptr
;
1744 u_short packet_len
,pdu_len
;
1748 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1749 need it for parsing the checksum TLV */
1750 isis_header
= (const struct isis_common_header
*)p
;
1751 TCHECK(*isis_header
);
1752 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1753 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1754 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1755 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1756 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1757 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1763 * Sanity checking of the header.
1766 if (isis_header
->version
!= ISIS_VERSION
) {
1767 printf("version %d packet not supported", isis_header
->version
);
1771 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
1772 printf("system ID length of %d is not supported",
1773 isis_header
->id_length
);
1777 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
1778 printf("version %d packet not supported", isis_header
->pdu_version
);
1782 max_area
= isis_header
->max_area
;
1785 max_area
= 3; /* silly shit */
1788 printf("bad packet -- 255 areas");
1794 id_length
= isis_header
->id_length
;
1797 id_length
= 6; /* silly shit again */
1799 case 1: /* 1-8 are valid sys-ID lenghts */
1809 id_length
= 0; /* entirely useless */
1815 /* toss any non 6-byte sys-ID len PDUs */
1816 if (id_length
!= 6 ) {
1817 printf("bad packet -- illegal sys-ID length (%u)", id_length
);
1821 pdu_type
=isis_header
->pdu_type
;
1823 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1827 tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1831 case ISIS_PDU_L1_LAN_IIH
:
1832 case ISIS_PDU_L2_LAN_IIH
:
1833 printf(", src-id %s",
1834 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1835 printf(", lan-id %s, prio %u",
1836 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
1837 header_iih_lan
->priority
);
1839 case ISIS_PDU_PTP_IIH
:
1840 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1842 case ISIS_PDU_L1_LSP
:
1843 case ISIS_PDU_L2_LSP
:
1844 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1845 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1846 EXTRACT_32BITS(header_lsp
->sequence_number
),
1847 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1849 case ISIS_PDU_L1_CSNP
:
1850 case ISIS_PDU_L2_CSNP
:
1851 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,NODE_ID_LEN
));
1853 case ISIS_PDU_L1_PSNP
:
1854 case ISIS_PDU_L2_PSNP
:
1855 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,NODE_ID_LEN
));
1859 printf(", length %u", length
);
1864 /* ok they seem to want to know everything - lets fully decode it */
1865 printf("%slength %u", eflag
? "" : ", ",length
);
1867 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1868 tok2str(isis_pdu_values
,
1871 isis_header
->fixed_len
,
1872 isis_header
->version
,
1873 isis_header
->pdu_version
,
1875 isis_header
->id_length
,
1877 isis_header
->max_area
);
1880 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1881 return(0); /* for optionally debugging the common header */
1886 case ISIS_PDU_L1_LAN_IIH
:
1887 case ISIS_PDU_L2_LAN_IIH
:
1888 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1889 printf(", bogus fixed header length %u should be %lu",
1890 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1894 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1895 if (packet_len
>pdu_len
) {
1896 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1900 TCHECK(*header_iih_lan
);
1901 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1902 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1903 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1904 tok2str(isis_iih_circuit_type_values
,
1905 "unknown circuit type 0x%02x",
1906 header_iih_lan
->circuit_type
));
1908 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1909 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1910 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
1914 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1918 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1919 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1922 case ISIS_PDU_PTP_IIH
:
1923 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1924 printf(", bogus fixed header length %u should be %lu",
1925 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1929 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1930 if (packet_len
>pdu_len
) {
1931 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1935 TCHECK(*header_iih_ptp
);
1936 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1937 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1938 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1939 tok2str(isis_iih_circuit_type_values
,
1940 "unknown circuit type 0x%02x",
1941 header_iih_ptp
->circuit_type
));
1943 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1944 header_iih_ptp
->circuit_id
,
1948 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1952 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1953 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1956 case ISIS_PDU_L1_LSP
:
1957 case ISIS_PDU_L2_LSP
:
1958 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1959 printf(", bogus fixed header length %u should be %lu",
1960 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1964 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1965 if (packet_len
>pdu_len
) {
1966 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1970 TCHECK(*header_lsp
);
1971 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1972 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1973 EXTRACT_32BITS(header_lsp
->sequence_number
),
1974 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
1975 EXTRACT_16BITS(header_lsp
->checksum
));
1977 /* if this is a purge do not attempt to verify the checksum */
1978 if ( EXTRACT_16BITS(header_lsp
->remaining_lifetime
) == 0 &&
1979 EXTRACT_16BITS(header_lsp
->checksum
) == 0)
1980 printf(" (purged)");
1982 /* verify the checksum -
1983 * checking starts at the lsp-id field at byte position [12]
1984 * hence the length needs to be reduced by 12 bytes */
1985 printf(" (%s)", (osi_cksum((u_int8_t
*)header_lsp
->lsp_id
, length
-12)) ? "incorrect" : "correct");
1987 printf(", PDU length: %u, Flags: [ %s",
1989 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1991 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1992 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1993 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1994 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1995 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1996 printf("ATT bit set, ");
1998 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1999 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
2002 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
2006 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2007 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2010 case ISIS_PDU_L1_CSNP
:
2011 case ISIS_PDU_L2_CSNP
:
2012 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
2013 printf(", bogus fixed header length %u should be %lu",
2014 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
2018 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
2019 if (packet_len
>pdu_len
) {
2020 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2024 TCHECK(*header_csnp
);
2025 printf("\n\t source-id: %s, PDU length: %u",
2026 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
2028 printf("\n\t start lsp-id: %s",
2029 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
2030 printf("\n\t end lsp-id: %s",
2031 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
2034 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
2038 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2039 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2042 case ISIS_PDU_L1_PSNP
:
2043 case ISIS_PDU_L2_PSNP
:
2044 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
2045 printf("- bogus fixed header length %u should be %lu",
2046 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
2050 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
2051 if (packet_len
>pdu_len
) {
2052 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2056 TCHECK(*header_psnp
);
2057 printf("\n\t source-id: %s, PDU length: %u",
2058 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
2062 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
2066 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2067 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2071 if(!print_unknown_data(pptr
,"\n\t ",length
))
2077 * Now print the TLV's.
2080 while (packet_len
>= 2) {
2081 if (pptr
== snapend
) {
2085 if (!TTEST2(*pptr
, 2)) {
2086 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
2087 (long)(pptr
-snapend
));
2092 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
2095 if (tlv_len
> packet_len
) {
2099 /* first lets see if we know the TLVs name*/
2100 printf("\n\t %s TLV #%u, length: %u",
2101 tok2str(isis_tlv_values
,
2107 if (tlv_len
== 0) /* something is malformed */
2110 /* now check if we have a decoder otherwise do a hexdump at the end*/
2112 case ISIS_TLV_AREA_ADDR
:
2113 if (!TTEST2(*tptr
, 1))
2116 while (tmp
&& alen
< tmp
) {
2117 printf("\n\t Area address (length: %u): %s",
2119 isonsap_string(tptr
,alen
));
2122 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
2124 if (!TTEST2(*tptr
, 1))
2129 case ISIS_TLV_ISNEIGH
:
2130 while (tmp
>= ETHER_ADDR_LEN
) {
2131 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
2133 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
2134 tmp
-= ETHER_ADDR_LEN
;
2135 tptr
+= ETHER_ADDR_LEN
;
2139 case ISIS_TLV_ISNEIGH_VARLEN
:
2140 if (!TTEST2(*tptr
, 1) || tmp
< 3) /* min. TLV length */
2142 lan_alen
= *tptr
++; /* LAN address length */
2143 if (lan_alen
== 0) {
2144 printf("\n\t LAN address length 0 bytes (invalid)");
2148 printf("\n\t LAN address length %u bytes ",lan_alen
);
2149 while (tmp
>= lan_alen
) {
2150 if (!TTEST2(*tptr
, lan_alen
))
2152 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
2158 case ISIS_TLV_PADDING
:
2161 case ISIS_TLV_MT_IS_REACH
:
2162 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
2163 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2164 if (mt_len
== 0) /* did something go wrong ? */
2169 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
2170 if (ext_is_len
== 0) /* did something go wrong ? */
2178 case ISIS_TLV_IS_ALIAS_ID
:
2179 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
2180 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
2181 if (ext_is_len
== 0) /* did something go wrong ? */
2188 case ISIS_TLV_EXT_IS_REACH
:
2189 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
2190 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
2191 if (ext_is_len
== 0) /* did something go wrong ? */
2197 case ISIS_TLV_IS_REACH
:
2198 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
2201 tok2str(isis_is_reach_virtual_values
,
2202 "bogus virtual flag 0x%02x",
2204 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
2205 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
2206 if (!TTEST(*tlv_is_reach
))
2208 printf("\n\t IS Neighbor: %s",
2209 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
2210 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
2211 tmp
-= sizeof(struct isis_tlv_is_reach
);
2216 case ISIS_TLV_ESNEIGH
:
2217 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
2218 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
2219 if (!TTEST(*tlv_es_reach
))
2221 printf("\n\t ES Neighbor: %s",
2222 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
2223 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
2224 tmp
-= sizeof(struct isis_tlv_es_reach
);
2229 /* those two TLVs share the same format */
2230 case ISIS_TLV_INT_IP_REACH
:
2231 case ISIS_TLV_EXT_IP_REACH
:
2232 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
2236 case ISIS_TLV_EXTD_IP_REACH
:
2238 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET
);
2239 if (ext_ip_len
== 0) /* did something go wrong ? */
2246 case ISIS_TLV_MT_IP_REACH
:
2248 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2249 if (mt_len
== 0) /* did something go wrong ? */
2254 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET
);
2255 if (ext_ip_len
== 0) /* did something go wrong ? */
2263 case ISIS_TLV_IP6_REACH
:
2265 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET6
);
2266 if (ext_ip_len
== 0) /* did something go wrong ? */
2273 case ISIS_TLV_MT_IP6_REACH
:
2275 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2276 if (mt_len
== 0) /* did something go wrong ? */
2281 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET6
);
2282 if (ext_ip_len
== 0) /* did something go wrong ? */
2289 case ISIS_TLV_IP6ADDR
:
2290 while (tmp
>=sizeof(struct in6_addr
)) {
2291 if (!TTEST2(*tptr
, sizeof(struct in6_addr
)))
2294 printf("\n\t IPv6 interface address: %s",
2295 ip6addr_string(tptr
));
2297 tptr
+= sizeof(struct in6_addr
);
2298 tmp
-= sizeof(struct in6_addr
);
2303 if (!TTEST2(*tptr
, 1))
2307 tok2str(isis_subtlv_auth_values
,
2308 "unknown Authentication type 0x%02x",
2312 case ISIS_SUBTLV_AUTH_SIMPLE
:
2313 for(i
=1;i
<tlv_len
;i
++) {
2314 if (!TTEST2(*(tptr
+i
), 1))
2316 printf("%c",*(tptr
+i
));
2319 case ISIS_SUBTLV_AUTH_MD5
:
2320 for(i
=1;i
<tlv_len
;i
++) {
2321 if (!TTEST2(*(tptr
+i
), 1))
2323 printf("%02x",*(tptr
+i
));
2325 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
2326 printf(", (malformed subTLV) ");
2328 case ISIS_SUBTLV_AUTH_PRIVATE
:
2330 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
2336 case ISIS_TLV_PTP_ADJ
:
2337 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
2339 if (!TTEST2(*tptr
, 1))
2341 printf("\n\t Adjacency State: %s (%u)",
2342 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
2346 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
2347 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
2348 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
2350 printf("\n\t Extended Local circuit-ID: 0x%08x",
2351 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
2352 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
2354 if(tmp
>=SYSTEM_ID_LEN
) {
2355 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
2357 printf("\n\t Neighbor System-ID: %s",
2358 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
2361 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
2362 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
2363 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
2365 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2366 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
2370 case ISIS_TLV_PROTOCOLS
:
2371 printf("\n\t NLPID(s): ");
2373 if (!TTEST2(*(tptr
), 1))
2375 printf("%s (0x%02x)",
2376 tok2str(nlpid_values
,
2380 if (tmp
>1) /* further NPLIDs ? - put comma */
2387 case ISIS_TLV_TE_ROUTER_ID
:
2388 if (!TTEST2(*pptr
, sizeof(struct in_addr
)))
2390 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
2393 case ISIS_TLV_IPADDR
:
2394 while (tmp
>=sizeof(struct in_addr
)) {
2395 if (!TTEST2(*tptr
, sizeof(struct in_addr
)))
2397 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2398 tptr
+= sizeof(struct in_addr
);
2399 tmp
-= sizeof(struct in_addr
);
2403 case ISIS_TLV_HOSTNAME
:
2404 printf("\n\t Hostname: ");
2406 if (!TTEST2(*tptr
, 1))
2408 printf("%c",*tptr
++);
2413 case ISIS_TLV_SHARED_RISK_GROUP
:
2414 if (tmp
< NODE_ID_LEN
)
2416 if (!TTEST2(*tptr
, NODE_ID_LEN
))
2418 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
2419 tptr
+=(NODE_ID_LEN
);
2424 if (!TTEST2(*tptr
, 1))
2426 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
2429 if (tmp
< sizeof(struct in_addr
))
2431 if (!TTEST2(*tptr
,sizeof(struct in_addr
)))
2433 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2434 tptr
+=sizeof(struct in_addr
);
2435 tmp
-=sizeof(struct in_addr
);
2437 if (tmp
< sizeof(struct in_addr
))
2439 if (!TTEST2(*tptr
,sizeof(struct in_addr
)))
2441 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
2442 tptr
+=sizeof(struct in_addr
);
2443 tmp
-=sizeof(struct in_addr
);
2446 if (!TTEST2(*tptr
, 4))
2448 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
2455 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2456 while(tmp
>=sizeof(struct isis_tlv_lsp
)) {
2457 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2459 printf("\n\t lsp-id: %s",
2460 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
2461 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
2463 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
2464 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2466 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
2467 if (!TTEST2(tlv_lsp
->checksum
, 2))
2469 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
2470 tmp
-=sizeof(struct isis_tlv_lsp
);
2475 case ISIS_TLV_CHECKSUM
:
2476 if (tmp
< ISIS_TLV_CHECKSUM_MINLEN
)
2478 if (!TTEST2(*tptr
, ISIS_TLV_CHECKSUM_MINLEN
))
2480 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
2481 /* do not attempt to verify the checksum if it is zero
2482 * most likely a HMAC-MD5 TLV is also present and
2483 * to avoid conflicts the checksum TLV is zeroed.
2484 * see rfc3358 for details
2486 if (EXTRACT_16BITS(tptr
) == 0)
2487 printf("(unverified)");
2488 else printf("(%s)", osi_cksum(optr
, length
) ? "incorrect" : "correct");
2491 case ISIS_TLV_MT_SUPPORTED
:
2492 if (tmp
< ISIS_TLV_MT_SUPPORTED_MINLEN
)
2495 /* length can only be a multiple of 2, otherwise there is
2496 something broken -> so decode down until length is 1 */
2498 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2499 if (mt_len
== 0) /* did something go wrong ? */
2504 printf("\n\t malformed MT-ID");
2510 case ISIS_TLV_RESTART_SIGNALING
:
2511 /* first attempt to decode the flags */
2512 if (tmp
< ISIS_TLV_RESTART_SIGNALING_FLAGLEN
)
2514 if (!TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_FLAGLEN
))
2516 printf("\n\t Flags [%s]",
2517 bittok2str(isis_restart_flag_values
, "none", *tptr
));
2518 tptr
+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2519 tmp
-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2521 /* is there anything other than the flags field? */
2525 if (tmp
< ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
)
2527 if (!TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
))
2530 printf(", Remaining holding time %us", EXTRACT_16BITS(tptr
+1));
2531 tptr
+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2532 tmp
-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2534 /* is there an additional sysid field present ?*/
2535 if (tmp
== SYSTEM_ID_LEN
) {
2536 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2538 printf(", for %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2542 case ISIS_TLV_IDRP_INFO
:
2543 if (tmp
< ISIS_TLV_IDRP_INFO_MINLEN
)
2545 if (!TTEST2(*tptr
, ISIS_TLV_IDRP_INFO_MINLEN
))
2547 printf("\n\t Inter-Domain Information Type: %s",
2548 tok2str(isis_subtlv_idrp_values
,
2552 case ISIS_SUBTLV_IDRP_ASN
:
2553 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
2555 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
2557 case ISIS_SUBTLV_IDRP_LOCAL
:
2558 case ISIS_SUBTLV_IDRP_RES
:
2560 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
2566 case ISIS_TLV_LSP_BUFFERSIZE
:
2567 if (tmp
< ISIS_TLV_LSP_BUFFERSIZE_MINLEN
)
2569 if (!TTEST2(*tptr
, ISIS_TLV_LSP_BUFFERSIZE_MINLEN
))
2571 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
2574 case ISIS_TLV_PART_DIS
:
2575 while (tmp
>= SYSTEM_ID_LEN
) {
2576 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2578 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2579 tptr
+=SYSTEM_ID_LEN
;
2584 case ISIS_TLV_PREFIX_NEIGH
:
2585 if (tmp
< sizeof(struct isis_metric_block
))
2587 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2589 printf("\n\t Metric Block");
2590 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2591 tptr
+=sizeof(struct isis_metric_block
);
2592 tmp
-=sizeof(struct isis_metric_block
);
2595 if (!TTEST2(*tptr
, 1))
2597 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2598 if (prefix_len
< 2) {
2599 printf("\n\t\tAddress: prefix length %u < 2", prefix_len
);
2603 if (tmp
< prefix_len
/2)
2605 if (!TTEST2(*tptr
, prefix_len
/2))
2607 printf("\n\t\tAddress: %s/%u",
2608 isonsap_string(tptr
,prefix_len
/2),
2615 case ISIS_TLV_IIH_SEQNR
:
2616 if (tmp
< ISIS_TLV_IIH_SEQNR_MINLEN
)
2618 if (!TTEST2(*tptr
, ISIS_TLV_IIH_SEQNR_MINLEN
)) /* check if four bytes are on the wire */
2620 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
2623 case ISIS_TLV_VENDOR_PRIVATE
:
2624 if (tmp
< ISIS_TLV_VENDOR_PRIVATE_MINLEN
)
2626 if (!TTEST2(*tptr
, ISIS_TLV_VENDOR_PRIVATE_MINLEN
)) /* check if enough byte for a full oui */
2628 vendor_id
= EXTRACT_24BITS(tptr
);
2629 printf("\n\t Vendor: %s (%u)",
2630 tok2str(oui_values
,"Unknown",vendor_id
),
2634 if (tmp
> 0) /* hexdump the rest */
2635 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
2639 * FIXME those are the defined TLVs that lack a decoder
2640 * you are welcome to contribute code ;-)
2643 case ISIS_TLV_DECNET_PHASE4
:
2644 case ISIS_TLV_LUCENT_PRIVATE
:
2645 case ISIS_TLV_IPAUTH
:
2646 case ISIS_TLV_NORTEL_PRIVATE1
:
2647 case ISIS_TLV_NORTEL_PRIVATE2
:
2651 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
2656 /* do we want to see an additionally hexdump ? */
2658 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2663 packet_len
-= tlv_len
;
2666 if (packet_len
!= 0) {
2667 printf("\n\t %u straggler bytes", packet_len
);
2672 fputs("[|isis]", stdout
);
2676 printf("\n\t\t packet exceeded snapshot");
2681 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2685 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2687 int32_t c0
= 0, c1
= 0;
2689 while ((int)--len
>= 0) {
2701 * c-style: whitesmith