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