]> The Tcpdump Group git mirrors - tcpdump/blob - print-isoclns.c
Parse the IS-IS Instance Identifier TLV from RFC8202
[tcpdump] / print-isoclns.c
1 /*
2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
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
16 * written permission.
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.
20 *
21 * Original code by Matt Thomas, Digital Equipment Corporation
22 *
23 * Extensively modified by Hannes Gredler (hannes@gredler.at) for more
24 * complete IS-IS & CLNP support.
25 */
26
27 /* \summary: ISO CLNS, ESIS, and ISIS printer */
28
29 /*
30 * specification:
31 *
32 * CLNP: ISO 8473 (respective ITU version is at https://www.itu.int/rec/T-REC-X.233/en/)
33 * ES-IS: ISO 9542
34 * IS-IS: ISO 10589
35 */
36
37 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
40
41 #include "netdissect-stdinc.h"
42
43 #include <string.h>
44
45 #include "netdissect.h"
46 #include "addrtoname.h"
47 #include "nlpid.h"
48 #include "extract.h"
49 #include "gmpls.h"
50 #include "oui.h"
51 #include "signature.h"
52
53
54 /*
55 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
56 */
57
58 #define SYSTEM_ID_LEN MAC_ADDR_LEN
59 #define NODE_ID_LEN (SYSTEM_ID_LEN+1)
60 #define LSP_ID_LEN (SYSTEM_ID_LEN+2)
61
62 #define ISIS_VERSION 1
63 #define ESIS_VERSION 1
64 #define CLNP_VERSION 1
65
66 #define ISIS_PDU_TYPE_MASK 0x1F
67 #define ESIS_PDU_TYPE_MASK 0x1F
68 #define CLNP_PDU_TYPE_MASK 0x1F
69 #define CLNP_FLAG_MASK 0xE0
70 #define ISIS_LAN_PRIORITY_MASK 0x7F
71
72 #define ISIS_PDU_L1_LAN_IIH 15
73 #define ISIS_PDU_L2_LAN_IIH 16
74 #define ISIS_PDU_PTP_IIH 17
75 #define ISIS_PDU_L1_LSP 18
76 #define ISIS_PDU_L2_LSP 20
77 #define ISIS_PDU_L1_CSNP 24
78 #define ISIS_PDU_L2_CSNP 25
79 #define ISIS_PDU_L1_PSNP 26
80 #define ISIS_PDU_L2_PSNP 27
81
82 static const struct tok isis_pdu_values[] = {
83 { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
84 { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
85 { ISIS_PDU_PTP_IIH, "p2p IIH"},
86 { ISIS_PDU_L1_LSP, "L1 LSP"},
87 { ISIS_PDU_L2_LSP, "L2 LSP"},
88 { ISIS_PDU_L1_CSNP, "L1 CSNP"},
89 { ISIS_PDU_L2_CSNP, "L2 CSNP"},
90 { ISIS_PDU_L1_PSNP, "L1 PSNP"},
91 { ISIS_PDU_L2_PSNP, "L2 PSNP"},
92 { 0, NULL}
93 };
94
95 /*
96 * A TLV is a tuple of a type, length and a value and is normally used for
97 * encoding information in all sorts of places. This is an enumeration of
98 * the well known types.
99 *
100 * list taken from rfc3359 plus some memory from veterans ;-)
101 */
102
103 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
104 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
105 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
106 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
107 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
108 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
109 #define ISIS_TLV_INSTANCE_ID 7 /* rfc8202 */
110 #define ISIS_TLV_PADDING 8 /* iso10589 */
111 #define ISIS_TLV_LSP 9 /* iso10589 */
112 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
113 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
114 #define ISIS_TLV_CHECKSUM_MINLEN 2
115 #define ISIS_TLV_POI 13 /* rfc6232 */
116 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
117 #define ISIS_TLV_EXT_IS_REACH 22 /* rfc5305 */
118 #define ISIS_TLV_IS_ALIAS_ID 24 /* rfc5311 */
119 #define ISIS_TLV_DECNET_PHASE4 42
120 #define ISIS_TLV_LUCENT_PRIVATE 66
121 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
122 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
123 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
124 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
125 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
126 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
127 #define ISIS_TLV_TE_ROUTER_ID 134 /* rfc5305 */
128 #define ISIS_TLV_EXTD_IP_REACH 135 /* rfc5305 */
129 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
130 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
131 #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
132 #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
133 #define ISIS_TLV_NORTEL_PRIVATE1 176
134 #define ISIS_TLV_NORTEL_PRIVATE2 177
135 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
136 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
137 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
138 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
139 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
140 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
141 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
142 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
143 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
144 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
145 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
146 #define ISIS_TLV_ROUTER_CAPABILITY 242 /* rfc7981 */
147 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
148 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
149
150 static const struct tok isis_tlv_values[] = {
151 { ISIS_TLV_AREA_ADDR, "Area address(es)"},
152 { ISIS_TLV_IS_REACH, "IS Reachability"},
153 { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
154 { ISIS_TLV_PART_DIS, "Partition DIS"},
155 { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
156 { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
157 { ISIS_TLV_INSTANCE_ID, "Instance Identifier"},
158 { ISIS_TLV_PADDING, "Padding"},
159 { ISIS_TLV_LSP, "LSP entries"},
160 { ISIS_TLV_AUTH, "Authentication"},
161 { ISIS_TLV_CHECKSUM, "Checksum"},
162 { ISIS_TLV_POI, "Purge Originator Identifier"},
163 { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
164 { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
165 { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
166 { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
167 { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
168 { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
169 { ISIS_TLV_PROTOCOLS, "Protocols supported"},
170 { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
171 { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
172 { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
173 { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
174 { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
175 { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
176 { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
177 { ISIS_TLV_MT_PORT_CAP, "Multi-Topology-Aware Port Capability"},
178 { ISIS_TLV_MT_CAPABILITY, "Multi-Topology Capability"},
179 { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
180 { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
181 { ISIS_TLV_HOSTNAME, "Hostname"},
182 { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
183 { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
184 { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
185 { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
186 { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
187 { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
188 { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
189 { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
190 { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
191 { ISIS_TLV_ROUTER_CAPABILITY, "IS-IS Router Capability"},
192 { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
193 { 0, NULL }
194 };
195
196 #define ESIS_OPTION_PROTOCOLS 129
197 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
198 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
199 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
200 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
201 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
202 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
203
204 static const struct tok esis_option_values[] = {
205 { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
206 { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
207 { ESIS_OPTION_SECURITY, "Security" },
208 { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
209 { ESIS_OPTION_PRIORITY, "Priority" },
210 { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
211 { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
212 { 0, NULL }
213 };
214
215 #define CLNP_OPTION_DISCARD_REASON 193
216 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
217 #define CLNP_OPTION_SECURITY 197 /* iso8473 */
218 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
219 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
220 #define CLNP_OPTION_PADDING 204 /* iso8473 */
221 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
222
223 static const struct tok clnp_option_values[] = {
224 { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
225 { CLNP_OPTION_PRIORITY, "Priority"},
226 { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
227 { CLNP_OPTION_SECURITY, "Security"},
228 { CLNP_OPTION_SOURCE_ROUTING, "Source Routing"},
229 { CLNP_OPTION_ROUTE_RECORDING, "Route Recording"},
230 { CLNP_OPTION_PADDING, "Padding"},
231 { 0, NULL }
232 };
233
234 static const struct tok clnp_option_rfd_class_values[] = {
235 { 0x0, "General"},
236 { 0x8, "Address"},
237 { 0x9, "Source Routeing"},
238 { 0xa, "Lifetime"},
239 { 0xb, "PDU Discarded"},
240 { 0xc, "Reassembly"},
241 { 0, NULL }
242 };
243
244 static const struct tok clnp_option_rfd_general_values[] = {
245 { 0x0, "Reason not specified"},
246 { 0x1, "Protocol procedure error"},
247 { 0x2, "Incorrect checksum"},
248 { 0x3, "PDU discarded due to congestion"},
249 { 0x4, "Header syntax error (cannot be parsed)"},
250 { 0x5, "Segmentation needed but not permitted"},
251 { 0x6, "Incomplete PDU received"},
252 { 0x7, "Duplicate option"},
253 { 0, NULL }
254 };
255
256 static const struct tok clnp_option_rfd_address_values[] = {
257 { 0x0, "Destination address unreachable"},
258 { 0x1, "Destination address unknown"},
259 { 0, NULL }
260 };
261
262 static const struct tok clnp_option_rfd_source_routeing_values[] = {
263 { 0x0, "Unspecified source routeing error"},
264 { 0x1, "Syntax error in source routeing field"},
265 { 0x2, "Unknown address in source routeing field"},
266 { 0x3, "Path not acceptable"},
267 { 0, NULL }
268 };
269
270 static const struct tok clnp_option_rfd_lifetime_values[] = {
271 { 0x0, "Lifetime expired while data unit in transit"},
272 { 0x1, "Lifetime expired during reassembly"},
273 { 0, NULL }
274 };
275
276 static const struct tok clnp_option_rfd_pdu_discard_values[] = {
277 { 0x0, "Unsupported option not specified"},
278 { 0x1, "Unsupported protocol version"},
279 { 0x2, "Unsupported security option"},
280 { 0x3, "Unsupported source routeing option"},
281 { 0x4, "Unsupported recording of route option"},
282 { 0, NULL }
283 };
284
285 static const struct tok clnp_option_rfd_reassembly_values[] = {
286 { 0x0, "Reassembly interference"},
287 { 0, NULL }
288 };
289
290 /* array of 16 error-classes */
291 static const struct tok *clnp_option_rfd_error_class[] = {
292 clnp_option_rfd_general_values,
293 NULL,
294 NULL,
295 NULL,
296 NULL,
297 NULL,
298 NULL,
299 NULL,
300 clnp_option_rfd_address_values,
301 clnp_option_rfd_source_routeing_values,
302 clnp_option_rfd_lifetime_values,
303 clnp_option_rfd_pdu_discard_values,
304 clnp_option_rfd_reassembly_values,
305 NULL,
306 NULL,
307 NULL
308 };
309
310 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
311 #define CLNP_OPTION_SCOPE_MASK 0xc0
312 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
313 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
314 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
315
316 static const struct tok clnp_option_scope_values[] = {
317 { CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
318 { CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
319 { CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
320 { 0, NULL }
321 };
322
323 static const struct tok clnp_option_sr_rr_values[] = {
324 { 0x0, "partial"},
325 { 0x1, "complete"},
326 { 0, NULL }
327 };
328
329 static const struct tok clnp_option_sr_rr_string_values[] = {
330 { CLNP_OPTION_SOURCE_ROUTING, "source routing"},
331 { CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
332 { 0, NULL }
333 };
334
335 static const struct tok clnp_option_qos_global_values[] = {
336 { 0x20, "reserved"},
337 { 0x10, "sequencing vs. delay"},
338 { 0x08, "congested"},
339 { 0x04, "delay vs. cost"},
340 { 0x02, "error vs. delay"},
341 { 0x01, "error vs. cost"},
342 { 0, NULL }
343 };
344
345 static const struct tok isis_tlv_router_capability_flags[] = {
346 { 0x01, "S bit"},
347 { 0x02, "D bit"},
348 { 0, NULL }
349 };
350
351 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* rfc5305 */
352 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */
353 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* rfc5305 */
354 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* rfc5305 */
355 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* rfc5305 */
356 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* rfc5305 */
357 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* rfc5305 */
358 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
359 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
360 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* rfc5305 */
361 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
362 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
363 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
364 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
365
366 #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
367
368 static const struct tok isis_ext_is_reach_subtlv_values[] = {
369 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
370 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
371 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
372 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
373 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
374 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
375 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
376 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
377 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
378 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE, "Link Attribute" },
379 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
380 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
381 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" },
382 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" },
383 { ISIS_SUBTLV_SPB_METRIC, "SPB Metric" },
384 { 250, "Reserved for cisco specific extensions" },
385 { 251, "Reserved for cisco specific extensions" },
386 { 252, "Reserved for cisco specific extensions" },
387 { 253, "Reserved for cisco specific extensions" },
388 { 254, "Reserved for cisco specific extensions" },
389 { 255, "Reserved for future expansion" },
390 { 0, NULL }
391 };
392
393 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
394 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
395 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
396
397 static const struct tok isis_ext_ip_reach_subtlv_values[] = {
398 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
399 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
400 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
401 { 0, NULL }
402 };
403
404 static const struct tok isis_subtlv_link_attribute_values[] = {
405 { 0x01, "Local Protection Available" },
406 { 0x02, "Link excluded from local protection path" },
407 { 0x04, "Local maintenance required"},
408 { 0, NULL }
409 };
410
411 #define ISIS_SUBTLV_AUTH_SIMPLE 1
412 #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
413 #define ISIS_SUBTLV_AUTH_MD5 54
414 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
415 #define ISIS_SUBTLV_AUTH_PRIVATE 255
416
417 static const struct tok isis_subtlv_auth_values[] = {
418 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
419 { ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
420 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
421 { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
422 { 0, NULL }
423 };
424
425 #define ISIS_SUBTLV_IDRP_RES 0
426 #define ISIS_SUBTLV_IDRP_LOCAL 1
427 #define ISIS_SUBTLV_IDRP_ASN 2
428
429 static const struct tok isis_subtlv_idrp_values[] = {
430 { ISIS_SUBTLV_IDRP_RES, "Reserved"},
431 { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
432 { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
433 { 0, NULL}
434 };
435
436 #define ISIS_SUBTLV_SPB_MCID 4
437 #define ISIS_SUBTLV_SPB_DIGEST 5
438 #define ISIS_SUBTLV_SPB_BVID 6
439
440 #define ISIS_SUBTLV_SPB_INSTANCE 1
441 #define ISIS_SUBTLV_SPBM_SI 3
442
443 #define ISIS_SPB_MCID_LEN 51
444 #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
445 #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
446 #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
447 #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
448 #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
449
450 static const struct tok isis_mt_port_cap_subtlv_values[] = {
451 { ISIS_SUBTLV_SPB_MCID, "SPB MCID" },
452 { ISIS_SUBTLV_SPB_DIGEST, "SPB Digest" },
453 { ISIS_SUBTLV_SPB_BVID, "SPB BVID" },
454 { 0, NULL }
455 };
456
457 static const struct tok isis_mt_capability_subtlv_values[] = {
458 { ISIS_SUBTLV_SPB_INSTANCE, "SPB Instance" },
459 { ISIS_SUBTLV_SPBM_SI, "SPBM Service Identifier and Unicast Address" },
460 { 0, NULL }
461 };
462
463 struct isis_spb_mcid {
464 nd_uint8_t format_id;
465 nd_byte name[32];
466 nd_uint16_t revision_lvl;
467 nd_byte digest[16];
468 };
469
470 struct isis_subtlv_spb_mcid {
471 struct isis_spb_mcid mcid;
472 struct isis_spb_mcid aux_mcid;
473 };
474
475 struct isis_subtlv_spb_instance {
476 nd_byte cist_root_id[8];
477 nd_uint32_t cist_external_root_path_cost;
478 nd_uint16_t bridge_priority;
479 nd_uint32_t spsourceid;
480 nd_uint8_t no_of_trees;
481 };
482
483 #define CLNP_SEGMENT_PART 0x80
484 #define CLNP_MORE_SEGMENTS 0x40
485 #define CLNP_REQUEST_ER 0x20
486
487 static const struct tok clnp_flag_values[] = {
488 { CLNP_SEGMENT_PART, "Segmentation permitted"},
489 { CLNP_MORE_SEGMENTS, "more Segments"},
490 { CLNP_REQUEST_ER, "request Error Report"},
491 { 0, NULL}
492 };
493
494 #define ISIS_MASK_LSP_OL_BIT(x) (GET_U_1(x)&0x4)
495 #define ISIS_MASK_LSP_ISTYPE_BITS(x) (GET_U_1(x)&0x3)
496 #define ISIS_MASK_LSP_PARTITION_BIT(x) (GET_U_1(x)&0x80)
497 #define ISIS_MASK_LSP_ATT_BITS(x) (GET_U_1(x)&0x78)
498 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) (GET_U_1(x)&0x40)
499 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) (GET_U_1(x)&0x20)
500 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) (GET_U_1(x)&0x10)
501 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) (GET_U_1(x)&0x8)
502
503 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
504 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
505
506 static const struct tok isis_mt_flag_values[] = {
507 { 0x4000, "ATT bit set"},
508 { 0x8000, "Overload bit set"},
509 { 0, NULL}
510 };
511
512 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
513 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
514
515 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
516 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
517
518 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) (GET_U_1(x)&0x80)
519 #define ISIS_LSP_TLV_METRIC_IE(x) (GET_U_1(x)&0x40)
520 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) (GET_U_1(x)&0x80)
521 #define ISIS_LSP_TLV_METRIC_VALUE(x) (GET_U_1(x)&0x3f)
522
523 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
524
525 static const struct tok isis_mt_values[] = {
526 { 0, "IPv4 unicast"},
527 { 1, "In-Band Management"},
528 { 2, "IPv6 unicast"},
529 { 3, "Multicast"},
530 { 4095, "Development, Experimental or Proprietary"},
531 { 0, NULL }
532 };
533
534 static const struct tok isis_iih_circuit_type_values[] = {
535 { 1, "Level 1 only"},
536 { 2, "Level 2 only"},
537 { 3, "Level 1, Level 2"},
538 { 0, NULL}
539 };
540
541 #define ISIS_LSP_TYPE_UNUSED0 0
542 #define ISIS_LSP_TYPE_LEVEL_1 1
543 #define ISIS_LSP_TYPE_UNUSED2 2
544 #define ISIS_LSP_TYPE_LEVEL_2 3
545
546 static const struct tok isis_lsp_istype_values[] = {
547 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
548 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
549 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
550 { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"},
551 { 0, NULL }
552 };
553
554 /*
555 * Katz's point to point adjacency TLV uses codes to tell us the state of
556 * the remote adjacency. Enumerate them.
557 */
558
559 #define ISIS_PTP_ADJ_UP 0
560 #define ISIS_PTP_ADJ_INIT 1
561 #define ISIS_PTP_ADJ_DOWN 2
562
563 static const struct tok isis_ptp_adjancey_values[] = {
564 { ISIS_PTP_ADJ_UP, "Up" },
565 { ISIS_PTP_ADJ_INIT, "Initializing" },
566 { ISIS_PTP_ADJ_DOWN, "Down" },
567 { 0, NULL}
568 };
569
570 struct isis_tlv_ptp_adj {
571 nd_uint8_t adjacency_state;
572 nd_uint32_t extd_local_circuit_id;
573 nd_byte neighbor_sysid[SYSTEM_ID_LEN];
574 nd_uint32_t neighbor_extd_local_circuit_id;
575 };
576
577 static void osi_print_cksum(netdissect_options *, const uint8_t *pptr,
578 uint16_t checksum, int checksum_offset, u_int length);
579 static int clnp_print(netdissect_options *, const uint8_t *, u_int);
580 static void esis_print(netdissect_options *, const uint8_t *, u_int);
581 static int isis_print(netdissect_options *, const uint8_t *, u_int);
582
583 struct isis_metric_block {
584 nd_uint8_t metric_default;
585 nd_uint8_t metric_delay;
586 nd_uint8_t metric_expense;
587 nd_uint8_t metric_error;
588 };
589
590 struct isis_tlv_is_reach {
591 struct isis_metric_block isis_metric_block;
592 nd_byte neighbor_nodeid[NODE_ID_LEN];
593 };
594
595 struct isis_tlv_es_reach {
596 struct isis_metric_block isis_metric_block;
597 nd_byte neighbor_sysid[SYSTEM_ID_LEN];
598 };
599
600 struct isis_tlv_ip_reach {
601 struct isis_metric_block isis_metric_block;
602 nd_ipv4 prefix;
603 nd_ipv4 mask;
604 };
605
606 static const struct tok isis_is_reach_virtual_values[] = {
607 { 0, "IsNotVirtual"},
608 { 1, "IsVirtual"},
609 { 0, NULL }
610 };
611
612 static const struct tok isis_restart_flag_values[] = {
613 { 0x1, "Restart Request"},
614 { 0x2, "Restart Acknowledgement"},
615 { 0x4, "Suppress adjacency advertisement"},
616 { 0, NULL }
617 };
618
619 struct isis_common_header {
620 nd_uint8_t nlpid;
621 nd_uint8_t fixed_len;
622 nd_uint8_t version; /* Protocol version */
623 nd_uint8_t id_length;
624 nd_uint8_t pdu_type; /* 3 MSbits are reserved */
625 nd_uint8_t pdu_version; /* Packet format version */
626 nd_byte reserved;
627 nd_uint8_t max_area;
628 };
629
630 struct isis_iih_lan_header {
631 nd_uint8_t circuit_type;
632 nd_byte source_id[SYSTEM_ID_LEN];
633 nd_uint16_t holding_time;
634 nd_uint16_t pdu_len;
635 nd_uint8_t priority;
636 nd_byte lan_id[NODE_ID_LEN];
637 };
638
639 struct isis_iih_ptp_header {
640 nd_uint8_t circuit_type;
641 nd_byte source_id[SYSTEM_ID_LEN];
642 nd_uint16_t holding_time;
643 nd_uint16_t pdu_len;
644 nd_uint8_t circuit_id;
645 };
646
647 struct isis_lsp_header {
648 nd_uint16_t pdu_len;
649 nd_uint16_t remaining_lifetime;
650 nd_byte lsp_id[LSP_ID_LEN];
651 nd_uint32_t sequence_number;
652 nd_uint16_t checksum;
653 nd_uint8_t typeblock;
654 };
655
656 struct isis_csnp_header {
657 nd_uint16_t pdu_len;
658 nd_byte source_id[NODE_ID_LEN];
659 nd_byte start_lsp_id[LSP_ID_LEN];
660 nd_byte end_lsp_id[LSP_ID_LEN];
661 };
662
663 struct isis_psnp_header {
664 nd_uint16_t pdu_len;
665 nd_byte source_id[NODE_ID_LEN];
666 };
667
668 struct isis_tlv_lsp {
669 nd_uint16_t remaining_lifetime;
670 nd_byte lsp_id[LSP_ID_LEN];
671 nd_uint32_t sequence_number;
672 nd_uint16_t checksum;
673 };
674
675 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
676 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
677 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
678 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
679 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
680 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
681
682 void
683 isoclns_print(netdissect_options *ndo, const u_char *p, u_int length)
684 {
685 ndo->ndo_protocol = "isoclns";
686 ND_TCHECK_1(p); /* enough bytes on the wire ? */
687
688 if (ndo->ndo_eflag)
689 ND_PRINT("OSI NLPID %s (0x%02x): ",
690 tok2str(nlpid_values, "Unknown", GET_U_1(p)),
691 GET_U_1(p));
692
693 switch (GET_U_1(p)) {
694
695 case NLPID_CLNP:
696 if (!clnp_print(ndo, p, length))
697 print_unknown_data(ndo, p, "\n\t", length);
698 break;
699
700 case NLPID_ESIS:
701 esis_print(ndo, p, length);
702 return;
703
704 case NLPID_ISIS:
705 if (!isis_print(ndo, p, length))
706 print_unknown_data(ndo, p, "\n\t", length);
707 break;
708
709 case NLPID_NULLNS:
710 ND_PRINT("%slength: %u", ndo->ndo_eflag ? "" : ", ", length);
711 break;
712
713 case NLPID_Q933:
714 q933_print(ndo, p + 1, length - 1);
715 break;
716
717 case NLPID_IP:
718 ip_print(ndo, p + 1, length - 1);
719 break;
720
721 case NLPID_IP6:
722 ip6_print(ndo, p + 1, length - 1);
723 break;
724
725 case NLPID_PPP:
726 ppp_print(ndo, p + 1, length - 1);
727 break;
728
729 default:
730 if (!ndo->ndo_eflag)
731 ND_PRINT("OSI NLPID 0x%02x unknown", GET_U_1(p));
732 ND_PRINT("%slength: %u", ndo->ndo_eflag ? "" : ", ", length);
733 if (length > 1)
734 print_unknown_data(ndo, p, "\n\t", length);
735 break;
736 }
737 return;
738 trunc:
739 nd_print_trunc(ndo);
740 }
741
742 #define CLNP_PDU_ER 1
743 #define CLNP_PDU_DT 28
744 #define CLNP_PDU_MD 29
745 #define CLNP_PDU_ERQ 30
746 #define CLNP_PDU_ERP 31
747
748 static const struct tok clnp_pdu_values[] = {
749 { CLNP_PDU_ER, "Error Report"},
750 { CLNP_PDU_MD, "MD"},
751 { CLNP_PDU_DT, "Data"},
752 { CLNP_PDU_ERQ, "Echo Request"},
753 { CLNP_PDU_ERP, "Echo Response"},
754 { 0, NULL }
755 };
756
757 struct clnp_header_t {
758 nd_uint8_t nlpid;
759 nd_uint8_t length_indicator;
760 nd_uint8_t version;
761 nd_uint8_t lifetime; /* units of 500ms */
762 nd_uint8_t type;
763 nd_uint16_t segment_length;
764 nd_uint16_t cksum;
765 };
766
767 struct clnp_segment_header_t {
768 nd_uint16_t data_unit_id;
769 nd_uint16_t segment_offset;
770 nd_uint16_t total_length;
771 };
772
773 /*
774 * clnp_print
775 * Decode CLNP packets. Return 0 on error.
776 */
777
778 static int
779 clnp_print(netdissect_options *ndo,
780 const uint8_t *pptr, u_int length)
781 {
782 const uint8_t *optr,*source_address,*dest_address;
783 u_int li,li_remaining,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
784 const struct clnp_header_t *clnp_header;
785 const struct clnp_segment_header_t *clnp_segment_header;
786 uint8_t rfd_error,rfd_error_major,rfd_error_minor;
787
788 ndo->ndo_protocol = "clnp";
789 clnp_header = (const struct clnp_header_t *) pptr;
790 ND_TCHECK_SIZE(clnp_header);
791
792 li = GET_U_1(clnp_header->length_indicator);
793 li_remaining = li;
794 optr = pptr;
795
796 if (!ndo->ndo_eflag)
797 nd_print_protocol_caps(ndo);
798
799 /*
800 * Sanity checking of the header.
801 */
802
803 if (GET_U_1(clnp_header->version) != CLNP_VERSION) {
804 ND_PRINT("version %u packet not supported",
805 GET_U_1(clnp_header->version));
806 return (0);
807 }
808
809 if (li > length) {
810 ND_PRINT(" length indicator(%u) > PDU size (%u)!", li, length);
811 return (0);
812 }
813
814 if (li < sizeof(struct clnp_header_t)) {
815 ND_PRINT(" length indicator %u < min PDU size:", li);
816 while (pptr < ndo->ndo_snapend) {
817 ND_PRINT("%02X", GET_U_1(pptr));
818 pptr++;
819 }
820 return (0);
821 }
822
823 /* FIXME further header sanity checking */
824
825 clnp_pdu_type = GET_U_1(clnp_header->type) & CLNP_PDU_TYPE_MASK;
826 clnp_flags = GET_U_1(clnp_header->type) & CLNP_FLAG_MASK;
827
828 pptr += sizeof(struct clnp_header_t);
829 li_remaining -= sizeof(struct clnp_header_t);
830
831 if (li_remaining < 1) {
832 ND_PRINT("li < size of fixed part of CLNP header and addresses");
833 return (0);
834 }
835 ND_TCHECK_1(pptr);
836 dest_address_length = GET_U_1(pptr);
837 pptr += 1;
838 li_remaining -= 1;
839 if (li_remaining < dest_address_length) {
840 ND_PRINT("li < size of fixed part of CLNP header and addresses");
841 return (0);
842 }
843 ND_TCHECK_LEN(pptr, dest_address_length);
844 dest_address = pptr;
845 pptr += dest_address_length;
846 li_remaining -= dest_address_length;
847
848 if (li_remaining < 1) {
849 ND_PRINT("li < size of fixed part of CLNP header and addresses");
850 return (0);
851 }
852 ND_TCHECK_1(pptr);
853 source_address_length = GET_U_1(pptr);
854 pptr += 1;
855 li_remaining -= 1;
856 if (li_remaining < source_address_length) {
857 ND_PRINT("li < size of fixed part of CLNP header and addresses");
858 return (0);
859 }
860 ND_TCHECK_LEN(pptr, source_address_length);
861 source_address = pptr;
862 pptr += source_address_length;
863 li_remaining -= source_address_length;
864
865 if (ndo->ndo_vflag < 1) {
866 ND_PRINT("%s%s > %s, %s, length %u",
867 ndo->ndo_eflag ? "" : ", ",
868 GET_ISONSAP_STRING(source_address, source_address_length),
869 GET_ISONSAP_STRING(dest_address, dest_address_length),
870 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
871 length);
872 return (1);
873 }
874 ND_PRINT("%slength %u", ndo->ndo_eflag ? "" : ", ", length);
875
876 ND_PRINT("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
877 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
878 GET_U_1(clnp_header->length_indicator),
879 GET_U_1(clnp_header->version),
880 GET_U_1(clnp_header->lifetime)/2,
881 (GET_U_1(clnp_header->lifetime)%2)*5,
882 GET_BE_U_2(clnp_header->segment_length),
883 GET_BE_U_2(clnp_header->cksum));
884
885 osi_print_cksum(ndo, optr, GET_BE_U_2(clnp_header->cksum), 7,
886 GET_U_1(clnp_header->length_indicator));
887
888 ND_PRINT("\n\tFlags [%s]",
889 bittok2str(clnp_flag_values, "none", clnp_flags));
890
891 ND_PRINT("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
892 source_address_length,
893 GET_ISONSAP_STRING(source_address, source_address_length),
894 dest_address_length,
895 GET_ISONSAP_STRING(dest_address, dest_address_length));
896
897 if (clnp_flags & CLNP_SEGMENT_PART) {
898 if (li_remaining < sizeof(struct clnp_segment_header_t)) {
899 ND_PRINT("li < size of fixed part of CLNP header, addresses, and segment part");
900 return (0);
901 }
902 clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
903 ND_TCHECK_SIZE(clnp_segment_header);
904 ND_PRINT("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
905 GET_BE_U_2(clnp_segment_header->data_unit_id),
906 GET_BE_U_2(clnp_segment_header->segment_offset),
907 GET_BE_U_2(clnp_segment_header->total_length));
908 pptr+=sizeof(struct clnp_segment_header_t);
909 li_remaining-=sizeof(struct clnp_segment_header_t);
910 }
911
912 /* now walk the options */
913 while (li_remaining != 0) {
914 u_int op, opli;
915 const uint8_t *tptr;
916
917 if (li_remaining < 2) {
918 ND_PRINT(", bad opts/li");
919 return (0);
920 }
921 ND_TCHECK_2(pptr);
922 op = GET_U_1(pptr);
923 opli = GET_U_1(pptr + 1);
924 pptr += 2;
925 li_remaining -= 2;
926 if (opli > li_remaining) {
927 ND_PRINT(", opt (%u) too long", op);
928 return (0);
929 }
930 ND_TCHECK_LEN(pptr, opli);
931 li_remaining -= opli;
932 tptr = pptr;
933 tlen = opli;
934
935 ND_PRINT("\n\t %s Option #%u, length %u, value: ",
936 tok2str(clnp_option_values,"Unknown",op),
937 op,
938 opli);
939
940 /*
941 * We've already checked that the entire option is present
942 * in the captured packet with the ND_TCHECK_LEN() call.
943 * Therefore, we don't need to do ND_TCHECK()/ND_TCHECK_LEN()
944 * checks.
945 * We do, however, need to check tlen, to make sure we
946 * don't run past the end of the option.
947 */
948 switch (op) {
949
950
951 case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
952 case CLNP_OPTION_SOURCE_ROUTING:
953 if (tlen < 2) {
954 ND_PRINT(", bad opt len");
955 return (0);
956 }
957 ND_PRINT("%s %s",
958 tok2str(clnp_option_sr_rr_values,"Unknown",GET_U_1(tptr)),
959 tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op));
960 nsap_offset=GET_U_1(tptr + 1);
961 if (nsap_offset == 0) {
962 ND_PRINT(" Bad NSAP offset (0)");
963 break;
964 }
965 nsap_offset-=1; /* offset to nsap list */
966 if (nsap_offset > tlen) {
967 ND_PRINT(" Bad NSAP offset (past end of option)");
968 break;
969 }
970 tptr+=nsap_offset;
971 tlen-=nsap_offset;
972 while (tlen > 0) {
973 source_address_length=GET_U_1(tptr);
974 if (tlen < source_address_length+1) {
975 ND_PRINT("\n\t NSAP address goes past end of option");
976 break;
977 }
978 if (source_address_length > 0) {
979 source_address=(tptr+1);
980 ND_TCHECK_LEN(source_address,
981 source_address_length);
982 ND_PRINT("\n\t NSAP address (length %u): %s",
983 source_address_length,
984 GET_ISONSAP_STRING(source_address, source_address_length));
985 }
986 tlen-=source_address_length+1;
987 }
988 break;
989
990 case CLNP_OPTION_PRIORITY:
991 if (tlen < 1) {
992 ND_PRINT(", bad opt len");
993 return (0);
994 }
995 ND_PRINT("0x%1x", GET_U_1(tptr)&0x0f);
996 break;
997
998 case CLNP_OPTION_QOS_MAINTENANCE:
999 if (tlen < 1) {
1000 ND_PRINT(", bad opt len");
1001 return (0);
1002 }
1003 ND_PRINT("\n\t Format Code: %s",
1004 tok2str(clnp_option_scope_values, "Reserved", GET_U_1(tptr) & CLNP_OPTION_SCOPE_MASK));
1005
1006 if ((GET_U_1(tptr)&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
1007 ND_PRINT("\n\t QoS Flags [%s]",
1008 bittok2str(clnp_option_qos_global_values,
1009 "none",
1010 GET_U_1(tptr)&CLNP_OPTION_OPTION_QOS_MASK));
1011 break;
1012
1013 case CLNP_OPTION_SECURITY:
1014 if (tlen < 2) {
1015 ND_PRINT(", bad opt len");
1016 return (0);
1017 }
1018 ND_PRINT("\n\t Format Code: %s, Security-Level %u",
1019 tok2str(clnp_option_scope_values,"Reserved",GET_U_1(tptr)&CLNP_OPTION_SCOPE_MASK),
1020 GET_U_1(tptr + 1));
1021 break;
1022
1023 case CLNP_OPTION_DISCARD_REASON:
1024 if (tlen < 1) {
1025 ND_PRINT(", bad opt len");
1026 return (0);
1027 }
1028 rfd_error = GET_U_1(tptr);
1029 rfd_error_major = (rfd_error&0xf0) >> 4;
1030 rfd_error_minor = rfd_error&0x0f;
1031 ND_PRINT("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
1032 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
1033 rfd_error_major,
1034 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
1035 rfd_error_minor);
1036 break;
1037
1038 case CLNP_OPTION_PADDING:
1039 ND_PRINT("padding data");
1040 break;
1041
1042 /*
1043 * FIXME those are the defined Options that lack a decoder
1044 * you are welcome to contribute code ;-)
1045 */
1046
1047 default:
1048 print_unknown_data(ndo, tptr, "\n\t ", opli);
1049 break;
1050 }
1051 if (ndo->ndo_vflag > 1)
1052 print_unknown_data(ndo, pptr, "\n\t ", opli);
1053 pptr += opli;
1054 }
1055
1056 switch (clnp_pdu_type) {
1057
1058 case CLNP_PDU_ER: /* fall through */
1059 case CLNP_PDU_ERP:
1060 ND_TCHECK_1(pptr);
1061 if (GET_U_1(pptr) == NLPID_CLNP) {
1062 ND_PRINT("\n\t-----original packet-----\n\t");
1063 /* FIXME recursion protection */
1064 clnp_print(ndo, pptr, length - li);
1065 break;
1066 }
1067
1068 /* The cases above break from the switch block if they see and print
1069 * a CLNP header in the Data part. For an Error Report PDU this is
1070 * described in Section 7.9.6 of ITU X.233 (1997 E), also known as
1071 * ISO/IEC 8473-1:1998(E). It is not clear why in this code the same
1072 * applies to an Echo Response PDU, as the standard does not specify
1073 * the contents -- could be a proprietary extension or a bug. In either
1074 * case, if the Data part does not contain a CLNP header, its structure
1075 * is considered unknown and the decoding falls through to print the
1076 * contents as-is.
1077 */
1078 ND_FALL_THROUGH;
1079
1080 case CLNP_PDU_DT:
1081 case CLNP_PDU_MD:
1082 case CLNP_PDU_ERQ:
1083
1084 default:
1085 /* dump the PDU specific data */
1086 if (length-(pptr-optr) > 0) {
1087 ND_PRINT("\n\t undecoded non-header data, length %u", length-li);
1088 print_unknown_data(ndo, pptr, "\n\t ", length - (int)(pptr - optr));
1089 }
1090 }
1091
1092 return (1);
1093
1094 trunc:
1095 nd_print_trunc(ndo);
1096 return (1);
1097
1098 }
1099
1100
1101 #define ESIS_PDU_REDIRECT 6
1102 #define ESIS_PDU_ESH 2
1103 #define ESIS_PDU_ISH 4
1104
1105 static const struct tok esis_pdu_values[] = {
1106 { ESIS_PDU_REDIRECT, "redirect"},
1107 { ESIS_PDU_ESH, "ESH"},
1108 { ESIS_PDU_ISH, "ISH"},
1109 { 0, NULL }
1110 };
1111
1112 struct esis_header_t {
1113 nd_uint8_t nlpid;
1114 nd_uint8_t length_indicator;
1115 nd_uint8_t version;
1116 nd_byte reserved;
1117 nd_uint8_t type;
1118 nd_uint16_t holdtime;
1119 nd_uint16_t cksum;
1120 };
1121
1122 static void
1123 esis_print(netdissect_options *ndo,
1124 const uint8_t *pptr, u_int length)
1125 {
1126 const uint8_t *optr;
1127 u_int li, version, esis_pdu_type, source_address_length, source_address_number;
1128 const struct esis_header_t *esis_header;
1129
1130 ndo->ndo_protocol = "esis";
1131 if (!ndo->ndo_eflag)
1132 ND_PRINT("ES-IS");
1133
1134 if (length <= 2) {
1135 ND_PRINT(ndo->ndo_qflag ? "bad pkt!" : "no header at all!");
1136 return;
1137 }
1138
1139 esis_header = (const struct esis_header_t *) pptr;
1140 ND_TCHECK_SIZE(esis_header);
1141 li = GET_U_1(esis_header->length_indicator);
1142 optr = pptr;
1143
1144 /*
1145 * Sanity checking of the header.
1146 */
1147
1148 if (GET_U_1(esis_header->nlpid) != NLPID_ESIS) {
1149 ND_PRINT(" nlpid 0x%02x packet not supported",
1150 GET_U_1(esis_header->nlpid));
1151 return;
1152 }
1153
1154 version = GET_U_1(esis_header->version);
1155 if (version != ESIS_VERSION) {
1156 ND_PRINT(" version %u packet not supported", version);
1157 return;
1158 }
1159
1160 if (li > length) {
1161 ND_PRINT(" length indicator(%u) > PDU size (%u)!", li, length);
1162 return;
1163 }
1164
1165 if (li < sizeof(struct esis_header_t) + 2) {
1166 ND_PRINT(" length indicator %u < min PDU size:", li);
1167 while (pptr < ndo->ndo_snapend) {
1168 ND_PRINT("%02X", GET_U_1(pptr));
1169 pptr++;
1170 }
1171 return;
1172 }
1173
1174 esis_pdu_type = GET_U_1(esis_header->type) & ESIS_PDU_TYPE_MASK;
1175
1176 if (ndo->ndo_vflag < 1) {
1177 ND_PRINT("%s%s, length %u",
1178 ndo->ndo_eflag ? "" : ", ",
1179 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
1180 length);
1181 return;
1182 } else
1183 ND_PRINT("%slength %u\n\t%s (%u)",
1184 ndo->ndo_eflag ? "" : ", ",
1185 length,
1186 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
1187 esis_pdu_type);
1188
1189 ND_PRINT(", v: %u%s", version, version == ESIS_VERSION ? "" : "unsupported" );
1190 ND_PRINT(", checksum: 0x%04x", GET_BE_U_2(esis_header->cksum));
1191
1192 osi_print_cksum(ndo, pptr, GET_BE_U_2(esis_header->cksum), 7,
1193 li);
1194
1195 ND_PRINT(", holding time: %us, length indicator: %u",
1196 GET_BE_U_2(esis_header->holdtime), li);
1197
1198 if (ndo->ndo_vflag > 1)
1199 print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
1200
1201 pptr += sizeof(struct esis_header_t);
1202 li -= sizeof(struct esis_header_t);
1203
1204 switch (esis_pdu_type) {
1205 case ESIS_PDU_REDIRECT: {
1206 const uint8_t *dst, *snpa, *neta;
1207 u_int dstl, snpal, netal;
1208
1209 ND_TCHECK_1(pptr);
1210 if (li < 1) {
1211 ND_PRINT(", bad redirect/li");
1212 return;
1213 }
1214 dstl = GET_U_1(pptr);
1215 pptr++;
1216 li--;
1217 ND_TCHECK_LEN(pptr, dstl);
1218 if (li < dstl) {
1219 ND_PRINT(", bad redirect/li");
1220 return;
1221 }
1222 dst = pptr;
1223 pptr += dstl;
1224 li -= dstl;
1225 ND_PRINT("\n\t %s", GET_ISONSAP_STRING(dst, dstl));
1226
1227 ND_TCHECK_1(pptr);
1228 if (li < 1) {
1229 ND_PRINT(", bad redirect/li");
1230 return;
1231 }
1232 snpal = GET_U_1(pptr);
1233 pptr++;
1234 li--;
1235 ND_TCHECK_LEN(pptr, snpal);
1236 if (li < snpal) {
1237 ND_PRINT(", bad redirect/li");
1238 return;
1239 }
1240 snpa = pptr;
1241 pptr += snpal;
1242 li -= snpal;
1243 ND_TCHECK_1(pptr);
1244 if (li < 1) {
1245 ND_PRINT(", bad redirect/li");
1246 return;
1247 }
1248 netal = GET_U_1(pptr);
1249 pptr++;
1250 ND_TCHECK_LEN(pptr, netal);
1251 if (li < netal) {
1252 ND_PRINT(", bad redirect/li");
1253 return;
1254 }
1255 neta = pptr;
1256 pptr += netal;
1257 li -= netal;
1258
1259 if (snpal == 6)
1260 ND_PRINT("\n\t SNPA (length: %u): %s",
1261 snpal,
1262 GET_ETHERADDR_STRING(snpa));
1263 else
1264 ND_PRINT("\n\t SNPA (length: %u): %s",
1265 snpal,
1266 GET_LINKADDR_STRING(snpa, LINKADDR_OTHER, snpal));
1267 if (netal != 0)
1268 ND_PRINT("\n\t NET (length: %u) %s",
1269 netal,
1270 GET_ISONSAP_STRING(neta, netal));
1271 break;
1272 }
1273
1274 case ESIS_PDU_ESH:
1275 ND_TCHECK_1(pptr);
1276 if (li < 1) {
1277 ND_PRINT(", bad esh/li");
1278 return;
1279 }
1280 source_address_number = GET_U_1(pptr);
1281 pptr++;
1282 li--;
1283
1284 ND_PRINT("\n\t Number of Source Addresses: %u", source_address_number);
1285
1286 while (source_address_number > 0) {
1287 ND_TCHECK_1(pptr);
1288 if (li < 1) {
1289 ND_PRINT(", bad esh/li");
1290 return;
1291 }
1292 source_address_length = GET_U_1(pptr);
1293 pptr++;
1294 li--;
1295
1296 ND_TCHECK_LEN(pptr, source_address_length);
1297 if (li < source_address_length) {
1298 ND_PRINT(", bad esh/li");
1299 return;
1300 }
1301 ND_PRINT("\n\t NET (length: %u): %s",
1302 source_address_length,
1303 GET_ISONSAP_STRING(pptr, source_address_length));
1304 pptr += source_address_length;
1305 li -= source_address_length;
1306 source_address_number--;
1307 }
1308
1309 break;
1310
1311 case ESIS_PDU_ISH: {
1312 ND_TCHECK_1(pptr);
1313 if (li < 1) {
1314 ND_PRINT(", bad ish/li");
1315 return;
1316 }
1317 source_address_length = GET_U_1(pptr);
1318 pptr++;
1319 li--;
1320 ND_TCHECK_LEN(pptr, source_address_length);
1321 if (li < source_address_length) {
1322 ND_PRINT(", bad ish/li");
1323 return;
1324 }
1325 ND_PRINT("\n\t NET (length: %u): %s", source_address_length, GET_ISONSAP_STRING(pptr, source_address_length));
1326 pptr += source_address_length;
1327 li -= source_address_length;
1328 break;
1329 }
1330
1331 default:
1332 if (ndo->ndo_vflag <= 1) {
1333 if (pptr < ndo->ndo_snapend)
1334 print_unknown_data(ndo, pptr, "\n\t ", (int)(ndo->ndo_snapend - pptr));
1335 }
1336 return;
1337 }
1338
1339 /* now walk the options */
1340 while (li != 0) {
1341 u_int op, opli;
1342 const uint8_t *tptr;
1343
1344 if (li < 2) {
1345 ND_PRINT(", bad opts/li");
1346 return;
1347 }
1348 ND_TCHECK_2(pptr);
1349 op = GET_U_1(pptr);
1350 opli = GET_U_1(pptr + 1);
1351 pptr += 2;
1352 li -= 2;
1353 if (opli > li) {
1354 ND_PRINT(", opt (%u) too long", op);
1355 return;
1356 }
1357 li -= opli;
1358 tptr = pptr;
1359
1360 ND_PRINT("\n\t %s Option #%u, length %u, value: ",
1361 tok2str(esis_option_values,"Unknown",op),
1362 op,
1363 opli);
1364
1365 switch (op) {
1366
1367 case ESIS_OPTION_ES_CONF_TIME:
1368 if (opli == 2) {
1369 ND_TCHECK_2(pptr);
1370 ND_PRINT("%us", GET_BE_U_2(tptr));
1371 } else
1372 ND_PRINT("(bad length)");
1373 break;
1374
1375 case ESIS_OPTION_PROTOCOLS:
1376 while (opli>0) {
1377 ND_TCHECK_1(tptr);
1378 ND_PRINT("%s (0x%02x)",
1379 tok2str(nlpid_values,
1380 "unknown",
1381 GET_U_1(tptr)),
1382 GET_U_1(tptr));
1383 if (opli>1) /* further NPLIDs ? - put comma */
1384 ND_PRINT(", ");
1385 tptr++;
1386 opli--;
1387 }
1388 break;
1389
1390 /*
1391 * FIXME those are the defined Options that lack a decoder
1392 * you are welcome to contribute code ;-)
1393 */
1394
1395 case ESIS_OPTION_QOS_MAINTENANCE:
1396 case ESIS_OPTION_SECURITY:
1397 case ESIS_OPTION_PRIORITY:
1398 case ESIS_OPTION_ADDRESS_MASK:
1399 case ESIS_OPTION_SNPA_MASK:
1400
1401 default:
1402 print_unknown_data(ndo, tptr, "\n\t ", opli);
1403 break;
1404 }
1405 if (ndo->ndo_vflag > 1)
1406 print_unknown_data(ndo, pptr, "\n\t ", opli);
1407 pptr += opli;
1408 }
1409 return;
1410
1411 trunc:
1412 nd_print_trunc(ndo);
1413 }
1414
1415 static void
1416 isis_print_mcid(netdissect_options *ndo,
1417 const struct isis_spb_mcid *mcid)
1418 {
1419 int i;
1420
1421 ND_TCHECK_SIZE(mcid);
1422 ND_PRINT("ID: %u, Name: ", GET_U_1(mcid->format_id));
1423
1424 if (nd_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
1425 goto trunc;
1426
1427 ND_PRINT("\n\t Lvl: %u", GET_BE_U_2(mcid->revision_lvl));
1428
1429 ND_PRINT(", Digest: ");
1430
1431 for(i=0;i<16;i++)
1432 ND_PRINT("%.2x ", mcid->digest[i]);
1433 return;
1434
1435 trunc:
1436 nd_print_trunc(ndo);
1437 }
1438
1439 static int
1440 isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
1441 const uint8_t *tptr, u_int len)
1442 {
1443 u_int stlv_type, stlv_len;
1444 const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
1445 int i;
1446
1447 while (len > 2)
1448 {
1449 ND_TCHECK_2(tptr);
1450 stlv_type = GET_U_1(tptr);
1451 stlv_len = GET_U_1(tptr + 1);
1452
1453 /* first lets see if we know the subTLVs name*/
1454 ND_PRINT("\n\t %s subTLV #%u, length: %u",
1455 tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
1456 stlv_type,
1457 stlv_len);
1458
1459 tptr += 2;
1460 /*len -= TLV_TYPE_LEN_OFFSET;*/
1461 len -= 2;
1462
1463 /* Make sure the subTLV fits within the space left */
1464 if (len < stlv_len)
1465 goto subtlv_too_long;
1466 /* Make sure the entire subTLV is in the captured data */
1467 ND_TCHECK_LEN(tptr, stlv_len);
1468
1469 switch (stlv_type)
1470 {
1471 case ISIS_SUBTLV_SPB_MCID:
1472 {
1473 if (stlv_len < ISIS_SUBTLV_SPB_MCID_MIN_LEN)
1474 goto subtlv_too_short;
1475
1476 subtlv_spb_mcid = (const struct isis_subtlv_spb_mcid *)tptr;
1477
1478 ND_PRINT("\n\t MCID: ");
1479 isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
1480
1481 /*tptr += SPB_MCID_MIN_LEN;
1482 len -= SPB_MCID_MIN_LEN; */
1483
1484 ND_PRINT("\n\t AUX-MCID: ");
1485 isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
1486
1487 /*tptr += SPB_MCID_MIN_LEN;
1488 len -= SPB_MCID_MIN_LEN; */
1489 tptr += ISIS_SUBTLV_SPB_MCID_MIN_LEN;
1490 len -= ISIS_SUBTLV_SPB_MCID_MIN_LEN;
1491 stlv_len -= ISIS_SUBTLV_SPB_MCID_MIN_LEN;
1492
1493 break;
1494 }
1495
1496 case ISIS_SUBTLV_SPB_DIGEST:
1497 {
1498 if (stlv_len < ISIS_SUBTLV_SPB_DIGEST_MIN_LEN)
1499 goto subtlv_too_short;
1500
1501 ND_PRINT("\n\t RES: %u V: %u A: %u D: %u",
1502 (GET_U_1(tptr) >> 5),
1503 ((GET_U_1(tptr) >> 4) & 0x01),
1504 ((GET_U_1(tptr) >> 2) & 0x03),
1505 (GET_U_1(tptr) & 0x03));
1506
1507 tptr++;
1508
1509 ND_PRINT("\n\t Digest: ");
1510
1511 for(i=1;i<=8; i++)
1512 {
1513 ND_PRINT("%08x ", GET_BE_U_4(tptr));
1514 if (i%4 == 0 && i != 8)
1515 ND_PRINT("\n\t ");
1516 tptr += 4;
1517 }
1518
1519 len -= ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
1520 stlv_len -= ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
1521
1522 break;
1523 }
1524
1525 case ISIS_SUBTLV_SPB_BVID:
1526 {
1527 while (stlv_len != 0)
1528 {
1529 if (stlv_len < 4)
1530 goto subtlv_too_short;
1531 ND_PRINT("\n\t ECT: %08x",
1532 GET_BE_U_4(tptr));
1533
1534 tptr += 4;
1535 len -= 4;
1536 stlv_len -= 4;
1537
1538 if (stlv_len < 2)
1539 goto subtlv_too_short;
1540 ND_PRINT(" BVID: %u, U:%01x M:%01x ",
1541 (GET_BE_U_2(tptr) >> 4) ,
1542 (GET_BE_U_2(tptr) >> 3) & 0x01,
1543 (GET_BE_U_2(tptr) >> 2) & 0x01);
1544
1545 tptr += 2;
1546 len -= 2;
1547 stlv_len -= 2;
1548 }
1549
1550 break;
1551 }
1552
1553 default:
1554 break;
1555 }
1556 tptr += stlv_len;
1557 len -= stlv_len;
1558 }
1559 return (0);
1560
1561 trunc:
1562 nd_print_trunc(ndo);
1563 return (1);
1564
1565 subtlv_too_long:
1566 ND_PRINT(" (> containing TLV length)");
1567 return (1);
1568
1569 subtlv_too_short:
1570 ND_PRINT(" (too short)");
1571 return (1);
1572 }
1573
1574 static int
1575 isis_print_mt_capability_subtlv(netdissect_options *ndo,
1576 const uint8_t *tptr, u_int len)
1577 {
1578 u_int stlv_type, stlv_len, treecount;
1579
1580 while (len > 2)
1581 {
1582 ND_TCHECK_2(tptr);
1583 stlv_type = GET_U_1(tptr);
1584 stlv_len = GET_U_1(tptr + 1);
1585 tptr += 2;
1586 len -= 2;
1587
1588 /* first lets see if we know the subTLVs name*/
1589 ND_PRINT("\n\t %s subTLV #%u, length: %u",
1590 tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
1591 stlv_type,
1592 stlv_len);
1593
1594 /* Make sure the subTLV fits within the space left */
1595 if (len < stlv_len)
1596 goto subtlv_too_long;
1597 /* Make sure the entire subTLV is in the captured data */
1598 ND_TCHECK_LEN(tptr, stlv_len);
1599
1600 switch (stlv_type)
1601 {
1602 case ISIS_SUBTLV_SPB_INSTANCE:
1603 if (stlv_len < ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN)
1604 goto subtlv_too_short;
1605
1606 ND_PRINT("\n\t CIST Root-ID: %08x", GET_BE_U_4(tptr));
1607 tptr += 4;
1608 ND_PRINT(" %08x", GET_BE_U_4(tptr));
1609 tptr += 4;
1610 ND_PRINT(", Path Cost: %08x", GET_BE_U_4(tptr));
1611 tptr += 4;
1612 ND_PRINT(", Prio: %u", GET_BE_U_2(tptr));
1613 tptr += 2;
1614 ND_PRINT("\n\t RES: %u",
1615 GET_BE_U_2(tptr) >> 5);
1616 ND_PRINT(", V: %u",
1617 (GET_BE_U_2(tptr) >> 4) & 0x0001);
1618 ND_PRINT(", SPSource-ID: %u",
1619 (GET_BE_U_4(tptr) & 0x000fffff));
1620 tptr += 4;
1621 ND_PRINT(", No of Trees: %x", GET_U_1(tptr));
1622
1623 treecount = GET_U_1(tptr);
1624 tptr++;
1625
1626 len -= ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
1627 stlv_len -= ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
1628
1629 while (treecount)
1630 {
1631 if (stlv_len < ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN)
1632 goto trunc;
1633
1634 ND_PRINT("\n\t U:%u, M:%u, A:%u, RES:%u",
1635 GET_U_1(tptr) >> 7,
1636 (GET_U_1(tptr) >> 6) & 0x01,
1637 (GET_U_1(tptr) >> 5) & 0x01,
1638 (GET_U_1(tptr) & 0x1f));
1639
1640 tptr++;
1641
1642 ND_PRINT(", ECT: %08x", GET_BE_U_4(tptr));
1643
1644 tptr += 4;
1645
1646 ND_PRINT(", BVID: %u, SPVID: %u",
1647 (GET_BE_U_3(tptr) >> 12) & 0x000fff,
1648 GET_BE_U_3(tptr) & 0x000fff);
1649
1650 tptr += 3;
1651 len -= ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
1652 stlv_len -= ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
1653 treecount--;
1654 }
1655
1656 break;
1657
1658 case ISIS_SUBTLV_SPBM_SI:
1659 if (stlv_len < 8)
1660 goto trunc;
1661
1662 ND_PRINT("\n\t BMAC: %08x", GET_BE_U_4(tptr));
1663 tptr += 4;
1664 ND_PRINT("%04x", GET_BE_U_2(tptr));
1665 tptr += 2;
1666
1667 ND_PRINT(", RES: %u, VID: %u", GET_BE_U_2(tptr) >> 12,
1668 (GET_BE_U_2(tptr)) & 0x0fff);
1669
1670 tptr += 2;
1671 len -= 8;
1672 stlv_len -= 8;
1673
1674 while (stlv_len >= 4) {
1675 ND_TCHECK_4(tptr);
1676 ND_PRINT("\n\t T: %u, R: %u, RES: %u, ISID: %u",
1677 (GET_BE_U_4(tptr) >> 31),
1678 (GET_BE_U_4(tptr) >> 30) & 0x01,
1679 (GET_BE_U_4(tptr) >> 24) & 0x03f,
1680 (GET_BE_U_4(tptr)) & 0x0ffffff);
1681
1682 tptr += 4;
1683 len -= 4;
1684 stlv_len -= 4;
1685 }
1686
1687 break;
1688
1689 default:
1690 break;
1691 }
1692 tptr += stlv_len;
1693 len -= stlv_len;
1694 }
1695 return (0);
1696
1697 trunc:
1698 nd_print_trunc(ndo);
1699 return (1);
1700
1701 subtlv_too_long:
1702 ND_PRINT(" (> containing TLV length)");
1703 return (1);
1704
1705 subtlv_too_short:
1706 ND_PRINT(" (too short)");
1707 return (1);
1708 }
1709
1710 /* shared routine for printing system, node and lsp-ids */
1711 static char *
1712 isis_print_id(netdissect_options *ndo, const uint8_t *cp, u_int id_len)
1713 {
1714 u_int i;
1715 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1716 char *pos = id;
1717 u_int sysid_len;
1718
1719 sysid_len = SYSTEM_ID_LEN;
1720 if (sysid_len > id_len)
1721 sysid_len = id_len;
1722 for (i = 1; i <= sysid_len; i++) {
1723 snprintf(pos, sizeof(id) - (pos - id), "%02x", GET_U_1(cp));
1724 cp++;
1725 pos += strlen(pos);
1726 if (i == 2 || i == 4)
1727 *pos++ = '.';
1728 }
1729 if (id_len >= NODE_ID_LEN) {
1730 snprintf(pos, sizeof(id) - (pos - id), ".%02x", GET_U_1(cp));
1731 cp++;
1732 pos += strlen(pos);
1733 }
1734 if (id_len == LSP_ID_LEN)
1735 snprintf(pos, sizeof(id) - (pos - id), "-%02x", GET_U_1(cp));
1736 return (id);
1737 }
1738
1739 /* print the 4-byte metric block which is common found in the old-style TLVs */
1740 static int
1741 isis_print_metric_block(netdissect_options *ndo,
1742 const struct isis_metric_block *isis_metric_block)
1743 {
1744 ND_PRINT(", Default Metric: %u, %s",
1745 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
1746 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal");
1747 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
1748 ND_PRINT("\n\t\t Delay Metric: %u, %s",
1749 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
1750 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal");
1751 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
1752 ND_PRINT("\n\t\t Expense Metric: %u, %s",
1753 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
1754 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal");
1755 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
1756 ND_PRINT("\n\t\t Error Metric: %u, %s",
1757 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
1758 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal");
1759
1760 return(1); /* everything is ok */
1761 }
1762
1763 static int
1764 isis_print_tlv_ip_reach(netdissect_options *ndo,
1765 const uint8_t *cp, const char *ident, u_int length)
1766 {
1767 int prefix_len;
1768 const struct isis_tlv_ip_reach *tlv_ip_reach;
1769
1770 tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
1771
1772 while (length > 0) {
1773 if ((size_t)length < sizeof(*tlv_ip_reach)) {
1774 ND_PRINT("short IPv4 Reachability (%u vs %zu)",
1775 length,
1776 sizeof(*tlv_ip_reach));
1777 return (0);
1778 }
1779
1780 ND_TCHECK_SIZE(tlv_ip_reach);
1781
1782 prefix_len = mask2plen(GET_IPV4_TO_HOST_ORDER(tlv_ip_reach->mask));
1783
1784 if (prefix_len == -1)
1785 ND_PRINT("%sIPv4 prefix: %s mask %s",
1786 ident,
1787 GET_IPADDR_STRING(tlv_ip_reach->prefix),
1788 GET_IPADDR_STRING(tlv_ip_reach->mask));
1789 else
1790 ND_PRINT("%sIPv4 prefix: %15s/%u",
1791 ident,
1792 GET_IPADDR_STRING(tlv_ip_reach->prefix),
1793 prefix_len);
1794
1795 ND_PRINT(", Distribution: %s, Metric: %u, %s",
1796 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
1797 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
1798 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal");
1799
1800 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
1801 ND_PRINT("%s Delay Metric: %u, %s",
1802 ident,
1803 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
1804 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal");
1805
1806 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
1807 ND_PRINT("%s Expense Metric: %u, %s",
1808 ident,
1809 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
1810 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal");
1811
1812 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
1813 ND_PRINT("%s Error Metric: %u, %s",
1814 ident,
1815 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
1816 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal");
1817
1818 length -= sizeof(struct isis_tlv_ip_reach);
1819 tlv_ip_reach++;
1820 }
1821 return (1);
1822 trunc:
1823 return 0;
1824 }
1825
1826 /*
1827 * this is the common IP-REACH subTLV decoder it is called
1828 * from various EXTD-IP REACH TLVs (135,235,236,237)
1829 */
1830
1831 static int
1832 isis_print_ip_reach_subtlv(netdissect_options *ndo,
1833 const uint8_t *tptr, u_int subt, u_int subl,
1834 const char *ident)
1835 {
1836 /* first lets see if we know the subTLVs name*/
1837 ND_PRINT("%s%s subTLV #%u, length: %u",
1838 ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
1839 subt, subl);
1840
1841 ND_TCHECK_LEN(tptr, subl);
1842
1843 switch(subt) {
1844 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
1845 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
1846 while (subl >= 4) {
1847 ND_PRINT(", 0x%08x (=%u)",
1848 GET_BE_U_4(tptr),
1849 GET_BE_U_4(tptr));
1850 tptr+=4;
1851 subl-=4;
1852 }
1853 break;
1854 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
1855 while (subl >= 8) {
1856 ND_PRINT(", 0x%08x%08x",
1857 GET_BE_U_4(tptr),
1858 GET_BE_U_4(tptr + 4));
1859 tptr+=8;
1860 subl-=8;
1861 }
1862 break;
1863 default:
1864 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
1865 return(0);
1866 break;
1867 }
1868 return(1);
1869
1870 trunc:
1871 nd_print_trunc(ndo);
1872 return(0);
1873 }
1874
1875 /*
1876 * this is the common IS-REACH decoder it is called
1877 * from various EXTD-IS REACH style TLVs (22,24,222)
1878 */
1879
1880 static int
1881 isis_print_ext_is_reach(netdissect_options *ndo,
1882 const uint8_t *tptr, const char *ident, u_int tlv_type,
1883 u_int tlv_remaining)
1884 {
1885 char ident_buffer[20];
1886 u_int subtlv_type,subtlv_len,subtlv_sum_len;
1887 int proc_bytes = 0; /* how many bytes did we process ? */
1888 u_int te_class,priority_level,gmpls_switch_cap;
1889 union { /* int to float conversion buffer for several subTLVs */
1890 float f;
1891 uint32_t i;
1892 } bw;
1893
1894 ND_TCHECK_LEN(tptr, NODE_ID_LEN);
1895 if (tlv_remaining < NODE_ID_LEN)
1896 return(0);
1897
1898 ND_PRINT("%sIS Neighbor: %s", ident, isis_print_id(ndo, tptr, NODE_ID_LEN));
1899 tptr+=NODE_ID_LEN;
1900 tlv_remaining-=NODE_ID_LEN;
1901 proc_bytes+=NODE_ID_LEN;
1902
1903 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
1904 ND_TCHECK_3(tptr);
1905 if (tlv_remaining < 3)
1906 return(0);
1907 ND_PRINT(", Metric: %u", GET_BE_U_3(tptr));
1908 tptr+=3;
1909 tlv_remaining-=3;
1910 proc_bytes+=3;
1911 }
1912
1913 ND_TCHECK_1(tptr);
1914 if (tlv_remaining < 1)
1915 return(0);
1916 subtlv_sum_len=GET_U_1(tptr); /* read out subTLV length */
1917 tptr++;
1918 tlv_remaining--;
1919 proc_bytes++;
1920 ND_PRINT(", %ssub-TLVs present",subtlv_sum_len ? "" : "no ");
1921 if (subtlv_sum_len) {
1922 ND_PRINT(" (%u)", subtlv_sum_len);
1923 /* prepend the indent string */
1924 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
1925 ident = ident_buffer;
1926 while (subtlv_sum_len != 0) {
1927 ND_TCHECK_2(tptr);
1928 if (tlv_remaining < 2) {
1929 ND_PRINT("%sRemaining data in TLV shorter than a subTLV header",ident);
1930 proc_bytes += tlv_remaining;
1931 break;
1932 }
1933 if (subtlv_sum_len < 2) {
1934 ND_PRINT("%sRemaining data in subTLVs shorter than a subTLV header",ident);
1935 proc_bytes += subtlv_sum_len;
1936 break;
1937 }
1938 subtlv_type=GET_U_1(tptr);
1939 subtlv_len=GET_U_1(tptr + 1);
1940 tptr += 2;
1941 tlv_remaining -= 2;
1942 subtlv_sum_len -= 2;
1943 proc_bytes += 2;
1944 ND_PRINT("%s%s subTLV #%u, length: %u",
1945 ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subtlv_type),
1946 subtlv_type, subtlv_len);
1947
1948 if (subtlv_sum_len < subtlv_len) {
1949 ND_PRINT(" (remaining data in subTLVs shorter than the current subTLV)");
1950 proc_bytes += subtlv_sum_len;
1951 break;
1952 }
1953
1954 if (tlv_remaining < subtlv_len) {
1955 ND_PRINT(" (> remaining tlv length)");
1956 proc_bytes += tlv_remaining;
1957 break;
1958 }
1959
1960 ND_TCHECK_LEN(tptr, subtlv_len);
1961
1962 switch(subtlv_type) {
1963 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
1964 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
1965 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
1966 if (subtlv_len >= 4) {
1967 ND_PRINT(", 0x%08x", GET_BE_U_4(tptr));
1968 if (subtlv_len == 8) /* rfc4205 */
1969 ND_PRINT(", 0x%08x", GET_BE_U_4(tptr + 4));
1970 }
1971 break;
1972 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
1973 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
1974 if (subtlv_len >= sizeof(nd_ipv4))
1975 ND_PRINT(", %s", GET_IPADDR_STRING(tptr));
1976 break;
1977 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
1978 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
1979 if (subtlv_len >= 4) {
1980 bw.i = GET_BE_U_4(tptr);
1981 ND_PRINT(", %.3f Mbps", bw.f * 8 / 1000000);
1982 }
1983 break;
1984 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
1985 if (subtlv_len >= 32) {
1986 for (te_class = 0; te_class < 8; te_class++) {
1987 bw.i = GET_BE_U_4(tptr);
1988 ND_PRINT("%s TE-Class %u: %.3f Mbps",
1989 ident,
1990 te_class,
1991 bw.f * 8 / 1000000);
1992 tptr += 4;
1993 subtlv_len -= 4;
1994 subtlv_sum_len -= 4;
1995 proc_bytes += 4;
1996 }
1997 }
1998 break;
1999 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
2000 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
2001 if (subtlv_len == 0)
2002 break;
2003 ND_PRINT("%sBandwidth Constraints Model ID: %s (%u)",
2004 ident,
2005 tok2str(diffserv_te_bc_values, "unknown", GET_U_1(tptr)),
2006 GET_U_1(tptr));
2007 tptr++;
2008 subtlv_len--;
2009 subtlv_sum_len--;
2010 proc_bytes++;
2011 /* decode BCs until the subTLV ends */
2012 for (te_class = 0; subtlv_len != 0; te_class++) {
2013 if (subtlv_len < 4)
2014 break;
2015 bw.i = GET_BE_U_4(tptr);
2016 ND_PRINT("%s Bandwidth constraint CT%u: %.3f Mbps",
2017 ident,
2018 te_class,
2019 bw.f * 8 / 1000000);
2020 tptr += 4;
2021 subtlv_len -= 4;
2022 subtlv_sum_len -= 4;
2023 proc_bytes += 4;
2024 }
2025 break;
2026 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
2027 if (subtlv_len >= 3)
2028 ND_PRINT(", %u", GET_BE_U_3(tptr));
2029 break;
2030 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
2031 if (subtlv_len == 2) {
2032 ND_PRINT(", [ %s ] (0x%04x)",
2033 bittok2str(isis_subtlv_link_attribute_values,
2034 "Unknown",
2035 GET_BE_U_2(tptr)),
2036 GET_BE_U_2(tptr));
2037 }
2038 break;
2039 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
2040 if (subtlv_len >= 2) {
2041 ND_PRINT(", %s, Priority %u",
2042 bittok2str(gmpls_link_prot_values, "none", GET_U_1(tptr)),
2043 GET_U_1(tptr + 1));
2044 }
2045 break;
2046 case ISIS_SUBTLV_SPB_METRIC:
2047 if (subtlv_len >= 6) {
2048 ND_PRINT(", LM: %u", GET_BE_U_3(tptr));
2049 tptr += 3;
2050 subtlv_len -= 3;
2051 subtlv_sum_len -= 3;
2052 proc_bytes += 3;
2053 ND_PRINT(", P: %u", GET_U_1(tptr));
2054 tptr++;
2055 subtlv_len--;
2056 subtlv_sum_len--;
2057 proc_bytes++;
2058 ND_PRINT(", P-ID: %u", GET_BE_U_2(tptr));
2059 }
2060 break;
2061 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
2062 if (subtlv_len >= 36) {
2063 gmpls_switch_cap = GET_U_1(tptr);
2064 ND_PRINT("%s Interface Switching Capability:%s",
2065 ident,
2066 tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap));
2067 ND_PRINT(", LSP Encoding: %s",
2068 tok2str(gmpls_encoding_values, "Unknown", GET_U_1((tptr + 1))));
2069 tptr += 4;
2070 subtlv_len -= 4;
2071 subtlv_sum_len -= 4;
2072 proc_bytes += 4;
2073 ND_PRINT("%s Max LSP Bandwidth:", ident);
2074 for (priority_level = 0; priority_level < 8; priority_level++) {
2075 bw.i = GET_BE_U_4(tptr);
2076 ND_PRINT("%s priority level %u: %.3f Mbps",
2077 ident,
2078 priority_level,
2079 bw.f * 8 / 1000000);
2080 tptr += 4;
2081 subtlv_len -= 4;
2082 subtlv_sum_len -= 4;
2083 proc_bytes += 4;
2084 }
2085 switch (gmpls_switch_cap) {
2086 case GMPLS_PSC1:
2087 case GMPLS_PSC2:
2088 case GMPLS_PSC3:
2089 case GMPLS_PSC4:
2090 if (subtlv_len < 6)
2091 break;
2092 bw.i = GET_BE_U_4(tptr);
2093 ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000);
2094 ND_PRINT("%s Interface MTU: %u", ident,
2095 GET_BE_U_2(tptr + 4));
2096 break;
2097 case GMPLS_TSC:
2098 if (subtlv_len < 8)
2099 break;
2100 bw.i = GET_BE_U_4(tptr);
2101 ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000);
2102 ND_PRINT("%s Indication %s", ident,
2103 tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", GET_U_1((tptr + 4))));
2104 break;
2105 default:
2106 /* there is some optional stuff left to decode but this is as of yet
2107 not specified so just lets hexdump what is left */
2108 if (subtlv_len != 0) {
2109 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subtlv_len))
2110 return(0);
2111 }
2112 }
2113 }
2114 break;
2115 default:
2116 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subtlv_len))
2117 return(0);
2118 break;
2119 }
2120
2121 tptr += subtlv_len;
2122 tlv_remaining -= subtlv_len;
2123 subtlv_sum_len -= subtlv_len;
2124 proc_bytes += subtlv_len;
2125 }
2126 }
2127 return(proc_bytes);
2128
2129 trunc:
2130 return(0);
2131 }
2132
2133 /*
2134 * this is the common Multi Topology ID decoder
2135 * it is called from various MT-TLVs (222,229,235,237)
2136 */
2137
2138 static uint8_t
2139 isis_print_mtid(netdissect_options *ndo,
2140 const uint8_t *tptr, const char *ident, u_int tlv_remaining)
2141 {
2142 if (tlv_remaining < 2)
2143 goto trunc;
2144 ND_TCHECK_2(tptr);
2145
2146 ND_PRINT("%s%s",
2147 ident,
2148 tok2str(isis_mt_values,
2149 "Reserved for IETF Consensus",
2150 ISIS_MASK_MTID(GET_BE_U_2(tptr))));
2151
2152 ND_PRINT(" Topology (0x%03x), Flags: [%s]",
2153 ISIS_MASK_MTID(GET_BE_U_2(tptr)),
2154 bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(GET_BE_U_2(tptr))));
2155
2156 return(2);
2157 trunc:
2158 return 0;
2159 }
2160
2161 /*
2162 * this is the common extended IP reach decoder
2163 * it is called from TLVs (135,235,236,237)
2164 * we process the TLV and optional subTLVs and return
2165 * the amount of processed bytes
2166 */
2167
2168 static u_int
2169 isis_print_extd_ip_reach(netdissect_options *ndo,
2170 const uint8_t *tptr, const char *ident, uint16_t afi)
2171 {
2172 char ident_buffer[20];
2173 uint8_t prefix[sizeof(nd_ipv6)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
2174 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
2175
2176 ND_TCHECK_4(tptr);
2177 metric = GET_BE_U_4(tptr);
2178 processed=4;
2179 tptr+=4;
2180
2181 if (afi == AF_INET) {
2182 ND_TCHECK_1(tptr);
2183 status_byte=GET_U_1(tptr);
2184 tptr++;
2185 bit_length = status_byte&0x3f;
2186 if (bit_length > 32) {
2187 ND_PRINT("%sIPv4 prefix: bad bit length %u",
2188 ident,
2189 bit_length);
2190 return (0);
2191 }
2192 processed++;
2193 } else if (afi == AF_INET6) {
2194 ND_TCHECK_2(tptr);
2195 status_byte=GET_U_1(tptr);
2196 bit_length=GET_U_1(tptr + 1);
2197 if (bit_length > 128) {
2198 ND_PRINT("%sIPv6 prefix: bad bit length %u",
2199 ident,
2200 bit_length);
2201 return (0);
2202 }
2203 tptr+=2;
2204 processed+=2;
2205 } else
2206 return (0); /* somebody is fooling us */
2207
2208 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
2209
2210 ND_TCHECK_LEN(tptr, byte_length);
2211 memset(prefix, 0, sizeof(prefix)); /* clear the copy buffer */
2212 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
2213 tptr+=byte_length;
2214 processed+=byte_length;
2215
2216 if (afi == AF_INET)
2217 ND_PRINT("%sIPv4 prefix: %15s/%u",
2218 ident,
2219 ipaddr_string(ndo, prefix), /* local buffer, not packet data; don't use GET_IPADDR_STRING() */
2220 bit_length);
2221 else if (afi == AF_INET6)
2222 ND_PRINT("%sIPv6 prefix: %s/%u",
2223 ident,
2224 ip6addr_string(ndo, prefix), /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
2225 bit_length);
2226
2227 ND_PRINT(", Distribution: %s, Metric: %u",
2228 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
2229 metric);
2230
2231 if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
2232 ND_PRINT(", sub-TLVs present");
2233 else if (afi == AF_INET6)
2234 ND_PRINT(", %s%s",
2235 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
2236 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
2237
2238 if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
2239 || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
2240 ) {
2241 /* assume that one prefix can hold more
2242 than one subTLV - therefore the first byte must reflect
2243 the aggregate bytecount of the subTLVs for this prefix
2244 */
2245 ND_TCHECK_1(tptr);
2246 sublen=GET_U_1(tptr);
2247 tptr++;
2248 processed+=sublen+1;
2249 ND_PRINT(" (%u)", sublen); /* print out subTLV length */
2250
2251 while (sublen>0) {
2252 ND_TCHECK_2(tptr);
2253 subtlvtype=GET_U_1(tptr);
2254 subtlvlen=GET_U_1(tptr + 1);
2255 tptr+=2;
2256 /* prepend the indent string */
2257 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
2258 if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
2259 return(0);
2260 tptr+=subtlvlen;
2261 sublen-=(subtlvlen+2);
2262 }
2263 }
2264 return (processed);
2265 trunc:
2266 return 0;
2267 }
2268
2269 /*
2270 * Clear checksum and lifetime prior to signature verification.
2271 */
2272 static void
2273 isis_clear_checksum_lifetime(void *header)
2274 {
2275 struct isis_lsp_header *header_lsp = (struct isis_lsp_header *) header;
2276
2277 header_lsp->checksum[0] = 0;
2278 header_lsp->checksum[1] = 0;
2279 header_lsp->remaining_lifetime[0] = 0;
2280 header_lsp->remaining_lifetime[1] = 0;
2281 }
2282
2283 /*
2284 * isis_print
2285 * Decode IS-IS packets. Return 0 on error.
2286 */
2287
2288 #define INVALID_OR_DECREMENT(length,decr) \
2289 if ((length) < (decr)) { \
2290 ND_PRINT(" [packet length %u < %zu]", (length), (decr)); \
2291 nd_print_invalid(ndo); \
2292 return 1; \
2293 } \
2294 length -= (decr);
2295
2296 static int
2297 isis_print(netdissect_options *ndo,
2298 const uint8_t *p, u_int length)
2299 {
2300 const struct isis_common_header *isis_header;
2301
2302 const struct isis_iih_lan_header *header_iih_lan;
2303 const struct isis_iih_ptp_header *header_iih_ptp;
2304 const struct isis_lsp_header *header_lsp;
2305 const struct isis_csnp_header *header_csnp;
2306 const struct isis_psnp_header *header_psnp;
2307
2308 const struct isis_tlv_lsp *tlv_lsp;
2309 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
2310 const struct isis_tlv_is_reach *tlv_is_reach;
2311 const struct isis_tlv_es_reach *tlv_es_reach;
2312
2313 uint8_t version, pdu_version, fixed_len;
2314 uint8_t pdu_type, pdu_max_area, max_area, pdu_id_length, id_length, tlv_type, tlv_len, tlen, alen, prefix_len;
2315 u_int ext_is_len, ext_ip_len;
2316 uint8_t mt_len;
2317 uint8_t isis_subtlv_idrp;
2318 const uint8_t *optr, *pptr, *tptr;
2319 u_int packet_len;
2320 u_short pdu_len, key_id;
2321 u_int i,vendor_id, num_vals;
2322 uint8_t auth_type;
2323 uint8_t num_system_ids;
2324 int sigcheck;
2325
2326 ndo->ndo_protocol = "isis";
2327 packet_len=length;
2328 optr = p; /* initialize the _o_riginal pointer to the packet start -
2329 need it for parsing the checksum TLV and authentication
2330 TLV verification */
2331 isis_header = (const struct isis_common_header *)p;
2332 ND_TCHECK_SIZE(isis_header);
2333 if (length < ISIS_COMMON_HEADER_SIZE)
2334 goto trunc;
2335 pptr = p+(ISIS_COMMON_HEADER_SIZE);
2336 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
2337 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
2338 header_lsp = (const struct isis_lsp_header *)pptr;
2339 header_csnp = (const struct isis_csnp_header *)pptr;
2340 header_psnp = (const struct isis_psnp_header *)pptr;
2341
2342 if (!ndo->ndo_eflag)
2343 ND_PRINT("IS-IS");
2344
2345 /*
2346 * Sanity checking of the header.
2347 */
2348
2349 version = GET_U_1(isis_header->version);
2350 if (version != ISIS_VERSION) {
2351 ND_PRINT("version %u packet not supported", version);
2352 return (0);
2353 }
2354
2355 pdu_id_length = GET_U_1(isis_header->id_length);
2356 if ((pdu_id_length != SYSTEM_ID_LEN) && (pdu_id_length != 0)) {
2357 ND_PRINT("system ID length of %u is not supported",
2358 pdu_id_length);
2359 return (0);
2360 }
2361
2362 pdu_version = GET_U_1(isis_header->pdu_version);
2363 if (pdu_version != ISIS_VERSION) {
2364 ND_PRINT("version %u packet not supported", pdu_version);
2365 return (0);
2366 }
2367
2368 fixed_len = GET_U_1(isis_header->fixed_len);
2369 if (length < fixed_len) {
2370 ND_PRINT("fixed header length %u > packet length %u", fixed_len, length);
2371 return (0);
2372 }
2373
2374 if (fixed_len < ISIS_COMMON_HEADER_SIZE) {
2375 ND_PRINT("fixed header length %u < minimum header size %u", fixed_len, (u_int)ISIS_COMMON_HEADER_SIZE);
2376 return (0);
2377 }
2378
2379 pdu_max_area = GET_U_1(isis_header->max_area);
2380 switch(pdu_max_area) {
2381 case 0:
2382 max_area = 3; /* silly shit */
2383 break;
2384 case 255:
2385 ND_PRINT("bad packet -- 255 areas");
2386 return (0);
2387 default:
2388 max_area = pdu_max_area;
2389 break;
2390 }
2391
2392 switch(pdu_id_length) {
2393 case 0:
2394 id_length = 6; /* silly shit again */
2395 break;
2396 case 1: /* 1-8 are valid sys-ID lengths */
2397 case 2:
2398 case 3:
2399 case 4:
2400 case 5:
2401 case 6:
2402 case 7:
2403 case 8:
2404 id_length = pdu_id_length;
2405 break;
2406 case 255:
2407 id_length = 0; /* entirely useless */
2408 break;
2409 default:
2410 id_length = pdu_id_length;
2411 break;
2412 }
2413
2414 /* toss any non 6-byte sys-ID len PDUs */
2415 if (id_length != 6 ) {
2416 ND_PRINT("bad packet -- illegal sys-ID length (%u)", id_length);
2417 return (0);
2418 }
2419
2420 pdu_type = GET_U_1(isis_header->pdu_type);
2421
2422 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
2423 if (ndo->ndo_vflag == 0) {
2424 ND_PRINT("%s%s",
2425 ndo->ndo_eflag ? "" : ", ",
2426 tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type));
2427 } else {
2428 /* ok they seem to want to know everything - lets fully decode it */
2429 ND_PRINT("%slength %u", ndo->ndo_eflag ? "" : ", ", length);
2430
2431 ND_PRINT("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
2432 tok2str(isis_pdu_values,
2433 "unknown, type %u",
2434 pdu_type),
2435 fixed_len,
2436 version,
2437 pdu_version,
2438 id_length,
2439 pdu_id_length,
2440 max_area,
2441 pdu_max_area);
2442
2443 if (ndo->ndo_vflag > 1) {
2444 if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
2445 return (0); /* for optionally debugging the common header */
2446 }
2447 }
2448
2449 switch (pdu_type) {
2450
2451 case ISIS_PDU_L1_LAN_IIH:
2452 case ISIS_PDU_L2_LAN_IIH:
2453 if (fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
2454 ND_PRINT(", bogus fixed header length %u should be %zu",
2455 fixed_len, ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2456 return (0);
2457 }
2458 ND_TCHECK_SIZE(header_iih_lan);
2459 if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)
2460 goto trunc;
2461 if (ndo->ndo_vflag == 0) {
2462 ND_PRINT(", src-id %s",
2463 isis_print_id(ndo, header_iih_lan->source_id, SYSTEM_ID_LEN));
2464 ND_PRINT(", lan-id %s, prio %u",
2465 isis_print_id(ndo, header_iih_lan->lan_id,NODE_ID_LEN),
2466 GET_U_1(header_iih_lan->priority));
2467 ND_PRINT(", length %u", length);
2468 return (1);
2469 }
2470 pdu_len=GET_BE_U_2(header_iih_lan->pdu_len);
2471 if (packet_len>pdu_len) {
2472 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2473 length=pdu_len;
2474 }
2475
2476 ND_PRINT("\n\t source-id: %s, holding time: %us, Flags: [%s]",
2477 isis_print_id(ndo, header_iih_lan->source_id,SYSTEM_ID_LEN),
2478 GET_BE_U_2(header_iih_lan->holding_time),
2479 tok2str(isis_iih_circuit_type_values,
2480 "unknown circuit type 0x%02x",
2481 GET_U_1(header_iih_lan->circuit_type)));
2482
2483 ND_PRINT("\n\t lan-id: %s, Priority: %u, PDU length: %u",
2484 isis_print_id(ndo, header_iih_lan->lan_id, NODE_ID_LEN),
2485 GET_U_1(header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
2486 pdu_len);
2487
2488 if (ndo->ndo_vflag > 1) {
2489 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE))
2490 return (0);
2491 }
2492
2493 INVALID_OR_DECREMENT(packet_len,ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2494 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2495 break;
2496
2497 case ISIS_PDU_PTP_IIH:
2498 if (fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
2499 ND_PRINT(", bogus fixed header length %u should be %zu",
2500 fixed_len, ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2501 return (0);
2502 }
2503 ND_TCHECK_SIZE(header_iih_ptp);
2504 if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)
2505 goto trunc;
2506 if (ndo->ndo_vflag == 0) {
2507 ND_PRINT(", src-id %s", isis_print_id(ndo, header_iih_ptp->source_id, SYSTEM_ID_LEN));
2508 ND_PRINT(", length %u", length);
2509 return (1);
2510 }
2511 pdu_len=GET_BE_U_2(header_iih_ptp->pdu_len);
2512 if (packet_len>pdu_len) {
2513 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2514 length=pdu_len;
2515 }
2516
2517 ND_PRINT("\n\t source-id: %s, holding time: %us, Flags: [%s]",
2518 isis_print_id(ndo, header_iih_ptp->source_id,SYSTEM_ID_LEN),
2519 GET_BE_U_2(header_iih_ptp->holding_time),
2520 tok2str(isis_iih_circuit_type_values,
2521 "unknown circuit type 0x%02x",
2522 GET_U_1(header_iih_ptp->circuit_type)));
2523
2524 ND_PRINT("\n\t circuit-id: 0x%02x, PDU length: %u",
2525 GET_U_1(header_iih_ptp->circuit_id),
2526 pdu_len);
2527
2528 if (ndo->ndo_vflag > 1) {
2529 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE))
2530 return (0);
2531 }
2532 INVALID_OR_DECREMENT(packet_len,ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2533 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2534 break;
2535
2536 case ISIS_PDU_L1_LSP:
2537 case ISIS_PDU_L2_LSP:
2538 if (fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
2539 ND_PRINT(", bogus fixed header length %u should be %zu",
2540 fixed_len, ISIS_LSP_HEADER_SIZE);
2541 return (0);
2542 }
2543 ND_TCHECK_SIZE(header_lsp);
2544 if (length < ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)
2545 goto trunc;
2546 if (ndo->ndo_vflag == 0) {
2547 ND_PRINT(", lsp-id %s, seq 0x%08x, lifetime %5us",
2548 isis_print_id(ndo, header_lsp->lsp_id, LSP_ID_LEN),
2549 GET_BE_U_4(header_lsp->sequence_number),
2550 GET_BE_U_2(header_lsp->remaining_lifetime));
2551 ND_PRINT(", length %u", length);
2552 return (1);
2553 }
2554 pdu_len=GET_BE_U_2(header_lsp->pdu_len);
2555 if (packet_len>pdu_len) {
2556 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2557 length=pdu_len;
2558 }
2559
2560 ND_PRINT("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
2561 isis_print_id(ndo, header_lsp->lsp_id, LSP_ID_LEN),
2562 GET_BE_U_4(header_lsp->sequence_number),
2563 GET_BE_U_2(header_lsp->remaining_lifetime),
2564 GET_BE_U_2(header_lsp->checksum));
2565
2566 osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id,
2567 GET_BE_U_2(header_lsp->checksum),
2568 12, length-12);
2569
2570 ND_PRINT(", PDU length: %u, Flags: [ %s",
2571 pdu_len,
2572 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
2573
2574 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
2575 ND_PRINT("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "");
2576 ND_PRINT("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "");
2577 ND_PRINT("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "");
2578 ND_PRINT("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "");
2579 ND_PRINT("ATT bit set, ");
2580 }
2581 ND_PRINT("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
2582 ND_PRINT("%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
2583 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
2584
2585 if (ndo->ndo_vflag > 1) {
2586 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE))
2587 return (0);
2588 }
2589
2590 INVALID_OR_DECREMENT(packet_len,ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
2591 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
2592 break;
2593
2594 case ISIS_PDU_L1_CSNP:
2595 case ISIS_PDU_L2_CSNP:
2596 if (fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
2597 ND_PRINT(", bogus fixed header length %u should be %zu",
2598 fixed_len, ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2599 return (0);
2600 }
2601 ND_TCHECK_SIZE(header_csnp);
2602 if (length < ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)
2603 goto trunc;
2604 if (ndo->ndo_vflag == 0) {
2605 ND_PRINT(", src-id %s", isis_print_id(ndo, header_csnp->source_id, NODE_ID_LEN));
2606 ND_PRINT(", length %u", length);
2607 return (1);
2608 }
2609 pdu_len=GET_BE_U_2(header_csnp->pdu_len);
2610 if (packet_len>pdu_len) {
2611 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2612 length=pdu_len;
2613 }
2614
2615 ND_PRINT("\n\t source-id: %s, PDU length: %u",
2616 isis_print_id(ndo, header_csnp->source_id, NODE_ID_LEN),
2617 pdu_len);
2618 ND_PRINT("\n\t start lsp-id: %s",
2619 isis_print_id(ndo, header_csnp->start_lsp_id, LSP_ID_LEN));
2620 ND_PRINT("\n\t end lsp-id: %s",
2621 isis_print_id(ndo, header_csnp->end_lsp_id, LSP_ID_LEN));
2622
2623 if (ndo->ndo_vflag > 1) {
2624 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
2625 return (0);
2626 }
2627
2628 INVALID_OR_DECREMENT(packet_len,ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2629 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2630 break;
2631
2632 case ISIS_PDU_L1_PSNP:
2633 case ISIS_PDU_L2_PSNP:
2634 if (fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
2635 ND_PRINT("- bogus fixed header length %u should be %zu",
2636 fixed_len, ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2637 return (0);
2638 }
2639 ND_TCHECK_SIZE(header_psnp);
2640 if (length < ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)
2641 goto trunc;
2642 if (ndo->ndo_vflag == 0) {
2643 ND_PRINT(", src-id %s", isis_print_id(ndo, header_psnp->source_id, NODE_ID_LEN));
2644 ND_PRINT(", length %u", length);
2645 return (1);
2646 }
2647 pdu_len=GET_BE_U_2(header_psnp->pdu_len);
2648 if (packet_len>pdu_len) {
2649 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2650 length=pdu_len;
2651 }
2652
2653 ND_PRINT("\n\t source-id: %s, PDU length: %u",
2654 isis_print_id(ndo, header_psnp->source_id, NODE_ID_LEN),
2655 pdu_len);
2656
2657 if (ndo->ndo_vflag > 1) {
2658 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE))
2659 return (0);
2660 }
2661
2662 INVALID_OR_DECREMENT(packet_len,ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2663 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2664 break;
2665
2666 default:
2667 if (ndo->ndo_vflag == 0) {
2668 ND_PRINT(", length %u", length);
2669 return (1);
2670 }
2671 (void)print_unknown_data(ndo, pptr, "\n\t ", length);
2672 return (0);
2673 }
2674
2675 /*
2676 * Now print the TLV's.
2677 */
2678
2679 while (packet_len > 0) {
2680 ND_TCHECK_2(pptr);
2681 if (packet_len < 2)
2682 goto trunc;
2683 tlv_type = GET_U_1(pptr);
2684 tlv_len = GET_U_1(pptr + 1);
2685 pptr += 2;
2686 packet_len -= 2;
2687 tlen = tlv_len; /* copy temporary len & pointer to packet data */
2688 tptr = pptr;
2689
2690 /* first lets see if we know the TLVs name*/
2691 ND_PRINT("\n\t %s TLV #%u, length: %u",
2692 tok2str(isis_tlv_values,
2693 "unknown",
2694 tlv_type),
2695 tlv_type,
2696 tlv_len);
2697
2698 if (packet_len < tlv_len)
2699 goto trunc;
2700
2701 /* now check if we have a decoder otherwise do a hexdump at the end*/
2702 switch (tlv_type) {
2703 case ISIS_TLV_AREA_ADDR:
2704 while (tlen != 0) {
2705 ND_TCHECK_1(tptr);
2706 alen = GET_U_1(tptr);
2707 tptr++;
2708 tlen--;
2709 if (tlen < alen)
2710 goto tlv_trunc;
2711 ND_TCHECK_LEN(tptr, alen);
2712 ND_PRINT("\n\t Area address (length: %u): %s",
2713 alen,
2714 GET_ISONSAP_STRING(tptr, alen));
2715 tptr += alen;
2716 tlen -= alen;
2717 }
2718 break;
2719 case ISIS_TLV_ISNEIGH:
2720 while (tlen != 0) {
2721 if (tlen < MAC_ADDR_LEN)
2722 goto tlv_trunc;
2723 ND_TCHECK_LEN(tptr, MAC_ADDR_LEN);
2724 ND_PRINT("\n\t SNPA: %s", isis_print_id(ndo, tptr, MAC_ADDR_LEN));
2725 tlen -= MAC_ADDR_LEN;
2726 tptr += MAC_ADDR_LEN;
2727 }
2728 break;
2729
2730 case ISIS_TLV_INSTANCE_ID:
2731 if (tlen < 4)
2732 goto tlv_trunc;
2733 num_vals = (tlen-2)/2;
2734 ND_PRINT("\n\t Instance ID: %u, ITIDs(%u)%s ",
2735 GET_BE_U_2(tptr), num_vals,
2736 num_vals ? ":" : "");
2737 tptr += 2;
2738 tlen -= 2;
2739 for (i=0; i < num_vals; i++) {
2740 ND_PRINT("%u", GET_BE_U_2(tptr));
2741 if (i < (num_vals - 1)) {
2742 ND_PRINT(", ");
2743 }
2744 tptr += 2;
2745 tlen -= 2;
2746 }
2747 break;
2748
2749 case ISIS_TLV_PADDING:
2750 break;
2751
2752 case ISIS_TLV_MT_IS_REACH:
2753 mt_len = isis_print_mtid(ndo, tptr, "\n\t ", tlen);
2754 if (mt_len == 0) /* did something go wrong ? */
2755 goto trunc;
2756 tptr+=mt_len;
2757 tlen-=mt_len;
2758 while (tlen != 0) {
2759 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type, tlen);
2760 if (ext_is_len == 0) /* did something go wrong ? */
2761 goto trunc;
2762 if (tlen < ext_is_len) {
2763 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_is_len);
2764 nd_print_invalid(ndo);
2765 break;
2766 }
2767 tlen-=(uint8_t)ext_is_len;
2768 tptr+=(uint8_t)ext_is_len;
2769 }
2770 break;
2771
2772 case ISIS_TLV_IS_ALIAS_ID:
2773 while (tlen != 0) {
2774 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type, tlen);
2775 if (ext_is_len == 0) /* did something go wrong ? */
2776 goto trunc;
2777 if (tlen < ext_is_len) {
2778 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_is_len);
2779 nd_print_invalid(ndo);
2780 break;
2781 }
2782 tlen-=(uint8_t)ext_is_len;
2783 tptr+=(uint8_t)ext_is_len;
2784 }
2785 break;
2786
2787 case ISIS_TLV_EXT_IS_REACH:
2788 while (tlen != 0) {
2789 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type, tlen);
2790 if (ext_is_len == 0) /* did something go wrong ? */
2791 goto trunc;
2792 if (tlen < ext_is_len) {
2793 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_is_len);
2794 nd_print_invalid(ndo);
2795 break;
2796 }
2797 tlen-=(uint8_t)ext_is_len;
2798 tptr+=(uint8_t)ext_is_len;
2799 }
2800 break;
2801 case ISIS_TLV_IS_REACH:
2802 if (tlen < 1)
2803 goto tlv_trunc;
2804 ND_TCHECK_1(tptr); /* check if there is one byte left to read out the virtual flag */
2805 ND_PRINT("\n\t %s",
2806 tok2str(isis_is_reach_virtual_values,
2807 "bogus virtual flag 0x%02x",
2808 GET_U_1(tptr)));
2809 tptr++;
2810 tlen--;
2811 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
2812 while (tlen != 0) {
2813 if (tlen < sizeof(struct isis_tlv_is_reach))
2814 goto tlv_trunc;
2815 ND_TCHECK_SIZE(tlv_is_reach);
2816 ND_PRINT("\n\t IS Neighbor: %s",
2817 isis_print_id(ndo, tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
2818 isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
2819 tlen -= sizeof(struct isis_tlv_is_reach);
2820 tlv_is_reach++;
2821 }
2822 break;
2823
2824 case ISIS_TLV_ESNEIGH:
2825 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
2826 while (tlen != 0) {
2827 if (tlen < sizeof(struct isis_tlv_es_reach))
2828 goto tlv_trunc;
2829 ND_TCHECK_SIZE(tlv_es_reach);
2830 ND_PRINT("\n\t ES Neighbor: %s",
2831 isis_print_id(ndo, tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN));
2832 isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
2833 tlen -= sizeof(struct isis_tlv_es_reach);
2834 tlv_es_reach++;
2835 }
2836 break;
2837
2838 /* those two TLVs share the same format */
2839 case ISIS_TLV_INT_IP_REACH:
2840 case ISIS_TLV_EXT_IP_REACH:
2841 if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len))
2842 return (1);
2843 break;
2844
2845 case ISIS_TLV_EXTD_IP_REACH:
2846 while (tlen != 0) {
2847 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
2848 if (ext_ip_len == 0) /* did something go wrong ? */
2849 goto trunc;
2850 if (tlen < ext_ip_len) {
2851 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_ip_len);
2852 nd_print_invalid(ndo);
2853 break;
2854 }
2855 tlen-=(uint8_t)ext_ip_len;
2856 tptr+=(uint8_t)ext_ip_len;
2857 }
2858 break;
2859
2860 case ISIS_TLV_MT_IP_REACH:
2861 mt_len = isis_print_mtid(ndo, tptr, "\n\t ", tlen);
2862 if (mt_len == 0) { /* did something go wrong ? */
2863 goto trunc;
2864 }
2865 tptr+=mt_len;
2866 tlen-=mt_len;
2867
2868 while (tlen != 0) {
2869 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
2870 if (ext_ip_len == 0) /* did something go wrong ? */
2871 goto trunc;
2872 if (tlen < ext_ip_len) {
2873 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_ip_len);
2874 nd_print_invalid(ndo);
2875 break;
2876 }
2877 tlen-=(uint8_t)ext_ip_len;
2878 tptr+=(uint8_t)ext_ip_len;
2879 }
2880 break;
2881
2882 case ISIS_TLV_IP6_REACH:
2883 while (tlen != 0) {
2884 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
2885 if (ext_ip_len == 0) /* did something go wrong ? */
2886 goto trunc;
2887 if (tlen < ext_ip_len) {
2888 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_ip_len);
2889 nd_print_invalid(ndo);
2890 break;
2891 }
2892 tlen-=(uint8_t)ext_ip_len;
2893 tptr+=(uint8_t)ext_ip_len;
2894 }
2895 break;
2896
2897 case ISIS_TLV_MT_IP6_REACH:
2898 mt_len = isis_print_mtid(ndo, tptr, "\n\t ", tlen);
2899 if (mt_len == 0) { /* did something go wrong ? */
2900 goto trunc;
2901 }
2902 tptr+=mt_len;
2903 tlen-=mt_len;
2904
2905 while (tlen != 0) {
2906 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
2907 if (ext_ip_len == 0) /* did something go wrong ? */
2908 goto trunc;
2909 if (tlen < ext_ip_len) {
2910 ND_PRINT(" [remaining tlv length %u < %u]", tlen, ext_ip_len);
2911 nd_print_invalid(ndo);
2912 break;
2913 }
2914 tlen-=(uint8_t)ext_ip_len;
2915 tptr+=(uint8_t)ext_ip_len;
2916 }
2917 break;
2918
2919 case ISIS_TLV_IP6ADDR:
2920 while (tlen != 0) {
2921 if (tlen < sizeof(nd_ipv6))
2922 goto tlv_trunc;
2923 ND_TCHECK_LEN(tptr, sizeof(nd_ipv6));
2924
2925 ND_PRINT("\n\t IPv6 interface address: %s",
2926 GET_IP6ADDR_STRING(tptr));
2927
2928 tptr += sizeof(nd_ipv6);
2929 tlen -= sizeof(nd_ipv6);
2930 }
2931 break;
2932 case ISIS_TLV_AUTH:
2933 if (tlen < 1)
2934 goto tlv_trunc;
2935 ND_TCHECK_1(tptr);
2936 auth_type = GET_U_1(tptr);
2937 tptr++;
2938 tlen--;
2939
2940 ND_PRINT("\n\t %s: ",
2941 tok2str(isis_subtlv_auth_values,
2942 "unknown Authentication type 0x%02x",
2943 auth_type));
2944
2945 switch (auth_type) {
2946 case ISIS_SUBTLV_AUTH_SIMPLE:
2947 if (nd_printzp(ndo, tptr, tlen, ndo->ndo_snapend))
2948 goto trunc;
2949 break;
2950 case ISIS_SUBTLV_AUTH_MD5:
2951 for(i=0;i<tlen;i++) {
2952 ND_TCHECK_1(tptr + i);
2953 ND_PRINT("%02x", GET_U_1(tptr + i));
2954 }
2955 if (tlen != ISIS_SUBTLV_AUTH_MD5_LEN)
2956 ND_PRINT(", (invalid subTLV) ");
2957
2958 sigcheck = signature_verify(ndo, optr, length, tptr,
2959 isis_clear_checksum_lifetime,
2960 header_lsp);
2961 ND_PRINT(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
2962
2963 break;
2964 case ISIS_SUBTLV_AUTH_GENERIC:
2965 if (tlen < 2)
2966 goto tlv_trunc;
2967 ND_TCHECK_2(tptr);
2968 key_id = GET_BE_U_2(tptr);
2969 ND_PRINT("%u, password: ", key_id);
2970 tptr += 2;
2971 tlen -= 2;
2972 for(i=0;i<tlen;i++) {
2973 ND_TCHECK_1(tptr + i);
2974 ND_PRINT("%02x", GET_U_1(tptr + i));
2975 }
2976 break;
2977 case ISIS_SUBTLV_AUTH_PRIVATE:
2978 default:
2979 if (!print_unknown_data(ndo, tptr, "\n\t\t ", tlen))
2980 return(0);
2981 break;
2982 }
2983 break;
2984
2985 case ISIS_TLV_PTP_ADJ:
2986 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
2987 if(tlen>=1) {
2988 ND_TCHECK_1(tptr);
2989 ND_PRINT("\n\t Adjacency State: %s (%u)",
2990 tok2str(isis_ptp_adjancey_values, "unknown", GET_U_1(tptr)),
2991 GET_U_1(tptr));
2992 tlen--;
2993 }
2994 if(tlen>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
2995 ND_TCHECK_4(tlv_ptp_adj->extd_local_circuit_id);
2996 ND_PRINT("\n\t Extended Local circuit-ID: 0x%08x",
2997 GET_BE_U_4(tlv_ptp_adj->extd_local_circuit_id));
2998 tlen-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
2999 }
3000 if(tlen>=SYSTEM_ID_LEN) {
3001 ND_TCHECK_LEN(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN);
3002 ND_PRINT("\n\t Neighbor System-ID: %s",
3003 isis_print_id(ndo, tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN));
3004 tlen-=SYSTEM_ID_LEN;
3005 }
3006 if(tlen>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
3007 ND_TCHECK_4(tlv_ptp_adj->neighbor_extd_local_circuit_id);
3008 ND_PRINT("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
3009 GET_BE_U_4(tlv_ptp_adj->neighbor_extd_local_circuit_id));
3010 }
3011 break;
3012
3013 case ISIS_TLV_PROTOCOLS:
3014 ND_PRINT("\n\t NLPID(s): ");
3015 while (tlen != 0) {
3016 ND_TCHECK_1(tptr);
3017 ND_PRINT("%s (0x%02x)",
3018 tok2str(nlpid_values,
3019 "unknown",
3020 GET_U_1(tptr)),
3021 GET_U_1(tptr));
3022 if (tlen>1) /* further NPLIDs ? - put comma */
3023 ND_PRINT(", ");
3024 tptr++;
3025 tlen--;
3026 }
3027 break;
3028
3029 case ISIS_TLV_MT_PORT_CAP:
3030 {
3031 if (tlen < 2)
3032 goto tlv_trunc;
3033 ND_TCHECK_2(tptr);
3034
3035 ND_PRINT("\n\t RES: %u, MTID(s): %u",
3036 (GET_BE_U_2(tptr) >> 12),
3037 (GET_BE_U_2(tptr) & 0x0fff));
3038
3039 tptr += 2;
3040 tlen -= 2;
3041
3042 if (tlen)
3043 isis_print_mt_port_cap_subtlv(ndo, tptr, tlen);
3044
3045 break;
3046 }
3047
3048 case ISIS_TLV_MT_CAPABILITY:
3049 if (tlen < 2)
3050 goto tlv_trunc;
3051 ND_TCHECK_2(tptr);
3052
3053 ND_PRINT("\n\t O: %u, RES: %u, MTID(s): %u",
3054 (GET_BE_U_2(tptr) >> 15) & 0x01,
3055 (GET_BE_U_2(tptr) >> 12) & 0x07,
3056 GET_BE_U_2(tptr) & 0x0fff);
3057
3058 tptr += 2;
3059 tlen -= 2;
3060
3061 if (tlen)
3062 isis_print_mt_capability_subtlv(ndo, tptr, tlen);
3063
3064 break;
3065
3066 case ISIS_TLV_TE_ROUTER_ID:
3067 if (tlen < sizeof(nd_ipv4))
3068 goto tlv_trunc;
3069 ND_TCHECK_LEN(pptr, sizeof(nd_ipv4));
3070 ND_PRINT("\n\t Traffic Engineering Router ID: %s", GET_IPADDR_STRING(pptr));
3071 break;
3072
3073 case ISIS_TLV_IPADDR:
3074 while (tlen != 0) {
3075 if (tlen < sizeof(nd_ipv4))
3076 goto tlv_trunc;
3077 ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
3078 ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr));
3079 tptr += sizeof(nd_ipv4);
3080 tlen -= sizeof(nd_ipv4);
3081 }
3082 break;
3083
3084 case ISIS_TLV_HOSTNAME:
3085 ND_PRINT("\n\t Hostname: ");
3086 if (nd_printzp(ndo, tptr, tlen, ndo->ndo_snapend))
3087 goto trunc;
3088 break;
3089
3090 case ISIS_TLV_SHARED_RISK_GROUP:
3091 if (tlen < NODE_ID_LEN)
3092 break;
3093 ND_TCHECK_LEN(tptr, NODE_ID_LEN);
3094 ND_PRINT("\n\t IS Neighbor: %s", isis_print_id(ndo, tptr, NODE_ID_LEN));
3095 tptr+=NODE_ID_LEN;
3096 tlen-=NODE_ID_LEN;
3097
3098 if (tlen < 1)
3099 break;
3100 ND_TCHECK_1(tptr);
3101 ND_PRINT(", Flags: [%s]",
3102 ISIS_MASK_TLV_SHARED_RISK_GROUP(GET_U_1(tptr)) ? "numbered" : "unnumbered");
3103 tptr++;
3104 tlen--;
3105
3106 if (tlen < sizeof(nd_ipv4))
3107 break;
3108 ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
3109 ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr));
3110 tptr+=sizeof(nd_ipv4);
3111 tlen-=sizeof(nd_ipv4);
3112
3113 if (tlen < sizeof(nd_ipv4))
3114 break;
3115 ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
3116 ND_PRINT("\n\t IPv4 neighbor address: %s", GET_IPADDR_STRING(tptr));
3117 tptr+=sizeof(nd_ipv4);
3118 tlen-=sizeof(nd_ipv4);
3119
3120 while (tlen != 0) {
3121 if (tlen < 4)
3122 goto tlv_trunc;
3123 ND_TCHECK_4(tptr);
3124 ND_PRINT("\n\t Link-ID: 0x%08x", GET_BE_U_4(tptr));
3125 tptr+=4;
3126 tlen-=4;
3127 }
3128 break;
3129
3130 case ISIS_TLV_LSP:
3131 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
3132 while (tlen != 0) {
3133 if (tlen < sizeof(struct isis_tlv_lsp))
3134 goto tlv_trunc;
3135 ND_TCHECK_1(tlv_lsp->lsp_id + LSP_ID_LEN - 1);
3136 ND_PRINT("\n\t lsp-id: %s",
3137 isis_print_id(ndo, tlv_lsp->lsp_id, LSP_ID_LEN));
3138 ND_TCHECK_4(tlv_lsp->sequence_number);
3139 ND_PRINT(", seq: 0x%08x",
3140 GET_BE_U_4(tlv_lsp->sequence_number));
3141 ND_TCHECK_2(tlv_lsp->remaining_lifetime);
3142 ND_PRINT(", lifetime: %5ds",
3143 GET_BE_U_2(tlv_lsp->remaining_lifetime));
3144 ND_TCHECK_2(tlv_lsp->checksum);
3145 ND_PRINT(", chksum: 0x%04x", GET_BE_U_2(tlv_lsp->checksum));
3146 tlen-=sizeof(struct isis_tlv_lsp);
3147 tlv_lsp++;
3148 }
3149 break;
3150
3151 case ISIS_TLV_CHECKSUM:
3152 if (tlen < ISIS_TLV_CHECKSUM_MINLEN)
3153 break;
3154 ND_TCHECK_LEN(tptr, ISIS_TLV_CHECKSUM_MINLEN);
3155 ND_PRINT("\n\t checksum: 0x%04x ", GET_BE_U_2(tptr));
3156 /* do not attempt to verify the checksum if it is zero
3157 * most likely a HMAC-MD5 TLV is also present and
3158 * to avoid conflicts the checksum TLV is zeroed.
3159 * see rfc3358 for details
3160 */
3161 osi_print_cksum(ndo, optr, GET_BE_U_2(tptr), (int)(tptr-optr),
3162 length);
3163 break;
3164
3165 case ISIS_TLV_POI:
3166 if (tlen < 1)
3167 goto tlv_trunc;
3168 ND_TCHECK_1(tptr);
3169 num_system_ids = GET_U_1(tptr);
3170 tptr++;
3171 tlen--;
3172 if (num_system_ids == 0) {
3173 /* Not valid */
3174 ND_PRINT(" No system IDs supplied");
3175 } else {
3176 if (tlen < SYSTEM_ID_LEN)
3177 goto tlv_trunc;
3178 ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN);
3179 ND_PRINT("\n\t Purge Originator System-ID: %s",
3180 isis_print_id(ndo, tptr, SYSTEM_ID_LEN));
3181 tptr += SYSTEM_ID_LEN;
3182 tlen -= SYSTEM_ID_LEN;
3183
3184 if (num_system_ids > 1) {
3185 if (tlen < SYSTEM_ID_LEN)
3186 goto tlv_trunc;
3187 ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN);
3188 ND_TCHECK_LEN(tptr, 2 * SYSTEM_ID_LEN + 1);
3189 ND_PRINT("\n\t Received from System-ID: %s",
3190 isis_print_id(ndo, tptr, SYSTEM_ID_LEN));
3191 }
3192 }
3193 break;
3194
3195 case ISIS_TLV_MT_SUPPORTED:
3196 while (tlen != 0) {
3197 /* length can only be a multiple of 2, otherwise there is
3198 something broken -> so decode down until length is 1 */
3199 if (tlen!=1) {
3200 mt_len = isis_print_mtid(ndo, tptr, "\n\t ", tlen);
3201 if (mt_len == 0) /* did something go wrong ? */
3202 goto trunc;
3203 tptr+=mt_len;
3204 tlen-=mt_len;
3205 } else {
3206 ND_PRINT("\n\t invalid MT-ID");
3207 break;
3208 }
3209 }
3210 break;
3211
3212 case ISIS_TLV_RESTART_SIGNALING:
3213 /* first attempt to decode the flags */
3214 if (tlen < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
3215 break;
3216 ND_TCHECK_LEN(tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN);
3217 ND_PRINT("\n\t Flags [%s]",
3218 bittok2str(isis_restart_flag_values, "none", GET_U_1(tptr)));
3219 tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
3220 tlen-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
3221
3222 /* is there anything other than the flags field? */
3223 if (tlen == 0)
3224 break;
3225
3226 if (tlen < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
3227 break;
3228 ND_TCHECK_LEN(tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN);
3229
3230 ND_PRINT(", Remaining holding time %us", GET_BE_U_2(tptr));
3231 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
3232 tlen-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
3233
3234 /* is there an additional sysid field present ?*/
3235 if (tlen == SYSTEM_ID_LEN) {
3236 ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN);
3237 ND_PRINT(", for %s", isis_print_id(ndo, tptr,SYSTEM_ID_LEN));
3238 }
3239 break;
3240
3241 case ISIS_TLV_IDRP_INFO:
3242 if (tlen < 1)
3243 break;
3244 ND_TCHECK_1(tptr);
3245 isis_subtlv_idrp = GET_U_1(tptr);
3246 ND_PRINT("\n\t Inter-Domain Information Type: %s",
3247 tok2str(isis_subtlv_idrp_values,
3248 "Unknown (0x%02x)",
3249 isis_subtlv_idrp));
3250 tptr++;
3251 tlen--;
3252 switch (isis_subtlv_idrp) {
3253 case ISIS_SUBTLV_IDRP_ASN:
3254 if (tlen < 2)
3255 goto tlv_trunc;
3256 ND_TCHECK_2(tptr); /* fetch AS number */
3257 ND_PRINT("AS Number: %u", GET_BE_U_2(tptr));
3258 break;
3259 case ISIS_SUBTLV_IDRP_LOCAL:
3260 case ISIS_SUBTLV_IDRP_RES:
3261 default:
3262 if (!print_unknown_data(ndo, tptr, "\n\t ", tlen))
3263 return(0);
3264 break;
3265 }
3266 break;
3267
3268 case ISIS_TLV_LSP_BUFFERSIZE:
3269 if (tlen < 2)
3270 break;
3271 ND_TCHECK_2(tptr);
3272 ND_PRINT("\n\t LSP Buffersize: %u", GET_BE_U_2(tptr));
3273 break;
3274
3275 case ISIS_TLV_PART_DIS:
3276 while (tlen != 0) {
3277 if (tlen < SYSTEM_ID_LEN)
3278 goto tlv_trunc;
3279 ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN);
3280 ND_PRINT("\n\t %s", isis_print_id(ndo, tptr, SYSTEM_ID_LEN));
3281 tptr+=SYSTEM_ID_LEN;
3282 tlen-=SYSTEM_ID_LEN;
3283 }
3284 break;
3285
3286 case ISIS_TLV_PREFIX_NEIGH:
3287 if (tlen < sizeof(struct isis_metric_block))
3288 break;
3289 ND_TCHECK_LEN(tptr, sizeof(struct isis_metric_block));
3290 ND_PRINT("\n\t Metric Block");
3291 isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
3292 tptr+=sizeof(struct isis_metric_block);
3293 tlen-=sizeof(struct isis_metric_block);
3294
3295 while (tlen != 0) {
3296 ND_TCHECK_1(tptr);
3297 prefix_len=GET_U_1(tptr); /* read out prefix length in semioctets*/
3298 tptr++;
3299 tlen--;
3300 if (prefix_len < 2) {
3301 ND_PRINT("\n\t\tAddress: prefix length %u < 2", prefix_len);
3302 break;
3303 }
3304 if (tlen < prefix_len/2)
3305 break;
3306 ND_TCHECK_LEN(tptr, prefix_len / 2);
3307 ND_PRINT("\n\t\tAddress: %s/%u",
3308 GET_ISONSAP_STRING(tptr, prefix_len / 2), prefix_len * 4);
3309 tptr+=prefix_len/2;
3310 tlen-=prefix_len/2;
3311 }
3312 break;
3313
3314 case ISIS_TLV_IIH_SEQNR:
3315 if (tlen < 4)
3316 break;
3317 ND_TCHECK_4(tptr); /* check if four bytes are on the wire */
3318 ND_PRINT("\n\t Sequence number: %u", GET_BE_U_4(tptr));
3319 break;
3320
3321 case ISIS_TLV_ROUTER_CAPABILITY:
3322 if (tlen < 5) {
3323 ND_PRINT(" [object length %u < 5]", tlen);
3324 nd_print_invalid(ndo);
3325 break;
3326 }
3327 ND_TCHECK_5(tptr); /* router-id + flags */
3328 ND_PRINT("\n\t\tRouter-id: %s", GET_IPADDR_STRING(tptr));
3329 ND_PRINT("\n\t\tFlags: [%s]",
3330 bittok2str(isis_tlv_router_capability_flags,
3331 "none",
3332 GET_U_1(tptr+4)));
3333 /* FIXME Optional set of sub-TLV */
3334 break;
3335
3336 case ISIS_TLV_VENDOR_PRIVATE:
3337 if (tlen < 3)
3338 break;
3339 ND_TCHECK_3(tptr); /* check if enough byte for a full oui */
3340 vendor_id = GET_BE_U_3(tptr);
3341 ND_PRINT("\n\t Vendor: %s (%u)",
3342 tok2str(oui_values, "Unknown", vendor_id),
3343 vendor_id);
3344 tptr+=3;
3345 tlen-=3;
3346 if (tlen != 0) /* hexdump the rest */
3347 if (!print_unknown_data(ndo, tptr, "\n\t\t", tlen))
3348 return(0);
3349 break;
3350 /*
3351 * FIXME those are the defined TLVs that lack a decoder
3352 * you are welcome to contribute code ;-)
3353 */
3354
3355 case ISIS_TLV_DECNET_PHASE4:
3356 case ISIS_TLV_LUCENT_PRIVATE:
3357 case ISIS_TLV_IPAUTH:
3358 case ISIS_TLV_NORTEL_PRIVATE1:
3359 case ISIS_TLV_NORTEL_PRIVATE2:
3360
3361 default:
3362 if (ndo->ndo_vflag <= 1) {
3363 if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
3364 return(0);
3365 }
3366 break;
3367 }
3368 tlv_trunc:
3369 /* do we want to see an additionally hexdump ? */
3370 if (ndo->ndo_vflag> 1) {
3371 if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len))
3372 return(0);
3373 }
3374
3375 pptr += tlv_len;
3376 packet_len -= tlv_len;
3377 }
3378
3379 if (packet_len != 0) {
3380 ND_PRINT("\n\t %u straggler bytes", packet_len);
3381 }
3382 return (1);
3383
3384 trunc:
3385 nd_print_trunc(ndo);
3386 return (1);
3387 }
3388
3389 static void
3390 osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
3391 uint16_t checksum, int checksum_offset, u_int length)
3392 {
3393 uint16_t calculated_checksum;
3394
3395 /* do not attempt to verify the checksum if it is zero,
3396 * if the offset is nonsense,
3397 * or the base pointer is not sane
3398 */
3399 if (!checksum
3400 || checksum_offset < 0
3401 || !ND_TTEST_2(pptr + checksum_offset)
3402 || (u_int)checksum_offset > length
3403 || !ND_TTEST_LEN(pptr, length)) {
3404 ND_PRINT(" (unverified)");
3405 } else {
3406 #if 0
3407 ND_PRINT("\nosi_print_cksum: %p %d %u\n", pptr, checksum_offset, length);
3408 #endif
3409 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
3410 if (checksum == calculated_checksum) {
3411 ND_PRINT(" (correct)");
3412 } else {
3413 ND_PRINT(" (incorrect should be 0x%04x)", calculated_checksum);
3414 }
3415 }
3416 }