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