2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
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
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.
21 * Original code by Matt Thomas, Digital Equipment Corporation
23 * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
24 * complete IS-IS & CLNP support.
30 static const char rcsid[] _U_ =
31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133 2005/04/06 21:32:40 mcr Exp $ (LBL)";
38 #include <tcpdump-stdinc.h>
43 #include "interface.h"
44 #include "addrtoname.h"
45 #include "ethertype.h"
52 #define IPV4 1 /* AFI value */
53 #define IPV6 2 /* AFI value */
56 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
59 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
60 #define NODE_ID_LEN SYSTEM_ID_LEN+1
61 #define LSP_ID_LEN SYSTEM_ID_LEN+2
63 #define ISIS_VERSION 1
64 #define ESIS_VERSION 1
65 #define CLNP_VERSION 1
67 #define ISIS_PDU_TYPE_MASK 0x1F
68 #define ESIS_PDU_TYPE_MASK 0x1F
69 #define CLNP_PDU_TYPE_MASK 0x1F
70 #define CLNP_FLAG_MASK 0xE0
71 #define ISIS_LAN_PRIORITY_MASK 0x7F
73 #define ISIS_PDU_L1_LAN_IIH 15
74 #define ISIS_PDU_L2_LAN_IIH 16
75 #define ISIS_PDU_PTP_IIH 17
76 #define ISIS_PDU_L1_LSP 18
77 #define ISIS_PDU_L2_LSP 20
78 #define ISIS_PDU_L1_CSNP 24
79 #define ISIS_PDU_L2_CSNP 25
80 #define ISIS_PDU_L1_PSNP 26
81 #define ISIS_PDU_L2_PSNP 27
83 static struct tok isis_pdu_values[] = {
84 { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
85 { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
86 { ISIS_PDU_PTP_IIH, "p2p IIH"},
87 { ISIS_PDU_L1_LSP, "L1 LSP"},
88 { ISIS_PDU_L2_LSP, "L2 LSP"},
89 { ISIS_PDU_L1_CSNP, "L1 CSNP"},
90 { ISIS_PDU_L2_CSNP, "L2 CSNP"},
91 { ISIS_PDU_L1_PSNP, "L1 PSNP"},
92 { ISIS_PDU_L2_PSNP, "L2 PSNP"},
97 * A TLV is a tuple of a type, length and a value and is normally used for
98 * encoding information in all sorts of places. This is an enumeration of
99 * the well known types.
101 * list taken from rfc3359 plus some memory from veterans ;-)
104 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
105 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
106 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
107 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
108 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
109 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
110 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
111 #define ISIS_TLV_PADDING 8 /* iso10589 */
112 #define ISIS_TLV_LSP 9 /* iso10589 */
113 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
114 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
115 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
116 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
117 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
118 #define ISIS_TLV_DECNET_PHASE4 42
119 #define ISIS_TLV_LUCENT_PRIVATE 66
120 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
121 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
122 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
123 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
124 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
125 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
126 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
127 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
128 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
129 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
130 #define ISIS_TLV_NORTEL_PRIVATE1 176
131 #define ISIS_TLV_NORTEL_PRIVATE2 177
132 #define ISIS_TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
133 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
134 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
135 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
136 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
137 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
138 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
139 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
140 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
141 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
143 static struct tok isis_tlv_values[] = {
144 { ISIS_TLV_AREA_ADDR, "Area address(es)"},
145 { ISIS_TLV_IS_REACH, "IS Reachability"},
146 { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
147 { ISIS_TLV_PART_DIS, "Partition DIS"},
148 { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
149 { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
150 { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
151 { ISIS_TLV_PADDING, "Padding"},
152 { ISIS_TLV_LSP, "LSP entries"},
153 { ISIS_TLV_AUTH, "Authentication"},
154 { ISIS_TLV_CHECKSUM, "Checksum"},
155 { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
156 { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
157 { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
158 { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
159 { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
160 { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
161 { ISIS_TLV_PROTOCOLS, "Protocols supported"},
162 { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
163 { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
164 { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
165 { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
166 { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
167 { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
168 { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
169 { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
170 { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
171 { ISIS_TLV_HOSTNAME, "Hostname"},
172 { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
173 { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
174 { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
175 { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
176 { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
177 { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
178 { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
179 { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
180 { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
181 { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
185 #define ESIS_OPTION_PROTOCOLS 129
186 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
187 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
188 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
189 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
190 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
191 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
193 static struct tok esis_option_values[] = {
194 { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
195 { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
196 { ESIS_OPTION_SECURITY, "Security" },
197 { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
198 { ESIS_OPTION_PRIORITY, "Priority" },
199 { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
200 { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
204 #define CLNP_OPTION_DISCARD_REASON 193
205 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
206 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
208 static struct tok clnp_option_values[] = {
209 { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
210 { CLNP_OPTION_PRIORITY, "Priority"},
211 { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
215 static struct tok clnp_option_rfd_class_values[] = {
218 { 0x9, "Source Routeing"},
220 { 0xb, "PDU Discarded"},
221 { 0xc, "Reassembly"},
225 static struct tok clnp_option_rfd_general_values[] = {
226 { 0x0, "Reason not specified"},
227 { 0x1, "Protocol procedure error"},
228 { 0x2, "Incorrect checksum"},
229 { 0x3, "PDU discarded due to congestion"},
230 { 0x4, "Header syntax error (cannot be parsed)"},
231 { 0x5, "Segmentation needed but not permitted"},
232 { 0x6, "Incomplete PDU received"},
233 { 0x7, "Duplicate option"},
237 static struct tok clnp_option_rfd_address_values[] = {
238 { 0x0, "Destination address unreachable"},
239 { 0x1, "Destination address unknown"},
243 static struct tok clnp_option_rfd_source_routeing_values[] = {
244 { 0x0, "Unspecified source routeing error"},
245 { 0x1, "Syntax error in source routeing field"},
246 { 0x2, "Unknown address in source routeing field"},
247 { 0x3, "Path not acceptable"},
251 static struct tok clnp_option_rfd_lifetime_values[] = {
252 { 0x0, "Lifetime expired while data unit in transit"},
253 { 0x1, "Lifetime expired during reassembly"},
257 static struct tok clnp_option_rfd_pdu_discard_values[] = {
258 { 0x0, "Unsupported option not specified"},
259 { 0x1, "Unsupported protocol version"},
260 { 0x2, "Unsupported security option"},
261 { 0x3, "Unsupported source routeing option"},
262 { 0x4, "Unsupported recording of route option"},
266 static struct tok clnp_option_rfd_reassembly_values[] = {
267 { 0x0, "Reassembly interference"},
271 /* array of 16 error-classes */
272 static struct tok *clnp_option_rfd_error_class[] = {
273 clnp_option_rfd_general_values,
281 clnp_option_rfd_address_values,
282 clnp_option_rfd_source_routeing_values,
283 clnp_option_rfd_lifetime_values,
284 clnp_option_rfd_pdu_discard_values,
285 clnp_option_rfd_reassembly_values,
292 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
293 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
294 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
295 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
296 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
297 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
298 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
299 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
300 #define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE 12 /* draft-ietf-tewg-diff-te-proto-06 */
301 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
302 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
303 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
305 static struct tok isis_ext_is_reach_subtlv_values[] = {
306 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
307 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
308 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
309 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
310 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
311 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
312 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
313 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
314 { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE, "Diffserv TE" },
315 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
316 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
317 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
318 { 250, "Reserved for cisco specific extensions" },
319 { 251, "Reserved for cisco specific extensions" },
320 { 252, "Reserved for cisco specific extensions" },
321 { 253, "Reserved for cisco specific extensions" },
322 { 254, "Reserved for cisco specific extensions" },
323 { 255, "Reserved for future expansion" },
327 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
328 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
329 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
331 static struct tok isis_ext_ip_reach_subtlv_values[] = {
332 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
333 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
334 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
338 #define ISIS_SUBTLV_AUTH_SIMPLE 1
339 #define ISIS_SUBTLV_AUTH_MD5 54
340 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
341 #define ISIS_SUBTLV_AUTH_PRIVATE 255
343 static struct tok isis_subtlv_auth_values[] = {
344 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
345 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
346 { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
350 #define ISIS_SUBTLV_IDRP_RES 0
351 #define ISIS_SUBTLV_IDRP_LOCAL 1
352 #define ISIS_SUBTLV_IDRP_ASN 2
354 static struct tok isis_subtlv_idrp_values[] = {
355 { ISIS_SUBTLV_IDRP_RES, "Reserved"},
356 { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
357 { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
361 #define CLNP_SEGMENT_PART 0x80
362 #define CLNP_MORE_SEGMENTS 0x40
363 #define CLNP_REQUEST_ER 0x20
365 static struct tok clnp_flag_values[] = {
366 { CLNP_SEGMENT_PART, "Segmentation permitted"},
367 { CLNP_MORE_SEGMENTS, "more Segments"},
368 { CLNP_REQUEST_ER, "request Error Report"},
372 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
373 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
374 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
375 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
376 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
377 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
378 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
379 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
381 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
382 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
384 static struct tok isis_mt_flag_values[] = {
385 { 0x4000, "sub-TLVs present"},
386 { 0x8000, "ATT bit set"},
390 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
391 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
393 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
394 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
396 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
397 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
398 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
399 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
401 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
403 static struct tok isis_mt_values[] = {
404 { 0, "IPv4 unicast"},
405 { 1, "In-Band Management"},
406 { 2, "IPv6 unicast"},
408 { 4095, "Development, Experimental or Proprietary"},
412 static struct tok isis_iih_circuit_type_values[] = {
413 { 1, "Level 1 only"},
414 { 2, "Level 2 only"},
415 { 3, "Level 1, Level 2"},
419 #define ISIS_LSP_TYPE_UNUSED0 0
420 #define ISIS_LSP_TYPE_LEVEL_1 1
421 #define ISIS_LSP_TYPE_UNUSED2 2
422 #define ISIS_LSP_TYPE_LEVEL_2 3
424 static struct tok isis_lsp_istype_values[] = {
425 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
426 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
427 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
428 { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"},
433 * Katz's point to point adjacency TLV uses codes to tell us the state of
434 * the remote adjacency. Enumerate them.
437 #define ISIS_PTP_ADJ_UP 0
438 #define ISIS_PTP_ADJ_INIT 1
439 #define ISIS_PTP_ADJ_DOWN 2
441 static struct tok isis_ptp_adjancey_values[] = {
442 { ISIS_PTP_ADJ_UP, "Up" },
443 { ISIS_PTP_ADJ_INIT, "Initializing" },
444 { ISIS_PTP_ADJ_DOWN, "Down" },
448 struct isis_tlv_ptp_adj {
449 u_int8_t adjacency_state;
450 u_int8_t extd_local_circuit_id[4];
451 u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
452 u_int8_t neighbor_extd_local_circuit_id[4];
455 static int osi_cksum(const u_int8_t *, u_int);
456 static int clnp_print(const u_int8_t *, u_int);
457 static void esis_print(const u_int8_t *, u_int);
458 static int isis_print(const u_int8_t *, u_int);
460 struct isis_metric_block {
461 u_int8_t metric_default;
462 u_int8_t metric_delay;
463 u_int8_t metric_expense;
464 u_int8_t metric_error;
467 struct isis_tlv_is_reach {
468 struct isis_metric_block isis_metric_block;
469 u_int8_t neighbor_nodeid[NODE_ID_LEN];
472 struct isis_tlv_es_reach {
473 struct isis_metric_block isis_metric_block;
474 u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
477 struct isis_tlv_ip_reach {
478 struct isis_metric_block isis_metric_block;
483 static struct tok isis_is_reach_virtual_values[] = {
484 { 0, "IsNotVirtual"},
489 static struct tok isis_restart_flag_values[] = {
490 { 0x1, "Restart Request"},
491 { 0x2, "Restart Acknowledgement"},
495 struct isis_common_header {
498 u_int8_t version; /* Protocol version */
500 u_int8_t pdu_type; /* 3 MSbits are reserved */
501 u_int8_t pdu_version; /* Packet format version */
506 struct isis_iih_lan_header {
507 u_int8_t circuit_type;
508 u_int8_t source_id[SYSTEM_ID_LEN];
509 u_int8_t holding_time[2];
512 u_int8_t lan_id[NODE_ID_LEN];
515 struct isis_iih_ptp_header {
516 u_int8_t circuit_type;
517 u_int8_t source_id[SYSTEM_ID_LEN];
518 u_int8_t holding_time[2];
523 struct isis_lsp_header {
525 u_int8_t remaining_lifetime[2];
526 u_int8_t lsp_id[LSP_ID_LEN];
527 u_int8_t sequence_number[4];
528 u_int8_t checksum[2];
532 struct isis_csnp_header {
534 u_int8_t source_id[NODE_ID_LEN];
535 u_int8_t start_lsp_id[LSP_ID_LEN];
536 u_int8_t end_lsp_id[LSP_ID_LEN];
539 struct isis_psnp_header {
541 u_int8_t source_id[NODE_ID_LEN];
544 struct isis_tlv_lsp {
545 u_int8_t remaining_lifetime[2];
546 u_int8_t lsp_id[LSP_ID_LEN];
547 u_int8_t sequence_number[4];
548 u_int8_t checksum[2];
551 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
552 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
553 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
554 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
555 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
556 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
558 void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
560 const struct isis_common_header *header;
562 header = (const struct isis_common_header *)p;
564 if (caplen <= 1) { /* enough bytes on the wire ? */
570 printf("OSI NLPID %s (0x%02x): ",
571 tok2str(nlpid_values,"Unknown",*p),
577 if (!clnp_print(p, length))
578 print_unknown_data(p,"\n\t",caplen);
582 esis_print(p, length);
586 if (!isis_print(p, length))
587 print_unknown_data(p,"\n\t",caplen);
591 (void)printf(", length: %u", length);
595 q933_print(p+1, length-1);
599 ip_print(gndo, p+1, length-1);
604 ip6_print(p+1, length-1);
609 ppp_print(p+1, length-1);
614 printf("OSI NLPID 0x%02x unknown",*p);
615 (void)printf(", length: %u", length);
617 print_unknown_data(p,"\n\t",caplen);
622 #define CLNP_PDU_ER 1
623 #define CLNP_PDU_DT 28
624 #define CLNP_PDU_MD 29
625 #define CLNP_PDU_ERQ 30
626 #define CLNP_PDU_ERP 31
628 static struct tok clnp_pdu_values[] = {
629 { CLNP_PDU_ER, "Error Report"},
630 { CLNP_PDU_MD, "MD"},
631 { CLNP_PDU_DT, "Data"},
632 { CLNP_PDU_ERQ, "Echo Request"},
633 { CLNP_PDU_ERP, "Echo Response"},
637 struct clnp_header_t {
639 u_int8_t length_indicator;
641 u_int8_t lifetime; /* units of 500ms */
643 u_int8_t segment_length[2];
647 struct clnp_segment_header_t {
648 u_int8_t data_unit_id[2];
649 u_int8_t segment_offset[2];
650 u_int8_t total_length[2];
655 * Decode CLNP packets. Return 0 on error.
658 static int clnp_print (const u_int8_t *pptr, u_int length)
660 const u_int8_t *optr,*source_address,*dest_address;
661 u_int li,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
662 const struct clnp_header_t *clnp_header;
663 const struct clnp_segment_header_t *clnp_segment_header;
664 u_int8_t rfd_error_major,rfd_error_minor;
666 clnp_header = (const struct clnp_header_t *) pptr;
667 TCHECK(*clnp_header);
669 li = clnp_header->length_indicator;
676 * Sanity checking of the header.
679 if (clnp_header->version != CLNP_VERSION) {
680 printf("version %d packet not supported", clnp_header->version);
684 /* FIXME further header sanity checking */
686 clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
687 clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
689 pptr += sizeof(struct clnp_header_t);
690 li -= sizeof(struct clnp_header_t);
691 dest_address_length = *pptr;
692 dest_address = pptr + 1;
694 pptr += (1 + dest_address_length);
695 li -= (1 + dest_address_length);
696 source_address_length = *pptr;
697 source_address = pptr +1;
699 pptr += (1 + source_address_length);
700 li -= (1 + source_address_length);
703 printf("%s%s > %s, %s, length %u",
705 isonsap_string(source_address, source_address_length),
706 isonsap_string(dest_address, dest_address_length),
707 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
711 printf("%slength %u",eflag ? "" : ", ",length);
713 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ",
714 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
715 clnp_header->length_indicator,
716 clnp_header->version,
717 clnp_header->lifetime/2,
718 (clnp_header->lifetime%2)*5,
719 EXTRACT_16BITS(clnp_header->segment_length),
720 EXTRACT_16BITS(clnp_header->cksum));
722 /* do not attempt to verify the checksum if it is zero */
723 if (EXTRACT_16BITS(clnp_header->cksum) == 0)
724 printf("(unverified)");
725 else printf("(%s)", osi_cksum(optr, clnp_header->length_indicator) ? "incorrect" : "correct");
727 printf("\n\tFlags [%s]",
728 bittok2str(clnp_flag_values,"none",clnp_flags));
730 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
731 source_address_length,
732 isonsap_string(source_address, source_address_length),
734 isonsap_string(dest_address,dest_address_length));
736 if (clnp_flags & CLNP_SEGMENT_PART) {
737 clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
738 printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
739 EXTRACT_16BITS(clnp_segment_header->data_unit_id),
740 EXTRACT_16BITS(clnp_segment_header->segment_offset),
741 EXTRACT_16BITS(clnp_segment_header->total_length));
742 pptr+=sizeof(const struct clnp_segment_header_t);
743 li-=sizeof(const struct clnp_segment_header_t);
746 /* now walk the options */
749 const u_int8_t *tptr;
751 if (snapend - pptr < 2)
754 printf(", bad opts/li");
761 printf(", opt (%d) too long", op);
770 printf("\n\t %s Option #%u, length %u, value: ",
771 tok2str(clnp_option_values,"Unknown",op),
777 case CLNP_OPTION_PRIORITY:
781 case CLNP_OPTION_DISCARD_REASON:
782 rfd_error_major = (*tptr&0xf0) >> 4;
783 rfd_error_minor = *tptr&0x0f;
784 printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
785 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
787 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
792 * FIXME those are the defined Options that lack a decoder
793 * you are welcome to contribute code ;-)
797 print_unknown_data(tptr,"\n\t ",opli);
801 print_unknown_data(pptr,"\n\t ",opli);
805 switch (clnp_pdu_type) {
807 case CLNP_PDU_ER: /* fall through */
809 if (*(pptr) == NLPID_CLNP) {
810 printf("\n\t-----original packet-----\n\t");
811 /* FIXME recursion protection */
812 clnp_print(pptr, length-clnp_header->length_indicator);
821 /* dump the PDU specific data */
822 if (length-(pptr-optr) > 0) {
823 printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator);
824 print_unknown_data(pptr,"\n\t ",length-(pptr-optr));
831 fputs("[|clnp]", stdout);
837 #define ESIS_PDU_REDIRECT 6
838 #define ESIS_PDU_ESH 2
839 #define ESIS_PDU_ISH 4
841 static struct tok esis_pdu_values[] = {
842 { ESIS_PDU_REDIRECT, "redirect"},
843 { ESIS_PDU_ESH, "ESH"},
844 { ESIS_PDU_ISH, "ISH"},
848 struct esis_header_t {
850 u_int8_t length_indicator;
854 u_int8_t holdtime[2];
859 esis_print(const u_int8_t *pptr, u_int length)
861 const u_int8_t *optr;
862 u_int li,esis_pdu_type,source_address_length, source_address_number;
863 const struct esis_header_t *esis_header;
872 printf("no header at all!");
876 esis_header = (const struct esis_header_t *) pptr;
877 li = esis_header->length_indicator;
881 * Sanity checking of the header.
884 if (esis_header->nlpid != NLPID_ESIS) {
885 printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
889 if (esis_header->version != ESIS_VERSION) {
890 printf(" version %d packet not supported", esis_header->version);
895 printf(" length indicator(%d) > PDU size (%d)!", li, length);
899 if (li < sizeof(struct esis_header_t) + 2) {
900 printf(" length indicator < min PDU size %d:", li);
901 while (--length != 0)
902 printf("%02X", *pptr++);
906 esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
909 printf("%s%s, length %u",
911 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
915 printf("%slength %u\n\t%s (%u)",
918 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
921 printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
922 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header->cksum));
923 /* do not attempt to verify the checksum if it is zero */
924 if (EXTRACT_16BITS(esis_header->cksum) == 0)
925 printf("(unverified)");
926 else printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct");
928 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
931 print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
933 pptr += sizeof(struct esis_header_t);
934 li -= sizeof(struct esis_header_t);
936 switch (esis_pdu_type) {
937 case ESIS_PDU_REDIRECT: {
938 const u_int8_t *dst, *snpa, *tptr;
940 dst = pptr; pptr += *pptr + 1;
943 printf("\n\t %s", isonsap_string(dst+1,*dst));
944 snpa = pptr; pptr += *pptr + 1;
945 tptr = pptr; pptr += *pptr + 1;
950 printf("\n\t %s", etheraddr_string(&snpa[1]));
952 printf("\n\t %s", isonsap_string(tptr+1,*tptr));
957 source_address_number = *pptr;
961 printf("\n\t Number of Source Addresses: %u", source_address_number);
963 while (source_address_number > 0) {
964 source_address_length = *pptr;
965 printf("\n\t NET (length: %u): %s",
966 source_address_length,
967 isonsap_string(pptr+1,source_address_length));
969 pptr += source_address_length+1;
970 li -= source_address_length+1;
971 source_address_number--;
977 source_address_length = *pptr;
978 printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr+1, source_address_length));
979 pptr += source_address_length+1;
980 li -= source_address_length +1;
987 print_unknown_data(pptr,"\n\t ",snapend-pptr);
992 /* now walk the options */
995 const u_int8_t *tptr;
997 if (snapend - pptr < 2)
1000 printf(", bad opts/li");
1007 printf(", opt (%d) too long", op);
1016 printf("\n\t %s Option #%u, length %u, value: ",
1017 tok2str(esis_option_values,"Unknown",op),
1023 case ESIS_OPTION_ES_CONF_TIME:
1024 printf("%us", EXTRACT_16BITS(tptr));
1028 case ESIS_OPTION_PROTOCOLS:
1030 printf("%s (0x%02x)",
1031 tok2str(nlpid_values,
1035 if (opli>1) /* further NPLIDs ? - put comma */
1043 * FIXME those are the defined Options that lack a decoder
1044 * you are welcome to contribute code ;-)
1047 case ESIS_OPTION_QOS_MAINTENANCE:
1048 case ESIS_OPTION_SECURITY:
1049 case ESIS_OPTION_PRIORITY:
1050 case ESIS_OPTION_ADDRESS_MASK:
1051 case ESIS_OPTION_SNPA_MASK:
1054 print_unknown_data(tptr,"\n\t ",opli);
1058 print_unknown_data(pptr,"\n\t ",opli);
1063 /* shared routine for printing system, node and lsp-ids */
1065 isis_print_id(const u_int8_t *cp, int id_len)
1068 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1071 for (i = 1; i <= SYSTEM_ID_LEN; i++) {
1072 snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++);
1074 if (i == 2 || i == 4)
1077 if (id_len >= NODE_ID_LEN) {
1078 snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++);
1081 if (id_len == LSP_ID_LEN)
1082 snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp);
1086 /* print the 4-byte metric block which is common found in the old-style TLVs */
1088 isis_print_metric_block (const struct isis_metric_block *isis_metric_block)
1090 printf(", Default Metric: %d, %s",
1091 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
1092 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal");
1093 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
1094 printf("\n\t\t Delay Metric: %d, %s",
1095 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
1096 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal");
1097 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
1098 printf("\n\t\t Expense Metric: %d, %s",
1099 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
1100 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal");
1101 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
1102 printf("\n\t\t Error Metric: %d, %s",
1103 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
1104 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal");
1106 return(1); /* everything is ok */
1110 isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
1113 const struct isis_tlv_ip_reach *tlv_ip_reach;
1115 tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
1117 while (length > 0) {
1118 if ((size_t)length < sizeof(*tlv_ip_reach)) {
1119 printf("short IPv4 Reachability (%d vs %lu)",
1121 (unsigned long)sizeof(*tlv_ip_reach));
1125 if (!TTEST(*tlv_ip_reach))
1128 prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
1130 if (prefix_len == -1)
1131 printf("%sIPv4 prefix: %s mask %s",
1133 ipaddr_string((tlv_ip_reach->prefix)),
1134 ipaddr_string((tlv_ip_reach->mask)));
1136 printf("%sIPv4 prefix: %15s/%u",
1138 ipaddr_string((tlv_ip_reach->prefix)),
1141 printf(", Distribution: %s, Metric: %u, %s",
1142 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
1143 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
1144 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal");
1146 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
1147 printf("%s Delay Metric: %u, %s",
1149 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
1150 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal");
1152 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
1153 printf("%s Expense Metric: %u, %s",
1155 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
1156 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal");
1158 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
1159 printf("%s Error Metric: %u, %s",
1161 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
1162 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal");
1164 length -= sizeof(struct isis_tlv_ip_reach);
1171 * this is the common IP-REACH subTLV decoder it is called
1172 * from various EXTD-IP REACH TLVs (135,235,236,237)
1176 isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
1178 /* first lets see if we know the subTLVs name*/
1179 printf("%s%s subTLV #%u, length: %u",
1181 tok2str(isis_ext_ip_reach_subtlv_values,
1187 if (!TTEST2(*tptr,subl))
1191 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
1192 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
1194 printf(", 0x%08x (=%u)",
1195 EXTRACT_32BITS(tptr),
1196 EXTRACT_32BITS(tptr));
1201 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
1203 printf(", 0x%08x%08x",
1204 EXTRACT_32BITS(tptr),
1205 EXTRACT_32BITS(tptr+4));
1211 if(!print_unknown_data(tptr,"\n\t\t ",
1219 printf("%spacket exceeded snapshot",ident);
1224 * this is the common IS-REACH subTLV decoder it is called
1225 * from isis_print_ext_is_reach()
1229 isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
1231 int priority_level,bandwidth_constraint;
1232 union { /* int to float conversion buffer for several subTLVs */
1237 /* first lets see if we know the subTLVs name*/
1238 printf("%s%s subTLV #%u, length: %u",
1240 tok2str(isis_ext_is_reach_subtlv_values,
1246 if (!TTEST2(*tptr,subl))
1250 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
1251 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
1252 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
1254 printf(", 0x%08x", EXTRACT_32BITS(tptr));
1255 if (subl == 8) /* draft-ietf-isis-gmpls-extensions */
1256 printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
1259 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
1260 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
1262 printf(", %s", ipaddr_string(tptr));
1264 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
1265 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
1267 bw.i = EXTRACT_32BITS(tptr);
1268 printf(", %.3f Mbps", bw.f*8/1000000 );
1271 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
1273 for (priority_level = 0; priority_level < 8; priority_level++) {
1274 bw.i = EXTRACT_32BITS(tptr);
1275 printf("%s priority level %d: %.3f Mbps",
1283 case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE:
1284 printf("%sBandwidth Constraints Model ID: %s (%u)",
1286 tok2str(diffserv_te_bc_values, "unknown", *tptr),
1289 /* decode BCs until the subTLV ends */
1290 for (bandwidth_constraint = 0; bandwidth_constraint < (subl-1)/4; bandwidth_constraint++) {
1291 bw.i = EXTRACT_32BITS(tptr);
1292 printf("%s Bandwidth constraint %d: %.3f Mbps",
1294 bandwidth_constraint,
1299 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
1301 printf(", %u", EXTRACT_24BITS(tptr));
1303 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
1305 printf(", %s, Priority %u",
1306 bittok2str(gmpls_link_prot_values, "none", *tptr),
1310 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
1312 printf("%s Interface Switching Capability:%s",
1314 tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)));
1315 printf(", LSP Encoding: %s",
1316 tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
1318 printf("%s Max LSP Bandwidth:",ident);
1319 for (priority_level = 0; priority_level < 8; priority_level++) {
1320 bw.i = EXTRACT_32BITS(tptr);
1321 printf("%s priority level %d: %.3f Mbps",
1328 /* there is some optional stuff left to decode but this is as of yet
1329 not specified so just lets hexdump what is left */
1331 if(!print_unknown_data(tptr,"\n\t\t ",
1338 if(!print_unknown_data(tptr,"\n\t\t ",
1346 printf("%spacket exceeded snapshot",ident);
1352 * this is the common IS-REACH decoder it is called
1353 * from various EXTD-IS REACH style TLVs (22,24,222)
1357 isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
1359 char ident_buffer[20];
1360 int subtlv_type,subtlv_len,subtlv_sum_len;
1361 int proc_bytes = 0; /* how many bytes did we process ? */
1363 if (!TTEST2(*tptr, NODE_ID_LEN))
1366 printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
1367 tptr+=(NODE_ID_LEN);
1369 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
1370 if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
1372 printf(", Metric: %d",EXTRACT_24BITS(tptr));
1376 if (!TTEST2(*tptr, 1))
1378 subtlv_sum_len=*(tptr++); /* read out subTLV length */
1379 proc_bytes=NODE_ID_LEN+3+1;
1380 printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no ");
1381 if (subtlv_sum_len) {
1382 printf(" (%u)",subtlv_sum_len);
1383 while (subtlv_sum_len>0) {
1384 if (!TTEST2(*tptr,2))
1386 subtlv_type=*(tptr++);
1387 subtlv_len=*(tptr++);
1388 /* prepend the ident string */
1389 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
1390 if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer))
1393 subtlv_sum_len-=(subtlv_len+2);
1394 proc_bytes+=(subtlv_len+2);
1401 * this is the common Multi Topology ID decoder
1402 * it is called from various MT-TLVs (222,229,235,237)
1406 isis_print_mtid (const u_int8_t *tptr,const char *ident) {
1408 if (!TTEST2(*tptr, 2))
1413 tok2str(isis_mt_values,
1414 "Reserved for IETF Consensus",
1415 ISIS_MASK_MTID(EXTRACT_16BITS(tptr))));
1417 printf(" Topology (0x%03x), Flags: [%s]",
1418 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
1419 bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr))));
1425 * this is the common extended IP reach decoder
1426 * it is called from TLVs (135,235,236,237)
1427 * we process the TLV and optional subTLVs and return
1428 * the amount of processed bytes
1432 isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) {
1434 char ident_buffer[20];
1435 u_int8_t prefix[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1436 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
1438 if (!TTEST2(*tptr, 4))
1440 metric = EXTRACT_32BITS(tptr);
1445 if (!TTEST2(*tptr, 1)) /* fetch status byte */
1447 status_byte=*(tptr++);
1448 bit_length = status_byte&0x3f;
1451 } else if (afi == IPV6) {
1452 if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
1454 status_byte=*(tptr++);
1455 bit_length=*(tptr++);
1459 return (0); /* somebody is fooling us */
1461 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
1463 if (!TTEST2(*tptr, byte_length))
1465 memset(prefix, 0, 16); /* clear the copy buffer */
1466 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
1468 processed+=byte_length;
1471 printf("%sIPv4 prefix: %15s/%u",
1473 ipaddr_string(prefix),
1477 printf("%sIPv6 prefix: %s/%u",
1479 ip6addr_string(prefix),
1483 printf(", Distribution: %s, Metric: %u",
1484 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
1487 if (afi == IPV4 && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
1488 printf(", sub-TLVs present");
1492 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
1493 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
1496 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte) && afi == IPV4) ||
1497 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == IPV6)) {
1498 /* assume that one prefix can hold more
1499 than one subTLV - therefore the first byte must reflect
1500 the aggregate bytecount of the subTLVs for this prefix
1502 if (!TTEST2(*tptr, 1))
1505 processed+=sublen+1;
1506 printf(" (%u)",sublen); /* print out subTLV length */
1509 if (!TTEST2(*tptr,2))
1511 subtlvtype=*(tptr++);
1512 subtlvlen=*(tptr++);
1513 /* prepend the ident string */
1514 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
1515 if(!isis_print_ip_reach_subtlv(tptr,subtlvtype,subtlvlen,ident_buffer))
1518 sublen-=(subtlvlen+2);
1526 * Decode IS-IS packets. Return 0 on error.
1529 static int isis_print (const u_int8_t *p, u_int length)
1531 const struct isis_common_header *isis_header;
1533 const struct isis_iih_lan_header *header_iih_lan;
1534 const struct isis_iih_ptp_header *header_iih_ptp;
1535 const struct isis_lsp_header *header_lsp;
1536 const struct isis_csnp_header *header_csnp;
1537 const struct isis_psnp_header *header_psnp;
1539 const struct isis_tlv_lsp *tlv_lsp;
1540 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
1541 const struct isis_tlv_is_reach *tlv_is_reach;
1542 const struct isis_tlv_es_reach *tlv_es_reach;
1544 u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
1545 u_int8_t ext_is_len, ext_ip_len, mt_len;
1546 const u_int8_t *optr, *pptr, *tptr;
1547 u_short packet_len,pdu_len;
1551 optr = p; /* initialize the _o_riginal pointer to the packet start -
1552 need it for parsing the checksum TLV */
1553 isis_header = (const struct isis_common_header *)p;
1554 TCHECK(*isis_header);
1555 pptr = p+(ISIS_COMMON_HEADER_SIZE);
1556 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
1557 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
1558 header_lsp = (const struct isis_lsp_header *)pptr;
1559 header_csnp = (const struct isis_csnp_header *)pptr;
1560 header_psnp = (const struct isis_psnp_header *)pptr;
1566 * Sanity checking of the header.
1569 if (isis_header->version != ISIS_VERSION) {
1570 printf("version %d packet not supported", isis_header->version);
1574 if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
1575 printf("system ID length of %d is not supported",
1576 isis_header->id_length);
1580 if (isis_header->pdu_version != ISIS_VERSION) {
1581 printf("version %d packet not supported", isis_header->pdu_version);
1585 max_area = isis_header->max_area;
1588 max_area = 3; /* silly shit */
1591 printf("bad packet -- 255 areas");
1597 id_length = isis_header->id_length;
1600 id_length = 6; /* silly shit again */
1602 case 1: /* 1-8 are valid sys-ID lenghts */
1612 id_length = 0; /* entirely useless */
1618 /* toss any non 6-byte sys-ID len PDUs */
1619 if (id_length != 6 ) {
1620 printf("bad packet -- illegal sys-ID length (%u)", id_length);
1624 pdu_type=isis_header->pdu_type;
1626 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1630 tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
1634 case ISIS_PDU_L1_LAN_IIH:
1635 case ISIS_PDU_L2_LAN_IIH:
1636 printf(", src-id %s",
1637 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
1638 printf(", lan-id %s, prio %u",
1639 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
1640 header_iih_lan->priority);
1642 case ISIS_PDU_PTP_IIH:
1643 printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
1645 case ISIS_PDU_L1_LSP:
1646 case ISIS_PDU_L2_LSP:
1647 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1648 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
1649 EXTRACT_32BITS(header_lsp->sequence_number),
1650 EXTRACT_16BITS(header_lsp->remaining_lifetime));
1652 case ISIS_PDU_L1_CSNP:
1653 case ISIS_PDU_L2_CSNP:
1654 printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
1656 case ISIS_PDU_L1_PSNP:
1657 case ISIS_PDU_L2_PSNP:
1658 printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
1662 printf(", length %u", length);
1667 /* ok they seem to want to know everything - lets fully decode it */
1668 printf("%slength %u", eflag ? "" : ", ",length);
1670 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1671 tok2str(isis_pdu_values,
1674 isis_header->fixed_len,
1675 isis_header->version,
1676 isis_header->pdu_version,
1678 isis_header->id_length,
1680 isis_header->max_area);
1683 if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
1684 return(0); /* for optionally debugging the common header */
1689 case ISIS_PDU_L1_LAN_IIH:
1690 case ISIS_PDU_L2_LAN_IIH:
1691 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
1692 printf(", bogus fixed header length %u should be %lu",
1693 isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
1697 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
1698 if (packet_len>pdu_len) {
1699 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1703 TCHECK(*header_iih_lan);
1704 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1705 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
1706 EXTRACT_16BITS(header_iih_lan->holding_time),
1707 tok2str(isis_iih_circuit_type_values,
1708 "unknown circuit type 0x%02x",
1709 header_iih_lan->circuit_type));
1711 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1712 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
1713 (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
1717 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE))
1721 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1722 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1725 case ISIS_PDU_PTP_IIH:
1726 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
1727 printf(", bogus fixed header length %u should be %lu",
1728 isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
1732 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
1733 if (packet_len>pdu_len) {
1734 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1738 TCHECK(*header_iih_ptp);
1739 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1740 isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
1741 EXTRACT_16BITS(header_iih_ptp->holding_time),
1742 tok2str(isis_iih_circuit_type_values,
1743 "unknown circuit type 0x%02x",
1744 header_iih_ptp->circuit_type));
1746 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1747 header_iih_ptp->circuit_id,
1751 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE))
1755 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1756 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1759 case ISIS_PDU_L1_LSP:
1760 case ISIS_PDU_L2_LSP:
1761 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
1762 printf(", bogus fixed header length %u should be %lu",
1763 isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
1767 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
1768 if (packet_len>pdu_len) {
1769 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1773 TCHECK(*header_lsp);
1774 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1775 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
1776 EXTRACT_32BITS(header_lsp->sequence_number),
1777 EXTRACT_16BITS(header_lsp->remaining_lifetime),
1778 EXTRACT_16BITS(header_lsp->checksum));
1780 /* if this is a purge do not attempt to verify the checksum */
1781 if ( EXTRACT_16BITS(header_lsp->remaining_lifetime) == 0 &&
1782 EXTRACT_16BITS(header_lsp->checksum) == 0)
1783 printf(" (purged)");
1785 /* verify the checksum -
1786 * checking starts at the lsp-id field at byte position [12]
1787 * hence the length needs to be reduced by 12 bytes */
1788 printf(" (%s)", (osi_cksum((u_int8_t *)header_lsp->lsp_id, length-12)) ? "incorrect" : "correct");
1790 printf(", PDU length: %u, Flags: [ %s",
1792 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
1794 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
1795 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "");
1796 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "");
1797 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "");
1798 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "");
1799 printf("ATT bit set, ");
1801 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
1802 printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
1805 if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE))
1809 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1810 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1813 case ISIS_PDU_L1_CSNP:
1814 case ISIS_PDU_L2_CSNP:
1815 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
1816 printf(", bogus fixed header length %u should be %lu",
1817 isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
1821 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
1822 if (packet_len>pdu_len) {
1823 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1827 TCHECK(*header_csnp);
1828 printf("\n\t source-id: %s, PDU length: %u",
1829 isis_print_id(header_csnp->source_id, NODE_ID_LEN),
1831 printf("\n\t start lsp-id: %s",
1832 isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
1833 printf("\n\t end lsp-id: %s",
1834 isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
1837 if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
1841 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
1842 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
1845 case ISIS_PDU_L1_PSNP:
1846 case ISIS_PDU_L2_PSNP:
1847 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
1848 printf("- bogus fixed header length %u should be %lu",
1849 isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
1853 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
1854 if (packet_len>pdu_len) {
1855 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1859 TCHECK(*header_psnp);
1860 printf("\n\t source-id: %s, PDU length: %u",
1861 isis_print_id(header_psnp->source_id, NODE_ID_LEN),
1865 if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE))
1869 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
1870 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
1874 if(!print_unknown_data(pptr,"\n\t ",length))
1880 * Now print the TLV's.
1883 while (packet_len >= 2) {
1884 if (pptr == snapend) {
1888 if (!TTEST2(*pptr, 2)) {
1889 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1890 (long)(pptr-snapend));
1895 tmp =tlv_len; /* copy temporary len & pointer to packet data */
1898 if (tlv_len > packet_len) {
1902 /* first lets see if we know the TLVs name*/
1903 printf("\n\t %s TLV #%u, length: %u",
1904 tok2str(isis_tlv_values,
1910 if (tlv_len == 0) /* something is malformed */
1913 /* now check if we have a decoder otherwise do a hexdump at the end*/
1915 case ISIS_TLV_AREA_ADDR:
1916 if (!TTEST2(*tptr, 1))
1919 while (tmp && alen < tmp) {
1920 printf("\n\t Area address (length: %u): %s",
1922 isonsap_string(tptr,alen));
1925 if (tmp==0) /* if this is the last area address do not attemt a boundary check */
1927 if (!TTEST2(*tptr, 1))
1932 case ISIS_TLV_ISNEIGH:
1933 while (tmp >= ETHER_ADDR_LEN) {
1934 if (!TTEST2(*tptr, ETHER_ADDR_LEN))
1936 printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
1937 tmp -= ETHER_ADDR_LEN;
1938 tptr += ETHER_ADDR_LEN;
1942 case ISIS_TLV_ISNEIGH_VARLEN:
1943 if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
1945 lan_alen = *tptr++; /* LAN adress length */
1947 printf("\n\t LAN address length %u bytes ",lan_alen);
1948 while (tmp >= lan_alen) {
1949 if (!TTEST2(*tptr, lan_alen))
1951 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
1957 case ISIS_TLV_PADDING:
1960 case ISIS_TLV_MT_IS_REACH:
1961 while (tmp >= 2+NODE_ID_LEN+3+1) {
1962 mt_len = isis_print_mtid(tptr, "\n\t ");
1963 if (mt_len == 0) /* did something go wrong ? */
1968 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1969 if (ext_is_len == 0) /* did something go wrong ? */
1977 case ISIS_TLV_IS_ALIAS_ID:
1978 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
1979 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1980 if (ext_is_len == 0) /* did something go wrong ? */
1987 case ISIS_TLV_EXT_IS_REACH:
1988 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
1989 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1990 if (ext_is_len == 0) /* did something go wrong ? */
1996 case ISIS_TLV_IS_REACH:
1997 if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
2000 tok2str(isis_is_reach_virtual_values,
2001 "bogus virtual flag 0x%02x",
2003 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
2004 while (tmp >= sizeof(struct isis_tlv_is_reach)) {
2005 if (!TTEST(*tlv_is_reach))
2007 printf("\n\t IS Neighbor: %s",
2008 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
2009 isis_print_metric_block(&tlv_is_reach->isis_metric_block);
2010 tmp -= sizeof(struct isis_tlv_is_reach);
2015 case ISIS_TLV_ESNEIGH:
2016 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
2017 while (tmp >= sizeof(struct isis_tlv_es_reach)) {
2018 if (!TTEST(*tlv_es_reach))
2020 printf("\n\t ES Neighbor: %s",
2021 isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
2022 isis_print_metric_block(&tlv_es_reach->isis_metric_block);
2023 tmp -= sizeof(struct isis_tlv_es_reach);
2028 /* those two TLVs share the same format */
2029 case ISIS_TLV_INT_IP_REACH:
2030 case ISIS_TLV_EXT_IP_REACH:
2031 if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
2035 case ISIS_TLV_EXTD_IP_REACH:
2037 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
2038 if (ext_ip_len == 0) /* did something go wrong ? */
2045 case ISIS_TLV_MT_IP_REACH:
2047 mt_len = isis_print_mtid(tptr, "\n\t ");
2048 if (mt_len == 0) /* did something go wrong ? */
2053 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
2054 if (ext_ip_len == 0) /* did something go wrong ? */
2062 case ISIS_TLV_IP6_REACH:
2064 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
2065 if (ext_ip_len == 0) /* did something go wrong ? */
2072 case ISIS_TLV_MT_IP6_REACH:
2074 mt_len = isis_print_mtid(tptr, "\n\t ");
2075 if (mt_len == 0) /* did something go wrong ? */
2080 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
2081 if (ext_ip_len == 0) /* did something go wrong ? */
2088 case ISIS_TLV_IP6ADDR:
2090 if (!TTEST2(*tptr, 16))
2093 printf("\n\t IPv6 interface address: %s",
2094 ip6addr_string(tptr));
2102 if (!TTEST2(*tptr, 1))
2106 tok2str(isis_subtlv_auth_values,
2107 "unknown Authentication type 0x%02x",
2111 case ISIS_SUBTLV_AUTH_SIMPLE:
2112 for(i=1;i<tlv_len;i++) {
2113 if (!TTEST2(*(tptr+i), 1))
2115 printf("%c",*(tptr+i));
2118 case ISIS_SUBTLV_AUTH_MD5:
2119 for(i=1;i<tlv_len;i++) {
2120 if (!TTEST2(*(tptr+i), 1))
2122 printf("%02x",*(tptr+i));
2124 if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
2125 printf(", (malformed subTLV) ");
2127 case ISIS_SUBTLV_AUTH_PRIVATE:
2129 if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
2135 case ISIS_TLV_PTP_ADJ:
2136 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
2138 if (!TTEST2(*tptr, 1))
2140 printf("\n\t Adjacency State: %s (%u)",
2141 tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
2145 if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
2146 if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id,
2147 sizeof(tlv_ptp_adj->extd_local_circuit_id)))
2149 printf("\n\t Extended Local circuit-ID: 0x%08x",
2150 EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id));
2151 tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
2153 if(tmp>=SYSTEM_ID_LEN) {
2154 if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
2156 printf("\n\t Neighbor System-ID: %s",
2157 isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
2160 if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
2161 if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
2162 sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
2164 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2165 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
2169 case ISIS_TLV_PROTOCOLS:
2170 printf("\n\t NLPID(s): ");
2172 if (!TTEST2(*(tptr), 1))
2174 printf("%s (0x%02x)",
2175 tok2str(nlpid_values,
2179 if (tmp>1) /* further NPLIDs ? - put comma */
2186 case ISIS_TLV_TE_ROUTER_ID:
2187 if (!TTEST2(*pptr, 4))
2189 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
2192 case ISIS_TLV_IPADDR:
2194 if (!TTEST2(*tptr, 4))
2196 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
2202 case ISIS_TLV_HOSTNAME:
2203 printf("\n\t Hostname: ");
2205 if (!TTEST2(*tptr, 1))
2207 printf("%c",*tptr++);
2212 case ISIS_TLV_SHARED_RISK_GROUP:
2213 if (!TTEST2(*tptr, NODE_ID_LEN))
2215 printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
2216 tptr+=(NODE_ID_LEN);
2219 if (!TTEST2(*tptr, 1))
2221 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
2224 if (!TTEST2(*tptr,4))
2226 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
2230 if (!TTEST2(*tptr,4))
2232 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr));
2237 if (!TTEST2(*tptr, 4))
2239 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
2246 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
2248 if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
2250 printf("\n\t lsp-id: %s",
2251 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
2252 if (!TTEST2(tlv_lsp->sequence_number, 4))
2254 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
2255 if (!TTEST2(tlv_lsp->remaining_lifetime, 2))
2257 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
2258 if (!TTEST2(tlv_lsp->checksum, 2))
2260 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
2261 tmp-=sizeof(struct isis_tlv_lsp);
2266 case ISIS_TLV_CHECKSUM:
2267 if (!TTEST2(*tptr, 2))
2269 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
2270 /* do not attempt to verify the checksum if it is zero
2271 * most likely a HMAC-MD5 TLV is also present and
2272 * to avoid conflicts the checksum TLV is zeroed.
2273 * see rfc3358 for details
2275 if (EXTRACT_16BITS(tptr) == 0)
2276 printf("(unverified)");
2277 else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct");
2280 case ISIS_TLV_MT_SUPPORTED:
2282 /* length can only be a multiple of 2, otherwise there is
2283 something broken -> so decode down until length is 1 */
2285 mt_len = isis_print_mtid(tptr, "\n\t ");
2286 if (mt_len == 0) /* did something go wrong ? */
2291 printf("\n\t malformed MT-ID");
2297 case ISIS_TLV_RESTART_SIGNALING:
2298 if (!TTEST2(*tptr, 3))
2300 printf("\n\t Flags [%s], Remaining holding time %us",
2301 bittok2str(isis_restart_flag_values, "none", *tptr),
2302 EXTRACT_16BITS(tptr+1));
2306 case ISIS_TLV_IDRP_INFO:
2307 if (!TTEST2(*tptr, 1))
2309 printf("\n\t Inter-Domain Information Type: %s",
2310 tok2str(isis_subtlv_idrp_values,
2314 case ISIS_SUBTLV_IDRP_ASN:
2315 if (!TTEST2(*tptr, 2)) /* fetch AS number */
2317 printf("AS Number: %u",EXTRACT_16BITS(tptr));
2319 case ISIS_SUBTLV_IDRP_LOCAL:
2320 case ISIS_SUBTLV_IDRP_RES:
2322 if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
2328 case ISIS_TLV_LSP_BUFFERSIZE:
2329 if (!TTEST2(*tptr, 2))
2331 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
2334 case ISIS_TLV_PART_DIS:
2335 while (tmp >= SYSTEM_ID_LEN) {
2336 if (!TTEST2(*tptr, SYSTEM_ID_LEN))
2338 printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
2339 tptr+=SYSTEM_ID_LEN;
2344 case ISIS_TLV_PREFIX_NEIGH:
2345 if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
2347 printf("\n\t Metric Block");
2348 isis_print_metric_block((const struct isis_metric_block *)tptr);
2349 tptr+=sizeof(struct isis_metric_block);
2350 tmp-=sizeof(struct isis_metric_block);
2353 if (!TTEST2(*tptr, 1))
2355 prefix_len=*tptr++; /* read out prefix length in semioctets*/
2357 if (!TTEST2(*tptr, prefix_len/2))
2359 printf("\n\t\tAddress: %s/%u",
2360 isonsap_string(tptr,prefix_len/2),
2367 case ISIS_TLV_IIH_SEQNR:
2368 if (!TTEST2(*tptr, 4)) /* check if four bytes are on the wire */
2370 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
2373 case ISIS_TLV_VENDOR_PRIVATE:
2374 if (!TTEST2(*tptr, 3)) /* check if enough byte for a full oui */
2376 vendor_id = EXTRACT_24BITS(tptr);
2377 printf("\n\t Vendor: %s (%u)",
2378 tok2str(oui_values,"Unknown",vendor_id),
2382 if (tmp > 0) /* hexdump the rest */
2383 if(!print_unknown_data(tptr,"\n\t\t",tmp))
2387 * FIXME those are the defined TLVs that lack a decoder
2388 * you are welcome to contribute code ;-)
2391 case ISIS_TLV_DECNET_PHASE4:
2392 case ISIS_TLV_LUCENT_PRIVATE:
2393 case ISIS_TLV_IPAUTH:
2394 case ISIS_TLV_NORTEL_PRIVATE1:
2395 case ISIS_TLV_NORTEL_PRIVATE2:
2399 if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
2404 /* do we want to see an additionally hexdump ? */
2406 if(!print_unknown_data(pptr,"\n\t ",tlv_len))
2411 packet_len -= tlv_len;
2414 if (packet_len != 0) {
2415 printf("\n\t %u straggler bytes", packet_len);
2420 fputs("[|isis]", stdout);
2424 printf("\n\t\t packet exceeded snapshot");
2429 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2433 osi_cksum(const u_int8_t *tptr, u_int len)
2435 int32_t c0 = 0, c1 = 0;
2437 while ((int)--len >= 0) {
2449 * c-style: whitesmith