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