2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * Original code by Matt Thomas, Digital Equipment Corporation
23 * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
24 * complete IS-IS & CLNP support.
31 #include <tcpdump-stdinc.h>
35 #include "interface.h"
36 #include "addrtoname.h"
42 #include "signature.h"
45 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
48 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
49 #define NODE_ID_LEN SYSTEM_ID_LEN+1
50 #define LSP_ID_LEN SYSTEM_ID_LEN+2
52 #define ISIS_VERSION 1
53 #define ESIS_VERSION 1
54 #define CLNP_VERSION 1
56 #define ISIS_PDU_TYPE_MASK 0x1F
57 #define ESIS_PDU_TYPE_MASK 0x1F
58 #define CLNP_PDU_TYPE_MASK 0x1F
59 #define CLNP_FLAG_MASK 0xE0
60 #define ISIS_LAN_PRIORITY_MASK 0x7F
62 #define ISIS_PDU_L1_LAN_IIH 15
63 #define ISIS_PDU_L2_LAN_IIH 16
64 #define ISIS_PDU_PTP_IIH 17
65 #define ISIS_PDU_L1_LSP 18
66 #define ISIS_PDU_L2_LSP 20
67 #define ISIS_PDU_L1_CSNP 24
68 #define ISIS_PDU_L2_CSNP 25
69 #define ISIS_PDU_L1_PSNP 26
70 #define ISIS_PDU_L2_PSNP 27
72 static const struct tok isis_pdu_values
[] = {
73 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
74 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
75 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
76 { ISIS_PDU_L1_LSP
, "L1 LSP"},
77 { ISIS_PDU_L2_LSP
, "L2 LSP"},
78 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
79 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
80 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
81 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
86 * A TLV is a tuple of a type, length and a value and is normally used for
87 * encoding information in all sorts of places. This is an enumeration of
88 * the well known types.
90 * list taken from rfc3359 plus some memory from veterans ;-)
93 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
94 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
95 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
96 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
97 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
98 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
99 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
100 #define ISIS_TLV_PADDING 8 /* iso10589 */
101 #define ISIS_TLV_LSP 9 /* iso10589 */
102 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
103 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
104 #define ISIS_TLV_CHECKSUM_MINLEN 2
105 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
106 #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
107 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
108 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
109 #define ISIS_TLV_DECNET_PHASE4 42
110 #define ISIS_TLV_LUCENT_PRIVATE 66
111 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
112 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
113 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
114 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
115 #define ISIS_TLV_IDRP_INFO_MINLEN 1
116 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
117 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
118 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
119 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
120 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
121 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
122 #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
123 #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
124 #define ISIS_TLV_NORTEL_PRIVATE1 176
125 #define ISIS_TLV_NORTEL_PRIVATE2 177
126 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
127 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
128 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
129 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
130 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
131 #define ISIS_TLV_MT_SUPPORTED_MINLEN 2
132 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
133 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
134 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
135 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
136 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
137 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
138 #define ISIS_TLV_IIH_SEQNR_MINLEN 4
139 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
140 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
142 static const struct tok isis_tlv_values
[] = {
143 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
144 { ISIS_TLV_IS_REACH
, "IS Reachability"},
145 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
146 { ISIS_TLV_PART_DIS
, "Partition DIS"},
147 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
148 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
149 { ISIS_TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
150 { ISIS_TLV_PADDING
, "Padding"},
151 { ISIS_TLV_LSP
, "LSP entries"},
152 { ISIS_TLV_AUTH
, "Authentication"},
153 { ISIS_TLV_CHECKSUM
, "Checksum"},
154 { ISIS_TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
155 { ISIS_TLV_EXT_IS_REACH
, "Extended IS Reachability"},
156 { ISIS_TLV_IS_ALIAS_ID
, "IS Alias ID"},
157 { ISIS_TLV_DECNET_PHASE4
, "DECnet Phase IV"},
158 { ISIS_TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
159 { ISIS_TLV_INT_IP_REACH
, "IPv4 Internal Reachability"},
160 { ISIS_TLV_PROTOCOLS
, "Protocols supported"},
161 { ISIS_TLV_EXT_IP_REACH
, "IPv4 External Reachability"},
162 { ISIS_TLV_IDRP_INFO
, "Inter-Domain Information Type"},
163 { ISIS_TLV_IPADDR
, "IPv4 Interface address(es)"},
164 { ISIS_TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
165 { ISIS_TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
166 { ISIS_TLV_EXTD_IP_REACH
, "Extended IPv4 Reachability"},
167 { ISIS_TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
168 { ISIS_TLV_MT_PORT_CAP
, "Multi-Topology-Aware Port Capability"},
169 { ISIS_TLV_MT_CAPABILITY
, "Multi-Topology Capability"},
170 { ISIS_TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
171 { ISIS_TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
172 { ISIS_TLV_HOSTNAME
, "Hostname"},
173 { ISIS_TLV_RESTART_SIGNALING
, "Restart Signaling"},
174 { ISIS_TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
175 { ISIS_TLV_MT_SUPPORTED
, "Multi Topology"},
176 { ISIS_TLV_IP6ADDR
, "IPv6 Interface address(es)"},
177 { ISIS_TLV_MT_IP_REACH
, "Multi-Topology IPv4 Reachability"},
178 { ISIS_TLV_IP6_REACH
, "IPv6 reachability"},
179 { ISIS_TLV_MT_IP6_REACH
, "Multi-Topology IP6 Reachability"},
180 { ISIS_TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
181 { ISIS_TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
182 { ISIS_TLV_VENDOR_PRIVATE
, "Vendor Private"},
186 #define ESIS_OPTION_PROTOCOLS 129
187 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
188 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
189 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
190 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
191 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
192 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
194 static const struct tok esis_option_values
[] = {
195 { ESIS_OPTION_PROTOCOLS
, "Protocols supported"},
196 { ESIS_OPTION_QOS_MAINTENANCE
, "QoS Maintenance" },
197 { ESIS_OPTION_SECURITY
, "Security" },
198 { ESIS_OPTION_ES_CONF_TIME
, "ES Configuration Time" },
199 { ESIS_OPTION_PRIORITY
, "Priority" },
200 { ESIS_OPTION_ADDRESS_MASK
, "Addressk Mask" },
201 { ESIS_OPTION_SNPA_MASK
, "SNPA Mask" },
205 #define CLNP_OPTION_DISCARD_REASON 193
206 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
207 #define CLNP_OPTION_SECURITY 197 /* iso8473 */
208 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
209 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
210 #define CLNP_OPTION_PADDING 204 /* iso8473 */
211 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
213 static const struct tok clnp_option_values
[] = {
214 { CLNP_OPTION_DISCARD_REASON
, "Discard Reason"},
215 { CLNP_OPTION_PRIORITY
, "Priority"},
216 { CLNP_OPTION_QOS_MAINTENANCE
, "QoS Maintenance"},
217 { CLNP_OPTION_SECURITY
, "Security"},
218 { CLNP_OPTION_SOURCE_ROUTING
, "Source Routing"},
219 { CLNP_OPTION_ROUTE_RECORDING
, "Route Recording"},
220 { CLNP_OPTION_PADDING
, "Padding"},
224 static const struct tok clnp_option_rfd_class_values
[] = {
227 { 0x9, "Source Routeing"},
229 { 0xb, "PDU Discarded"},
230 { 0xc, "Reassembly"},
234 static const struct tok clnp_option_rfd_general_values
[] = {
235 { 0x0, "Reason not specified"},
236 { 0x1, "Protocol procedure error"},
237 { 0x2, "Incorrect checksum"},
238 { 0x3, "PDU discarded due to congestion"},
239 { 0x4, "Header syntax error (cannot be parsed)"},
240 { 0x5, "Segmentation needed but not permitted"},
241 { 0x6, "Incomplete PDU received"},
242 { 0x7, "Duplicate option"},
246 static const struct tok clnp_option_rfd_address_values
[] = {
247 { 0x0, "Destination address unreachable"},
248 { 0x1, "Destination address unknown"},
252 static const struct tok clnp_option_rfd_source_routeing_values
[] = {
253 { 0x0, "Unspecified source routeing error"},
254 { 0x1, "Syntax error in source routeing field"},
255 { 0x2, "Unknown address in source routeing field"},
256 { 0x3, "Path not acceptable"},
260 static const struct tok clnp_option_rfd_lifetime_values
[] = {
261 { 0x0, "Lifetime expired while data unit in transit"},
262 { 0x1, "Lifetime expired during reassembly"},
266 static const struct tok clnp_option_rfd_pdu_discard_values
[] = {
267 { 0x0, "Unsupported option not specified"},
268 { 0x1, "Unsupported protocol version"},
269 { 0x2, "Unsupported security option"},
270 { 0x3, "Unsupported source routeing option"},
271 { 0x4, "Unsupported recording of route option"},
275 static const struct tok clnp_option_rfd_reassembly_values
[] = {
276 { 0x0, "Reassembly interference"},
280 /* array of 16 error-classes */
281 static const struct tok
*clnp_option_rfd_error_class
[] = {
282 clnp_option_rfd_general_values
,
290 clnp_option_rfd_address_values
,
291 clnp_option_rfd_source_routeing_values
,
292 clnp_option_rfd_lifetime_values
,
293 clnp_option_rfd_pdu_discard_values
,
294 clnp_option_rfd_reassembly_values
,
300 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
301 #define CLNP_OPTION_SCOPE_MASK 0xc0
302 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
303 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
304 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
306 static const struct tok clnp_option_scope_values
[] = {
307 { CLNP_OPTION_SCOPE_SA_SPEC
, "Source Address Specific"},
308 { CLNP_OPTION_SCOPE_DA_SPEC
, "Destination Address Specific"},
309 { CLNP_OPTION_SCOPE_GLOBAL
, "Globally unique"},
313 static const struct tok clnp_option_sr_rr_values
[] = {
319 static const struct tok clnp_option_sr_rr_string_values
[] = {
320 { CLNP_OPTION_SOURCE_ROUTING
, "source routing"},
321 { CLNP_OPTION_ROUTE_RECORDING
, "recording of route in progress"},
325 static const struct tok clnp_option_qos_global_values
[] = {
327 { 0x10, "sequencing vs. delay"},
328 { 0x08, "congested"},
329 { 0x04, "delay vs. cost"},
330 { 0x02, "error vs. delay"},
331 { 0x01, "error vs. cost"},
335 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
336 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */
337 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
338 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
339 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
340 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
341 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
342 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
343 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
344 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
345 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
346 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
347 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
348 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
350 #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
352 static const struct tok isis_ext_is_reach_subtlv_values
[] = {
353 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
354 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
355 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
356 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
357 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
358 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
359 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
360 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
361 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
362 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
, "Link Attribute" },
363 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
364 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
365 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
, "Bandwidth Constraints (old)" },
366 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
, "Bandwidth Constraints" },
367 { ISIS_SUBTLV_SPB_METRIC
, "SPB Metric" },
368 { 250, "Reserved for cisco specific extensions" },
369 { 251, "Reserved for cisco specific extensions" },
370 { 252, "Reserved for cisco specific extensions" },
371 { 253, "Reserved for cisco specific extensions" },
372 { 254, "Reserved for cisco specific extensions" },
373 { 255, "Reserved for future expansion" },
377 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
378 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
379 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
381 static const struct tok isis_ext_ip_reach_subtlv_values
[] = {
382 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
383 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
384 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
388 static const struct tok isis_subtlv_link_attribute_values
[] = {
389 { 0x01, "Local Protection Available" },
390 { 0x02, "Link excluded from local protection path" },
391 { 0x04, "Local maintenance required"},
395 #define ISIS_SUBTLV_AUTH_SIMPLE 1
396 #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
397 #define ISIS_SUBTLV_AUTH_MD5 54
398 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
399 #define ISIS_SUBTLV_AUTH_PRIVATE 255
401 static const struct tok isis_subtlv_auth_values
[] = {
402 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
403 { ISIS_SUBTLV_AUTH_GENERIC
, "Generic Crypto key-id"},
404 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
405 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
409 #define ISIS_SUBTLV_IDRP_RES 0
410 #define ISIS_SUBTLV_IDRP_LOCAL 1
411 #define ISIS_SUBTLV_IDRP_ASN 2
413 static const struct tok isis_subtlv_idrp_values
[] = {
414 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
415 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
416 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
420 #define ISIS_SUBTLV_SPB_MCID 4
421 #define ISIS_SUBTLV_SPB_DIGEST 5
422 #define ISIS_SUBTLV_SPB_BVID 6
424 #define ISIS_SUBTLV_SPB_INSTANCE 1
425 #define ISIS_SUBTLV_SPBM_SI 3
427 #define ISIS_SPB_MCID_LEN 51
428 #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
429 #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
430 #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
431 #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
432 #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
434 static const struct tok isis_mt_port_cap_subtlv_values
[] = {
435 { ISIS_SUBTLV_SPB_MCID
, "SPB MCID" },
436 { ISIS_SUBTLV_SPB_DIGEST
, "SPB Digest" },
437 { ISIS_SUBTLV_SPB_BVID
, "SPB BVID" },
441 static const struct tok isis_mt_capability_subtlv_values
[] = {
442 { ISIS_SUBTLV_SPB_INSTANCE
, "SPB Instance" },
443 { ISIS_SUBTLV_SPBM_SI
, "SPBM Service Identifier and Unicast Address" },
447 struct isis_spb_mcid
{
450 uint8_t revision_lvl
[2];
454 struct isis_subtlv_spb_mcid
{
455 struct isis_spb_mcid mcid
;
456 struct isis_spb_mcid aux_mcid
;
459 struct isis_subtlv_spb_instance
{
460 uint8_t cist_root_id
[8];
461 uint8_t cist_external_root_path_cost
[4];
462 uint8_t bridge_priority
[2];
463 uint8_t spsourceid
[4];
467 #define CLNP_SEGMENT_PART 0x80
468 #define CLNP_MORE_SEGMENTS 0x40
469 #define CLNP_REQUEST_ER 0x20
471 static const struct tok clnp_flag_values
[] = {
472 { CLNP_SEGMENT_PART
, "Segmentation permitted"},
473 { CLNP_MORE_SEGMENTS
, "more Segments"},
474 { CLNP_REQUEST_ER
, "request Error Report"},
478 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
479 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
480 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
481 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
482 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
483 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
484 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
485 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
487 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
488 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
490 static const struct tok isis_mt_flag_values
[] = {
491 { 0x4000, "ATT bit set"},
492 { 0x8000, "Overload bit set"},
496 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
497 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
499 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
500 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
502 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
503 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
504 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
505 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
507 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
509 static const struct tok isis_mt_values
[] = {
510 { 0, "IPv4 unicast"},
511 { 1, "In-Band Management"},
512 { 2, "IPv6 unicast"},
514 { 4095, "Development, Experimental or Proprietary"},
518 static const struct tok isis_iih_circuit_type_values
[] = {
519 { 1, "Level 1 only"},
520 { 2, "Level 2 only"},
521 { 3, "Level 1, Level 2"},
525 #define ISIS_LSP_TYPE_UNUSED0 0
526 #define ISIS_LSP_TYPE_LEVEL_1 1
527 #define ISIS_LSP_TYPE_UNUSED2 2
528 #define ISIS_LSP_TYPE_LEVEL_2 3
530 static const struct tok isis_lsp_istype_values
[] = {
531 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
532 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
533 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
534 { ISIS_LSP_TYPE_LEVEL_2
, "L2 IS"},
539 * Katz's point to point adjacency TLV uses codes to tell us the state of
540 * the remote adjacency. Enumerate them.
543 #define ISIS_PTP_ADJ_UP 0
544 #define ISIS_PTP_ADJ_INIT 1
545 #define ISIS_PTP_ADJ_DOWN 2
547 static const struct tok isis_ptp_adjancey_values
[] = {
548 { ISIS_PTP_ADJ_UP
, "Up" },
549 { ISIS_PTP_ADJ_INIT
, "Initializing" },
550 { ISIS_PTP_ADJ_DOWN
, "Down" },
554 struct isis_tlv_ptp_adj
{
555 uint8_t adjacency_state
;
556 uint8_t extd_local_circuit_id
[4];
557 uint8_t neighbor_sysid
[SYSTEM_ID_LEN
];
558 uint8_t neighbor_extd_local_circuit_id
[4];
561 static void osi_print_cksum(netdissect_options
*, const uint8_t *pptr
, uint16_t checksum
,
562 u_int checksum_offset
, u_int length
);
563 static int clnp_print(netdissect_options
*, const uint8_t *, u_int
);
564 static void esis_print(netdissect_options
*, const uint8_t *, u_int
);
565 static int isis_print(netdissect_options
*, const uint8_t *, u_int
);
567 struct isis_metric_block
{
568 uint8_t metric_default
;
569 uint8_t metric_delay
;
570 uint8_t metric_expense
;
571 uint8_t metric_error
;
574 struct isis_tlv_is_reach
{
575 struct isis_metric_block isis_metric_block
;
576 uint8_t neighbor_nodeid
[NODE_ID_LEN
];
579 struct isis_tlv_es_reach
{
580 struct isis_metric_block isis_metric_block
;
581 uint8_t neighbor_sysid
[SYSTEM_ID_LEN
];
584 struct isis_tlv_ip_reach
{
585 struct isis_metric_block isis_metric_block
;
590 static const struct tok isis_is_reach_virtual_values
[] = {
591 { 0, "IsNotVirtual"},
596 static const struct tok isis_restart_flag_values
[] = {
597 { 0x1, "Restart Request"},
598 { 0x2, "Restart Acknowledgement"},
599 { 0x4, "Suppress adjacency advertisement"},
603 struct isis_common_header
{
606 uint8_t version
; /* Protocol version */
608 uint8_t pdu_type
; /* 3 MSbits are reserved */
609 uint8_t pdu_version
; /* Packet format version */
614 struct isis_iih_lan_header
{
615 uint8_t circuit_type
;
616 uint8_t source_id
[SYSTEM_ID_LEN
];
617 uint8_t holding_time
[2];
620 uint8_t lan_id
[NODE_ID_LEN
];
623 struct isis_iih_ptp_header
{
624 uint8_t circuit_type
;
625 uint8_t source_id
[SYSTEM_ID_LEN
];
626 uint8_t holding_time
[2];
631 struct isis_lsp_header
{
633 uint8_t remaining_lifetime
[2];
634 uint8_t lsp_id
[LSP_ID_LEN
];
635 uint8_t sequence_number
[4];
640 struct isis_csnp_header
{
642 uint8_t source_id
[NODE_ID_LEN
];
643 uint8_t start_lsp_id
[LSP_ID_LEN
];
644 uint8_t end_lsp_id
[LSP_ID_LEN
];
647 struct isis_psnp_header
{
649 uint8_t source_id
[NODE_ID_LEN
];
652 struct isis_tlv_lsp
{
653 uint8_t remaining_lifetime
[2];
654 uint8_t lsp_id
[LSP_ID_LEN
];
655 uint8_t sequence_number
[4];
659 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
660 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
661 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
662 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
663 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
664 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
666 void isoclns_print(netdissect_options
*ndo
,
667 const uint8_t *p
, u_int length
, u_int caplen
)
669 if (caplen
<= 1) { /* enough bytes on the wire ? */
670 ND_PRINT((ndo
, "|OSI"));
675 ND_PRINT((ndo
, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values
, "Unknown", *p
), *p
));
680 if (!clnp_print(ndo
, p
, length
))
681 print_unknown_data(ndo
, p
, "\n\t", caplen
);
685 esis_print(ndo
, p
, length
);
689 if (!isis_print(ndo
, p
, length
))
690 print_unknown_data(ndo
, p
, "\n\t", caplen
);
694 ND_PRINT((ndo
, "%slength: %u", ndo
->ndo_eflag
? "" : ", ", length
));
698 q933_print(ndo
, p
+ 1, length
- 1);
702 ip_print(ndo
, p
+ 1, length
- 1);
706 ip6_print(ndo
, p
+ 1, length
- 1);
710 ppp_print(ndo
, p
+ 1, length
- 1);
715 ND_PRINT((ndo
, "OSI NLPID 0x%02x unknown", *p
));
716 ND_PRINT((ndo
, "%slength: %u", ndo
->ndo_eflag
? "" : ", ", length
));
718 print_unknown_data(ndo
, p
, "\n\t", caplen
);
723 #define CLNP_PDU_ER 1
724 #define CLNP_PDU_DT 28
725 #define CLNP_PDU_MD 29
726 #define CLNP_PDU_ERQ 30
727 #define CLNP_PDU_ERP 31
729 static const struct tok clnp_pdu_values
[] = {
730 { CLNP_PDU_ER
, "Error Report"},
731 { CLNP_PDU_MD
, "MD"},
732 { CLNP_PDU_DT
, "Data"},
733 { CLNP_PDU_ERQ
, "Echo Request"},
734 { CLNP_PDU_ERP
, "Echo Response"},
738 struct clnp_header_t
{
740 uint8_t length_indicator
;
742 uint8_t lifetime
; /* units of 500ms */
744 uint8_t segment_length
[2];
748 struct clnp_segment_header_t
{
749 uint8_t data_unit_id
[2];
750 uint8_t segment_offset
[2];
751 uint8_t total_length
[2];
756 * Decode CLNP packets. Return 0 on error.
760 clnp_print(netdissect_options
*ndo
,
761 const uint8_t *pptr
, u_int length
)
763 const uint8_t *optr
,*source_address
,*dest_address
;
764 u_int li
,tlen
,nsap_offset
,source_address_length
,dest_address_length
, clnp_pdu_type
, clnp_flags
;
765 const struct clnp_header_t
*clnp_header
;
766 const struct clnp_segment_header_t
*clnp_segment_header
;
767 uint8_t rfd_error_major
,rfd_error_minor
;
769 clnp_header
= (const struct clnp_header_t
*) pptr
;
770 ND_TCHECK(*clnp_header
);
772 li
= clnp_header
->length_indicator
;
776 ND_PRINT((ndo
, "CLNP"));
779 * Sanity checking of the header.
782 if (clnp_header
->version
!= CLNP_VERSION
) {
783 ND_PRINT((ndo
, "version %d packet not supported", clnp_header
->version
));
787 /* FIXME further header sanity checking */
789 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
790 clnp_flags
= clnp_header
->type
& CLNP_FLAG_MASK
;
792 pptr
+= sizeof(struct clnp_header_t
);
793 li
-= sizeof(struct clnp_header_t
);
794 dest_address_length
= *pptr
;
795 dest_address
= pptr
+ 1;
797 pptr
+= (1 + dest_address_length
);
798 li
-= (1 + dest_address_length
);
799 source_address_length
= *pptr
;
800 source_address
= pptr
+1;
802 pptr
+= (1 + source_address_length
);
803 li
-= (1 + source_address_length
);
805 if (ndo
->ndo_vflag
< 1) {
806 ND_PRINT((ndo
, "%s%s > %s, %s, length %u",
807 ndo
->ndo_eflag
? "" : ", ",
808 isonsap_string(source_address
, source_address_length
),
809 isonsap_string(dest_address
, dest_address_length
),
810 tok2str(clnp_pdu_values
,"unknown (%u)",clnp_pdu_type
),
814 ND_PRINT((ndo
, "%slength %u", ndo
->ndo_eflag
? "" : ", ", length
));
816 ND_PRINT((ndo
, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
817 tok2str(clnp_pdu_values
, "unknown (%u)",clnp_pdu_type
),
818 clnp_header
->length_indicator
,
819 clnp_header
->version
,
820 clnp_header
->lifetime
/2,
821 (clnp_header
->lifetime
%2)*5,
822 EXTRACT_16BITS(clnp_header
->segment_length
),
823 EXTRACT_16BITS(clnp_header
->cksum
)));
825 osi_print_cksum(ndo
, optr
, EXTRACT_16BITS(clnp_header
->cksum
), 7,
826 clnp_header
->length_indicator
);
828 ND_PRINT((ndo
, "\n\tFlags [%s]",
829 bittok2str(clnp_flag_values
, "none", clnp_flags
)));
831 ND_PRINT((ndo
, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
832 source_address_length
,
833 isonsap_string(source_address
, source_address_length
),
835 isonsap_string(dest_address
, dest_address_length
)));
837 if (clnp_flags
& CLNP_SEGMENT_PART
) {
838 clnp_segment_header
= (const struct clnp_segment_header_t
*) pptr
;
839 ND_TCHECK(*clnp_segment_header
);
840 ND_PRINT((ndo
, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
841 EXTRACT_16BITS(clnp_segment_header
->data_unit_id
),
842 EXTRACT_16BITS(clnp_segment_header
->segment_offset
),
843 EXTRACT_16BITS(clnp_segment_header
->total_length
)));
844 pptr
+=sizeof(const struct clnp_segment_header_t
);
845 li
-=sizeof(const struct clnp_segment_header_t
);
848 /* now walk the options */
853 ND_TCHECK2(*pptr
, 2);
855 ND_PRINT((ndo
, ", bad opts/li"));
861 ND_TCHECK2(*pptr
, opli
);
863 ND_PRINT((ndo
, ", opt (%d) too long", op
));
870 ND_PRINT((ndo
, "\n\t %s Option #%u, length %u, value: ",
871 tok2str(clnp_option_values
,"Unknown",op
),
878 case CLNP_OPTION_ROUTE_RECORDING
: /* those two options share the format */
879 case CLNP_OPTION_SOURCE_ROUTING
:
880 ND_PRINT((ndo
, "%s %s",
881 tok2str(clnp_option_sr_rr_values
,"Unknown",*tptr
),
882 tok2str(clnp_option_sr_rr_string_values
, "Unknown Option %u", op
)));
883 nsap_offset
=*(tptr
+1);
884 if (nsap_offset
== 0) {
885 ND_PRINT((ndo
, " Bad NSAP offset (0)"));
888 nsap_offset
-=1; /* offset to nsap list */
889 if (nsap_offset
> tlen
) {
890 ND_PRINT((ndo
, " Bad NSAP offset (past end of option)"));
896 source_address_length
=*tptr
;
897 if (tlen
< source_address_length
+1) {
898 ND_PRINT((ndo
, "\n\t NSAP address goes past end of option"));
901 if (source_address_length
> 0) {
902 source_address
=(tptr
+1);
903 ND_TCHECK2(*source_address
, source_address_length
);
904 ND_PRINT((ndo
, "\n\t NSAP address (length %u): %s",
905 source_address_length
,
906 isonsap_string(source_address
, source_address_length
)));
908 tlen
-=source_address_length
+1;
912 case CLNP_OPTION_PRIORITY
:
913 ND_PRINT((ndo
, "0x%1x", *tptr
&0x0f));
916 case CLNP_OPTION_QOS_MAINTENANCE
:
917 ND_PRINT((ndo
, "\n\t Format Code: %s",
918 tok2str(clnp_option_scope_values
, "Reserved", *tptr
&CLNP_OPTION_SCOPE_MASK
)));
920 if ((*tptr
&CLNP_OPTION_SCOPE_MASK
) == CLNP_OPTION_SCOPE_GLOBAL
)
921 ND_PRINT((ndo
, "\n\t QoS Flags [%s]",
922 bittok2str(clnp_option_qos_global_values
,
924 *tptr
&CLNP_OPTION_OPTION_QOS_MASK
)));
927 case CLNP_OPTION_SECURITY
:
928 ND_PRINT((ndo
, "\n\t Format Code: %s, Security-Level %u",
929 tok2str(clnp_option_scope_values
,"Reserved",*tptr
&CLNP_OPTION_SCOPE_MASK
),
933 case CLNP_OPTION_DISCARD_REASON
:
934 rfd_error_major
= (*tptr
&0xf0) >> 4;
935 rfd_error_minor
= *tptr
&0x0f;
936 ND_PRINT((ndo
, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
937 tok2str(clnp_option_rfd_class_values
,"Unknown",rfd_error_major
),
939 tok2str(clnp_option_rfd_error_class
[rfd_error_major
],"Unknown",rfd_error_minor
),
943 case CLNP_OPTION_PADDING
:
944 ND_PRINT((ndo
, "padding data"));
948 * FIXME those are the defined Options that lack a decoder
949 * you are welcome to contribute code ;-)
953 print_unknown_data(ndo
, tptr
, "\n\t ", opli
);
956 if (ndo
->ndo_vflag
> 1)
957 print_unknown_data(ndo
, pptr
, "\n\t ", opli
);
961 switch (clnp_pdu_type
) {
963 case CLNP_PDU_ER
: /* fall through */
966 if (*(pptr
) == NLPID_CLNP
) {
967 ND_PRINT((ndo
, "\n\t-----original packet-----\n\t"));
968 /* FIXME recursion protection */
969 clnp_print(ndo
, pptr
, length
- clnp_header
->length_indicator
);
978 /* dump the PDU specific data */
979 if (length
-(pptr
-optr
) > 0) {
980 ND_PRINT((ndo
, "\n\t undecoded non-header data, length %u", length
-clnp_header
->length_indicator
));
981 print_unknown_data(ndo
, pptr
, "\n\t ", length
- (pptr
- optr
));
988 ND_PRINT((ndo
, "[|clnp]"));
994 #define ESIS_PDU_REDIRECT 6
995 #define ESIS_PDU_ESH 2
996 #define ESIS_PDU_ISH 4
998 static const struct tok esis_pdu_values
[] = {
999 { ESIS_PDU_REDIRECT
, "redirect"},
1000 { ESIS_PDU_ESH
, "ESH"},
1001 { ESIS_PDU_ISH
, "ISH"},
1005 struct esis_header_t
{
1007 uint8_t length_indicator
;
1011 uint8_t holdtime
[2];
1016 esis_print(netdissect_options
*ndo
,
1017 const uint8_t *pptr
, u_int length
)
1019 const uint8_t *optr
;
1020 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
1021 const struct esis_header_t
*esis_header
;
1023 if (!ndo
->ndo_eflag
)
1024 ND_PRINT((ndo
, "ES-IS"));
1027 ND_PRINT((ndo
, ndo
->ndo_qflag
? "bad pkt!" : "no header at all!"));
1031 esis_header
= (const struct esis_header_t
*) pptr
;
1032 ND_TCHECK(*esis_header
);
1033 li
= esis_header
->length_indicator
;
1037 * Sanity checking of the header.
1040 if (esis_header
->nlpid
!= NLPID_ESIS
) {
1041 ND_PRINT((ndo
, " nlpid 0x%02x packet not supported", esis_header
->nlpid
));
1045 if (esis_header
->version
!= ESIS_VERSION
) {
1046 ND_PRINT((ndo
, " version %d packet not supported", esis_header
->version
));
1051 ND_PRINT((ndo
, " length indicator(%d) > PDU size (%d)!", li
, length
));
1055 if (li
< sizeof(struct esis_header_t
) + 2) {
1056 ND_PRINT((ndo
, " length indicator < min PDU size %d:", li
));
1057 while (pptr
< ndo
->ndo_snapend
)
1058 ND_PRINT((ndo
, "%02X", *pptr
++));
1062 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
1064 if (ndo
->ndo_vflag
< 1) {
1065 ND_PRINT((ndo
, "%s%s, length %u",
1066 ndo
->ndo_eflag
? "" : ", ",
1067 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
1071 ND_PRINT((ndo
, "%slength %u\n\t%s (%u)",
1072 ndo
->ndo_eflag
? "" : ", ",
1074 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
1077 ND_PRINT((ndo
, ", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" ));
1078 ND_PRINT((ndo
, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header
->cksum
)));
1080 osi_print_cksum(ndo
, pptr
, EXTRACT_16BITS(esis_header
->cksum
), 7, li
);
1082 ND_PRINT((ndo
, ", holding time: %us, length indicator: %u",
1083 EXTRACT_16BITS(esis_header
->holdtime
), li
));
1085 if (ndo
->ndo_vflag
> 1)
1086 print_unknown_data(ndo
, optr
, "\n\t", sizeof(struct esis_header_t
));
1088 pptr
+= sizeof(struct esis_header_t
);
1089 li
-= sizeof(struct esis_header_t
);
1091 switch (esis_pdu_type
) {
1092 case ESIS_PDU_REDIRECT
: {
1093 const uint8_t *dst
, *snpa
, *neta
;
1094 u_int dstl
, snpal
, netal
;
1098 ND_PRINT((ndo
, ", bad redirect/li"));
1104 ND_TCHECK2(*pptr
, dstl
);
1106 ND_PRINT((ndo
, ", bad redirect/li"));
1112 ND_PRINT((ndo
, "\n\t %s", isonsap_string(dst
, dstl
)));
1116 ND_PRINT((ndo
, ", bad redirect/li"));
1122 ND_TCHECK2(*pptr
, snpal
);
1124 ND_PRINT((ndo
, ", bad redirect/li"));
1132 ND_PRINT((ndo
, ", bad redirect/li"));
1137 ND_TCHECK2(*pptr
, netal
);
1139 ND_PRINT((ndo
, ", bad redirect/li"));
1147 ND_PRINT((ndo
, "\n\t %s", etheraddr_string(ndo
, snpa
)));
1149 ND_PRINT((ndo
, "\n\t %s", isonsap_string(neta
, netal
)));
1156 ND_PRINT((ndo
, ", bad esh/li"));
1159 source_address_number
= *pptr
;
1163 ND_PRINT((ndo
, "\n\t Number of Source Addresses: %u", source_address_number
));
1165 while (source_address_number
> 0) {
1168 ND_PRINT((ndo
, ", bad esh/li"));
1171 source_address_length
= *pptr
;
1175 ND_TCHECK2(*pptr
, source_address_length
);
1176 if (li
< source_address_length
) {
1177 ND_PRINT((ndo
, ", bad esh/li"));
1180 ND_PRINT((ndo
, "\n\t NET (length: %u): %s",
1181 source_address_length
,
1182 isonsap_string(pptr
, source_address_length
)));
1183 pptr
+= source_address_length
;
1184 li
-= source_address_length
;
1185 source_address_number
--;
1190 case ESIS_PDU_ISH
: {
1193 ND_PRINT((ndo
, ", bad ish/li"));
1196 source_address_length
= *pptr
;
1199 ND_TCHECK2(*pptr
, source_address_length
);
1200 if (li
< source_address_length
) {
1201 ND_PRINT((ndo
, ", bad ish/li"));
1204 ND_PRINT((ndo
, "\n\t NET (length: %u): %s", source_address_length
, isonsap_string(pptr
, source_address_length
)));
1205 pptr
+= source_address_length
;
1206 li
-= source_address_length
;
1211 if (ndo
->ndo_vflag
<= 1) {
1212 if (pptr
< ndo
->ndo_snapend
)
1213 print_unknown_data(ndo
, pptr
, "\n\t ", ndo
->ndo_snapend
- pptr
);
1218 /* now walk the options */
1221 const uint8_t *tptr
;
1224 ND_PRINT((ndo
, ", bad opts/li"));
1227 ND_TCHECK2(*pptr
, 2);
1232 ND_PRINT((ndo
, ", opt (%d) too long", op
));
1238 ND_PRINT((ndo
, "\n\t %s Option #%u, length %u, value: ",
1239 tok2str(esis_option_values
,"Unknown",op
),
1245 case ESIS_OPTION_ES_CONF_TIME
:
1247 ND_TCHECK2(*pptr
, 2);
1248 ND_PRINT((ndo
, "%us", EXTRACT_16BITS(tptr
)));
1250 ND_PRINT((ndo
, "(bad length)"));
1253 case ESIS_OPTION_PROTOCOLS
:
1256 ND_PRINT((ndo
, "%s (0x%02x)",
1257 tok2str(nlpid_values
,
1261 if (opli
>1) /* further NPLIDs ? - put comma */
1262 ND_PRINT((ndo
, ", "));
1269 * FIXME those are the defined Options that lack a decoder
1270 * you are welcome to contribute code ;-)
1273 case ESIS_OPTION_QOS_MAINTENANCE
:
1274 case ESIS_OPTION_SECURITY
:
1275 case ESIS_OPTION_PRIORITY
:
1276 case ESIS_OPTION_ADDRESS_MASK
:
1277 case ESIS_OPTION_SNPA_MASK
:
1280 print_unknown_data(ndo
, tptr
, "\n\t ", opli
);
1283 if (ndo
->ndo_vflag
> 1)
1284 print_unknown_data(ndo
, pptr
, "\n\t ", opli
);
1292 isis_print_mcid(netdissect_options
*ndo
,
1293 const struct isis_spb_mcid
*mcid
)
1297 ND_PRINT((ndo
, "ID: %d, Name: ", mcid
->format_id
));
1301 ND_PRINT((ndo
, "%c", mcid
->name
[i
]));
1302 if(mcid
->name
[i
] == '\0')
1306 ND_PRINT((ndo
, "\n\t Lvl: %d", EXTRACT_16BITS(mcid
->revision_lvl
)));
1308 ND_PRINT((ndo
, ", Digest: "));
1311 ND_PRINT((ndo
, "%.2x ", mcid
->digest
[i
]));
1315 isis_print_mt_port_cap_subtlv(netdissect_options
*ndo
,
1316 const uint8_t *tptr
, int len
)
1318 int stlv_type
, stlv_len
;
1319 const struct isis_subtlv_spb_mcid
*subtlv_spb_mcid
;
1324 stlv_type
= *(tptr
++);
1325 stlv_len
= *(tptr
++);
1327 /* first lets see if we know the subTLVs name*/
1328 ND_PRINT((ndo
, "\n\t %s subTLV #%u, length: %u",
1329 tok2str(isis_mt_port_cap_subtlv_values
, "unknown", stlv_type
),
1333 /*len -= TLV_TYPE_LEN_OFFSET;*/
1338 case ISIS_SUBTLV_SPB_MCID
:
1340 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_MCID_MIN_LEN
))
1343 subtlv_spb_mcid
= (const struct isis_subtlv_spb_mcid
*)tptr
;
1345 ND_PRINT((ndo
, "\n\t MCID: "));
1346 isis_print_mcid(ndo
, &(subtlv_spb_mcid
->mcid
));
1348 /*tptr += SPB_MCID_MIN_LEN;
1349 len -= SPB_MCID_MIN_LEN; */
1351 ND_PRINT((ndo
, "\n\t AUX-MCID: "));
1352 isis_print_mcid(ndo
, &(subtlv_spb_mcid
->aux_mcid
));
1354 /*tptr += SPB_MCID_MIN_LEN;
1355 len -= SPB_MCID_MIN_LEN; */
1356 tptr
= tptr
+ sizeof(struct isis_subtlv_spb_mcid
);
1357 len
= len
- sizeof(struct isis_subtlv_spb_mcid
);
1362 case ISIS_SUBTLV_SPB_DIGEST
:
1364 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
))
1367 ND_PRINT((ndo
, "\n\t RES: %d V: %d A: %d D: %d",
1368 (*(tptr
) >> 5), (((*tptr
)>> 4) & 0x01),
1369 ((*(tptr
) >> 2) & 0x03), ((*tptr
) & 0x03)));
1373 ND_PRINT((ndo
, "\n\t Digest: "));
1377 ND_PRINT((ndo
, "%08x ", EXTRACT_32BITS(tptr
)));
1378 if (i
%4 == 0 && i
!= 8)
1379 ND_PRINT((ndo
, "\n\t "));
1383 len
= len
- ISIS_SUBTLV_SPB_DIGEST_MIN_LEN
;
1388 case ISIS_SUBTLV_SPB_BVID
:
1390 if (!ND_TTEST2(*(tptr
), stlv_len
))
1395 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_BVID_MIN_LEN
))
1398 ND_PRINT((ndo
, "\n\t ECT: %08x",
1399 EXTRACT_32BITS(tptr
)));
1403 ND_PRINT((ndo
, " BVID: %d, U:%01x M:%01x ",
1404 (EXTRACT_16BITS (tptr
) >> 4) ,
1405 (EXTRACT_16BITS (tptr
) >> 3) & 0x01,
1406 (EXTRACT_16BITS (tptr
) >> 2) & 0x01));
1409 len
= len
- ISIS_SUBTLV_SPB_BVID_MIN_LEN
;
1423 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot"));
1428 isis_print_mt_capability_subtlv(netdissect_options
*ndo
,
1429 const uint8_t *tptr
, int len
)
1431 int stlv_type
, stlv_len
, tmp
;
1435 stlv_type
= *(tptr
++);
1436 stlv_len
= *(tptr
++);
1438 /* first lets see if we know the subTLVs name*/
1439 ND_PRINT((ndo
, "\n\t %s subTLV #%u, length: %u",
1440 tok2str(isis_mt_capability_subtlv_values
, "unknown", stlv_type
),
1448 case ISIS_SUBTLV_SPB_INSTANCE
:
1450 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
))
1453 ND_PRINT((ndo
, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr
)));
1455 ND_PRINT((ndo
, " %08x", EXTRACT_32BITS(tptr
)));
1457 ND_PRINT((ndo
, ", Path Cost: %08x", EXTRACT_32BITS(tptr
)));
1459 ND_PRINT((ndo
, ", Prio: %d", EXTRACT_16BITS(tptr
)));
1461 ND_PRINT((ndo
, "\n\t RES: %d",
1462 EXTRACT_16BITS(tptr
) >> 5));
1463 ND_PRINT((ndo
, ", V: %d",
1464 (EXTRACT_16BITS(tptr
) >> 4) & 0x0001));
1465 ND_PRINT((ndo
, ", SPSource-ID: %d",
1466 (EXTRACT_32BITS(tptr
) & 0x000fffff)));
1468 ND_PRINT((ndo
, ", No of Trees: %x", *(tptr
)));
1472 len
= len
- ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN
;
1476 if (!ND_TTEST2(*(tptr
), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
))
1479 ND_PRINT((ndo
, "\n\t U:%d, M:%d, A:%d, RES:%d",
1480 *(tptr
) >> 7, (*(tptr
) >> 6) & 0x01,
1481 (*(tptr
) >> 5) & 0x01, (*(tptr
) & 0x1f)));
1485 ND_PRINT((ndo
, ", ECT: %08x", EXTRACT_32BITS(tptr
)));
1489 ND_PRINT((ndo
, ", BVID: %d, SPVID: %d",
1490 (EXTRACT_24BITS(tptr
) >> 12) & 0x000fff,
1491 EXTRACT_24BITS(tptr
) & 0x000fff));
1494 len
= len
- ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN
;
1500 case ISIS_SUBTLV_SPBM_SI
:
1502 if (!ND_TTEST2(*(tptr
), 6))
1505 ND_PRINT((ndo
, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr
)));
1507 ND_PRINT((ndo
, "%04x", EXTRACT_16BITS(tptr
)));
1510 ND_PRINT((ndo
, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr
) >> 12,
1511 (EXTRACT_16BITS(tptr
)) & 0x0fff));
1515 stlv_len
= stlv_len
- 8;
1519 ND_PRINT((ndo
, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
1520 (EXTRACT_32BITS(tptr
) >> 31),
1521 (EXTRACT_32BITS(tptr
) >> 30) & 0x01,
1522 (EXTRACT_32BITS(tptr
) >> 24) & 0x03f,
1523 (EXTRACT_32BITS(tptr
)) & 0x0ffffff));
1527 stlv_len
= stlv_len
- 4;
1539 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot"));
1543 /* shared routine for printing system, node and lsp-ids */
1545 isis_print_id(const uint8_t *cp
, int id_len
)
1548 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1551 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
1552 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
1554 if (i
== 2 || i
== 4)
1557 if (id_len
>= NODE_ID_LEN
) {
1558 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
1561 if (id_len
== LSP_ID_LEN
)
1562 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
1566 /* print the 4-byte metric block which is common found in the old-style TLVs */
1568 isis_print_metric_block(netdissect_options
*ndo
,
1569 const struct isis_metric_block
*isis_metric_block
)
1571 ND_PRINT((ndo
, ", Default Metric: %d, %s",
1572 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
1573 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal"));
1574 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
1575 ND_PRINT((ndo
, "\n\t\t Delay Metric: %d, %s",
1576 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
1577 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal"));
1578 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
1579 ND_PRINT((ndo
, "\n\t\t Expense Metric: %d, %s",
1580 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
1581 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal"));
1582 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
1583 ND_PRINT((ndo
, "\n\t\t Error Metric: %d, %s",
1584 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
1585 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal"));
1587 return(1); /* everything is ok */
1591 isis_print_tlv_ip_reach(netdissect_options
*ndo
,
1592 const uint8_t *cp
, const char *ident
, int length
)
1595 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
1597 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
1599 while (length
> 0) {
1600 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
1601 ND_PRINT((ndo
, "short IPv4 Reachability (%d vs %lu)",
1603 (unsigned long)sizeof(*tlv_ip_reach
)));
1607 if (!ND_TTEST(*tlv_ip_reach
))
1610 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
1612 if (prefix_len
== -1)
1613 ND_PRINT((ndo
, "%sIPv4 prefix: %s mask %s",
1615 ipaddr_string(ndo
, (tlv_ip_reach
->prefix
)),
1616 ipaddr_string(ndo
, (tlv_ip_reach
->mask
))));
1618 ND_PRINT((ndo
, "%sIPv4 prefix: %15s/%u",
1620 ipaddr_string(ndo
, (tlv_ip_reach
->prefix
)),
1623 ND_PRINT((ndo
, ", Distribution: %s, Metric: %u, %s",
1624 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
1625 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
1626 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal"));
1628 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
1629 ND_PRINT((ndo
, "%s Delay Metric: %u, %s",
1631 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
1632 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal"));
1634 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
1635 ND_PRINT((ndo
, "%s Expense Metric: %u, %s",
1637 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
1638 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal"));
1640 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
1641 ND_PRINT((ndo
, "%s Error Metric: %u, %s",
1643 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
1644 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal"));
1646 length
-= sizeof(struct isis_tlv_ip_reach
);
1653 * this is the common IP-REACH subTLV decoder it is called
1654 * from various EXTD-IP REACH TLVs (135,235,236,237)
1658 isis_print_ip_reach_subtlv(netdissect_options
*ndo
,
1659 const uint8_t *tptr
, int subt
, int subl
,
1662 /* first lets see if we know the subTLVs name*/
1663 ND_PRINT((ndo
, "%s%s subTLV #%u, length: %u",
1664 ident
, tok2str(isis_ext_ip_reach_subtlv_values
, "unknown", subt
),
1667 if (!ND_TTEST2(*tptr
,subl
))
1671 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1672 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1674 ND_PRINT((ndo
, ", 0x%08x (=%u)",
1675 EXTRACT_32BITS(tptr
),
1676 EXTRACT_32BITS(tptr
)));
1681 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1683 ND_PRINT((ndo
, ", 0x%08x%08x",
1684 EXTRACT_32BITS(tptr
),
1685 EXTRACT_32BITS(tptr
+4)));
1691 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1698 ND_PRINT((ndo
, "%spacket exceeded snapshot", ident
));
1703 * this is the common IS-REACH subTLV decoder it is called
1704 * from isis_print_ext_is_reach()
1708 isis_print_is_reach_subtlv(netdissect_options
*ndo
,
1709 const uint8_t *tptr
, u_int subt
, u_int subl
,
1712 u_int te_class
,priority_level
,gmpls_switch_cap
;
1713 union { /* int to float conversion buffer for several subTLVs */
1718 /* first lets see if we know the subTLVs name*/
1719 ND_PRINT((ndo
, "%s%s subTLV #%u, length: %u",
1720 ident
, tok2str(isis_ext_is_reach_subtlv_values
, "unknown", subt
),
1723 if (!ND_TTEST2(*tptr
,subl
))
1727 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1728 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1729 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1731 ND_PRINT((ndo
, ", 0x%08x", EXTRACT_32BITS(tptr
)));
1732 if (subl
== 8) /* rfc4205 */
1733 ND_PRINT((ndo
, ", 0x%08x", EXTRACT_32BITS(tptr
+4)));
1736 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1737 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1738 if (subl
>= sizeof(struct in_addr
))
1739 ND_PRINT((ndo
, ", %s", ipaddr_string(ndo
, tptr
)));
1741 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1742 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1744 bw
.i
= EXTRACT_32BITS(tptr
);
1745 ND_PRINT((ndo
, ", %.3f Mbps", bw
.f
* 8 / 1000000));
1748 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1750 for (te_class
= 0; te_class
< 8; te_class
++) {
1751 bw
.i
= EXTRACT_32BITS(tptr
);
1752 ND_PRINT((ndo
, "%s TE-Class %u: %.3f Mbps",
1755 bw
.f
* 8 / 1000000));
1760 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS
: /* fall through */
1761 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD
:
1762 ND_PRINT((ndo
, "%sBandwidth Constraints Model ID: %s (%u)",
1764 tok2str(diffserv_te_bc_values
, "unknown", *tptr
),
1767 /* decode BCs until the subTLV ends */
1768 for (te_class
= 0; te_class
< (subl
-1)/4; te_class
++) {
1769 bw
.i
= EXTRACT_32BITS(tptr
);
1770 ND_PRINT((ndo
, "%s Bandwidth constraint CT%u: %.3f Mbps",
1773 bw
.f
* 8 / 1000000));
1777 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1779 ND_PRINT((ndo
, ", %u", EXTRACT_24BITS(tptr
)));
1781 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE
:
1783 ND_PRINT((ndo
, ", [ %s ] (0x%04x)",
1784 bittok2str(isis_subtlv_link_attribute_values
,
1786 EXTRACT_16BITS(tptr
)),
1787 EXTRACT_16BITS(tptr
)));
1790 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1792 ND_PRINT((ndo
, ", %s, Priority %u",
1793 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1797 case ISIS_SUBTLV_SPB_METRIC
:
1799 ND_PRINT((ndo
, ", LM: %u", EXTRACT_24BITS(tptr
)));
1801 ND_PRINT((ndo
, ", P: %u", *(tptr
)));
1803 ND_PRINT((ndo
, ", P-ID: %u", EXTRACT_16BITS(tptr
)));
1806 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1808 gmpls_switch_cap
= *tptr
;
1809 ND_PRINT((ndo
, "%s Interface Switching Capability:%s",
1811 tok2str(gmpls_switch_cap_values
, "Unknown", gmpls_switch_cap
)));
1812 ND_PRINT((ndo
, ", LSP Encoding: %s",
1813 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+ 1))));
1815 ND_PRINT((ndo
, "%s Max LSP Bandwidth:", ident
));
1816 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1817 bw
.i
= EXTRACT_32BITS(tptr
);
1818 ND_PRINT((ndo
, "%s priority level %d: %.3f Mbps",
1821 bw
.f
* 8 / 1000000));
1825 switch (gmpls_switch_cap
) {
1830 bw
.i
= EXTRACT_32BITS(tptr
);
1831 ND_PRINT((ndo
, "%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
* 8 / 1000000));
1832 ND_PRINT((ndo
, "%s Interface MTU: %u", ident
, EXTRACT_16BITS(tptr
+ 4)));
1835 bw
.i
= EXTRACT_32BITS(tptr
);
1836 ND_PRINT((ndo
, "%s Min LSP Bandwidth: %.3f Mbps", ident
, bw
.f
* 8 / 1000000));
1837 ND_PRINT((ndo
, "%s Indication %s", ident
,
1838 tok2str(gmpls_switch_cap_tsc_indication_values
, "Unknown (%u)", *(tptr
+ 4))));
1841 /* there is some optional stuff left to decode but this is as of yet
1842 not specified so just lets hexdump what is left */
1844 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1851 if (!print_unknown_data(ndo
, tptr
, "\n\t\t ", subl
))
1858 ND_PRINT((ndo
, "%spacket exceeded snapshot", ident
));
1864 * this is the common IS-REACH decoder it is called
1865 * from various EXTD-IS REACH style TLVs (22,24,222)
1869 isis_print_ext_is_reach(netdissect_options
*ndo
,
1870 const uint8_t *tptr
, const char *ident
, int tlv_type
)
1872 char ident_buffer
[20];
1873 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1874 int proc_bytes
= 0; /* how many bytes did we process ? */
1876 if (!ND_TTEST2(*tptr
, NODE_ID_LEN
))
1879 ND_PRINT((ndo
, "%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
)));
1880 tptr
+=(NODE_ID_LEN
);
1882 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1883 if (!ND_TTEST2(*tptr
, 3)) /* and is therefore skipped */
1885 ND_PRINT((ndo
, ", Metric: %d", EXTRACT_24BITS(tptr
)));
1889 if (!ND_TTEST2(*tptr
, 1))
1891 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1892 proc_bytes
=NODE_ID_LEN
+3+1;
1893 ND_PRINT((ndo
, ", %ssub-TLVs present",subtlv_sum_len
? "" : "no "));
1894 if (subtlv_sum_len
) {
1895 ND_PRINT((ndo
, " (%u)", subtlv_sum_len
));
1896 while (subtlv_sum_len
>0) {
1897 if (!ND_TTEST2(*tptr
,2))
1899 subtlv_type
=*(tptr
++);
1900 subtlv_len
=*(tptr
++);
1901 /* prepend the ident string */
1902 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1903 if (!isis_print_is_reach_subtlv(ndo
, tptr
, subtlv_type
, subtlv_len
, ident_buffer
))
1906 subtlv_sum_len
-=(subtlv_len
+2);
1907 proc_bytes
+=(subtlv_len
+2);
1914 * this is the common Multi Topology ID decoder
1915 * it is called from various MT-TLVs (222,229,235,237)
1919 isis_print_mtid(netdissect_options
*ndo
,
1920 const uint8_t *tptr
, const char *ident
)
1922 if (!ND_TTEST2(*tptr
, 2))
1925 ND_PRINT((ndo
, "%s%s",
1927 tok2str(isis_mt_values
,
1928 "Reserved for IETF Consensus",
1929 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)))));
1931 ND_PRINT((ndo
, " Topology (0x%03x), Flags: [%s]",
1932 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1933 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
)))));
1939 * this is the common extended IP reach decoder
1940 * it is called from TLVs (135,235,236,237)
1941 * we process the TLV and optional subTLVs and return
1942 * the amount of processed bytes
1946 isis_print_extd_ip_reach(netdissect_options
*ndo
,
1947 const uint8_t *tptr
, const char *ident
, uint16_t afi
)
1949 char ident_buffer
[20];
1951 uint8_t prefix
[sizeof(struct in6_addr
)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1953 uint8_t prefix
[sizeof(struct in_addr
)]; /* shared copy buffer for IPv4 prefixes */
1955 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1957 if (!ND_TTEST2(*tptr
, 4))
1959 metric
= EXTRACT_32BITS(tptr
);
1963 if (afi
== AF_INET
) {
1964 if (!ND_TTEST2(*tptr
, 1)) /* fetch status byte */
1966 status_byte
=*(tptr
++);
1967 bit_length
= status_byte
&0x3f;
1968 if (bit_length
> 32) {
1969 ND_PRINT((ndo
, "%sIPv4 prefix: bad bit length %u",
1976 } else if (afi
== AF_INET6
) {
1977 if (!ND_TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1979 status_byte
=*(tptr
++);
1980 bit_length
=*(tptr
++);
1981 if (bit_length
> 128) {
1982 ND_PRINT((ndo
, "%sIPv6 prefix: bad bit length %u",
1990 return (0); /* somebody is fooling us */
1992 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1994 if (!ND_TTEST2(*tptr
, byte_length
))
1996 memset(prefix
, 0, sizeof prefix
); /* clear the copy buffer */
1997 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1999 processed
+=byte_length
;
2002 ND_PRINT((ndo
, "%sIPv4 prefix: %15s/%u",
2004 ipaddr_string(ndo
, prefix
),
2007 if (afi
== AF_INET6
)
2008 ND_PRINT((ndo
, "%sIPv6 prefix: %s/%u",
2010 ip6addr_string(ndo
, prefix
),
2014 ND_PRINT((ndo
, ", Distribution: %s, Metric: %u",
2015 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
2018 if (afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2019 ND_PRINT((ndo
, ", sub-TLVs present"));
2021 if (afi
== AF_INET6
)
2022 ND_PRINT((ndo
, ", %s%s",
2023 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
2024 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : ""));
2027 if ((afi
== AF_INET
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
2029 || (afi
== AF_INET6
&& ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
))
2032 /* assume that one prefix can hold more
2033 than one subTLV - therefore the first byte must reflect
2034 the aggregate bytecount of the subTLVs for this prefix
2036 if (!ND_TTEST2(*tptr
, 1))
2039 processed
+=sublen
+1;
2040 ND_PRINT((ndo
, " (%u)", sublen
)); /* print out subTLV length */
2043 if (!ND_TTEST2(*tptr
,2))
2045 subtlvtype
=*(tptr
++);
2046 subtlvlen
=*(tptr
++);
2047 /* prepend the ident string */
2048 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
2049 if (!isis_print_ip_reach_subtlv(ndo
, tptr
, subtlvtype
, subtlvlen
, ident_buffer
))
2052 sublen
-=(subtlvlen
+2);
2060 * Decode IS-IS packets. Return 0 on error.
2064 isis_print(netdissect_options
*ndo
,
2065 const uint8_t *p
, u_int length
)
2067 const struct isis_common_header
*isis_header
;
2069 const struct isis_iih_lan_header
*header_iih_lan
;
2070 const struct isis_iih_ptp_header
*header_iih_ptp
;
2071 struct isis_lsp_header
*header_lsp
;
2072 const struct isis_csnp_header
*header_csnp
;
2073 const struct isis_psnp_header
*header_psnp
;
2075 const struct isis_tlv_lsp
*tlv_lsp
;
2076 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
2077 const struct isis_tlv_is_reach
*tlv_is_reach
;
2078 const struct isis_tlv_es_reach
*tlv_es_reach
;
2080 uint8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
2081 uint8_t ext_is_len
, ext_ip_len
, mt_len
;
2082 const uint8_t *optr
, *pptr
, *tptr
;
2083 u_short packet_len
,pdu_len
, key_id
;
2088 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
2089 need it for parsing the checksum TLV and authentication
2091 isis_header
= (const struct isis_common_header
*)p
;
2092 ND_TCHECK(*isis_header
);
2093 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
2094 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
2095 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
2096 header_lsp
= (struct isis_lsp_header
*)pptr
;
2097 header_csnp
= (const struct isis_csnp_header
*)pptr
;
2098 header_psnp
= (const struct isis_psnp_header
*)pptr
;
2100 if (!ndo
->ndo_eflag
)
2101 ND_PRINT((ndo
, "IS-IS"));
2104 * Sanity checking of the header.
2107 if (isis_header
->version
!= ISIS_VERSION
) {
2108 ND_PRINT((ndo
, "version %d packet not supported", isis_header
->version
));
2112 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
2113 ND_PRINT((ndo
, "system ID length of %d is not supported",
2114 isis_header
->id_length
));
2118 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
2119 ND_PRINT((ndo
, "version %d packet not supported", isis_header
->pdu_version
));
2123 max_area
= isis_header
->max_area
;
2126 max_area
= 3; /* silly shit */
2129 ND_PRINT((ndo
, "bad packet -- 255 areas"));
2135 id_length
= isis_header
->id_length
;
2138 id_length
= 6; /* silly shit again */
2140 case 1: /* 1-8 are valid sys-ID lenghts */
2150 id_length
= 0; /* entirely useless */
2156 /* toss any non 6-byte sys-ID len PDUs */
2157 if (id_length
!= 6 ) {
2158 ND_PRINT((ndo
, "bad packet -- illegal sys-ID length (%u)", id_length
));
2162 pdu_type
=isis_header
->pdu_type
;
2164 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
2165 if (ndo
->ndo_vflag
< 1) {
2166 ND_PRINT((ndo
, "%s%s",
2167 ndo
->ndo_eflag
? "" : ", ",
2168 tok2str(isis_pdu_values
, "unknown PDU-Type %u", pdu_type
)));
2172 case ISIS_PDU_L1_LAN_IIH
:
2173 case ISIS_PDU_L2_LAN_IIH
:
2174 ND_PRINT((ndo
, ", src-id %s",
2175 isis_print_id(header_iih_lan
->source_id
, SYSTEM_ID_LEN
)));
2176 ND_PRINT((ndo
, ", lan-id %s, prio %u",
2177 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
2178 header_iih_lan
->priority
));
2180 case ISIS_PDU_PTP_IIH
:
2181 ND_PRINT((ndo
, ", src-id %s", isis_print_id(header_iih_ptp
->source_id
, SYSTEM_ID_LEN
)));
2183 case ISIS_PDU_L1_LSP
:
2184 case ISIS_PDU_L2_LSP
:
2185 ND_PRINT((ndo
, ", lsp-id %s, seq 0x%08x, lifetime %5us",
2186 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
2187 EXTRACT_32BITS(header_lsp
->sequence_number
),
2188 EXTRACT_16BITS(header_lsp
->remaining_lifetime
)));
2190 case ISIS_PDU_L1_CSNP
:
2191 case ISIS_PDU_L2_CSNP
:
2192 ND_PRINT((ndo
, ", src-id %s", isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
)));
2194 case ISIS_PDU_L1_PSNP
:
2195 case ISIS_PDU_L2_PSNP
:
2196 ND_PRINT((ndo
, ", src-id %s", isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
)));
2200 ND_PRINT((ndo
, ", length %u", length
));
2205 /* ok they seem to want to know everything - lets fully decode it */
2206 ND_PRINT((ndo
, "%slength %u", ndo
->ndo_eflag
? "" : ", ", length
));
2208 ND_PRINT((ndo
, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
2209 tok2str(isis_pdu_values
,
2212 isis_header
->fixed_len
,
2213 isis_header
->version
,
2214 isis_header
->pdu_version
,
2216 isis_header
->id_length
,
2218 isis_header
->max_area
));
2220 if (ndo
->ndo_vflag
> 1) {
2221 if (!print_unknown_data(ndo
, optr
, "\n\t", 8)) /* provide the _o_riginal pointer */
2222 return(0); /* for optionally debugging the common header */
2227 case ISIS_PDU_L1_LAN_IIH
:
2228 case ISIS_PDU_L2_LAN_IIH
:
2229 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
2230 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2231 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
));
2235 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
2236 if (packet_len
>pdu_len
) {
2237 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2241 ND_TCHECK(*header_iih_lan
);
2242 ND_PRINT((ndo
, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
2243 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
2244 EXTRACT_16BITS(header_iih_lan
->holding_time
),
2245 tok2str(isis_iih_circuit_type_values
,
2246 "unknown circuit type 0x%02x",
2247 header_iih_lan
->circuit_type
)));
2249 ND_PRINT((ndo
, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
2250 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
2251 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
2254 if (ndo
->ndo_vflag
> 1) {
2255 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE
))
2259 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2260 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
2263 case ISIS_PDU_PTP_IIH
:
2264 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
2265 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2266 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
));
2270 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
2271 if (packet_len
>pdu_len
) {
2272 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2276 ND_TCHECK(*header_iih_ptp
);
2277 ND_PRINT((ndo
, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
2278 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
2279 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
2280 tok2str(isis_iih_circuit_type_values
,
2281 "unknown circuit type 0x%02x",
2282 header_iih_ptp
->circuit_type
)));
2284 ND_PRINT((ndo
, "\n\t circuit-id: 0x%02x, PDU length: %u",
2285 header_iih_ptp
->circuit_id
,
2288 if (ndo
->ndo_vflag
> 1) {
2289 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE
))
2293 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2294 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
2297 case ISIS_PDU_L1_LSP
:
2298 case ISIS_PDU_L2_LSP
:
2299 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
2300 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2301 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
));
2305 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
2306 if (packet_len
>pdu_len
) {
2307 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2311 ND_TCHECK(*header_lsp
);
2312 ND_PRINT((ndo
, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
2313 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
2314 EXTRACT_32BITS(header_lsp
->sequence_number
),
2315 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
2316 EXTRACT_16BITS(header_lsp
->checksum
)));
2319 osi_print_cksum(ndo
, (uint8_t *)header_lsp
->lsp_id
,
2320 EXTRACT_16BITS(header_lsp
->checksum
), 12, length
-12);
2323 * Clear checksum and lifetime prior to signature verification.
2325 header_lsp
->checksum
[0] = 0;
2326 header_lsp
->checksum
[1] = 0;
2327 header_lsp
->remaining_lifetime
[0] = 0;
2328 header_lsp
->remaining_lifetime
[1] = 0;
2331 ND_PRINT((ndo
, ", PDU length: %u, Flags: [ %s",
2333 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : ""));
2335 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
2336 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : ""));
2337 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : ""));
2338 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : ""));
2339 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : ""));
2340 ND_PRINT((ndo
, "ATT bit set, "));
2342 ND_PRINT((ndo
, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : ""));
2343 ND_PRINT((ndo
, "%s ]", tok2str(isis_lsp_istype_values
, "Unknown(0x%x)",
2344 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
))));
2346 if (ndo
->ndo_vflag
> 1) {
2347 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_LSP_HEADER_SIZE
))
2351 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2352 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
2355 case ISIS_PDU_L1_CSNP
:
2356 case ISIS_PDU_L2_CSNP
:
2357 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
2358 ND_PRINT((ndo
, ", bogus fixed header length %u should be %lu",
2359 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
));
2363 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
2364 if (packet_len
>pdu_len
) {
2365 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2369 ND_TCHECK(*header_csnp
);
2370 ND_PRINT((ndo
, "\n\t source-id: %s, PDU length: %u",
2371 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
2373 ND_PRINT((ndo
, "\n\t start lsp-id: %s",
2374 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
)));
2375 ND_PRINT((ndo
, "\n\t end lsp-id: %s",
2376 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
)));
2378 if (ndo
->ndo_vflag
> 1) {
2379 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_CSNP_HEADER_SIZE
))
2383 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2384 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
2387 case ISIS_PDU_L1_PSNP
:
2388 case ISIS_PDU_L2_PSNP
:
2389 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
2390 ND_PRINT((ndo
, "- bogus fixed header length %u should be %lu",
2391 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
));
2395 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
2396 if (packet_len
>pdu_len
) {
2397 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
2401 ND_TCHECK(*header_psnp
);
2402 ND_PRINT((ndo
, "\n\t source-id: %s, PDU length: %u",
2403 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
2406 if (ndo
->ndo_vflag
> 1) {
2407 if (!print_unknown_data(ndo
, pptr
, "\n\t ", ISIS_PSNP_HEADER_SIZE
))
2411 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2412 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
2416 (void)print_unknown_data(ndo
, pptr
, "\n\t ", length
);
2421 * Now print the TLV's.
2424 while (packet_len
>= 2) {
2425 if (pptr
== ndo
->ndo_snapend
) {
2429 if (!ND_TTEST2(*pptr
, 2)) {
2430 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot (%ld) bytes",
2431 (long)(pptr
- ndo
->ndo_snapend
)));
2436 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
2439 if (tlv_len
> packet_len
) {
2443 /* first lets see if we know the TLVs name*/
2444 ND_PRINT((ndo
, "\n\t %s TLV #%u, length: %u",
2445 tok2str(isis_tlv_values
,
2451 if (tlv_len
== 0) /* something is malformed */
2454 /* now check if we have a decoder otherwise do a hexdump at the end*/
2456 case ISIS_TLV_AREA_ADDR
:
2457 if (!ND_TTEST2(*tptr
, 1))
2460 while (tmp
&& alen
< tmp
) {
2461 ND_PRINT((ndo
, "\n\t Area address (length: %u): %s",
2463 isonsap_string(tptr
, alen
)));
2466 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
2468 if (!ND_TTEST2(*tptr
, 1))
2473 case ISIS_TLV_ISNEIGH
:
2474 while (tmp
>= ETHER_ADDR_LEN
) {
2475 if (!ND_TTEST2(*tptr
, ETHER_ADDR_LEN
))
2477 ND_PRINT((ndo
, "\n\t SNPA: %s", isis_print_id(tptr
, ETHER_ADDR_LEN
)));
2478 tmp
-= ETHER_ADDR_LEN
;
2479 tptr
+= ETHER_ADDR_LEN
;
2483 case ISIS_TLV_ISNEIGH_VARLEN
:
2484 if (!ND_TTEST2(*tptr
, 1) || tmp
< 3) /* min. TLV length */
2486 lan_alen
= *tptr
++; /* LAN address length */
2487 if (lan_alen
== 0) {
2488 ND_PRINT((ndo
, "\n\t LAN address length 0 bytes (invalid)"));
2492 ND_PRINT((ndo
, "\n\t LAN address length %u bytes ", lan_alen
));
2493 while (tmp
>= lan_alen
) {
2494 if (!ND_TTEST2(*tptr
, lan_alen
))
2496 ND_PRINT((ndo
, "\n\t\tIS Neighbor: %s", isis_print_id(tptr
, lan_alen
)));
2502 case ISIS_TLV_PADDING
:
2505 case ISIS_TLV_MT_IS_REACH
:
2506 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2507 if (mt_len
== 0) /* did something go wrong ? */
2511 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
2512 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
);
2513 if (ext_is_len
== 0) /* did something go wrong ? */
2521 case ISIS_TLV_IS_ALIAS_ID
:
2522 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
2523 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
);
2524 if (ext_is_len
== 0) /* did something go wrong ? */
2531 case ISIS_TLV_EXT_IS_REACH
:
2532 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
2533 ext_is_len
= isis_print_ext_is_reach(ndo
, tptr
, "\n\t ", tlv_type
);
2534 if (ext_is_len
== 0) /* did something go wrong ? */
2540 case ISIS_TLV_IS_REACH
:
2541 if (!ND_TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
2543 ND_PRINT((ndo
, "\n\t %s",
2544 tok2str(isis_is_reach_virtual_values
,
2545 "bogus virtual flag 0x%02x",
2547 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
2548 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
2549 if (!ND_TTEST(*tlv_is_reach
))
2551 ND_PRINT((ndo
, "\n\t IS Neighbor: %s",
2552 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
)));
2553 isis_print_metric_block(ndo
, &tlv_is_reach
->isis_metric_block
);
2554 tmp
-= sizeof(struct isis_tlv_is_reach
);
2559 case ISIS_TLV_ESNEIGH
:
2560 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
2561 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
2562 if (!ND_TTEST(*tlv_es_reach
))
2564 ND_PRINT((ndo
, "\n\t ES Neighbor: %s",
2565 isis_print_id(tlv_es_reach
->neighbor_sysid
, SYSTEM_ID_LEN
)));
2566 isis_print_metric_block(ndo
, &tlv_es_reach
->isis_metric_block
);
2567 tmp
-= sizeof(struct isis_tlv_es_reach
);
2572 /* those two TLVs share the same format */
2573 case ISIS_TLV_INT_IP_REACH
:
2574 case ISIS_TLV_EXT_IP_REACH
:
2575 if (!isis_print_tlv_ip_reach(ndo
, pptr
, "\n\t ", tlv_len
))
2579 case ISIS_TLV_EXTD_IP_REACH
:
2581 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET
);
2582 if (ext_ip_len
== 0) /* did something go wrong ? */
2589 case ISIS_TLV_MT_IP_REACH
:
2590 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2591 if (mt_len
== 0) { /* did something go wrong ? */
2598 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET
);
2599 if (ext_ip_len
== 0) /* did something go wrong ? */
2607 case ISIS_TLV_IP6_REACH
:
2609 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET6
);
2610 if (ext_ip_len
== 0) /* did something go wrong ? */
2617 case ISIS_TLV_MT_IP6_REACH
:
2618 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2619 if (mt_len
== 0) { /* did something go wrong ? */
2626 ext_ip_len
= isis_print_extd_ip_reach(ndo
, tptr
, "\n\t ", AF_INET6
);
2627 if (ext_ip_len
== 0) /* did something go wrong ? */
2634 case ISIS_TLV_IP6ADDR
:
2635 while (tmp
>=sizeof(struct in6_addr
)) {
2636 if (!ND_TTEST2(*tptr
, sizeof(struct in6_addr
)))
2639 ND_PRINT((ndo
, "\n\t IPv6 interface address: %s",
2640 ip6addr_string(ndo
, tptr
)));
2642 tptr
+= sizeof(struct in6_addr
);
2643 tmp
-= sizeof(struct in6_addr
);
2648 if (!ND_TTEST2(*tptr
, 1))
2651 ND_PRINT((ndo
, "\n\t %s: ",
2652 tok2str(isis_subtlv_auth_values
,
2653 "unknown Authentication type 0x%02x",
2657 case ISIS_SUBTLV_AUTH_SIMPLE
:
2658 for(i
=1;i
<tlv_len
;i
++) {
2659 if (!ND_TTEST2(*(tptr
+ i
), 1))
2661 ND_PRINT((ndo
, "%c", *(tptr
+ i
)));
2664 case ISIS_SUBTLV_AUTH_MD5
:
2665 for(i
=1;i
<tlv_len
;i
++) {
2666 if (!ND_TTEST2(*(tptr
+ i
), 1))
2668 ND_PRINT((ndo
, "%02x", *(tptr
+ i
)));
2670 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
2671 ND_PRINT((ndo
, ", (malformed subTLV) "));
2673 #ifdef HAVE_LIBCRYPTO
2674 sigcheck
= signature_verify(ndo
, optr
, length
,
2675 (unsigned char *)tptr
+ 1);
2677 sigcheck
= CANT_CHECK_SIGNATURE
;
2679 ND_PRINT((ndo
, " (%s)", tok2str(signature_check_values
, "Unknown", sigcheck
)));
2682 case ISIS_SUBTLV_AUTH_GENERIC
:
2683 key_id
= EXTRACT_16BITS((tptr
+1));
2684 ND_PRINT((ndo
, "%u, password: ", key_id
));
2685 for(i
=1 + sizeof(uint16_t);i
<tlv_len
;i
++) {
2686 if (!ND_TTEST2(*(tptr
+ i
), 1))
2688 ND_PRINT((ndo
, "%02x", *(tptr
+ i
)));
2691 case ISIS_SUBTLV_AUTH_PRIVATE
:
2693 if (!print_unknown_data(ndo
, tptr
+ 1, "\n\t\t ", tlv_len
- 1))
2699 case ISIS_TLV_PTP_ADJ
:
2700 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
2702 if (!ND_TTEST2(*tptr
, 1))
2704 ND_PRINT((ndo
, "\n\t Adjacency State: %s (%u)",
2705 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
2709 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
2710 if (!ND_TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
2711 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
2713 ND_PRINT((ndo
, "\n\t Extended Local circuit-ID: 0x%08x",
2714 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
)));
2715 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
2717 if(tmp
>=SYSTEM_ID_LEN
) {
2718 if (!ND_TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
2720 ND_PRINT((ndo
, "\n\t Neighbor System-ID: %s",
2721 isis_print_id(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
)));
2724 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
2725 if (!ND_TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
2726 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
2728 ND_PRINT((ndo
, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2729 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)));
2733 case ISIS_TLV_PROTOCOLS
:
2734 ND_PRINT((ndo
, "\n\t NLPID(s): "));
2736 if (!ND_TTEST2(*(tptr
), 1))
2738 ND_PRINT((ndo
, "%s (0x%02x)",
2739 tok2str(nlpid_values
,
2743 if (tmp
>1) /* further NPLIDs ? - put comma */
2744 ND_PRINT((ndo
, ", "));
2750 case ISIS_TLV_MT_PORT_CAP
:
2752 if (!ND_TTEST2(*(tptr
), 2))
2755 ND_PRINT((ndo
, "\n\t RES: %d, MTID(s): %d",
2756 (EXTRACT_16BITS (tptr
) >> 12),
2757 (EXTRACT_16BITS (tptr
) & 0x0fff)));
2763 isis_print_mt_port_cap_subtlv(ndo
, tptr
, tmp
);
2768 case ISIS_TLV_MT_CAPABILITY
:
2770 if (!ND_TTEST2(*(tptr
), 2))
2773 ND_PRINT((ndo
, "\n\t O: %d, RES: %d, MTID(s): %d",
2774 (EXTRACT_16BITS(tptr
) >> 15) & 0x01,
2775 (EXTRACT_16BITS(tptr
) >> 12) & 0x07,
2776 EXTRACT_16BITS(tptr
) & 0x0fff));
2782 isis_print_mt_capability_subtlv(ndo
, tptr
, tmp
);
2786 case ISIS_TLV_TE_ROUTER_ID
:
2787 if (!ND_TTEST2(*pptr
, sizeof(struct in_addr
)))
2789 ND_PRINT((ndo
, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo
, pptr
)));
2792 case ISIS_TLV_IPADDR
:
2793 while (tmp
>=sizeof(struct in_addr
)) {
2794 if (!ND_TTEST2(*tptr
, sizeof(struct in_addr
)))
2796 ND_PRINT((ndo
, "\n\t IPv4 interface address: %s", ipaddr_string(ndo
, tptr
)));
2797 tptr
+= sizeof(struct in_addr
);
2798 tmp
-= sizeof(struct in_addr
);
2802 case ISIS_TLV_HOSTNAME
:
2803 ND_PRINT((ndo
, "\n\t Hostname: "));
2805 if (!ND_TTEST2(*tptr
, 1))
2807 ND_PRINT((ndo
, "%c", *tptr
++));
2812 case ISIS_TLV_SHARED_RISK_GROUP
:
2813 if (tmp
< NODE_ID_LEN
)
2815 if (!ND_TTEST2(*tptr
, NODE_ID_LEN
))
2817 ND_PRINT((ndo
, "\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
)));
2818 tptr
+=(NODE_ID_LEN
);
2823 if (!ND_TTEST2(*tptr
, 1))
2825 ND_PRINT((ndo
, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered"));
2828 if (tmp
< sizeof(struct in_addr
))
2830 if (!ND_TTEST2(*tptr
, sizeof(struct in_addr
)))
2832 ND_PRINT((ndo
, "\n\t IPv4 interface address: %s", ipaddr_string(ndo
, tptr
)));
2833 tptr
+=sizeof(struct in_addr
);
2834 tmp
-=sizeof(struct in_addr
);
2836 if (tmp
< sizeof(struct in_addr
))
2838 if (!ND_TTEST2(*tptr
, sizeof(struct in_addr
)))
2840 ND_PRINT((ndo
, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo
, tptr
)));
2841 tptr
+=sizeof(struct in_addr
);
2842 tmp
-=sizeof(struct in_addr
);
2845 if (!ND_TTEST2(*tptr
, 4))
2847 ND_PRINT((ndo
, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
)));
2854 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2855 while(tmp
>=sizeof(struct isis_tlv_lsp
)) {
2856 if (!ND_TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2858 ND_PRINT((ndo
, "\n\t lsp-id: %s",
2859 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
)));
2860 if (!ND_TTEST2(tlv_lsp
->sequence_number
, 4))
2862 ND_PRINT((ndo
, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp
->sequence_number
)));
2863 if (!ND_TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2865 ND_PRINT((ndo
, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
)));
2866 if (!ND_TTEST2(tlv_lsp
->checksum
, 2))
2868 ND_PRINT((ndo
, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp
->checksum
)));
2869 tmp
-=sizeof(struct isis_tlv_lsp
);
2874 case ISIS_TLV_CHECKSUM
:
2875 if (tmp
< ISIS_TLV_CHECKSUM_MINLEN
)
2877 if (!ND_TTEST2(*tptr
, ISIS_TLV_CHECKSUM_MINLEN
))
2879 ND_PRINT((ndo
, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
)));
2880 /* do not attempt to verify the checksum if it is zero
2881 * most likely a HMAC-MD5 TLV is also present and
2882 * to avoid conflicts the checksum TLV is zeroed.
2883 * see rfc3358 for details
2885 osi_print_cksum(ndo
, optr
, EXTRACT_16BITS(tptr
), tptr
-optr
, length
);
2888 case ISIS_TLV_MT_SUPPORTED
:
2889 if (tmp
< ISIS_TLV_MT_SUPPORTED_MINLEN
)
2892 /* length can only be a multiple of 2, otherwise there is
2893 something broken -> so decode down until length is 1 */
2895 mt_len
= isis_print_mtid(ndo
, tptr
, "\n\t ");
2896 if (mt_len
== 0) /* did something go wrong ? */
2901 ND_PRINT((ndo
, "\n\t malformed MT-ID"));
2907 case ISIS_TLV_RESTART_SIGNALING
:
2908 /* first attempt to decode the flags */
2909 if (tmp
< ISIS_TLV_RESTART_SIGNALING_FLAGLEN
)
2911 if (!ND_TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_FLAGLEN
))
2913 ND_PRINT((ndo
, "\n\t Flags [%s]",
2914 bittok2str(isis_restart_flag_values
, "none", *tptr
)));
2915 tptr
+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2916 tmp
-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN
;
2918 /* is there anything other than the flags field? */
2922 if (tmp
< ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
)
2924 if (!ND_TTEST2(*tptr
, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
))
2927 ND_PRINT((ndo
, ", Remaining holding time %us", EXTRACT_16BITS(tptr
)));
2928 tptr
+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2929 tmp
-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN
;
2931 /* is there an additional sysid field present ?*/
2932 if (tmp
== SYSTEM_ID_LEN
) {
2933 if (!ND_TTEST2(*tptr
, SYSTEM_ID_LEN
))
2935 ND_PRINT((ndo
, ", for %s", isis_print_id(tptr
,SYSTEM_ID_LEN
)));
2939 case ISIS_TLV_IDRP_INFO
:
2940 if (tmp
< ISIS_TLV_IDRP_INFO_MINLEN
)
2942 if (!ND_TTEST2(*tptr
, ISIS_TLV_IDRP_INFO_MINLEN
))
2944 ND_PRINT((ndo
, "\n\t Inter-Domain Information Type: %s",
2945 tok2str(isis_subtlv_idrp_values
,
2949 case ISIS_SUBTLV_IDRP_ASN
:
2950 if (!ND_TTEST2(*tptr
, 2)) /* fetch AS number */
2952 ND_PRINT((ndo
, "AS Number: %u", EXTRACT_16BITS(tptr
)));
2954 case ISIS_SUBTLV_IDRP_LOCAL
:
2955 case ISIS_SUBTLV_IDRP_RES
:
2957 if (!print_unknown_data(ndo
, tptr
, "\n\t ", tlv_len
- 1))
2963 case ISIS_TLV_LSP_BUFFERSIZE
:
2964 if (tmp
< ISIS_TLV_LSP_BUFFERSIZE_MINLEN
)
2966 if (!ND_TTEST2(*tptr
, ISIS_TLV_LSP_BUFFERSIZE_MINLEN
))
2968 ND_PRINT((ndo
, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr
)));
2971 case ISIS_TLV_PART_DIS
:
2972 while (tmp
>= SYSTEM_ID_LEN
) {
2973 if (!ND_TTEST2(*tptr
, SYSTEM_ID_LEN
))
2975 ND_PRINT((ndo
, "\n\t %s", isis_print_id(tptr
, SYSTEM_ID_LEN
)));
2976 tptr
+=SYSTEM_ID_LEN
;
2981 case ISIS_TLV_PREFIX_NEIGH
:
2982 if (tmp
< sizeof(struct isis_metric_block
))
2984 if (!ND_TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2986 ND_PRINT((ndo
, "\n\t Metric Block"));
2987 isis_print_metric_block(ndo
, (const struct isis_metric_block
*)tptr
);
2988 tptr
+=sizeof(struct isis_metric_block
);
2989 tmp
-=sizeof(struct isis_metric_block
);
2992 if (!ND_TTEST2(*tptr
, 1))
2994 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2995 if (prefix_len
< 2) {
2996 ND_PRINT((ndo
, "\n\t\tAddress: prefix length %u < 2", prefix_len
));
3000 if (tmp
< prefix_len
/2)
3002 if (!ND_TTEST2(*tptr
, prefix_len
/ 2))
3004 ND_PRINT((ndo
, "\n\t\tAddress: %s/%u",
3005 isonsap_string(tptr
, prefix_len
/ 2), prefix_len
* 4));
3011 case ISIS_TLV_IIH_SEQNR
:
3012 if (tmp
< ISIS_TLV_IIH_SEQNR_MINLEN
)
3014 if (!ND_TTEST2(*tptr
, ISIS_TLV_IIH_SEQNR_MINLEN
)) /* check if four bytes are on the wire */
3016 ND_PRINT((ndo
, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr
)));
3019 case ISIS_TLV_VENDOR_PRIVATE
:
3020 if (tmp
< ISIS_TLV_VENDOR_PRIVATE_MINLEN
)
3022 if (!ND_TTEST2(*tptr
, ISIS_TLV_VENDOR_PRIVATE_MINLEN
)) /* check if enough byte for a full oui */
3024 vendor_id
= EXTRACT_24BITS(tptr
);
3025 ND_PRINT((ndo
, "\n\t Vendor: %s (%u)",
3026 tok2str(oui_values
, "Unknown", vendor_id
),
3030 if (tmp
> 0) /* hexdump the rest */
3031 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", tmp
))
3035 * FIXME those are the defined TLVs that lack a decoder
3036 * you are welcome to contribute code ;-)
3039 case ISIS_TLV_DECNET_PHASE4
:
3040 case ISIS_TLV_LUCENT_PRIVATE
:
3041 case ISIS_TLV_IPAUTH
:
3042 case ISIS_TLV_NORTEL_PRIVATE1
:
3043 case ISIS_TLV_NORTEL_PRIVATE2
:
3046 if (ndo
->ndo_vflag
<= 1) {
3047 if (!print_unknown_data(ndo
, pptr
, "\n\t\t", tlv_len
))
3052 /* do we want to see an additionally hexdump ? */
3053 if (ndo
->ndo_vflag
> 1) {
3054 if (!print_unknown_data(ndo
, pptr
, "\n\t ", tlv_len
))
3059 packet_len
-= tlv_len
;
3062 if (packet_len
!= 0) {
3063 ND_PRINT((ndo
, "\n\t %u straggler bytes", packet_len
));
3068 ND_PRINT((ndo
, "[|isis]"));
3072 ND_PRINT((ndo
, "\n\t\t packet exceeded snapshot"));
3077 osi_print_cksum(netdissect_options
*ndo
,
3078 const uint8_t *pptr
, uint16_t checksum
,
3079 u_int checksum_offset
, u_int length
)
3081 uint16_t calculated_checksum
;
3083 /* do not attempt to verify the checksum if it is zero,
3084 * if the total length is nonsense,
3085 * if the offset is nonsense,
3086 * or the base pointer is not sane
3089 || length
> ndo
->ndo_snaplen
3090 || checksum_offset
> ndo
->ndo_snaplen
3091 || checksum_offset
> length
) {
3092 ND_PRINT((ndo
, " (unverified)"));
3094 const char *truncated
= "trunc";
3096 printf("\nosi_print_cksum: %p %u %u %u\n", pptr
, checksum_offset
, length
, ndo
->ndo_snaplen
);
3097 ND_TCHECK2(pptr
, checksum_offset
+length
);
3099 calculated_checksum
= create_osi_cksum(pptr
, checksum_offset
, length
);
3100 if (checksum
== calculated_checksum
) {
3101 ND_PRINT((ndo
, " (correct)"));
3103 truncated
= "incorrect";
3107 ND_PRINT((ndo
, " (%s should be 0x%04x)", truncated
, calculated_checksum
));
3114 * c-style: whitesmith