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