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.
31 #include <tcpdump-stdinc.h>
36 #include "interface.h"
37 #include "addrtoname.h"
38 #include "ethertype.h"
44 #include "signature.h"
47 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
50 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
51 #define NODE_ID_LEN SYSTEM_ID_LEN+1
52 #define LSP_ID_LEN SYSTEM_ID_LEN+2
54 #define ISIS_VERSION 1
55 #define ESIS_VERSION 1
56 #define CLNP_VERSION 1
58 #define ISIS_PDU_TYPE_MASK 0x1F
59 #define ESIS_PDU_TYPE_MASK 0x1F
60 #define CLNP_PDU_TYPE_MASK 0x1F
61 #define CLNP_FLAG_MASK 0xE0
62 #define ISIS_LAN_PRIORITY_MASK 0x7F
64 #define ISIS_PDU_L1_LAN_IIH 15
65 #define ISIS_PDU_L2_LAN_IIH 16
66 #define ISIS_PDU_PTP_IIH 17
67 #define ISIS_PDU_L1_LSP 18
68 #define ISIS_PDU_L2_LSP 20
69 #define ISIS_PDU_L1_CSNP 24
70 #define ISIS_PDU_L2_CSNP 25
71 #define ISIS_PDU_L1_PSNP 26
72 #define ISIS_PDU_L2_PSNP 27
74 static const struct tok isis_pdu_values
[] = {
75 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
76 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
77 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
78 { ISIS_PDU_L1_LSP
, "L1 LSP"},
79 { ISIS_PDU_L2_LSP
, "L2 LSP"},
80 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
81 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
82 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
83 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
88 * A TLV is a tuple of a type, length and a value and is normally used for
89 * encoding information in all sorts of places. This is an enumeration of
90 * the well known types.
92 * list taken from rfc3359 plus some memory from veterans ;-)
95 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
96 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
97 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
98 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
99 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
100 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
101 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
102 #define ISIS_TLV_PADDING 8 /* iso10589 */
103 #define ISIS_TLV_LSP 9 /* iso10589 */
104 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
105 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
106 #define ISIS_TLV_CHECKSUM_MINLEN 2
107 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
108 #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
109 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
110 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
111 #define ISIS_TLV_DECNET_PHASE4 42
112 #define ISIS_TLV_LUCENT_PRIVATE 66
113 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
114 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
115 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
116 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
117 #define ISIS_TLV_IDRP_INFO_MINLEN 1
118 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
119 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
120 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
121 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
122 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
123 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
124 #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
125 #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
126 #define ISIS_TLV_NORTEL_PRIVATE1 176
127 #define ISIS_TLV_NORTEL_PRIVATE2 177
128 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
129 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
130 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
131 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
132 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
133 #define ISIS_TLV_MT_SUPPORTED_MINLEN 2
134 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
135 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
136 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
137 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
138 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
139 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
140 #define ISIS_TLV_IIH_SEQNR_MINLEN 4
141 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
142 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
144 static const struct tok isis_tlv_values
[] = {
145 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
146 { ISIS_TLV_IS_REACH
, "IS Reachability"},
147 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
148 { ISIS_TLV_PART_DIS
, "Partition DIS"},
149 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
150 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
151 { ISIS_TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
152 { ISIS_TLV_PADDING
, "Padding"},
153 { ISIS_TLV_LSP
, "LSP entries"},
154 { ISIS_TLV_AUTH
, "Authentication"},
155 { ISIS_TLV_CHECKSUM
, "Checksum"},
156 { ISIS_TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
157 { ISIS_TLV_EXT_IS_REACH
, "Extended IS Reachability"},
158 { ISIS_TLV_IS_ALIAS_ID
, "IS Alias ID"},
159 { ISIS_TLV_DECNET_PHASE4
, "DECnet Phase IV"},
160 { ISIS_TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
161 { ISIS_TLV_INT_IP_REACH
, "IPv4 Internal Reachability"},
162 { ISIS_TLV_PROTOCOLS
, "Protocols supported"},
163 { ISIS_TLV_EXT_IP_REACH
, "IPv4 External Reachability"},
164 { ISIS_TLV_IDRP_INFO
, "Inter-Domain Information Type"},
165 { ISIS_TLV_IPADDR
, "IPv4 Interface address(es)"},
166 { ISIS_TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
167 { ISIS_TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
168 { ISIS_TLV_EXTD_IP_REACH
, "Extended IPv4 Reachability"},
169 { ISIS_TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
170 { ISIS_TLV_MT_PORT_CAP
, "Multi-Topology-Aware Port Capability"},
171 { ISIS_TLV_MT_CAPABILITY
, "Multi-Topology Capability"},
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 const 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 const 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 const struct tok clnp_option_rfd_class_values
[] = {
229 { 0x9, "Source Routeing"},
231 { 0xb, "PDU Discarded"},
232 { 0xc, "Reassembly"},
236 static const 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 const struct tok clnp_option_rfd_address_values
[] = {
249 { 0x0, "Destination address unreachable"},
250 { 0x1, "Destination address unknown"},
254 static const 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 const struct tok clnp_option_rfd_lifetime_values
[] = {
263 { 0x0, "Lifetime expired while data unit in transit"},
264 { 0x1, "Lifetime expired during reassembly"},
268 static const 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 const struct tok clnp_option_rfd_reassembly_values
[] = {
278 { 0x0, "Reassembly interference"},
282 /* array of 16 error-classes */
283 static const 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 const 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 const struct tok clnp_option_sr_rr_values
[] = {
321 static const 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 const 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 /* rfc4205 */
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_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
348 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
349 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
350 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
352 #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
354 static const struct tok isis_ext_is_reach_subtlv_values
[] = {
355 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
356 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
357 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
358 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
359 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
360 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
361 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
362 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
363 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
364 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
, "Link Attribute" },
365 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
366 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
367 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
, "Bandwidth Constraints (old)" },
368 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
, "Bandwidth Constraints" },
369 { ISIS_SUBTLV_SPB_METRIC
, "SPB Metric" },
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 const 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 static const struct tok isis_subtlv_link_attribute_values
[] = {
391 { 0x01, "Local Protection Available" },
392 { 0x02, "Link excluded from local protection path" },
393 { 0x04, "Local maintenance required"},
397 #define ISIS_SUBTLV_AUTH_SIMPLE 1
398 #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
399 #define ISIS_SUBTLV_AUTH_MD5 54
400 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
401 #define ISIS_SUBTLV_AUTH_PRIVATE 255
403 static const struct tok isis_subtlv_auth_values
[] = {
404 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
405 { ISIS_SUBTLV_AUTH_GENERIC
, "Generic Crypto key-id"},
406 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
407 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
411 #define ISIS_SUBTLV_IDRP_RES 0
412 #define ISIS_SUBTLV_IDRP_LOCAL 1
413 #define ISIS_SUBTLV_IDRP_ASN 2
415 static const struct tok isis_subtlv_idrp_values
[] = {
416 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
417 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
418 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
422 #define ISIS_SUBTLV_SPB_MCID 4
423 #define ISIS_SUBTLV_SPB_DIGEST 5
424 #define ISIS_SUBTLV_SPB_BVID 6
426 #define ISIS_SUBTLV_SPB_INSTANCE 1
427 #define ISIS_SUBTLV_SPBM_SI 3
429 #define ISIS_SPB_MCID_LEN 51
430 #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
431 #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
432 #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
433 #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
434 #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
436 static const struct tok isis_mt_port_cap_subtlv_values
[] = {
437 { ISIS_SUBTLV_SPB_MCID
, "SPB MCID" },
438 { ISIS_SUBTLV_SPB_DIGEST
, "SPB Digest" },
439 { ISIS_SUBTLV_SPB_BVID
, "SPB BVID" },
443 static const struct tok isis_mt_capability_subtlv_values
[] = {
444 { ISIS_SUBTLV_SPB_INSTANCE
, "SPB Instance" },
445 { ISIS_SUBTLV_SPBM_SI
, "SPBM Service Identifier and Unicast Address" },
449 struct isis_spb_mcid
{
452 u_int8_t revision_lvl
[2];
456 struct isis_subtlv_spb_mcid
{
457 struct isis_spb_mcid mcid
;
458 struct isis_spb_mcid aux_mcid
;
461 struct isis_subtlv_spb_instance
{
462 u_int8_t cist_root_id
[8];
463 u_int8_t cist_external_root_path_cost
[4];
464 u_int8_t bridge_priority
[2];
465 u_int8_t spsourceid
[4];
466 u_int8_t no_of_trees
;
469 #define CLNP_SEGMENT_PART 0x80
470 #define CLNP_MORE_SEGMENTS 0x40
471 #define CLNP_REQUEST_ER 0x20
473 static const struct tok clnp_flag_values
[] = {
474 { CLNP_SEGMENT_PART
, "Segmentation permitted"},
475 { CLNP_MORE_SEGMENTS
, "more Segments"},
476 { CLNP_REQUEST_ER
, "request Error Report"},
480 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
481 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
482 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
483 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
484 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
485 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
486 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
487 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
489 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
490 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
492 static const struct tok isis_mt_flag_values
[] = {
493 { 0x4000, "ATT bit set"},
494 { 0x8000, "Overload bit set"},
498 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
499 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
501 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
502 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
504 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
505 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
506 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
507 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
509 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
511 static const struct tok isis_mt_values
[] = {
512 { 0, "IPv4 unicast"},
513 { 1, "In-Band Management"},
514 { 2, "IPv6 unicast"},
516 { 4095, "Development, Experimental or Proprietary"},
520 static const struct tok isis_iih_circuit_type_values
[] = {
521 { 1, "Level 1 only"},
522 { 2, "Level 2 only"},
523 { 3, "Level 1, Level 2"},
527 #define ISIS_LSP_TYPE_UNUSED0 0
528 #define ISIS_LSP_TYPE_LEVEL_1 1
529 #define ISIS_LSP_TYPE_UNUSED2 2
530 #define ISIS_LSP_TYPE_LEVEL_2 3
532 static const struct tok isis_lsp_istype_values
[] = {
533 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
534 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
535 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
536 { ISIS_LSP_TYPE_LEVEL_2
, "L2 IS"},
541 * Katz's point to point adjacency TLV uses codes to tell us the state of
542 * the remote adjacency. Enumerate them.
545 #define ISIS_PTP_ADJ_UP 0
546 #define ISIS_PTP_ADJ_INIT 1
547 #define ISIS_PTP_ADJ_DOWN 2
549 static const struct tok isis_ptp_adjancey_values
[] = {
550 { ISIS_PTP_ADJ_UP
, "Up" },
551 { ISIS_PTP_ADJ_INIT
, "Initializing" },
552 { ISIS_PTP_ADJ_DOWN
, "Down" },
556 struct isis_tlv_ptp_adj
{
557 u_int8_t adjacency_state
;
558 u_int8_t extd_local_circuit_id
[4];
559 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
560 u_int8_t neighbor_extd_local_circuit_id
[4];
563 static void osi_print_cksum(const u_int8_t
*pptr
, u_int16_t checksum
,
564 u_int checksum_offset
, u_int length
);
565 static int clnp_print(const u_int8_t
*, u_int
);
566 static void esis_print(const u_int8_t
*, u_int
);
567 static int isis_print(const u_int8_t
*, u_int
);
569 struct isis_metric_block
{
570 u_int8_t metric_default
;
571 u_int8_t metric_delay
;
572 u_int8_t metric_expense
;
573 u_int8_t metric_error
;
576 struct isis_tlv_is_reach
{
577 struct isis_metric_block isis_metric_block
;
578 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
581 struct isis_tlv_es_reach
{
582 struct isis_metric_block isis_metric_block
;
583 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
586 struct isis_tlv_ip_reach
{
587 struct isis_metric_block isis_metric_block
;
592 static const struct tok isis_is_reach_virtual_values
[] = {
593 { 0, "IsNotVirtual"},
598 static const struct tok isis_restart_flag_values
[] = {
599 { 0x1, "Restart Request"},
600 { 0x2, "Restart Acknowledgement"},
601 { 0x4, "Suppress adjacency advertisement"},
605 struct isis_common_header
{
608 u_int8_t version
; /* Protocol version */
610 u_int8_t pdu_type
; /* 3 MSbits are reserved */
611 u_int8_t pdu_version
; /* Packet format version */
616 struct isis_iih_lan_header
{
617 u_int8_t circuit_type
;
618 u_int8_t source_id
[SYSTEM_ID_LEN
];
619 u_int8_t holding_time
[2];
622 u_int8_t lan_id
[NODE_ID_LEN
];
625 struct isis_iih_ptp_header
{
626 u_int8_t circuit_type
;
627 u_int8_t source_id
[SYSTEM_ID_LEN
];
628 u_int8_t holding_time
[2];
633 struct isis_lsp_header
{
635 u_int8_t remaining_lifetime
[2];
636 u_int8_t lsp_id
[LSP_ID_LEN
];
637 u_int8_t sequence_number
[4];
638 u_int8_t checksum
[2];
642 struct isis_csnp_header
{
644 u_int8_t source_id
[NODE_ID_LEN
];
645 u_int8_t start_lsp_id
[LSP_ID_LEN
];
646 u_int8_t end_lsp_id
[LSP_ID_LEN
];
649 struct isis_psnp_header
{
651 u_int8_t source_id
[NODE_ID_LEN
];
654 struct isis_tlv_lsp
{
655 u_int8_t remaining_lifetime
[2];
656 u_int8_t lsp_id
[LSP_ID_LEN
];
657 u_int8_t sequence_number
[4];
658 u_int8_t checksum
[2];
661 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
662 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
663 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
664 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
665 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
666 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
668 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
670 if (caplen
<= 1) { /* enough bytes on the wire ? */
676 printf("OSI NLPID %s (0x%02x): ",
677 tok2str(nlpid_values
,"Unknown",*p
),
683 if (!clnp_print(p
, length
))
684 print_unknown_data(gndo
,p
,"\n\t",caplen
);
688 esis_print(p
, length
);
692 if (!isis_print(p
, length
))
693 print_unknown_data(gndo
,p
,"\n\t",caplen
);
697 (void)printf("%slength: %u",
703 q933_print(gndo
, p
+1, length
-1);
707 ip_print(gndo
, p
+1, length
-1);
712 ip6_print(gndo
, p
+1, length
-1);
717 ppp_print(p
+1, length
-1);
722 printf("OSI NLPID 0x%02x unknown",*p
);
723 (void)printf("%slength: %u",
727 print_unknown_data(gndo
,p
,"\n\t",caplen
);
732 #define CLNP_PDU_ER 1
733 #define CLNP_PDU_DT 28
734 #define CLNP_PDU_MD 29
735 #define CLNP_PDU_ERQ 30
736 #define CLNP_PDU_ERP 31
738 static const struct tok clnp_pdu_values
[] = {
739 { CLNP_PDU_ER
, "Error Report"},
740 { CLNP_PDU_MD
, "MD"},
741 { CLNP_PDU_DT
, "Data"},
742 { CLNP_PDU_ERQ
, "Echo Request"},
743 { CLNP_PDU_ERP
, "Echo Response"},
747 struct clnp_header_t
{
749 u_int8_t length_indicator
;
751 u_int8_t lifetime
; /* units of 500ms */
753 u_int8_t segment_length
[2];
757 struct clnp_segment_header_t
{
758 u_int8_t data_unit_id
[2];
759 u_int8_t segment_offset
[2];
760 u_int8_t total_length
[2];
765 * Decode CLNP packets. Return 0 on error.
768 static int clnp_print (const u_int8_t
*pptr
, u_int length
)
770 const u_int8_t
*optr
,*source_address
,*dest_address
;
771 u_int li
,tlen
,nsap_offset
,source_address_length
,dest_address_length
, clnp_pdu_type
, clnp_flags
;
772 const struct clnp_header_t
*clnp_header
;
773 const struct clnp_segment_header_t
*clnp_segment_header
;
774 u_int8_t rfd_error_major
,rfd_error_minor
;
776 clnp_header
= (const struct clnp_header_t
*) pptr
;
777 TCHECK(*clnp_header
);
779 li
= clnp_header
->length_indicator
;
786 * Sanity checking of the header.
789 if (clnp_header
->version
!= CLNP_VERSION
) {
790 printf("version %d packet not supported", clnp_header
->version
);
794 /* FIXME further header sanity checking */
796 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
797 clnp_flags
= clnp_header
->type
& CLNP_FLAG_MASK
;
799 pptr
+= sizeof(struct clnp_header_t
);
800 li
-= sizeof(struct clnp_header_t
);
801 dest_address_length
= *pptr
;
802 dest_address
= pptr
+ 1;
804 pptr
+= (1 + dest_address_length
);
805 li
-= (1 + dest_address_length
);
806 source_address_length
= *pptr
;
807 source_address
= pptr
+1;
809 pptr
+= (1 + source_address_length
);
810 li
-= (1 + source_address_length
);
813 printf("%s%s > %s, %s, length %u",
815 isonsap_string(source_address
, source_address_length
),
816 isonsap_string(dest_address
, dest_address_length
),
817 tok2str(clnp_pdu_values
,"unknown (%u)",clnp_pdu_type
),
821 printf("%slength %u",eflag
? "" : ", ",length
);
823 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
824 tok2str(clnp_pdu_values
, "unknown (%u)",clnp_pdu_type
),
825 clnp_header
->length_indicator
,
826 clnp_header
->version
,
827 clnp_header
->lifetime
/2,
828 (clnp_header
->lifetime
%2)*5,
829 EXTRACT_16BITS(clnp_header
->segment_length
),
830 EXTRACT_16BITS(clnp_header
->cksum
));
832 osi_print_cksum(optr
, EXTRACT_16BITS(clnp_header
->cksum
), 7,
833 clnp_header
->length_indicator
);
835 printf("\n\tFlags [%s]",
836 bittok2str(clnp_flag_values
,"none",clnp_flags
));
838 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
839 source_address_length
,
840 isonsap_string(source_address
, source_address_length
),
842 isonsap_string(dest_address
,dest_address_length
));
844 if (clnp_flags
& CLNP_SEGMENT_PART
) {
845 clnp_segment_header
= (const struct clnp_segment_header_t
*) pptr
;
846 TCHECK(*clnp_segment_header
);
847 printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
848 EXTRACT_16BITS(clnp_segment_header
->data_unit_id
),
849 EXTRACT_16BITS(clnp_segment_header
->segment_offset
),
850 EXTRACT_16BITS(clnp_segment_header
->total_length
));
851 pptr
+=sizeof(const struct clnp_segment_header_t
);
852 li
-=sizeof(const struct clnp_segment_header_t
);
855 /* now walk the options */
858 const u_int8_t
*tptr
;
862 printf(", bad opts/li");
868 TCHECK2(*pptr
, opli
);
870 printf(", opt (%d) too long", op
);
877 printf("\n\t %s Option #%u, length %u, value: ",
878 tok2str(clnp_option_values
,"Unknown",op
),
885 case CLNP_OPTION_ROUTE_RECORDING
: /* those two options share the format */
886 case CLNP_OPTION_SOURCE_ROUTING
:
888 tok2str(clnp_option_sr_rr_values
,"Unknown",*tptr
),
889 tok2str(clnp_option_sr_rr_string_values
,"Unknown Option %u",op
));
890 nsap_offset
=*(tptr
+1);
891 if (nsap_offset
== 0) {
892 printf(" Bad NSAP offset (0)");
895 nsap_offset
-=1; /* offset to nsap list */
896 if (nsap_offset
> tlen
) {
897 printf(" Bad NSAP offset (past end of option)");
903 source_address_length
=*tptr
;
904 if (tlen
< source_address_length
+1) {
905 printf("\n\t NSAP address goes past end of option");
908 if (source_address_length
> 0) {
909 source_address
=(tptr
+1);
910 TCHECK2(*source_address
, source_address_length
);
911 printf("\n\t NSAP address (length %u): %s",
912 source_address_length
,
913 isonsap_string(source_address
, source_address_length
));
915 tlen
-=source_address_length
+1;
919 case CLNP_OPTION_PRIORITY
:
920 printf("0x%1x", *tptr
&0x0f);
923 case CLNP_OPTION_QOS_MAINTENANCE
:
924 printf("\n\t Format Code: %s",
925 tok2str(clnp_option_scope_values
,"Reserved",*tptr
&CLNP_OPTION_SCOPE_MASK
));
927 if ((*tptr
&CLNP_OPTION_SCOPE_MASK
) == CLNP_OPTION_SCOPE_GLOBAL
)
928 printf("\n\t QoS Flags [%s]",
929 bittok2str(clnp_option_qos_global_values
,
931 *tptr
&CLNP_OPTION_OPTION_QOS_MASK
));
934 case CLNP_OPTION_SECURITY
:
935 printf("\n\t Format Code: %s, Security-Level %u",
936 tok2str(clnp_option_scope_values
,"Reserved",*tptr
&CLNP_OPTION_SCOPE_MASK
),
940 case CLNP_OPTION_DISCARD_REASON
:
941 rfd_error_major
= (*tptr
&0xf0) >> 4;
942 rfd_error_minor
= *tptr
&0x0f;
943 printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
944 tok2str(clnp_option_rfd_class_values
,"Unknown",rfd_error_major
),
946 tok2str(clnp_option_rfd_error_class
[rfd_error_major
],"Unknown",rfd_error_minor
),
950 case CLNP_OPTION_PADDING
:
951 printf("padding data");
955 * FIXME those are the defined Options that lack a decoder
956 * you are welcome to contribute code ;-)
960 print_unknown_data(gndo
,tptr
,"\n\t ",opli
);
964 print_unknown_data(gndo
,pptr
,"\n\t ",opli
);
968 switch (clnp_pdu_type
) {
970 case CLNP_PDU_ER
: /* fall through */
973 if (*(pptr
) == NLPID_CLNP
) {
974 printf("\n\t-----original packet-----\n\t");
975 /* FIXME recursion protection */
976 clnp_print(pptr
, length
-clnp_header
->length_indicator
);
985 /* dump the PDU specific data */
986 if (length
-(pptr
-optr
) > 0) {
987 printf("\n\t undecoded non-header data, length %u",length
-clnp_header
->length_indicator
);
988 print_unknown_data(gndo
,pptr
,"\n\t ",length
-(pptr
-optr
));
995 fputs("[|clnp]", stdout
);
1001 #define ESIS_PDU_REDIRECT 6
1002 #define ESIS_PDU_ESH 2
1003 #define ESIS_PDU_ISH 4
1005 static const struct tok esis_pdu_values
[] = {
1006 { ESIS_PDU_REDIRECT
, "redirect"},
1007 { ESIS_PDU_ESH
, "ESH"},
1008 { ESIS_PDU_ISH
, "ISH"},
1012 struct esis_header_t
{
1014 u_int8_t length_indicator
;
1018 u_int8_t holdtime
[2];
1023 esis_print(const u_int8_t
*pptr
, u_int length
)
1025 const u_int8_t
*optr
;
1026 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
1027 const struct esis_header_t
*esis_header
;
1036 printf("no header at all!");
1040 esis_header
= (const struct esis_header_t
*) pptr
;
1041 TCHECK(*esis_header
);
1042 li
= esis_header
->length_indicator
;
1046 * Sanity checking of the header.
1049 if (esis_header
->nlpid
!= NLPID_ESIS
) {
1050 printf(" nlpid 0x%02x packet not supported", esis_header
->nlpid
);
1054 if (esis_header
->version
!= ESIS_VERSION
) {
1055 printf(" version %d packet not supported", esis_header
->version
);
1060 printf(" length indicator(%d) > PDU size (%d)!", li
, length
);
1064 if (li
< sizeof(struct esis_header_t
) + 2) {
1065 printf(" length indicator < min PDU size %d:", li
);
1066 while (--length
!= 0)
1067 printf("%02X", *pptr
++);
1071 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
1074 printf("%s%s, length %u",
1076 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
1080 printf("%slength %u\n\t%s (%u)",
1083 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
1086 printf(", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" );
1087 printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header
->cksum
));
1089 osi_print_cksum(pptr
, EXTRACT_16BITS(esis_header
->cksum
), 7, li
);
1091 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header
->holdtime
),li
);
1094 print_unknown_data(gndo
,optr
,"\n\t",sizeof(struct esis_header_t
));
1096 pptr
+= sizeof(struct esis_header_t
);
1097 li
-= sizeof(struct esis_header_t
);
1099 switch (esis_pdu_type
) {
1100 case ESIS_PDU_REDIRECT
: {
1101 const u_int8_t
*dst
, *snpa
, *neta
;
1102 u_int dstl
, snpal
, netal
;
1106 printf(", bad redirect/li");
1112 TCHECK2(*pptr
, dstl
);
1114 printf(", bad redirect/li");
1120 printf("\n\t %s", isonsap_string(dst
,dstl
));
1124 printf(", bad redirect/li");
1130 TCHECK2(*pptr
, snpal
);
1132 printf(", bad redirect/li");
1140 printf(", bad redirect/li");
1145 TCHECK2(*pptr
, netal
);
1147 printf(", bad redirect/li");
1155 printf("\n\t %s", etheraddr_string(snpa
));
1157 printf("\n\t %s", isonsap_string(neta
,netal
));
1164 printf(", bad esh/li");
1167 source_address_number
= *pptr
;
1171 printf("\n\t Number of Source Addresses: %u", source_address_number
);
1173 while (source_address_number
> 0) {
1176 printf(", bad esh/li");
1179 source_address_length
= *pptr
;
1183 TCHECK2(*pptr
, source_address_length
);
1184 if (li
< source_address_length
) {
1185 printf(", bad esh/li");
1188 printf("\n\t NET (length: %u): %s",
1189 source_address_length
,
1190 isonsap_string(pptr
,source_address_length
));
1191 pptr
+= source_address_length
;
1192 li
-= source_address_length
;
1193 source_address_number
--;
1198 case ESIS_PDU_ISH
: {
1201 printf(", bad ish/li");
1204 source_address_length
= *pptr
;
1207 TCHECK2(*pptr
, source_address_length
);
1208 if (li
< source_address_length
) {
1209 printf(", bad ish/li");
1212 printf("\n\t NET (length: %u): %s", source_address_length
, isonsap_string(pptr
, source_address_length
));
1213 pptr
+= source_address_length
;
1214 li
-= source_address_length
;
1221 print_unknown_data(gndo
,pptr
,"\n\t ",snapend
-pptr
);
1226 /* now walk the options */
1229 const u_int8_t
*tptr
;
1232 printf(", bad opts/li");
1240 printf(", opt (%d) too long", op
);
1246 printf("\n\t %s Option #%u, length %u, value: ",
1247 tok2str(esis_option_values
,"Unknown",op
),
1253 case ESIS_OPTION_ES_CONF_TIME
:
1256 printf("%us", EXTRACT_16BITS(tptr
));
1258 printf("(bad length)");
1261 case ESIS_OPTION_PROTOCOLS
:
1264 printf("%s (0x%02x)",
1265 tok2str(nlpid_values
,
1269 if (opli
>1) /* further NPLIDs ? - put comma */
1277 * FIXME those are the defined Options that lack a decoder
1278 * you are welcome to contribute code ;-)
1281 case ESIS_OPTION_QOS_MAINTENANCE
:
1282 case ESIS_OPTION_SECURITY
:
1283 case ESIS_OPTION_PRIORITY
:
1284 case ESIS_OPTION_ADDRESS_MASK
:
1285 case ESIS_OPTION_SNPA_MASK
:
1288 print_unknown_data(gndo
,tptr
,"\n\t ",opli
);
1292 print_unknown_data(gndo
,pptr
,"\n\t ",opli
);
1301 isis_print_mcid (const struct isis_spb_mcid
*mcid
)
1305 printf( "ID: %d, Name: ", mcid
->format_id
);
1309 printf("%c", mcid
->name
[i
]);
1310 if(mcid
->name
[i
] == '\0')
1314 printf("\n\t Lvl: %d",
1315 EXTRACT_16BITS(mcid
->revision_lvl
));
1317 printf( ", Digest: ");
1320 printf("%.2x ",mcid
->digest
[i
]);
1324 isis_print_mt_port_cap_subtlv (const u_int8_t
*tptr
, int len
)
1326 int stlv_type
, stlv_len
;
1327 const struct isis_subtlv_spb_mcid
*subtlv_spb_mcid
;
1332 stlv_type
= *(tptr
++);
1333 stlv_len
= *(tptr
++);
1335 /* first lets see if we know the subTLVs name*/
1336 printf("\n\t %s subTLV #%u, length: %u",
1337 tok2str(isis_mt_port_cap_subtlv_values
, "unknown", stlv_type
),
1341 /*len -= TLV_TYPE_LEN_OFFSET;*/
1346 case ISIS_SUBTLV_SPB_MCID
:
1348 if (!TTEST2(*(tptr
), ISIS_SUBTLV_SPB_MCID_MIN_LEN
))
1351 subtlv_spb_mcid
= (struct isis_subtlv_spb_mcid
*)tptr
;
1353 printf( "\n\t MCID: ");
1354 isis_print_mcid (&(subtlv_spb_mcid
->mcid
));
1356 /*tptr += SPB_MCID_MIN_LEN;
1357 len -= SPB_MCID_MIN_LEN; */
1359 printf( "\n\t AUX-MCID: ");
1360 isis_print_mcid (&(subtlv_spb_mcid
->aux_mcid
));
1362 /*tptr += SPB_MCID_MIN_LEN;
1363 len -= SPB_MCID_MIN_LEN; */
1364 tptr
= tptr
+ sizeof(struct isis_subtlv_spb_mcid
);
1365 len
= len
- sizeof(struct isis_subtlv_spb_mcid
);
1370 case ISIS_SUBTLV_SPB_DIGEST
:
1372 if (!TTEST2(*(tptr
), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
))
1375 printf ("\n\t RES: %d V: %d A: %d D: %d",
1376 (*(tptr
) >> 5), (((*tptr
)>> 4) & 0x01),
1377 ((*(tptr
) >> 2) & 0x03), ((*tptr
) & 0x03));
1381 printf( "\n\t Digest: ");
1385 printf("%08x ", EXTRACT_32BITS(tptr
));
1386 if (i
%4 == 0 && i
!= 8)
1391 len
= len
- ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
;
1396 case ISIS_SUBTLV_SPB_BVID
:
1398 if (!TTEST2(*(tptr
), stlv_len
))
1403 if (!TTEST2(*(tptr
), ISIS_SUBTLV_SPB_BVID_MIN_LEN
))
1406 printf("\n\t ECT: %08x",
1407 EXTRACT_32BITS(tptr
));
1411 printf(" BVID: %d, U:%01x M:%01x ",
1412 (EXTRACT_16BITS (tptr
) >> 4) ,
1413 (EXTRACT_16BITS (tptr
) >> 3) & 0x01,
1414 (EXTRACT_16BITS (tptr
) >> 2) & 0x01);
1417 len
= len
- ISIS_SUBTLV_SPB_BVID_MIN_LEN
;
1431 printf("\n\t\t packet exceeded snapshot");
1436 isis_print_mt_capability_subtlv (const u_int8_t
*tptr
, int len
)
1438 int stlv_type
, stlv_len
, tmp
;
1442 stlv_type
= *(tptr
++);
1443 stlv_len
= *(tptr
++);
1445 /* first lets see if we know the subTLVs name*/
1446 printf("\n\t %s subTLV #%u, length: %u",
1447 tok2str(isis_mt_capability_subtlv_values
, "unknown", stlv_type
),
1455 case ISIS_SUBTLV_SPB_INSTANCE
:
1457 if (!TTEST2(*(tptr
), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
))
1460 printf("\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr
));
1462 printf(" %08x", EXTRACT_32BITS(tptr
));
1464 printf(", Path Cost: %08x", EXTRACT_32BITS(tptr
));
1466 printf(", Prio: %d", EXTRACT_16BITS(tptr
));
1468 printf("\n\t RES: %d",
1469 EXTRACT_16BITS(tptr
) >> 5);
1471 (EXTRACT_16BITS(tptr
) >> 4) & 0x0001);
1472 printf(", SPSource-ID: %d",
1473 (EXTRACT_32BITS(tptr
) & 0x000fffff));
1475 printf(", No of Trees: %x", *(tptr
));
1479 len
= len
- ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
;
1483 if (!TTEST2(*(tptr
), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
))
1486 printf ("\n\t U:%d, M:%d, A:%d, RES:%d",
1487 *(tptr
) >> 7, (*(tptr
) >> 6) & 0x01,
1488 (*(tptr
) >> 5) & 0x01, (*(tptr
) & 0x1f));
1492 printf (", ECT: %08x", EXTRACT_32BITS(tptr
));
1496 printf (", BVID: %d, SPVID: %d",
1497 (EXTRACT_24BITS(tptr
) >> 12) & 0x000fff,
1498 EXTRACT_24BITS(tptr
) & 0x000fff);
1501 len
= len
- ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
;
1507 case ISIS_SUBTLV_SPBM_SI
:
1509 if (!TTEST2(*(tptr
), 6))
1512 printf("\n\t BMAC: %08x", EXTRACT_32BITS(tptr
));
1514 printf("%04x", EXTRACT_16BITS(tptr
));
1517 printf (", RES: %d, VID: %d", EXTRACT_16BITS(tptr
) >> 12,
1518 (EXTRACT_16BITS(tptr
)) & 0x0fff);
1522 stlv_len
= stlv_len
- 8;
1526 printf("\n\t T: %d, R: %d, RES: %d, ISID: %d",
1527 (EXTRACT_32BITS(tptr
) >> 31),
1528 (EXTRACT_32BITS(tptr
) >> 30) & 0x01,
1529 (EXTRACT_32BITS(tptr
) >> 24) & 0x03f,
1530 (EXTRACT_32BITS(tptr
)) & 0x0ffffff);
1534 stlv_len
= stlv_len
- 4;
1546 printf("\n\t\t packet exceeded snapshot");
1551 /* shared routine for printing system, node and lsp-ids */
1553 isis_print_id(const u_int8_t
*cp
, int id_len
)
1556 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1559 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
1560 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
1562 if (i
== 2 || i
== 4)
1565 if (id_len
>= NODE_ID_LEN
) {
1566 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
1569 if (id_len
== LSP_ID_LEN
)
1570 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
1574 /* print the 4-byte metric block which is common found in the old-style TLVs */
1576 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
1578 printf(", Default Metric: %d, %s",
1579 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
1580 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
1581 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
1582 printf("\n\t\t Delay Metric: %d, %s",
1583 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
1584 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
1585 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
1586 printf("\n\t\t Expense Metric: %d, %s",
1587 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
1588 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
1589 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
1590 printf("\n\t\t Error Metric: %d, %s",
1591 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
1592 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
1594 return(1); /* everything is ok */
1598 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
1601 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
1603 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
1605 while (length
> 0) {
1606 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
1607 printf("short IPv4 Reachability (%d vs %lu)",
1609 (unsigned long)sizeof(*tlv_ip_reach
));
1613 if (!TTEST(*tlv_ip_reach
))
1616 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
1618 if (prefix_len
== -1)
1619 printf("%sIPv4 prefix: %s mask %s",
1621 ipaddr_string((tlv_ip_reach
->prefix
)),
1622 ipaddr_string((tlv_ip_reach
->mask
)));
1624 printf("%sIPv4 prefix: %15s/%u",
1626 ipaddr_string((tlv_ip_reach
->prefix
)),
1629 printf(", Distribution: %s, Metric: %u, %s",
1630 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
1631 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
1632 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
1634 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
1635 printf("%s Delay Metric: %u, %s",
1637 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
1638 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
1640 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
1641 printf("%s Expense Metric: %u, %s",
1643 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
1644 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
1646 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
1647 printf("%s Error Metric: %u, %s",
1649 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
1650 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
1652 length
-= sizeof(struct isis_tlv_ip_reach
);
1659 * this is the common IP-REACH subTLV decoder it is called
1660 * from various EXTD-IP REACH TLVs (135,235,236,237)
1664 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
1666 /* first lets see if we know the subTLVs name*/
1667 printf("%s%s subTLV #%u, length: %u",
1669 tok2str(isis_ext_ip_reach_subtlv_values
,
1675 if (!TTEST2(*tptr
,subl
))
1679 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1680 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1682 printf(", 0x%08x (=%u)",
1683 EXTRACT_32BITS(tptr
),
1684 EXTRACT_32BITS(tptr
));
1689 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1691 printf(", 0x%08x%08x",
1692 EXTRACT_32BITS(tptr
),
1693 EXTRACT_32BITS(tptr
+4));
1699 if(!print_unknown_data(gndo
,tptr
,"\n\t\t ",
1707 printf("%spacket exceeded snapshot",ident
);
1712 * this is the common IS-REACH subTLV decoder it is called
1713 * from isis_print_ext_is_reach()
1717 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,u_int subt
,u_int subl
,const char *ident
) {
1719 u_int te_class
,priority_level
,gmpls_switch_cap
;
1720 union { /* int to float conversion buffer for several subTLVs */
1725 /* first lets see if we know the subTLVs name*/
1726 printf("%s%s subTLV #%u, length: %u",
1728 tok2str(isis_ext_is_reach_subtlv_values
,
1734 if (!TTEST2(*tptr
,subl
))
1738 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1739 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1740 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1742 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
1743 if (subl
== 8) /* rfc4205 */
1744 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
1747 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1748 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1749 if (subl
>= sizeof(struct in_addr
))
1750 printf(", %s", ipaddr_string(tptr
));
1752 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1753 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1755 bw
.i
= EXTRACT_32BITS(tptr
);
1756 printf(", %.3f Mbps", bw
.f
*8/1000000 );
1759 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1761 for (te_class
= 0; te_class
< 8; te_class
++) {
1762 bw
.i
= EXTRACT_32BITS(tptr
);
1763 printf("%s TE-Class %u: %.3f Mbps",
1771 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
: /* fall through */
1772 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
:
1773 printf("%sBandwidth Constraints Model ID: %s (%u)",
1775 tok2str(diffserv_te_bc_values
, "unknown", *tptr
),
1778 /* decode BCs until the subTLV ends */
1779 for (te_class
= 0; te_class
< (subl
-1)/4; te_class
++) {
1780 bw
.i
= EXTRACT_32BITS(tptr
);
1781 printf("%s Bandwidth constraint CT%u: %.3f Mbps",
1788 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1790 printf(", %u", EXTRACT_24BITS(tptr
));
1792 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
:
1794 printf(", [ %s ] (0x%04x)",
1795 bittok2str(isis_subtlv_link_attribute_values
,
1797 EXTRACT_16BITS(tptr
)),
1798 EXTRACT_16BITS(tptr
));
1801 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1803 printf(", %s, Priority %u",
1804 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1808 case ISIS_SUBTLV_SPB_METRIC
:
1810 printf (", LM: %u", EXTRACT_24BITS(tptr
));
1812 printf (", P: %u", *(tptr
));
1814 printf (", P-ID: %u", EXTRACT_16BITS(tptr
));
1817 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1819 gmpls_switch_cap
= *tptr
;
1820 printf("%s Interface Switching Capability:%s",
1822 tok2str(gmpls_switch_cap_values
, "Unknown", gmpls_switch_cap
));
1823 printf(", LSP Encoding: %s",
1824 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
1826 printf("%s Max LSP Bandwidth:",ident
);
1827 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1828 bw
.i
= EXTRACT_32BITS(tptr
);
1829 printf("%s priority level %d: %.3f Mbps",
1836 switch (gmpls_switch_cap
) {
1841 bw
.i
= EXTRACT_32BITS(tptr
);
1842 printf("%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
*8/1000000);
1843 printf("%s Interface MTU: %u", ident
, EXTRACT_16BITS(tptr
+4));
1846 bw
.i
= EXTRACT_32BITS(tptr
);
1847 printf("%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
*8/1000000);
1848 printf("%s Indication %s", ident
,
1849 tok2str(gmpls_switch_cap_tsc_indication_values
, "Unknown (%u)", *(tptr
+4)));
1852 /* there is some optional stuff left to decode but this is as of yet
1853 not specified so just lets hexdump what is left */
1855 if(!print_unknown_data(gndo
,tptr
,"\n\t\t ",
1863 if(!print_unknown_data(gndo
,tptr
,"\n\t\t ",
1871 printf("%spacket exceeded snapshot",ident
);
1877 * this is the common IS-REACH decoder it is called
1878 * from various EXTD-IS REACH style TLVs (22,24,222)
1882 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
1884 char ident_buffer
[20];
1885 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1886 int proc_bytes
= 0; /* how many bytes did we process ? */
1888 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1891 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1892 tptr
+=(NODE_ID_LEN
);
1894 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1895 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
1897 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1901 if (!TTEST2(*tptr
, 1))
1903 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1904 proc_bytes
=NODE_ID_LEN
+3+1;
1905 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1906 if (subtlv_sum_len
) {
1907 printf(" (%u)",subtlv_sum_len
);
1908 while (subtlv_sum_len
>0) {
1909 if (!TTEST2(*tptr
,2))
1911 subtlv_type
=*(tptr
++);
1912 subtlv_len
=*(tptr
++);
1913 /* prepend the ident string */
1914 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1915 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
1918 subtlv_sum_len
-=(subtlv_len
+2);
1919 proc_bytes
+=(subtlv_len
+2);
1926 * this is the common Multi Topology ID decoder
1927 * it is called from various MT-TLVs (222,229,235,237)
1931 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1933 if (!TTEST2(*tptr
, 2))
1938 tok2str(isis_mt_values
,
1939 "Reserved for IETF Consensus",
1940 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1942 printf(" Topology (0x%03x), Flags: [%s]",
1943 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1944 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1950 * this is the common extended IP reach decoder
1951 * it is called from TLVs (135,235,236,237)
1952 * we process the TLV and optional subTLVs and return
1953 * the amount of processed bytes
1957 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1959 char ident_buffer
[20];
1961 u_int8_t prefix
[sizeof(struct in6_addr
)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1963 u_int8_t prefix
[sizeof(struct in_addr
)]; /* shared copy buffer for IPv4 prefixes */
1965 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1967 if (!TTEST2(*tptr
, 4))
1969 metric
= EXTRACT_32BITS(tptr
);
1973 if (afi
== AF_INET
) {
1974 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1976 status_byte
=*(tptr
++);
1977 bit_length
= status_byte
&0x3f;
1978 if (bit_length
> 32) {
1979 printf("%sIPv4 prefix: bad bit length %u",
1986 } else if (afi
== AF_INET6
) {
1987 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1989 status_byte
=*(tptr
++);
1990 bit_length
=*(tptr
++);
1991 if (bit_length
> 128) {
1992 printf("%sIPv6 prefix: bad bit length %u",
2000 return (0); /* somebody is fooling us */
2002 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
2004 if (!TTEST2(*tptr
, byte_length
))
2006 memset(prefix
, 0, sizeof prefix
); /* clear the copy buffer */
2007 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
2009 processed
+=byte_length
;
2012 printf("%sIPv4 prefix: %15s/%u",
2014 ipaddr_string(prefix
),
2017 if (afi
== AF_INET6
)
2018 printf("%sIPv6 prefix: %s/%u",
2020 ip6addr_string(prefix
),
2024 printf(", Distribution: %s, Metric: %u",
2025 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
2028 if (afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2029 printf(", sub-TLVs present");
2031 if (afi
== AF_INET6
)
2033 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
2034 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
2037 if ((afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2039 || (afi
== AF_INET6
&& ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
))
2042 /* assume that one prefix can hold more
2043 than one subTLV - therefore the first byte must reflect
2044 the aggregate bytecount of the subTLVs for this prefix
2046 if (!TTEST2(*tptr
, 1))
2049 processed
+=sublen
+1;
2050 printf(" (%u)",sublen
); /* print out subTLV length */
2053 if (!TTEST2(*tptr
,2))
2055 subtlvtype
=*(tptr
++);
2056 subtlvlen
=*(tptr
++);
2057 /* prepend the ident string */
2058 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
2059 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
2062 sublen
-=(subtlvlen
+2);
2070 * Decode IS-IS packets. Return 0 on error.
2073 static int isis_print (const u_int8_t
*p
, u_int length
)
2075 const struct isis_common_header
*isis_header
;
2077 const struct isis_iih_lan_header
*header_iih_lan
;
2078 const struct isis_iih_ptp_header
*header_iih_ptp
;
2079 struct isis_lsp_header
*header_lsp
;
2080 const struct isis_csnp_header
*header_csnp
;
2081 const struct isis_psnp_header
*header_psnp
;
2083 const struct isis_tlv_lsp
*tlv_lsp
;
2084 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
2085 const struct isis_tlv_is_reach
*tlv_is_reach
;
2086 const struct isis_tlv_es_reach
*tlv_es_reach
;
2088 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
2089 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
2090 const u_int8_t
*optr
, *pptr
, *tptr
;
2091 u_short packet_len
,pdu_len
, key_id
;
2096 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
2097 need it for parsing the checksum TLV and authentication
2099 isis_header
= (const struct isis_common_header
*)p
;
2100 TCHECK(*isis_header
);
2101 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
2102 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
2103 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
2104 header_lsp
= (struct isis_lsp_header
*)pptr
;
2105 header_csnp
= (const struct isis_csnp_header
*)pptr
;
2106 header_psnp
= (const struct isis_psnp_header
*)pptr
;
2112 * Sanity checking of the header.
2115 if (isis_header
->version
!= ISIS_VERSION
) {
2116 printf("version %d packet not supported", isis_header
->version
);
2120 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
2121 printf("system ID length of %d is not supported",
2122 isis_header
->id_length
);
2126 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
2127 printf("version %d packet not supported", isis_header
->pdu_version
);
2131 max_area
= isis_header
->max_area
;
2134 max_area
= 3; /* silly shit */
2137 printf("bad packet -- 255 areas");
2143 id_length
= isis_header
->id_length
;
2146 id_length
= 6; /* silly shit again */
2148 case 1: /* 1-8 are valid sys-ID lenghts */
2158 id_length
= 0; /* entirely useless */
2164 /* toss any non 6-byte sys-ID len PDUs */
2165 if (id_length
!= 6 ) {
2166 printf("bad packet -- illegal sys-ID length (%u)", id_length
);
2170 pdu_type
=isis_header
->pdu_type
;
2172 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
2176 tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
2180 case ISIS_PDU_L1_LAN_IIH
:
2181 case ISIS_PDU_L2_LAN_IIH
:
2182 printf(", src-id %s",
2183 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
2184 printf(", lan-id %s, prio %u",
2185 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
2186 header_iih_lan
->priority
);
2188 case ISIS_PDU_PTP_IIH
:
2189 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
2191 case ISIS_PDU_L1_LSP
:
2192 case ISIS_PDU_L2_LSP
:
2193 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
2194 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
2195 EXTRACT_32BITS(header_lsp
->sequence_number
),
2196 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
2198 case ISIS_PDU_L1_CSNP
:
2199 case ISIS_PDU_L2_CSNP
:
2200 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,NODE_ID_LEN
));
2202 case ISIS_PDU_L1_PSNP
:
2203 case ISIS_PDU_L2_PSNP
:
2204 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,NODE_ID_LEN
));
2208 printf(", length %u", length
);
2213 /* ok they seem to want to know everything - lets fully decode it */
2214 printf("%slength %u", eflag
? "" : ", ",length
);
2216 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
2217 tok2str(isis_pdu_values
,
2220 isis_header
->fixed_len
,
2221 isis_header
->version
,
2222 isis_header
->pdu_version
,
2224 isis_header
->id_length
,
2226 isis_header
->max_area
);
2229 if(!print_unknown_data(gndo
,optr
,"\n\t",8)) /* provide the _o_riginal pointer */
2230 return(0); /* for optionally debugging the common header */
2235 case ISIS_PDU_L1_LAN_IIH
:
2236 case ISIS_PDU_L2_LAN_IIH
:
2237 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
2238 printf(", bogus fixed header length %u should be %lu",
2239 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
2243 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
2244 if (packet_len
>pdu_len
) {
2245 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2249 TCHECK(*header_iih_lan
);
2250 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
2251 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
2252 EXTRACT_16BITS(header_iih_lan
->holding_time
),
2253 tok2str(isis_iih_circuit_type_values
,
2254 "unknown circuit type 0x%02x",
2255 header_iih_lan
->circuit_type
));
2257 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
2258 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
2259 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
2263 if(!print_unknown_data(gndo
,pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
2267 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2268 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2271 case ISIS_PDU_PTP_IIH
:
2272 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
2273 printf(", bogus fixed header length %u should be %lu",
2274 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
2278 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
2279 if (packet_len
>pdu_len
) {
2280 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2284 TCHECK(*header_iih_ptp
);
2285 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
2286 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
2287 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
2288 tok2str(isis_iih_circuit_type_values
,
2289 "unknown circuit type 0x%02x",
2290 header_iih_ptp
->circuit_type
));
2292 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
2293 header_iih_ptp
->circuit_id
,
2297 if(!print_unknown_data(gndo
,pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
2301 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2302 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2305 case ISIS_PDU_L1_LSP
:
2306 case ISIS_PDU_L2_LSP
:
2307 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
2308 printf(", bogus fixed header length %u should be %lu",
2309 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
2313 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
2314 if (packet_len
>pdu_len
) {
2315 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2319 TCHECK(*header_lsp
);
2320 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
2321 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
2322 EXTRACT_32BITS(header_lsp
->sequence_number
),
2323 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
2324 EXTRACT_16BITS(header_lsp
->checksum
));
2327 osi_print_cksum((u_int8_t
*)header_lsp
->lsp_id
,
2328 EXTRACT_16BITS(header_lsp
->checksum
), 12, length
-12);
2331 * Clear checksum and lifetime prior to signature verification.
2333 header_lsp
->checksum
[0] = 0;
2334 header_lsp
->checksum
[1] = 0;
2335 header_lsp
->remaining_lifetime
[0] = 0;
2336 header_lsp
->remaining_lifetime
[1] = 0;
2339 printf(", PDU length: %u, Flags: [ %s",
2341 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
2343 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
2344 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
2345 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
2346 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
2347 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
2348 printf("ATT bit set, ");
2350 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
2351 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
2354 if(!print_unknown_data(gndo
,pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
2358 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2359 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2362 case ISIS_PDU_L1_CSNP
:
2363 case ISIS_PDU_L2_CSNP
:
2364 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
2365 printf(", bogus fixed header length %u should be %lu",
2366 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
2370 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
2371 if (packet_len
>pdu_len
) {
2372 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2376 TCHECK(*header_csnp
);
2377 printf("\n\t source-id: %s, PDU length: %u",
2378 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
2380 printf("\n\t start lsp-id: %s",
2381 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
2382 printf("\n\t end lsp-id: %s",
2383 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
2386 if(!print_unknown_data(gndo
,pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
2390 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2391 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2394 case ISIS_PDU_L1_PSNP
:
2395 case ISIS_PDU_L2_PSNP
:
2396 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
2397 printf("- bogus fixed header length %u should be %lu",
2398 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
2402 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
2403 if (packet_len
>pdu_len
) {
2404 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2408 TCHECK(*header_psnp
);
2409 printf("\n\t source-id: %s, PDU length: %u",
2410 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
2414 if(!print_unknown_data(gndo
,pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
2418 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2419 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2423 if(!print_unknown_data(gndo
,pptr
,"\n\t ",length
))
2429 * Now print the TLV's.
2432 while (packet_len
>= 2) {
2433 if (pptr
== snapend
) {
2437 if (!TTEST2(*pptr
, 2)) {
2438 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
2439 (long)(pptr
-snapend
));
2444 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
2447 if (tlv_len
> packet_len
) {
2451 /* first lets see if we know the TLVs name*/
2452 printf("\n\t %s TLV #%u, length: %u",
2453 tok2str(isis_tlv_values
,
2459 if (tlv_len
== 0) /* something is malformed */
2462 /* now check if we have a decoder otherwise do a hexdump at the end*/
2464 case ISIS_TLV_AREA_ADDR
:
2465 if (!TTEST2(*tptr
, 1))
2468 while (tmp
&& alen
< tmp
) {
2469 printf("\n\t Area address (length: %u): %s",
2471 isonsap_string(tptr
,alen
));
2474 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
2476 if (!TTEST2(*tptr
, 1))
2481 case ISIS_TLV_ISNEIGH
:
2482 while (tmp
>= ETHER_ADDR_LEN
) {
2483 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
2485 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
2486 tmp
-= ETHER_ADDR_LEN
;
2487 tptr
+= ETHER_ADDR_LEN
;
2491 case ISIS_TLV_ISNEIGH_VARLEN
:
2492 if (!TTEST2(*tptr
, 1) || tmp
< 3) /* min. TLV length */
2494 lan_alen
= *tptr
++; /* LAN address length */
2495 if (lan_alen
== 0) {
2496 printf("\n\t LAN address length 0 bytes (invalid)");
2500 printf("\n\t LAN address length %u bytes ",lan_alen
);
2501 while (tmp
>= lan_alen
) {
2502 if (!TTEST2(*tptr
, lan_alen
))
2504 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
2510 case ISIS_TLV_PADDING
:
2513 case ISIS_TLV_MT_IS_REACH
:
2514 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2515 if (mt_len
== 0) /* did something go wrong ? */
2519 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
2520 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
2521 if (ext_is_len
== 0) /* did something go wrong ? */
2529 case ISIS_TLV_IS_ALIAS_ID
:
2530 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
2531 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
2532 if (ext_is_len
== 0) /* did something go wrong ? */
2539 case ISIS_TLV_EXT_IS_REACH
:
2540 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
2541 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
2542 if (ext_is_len
== 0) /* did something go wrong ? */
2548 case ISIS_TLV_IS_REACH
:
2549 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
2552 tok2str(isis_is_reach_virtual_values
,
2553 "bogus virtual flag 0x%02x",
2555 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
2556 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
2557 if (!TTEST(*tlv_is_reach
))
2559 printf("\n\t IS Neighbor: %s",
2560 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
2561 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
2562 tmp
-= sizeof(struct isis_tlv_is_reach
);
2567 case ISIS_TLV_ESNEIGH
:
2568 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
2569 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
2570 if (!TTEST(*tlv_es_reach
))
2572 printf("\n\t ES Neighbor: %s",
2573 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
2574 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
2575 tmp
-= sizeof(struct isis_tlv_es_reach
);
2580 /* those two TLVs share the same format */
2581 case ISIS_TLV_INT_IP_REACH
:
2582 case ISIS_TLV_EXT_IP_REACH
:
2583 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
2587 case ISIS_TLV_EXTD_IP_REACH
:
2589 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET
);
2590 if (ext_ip_len
== 0) /* did something go wrong ? */
2597 case ISIS_TLV_MT_IP_REACH
:
2598 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2599 if (mt_len
== 0) { /* did something go wrong ? */
2606 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET
);
2607 if (ext_ip_len
== 0) /* did something go wrong ? */
2615 case ISIS_TLV_IP6_REACH
:
2617 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET6
);
2618 if (ext_ip_len
== 0) /* did something go wrong ? */
2625 case ISIS_TLV_MT_IP6_REACH
:
2626 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2627 if (mt_len
== 0) { /* did something go wrong ? */
2634 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", AF_INET6
);
2635 if (ext_ip_len
== 0) /* did something go wrong ? */
2642 case ISIS_TLV_IP6ADDR
:
2643 while (tmp
>=sizeof(struct in6_addr
)) {
2644 if (!TTEST2(*tptr
, sizeof(struct in6_addr
)))
2647 printf("\n\t IPv6 interface address: %s",
2648 ip6addr_string(tptr
));
2650 tptr
+= sizeof(struct in6_addr
);
2651 tmp
-= sizeof(struct in6_addr
);
2656 if (!TTEST2(*tptr
, 1))
2660 tok2str(isis_subtlv_auth_values
,
2661 "unknown Authentication type 0x%02x",
2665 case ISIS_SUBTLV_AUTH_SIMPLE
:
2666 for(i
=1;i
<tlv_len
;i
++) {
2667 if (!TTEST2(*(tptr
+i
), 1))
2669 printf("%c",*(tptr
+i
));
2672 case ISIS_SUBTLV_AUTH_MD5
:
2673 for(i
=1;i
<tlv_len
;i
++) {
2674 if (!TTEST2(*(tptr
+i
), 1))
2676 printf("%02x",*(tptr
+i
));
2678 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
2679 printf(", (malformed subTLV) ");
2681 #ifdef HAVE_LIBCRYPTO
2682 sigcheck
= signature_verify(optr
, length
,
2683 (unsigned char *)tptr
+ 1);
2685 sigcheck
= CANT_CHECK_SIGNATURE
;
2687 printf(" (%s)", tok2str(signature_check_values
, "Unknown", sigcheck
));
2690 case ISIS_SUBTLV_AUTH_GENERIC
:
2691 key_id
= EXTRACT_16BITS((tptr
+1));
2692 printf("%u, password: ", key_id
);
2693 for(i
=1 + sizeof(u_int16_t
);i
<tlv_len
;i
++) {
2694 if (!TTEST2(*(tptr
+i
), 1))
2696 printf("%02x",*(tptr
+i
));
2699 case ISIS_SUBTLV_AUTH_PRIVATE
:
2701 if(!print_unknown_data(gndo
,tptr
+1,"\n\t\t ",tlv_len
-1))
2707 case ISIS_TLV_PTP_ADJ
:
2708 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
2710 if (!TTEST2(*tptr
, 1))
2712 printf("\n\t Adjacency State: %s (%u)",
2713 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
2717 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
2718 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
2719 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
2721 printf("\n\t Extended Local circuit-ID: 0x%08x",
2722 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
2723 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
2725 if(tmp
>=SYSTEM_ID_LEN
) {
2726 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
2728 printf("\n\t Neighbor System-ID: %s",
2729 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
2732 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
2733 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
2734 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
2736 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2737 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
2741 case ISIS_TLV_PROTOCOLS
:
2742 printf("\n\t NLPID(s): ");
2744 if (!TTEST2(*(tptr
), 1))
2746 printf("%s (0x%02x)",
2747 tok2str(nlpid_values
,
2751 if (tmp
>1) /* further NPLIDs ? - put comma */
2758 case ISIS_TLV_MT_PORT_CAP
:
2760 if (!TTEST2(*(tptr
), 2))
2763 printf("\n\t RES: %d, MTID(s): %d",
2764 (EXTRACT_16BITS (tptr
) >> 12),
2765 (EXTRACT_16BITS (tptr
) & 0x0fff));
2771 isis_print_mt_port_cap_subtlv (tptr
, tmp
);
2776 case ISIS_TLV_MT_CAPABILITY
:
2778 if (!TTEST2(*(tptr
), 2))
2781 printf("\n\t O: %d, RES: %d, MTID(s): %d",
2782 (EXTRACT_16BITS(tptr
) >> 15) & 0x01,
2783 (EXTRACT_16BITS(tptr
) >> 12) & 0x07,
2784 EXTRACT_16BITS(tptr
) & 0x0fff);
2790 isis_print_mt_capability_subtlv (tptr
, tmp
);
2794 case ISIS_TLV_TE_ROUTER_ID
:
2795 if (!TTEST2(*pptr
, sizeof(struct in_addr
)))
2797 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
2800 case ISIS_TLV_IPADDR
:
2801 while (tmp
>=sizeof(struct in_addr
)) {
2802 if (!TTEST2(*tptr
, sizeof(struct in_addr
)))
2804 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2805 tptr
+= sizeof(struct in_addr
);
2806 tmp
-= sizeof(struct in_addr
);
2810 case ISIS_TLV_HOSTNAME
:
2811 printf("\n\t Hostname: ");
2813 if (!TTEST2(*tptr
, 1))
2815 printf("%c",*tptr
++);
2820 case ISIS_TLV_SHARED_RISK_GROUP
:
2821 if (tmp
< NODE_ID_LEN
)
2823 if (!TTEST2(*tptr
, NODE_ID_LEN
))
2825 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
2826 tptr
+=(NODE_ID_LEN
);
2831 if (!TTEST2(*tptr
, 1))
2833 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
2836 if (tmp
< sizeof(struct in_addr
))
2838 if (!TTEST2(*tptr
,sizeof(struct in_addr
)))
2840 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2841 tptr
+=sizeof(struct in_addr
);
2842 tmp
-=sizeof(struct in_addr
);
2844 if (tmp
< sizeof(struct in_addr
))
2846 if (!TTEST2(*tptr
,sizeof(struct in_addr
)))
2848 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
2849 tptr
+=sizeof(struct in_addr
);
2850 tmp
-=sizeof(struct in_addr
);
2853 if (!TTEST2(*tptr
, 4))
2855 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
2862 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2863 while(tmp
>=sizeof(struct isis_tlv_lsp
)) {
2864 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2866 printf("\n\t lsp-id: %s",
2867 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
2868 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
2870 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
2871 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2873 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
2874 if (!TTEST2(tlv_lsp
->checksum
, 2))
2876 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
2877 tmp
-=sizeof(struct isis_tlv_lsp
);
2882 case ISIS_TLV_CHECKSUM
:
2883 if (tmp
< ISIS_TLV_CHECKSUM_MINLEN
)
2885 if (!TTEST2(*tptr
, ISIS_TLV_CHECKSUM_MINLEN
))
2887 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
2888 /* do not attempt to verify the checksum if it is zero
2889 * most likely a HMAC-MD5 TLV is also present and
2890 * to avoid conflicts the checksum TLV is zeroed.
2891 * see rfc3358 for details
2893 osi_print_cksum(optr
, EXTRACT_16BITS(tptr
), tptr
-optr
, length
);
2896 case ISIS_TLV_MT_SUPPORTED
:
2897 if (tmp
< ISIS_TLV_MT_SUPPORTED_MINLEN
)
2900 /* length can only be a multiple of 2, otherwise there is
2901 something broken -> so decode down until length is 1 */
2903 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2904 if (mt_len
== 0) /* did something go wrong ? */
2909 printf("\n\t malformed MT-ID");
2915 case ISIS_TLV_RESTART_SIGNALING
:
2916 /* first attempt to decode the flags */
2917 if (tmp
< ISIS_TLV_RESTART_SIGNALING_FLAGLEN
)
2919 if (!TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_FLAGLEN
))
2921 printf("\n\t Flags [%s]",
2922 bittok2str(isis_restart_flag_values
, "none", *tptr
));
2923 tptr
+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2924 tmp
-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2926 /* is there anything other than the flags field? */
2930 if (tmp
< ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
)
2932 if (!TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
))
2935 printf(", Remaining holding time %us", EXTRACT_16BITS(tptr
));
2936 tptr
+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2937 tmp
-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2939 /* is there an additional sysid field present ?*/
2940 if (tmp
== SYSTEM_ID_LEN
) {
2941 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2943 printf(", for %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2947 case ISIS_TLV_IDRP_INFO
:
2948 if (tmp
< ISIS_TLV_IDRP_INFO_MINLEN
)
2950 if (!TTEST2(*tptr
, ISIS_TLV_IDRP_INFO_MINLEN
))
2952 printf("\n\t Inter-Domain Information Type: %s",
2953 tok2str(isis_subtlv_idrp_values
,
2957 case ISIS_SUBTLV_IDRP_ASN
:
2958 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
2960 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
2962 case ISIS_SUBTLV_IDRP_LOCAL
:
2963 case ISIS_SUBTLV_IDRP_RES
:
2965 if(!print_unknown_data(gndo
,tptr
,"\n\t ",tlv_len
-1))
2971 case ISIS_TLV_LSP_BUFFERSIZE
:
2972 if (tmp
< ISIS_TLV_LSP_BUFFERSIZE_MINLEN
)
2974 if (!TTEST2(*tptr
, ISIS_TLV_LSP_BUFFERSIZE_MINLEN
))
2976 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
2979 case ISIS_TLV_PART_DIS
:
2980 while (tmp
>= SYSTEM_ID_LEN
) {
2981 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2983 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2984 tptr
+=SYSTEM_ID_LEN
;
2989 case ISIS_TLV_PREFIX_NEIGH
:
2990 if (tmp
< sizeof(struct isis_metric_block
))
2992 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2994 printf("\n\t Metric Block");
2995 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2996 tptr
+=sizeof(struct isis_metric_block
);
2997 tmp
-=sizeof(struct isis_metric_block
);
3000 if (!TTEST2(*tptr
, 1))
3002 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
3003 if (prefix_len
< 2) {
3004 printf("\n\t\tAddress: prefix length %u < 2", prefix_len
);
3008 if (tmp
< prefix_len
/2)
3010 if (!TTEST2(*tptr
, prefix_len
/2))
3012 printf("\n\t\tAddress: %s/%u",
3013 isonsap_string(tptr
,prefix_len
/2),
3020 case ISIS_TLV_IIH_SEQNR
:
3021 if (tmp
< ISIS_TLV_IIH_SEQNR_MINLEN
)
3023 if (!TTEST2(*tptr
, ISIS_TLV_IIH_SEQNR_MINLEN
)) /* check if four bytes are on the wire */
3025 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
3028 case ISIS_TLV_VENDOR_PRIVATE
:
3029 if (tmp
< ISIS_TLV_VENDOR_PRIVATE_MINLEN
)
3031 if (!TTEST2(*tptr
, ISIS_TLV_VENDOR_PRIVATE_MINLEN
)) /* check if enough byte for a full oui */
3033 vendor_id
= EXTRACT_24BITS(tptr
);
3034 printf("\n\t Vendor: %s (%u)",
3035 tok2str(oui_values
,"Unknown",vendor_id
),
3039 if (tmp
> 0) /* hexdump the rest */
3040 if(!print_unknown_data(gndo
,tptr
,"\n\t\t",tmp
))
3044 * FIXME those are the defined TLVs that lack a decoder
3045 * you are welcome to contribute code ;-)
3048 case ISIS_TLV_DECNET_PHASE4
:
3049 case ISIS_TLV_LUCENT_PRIVATE
:
3050 case ISIS_TLV_IPAUTH
:
3051 case ISIS_TLV_NORTEL_PRIVATE1
:
3052 case ISIS_TLV_NORTEL_PRIVATE2
:
3056 if(!print_unknown_data(gndo
,pptr
,"\n\t\t",tlv_len
))
3061 /* do we want to see an additionally hexdump ? */
3063 if(!print_unknown_data(gndo
,pptr
,"\n\t ",tlv_len
))
3068 packet_len
-= tlv_len
;
3071 if (packet_len
!= 0) {
3072 printf("\n\t %u straggler bytes", packet_len
);
3077 fputs("[|isis]", stdout
);
3081 printf("\n\t\t packet exceeded snapshot");
3086 osi_print_cksum (const u_int8_t
*pptr
, u_int16_t checksum
,
3087 u_int checksum_offset
, u_int length
)
3089 u_int16_t calculated_checksum
;
3091 /* do not attempt to verify the checksum if it is zero */
3093 printf("(unverified)");
3095 calculated_checksum
= create_osi_cksum(pptr
, checksum_offset
, length
);
3096 if (checksum
== calculated_checksum
) {
3097 printf(" (correct)");
3099 printf(" (incorrect should be 0x%04x)", calculated_checksum
);
3106 * c-style: whitesmith