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@gredler.at) for more
24 * complete IS-IS & CLNP support.
27 /* \summary: ISO CLNS, ESIS, and ISIS printer */
32 * CLNP: ISO 8473 (respective ITU version is at https://www.itu.int/rec/T-REC-X.233/en/)
41 #include "netdissect-stdinc.h"
45 #include "netdissect.h"
46 #include "addrtoname.h"
51 #include "signature.h"
55 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
58 #define SYSTEM_ID_LEN MAC_ADDR_LEN
59 #define NODE_ID_LEN (SYSTEM_ID_LEN+1)
60 #define LSP_ID_LEN (SYSTEM_ID_LEN+2)
62 #define ISIS_VERSION 1
63 #define ESIS_VERSION 1
64 #define CLNP_VERSION 1
66 #define ISIS_PDU_TYPE_MASK 0x1F
67 #define ESIS_PDU_TYPE_MASK 0x1F
68 #define CLNP_PDU_TYPE_MASK 0x1F
69 #define CLNP_FLAG_MASK 0xE0
70 #define ISIS_LAN_PRIORITY_MASK 0x7F
72 #define ISIS_PDU_L1_LAN_IIH 15
73 #define ISIS_PDU_L2_LAN_IIH 16
74 #define ISIS_PDU_PTP_IIH 17
75 #define ISIS_PDU_L1_LSP 18
76 #define ISIS_PDU_L2_LSP 20
77 #define ISIS_PDU_L1_CSNP 24
78 #define ISIS_PDU_L2_CSNP 25
79 #define ISIS_PDU_L1_PSNP 26
80 #define ISIS_PDU_L2_PSNP 27
82 static const struct tok isis_pdu_values
[] = {
83 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
84 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
85 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
86 { ISIS_PDU_L1_LSP
, "L1 LSP"},
87 { ISIS_PDU_L2_LSP
, "L2 LSP"},
88 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
89 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
90 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
91 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
96 * A TLV is a tuple of a type, length and a value and is normally used for
97 * encoding information in all sorts of places. This is an enumeration of
98 * the well known types.
100 * list taken from rfc3359 plus some memory from veterans ;-)
103 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
104 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
105 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
106 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
107 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
108 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
109 #define ISIS_TLV_INSTANCE_ID 7 /* rfc8202 */
110 #define ISIS_TLV_PADDING 8 /* iso10589 */
111 #define ISIS_TLV_LSP 9 /* iso10589 */
112 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
113 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
114 #define ISIS_TLV_CHECKSUM_MINLEN 2
115 #define ISIS_TLV_POI 13 /* rfc6232 */
116 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
117 #define ISIS_TLV_EXT_IS_REACH 22 /* rfc5305 */
118 #define ISIS_TLV_IS_ALIAS_ID 24 /* rfc5311 */
119 #define ISIS_TLV_DECNET_PHASE4 42
120 #define ISIS_TLV_LUCENT_PRIVATE 66
121 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
122 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
123 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
124 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
125 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
126 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
127 #define ISIS_TLV_TE_ROUTER_ID 134 /* rfc5305 */
128 #define ISIS_TLV_EXTD_IP_REACH 135 /* rfc5305 */
129 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
130 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
131 #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
132 #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
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_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
141 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
142 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
143 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
144 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
145 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
146 #define ISIS_TLV_ROUTER_CAPABILITY 242 /* rfc7981 */
147 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
148 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
150 static const struct tok isis_tlv_values
[] = {
151 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
152 { ISIS_TLV_IS_REACH
, "IS Reachability"},
153 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
154 { ISIS_TLV_PART_DIS
, "Partition DIS"},
155 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
156 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
157 { ISIS_TLV_INSTANCE_ID
, "Instance Identifier"},
158 { ISIS_TLV_PADDING
, "Padding"},
159 { ISIS_TLV_LSP
, "LSP entries"},
160 { ISIS_TLV_AUTH
, "Authentication"},
161 { ISIS_TLV_CHECKSUM
, "Checksum"},
162 { ISIS_TLV_POI
, "Purge Originator Identifier"},
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_MT_PORT_CAP
, "Multi-Topology-Aware Port Capability"},
178 { ISIS_TLV_MT_CAPABILITY
, "Multi-Topology Capability"},
179 { ISIS_TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
180 { ISIS_TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
181 { ISIS_TLV_HOSTNAME
, "Hostname"},
182 { ISIS_TLV_RESTART_SIGNALING
, "Restart Signaling"},
183 { ISIS_TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
184 { ISIS_TLV_MT_SUPPORTED
, "Multi Topology"},
185 { ISIS_TLV_IP6ADDR
, "IPv6 Interface address(es)"},
186 { ISIS_TLV_MT_IP_REACH
, "Multi-Topology IPv4 Reachability"},
187 { ISIS_TLV_IP6_REACH
, "IPv6 reachability"},
188 { ISIS_TLV_MT_IP6_REACH
, "Multi-Topology IP6 Reachability"},
189 { ISIS_TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
190 { ISIS_TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
191 { ISIS_TLV_ROUTER_CAPABILITY
, "IS-IS Router Capability"},
192 { ISIS_TLV_VENDOR_PRIVATE
, "Vendor Private"},
196 #define ESIS_OPTION_PROTOCOLS 129
197 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
198 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
199 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
200 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
201 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
202 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
204 static const struct tok esis_option_values
[] = {
205 { ESIS_OPTION_PROTOCOLS
, "Protocols supported"},
206 { ESIS_OPTION_QOS_MAINTENANCE
, "QoS Maintenance" },
207 { ESIS_OPTION_SECURITY
, "Security" },
208 { ESIS_OPTION_ES_CONF_TIME
, "ES Configuration Time" },
209 { ESIS_OPTION_PRIORITY
, "Priority" },
210 { ESIS_OPTION_ADDRESS_MASK
, "Addressk Mask" },
211 { ESIS_OPTION_SNPA_MASK
, "SNPA Mask" },
215 #define CLNP_OPTION_DISCARD_REASON 193
216 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
217 #define CLNP_OPTION_SECURITY 197 /* iso8473 */
218 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
219 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
220 #define CLNP_OPTION_PADDING 204 /* iso8473 */
221 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
223 static const struct tok clnp_option_values
[] = {
224 { CLNP_OPTION_DISCARD_REASON
, "Discard Reason"},
225 { CLNP_OPTION_PRIORITY
, "Priority"},
226 { CLNP_OPTION_QOS_MAINTENANCE
, "QoS Maintenance"},
227 { CLNP_OPTION_SECURITY
, "Security"},
228 { CLNP_OPTION_SOURCE_ROUTING
, "Source Routing"},
229 { CLNP_OPTION_ROUTE_RECORDING
, "Route Recording"},
230 { CLNP_OPTION_PADDING
, "Padding"},
234 static const struct tok clnp_option_rfd_class_values
[] = {
237 { 0x9, "Source Routeing"},
239 { 0xb, "PDU Discarded"},
240 { 0xc, "Reassembly"},
244 static const struct tok clnp_option_rfd_general_values
[] = {
245 { 0x0, "Reason not specified"},
246 { 0x1, "Protocol procedure error"},
247 { 0x2, "Incorrect checksum"},
248 { 0x3, "PDU discarded due to congestion"},
249 { 0x4, "Header syntax error (cannot be parsed)"},
250 { 0x5, "Segmentation needed but not permitted"},
251 { 0x6, "Incomplete PDU received"},
252 { 0x7, "Duplicate option"},
256 static const struct tok clnp_option_rfd_address_values
[] = {
257 { 0x0, "Destination address unreachable"},
258 { 0x1, "Destination address unknown"},
262 static const struct tok clnp_option_rfd_source_routeing_values
[] = {
263 { 0x0, "Unspecified source routeing error"},
264 { 0x1, "Syntax error in source routeing field"},
265 { 0x2, "Unknown address in source routeing field"},
266 { 0x3, "Path not acceptable"},
270 static const struct tok clnp_option_rfd_lifetime_values
[] = {
271 { 0x0, "Lifetime expired while data unit in transit"},
272 { 0x1, "Lifetime expired during reassembly"},
276 static const struct tok clnp_option_rfd_pdu_discard_values
[] = {
277 { 0x0, "Unsupported option not specified"},
278 { 0x1, "Unsupported protocol version"},
279 { 0x2, "Unsupported security option"},
280 { 0x3, "Unsupported source routeing option"},
281 { 0x4, "Unsupported recording of route option"},
285 static const struct tok clnp_option_rfd_reassembly_values
[] = {
286 { 0x0, "Reassembly interference"},
290 /* array of 16 error-classes */
291 static const struct tok
*clnp_option_rfd_error_class
[] = {
292 clnp_option_rfd_general_values
,
300 clnp_option_rfd_address_values
,
301 clnp_option_rfd_source_routeing_values
,
302 clnp_option_rfd_lifetime_values
,
303 clnp_option_rfd_pdu_discard_values
,
304 clnp_option_rfd_reassembly_values
,
310 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
311 #define CLNP_OPTION_SCOPE_MASK 0xc0
312 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
313 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
314 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
316 static const struct tok clnp_option_scope_values
[] = {
317 { CLNP_OPTION_SCOPE_SA_SPEC
, "Source Address Specific"},
318 { CLNP_OPTION_SCOPE_DA_SPEC
, "Destination Address Specific"},
319 { CLNP_OPTION_SCOPE_GLOBAL
, "Globally unique"},
323 static const struct tok clnp_option_sr_rr_values
[] = {
329 static const struct tok clnp_option_sr_rr_string_values
[] = {
330 { CLNP_OPTION_SOURCE_ROUTING
, "source routing"},
331 { CLNP_OPTION_ROUTE_RECORDING
, "recording of route in progress"},
335 static const struct tok clnp_option_qos_global_values
[] = {
337 { 0x10, "sequencing vs. delay"},
338 { 0x08, "congested"},
339 { 0x04, "delay vs. cost"},
340 { 0x02, "error vs. delay"},
341 { 0x01, "error vs. cost"},
345 static const struct tok isis_tlv_router_capability_flags
[] = {
351 #define ISIS_SUBTLV_ROUTER_CAP_SR 2 /* rfc 8667 */
353 static const struct tok isis_router_capability_subtlv_values
[] = {
354 { ISIS_SUBTLV_ROUTER_CAP_SR
, "SR-Capabilities"},
358 static const struct tok isis_router_capability_sr_flags
[] = {
364 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* rfc5305 */
365 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */
366 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* rfc5305 */
367 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* rfc5305 */
368 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* rfc5305 */
369 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* rfc5305 */
370 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* rfc5305 */
371 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
372 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
373 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* rfc5305 */
374 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
375 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
376 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
377 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
378 #define ISIS_SUBTLV_EXT_IS_REACH_LAN_ADJ_SEGMENT_ID 32 /* rfc8667 */
380 #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
382 static const struct tok isis_ext_is_reach_subtlv_values
[] = {
383 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
384 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
385 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
386 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
387 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
388 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
389 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
390 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
391 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
392 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
, "Link Attribute" },
393 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
394 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
395 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
, "Bandwidth Constraints (old)" },
396 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
, "Bandwidth Constraints" },
397 { ISIS_SUBTLV_EXT_IS_REACH_LAN_ADJ_SEGMENT_ID
, "LAN Adjacency Segment Identifier" },
398 { ISIS_SUBTLV_SPB_METRIC
, "SPB Metric" },
399 { 250, "Reserved for cisco specific extensions" },
400 { 251, "Reserved for cisco specific extensions" },
401 { 252, "Reserved for cisco specific extensions" },
402 { 253, "Reserved for cisco specific extensions" },
403 { 254, "Reserved for cisco specific extensions" },
404 { 255, "Reserved for future expansion" },
408 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
409 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
410 #define ISIS_SUBTLV_EXTD_IP_REACH_PREFIX_SID 3 /* rfc8667 */
411 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
413 static const struct tok isis_ext_ip_reach_subtlv_values
[] = {
414 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
415 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
416 { ISIS_SUBTLV_EXTD_IP_REACH_PREFIX_SID
, "Prefix SID" },
417 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
421 #define ISIS_PREFIX_SID_FLAG_R 0x80 /* rfc 8667 */
422 #define ISIS_PREFIX_SID_FLAG_N 0x40 /* rfc 8667 */
423 #define ISIS_PREFIX_SID_FLAG_P 0x20 /* rfc 8667 */
424 #define ISIS_PREFIX_SID_FLAG_E 0x10 /* rfc 8667 */
425 #define ISIS_PREFIX_SID_FLAG_V 0x08 /* rfc 8667 */
426 #define ISIS_PREFIX_SID_FLAG_L 0x04 /* rfc 8667 */
428 static const struct tok prefix_sid_flag_values
[] = {
429 { ISIS_PREFIX_SID_FLAG_R
, "Readvertisement"},
430 { ISIS_PREFIX_SID_FLAG_N
, "Node"},
431 { ISIS_PREFIX_SID_FLAG_P
, "No-PHP"},
432 { ISIS_PREFIX_SID_FLAG_E
, "Explicit NULL"},
433 { ISIS_PREFIX_SID_FLAG_V
, "Value"},
434 { ISIS_PREFIX_SID_FLAG_L
, "Local"},
440 static const struct tok prefix_sid_algo_values
[] = {
446 static const struct tok isis_subtlv_link_attribute_values
[] = {
447 { 0x01, "Local Protection Available" },
448 { 0x02, "Link excluded from local protection path" },
449 { 0x04, "Local maintenance required"},
453 static const struct tok isis_lan_adj_sid_flag_values
[] = {
454 { 0x80, "Address family IPv6" },
457 { 0x10, "Local significance" },
458 { 0x08, "Set of adjacencies" },
459 { 0x04, "Persistent" },
463 #define ISIS_SUBTLV_AUTH_SIMPLE 1
464 #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
465 #define ISIS_SUBTLV_AUTH_MD5 54
466 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
467 #define ISIS_SUBTLV_AUTH_PRIVATE 255
469 static const struct tok isis_subtlv_auth_values
[] = {
470 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
471 { ISIS_SUBTLV_AUTH_GENERIC
, "Generic Crypto key-id"},
472 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
473 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
477 #define ISIS_SUBTLV_IDRP_RES 0
478 #define ISIS_SUBTLV_IDRP_LOCAL 1
479 #define ISIS_SUBTLV_IDRP_ASN 2
481 static const struct tok isis_subtlv_idrp_values
[] = {
482 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
483 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
484 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
488 #define ISIS_SUBTLV_SPB_MCID 4
489 #define ISIS_SUBTLV_SPB_DIGEST 5
490 #define ISIS_SUBTLV_SPB_BVID 6
492 #define ISIS_SUBTLV_SPB_INSTANCE 1
493 #define ISIS_SUBTLV_SPBM_SI 3
495 #define ISIS_SPB_MCID_LEN 51
496 #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
497 #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
498 #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
499 #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
500 #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
502 static const struct tok isis_mt_port_cap_subtlv_values
[] = {
503 { ISIS_SUBTLV_SPB_MCID
, "SPB MCID" },
504 { ISIS_SUBTLV_SPB_DIGEST
, "SPB Digest" },
505 { ISIS_SUBTLV_SPB_BVID
, "SPB BVID" },
509 static const struct tok isis_mt_capability_subtlv_values
[] = {
510 { ISIS_SUBTLV_SPB_INSTANCE
, "SPB Instance" },
511 { ISIS_SUBTLV_SPBM_SI
, "SPBM Service Identifier and Unicast Address" },
515 struct isis_spb_mcid
{
516 nd_uint8_t format_id
;
518 nd_uint16_t revision_lvl
;
522 struct isis_subtlv_spb_mcid
{
523 struct isis_spb_mcid mcid
;
524 struct isis_spb_mcid aux_mcid
;
527 struct isis_subtlv_spb_instance
{
528 nd_byte cist_root_id
[8];
529 nd_uint32_t cist_external_root_path_cost
;
530 nd_uint16_t bridge_priority
;
531 nd_uint32_t spsourceid
;
532 nd_uint8_t no_of_trees
;
535 #define CLNP_SEGMENT_PART 0x80
536 #define CLNP_MORE_SEGMENTS 0x40
537 #define CLNP_REQUEST_ER 0x20
539 static const struct tok clnp_flag_values
[] = {
540 { CLNP_SEGMENT_PART
, "Segmentation permitted"},
541 { CLNP_MORE_SEGMENTS
, "more Segments"},
542 { CLNP_REQUEST_ER
, "request Error Report"},
546 #define ISIS_MASK_LSP_OL_BIT(x) (GET_U_1(x)&0x4)
547 #define ISIS_MASK_LSP_ISTYPE_BITS(x) (GET_U_1(x)&0x3)
548 #define ISIS_MASK_LSP_PARTITION_BIT(x) (GET_U_1(x)&0x80)
549 #define ISIS_MASK_LSP_ATT_BITS(x) (GET_U_1(x)&0x78)
550 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) (GET_U_1(x)&0x40)
551 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) (GET_U_1(x)&0x20)
552 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) (GET_U_1(x)&0x10)
553 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) (GET_U_1(x)&0x8)
555 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
556 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
558 static const struct tok isis_mt_flag_values
[] = {
559 { 0x4000, "ATT bit set"},
560 { 0x8000, "Overload bit set"},
564 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
565 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
567 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
568 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
570 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) (GET_U_1(x)&0x80)
571 #define ISIS_LSP_TLV_METRIC_IE(x) (GET_U_1(x)&0x40)
572 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) (GET_U_1(x)&0x80)
573 #define ISIS_LSP_TLV_METRIC_VALUE(x) (GET_U_1(x)&0x3f)
575 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
577 static const struct tok isis_mt_values
[] = {
578 { 0, "IPv4 unicast"},
579 { 1, "In-Band Management"},
580 { 2, "IPv6 unicast"},
582 { 4095, "Development, Experimental or Proprietary"},
586 static const struct tok isis_iih_circuit_type_values
[] = {
587 { 1, "Level 1 only"},
588 { 2, "Level 2 only"},
589 { 3, "Level 1, Level 2"},
593 #define ISIS_LSP_TYPE_UNUSED0 0
594 #define ISIS_LSP_TYPE_LEVEL_1 1
595 #define ISIS_LSP_TYPE_UNUSED2 2
596 #define ISIS_LSP_TYPE_LEVEL_2 3
598 static const struct tok isis_lsp_istype_values
[] = {
599 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
600 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
601 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
602 { ISIS_LSP_TYPE_LEVEL_2
, "L2 IS"},
607 * Katz's point to point adjacency TLV uses codes to tell us the state of
608 * the remote adjacency. Enumerate them.
611 #define ISIS_PTP_ADJ_UP 0
612 #define ISIS_PTP_ADJ_INIT 1
613 #define ISIS_PTP_ADJ_DOWN 2
615 static const struct tok isis_ptp_adjancey_values
[] = {
616 { ISIS_PTP_ADJ_UP
, "Up" },
617 { ISIS_PTP_ADJ_INIT
, "Initializing" },
618 { ISIS_PTP_ADJ_DOWN
, "Down" },
622 struct isis_tlv_ptp_adj
{
623 nd_uint8_t adjacency_state
;
624 nd_uint32_t extd_local_circuit_id
;
625 nd_byte neighbor_sysid
[SYSTEM_ID_LEN
];
626 nd_uint32_t neighbor_extd_local_circuit_id
;
629 static void osi_print_cksum(netdissect_options
*, const uint8_t *pptr
,
630 uint16_t checksum
, int checksum_offset
, u_int length
);
631 static int clnp_print(netdissect_options
*, const uint8_t *, u_int
);
632 static void esis_print(netdissect_options
*, const uint8_t *, u_int
);
633 static int isis_print(netdissect_options
*, const uint8_t *, u_int
);
635 struct isis_metric_block
{
636 nd_uint8_t metric_default
;
637 nd_uint8_t metric_delay
;
638 nd_uint8_t metric_expense
;
639 nd_uint8_t metric_error
;
642 struct isis_tlv_is_reach
{
643 struct isis_metric_block isis_metric_block
;
644 nd_byte neighbor_nodeid
[NODE_ID_LEN
];
647 struct isis_tlv_es_reach
{
648 struct isis_metric_block isis_metric_block
;
649 nd_byte neighbor_sysid
[SYSTEM_ID_LEN
];
652 struct isis_tlv_ip_reach
{
653 struct isis_metric_block isis_metric_block
;
658 static const struct tok isis_is_reach_virtual_values
[] = {
659 { 0, "IsNotVirtual"},
664 static const struct tok isis_restart_flag_values
[] = {
665 { 0x1, "Restart Request"},
666 { 0x2, "Restart Acknowledgement"},
667 { 0x4, "Suppress adjacency advertisement"},
671 struct isis_common_header
{
673 nd_uint8_t fixed_len
;
674 nd_uint8_t version
; /* Protocol version */
675 nd_uint8_t id_length
;
676 nd_uint8_t pdu_type
; /* 3 MSbits are reserved */
677 nd_uint8_t pdu_version
; /* Packet format version */
682 struct isis_iih_lan_header
{
683 nd_uint8_t circuit_type
;
684 nd_byte source_id
[SYSTEM_ID_LEN
];
685 nd_uint16_t holding_time
;
688 nd_byte lan_id
[NODE_ID_LEN
];
691 struct isis_iih_ptp_header
{
692 nd_uint8_t circuit_type
;
693 nd_byte source_id
[SYSTEM_ID_LEN
];
694 nd_uint16_t holding_time
;
696 nd_uint8_t circuit_id
;
699 struct isis_lsp_header
{
701 nd_uint16_t remaining_lifetime
;
702 nd_byte lsp_id
[LSP_ID_LEN
];
703 nd_uint32_t sequence_number
;
704 nd_uint16_t checksum
;
705 nd_uint8_t typeblock
;
708 struct isis_csnp_header
{
710 nd_byte source_id
[NODE_ID_LEN
];
711 nd_byte start_lsp_id
[LSP_ID_LEN
];
712 nd_byte end_lsp_id
[LSP_ID_LEN
];
715 struct isis_psnp_header
{
717 nd_byte source_id
[NODE_ID_LEN
];
720 struct isis_tlv_lsp
{
721 nd_uint16_t remaining_lifetime
;
722 nd_byte lsp_id
[LSP_ID_LEN
];
723 nd_uint32_t sequence_number
;
724 nd_uint16_t checksum
;
727 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
728 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
729 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
730 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
731 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
732 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
735 isoclns_print(netdissect_options
*ndo
, const u_char
*p
, u_int length
)
737 ndo
->ndo_protocol
= "isoclns";
740 ND_PRINT("OSI NLPID %s (0x%02x): ",
741 tok2str(nlpid_values
, "Unknown", GET_U_1(p
)),
744 switch (GET_U_1(p
)) {
747 if (!clnp_print(ndo
, p
, length
))
748 print_unknown_data(ndo
, p
, "\n\t", length
);
752 esis_print(ndo
, p
, length
);
756 if (!isis_print(ndo
, p
, length
))
757 print_unknown_data(ndo
, p
, "\n\t", length
);
761 ND_PRINT("%slength: %u", ndo
->ndo_eflag
? "" : ", ", length
);
765 q933_print(ndo
, p
+ 1, length
- 1);
769 ip_print(ndo
, p
+ 1, length
- 1);
773 ip6_print(ndo
, p
+ 1, length
- 1);
777 ppp_print(ndo
, p
+ 1, length
- 1);
782 ND_PRINT("OSI NLPID 0x%02x unknown", GET_U_1(p
));
783 ND_PRINT("%slength: %u", ndo
->ndo_eflag
? "" : ", ", length
);
785 print_unknown_data(ndo
, p
, "\n\t", length
);
790 #define CLNP_PDU_ER 1
791 #define CLNP_PDU_DT 28
792 #define CLNP_PDU_MD 29
793 #define CLNP_PDU_ERQ 30
794 #define CLNP_PDU_ERP 31
796 static const struct tok clnp_pdu_values
[] = {
797 { CLNP_PDU_ER
, "Error Report"},
798 { CLNP_PDU_MD
, "MD"},
799 { CLNP_PDU_DT
, "Data"},
800 { CLNP_PDU_ERQ
, "Echo Request"},
801 { CLNP_PDU_ERP
, "Echo Response"},
805 struct clnp_header_t
{
807 nd_uint8_t length_indicator
;
809 nd_uint8_t lifetime
; /* units of 500ms */
811 nd_uint16_t segment_length
;
815 struct clnp_segment_header_t
{
816 nd_uint16_t data_unit_id
;
817 nd_uint16_t segment_offset
;
818 nd_uint16_t total_length
;
823 * Decode CLNP packets. Return 0 on error.
827 clnp_print(netdissect_options
*ndo
,
828 const uint8_t *pptr
, u_int length
)
830 const uint8_t *optr
,*source_address
,*dest_address
;
831 u_int li
,li_remaining
,tlen
,nsap_offset
,source_address_length
,dest_address_length
, clnp_pdu_type
, clnp_flags
;
832 const struct clnp_header_t
*clnp_header
;
833 const struct clnp_segment_header_t
*clnp_segment_header
;
834 uint8_t rfd_error
,rfd_error_major
,rfd_error_minor
;
836 ndo
->ndo_protocol
= "clnp";
837 clnp_header
= (const struct clnp_header_t
*) pptr
;
838 ND_TCHECK_SIZE(clnp_header
);
840 li
= GET_U_1(clnp_header
->length_indicator
);
845 nd_print_protocol_caps(ndo
);
848 * Sanity checking of the header.
851 if (GET_U_1(clnp_header
->version
) != CLNP_VERSION
) {
852 ND_PRINT("version %u packet not supported",
853 GET_U_1(clnp_header
->version
));
858 ND_PRINT(" length indicator(%u) > PDU size (%u)!", li
, length
);
862 if (li
< sizeof(struct clnp_header_t
)) {
863 ND_PRINT(" length indicator %u < min PDU size:", li
);
864 while (pptr
< ndo
->ndo_snapend
) {
865 ND_PRINT("%02X", GET_U_1(pptr
));
871 /* FIXME further header sanity checking */
873 clnp_pdu_type
= GET_U_1(clnp_header
->type
) & CLNP_PDU_TYPE_MASK
;
874 clnp_flags
= GET_U_1(clnp_header
->type
) & CLNP_FLAG_MASK
;
876 pptr
+= sizeof(struct clnp_header_t
);
877 li_remaining
-= sizeof(struct clnp_header_t
);
879 if (li_remaining
< 1) {
880 ND_PRINT("li < size of fixed part of CLNP header and addresses");
883 dest_address_length
= GET_U_1(pptr
);
886 if (li_remaining
< dest_address_length
) {
887 ND_PRINT("li < size of fixed part of CLNP header and addresses");
890 ND_TCHECK_LEN(pptr
, dest_address_length
);
892 pptr
+= dest_address_length
;
893 li_remaining
-= dest_address_length
;
895 if (li_remaining
< 1) {
896 ND_PRINT("li < size of fixed part of CLNP header and addresses");
899 source_address_length
= GET_U_1(pptr
);
902 if (li_remaining
< source_address_length
) {
903 ND_PRINT("li < size of fixed part of CLNP header and addresses");
906 ND_TCHECK_LEN(pptr
, source_address_length
);
907 source_address
= pptr
;
908 pptr
+= source_address_length
;
909 li_remaining
-= source_address_length
;
911 if (ndo
->ndo_vflag
< 1) {
912 ND_PRINT("%s%s > %s, %s, length %u",
913 ndo
->ndo_eflag
? "" : ", ",
914 GET_ISONSAP_STRING(source_address
, source_address_length
),
915 GET_ISONSAP_STRING(dest_address
, dest_address_length
),
916 tok2str(clnp_pdu_values
,"unknown (%u)",clnp_pdu_type
),
920 ND_PRINT("%slength %u", ndo
->ndo_eflag
? "" : ", ", length
);
922 ND_PRINT("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
923 tok2str(clnp_pdu_values
, "unknown (%u)",clnp_pdu_type
),
924 GET_U_1(clnp_header
->length_indicator
),
925 GET_U_1(clnp_header
->version
),
926 GET_U_1(clnp_header
->lifetime
)/2,
927 (GET_U_1(clnp_header
->lifetime
)%2)*5,
928 GET_BE_U_2(clnp_header
->segment_length
),
929 GET_BE_U_2(clnp_header
->cksum
));
931 osi_print_cksum(ndo
, optr
, GET_BE_U_2(clnp_header
->cksum
), 7,
932 GET_U_1(clnp_header
->length_indicator
));
934 ND_PRINT("\n\tFlags [%s]",
935 bittok2str(clnp_flag_values
, "none", clnp_flags
));
937 ND_PRINT("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
938 source_address_length
,
939 GET_ISONSAP_STRING(source_address
, source_address_length
),
941 GET_ISONSAP_STRING(dest_address
, dest_address_length
));
943 if (clnp_flags
& CLNP_SEGMENT_PART
) {
944 if (li_remaining
< sizeof(struct clnp_segment_header_t
)) {
945 ND_PRINT("li < size of fixed part of CLNP header, addresses, and segment part");
948 clnp_segment_header
= (const struct clnp_segment_header_t
*) pptr
;
949 ND_TCHECK_SIZE(clnp_segment_header
);
950 ND_PRINT("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
951 GET_BE_U_2(clnp_segment_header
->data_unit_id
),
952 GET_BE_U_2(clnp_segment_header
->segment_offset
),
953 GET_BE_U_2(clnp_segment_header
->total_length
));
954 pptr
+=sizeof(struct clnp_segment_header_t
);
955 li_remaining
-=sizeof(struct clnp_segment_header_t
);
958 /* now walk the options */
959 while (li_remaining
!= 0) {
963 if (li_remaining
< 2) {
964 ND_PRINT(", bad opts/li");
969 opli
= GET_U_1(pptr
+ 1);
972 if (opli
> li_remaining
) {
973 ND_PRINT(", opt (%u) too long", op
);
976 ND_TCHECK_LEN(pptr
, opli
);
977 li_remaining
-= opli
;
981 ND_PRINT("\n\t %s Option #%u, length %u, value: ",
982 tok2str(clnp_option_values
,"Unknown",op
),
987 * We've already checked that the entire option is present
988 * in the captured packet with the ND_TCHECK_LEN() call.
989 * Therefore, we don't need to do ND_TCHECK()/ND_TCHECK_LEN()
991 * We do, however, need to check tlen, to make sure we
992 * don't run past the end of the option.
997 case CLNP_OPTION_ROUTE_RECORDING
: /* those two options share the format */
998 case CLNP_OPTION_SOURCE_ROUTING
:
1000 ND_PRINT(", bad opt len");
1004 tok2str(clnp_option_sr_rr_values
,"Unknown",GET_U_1(tptr
)),
1005 tok2str(clnp_option_sr_rr_string_values
, "Unknown Option %u", op
));
1006 nsap_offset
=GET_U_1(tptr
+ 1);
1007 if (nsap_offset
== 0) {
1008 ND_PRINT(" Bad NSAP offset (0)");
1011 nsap_offset
-=1; /* offset to nsap list */
1012 if (nsap_offset
> tlen
) {
1013 ND_PRINT(" Bad NSAP offset (past end of option)");
1019 source_address_length
=GET_U_1(tptr
);
1020 if (tlen
< source_address_length
+1) {
1021 ND_PRINT("\n\t NSAP address goes past end of option");
1024 if (source_address_length
> 0) {
1025 source_address
=(tptr
+1);
1026 ND_TCHECK_LEN(source_address
,
1027 source_address_length
);
1028 ND_PRINT("\n\t NSAP address (length %u): %s",
1029 source_address_length
,
1030 GET_ISONSAP_STRING(source_address
, source_address_length
));
1032 tlen
-=source_address_length
+1;
1036 case CLNP_OPTION_PRIORITY
:
1038 ND_PRINT(", bad opt len");
1041 ND_PRINT("0x%1x", GET_U_1(tptr
)&0x0f);
1044 case CLNP_OPTION_QOS_MAINTENANCE
:
1046 ND_PRINT(", bad opt len");
1049 ND_PRINT("\n\t Format Code: %s",
1050 tok2str(clnp_option_scope_values
, "Reserved", GET_U_1(tptr
) & CLNP_OPTION_SCOPE_MASK
));
1052 if ((GET_U_1(tptr
)&CLNP_OPTION_SCOPE_MASK
) == CLNP_OPTION_SCOPE_GLOBAL
)
1053 ND_PRINT("\n\t QoS Flags [%s]",
1054 bittok2str(clnp_option_qos_global_values
,
1056 GET_U_1(tptr
)&CLNP_OPTION_OPTION_QOS_MASK
));
1059 case CLNP_OPTION_SECURITY
:
1061 ND_PRINT(", bad opt len");
1064 ND_PRINT("\n\t Format Code: %s, Security-Level %u",
1065 tok2str(clnp_option_scope_values
,"Reserved",GET_U_1(tptr
)&CLNP_OPTION_SCOPE_MASK
),
1069 case CLNP_OPTION_DISCARD_REASON
:
1071 ND_PRINT(", bad opt len");
1074 rfd_error
= GET_U_1(tptr
);
1075 rfd_error_major
= (rfd_error
&0xf0) >> 4;
1076 rfd_error_minor
= rfd_error
&0x0f;
1077 ND_PRINT("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
1078 tok2str(clnp_option_rfd_class_values
,"Unknown",rfd_error_major
),
1080 tok2str(clnp_option_rfd_error_class
[rfd_error_major
],"Unknown",rfd_error_minor
),
1084 case CLNP_OPTION_PADDING
:
1085 ND_PRINT("padding data");
1089 * FIXME those are the defined Options that lack a decoder
1090 * you are welcome to contribute code ;-)
1094 print_unknown_data(ndo
, tptr
, "\n\t ", opli
);
1097 if (ndo
->ndo_vflag
> 1)
1098 print_unknown_data(ndo
, pptr
, "\n\t ", opli
);
1102 switch (clnp_pdu_type
) {
1104 case CLNP_PDU_ER
: /* fall through */
1106 if (GET_U_1(pptr
) == NLPID_CLNP
) {
1107 ND_PRINT("\n\t-----original packet-----\n\t");
1108 /* FIXME recursion protection */
1109 clnp_print(ndo
, pptr
, length
- li
);
1113 /* The cases above break from the switch block if they see and print
1114 * a CLNP header in the Data part. For an Error Report PDU this is
1115 * described in Section 7.9.6 of ITU X.233 (1997 E), also known as
1116 * ISO/IEC 8473-1:1998(E). It is not clear why in this code the same
1117 * applies to an Echo Response PDU, as the standard does not specify
1118 * the contents -- could be a proprietary extension or a bug. In either
1119 * case, if the Data part does not contain a CLNP header, its structure
1120 * is considered unknown and the decoding falls through to print the
1130 /* dump the PDU specific data */
1131 if (length
> ND_BYTES_BETWEEN(pptr
, optr
)) {
1132 ND_PRINT("\n\t undecoded non-header data, length %u", length
-li
);
1133 print_unknown_data(ndo
, pptr
, "\n\t ", length
- ND_BYTES_BETWEEN(pptr
, optr
));
1140 nd_print_trunc(ndo
);
1146 #define ESIS_PDU_REDIRECT 6
1147 #define ESIS_PDU_ESH 2
1148 #define ESIS_PDU_ISH 4
1150 static const struct tok esis_pdu_values
[] = {
1151 { ESIS_PDU_REDIRECT
, "redirect"},
1152 { ESIS_PDU_ESH
, "ESH"},
1153 { ESIS_PDU_ISH
, "ISH"},
1157 struct esis_header_t
{
1159 nd_uint8_t length_indicator
;
1163 nd_uint16_t holdtime
;
1168 esis_print(netdissect_options
*ndo
,
1169 const uint8_t *pptr
, u_int length
)
1171 const uint8_t *optr
;
1172 u_int li
, version
, esis_pdu_type
, source_address_length
, source_address_number
;
1173 const struct esis_header_t
*esis_header
;
1175 ndo
->ndo_protocol
= "esis";
1176 if (!ndo
->ndo_eflag
)
1180 ND_PRINT(ndo
->ndo_qflag
? "bad pkt!" : "no header at all!");
1184 esis_header
= (const struct esis_header_t
*) pptr
;
1185 ND_TCHECK_SIZE(esis_header
);
1186 li
= GET_U_1(esis_header
->length_indicator
);
1190 * Sanity checking of the header.
1193 if (GET_U_1(esis_header
->nlpid
) != NLPID_ESIS
) {
1194 ND_PRINT(" nlpid 0x%02x packet not supported",
1195 GET_U_1(esis_header
->nlpid
));
1199 version
= GET_U_1(esis_header
->version
);
1200 if (version
!= ESIS_VERSION
) {
1201 ND_PRINT(" version %u packet not supported", version
);
1206 ND_PRINT(" length indicator(%u) > PDU size (%u)!", li
, length
);
1210 if (li
< sizeof(struct esis_header_t
) + 2) {
1211 ND_PRINT(" length indicator %u < min PDU size:", li
);
1212 while (pptr
< ndo
->ndo_snapend
) {
1213 ND_PRINT("%02X", GET_U_1(pptr
));
1219 esis_pdu_type
= GET_U_1(esis_header
->type
) & ESIS_PDU_TYPE_MASK
;
1221 if (ndo
->ndo_vflag
< 1) {
1222 ND_PRINT("%s%s, length %u",
1223 ndo
->ndo_eflag
? "" : ", ",
1224 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
1228 ND_PRINT("%slength %u\n\t%s (%u)",
1229 ndo
->ndo_eflag
? "" : ", ",
1231 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
1234 ND_PRINT(", v: %u%s", version
, version
== ESIS_VERSION
? "" : "unsupported" );
1235 ND_PRINT(", checksum: 0x%04x", GET_BE_U_2(esis_header
->cksum
));
1237 osi_print_cksum(ndo
, pptr
, GET_BE_U_2(esis_header
->cksum
), 7,
1240 ND_PRINT(", holding time: %us, length indicator: %u",
1241 GET_BE_U_2(esis_header
->holdtime
), li
);
1243 if (ndo
->ndo_vflag
> 1)
1244 print_unknown_data(ndo
, optr
, "\n\t", sizeof(struct esis_header_t
));
1246 pptr
+= sizeof(struct esis_header_t
);
1247 li
-= sizeof(struct esis_header_t
);
1249 switch (esis_pdu_type
) {
1250 case ESIS_PDU_REDIRECT
: {
1251 const uint8_t *dst
, *snpa
, *neta
;
1252 u_int dstl
, snpal
, netal
;
1256 ND_PRINT(", bad redirect/li");
1259 dstl
= GET_U_1(pptr
);
1262 ND_TCHECK_LEN(pptr
, dstl
);
1264 ND_PRINT(", bad redirect/li");
1270 ND_PRINT("\n\t %s", GET_ISONSAP_STRING(dst
, dstl
));
1274 ND_PRINT(", bad redirect/li");
1277 snpal
= GET_U_1(pptr
);
1280 ND_TCHECK_LEN(pptr
, snpal
);
1282 ND_PRINT(", bad redirect/li");
1290 ND_PRINT(", bad redirect/li");
1293 netal
= GET_U_1(pptr
);
1295 ND_TCHECK_LEN(pptr
, netal
);
1297 ND_PRINT(", bad redirect/li");
1305 ND_PRINT("\n\t SNPA (length: %u): %s",
1307 GET_ETHERADDR_STRING(snpa
));
1309 ND_PRINT("\n\t SNPA (length: %u): %s",
1311 GET_LINKADDR_STRING(snpa
, LINKADDR_OTHER
, snpal
));
1313 ND_PRINT("\n\t NET (length: %u) %s",
1315 GET_ISONSAP_STRING(neta
, netal
));
1322 ND_PRINT(", bad esh/li");
1325 source_address_number
= GET_U_1(pptr
);
1329 ND_PRINT("\n\t Number of Source Addresses: %u", source_address_number
);
1331 while (source_address_number
> 0) {
1334 ND_PRINT(", bad esh/li");
1337 source_address_length
= GET_U_1(pptr
);
1341 ND_TCHECK_LEN(pptr
, source_address_length
);
1342 if (li
< source_address_length
) {
1343 ND_PRINT(", bad esh/li");
1346 ND_PRINT("\n\t NET (length: %u): %s",
1347 source_address_length
,
1348 GET_ISONSAP_STRING(pptr
, source_address_length
));
1349 pptr
+= source_address_length
;
1350 li
-= source_address_length
;
1351 source_address_number
--;
1356 case ESIS_PDU_ISH
: {
1359 ND_PRINT(", bad ish/li");
1362 source_address_length
= GET_U_1(pptr
);
1365 ND_TCHECK_LEN(pptr
, source_address_length
);
1366 if (li
< source_address_length
) {
1367 ND_PRINT(", bad ish/li");
1370 ND_PRINT("\n\t NET (length: %u): %s", source_address_length
, GET_ISONSAP_STRING(pptr
, source_address_length
));
1371 pptr
+= source_address_length
;
1372 li
-= source_address_length
;
1377 if (ndo
->ndo_vflag
<= 1) {
1379 * If there's at least one byte to print, print
1382 if (ND_TTEST_LEN(pptr
, 1))
1383 print_unknown_data(ndo
, pptr
, "\n\t ", ND_BYTES_AVAILABLE_AFTER(pptr
));
1388 /* now walk the options */
1391 const uint8_t *tptr
;
1394 ND_PRINT(", bad opts/li");
1399 opli
= GET_U_1(pptr
+ 1);
1403 ND_PRINT(", opt (%u) too long", op
);
1409 ND_PRINT("\n\t %s Option #%u, length %u, value: ",
1410 tok2str(esis_option_values
,"Unknown",op
),
1416 case ESIS_OPTION_ES_CONF_TIME
:
1419 ND_PRINT("%us", GET_BE_U_2(tptr
));
1421 ND_PRINT("(bad length)");
1424 case ESIS_OPTION_PROTOCOLS
:
1426 ND_PRINT("%s (0x%02x)",
1427 tok2str(nlpid_values
,
1431 if (opli
>1) /* further NPLIDs ? - put comma */
1439 * FIXME those are the defined Options that lack a decoder
1440 * you are welcome to contribute code ;-)
1443 case ESIS_OPTION_QOS_MAINTENANCE
:
1444 case ESIS_OPTION_SECURITY
:
1445 case ESIS_OPTION_PRIORITY
:
1446 case ESIS_OPTION_ADDRESS_MASK
:
1447 case ESIS_OPTION_SNPA_MASK
:
1450 print_unknown_data(ndo
, tptr
, "\n\t ", opli
);
1453 if (ndo
->ndo_vflag
> 1)
1454 print_unknown_data(ndo
, pptr
, "\n\t ", opli
);
1460 nd_print_trunc(ndo
);
1464 isis_print_mcid(netdissect_options
*ndo
,
1465 const struct isis_spb_mcid
*mcid
)
1469 ND_TCHECK_SIZE(mcid
);
1470 ND_PRINT("ID: %u, Name: ", GET_U_1(mcid
->format_id
));
1472 if (nd_printzp(ndo
, mcid
->name
, 32, ndo
->ndo_snapend
))
1475 ND_PRINT("\n\t Lvl: %u", GET_BE_U_2(mcid
->revision_lvl
));
1477 ND_PRINT(", Digest: ");
1480 ND_PRINT("%.2x ", mcid
->digest
[i
]);
1484 nd_print_trunc(ndo
);
1488 isis_print_mt_port_cap_subtlv(netdissect_options
*ndo
,
1489 const uint8_t *tptr
, u_int len
)
1491 u_int stlv_type
, stlv_len
;
1492 const struct isis_subtlv_spb_mcid
*subtlv_spb_mcid
;
1498 stlv_type
= GET_U_1(tptr
);
1499 stlv_len
= GET_U_1(tptr
+ 1);
1501 /* first lets see if we know the subTLVs name*/
1502 ND_PRINT("\n\t %s subTLV #%u, length: %u",
1503 tok2str(isis_mt_port_cap_subtlv_values
, "unknown", stlv_type
),
1508 /*len -= TLV_TYPE_LEN_OFFSET;*/
1511 /* Make sure the subTLV fits within the space left */
1513 goto subtlv_too_long
;
1514 /* Make sure the entire subTLV is in the captured data */
1515 ND_TCHECK_LEN(tptr
, stlv_len
);
1519 case ISIS_SUBTLV_SPB_MCID
:
1521 if (stlv_len
< ISIS_SUBTLV_SPB_MCID_MIN_LEN
)
1522 goto subtlv_too_short
;
1524 subtlv_spb_mcid
= (const struct isis_subtlv_spb_mcid
*)tptr
;
1526 ND_PRINT("\n\t MCID: ");
1527 isis_print_mcid(ndo
, &(subtlv_spb_mcid
->mcid
));
1529 /*tptr += SPB_MCID_MIN_LEN;
1530 len -= SPB_MCID_MIN_LEN; */
1532 ND_PRINT("\n\t AUX-MCID: ");
1533 isis_print_mcid(ndo
, &(subtlv_spb_mcid
->aux_mcid
));
1535 /*tptr += SPB_MCID_MIN_LEN;
1536 len -= SPB_MCID_MIN_LEN; */
1537 tptr
+= ISIS_SUBTLV_SPB_MCID_MIN_LEN
;
1538 len
-= ISIS_SUBTLV_SPB_MCID_MIN_LEN
;
1539 stlv_len
-= ISIS_SUBTLV_SPB_MCID_MIN_LEN
;
1544 case ISIS_SUBTLV_SPB_DIGEST
:
1546 if (stlv_len
< ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
)
1547 goto subtlv_too_short
;
1549 ND_PRINT("\n\t RES: %u V: %u A: %u D: %u",
1550 (GET_U_1(tptr
) >> 5),
1551 ((GET_U_1(tptr
) >> 4) & 0x01),
1552 ((GET_U_1(tptr
) >> 2) & 0x03),
1553 (GET_U_1(tptr
) & 0x03));
1557 ND_PRINT("\n\t Digest: ");
1561 ND_PRINT("%08x ", GET_BE_U_4(tptr
));
1562 if (i
%4 == 0 && i
!= 8)
1567 len
-= ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
;
1568 stlv_len
-= ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
;
1573 case ISIS_SUBTLV_SPB_BVID
:
1575 while (stlv_len
!= 0)
1578 goto subtlv_too_short
;
1579 ND_PRINT("\n\t ECT: %08x",
1587 goto subtlv_too_short
;
1588 ND_PRINT(" BVID: %u, U:%01x M:%01x ",
1589 (GET_BE_U_2(tptr
) >> 4) ,
1590 (GET_BE_U_2(tptr
) >> 3) & 0x01,
1591 (GET_BE_U_2(tptr
) >> 2) & 0x01);
1610 nd_print_trunc(ndo
);
1614 ND_PRINT(" (> containing TLV length)");
1618 ND_PRINT(" (too short)");
1623 isis_print_mt_capability_subtlv(netdissect_options
*ndo
,
1624 const uint8_t *tptr
, u_int len
)
1626 u_int stlv_type
, stlv_len
, treecount
;
1631 stlv_type
= GET_U_1(tptr
);
1632 stlv_len
= GET_U_1(tptr
+ 1);
1636 /* first lets see if we know the subTLVs name*/
1637 ND_PRINT("\n\t %s subTLV #%u, length: %u",
1638 tok2str(isis_mt_capability_subtlv_values
, "unknown", stlv_type
),
1642 /* Make sure the subTLV fits within the space left */
1644 goto subtlv_too_long
;
1645 /* Make sure the entire subTLV is in the captured data */
1646 ND_TCHECK_LEN(tptr
, stlv_len
);
1650 case ISIS_SUBTLV_SPB_INSTANCE
:
1651 if (stlv_len
< ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
)
1652 goto subtlv_too_short
;
1654 ND_PRINT("\n\t CIST Root-ID: %08x", GET_BE_U_4(tptr
));
1656 ND_PRINT(" %08x", GET_BE_U_4(tptr
));
1658 ND_PRINT(", Path Cost: %08x", GET_BE_U_4(tptr
));
1660 ND_PRINT(", Prio: %u", GET_BE_U_2(tptr
));
1662 ND_PRINT("\n\t RES: %u",
1663 GET_BE_U_2(tptr
) >> 5);
1665 (GET_BE_U_2(tptr
) >> 4) & 0x0001);
1666 ND_PRINT(", SPSource-ID: %u",
1667 (GET_BE_U_4(tptr
) & 0x000fffff));
1669 ND_PRINT(", No of Trees: %x", GET_U_1(tptr
));
1671 treecount
= GET_U_1(tptr
);
1674 len
-= ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
;
1675 stlv_len
-= ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
;
1679 if (stlv_len
< ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
)
1682 ND_PRINT("\n\t U:%u, M:%u, A:%u, RES:%u",
1684 (GET_U_1(tptr
) >> 6) & 0x01,
1685 (GET_U_1(tptr
) >> 5) & 0x01,
1686 (GET_U_1(tptr
) & 0x1f));
1690 ND_PRINT(", ECT: %08x", GET_BE_U_4(tptr
));
1694 ND_PRINT(", BVID: %u, SPVID: %u",
1695 (GET_BE_U_3(tptr
) >> 12) & 0x000fff,
1696 GET_BE_U_3(tptr
) & 0x000fff);
1699 len
-= ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
;
1700 stlv_len
-= ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
;
1706 case ISIS_SUBTLV_SPBM_SI
:
1710 ND_PRINT("\n\t BMAC: %08x", GET_BE_U_4(tptr
));
1712 ND_PRINT("%04x", GET_BE_U_2(tptr
));
1715 ND_PRINT(", RES: %u, VID: %u", GET_BE_U_2(tptr
) >> 12,
1716 (GET_BE_U_2(tptr
)) & 0x0fff);
1722 while (stlv_len
>= 4) {
1723 ND_PRINT("\n\t T: %u, R: %u, RES: %u, ISID: %u",
1724 (GET_BE_U_4(tptr
) >> 31),
1725 (GET_BE_U_4(tptr
) >> 30) & 0x01,
1726 (GET_BE_U_4(tptr
) >> 24) & 0x03f,
1727 (GET_BE_U_4(tptr
)) & 0x0ffffff);
1745 nd_print_trunc(ndo
);
1749 ND_PRINT(" (> containing TLV length)");
1753 ND_PRINT(" (too short)");
1757 /* shared routine for printing system, node and lsp-ids */
1759 isis_print_id(netdissect_options
*ndo
, const uint8_t *cp
, u_int id_len
)
1762 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1766 sysid_len
= SYSTEM_ID_LEN
;
1767 if (sysid_len
> id_len
)
1769 for (i
= 1; i
<= sysid_len
; i
++) {
1770 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", GET_U_1(cp
));
1773 if (i
== 2 || i
== 4)
1776 if (id_len
>= NODE_ID_LEN
) {
1777 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", GET_U_1(cp
));
1781 if (id_len
== LSP_ID_LEN
)
1782 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", GET_U_1(cp
));
1786 /* print the 4-byte metric block which is common found in the old-style TLVs */
1788 isis_print_metric_block(netdissect_options
*ndo
,
1789 const struct isis_metric_block
*isis_metric_block
)
1791 ND_PRINT(", Default Metric: %u, %s",
1792 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
1793 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
1794 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
1795 ND_PRINT("\n\t\t Delay Metric: %u, %s",
1796 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
1797 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
1798 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
1799 ND_PRINT("\n\t\t Expense Metric: %u, %s",
1800 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
1801 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
1802 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
1803 ND_PRINT("\n\t\t Error Metric: %u, %s",
1804 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
1805 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
1807 return(1); /* everything is ok */
1811 isis_print_tlv_ip_reach(netdissect_options
*ndo
,
1812 const uint8_t *cp
, const char *ident
, u_int length
)
1815 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
1817 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
1819 while (length
> 0) {
1820 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
1821 ND_PRINT("short IPv4 Reachability (%u vs %zu)",
1823 sizeof(*tlv_ip_reach
));
1827 ND_TCHECK_SIZE(tlv_ip_reach
);
1829 prefix_len
= mask2plen(GET_IPV4_TO_HOST_ORDER(tlv_ip_reach
->mask
));
1831 if (prefix_len
== -1)
1832 ND_PRINT("%sIPv4 prefix: %s mask %s",
1834 GET_IPADDR_STRING(tlv_ip_reach
->prefix
),
1835 GET_IPADDR_STRING(tlv_ip_reach
->mask
));
1837 ND_PRINT("%sIPv4 prefix: %15s/%u",
1839 GET_IPADDR_STRING(tlv_ip_reach
->prefix
),
1842 ND_PRINT(", Distribution: %s, Metric: %u, %s",
1843 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
1844 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
1845 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
1847 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
1848 ND_PRINT("%s Delay Metric: %u, %s",
1850 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
1851 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
1853 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
1854 ND_PRINT("%s Expense Metric: %u, %s",
1856 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
1857 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
1859 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
1860 ND_PRINT("%s Error Metric: %u, %s",
1862 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
1863 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
1865 length
-= sizeof(struct isis_tlv_ip_reach
);
1874 * this is the common IP-REACH subTLV decoder it is called
1875 * from various EXTD-IP REACH TLVs (135,235,236,237)
1879 isis_print_ip_reach_subtlv(netdissect_options
*ndo
,
1880 const uint8_t *tptr
, u_int subt
, u_int subl
,
1883 /* first lets see if we know the subTLVs name*/
1884 ND_PRINT("%s%s subTLV #%u, length: %u",
1885 ident
, tok2str(isis_ext_ip_reach_subtlv_values
, "unknown", subt
),
1888 ND_TCHECK_LEN(tptr
, subl
);
1891 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1892 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1894 ND_PRINT(", 0x%08x (=%u)",
1901 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1903 ND_PRINT(", 0x%08x%08x",
1905 GET_BE_U_4(tptr
+ 4));
1910 case ISIS_SUBTLV_EXTD_IP_REACH_PREFIX_SID
:
1912 uint8_t algo
, flags
;
1915 flags
= GET_U_1(tptr
);
1916 algo
= GET_U_1(tptr
+1);
1918 if (flags
& ISIS_PREFIX_SID_FLAG_V
) {
1921 sid
= GET_BE_U_3(tptr
+2);
1927 sid
= GET_BE_U_4(tptr
+2);
1932 ND_PRINT(", Flags [%s], Algo %s (%u), %s %u",
1933 bittok2str(prefix_sid_flag_values
, "None", flags
),
1934 tok2str(prefix_sid_algo_values
, "Unknown", algo
), algo
,
1935 flags
& ISIS_PREFIX_SID_FLAG_V
? "label" : "index",
1940 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1947 nd_print_trunc(ndo
);
1952 * this is the common IS-REACH decoder it is called
1953 * from various EXTD-IS REACH style TLVs (22,24,222)
1957 isis_print_ext_is_reach(netdissect_options
*ndo
,
1958 const uint8_t *tptr
, const char *ident
, u_int tlv_type
,
1959 u_int tlv_remaining
)
1961 char ident_buffer
[20];
1962 u_int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1963 int proc_bytes
= 0; /* how many bytes did we process ? */
1964 u_int te_class
,priority_level
,gmpls_switch_cap
;
1965 union { /* int to float conversion buffer for several subTLVs */
1970 ND_TCHECK_LEN(tptr
, NODE_ID_LEN
);
1971 if (tlv_remaining
< NODE_ID_LEN
)
1974 ND_PRINT("%sIS Neighbor: %s", ident
, isis_print_id(ndo
, tptr
, NODE_ID_LEN
));
1976 tlv_remaining
-=NODE_ID_LEN
;
1977 proc_bytes
+=NODE_ID_LEN
;
1979 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1981 if (tlv_remaining
< 3)
1983 ND_PRINT(", Metric: %u", GET_BE_U_3(tptr
));
1990 if (tlv_remaining
< 1)
1992 subtlv_sum_len
=GET_U_1(tptr
); /* read out subTLV length */
1996 ND_PRINT(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1997 if (subtlv_sum_len
) {
1998 ND_PRINT(" (%u)", subtlv_sum_len
);
1999 /* prepend the indent string */
2000 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
2001 ident
= ident_buffer
;
2002 while (subtlv_sum_len
!= 0) {
2004 if (tlv_remaining
< 2) {
2005 ND_PRINT("%sRemaining data in TLV shorter than a subTLV header",ident
);
2006 proc_bytes
+= tlv_remaining
;
2009 if (subtlv_sum_len
< 2) {
2010 ND_PRINT("%sRemaining data in subTLVs shorter than a subTLV header",ident
);
2011 proc_bytes
+= subtlv_sum_len
;
2014 subtlv_type
=GET_U_1(tptr
);
2015 subtlv_len
=GET_U_1(tptr
+ 1);
2018 subtlv_sum_len
-= 2;
2020 ND_PRINT("%s%s subTLV #%u, length: %u",
2021 ident
, tok2str(isis_ext_is_reach_subtlv_values
, "unknown", subtlv_type
),
2022 subtlv_type
, subtlv_len
);
2024 if (subtlv_sum_len
< subtlv_len
) {
2025 ND_PRINT(" (remaining data in subTLVs shorter than the current subTLV)");
2026 proc_bytes
+= subtlv_sum_len
;
2030 if (tlv_remaining
< subtlv_len
) {
2031 ND_PRINT(" (> remaining tlv length)");
2032 proc_bytes
+= tlv_remaining
;
2036 ND_TCHECK_LEN(tptr
, subtlv_len
);
2038 switch(subtlv_type
) {
2039 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
2040 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
2041 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
2042 if (subtlv_len
>= 4) {
2043 ND_PRINT(", 0x%08x", GET_BE_U_4(tptr
));
2044 if (subtlv_len
== 8) /* rfc4205 */
2045 ND_PRINT(", 0x%08x", GET_BE_U_4(tptr
+ 4));
2048 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
2049 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
2050 if (subtlv_len
>= sizeof(nd_ipv4
))
2051 ND_PRINT(", %s", GET_IPADDR_STRING(tptr
));
2053 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
2054 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
2055 if (subtlv_len
>= 4) {
2056 bw
.i
= GET_BE_U_4(tptr
);
2057 ND_PRINT(", %.3f Mbps", bw
.f
* 8 / 1000000);
2060 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
2061 if (subtlv_len
>= 32) {
2062 for (te_class
= 0; te_class
< 8; te_class
++) {
2063 bw
.i
= GET_BE_U_4(tptr
);
2064 ND_PRINT("%s TE-Class %u: %.3f Mbps",
2067 bw
.f
* 8 / 1000000);
2070 subtlv_sum_len
-= 4;
2075 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
: /* fall through */
2076 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
:
2077 if (subtlv_len
== 0)
2079 ND_PRINT("%sBandwidth Constraints Model ID: %s (%u)",
2081 tok2str(diffserv_te_bc_values
, "unknown", GET_U_1(tptr
)),
2087 /* decode BCs until the subTLV ends */
2088 for (te_class
= 0; subtlv_len
!= 0; te_class
++) {
2091 bw
.i
= GET_BE_U_4(tptr
);
2092 ND_PRINT("%s Bandwidth constraint CT%u: %.3f Mbps",
2095 bw
.f
* 8 / 1000000);
2098 subtlv_sum_len
-= 4;
2102 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
2103 if (subtlv_len
>= 3)
2104 ND_PRINT(", %u", GET_BE_U_3(tptr
));
2106 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
:
2107 if (subtlv_len
== 2) {
2108 ND_PRINT(", [ %s ] (0x%04x)",
2109 bittok2str(isis_subtlv_link_attribute_values
,
2115 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
2116 if (subtlv_len
>= 2) {
2117 ND_PRINT(", %s, Priority %u",
2118 bittok2str(gmpls_link_prot_values
, "none", GET_U_1(tptr
)),
2122 case ISIS_SUBTLV_SPB_METRIC
:
2123 if (subtlv_len
>= 6) {
2124 ND_PRINT(", LM: %u", GET_BE_U_3(tptr
));
2127 subtlv_sum_len
-= 3;
2129 ND_PRINT(", P: %u", GET_U_1(tptr
));
2134 ND_PRINT(", P-ID: %u", GET_BE_U_2(tptr
));
2137 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
2138 if (subtlv_len
>= 36) {
2139 gmpls_switch_cap
= GET_U_1(tptr
);
2140 ND_PRINT("%s Interface Switching Capability:%s",
2142 tok2str(gmpls_switch_cap_values
, "Unknown", gmpls_switch_cap
));
2143 ND_PRINT(", LSP Encoding: %s",
2144 tok2str(gmpls_encoding_values
, "Unknown", GET_U_1((tptr
+ 1))));
2147 subtlv_sum_len
-= 4;
2149 ND_PRINT("%s Max LSP Bandwidth:", ident
);
2150 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
2151 bw
.i
= GET_BE_U_4(tptr
);
2152 ND_PRINT("%s priority level %u: %.3f Mbps",
2155 bw
.f
* 8 / 1000000);
2158 subtlv_sum_len
-= 4;
2161 switch (gmpls_switch_cap
) {
2168 bw
.i
= GET_BE_U_4(tptr
);
2169 ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
* 8 / 1000000);
2170 ND_PRINT("%s Interface MTU: %u", ident
,
2171 GET_BE_U_2(tptr
+ 4));
2176 bw
.i
= GET_BE_U_4(tptr
);
2177 ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
* 8 / 1000000);
2178 ND_PRINT("%s Indication %s", ident
,
2179 tok2str(gmpls_switch_cap_tsc_indication_values
, "Unknown (%u)", GET_U_1((tptr
+ 4))));
2182 /* there is some optional stuff left to decode but this is as of yet
2183 not specified so just lets hexdump what is left */
2184 if (subtlv_len
!= 0) {
2185 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subtlv_len
))
2191 case ISIS_SUBTLV_EXT_IS_REACH_LAN_ADJ_SEGMENT_ID
:
2192 if (subtlv_len
>= 8) {
2193 ND_PRINT("%s Flags: [%s]", ident
,
2194 bittok2str(isis_lan_adj_sid_flag_values
,
2197 int vflag
= (GET_U_1(tptr
) & 0x20) ? 1:0;
2198 int lflag
= (GET_U_1(tptr
) & 0x10) ? 1:0;
2203 ND_PRINT("%s Weight: %u", ident
, GET_U_1(tptr
));
2208 if(subtlv_len
>=SYSTEM_ID_LEN
) {
2209 ND_TCHECK_LEN(tptr
, SYSTEM_ID_LEN
);
2210 ND_PRINT("%s Neighbor System-ID: %s", ident
,
2211 isis_print_id(ndo
, tptr
, SYSTEM_ID_LEN
));
2213 /* RFC 8667 section 2.2.2 */
2214 /* if V-flag is set to 1 and L-flag is set to 1 ==> 3 octet label */
2215 /* if V-flag is set to 0 and L-flag is set to 0 ==> 4 octet index */
2216 if (vflag
&& lflag
) {
2217 ND_PRINT("%s Label: %u",
2218 ident
, GET_BE_U_3(tptr
+SYSTEM_ID_LEN
));
2219 } else if ((!vflag
) && (!lflag
)) {
2220 ND_PRINT("%s Index: %u",
2221 ident
, GET_BE_U_4(tptr
+SYSTEM_ID_LEN
));
2223 nd_print_invalid(ndo
);
2227 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subtlv_len
))
2233 tlv_remaining
-= subtlv_len
;
2234 subtlv_sum_len
-= subtlv_len
;
2235 proc_bytes
+= subtlv_len
;
2245 * this is the common Multi Topology ID decoder
2246 * it is called from various MT-TLVs (222,229,235,237)
2250 isis_print_mtid(netdissect_options
*ndo
,
2251 const uint8_t *tptr
, const char *ident
, u_int tlv_remaining
)
2253 if (tlv_remaining
< 2)
2259 tok2str(isis_mt_values
,
2260 "Reserved for IETF Consensus",
2261 ISIS_MASK_MTID(GET_BE_U_2(tptr
))));
2263 ND_PRINT(" Topology (0x%03x), Flags: [%s]",
2264 ISIS_MASK_MTID(GET_BE_U_2(tptr
)),
2265 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(GET_BE_U_2(tptr
))));
2273 * this is the common extended IP reach decoder
2274 * it is called from TLVs (135,235,236,237)
2275 * we process the TLV and optional subTLVs and return
2276 * the amount of processed bytes
2280 isis_print_extd_ip_reach(netdissect_options
*ndo
,
2281 const uint8_t *tptr
, const char *ident
, uint16_t afi
)
2283 char ident_buffer
[20];
2284 uint8_t prefix
[sizeof(nd_ipv6
)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
2285 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
2287 metric
= GET_BE_U_4(tptr
);
2291 if (afi
== AF_INET
) {
2292 status_byte
=GET_U_1(tptr
);
2294 bit_length
= status_byte
&0x3f;
2295 if (bit_length
> 32) {
2296 ND_PRINT("%sIPv4 prefix: bad bit length %u",
2302 } else if (afi
== AF_INET6
) {
2304 status_byte
=GET_U_1(tptr
);
2305 bit_length
=GET_U_1(tptr
+ 1);
2306 if (bit_length
> 128) {
2307 ND_PRINT("%sIPv6 prefix: bad bit length %u",
2315 return (0); /* somebody is fooling us */
2317 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
2319 ND_TCHECK_LEN(tptr
, byte_length
);
2320 memset(prefix
, 0, sizeof(prefix
)); /* clear the copy buffer */
2321 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
2323 processed
+=byte_length
;
2326 ND_PRINT("%sIPv4 prefix: %15s/%u",
2328 ipaddr_string(ndo
, prefix
), /* local buffer, not packet data; don't use GET_IPADDR_STRING() */
2330 else if (afi
== AF_INET6
)
2331 ND_PRINT("%sIPv6 prefix: %s/%u",
2333 ip6addr_string(ndo
, prefix
), /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
2336 ND_PRINT(", Distribution: %s, Metric: %u",
2337 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
2340 if (afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2341 ND_PRINT(", sub-TLVs present");
2342 else if (afi
== AF_INET6
)
2344 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
2345 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
2347 if ((afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2348 || (afi
== AF_INET6
&& ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
))
2350 /* assume that one prefix can hold more
2351 than one subTLV - therefore the first byte must reflect
2352 the aggregate bytecount of the subTLVs for this prefix
2354 sublen
=GET_U_1(tptr
);
2356 processed
+=sublen
+1;
2357 ND_PRINT(" (%u)", sublen
); /* print out subTLV length */
2361 subtlvtype
=GET_U_1(tptr
);
2362 subtlvlen
=GET_U_1(tptr
+ 1);
2364 /* prepend the indent string */
2365 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
2366 if (!isis_print_ip_reach_subtlv(ndo
, tptr
, subtlvtype
, subtlvlen
, ident_buffer
))
2369 sublen
-=(subtlvlen
+2);
2378 isis_print_router_cap_subtlv(netdissect_options
*ndo
, const uint8_t *tptr
, uint8_t tlen
)
2383 ND_TCHECK_LEN(tptr
, 2);
2384 subt
= GET_U_1(tptr
);
2385 subl
= GET_U_1(tptr
+1);
2389 /* first lets see if we know the subTLVs name*/
2390 ND_PRINT("\n\t\t%s subTLV #%u, length: %u",
2391 tok2str(isis_router_capability_subtlv_values
, "unknown", subt
),
2400 ND_TCHECK_LEN(tptr
, subl
);
2403 case ISIS_SUBTLV_ROUTER_CAP_SR
:
2405 uint8_t flags
, sid_tlen
, sid_type
, sid_len
;
2407 const uint8_t *sid_ptr
;
2409 flags
= GET_U_1(tptr
);
2410 range
= GET_BE_U_3(tptr
+1);
2411 ND_PRINT(", Flags [%s], Range %u",
2412 bittok2str(isis_router_capability_sr_flags
, "None", flags
),
2415 sid_tlen
= subl
- 4;
2417 while (sid_tlen
>= 5) {
2418 sid_type
= GET_U_1(sid_ptr
);
2419 sid_len
= GET_U_1(sid_ptr
+1);
2426 if (sid_len
> sid_tlen
) {
2433 ND_PRINT(", SID value %u", GET_BE_U_3(sid_ptr
));
2434 } else if (sid_len
== 4) {
2435 ND_PRINT(", SID value %u", GET_BE_U_4(sid_ptr
));
2437 ND_PRINT(", Unknown SID length%u", sid_len
);
2441 print_unknown_data(ndo
, sid_ptr
, "\n\t\t ", sid_len
);
2445 sid_tlen
-= sid_len
;
2450 print_unknown_data(ndo
, tptr
, "\n\t\t", subl
);
2462 * Clear checksum and lifetime prior to signature verification.
2465 isis_clear_checksum_lifetime(void *header
)
2467 struct isis_lsp_header
*header_lsp
= (struct isis_lsp_header
*) header
;
2469 header_lsp
->checksum
[0] = 0;
2470 header_lsp
->checksum
[1] = 0;
2471 header_lsp
->remaining_lifetime
[0] = 0;
2472 header_lsp
->remaining_lifetime
[1] = 0;
2477 * Decode IS-IS packets. Return 0 on error.
2480 #define INVALID_OR_DECREMENT(length,decr) \
2481 if ((length) < (decr)) { \
2482 ND_PRINT(" [packet length %u < %zu]", (length), (decr)); \
2483 nd_print_invalid(ndo); \
2489 isis_print(netdissect_options
*ndo
,
2490 const uint8_t *p
, u_int length
)
2492 const struct isis_common_header
*isis_header
;
2494 const struct isis_iih_lan_header
*header_iih_lan
;
2495 const struct isis_iih_ptp_header
*header_iih_ptp
;
2496 const struct isis_lsp_header
*header_lsp
;
2497 const struct isis_csnp_header
*header_csnp
;
2498 const struct isis_psnp_header
*header_psnp
;
2500 const struct isis_tlv_lsp
*tlv_lsp
;
2501 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
2502 const struct isis_tlv_is_reach
*tlv_is_reach
;
2503 const struct isis_tlv_es_reach
*tlv_es_reach
;
2505 uint8_t version
, pdu_version
, fixed_len
;
2506 uint8_t pdu_type
, pdu_max_area
, max_area
, pdu_id_length
, id_length
, tlv_type
, tlv_len
, tlen
, alen
, prefix_len
;
2507 u_int ext_is_len
, ext_ip_len
;
2509 uint8_t isis_subtlv_idrp
;
2510 const uint8_t *optr
, *pptr
, *tptr
;
2512 u_short pdu_len
, key_id
;
2513 u_int i
,vendor_id
, num_vals
;
2515 uint8_t num_system_ids
;
2518 ndo
->ndo_protocol
= "isis";
2520 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
2521 need it for parsing the checksum TLV and authentication
2523 isis_header
= (const struct isis_common_header
*)p
;
2524 ND_TCHECK_SIZE(isis_header
);
2525 if (length
< ISIS_COMMON_HEADER_SIZE
)
2527 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
2528 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
2529 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
2530 header_lsp
= (const struct isis_lsp_header
*)pptr
;
2531 header_csnp
= (const struct isis_csnp_header
*)pptr
;
2532 header_psnp
= (const struct isis_psnp_header
*)pptr
;
2534 if (!ndo
->ndo_eflag
)
2538 * Sanity checking of the header.
2541 version
= GET_U_1(isis_header
->version
);
2542 if (version
!= ISIS_VERSION
) {
2543 ND_PRINT("version %u packet not supported", version
);
2547 pdu_id_length
= GET_U_1(isis_header
->id_length
);
2548 if ((pdu_id_length
!= SYSTEM_ID_LEN
) && (pdu_id_length
!= 0)) {
2549 ND_PRINT("system ID length of %u is not supported",
2554 pdu_version
= GET_U_1(isis_header
->pdu_version
);
2555 if (pdu_version
!= ISIS_VERSION
) {
2556 ND_PRINT("version %u packet not supported", pdu_version
);
2560 fixed_len
= GET_U_1(isis_header
->fixed_len
);
2561 if (length
< fixed_len
) {
2562 ND_PRINT("fixed header length %u > packet length %u", fixed_len
, length
);
2566 if (fixed_len
< ISIS_COMMON_HEADER_SIZE
) {
2567 ND_PRINT("fixed header length %u < minimum header size %u", fixed_len
, (u_int
)ISIS_COMMON_HEADER_SIZE
);
2571 pdu_max_area
= GET_U_1(isis_header
->max_area
);
2572 switch(pdu_max_area
) {
2574 max_area
= 3; /* silly shit */
2577 ND_PRINT("bad packet -- 255 areas");
2580 max_area
= pdu_max_area
;
2584 switch(pdu_id_length
) {
2586 id_length
= 6; /* silly shit again */
2588 case 1: /* 1-8 are valid sys-ID lengths */
2596 id_length
= pdu_id_length
;
2599 id_length
= 0; /* entirely useless */
2602 id_length
= pdu_id_length
;
2606 /* toss any non 6-byte sys-ID len PDUs */
2607 if (id_length
!= 6 ) {
2608 ND_PRINT("bad packet -- illegal sys-ID length (%u)", id_length
);
2612 pdu_type
= GET_U_1(isis_header
->pdu_type
);
2614 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
2615 if (ndo
->ndo_vflag
== 0) {
2617 ndo
->ndo_eflag
? "" : ", ",
2618 tok2str(isis_pdu_values
, "unknown PDU-Type %u", pdu_type
));
2620 /* ok they seem to want to know everything - lets fully decode it */
2621 ND_PRINT("%slength %u", ndo
->ndo_eflag
? "" : ", ", length
);
2623 ND_PRINT("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
2624 tok2str(isis_pdu_values
,
2635 if (ndo
->ndo_vflag
> 1) {
2636 if (!print_unknown_data(ndo
, optr
, "\n\t", 8)) /* provide the _o_riginal pointer */
2637 return (0); /* for optionally debugging the common header */
2643 case ISIS_PDU_L1_LAN_IIH
:
2644 case ISIS_PDU_L2_LAN_IIH
:
2645 if (fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
2646 ND_PRINT(", bogus fixed header length %u should be %zu",
2647 fixed_len
, ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2650 ND_TCHECK_SIZE(header_iih_lan
);
2651 if (length
< ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)
2653 if (ndo
->ndo_vflag
== 0) {
2654 ND_PRINT(", src-id %s",
2655 isis_print_id(ndo
, header_iih_lan
->source_id
, SYSTEM_ID_LEN
));
2656 ND_PRINT(", lan-id %s, prio %u",
2657 isis_print_id(ndo
, header_iih_lan
->lan_id
,NODE_ID_LEN
),
2658 GET_U_1(header_iih_lan
->priority
));
2659 ND_PRINT(", length %u", length
);
2662 pdu_len
=GET_BE_U_2(header_iih_lan
->pdu_len
);
2663 if (packet_len
>pdu_len
) {
2664 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2668 ND_PRINT("\n\t source-id: %s, holding time: %us, Flags: [%s]",
2669 isis_print_id(ndo
, header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
2670 GET_BE_U_2(header_iih_lan
->holding_time
),
2671 tok2str(isis_iih_circuit_type_values
,
2672 "unknown circuit type 0x%02x",
2673 GET_U_1(header_iih_lan
->circuit_type
)));
2675 ND_PRINT("\n\t lan-id: %s, Priority: %u, PDU length: %u",
2676 isis_print_id(ndo
, header_iih_lan
->lan_id
, NODE_ID_LEN
),
2677 GET_U_1(header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
2680 if (ndo
->ndo_vflag
> 1) {
2681 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE
))
2685 INVALID_OR_DECREMENT(packet_len
,ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2686 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2689 case ISIS_PDU_PTP_IIH
:
2690 if (fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
2691 ND_PRINT(", bogus fixed header length %u should be %zu",
2692 fixed_len
, ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2695 ND_TCHECK_SIZE(header_iih_ptp
);
2696 if (length
< ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)
2698 if (ndo
->ndo_vflag
== 0) {
2699 ND_PRINT(", src-id %s", isis_print_id(ndo
, header_iih_ptp
->source_id
, SYSTEM_ID_LEN
));
2700 ND_PRINT(", length %u", length
);
2703 pdu_len
=GET_BE_U_2(header_iih_ptp
->pdu_len
);
2704 if (packet_len
>pdu_len
) {
2705 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2709 ND_PRINT("\n\t source-id: %s, holding time: %us, Flags: [%s]",
2710 isis_print_id(ndo
, header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
2711 GET_BE_U_2(header_iih_ptp
->holding_time
),
2712 tok2str(isis_iih_circuit_type_values
,
2713 "unknown circuit type 0x%02x",
2714 GET_U_1(header_iih_ptp
->circuit_type
)));
2716 ND_PRINT("\n\t circuit-id: 0x%02x, PDU length: %u",
2717 GET_U_1(header_iih_ptp
->circuit_id
),
2720 if (ndo
->ndo_vflag
> 1) {
2721 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE
))
2724 INVALID_OR_DECREMENT(packet_len
,ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2725 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2728 case ISIS_PDU_L1_LSP
:
2729 case ISIS_PDU_L2_LSP
:
2730 if (fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
2731 ND_PRINT(", bogus fixed header length %u should be %zu",
2732 fixed_len
, ISIS_LSP_HEADER_SIZE
);
2735 ND_TCHECK_SIZE(header_lsp
);
2736 if (length
< ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)
2738 if (ndo
->ndo_vflag
== 0) {
2739 ND_PRINT(", lsp-id %s, seq 0x%08x, lifetime %5us",
2740 isis_print_id(ndo
, header_lsp
->lsp_id
, LSP_ID_LEN
),
2741 GET_BE_U_4(header_lsp
->sequence_number
),
2742 GET_BE_U_2(header_lsp
->remaining_lifetime
));
2743 ND_PRINT(", length %u", length
);
2746 pdu_len
=GET_BE_U_2(header_lsp
->pdu_len
);
2747 if (packet_len
>pdu_len
) {
2748 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2752 ND_PRINT("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
2753 isis_print_id(ndo
, header_lsp
->lsp_id
, LSP_ID_LEN
),
2754 GET_BE_U_4(header_lsp
->sequence_number
),
2755 GET_BE_U_2(header_lsp
->remaining_lifetime
),
2756 GET_BE_U_2(header_lsp
->checksum
));
2758 osi_print_cksum(ndo
, (const uint8_t *)header_lsp
->lsp_id
,
2759 GET_BE_U_2(header_lsp
->checksum
),
2762 ND_PRINT(", PDU length: %u, Flags: [ %s",
2764 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
2766 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
2767 ND_PRINT("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
2768 ND_PRINT("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
2769 ND_PRINT("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
2770 ND_PRINT("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
2771 ND_PRINT("ATT bit set, ");
2773 ND_PRINT("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
2774 ND_PRINT("%s ]", tok2str(isis_lsp_istype_values
, "Unknown(0x%x)",
2775 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
2777 if (ndo
->ndo_vflag
> 1) {
2778 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_LSP_HEADER_SIZE
))
2782 INVALID_OR_DECREMENT(packet_len
,ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2783 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2786 case ISIS_PDU_L1_CSNP
:
2787 case ISIS_PDU_L2_CSNP
:
2788 if (fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
2789 ND_PRINT(", bogus fixed header length %u should be %zu",
2790 fixed_len
, ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2793 ND_TCHECK_SIZE(header_csnp
);
2794 if (length
< ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)
2796 if (ndo
->ndo_vflag
== 0) {
2797 ND_PRINT(", src-id %s", isis_print_id(ndo
, header_csnp
->source_id
, NODE_ID_LEN
));
2798 ND_PRINT(", length %u", length
);
2801 pdu_len
=GET_BE_U_2(header_csnp
->pdu_len
);
2802 if (packet_len
>pdu_len
) {
2803 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2807 ND_PRINT("\n\t source-id: %s, PDU length: %u",
2808 isis_print_id(ndo
, header_csnp
->source_id
, NODE_ID_LEN
),
2810 ND_PRINT("\n\t start lsp-id: %s",
2811 isis_print_id(ndo
, header_csnp
->start_lsp_id
, LSP_ID_LEN
));
2812 ND_PRINT("\n\t end lsp-id: %s",
2813 isis_print_id(ndo
, header_csnp
->end_lsp_id
, LSP_ID_LEN
));
2815 if (ndo
->ndo_vflag
> 1) {
2816 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_CSNP_HEADER_SIZE
))
2820 INVALID_OR_DECREMENT(packet_len
,ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2821 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2824 case ISIS_PDU_L1_PSNP
:
2825 case ISIS_PDU_L2_PSNP
:
2826 if (fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
2827 ND_PRINT("- bogus fixed header length %u should be %zu",
2828 fixed_len
, ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2831 ND_TCHECK_SIZE(header_psnp
);
2832 if (length
< ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)
2834 if (ndo
->ndo_vflag
== 0) {
2835 ND_PRINT(", src-id %s", isis_print_id(ndo
, header_psnp
->source_id
, NODE_ID_LEN
));
2836 ND_PRINT(", length %u", length
);
2839 pdu_len
=GET_BE_U_2(header_psnp
->pdu_len
);
2840 if (packet_len
>pdu_len
) {
2841 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2845 ND_PRINT("\n\t source-id: %s, PDU length: %u",
2846 isis_print_id(ndo
, header_psnp
->source_id
, NODE_ID_LEN
),
2849 if (ndo
->ndo_vflag
> 1) {
2850 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_PSNP_HEADER_SIZE
))
2854 INVALID_OR_DECREMENT(packet_len
,ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2855 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2859 if (ndo
->ndo_vflag
== 0) {
2860 ND_PRINT(", length %u", length
);
2863 (void)print_unknown_data(ndo
, pptr
, "\n\t ", length
);
2868 * Now print the TLV's.
2871 while (packet_len
> 0) {
2875 tlv_type
= GET_U_1(pptr
);
2876 tlv_len
= GET_U_1(pptr
+ 1);
2879 tlen
= tlv_len
; /* copy temporary len & pointer to packet data */
2882 /* first lets see if we know the TLVs name*/
2883 ND_PRINT("\n\t %s TLV #%u, length: %u",
2884 tok2str(isis_tlv_values
,
2890 if (packet_len
< tlv_len
)
2893 /* now check if we have a decoder otherwise do a hexdump at the end*/
2895 case ISIS_TLV_AREA_ADDR
:
2897 alen
= GET_U_1(tptr
);
2902 ND_TCHECK_LEN(tptr
, alen
);
2903 ND_PRINT("\n\t Area address (length: %u): %s",
2905 GET_ISONSAP_STRING(tptr
, alen
));
2910 case ISIS_TLV_ISNEIGH
:
2912 if (tlen
< MAC_ADDR_LEN
)
2914 ND_TCHECK_LEN(tptr
, MAC_ADDR_LEN
);
2915 ND_PRINT("\n\t SNPA: %s", isis_print_id(ndo
, tptr
, MAC_ADDR_LEN
));
2916 tlen
-= MAC_ADDR_LEN
;
2917 tptr
+= MAC_ADDR_LEN
;
2921 case ISIS_TLV_INSTANCE_ID
:
2924 num_vals
= (tlen
-2)/2;
2925 ND_PRINT("\n\t Instance ID: %u, ITIDs(%u)%s ",
2926 GET_BE_U_2(tptr
), num_vals
,
2927 num_vals
? ":" : "");
2930 for (i
=0; i
< num_vals
; i
++) {
2931 ND_PRINT("%u", GET_BE_U_2(tptr
));
2932 if (i
< (num_vals
- 1)) {
2940 case ISIS_TLV_PADDING
:
2943 case ISIS_TLV_MT_IS_REACH
:
2944 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ", tlen
);
2945 if (mt_len
== 0) /* did something go wrong ? */
2950 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
, tlen
);
2951 if (ext_is_len
== 0) /* did something go wrong ? */
2953 if (tlen
< ext_is_len
) {
2954 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_is_len
);
2955 nd_print_invalid(ndo
);
2958 tlen
-=(uint8_t)ext_is_len
;
2959 tptr
+=(uint8_t)ext_is_len
;
2963 case ISIS_TLV_IS_ALIAS_ID
:
2965 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
, tlen
);
2966 if (ext_is_len
== 0) /* did something go wrong ? */
2968 if (tlen
< ext_is_len
) {
2969 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_is_len
);
2970 nd_print_invalid(ndo
);
2973 tlen
-=(uint8_t)ext_is_len
;
2974 tptr
+=(uint8_t)ext_is_len
;
2978 case ISIS_TLV_EXT_IS_REACH
:
2980 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
, tlen
);
2981 if (ext_is_len
== 0) /* did something go wrong ? */
2983 if (tlen
< ext_is_len
) {
2984 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_is_len
);
2985 nd_print_invalid(ndo
);
2988 tlen
-=(uint8_t)ext_is_len
;
2989 tptr
+=(uint8_t)ext_is_len
;
2992 case ISIS_TLV_IS_REACH
:
2996 tok2str(isis_is_reach_virtual_values
,
2997 "bogus virtual flag 0x%02x",
3001 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
3003 if (tlen
< sizeof(struct isis_tlv_is_reach
))
3005 ND_TCHECK_SIZE(tlv_is_reach
);
3006 ND_PRINT("\n\t IS Neighbor: %s",
3007 isis_print_id(ndo
, tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
3008 isis_print_metric_block(ndo
, &tlv_is_reach
->isis_metric_block
);
3009 tlen
-= sizeof(struct isis_tlv_is_reach
);
3014 case ISIS_TLV_ESNEIGH
:
3015 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
3017 if (tlen
< sizeof(struct isis_tlv_es_reach
))
3019 ND_TCHECK_SIZE(tlv_es_reach
);
3020 ND_PRINT("\n\t ES Neighbor: %s",
3021 isis_print_id(ndo
, tlv_es_reach
->neighbor_sysid
, SYSTEM_ID_LEN
));
3022 isis_print_metric_block(ndo
, &tlv_es_reach
->isis_metric_block
);
3023 tlen
-= sizeof(struct isis_tlv_es_reach
);
3028 /* those two TLVs share the same format */
3029 case ISIS_TLV_INT_IP_REACH
:
3030 case ISIS_TLV_EXT_IP_REACH
:
3031 if (!isis_print_tlv_ip_reach(ndo
, pptr
, "\n\t ", tlv_len
))
3035 case ISIS_TLV_EXTD_IP_REACH
:
3037 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET
);
3038 if (ext_ip_len
== 0) /* did something go wrong ? */
3040 if (tlen
< ext_ip_len
) {
3041 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_ip_len
);
3042 nd_print_invalid(ndo
);
3045 tlen
-=(uint8_t)ext_ip_len
;
3046 tptr
+=(uint8_t)ext_ip_len
;
3050 case ISIS_TLV_MT_IP_REACH
:
3051 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ", tlen
);
3052 if (mt_len
== 0) { /* did something go wrong ? */
3059 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET
);
3060 if (ext_ip_len
== 0) /* did something go wrong ? */
3062 if (tlen
< ext_ip_len
) {
3063 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_ip_len
);
3064 nd_print_invalid(ndo
);
3067 tlen
-=(uint8_t)ext_ip_len
;
3068 tptr
+=(uint8_t)ext_ip_len
;
3072 case ISIS_TLV_IP6_REACH
:
3074 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET6
);
3075 if (ext_ip_len
== 0) /* did something go wrong ? */
3077 if (tlen
< ext_ip_len
) {
3078 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_ip_len
);
3079 nd_print_invalid(ndo
);
3082 tlen
-=(uint8_t)ext_ip_len
;
3083 tptr
+=(uint8_t)ext_ip_len
;
3087 case ISIS_TLV_MT_IP6_REACH
:
3088 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ", tlen
);
3089 if (mt_len
== 0) { /* did something go wrong ? */
3096 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET6
);
3097 if (ext_ip_len
== 0) /* did something go wrong ? */
3099 if (tlen
< ext_ip_len
) {
3100 ND_PRINT(" [remaining tlv length %u < %u]", tlen
, ext_ip_len
);
3101 nd_print_invalid(ndo
);
3104 tlen
-=(uint8_t)ext_ip_len
;
3105 tptr
+=(uint8_t)ext_ip_len
;
3109 case ISIS_TLV_IP6ADDR
:
3111 if (tlen
< sizeof(nd_ipv6
))
3113 ND_TCHECK_LEN(tptr
, sizeof(nd_ipv6
));
3115 ND_PRINT("\n\t IPv6 interface address: %s",
3116 GET_IP6ADDR_STRING(tptr
));
3118 tptr
+= sizeof(nd_ipv6
);
3119 tlen
-= sizeof(nd_ipv6
);
3125 auth_type
= GET_U_1(tptr
);
3129 ND_PRINT("\n\t %s: ",
3130 tok2str(isis_subtlv_auth_values
,
3131 "unknown Authentication type 0x%02x",
3134 switch (auth_type
) {
3135 case ISIS_SUBTLV_AUTH_SIMPLE
:
3136 if (nd_printzp(ndo
, tptr
, tlen
, ndo
->ndo_snapend
))
3139 case ISIS_SUBTLV_AUTH_MD5
:
3140 for(i
=0;i
<tlen
;i
++) {
3141 ND_PRINT("%02x", GET_U_1(tptr
+ i
));
3143 if (tlen
!= ISIS_SUBTLV_AUTH_MD5_LEN
)
3144 ND_PRINT(", (invalid subTLV) ");
3146 sigcheck
= signature_verify(ndo
, optr
, length
, tptr
,
3147 isis_clear_checksum_lifetime
,
3149 ND_PRINT(" (%s)", tok2str(signature_check_values
, "Unknown", sigcheck
));
3152 case ISIS_SUBTLV_AUTH_GENERIC
:
3155 key_id
= GET_BE_U_2(tptr
);
3156 ND_PRINT("%u, password: ", key_id
);
3159 for(i
=0;i
<tlen
;i
++) {
3160 ND_PRINT("%02x", GET_U_1(tptr
+ i
));
3163 case ISIS_SUBTLV_AUTH_PRIVATE
:
3165 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", tlen
))
3171 case ISIS_TLV_PTP_ADJ
:
3172 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
3174 ND_PRINT("\n\t Adjacency State: %s (%u)",
3175 tok2str(isis_ptp_adjancey_values
, "unknown", GET_U_1(tptr
)),
3179 if(tlen
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
3180 ND_PRINT("\n\t Extended Local circuit-ID: 0x%08x",
3181 GET_BE_U_4(tlv_ptp_adj
->extd_local_circuit_id
));
3182 tlen
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
3184 if(tlen
>=SYSTEM_ID_LEN
) {
3185 ND_TCHECK_LEN(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
);
3186 ND_PRINT("\n\t Neighbor System-ID: %s",
3187 isis_print_id(ndo
, tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
));
3188 tlen
-=SYSTEM_ID_LEN
;
3190 if(tlen
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
3191 ND_PRINT("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
3192 GET_BE_U_4(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
3196 case ISIS_TLV_PROTOCOLS
:
3197 ND_PRINT("\n\t NLPID(s): ");
3199 ND_PRINT("%s (0x%02x)",
3200 tok2str(nlpid_values
,
3204 if (tlen
>1) /* further NPLIDs ? - put comma */
3211 case ISIS_TLV_MT_PORT_CAP
:
3217 ND_PRINT("\n\t RES: %u, MTID(s): %u",
3218 (GET_BE_U_2(tptr
) >> 12),
3219 (GET_BE_U_2(tptr
) & 0x0fff));
3225 isis_print_mt_port_cap_subtlv(ndo
, tptr
, tlen
);
3230 case ISIS_TLV_MT_CAPABILITY
:
3234 ND_PRINT("\n\t O: %u, RES: %u, MTID(s): %u",
3235 (GET_BE_U_2(tptr
) >> 15) & 0x01,
3236 (GET_BE_U_2(tptr
) >> 12) & 0x07,
3237 GET_BE_U_2(tptr
) & 0x0fff);
3243 isis_print_mt_capability_subtlv(ndo
, tptr
, tlen
);
3247 case ISIS_TLV_TE_ROUTER_ID
:
3248 if (tlen
< sizeof(nd_ipv4
))
3250 ND_TCHECK_LEN(pptr
, sizeof(nd_ipv4
));
3251 ND_PRINT("\n\t Traffic Engineering Router ID: %s", GET_IPADDR_STRING(pptr
));
3254 case ISIS_TLV_IPADDR
:
3256 if (tlen
< sizeof(nd_ipv4
))
3258 ND_TCHECK_LEN(tptr
, sizeof(nd_ipv4
));
3259 ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr
));
3260 tptr
+= sizeof(nd_ipv4
);
3261 tlen
-= sizeof(nd_ipv4
);
3265 case ISIS_TLV_HOSTNAME
:
3266 ND_PRINT("\n\t Hostname: ");
3267 if (nd_printzp(ndo
, tptr
, tlen
, ndo
->ndo_snapend
))
3271 case ISIS_TLV_SHARED_RISK_GROUP
:
3272 if (tlen
< NODE_ID_LEN
)
3274 ND_TCHECK_LEN(tptr
, NODE_ID_LEN
);
3275 ND_PRINT("\n\t IS Neighbor: %s", isis_print_id(ndo
, tptr
, NODE_ID_LEN
));
3281 ND_PRINT(", Flags: [%s]",
3282 ISIS_MASK_TLV_SHARED_RISK_GROUP(GET_U_1(tptr
)) ? "numbered" : "unnumbered");
3286 if (tlen
< sizeof(nd_ipv4
))
3288 ND_TCHECK_LEN(tptr
, sizeof(nd_ipv4
));
3289 ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr
));
3290 tptr
+=sizeof(nd_ipv4
);
3291 tlen
-=sizeof(nd_ipv4
);
3293 if (tlen
< sizeof(nd_ipv4
))
3295 ND_TCHECK_LEN(tptr
, sizeof(nd_ipv4
));
3296 ND_PRINT("\n\t IPv4 neighbor address: %s", GET_IPADDR_STRING(tptr
));
3297 tptr
+=sizeof(nd_ipv4
);
3298 tlen
-=sizeof(nd_ipv4
);
3303 ND_PRINT("\n\t Link-ID: 0x%08x", GET_BE_U_4(tptr
));
3310 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
3312 if (tlen
< sizeof(struct isis_tlv_lsp
))
3314 ND_TCHECK_1(tlv_lsp
->lsp_id
+ LSP_ID_LEN
- 1);
3315 ND_PRINT("\n\t lsp-id: %s",
3316 isis_print_id(ndo
, tlv_lsp
->lsp_id
, LSP_ID_LEN
));
3317 ND_PRINT(", seq: 0x%08x",
3318 GET_BE_U_4(tlv_lsp
->sequence_number
));
3319 ND_PRINT(", lifetime: %5ds",
3320 GET_BE_U_2(tlv_lsp
->remaining_lifetime
));
3321 ND_PRINT(", chksum: 0x%04x", GET_BE_U_2(tlv_lsp
->checksum
));
3322 tlen
-=sizeof(struct isis_tlv_lsp
);
3327 case ISIS_TLV_CHECKSUM
:
3328 if (tlen
< ISIS_TLV_CHECKSUM_MINLEN
)
3330 ND_TCHECK_LEN(tptr
, ISIS_TLV_CHECKSUM_MINLEN
);
3331 ND_PRINT("\n\t checksum: 0x%04x ", GET_BE_U_2(tptr
));
3332 /* do not attempt to verify the checksum if it is zero
3333 * most likely a HMAC-MD5 TLV is also present and
3334 * to avoid conflicts the checksum TLV is zeroed.
3335 * see rfc3358 for details
3337 osi_print_cksum(ndo
, optr
, GET_BE_U_2(tptr
), (int)(tptr
-optr
),
3344 num_system_ids
= GET_U_1(tptr
);
3347 if (num_system_ids
== 0) {
3349 ND_PRINT(" No system IDs supplied");
3351 if (tlen
< SYSTEM_ID_LEN
)
3353 ND_TCHECK_LEN(tptr
, SYSTEM_ID_LEN
);
3354 ND_PRINT("\n\t Purge Originator System-ID: %s",
3355 isis_print_id(ndo
, tptr
, SYSTEM_ID_LEN
));
3356 tptr
+= SYSTEM_ID_LEN
;
3357 tlen
-= SYSTEM_ID_LEN
;
3359 if (num_system_ids
> 1) {
3360 if (tlen
< SYSTEM_ID_LEN
)
3362 ND_TCHECK_LEN(tptr
, SYSTEM_ID_LEN
);
3363 ND_TCHECK_LEN(tptr
, 2 * SYSTEM_ID_LEN
+ 1);
3364 ND_PRINT("\n\t Received from System-ID: %s",
3365 isis_print_id(ndo
, tptr
, SYSTEM_ID_LEN
));
3370 case ISIS_TLV_MT_SUPPORTED
:
3372 /* length can only be a multiple of 2, otherwise there is
3373 something broken -> so decode down until length is 1 */
3375 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ", tlen
);
3376 if (mt_len
== 0) /* did something go wrong ? */
3381 ND_PRINT("\n\t invalid MT-ID");
3387 case ISIS_TLV_RESTART_SIGNALING
:
3388 /* first attempt to decode the flags */
3389 if (tlen
< ISIS_TLV_RESTART_SIGNALING_FLAGLEN
)
3391 ND_TCHECK_LEN(tptr
, ISIS_TLV_RESTART_SIGNALING_FLAGLEN
);
3392 ND_PRINT("\n\t Flags [%s]",
3393 bittok2str(isis_restart_flag_values
, "none", GET_U_1(tptr
)));
3394 tptr
+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
3395 tlen
-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
3397 /* is there anything other than the flags field? */
3401 if (tlen
< ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
)
3403 ND_TCHECK_LEN(tptr
, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
);
3405 ND_PRINT(", Remaining holding time %us", GET_BE_U_2(tptr
));
3406 tptr
+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
3407 tlen
-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
3409 /* is there an additional sysid field present ?*/
3410 if (tlen
== SYSTEM_ID_LEN
) {
3411 ND_TCHECK_LEN(tptr
, SYSTEM_ID_LEN
);
3412 ND_PRINT(", for %s", isis_print_id(ndo
, tptr
,SYSTEM_ID_LEN
));
3416 case ISIS_TLV_IDRP_INFO
:
3419 isis_subtlv_idrp
= GET_U_1(tptr
);
3420 ND_PRINT("\n\t Inter-Domain Information Type: %s",
3421 tok2str(isis_subtlv_idrp_values
,
3426 switch (isis_subtlv_idrp
) {
3427 case ISIS_SUBTLV_IDRP_ASN
:
3430 ND_PRINT("AS Number: %u", GET_BE_U_2(tptr
));
3432 case ISIS_SUBTLV_IDRP_LOCAL
:
3433 case ISIS_SUBTLV_IDRP_RES
:
3435 if (!print_unknown_data(ndo
, tptr
, "\n\t ", tlen
))
3441 case ISIS_TLV_LSP_BUFFERSIZE
:
3444 ND_PRINT("\n\t LSP Buffersize: %u", GET_BE_U_2(tptr
));
3447 case ISIS_TLV_PART_DIS
:
3449 if (tlen
< SYSTEM_ID_LEN
)
3451 ND_TCHECK_LEN(tptr
, SYSTEM_ID_LEN
);
3452 ND_PRINT("\n\t %s", isis_print_id(ndo
, tptr
, SYSTEM_ID_LEN
));
3453 tptr
+=SYSTEM_ID_LEN
;
3454 tlen
-=SYSTEM_ID_LEN
;
3458 case ISIS_TLV_PREFIX_NEIGH
:
3459 if (tlen
< sizeof(struct isis_metric_block
))
3461 ND_TCHECK_LEN(tptr
, sizeof(struct isis_metric_block
));
3462 ND_PRINT("\n\t Metric Block");
3463 isis_print_metric_block(ndo
, (const struct isis_metric_block
*)tptr
);
3464 tptr
+=sizeof(struct isis_metric_block
);
3465 tlen
-=sizeof(struct isis_metric_block
);
3468 prefix_len
=GET_U_1(tptr
); /* read out prefix length in semioctets*/
3471 if (prefix_len
< 2) {
3472 ND_PRINT("\n\t\tAddress: prefix length %u < 2", prefix_len
);
3475 if (tlen
< prefix_len
/2)
3477 ND_TCHECK_LEN(tptr
, prefix_len
/ 2);
3478 ND_PRINT("\n\t\tAddress: %s/%u",
3479 GET_ISONSAP_STRING(tptr
, prefix_len
/ 2), prefix_len
* 4);
3485 case ISIS_TLV_IIH_SEQNR
:
3488 ND_PRINT("\n\t Sequence number: %u", GET_BE_U_4(tptr
));
3491 case ISIS_TLV_ROUTER_CAPABILITY
:
3493 ND_PRINT(" [object length %u < 5]", tlen
);
3494 nd_print_invalid(ndo
);
3497 ND_TCHECK_5(tptr
); /* router-id + flags */
3498 ND_PRINT("\n\t Router-ID %s", GET_IPADDR_STRING(tptr
));
3499 ND_PRINT(", Flags [%s]",
3500 bittok2str(isis_tlv_router_capability_flags
, "none", GET_U_1(tptr
+4)));
3502 /* Optional set of sub-TLV */
3504 isis_print_router_cap_subtlv(ndo
, tptr
+5, tlen
-5);
3508 case ISIS_TLV_VENDOR_PRIVATE
:
3511 vendor_id
= GET_BE_U_3(tptr
);
3512 ND_PRINT("\n\t Vendor: %s (%u)",
3513 tok2str(oui_values
, "Unknown", vendor_id
),
3517 if (tlen
!= 0) /* hexdump the rest */
3518 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", tlen
))
3522 * FIXME those are the defined TLVs that lack a decoder
3523 * you are welcome to contribute code ;-)
3526 case ISIS_TLV_DECNET_PHASE4
:
3527 case ISIS_TLV_LUCENT_PRIVATE
:
3528 case ISIS_TLV_IPAUTH
:
3529 case ISIS_TLV_NORTEL_PRIVATE1
:
3530 case ISIS_TLV_NORTEL_PRIVATE2
:
3533 if (ndo
->ndo_vflag
<= 1) {
3534 if (!print_unknown_data(ndo
, pptr
, "\n\t\t", tlv_len
))
3540 /* do we want to see an additionally hexdump ? */
3541 if (ndo
->ndo_vflag
> 1) {
3542 if (!print_unknown_data(ndo
, pptr
, "\n\t ", tlv_len
))
3547 packet_len
-= tlv_len
;
3550 if (packet_len
!= 0) {
3551 ND_PRINT("\n\t %u straggler bytes", packet_len
);
3556 nd_print_trunc(ndo
);
3561 osi_print_cksum(netdissect_options
*ndo
, const uint8_t *pptr
,
3562 uint16_t checksum
, int checksum_offset
, u_int length
)
3564 uint16_t calculated_checksum
;
3566 /* do not attempt to verify the checksum if it is zero,
3567 * if the offset is nonsense,
3568 * or the base pointer is not sane
3571 || checksum_offset
< 0
3572 || !ND_TTEST_2(pptr
+ checksum_offset
)
3573 || (u_int
)checksum_offset
> length
3574 || !ND_TTEST_LEN(pptr
, length
)) {
3575 ND_PRINT(" (unverified)");
3578 ND_PRINT("\nosi_print_cksum: %p %d %u\n", pptr
, checksum_offset
, length
);
3580 calculated_checksum
= create_osi_cksum(pptr
, checksum_offset
, length
);
3581 if (checksum
== calculated_checksum
) {
3582 ND_PRINT(" (correct)");
3584 ND_PRINT(" (incorrect should be 0x%04x)", calculated_checksum
);