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