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