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.
30 static const char rcsid[] _U_ =
31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.19 2005/09/20 10:15:22 hannes Exp $ (LBL)";
38 #include <tcpdump-stdinc.h>
43 #include "interface.h"
44 #include "addrtoname.h"
45 #include "ethertype.h"
52 #define IPV4 1 /* AFI value */
53 #define IPV6 2 /* AFI value */
56 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
59 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
60 #define NODE_ID_LEN SYSTEM_ID_LEN+1
61 #define LSP_ID_LEN SYSTEM_ID_LEN+2
63 #define ISIS_VERSION 1
64 #define ESIS_VERSION 1
65 #define CLNP_VERSION 1
67 #define ISIS_PDU_TYPE_MASK 0x1F
68 #define ESIS_PDU_TYPE_MASK 0x1F
69 #define CLNP_PDU_TYPE_MASK 0x1F
70 #define CLNP_FLAG_MASK 0xE0
71 #define ISIS_LAN_PRIORITY_MASK 0x7F
73 #define ISIS_PDU_L1_LAN_IIH 15
74 #define ISIS_PDU_L2_LAN_IIH 16
75 #define ISIS_PDU_PTP_IIH 17
76 #define ISIS_PDU_L1_LSP 18
77 #define ISIS_PDU_L2_LSP 20
78 #define ISIS_PDU_L1_CSNP 24
79 #define ISIS_PDU_L2_CSNP 25
80 #define ISIS_PDU_L1_PSNP 26
81 #define ISIS_PDU_L2_PSNP 27
83 static struct tok isis_pdu_values[] = {
84 { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
85 { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
86 { ISIS_PDU_PTP_IIH, "p2p IIH"},
87 { ISIS_PDU_L1_LSP, "L1 LSP"},
88 { ISIS_PDU_L2_LSP, "L2 LSP"},
89 { ISIS_PDU_L1_CSNP, "L1 CSNP"},
90 { ISIS_PDU_L2_CSNP, "L2 CSNP"},
91 { ISIS_PDU_L1_PSNP, "L1 PSNP"},
92 { ISIS_PDU_L2_PSNP, "L2 PSNP"},
97 * A TLV is a tuple of a type, length and a value and is normally used for
98 * encoding information in all sorts of places. This is an enumeration of
99 * the well known types.
101 * list taken from rfc3359 plus some memory from veterans ;-)
104 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
105 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
106 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
107 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
108 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
109 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
110 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
111 #define ISIS_TLV_PADDING 8 /* iso10589 */
112 #define ISIS_TLV_LSP 9 /* iso10589 */
113 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
114 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
115 #define ISIS_TLV_CHECKSUM_MINLEN 2
116 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
117 #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
118 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
119 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
120 #define ISIS_TLV_DECNET_PHASE4 42
121 #define ISIS_TLV_LUCENT_PRIVATE 66
122 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
123 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
124 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
125 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
126 #define ISIS_TLV_IDRP_INFO_MINLEN 1
127 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
128 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
129 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
130 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
131 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
132 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
133 #define ISIS_TLV_NORTEL_PRIVATE1 176
134 #define ISIS_TLV_NORTEL_PRIVATE2 177
135 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
136 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
137 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
138 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
139 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
140 #define ISIS_TLV_MT_SUPPORTED_MINLEN 2
141 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
142 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
143 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
144 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
145 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
146 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
147 #define ISIS_TLV_IIH_SEQNR_MINLEN 4
148 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
149 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
151 static struct tok isis_tlv_values[] = {
152 { ISIS_TLV_AREA_ADDR, "Area address(es)"},
153 { ISIS_TLV_IS_REACH, "IS Reachability"},
154 { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
155 { ISIS_TLV_PART_DIS, "Partition DIS"},
156 { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
157 { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
158 { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
159 { ISIS_TLV_PADDING, "Padding"},
160 { ISIS_TLV_LSP, "LSP entries"},
161 { ISIS_TLV_AUTH, "Authentication"},
162 { ISIS_TLV_CHECKSUM, "Checksum"},
163 { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
164 { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
165 { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
166 { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
167 { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
168 { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
169 { ISIS_TLV_PROTOCOLS, "Protocols supported"},
170 { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
171 { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
172 { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
173 { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
174 { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
175 { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
176 { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
177 { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
178 { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
179 { ISIS_TLV_HOSTNAME, "Hostname"},
180 { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
181 { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
182 { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
183 { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
184 { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
185 { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
186 { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
187 { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
188 { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
189 { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
193 #define ESIS_OPTION_PROTOCOLS 129
194 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
195 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
196 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
197 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
198 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
199 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
201 static struct tok esis_option_values[] = {
202 { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
203 { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
204 { ESIS_OPTION_SECURITY, "Security" },
205 { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
206 { ESIS_OPTION_PRIORITY, "Priority" },
207 { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
208 { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
212 #define CLNP_OPTION_DISCARD_REASON 193
213 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
214 #define CLNP_OPTION_SECURITY 197 /* iso8473 */
215 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
216 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
217 #define CLNP_OPTION_PADDING 204 /* iso8473 */
218 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
220 static struct tok clnp_option_values[] = {
221 { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
222 { CLNP_OPTION_PRIORITY, "Priority"},
223 { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
224 { CLNP_OPTION_SECURITY, "Security"},
225 { CLNP_OPTION_SOURCE_ROUTING, "Source Routing"},
226 { CLNP_OPTION_ROUTE_RECORDING, "Route Recording"},
227 { CLNP_OPTION_PADDING, "Padding"},
231 static struct tok clnp_option_rfd_class_values[] = {
234 { 0x9, "Source Routeing"},
236 { 0xb, "PDU Discarded"},
237 { 0xc, "Reassembly"},
241 static struct tok clnp_option_rfd_general_values[] = {
242 { 0x0, "Reason not specified"},
243 { 0x1, "Protocol procedure error"},
244 { 0x2, "Incorrect checksum"},
245 { 0x3, "PDU discarded due to congestion"},
246 { 0x4, "Header syntax error (cannot be parsed)"},
247 { 0x5, "Segmentation needed but not permitted"},
248 { 0x6, "Incomplete PDU received"},
249 { 0x7, "Duplicate option"},
253 static struct tok clnp_option_rfd_address_values[] = {
254 { 0x0, "Destination address unreachable"},
255 { 0x1, "Destination address unknown"},
259 static struct tok clnp_option_rfd_source_routeing_values[] = {
260 { 0x0, "Unspecified source routeing error"},
261 { 0x1, "Syntax error in source routeing field"},
262 { 0x2, "Unknown address in source routeing field"},
263 { 0x3, "Path not acceptable"},
267 static struct tok clnp_option_rfd_lifetime_values[] = {
268 { 0x0, "Lifetime expired while data unit in transit"},
269 { 0x1, "Lifetime expired during reassembly"},
273 static struct tok clnp_option_rfd_pdu_discard_values[] = {
274 { 0x0, "Unsupported option not specified"},
275 { 0x1, "Unsupported protocol version"},
276 { 0x2, "Unsupported security option"},
277 { 0x3, "Unsupported source routeing option"},
278 { 0x4, "Unsupported recording of route option"},
282 static struct tok clnp_option_rfd_reassembly_values[] = {
283 { 0x0, "Reassembly interference"},
287 /* array of 16 error-classes */
288 static struct tok *clnp_option_rfd_error_class[] = {
289 clnp_option_rfd_general_values,
297 clnp_option_rfd_address_values,
298 clnp_option_rfd_source_routeing_values,
299 clnp_option_rfd_lifetime_values,
300 clnp_option_rfd_pdu_discard_values,
301 clnp_option_rfd_reassembly_values,
307 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
308 #define CLNP_OPTION_SCOPE_MASK 0xc0
309 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
310 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
311 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
313 static struct tok clnp_option_scope_values[] = {
314 { CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
315 { CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
316 { CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
320 static struct tok clnp_option_sr_rr_values[] = {
326 static struct tok clnp_option_sr_rr_string_values[] = {
327 { CLNP_OPTION_SOURCE_ROUTING, "source routing"},
328 { CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
332 static struct tok clnp_option_qos_global_values[] = {
334 { 0x10, "sequencing vs. delay"},
335 { 0x08, "congested"},
336 { 0x04, "delay vs. cost"},
337 { 0x02, "error vs. delay"},
338 { 0x01, "error vs. cost"},
342 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
343 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
344 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
345 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
346 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
347 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
348 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
349 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
350 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
351 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
352 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
353 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
354 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
356 static struct tok isis_ext_is_reach_subtlv_values[] = {
357 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
358 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
359 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
360 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
361 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
362 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
363 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
364 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
365 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
366 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
367 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
368 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" },
369 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" },
370 { 250, "Reserved for cisco specific extensions" },
371 { 251, "Reserved for cisco specific extensions" },
372 { 252, "Reserved for cisco specific extensions" },
373 { 253, "Reserved for cisco specific extensions" },
374 { 254, "Reserved for cisco specific extensions" },
375 { 255, "Reserved for future expansion" },
379 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
380 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
381 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
383 static struct tok isis_ext_ip_reach_subtlv_values[] = {
384 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
385 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
386 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
390 #define ISIS_SUBTLV_AUTH_SIMPLE 1
391 #define ISIS_SUBTLV_AUTH_MD5 54
392 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
393 #define ISIS_SUBTLV_AUTH_PRIVATE 255
395 static struct tok isis_subtlv_auth_values[] = {
396 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
397 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
398 { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
402 #define ISIS_SUBTLV_IDRP_RES 0
403 #define ISIS_SUBTLV_IDRP_LOCAL 1
404 #define ISIS_SUBTLV_IDRP_ASN 2
406 static struct tok isis_subtlv_idrp_values[] = {
407 { ISIS_SUBTLV_IDRP_RES, "Reserved"},
408 { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
409 { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
413 #define CLNP_SEGMENT_PART 0x80
414 #define CLNP_MORE_SEGMENTS 0x40
415 #define CLNP_REQUEST_ER 0x20
417 static struct tok clnp_flag_values[] = {
418 { CLNP_SEGMENT_PART, "Segmentation permitted"},
419 { CLNP_MORE_SEGMENTS, "more Segments"},
420 { CLNP_REQUEST_ER, "request Error Report"},
424 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
425 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
426 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
427 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
428 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
429 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
430 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
431 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
433 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
434 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
436 static struct tok isis_mt_flag_values[] = {
437 { 0x4000, "sub-TLVs present"},
438 { 0x8000, "ATT bit set"},
442 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
443 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
445 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
446 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
448 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
449 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
450 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
451 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
453 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
455 static struct tok isis_mt_values[] = {
456 { 0, "IPv4 unicast"},
457 { 1, "In-Band Management"},
458 { 2, "IPv6 unicast"},
460 { 4095, "Development, Experimental or Proprietary"},
464 static struct tok isis_iih_circuit_type_values[] = {
465 { 1, "Level 1 only"},
466 { 2, "Level 2 only"},
467 { 3, "Level 1, Level 2"},
471 #define ISIS_LSP_TYPE_UNUSED0 0
472 #define ISIS_LSP_TYPE_LEVEL_1 1
473 #define ISIS_LSP_TYPE_UNUSED2 2
474 #define ISIS_LSP_TYPE_LEVEL_2 3
476 static struct tok isis_lsp_istype_values[] = {
477 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
478 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
479 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
480 { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"},
485 * Katz's point to point adjacency TLV uses codes to tell us the state of
486 * the remote adjacency. Enumerate them.
489 #define ISIS_PTP_ADJ_UP 0
490 #define ISIS_PTP_ADJ_INIT 1
491 #define ISIS_PTP_ADJ_DOWN 2
493 static struct tok isis_ptp_adjancey_values[] = {
494 { ISIS_PTP_ADJ_UP, "Up" },
495 { ISIS_PTP_ADJ_INIT, "Initializing" },
496 { ISIS_PTP_ADJ_DOWN, "Down" },
500 struct isis_tlv_ptp_adj {
501 u_int8_t adjacency_state;
502 u_int8_t extd_local_circuit_id[4];
503 u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
504 u_int8_t neighbor_extd_local_circuit_id[4];
507 static int osi_cksum(const u_int8_t *, u_int);
508 static int clnp_print(const u_int8_t *, u_int);
509 static void esis_print(const u_int8_t *, u_int);
510 static int isis_print(const u_int8_t *, u_int);
512 struct isis_metric_block {
513 u_int8_t metric_default;
514 u_int8_t metric_delay;
515 u_int8_t metric_expense;
516 u_int8_t metric_error;
519 struct isis_tlv_is_reach {
520 struct isis_metric_block isis_metric_block;
521 u_int8_t neighbor_nodeid[NODE_ID_LEN];
524 struct isis_tlv_es_reach {
525 struct isis_metric_block isis_metric_block;
526 u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
529 struct isis_tlv_ip_reach {
530 struct isis_metric_block isis_metric_block;
535 static struct tok isis_is_reach_virtual_values[] = {
536 { 0, "IsNotVirtual"},
541 static struct tok isis_restart_flag_values[] = {
542 { 0x1, "Restart Request"},
543 { 0x2, "Restart Acknowledgement"},
544 { 0x4, "Suppress adjacency advertisement"},
548 struct isis_common_header {
551 u_int8_t version; /* Protocol version */
553 u_int8_t pdu_type; /* 3 MSbits are reserved */
554 u_int8_t pdu_version; /* Packet format version */
559 struct isis_iih_lan_header {
560 u_int8_t circuit_type;
561 u_int8_t source_id[SYSTEM_ID_LEN];
562 u_int8_t holding_time[2];
565 u_int8_t lan_id[NODE_ID_LEN];
568 struct isis_iih_ptp_header {
569 u_int8_t circuit_type;
570 u_int8_t source_id[SYSTEM_ID_LEN];
571 u_int8_t holding_time[2];
576 struct isis_lsp_header {
578 u_int8_t remaining_lifetime[2];
579 u_int8_t lsp_id[LSP_ID_LEN];
580 u_int8_t sequence_number[4];
581 u_int8_t checksum[2];
585 struct isis_csnp_header {
587 u_int8_t source_id[NODE_ID_LEN];
588 u_int8_t start_lsp_id[LSP_ID_LEN];
589 u_int8_t end_lsp_id[LSP_ID_LEN];
592 struct isis_psnp_header {
594 u_int8_t source_id[NODE_ID_LEN];
597 struct isis_tlv_lsp {
598 u_int8_t remaining_lifetime[2];
599 u_int8_t lsp_id[LSP_ID_LEN];
600 u_int8_t sequence_number[4];
601 u_int8_t checksum[2];
604 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
605 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
606 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
607 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
608 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
609 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
611 void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
613 const struct isis_common_header *header;
615 header = (const struct isis_common_header *)p;
617 if (caplen <= 1) { /* enough bytes on the wire ? */
623 printf("OSI NLPID %s (0x%02x): ",
624 tok2str(nlpid_values,"Unknown",*p),
630 if (!clnp_print(p, length))
631 print_unknown_data(p,"\n\t",caplen);
635 esis_print(p, length);
639 if (!isis_print(p, length))
640 print_unknown_data(p,"\n\t",caplen);
644 (void)printf("%slength: %u",
650 q933_print(p+1, length-1);
654 ip_print(gndo, p+1, length-1);
659 ip6_print(p+1, length-1);
664 ppp_print(p+1, length-1);
669 printf("OSI NLPID 0x%02x unknown",*p);
670 (void)printf("%slength: %u",
674 print_unknown_data(p,"\n\t",caplen);
679 #define CLNP_PDU_ER 1
680 #define CLNP_PDU_DT 28
681 #define CLNP_PDU_MD 29
682 #define CLNP_PDU_ERQ 30
683 #define CLNP_PDU_ERP 31
685 static struct tok clnp_pdu_values[] = {
686 { CLNP_PDU_ER, "Error Report"},
687 { CLNP_PDU_MD, "MD"},
688 { CLNP_PDU_DT, "Data"},
689 { CLNP_PDU_ERQ, "Echo Request"},
690 { CLNP_PDU_ERP, "Echo Response"},
694 struct clnp_header_t {
696 u_int8_t length_indicator;
698 u_int8_t lifetime; /* units of 500ms */
700 u_int8_t segment_length[2];
704 struct clnp_segment_header_t {
705 u_int8_t data_unit_id[2];
706 u_int8_t segment_offset[2];
707 u_int8_t total_length[2];
712 * Decode CLNP packets. Return 0 on error.
715 static int clnp_print (const u_int8_t *pptr, u_int length)
717 const u_int8_t *optr,*source_address,*dest_address;
718 u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
719 const struct clnp_header_t *clnp_header;
720 const struct clnp_segment_header_t *clnp_segment_header;
721 u_int8_t rfd_error_major,rfd_error_minor;
723 clnp_header = (const struct clnp_header_t *) pptr;
724 TCHECK(*clnp_header);
726 li = clnp_header->length_indicator;
733 * Sanity checking of the header.
736 if (clnp_header->version != CLNP_VERSION) {
737 printf("version %d packet not supported", clnp_header->version);
741 /* FIXME further header sanity checking */
743 clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
744 clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
746 pptr += sizeof(struct clnp_header_t);
747 li -= sizeof(struct clnp_header_t);
748 dest_address_length = *pptr;
749 dest_address = pptr + 1;
751 pptr += (1 + dest_address_length);
752 li -= (1 + dest_address_length);
753 source_address_length = *pptr;
754 source_address = pptr +1;
756 pptr += (1 + source_address_length);
757 li -= (1 + source_address_length);
760 printf("%s%s > %s, %s, length %u",
762 isonsap_string(source_address, source_address_length),
763 isonsap_string(dest_address, dest_address_length),
764 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
768 printf("%slength %u",eflag ? "" : ", ",length);
770 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ",
771 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
772 clnp_header->length_indicator,
773 clnp_header->version,
774 clnp_header->lifetime/2,
775 (clnp_header->lifetime%2)*5,
776 EXTRACT_16BITS(clnp_header->segment_length),
777 EXTRACT_16BITS(clnp_header->cksum));
779 /* do not attempt to verify the checksum if it is zero */
780 if (EXTRACT_16BITS(clnp_header->cksum) == 0)
781 printf("(unverified)");
782 else printf("(%s)", osi_cksum(optr, clnp_header->length_indicator) ? "incorrect" : "correct");
784 printf("\n\tFlags [%s]",
785 bittok2str(clnp_flag_values,"none",clnp_flags));
787 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
788 source_address_length,
789 isonsap_string(source_address, source_address_length),
791 isonsap_string(dest_address,dest_address_length));
793 if (clnp_flags & CLNP_SEGMENT_PART) {
794 clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
795 TCHECK(*clnp_segment_header);
796 printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
797 EXTRACT_16BITS(clnp_segment_header->data_unit_id),
798 EXTRACT_16BITS(clnp_segment_header->segment_offset),
799 EXTRACT_16BITS(clnp_segment_header->total_length));
800 pptr+=sizeof(const struct clnp_segment_header_t);
801 li-=sizeof(const struct clnp_segment_header_t);
804 /* now walk the options */
807 const u_int8_t *tptr;
811 printf(", bad opts/li");
817 TCHECK2(*pptr, opli);
819 printf(", opt (%d) too long", op);
826 printf("\n\t %s Option #%u, length %u, value: ",
827 tok2str(clnp_option_values,"Unknown",op),
834 case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
835 case CLNP_OPTION_SOURCE_ROUTING:
837 tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
838 tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op));
839 nsap_offset=*(tptr+1);
840 if (nsap_offset == 0) {
841 printf(" Bad NSAP offset (0)");
844 nsap_offset-=1; /* offset to nsap list */
845 if (nsap_offset > tlen) {
846 printf(" Bad NSAP offset (past end of option)");
852 source_address_length=*tptr;
853 if (tlen < source_address_length+1) {
854 printf("\n\t NSAP address goes past end of option");
857 if (source_address_length > 0) {
858 source_address=(tptr+1);
859 TCHECK2(*source_address, source_address_length);
860 printf("\n\t NSAP address (length %u): %s",
861 source_address_length,
862 isonsap_string(source_address, source_address_length));
864 tlen-=source_address_length+1;
868 case CLNP_OPTION_PRIORITY:
869 printf("0x%1x", *tptr&0x0f);
872 case CLNP_OPTION_QOS_MAINTENANCE:
873 printf("\n\t Format Code: %s",
874 tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK));
876 if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
877 printf("\n\t QoS Flags [%s]",
878 bittok2str(clnp_option_qos_global_values,
880 *tptr&CLNP_OPTION_OPTION_QOS_MASK));
883 case CLNP_OPTION_SECURITY:
884 printf("\n\t Format Code: %s, Security-Level %u",
885 tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
889 case CLNP_OPTION_DISCARD_REASON:
890 rfd_error_major = (*tptr&0xf0) >> 4;
891 rfd_error_minor = *tptr&0x0f;
892 printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
893 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
895 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
899 case CLNP_OPTION_PADDING:
900 printf("padding data");
904 * FIXME those are the defined Options that lack a decoder
905 * you are welcome to contribute code ;-)
909 print_unknown_data(tptr,"\n\t ",opli);
913 print_unknown_data(pptr,"\n\t ",opli);
917 switch (clnp_pdu_type) {
919 case CLNP_PDU_ER: /* fall through */
922 if (*(pptr) == NLPID_CLNP) {
923 printf("\n\t-----original packet-----\n\t");
924 /* FIXME recursion protection */
925 clnp_print(pptr, length-clnp_header->length_indicator);
934 /* dump the PDU specific data */
935 if (length-(pptr-optr) > 0) {
936 printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator);
937 print_unknown_data(pptr,"\n\t ",length-(pptr-optr));
944 fputs("[|clnp]", stdout);
950 #define ESIS_PDU_REDIRECT 6
951 #define ESIS_PDU_ESH 2
952 #define ESIS_PDU_ISH 4
954 static struct tok esis_pdu_values[] = {
955 { ESIS_PDU_REDIRECT, "redirect"},
956 { ESIS_PDU_ESH, "ESH"},
957 { ESIS_PDU_ISH, "ISH"},
961 struct esis_header_t {
963 u_int8_t length_indicator;
967 u_int8_t holdtime[2];
972 esis_print(const u_int8_t *pptr, u_int length)
974 const u_int8_t *optr;
975 u_int li,esis_pdu_type,source_address_length, source_address_number;
976 const struct esis_header_t *esis_header;
985 printf("no header at all!");
989 esis_header = (const struct esis_header_t *) pptr;
990 TCHECK(*esis_header);
991 li = esis_header->length_indicator;
995 * Sanity checking of the header.
998 if (esis_header->nlpid != NLPID_ESIS) {
999 printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
1003 if (esis_header->version != ESIS_VERSION) {
1004 printf(" version %d packet not supported", esis_header->version);
1009 printf(" length indicator(%d) > PDU size (%d)!", li, length);
1013 if (li < sizeof(struct esis_header_t) + 2) {
1014 printf(" length indicator < min PDU size %d:", li);
1015 while (--length != 0)
1016 printf("%02X", *pptr++);
1020 esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
1023 printf("%s%s, length %u",
1025 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
1029 printf("%slength %u\n\t%s (%u)",
1032 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
1035 printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
1036 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header->cksum));
1037 /* do not attempt to verify the checksum if it is zero */
1038 if (EXTRACT_16BITS(esis_header->cksum) == 0)
1039 printf("(unverified)");
1041 printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct");
1043 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
1046 print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
1048 pptr += sizeof(struct esis_header_t);
1049 li -= sizeof(struct esis_header_t);
1051 switch (esis_pdu_type) {
1052 case ESIS_PDU_REDIRECT: {
1053 const u_int8_t *dst, *snpa, *neta;
1054 u_int dstl, snpal, netal;
1058 printf(", bad redirect/li");
1064 TCHECK2(*pptr, dstl);
1066 printf(", bad redirect/li");
1072 printf("\n\t %s", isonsap_string(dst,dstl));
1076 printf(", bad redirect/li");
1082 TCHECK2(*pptr, snpal);
1084 printf(", bad redirect/li");
1092 printf(", bad redirect/li");
1097 TCHECK2(*pptr, netal);
1099 printf(", bad redirect/li");
1107 printf("\n\t %s", etheraddr_string(snpa));
1109 printf("\n\t %s", isonsap_string(neta,netal));
1116 printf(", bad esh/li");
1119 source_address_number = *pptr;
1123 printf("\n\t Number of Source Addresses: %u", source_address_number);
1125 while (source_address_number > 0) {
1128 printf(", bad esh/li");
1131 source_address_length = *pptr;
1135 TCHECK2(*pptr, source_address_length);
1136 if (li < source_address_length) {
1137 printf(", bad esh/li");
1140 printf("\n\t NET (length: %u): %s",
1141 source_address_length,
1142 isonsap_string(pptr,source_address_length));
1143 pptr += source_address_length;
1144 li -= source_address_length;
1145 source_address_number--;
1150 case ESIS_PDU_ISH: {
1153 printf(", bad ish/li");
1156 source_address_length = *pptr;
1159 TCHECK2(*pptr, source_address_length);
1160 if (li < source_address_length) {
1161 printf(", bad ish/li");
1164 printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length));
1165 pptr += source_address_length;
1166 li -= source_address_length;
1173 print_unknown_data(pptr,"\n\t ",snapend-pptr);
1178 /* now walk the options */
1181 const u_int8_t *tptr;
1185 printf(", bad opts/li");
1192 printf(", opt (%d) too long", op);
1198 printf("\n\t %s Option #%u, length %u, value: ",
1199 tok2str(esis_option_values,"Unknown",op),
1205 case ESIS_OPTION_ES_CONF_TIME:
1207 printf("%us", EXTRACT_16BITS(tptr));
1210 case ESIS_OPTION_PROTOCOLS:
1213 printf("%s (0x%02x)",
1214 tok2str(nlpid_values,
1218 if (opli>1) /* further NPLIDs ? - put comma */
1226 * FIXME those are the defined Options that lack a decoder
1227 * you are welcome to contribute code ;-)
1230 case ESIS_OPTION_QOS_MAINTENANCE:
1231 case ESIS_OPTION_SECURITY:
1232 case ESIS_OPTION_PRIORITY:
1233 case ESIS_OPTION_ADDRESS_MASK:
1234 case ESIS_OPTION_SNPA_MASK:
1237 print_unknown_data(tptr,"\n\t ",opli);
1241 print_unknown_data(pptr,"\n\t ",opli);
1248 /* shared routine for printing system, node and lsp-ids */
1250 isis_print_id(const u_int8_t *cp, int id_len)
1253 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1256 for (i = 1; i <= SYSTEM_ID_LEN; i++) {
1257 snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++);
1259 if (i == 2 || i == 4)
1262 if (id_len >= NODE_ID_LEN) {
1263 snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++);
1266 if (id_len == LSP_ID_LEN)
1267 snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp);
1271 /* print the 4-byte metric block which is common found in the old-style TLVs */
1273 isis_print_metric_block (const struct isis_metric_block *isis_metric_block)
1275 printf(", Default Metric: %d, %s",
1276 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
1277 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal");
1278 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
1279 printf("\n\t\t Delay Metric: %d, %s",
1280 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
1281 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal");
1282 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
1283 printf("\n\t\t Expense Metric: %d, %s",
1284 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
1285 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal");
1286 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
1287 printf("\n\t\t Error Metric: %d, %s",
1288 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
1289 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal");
1291 return(1); /* everything is ok */
1295 isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
1298 const struct isis_tlv_ip_reach *tlv_ip_reach;
1300 tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
1302 while (length > 0) {
1303 if ((size_t)length < sizeof(*tlv_ip_reach)) {
1304 printf("short IPv4 Reachability (%d vs %lu)",
1306 (unsigned long)sizeof(*tlv_ip_reach));
1310 if (!TTEST(*tlv_ip_reach))
1313 prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
1315 if (prefix_len == -1)
1316 printf("%sIPv4 prefix: %s mask %s",
1318 ipaddr_string((tlv_ip_reach->prefix)),
1319 ipaddr_string((tlv_ip_reach->mask)));
1321 printf("%sIPv4 prefix: %15s/%u",
1323 ipaddr_string((tlv_ip_reach->prefix)),
1326 printf(", Distribution: %s, Metric: %u, %s",
1327 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
1328 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
1329 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal");
1331 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
1332 printf("%s Delay Metric: %u, %s",
1334 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
1335 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal");
1337 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
1338 printf("%s Expense Metric: %u, %s",
1340 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
1341 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal");
1343 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
1344 printf("%s Error Metric: %u, %s",
1346 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
1347 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal");
1349 length -= sizeof(struct isis_tlv_ip_reach);
1356 * this is the common IP-REACH subTLV decoder it is called
1357 * from various EXTD-IP REACH TLVs (135,235,236,237)
1361 isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
1363 /* first lets see if we know the subTLVs name*/
1364 printf("%s%s subTLV #%u, length: %u",
1366 tok2str(isis_ext_ip_reach_subtlv_values,
1372 if (!TTEST2(*tptr,subl))
1376 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
1377 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
1379 printf(", 0x%08x (=%u)",
1380 EXTRACT_32BITS(tptr),
1381 EXTRACT_32BITS(tptr));
1386 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
1388 printf(", 0x%08x%08x",
1389 EXTRACT_32BITS(tptr),
1390 EXTRACT_32BITS(tptr+4));
1396 if(!print_unknown_data(tptr,"\n\t\t ",
1404 printf("%spacket exceeded snapshot",ident);
1409 * this is the common IS-REACH subTLV decoder it is called
1410 * from isis_print_ext_is_reach()
1414 isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) {
1416 u_int te_class,priority_level;
1417 union { /* int to float conversion buffer for several subTLVs */
1422 /* first lets see if we know the subTLVs name*/
1423 printf("%s%s subTLV #%u, length: %u",
1425 tok2str(isis_ext_is_reach_subtlv_values,
1431 if (!TTEST2(*tptr,subl))
1435 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
1436 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
1437 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
1439 printf(", 0x%08x", EXTRACT_32BITS(tptr));
1440 if (subl == 8) /* draft-ietf-isis-gmpls-extensions */
1441 printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
1444 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
1445 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
1446 if (subl >= sizeof(struct in_addr))
1447 printf(", %s", ipaddr_string(tptr));
1449 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
1450 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
1452 bw.i = EXTRACT_32BITS(tptr);
1453 printf(", %.3f Mbps", bw.f*8/1000000 );
1456 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
1458 for (te_class = 0; te_class < 8; te_class++) {
1459 bw.i = EXTRACT_32BITS(tptr);
1460 printf("%s TE-Class %u: %.3f Mbps",
1468 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
1469 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
1470 printf("%sBandwidth Constraints Model ID: %s (%u)",
1472 tok2str(diffserv_te_bc_values, "unknown", *tptr),
1475 /* decode BCs until the subTLV ends */
1476 for (te_class = 0; te_class < (subl-1)/4; te_class++) {
1477 bw.i = EXTRACT_32BITS(tptr);
1478 printf("%s Bandwidth constraint CT%u: %.3f Mbps",
1485 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
1487 printf(", %u", EXTRACT_24BITS(tptr));
1489 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
1491 printf(", %s, Priority %u",
1492 bittok2str(gmpls_link_prot_values, "none", *tptr),
1496 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
1498 printf("%s Interface Switching Capability:%s",
1500 tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)));
1501 printf(", LSP Encoding: %s",
1502 tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
1504 printf("%s Max LSP Bandwidth:",ident);
1505 for (priority_level = 0; priority_level < 8; priority_level++) {
1506 bw.i = EXTRACT_32BITS(tptr);
1507 printf("%s priority level %d: %.3f Mbps",
1514 /* there is some optional stuff left to decode but this is as of yet
1515 not specified so just lets hexdump what is left */
1517 if(!print_unknown_data(tptr,"\n\t\t ",
1524 if(!print_unknown_data(tptr,"\n\t\t ",
1532 printf("%spacket exceeded snapshot",ident);
1538 * this is the common IS-REACH decoder it is called
1539 * from various EXTD-IS REACH style TLVs (22,24,222)
1543 isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
1545 char ident_buffer[20];
1546 int subtlv_type,subtlv_len,subtlv_sum_len;
1547 int proc_bytes = 0; /* how many bytes did we process ? */
1549 if (!TTEST2(*tptr, NODE_ID_LEN))
1552 printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
1553 tptr+=(NODE_ID_LEN);
1555 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
1556 if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
1558 printf(", Metric: %d",EXTRACT_24BITS(tptr));
1562 if (!TTEST2(*tptr, 1))
1564 subtlv_sum_len=*(tptr++); /* read out subTLV length */
1565 proc_bytes=NODE_ID_LEN+3+1;
1566 printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no ");
1567 if (subtlv_sum_len) {
1568 printf(" (%u)",subtlv_sum_len);
1569 while (subtlv_sum_len>0) {
1570 if (!TTEST2(*tptr,2))
1572 subtlv_type=*(tptr++);
1573 subtlv_len=*(tptr++);
1574 /* prepend the ident string */
1575 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
1576 if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer))
1579 subtlv_sum_len-=(subtlv_len+2);
1580 proc_bytes+=(subtlv_len+2);
1587 * this is the common Multi Topology ID decoder
1588 * it is called from various MT-TLVs (222,229,235,237)
1592 isis_print_mtid (const u_int8_t *tptr,const char *ident) {
1594 if (!TTEST2(*tptr, 2))
1599 tok2str(isis_mt_values,
1600 "Reserved for IETF Consensus",
1601 ISIS_MASK_MTID(EXTRACT_16BITS(tptr))));
1603 printf(" Topology (0x%03x), Flags: [%s]",
1604 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
1605 bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr))));
1611 * this is the common extended IP reach decoder
1612 * it is called from TLVs (135,235,236,237)
1613 * we process the TLV and optional subTLVs and return
1614 * the amount of processed bytes
1618 isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) {
1620 char ident_buffer[20];
1621 u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1622 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
1624 if (!TTEST2(*tptr, 4))
1626 metric = EXTRACT_32BITS(tptr);
1631 if (!TTEST2(*tptr, 1)) /* fetch status byte */
1633 status_byte=*(tptr++);
1634 bit_length = status_byte&0x3f;
1637 } else if (afi == IPV6) {
1638 if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
1640 status_byte=*(tptr++);
1641 bit_length=*(tptr++);
1645 return (0); /* somebody is fooling us */
1647 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
1649 if (!TTEST2(*tptr, byte_length))
1651 memset(prefix, 0, sizeof(struct in6_addr)); /* clear the copy buffer */
1652 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
1654 processed+=byte_length;
1657 printf("%sIPv4 prefix: %15s/%u",
1659 ipaddr_string(prefix),
1663 printf("%sIPv6 prefix: %s/%u",
1665 ip6addr_string(prefix),
1669 printf(", Distribution: %s, Metric: %u",
1670 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
1673 if (afi == IPV4 && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
1674 printf(", sub-TLVs present");
1678 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
1679 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
1682 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte) && afi == IPV4) ||
1683 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == IPV6)) {
1684 /* assume that one prefix can hold more
1685 than one subTLV - therefore the first byte must reflect
1686 the aggregate bytecount of the subTLVs for this prefix
1688 if (!TTEST2(*tptr, 1))
1691 processed+=sublen+1;
1692 printf(" (%u)",sublen); /* print out subTLV length */
1695 if (!TTEST2(*tptr,2))
1697 subtlvtype=*(tptr++);
1698 subtlvlen=*(tptr++);
1699 /* prepend the ident string */
1700 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
1701 if(!isis_print_ip_reach_subtlv(tptr,subtlvtype,subtlvlen,ident_buffer))
1704 sublen-=(subtlvlen+2);
1712 * Decode IS-IS packets. Return 0 on error.
1715 static int isis_print (const u_int8_t *p, u_int length)
1717 const struct isis_common_header *isis_header;
1719 const struct isis_iih_lan_header *header_iih_lan;
1720 const struct isis_iih_ptp_header *header_iih_ptp;
1721 const struct isis_lsp_header *header_lsp;
1722 const struct isis_csnp_header *header_csnp;
1723 const struct isis_psnp_header *header_psnp;
1725 const struct isis_tlv_lsp *tlv_lsp;
1726 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
1727 const struct isis_tlv_is_reach *tlv_is_reach;
1728 const struct isis_tlv_es_reach *tlv_es_reach;
1730 u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
1731 u_int8_t ext_is_len, ext_ip_len, mt_len;
1732 const u_int8_t *optr, *pptr, *tptr;
1733 u_short packet_len,pdu_len;
1737 optr = p; /* initialize the _o_riginal pointer to the packet start -
1738 need it for parsing the checksum TLV */
1739 isis_header = (const struct isis_common_header *)p;
1740 TCHECK(*isis_header);
1741 pptr = p+(ISIS_COMMON_HEADER_SIZE);
1742 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
1743 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
1744 header_lsp = (const struct isis_lsp_header *)pptr;
1745 header_csnp = (const struct isis_csnp_header *)pptr;
1746 header_psnp = (const struct isis_psnp_header *)pptr;
1752 * Sanity checking of the header.
1755 if (isis_header->version != ISIS_VERSION) {
1756 printf("version %d packet not supported", isis_header->version);
1760 if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
1761 printf("system ID length of %d is not supported",
1762 isis_header->id_length);
1766 if (isis_header->pdu_version != ISIS_VERSION) {
1767 printf("version %d packet not supported", isis_header->pdu_version);
1771 max_area = isis_header->max_area;
1774 max_area = 3; /* silly shit */
1777 printf("bad packet -- 255 areas");
1783 id_length = isis_header->id_length;
1786 id_length = 6; /* silly shit again */
1788 case 1: /* 1-8 are valid sys-ID lenghts */
1798 id_length = 0; /* entirely useless */
1804 /* toss any non 6-byte sys-ID len PDUs */
1805 if (id_length != 6 ) {
1806 printf("bad packet -- illegal sys-ID length (%u)", id_length);
1810 pdu_type=isis_header->pdu_type;
1812 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1816 tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
1820 case ISIS_PDU_L1_LAN_IIH:
1821 case ISIS_PDU_L2_LAN_IIH:
1822 printf(", src-id %s",
1823 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
1824 printf(", lan-id %s, prio %u",
1825 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
1826 header_iih_lan->priority);
1828 case ISIS_PDU_PTP_IIH:
1829 printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
1831 case ISIS_PDU_L1_LSP:
1832 case ISIS_PDU_L2_LSP:
1833 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1834 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
1835 EXTRACT_32BITS(header_lsp->sequence_number),
1836 EXTRACT_16BITS(header_lsp->remaining_lifetime));
1838 case ISIS_PDU_L1_CSNP:
1839 case ISIS_PDU_L2_CSNP:
1840 printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
1842 case ISIS_PDU_L1_PSNP:
1843 case ISIS_PDU_L2_PSNP:
1844 printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
1848 printf(", length %u", length);
1853 /* ok they seem to want to know everything - lets fully decode it */
1854 printf("%slength %u", eflag ? "" : ", ",length);
1856 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1857 tok2str(isis_pdu_values,
1860 isis_header->fixed_len,
1861 isis_header->version,
1862 isis_header->pdu_version,
1864 isis_header->id_length,
1866 isis_header->max_area);
1869 if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
1870 return(0); /* for optionally debugging the common header */
1875 case ISIS_PDU_L1_LAN_IIH:
1876 case ISIS_PDU_L2_LAN_IIH:
1877 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
1878 printf(", bogus fixed header length %u should be %lu",
1879 isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
1883 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
1884 if (packet_len>pdu_len) {
1885 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1889 TCHECK(*header_iih_lan);
1890 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1891 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
1892 EXTRACT_16BITS(header_iih_lan->holding_time),
1893 tok2str(isis_iih_circuit_type_values,
1894 "unknown circuit type 0x%02x",
1895 header_iih_lan->circuit_type));
1897 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1898 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
1899 (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
1903 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE))
1907 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1908 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1911 case ISIS_PDU_PTP_IIH:
1912 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
1913 printf(", bogus fixed header length %u should be %lu",
1914 isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
1918 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
1919 if (packet_len>pdu_len) {
1920 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1924 TCHECK(*header_iih_ptp);
1925 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1926 isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
1927 EXTRACT_16BITS(header_iih_ptp->holding_time),
1928 tok2str(isis_iih_circuit_type_values,
1929 "unknown circuit type 0x%02x",
1930 header_iih_ptp->circuit_type));
1932 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1933 header_iih_ptp->circuit_id,
1937 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE))
1941 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1942 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1945 case ISIS_PDU_L1_LSP:
1946 case ISIS_PDU_L2_LSP:
1947 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
1948 printf(", bogus fixed header length %u should be %lu",
1949 isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
1953 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
1954 if (packet_len>pdu_len) {
1955 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1959 TCHECK(*header_lsp);
1960 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1961 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
1962 EXTRACT_32BITS(header_lsp->sequence_number),
1963 EXTRACT_16BITS(header_lsp->remaining_lifetime),
1964 EXTRACT_16BITS(header_lsp->checksum));
1966 /* if this is a purge do not attempt to verify the checksum */
1967 if ( EXTRACT_16BITS(header_lsp->remaining_lifetime) == 0 &&
1968 EXTRACT_16BITS(header_lsp->checksum) == 0)
1969 printf(" (purged)");
1971 /* verify the checksum -
1972 * checking starts at the lsp-id field at byte position [12]
1973 * hence the length needs to be reduced by 12 bytes */
1974 printf(" (%s)", (osi_cksum((u_int8_t *)header_lsp->lsp_id, length-12)) ? "incorrect" : "correct");
1976 printf(", PDU length: %u, Flags: [ %s",
1978 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
1980 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
1981 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "");
1982 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "");
1983 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "");
1984 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "");
1985 printf("ATT bit set, ");
1987 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
1988 printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
1991 if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE))
1995 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1996 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1999 case ISIS_PDU_L1_CSNP:
2000 case ISIS_PDU_L2_CSNP:
2001 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
2002 printf(", bogus fixed header length %u should be %lu",
2003 isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
2007 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
2008 if (packet_len>pdu_len) {
2009 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2013 TCHECK(*header_csnp);
2014 printf("\n\t source-id: %s, PDU length: %u",
2015 isis_print_id(header_csnp->source_id, NODE_ID_LEN),
2017 printf("\n\t start lsp-id: %s",
2018 isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
2019 printf("\n\t end lsp-id: %s",
2020 isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
2023 if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
2027 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2028 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2031 case ISIS_PDU_L1_PSNP:
2032 case ISIS_PDU_L2_PSNP:
2033 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
2034 printf("- bogus fixed header length %u should be %lu",
2035 isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
2039 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
2040 if (packet_len>pdu_len) {
2041 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2045 TCHECK(*header_psnp);
2046 printf("\n\t source-id: %s, PDU length: %u",
2047 isis_print_id(header_psnp->source_id, NODE_ID_LEN),
2051 if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE))
2055 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2056 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2060 if(!print_unknown_data(pptr,"\n\t ",length))
2066 * Now print the TLV's.
2069 while (packet_len >= 2) {
2070 if (pptr == snapend) {
2074 if (!TTEST2(*pptr, 2)) {
2075 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
2076 (long)(pptr-snapend));
2081 tmp =tlv_len; /* copy temporary len & pointer to packet data */
2084 if (tlv_len > packet_len) {
2088 /* first lets see if we know the TLVs name*/
2089 printf("\n\t %s TLV #%u, length: %u",
2090 tok2str(isis_tlv_values,
2096 if (tlv_len == 0) /* something is malformed */
2099 /* now check if we have a decoder otherwise do a hexdump at the end*/
2101 case ISIS_TLV_AREA_ADDR:
2102 if (!TTEST2(*tptr, 1))
2105 while (tmp && alen < tmp) {
2106 printf("\n\t Area address (length: %u): %s",
2108 isonsap_string(tptr,alen));
2111 if (tmp==0) /* if this is the last area address do not attemt a boundary check */
2113 if (!TTEST2(*tptr, 1))
2118 case ISIS_TLV_ISNEIGH:
2119 while (tmp >= ETHER_ADDR_LEN) {
2120 if (!TTEST2(*tptr, ETHER_ADDR_LEN))
2122 printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
2123 tmp -= ETHER_ADDR_LEN;
2124 tptr += ETHER_ADDR_LEN;
2128 case ISIS_TLV_ISNEIGH_VARLEN:
2129 if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
2131 lan_alen = *tptr++; /* LAN address length */
2132 if (lan_alen == 0) {
2133 printf("\n\t LAN address length 0 bytes (invalid)");
2137 printf("\n\t LAN address length %u bytes ",lan_alen);
2138 while (tmp >= lan_alen) {
2139 if (!TTEST2(*tptr, lan_alen))
2141 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
2147 case ISIS_TLV_PADDING:
2150 case ISIS_TLV_MT_IS_REACH:
2151 while (tmp >= 2+NODE_ID_LEN+3+1) {
2152 mt_len = isis_print_mtid(tptr, "\n\t ");
2153 if (mt_len == 0) /* did something go wrong ? */
2158 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
2159 if (ext_is_len == 0) /* did something go wrong ? */
2167 case ISIS_TLV_IS_ALIAS_ID:
2168 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
2169 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
2170 if (ext_is_len == 0) /* did something go wrong ? */
2177 case ISIS_TLV_EXT_IS_REACH:
2178 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
2179 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
2180 if (ext_is_len == 0) /* did something go wrong ? */
2186 case ISIS_TLV_IS_REACH:
2187 if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
2190 tok2str(isis_is_reach_virtual_values,
2191 "bogus virtual flag 0x%02x",
2193 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
2194 while (tmp >= sizeof(struct isis_tlv_is_reach)) {
2195 if (!TTEST(*tlv_is_reach))
2197 printf("\n\t IS Neighbor: %s",
2198 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
2199 isis_print_metric_block(&tlv_is_reach->isis_metric_block);
2200 tmp -= sizeof(struct isis_tlv_is_reach);
2205 case ISIS_TLV_ESNEIGH:
2206 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
2207 while (tmp >= sizeof(struct isis_tlv_es_reach)) {
2208 if (!TTEST(*tlv_es_reach))
2210 printf("\n\t ES Neighbor: %s",
2211 isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
2212 isis_print_metric_block(&tlv_es_reach->isis_metric_block);
2213 tmp -= sizeof(struct isis_tlv_es_reach);
2218 /* those two TLVs share the same format */
2219 case ISIS_TLV_INT_IP_REACH:
2220 case ISIS_TLV_EXT_IP_REACH:
2221 if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
2225 case ISIS_TLV_EXTD_IP_REACH:
2227 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
2228 if (ext_ip_len == 0) /* did something go wrong ? */
2235 case ISIS_TLV_MT_IP_REACH:
2237 mt_len = isis_print_mtid(tptr, "\n\t ");
2238 if (mt_len == 0) /* did something go wrong ? */
2243 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
2244 if (ext_ip_len == 0) /* did something go wrong ? */
2252 case ISIS_TLV_IP6_REACH:
2254 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
2255 if (ext_ip_len == 0) /* did something go wrong ? */
2262 case ISIS_TLV_MT_IP6_REACH:
2264 mt_len = isis_print_mtid(tptr, "\n\t ");
2265 if (mt_len == 0) /* did something go wrong ? */
2270 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
2271 if (ext_ip_len == 0) /* did something go wrong ? */
2278 case ISIS_TLV_IP6ADDR:
2279 while (tmp>=sizeof(struct in6_addr)) {
2280 if (!TTEST2(*tptr, sizeof(struct in6_addr)))
2283 printf("\n\t IPv6 interface address: %s",
2284 ip6addr_string(tptr));
2286 tptr += sizeof(struct in6_addr);
2287 tmp -= sizeof(struct in6_addr);
2292 if (!TTEST2(*tptr, 1))
2296 tok2str(isis_subtlv_auth_values,
2297 "unknown Authentication type 0x%02x",
2301 case ISIS_SUBTLV_AUTH_SIMPLE:
2302 for(i=1;i<tlv_len;i++) {
2303 if (!TTEST2(*(tptr+i), 1))
2305 printf("%c",*(tptr+i));
2308 case ISIS_SUBTLV_AUTH_MD5:
2309 for(i=1;i<tlv_len;i++) {
2310 if (!TTEST2(*(tptr+i), 1))
2312 printf("%02x",*(tptr+i));
2314 if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
2315 printf(", (malformed subTLV) ");
2317 case ISIS_SUBTLV_AUTH_PRIVATE:
2319 if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
2325 case ISIS_TLV_PTP_ADJ:
2326 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
2328 if (!TTEST2(*tptr, 1))
2330 printf("\n\t Adjacency State: %s (%u)",
2331 tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
2335 if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
2336 if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id,
2337 sizeof(tlv_ptp_adj->extd_local_circuit_id)))
2339 printf("\n\t Extended Local circuit-ID: 0x%08x",
2340 EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id));
2341 tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
2343 if(tmp>=SYSTEM_ID_LEN) {
2344 if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
2346 printf("\n\t Neighbor System-ID: %s",
2347 isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
2350 if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
2351 if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
2352 sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
2354 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2355 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
2359 case ISIS_TLV_PROTOCOLS:
2360 printf("\n\t NLPID(s): ");
2362 if (!TTEST2(*(tptr), 1))
2364 printf("%s (0x%02x)",
2365 tok2str(nlpid_values,
2369 if (tmp>1) /* further NPLIDs ? - put comma */
2376 case ISIS_TLV_TE_ROUTER_ID:
2377 if (!TTEST2(*pptr, sizeof(struct in_addr)))
2379 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
2382 case ISIS_TLV_IPADDR:
2383 while (tmp>=sizeof(struct in_addr)) {
2384 if (!TTEST2(*tptr, sizeof(struct in_addr)))
2386 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
2387 tptr += sizeof(struct in_addr);
2388 tmp -= sizeof(struct in_addr);
2392 case ISIS_TLV_HOSTNAME:
2393 printf("\n\t Hostname: ");
2395 if (!TTEST2(*tptr, 1))
2397 printf("%c",*tptr++);
2402 case ISIS_TLV_SHARED_RISK_GROUP:
2403 if (tmp < NODE_ID_LEN)
2405 if (!TTEST2(*tptr, NODE_ID_LEN))
2407 printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
2408 tptr+=(NODE_ID_LEN);
2413 if (!TTEST2(*tptr, 1))
2415 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
2418 if (tmp < sizeof(struct in_addr))
2420 if (!TTEST2(*tptr,sizeof(struct in_addr)))
2422 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
2423 tptr+=sizeof(struct in_addr);
2424 tmp-=sizeof(struct in_addr);
2426 if (tmp < sizeof(struct in_addr))
2428 if (!TTEST2(*tptr,sizeof(struct in_addr)))
2430 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr));
2431 tptr+=sizeof(struct in_addr);
2432 tmp-=sizeof(struct in_addr);
2435 if (!TTEST2(*tptr, 4))
2437 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
2444 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
2445 while(tmp>=sizeof(struct isis_tlv_lsp)) {
2446 if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
2448 printf("\n\t lsp-id: %s",
2449 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
2450 if (!TTEST2(tlv_lsp->sequence_number, 4))
2452 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
2453 if (!TTEST2(tlv_lsp->remaining_lifetime, 2))
2455 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
2456 if (!TTEST2(tlv_lsp->checksum, 2))
2458 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
2459 tmp-=sizeof(struct isis_tlv_lsp);
2464 case ISIS_TLV_CHECKSUM:
2465 if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
2467 if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
2469 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
2470 /* do not attempt to verify the checksum if it is zero
2471 * most likely a HMAC-MD5 TLV is also present and
2472 * to avoid conflicts the checksum TLV is zeroed.
2473 * see rfc3358 for details
2475 if (EXTRACT_16BITS(tptr) == 0)
2476 printf("(unverified)");
2477 else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct");
2480 case ISIS_TLV_MT_SUPPORTED:
2481 if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN)
2484 /* length can only be a multiple of 2, otherwise there is
2485 something broken -> so decode down until length is 1 */
2487 mt_len = isis_print_mtid(tptr, "\n\t ");
2488 if (mt_len == 0) /* did something go wrong ? */
2493 printf("\n\t malformed MT-ID");
2499 case ISIS_TLV_RESTART_SIGNALING:
2500 /* first attempt to decode the flags */
2501 if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
2503 if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
2505 printf("\n\t Flags [%s]",
2506 bittok2str(isis_restart_flag_values, "none", *tptr));
2507 tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
2508 tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
2510 /* is there anything other than the flags field? */
2514 if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
2516 if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
2519 printf(", Remaining holding time %us", EXTRACT_16BITS(tptr+1));
2520 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
2521 tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
2523 /* is there an additional sysid field present ?*/
2524 if (tmp == SYSTEM_ID_LEN) {
2525 if (!TTEST2(*tptr, SYSTEM_ID_LEN))
2527 printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN));
2531 case ISIS_TLV_IDRP_INFO:
2532 if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
2534 if (!TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
2536 printf("\n\t Inter-Domain Information Type: %s",
2537 tok2str(isis_subtlv_idrp_values,
2541 case ISIS_SUBTLV_IDRP_ASN:
2542 if (!TTEST2(*tptr, 2)) /* fetch AS number */
2544 printf("AS Number: %u",EXTRACT_16BITS(tptr));
2546 case ISIS_SUBTLV_IDRP_LOCAL:
2547 case ISIS_SUBTLV_IDRP_RES:
2549 if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
2555 case ISIS_TLV_LSP_BUFFERSIZE:
2556 if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
2558 if (!TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
2560 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
2563 case ISIS_TLV_PART_DIS:
2564 while (tmp >= SYSTEM_ID_LEN) {
2565 if (!TTEST2(*tptr, SYSTEM_ID_LEN))
2567 printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
2568 tptr+=SYSTEM_ID_LEN;
2573 case ISIS_TLV_PREFIX_NEIGH:
2574 if (tmp < sizeof(struct isis_metric_block))
2576 if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
2578 printf("\n\t Metric Block");
2579 isis_print_metric_block((const struct isis_metric_block *)tptr);
2580 tptr+=sizeof(struct isis_metric_block);
2581 tmp-=sizeof(struct isis_metric_block);
2584 if (!TTEST2(*tptr, 1))
2586 prefix_len=*tptr++; /* read out prefix length in semioctets*/
2587 if (prefix_len < 2) {
2588 printf("\n\t\tAddress: prefix length %u < 2", prefix_len);
2592 if (tmp < prefix_len/2)
2594 if (!TTEST2(*tptr, prefix_len/2))
2596 printf("\n\t\tAddress: %s/%u",
2597 isonsap_string(tptr,prefix_len/2),
2604 case ISIS_TLV_IIH_SEQNR:
2605 if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
2607 if (!TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
2609 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
2612 case ISIS_TLV_VENDOR_PRIVATE:
2613 if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
2615 if (!TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
2617 vendor_id = EXTRACT_24BITS(tptr);
2618 printf("\n\t Vendor: %s (%u)",
2619 tok2str(oui_values,"Unknown",vendor_id),
2623 if (tmp > 0) /* hexdump the rest */
2624 if(!print_unknown_data(tptr,"\n\t\t",tmp))
2628 * FIXME those are the defined TLVs that lack a decoder
2629 * you are welcome to contribute code ;-)
2632 case ISIS_TLV_DECNET_PHASE4:
2633 case ISIS_TLV_LUCENT_PRIVATE:
2634 case ISIS_TLV_IPAUTH:
2635 case ISIS_TLV_NORTEL_PRIVATE1:
2636 case ISIS_TLV_NORTEL_PRIVATE2:
2640 if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
2645 /* do we want to see an additionally hexdump ? */
2647 if(!print_unknown_data(pptr,"\n\t ",tlv_len))
2652 packet_len -= tlv_len;
2655 if (packet_len != 0) {
2656 printf("\n\t %u straggler bytes", packet_len);
2661 fputs("[|isis]", stdout);
2665 printf("\n\t\t packet exceeded snapshot");
2670 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2674 osi_cksum(const u_int8_t *tptr, u_int len)
2676 int32_t c0 = 0, c1 = 0;
2678 while ((int)--len >= 0) {
2690 * c-style: whitesmith