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