blob: d08085faf2e2e56c6d05e29d935d0a354902ec24 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
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
Elliott Hughese2e3bd12017-05-15 10:59:29 -070027/* \summary: ISO CLNS, ESIS, and ISIS printer */
28
The Android Open Source Project2949f582009-03-03 19:30:46 -080029#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
Elliott Hughese2e3bd12017-05-15 10:59:29 -070033#include <netdissect-stdinc.h>
The Android Open Source Project2949f582009-03-03 19:30:46 -080034
The Android Open Source Project2949f582009-03-03 19:30:46 -080035#include <string.h>
36
Elliott Hughese2e3bd12017-05-15 10:59:29 -070037#include "netdissect.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080038#include "addrtoname.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080039#include "ether.h"
40#include "nlpid.h"
41#include "extract.h"
42#include "gmpls.h"
43#include "oui.h"
JP Abgrall53f17a92014-02-12 14:02:41 -080044#include "signature.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080045
Elliott Hughese2e3bd12017-05-15 10:59:29 -070046static const char tstr[] = " [|isis]";
47
The Android Open Source Project2949f582009-03-03 19:30:46 -080048/*
49 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
50 */
51
52#define SYSTEM_ID_LEN ETHER_ADDR_LEN
53#define NODE_ID_LEN SYSTEM_ID_LEN+1
54#define LSP_ID_LEN SYSTEM_ID_LEN+2
55
56#define ISIS_VERSION 1
57#define ESIS_VERSION 1
58#define CLNP_VERSION 1
59
60#define ISIS_PDU_TYPE_MASK 0x1F
61#define ESIS_PDU_TYPE_MASK 0x1F
62#define CLNP_PDU_TYPE_MASK 0x1F
63#define CLNP_FLAG_MASK 0xE0
64#define ISIS_LAN_PRIORITY_MASK 0x7F
65
66#define ISIS_PDU_L1_LAN_IIH 15
67#define ISIS_PDU_L2_LAN_IIH 16
68#define ISIS_PDU_PTP_IIH 17
69#define ISIS_PDU_L1_LSP 18
70#define ISIS_PDU_L2_LSP 20
71#define ISIS_PDU_L1_CSNP 24
72#define ISIS_PDU_L2_CSNP 25
73#define ISIS_PDU_L1_PSNP 26
74#define ISIS_PDU_L2_PSNP 27
75
JP Abgrall53f17a92014-02-12 14:02:41 -080076static const struct tok isis_pdu_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -080077 { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
78 { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
79 { ISIS_PDU_PTP_IIH, "p2p IIH"},
80 { ISIS_PDU_L1_LSP, "L1 LSP"},
81 { ISIS_PDU_L2_LSP, "L2 LSP"},
82 { ISIS_PDU_L1_CSNP, "L1 CSNP"},
83 { ISIS_PDU_L2_CSNP, "L2 CSNP"},
84 { ISIS_PDU_L1_PSNP, "L1 PSNP"},
85 { ISIS_PDU_L2_PSNP, "L2 PSNP"},
86 { 0, NULL}
87};
88
89/*
90 * A TLV is a tuple of a type, length and a value and is normally used for
91 * encoding information in all sorts of places. This is an enumeration of
92 * the well known types.
93 *
94 * list taken from rfc3359 plus some memory from veterans ;-)
95 */
96
97#define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
98#define ISIS_TLV_IS_REACH 2 /* iso10589 */
99#define ISIS_TLV_ESNEIGH 3 /* iso10589 */
100#define ISIS_TLV_PART_DIS 4 /* iso10589 */
101#define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
102#define ISIS_TLV_ISNEIGH 6 /* iso10589 */
103#define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
104#define ISIS_TLV_PADDING 8 /* iso10589 */
105#define ISIS_TLV_LSP 9 /* iso10589 */
106#define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
107#define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
108#define ISIS_TLV_CHECKSUM_MINLEN 2
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700109#define ISIS_TLV_POI 13 /* rfc6232 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800110#define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
111#define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
112#define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
113#define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
114#define ISIS_TLV_DECNET_PHASE4 42
115#define ISIS_TLV_LUCENT_PRIVATE 66
116#define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
117#define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
118#define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
119#define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
120#define ISIS_TLV_IDRP_INFO_MINLEN 1
121#define ISIS_TLV_IPADDR 132 /* rfc1195 */
122#define ISIS_TLV_IPAUTH 133 /* rfc1195 */
123#define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
124#define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
125#define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
126#define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
JP Abgrall53f17a92014-02-12 14:02:41 -0800127#define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
128#define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800129#define ISIS_TLV_NORTEL_PRIVATE1 176
130#define ISIS_TLV_NORTEL_PRIVATE2 177
131#define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
132#define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
133#define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
134#define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
135#define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
136#define ISIS_TLV_MT_SUPPORTED_MINLEN 2
137#define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
138#define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
139#define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
140#define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
141#define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
142#define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
143#define ISIS_TLV_IIH_SEQNR_MINLEN 4
144#define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
145#define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
146
JP Abgrall53f17a92014-02-12 14:02:41 -0800147static const struct tok isis_tlv_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800148 { ISIS_TLV_AREA_ADDR, "Area address(es)"},
149 { ISIS_TLV_IS_REACH, "IS Reachability"},
150 { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
151 { ISIS_TLV_PART_DIS, "Partition DIS"},
152 { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
153 { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
154 { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
155 { ISIS_TLV_PADDING, "Padding"},
156 { ISIS_TLV_LSP, "LSP entries"},
157 { ISIS_TLV_AUTH, "Authentication"},
158 { ISIS_TLV_CHECKSUM, "Checksum"},
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700159 { ISIS_TLV_POI, "Purge Originator Identifier"},
The Android Open Source Project2949f582009-03-03 19:30:46 -0800160 { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
161 { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
162 { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
163 { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
164 { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
165 { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
166 { ISIS_TLV_PROTOCOLS, "Protocols supported"},
167 { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
168 { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
169 { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
170 { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
171 { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
172 { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
173 { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
JP Abgrall53f17a92014-02-12 14:02:41 -0800174 { ISIS_TLV_MT_PORT_CAP, "Multi-Topology-Aware Port Capability"},
175 { ISIS_TLV_MT_CAPABILITY, "Multi-Topology Capability"},
The Android Open Source Project2949f582009-03-03 19:30:46 -0800176 { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
177 { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
178 { ISIS_TLV_HOSTNAME, "Hostname"},
179 { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
180 { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
181 { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
182 { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
183 { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
184 { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
185 { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
186 { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
187 { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
188 { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
189 { 0, NULL }
190};
191
192#define ESIS_OPTION_PROTOCOLS 129
193#define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
194#define ESIS_OPTION_SECURITY 197 /* iso9542 */
195#define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
196#define ESIS_OPTION_PRIORITY 205 /* iso9542 */
197#define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
198#define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
199
JP Abgrall53f17a92014-02-12 14:02:41 -0800200static const struct tok esis_option_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800201 { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
202 { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
203 { ESIS_OPTION_SECURITY, "Security" },
204 { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
205 { ESIS_OPTION_PRIORITY, "Priority" },
206 { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
207 { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
208 { 0, NULL }
209};
210
211#define CLNP_OPTION_DISCARD_REASON 193
212#define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
213#define CLNP_OPTION_SECURITY 197 /* iso8473 */
214#define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
215#define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
216#define CLNP_OPTION_PADDING 204 /* iso8473 */
217#define CLNP_OPTION_PRIORITY 205 /* iso8473 */
218
JP Abgrall53f17a92014-02-12 14:02:41 -0800219static const struct tok clnp_option_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800220 { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
221 { CLNP_OPTION_PRIORITY, "Priority"},
222 { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
223 { CLNP_OPTION_SECURITY, "Security"},
224 { CLNP_OPTION_SOURCE_ROUTING, "Source Routing"},
225 { CLNP_OPTION_ROUTE_RECORDING, "Route Recording"},
226 { CLNP_OPTION_PADDING, "Padding"},
227 { 0, NULL }
228};
229
JP Abgrall53f17a92014-02-12 14:02:41 -0800230static const struct tok clnp_option_rfd_class_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800231 { 0x0, "General"},
232 { 0x8, "Address"},
233 { 0x9, "Source Routeing"},
234 { 0xa, "Lifetime"},
235 { 0xb, "PDU Discarded"},
236 { 0xc, "Reassembly"},
237 { 0, NULL }
238};
239
JP Abgrall53f17a92014-02-12 14:02:41 -0800240static const struct tok clnp_option_rfd_general_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800241 { 0x0, "Reason not specified"},
242 { 0x1, "Protocol procedure error"},
243 { 0x2, "Incorrect checksum"},
244 { 0x3, "PDU discarded due to congestion"},
245 { 0x4, "Header syntax error (cannot be parsed)"},
246 { 0x5, "Segmentation needed but not permitted"},
247 { 0x6, "Incomplete PDU received"},
248 { 0x7, "Duplicate option"},
249 { 0, NULL }
250};
251
JP Abgrall53f17a92014-02-12 14:02:41 -0800252static const struct tok clnp_option_rfd_address_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800253 { 0x0, "Destination address unreachable"},
254 { 0x1, "Destination address unknown"},
255 { 0, NULL }
256};
257
JP Abgrall53f17a92014-02-12 14:02:41 -0800258static const struct tok clnp_option_rfd_source_routeing_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800259 { 0x0, "Unspecified source routeing error"},
260 { 0x1, "Syntax error in source routeing field"},
261 { 0x2, "Unknown address in source routeing field"},
262 { 0x3, "Path not acceptable"},
263 { 0, NULL }
264};
265
JP Abgrall53f17a92014-02-12 14:02:41 -0800266static const struct tok clnp_option_rfd_lifetime_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800267 { 0x0, "Lifetime expired while data unit in transit"},
268 { 0x1, "Lifetime expired during reassembly"},
269 { 0, NULL }
270};
271
JP Abgrall53f17a92014-02-12 14:02:41 -0800272static const struct tok clnp_option_rfd_pdu_discard_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800273 { 0x0, "Unsupported option not specified"},
274 { 0x1, "Unsupported protocol version"},
275 { 0x2, "Unsupported security option"},
276 { 0x3, "Unsupported source routeing option"},
277 { 0x4, "Unsupported recording of route option"},
278 { 0, NULL }
279};
280
JP Abgrall53f17a92014-02-12 14:02:41 -0800281static const struct tok clnp_option_rfd_reassembly_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800282 { 0x0, "Reassembly interference"},
283 { 0, NULL }
284};
285
286/* array of 16 error-classes */
JP Abgrall53f17a92014-02-12 14:02:41 -0800287static const struct tok *clnp_option_rfd_error_class[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800288 clnp_option_rfd_general_values,
289 NULL,
290 NULL,
291 NULL,
292 NULL,
293 NULL,
294 NULL,
295 NULL,
296 clnp_option_rfd_address_values,
297 clnp_option_rfd_source_routeing_values,
298 clnp_option_rfd_lifetime_values,
299 clnp_option_rfd_pdu_discard_values,
300 clnp_option_rfd_reassembly_values,
301 NULL,
302 NULL,
303 NULL
304};
305
306#define CLNP_OPTION_OPTION_QOS_MASK 0x3f
307#define CLNP_OPTION_SCOPE_MASK 0xc0
308#define CLNP_OPTION_SCOPE_SA_SPEC 0x40
309#define CLNP_OPTION_SCOPE_DA_SPEC 0x80
310#define CLNP_OPTION_SCOPE_GLOBAL 0xc0
311
JP Abgrall53f17a92014-02-12 14:02:41 -0800312static const struct tok clnp_option_scope_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800313 { CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
314 { CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
315 { CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
316 { 0, NULL }
317};
318
JP Abgrall53f17a92014-02-12 14:02:41 -0800319static const struct tok clnp_option_sr_rr_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800320 { 0x0, "partial"},
321 { 0x1, "complete"},
322 { 0, NULL }
323};
324
JP Abgrall53f17a92014-02-12 14:02:41 -0800325static const struct tok clnp_option_sr_rr_string_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800326 { CLNP_OPTION_SOURCE_ROUTING, "source routing"},
327 { CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
328 { 0, NULL }
329};
330
JP Abgrall53f17a92014-02-12 14:02:41 -0800331static const struct tok clnp_option_qos_global_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800332 { 0x20, "reserved"},
333 { 0x10, "sequencing vs. delay"},
334 { 0x08, "congested"},
335 { 0x04, "delay vs. cost"},
336 { 0x02, "error vs. delay"},
337 { 0x01, "error vs. cost"},
338 { 0, NULL }
339};
340
341#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
JP Abgrall53f17a92014-02-12 14:02:41 -0800342#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800343#define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
344#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
345#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
346#define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
347#define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
348#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
349#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
350#define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
JP Abgrall53f17a92014-02-12 14:02:41 -0800351#define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
352#define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
353#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800354#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
355
JP Abgrall53f17a92014-02-12 14:02:41 -0800356#define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
357
358static const struct tok isis_ext_is_reach_subtlv_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800359 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
360 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
361 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
362 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
363 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
364 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
365 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
366 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
367 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
JP Abgrall53f17a92014-02-12 14:02:41 -0800368 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE, "Link Attribute" },
The Android Open Source Project2949f582009-03-03 19:30:46 -0800369 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
370 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
371 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" },
372 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" },
JP Abgrall53f17a92014-02-12 14:02:41 -0800373 { ISIS_SUBTLV_SPB_METRIC, "SPB Metric" },
The Android Open Source Project2949f582009-03-03 19:30:46 -0800374 { 250, "Reserved for cisco specific extensions" },
375 { 251, "Reserved for cisco specific extensions" },
376 { 252, "Reserved for cisco specific extensions" },
377 { 253, "Reserved for cisco specific extensions" },
378 { 254, "Reserved for cisco specific extensions" },
379 { 255, "Reserved for future expansion" },
380 { 0, NULL }
381};
382
383#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
384#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
385#define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
386
JP Abgrall53f17a92014-02-12 14:02:41 -0800387static const struct tok isis_ext_ip_reach_subtlv_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800388 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
389 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
390 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
391 { 0, NULL }
392};
393
JP Abgrall53f17a92014-02-12 14:02:41 -0800394static const struct tok isis_subtlv_link_attribute_values[] = {
395 { 0x01, "Local Protection Available" },
396 { 0x02, "Link excluded from local protection path" },
397 { 0x04, "Local maintenance required"},
398 { 0, NULL }
399};
400
The Android Open Source Project2949f582009-03-03 19:30:46 -0800401#define ISIS_SUBTLV_AUTH_SIMPLE 1
JP Abgrall53f17a92014-02-12 14:02:41 -0800402#define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800403#define ISIS_SUBTLV_AUTH_MD5 54
404#define ISIS_SUBTLV_AUTH_MD5_LEN 16
405#define ISIS_SUBTLV_AUTH_PRIVATE 255
406
JP Abgrall53f17a92014-02-12 14:02:41 -0800407static const struct tok isis_subtlv_auth_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800408 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
JP Abgrall53f17a92014-02-12 14:02:41 -0800409 { ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
The Android Open Source Project2949f582009-03-03 19:30:46 -0800410 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
411 { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
412 { 0, NULL }
413};
414
415#define ISIS_SUBTLV_IDRP_RES 0
416#define ISIS_SUBTLV_IDRP_LOCAL 1
417#define ISIS_SUBTLV_IDRP_ASN 2
418
JP Abgrall53f17a92014-02-12 14:02:41 -0800419static const struct tok isis_subtlv_idrp_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800420 { ISIS_SUBTLV_IDRP_RES, "Reserved"},
421 { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
422 { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
423 { 0, NULL}
424};
425
JP Abgrall53f17a92014-02-12 14:02:41 -0800426#define ISIS_SUBTLV_SPB_MCID 4
427#define ISIS_SUBTLV_SPB_DIGEST 5
428#define ISIS_SUBTLV_SPB_BVID 6
429
430#define ISIS_SUBTLV_SPB_INSTANCE 1
431#define ISIS_SUBTLV_SPBM_SI 3
432
433#define ISIS_SPB_MCID_LEN 51
434#define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
435#define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
436#define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
437#define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
438#define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
439
440static const struct tok isis_mt_port_cap_subtlv_values[] = {
441 { ISIS_SUBTLV_SPB_MCID, "SPB MCID" },
442 { ISIS_SUBTLV_SPB_DIGEST, "SPB Digest" },
443 { ISIS_SUBTLV_SPB_BVID, "SPB BVID" },
444 { 0, NULL }
445};
446
447static const struct tok isis_mt_capability_subtlv_values[] = {
448 { ISIS_SUBTLV_SPB_INSTANCE, "SPB Instance" },
449 { ISIS_SUBTLV_SPBM_SI, "SPBM Service Identifier and Unicast Address" },
450 { 0, NULL }
451};
452
453struct isis_spb_mcid {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700454 uint8_t format_id;
455 uint8_t name[32];
456 uint8_t revision_lvl[2];
457 uint8_t digest[16];
JP Abgrall53f17a92014-02-12 14:02:41 -0800458};
459
460struct isis_subtlv_spb_mcid {
461 struct isis_spb_mcid mcid;
462 struct isis_spb_mcid aux_mcid;
463};
464
465struct isis_subtlv_spb_instance {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700466 uint8_t cist_root_id[8];
467 uint8_t cist_external_root_path_cost[4];
468 uint8_t bridge_priority[2];
469 uint8_t spsourceid[4];
470 uint8_t no_of_trees;
JP Abgrall53f17a92014-02-12 14:02:41 -0800471};
472
The Android Open Source Project2949f582009-03-03 19:30:46 -0800473#define CLNP_SEGMENT_PART 0x80
474#define CLNP_MORE_SEGMENTS 0x40
475#define CLNP_REQUEST_ER 0x20
476
JP Abgrall53f17a92014-02-12 14:02:41 -0800477static const struct tok clnp_flag_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800478 { CLNP_SEGMENT_PART, "Segmentation permitted"},
479 { CLNP_MORE_SEGMENTS, "more Segments"},
480 { CLNP_REQUEST_ER, "request Error Report"},
481 { 0, NULL}
482};
483
484#define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
485#define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
486#define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
487#define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
488#define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
489#define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
490#define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
491#define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
492
493#define ISIS_MASK_MTID(x) ((x)&0x0fff)
494#define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
495
JP Abgrall53f17a92014-02-12 14:02:41 -0800496static const struct tok isis_mt_flag_values[] = {
497 { 0x4000, "ATT bit set"},
498 { 0x8000, "Overload bit set"},
The Android Open Source Project2949f582009-03-03 19:30:46 -0800499 { 0, NULL}
500};
501
502#define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
503#define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
504
505#define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
506#define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
507
508#define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
509#define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
510#define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
511#define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
512
513#define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
514
JP Abgrall53f17a92014-02-12 14:02:41 -0800515static const struct tok isis_mt_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800516 { 0, "IPv4 unicast"},
517 { 1, "In-Band Management"},
518 { 2, "IPv6 unicast"},
519 { 3, "Multicast"},
520 { 4095, "Development, Experimental or Proprietary"},
521 { 0, NULL }
522};
523
JP Abgrall53f17a92014-02-12 14:02:41 -0800524static const struct tok isis_iih_circuit_type_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800525 { 1, "Level 1 only"},
526 { 2, "Level 2 only"},
527 { 3, "Level 1, Level 2"},
528 { 0, NULL}
529};
530
531#define ISIS_LSP_TYPE_UNUSED0 0
532#define ISIS_LSP_TYPE_LEVEL_1 1
533#define ISIS_LSP_TYPE_UNUSED2 2
534#define ISIS_LSP_TYPE_LEVEL_2 3
535
JP Abgrall53f17a92014-02-12 14:02:41 -0800536static const struct tok isis_lsp_istype_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800537 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
538 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
539 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
540 { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"},
541 { 0, NULL }
542};
543
544/*
545 * Katz's point to point adjacency TLV uses codes to tell us the state of
546 * the remote adjacency. Enumerate them.
547 */
548
549#define ISIS_PTP_ADJ_UP 0
550#define ISIS_PTP_ADJ_INIT 1
551#define ISIS_PTP_ADJ_DOWN 2
552
JP Abgrall53f17a92014-02-12 14:02:41 -0800553static const struct tok isis_ptp_adjancey_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800554 { ISIS_PTP_ADJ_UP, "Up" },
555 { ISIS_PTP_ADJ_INIT, "Initializing" },
556 { ISIS_PTP_ADJ_DOWN, "Down" },
557 { 0, NULL}
558};
559
560struct isis_tlv_ptp_adj {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700561 uint8_t adjacency_state;
562 uint8_t extd_local_circuit_id[4];
563 uint8_t neighbor_sysid[SYSTEM_ID_LEN];
564 uint8_t neighbor_extd_local_circuit_id[4];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800565};
566
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700567static int osi_print_cksum(netdissect_options *, const uint8_t *pptr,
Aurimas Liutikasba29be72016-05-10 12:28:35 -0700568 uint16_t checksum, int checksum_offset, int length);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700569static int clnp_print(netdissect_options *, const uint8_t *, u_int);
570static void esis_print(netdissect_options *, const uint8_t *, u_int);
571static int isis_print(netdissect_options *, const uint8_t *, u_int);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800572
573struct isis_metric_block {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700574 uint8_t metric_default;
575 uint8_t metric_delay;
576 uint8_t metric_expense;
577 uint8_t metric_error;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800578};
579
580struct isis_tlv_is_reach {
581 struct isis_metric_block isis_metric_block;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700582 uint8_t neighbor_nodeid[NODE_ID_LEN];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800583};
584
585struct isis_tlv_es_reach {
586 struct isis_metric_block isis_metric_block;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700587 uint8_t neighbor_sysid[SYSTEM_ID_LEN];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800588};
589
590struct isis_tlv_ip_reach {
591 struct isis_metric_block isis_metric_block;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700592 uint8_t prefix[4];
593 uint8_t mask[4];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800594};
595
JP Abgrall53f17a92014-02-12 14:02:41 -0800596static const struct tok isis_is_reach_virtual_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800597 { 0, "IsNotVirtual"},
598 { 1, "IsVirtual"},
599 { 0, NULL }
600};
601
JP Abgrall53f17a92014-02-12 14:02:41 -0800602static const struct tok isis_restart_flag_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800603 { 0x1, "Restart Request"},
604 { 0x2, "Restart Acknowledgement"},
605 { 0x4, "Suppress adjacency advertisement"},
606 { 0, NULL }
607};
608
609struct isis_common_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700610 uint8_t nlpid;
611 uint8_t fixed_len;
612 uint8_t version; /* Protocol version */
613 uint8_t id_length;
614 uint8_t pdu_type; /* 3 MSbits are reserved */
615 uint8_t pdu_version; /* Packet format version */
616 uint8_t reserved;
617 uint8_t max_area;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800618};
619
620struct isis_iih_lan_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700621 uint8_t circuit_type;
622 uint8_t source_id[SYSTEM_ID_LEN];
623 uint8_t holding_time[2];
624 uint8_t pdu_len[2];
625 uint8_t priority;
626 uint8_t lan_id[NODE_ID_LEN];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800627};
628
629struct isis_iih_ptp_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700630 uint8_t circuit_type;
631 uint8_t source_id[SYSTEM_ID_LEN];
632 uint8_t holding_time[2];
633 uint8_t pdu_len[2];
634 uint8_t circuit_id;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800635};
636
637struct isis_lsp_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700638 uint8_t pdu_len[2];
639 uint8_t remaining_lifetime[2];
640 uint8_t lsp_id[LSP_ID_LEN];
641 uint8_t sequence_number[4];
642 uint8_t checksum[2];
643 uint8_t typeblock;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800644};
645
646struct isis_csnp_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700647 uint8_t pdu_len[2];
648 uint8_t source_id[NODE_ID_LEN];
649 uint8_t start_lsp_id[LSP_ID_LEN];
650 uint8_t end_lsp_id[LSP_ID_LEN];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800651};
652
653struct isis_psnp_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700654 uint8_t pdu_len[2];
655 uint8_t source_id[NODE_ID_LEN];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800656};
657
658struct isis_tlv_lsp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700659 uint8_t remaining_lifetime[2];
660 uint8_t lsp_id[LSP_ID_LEN];
661 uint8_t sequence_number[4];
662 uint8_t checksum[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800663};
664
665#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
666#define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
667#define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
668#define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
669#define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
670#define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
671
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700672void
673isoclns_print(netdissect_options *ndo,
674 const uint8_t *p, u_int length, u_int caplen)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800675{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700676 if (caplen <= 1) { /* enough bytes on the wire ? */
677 ND_PRINT((ndo, "|OSI"));
678 return;
679 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800680
Elliott Hughes892a68b2015-10-19 14:43:53 -0700681 if (ndo->ndo_eflag)
682 ND_PRINT((ndo, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", *p), *p));
683
The Android Open Source Project2949f582009-03-03 19:30:46 -0800684 switch (*p) {
685
686 case NLPID_CLNP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700687 if (!clnp_print(ndo, p, length))
688 print_unknown_data(ndo, p, "\n\t", caplen);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800689 break;
690
691 case NLPID_ESIS:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700692 esis_print(ndo, p, length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800693 return;
694
695 case NLPID_ISIS:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700696 if (!isis_print(ndo, p, length))
697 print_unknown_data(ndo, p, "\n\t", caplen);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800698 break;
699
700 case NLPID_NULLNS:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700701 ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800702 break;
703
Elliott Hughes892a68b2015-10-19 14:43:53 -0700704 case NLPID_Q933:
705 q933_print(ndo, p + 1, length - 1);
706 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800707
Elliott Hughes892a68b2015-10-19 14:43:53 -0700708 case NLPID_IP:
709 ip_print(ndo, p + 1, length - 1);
710 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800711
Elliott Hughes892a68b2015-10-19 14:43:53 -0700712 case NLPID_IP6:
713 ip6_print(ndo, p + 1, length - 1);
714 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800715
Elliott Hughes892a68b2015-10-19 14:43:53 -0700716 case NLPID_PPP:
717 ppp_print(ndo, p + 1, length - 1);
718 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800719
720 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700721 if (!ndo->ndo_eflag)
722 ND_PRINT((ndo, "OSI NLPID 0x%02x unknown", *p));
723 ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800724 if (caplen > 1)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700725 print_unknown_data(ndo, p, "\n\t", caplen);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800726 break;
727 }
728}
729
730#define CLNP_PDU_ER 1
731#define CLNP_PDU_DT 28
732#define CLNP_PDU_MD 29
733#define CLNP_PDU_ERQ 30
734#define CLNP_PDU_ERP 31
735
JP Abgrall53f17a92014-02-12 14:02:41 -0800736static const struct tok clnp_pdu_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800737 { CLNP_PDU_ER, "Error Report"},
738 { CLNP_PDU_MD, "MD"},
739 { CLNP_PDU_DT, "Data"},
740 { CLNP_PDU_ERQ, "Echo Request"},
741 { CLNP_PDU_ERP, "Echo Response"},
742 { 0, NULL }
743};
744
745struct clnp_header_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700746 uint8_t nlpid;
747 uint8_t length_indicator;
748 uint8_t version;
749 uint8_t lifetime; /* units of 500ms */
750 uint8_t type;
751 uint8_t segment_length[2];
752 uint8_t cksum[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800753};
754
755struct clnp_segment_header_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700756 uint8_t data_unit_id[2];
757 uint8_t segment_offset[2];
758 uint8_t total_length[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800759};
760
761/*
762 * clnp_print
763 * Decode CLNP packets. Return 0 on error.
764 */
765
Elliott Hughes892a68b2015-10-19 14:43:53 -0700766static int
767clnp_print(netdissect_options *ndo,
768 const uint8_t *pptr, u_int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800769{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700770 const uint8_t *optr,*source_address,*dest_address;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800771 u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
772 const struct clnp_header_t *clnp_header;
773 const struct clnp_segment_header_t *clnp_segment_header;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700774 uint8_t rfd_error_major,rfd_error_minor;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800775
776 clnp_header = (const struct clnp_header_t *) pptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700777 ND_TCHECK(*clnp_header);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800778
779 li = clnp_header->length_indicator;
780 optr = pptr;
781
Elliott Hughes892a68b2015-10-19 14:43:53 -0700782 if (!ndo->ndo_eflag)
783 ND_PRINT((ndo, "CLNP"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800784
785 /*
786 * Sanity checking of the header.
787 */
788
789 if (clnp_header->version != CLNP_VERSION) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700790 ND_PRINT((ndo, "version %d packet not supported", clnp_header->version));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800791 return (0);
792 }
793
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700794 if (li > length) {
795 ND_PRINT((ndo, " length indicator(%u) > PDU size (%u)!", li, length));
796 return (0);
797 }
798
799 if (li < sizeof(struct clnp_header_t)) {
800 ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
801 while (pptr < ndo->ndo_snapend)
802 ND_PRINT((ndo, "%02X", *pptr++));
803 return (0);
804 }
805
The Android Open Source Project2949f582009-03-03 19:30:46 -0800806 /* FIXME further header sanity checking */
807
808 clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
809 clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
810
811 pptr += sizeof(struct clnp_header_t);
812 li -= sizeof(struct clnp_header_t);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700813
814 if (li < 1) {
815 ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
816 return (0);
817 }
818 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800819 dest_address_length = *pptr;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700820 pptr += 1;
821 li -= 1;
822 if (li < dest_address_length) {
823 ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
824 return (0);
825 }
826 ND_TCHECK2(*pptr, dest_address_length);
827 dest_address = pptr;
828 pptr += dest_address_length;
829 li -= dest_address_length;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800830
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700831 if (li < 1) {
832 ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
833 return (0);
834 }
835 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800836 source_address_length = *pptr;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700837 pptr += 1;
838 li -= 1;
839 if (li < source_address_length) {
840 ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
841 return (0);
842 }
843 ND_TCHECK2(*pptr, source_address_length);
844 source_address = pptr;
845 pptr += source_address_length;
846 li -= source_address_length;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800847
Elliott Hughes892a68b2015-10-19 14:43:53 -0700848 if (ndo->ndo_vflag < 1) {
849 ND_PRINT((ndo, "%s%s > %s, %s, length %u",
850 ndo->ndo_eflag ? "" : ", ",
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700851 isonsap_string(ndo, source_address, source_address_length),
852 isonsap_string(ndo, dest_address, dest_address_length),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800853 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700854 length));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800855 return (1);
856 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700857 ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800858
Elliott Hughes892a68b2015-10-19 14:43:53 -0700859 ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800860 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
861 clnp_header->length_indicator,
862 clnp_header->version,
863 clnp_header->lifetime/2,
864 (clnp_header->lifetime%2)*5,
865 EXTRACT_16BITS(clnp_header->segment_length),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700866 EXTRACT_16BITS(clnp_header->cksum)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800867
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700868 if (osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7,
869 clnp_header->length_indicator) == 0)
870 goto trunc;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800871
Elliott Hughes892a68b2015-10-19 14:43:53 -0700872 ND_PRINT((ndo, "\n\tFlags [%s]",
873 bittok2str(clnp_flag_values, "none", clnp_flags)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800874
Elliott Hughes892a68b2015-10-19 14:43:53 -0700875 ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800876 source_address_length,
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700877 isonsap_string(ndo, source_address, source_address_length),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800878 dest_address_length,
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700879 isonsap_string(ndo, dest_address, dest_address_length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800880
881 if (clnp_flags & CLNP_SEGMENT_PART) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700882 if (li < sizeof(const struct clnp_segment_header_t)) {
883 ND_PRINT((ndo, "li < size of fixed part of CLNP header, addresses, and segment part"));
884 return (0);
885 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800886 clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700887 ND_TCHECK(*clnp_segment_header);
888 ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800889 EXTRACT_16BITS(clnp_segment_header->data_unit_id),
890 EXTRACT_16BITS(clnp_segment_header->segment_offset),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700891 EXTRACT_16BITS(clnp_segment_header->total_length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800892 pptr+=sizeof(const struct clnp_segment_header_t);
893 li-=sizeof(const struct clnp_segment_header_t);
894 }
895
896 /* now walk the options */
897 while (li >= 2) {
898 u_int op, opli;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700899 const uint8_t *tptr;
900
The Android Open Source Project2949f582009-03-03 19:30:46 -0800901 if (li < 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700902 ND_PRINT((ndo, ", bad opts/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800903 return (0);
904 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700905 ND_TCHECK2(*pptr, 2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800906 op = *pptr++;
907 opli = *pptr++;
908 li -= 2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800909 if (opli > li) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700910 ND_PRINT((ndo, ", opt (%d) too long", op));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800911 return (0);
912 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700913 ND_TCHECK2(*pptr, opli);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800914 li -= opli;
915 tptr = pptr;
916 tlen = opli;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700917
918 ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800919 tok2str(clnp_option_values,"Unknown",op),
920 op,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700921 opli));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800922
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700923 /*
924 * We've already checked that the entire option is present
925 * in the captured packet with the ND_TCHECK2() call.
926 * Therefore, we don't need to do ND_TCHECK()/ND_TCHECK2()
927 * checks.
928 * We do, however, need to check tlen, to make sure we
929 * don't run past the end of the option.
930 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800931 switch (op) {
932
933
934 case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700935 case CLNP_OPTION_SOURCE_ROUTING:
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700936 if (tlen < 2) {
937 ND_PRINT((ndo, ", bad opt len"));
938 return (0);
939 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700940 ND_PRINT((ndo, "%s %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800941 tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700942 tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800943 nsap_offset=*(tptr+1);
944 if (nsap_offset == 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700945 ND_PRINT((ndo, " Bad NSAP offset (0)"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800946 break;
947 }
948 nsap_offset-=1; /* offset to nsap list */
949 if (nsap_offset > tlen) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700950 ND_PRINT((ndo, " Bad NSAP offset (past end of option)"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800951 break;
952 }
953 tptr+=nsap_offset;
954 tlen-=nsap_offset;
955 while (tlen > 0) {
956 source_address_length=*tptr;
957 if (tlen < source_address_length+1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700958 ND_PRINT((ndo, "\n\t NSAP address goes past end of option"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800959 break;
960 }
961 if (source_address_length > 0) {
962 source_address=(tptr+1);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700963 ND_TCHECK2(*source_address, source_address_length);
964 ND_PRINT((ndo, "\n\t NSAP address (length %u): %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800965 source_address_length,
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700966 isonsap_string(ndo, source_address, source_address_length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800967 }
968 tlen-=source_address_length+1;
969 }
970 break;
971
972 case CLNP_OPTION_PRIORITY:
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700973 if (tlen < 1) {
974 ND_PRINT((ndo, ", bad opt len"));
975 return (0);
976 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700977 ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800978 break;
979
980 case CLNP_OPTION_QOS_MAINTENANCE:
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700981 if (tlen < 1) {
982 ND_PRINT((ndo, ", bad opt len"));
983 return (0);
984 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700985 ND_PRINT((ndo, "\n\t Format Code: %s",
986 tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800987
988 if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700989 ND_PRINT((ndo, "\n\t QoS Flags [%s]",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800990 bittok2str(clnp_option_qos_global_values,
991 "none",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700992 *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800993 break;
994
995 case CLNP_OPTION_SECURITY:
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700996 if (tlen < 2) {
997 ND_PRINT((ndo, ", bad opt len"));
998 return (0);
999 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001000 ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001001 tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001002 *(tptr+1)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001003 break;
1004
1005 case CLNP_OPTION_DISCARD_REASON:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001006 if (tlen < 1) {
1007 ND_PRINT((ndo, ", bad opt len"));
1008 return (0);
1009 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08001010 rfd_error_major = (*tptr&0xf0) >> 4;
1011 rfd_error_minor = *tptr&0x0f;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001012 ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001013 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
1014 rfd_error_major,
1015 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001016 rfd_error_minor));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001017 break;
1018
1019 case CLNP_OPTION_PADDING:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001020 ND_PRINT((ndo, "padding data"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001021 break;
1022
1023 /*
1024 * FIXME those are the defined Options that lack a decoder
1025 * you are welcome to contribute code ;-)
1026 */
1027
1028 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001029 print_unknown_data(ndo, tptr, "\n\t ", opli);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001030 break;
1031 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001032 if (ndo->ndo_vflag > 1)
1033 print_unknown_data(ndo, pptr, "\n\t ", opli);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001034 pptr += opli;
1035 }
1036
1037 switch (clnp_pdu_type) {
1038
1039 case CLNP_PDU_ER: /* fall through */
1040 case CLNP_PDU_ERP:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001041 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001042 if (*(pptr) == NLPID_CLNP) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001043 ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001044 /* FIXME recursion protection */
Elliott Hughes892a68b2015-10-19 14:43:53 -07001045 clnp_print(ndo, pptr, length - clnp_header->length_indicator);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001046 break;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001047 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08001048
1049 case CLNP_PDU_DT:
1050 case CLNP_PDU_MD:
1051 case CLNP_PDU_ERQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001052
The Android Open Source Project2949f582009-03-03 19:30:46 -08001053 default:
1054 /* dump the PDU specific data */
1055 if (length-(pptr-optr) > 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001056 ND_PRINT((ndo, "\n\t undecoded non-header data, length %u", length-clnp_header->length_indicator));
1057 print_unknown_data(ndo, pptr, "\n\t ", length - (pptr - optr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001058 }
1059 }
1060
1061 return (1);
1062
1063 trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001064 ND_PRINT((ndo, "[|clnp]"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001065 return (1);
1066
1067}
1068
1069
1070#define ESIS_PDU_REDIRECT 6
1071#define ESIS_PDU_ESH 2
1072#define ESIS_PDU_ISH 4
1073
JP Abgrall53f17a92014-02-12 14:02:41 -08001074static const struct tok esis_pdu_values[] = {
The Android Open Source Project2949f582009-03-03 19:30:46 -08001075 { ESIS_PDU_REDIRECT, "redirect"},
1076 { ESIS_PDU_ESH, "ESH"},
1077 { ESIS_PDU_ISH, "ISH"},
1078 { 0, NULL }
1079};
1080
1081struct esis_header_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001082 uint8_t nlpid;
1083 uint8_t length_indicator;
1084 uint8_t version;
1085 uint8_t reserved;
1086 uint8_t type;
1087 uint8_t holdtime[2];
1088 uint8_t cksum[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -08001089};
1090
1091static void
Elliott Hughes892a68b2015-10-19 14:43:53 -07001092esis_print(netdissect_options *ndo,
1093 const uint8_t *pptr, u_int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -08001094{
Elliott Hughes892a68b2015-10-19 14:43:53 -07001095 const uint8_t *optr;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001096 u_int li,esis_pdu_type,source_address_length, source_address_number;
1097 const struct esis_header_t *esis_header;
1098
Elliott Hughes892a68b2015-10-19 14:43:53 -07001099 if (!ndo->ndo_eflag)
1100 ND_PRINT((ndo, "ES-IS"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001101
1102 if (length <= 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001103 ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001104 return;
1105 }
1106
1107 esis_header = (const struct esis_header_t *) pptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001108 ND_TCHECK(*esis_header);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001109 li = esis_header->length_indicator;
1110 optr = pptr;
1111
1112 /*
1113 * Sanity checking of the header.
1114 */
1115
1116 if (esis_header->nlpid != NLPID_ESIS) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001117 ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001118 return;
1119 }
1120
1121 if (esis_header->version != ESIS_VERSION) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001122 ND_PRINT((ndo, " version %d packet not supported", esis_header->version));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001123 return;
1124 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001125
The Android Open Source Project2949f582009-03-03 19:30:46 -08001126 if (li > length) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001127 ND_PRINT((ndo, " length indicator(%u) > PDU size (%u)!", li, length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001128 return;
1129 }
1130
1131 if (li < sizeof(struct esis_header_t) + 2) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001132 ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
Elliott Hughes892a68b2015-10-19 14:43:53 -07001133 while (pptr < ndo->ndo_snapend)
1134 ND_PRINT((ndo, "%02X", *pptr++));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001135 return;
1136 }
1137
1138 esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
1139
Elliott Hughes892a68b2015-10-19 14:43:53 -07001140 if (ndo->ndo_vflag < 1) {
1141 ND_PRINT((ndo, "%s%s, length %u",
1142 ndo->ndo_eflag ? "" : ", ",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001143 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001144 length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001145 return;
1146 } else
Elliott Hughes892a68b2015-10-19 14:43:53 -07001147 ND_PRINT((ndo, "%slength %u\n\t%s (%u)",
1148 ndo->ndo_eflag ? "" : ", ",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001149 length,
1150 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001151 esis_pdu_type));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001152
Elliott Hughes892a68b2015-10-19 14:43:53 -07001153 ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ));
1154 ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001155
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001156 if (osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li) == 0)
1157 goto trunc;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001158
Elliott Hughes892a68b2015-10-19 14:43:53 -07001159 ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
1160 EXTRACT_16BITS(esis_header->holdtime), li));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001161
Elliott Hughes892a68b2015-10-19 14:43:53 -07001162 if (ndo->ndo_vflag > 1)
1163 print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001164
1165 pptr += sizeof(struct esis_header_t);
1166 li -= sizeof(struct esis_header_t);
1167
1168 switch (esis_pdu_type) {
1169 case ESIS_PDU_REDIRECT: {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001170 const uint8_t *dst, *snpa, *neta;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001171 u_int dstl, snpal, netal;
1172
Elliott Hughes892a68b2015-10-19 14:43:53 -07001173 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001174 if (li < 1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001175 ND_PRINT((ndo, ", bad redirect/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001176 return;
1177 }
1178 dstl = *pptr;
1179 pptr++;
1180 li--;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001181 ND_TCHECK2(*pptr, dstl);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001182 if (li < dstl) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001183 ND_PRINT((ndo, ", bad redirect/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001184 return;
1185 }
1186 dst = pptr;
1187 pptr += dstl;
1188 li -= dstl;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001189 ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, dst, dstl)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001190
Elliott Hughes892a68b2015-10-19 14:43:53 -07001191 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001192 if (li < 1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001193 ND_PRINT((ndo, ", bad redirect/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001194 return;
1195 }
1196 snpal = *pptr;
1197 pptr++;
1198 li--;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001199 ND_TCHECK2(*pptr, snpal);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001200 if (li < snpal) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001201 ND_PRINT((ndo, ", bad redirect/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001202 return;
1203 }
1204 snpa = pptr;
1205 pptr += snpal;
1206 li -= snpal;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001207 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001208 if (li < 1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001209 ND_PRINT((ndo, ", bad redirect/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001210 return;
1211 }
1212 netal = *pptr;
1213 pptr++;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001214 ND_TCHECK2(*pptr, netal);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001215 if (li < netal) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001216 ND_PRINT((ndo, ", bad redirect/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001217 return;
1218 }
1219 neta = pptr;
1220 pptr += netal;
1221 li -= netal;
1222
1223 if (netal == 0)
Elliott Hughes892a68b2015-10-19 14:43:53 -07001224 ND_PRINT((ndo, "\n\t %s", etheraddr_string(ndo, snpa)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001225 else
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001226 ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, neta, netal)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001227 break;
1228 }
1229
1230 case ESIS_PDU_ESH:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001231 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001232 if (li < 1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001233 ND_PRINT((ndo, ", bad esh/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001234 return;
1235 }
1236 source_address_number = *pptr;
1237 pptr++;
1238 li--;
1239
Elliott Hughes892a68b2015-10-19 14:43:53 -07001240 ND_PRINT((ndo, "\n\t Number of Source Addresses: %u", source_address_number));
1241
The Android Open Source Project2949f582009-03-03 19:30:46 -08001242 while (source_address_number > 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001243 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001244 if (li < 1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001245 ND_PRINT((ndo, ", bad esh/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001246 return;
1247 }
1248 source_address_length = *pptr;
1249 pptr++;
1250 li--;
1251
Elliott Hughes892a68b2015-10-19 14:43:53 -07001252 ND_TCHECK2(*pptr, source_address_length);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001253 if (li < source_address_length) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001254 ND_PRINT((ndo, ", bad esh/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001255 return;
1256 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001257 ND_PRINT((ndo, "\n\t NET (length: %u): %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001258 source_address_length,
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001259 isonsap_string(ndo, pptr, source_address_length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001260 pptr += source_address_length;
1261 li -= source_address_length;
1262 source_address_number--;
1263 }
1264
1265 break;
1266
1267 case ESIS_PDU_ISH: {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001268 ND_TCHECK(*pptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001269 if (li < 1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001270 ND_PRINT((ndo, ", bad ish/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001271 return;
1272 }
1273 source_address_length = *pptr;
1274 pptr++;
1275 li--;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001276 ND_TCHECK2(*pptr, source_address_length);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001277 if (li < source_address_length) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001278 ND_PRINT((ndo, ", bad ish/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001279 return;
1280 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001281 ND_PRINT((ndo, "\n\t NET (length: %u): %s", source_address_length, isonsap_string(ndo, pptr, source_address_length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001282 pptr += source_address_length;
1283 li -= source_address_length;
1284 break;
1285 }
1286
1287 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001288 if (ndo->ndo_vflag <= 1) {
1289 if (pptr < ndo->ndo_snapend)
1290 print_unknown_data(ndo, pptr, "\n\t ", ndo->ndo_snapend - pptr);
1291 }
1292 return;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001293 }
1294
1295 /* now walk the options */
JP Abgrall53f17a92014-02-12 14:02:41 -08001296 while (li != 0) {
The Android Open Source Project2949f582009-03-03 19:30:46 -08001297 u_int op, opli;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001298 const uint8_t *tptr;
1299
The Android Open Source Project2949f582009-03-03 19:30:46 -08001300 if (li < 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001301 ND_PRINT((ndo, ", bad opts/li"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001302 return;
1303 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001304 ND_TCHECK2(*pptr, 2);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001305 op = *pptr++;
1306 opli = *pptr++;
1307 li -= 2;
1308 if (opli > li) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001309 ND_PRINT((ndo, ", opt (%d) too long", op));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001310 return;
1311 }
1312 li -= opli;
1313 tptr = pptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001314
1315 ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001316 tok2str(esis_option_values,"Unknown",op),
1317 op,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001318 opli));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001319
1320 switch (op) {
1321
1322 case ESIS_OPTION_ES_CONF_TIME:
JP Abgrall53f17a92014-02-12 14:02:41 -08001323 if (opli == 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001324 ND_TCHECK2(*pptr, 2);
1325 ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001326 } else
Elliott Hughes892a68b2015-10-19 14:43:53 -07001327 ND_PRINT((ndo, "(bad length)"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001328 break;
1329
1330 case ESIS_OPTION_PROTOCOLS:
1331 while (opli>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001332 ND_TCHECK(*pptr);
1333 ND_PRINT((ndo, "%s (0x%02x)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001334 tok2str(nlpid_values,
1335 "unknown",
1336 *tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001337 *tptr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001338 if (opli>1) /* further NPLIDs ? - put comma */
Elliott Hughes892a68b2015-10-19 14:43:53 -07001339 ND_PRINT((ndo, ", "));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001340 tptr++;
1341 opli--;
1342 }
1343 break;
1344
1345 /*
1346 * FIXME those are the defined Options that lack a decoder
1347 * you are welcome to contribute code ;-)
1348 */
1349
1350 case ESIS_OPTION_QOS_MAINTENANCE:
1351 case ESIS_OPTION_SECURITY:
1352 case ESIS_OPTION_PRIORITY:
1353 case ESIS_OPTION_ADDRESS_MASK:
1354 case ESIS_OPTION_SNPA_MASK:
1355
1356 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001357 print_unknown_data(ndo, tptr, "\n\t ", opli);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001358 break;
1359 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001360 if (ndo->ndo_vflag > 1)
1361 print_unknown_data(ndo, pptr, "\n\t ", opli);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001362 pptr += opli;
1363 }
1364trunc:
1365 return;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001366}
JP Abgrall53f17a92014-02-12 14:02:41 -08001367
1368static void
Elliott Hughes892a68b2015-10-19 14:43:53 -07001369isis_print_mcid(netdissect_options *ndo,
1370 const struct isis_spb_mcid *mcid)
JP Abgrall53f17a92014-02-12 14:02:41 -08001371{
1372 int i;
1373
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001374 ND_TCHECK(*mcid);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001375 ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id));
JP Abgrall53f17a92014-02-12 14:02:41 -08001376
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001377 if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
1378 goto trunc;
JP Abgrall53f17a92014-02-12 14:02:41 -08001379
Elliott Hughes892a68b2015-10-19 14:43:53 -07001380 ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001381
Elliott Hughes892a68b2015-10-19 14:43:53 -07001382 ND_PRINT((ndo, ", Digest: "));
JP Abgrall53f17a92014-02-12 14:02:41 -08001383
Elliott Hughes892a68b2015-10-19 14:43:53 -07001384 for(i=0;i<16;i++)
1385 ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001386
1387trunc:
1388 ND_PRINT((ndo, "%s", tstr));
JP Abgrall53f17a92014-02-12 14:02:41 -08001389}
1390
1391static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001392isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
1393 const uint8_t *tptr, int len)
JP Abgrall53f17a92014-02-12 14:02:41 -08001394{
1395 int stlv_type, stlv_len;
1396 const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
1397 int i;
1398
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001399 while (len > 2)
JP Abgrall53f17a92014-02-12 14:02:41 -08001400 {
1401 stlv_type = *(tptr++);
1402 stlv_len = *(tptr++);
1403
1404 /* first lets see if we know the subTLVs name*/
Elliott Hughes892a68b2015-10-19 14:43:53 -07001405 ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
JP Abgrall53f17a92014-02-12 14:02:41 -08001406 tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
1407 stlv_type,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001408 stlv_len));
JP Abgrall53f17a92014-02-12 14:02:41 -08001409
1410 /*len -= TLV_TYPE_LEN_OFFSET;*/
1411 len = len -2;
1412
1413 switch (stlv_type)
1414 {
1415 case ISIS_SUBTLV_SPB_MCID:
1416 {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001417 ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN);
JP Abgrall53f17a92014-02-12 14:02:41 -08001418
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001419 subtlv_spb_mcid = (const struct isis_subtlv_spb_mcid *)tptr;
JP Abgrall53f17a92014-02-12 14:02:41 -08001420
Elliott Hughes892a68b2015-10-19 14:43:53 -07001421 ND_PRINT((ndo, "\n\t MCID: "));
1422 isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
JP Abgrall53f17a92014-02-12 14:02:41 -08001423
1424 /*tptr += SPB_MCID_MIN_LEN;
1425 len -= SPB_MCID_MIN_LEN; */
1426
Elliott Hughes892a68b2015-10-19 14:43:53 -07001427 ND_PRINT((ndo, "\n\t AUX-MCID: "));
1428 isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
JP Abgrall53f17a92014-02-12 14:02:41 -08001429
1430 /*tptr += SPB_MCID_MIN_LEN;
1431 len -= SPB_MCID_MIN_LEN; */
1432 tptr = tptr + sizeof(struct isis_subtlv_spb_mcid);
1433 len = len - sizeof(struct isis_subtlv_spb_mcid);
1434
1435 break;
1436 }
1437
1438 case ISIS_SUBTLV_SPB_DIGEST:
1439 {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001440 ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN);
JP Abgrall53f17a92014-02-12 14:02:41 -08001441
Elliott Hughes892a68b2015-10-19 14:43:53 -07001442 ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
JP Abgrall53f17a92014-02-12 14:02:41 -08001443 (*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001444 ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001445
1446 tptr++;
1447
Elliott Hughes892a68b2015-10-19 14:43:53 -07001448 ND_PRINT((ndo, "\n\t Digest: "));
1449
JP Abgrall53f17a92014-02-12 14:02:41 -08001450 for(i=1;i<=8; i++)
1451 {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001452 ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001453 if (i%4 == 0 && i != 8)
Elliott Hughes892a68b2015-10-19 14:43:53 -07001454 ND_PRINT((ndo, "\n\t "));
JP Abgrall53f17a92014-02-12 14:02:41 -08001455 tptr = tptr + 4;
1456 }
1457
1458 len = len - ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
1459
1460 break;
1461 }
1462
1463 case ISIS_SUBTLV_SPB_BVID:
1464 {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001465 ND_TCHECK2(*(tptr), stlv_len);
JP Abgrall53f17a92014-02-12 14:02:41 -08001466
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001467 while (len >= ISIS_SUBTLV_SPB_BVID_MIN_LEN)
JP Abgrall53f17a92014-02-12 14:02:41 -08001468 {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001469 ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN);
JP Abgrall53f17a92014-02-12 14:02:41 -08001470
Elliott Hughes892a68b2015-10-19 14:43:53 -07001471 ND_PRINT((ndo, "\n\t ECT: %08x",
1472 EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001473
1474 tptr = tptr+4;
1475
Elliott Hughes892a68b2015-10-19 14:43:53 -07001476 ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ",
JP Abgrall53f17a92014-02-12 14:02:41 -08001477 (EXTRACT_16BITS (tptr) >> 4) ,
1478 (EXTRACT_16BITS (tptr) >> 3) & 0x01,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001479 (EXTRACT_16BITS (tptr) >> 2) & 0x01));
JP Abgrall53f17a92014-02-12 14:02:41 -08001480
1481 tptr = tptr + 2;
1482 len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
1483 }
1484
1485 break;
1486 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001487
JP Abgrall53f17a92014-02-12 14:02:41 -08001488 default:
1489 break;
1490 }
1491 }
1492
1493 return 0;
1494
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001495 trunc:
1496 ND_PRINT((ndo, "\n\t\t"));
1497 ND_PRINT((ndo, "%s", tstr));
Elliott Hughes892a68b2015-10-19 14:43:53 -07001498 return(1);
JP Abgrall53f17a92014-02-12 14:02:41 -08001499}
1500
1501static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001502isis_print_mt_capability_subtlv(netdissect_options *ndo,
1503 const uint8_t *tptr, int len)
JP Abgrall53f17a92014-02-12 14:02:41 -08001504{
1505 int stlv_type, stlv_len, tmp;
1506
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001507 while (len > 2)
Elliott Hughes892a68b2015-10-19 14:43:53 -07001508 {
JP Abgrall53f17a92014-02-12 14:02:41 -08001509 stlv_type = *(tptr++);
1510 stlv_len = *(tptr++);
1511
1512 /* first lets see if we know the subTLVs name*/
Elliott Hughes892a68b2015-10-19 14:43:53 -07001513 ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
JP Abgrall53f17a92014-02-12 14:02:41 -08001514 tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
1515 stlv_type,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001516 stlv_len));
1517
JP Abgrall53f17a92014-02-12 14:02:41 -08001518 len = len - 2;
1519
1520 switch (stlv_type)
Elliott Hughes892a68b2015-10-19 14:43:53 -07001521 {
JP Abgrall53f17a92014-02-12 14:02:41 -08001522 case ISIS_SUBTLV_SPB_INSTANCE:
1523
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001524 ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN);
JP Abgrall53f17a92014-02-12 14:02:41 -08001525
Elliott Hughes892a68b2015-10-19 14:43:53 -07001526 ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001527 tptr = tptr+4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001528 ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001529 tptr = tptr+4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001530 ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001531 tptr = tptr+4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001532 ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr)));
1533 tptr = tptr + 2;
1534 ND_PRINT((ndo, "\n\t RES: %d",
1535 EXTRACT_16BITS(tptr) >> 5));
1536 ND_PRINT((ndo, ", V: %d",
1537 (EXTRACT_16BITS(tptr) >> 4) & 0x0001));
1538 ND_PRINT((ndo, ", SPSource-ID: %d",
1539 (EXTRACT_32BITS(tptr) & 0x000fffff)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001540 tptr = tptr+4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001541 ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001542
1543 tmp = *(tptr++);
1544
1545 len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
1546
1547 while (tmp)
1548 {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001549 ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN);
JP Abgrall53f17a92014-02-12 14:02:41 -08001550
Elliott Hughes892a68b2015-10-19 14:43:53 -07001551 ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
JP Abgrall53f17a92014-02-12 14:02:41 -08001552 *(tptr) >> 7, (*(tptr) >> 6) & 0x01,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001553 (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
1554
JP Abgrall53f17a92014-02-12 14:02:41 -08001555 tptr++;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001556
1557 ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001558
1559 tptr = tptr + 4;
1560
Elliott Hughes892a68b2015-10-19 14:43:53 -07001561 ND_PRINT((ndo, ", BVID: %d, SPVID: %d",
JP Abgrall53f17a92014-02-12 14:02:41 -08001562 (EXTRACT_24BITS(tptr) >> 12) & 0x000fff,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001563 EXTRACT_24BITS(tptr) & 0x000fff));
JP Abgrall53f17a92014-02-12 14:02:41 -08001564
1565 tptr = tptr + 3;
1566 len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001567 tmp--;
JP Abgrall53f17a92014-02-12 14:02:41 -08001568 }
1569
1570 break;
1571
1572 case ISIS_SUBTLV_SPBM_SI:
1573
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001574 ND_TCHECK2(*tptr, 8);
JP Abgrall53f17a92014-02-12 14:02:41 -08001575
Elliott Hughes892a68b2015-10-19 14:43:53 -07001576 ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001577 tptr = tptr+4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001578 ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001579 tptr = tptr+2;
1580
Elliott Hughes892a68b2015-10-19 14:43:53 -07001581 ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
1582 (EXTRACT_16BITS(tptr)) & 0x0fff));
JP Abgrall53f17a92014-02-12 14:02:41 -08001583
1584 tptr = tptr+2;
1585 len = len - 8;
1586 stlv_len = stlv_len - 8;
1587
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001588 while (stlv_len >= 4) {
1589 ND_TCHECK2(*tptr, 4);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001590 ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
JP Abgrall53f17a92014-02-12 14:02:41 -08001591 (EXTRACT_32BITS(tptr) >> 31),
1592 (EXTRACT_32BITS(tptr) >> 30) & 0x01,
1593 (EXTRACT_32BITS(tptr) >> 24) & 0x03f,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001594 (EXTRACT_32BITS(tptr)) & 0x0ffffff));
JP Abgrall53f17a92014-02-12 14:02:41 -08001595
1596 tptr = tptr + 4;
1597 len = len - 4;
1598 stlv_len = stlv_len - 4;
1599 }
1600
1601 break;
1602
1603 default:
1604 break;
1605 }
1606 }
1607 return 0;
1608
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001609 trunc:
1610 ND_PRINT((ndo, "\n\t\t"));
1611 ND_PRINT((ndo, "%s", tstr));
JP Abgrall53f17a92014-02-12 14:02:41 -08001612 return(1);
1613}
1614
The Android Open Source Project2949f582009-03-03 19:30:46 -08001615/* shared routine for printing system, node and lsp-ids */
1616static char *
Elliott Hughes892a68b2015-10-19 14:43:53 -07001617isis_print_id(const uint8_t *cp, int id_len)
The Android Open Source Project2949f582009-03-03 19:30:46 -08001618{
1619 int i;
1620 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1621 char *pos = id;
1622
1623 for (i = 1; i <= SYSTEM_ID_LEN; i++) {
1624 snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++);
1625 pos += strlen(pos);
1626 if (i == 2 || i == 4)
1627 *pos++ = '.';
1628 }
1629 if (id_len >= NODE_ID_LEN) {
1630 snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++);
1631 pos += strlen(pos);
1632 }
1633 if (id_len == LSP_ID_LEN)
1634 snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp);
1635 return (id);
1636}
1637
1638/* print the 4-byte metric block which is common found in the old-style TLVs */
1639static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001640isis_print_metric_block(netdissect_options *ndo,
1641 const struct isis_metric_block *isis_metric_block)
The Android Open Source Project2949f582009-03-03 19:30:46 -08001642{
Elliott Hughes892a68b2015-10-19 14:43:53 -07001643 ND_PRINT((ndo, ", Default Metric: %d, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001644 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001645 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001646 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001647 ND_PRINT((ndo, "\n\t\t Delay Metric: %d, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001648 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001649 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001650 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001651 ND_PRINT((ndo, "\n\t\t Expense Metric: %d, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001652 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001653 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001654 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001655 ND_PRINT((ndo, "\n\t\t Error Metric: %d, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001656 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001657 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001658
1659 return(1); /* everything is ok */
1660}
1661
1662static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001663isis_print_tlv_ip_reach(netdissect_options *ndo,
1664 const uint8_t *cp, const char *ident, int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -08001665{
1666 int prefix_len;
1667 const struct isis_tlv_ip_reach *tlv_ip_reach;
1668
1669 tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
1670
1671 while (length > 0) {
1672 if ((size_t)length < sizeof(*tlv_ip_reach)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001673 ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001674 length,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001675 (unsigned long)sizeof(*tlv_ip_reach)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001676 return (0);
1677 }
1678
Elliott Hughes892a68b2015-10-19 14:43:53 -07001679 if (!ND_TTEST(*tlv_ip_reach))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001680 return (0);
1681
1682 prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
1683
1684 if (prefix_len == -1)
Elliott Hughes892a68b2015-10-19 14:43:53 -07001685 ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001686 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001687 ipaddr_string(ndo, (tlv_ip_reach->prefix)),
1688 ipaddr_string(ndo, (tlv_ip_reach->mask))));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001689 else
Elliott Hughes892a68b2015-10-19 14:43:53 -07001690 ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001691 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001692 ipaddr_string(ndo, (tlv_ip_reach->prefix)),
1693 prefix_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001694
Elliott Hughes892a68b2015-10-19 14:43:53 -07001695 ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001696 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
1697 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001698 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001699
1700 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001701 ND_PRINT((ndo, "%s Delay Metric: %u, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001702 ident,
1703 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001704 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"));
1705
The Android Open Source Project2949f582009-03-03 19:30:46 -08001706 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001707 ND_PRINT((ndo, "%s Expense Metric: %u, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001708 ident,
1709 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001710 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"));
1711
The Android Open Source Project2949f582009-03-03 19:30:46 -08001712 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001713 ND_PRINT((ndo, "%s Error Metric: %u, %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001714 ident,
1715 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001716 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001717
1718 length -= sizeof(struct isis_tlv_ip_reach);
1719 tlv_ip_reach++;
1720 }
1721 return (1);
1722}
1723
1724/*
1725 * this is the common IP-REACH subTLV decoder it is called
1726 * from various EXTD-IP REACH TLVs (135,235,236,237)
1727 */
1728
1729static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001730isis_print_ip_reach_subtlv(netdissect_options *ndo,
1731 const uint8_t *tptr, int subt, int subl,
1732 const char *ident)
1733{
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001734 /* first lets see if we know the subTLVs name*/
1735 ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
1736 ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
1737 subt, subl));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001738
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001739 ND_TCHECK2(*tptr,subl);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001740
1741 switch(subt) {
1742 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
1743 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
1744 while (subl >= 4) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001745 ND_PRINT((ndo, ", 0x%08x (=%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001746 EXTRACT_32BITS(tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001747 EXTRACT_32BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001748 tptr+=4;
1749 subl-=4;
1750 }
1751 break;
1752 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
1753 while (subl >= 8) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001754 ND_PRINT((ndo, ", 0x%08x%08x",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001755 EXTRACT_32BITS(tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001756 EXTRACT_32BITS(tptr+4)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001757 tptr+=8;
1758 subl-=8;
1759 }
1760 break;
1761 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001762 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001763 return(0);
1764 break;
1765 }
1766 return(1);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001767
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001768trunc:
1769 ND_PRINT((ndo, "%s", ident));
1770 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001771 return(0);
1772}
1773
1774/*
1775 * this is the common IS-REACH subTLV decoder it is called
1776 * from isis_print_ext_is_reach()
1777 */
1778
1779static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001780isis_print_is_reach_subtlv(netdissect_options *ndo,
1781 const uint8_t *tptr, u_int subt, u_int subl,
1782 const char *ident)
1783{
JP Abgrall53f17a92014-02-12 14:02:41 -08001784 u_int te_class,priority_level,gmpls_switch_cap;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001785 union { /* int to float conversion buffer for several subTLVs */
Elliott Hughes892a68b2015-10-19 14:43:53 -07001786 float f;
1787 uint32_t i;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001788 } bw;
1789
1790 /* first lets see if we know the subTLVs name*/
Elliott Hughes892a68b2015-10-19 14:43:53 -07001791 ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
1792 ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
1793 subt, subl));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001794
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001795 ND_TCHECK2(*tptr, subl);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001796
1797 switch(subt) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001798 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
The Android Open Source Project2949f582009-03-03 19:30:46 -08001799 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
1800 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
1801 if (subl >= 4) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001802 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001803 if (subl == 8) /* rfc4205 */
Elliott Hughes892a68b2015-10-19 14:43:53 -07001804 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001805 }
1806 break;
1807 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
1808 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
1809 if (subl >= sizeof(struct in_addr))
Elliott Hughes892a68b2015-10-19 14:43:53 -07001810 ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001811 break;
1812 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
Elliott Hughes892a68b2015-10-19 14:43:53 -07001813 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
The Android Open Source Project2949f582009-03-03 19:30:46 -08001814 if (subl >= 4) {
1815 bw.i = EXTRACT_32BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001816 ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001817 }
1818 break;
1819 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
1820 if (subl >= 32) {
1821 for (te_class = 0; te_class < 8; te_class++) {
1822 bw.i = EXTRACT_32BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001823 ND_PRINT((ndo, "%s TE-Class %u: %.3f Mbps",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001824 ident,
1825 te_class,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001826 bw.f * 8 / 1000000));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001827 tptr+=4;
1828 }
1829 }
1830 break;
1831 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
1832 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001833 ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001834 ident,
1835 tok2str(diffserv_te_bc_values, "unknown", *tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001836 *tptr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001837 tptr++;
1838 /* decode BCs until the subTLV ends */
1839 for (te_class = 0; te_class < (subl-1)/4; te_class++) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001840 ND_TCHECK2(*tptr, 4);
The Android Open Source Project2949f582009-03-03 19:30:46 -08001841 bw.i = EXTRACT_32BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001842 ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001843 ident,
1844 te_class,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001845 bw.f * 8 / 1000000));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001846 tptr+=4;
1847 }
1848 break;
1849 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
1850 if (subl >= 3)
Elliott Hughes892a68b2015-10-19 14:43:53 -07001851 ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001852 break;
JP Abgrall53f17a92014-02-12 14:02:41 -08001853 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
1854 if (subl == 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001855 ND_PRINT((ndo, ", [ %s ] (0x%04x)",
JP Abgrall53f17a92014-02-12 14:02:41 -08001856 bittok2str(isis_subtlv_link_attribute_values,
1857 "Unknown",
1858 EXTRACT_16BITS(tptr)),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001859 EXTRACT_16BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001860 }
1861 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001862 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
1863 if (subl >= 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001864 ND_PRINT((ndo, ", %s, Priority %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001865 bittok2str(gmpls_link_prot_values, "none", *tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07001866 *(tptr+1)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001867 }
1868 break;
JP Abgrall53f17a92014-02-12 14:02:41 -08001869 case ISIS_SUBTLV_SPB_METRIC:
1870 if (subl >= 6) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001871 ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001872 tptr=tptr+3;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001873 ND_PRINT((ndo, ", P: %u", *(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001874 tptr++;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001875 ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001876 }
1877 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -08001878 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
1879 if (subl >= 36) {
JP Abgrall53f17a92014-02-12 14:02:41 -08001880 gmpls_switch_cap = *tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001881 ND_PRINT((ndo, "%s Interface Switching Capability:%s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001882 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001883 tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
1884 ND_PRINT((ndo, ", LSP Encoding: %s",
1885 tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001886 tptr+=4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001887 ND_PRINT((ndo, "%s Max LSP Bandwidth:", ident));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001888 for (priority_level = 0; priority_level < 8; priority_level++) {
1889 bw.i = EXTRACT_32BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001890 ND_PRINT((ndo, "%s priority level %d: %.3f Mbps",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001891 ident,
1892 priority_level,
Elliott Hughes892a68b2015-10-19 14:43:53 -07001893 bw.f * 8 / 1000000));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001894 tptr+=4;
1895 }
1896 subl-=36;
JP Abgrall53f17a92014-02-12 14:02:41 -08001897 switch (gmpls_switch_cap) {
1898 case GMPLS_PSC1:
1899 case GMPLS_PSC2:
1900 case GMPLS_PSC3:
1901 case GMPLS_PSC4:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001902 ND_TCHECK2(*tptr, 6);
JP Abgrall53f17a92014-02-12 14:02:41 -08001903 bw.i = EXTRACT_32BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001904 ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
1905 ND_PRINT((ndo, "%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr + 4)));
JP Abgrall53f17a92014-02-12 14:02:41 -08001906 break;
1907 case GMPLS_TSC:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001908 ND_TCHECK2(*tptr, 8);
JP Abgrall53f17a92014-02-12 14:02:41 -08001909 bw.i = EXTRACT_32BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001910 ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
1911 ND_PRINT((ndo, "%s Indication %s", ident,
1912 tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr + 4))));
JP Abgrall53f17a92014-02-12 14:02:41 -08001913 break;
1914 default:
1915 /* there is some optional stuff left to decode but this is as of yet
1916 not specified so just lets hexdump what is left */
1917 if(subl>0){
Elliott Hughes892a68b2015-10-19 14:43:53 -07001918 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001919 return(0);
JP Abgrall53f17a92014-02-12 14:02:41 -08001920 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08001921 }
1922 }
1923 break;
1924 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001925 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001926 return(0);
1927 break;
1928 }
1929 return(1);
1930
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001931trunc:
The Android Open Source Project2949f582009-03-03 19:30:46 -08001932 return(0);
1933}
1934
The Android Open Source Project2949f582009-03-03 19:30:46 -08001935/*
1936 * this is the common IS-REACH decoder it is called
1937 * from various EXTD-IS REACH style TLVs (22,24,222)
1938 */
1939
1940static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001941isis_print_ext_is_reach(netdissect_options *ndo,
1942 const uint8_t *tptr, const char *ident, int tlv_type)
1943{
The Android Open Source Project2949f582009-03-03 19:30:46 -08001944 char ident_buffer[20];
1945 int subtlv_type,subtlv_len,subtlv_sum_len;
1946 int proc_bytes = 0; /* how many bytes did we process ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -07001947
1948 if (!ND_TTEST2(*tptr, NODE_ID_LEN))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001949 return(0);
1950
Elliott Hughes892a68b2015-10-19 14:43:53 -07001951 ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001952 tptr+=(NODE_ID_LEN);
1953
1954 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
Elliott Hughes892a68b2015-10-19 14:43:53 -07001955 if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */
The Android Open Source Project2949f582009-03-03 19:30:46 -08001956 return(0);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001957 ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001958 tptr+=3;
1959 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07001960
1961 if (!ND_TTEST2(*tptr, 1))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001962 return(0);
1963 subtlv_sum_len=*(tptr++); /* read out subTLV length */
1964 proc_bytes=NODE_ID_LEN+3+1;
Elliott Hughes892a68b2015-10-19 14:43:53 -07001965 ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001966 if (subtlv_sum_len) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001967 ND_PRINT((ndo, " (%u)", subtlv_sum_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001968 while (subtlv_sum_len>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07001969 if (!ND_TTEST2(*tptr,2))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001970 return(0);
1971 subtlv_type=*(tptr++);
1972 subtlv_len=*(tptr++);
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001973 /* prepend the indent string */
The Android Open Source Project2949f582009-03-03 19:30:46 -08001974 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
Elliott Hughes892a68b2015-10-19 14:43:53 -07001975 if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001976 return(0);
1977 tptr+=subtlv_len;
1978 subtlv_sum_len-=(subtlv_len+2);
1979 proc_bytes+=(subtlv_len+2);
1980 }
1981 }
1982 return(proc_bytes);
1983}
1984
1985/*
1986 * this is the common Multi Topology ID decoder
1987 * it is called from various MT-TLVs (222,229,235,237)
1988 */
1989
1990static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07001991isis_print_mtid(netdissect_options *ndo,
1992 const uint8_t *tptr, const char *ident)
1993{
1994 if (!ND_TTEST2(*tptr, 2))
The Android Open Source Project2949f582009-03-03 19:30:46 -08001995 return(0);
1996
Elliott Hughes892a68b2015-10-19 14:43:53 -07001997 ND_PRINT((ndo, "%s%s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08001998 ident,
1999 tok2str(isis_mt_values,
2000 "Reserved for IETF Consensus",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002001 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002002
Elliott Hughes892a68b2015-10-19 14:43:53 -07002003 ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002004 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002005 bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002006
2007 return(2);
2008}
2009
2010/*
2011 * this is the common extended IP reach decoder
2012 * it is called from TLVs (135,235,236,237)
2013 * we process the TLV and optional subTLVs and return
2014 * the amount of processed bytes
2015 */
2016
2017static int
Elliott Hughes892a68b2015-10-19 14:43:53 -07002018isis_print_extd_ip_reach(netdissect_options *ndo,
2019 const uint8_t *tptr, const char *ident, uint16_t afi)
2020{
The Android Open Source Project2949f582009-03-03 19:30:46 -08002021 char ident_buffer[20];
Elliott Hughes892a68b2015-10-19 14:43:53 -07002022 uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002023 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
2024
Elliott Hughes892a68b2015-10-19 14:43:53 -07002025 if (!ND_TTEST2(*tptr, 4))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002026 return (0);
2027 metric = EXTRACT_32BITS(tptr);
2028 processed=4;
2029 tptr+=4;
Elliott Hughes892a68b2015-10-19 14:43:53 -07002030
JP Abgrall53f17a92014-02-12 14:02:41 -08002031 if (afi == AF_INET) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002032 if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002033 return (0);
2034 status_byte=*(tptr++);
2035 bit_length = status_byte&0x3f;
2036 if (bit_length > 32) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002037 ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002038 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002039 bit_length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002040 return (0);
2041 }
2042 processed++;
JP Abgrall53f17a92014-02-12 14:02:41 -08002043 } else if (afi == AF_INET6) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002044 if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002045 return (0);
2046 status_byte=*(tptr++);
2047 bit_length=*(tptr++);
2048 if (bit_length > 128) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002049 ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002050 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002051 bit_length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002052 return (0);
2053 }
2054 processed+=2;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002055 } else
2056 return (0); /* somebody is fooling us */
2057
2058 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002059
2060 if (!ND_TTEST2(*tptr, byte_length))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002061 return (0);
2062 memset(prefix, 0, sizeof prefix); /* clear the copy buffer */
2063 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
2064 tptr+=byte_length;
2065 processed+=byte_length;
2066
JP Abgrall53f17a92014-02-12 14:02:41 -08002067 if (afi == AF_INET)
Elliott Hughes892a68b2015-10-19 14:43:53 -07002068 ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002069 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002070 ipaddr_string(ndo, prefix),
2071 bit_length));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002072 else if (afi == AF_INET6)
Elliott Hughes892a68b2015-10-19 14:43:53 -07002073 ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002074 ident,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002075 ip6addr_string(ndo, prefix),
2076 bit_length));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002077
2078 ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002079 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002080 metric));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002081
JP Abgrall53f17a92014-02-12 14:02:41 -08002082 if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
Elliott Hughes892a68b2015-10-19 14:43:53 -07002083 ND_PRINT((ndo, ", sub-TLVs present"));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002084 else if (afi == AF_INET6)
Elliott Hughes892a68b2015-10-19 14:43:53 -07002085 ND_PRINT((ndo, ", %s%s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002086 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002087 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002088
JP Abgrall53f17a92014-02-12 14:02:41 -08002089 if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
JP Abgrall53f17a92014-02-12 14:02:41 -08002090 || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
JP Abgrall53f17a92014-02-12 14:02:41 -08002091 ) {
The Android Open Source Project2949f582009-03-03 19:30:46 -08002092 /* assume that one prefix can hold more
2093 than one subTLV - therefore the first byte must reflect
2094 the aggregate bytecount of the subTLVs for this prefix
2095 */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002096 if (!ND_TTEST2(*tptr, 1))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002097 return (0);
2098 sublen=*(tptr++);
2099 processed+=sublen+1;
Elliott Hughes892a68b2015-10-19 14:43:53 -07002100 ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
2101
The Android Open Source Project2949f582009-03-03 19:30:46 -08002102 while (sublen>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002103 if (!ND_TTEST2(*tptr,2))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002104 return (0);
2105 subtlvtype=*(tptr++);
2106 subtlvlen=*(tptr++);
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002107 /* prepend the indent string */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002108 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002109 if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002110 return(0);
2111 tptr+=subtlvlen;
2112 sublen-=(subtlvlen+2);
2113 }
2114 }
2115 return (processed);
2116}
2117
2118/*
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002119 * Clear checksum and lifetime prior to signature verification.
2120 */
2121static void
2122isis_clear_checksum_lifetime(void *header)
2123{
2124 struct isis_lsp_header *header_lsp = (struct isis_lsp_header *) header;
2125
2126 header_lsp->checksum[0] = 0;
2127 header_lsp->checksum[1] = 0;
2128 header_lsp->remaining_lifetime[0] = 0;
2129 header_lsp->remaining_lifetime[1] = 0;
2130}
2131
2132/*
The Android Open Source Project2949f582009-03-03 19:30:46 -08002133 * isis_print
2134 * Decode IS-IS packets. Return 0 on error.
2135 */
2136
Elliott Hughes892a68b2015-10-19 14:43:53 -07002137static int
2138isis_print(netdissect_options *ndo,
2139 const uint8_t *p, u_int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -08002140{
2141 const struct isis_common_header *isis_header;
2142
2143 const struct isis_iih_lan_header *header_iih_lan;
2144 const struct isis_iih_ptp_header *header_iih_ptp;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002145 const struct isis_lsp_header *header_lsp;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002146 const struct isis_csnp_header *header_csnp;
2147 const struct isis_psnp_header *header_psnp;
2148
2149 const struct isis_tlv_lsp *tlv_lsp;
2150 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
2151 const struct isis_tlv_is_reach *tlv_is_reach;
2152 const struct isis_tlv_es_reach *tlv_es_reach;
2153
Elliott Hughes892a68b2015-10-19 14:43:53 -07002154 uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
2155 uint8_t ext_is_len, ext_ip_len, mt_len;
2156 const uint8_t *optr, *pptr, *tptr;
JP Abgrall53f17a92014-02-12 14:02:41 -08002157 u_short packet_len,pdu_len, key_id;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002158 u_int i,vendor_id;
JP Abgrall53f17a92014-02-12 14:02:41 -08002159 int sigcheck;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002160
2161 packet_len=length;
2162 optr = p; /* initialize the _o_riginal pointer to the packet start -
JP Abgrall53f17a92014-02-12 14:02:41 -08002163 need it for parsing the checksum TLV and authentication
2164 TLV verification */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002165 isis_header = (const struct isis_common_header *)p;
Elliott Hughes892a68b2015-10-19 14:43:53 -07002166 ND_TCHECK(*isis_header);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002167 pptr = p+(ISIS_COMMON_HEADER_SIZE);
2168 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
2169 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002170 header_lsp = (const struct isis_lsp_header *)pptr;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002171 header_csnp = (const struct isis_csnp_header *)pptr;
2172 header_psnp = (const struct isis_psnp_header *)pptr;
2173
Elliott Hughes892a68b2015-10-19 14:43:53 -07002174 if (!ndo->ndo_eflag)
2175 ND_PRINT((ndo, "IS-IS"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002176
2177 /*
2178 * Sanity checking of the header.
2179 */
2180
2181 if (isis_header->version != ISIS_VERSION) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002182 ND_PRINT((ndo, "version %d packet not supported", isis_header->version));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002183 return (0);
2184 }
2185
2186 if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002187 ND_PRINT((ndo, "system ID length of %d is not supported",
2188 isis_header->id_length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002189 return (0);
2190 }
2191
2192 if (isis_header->pdu_version != ISIS_VERSION) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002193 ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002194 return (0);
2195 }
2196
2197 max_area = isis_header->max_area;
2198 switch(max_area) {
2199 case 0:
2200 max_area = 3; /* silly shit */
2201 break;
2202 case 255:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002203 ND_PRINT((ndo, "bad packet -- 255 areas"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002204 return (0);
2205 default:
2206 break;
2207 }
2208
2209 id_length = isis_header->id_length;
2210 switch(id_length) {
2211 case 0:
2212 id_length = 6; /* silly shit again */
2213 break;
2214 case 1: /* 1-8 are valid sys-ID lenghts */
2215 case 2:
2216 case 3:
2217 case 4:
2218 case 5:
2219 case 6:
2220 case 7:
2221 case 8:
2222 break;
2223 case 255:
2224 id_length = 0; /* entirely useless */
2225 break;
2226 default:
2227 break;
2228 }
2229
2230 /* toss any non 6-byte sys-ID len PDUs */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002231 if (id_length != 6 ) {
2232 ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002233 return (0);
2234 }
2235
2236 pdu_type=isis_header->pdu_type;
2237
2238 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
Elliott Hughes892a68b2015-10-19 14:43:53 -07002239 if (ndo->ndo_vflag < 1) {
2240 ND_PRINT((ndo, "%s%s",
2241 ndo->ndo_eflag ? "" : ", ",
2242 tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002243
2244 switch (pdu_type) {
2245
2246 case ISIS_PDU_L1_LAN_IIH:
2247 case ISIS_PDU_L2_LAN_IIH:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002248 ND_TCHECK(*header_iih_lan);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002249 ND_PRINT((ndo, ", src-id %s",
2250 isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN)));
2251 ND_PRINT((ndo, ", lan-id %s, prio %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002252 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002253 header_iih_lan->priority));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002254 break;
2255 case ISIS_PDU_PTP_IIH:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002256 ND_TCHECK(*header_iih_ptp);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002257 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002258 break;
2259 case ISIS_PDU_L1_LSP:
2260 case ISIS_PDU_L2_LSP:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002261 ND_TCHECK(*header_lsp);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002262 ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002263 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
2264 EXTRACT_32BITS(header_lsp->sequence_number),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002265 EXTRACT_16BITS(header_lsp->remaining_lifetime)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002266 break;
2267 case ISIS_PDU_L1_CSNP:
2268 case ISIS_PDU_L2_CSNP:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002269 ND_TCHECK(*header_csnp);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002270 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002271 break;
2272 case ISIS_PDU_L1_PSNP:
2273 case ISIS_PDU_L2_PSNP:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002274 ND_TCHECK(*header_psnp);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002275 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002276 break;
2277
2278 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07002279 ND_PRINT((ndo, ", length %u", length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002280
2281 return(1);
2282 }
2283
2284 /* ok they seem to want to know everything - lets fully decode it */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002285 ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002286
Elliott Hughes892a68b2015-10-19 14:43:53 -07002287 ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002288 tok2str(isis_pdu_values,
2289 "unknown, type %u",
2290 pdu_type),
2291 isis_header->fixed_len,
2292 isis_header->version,
2293 isis_header->pdu_version,
2294 id_length,
2295 isis_header->id_length,
2296 max_area,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002297 isis_header->max_area));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002298
Elliott Hughes892a68b2015-10-19 14:43:53 -07002299 if (ndo->ndo_vflag > 1) {
2300 if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002301 return(0); /* for optionally debugging the common header */
2302 }
2303
2304 switch (pdu_type) {
2305
2306 case ISIS_PDU_L1_LAN_IIH:
2307 case ISIS_PDU_L2_LAN_IIH:
2308 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002309 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2310 isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002311 return (0);
2312 }
2313
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002314 ND_TCHECK(*header_iih_lan);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002315 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
2316 if (packet_len>pdu_len) {
2317 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2318 length=pdu_len;
2319 }
2320
Elliott Hughes892a68b2015-10-19 14:43:53 -07002321 ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002322 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
2323 EXTRACT_16BITS(header_iih_lan->holding_time),
2324 tok2str(isis_iih_circuit_type_values,
2325 "unknown circuit type 0x%02x",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002326 header_iih_lan->circuit_type)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002327
Elliott Hughes892a68b2015-10-19 14:43:53 -07002328 ND_PRINT((ndo, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002329 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
2330 (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002331 pdu_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002332
Elliott Hughes892a68b2015-10-19 14:43:53 -07002333 if (ndo->ndo_vflag > 1) {
2334 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE))
2335 return(0);
2336 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002337
2338 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2339 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
2340 break;
2341
2342 case ISIS_PDU_PTP_IIH:
2343 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002344 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2345 isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002346 return (0);
2347 }
2348
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002349 ND_TCHECK(*header_iih_ptp);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002350 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
2351 if (packet_len>pdu_len) {
2352 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2353 length=pdu_len;
2354 }
2355
Elliott Hughes892a68b2015-10-19 14:43:53 -07002356 ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002357 isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
2358 EXTRACT_16BITS(header_iih_ptp->holding_time),
2359 tok2str(isis_iih_circuit_type_values,
2360 "unknown circuit type 0x%02x",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002361 header_iih_ptp->circuit_type)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002362
Elliott Hughes892a68b2015-10-19 14:43:53 -07002363 ND_PRINT((ndo, "\n\t circuit-id: 0x%02x, PDU length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002364 header_iih_ptp->circuit_id,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002365 pdu_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002366
Elliott Hughes892a68b2015-10-19 14:43:53 -07002367 if (ndo->ndo_vflag > 1) {
2368 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE))
2369 return(0);
2370 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002371
2372 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2373 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
2374 break;
2375
2376 case ISIS_PDU_L1_LSP:
2377 case ISIS_PDU_L2_LSP:
2378 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002379 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2380 isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002381 return (0);
2382 }
2383
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002384 ND_TCHECK(*header_lsp);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002385 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
2386 if (packet_len>pdu_len) {
2387 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2388 length=pdu_len;
2389 }
2390
Elliott Hughes892a68b2015-10-19 14:43:53 -07002391 ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002392 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
2393 EXTRACT_32BITS(header_lsp->sequence_number),
2394 EXTRACT_16BITS(header_lsp->remaining_lifetime),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002395 EXTRACT_16BITS(header_lsp->checksum)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002396
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002397 if (osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id,
2398 EXTRACT_16BITS(header_lsp->checksum),
2399 12, length-12) == 0)
2400 goto trunc;
Elliott Hughes892a68b2015-10-19 14:43:53 -07002401
2402 ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002403 pdu_len,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002404 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002405
2406 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002407 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""));
2408 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""));
2409 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""));
2410 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""));
2411 ND_PRINT((ndo, "ATT bit set, "));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002412 }
Elliott Hughes892a68b2015-10-19 14:43:53 -07002413 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""));
2414 ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
2415 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002416
Elliott Hughes892a68b2015-10-19 14:43:53 -07002417 if (ndo->ndo_vflag > 1) {
2418 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE))
2419 return(0);
2420 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002421
2422 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
2423 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
2424 break;
2425
2426 case ISIS_PDU_L1_CSNP:
2427 case ISIS_PDU_L2_CSNP:
2428 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002429 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
2430 isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002431 return (0);
2432 }
2433
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002434 ND_TCHECK(*header_csnp);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002435 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
2436 if (packet_len>pdu_len) {
2437 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2438 length=pdu_len;
2439 }
2440
Elliott Hughes892a68b2015-10-19 14:43:53 -07002441 ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002442 isis_print_id(header_csnp->source_id, NODE_ID_LEN),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002443 pdu_len));
2444 ND_PRINT((ndo, "\n\t start lsp-id: %s",
2445 isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)));
2446 ND_PRINT((ndo, "\n\t end lsp-id: %s",
2447 isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002448
Elliott Hughes892a68b2015-10-19 14:43:53 -07002449 if (ndo->ndo_vflag > 1) {
2450 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
2451 return(0);
2452 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002453
2454 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2455 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
2456 break;
2457
2458 case ISIS_PDU_L1_PSNP:
2459 case ISIS_PDU_L2_PSNP:
2460 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002461 ND_PRINT((ndo, "- bogus fixed header length %u should be %lu",
2462 isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002463 return (0);
2464 }
2465
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002466 ND_TCHECK(*header_psnp);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002467 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
2468 if (packet_len>pdu_len) {
2469 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
2470 length=pdu_len;
2471 }
2472
Elliott Hughes892a68b2015-10-19 14:43:53 -07002473 ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002474 isis_print_id(header_psnp->source_id, NODE_ID_LEN),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002475 pdu_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002476
Elliott Hughes892a68b2015-10-19 14:43:53 -07002477 if (ndo->ndo_vflag > 1) {
2478 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE))
2479 return(0);
2480 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002481
2482 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2483 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
2484 break;
2485
2486 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002487 (void)print_unknown_data(ndo, pptr, "\n\t ", length);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002488 return (0);
2489 }
2490
2491 /*
2492 * Now print the TLV's.
2493 */
2494
2495 while (packet_len >= 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002496 if (pptr == ndo->ndo_snapend) {
2497 return (1);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002498 }
2499
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002500 ND_TCHECK2(*pptr, 2);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002501 tlv_type = *pptr++;
2502 tlv_len = *pptr++;
2503 tmp =tlv_len; /* copy temporary len & pointer to packet data */
2504 tptr = pptr;
2505 packet_len -= 2;
2506 if (tlv_len > packet_len) {
2507 break;
2508 }
2509
2510 /* first lets see if we know the TLVs name*/
Elliott Hughes892a68b2015-10-19 14:43:53 -07002511 ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002512 tok2str(isis_tlv_values,
2513 "unknown",
2514 tlv_type),
2515 tlv_type,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002516 tlv_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002517
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002518 if (tlv_len == 0) /* something is invalid */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002519 continue;
2520
2521 /* now check if we have a decoder otherwise do a hexdump at the end*/
2522 switch (tlv_type) {
2523 case ISIS_TLV_AREA_ADDR:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002524 ND_TCHECK2(*tptr, 1);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002525 alen = *tptr++;
2526 while (tmp && alen < tmp) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002527 ND_PRINT((ndo, "\n\t Area address (length: %u): %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002528 alen,
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002529 isonsap_string(ndo, tptr, alen)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002530 tptr += alen;
2531 tmp -= alen + 1;
2532 if (tmp==0) /* if this is the last area address do not attemt a boundary check */
2533 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002534 ND_TCHECK2(*tptr, 1);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002535 alen = *tptr++;
2536 }
2537 break;
2538 case ISIS_TLV_ISNEIGH:
2539 while (tmp >= ETHER_ADDR_LEN) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002540 ND_TCHECK2(*tptr, ETHER_ADDR_LEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002541 ND_PRINT((ndo, "\n\t SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002542 tmp -= ETHER_ADDR_LEN;
2543 tptr += ETHER_ADDR_LEN;
2544 }
2545 break;
2546
2547 case ISIS_TLV_ISNEIGH_VARLEN:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002548 if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
The Android Open Source Project2949f582009-03-03 19:30:46 -08002549 goto trunctlv;
2550 lan_alen = *tptr++; /* LAN address length */
2551 if (lan_alen == 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002552 ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002553 break;
2554 }
2555 tmp --;
Elliott Hughes892a68b2015-10-19 14:43:53 -07002556 ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002557 while (tmp >= lan_alen) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002558 ND_TCHECK2(*tptr, lan_alen);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002559 ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002560 tmp -= lan_alen;
2561 tptr +=lan_alen;
2562 }
2563 break;
2564
2565 case ISIS_TLV_PADDING:
2566 break;
2567
2568 case ISIS_TLV_MT_IS_REACH:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002569 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
JP Abgrall53f17a92014-02-12 14:02:41 -08002570 if (mt_len == 0) /* did something go wrong ? */
2571 goto trunctlv;
2572 tptr+=mt_len;
2573 tmp-=mt_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002574 while (tmp >= 2+NODE_ID_LEN+3+1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002575 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002576 if (ext_is_len == 0) /* did something go wrong ? */
2577 goto trunctlv;
Elliott Hughes892a68b2015-10-19 14:43:53 -07002578
The Android Open Source Project2949f582009-03-03 19:30:46 -08002579 tmp-=ext_is_len;
2580 tptr+=ext_is_len;
2581 }
2582 break;
2583
2584 case ISIS_TLV_IS_ALIAS_ID:
2585 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002586 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002587 if (ext_is_len == 0) /* did something go wrong ? */
2588 goto trunctlv;
2589 tmp-=ext_is_len;
2590 tptr+=ext_is_len;
2591 }
2592 break;
2593
2594 case ISIS_TLV_EXT_IS_REACH:
2595 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002596 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002597 if (ext_is_len == 0) /* did something go wrong ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002598 goto trunctlv;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002599 tmp-=ext_is_len;
2600 tptr+=ext_is_len;
2601 }
2602 break;
2603 case ISIS_TLV_IS_REACH:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002604 ND_TCHECK2(*tptr,1); /* check if there is one byte left to read out the virtual flag */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002605 ND_PRINT((ndo, "\n\t %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002606 tok2str(isis_is_reach_virtual_values,
2607 "bogus virtual flag 0x%02x",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002608 *tptr++)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002609 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
2610 while (tmp >= sizeof(struct isis_tlv_is_reach)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002611 ND_TCHECK(*tlv_is_reach);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002612 ND_PRINT((ndo, "\n\t IS Neighbor: %s",
2613 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)));
2614 isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002615 tmp -= sizeof(struct isis_tlv_is_reach);
2616 tlv_is_reach++;
2617 }
2618 break;
2619
2620 case ISIS_TLV_ESNEIGH:
2621 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
2622 while (tmp >= sizeof(struct isis_tlv_es_reach)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002623 ND_TCHECK(*tlv_es_reach);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002624 ND_PRINT((ndo, "\n\t ES Neighbor: %s",
2625 isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN)));
2626 isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002627 tmp -= sizeof(struct isis_tlv_es_reach);
2628 tlv_es_reach++;
2629 }
2630 break;
2631
2632 /* those two TLVs share the same format */
2633 case ISIS_TLV_INT_IP_REACH:
2634 case ISIS_TLV_EXT_IP_REACH:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002635 if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len))
2636 return (1);
2637 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002638
2639 case ISIS_TLV_EXTD_IP_REACH:
2640 while (tmp>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002641 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002642 if (ext_ip_len == 0) /* did something go wrong ? */
2643 goto trunctlv;
2644 tptr+=ext_ip_len;
2645 tmp-=ext_ip_len;
2646 }
2647 break;
2648
2649 case ISIS_TLV_MT_IP_REACH:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002650 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
The Android Open Source Project2949f582009-03-03 19:30:46 -08002651 if (mt_len == 0) { /* did something go wrong ? */
2652 goto trunctlv;
2653 }
2654 tptr+=mt_len;
2655 tmp-=mt_len;
2656
2657 while (tmp>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002658 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002659 if (ext_ip_len == 0) /* did something go wrong ? */
2660 goto trunctlv;
2661 tptr+=ext_ip_len;
2662 tmp-=ext_ip_len;
2663 }
2664 break;
2665
The Android Open Source Project2949f582009-03-03 19:30:46 -08002666 case ISIS_TLV_IP6_REACH:
2667 while (tmp>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002668 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002669 if (ext_ip_len == 0) /* did something go wrong ? */
2670 goto trunctlv;
2671 tptr+=ext_ip_len;
2672 tmp-=ext_ip_len;
2673 }
2674 break;
2675
2676 case ISIS_TLV_MT_IP6_REACH:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002677 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
The Android Open Source Project2949f582009-03-03 19:30:46 -08002678 if (mt_len == 0) { /* did something go wrong ? */
2679 goto trunctlv;
2680 }
2681 tptr+=mt_len;
2682 tmp-=mt_len;
2683
2684 while (tmp>0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002685 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002686 if (ext_ip_len == 0) /* did something go wrong ? */
2687 goto trunctlv;
2688 tptr+=ext_ip_len;
2689 tmp-=ext_ip_len;
2690 }
2691 break;
2692
2693 case ISIS_TLV_IP6ADDR:
2694 while (tmp>=sizeof(struct in6_addr)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002695 ND_TCHECK2(*tptr, sizeof(struct in6_addr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002696
Elliott Hughes892a68b2015-10-19 14:43:53 -07002697 ND_PRINT((ndo, "\n\t IPv6 interface address: %s",
2698 ip6addr_string(ndo, tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002699
2700 tptr += sizeof(struct in6_addr);
2701 tmp -= sizeof(struct in6_addr);
2702 }
2703 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002704 case ISIS_TLV_AUTH:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002705 ND_TCHECK2(*tptr, 1);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002706
Elliott Hughes892a68b2015-10-19 14:43:53 -07002707 ND_PRINT((ndo, "\n\t %s: ",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002708 tok2str(isis_subtlv_auth_values,
2709 "unknown Authentication type 0x%02x",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002710 *tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002711
2712 switch (*tptr) {
2713 case ISIS_SUBTLV_AUTH_SIMPLE:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002714 if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
2715 goto trunctlv;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002716 break;
2717 case ISIS_SUBTLV_AUTH_MD5:
2718 for(i=1;i<tlv_len;i++) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002719 ND_TCHECK2(*(tptr + i), 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002720 ND_PRINT((ndo, "%02x", *(tptr + i)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002721 }
2722 if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002723 ND_PRINT((ndo, ", (invalid subTLV) "));
JP Abgrall53f17a92014-02-12 14:02:41 -08002724
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002725 sigcheck = signature_verify(ndo, optr, length, tptr + 1,
2726 isis_clear_checksum_lifetime,
2727 header_lsp);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002728 ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
JP Abgrall53f17a92014-02-12 14:02:41 -08002729
The Android Open Source Project2949f582009-03-03 19:30:46 -08002730 break;
JP Abgrall53f17a92014-02-12 14:02:41 -08002731 case ISIS_SUBTLV_AUTH_GENERIC:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002732 ND_TCHECK2(*(tptr + 1), 2);
JP Abgrall53f17a92014-02-12 14:02:41 -08002733 key_id = EXTRACT_16BITS((tptr+1));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002734 ND_PRINT((ndo, "%u, password: ", key_id));
2735 for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002736 ND_TCHECK2(*(tptr + i), 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002737 ND_PRINT((ndo, "%02x", *(tptr + i)));
JP Abgrall53f17a92014-02-12 14:02:41 -08002738 }
2739 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002740 case ISIS_SUBTLV_AUTH_PRIVATE:
2741 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002742 if (!print_unknown_data(ndo, tptr + 1, "\n\t\t ", tlv_len - 1))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002743 return(0);
2744 break;
2745 }
2746 break;
2747
2748 case ISIS_TLV_PTP_ADJ:
2749 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
2750 if(tmp>=1) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002751 ND_TCHECK2(*tptr, 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002752 ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002753 tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002754 *tptr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002755 tmp--;
2756 }
2757 if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002758 ND_TCHECK(tlv_ptp_adj->extd_local_circuit_id);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002759 ND_PRINT((ndo, "\n\t Extended Local circuit-ID: 0x%08x",
2760 EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002761 tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
2762 }
2763 if(tmp>=SYSTEM_ID_LEN) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002764 ND_TCHECK2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002765 ND_PRINT((ndo, "\n\t Neighbor System-ID: %s",
2766 isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002767 tmp-=SYSTEM_ID_LEN;
2768 }
2769 if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002770 ND_TCHECK(tlv_ptp_adj->neighbor_extd_local_circuit_id);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002771 ND_PRINT((ndo, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2772 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002773 }
2774 break;
2775
2776 case ISIS_TLV_PROTOCOLS:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002777 ND_PRINT((ndo, "\n\t NLPID(s): "));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002778 while (tmp>0) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002779 ND_TCHECK2(*(tptr), 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002780 ND_PRINT((ndo, "%s (0x%02x)",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002781 tok2str(nlpid_values,
2782 "unknown",
2783 *tptr),
Elliott Hughes892a68b2015-10-19 14:43:53 -07002784 *tptr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002785 if (tmp>1) /* further NPLIDs ? - put comma */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002786 ND_PRINT((ndo, ", "));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002787 tptr++;
2788 tmp--;
2789 }
2790 break;
2791
JP Abgrall53f17a92014-02-12 14:02:41 -08002792 case ISIS_TLV_MT_PORT_CAP:
2793 {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002794 ND_TCHECK2(*(tptr), 2);
JP Abgrall53f17a92014-02-12 14:02:41 -08002795
Elliott Hughes892a68b2015-10-19 14:43:53 -07002796 ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
2797 (EXTRACT_16BITS (tptr) >> 12),
2798 (EXTRACT_16BITS (tptr) & 0x0fff)));
JP Abgrall53f17a92014-02-12 14:02:41 -08002799
2800 tmp = tmp-2;
2801 tptr = tptr+2;
2802
2803 if (tmp)
Elliott Hughes892a68b2015-10-19 14:43:53 -07002804 isis_print_mt_port_cap_subtlv(ndo, tptr, tmp);
JP Abgrall53f17a92014-02-12 14:02:41 -08002805
2806 break;
2807 }
2808
2809 case ISIS_TLV_MT_CAPABILITY:
2810
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002811 ND_TCHECK2(*(tptr), 2);
JP Abgrall53f17a92014-02-12 14:02:41 -08002812
Elliott Hughes892a68b2015-10-19 14:43:53 -07002813 ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
JP Abgrall53f17a92014-02-12 14:02:41 -08002814 (EXTRACT_16BITS(tptr) >> 15) & 0x01,
2815 (EXTRACT_16BITS(tptr) >> 12) & 0x07,
Elliott Hughes892a68b2015-10-19 14:43:53 -07002816 EXTRACT_16BITS(tptr) & 0x0fff));
JP Abgrall53f17a92014-02-12 14:02:41 -08002817
2818 tmp = tmp-2;
2819 tptr = tptr+2;
2820
2821 if (tmp)
Elliott Hughes892a68b2015-10-19 14:43:53 -07002822 isis_print_mt_capability_subtlv(ndo, tptr, tmp);
JP Abgrall53f17a92014-02-12 14:02:41 -08002823
2824 break;
2825
The Android Open Source Project2949f582009-03-03 19:30:46 -08002826 case ISIS_TLV_TE_ROUTER_ID:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002827 ND_TCHECK2(*pptr, sizeof(struct in_addr));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002828 ND_PRINT((ndo, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002829 break;
2830
2831 case ISIS_TLV_IPADDR:
2832 while (tmp>=sizeof(struct in_addr)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002833 ND_TCHECK2(*tptr, sizeof(struct in_addr));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002834 ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002835 tptr += sizeof(struct in_addr);
2836 tmp -= sizeof(struct in_addr);
2837 }
2838 break;
2839
2840 case ISIS_TLV_HOSTNAME:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002841 ND_PRINT((ndo, "\n\t Hostname: "));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002842 if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
2843 goto trunctlv;
The Android Open Source Project2949f582009-03-03 19:30:46 -08002844 break;
2845
2846 case ISIS_TLV_SHARED_RISK_GROUP:
2847 if (tmp < NODE_ID_LEN)
2848 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002849 ND_TCHECK2(*tptr, NODE_ID_LEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002850 ND_PRINT((ndo, "\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002851 tptr+=(NODE_ID_LEN);
2852 tmp-=(NODE_ID_LEN);
2853
2854 if (tmp < 1)
2855 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002856 ND_TCHECK2(*tptr, 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002857 ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002858 tmp--;
2859
2860 if (tmp < sizeof(struct in_addr))
2861 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002862 ND_TCHECK2(*tptr, sizeof(struct in_addr));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002863 ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002864 tptr+=sizeof(struct in_addr);
2865 tmp-=sizeof(struct in_addr);
2866
2867 if (tmp < sizeof(struct in_addr))
2868 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002869 ND_TCHECK2(*tptr, sizeof(struct in_addr));
Elliott Hughes892a68b2015-10-19 14:43:53 -07002870 ND_PRINT((ndo, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo, tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002871 tptr+=sizeof(struct in_addr);
2872 tmp-=sizeof(struct in_addr);
2873
2874 while (tmp>=4) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002875 ND_TCHECK2(*tptr, 4);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002876 ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002877 tptr+=4;
2878 tmp-=4;
2879 }
2880 break;
2881
2882 case ISIS_TLV_LSP:
2883 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
2884 while(tmp>=sizeof(struct isis_tlv_lsp)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002885 ND_TCHECK((tlv_lsp->lsp_id)[LSP_ID_LEN-1]);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002886 ND_PRINT((ndo, "\n\t lsp-id: %s",
2887 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002888 ND_TCHECK2(tlv_lsp->sequence_number, 4);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002889 ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002890 ND_TCHECK2(tlv_lsp->remaining_lifetime, 2);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002891 ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002892 ND_TCHECK2(tlv_lsp->checksum, 2);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002893 ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002894 tmp-=sizeof(struct isis_tlv_lsp);
2895 tlv_lsp++;
2896 }
2897 break;
2898
2899 case ISIS_TLV_CHECKSUM:
2900 if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
2901 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002902 ND_TCHECK2(*tptr, ISIS_TLV_CHECKSUM_MINLEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002903 ND_PRINT((ndo, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002904 /* do not attempt to verify the checksum if it is zero
2905 * most likely a HMAC-MD5 TLV is also present and
2906 * to avoid conflicts the checksum TLV is zeroed.
2907 * see rfc3358 for details
2908 */
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002909 if (osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr,
2910 length) == 0)
2911 goto trunc;
2912 break;
2913
2914 case ISIS_TLV_POI:
2915 if (tlv_len >= SYSTEM_ID_LEN + 1) {
2916 ND_TCHECK2(*tptr, SYSTEM_ID_LEN + 1);
2917 ND_PRINT((ndo, "\n\t Purge Originator System-ID: %s",
2918 isis_print_id(tptr + 1, SYSTEM_ID_LEN)));
2919 }
2920
2921 if (tlv_len == 2 * SYSTEM_ID_LEN + 1) {
2922 ND_TCHECK2(*tptr, 2 * SYSTEM_ID_LEN + 1);
2923 ND_PRINT((ndo, "\n\t Received from System-ID: %s",
2924 isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN)));
2925 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002926 break;
2927
2928 case ISIS_TLV_MT_SUPPORTED:
2929 if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN)
2930 break;
2931 while (tmp>1) {
2932 /* length can only be a multiple of 2, otherwise there is
2933 something broken -> so decode down until length is 1 */
2934 if (tmp!=1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07002935 mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
The Android Open Source Project2949f582009-03-03 19:30:46 -08002936 if (mt_len == 0) /* did something go wrong ? */
2937 goto trunctlv;
2938 tptr+=mt_len;
2939 tmp-=mt_len;
2940 } else {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002941 ND_PRINT((ndo, "\n\t invalid MT-ID"));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002942 break;
2943 }
2944 }
2945 break;
2946
2947 case ISIS_TLV_RESTART_SIGNALING:
2948 /* first attempt to decode the flags */
2949 if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
2950 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002951 ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002952 ND_PRINT((ndo, "\n\t Flags [%s]",
2953 bittok2str(isis_restart_flag_values, "none", *tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002954 tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
2955 tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
2956
2957 /* is there anything other than the flags field? */
2958 if (tmp == 0)
2959 break;
2960
2961 if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
2962 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002963 ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN);
The Android Open Source Project2949f582009-03-03 19:30:46 -08002964
Elliott Hughes892a68b2015-10-19 14:43:53 -07002965 ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002966 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
2967 tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
2968
2969 /* is there an additional sysid field present ?*/
2970 if (tmp == SYSTEM_ID_LEN) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002971 ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002972 ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
2973 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08002974 break;
2975
2976 case ISIS_TLV_IDRP_INFO:
2977 if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
2978 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002979 ND_TCHECK2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07002980 ND_PRINT((ndo, "\n\t Inter-Domain Information Type: %s",
The Android Open Source Project2949f582009-03-03 19:30:46 -08002981 tok2str(isis_subtlv_idrp_values,
2982 "Unknown (0x%02x)",
Elliott Hughes892a68b2015-10-19 14:43:53 -07002983 *tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002984 switch (*tptr++) {
2985 case ISIS_SUBTLV_IDRP_ASN:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07002986 ND_TCHECK2(*tptr, 2); /* fetch AS number */
Elliott Hughes892a68b2015-10-19 14:43:53 -07002987 ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08002988 break;
2989 case ISIS_SUBTLV_IDRP_LOCAL:
2990 case ISIS_SUBTLV_IDRP_RES:
2991 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07002992 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_len - 1))
The Android Open Source Project2949f582009-03-03 19:30:46 -08002993 return(0);
2994 break;
2995 }
2996 break;
2997
2998 case ISIS_TLV_LSP_BUFFERSIZE:
2999 if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
3000 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003001 ND_TCHECK2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07003002 ND_PRINT((ndo, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003003 break;
3004
3005 case ISIS_TLV_PART_DIS:
3006 while (tmp >= SYSTEM_ID_LEN) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003007 ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
Elliott Hughes892a68b2015-10-19 14:43:53 -07003008 ND_PRINT((ndo, "\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003009 tptr+=SYSTEM_ID_LEN;
3010 tmp-=SYSTEM_ID_LEN;
3011 }
3012 break;
3013
3014 case ISIS_TLV_PREFIX_NEIGH:
3015 if (tmp < sizeof(struct isis_metric_block))
3016 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003017 ND_TCHECK2(*tptr, sizeof(struct isis_metric_block));
Elliott Hughes892a68b2015-10-19 14:43:53 -07003018 ND_PRINT((ndo, "\n\t Metric Block"));
3019 isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
The Android Open Source Project2949f582009-03-03 19:30:46 -08003020 tptr+=sizeof(struct isis_metric_block);
3021 tmp-=sizeof(struct isis_metric_block);
3022
3023 while(tmp>0) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003024 ND_TCHECK2(*tptr, 1);
The Android Open Source Project2949f582009-03-03 19:30:46 -08003025 prefix_len=*tptr++; /* read out prefix length in semioctets*/
3026 if (prefix_len < 2) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07003027 ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003028 break;
3029 }
3030 tmp--;
3031 if (tmp < prefix_len/2)
3032 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003033 ND_TCHECK2(*tptr, prefix_len / 2);
Elliott Hughes892a68b2015-10-19 14:43:53 -07003034 ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003035 isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003036 tptr+=prefix_len/2;
3037 tmp-=prefix_len/2;
3038 }
3039 break;
3040
3041 case ISIS_TLV_IIH_SEQNR:
3042 if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
3043 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003044 ND_TCHECK2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN); /* check if four bytes are on the wire */
Elliott Hughes892a68b2015-10-19 14:43:53 -07003045 ND_PRINT((ndo, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003046 break;
3047
3048 case ISIS_TLV_VENDOR_PRIVATE:
3049 if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
3050 break;
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003051 ND_TCHECK2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN); /* check if enough byte for a full oui */
The Android Open Source Project2949f582009-03-03 19:30:46 -08003052 vendor_id = EXTRACT_24BITS(tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -07003053 ND_PRINT((ndo, "\n\t Vendor: %s (%u)",
3054 tok2str(oui_values, "Unknown", vendor_id),
3055 vendor_id));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003056 tptr+=3;
3057 tmp-=3;
3058 if (tmp > 0) /* hexdump the rest */
Elliott Hughes892a68b2015-10-19 14:43:53 -07003059 if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp))
The Android Open Source Project2949f582009-03-03 19:30:46 -08003060 return(0);
3061 break;
3062 /*
3063 * FIXME those are the defined TLVs that lack a decoder
3064 * you are welcome to contribute code ;-)
3065 */
3066
3067 case ISIS_TLV_DECNET_PHASE4:
3068 case ISIS_TLV_LUCENT_PRIVATE:
3069 case ISIS_TLV_IPAUTH:
3070 case ISIS_TLV_NORTEL_PRIVATE1:
3071 case ISIS_TLV_NORTEL_PRIVATE2:
3072
3073 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -07003074 if (ndo->ndo_vflag <= 1) {
3075 if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
3076 return(0);
3077 }
3078 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -08003079 }
3080 /* do we want to see an additionally hexdump ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -07003081 if (ndo->ndo_vflag> 1) {
3082 if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len))
3083 return(0);
3084 }
The Android Open Source Project2949f582009-03-03 19:30:46 -08003085
3086 pptr += tlv_len;
3087 packet_len -= tlv_len;
3088 }
3089
3090 if (packet_len != 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07003091 ND_PRINT((ndo, "\n\t %u straggler bytes", packet_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003092 }
3093 return (1);
3094
3095 trunc:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003096 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003097 return (1);
3098
3099 trunctlv:
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003100 ND_PRINT((ndo, "\n\t\t"));
3101 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08003102 return(1);
3103}
3104
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003105static int
Aurimas Liutikasba29be72016-05-10 12:28:35 -07003106osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
3107 uint16_t checksum, int checksum_offset, int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -08003108{
Elliott Hughes892a68b2015-10-19 14:43:53 -07003109 uint16_t calculated_checksum;
The Android Open Source Project2949f582009-03-03 19:30:46 -08003110
Elliott Hughes892a68b2015-10-19 14:43:53 -07003111 /* do not attempt to verify the checksum if it is zero,
3112 * if the total length is nonsense,
3113 * if the offset is nonsense,
3114 * or the base pointer is not sane
3115 */
3116 if (!checksum
Aurimas Liutikasba29be72016-05-10 12:28:35 -07003117 || length < 0
3118 || checksum_offset < 0
Elliott Hughes892a68b2015-10-19 14:43:53 -07003119 || length > ndo->ndo_snaplen
3120 || checksum_offset > ndo->ndo_snaplen
3121 || checksum_offset > length) {
Aurimas Liutikas6af45812016-05-10 13:01:22 -07003122 ND_PRINT((ndo, " (unverified)"));
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003123 return 1;
JP Abgrall53f17a92014-02-12 14:02:41 -08003124 } else {
Elliott Hughes892a68b2015-10-19 14:43:53 -07003125#if 0
3126 printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen);
Elliott Hughes892a68b2015-10-19 14:43:53 -07003127#endif
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003128 ND_TCHECK2(*pptr, length);
JP Abgrall53f17a92014-02-12 14:02:41 -08003129 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
3130 if (checksum == calculated_checksum) {
Elliott Hughes892a68b2015-10-19 14:43:53 -07003131 ND_PRINT((ndo, " (correct)"));
JP Abgrall53f17a92014-02-12 14:02:41 -08003132 } else {
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003133 ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
JP Abgrall53f17a92014-02-12 14:02:41 -08003134 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003135 return 1;
JP Abgrall53f17a92014-02-12 14:02:41 -08003136 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -07003137trunc:
3138 return 0;
The Android Open Source Project2949f582009-03-03 19:30:46 -08003139}
3140
The Android Open Source Project2949f582009-03-03 19:30:46 -08003141/*
3142 * Local Variables:
3143 * c-style: whitesmith
3144 * c-basic-offset: 8
3145 * End:
3146 */