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