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