]> The Tcpdump Group git mirrors - tcpdump/blob - print-isoclns.c
Compile with '-Wused-but-marked-unused' in devel mode if supported
[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@juniper.net) 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 int osi_print_cksum(netdissect_options *, const uint8_t *pptr,
568 uint16_t checksum, int checksum_offset, 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 /* FIXME further header sanity checking */
795
796 clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
797 clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
798
799 pptr += sizeof(struct clnp_header_t);
800 li -= sizeof(struct clnp_header_t);
801 dest_address_length = *pptr;
802 dest_address = pptr + 1;
803
804 pptr += (1 + dest_address_length);
805 li -= (1 + dest_address_length);
806 source_address_length = *pptr;
807 source_address = pptr +1;
808
809 pptr += (1 + source_address_length);
810 li -= (1 + source_address_length);
811
812 if (ndo->ndo_vflag < 1) {
813 ND_PRINT((ndo, "%s%s > %s, %s, length %u",
814 ndo->ndo_eflag ? "" : ", ",
815 isonsap_string(ndo, source_address, source_address_length),
816 isonsap_string(ndo, dest_address, dest_address_length),
817 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
818 length));
819 return (1);
820 }
821 ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
822
823 ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
824 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
825 clnp_header->length_indicator,
826 clnp_header->version,
827 clnp_header->lifetime/2,
828 (clnp_header->lifetime%2)*5,
829 EXTRACT_16BITS(clnp_header->segment_length),
830 EXTRACT_16BITS(clnp_header->cksum)));
831
832 if (osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7,
833 clnp_header->length_indicator) == 0)
834 goto trunc;
835
836 ND_PRINT((ndo, "\n\tFlags [%s]",
837 bittok2str(clnp_flag_values, "none", clnp_flags)));
838
839 ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
840 source_address_length,
841 isonsap_string(ndo, source_address, source_address_length),
842 dest_address_length,
843 isonsap_string(ndo, dest_address, dest_address_length)));
844
845 if (clnp_flags & CLNP_SEGMENT_PART) {
846 clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
847 ND_TCHECK(*clnp_segment_header);
848 ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
849 EXTRACT_16BITS(clnp_segment_header->data_unit_id),
850 EXTRACT_16BITS(clnp_segment_header->segment_offset),
851 EXTRACT_16BITS(clnp_segment_header->total_length)));
852 pptr+=sizeof(const struct clnp_segment_header_t);
853 li-=sizeof(const struct clnp_segment_header_t);
854 }
855
856 /* now walk the options */
857 while (li >= 2) {
858 u_int op, opli;
859 const uint8_t *tptr;
860
861 ND_TCHECK2(*pptr, 2);
862 if (li < 2) {
863 ND_PRINT((ndo, ", bad opts/li"));
864 return (0);
865 }
866 op = *pptr++;
867 opli = *pptr++;
868 li -= 2;
869 ND_TCHECK2(*pptr, opli);
870 if (opli > li) {
871 ND_PRINT((ndo, ", opt (%d) too long", op));
872 return (0);
873 }
874 li -= opli;
875 tptr = pptr;
876 tlen = opli;
877
878 ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
879 tok2str(clnp_option_values,"Unknown",op),
880 op,
881 opli));
882
883 switch (op) {
884
885
886 case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
887 case CLNP_OPTION_SOURCE_ROUTING:
888 ND_PRINT((ndo, "%s %s",
889 tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
890 tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
891 nsap_offset=*(tptr+1);
892 if (nsap_offset == 0) {
893 ND_PRINT((ndo, " Bad NSAP offset (0)"));
894 break;
895 }
896 nsap_offset-=1; /* offset to nsap list */
897 if (nsap_offset > tlen) {
898 ND_PRINT((ndo, " Bad NSAP offset (past end of option)"));
899 break;
900 }
901 tptr+=nsap_offset;
902 tlen-=nsap_offset;
903 while (tlen > 0) {
904 source_address_length=*tptr;
905 if (tlen < source_address_length+1) {
906 ND_PRINT((ndo, "\n\t NSAP address goes past end of option"));
907 break;
908 }
909 if (source_address_length > 0) {
910 source_address=(tptr+1);
911 ND_TCHECK2(*source_address, source_address_length);
912 ND_PRINT((ndo, "\n\t NSAP address (length %u): %s",
913 source_address_length,
914 isonsap_string(ndo, source_address, source_address_length)));
915 }
916 tlen-=source_address_length+1;
917 }
918 break;
919
920 case CLNP_OPTION_PRIORITY:
921 ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
922 break;
923
924 case CLNP_OPTION_QOS_MAINTENANCE:
925 ND_PRINT((ndo, "\n\t Format Code: %s",
926 tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK)));
927
928 if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
929 ND_PRINT((ndo, "\n\t QoS Flags [%s]",
930 bittok2str(clnp_option_qos_global_values,
931 "none",
932 *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
933 break;
934
935 case CLNP_OPTION_SECURITY:
936 ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u",
937 tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
938 *(tptr+1)));
939 break;
940
941 case CLNP_OPTION_DISCARD_REASON:
942 rfd_error_major = (*tptr&0xf0) >> 4;
943 rfd_error_minor = *tptr&0x0f;
944 ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
945 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
946 rfd_error_major,
947 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
948 rfd_error_minor));
949 break;
950
951 case CLNP_OPTION_PADDING:
952 ND_PRINT((ndo, "padding data"));
953 break;
954
955 /*
956 * FIXME those are the defined Options that lack a decoder
957 * you are welcome to contribute code ;-)
958 */
959
960 default:
961 print_unknown_data(ndo, tptr, "\n\t ", opli);
962 break;
963 }
964 if (ndo->ndo_vflag > 1)
965 print_unknown_data(ndo, pptr, "\n\t ", opli);
966 pptr += opli;
967 }
968
969 switch (clnp_pdu_type) {
970
971 case CLNP_PDU_ER: /* fall through */
972 case CLNP_PDU_ERP:
973 ND_TCHECK(*pptr);
974 if (*(pptr) == NLPID_CLNP) {
975 ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
976 /* FIXME recursion protection */
977 clnp_print(ndo, pptr, length - clnp_header->length_indicator);
978 break;
979 }
980
981 case CLNP_PDU_DT:
982 case CLNP_PDU_MD:
983 case CLNP_PDU_ERQ:
984
985 default:
986 /* dump the PDU specific data */
987 if (length-(pptr-optr) > 0) {
988 ND_PRINT((ndo, "\n\t undecoded non-header data, length %u", length-clnp_header->length_indicator));
989 print_unknown_data(ndo, pptr, "\n\t ", length - (pptr - optr));
990 }
991 }
992
993 return (1);
994
995 trunc:
996 ND_PRINT((ndo, "[|clnp]"));
997 return (1);
998
999 }
1000
1001
1002 #define ESIS_PDU_REDIRECT 6
1003 #define ESIS_PDU_ESH 2
1004 #define ESIS_PDU_ISH 4
1005
1006 static const struct tok esis_pdu_values[] = {
1007 { ESIS_PDU_REDIRECT, "redirect"},
1008 { ESIS_PDU_ESH, "ESH"},
1009 { ESIS_PDU_ISH, "ISH"},
1010 { 0, NULL }
1011 };
1012
1013 struct esis_header_t {
1014 uint8_t nlpid;
1015 uint8_t length_indicator;
1016 uint8_t version;
1017 uint8_t reserved;
1018 uint8_t type;
1019 uint8_t holdtime[2];
1020 uint8_t cksum[2];
1021 };
1022
1023 static void
1024 esis_print(netdissect_options *ndo,
1025 const uint8_t *pptr, u_int length)
1026 {
1027 const uint8_t *optr;
1028 u_int li,esis_pdu_type,source_address_length, source_address_number;
1029 const struct esis_header_t *esis_header;
1030
1031 if (!ndo->ndo_eflag)
1032 ND_PRINT((ndo, "ES-IS"));
1033
1034 if (length <= 2) {
1035 ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!"));
1036 return;
1037 }
1038
1039 esis_header = (const struct esis_header_t *) pptr;
1040 ND_TCHECK(*esis_header);
1041 li = esis_header->length_indicator;
1042 optr = pptr;
1043
1044 /*
1045 * Sanity checking of the header.
1046 */
1047
1048 if (esis_header->nlpid != NLPID_ESIS) {
1049 ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid));
1050 return;
1051 }
1052
1053 if (esis_header->version != ESIS_VERSION) {
1054 ND_PRINT((ndo, " version %d packet not supported", esis_header->version));
1055 return;
1056 }
1057
1058 if (li > length) {
1059 ND_PRINT((ndo, " length indicator(%d) > PDU size (%d)!", li, length));
1060 return;
1061 }
1062
1063 if (li < sizeof(struct esis_header_t) + 2) {
1064 ND_PRINT((ndo, " length indicator < min PDU size %d:", li));
1065 while (pptr < ndo->ndo_snapend)
1066 ND_PRINT((ndo, "%02X", *pptr++));
1067 return;
1068 }
1069
1070 esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
1071
1072 if (ndo->ndo_vflag < 1) {
1073 ND_PRINT((ndo, "%s%s, length %u",
1074 ndo->ndo_eflag ? "" : ", ",
1075 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
1076 length));
1077 return;
1078 } else
1079 ND_PRINT((ndo, "%slength %u\n\t%s (%u)",
1080 ndo->ndo_eflag ? "" : ", ",
1081 length,
1082 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
1083 esis_pdu_type));
1084
1085 ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ));
1086 ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)));
1087
1088 if (osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li) == 0)
1089 goto trunc;
1090
1091 ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
1092 EXTRACT_16BITS(esis_header->holdtime), li));
1093
1094 if (ndo->ndo_vflag > 1)
1095 print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
1096
1097 pptr += sizeof(struct esis_header_t);
1098 li -= sizeof(struct esis_header_t);
1099
1100 switch (esis_pdu_type) {
1101 case ESIS_PDU_REDIRECT: {
1102 const uint8_t *dst, *snpa, *neta;
1103 u_int dstl, snpal, netal;
1104
1105 ND_TCHECK(*pptr);
1106 if (li < 1) {
1107 ND_PRINT((ndo, ", bad redirect/li"));
1108 return;
1109 }
1110 dstl = *pptr;
1111 pptr++;
1112 li--;
1113 ND_TCHECK2(*pptr, dstl);
1114 if (li < dstl) {
1115 ND_PRINT((ndo, ", bad redirect/li"));
1116 return;
1117 }
1118 dst = pptr;
1119 pptr += dstl;
1120 li -= dstl;
1121 ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, dst, dstl)));
1122
1123 ND_TCHECK(*pptr);
1124 if (li < 1) {
1125 ND_PRINT((ndo, ", bad redirect/li"));
1126 return;
1127 }
1128 snpal = *pptr;
1129 pptr++;
1130 li--;
1131 ND_TCHECK2(*pptr, snpal);
1132 if (li < snpal) {
1133 ND_PRINT((ndo, ", bad redirect/li"));
1134 return;
1135 }
1136 snpa = pptr;
1137 pptr += snpal;
1138 li -= snpal;
1139 ND_TCHECK(*pptr);
1140 if (li < 1) {
1141 ND_PRINT((ndo, ", bad redirect/li"));
1142 return;
1143 }
1144 netal = *pptr;
1145 pptr++;
1146 ND_TCHECK2(*pptr, netal);
1147 if (li < netal) {
1148 ND_PRINT((ndo, ", bad redirect/li"));
1149 return;
1150 }
1151 neta = pptr;
1152 pptr += netal;
1153 li -= netal;
1154
1155 if (netal == 0)
1156 ND_PRINT((ndo, "\n\t %s", etheraddr_string(ndo, snpa)));
1157 else
1158 ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, neta, netal)));
1159 break;
1160 }
1161
1162 case ESIS_PDU_ESH:
1163 ND_TCHECK(*pptr);
1164 if (li < 1) {
1165 ND_PRINT((ndo, ", bad esh/li"));
1166 return;
1167 }
1168 source_address_number = *pptr;
1169 pptr++;
1170 li--;
1171
1172 ND_PRINT((ndo, "\n\t Number of Source Addresses: %u", source_address_number));
1173
1174 while (source_address_number > 0) {
1175 ND_TCHECK(*pptr);
1176 if (li < 1) {
1177 ND_PRINT((ndo, ", bad esh/li"));
1178 return;
1179 }
1180 source_address_length = *pptr;
1181 pptr++;
1182 li--;
1183
1184 ND_TCHECK2(*pptr, source_address_length);
1185 if (li < source_address_length) {
1186 ND_PRINT((ndo, ", bad esh/li"));
1187 return;
1188 }
1189 ND_PRINT((ndo, "\n\t NET (length: %u): %s",
1190 source_address_length,
1191 isonsap_string(ndo, pptr, source_address_length)));
1192 pptr += source_address_length;
1193 li -= source_address_length;
1194 source_address_number--;
1195 }
1196
1197 break;
1198
1199 case ESIS_PDU_ISH: {
1200 ND_TCHECK(*pptr);
1201 if (li < 1) {
1202 ND_PRINT((ndo, ", bad ish/li"));
1203 return;
1204 }
1205 source_address_length = *pptr;
1206 pptr++;
1207 li--;
1208 ND_TCHECK2(*pptr, source_address_length);
1209 if (li < source_address_length) {
1210 ND_PRINT((ndo, ", bad ish/li"));
1211 return;
1212 }
1213 ND_PRINT((ndo, "\n\t NET (length: %u): %s", source_address_length, isonsap_string(ndo, pptr, source_address_length)));
1214 pptr += source_address_length;
1215 li -= source_address_length;
1216 break;
1217 }
1218
1219 default:
1220 if (ndo->ndo_vflag <= 1) {
1221 if (pptr < ndo->ndo_snapend)
1222 print_unknown_data(ndo, pptr, "\n\t ", ndo->ndo_snapend - pptr);
1223 }
1224 return;
1225 }
1226
1227 /* now walk the options */
1228 while (li != 0) {
1229 u_int op, opli;
1230 const uint8_t *tptr;
1231
1232 if (li < 2) {
1233 ND_PRINT((ndo, ", bad opts/li"));
1234 return;
1235 }
1236 ND_TCHECK2(*pptr, 2);
1237 op = *pptr++;
1238 opli = *pptr++;
1239 li -= 2;
1240 if (opli > li) {
1241 ND_PRINT((ndo, ", opt (%d) too long", op));
1242 return;
1243 }
1244 li -= opli;
1245 tptr = pptr;
1246
1247 ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
1248 tok2str(esis_option_values,"Unknown",op),
1249 op,
1250 opli));
1251
1252 switch (op) {
1253
1254 case ESIS_OPTION_ES_CONF_TIME:
1255 if (opli == 2) {
1256 ND_TCHECK2(*pptr, 2);
1257 ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr)));
1258 } else
1259 ND_PRINT((ndo, "(bad length)"));
1260 break;
1261
1262 case ESIS_OPTION_PROTOCOLS:
1263 while (opli>0) {
1264 ND_TCHECK(*pptr);
1265 ND_PRINT((ndo, "%s (0x%02x)",
1266 tok2str(nlpid_values,
1267 "unknown",
1268 *tptr),
1269 *tptr));
1270 if (opli>1) /* further NPLIDs ? - put comma */
1271 ND_PRINT((ndo, ", "));
1272 tptr++;
1273 opli--;
1274 }
1275 break;
1276
1277 /*
1278 * FIXME those are the defined Options that lack a decoder
1279 * you are welcome to contribute code ;-)
1280 */
1281
1282 case ESIS_OPTION_QOS_MAINTENANCE:
1283 case ESIS_OPTION_SECURITY:
1284 case ESIS_OPTION_PRIORITY:
1285 case ESIS_OPTION_ADDRESS_MASK:
1286 case ESIS_OPTION_SNPA_MASK:
1287
1288 default:
1289 print_unknown_data(ndo, tptr, "\n\t ", opli);
1290 break;
1291 }
1292 if (ndo->ndo_vflag > 1)
1293 print_unknown_data(ndo, pptr, "\n\t ", opli);
1294 pptr += opli;
1295 }
1296 trunc:
1297 return;
1298 }
1299
1300 static void
1301 isis_print_mcid(netdissect_options *ndo,
1302 const struct isis_spb_mcid *mcid)
1303 {
1304 int i;
1305
1306 ND_TCHECK(*mcid);
1307 ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id));
1308
1309 if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
1310 goto trunc;
1311
1312 ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
1313
1314 ND_PRINT((ndo, ", Digest: "));
1315
1316 for(i=0;i<16;i++)
1317 ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
1318
1319 trunc:
1320 ND_PRINT((ndo, "%s", tstr));
1321 }
1322
1323 static int
1324 isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
1325 const uint8_t *tptr, int len)
1326 {
1327 int stlv_type, stlv_len;
1328 const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
1329 int i;
1330
1331 while (len > 2)
1332 {
1333 stlv_type = *(tptr++);
1334 stlv_len = *(tptr++);
1335
1336 /* first lets see if we know the subTLVs name*/
1337 ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
1338 tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
1339 stlv_type,
1340 stlv_len));
1341
1342 /*len -= TLV_TYPE_LEN_OFFSET;*/
1343 len = len -2;
1344
1345 switch (stlv_type)
1346 {
1347 case ISIS_SUBTLV_SPB_MCID:
1348 {
1349 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN))
1350 goto trunctlv;
1351
1352 subtlv_spb_mcid = (const struct isis_subtlv_spb_mcid *)tptr;
1353
1354 ND_PRINT((ndo, "\n\t MCID: "));
1355 isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
1356
1357 /*tptr += SPB_MCID_MIN_LEN;
1358 len -= SPB_MCID_MIN_LEN; */
1359
1360 ND_PRINT((ndo, "\n\t AUX-MCID: "));
1361 isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
1362
1363 /*tptr += SPB_MCID_MIN_LEN;
1364 len -= SPB_MCID_MIN_LEN; */
1365 tptr = tptr + sizeof(struct isis_subtlv_spb_mcid);
1366 len = len - sizeof(struct isis_subtlv_spb_mcid);
1367
1368 break;
1369 }
1370
1371 case ISIS_SUBTLV_SPB_DIGEST:
1372 {
1373 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
1374 goto trunctlv;
1375
1376 ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
1377 (*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
1378 ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
1379
1380 tptr++;
1381
1382 ND_PRINT((ndo, "\n\t Digest: "));
1383
1384 for(i=1;i<=8; i++)
1385 {
1386 ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr)));
1387 if (i%4 == 0 && i != 8)
1388 ND_PRINT((ndo, "\n\t "));
1389 tptr = tptr + 4;
1390 }
1391
1392 len = len - ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
1393
1394 break;
1395 }
1396
1397 case ISIS_SUBTLV_SPB_BVID:
1398 {
1399 if (!ND_TTEST2(*(tptr), stlv_len))
1400 goto trunctlv;
1401
1402 while (len >= ISIS_SUBTLV_SPB_BVID_MIN_LEN)
1403 {
1404 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
1405 goto trunctlv;
1406
1407 ND_PRINT((ndo, "\n\t ECT: %08x",
1408 EXTRACT_32BITS(tptr)));
1409
1410 tptr = tptr+4;
1411
1412 ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ",
1413 (EXTRACT_16BITS (tptr) >> 4) ,
1414 (EXTRACT_16BITS (tptr) >> 3) & 0x01,
1415 (EXTRACT_16BITS (tptr) >> 2) & 0x01));
1416
1417 tptr = tptr + 2;
1418 len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
1419 }
1420
1421 break;
1422 }
1423
1424 default:
1425 break;
1426 }
1427 }
1428
1429 return 0;
1430
1431 trunctlv:
1432 ND_PRINT((ndo, "\n\t\t"));
1433 ND_PRINT((ndo, "%s", tstr));
1434 return(1);
1435 }
1436
1437 static int
1438 isis_print_mt_capability_subtlv(netdissect_options *ndo,
1439 const uint8_t *tptr, int len)
1440 {
1441 int stlv_type, stlv_len, tmp;
1442
1443 while (len > 2)
1444 {
1445 stlv_type = *(tptr++);
1446 stlv_len = *(tptr++);
1447
1448 /* first lets see if we know the subTLVs name*/
1449 ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
1450 tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
1451 stlv_type,
1452 stlv_len));
1453
1454 len = len - 2;
1455
1456 switch (stlv_type)
1457 {
1458 case ISIS_SUBTLV_SPB_INSTANCE:
1459
1460 ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN);
1461
1462 ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
1463 tptr = tptr+4;
1464 ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr)));
1465 tptr = tptr+4;
1466 ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr)));
1467 tptr = tptr+4;
1468 ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr)));
1469 tptr = tptr + 2;
1470 ND_PRINT((ndo, "\n\t RES: %d",
1471 EXTRACT_16BITS(tptr) >> 5));
1472 ND_PRINT((ndo, ", V: %d",
1473 (EXTRACT_16BITS(tptr) >> 4) & 0x0001));
1474 ND_PRINT((ndo, ", SPSource-ID: %d",
1475 (EXTRACT_32BITS(tptr) & 0x000fffff)));
1476 tptr = tptr+4;
1477 ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
1478
1479 tmp = *(tptr++);
1480
1481 len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
1482
1483 while (tmp)
1484 {
1485 ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN);
1486
1487 ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
1488 *(tptr) >> 7, (*(tptr) >> 6) & 0x01,
1489 (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
1490
1491 tptr++;
1492
1493 ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr)));
1494
1495 tptr = tptr + 4;
1496
1497 ND_PRINT((ndo, ", BVID: %d, SPVID: %d",
1498 (EXTRACT_24BITS(tptr) >> 12) & 0x000fff,
1499 EXTRACT_24BITS(tptr) & 0x000fff));
1500
1501 tptr = tptr + 3;
1502 len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
1503 tmp--;
1504 }
1505
1506 break;
1507
1508 case ISIS_SUBTLV_SPBM_SI:
1509
1510 ND_TCHECK2(*tptr, 8);
1511
1512 ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr)));
1513 tptr = tptr+4;
1514 ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr)));
1515 tptr = tptr+2;
1516
1517 ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
1518 (EXTRACT_16BITS(tptr)) & 0x0fff));
1519
1520 tptr = tptr+2;
1521 len = len - 8;
1522 stlv_len = stlv_len - 8;
1523
1524 while (stlv_len >= 4) {
1525 ND_TCHECK2(*tptr, 4);
1526 ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
1527 (EXTRACT_32BITS(tptr) >> 31),
1528 (EXTRACT_32BITS(tptr) >> 30) & 0x01,
1529 (EXTRACT_32BITS(tptr) >> 24) & 0x03f,
1530 (EXTRACT_32BITS(tptr)) & 0x0ffffff));
1531
1532 tptr = tptr + 4;
1533 len = len - 4;
1534 stlv_len = stlv_len - 4;
1535 }
1536
1537 break;
1538
1539 default:
1540 break;
1541 }
1542 }
1543 return 0;
1544
1545 trunc:
1546 ND_PRINT((ndo, "\n\t\t"));
1547 ND_PRINT((ndo, "%s", tstr));
1548 return(1);
1549 }
1550
1551 /* shared routine for printing system, node and lsp-ids */
1552 static char *
1553 isis_print_id(const uint8_t *cp, int id_len)
1554 {
1555 int i;
1556 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1557 char *pos = id;
1558
1559 for (i = 1; i <= SYSTEM_ID_LEN; i++) {
1560 snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++);
1561 pos += strlen(pos);
1562 if (i == 2 || i == 4)
1563 *pos++ = '.';
1564 }
1565 if (id_len >= NODE_ID_LEN) {
1566 snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++);
1567 pos += strlen(pos);
1568 }
1569 if (id_len == LSP_ID_LEN)
1570 snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp);
1571 return (id);
1572 }
1573
1574 /* print the 4-byte metric block which is common found in the old-style TLVs */
1575 static int
1576 isis_print_metric_block(netdissect_options *ndo,
1577 const struct isis_metric_block *isis_metric_block)
1578 {
1579 ND_PRINT((ndo, ", Default Metric: %d, %s",
1580 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
1581 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"));
1582 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
1583 ND_PRINT((ndo, "\n\t\t Delay Metric: %d, %s",
1584 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
1585 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"));
1586 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
1587 ND_PRINT((ndo, "\n\t\t Expense Metric: %d, %s",
1588 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
1589 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"));
1590 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
1591 ND_PRINT((ndo, "\n\t\t Error Metric: %d, %s",
1592 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
1593 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"));
1594
1595 return(1); /* everything is ok */
1596 }
1597
1598 static int
1599 isis_print_tlv_ip_reach(netdissect_options *ndo,
1600 const uint8_t *cp, const char *ident, int length)
1601 {
1602 int prefix_len;
1603 const struct isis_tlv_ip_reach *tlv_ip_reach;
1604
1605 tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
1606
1607 while (length > 0) {
1608 if ((size_t)length < sizeof(*tlv_ip_reach)) {
1609 ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)",
1610 length,
1611 (unsigned long)sizeof(*tlv_ip_reach)));
1612 return (0);
1613 }
1614
1615 if (!ND_TTEST(*tlv_ip_reach))
1616 return (0);
1617
1618 prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
1619
1620 if (prefix_len == -1)
1621 ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s",
1622 ident,
1623 ipaddr_string(ndo, (tlv_ip_reach->prefix)),
1624 ipaddr_string(ndo, (tlv_ip_reach->mask))));
1625 else
1626 ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
1627 ident,
1628 ipaddr_string(ndo, (tlv_ip_reach->prefix)),
1629 prefix_len));
1630
1631 ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s",
1632 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
1633 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
1634 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"));
1635
1636 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
1637 ND_PRINT((ndo, "%s Delay Metric: %u, %s",
1638 ident,
1639 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
1640 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"));
1641
1642 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
1643 ND_PRINT((ndo, "%s Expense Metric: %u, %s",
1644 ident,
1645 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
1646 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"));
1647
1648 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
1649 ND_PRINT((ndo, "%s Error Metric: %u, %s",
1650 ident,
1651 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
1652 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"));
1653
1654 length -= sizeof(struct isis_tlv_ip_reach);
1655 tlv_ip_reach++;
1656 }
1657 return (1);
1658 }
1659
1660 /*
1661 * this is the common IP-REACH subTLV decoder it is called
1662 * from various EXTD-IP REACH TLVs (135,235,236,237)
1663 */
1664
1665 static int
1666 isis_print_ip_reach_subtlv(netdissect_options *ndo,
1667 const uint8_t *tptr, int subt, int subl,
1668 const char *ident)
1669 {
1670 /* first lets see if we know the subTLVs name*/
1671 ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
1672 ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
1673 subt, subl));
1674
1675 if (!ND_TTEST2(*tptr,subl))
1676 goto trunctlv;
1677
1678 switch(subt) {
1679 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
1680 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
1681 while (subl >= 4) {
1682 ND_PRINT((ndo, ", 0x%08x (=%u)",
1683 EXTRACT_32BITS(tptr),
1684 EXTRACT_32BITS(tptr)));
1685 tptr+=4;
1686 subl-=4;
1687 }
1688 break;
1689 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
1690 while (subl >= 8) {
1691 ND_PRINT((ndo, ", 0x%08x%08x",
1692 EXTRACT_32BITS(tptr),
1693 EXTRACT_32BITS(tptr+4)));
1694 tptr+=8;
1695 subl-=8;
1696 }
1697 break;
1698 default:
1699 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
1700 return(0);
1701 break;
1702 }
1703 return(1);
1704
1705 trunctlv:
1706 ND_PRINT((ndo, "%s", ident));
1707 ND_PRINT((ndo, "%s", tstr));
1708 return(0);
1709 }
1710
1711 /*
1712 * this is the common IS-REACH subTLV decoder it is called
1713 * from isis_print_ext_is_reach()
1714 */
1715
1716 static int
1717 isis_print_is_reach_subtlv(netdissect_options *ndo,
1718 const uint8_t *tptr, u_int subt, u_int subl,
1719 const char *ident)
1720 {
1721 u_int te_class,priority_level,gmpls_switch_cap;
1722 union { /* int to float conversion buffer for several subTLVs */
1723 float f;
1724 uint32_t i;
1725 } bw;
1726
1727 /* first lets see if we know the subTLVs name*/
1728 ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
1729 ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
1730 subt, subl));
1731
1732 ND_TCHECK2(*tptr, subl);
1733
1734 switch(subt) {
1735 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
1736 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
1737 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
1738 if (subl >= 4) {
1739 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
1740 if (subl == 8) /* rfc4205 */
1741 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4)));
1742 }
1743 break;
1744 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
1745 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
1746 if (subl >= sizeof(struct in_addr))
1747 ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
1748 break;
1749 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
1750 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
1751 if (subl >= 4) {
1752 bw.i = EXTRACT_32BITS(tptr);
1753 ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
1754 }
1755 break;
1756 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
1757 if (subl >= 32) {
1758 for (te_class = 0; te_class < 8; te_class++) {
1759 bw.i = EXTRACT_32BITS(tptr);
1760 ND_PRINT((ndo, "%s TE-Class %u: %.3f Mbps",
1761 ident,
1762 te_class,
1763 bw.f * 8 / 1000000));
1764 tptr+=4;
1765 }
1766 }
1767 break;
1768 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
1769 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
1770 ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
1771 ident,
1772 tok2str(diffserv_te_bc_values, "unknown", *tptr),
1773 *tptr));
1774 tptr++;
1775 /* decode BCs until the subTLV ends */
1776 for (te_class = 0; te_class < (subl-1)/4; te_class++) {
1777 ND_TCHECK2(*tptr, 4);
1778 bw.i = EXTRACT_32BITS(tptr);
1779 ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps",
1780 ident,
1781 te_class,
1782 bw.f * 8 / 1000000));
1783 tptr+=4;
1784 }
1785 break;
1786 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
1787 if (subl >= 3)
1788 ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr)));
1789 break;
1790 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
1791 if (subl == 2) {
1792 ND_PRINT((ndo, ", [ %s ] (0x%04x)",
1793 bittok2str(isis_subtlv_link_attribute_values,
1794 "Unknown",
1795 EXTRACT_16BITS(tptr)),
1796 EXTRACT_16BITS(tptr)));
1797 }
1798 break;
1799 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
1800 if (subl >= 2) {
1801 ND_PRINT((ndo, ", %s, Priority %u",
1802 bittok2str(gmpls_link_prot_values, "none", *tptr),
1803 *(tptr+1)));
1804 }
1805 break;
1806 case ISIS_SUBTLV_SPB_METRIC:
1807 if (subl >= 6) {
1808 ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr)));
1809 tptr=tptr+3;
1810 ND_PRINT((ndo, ", P: %u", *(tptr)));
1811 tptr++;
1812 ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr)));
1813 }
1814 break;
1815 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
1816 if (subl >= 36) {
1817 gmpls_switch_cap = *tptr;
1818 ND_PRINT((ndo, "%s Interface Switching Capability:%s",
1819 ident,
1820 tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
1821 ND_PRINT((ndo, ", LSP Encoding: %s",
1822 tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
1823 tptr+=4;
1824 ND_PRINT((ndo, "%s Max LSP Bandwidth:", ident));
1825 for (priority_level = 0; priority_level < 8; priority_level++) {
1826 bw.i = EXTRACT_32BITS(tptr);
1827 ND_PRINT((ndo, "%s priority level %d: %.3f Mbps",
1828 ident,
1829 priority_level,
1830 bw.f * 8 / 1000000));
1831 tptr+=4;
1832 }
1833 subl-=36;
1834 switch (gmpls_switch_cap) {
1835 case GMPLS_PSC1:
1836 case GMPLS_PSC2:
1837 case GMPLS_PSC3:
1838 case GMPLS_PSC4:
1839 ND_TCHECK2(*tptr, 6);
1840 bw.i = EXTRACT_32BITS(tptr);
1841 ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
1842 ND_PRINT((ndo, "%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr + 4)));
1843 break;
1844 case GMPLS_TSC:
1845 ND_TCHECK2(*tptr, 8);
1846 bw.i = EXTRACT_32BITS(tptr);
1847 ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
1848 ND_PRINT((ndo, "%s Indication %s", ident,
1849 tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr + 4))));
1850 break;
1851 default:
1852 /* there is some optional stuff left to decode but this is as of yet
1853 not specified so just lets hexdump what is left */
1854 if(subl>0){
1855 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
1856 return(0);
1857 }
1858 }
1859 }
1860 break;
1861 default:
1862 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
1863 return(0);
1864 break;
1865 }
1866 return(1);
1867
1868 trunc:
1869 return(0);
1870 }
1871
1872 /*
1873 * this is the common IS-REACH decoder it is called
1874 * from various EXTD-IS REACH style TLVs (22,24,222)
1875 */
1876
1877 static int
1878 isis_print_ext_is_reach(netdissect_options *ndo,
1879 const uint8_t *tptr, const char *ident, int tlv_type)
1880 {
1881 char ident_buffer[20];
1882 int subtlv_type,subtlv_len,subtlv_sum_len;
1883 int proc_bytes = 0; /* how many bytes did we process ? */
1884
1885 if (!ND_TTEST2(*tptr, NODE_ID_LEN))
1886 return(0);
1887
1888 ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)));
1889 tptr+=(NODE_ID_LEN);
1890
1891 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
1892 if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */
1893 return(0);
1894 ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr)));
1895 tptr+=3;
1896 }
1897
1898 if (!ND_TTEST2(*tptr, 1))
1899 return(0);
1900 subtlv_sum_len=*(tptr++); /* read out subTLV length */
1901 proc_bytes=NODE_ID_LEN+3+1;
1902 ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
1903 if (subtlv_sum_len) {
1904 ND_PRINT((ndo, " (%u)", subtlv_sum_len));
1905 while (subtlv_sum_len>0) {
1906 if (!ND_TTEST2(*tptr,2))
1907 return(0);
1908 subtlv_type=*(tptr++);
1909 subtlv_len=*(tptr++);
1910 /* prepend the indent string */
1911 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
1912 if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
1913 return(0);
1914 tptr+=subtlv_len;
1915 subtlv_sum_len-=(subtlv_len+2);
1916 proc_bytes+=(subtlv_len+2);
1917 }
1918 }
1919 return(proc_bytes);
1920 }
1921
1922 /*
1923 * this is the common Multi Topology ID decoder
1924 * it is called from various MT-TLVs (222,229,235,237)
1925 */
1926
1927 static int
1928 isis_print_mtid(netdissect_options *ndo,
1929 const uint8_t *tptr, const char *ident)
1930 {
1931 if (!ND_TTEST2(*tptr, 2))
1932 return(0);
1933
1934 ND_PRINT((ndo, "%s%s",
1935 ident,
1936 tok2str(isis_mt_values,
1937 "Reserved for IETF Consensus",
1938 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))));
1939
1940 ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]",
1941 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
1942 bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))));
1943
1944 return(2);
1945 }
1946
1947 /*
1948 * this is the common extended IP reach decoder
1949 * it is called from TLVs (135,235,236,237)
1950 * we process the TLV and optional subTLVs and return
1951 * the amount of processed bytes
1952 */
1953
1954 static int
1955 isis_print_extd_ip_reach(netdissect_options *ndo,
1956 const uint8_t *tptr, const char *ident, uint16_t afi)
1957 {
1958 char ident_buffer[20];
1959 uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1960 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
1961
1962 if (!ND_TTEST2(*tptr, 4))
1963 return (0);
1964 metric = EXTRACT_32BITS(tptr);
1965 processed=4;
1966 tptr+=4;
1967
1968 if (afi == AF_INET) {
1969 if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
1970 return (0);
1971 status_byte=*(tptr++);
1972 bit_length = status_byte&0x3f;
1973 if (bit_length > 32) {
1974 ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
1975 ident,
1976 bit_length));
1977 return (0);
1978 }
1979 processed++;
1980 } else if (afi == AF_INET6) {
1981 if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
1982 return (0);
1983 status_byte=*(tptr++);
1984 bit_length=*(tptr++);
1985 if (bit_length > 128) {
1986 ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
1987 ident,
1988 bit_length));
1989 return (0);
1990 }
1991 processed+=2;
1992 } else
1993 return (0); /* somebody is fooling us */
1994
1995 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
1996
1997 if (!ND_TTEST2(*tptr, byte_length))
1998 return (0);
1999 memset(prefix, 0, sizeof prefix); /* clear the copy buffer */
2000 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
2001 tptr+=byte_length;
2002 processed+=byte_length;
2003
2004 if (afi == AF_INET)
2005 ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
2006 ident,
2007 ipaddr_string(ndo, prefix),
2008 bit_length));
2009 else if (afi == AF_INET6)
2010 ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
2011 ident,
2012 ip6addr_string(ndo, prefix),
2013 bit_length));
2014
2015 ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
2016 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
2017 metric));
2018
2019 if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
2020 ND_PRINT((ndo, ", sub-TLVs present"));
2021 else if (afi == AF_INET6)
2022 ND_PRINT((ndo, ", %s%s",
2023 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
2024 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
2025
2026 if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
2027 || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
2028 ) {
2029 /* assume that one prefix can hold more
2030 than one subTLV - therefore the first byte must reflect
2031 the aggregate bytecount of the subTLVs for this prefix
2032 */
2033 if (!ND_TTEST2(*tptr, 1))
2034 return (0);
2035 sublen=*(tptr++);
2036 processed+=sublen+1;
2037 ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
2038
2039 while (sublen>0) {
2040 if (!ND_TTEST2(*tptr,2))
2041 return (0);
2042 subtlvtype=*(tptr++);
2043 subtlvlen=*(tptr++);
2044 /* prepend the indent string */
2045 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
2046 if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
2047 return(0);
2048 tptr+=subtlvlen;
2049 sublen-=(subtlvlen+2);
2050 }
2051 }
2052 return (processed);
2053 }
2054
2055 /*
2056 * Clear checksum and lifetime prior to signature verification.
2057 */
2058 static void
2059 isis_clear_checksum_lifetime(void *header)
2060 {
2061 struct isis_lsp_header *header_lsp = (struct isis_lsp_header *) header;
2062
2063 header_lsp->checksum[0] = 0;
2064 header_lsp->checksum[1] = 0;
2065 header_lsp->remaining_lifetime[0] = 0;
2066 header_lsp->remaining_lifetime[1] = 0;
2067 }
2068
2069 /*
2070 * isis_print
2071 * Decode IS-IS packets. Return 0 on error.
2072 */
2073
2074 static int
2075 isis_print(netdissect_options *ndo,
2076 const uint8_t *p, u_int length)
2077 {
2078 const struct isis_common_header *isis_header;
2079
2080 const struct isis_iih_lan_header *header_iih_lan;
2081 const struct isis_iih_ptp_header *header_iih_ptp;
2082 const struct isis_lsp_header *header_lsp;
2083 const struct isis_csnp_header *header_csnp;
2084 const struct isis_psnp_header *header_psnp;
2085
2086 const struct isis_tlv_lsp *tlv_lsp;
2087 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
2088 const struct isis_tlv_is_reach *tlv_is_reach;
2089 const struct isis_tlv_es_reach *tlv_es_reach;
2090
2091 uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
2092 uint8_t ext_is_len, ext_ip_len, mt_len;
2093 const uint8_t *optr, *pptr, *tptr;
2094 u_short packet_len,pdu_len, key_id;
2095 u_int i,vendor_id;
2096 int sigcheck;
2097
2098 packet_len=length;
2099 optr = p; /* initialize the _o_riginal pointer to the packet start -
2100 need it for parsing the checksum TLV and authentication
2101 TLV verification */
2102 isis_header = (const struct isis_common_header *)p;
2103 ND_TCHECK(*isis_header);
2104 pptr = p+(ISIS_COMMON_HEADER_SIZE);
2105 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
2106 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
2107 header_lsp = (const struct isis_lsp_header *)pptr;
2108 header_csnp = (const struct isis_csnp_header *)pptr;
2109 header_psnp = (const struct isis_psnp_header *)pptr;
2110
2111 if (!ndo->ndo_eflag)
2112 ND_PRINT((ndo, "IS-IS"));
2113
2114 /*
2115 * Sanity checking of the header.
2116 */
2117
2118 if (isis_header->version != ISIS_VERSION) {
2119 ND_PRINT((ndo, "version %d packet not supported", isis_header->version));
2120 return (0);
2121 }
2122
2123 if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
2124 ND_PRINT((ndo, "system ID length of %d is not supported",
2125 isis_header->id_length));
2126 return (0);
2127 }
2128
2129 if (isis_header->pdu_version != ISIS_VERSION) {
2130 ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version));
2131 return (0);
2132 }
2133
2134 max_area = isis_header->max_area;
2135 switch(max_area) {
2136 case 0:
2137 max_area = 3; /* silly shit */
2138 break;
2139 case 255:
2140 ND_PRINT((ndo, "bad packet -- 255 areas"));
2141 return (0);
2142 default:
2143 break;
2144 }
2145
2146 id_length = isis_header->id_length;
2147 switch(id_length) {
2148 case 0:
2149 id_length = 6; /* silly shit again */
2150 break;
2151 case 1: /* 1-8 are valid sys-ID lenghts */
2152 case 2:
2153 case 3:
2154 case 4:
2155 case 5:
2156 case 6:
2157 case 7:
2158 case 8:
2159 break;
2160 case 255:
2161 id_length = 0; /* entirely useless */
2162 break;
2163 default:
2164 break;
2165 }
2166
2167 /* toss any non 6-byte sys-ID len PDUs */
2168 if (id_length != 6 ) {
2169 ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length));
2170 return (0);
2171 }
2172
2173 pdu_type=isis_header->pdu_type;
2174
2175 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
2176 if (ndo->ndo_vflag < 1) {
2177 ND_PRINT((ndo, "%s%s",
2178 ndo->ndo_eflag ? "" : ", ",
2179 tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type)));
2180
2181 switch (pdu_type) {
2182
2183 case ISIS_PDU_L1_LAN_IIH:
2184 case ISIS_PDU_L2_LAN_IIH:
2185 ND_TCHECK(*header_iih_lan);
2186 ND_PRINT((ndo, ", src-id %s",
2187 isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN)));
2188 ND_PRINT((ndo, ", lan-id %s, prio %u",
2189 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
2190 header_iih_lan->priority));
2191 break;
2192 case ISIS_PDU_PTP_IIH:
2193 ND_TCHECK(*header_iih_ptp);
2194 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN)));
2195 break;
2196 case ISIS_PDU_L1_LSP:
2197 case ISIS_PDU_L2_LSP:
2198 ND_TCHECK(*header_lsp);
2199 ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us",
2200 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
2201 EXTRACT_32BITS(header_lsp->sequence_number),
2202 EXTRACT_16BITS(header_lsp->remaining_lifetime)));
2203 break;
2204 case ISIS_PDU_L1_CSNP:
2205 case ISIS_PDU_L2_CSNP:
2206 ND_TCHECK(*header_csnp);
2207 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN)));
2208 break;
2209 case ISIS_PDU_L1_PSNP:
2210 case ISIS_PDU_L2_PSNP:
2211 ND_TCHECK(*header_psnp);
2212 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
2213 break;
2214
2215 }
2216 ND_PRINT((ndo, ", length %u", length));
2217
2218 return(1);
2219 }
2220
2221 /* ok they seem to want to know everything - lets fully decode it */
2222 ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
2223
2224 ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
2225 tok2str(isis_pdu_values,
2226 "unknown, type %u",
2227 pdu_type),
2228 isis_header->fixed_len,
2229 isis_header->version,
2230 isis_header->pdu_version,
2231 id_length,
2232 isis_header->id_length,
2233 max_area,
2234 isis_header->max_area));
2235
2236 if (ndo->ndo_vflag > 1) {
2237 if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
2238 return(0); /* for optionally debugging the common header */
2239 }
2240
2241 switch (pdu_type) {
2242
2243 case ISIS_PDU_L1_LAN_IIH:
2244 case ISIS_PDU_L2_LAN_IIH:
2245 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
2246 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2247 isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE));
2248 return (0);
2249 }
2250
2251 ND_TCHECK(*header_iih_lan);
2252 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
2253 if (packet_len>pdu_len) {
2254 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2255 length=pdu_len;
2256 }
2257
2258 ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
2259 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
2260 EXTRACT_16BITS(header_iih_lan->holding_time),
2261 tok2str(isis_iih_circuit_type_values,
2262 "unknown circuit type 0x%02x",
2263 header_iih_lan->circuit_type)));
2264
2265 ND_PRINT((ndo, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
2266 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
2267 (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
2268 pdu_len));
2269
2270 if (ndo->ndo_vflag > 1) {
2271 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE))
2272 return(0);
2273 }
2274
2275 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2276 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2277 break;
2278
2279 case ISIS_PDU_PTP_IIH:
2280 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
2281 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2282 isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE));
2283 return (0);
2284 }
2285
2286 ND_TCHECK(*header_iih_ptp);
2287 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
2288 if (packet_len>pdu_len) {
2289 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2290 length=pdu_len;
2291 }
2292
2293 ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
2294 isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
2295 EXTRACT_16BITS(header_iih_ptp->holding_time),
2296 tok2str(isis_iih_circuit_type_values,
2297 "unknown circuit type 0x%02x",
2298 header_iih_ptp->circuit_type)));
2299
2300 ND_PRINT((ndo, "\n\t circuit-id: 0x%02x, PDU length: %u",
2301 header_iih_ptp->circuit_id,
2302 pdu_len));
2303
2304 if (ndo->ndo_vflag > 1) {
2305 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE))
2306 return(0);
2307 }
2308
2309 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2310 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2311 break;
2312
2313 case ISIS_PDU_L1_LSP:
2314 case ISIS_PDU_L2_LSP:
2315 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
2316 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2317 isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE));
2318 return (0);
2319 }
2320
2321 ND_TCHECK(*header_lsp);
2322 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
2323 if (packet_len>pdu_len) {
2324 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2325 length=pdu_len;
2326 }
2327
2328 ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
2329 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
2330 EXTRACT_32BITS(header_lsp->sequence_number),
2331 EXTRACT_16BITS(header_lsp->remaining_lifetime),
2332 EXTRACT_16BITS(header_lsp->checksum)));
2333
2334 if (osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id,
2335 EXTRACT_16BITS(header_lsp->checksum),
2336 12, length-12) == 0)
2337 goto trunc;
2338
2339 ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
2340 pdu_len,
2341 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""));
2342
2343 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
2344 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""));
2345 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""));
2346 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""));
2347 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""));
2348 ND_PRINT((ndo, "ATT bit set, "));
2349 }
2350 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""));
2351 ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
2352 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))));
2353
2354 if (ndo->ndo_vflag > 1) {
2355 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE))
2356 return(0);
2357 }
2358
2359 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
2360 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
2361 break;
2362
2363 case ISIS_PDU_L1_CSNP:
2364 case ISIS_PDU_L2_CSNP:
2365 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
2366 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2367 isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE));
2368 return (0);
2369 }
2370
2371 ND_TCHECK(*header_csnp);
2372 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
2373 if (packet_len>pdu_len) {
2374 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2375 length=pdu_len;
2376 }
2377
2378 ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
2379 isis_print_id(header_csnp->source_id, NODE_ID_LEN),
2380 pdu_len));
2381 ND_PRINT((ndo, "\n\t start lsp-id: %s",
2382 isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)));
2383 ND_PRINT((ndo, "\n\t end lsp-id: %s",
2384 isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)));
2385
2386 if (ndo->ndo_vflag > 1) {
2387 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
2388 return(0);
2389 }
2390
2391 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2392 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2393 break;
2394
2395 case ISIS_PDU_L1_PSNP:
2396 case ISIS_PDU_L2_PSNP:
2397 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
2398 ND_PRINT((ndo, "- bogus fixed header length %u should be %lu",
2399 isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE));
2400 return (0);
2401 }
2402
2403 ND_TCHECK(*header_psnp);
2404 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
2405 if (packet_len>pdu_len) {
2406 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2407 length=pdu_len;
2408 }
2409
2410 ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
2411 isis_print_id(header_psnp->source_id, NODE_ID_LEN),
2412 pdu_len));
2413
2414 if (ndo->ndo_vflag > 1) {
2415 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE))
2416 return(0);
2417 }
2418
2419 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2420 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2421 break;
2422
2423 default:
2424 (void)print_unknown_data(ndo, pptr, "\n\t ", length);
2425 return (0);
2426 }
2427
2428 /*
2429 * Now print the TLV's.
2430 */
2431
2432 while (packet_len >= 2) {
2433 if (pptr == ndo->ndo_snapend) {
2434 return (1);
2435 }
2436
2437 ND_TCHECK2(*pptr, 2);
2438 tlv_type = *pptr++;
2439 tlv_len = *pptr++;
2440 tmp =tlv_len; /* copy temporary len & pointer to packet data */
2441 tptr = pptr;
2442 packet_len -= 2;
2443 if (tlv_len > packet_len) {
2444 break;
2445 }
2446
2447 /* first lets see if we know the TLVs name*/
2448 ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u",
2449 tok2str(isis_tlv_values,
2450 "unknown",
2451 tlv_type),
2452 tlv_type,
2453 tlv_len));
2454
2455 if (tlv_len == 0) /* something is invalid */
2456 continue;
2457
2458 /* now check if we have a decoder otherwise do a hexdump at the end*/
2459 switch (tlv_type) {
2460 case ISIS_TLV_AREA_ADDR:
2461 if (!ND_TTEST2(*tptr, 1))
2462 goto trunctlv;
2463 alen = *tptr++;
2464 while (tmp && alen < tmp) {
2465 ND_PRINT((ndo, "\n\t Area address (length: %u): %s",
2466 alen,
2467 isonsap_string(ndo, tptr, alen)));
2468 tptr += alen;
2469 tmp -= alen + 1;
2470 if (tmp==0) /* if this is the last area address do not attemt a boundary check */
2471 break;
2472 if (!ND_TTEST2(*tptr, 1))
2473 goto trunctlv;
2474 alen = *tptr++;
2475 }
2476 break;
2477 case ISIS_TLV_ISNEIGH:
2478 while (tmp >= ETHER_ADDR_LEN) {
2479 if (!ND_TTEST2(*tptr, ETHER_ADDR_LEN))
2480 goto trunctlv;
2481 ND_PRINT((ndo, "\n\t SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
2482 tmp -= ETHER_ADDR_LEN;
2483 tptr += ETHER_ADDR_LEN;
2484 }
2485 break;
2486
2487 case ISIS_TLV_ISNEIGH_VARLEN:
2488 if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
2489 goto trunctlv;
2490 lan_alen = *tptr++; /* LAN address length */
2491 if (lan_alen == 0) {
2492 ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)"));
2493 break;
2494 }
2495 tmp --;
2496 ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen));
2497 while (tmp >= lan_alen) {
2498 if (!ND_TTEST2(*tptr, lan_alen))
2499 goto trunctlv;
2500 ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen)));
2501 tmp -= lan_alen;
2502 tptr +=lan_alen;
2503 }
2504 break;
2505
2506 case ISIS_TLV_PADDING:
2507 break;
2508
2509 case ISIS_TLV_MT_IS_REACH:
2510 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
2511 if (mt_len == 0) /* did something go wrong ? */
2512 goto trunctlv;
2513 tptr+=mt_len;
2514 tmp-=mt_len;
2515 while (tmp >= 2+NODE_ID_LEN+3+1) {
2516 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
2517 if (ext_is_len == 0) /* did something go wrong ? */
2518 goto trunctlv;
2519
2520 tmp-=ext_is_len;
2521 tptr+=ext_is_len;
2522 }
2523 break;
2524
2525 case ISIS_TLV_IS_ALIAS_ID:
2526 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
2527 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
2528 if (ext_is_len == 0) /* did something go wrong ? */
2529 goto trunctlv;
2530 tmp-=ext_is_len;
2531 tptr+=ext_is_len;
2532 }
2533 break;
2534
2535 case ISIS_TLV_EXT_IS_REACH:
2536 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
2537 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
2538 if (ext_is_len == 0) /* did something go wrong ? */
2539 goto trunctlv;
2540 tmp-=ext_is_len;
2541 tptr+=ext_is_len;
2542 }
2543 break;
2544 case ISIS_TLV_IS_REACH:
2545 if (!ND_TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
2546 goto trunctlv;
2547 ND_PRINT((ndo, "\n\t %s",
2548 tok2str(isis_is_reach_virtual_values,
2549 "bogus virtual flag 0x%02x",
2550 *tptr++)));
2551 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
2552 while (tmp >= sizeof(struct isis_tlv_is_reach)) {
2553 if (!ND_TTEST(*tlv_is_reach))
2554 goto trunctlv;
2555 ND_PRINT((ndo, "\n\t IS Neighbor: %s",
2556 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)));
2557 isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
2558 tmp -= sizeof(struct isis_tlv_is_reach);
2559 tlv_is_reach++;
2560 }
2561 break;
2562
2563 case ISIS_TLV_ESNEIGH:
2564 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
2565 while (tmp >= sizeof(struct isis_tlv_es_reach)) {
2566 if (!ND_TTEST(*tlv_es_reach))
2567 goto trunctlv;
2568 ND_PRINT((ndo, "\n\t ES Neighbor: %s",
2569 isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN)));
2570 isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
2571 tmp -= sizeof(struct isis_tlv_es_reach);
2572 tlv_es_reach++;
2573 }
2574 break;
2575
2576 /* those two TLVs share the same format */
2577 case ISIS_TLV_INT_IP_REACH:
2578 case ISIS_TLV_EXT_IP_REACH:
2579 if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len))
2580 return (1);
2581 break;
2582
2583 case ISIS_TLV_EXTD_IP_REACH:
2584 while (tmp>0) {
2585 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
2586 if (ext_ip_len == 0) /* did something go wrong ? */
2587 goto trunctlv;
2588 tptr+=ext_ip_len;
2589 tmp-=ext_ip_len;
2590 }
2591 break;
2592
2593 case ISIS_TLV_MT_IP_REACH:
2594 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
2595 if (mt_len == 0) { /* did something go wrong ? */
2596 goto trunctlv;
2597 }
2598 tptr+=mt_len;
2599 tmp-=mt_len;
2600
2601 while (tmp>0) {
2602 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
2603 if (ext_ip_len == 0) /* did something go wrong ? */
2604 goto trunctlv;
2605 tptr+=ext_ip_len;
2606 tmp-=ext_ip_len;
2607 }
2608 break;
2609
2610 case ISIS_TLV_IP6_REACH:
2611 while (tmp>0) {
2612 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
2613 if (ext_ip_len == 0) /* did something go wrong ? */
2614 goto trunctlv;
2615 tptr+=ext_ip_len;
2616 tmp-=ext_ip_len;
2617 }
2618 break;
2619
2620 case ISIS_TLV_MT_IP6_REACH:
2621 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
2622 if (mt_len == 0) { /* did something go wrong ? */
2623 goto trunctlv;
2624 }
2625 tptr+=mt_len;
2626 tmp-=mt_len;
2627
2628 while (tmp>0) {
2629 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
2630 if (ext_ip_len == 0) /* did something go wrong ? */
2631 goto trunctlv;
2632 tptr+=ext_ip_len;
2633 tmp-=ext_ip_len;
2634 }
2635 break;
2636
2637 case ISIS_TLV_IP6ADDR:
2638 while (tmp>=sizeof(struct in6_addr)) {
2639 if (!ND_TTEST2(*tptr, sizeof(struct in6_addr)))
2640 goto trunctlv;
2641
2642 ND_PRINT((ndo, "\n\t IPv6 interface address: %s",
2643 ip6addr_string(ndo, tptr)));
2644
2645 tptr += sizeof(struct in6_addr);
2646 tmp -= sizeof(struct in6_addr);
2647 }
2648 break;
2649 case ISIS_TLV_AUTH:
2650 if (!ND_TTEST2(*tptr, 1))
2651 goto trunctlv;
2652
2653 ND_PRINT((ndo, "\n\t %s: ",
2654 tok2str(isis_subtlv_auth_values,
2655 "unknown Authentication type 0x%02x",
2656 *tptr)));
2657
2658 switch (*tptr) {
2659 case ISIS_SUBTLV_AUTH_SIMPLE:
2660 if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
2661 goto trunctlv;
2662 break;
2663 case ISIS_SUBTLV_AUTH_MD5:
2664 for(i=1;i<tlv_len;i++) {
2665 if (!ND_TTEST2(*(tptr + i), 1))
2666 goto trunctlv;
2667 ND_PRINT((ndo, "%02x", *(tptr + i)));
2668 }
2669 if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
2670 ND_PRINT((ndo, ", (invalid subTLV) "));
2671
2672 sigcheck = signature_verify(ndo, optr, length, tptr + 1,
2673 isis_clear_checksum_lifetime,
2674 header_lsp);
2675 ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
2676
2677 break;
2678 case ISIS_SUBTLV_AUTH_GENERIC:
2679 ND_TCHECK2(*(tptr + 1), 2);
2680 key_id = EXTRACT_16BITS((tptr+1));
2681 ND_PRINT((ndo, "%u, password: ", key_id));
2682 for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
2683 if (!ND_TTEST2(*(tptr + i), 1))
2684 goto trunctlv;
2685 ND_PRINT((ndo, "%02x", *(tptr + i)));
2686 }
2687 break;
2688 case ISIS_SUBTLV_AUTH_PRIVATE:
2689 default:
2690 if (!print_unknown_data(ndo, tptr + 1, "\n\t\t ", tlv_len - 1))
2691 return(0);
2692 break;
2693 }
2694 break;
2695
2696 case ISIS_TLV_PTP_ADJ:
2697 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
2698 if(tmp>=1) {
2699 if (!ND_TTEST2(*tptr, 1))
2700 goto trunctlv;
2701 ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
2702 tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
2703 *tptr));
2704 tmp--;
2705 }
2706 if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
2707 if (!ND_TTEST2(tlv_ptp_adj->extd_local_circuit_id,
2708 sizeof(tlv_ptp_adj->extd_local_circuit_id)))
2709 goto trunctlv;
2710 ND_PRINT((ndo, "\n\t Extended Local circuit-ID: 0x%08x",
2711 EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)));
2712 tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
2713 }
2714 if(tmp>=SYSTEM_ID_LEN) {
2715 if (!ND_TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
2716 goto trunctlv;
2717 ND_PRINT((ndo, "\n\t Neighbor System-ID: %s",
2718 isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)));
2719 tmp-=SYSTEM_ID_LEN;
2720 }
2721 if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
2722 if (!ND_TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
2723 sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
2724 goto trunctlv;
2725 ND_PRINT((ndo, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2726 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)));
2727 }
2728 break;
2729
2730 case ISIS_TLV_PROTOCOLS:
2731 ND_PRINT((ndo, "\n\t NLPID(s): "));
2732 while (tmp>0) {
2733 if (!ND_TTEST2(*(tptr), 1))
2734 goto trunctlv;
2735 ND_PRINT((ndo, "%s (0x%02x)",
2736 tok2str(nlpid_values,
2737 "unknown",
2738 *tptr),
2739 *tptr));
2740 if (tmp>1) /* further NPLIDs ? - put comma */
2741 ND_PRINT((ndo, ", "));
2742 tptr++;
2743 tmp--;
2744 }
2745 break;
2746
2747 case ISIS_TLV_MT_PORT_CAP:
2748 {
2749 if (!ND_TTEST2(*(tptr), 2))
2750 goto trunctlv;
2751
2752 ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
2753 (EXTRACT_16BITS (tptr) >> 12),
2754 (EXTRACT_16BITS (tptr) & 0x0fff)));
2755
2756 tmp = tmp-2;
2757 tptr = tptr+2;
2758
2759 if (tmp)
2760 isis_print_mt_port_cap_subtlv(ndo, tptr, tmp);
2761
2762 break;
2763 }
2764
2765 case ISIS_TLV_MT_CAPABILITY:
2766
2767 if (!ND_TTEST2(*(tptr), 2))
2768 goto trunctlv;
2769
2770 ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
2771 (EXTRACT_16BITS(tptr) >> 15) & 0x01,
2772 (EXTRACT_16BITS(tptr) >> 12) & 0x07,
2773 EXTRACT_16BITS(tptr) & 0x0fff));
2774
2775 tmp = tmp-2;
2776 tptr = tptr+2;
2777
2778 if (tmp)
2779 isis_print_mt_capability_subtlv(ndo, tptr, tmp);
2780
2781 break;
2782
2783 case ISIS_TLV_TE_ROUTER_ID:
2784 if (!ND_TTEST2(*pptr, sizeof(struct in_addr)))
2785 goto trunctlv;
2786 ND_PRINT((ndo, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr)));
2787 break;
2788
2789 case ISIS_TLV_IPADDR:
2790 while (tmp>=sizeof(struct in_addr)) {
2791 if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
2792 goto trunctlv;
2793 ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
2794 tptr += sizeof(struct in_addr);
2795 tmp -= sizeof(struct in_addr);
2796 }
2797 break;
2798
2799 case ISIS_TLV_HOSTNAME:
2800 ND_PRINT((ndo, "\n\t Hostname: "));
2801 if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
2802 goto trunctlv;
2803 break;
2804
2805 case ISIS_TLV_SHARED_RISK_GROUP:
2806 if (tmp < NODE_ID_LEN)
2807 break;
2808 if (!ND_TTEST2(*tptr, NODE_ID_LEN))
2809 goto trunctlv;
2810 ND_PRINT((ndo, "\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)));
2811 tptr+=(NODE_ID_LEN);
2812 tmp-=(NODE_ID_LEN);
2813
2814 if (tmp < 1)
2815 break;
2816 if (!ND_TTEST2(*tptr, 1))
2817 goto trunctlv;
2818 ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"));
2819 tmp--;
2820
2821 if (tmp < sizeof(struct in_addr))
2822 break;
2823 if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
2824 goto trunctlv;
2825 ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
2826 tptr+=sizeof(struct in_addr);
2827 tmp-=sizeof(struct in_addr);
2828
2829 if (tmp < sizeof(struct in_addr))
2830 break;
2831 if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
2832 goto trunctlv;
2833 ND_PRINT((ndo, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo, tptr)));
2834 tptr+=sizeof(struct in_addr);
2835 tmp-=sizeof(struct in_addr);
2836
2837 while (tmp>=4) {
2838 if (!ND_TTEST2(*tptr, 4))
2839 goto trunctlv;
2840 ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
2841 tptr+=4;
2842 tmp-=4;
2843 }
2844 break;
2845
2846 case ISIS_TLV_LSP:
2847 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
2848 while(tmp>=sizeof(struct isis_tlv_lsp)) {
2849 if (!ND_TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
2850 goto trunctlv;
2851 ND_PRINT((ndo, "\n\t lsp-id: %s",
2852 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)));
2853 if (!ND_TTEST2(tlv_lsp->sequence_number, 4))
2854 goto trunctlv;
2855 ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
2856 if (!ND_TTEST2(tlv_lsp->remaining_lifetime, 2))
2857 goto trunctlv;
2858 ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
2859 if (!ND_TTEST2(tlv_lsp->checksum, 2))
2860 goto trunctlv;
2861 ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum)));
2862 tmp-=sizeof(struct isis_tlv_lsp);
2863 tlv_lsp++;
2864 }
2865 break;
2866
2867 case ISIS_TLV_CHECKSUM:
2868 if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
2869 break;
2870 if (!ND_TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
2871 goto trunctlv;
2872 ND_PRINT((ndo, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)));
2873 /* do not attempt to verify the checksum if it is zero
2874 * most likely a HMAC-MD5 TLV is also present and
2875 * to avoid conflicts the checksum TLV is zeroed.
2876 * see rfc3358 for details
2877 */
2878 if (osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr,
2879 length) == 0)
2880 goto trunc;
2881 break;
2882
2883 case ISIS_TLV_POI:
2884 if (tlv_len >= SYSTEM_ID_LEN + 1) {
2885 if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN + 1))
2886 goto trunctlv;
2887 ND_PRINT((ndo, "\n\t Purge Originator System-ID: %s",
2888 isis_print_id(tptr + 1, SYSTEM_ID_LEN)));
2889 }
2890
2891 if (tlv_len == 2 * SYSTEM_ID_LEN + 1) {
2892 if (!ND_TTEST2(*tptr, 2 * SYSTEM_ID_LEN + 1))
2893 goto trunctlv;
2894 ND_PRINT((ndo, "\n\t Received from System-ID: %s",
2895 isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN)));
2896 }
2897 break;
2898
2899 case ISIS_TLV_MT_SUPPORTED:
2900 if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN)
2901 break;
2902 while (tmp>1) {
2903 /* length can only be a multiple of 2, otherwise there is
2904 something broken -> so decode down until length is 1 */
2905 if (tmp!=1) {
2906 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
2907 if (mt_len == 0) /* did something go wrong ? */
2908 goto trunctlv;
2909 tptr+=mt_len;
2910 tmp-=mt_len;
2911 } else {
2912 ND_PRINT((ndo, "\n\t invalid MT-ID"));
2913 break;
2914 }
2915 }
2916 break;
2917
2918 case ISIS_TLV_RESTART_SIGNALING:
2919 /* first attempt to decode the flags */
2920 if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
2921 break;
2922 if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
2923 goto trunctlv;
2924 ND_PRINT((ndo, "\n\t Flags [%s]",
2925 bittok2str(isis_restart_flag_values, "none", *tptr)));
2926 tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
2927 tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
2928
2929 /* is there anything other than the flags field? */
2930 if (tmp == 0)
2931 break;
2932
2933 if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
2934 break;
2935 if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
2936 goto trunctlv;
2937
2938 ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
2939 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
2940 tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
2941
2942 /* is there an additional sysid field present ?*/
2943 if (tmp == SYSTEM_ID_LEN) {
2944 if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
2945 goto trunctlv;
2946 ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
2947 }
2948 break;
2949
2950 case ISIS_TLV_IDRP_INFO:
2951 if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
2952 break;
2953 if (!ND_TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
2954 goto trunctlv;
2955 ND_PRINT((ndo, "\n\t Inter-Domain Information Type: %s",
2956 tok2str(isis_subtlv_idrp_values,
2957 "Unknown (0x%02x)",
2958 *tptr)));
2959 switch (*tptr++) {
2960 case ISIS_SUBTLV_IDRP_ASN:
2961 if (!ND_TTEST2(*tptr, 2)) /* fetch AS number */
2962 goto trunctlv;
2963 ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
2964 break;
2965 case ISIS_SUBTLV_IDRP_LOCAL:
2966 case ISIS_SUBTLV_IDRP_RES:
2967 default:
2968 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_len - 1))
2969 return(0);
2970 break;
2971 }
2972 break;
2973
2974 case ISIS_TLV_LSP_BUFFERSIZE:
2975 if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
2976 break;
2977 if (!ND_TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
2978 goto trunctlv;
2979 ND_PRINT((ndo, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr)));
2980 break;
2981
2982 case ISIS_TLV_PART_DIS:
2983 while (tmp >= SYSTEM_ID_LEN) {
2984 if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
2985 goto trunctlv;
2986 ND_PRINT((ndo, "\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN)));
2987 tptr+=SYSTEM_ID_LEN;
2988 tmp-=SYSTEM_ID_LEN;
2989 }
2990 break;
2991
2992 case ISIS_TLV_PREFIX_NEIGH:
2993 if (tmp < sizeof(struct isis_metric_block))
2994 break;
2995 if (!ND_TTEST2(*tptr, sizeof(struct isis_metric_block)))
2996 goto trunctlv;
2997 ND_PRINT((ndo, "\n\t Metric Block"));
2998 isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
2999 tptr+=sizeof(struct isis_metric_block);
3000 tmp-=sizeof(struct isis_metric_block);
3001
3002 while(tmp>0) {
3003 if (!ND_TTEST2(*tptr, 1))
3004 goto trunctlv;
3005 prefix_len=*tptr++; /* read out prefix length in semioctets*/
3006 if (prefix_len < 2) {
3007 ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
3008 break;
3009 }
3010 tmp--;
3011 if (tmp < prefix_len/2)
3012 break;
3013 if (!ND_TTEST2(*tptr, prefix_len / 2))
3014 goto trunctlv;
3015 ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
3016 isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4));
3017 tptr+=prefix_len/2;
3018 tmp-=prefix_len/2;
3019 }
3020 break;
3021
3022 case ISIS_TLV_IIH_SEQNR:
3023 if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
3024 break;
3025 if (!ND_TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
3026 goto trunctlv;
3027 ND_PRINT((ndo, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr)));
3028 break;
3029
3030 case ISIS_TLV_VENDOR_PRIVATE:
3031 if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
3032 break;
3033 if (!ND_TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
3034 goto trunctlv;
3035 vendor_id = EXTRACT_24BITS(tptr);
3036 ND_PRINT((ndo, "\n\t Vendor: %s (%u)",
3037 tok2str(oui_values, "Unknown", vendor_id),
3038 vendor_id));
3039 tptr+=3;
3040 tmp-=3;
3041 if (tmp > 0) /* hexdump the rest */
3042 if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp))
3043 return(0);
3044 break;
3045 /*
3046 * FIXME those are the defined TLVs that lack a decoder
3047 * you are welcome to contribute code ;-)
3048 */
3049
3050 case ISIS_TLV_DECNET_PHASE4:
3051 case ISIS_TLV_LUCENT_PRIVATE:
3052 case ISIS_TLV_IPAUTH:
3053 case ISIS_TLV_NORTEL_PRIVATE1:
3054 case ISIS_TLV_NORTEL_PRIVATE2:
3055
3056 default:
3057 if (ndo->ndo_vflag <= 1) {
3058 if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
3059 return(0);
3060 }
3061 break;
3062 }
3063 /* do we want to see an additionally hexdump ? */
3064 if (ndo->ndo_vflag> 1) {
3065 if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len))
3066 return(0);
3067 }
3068
3069 pptr += tlv_len;
3070 packet_len -= tlv_len;
3071 }
3072
3073 if (packet_len != 0) {
3074 ND_PRINT((ndo, "\n\t %u straggler bytes", packet_len));
3075 }
3076 return (1);
3077
3078 trunc:
3079 ND_PRINT((ndo, "%s", tstr));
3080 return (1);
3081
3082 trunctlv:
3083 ND_PRINT((ndo, "\n\t\t"));
3084 ND_PRINT((ndo, "%s", tstr));
3085 return(1);
3086 }
3087
3088 static int
3089 osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
3090 uint16_t checksum, int checksum_offset, int length)
3091 {
3092 uint16_t calculated_checksum;
3093
3094 /* do not attempt to verify the checksum if it is zero,
3095 * if the total length is nonsense,
3096 * if the offset is nonsense,
3097 * or the base pointer is not sane
3098 */
3099 if (!checksum
3100 || length < 0
3101 || checksum_offset < 0
3102 || length > ndo->ndo_snaplen
3103 || checksum_offset > ndo->ndo_snaplen
3104 || checksum_offset > length) {
3105 ND_PRINT((ndo, " (unverified)"));
3106 return 1;
3107 } else {
3108 #if 0
3109 printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen);
3110 #endif
3111 ND_TCHECK2(*pptr, length);
3112 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
3113 if (checksum == calculated_checksum) {
3114 ND_PRINT((ndo, " (correct)"));
3115 } else {
3116 ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
3117 }
3118 return 1;
3119 }
3120 trunc:
3121 return 0;
3122 }
3123
3124 /*
3125 * Local Variables:
3126 * c-style: whitesmith
3127 * c-basic-offset: 8
3128 * End:
3129 */