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