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.
27 #define NETDISSECT_REWORKED
32 #include <tcpdump-stdinc.h>
36 #include "interface.h"
37 #include "addrtoname.h"
43 #include "signature.h"
46 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
49 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
50 #define NODE_ID_LEN SYSTEM_ID_LEN+1
51 #define LSP_ID_LEN SYSTEM_ID_LEN+2
53 #define ISIS_VERSION 1
54 #define ESIS_VERSION 1
55 #define CLNP_VERSION 1
57 #define ISIS_PDU_TYPE_MASK 0x1F
58 #define ESIS_PDU_TYPE_MASK 0x1F
59 #define CLNP_PDU_TYPE_MASK 0x1F
60 #define CLNP_FLAG_MASK 0xE0
61 #define ISIS_LAN_PRIORITY_MASK 0x7F
63 #define ISIS_PDU_L1_LAN_IIH 15
64 #define ISIS_PDU_L2_LAN_IIH 16
65 #define ISIS_PDU_PTP_IIH 17
66 #define ISIS_PDU_L1_LSP 18
67 #define ISIS_PDU_L2_LSP 20
68 #define ISIS_PDU_L1_CSNP 24
69 #define ISIS_PDU_L2_CSNP 25
70 #define ISIS_PDU_L1_PSNP 26
71 #define ISIS_PDU_L2_PSNP 27
73 static const struct tok isis_pdu_values
[] = {
74 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
75 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
76 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
77 { ISIS_PDU_L1_LSP
, "L1 LSP"},
78 { ISIS_PDU_L2_LSP
, "L2 LSP"},
79 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
80 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
81 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
82 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
87 * A TLV is a tuple of a type, length and a value and is normally used for
88 * encoding information in all sorts of places. This is an enumeration of
89 * the well known types.
91 * list taken from rfc3359 plus some memory from veterans ;-)
94 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
95 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
96 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
97 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
98 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
99 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
100 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
101 #define ISIS_TLV_PADDING 8 /* iso10589 */
102 #define ISIS_TLV_LSP 9 /* iso10589 */
103 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
104 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
105 #define ISIS_TLV_CHECKSUM_MINLEN 2
106 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
107 #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
108 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
109 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
110 #define ISIS_TLV_DECNET_PHASE4 42
111 #define ISIS_TLV_LUCENT_PRIVATE 66
112 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
113 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
114 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
115 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
116 #define ISIS_TLV_IDRP_INFO_MINLEN 1
117 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
118 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
119 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
120 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
121 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
122 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
123 #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
124 #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
125 #define ISIS_TLV_NORTEL_PRIVATE1 176
126 #define ISIS_TLV_NORTEL_PRIVATE2 177
127 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
128 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
129 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
130 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
131 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
132 #define ISIS_TLV_MT_SUPPORTED_MINLEN 2
133 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
134 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
135 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
136 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
137 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
138 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
139 #define ISIS_TLV_IIH_SEQNR_MINLEN 4
140 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
141 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
143 static const struct tok isis_tlv_values
[] = {
144 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
145 { ISIS_TLV_IS_REACH
, "IS Reachability"},
146 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
147 { ISIS_TLV_PART_DIS
, "Partition DIS"},
148 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
149 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
150 { ISIS_TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
151 { ISIS_TLV_PADDING
, "Padding"},
152 { ISIS_TLV_LSP
, "LSP entries"},
153 { ISIS_TLV_AUTH
, "Authentication"},
154 { ISIS_TLV_CHECKSUM
, "Checksum"},
155 { ISIS_TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
156 { ISIS_TLV_EXT_IS_REACH
, "Extended IS Reachability"},
157 { ISIS_TLV_IS_ALIAS_ID
, "IS Alias ID"},
158 { ISIS_TLV_DECNET_PHASE4
, "DECnet Phase IV"},
159 { ISIS_TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
160 { ISIS_TLV_INT_IP_REACH
, "IPv4 Internal Reachability"},
161 { ISIS_TLV_PROTOCOLS
, "Protocols supported"},
162 { ISIS_TLV_EXT_IP_REACH
, "IPv4 External Reachability"},
163 { ISIS_TLV_IDRP_INFO
, "Inter-Domain Information Type"},
164 { ISIS_TLV_IPADDR
, "IPv4 Interface address(es)"},
165 { ISIS_TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
166 { ISIS_TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
167 { ISIS_TLV_EXTD_IP_REACH
, "Extended IPv4 Reachability"},
168 { ISIS_TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
169 { ISIS_TLV_MT_PORT_CAP
, "Multi-Topology-Aware Port Capability"},
170 { ISIS_TLV_MT_CAPABILITY
, "Multi-Topology Capability"},
171 { ISIS_TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
172 { ISIS_TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
173 { ISIS_TLV_HOSTNAME
, "Hostname"},
174 { ISIS_TLV_RESTART_SIGNALING
, "Restart Signaling"},
175 { ISIS_TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
176 { ISIS_TLV_MT_SUPPORTED
, "Multi Topology"},
177 { ISIS_TLV_IP6ADDR
, "IPv6 Interface address(es)"},
178 { ISIS_TLV_MT_IP_REACH
, "Multi-Topology IPv4 Reachability"},
179 { ISIS_TLV_IP6_REACH
, "IPv6 reachability"},
180 { ISIS_TLV_MT_IP6_REACH
, "Multi-Topology IP6 Reachability"},
181 { ISIS_TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
182 { ISIS_TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
183 { ISIS_TLV_VENDOR_PRIVATE
, "Vendor Private"},
187 #define ESIS_OPTION_PROTOCOLS 129
188 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
189 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
190 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
191 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
192 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
193 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
195 static const struct tok esis_option_values
[] = {
196 { ESIS_OPTION_PROTOCOLS
, "Protocols supported"},
197 { ESIS_OPTION_QOS_MAINTENANCE
, "QoS Maintenance" },
198 { ESIS_OPTION_SECURITY
, "Security" },
199 { ESIS_OPTION_ES_CONF_TIME
, "ES Configuration Time" },
200 { ESIS_OPTION_PRIORITY
, "Priority" },
201 { ESIS_OPTION_ADDRESS_MASK
, "Addressk Mask" },
202 { ESIS_OPTION_SNPA_MASK
, "SNPA Mask" },
206 #define CLNP_OPTION_DISCARD_REASON 193
207 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
208 #define CLNP_OPTION_SECURITY 197 /* iso8473 */
209 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
210 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
211 #define CLNP_OPTION_PADDING 204 /* iso8473 */
212 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
214 static const struct tok clnp_option_values
[] = {
215 { CLNP_OPTION_DISCARD_REASON
, "Discard Reason"},
216 { CLNP_OPTION_PRIORITY
, "Priority"},
217 { CLNP_OPTION_QOS_MAINTENANCE
, "QoS Maintenance"},
218 { CLNP_OPTION_SECURITY
, "Security"},
219 { CLNP_OPTION_SOURCE_ROUTING
, "Source Routing"},
220 { CLNP_OPTION_ROUTE_RECORDING
, "Route Recording"},
221 { CLNP_OPTION_PADDING
, "Padding"},
225 static const struct tok clnp_option_rfd_class_values
[] = {
228 { 0x9, "Source Routeing"},
230 { 0xb, "PDU Discarded"},
231 { 0xc, "Reassembly"},
235 static const struct tok clnp_option_rfd_general_values
[] = {
236 { 0x0, "Reason not specified"},
237 { 0x1, "Protocol procedure error"},
238 { 0x2, "Incorrect checksum"},
239 { 0x3, "PDU discarded due to congestion"},
240 { 0x4, "Header syntax error (cannot be parsed)"},
241 { 0x5, "Segmentation needed but not permitted"},
242 { 0x6, "Incomplete PDU received"},
243 { 0x7, "Duplicate option"},
247 static const struct tok clnp_option_rfd_address_values
[] = {
248 { 0x0, "Destination address unreachable"},
249 { 0x1, "Destination address unknown"},
253 static const struct tok clnp_option_rfd_source_routeing_values
[] = {
254 { 0x0, "Unspecified source routeing error"},
255 { 0x1, "Syntax error in source routeing field"},
256 { 0x2, "Unknown address in source routeing field"},
257 { 0x3, "Path not acceptable"},
261 static const struct tok clnp_option_rfd_lifetime_values
[] = {
262 { 0x0, "Lifetime expired while data unit in transit"},
263 { 0x1, "Lifetime expired during reassembly"},
267 static const struct tok clnp_option_rfd_pdu_discard_values
[] = {
268 { 0x0, "Unsupported option not specified"},
269 { 0x1, "Unsupported protocol version"},
270 { 0x2, "Unsupported security option"},
271 { 0x3, "Unsupported source routeing option"},
272 { 0x4, "Unsupported recording of route option"},
276 static const struct tok clnp_option_rfd_reassembly_values
[] = {
277 { 0x0, "Reassembly interference"},
281 /* array of 16 error-classes */
282 static const struct tok
*clnp_option_rfd_error_class
[] = {
283 clnp_option_rfd_general_values
,
291 clnp_option_rfd_address_values
,
292 clnp_option_rfd_source_routeing_values
,
293 clnp_option_rfd_lifetime_values
,
294 clnp_option_rfd_pdu_discard_values
,
295 clnp_option_rfd_reassembly_values
,
301 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
302 #define CLNP_OPTION_SCOPE_MASK 0xc0
303 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
304 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
305 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
307 static const struct tok clnp_option_scope_values
[] = {
308 { CLNP_OPTION_SCOPE_SA_SPEC
, "Source Address Specific"},
309 { CLNP_OPTION_SCOPE_DA_SPEC
, "Destination Address Specific"},
310 { CLNP_OPTION_SCOPE_GLOBAL
, "Globally unique"},
314 static const struct tok clnp_option_sr_rr_values
[] = {
320 static const struct tok clnp_option_sr_rr_string_values
[] = {
321 { CLNP_OPTION_SOURCE_ROUTING
, "source routing"},
322 { CLNP_OPTION_ROUTE_RECORDING
, "recording of route in progress"},
326 static const struct tok clnp_option_qos_global_values
[] = {
328 { 0x10, "sequencing vs. delay"},
329 { 0x08, "congested"},
330 { 0x04, "delay vs. cost"},
331 { 0x02, "error vs. delay"},
332 { 0x01, "error vs. cost"},
336 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
337 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */
338 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
339 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
340 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
341 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
342 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
343 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
344 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
345 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
346 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
347 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
348 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
349 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
351 #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
353 static const struct tok isis_ext_is_reach_subtlv_values
[] = {
354 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
355 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
356 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
357 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
358 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
359 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
360 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
361 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
362 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
363 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
, "Link Attribute" },
364 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
365 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
366 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
, "Bandwidth Constraints (old)" },
367 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
, "Bandwidth Constraints" },
368 { ISIS_SUBTLV_SPB_METRIC
, "SPB Metric" },
369 { 250, "Reserved for cisco specific extensions" },
370 { 251, "Reserved for cisco specific extensions" },
371 { 252, "Reserved for cisco specific extensions" },
372 { 253, "Reserved for cisco specific extensions" },
373 { 254, "Reserved for cisco specific extensions" },
374 { 255, "Reserved for future expansion" },
378 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
379 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
380 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
382 static const struct tok isis_ext_ip_reach_subtlv_values
[] = {
383 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
384 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
385 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
389 static const struct tok isis_subtlv_link_attribute_values
[] = {
390 { 0x01, "Local Protection Available" },
391 { 0x02, "Link excluded from local protection path" },
392 { 0x04, "Local maintenance required"},
396 #define ISIS_SUBTLV_AUTH_SIMPLE 1
397 #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
398 #define ISIS_SUBTLV_AUTH_MD5 54
399 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
400 #define ISIS_SUBTLV_AUTH_PRIVATE 255
402 static const struct tok isis_subtlv_auth_values
[] = {
403 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
404 { ISIS_SUBTLV_AUTH_GENERIC
, "Generic Crypto key-id"},
405 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
406 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
410 #define ISIS_SUBTLV_IDRP_RES 0
411 #define ISIS_SUBTLV_IDRP_LOCAL 1
412 #define ISIS_SUBTLV_IDRP_ASN 2
414 static const struct tok isis_subtlv_idrp_values
[] = {
415 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
416 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
417 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
421 #define ISIS_SUBTLV_SPB_MCID 4
422 #define ISIS_SUBTLV_SPB_DIGEST 5
423 #define ISIS_SUBTLV_SPB_BVID 6
425 #define ISIS_SUBTLV_SPB_INSTANCE 1
426 #define ISIS_SUBTLV_SPBM_SI 3
428 #define ISIS_SPB_MCID_LEN 51
429 #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
430 #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
431 #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
432 #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
433 #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
435 static const struct tok isis_mt_port_cap_subtlv_values
[] = {
436 { ISIS_SUBTLV_SPB_MCID
, "SPB MCID" },
437 { ISIS_SUBTLV_SPB_DIGEST
, "SPB Digest" },
438 { ISIS_SUBTLV_SPB_BVID
, "SPB BVID" },
442 static const struct tok isis_mt_capability_subtlv_values
[] = {
443 { ISIS_SUBTLV_SPB_INSTANCE
, "SPB Instance" },
444 { ISIS_SUBTLV_SPBM_SI
, "SPBM Service Identifier and Unicast Address" },
448 struct isis_spb_mcid
{
451 uint8_t revision_lvl
[2];
455 struct isis_subtlv_spb_mcid
{
456 struct isis_spb_mcid mcid
;
457 struct isis_spb_mcid aux_mcid
;
460 struct isis_subtlv_spb_instance
{
461 uint8_t cist_root_id
[8];
462 uint8_t cist_external_root_path_cost
[4];
463 uint8_t bridge_priority
[2];
464 uint8_t spsourceid
[4];
468 #define CLNP_SEGMENT_PART 0x80
469 #define CLNP_MORE_SEGMENTS 0x40
470 #define CLNP_REQUEST_ER 0x20
472 static const struct tok clnp_flag_values
[] = {
473 { CLNP_SEGMENT_PART
, "Segmentation permitted"},
474 { CLNP_MORE_SEGMENTS
, "more Segments"},
475 { CLNP_REQUEST_ER
, "request Error Report"},
479 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
480 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
481 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
482 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
483 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
484 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
485 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
486 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
488 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
489 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
491 static const struct tok isis_mt_flag_values
[] = {
492 { 0x4000, "ATT bit set"},
493 { 0x8000, "Overload bit set"},
497 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
498 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
500 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
501 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
503 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
504 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
505 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
506 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
508 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
510 static const struct tok isis_mt_values
[] = {
511 { 0, "IPv4 unicast"},
512 { 1, "In-Band Management"},
513 { 2, "IPv6 unicast"},
515 { 4095, "Development, Experimental or Proprietary"},
519 static const struct tok isis_iih_circuit_type_values
[] = {
520 { 1, "Level 1 only"},
521 { 2, "Level 2 only"},
522 { 3, "Level 1, Level 2"},
526 #define ISIS_LSP_TYPE_UNUSED0 0
527 #define ISIS_LSP_TYPE_LEVEL_1 1
528 #define ISIS_LSP_TYPE_UNUSED2 2
529 #define ISIS_LSP_TYPE_LEVEL_2 3
531 static const struct tok isis_lsp_istype_values
[] = {
532 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
533 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
534 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
535 { ISIS_LSP_TYPE_LEVEL_2
, "L2 IS"},
540 * Katz's point to point adjacency TLV uses codes to tell us the state of
541 * the remote adjacency. Enumerate them.
544 #define ISIS_PTP_ADJ_UP 0
545 #define ISIS_PTP_ADJ_INIT 1
546 #define ISIS_PTP_ADJ_DOWN 2
548 static const struct tok isis_ptp_adjancey_values
[] = {
549 { ISIS_PTP_ADJ_UP
, "Up" },
550 { ISIS_PTP_ADJ_INIT
, "Initializing" },
551 { ISIS_PTP_ADJ_DOWN
, "Down" },
555 struct isis_tlv_ptp_adj
{
556 uint8_t adjacency_state
;
557 uint8_t extd_local_circuit_id
[4];
558 uint8_t neighbor_sysid
[SYSTEM_ID_LEN
];
559 uint8_t neighbor_extd_local_circuit_id
[4];
562 static void osi_print_cksum(netdissect_options
*, const uint8_t *pptr
, uint16_t checksum
,
563 u_int checksum_offset
, u_int length
);
564 static int clnp_print(netdissect_options
*, const uint8_t *, u_int
);
565 static void esis_print(netdissect_options
*, const uint8_t *, u_int
);
566 static int isis_print(netdissect_options
*, const uint8_t *, u_int
);
568 struct isis_metric_block
{
569 uint8_t metric_default
;
570 uint8_t metric_delay
;
571 uint8_t metric_expense
;
572 uint8_t metric_error
;
575 struct isis_tlv_is_reach
{
576 struct isis_metric_block isis_metric_block
;
577 uint8_t neighbor_nodeid
[NODE_ID_LEN
];
580 struct isis_tlv_es_reach
{
581 struct isis_metric_block isis_metric_block
;
582 uint8_t neighbor_sysid
[SYSTEM_ID_LEN
];
585 struct isis_tlv_ip_reach
{
586 struct isis_metric_block isis_metric_block
;
591 static const struct tok isis_is_reach_virtual_values
[] = {
592 { 0, "IsNotVirtual"},
597 static const struct tok isis_restart_flag_values
[] = {
598 { 0x1, "Restart Request"},
599 { 0x2, "Restart Acknowledgement"},
600 { 0x4, "Suppress adjacency advertisement"},
604 struct isis_common_header
{
607 uint8_t version
; /* Protocol version */
609 uint8_t pdu_type
; /* 3 MSbits are reserved */
610 uint8_t pdu_version
; /* Packet format version */
615 struct isis_iih_lan_header
{
616 uint8_t circuit_type
;
617 uint8_t source_id
[SYSTEM_ID_LEN
];
618 uint8_t holding_time
[2];
621 uint8_t lan_id
[NODE_ID_LEN
];
624 struct isis_iih_ptp_header
{
625 uint8_t circuit_type
;
626 uint8_t source_id
[SYSTEM_ID_LEN
];
627 uint8_t holding_time
[2];
632 struct isis_lsp_header
{
634 uint8_t remaining_lifetime
[2];
635 uint8_t lsp_id
[LSP_ID_LEN
];
636 uint8_t sequence_number
[4];
641 struct isis_csnp_header
{
643 uint8_t source_id
[NODE_ID_LEN
];
644 uint8_t start_lsp_id
[LSP_ID_LEN
];
645 uint8_t end_lsp_id
[LSP_ID_LEN
];
648 struct isis_psnp_header
{
650 uint8_t source_id
[NODE_ID_LEN
];
653 struct isis_tlv_lsp
{
654 uint8_t remaining_lifetime
[2];
655 uint8_t lsp_id
[LSP_ID_LEN
];
656 uint8_t sequence_number
[4];
660 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
661 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
662 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
663 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
664 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
665 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
667 void isoclns_print(netdissect_options
*ndo
,
668 const uint8_t *p
, u_int length
, u_int caplen
)
670 if (caplen
<= 1) { /* enough bytes on the wire ? */
671 ND_PRINT((ndo
, "|OSI"));
676 ND_PRINT((ndo
, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values
, "Unknown", *p
), *p
));
681 if (!clnp_print(ndo
, p
, length
))
682 print_unknown_data(ndo
, p
, "\n\t", caplen
);
686 esis_print(ndo
, p
, length
);
690 if (!isis_print(ndo
, p
, length
))
691 print_unknown_data(ndo
, p
, "\n\t", caplen
);
695 ND_PRINT((ndo
, "%slength: %u", ndo
->ndo_eflag
? "" : ", ", length
));
699 q933_print(ndo
, p
+ 1, length
- 1);
703 ip_print(ndo
, p
+ 1, length
- 1);
707 ip6_print(ndo
, p
+ 1, length
- 1);
711 ppp_print(ndo
, p
+ 1, length
- 1);
716 ND_PRINT((ndo
, "OSI NLPID 0x%02x unknown", *p
));
717 ND_PRINT((ndo
, "%slength: %u", ndo
->ndo_eflag
? "" : ", ", length
));
719 print_unknown_data(ndo
, p
, "\n\t", caplen
);
724 #define CLNP_PDU_ER 1
725 #define CLNP_PDU_DT 28
726 #define CLNP_PDU_MD 29
727 #define CLNP_PDU_ERQ 30
728 #define CLNP_PDU_ERP 31
730 static const struct tok clnp_pdu_values
[] = {
731 { CLNP_PDU_ER
, "Error Report"},
732 { CLNP_PDU_MD
, "MD"},
733 { CLNP_PDU_DT
, "Data"},
734 { CLNP_PDU_ERQ
, "Echo Request"},
735 { CLNP_PDU_ERP
, "Echo Response"},
739 struct clnp_header_t
{
741 uint8_t length_indicator
;
743 uint8_t lifetime
; /* units of 500ms */
745 uint8_t segment_length
[2];
749 struct clnp_segment_header_t
{
750 uint8_t data_unit_id
[2];
751 uint8_t segment_offset
[2];
752 uint8_t total_length
[2];
757 * Decode CLNP packets. Return 0 on error.
761 clnp_print(netdissect_options
*ndo
,
762 const uint8_t *pptr
, u_int length
)
764 const uint8_t *optr
,*source_address
,*dest_address
;
765 u_int li
,tlen
,nsap_offset
,source_address_length
,dest_address_length
, clnp_pdu_type
, clnp_flags
;
766 const struct clnp_header_t
*clnp_header
;
767 const struct clnp_segment_header_t
*clnp_segment_header
;
768 uint8_t rfd_error_major
,rfd_error_minor
;
770 clnp_header
= (const struct clnp_header_t
*) pptr
;
771 ND_TCHECK(*clnp_header
);
773 li
= clnp_header
->length_indicator
;
777 ND_PRINT((ndo
, "CLNP"));
780 * Sanity checking of the header.
783 if (clnp_header
->version
!= CLNP_VERSION
) {
784 ND_PRINT((ndo
, "version %d packet not supported", clnp_header
->version
));
788 /* FIXME further header sanity checking */
790 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
791 clnp_flags
= clnp_header
->type
& CLNP_FLAG_MASK
;
793 pptr
+= sizeof(struct clnp_header_t
);
794 li
-= sizeof(struct clnp_header_t
);
795 dest_address_length
= *pptr
;
796 dest_address
= pptr
+ 1;
798 pptr
+= (1 + dest_address_length
);
799 li
-= (1 + dest_address_length
);
800 source_address_length
= *pptr
;
801 source_address
= pptr
+1;
803 pptr
+= (1 + source_address_length
);
804 li
-= (1 + source_address_length
);
806 if (ndo
->ndo_vflag
< 1) {
807 ND_PRINT((ndo
, "%s%s > %s, %s, length %u",
808 ndo
->ndo_eflag
? "" : ", ",
809 isonsap_string(source_address
, source_address_length
),
810 isonsap_string(dest_address
, dest_address_length
),
811 tok2str(clnp_pdu_values
,"unknown (%u)",clnp_pdu_type
),
815 ND_PRINT((ndo
, "%slength %u", ndo
->ndo_eflag
? "" : ", ", length
));
817 ND_PRINT((ndo
, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
818 tok2str(clnp_pdu_values
, "unknown (%u)",clnp_pdu_type
),
819 clnp_header
->length_indicator
,
820 clnp_header
->version
,
821 clnp_header
->lifetime
/2,
822 (clnp_header
->lifetime
%2)*5,
823 EXTRACT_16BITS(clnp_header
->segment_length
),
824 EXTRACT_16BITS(clnp_header
->cksum
)));
826 osi_print_cksum(ndo
, optr
, EXTRACT_16BITS(clnp_header
->cksum
), 7,
827 clnp_header
->length_indicator
);
829 ND_PRINT((ndo
, "\n\tFlags [%s]",
830 bittok2str(clnp_flag_values
, "none", clnp_flags
)));
832 ND_PRINT((ndo
, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
833 source_address_length
,
834 isonsap_string(source_address
, source_address_length
),
836 isonsap_string(dest_address
, dest_address_length
)));
838 if (clnp_flags
& CLNP_SEGMENT_PART
) {
839 clnp_segment_header
= (const struct clnp_segment_header_t
*) pptr
;
840 ND_TCHECK(*clnp_segment_header
);
841 ND_PRINT((ndo
, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
842 EXTRACT_16BITS(clnp_segment_header
->data_unit_id
),
843 EXTRACT_16BITS(clnp_segment_header
->segment_offset
),
844 EXTRACT_16BITS(clnp_segment_header
->total_length
)));
845 pptr
+=sizeof(const struct clnp_segment_header_t
);
846 li
-=sizeof(const struct clnp_segment_header_t
);
849 /* now walk the options */
854 ND_TCHECK2(*pptr
, 2);
856 ND_PRINT((ndo
, ", bad opts/li"));
862 ND_TCHECK2(*pptr
, opli
);
864 ND_PRINT((ndo
, ", opt (%d) too long", op
));
871 ND_PRINT((ndo
, "\n\t %s Option #%u, length %u, value: ",
872 tok2str(clnp_option_values
,"Unknown",op
),
879 case CLNP_OPTION_ROUTE_RECORDING
: /* those two options share the format */
880 case CLNP_OPTION_SOURCE_ROUTING
:
881 ND_PRINT((ndo
, "%s %s",
882 tok2str(clnp_option_sr_rr_values
,"Unknown",*tptr
),
883 tok2str(clnp_option_sr_rr_string_values
, "Unknown Option %u", op
)));
884 nsap_offset
=*(tptr
+1);
885 if (nsap_offset
== 0) {
886 ND_PRINT((ndo
, " Bad NSAP offset (0)"));
889 nsap_offset
-=1; /* offset to nsap list */
890 if (nsap_offset
> tlen
) {
891 ND_PRINT((ndo
, " Bad NSAP offset (past end of option)"));
897 source_address_length
=*tptr
;
898 if (tlen
< source_address_length
+1) {
899 ND_PRINT((ndo
, "\n\t NSAP address goes past end of option"));
902 if (source_address_length
> 0) {
903 source_address
=(tptr
+1);
904 ND_TCHECK2(*source_address
, source_address_length
);
905 ND_PRINT((ndo
, "\n\t NSAP address (length %u): %s",
906 source_address_length
,
907 isonsap_string(source_address
, source_address_length
)));
909 tlen
-=source_address_length
+1;
913 case CLNP_OPTION_PRIORITY
:
914 ND_PRINT((ndo
, "0x%1x", *tptr
&0x0f));
917 case CLNP_OPTION_QOS_MAINTENANCE
:
918 ND_PRINT((ndo
, "\n\t Format Code: %s",
919 tok2str(clnp_option_scope_values
, "Reserved", *tptr
&CLNP_OPTION_SCOPE_MASK
)));
921 if ((*tptr
&CLNP_OPTION_SCOPE_MASK
) == CLNP_OPTION_SCOPE_GLOBAL
)
922 ND_PRINT((ndo
, "\n\t QoS Flags [%s]",
923 bittok2str(clnp_option_qos_global_values
,
925 *tptr
&CLNP_OPTION_OPTION_QOS_MASK
)));
928 case CLNP_OPTION_SECURITY
:
929 ND_PRINT((ndo
, "\n\t Format Code: %s, Security-Level %u",
930 tok2str(clnp_option_scope_values
,"Reserved",*tptr
&CLNP_OPTION_SCOPE_MASK
),
934 case CLNP_OPTION_DISCARD_REASON
:
935 rfd_error_major
= (*tptr
&0xf0) >> 4;
936 rfd_error_minor
= *tptr
&0x0f;
937 ND_PRINT((ndo
, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
938 tok2str(clnp_option_rfd_class_values
,"Unknown",rfd_error_major
),
940 tok2str(clnp_option_rfd_error_class
[rfd_error_major
],"Unknown",rfd_error_minor
),
944 case CLNP_OPTION_PADDING
:
945 ND_PRINT((ndo
, "padding data"));
949 * FIXME those are the defined Options that lack a decoder
950 * you are welcome to contribute code ;-)
954 print_unknown_data(ndo
, tptr
, "\n\t ", opli
);
957 if (ndo
->ndo_vflag
> 1)
958 print_unknown_data(ndo
, pptr
, "\n\t ", opli
);
962 switch (clnp_pdu_type
) {
964 case CLNP_PDU_ER
: /* fall through */
967 if (*(pptr
) == NLPID_CLNP
) {
968 ND_PRINT((ndo
, "\n\t-----original packet-----\n\t"));
969 /* FIXME recursion protection */
970 clnp_print(ndo
, pptr
, length
- clnp_header
->length_indicator
);
979 /* dump the PDU specific data */
980 if (length
-(pptr
-optr
) > 0) {
981 ND_PRINT((ndo
, "\n\t undecoded non-header data, length %u", length
-clnp_header
->length_indicator
));
982 print_unknown_data(ndo
, pptr
, "\n\t ", length
- (pptr
- optr
));
989 ND_PRINT((ndo
, "[|clnp]"));
995 #define ESIS_PDU_REDIRECT 6
996 #define ESIS_PDU_ESH 2
997 #define ESIS_PDU_ISH 4
999 static const struct tok esis_pdu_values
[] = {
1000 { ESIS_PDU_REDIRECT
, "redirect"},
1001 { ESIS_PDU_ESH
, "ESH"},
1002 { ESIS_PDU_ISH
, "ISH"},
1006 struct esis_header_t
{
1008 uint8_t length_indicator
;
1012 uint8_t holdtime
[2];
1017 esis_print(netdissect_options
*ndo
,
1018 const uint8_t *pptr
, u_int length
)
1020 const uint8_t *optr
;
1021 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
1022 const struct esis_header_t
*esis_header
;
1024 if (!ndo
->ndo_eflag
)
1025 ND_PRINT((ndo
, "ES-IS"));
1028 ND_PRINT((ndo
, ndo
->ndo_qflag
? "bad pkt!" : "no header at all!"));
1032 esis_header
= (const struct esis_header_t
*) pptr
;
1033 ND_TCHECK(*esis_header
);
1034 li
= esis_header
->length_indicator
;
1038 * Sanity checking of the header.
1041 if (esis_header
->nlpid
!= NLPID_ESIS
) {
1042 ND_PRINT((ndo
, " nlpid 0x%02x packet not supported", esis_header
->nlpid
));
1046 if (esis_header
->version
!= ESIS_VERSION
) {
1047 ND_PRINT((ndo
, " version %d packet not supported", esis_header
->version
));
1052 ND_PRINT((ndo
, " length indicator(%d) > PDU size (%d)!", li
, length
));
1056 if (li
< sizeof(struct esis_header_t
) + 2) {
1057 ND_PRINT((ndo
, " length indicator < min PDU size %d:", li
));
1058 while (--length
!= 0)
1059 ND_PRINT((ndo
, "%02X", *pptr
++));
1063 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
1065 if (ndo
->ndo_vflag
< 1) {
1066 ND_PRINT((ndo
, "%s%s, length %u",
1067 ndo
->ndo_eflag
? "" : ", ",
1068 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
1072 ND_PRINT((ndo
, "%slength %u\n\t%s (%u)",
1073 ndo
->ndo_eflag
? "" : ", ",
1075 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
1078 ND_PRINT((ndo
, ", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" ));
1079 ND_PRINT((ndo
, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header
->cksum
)));
1081 osi_print_cksum(ndo
, pptr
, EXTRACT_16BITS(esis_header
->cksum
), 7, li
);
1083 ND_PRINT((ndo
, ", holding time: %us, length indicator: %u",
1084 EXTRACT_16BITS(esis_header
->holdtime
), li
));
1086 if (ndo
->ndo_vflag
> 1)
1087 print_unknown_data(ndo
, optr
, "\n\t", sizeof(struct esis_header_t
));
1089 pptr
+= sizeof(struct esis_header_t
);
1090 li
-= sizeof(struct esis_header_t
);
1092 switch (esis_pdu_type
) {
1093 case ESIS_PDU_REDIRECT
: {
1094 const uint8_t *dst
, *snpa
, *neta
;
1095 u_int dstl
, snpal
, netal
;
1099 ND_PRINT((ndo
, ", bad redirect/li"));
1105 ND_TCHECK2(*pptr
, dstl
);
1107 ND_PRINT((ndo
, ", bad redirect/li"));
1113 ND_PRINT((ndo
, "\n\t %s", isonsap_string(dst
, dstl
)));
1117 ND_PRINT((ndo
, ", bad redirect/li"));
1123 ND_TCHECK2(*pptr
, snpal
);
1125 ND_PRINT((ndo
, ", bad redirect/li"));
1133 ND_PRINT((ndo
, ", bad redirect/li"));
1138 ND_TCHECK2(*pptr
, netal
);
1140 ND_PRINT((ndo
, ", bad redirect/li"));
1148 ND_PRINT((ndo
, "\n\t %s", etheraddr_string(ndo
, snpa
)));
1150 ND_PRINT((ndo
, "\n\t %s", isonsap_string(neta
, netal
)));
1157 ND_PRINT((ndo
, ", bad esh/li"));
1160 source_address_number
= *pptr
;
1164 ND_PRINT((ndo
, "\n\t Number of Source Addresses: %u", source_address_number
));
1166 while (source_address_number
> 0) {
1169 ND_PRINT((ndo
, ", bad esh/li"));
1172 source_address_length
= *pptr
;
1176 ND_TCHECK2(*pptr
, source_address_length
);
1177 if (li
< source_address_length
) {
1178 ND_PRINT((ndo
, ", bad esh/li"));
1181 ND_PRINT((ndo
, "\n\t NET (length: %u): %s",
1182 source_address_length
,
1183 isonsap_string(pptr
, source_address_length
)));
1184 pptr
+= source_address_length
;
1185 li
-= source_address_length
;
1186 source_address_number
--;
1191 case ESIS_PDU_ISH
: {
1194 ND_PRINT((ndo
, ", bad ish/li"));
1197 source_address_length
= *pptr
;
1200 ND_TCHECK2(*pptr
, source_address_length
);
1201 if (li
< source_address_length
) {
1202 ND_PRINT((ndo
, ", bad ish/li"));
1205 ND_PRINT((ndo
, "\n\t NET (length: %u): %s", source_address_length
, isonsap_string(pptr
, source_address_length
)));
1206 pptr
+= source_address_length
;
1207 li
-= source_address_length
;
1212 if (ndo
->ndo_vflag
<= 1) {
1213 if (pptr
< ndo
->ndo_snapend
)
1214 print_unknown_data(ndo
, pptr
, "\n\t ", ndo
->ndo_snapend
- pptr
);
1219 /* now walk the options */
1222 const uint8_t *tptr
;
1225 ND_PRINT((ndo
, ", bad opts/li"));
1228 ND_TCHECK2(*pptr
, 2);
1233 ND_PRINT((ndo
, ", opt (%d) too long", op
));
1239 ND_PRINT((ndo
, "\n\t %s Option #%u, length %u, value: ",
1240 tok2str(esis_option_values
,"Unknown",op
),
1246 case ESIS_OPTION_ES_CONF_TIME
:
1248 ND_TCHECK2(*pptr
, 2);
1249 ND_PRINT((ndo
, "%us", EXTRACT_16BITS(tptr
)));
1251 ND_PRINT((ndo
, "(bad length)"));
1254 case ESIS_OPTION_PROTOCOLS
:
1257 ND_PRINT((ndo
, "%s (0x%02x)",
1258 tok2str(nlpid_values
,
1262 if (opli
>1) /* further NPLIDs ? - put comma */
1263 ND_PRINT((ndo
, ", "));
1270 * FIXME those are the defined Options that lack a decoder
1271 * you are welcome to contribute code ;-)
1274 case ESIS_OPTION_QOS_MAINTENANCE
:
1275 case ESIS_OPTION_SECURITY
:
1276 case ESIS_OPTION_PRIORITY
:
1277 case ESIS_OPTION_ADDRESS_MASK
:
1278 case ESIS_OPTION_SNPA_MASK
:
1281 print_unknown_data(ndo
, tptr
, "\n\t ", opli
);
1284 if (ndo
->ndo_vflag
> 1)
1285 print_unknown_data(ndo
, pptr
, "\n\t ", opli
);
1293 isis_print_mcid(netdissect_options
*ndo
,
1294 const struct isis_spb_mcid
*mcid
)
1298 ND_PRINT((ndo
, "ID: %d, Name: ", mcid
->format_id
));
1302 ND_PRINT((ndo
, "%c", mcid
->name
[i
]));
1303 if(mcid
->name
[i
] == '\0')
1307 ND_PRINT((ndo
, "\n\t Lvl: %d", EXTRACT_16BITS(mcid
->revision_lvl
)));
1309 ND_PRINT((ndo
, ", Digest: "));
1312 ND_PRINT((ndo
, "%.2x ", mcid
->digest
[i
]));
1316 isis_print_mt_port_cap_subtlv(netdissect_options
*ndo
,
1317 const uint8_t *tptr
, int len
)
1319 int stlv_type
, stlv_len
;
1320 const struct isis_subtlv_spb_mcid
*subtlv_spb_mcid
;
1325 stlv_type
= *(tptr
++);
1326 stlv_len
= *(tptr
++);
1328 /* first lets see if we know the subTLVs name*/
1329 ND_PRINT((ndo
, "\n\t %s subTLV #%u, length: %u",
1330 tok2str(isis_mt_port_cap_subtlv_values
, "unknown", stlv_type
),
1334 /*len -= TLV_TYPE_LEN_OFFSET;*/
1339 case ISIS_SUBTLV_SPB_MCID
:
1341 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_MCID_MIN_LEN
))
1344 subtlv_spb_mcid
= (struct isis_subtlv_spb_mcid
*)tptr
;
1346 ND_PRINT((ndo
, "\n\t MCID: "));
1347 isis_print_mcid(ndo
, &(subtlv_spb_mcid
->mcid
));
1349 /*tptr += SPB_MCID_MIN_LEN;
1350 len -= SPB_MCID_MIN_LEN; */
1352 ND_PRINT((ndo
, "\n\t AUX-MCID: "));
1353 isis_print_mcid(ndo
, &(subtlv_spb_mcid
->aux_mcid
));
1355 /*tptr += SPB_MCID_MIN_LEN;
1356 len -= SPB_MCID_MIN_LEN; */
1357 tptr
= tptr
+ sizeof(struct isis_subtlv_spb_mcid
);
1358 len
= len
- sizeof(struct isis_subtlv_spb_mcid
);
1363 case ISIS_SUBTLV_SPB_DIGEST
:
1365 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
))
1368 ND_PRINT((ndo
, "\n\t RES: %d V: %d A: %d D: %d",
1369 (*(tptr
) >> 5), (((*tptr
)>> 4) & 0x01),
1370 ((*(tptr
) >> 2) & 0x03), ((*tptr
) & 0x03)));
1374 ND_PRINT((ndo
, "\n\t Digest: "));
1378 ND_PRINT((ndo
, "%08x ", EXTRACT_32BITS(tptr
)));
1379 if (i
%4 == 0 && i
!= 8)
1380 ND_PRINT((ndo
, "\n\t "));
1384 len
= len
- ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
;
1389 case ISIS_SUBTLV_SPB_BVID
:
1391 if (!ND_TTEST2(*(tptr
), stlv_len
))
1396 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_BVID_MIN_LEN
))
1399 ND_PRINT((ndo
, "\n\t ECT: %08x",
1400 EXTRACT_32BITS(tptr
)));
1404 ND_PRINT((ndo
, " BVID: %d, U:%01x M:%01x ",
1405 (EXTRACT_16BITS (tptr
) >> 4) ,
1406 (EXTRACT_16BITS (tptr
) >> 3) & 0x01,
1407 (EXTRACT_16BITS (tptr
) >> 2) & 0x01));
1410 len
= len
- ISIS_SUBTLV_SPB_BVID_MIN_LEN
;
1424 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot"));
1429 isis_print_mt_capability_subtlv(netdissect_options
*ndo
,
1430 const uint8_t *tptr
, int len
)
1432 int stlv_type
, stlv_len
, tmp
;
1436 stlv_type
= *(tptr
++);
1437 stlv_len
= *(tptr
++);
1439 /* first lets see if we know the subTLVs name*/
1440 ND_PRINT((ndo
, "\n\t %s subTLV #%u, length: %u",
1441 tok2str(isis_mt_capability_subtlv_values
, "unknown", stlv_type
),
1449 case ISIS_SUBTLV_SPB_INSTANCE
:
1451 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
))
1454 ND_PRINT((ndo
, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr
)));
1456 ND_PRINT((ndo
, " %08x", EXTRACT_32BITS(tptr
)));
1458 ND_PRINT((ndo
, ", Path Cost: %08x", EXTRACT_32BITS(tptr
)));
1460 ND_PRINT((ndo
, ", Prio: %d", EXTRACT_16BITS(tptr
)));
1462 ND_PRINT((ndo
, "\n\t RES: %d",
1463 EXTRACT_16BITS(tptr
) >> 5));
1464 ND_PRINT((ndo
, ", V: %d",
1465 (EXTRACT_16BITS(tptr
) >> 4) & 0x0001));
1466 ND_PRINT((ndo
, ", SPSource-ID: %d",
1467 (EXTRACT_32BITS(tptr
) & 0x000fffff)));
1469 ND_PRINT((ndo
, ", No of Trees: %x", *(tptr
)));
1473 len
= len
- ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
;
1477 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
))
1480 ND_PRINT((ndo
, "\n\t U:%d, M:%d, A:%d, RES:%d",
1481 *(tptr
) >> 7, (*(tptr
) >> 6) & 0x01,
1482 (*(tptr
) >> 5) & 0x01, (*(tptr
) & 0x1f)));
1486 ND_PRINT((ndo
, ", ECT: %08x", EXTRACT_32BITS(tptr
)));
1490 ND_PRINT((ndo
, ", BVID: %d, SPVID: %d",
1491 (EXTRACT_24BITS(tptr
) >> 12) & 0x000fff,
1492 EXTRACT_24BITS(tptr
) & 0x000fff));
1495 len
= len
- ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
;
1501 case ISIS_SUBTLV_SPBM_SI
:
1503 if (!ND_TTEST2(*(tptr
), 6))
1506 ND_PRINT((ndo
, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr
)));
1508 ND_PRINT((ndo
, "%04x", EXTRACT_16BITS(tptr
)));
1511 ND_PRINT((ndo
, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr
) >> 12,
1512 (EXTRACT_16BITS(tptr
)) & 0x0fff));
1516 stlv_len
= stlv_len
- 8;
1520 ND_PRINT((ndo
, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
1521 (EXTRACT_32BITS(tptr
) >> 31),
1522 (EXTRACT_32BITS(tptr
) >> 30) & 0x01,
1523 (EXTRACT_32BITS(tptr
) >> 24) & 0x03f,
1524 (EXTRACT_32BITS(tptr
)) & 0x0ffffff));
1528 stlv_len
= stlv_len
- 4;
1540 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot"));
1544 /* shared routine for printing system, node and lsp-ids */
1546 isis_print_id(const uint8_t *cp
, int id_len
)
1549 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1552 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
1553 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
1555 if (i
== 2 || i
== 4)
1558 if (id_len
>= NODE_ID_LEN
) {
1559 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
1562 if (id_len
== LSP_ID_LEN
)
1563 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
1567 /* print the 4-byte metric block which is common found in the old-style TLVs */
1569 isis_print_metric_block(netdissect_options
*ndo
,
1570 const struct isis_metric_block
*isis_metric_block
)
1572 ND_PRINT((ndo
, ", Default Metric: %d, %s",
1573 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
1574 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal"));
1575 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
1576 ND_PRINT((ndo
, "\n\t\t Delay Metric: %d, %s",
1577 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
1578 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal"));
1579 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
1580 ND_PRINT((ndo
, "\n\t\t Expense Metric: %d, %s",
1581 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
1582 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal"));
1583 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
1584 ND_PRINT((ndo
, "\n\t\t Error Metric: %d, %s",
1585 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
1586 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal"));
1588 return(1); /* everything is ok */
1592 isis_print_tlv_ip_reach(netdissect_options
*ndo
,
1593 const uint8_t *cp
, const char *ident
, int length
)
1596 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
1598 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
1600 while (length
> 0) {
1601 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
1602 ND_PRINT((ndo
, "short IPv4 Reachability (%d vs %lu)",
1604 (unsigned long)sizeof(*tlv_ip_reach
)));
1608 if (!ND_TTEST(*tlv_ip_reach
))
1611 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
1613 if (prefix_len
== -1)
1614 ND_PRINT((ndo
, "%sIPv4 prefix: %s mask %s",
1616 ipaddr_string(ndo
, (tlv_ip_reach
->prefix
)),
1617 ipaddr_string(ndo
, (tlv_ip_reach
->mask
))));
1619 ND_PRINT((ndo
, "%sIPv4 prefix: %15s/%u",
1621 ipaddr_string(ndo
, (tlv_ip_reach
->prefix
)),
1624 ND_PRINT((ndo
, ", Distribution: %s, Metric: %u, %s",
1625 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
1626 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
1627 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal"));
1629 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
1630 ND_PRINT((ndo
, "%s Delay Metric: %u, %s",
1632 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
1633 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal"));
1635 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
1636 ND_PRINT((ndo
, "%s Expense Metric: %u, %s",
1638 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
1639 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal"));
1641 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
1642 ND_PRINT((ndo
, "%s Error Metric: %u, %s",
1644 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
1645 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal"));
1647 length
-= sizeof(struct isis_tlv_ip_reach
);
1654 * this is the common IP-REACH subTLV decoder it is called
1655 * from various EXTD-IP REACH TLVs (135,235,236,237)
1659 isis_print_ip_reach_subtlv(netdissect_options
*ndo
,
1660 const uint8_t *tptr
, int subt
, int subl
,
1661 const char *ident
) {
1663 /* first lets see if we know the subTLVs name*/
1664 ND_PRINT((ndo
, "%s%s subTLV #%u, length: %u",
1665 ident
, tok2str(isis_ext_ip_reach_subtlv_values
, "unknown", subt
),
1668 if (!ND_TTEST2(*tptr
,subl
))
1672 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1673 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1675 ND_PRINT((ndo
, ", 0x%08x (=%u)",
1676 EXTRACT_32BITS(tptr
),
1677 EXTRACT_32BITS(tptr
)));
1682 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1684 ND_PRINT((ndo
, ", 0x%08x%08x",
1685 EXTRACT_32BITS(tptr
),
1686 EXTRACT_32BITS(tptr
+4)));
1692 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1699 ND_PRINT((ndo
, "%spacket exceeded snapshot", ident
));
1704 * this is the common IS-REACH subTLV decoder it is called
1705 * from isis_print_ext_is_reach()
1709 isis_print_is_reach_subtlv(netdissect_options
*ndo
,
1710 const uint8_t *tptr
, u_int subt
, u_int subl
,
1711 const char *ident
) {
1713 u_int te_class
,priority_level
,gmpls_switch_cap
;
1714 union { /* int to float conversion buffer for several subTLVs */
1719 /* first lets see if we know the subTLVs name*/
1720 ND_PRINT((ndo
, "%s%s subTLV #%u, length: %u",
1721 ident
, tok2str(isis_ext_is_reach_subtlv_values
, "unknown", subt
),
1724 if (!ND_TTEST2(*tptr
,subl
))
1728 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1729 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1730 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1732 ND_PRINT((ndo
, ", 0x%08x", EXTRACT_32BITS(tptr
)));
1733 if (subl
== 8) /* rfc4205 */
1734 ND_PRINT((ndo
, ", 0x%08x", EXTRACT_32BITS(tptr
+4)));
1737 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1738 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1739 if (subl
>= sizeof(struct in_addr
))
1740 ND_PRINT((ndo
, ", %s", ipaddr_string(ndo
, tptr
)));
1742 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1743 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1745 bw
.i
= EXTRACT_32BITS(tptr
);
1746 ND_PRINT((ndo
, ", %.3f Mbps", bw
.f
* 8 / 1000000));
1749 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1751 for (te_class
= 0; te_class
< 8; te_class
++) {
1752 bw
.i
= EXTRACT_32BITS(tptr
);
1753 ND_PRINT((ndo
, "%s TE-Class %u: %.3f Mbps",
1756 bw
.f
* 8 / 1000000));
1761 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
: /* fall through */
1762 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
:
1763 ND_PRINT((ndo
, "%sBandwidth Constraints Model ID: %s (%u)",
1765 tok2str(diffserv_te_bc_values
, "unknown", *tptr
),
1768 /* decode BCs until the subTLV ends */
1769 for (te_class
= 0; te_class
< (subl
-1)/4; te_class
++) {
1770 bw
.i
= EXTRACT_32BITS(tptr
);
1771 ND_PRINT((ndo
, "%s Bandwidth constraint CT%u: %.3f Mbps",
1774 bw
.f
* 8 / 1000000));
1778 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1780 ND_PRINT((ndo
, ", %u", EXTRACT_24BITS(tptr
)));
1782 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
:
1784 ND_PRINT((ndo
, ", [ %s ] (0x%04x)",
1785 bittok2str(isis_subtlv_link_attribute_values
,
1787 EXTRACT_16BITS(tptr
)),
1788 EXTRACT_16BITS(tptr
)));
1791 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1793 ND_PRINT((ndo
, ", %s, Priority %u",
1794 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1798 case ISIS_SUBTLV_SPB_METRIC
:
1800 ND_PRINT((ndo
, ", LM: %u", EXTRACT_24BITS(tptr
)));
1802 ND_PRINT((ndo
, ", P: %u", *(tptr
)));
1804 ND_PRINT((ndo
, ", P-ID: %u", EXTRACT_16BITS(tptr
)));
1807 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1809 gmpls_switch_cap
= *tptr
;
1810 ND_PRINT((ndo
, "%s Interface Switching Capability:%s",
1812 tok2str(gmpls_switch_cap_values
, "Unknown", gmpls_switch_cap
)));
1813 ND_PRINT((ndo
, ", LSP Encoding: %s",
1814 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+ 1))));
1816 ND_PRINT((ndo
, "%s Max LSP Bandwidth:", ident
));
1817 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1818 bw
.i
= EXTRACT_32BITS(tptr
);
1819 ND_PRINT((ndo
, "%s priority level %d: %.3f Mbps",
1822 bw
.f
* 8 / 1000000));
1826 switch (gmpls_switch_cap
) {
1831 bw
.i
= EXTRACT_32BITS(tptr
);
1832 ND_PRINT((ndo
, "%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
* 8 / 1000000));
1833 ND_PRINT((ndo
, "%s Interface MTU: %u", ident
, EXTRACT_16BITS(tptr
+ 4)));
1836 bw
.i
= EXTRACT_32BITS(tptr
);
1837 ND_PRINT((ndo
, "%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
* 8 / 1000000));
1838 ND_PRINT((ndo
, "%s Indication %s", ident
,
1839 tok2str(gmpls_switch_cap_tsc_indication_values
, "Unknown (%u)", *(tptr
+ 4))));
1842 /* there is some optional stuff left to decode but this is as of yet
1843 not specified so just lets hexdump what is left */
1845 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1852 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1859 ND_PRINT((ndo
, "%spacket exceeded snapshot", ident
));
1865 * this is the common IS-REACH decoder it is called
1866 * from various EXTD-IS REACH style TLVs (22,24,222)
1870 isis_print_ext_is_reach(netdissect_options
*ndo
,
1871 const uint8_t *tptr
, const char *ident
, int tlv_type
) {
1873 char ident_buffer
[20];
1874 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1875 int proc_bytes
= 0; /* how many bytes did we process ? */
1877 if (!ND_TTEST2(*tptr
, NODE_ID_LEN
))
1880 ND_PRINT((ndo
, "%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
)));
1881 tptr
+=(NODE_ID_LEN
);
1883 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1884 if (!ND_TTEST2(*tptr
, 3)) /* and is therefore skipped */
1886 ND_PRINT((ndo
, ", Metric: %d", EXTRACT_24BITS(tptr
)));
1890 if (!ND_TTEST2(*tptr
, 1))
1892 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1893 proc_bytes
=NODE_ID_LEN
+3+1;
1894 ND_PRINT((ndo
, ", %ssub-TLVs present",subtlv_sum_len
? "" : "no "));
1895 if (subtlv_sum_len
) {
1896 ND_PRINT((ndo
, " (%u)", subtlv_sum_len
));
1897 while (subtlv_sum_len
>0) {
1898 if (!ND_TTEST2(*tptr
,2))
1900 subtlv_type
=*(tptr
++);
1901 subtlv_len
=*(tptr
++);
1902 /* prepend the ident string */
1903 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1904 if (!isis_print_is_reach_subtlv(ndo
, tptr
, subtlv_type
, subtlv_len
, ident_buffer
))
1907 subtlv_sum_len
-=(subtlv_len
+2);
1908 proc_bytes
+=(subtlv_len
+2);
1915 * this is the common Multi Topology ID decoder
1916 * it is called from various MT-TLVs (222,229,235,237)
1920 isis_print_mtid(netdissect_options
*ndo
,
1921 const uint8_t *tptr
, const char *ident
) {
1923 if (!ND_TTEST2(*tptr
, 2))
1926 ND_PRINT((ndo
, "%s%s",
1928 tok2str(isis_mt_values
,
1929 "Reserved for IETF Consensus",
1930 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)))));
1932 ND_PRINT((ndo
, " Topology (0x%03x), Flags: [%s]",
1933 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1934 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
)))));
1940 * this is the common extended IP reach decoder
1941 * it is called from TLVs (135,235,236,237)
1942 * we process the TLV and optional subTLVs and return
1943 * the amount of processed bytes
1947 isis_print_extd_ip_reach(netdissect_options
*ndo
,
1948 const uint8_t *tptr
, const char *ident
, uint16_t afi
) {
1950 char ident_buffer
[20];
1952 uint8_t prefix
[sizeof(struct in6_addr
)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1954 uint8_t prefix
[sizeof(struct in_addr
)]; /* shared copy buffer for IPv4 prefixes */
1956 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1958 if (!ND_TTEST2(*tptr
, 4))
1960 metric
= EXTRACT_32BITS(tptr
);
1964 if (afi
== AF_INET
) {
1965 if (!ND_TTEST2(*tptr
, 1)) /* fetch status byte */
1967 status_byte
=*(tptr
++);
1968 bit_length
= status_byte
&0x3f;
1969 if (bit_length
> 32) {
1970 ND_PRINT((ndo
, "%sIPv4 prefix: bad bit length %u",
1977 } else if (afi
== AF_INET6
) {
1978 if (!ND_TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1980 status_byte
=*(tptr
++);
1981 bit_length
=*(tptr
++);
1982 if (bit_length
> 128) {
1983 ND_PRINT((ndo
, "%sIPv6 prefix: bad bit length %u",
1991 return (0); /* somebody is fooling us */
1993 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1995 if (!ND_TTEST2(*tptr
, byte_length
))
1997 memset(prefix
, 0, sizeof prefix
); /* clear the copy buffer */
1998 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
2000 processed
+=byte_length
;
2003 ND_PRINT((ndo
, "%sIPv4 prefix: %15s/%u",
2005 ipaddr_string(ndo
, prefix
),
2008 if (afi
== AF_INET6
)
2009 ND_PRINT((ndo
, "%sIPv6 prefix: %s/%u",
2011 ip6addr_string(ndo
, prefix
),
2015 ND_PRINT((ndo
, ", Distribution: %s, Metric: %u",
2016 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
2019 if (afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2020 ND_PRINT((ndo
, ", sub-TLVs present"));
2022 if (afi
== AF_INET6
)
2023 ND_PRINT((ndo
, ", %s%s",
2024 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
2025 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : ""));
2028 if ((afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2030 || (afi
== AF_INET6
&& ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
))
2033 /* assume that one prefix can hold more
2034 than one subTLV - therefore the first byte must reflect
2035 the aggregate bytecount of the subTLVs for this prefix
2037 if (!ND_TTEST2(*tptr
, 1))
2040 processed
+=sublen
+1;
2041 ND_PRINT((ndo
, " (%u)", sublen
)); /* print out subTLV length */
2044 if (!ND_TTEST2(*tptr
,2))
2046 subtlvtype
=*(tptr
++);
2047 subtlvlen
=*(tptr
++);
2048 /* prepend the ident string */
2049 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
2050 if (!isis_print_ip_reach_subtlv(ndo
, tptr
, subtlvtype
, subtlvlen
, ident_buffer
))
2053 sublen
-=(subtlvlen
+2);
2061 * Decode IS-IS packets. Return 0 on error.
2065 isis_print(netdissect_options
*ndo
,
2066 const uint8_t *p
, u_int length
)
2068 const struct isis_common_header
*isis_header
;
2070 const struct isis_iih_lan_header
*header_iih_lan
;
2071 const struct isis_iih_ptp_header
*header_iih_ptp
;
2072 struct isis_lsp_header
*header_lsp
;
2073 const struct isis_csnp_header
*header_csnp
;
2074 const struct isis_psnp_header
*header_psnp
;
2076 const struct isis_tlv_lsp
*tlv_lsp
;
2077 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
2078 const struct isis_tlv_is_reach
*tlv_is_reach
;
2079 const struct isis_tlv_es_reach
*tlv_es_reach
;
2081 uint8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
2082 uint8_t ext_is_len
, ext_ip_len
, mt_len
;
2083 const uint8_t *optr
, *pptr
, *tptr
;
2084 u_short packet_len
,pdu_len
, key_id
;
2089 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
2090 need it for parsing the checksum TLV and authentication
2092 isis_header
= (const struct isis_common_header
*)p
;
2093 ND_TCHECK(*isis_header
);
2094 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
2095 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
2096 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
2097 header_lsp
= (struct isis_lsp_header
*)pptr
;
2098 header_csnp
= (const struct isis_csnp_header
*)pptr
;
2099 header_psnp
= (const struct isis_psnp_header
*)pptr
;
2101 if (!ndo
->ndo_eflag
)
2102 ND_PRINT((ndo
, "IS-IS"));
2105 * Sanity checking of the header.
2108 if (isis_header
->version
!= ISIS_VERSION
) {
2109 ND_PRINT((ndo
, "version %d packet not supported", isis_header
->version
));
2113 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
2114 ND_PRINT((ndo
, "system ID length of %d is not supported",
2115 isis_header
->id_length
));
2119 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
2120 ND_PRINT((ndo
, "version %d packet not supported", isis_header
->pdu_version
));
2124 max_area
= isis_header
->max_area
;
2127 max_area
= 3; /* silly shit */
2130 ND_PRINT((ndo
, "bad packet -- 255 areas"));
2136 id_length
= isis_header
->id_length
;
2139 id_length
= 6; /* silly shit again */
2141 case 1: /* 1-8 are valid sys-ID lenghts */
2151 id_length
= 0; /* entirely useless */
2157 /* toss any non 6-byte sys-ID len PDUs */
2158 if (id_length
!= 6 ) {
2159 ND_PRINT((ndo
, "bad packet -- illegal sys-ID length (%u)", id_length
));
2163 pdu_type
=isis_header
->pdu_type
;
2165 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
2166 if (ndo
->ndo_vflag
< 1) {
2167 ND_PRINT((ndo
, "%s%s",
2168 ndo
->ndo_eflag
? "" : ", ",
2169 tok2str(isis_pdu_values
, "unknown PDU-Type %u", pdu_type
)));
2173 case ISIS_PDU_L1_LAN_IIH
:
2174 case ISIS_PDU_L2_LAN_IIH
:
2175 ND_PRINT((ndo
, ", src-id %s",
2176 isis_print_id(header_iih_lan
->source_id
, SYSTEM_ID_LEN
)));
2177 ND_PRINT((ndo
, ", lan-id %s, prio %u",
2178 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
2179 header_iih_lan
->priority
));
2181 case ISIS_PDU_PTP_IIH
:
2182 ND_PRINT((ndo
, ", src-id %s", isis_print_id(header_iih_ptp
->source_id
, SYSTEM_ID_LEN
)));
2184 case ISIS_PDU_L1_LSP
:
2185 case ISIS_PDU_L2_LSP
:
2186 ND_PRINT((ndo
, ", lsp-id %s, seq 0x%08x, lifetime %5us",
2187 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
2188 EXTRACT_32BITS(header_lsp
->sequence_number
),
2189 EXTRACT_16BITS(header_lsp
->remaining_lifetime
)));
2191 case ISIS_PDU_L1_CSNP
:
2192 case ISIS_PDU_L2_CSNP
:
2193 ND_PRINT((ndo
, ", src-id %s", isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
)));
2195 case ISIS_PDU_L1_PSNP
:
2196 case ISIS_PDU_L2_PSNP
:
2197 ND_PRINT((ndo
, ", src-id %s", isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
)));
2201 ND_PRINT((ndo
, ", length %u", length
));
2206 /* ok they seem to want to know everything - lets fully decode it */
2207 ND_PRINT((ndo
, "%slength %u", ndo
->ndo_eflag
? "" : ", ", length
));
2209 ND_PRINT((ndo
, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
2210 tok2str(isis_pdu_values
,
2213 isis_header
->fixed_len
,
2214 isis_header
->version
,
2215 isis_header
->pdu_version
,
2217 isis_header
->id_length
,
2219 isis_header
->max_area
));
2221 if (ndo
->ndo_vflag
> 1) {
2222 if (!print_unknown_data(ndo
, optr
, "\n\t", 8)) /* provide the _o_riginal pointer */
2223 return(0); /* for optionally debugging the common header */
2228 case ISIS_PDU_L1_LAN_IIH
:
2229 case ISIS_PDU_L2_LAN_IIH
:
2230 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
2231 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2232 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
));
2236 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
2237 if (packet_len
>pdu_len
) {
2238 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2242 ND_TCHECK(*header_iih_lan
);
2243 ND_PRINT((ndo
, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
2244 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
2245 EXTRACT_16BITS(header_iih_lan
->holding_time
),
2246 tok2str(isis_iih_circuit_type_values
,
2247 "unknown circuit type 0x%02x",
2248 header_iih_lan
->circuit_type
)));
2250 ND_PRINT((ndo
, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
2251 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
2252 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
2255 if (ndo
->ndo_vflag
> 1) {
2256 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE
))
2260 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2261 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2264 case ISIS_PDU_PTP_IIH
:
2265 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
2266 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2267 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
));
2271 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
2272 if (packet_len
>pdu_len
) {
2273 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2277 ND_TCHECK(*header_iih_ptp
);
2278 ND_PRINT((ndo
, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
2279 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
2280 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
2281 tok2str(isis_iih_circuit_type_values
,
2282 "unknown circuit type 0x%02x",
2283 header_iih_ptp
->circuit_type
)));
2285 ND_PRINT((ndo
, "\n\t circuit-id: 0x%02x, PDU length: %u",
2286 header_iih_ptp
->circuit_id
,
2289 if (ndo
->ndo_vflag
> 1) {
2290 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE
))
2294 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2295 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2298 case ISIS_PDU_L1_LSP
:
2299 case ISIS_PDU_L2_LSP
:
2300 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
2301 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2302 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
));
2306 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
2307 if (packet_len
>pdu_len
) {
2308 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2312 ND_TCHECK(*header_lsp
);
2313 ND_PRINT((ndo
, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
2314 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
2315 EXTRACT_32BITS(header_lsp
->sequence_number
),
2316 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
2317 EXTRACT_16BITS(header_lsp
->checksum
)));
2320 osi_print_cksum(ndo
, (uint8_t *)header_lsp
->lsp_id
,
2321 EXTRACT_16BITS(header_lsp
->checksum
), 12, length
-12);
2324 * Clear checksum and lifetime prior to signature verification.
2326 header_lsp
->checksum
[0] = 0;
2327 header_lsp
->checksum
[1] = 0;
2328 header_lsp
->remaining_lifetime
[0] = 0;
2329 header_lsp
->remaining_lifetime
[1] = 0;
2332 ND_PRINT((ndo
, ", PDU length: %u, Flags: [ %s",
2334 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : ""));
2336 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
2337 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : ""));
2338 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : ""));
2339 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : ""));
2340 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : ""));
2341 ND_PRINT((ndo
, "ATT bit set, "));
2343 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : ""));
2344 ND_PRINT((ndo
, "%s ]", tok2str(isis_lsp_istype_values
, "Unknown(0x%x)",
2345 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
))));
2347 if (ndo
->ndo_vflag
> 1) {
2348 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_LSP_HEADER_SIZE
))
2352 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2353 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2356 case ISIS_PDU_L1_CSNP
:
2357 case ISIS_PDU_L2_CSNP
:
2358 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
2359 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2360 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
));
2364 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
2365 if (packet_len
>pdu_len
) {
2366 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2370 ND_TCHECK(*header_csnp
);
2371 ND_PRINT((ndo
, "\n\t source-id: %s, PDU length: %u",
2372 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
2374 ND_PRINT((ndo
, "\n\t start lsp-id: %s",
2375 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
)));
2376 ND_PRINT((ndo
, "\n\t end lsp-id: %s",
2377 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
)));
2379 if (ndo
->ndo_vflag
> 1) {
2380 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_CSNP_HEADER_SIZE
))
2384 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2385 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2388 case ISIS_PDU_L1_PSNP
:
2389 case ISIS_PDU_L2_PSNP
:
2390 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
2391 ND_PRINT((ndo
, "- bogus fixed header length %u should be %lu",
2392 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
));
2396 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
2397 if (packet_len
>pdu_len
) {
2398 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2402 ND_TCHECK(*header_psnp
);
2403 ND_PRINT((ndo
, "\n\t source-id: %s, PDU length: %u",
2404 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
2407 if (ndo
->ndo_vflag
> 1) {
2408 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_PSNP_HEADER_SIZE
))
2412 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2413 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2417 if (!print_unknown_data(ndo
, pptr
, "\n\t ", length
))
2423 * Now print the TLV's.
2426 while (packet_len
>= 2) {
2427 if (pptr
== ndo
->ndo_snapend
) {
2431 if (!ND_TTEST2(*pptr
, 2)) {
2432 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot (%ld) bytes",
2433 (long)(pptr
- ndo
->ndo_snapend
)));
2438 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
2441 if (tlv_len
> packet_len
) {
2445 /* first lets see if we know the TLVs name*/
2446 ND_PRINT((ndo
, "\n\t %s TLV #%u, length: %u",
2447 tok2str(isis_tlv_values
,
2453 if (tlv_len
== 0) /* something is malformed */
2456 /* now check if we have a decoder otherwise do a hexdump at the end*/
2458 case ISIS_TLV_AREA_ADDR
:
2459 if (!ND_TTEST2(*tptr
, 1))
2462 while (tmp
&& alen
< tmp
) {
2463 ND_PRINT((ndo
, "\n\t Area address (length: %u): %s",
2465 isonsap_string(tptr
, alen
)));
2468 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
2470 if (!ND_TTEST2(*tptr
, 1))
2475 case ISIS_TLV_ISNEIGH
:
2476 while (tmp
>= ETHER_ADDR_LEN
) {
2477 if (!ND_TTEST2(*tptr
, ETHER_ADDR_LEN
))
2479 ND_PRINT((ndo
, "\n\t SNPA: %s", isis_print_id(tptr
, ETHER_ADDR_LEN
)));
2480 tmp
-= ETHER_ADDR_LEN
;
2481 tptr
+= ETHER_ADDR_LEN
;
2485 case ISIS_TLV_ISNEIGH_VARLEN
:
2486 if (!ND_TTEST2(*tptr
, 1) || tmp
< 3) /* min. TLV length */
2488 lan_alen
= *tptr
++; /* LAN address length */
2489 if (lan_alen
== 0) {
2490 ND_PRINT((ndo
, "\n\t LAN address length 0 bytes (invalid)"));
2494 ND_PRINT((ndo
, "\n\t LAN address length %u bytes ", lan_alen
));
2495 while (tmp
>= lan_alen
) {
2496 if (!ND_TTEST2(*tptr
, lan_alen
))
2498 ND_PRINT((ndo
, "\n\t\tIS Neighbor: %s", isis_print_id(tptr
, lan_alen
)));
2504 case ISIS_TLV_PADDING
:
2507 case ISIS_TLV_MT_IS_REACH
:
2508 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2509 if (mt_len
== 0) /* did something go wrong ? */
2513 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
2514 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
);
2515 if (ext_is_len
== 0) /* did something go wrong ? */
2523 case ISIS_TLV_IS_ALIAS_ID
:
2524 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
2525 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
);
2526 if (ext_is_len
== 0) /* did something go wrong ? */
2533 case ISIS_TLV_EXT_IS_REACH
:
2534 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
2535 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
);
2536 if (ext_is_len
== 0) /* did something go wrong ? */
2542 case ISIS_TLV_IS_REACH
:
2543 if (!ND_TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
2545 ND_PRINT((ndo
, "\n\t %s",
2546 tok2str(isis_is_reach_virtual_values
,
2547 "bogus virtual flag 0x%02x",
2549 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
2550 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
2551 if (!ND_TTEST(*tlv_is_reach
))
2553 ND_PRINT((ndo
, "\n\t IS Neighbor: %s",
2554 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
)));
2555 isis_print_metric_block(ndo
, &tlv_is_reach
->isis_metric_block
);
2556 tmp
-= sizeof(struct isis_tlv_is_reach
);
2561 case ISIS_TLV_ESNEIGH
:
2562 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
2563 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
2564 if (!ND_TTEST(*tlv_es_reach
))
2566 ND_PRINT((ndo
, "\n\t ES Neighbor: %s",
2567 isis_print_id(tlv_es_reach
->neighbor_sysid
, SYSTEM_ID_LEN
)));
2568 isis_print_metric_block(ndo
, &tlv_es_reach
->isis_metric_block
);
2569 tmp
-= sizeof(struct isis_tlv_es_reach
);
2574 /* those two TLVs share the same format */
2575 case ISIS_TLV_INT_IP_REACH
:
2576 case ISIS_TLV_EXT_IP_REACH
:
2577 if (!isis_print_tlv_ip_reach(ndo
, pptr
, "\n\t ", tlv_len
))
2581 case ISIS_TLV_EXTD_IP_REACH
:
2583 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET
);
2584 if (ext_ip_len
== 0) /* did something go wrong ? */
2591 case ISIS_TLV_MT_IP_REACH
:
2592 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2593 if (mt_len
== 0) { /* did something go wrong ? */
2600 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET
);
2601 if (ext_ip_len
== 0) /* did something go wrong ? */
2609 case ISIS_TLV_IP6_REACH
:
2611 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET6
);
2612 if (ext_ip_len
== 0) /* did something go wrong ? */
2619 case ISIS_TLV_MT_IP6_REACH
:
2620 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2621 if (mt_len
== 0) { /* did something go wrong ? */
2628 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET6
);
2629 if (ext_ip_len
== 0) /* did something go wrong ? */
2636 case ISIS_TLV_IP6ADDR
:
2637 while (tmp
>=sizeof(struct in6_addr
)) {
2638 if (!ND_TTEST2(*tptr
, sizeof(struct in6_addr
)))
2641 ND_PRINT((ndo
, "\n\t IPv6 interface address: %s",
2642 ip6addr_string(ndo
, tptr
)));
2644 tptr
+= sizeof(struct in6_addr
);
2645 tmp
-= sizeof(struct in6_addr
);
2650 if (!ND_TTEST2(*tptr
, 1))
2653 ND_PRINT((ndo
, "\n\t %s: ",
2654 tok2str(isis_subtlv_auth_values
,
2655 "unknown Authentication type 0x%02x",
2659 case ISIS_SUBTLV_AUTH_SIMPLE
:
2660 for(i
=1;i
<tlv_len
;i
++) {
2661 if (!ND_TTEST2(*(tptr
+ i
), 1))
2663 ND_PRINT((ndo
, "%c", *(tptr
+ i
)));
2666 case ISIS_SUBTLV_AUTH_MD5
:
2667 for(i
=1;i
<tlv_len
;i
++) {
2668 if (!ND_TTEST2(*(tptr
+ i
), 1))
2670 ND_PRINT((ndo
, "%02x", *(tptr
+ i
)));
2672 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
2673 ND_PRINT((ndo
, ", (malformed subTLV) "));
2675 #ifdef HAVE_LIBCRYPTO
2676 sigcheck
= signature_verify(ndo
, optr
, length
,
2677 (unsigned char *)tptr
+ 1);
2679 sigcheck
= CANT_CHECK_SIGNATURE
;
2681 ND_PRINT((ndo
, " (%s)", tok2str(signature_check_values
, "Unknown", sigcheck
)));
2684 case ISIS_SUBTLV_AUTH_GENERIC
:
2685 key_id
= EXTRACT_16BITS((tptr
+1));
2686 ND_PRINT((ndo
, "%u, password: ", key_id
));
2687 for(i
=1 + sizeof(uint16_t);i
<tlv_len
;i
++) {
2688 if (!ND_TTEST2(*(tptr
+ i
), 1))
2690 ND_PRINT((ndo
, "%02x", *(tptr
+ i
)));
2693 case ISIS_SUBTLV_AUTH_PRIVATE
:
2695 if (!print_unknown_data(ndo
, tptr
+ 1, "\n\t\t ", tlv_len
- 1))
2701 case ISIS_TLV_PTP_ADJ
:
2702 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
2704 if (!ND_TTEST2(*tptr
, 1))
2706 ND_PRINT((ndo
, "\n\t Adjacency State: %s (%u)",
2707 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
2711 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
2712 if (!ND_TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
2713 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
2715 ND_PRINT((ndo
, "\n\t Extended Local circuit-ID: 0x%08x",
2716 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
)));
2717 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
2719 if(tmp
>=SYSTEM_ID_LEN
) {
2720 if (!ND_TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
2722 ND_PRINT((ndo
, "\n\t Neighbor System-ID: %s",
2723 isis_print_id(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
)));
2726 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
2727 if (!ND_TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
2728 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
2730 ND_PRINT((ndo
, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2731 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)));
2735 case ISIS_TLV_PROTOCOLS
:
2736 ND_PRINT((ndo
, "\n\t NLPID(s): "));
2738 if (!ND_TTEST2(*(tptr
), 1))
2740 ND_PRINT((ndo
, "%s (0x%02x)",
2741 tok2str(nlpid_values
,
2745 if (tmp
>1) /* further NPLIDs ? - put comma */
2746 ND_PRINT((ndo
, ", "));
2752 case ISIS_TLV_MT_PORT_CAP
:
2754 if (!ND_TTEST2(*(tptr
), 2))
2757 ND_PRINT((ndo
, "\n\t RES: %d, MTID(s): %d",
2758 (EXTRACT_16BITS (tptr
) >> 12),
2759 (EXTRACT_16BITS (tptr
) & 0x0fff)));
2765 isis_print_mt_port_cap_subtlv(ndo
, tptr
, tmp
);
2770 case ISIS_TLV_MT_CAPABILITY
:
2772 if (!ND_TTEST2(*(tptr
), 2))
2775 ND_PRINT((ndo
, "\n\t O: %d, RES: %d, MTID(s): %d",
2776 (EXTRACT_16BITS(tptr
) >> 15) & 0x01,
2777 (EXTRACT_16BITS(tptr
) >> 12) & 0x07,
2778 EXTRACT_16BITS(tptr
) & 0x0fff));
2784 isis_print_mt_capability_subtlv(ndo
, tptr
, tmp
);
2788 case ISIS_TLV_TE_ROUTER_ID
:
2789 if (!ND_TTEST2(*pptr
, sizeof(struct in_addr
)))
2791 ND_PRINT((ndo
, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo
, pptr
)));
2794 case ISIS_TLV_IPADDR
:
2795 while (tmp
>=sizeof(struct in_addr
)) {
2796 if (!ND_TTEST2(*tptr
, sizeof(struct in_addr
)))
2798 ND_PRINT((ndo
, "\n\t IPv4 interface address: %s", ipaddr_string(ndo
, tptr
)));
2799 tptr
+= sizeof(struct in_addr
);
2800 tmp
-= sizeof(struct in_addr
);
2804 case ISIS_TLV_HOSTNAME
:
2805 ND_PRINT((ndo
, "\n\t Hostname: "));
2807 if (!ND_TTEST2(*tptr
, 1))
2809 ND_PRINT((ndo
, "%c", *tptr
++));
2814 case ISIS_TLV_SHARED_RISK_GROUP
:
2815 if (tmp
< NODE_ID_LEN
)
2817 if (!ND_TTEST2(*tptr
, NODE_ID_LEN
))
2819 ND_PRINT((ndo
, "\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
)));
2820 tptr
+=(NODE_ID_LEN
);
2825 if (!ND_TTEST2(*tptr
, 1))
2827 ND_PRINT((ndo
, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered"));
2830 if (tmp
< sizeof(struct in_addr
))
2832 if (!ND_TTEST2(*tptr
, sizeof(struct in_addr
)))
2834 ND_PRINT((ndo
, "\n\t IPv4 interface address: %s", ipaddr_string(ndo
, tptr
)));
2835 tptr
+=sizeof(struct in_addr
);
2836 tmp
-=sizeof(struct in_addr
);
2838 if (tmp
< sizeof(struct in_addr
))
2840 if (!ND_TTEST2(*tptr
, sizeof(struct in_addr
)))
2842 ND_PRINT((ndo
, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo
, tptr
)));
2843 tptr
+=sizeof(struct in_addr
);
2844 tmp
-=sizeof(struct in_addr
);
2847 if (!ND_TTEST2(*tptr
, 4))
2849 ND_PRINT((ndo
, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
)));
2856 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2857 while(tmp
>=sizeof(struct isis_tlv_lsp
)) {
2858 if (!ND_TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2860 ND_PRINT((ndo
, "\n\t lsp-id: %s",
2861 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
)));
2862 if (!ND_TTEST2(tlv_lsp
->sequence_number
, 4))
2864 ND_PRINT((ndo
, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp
->sequence_number
)));
2865 if (!ND_TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2867 ND_PRINT((ndo
, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
)));
2868 if (!ND_TTEST2(tlv_lsp
->checksum
, 2))
2870 ND_PRINT((ndo
, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp
->checksum
)));
2871 tmp
-=sizeof(struct isis_tlv_lsp
);
2876 case ISIS_TLV_CHECKSUM
:
2877 if (tmp
< ISIS_TLV_CHECKSUM_MINLEN
)
2879 if (!ND_TTEST2(*tptr
, ISIS_TLV_CHECKSUM_MINLEN
))
2881 ND_PRINT((ndo
, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
)));
2882 /* do not attempt to verify the checksum if it is zero
2883 * most likely a HMAC-MD5 TLV is also present and
2884 * to avoid conflicts the checksum TLV is zeroed.
2885 * see rfc3358 for details
2887 osi_print_cksum(ndo
, optr
, EXTRACT_16BITS(tptr
), tptr
-optr
, length
);
2890 case ISIS_TLV_MT_SUPPORTED
:
2891 if (tmp
< ISIS_TLV_MT_SUPPORTED_MINLEN
)
2894 /* length can only be a multiple of 2, otherwise there is
2895 something broken -> so decode down until length is 1 */
2897 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2898 if (mt_len
== 0) /* did something go wrong ? */
2903 ND_PRINT((ndo
, "\n\t malformed MT-ID"));
2909 case ISIS_TLV_RESTART_SIGNALING
:
2910 /* first attempt to decode the flags */
2911 if (tmp
< ISIS_TLV_RESTART_SIGNALING_FLAGLEN
)
2913 if (!ND_TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_FLAGLEN
))
2915 ND_PRINT((ndo
, "\n\t Flags [%s]",
2916 bittok2str(isis_restart_flag_values
, "none", *tptr
)));
2917 tptr
+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2918 tmp
-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2920 /* is there anything other than the flags field? */
2924 if (tmp
< ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
)
2926 if (!ND_TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
))
2929 ND_PRINT((ndo
, ", Remaining holding time %us", EXTRACT_16BITS(tptr
)));
2930 tptr
+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2931 tmp
-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2933 /* is there an additional sysid field present ?*/
2934 if (tmp
== SYSTEM_ID_LEN
) {
2935 if (!ND_TTEST2(*tptr
, SYSTEM_ID_LEN
))
2937 ND_PRINT((ndo
, ", for %s", isis_print_id(tptr
,SYSTEM_ID_LEN
)));
2941 case ISIS_TLV_IDRP_INFO
:
2942 if (tmp
< ISIS_TLV_IDRP_INFO_MINLEN
)
2944 if (!ND_TTEST2(*tptr
, ISIS_TLV_IDRP_INFO_MINLEN
))
2946 ND_PRINT((ndo
, "\n\t Inter-Domain Information Type: %s",
2947 tok2str(isis_subtlv_idrp_values
,
2951 case ISIS_SUBTLV_IDRP_ASN
:
2952 if (!ND_TTEST2(*tptr
, 2)) /* fetch AS number */
2954 ND_PRINT((ndo
, "AS Number: %u", EXTRACT_16BITS(tptr
)));
2956 case ISIS_SUBTLV_IDRP_LOCAL
:
2957 case ISIS_SUBTLV_IDRP_RES
:
2959 if (!print_unknown_data(ndo
, tptr
, "\n\t ", tlv_len
- 1))
2965 case ISIS_TLV_LSP_BUFFERSIZE
:
2966 if (tmp
< ISIS_TLV_LSP_BUFFERSIZE_MINLEN
)
2968 if (!ND_TTEST2(*tptr
, ISIS_TLV_LSP_BUFFERSIZE_MINLEN
))
2970 ND_PRINT((ndo
, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr
)));
2973 case ISIS_TLV_PART_DIS
:
2974 while (tmp
>= SYSTEM_ID_LEN
) {
2975 if (!ND_TTEST2(*tptr
, SYSTEM_ID_LEN
))
2977 ND_PRINT((ndo
, "\n\t %s", isis_print_id(tptr
, SYSTEM_ID_LEN
)));
2978 tptr
+=SYSTEM_ID_LEN
;
2983 case ISIS_TLV_PREFIX_NEIGH
:
2984 if (tmp
< sizeof(struct isis_metric_block
))
2986 if (!ND_TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2988 ND_PRINT((ndo
, "\n\t Metric Block"));
2989 isis_print_metric_block(ndo
, (const struct isis_metric_block
*)tptr
);
2990 tptr
+=sizeof(struct isis_metric_block
);
2991 tmp
-=sizeof(struct isis_metric_block
);
2994 if (!ND_TTEST2(*tptr
, 1))
2996 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2997 if (prefix_len
< 2) {
2998 ND_PRINT((ndo
, "\n\t\tAddress: prefix length %u < 2", prefix_len
));
3002 if (tmp
< prefix_len
/2)
3004 if (!ND_TTEST2(*tptr
, prefix_len
/ 2))
3006 ND_PRINT((ndo
, "\n\t\tAddress: %s/%u",
3007 isonsap_string(tptr
, prefix_len
/ 2), prefix_len
* 4));
3013 case ISIS_TLV_IIH_SEQNR
:
3014 if (tmp
< ISIS_TLV_IIH_SEQNR_MINLEN
)
3016 if (!ND_TTEST2(*tptr
, ISIS_TLV_IIH_SEQNR_MINLEN
)) /* check if four bytes are on the wire */
3018 ND_PRINT((ndo
, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr
)));
3021 case ISIS_TLV_VENDOR_PRIVATE
:
3022 if (tmp
< ISIS_TLV_VENDOR_PRIVATE_MINLEN
)
3024 if (!ND_TTEST2(*tptr
, ISIS_TLV_VENDOR_PRIVATE_MINLEN
)) /* check if enough byte for a full oui */
3026 vendor_id
= EXTRACT_24BITS(tptr
);
3027 ND_PRINT((ndo
, "\n\t Vendor: %s (%u)",
3028 tok2str(oui_values
, "Unknown", vendor_id
),
3032 if (tmp
> 0) /* hexdump the rest */
3033 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", tmp
))
3037 * FIXME those are the defined TLVs that lack a decoder
3038 * you are welcome to contribute code ;-)
3041 case ISIS_TLV_DECNET_PHASE4
:
3042 case ISIS_TLV_LUCENT_PRIVATE
:
3043 case ISIS_TLV_IPAUTH
:
3044 case ISIS_TLV_NORTEL_PRIVATE1
:
3045 case ISIS_TLV_NORTEL_PRIVATE2
:
3048 if (ndo
->ndo_vflag
<= 1) {
3049 if (!print_unknown_data(ndo
, pptr
, "\n\t\t", tlv_len
))
3054 /* do we want to see an additionally hexdump ? */
3055 if (ndo
->ndo_vflag
> 1) {
3056 if (!print_unknown_data(ndo
, pptr
, "\n\t ", tlv_len
))
3061 packet_len
-= tlv_len
;
3064 if (packet_len
!= 0) {
3065 ND_PRINT((ndo
, "\n\t %u straggler bytes", packet_len
));
3070 ND_PRINT((ndo
, "[|isis]"));
3074 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot"));
3079 osi_print_cksum(netdissect_options
*ndo
,
3080 const uint8_t *pptr
, uint16_t checksum
,
3081 u_int checksum_offset
, u_int length
)
3083 uint16_t calculated_checksum
;
3085 /* do not attempt to verify the checksum if it is zero */
3087 ND_PRINT((ndo
, "(unverified)"));
3089 calculated_checksum
= create_osi_cksum(pptr
, checksum_offset
, length
);
3090 if (checksum
== calculated_checksum
) {
3091 ND_PRINT((ndo
, " (correct)"));
3093 ND_PRINT((ndo
, " (incorrect should be 0x%04x)", calculated_checksum
));
3100 * c-style: whitesmith