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