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