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