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 support.
28 static const char rcsid
[] _U_
=
29 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.118 2004-03-18 10:58:17 hannes Exp $ (LBL)";
36 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
43 #include "ethertype.h"
49 #define NLPID_CLNP 0x81 /* iso9577 */
50 #define NLPID_ESIS 0x82 /* iso9577 */
51 #define NLPID_ISIS 0x83 /* iso9577 */
52 #define NLPID_IP6 0x8e
54 #define NLPID_NULLNS 0
56 static struct tok osi_nlpid_values
[] = {
57 { NLPID_NULLNS
, "NULL-NS"},
58 { NLPID_CLNP
, "CLNP"},
59 { NLPID_ESIS
, "ES-IS"},
60 { NLPID_ISIS
, "IS-IS"},
66 #define IPV4 1 /* AFI value */
67 #define IPV6 2 /* AFI value */
70 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
73 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
74 #define NODE_ID_LEN SYSTEM_ID_LEN+1
75 #define LSP_ID_LEN SYSTEM_ID_LEN+2
76 #define NSAP_MAX_LENGTH 20
78 #define ISIS_VERSION 1
79 #define ESIS_VERSION 1
81 #define ISIS_PDU_TYPE_MASK 0x1F
82 #define ESIS_PDU_TYPE_MASK 0x1F
83 #define CLNP_PDU_TYPE_MASK 0x1F
84 #define ISIS_LAN_PRIORITY_MASK 0x7F
86 #define ISIS_PDU_L1_LAN_IIH 15
87 #define ISIS_PDU_L2_LAN_IIH 16
88 #define ISIS_PDU_PTP_IIH 17
89 #define ISIS_PDU_L1_LSP 18
90 #define ISIS_PDU_L2_LSP 20
91 #define ISIS_PDU_L1_CSNP 24
92 #define ISIS_PDU_L2_CSNP 25
93 #define ISIS_PDU_L1_PSNP 26
94 #define ISIS_PDU_L2_PSNP 27
96 static struct tok isis_pdu_values
[] = {
97 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
98 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
99 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
100 { ISIS_PDU_L1_LSP
, "L1 LSP"},
101 { ISIS_PDU_L2_LSP
, "L2 LSP"},
102 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
103 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
104 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
105 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
110 * A TLV is a tuple of a type, length and a value and is normally used for
111 * encoding information in all sorts of places. This is an enumeration of
112 * the well known types.
114 * list taken from rfc3359 plus some memory from veterans ;-)
117 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
118 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
119 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
120 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
121 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
122 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
123 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
124 #define ISIS_TLV_PADDING 8 /* iso10589 */
125 #define ISIS_TLV_LSP 9 /* iso10589 */
126 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
127 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
128 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
129 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
130 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
131 #define ISIS_TLV_DECNET_PHASE4 42
132 #define ISIS_TLV_LUCENT_PRIVATE 66
133 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
134 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
135 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
136 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
137 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
138 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
139 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
140 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
141 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
142 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
143 #define ISIS_TLV_NORTEL_PRIVATE1 176
144 #define ISIS_TLV_NORTEL_PRIVATE2 177
145 #define ISIS_TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
146 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
147 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
148 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
149 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
150 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
151 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
152 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
153 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
154 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
156 static struct tok isis_tlv_values
[] = {
157 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
158 { ISIS_TLV_IS_REACH
, "IS Reachability"},
159 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
160 { ISIS_TLV_PART_DIS
, "Partition DIS"},
161 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
162 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
163 { ISIS_TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
164 { ISIS_TLV_PADDING
, "Padding"},
165 { ISIS_TLV_LSP
, "LSP entries"},
166 { ISIS_TLV_AUTH
, "Authentication"},
167 { ISIS_TLV_CHECKSUM
, "Checksum"},
168 { ISIS_TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
169 { ISIS_TLV_EXT_IS_REACH
, "Extended IS Reachability"},
170 { ISIS_TLV_IS_ALIAS_ID
, "IS Alias ID"},
171 { ISIS_TLV_DECNET_PHASE4
, "DECnet Phase IV"},
172 { ISIS_TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
173 { ISIS_TLV_INT_IP_REACH
, "IPv4 Internal Reachability"},
174 { ISIS_TLV_PROTOCOLS
, "Protocols supported"},
175 { ISIS_TLV_EXT_IP_REACH
, "IPv4 External Reachability"},
176 { ISIS_TLV_IDRP_INFO
, "Inter-Domain Information Type"},
177 { ISIS_TLV_IPADDR
, "IPv4 Interface address(es)"},
178 { ISIS_TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
179 { ISIS_TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
180 { ISIS_TLV_EXTD_IP_REACH
, "Extended IPv4 Reachability"},
181 { ISIS_TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
182 { ISIS_TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
183 { ISIS_TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
184 { ISIS_TLV_HOSTNAME
, "Hostname"},
185 { ISIS_TLV_RESTART_SIGNALING
, "Restart Signaling"},
186 { ISIS_TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
187 { ISIS_TLV_MT_SUPPORTED
, "Multi Topology"},
188 { ISIS_TLV_IP6ADDR
, "IPv6 Interface address(es)"},
189 { ISIS_TLV_MT_IP_REACH
, "Multi-Topology IPv4 Reachability"},
190 { ISIS_TLV_IP6_REACH
, "IPv6 reachability"},
191 { ISIS_TLV_MT_IP6_REACH
, "Multi-Topology IP6 Reachability"},
192 { ISIS_TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
193 { ISIS_TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
194 { ISIS_TLV_VENDOR_PRIVATE
, "Vendor Private"},
198 #define ESIS_OPTION_PROTOCOLS 129
199 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
200 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
201 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
202 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
203 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
204 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
206 static struct tok esis_option_values
[] = {
207 { ESIS_OPTION_PROTOCOLS
, "Protocols supported"},
208 { ESIS_OPTION_QOS_MAINTENANCE
, "QoS Maintenance" },
209 { ESIS_OPTION_SECURITY
, "Security" },
210 { ESIS_OPTION_ES_CONF_TIME
, "ES Configuration Time" },
211 { ESIS_OPTION_PRIORITY
, "Priority" },
212 { ESIS_OPTION_ADDRESS_MASK
, "Addressk Mask" },
213 { ESIS_OPTION_SNPA_MASK
, "SNPA Mask" },
217 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
218 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
219 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
220 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
221 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
222 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
223 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
224 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
225 #define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE 12 /* draft-ietf-tewg-diff-te-proto-06 */
226 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
227 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
228 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
230 static struct tok isis_ext_is_reach_subtlv_values
[] = {
231 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
232 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
233 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
234 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
235 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
236 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
237 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
238 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
239 { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE
, "Diffserv TE" },
240 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
241 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
242 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
243 { 250, "Reserved for cisco specific extensions" },
244 { 251, "Reserved for cisco specific extensions" },
245 { 252, "Reserved for cisco specific extensions" },
246 { 253, "Reserved for cisco specific extensions" },
247 { 254, "Reserved for cisco specific extensions" },
248 { 255, "Reserved for future expansion" },
252 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
253 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
254 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
256 static struct tok isis_ext_ip_reach_subtlv_values
[] = {
257 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
258 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
259 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
263 #define ISIS_SUBTLV_AUTH_SIMPLE 1
264 #define ISIS_SUBTLV_AUTH_MD5 54
265 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
266 #define ISIS_SUBTLV_AUTH_PRIVATE 255
268 static struct tok isis_subtlv_auth_values
[] = {
269 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
270 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
271 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
275 #define ISIS_SUBTLV_IDRP_RES 0
276 #define ISIS_SUBTLV_IDRP_LOCAL 1
277 #define ISIS_SUBTLV_IDRP_ASN 2
279 static struct tok isis_subtlv_idrp_values
[] = {
280 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
281 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
282 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
286 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
287 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
288 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
289 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
290 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
291 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
292 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
293 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
295 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
296 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
298 static struct tok isis_mt_flag_values
[] = {
299 { 0x4000, "sub-TLVs present"},
300 { 0x8000, "ATT bit set"},
304 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
305 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
307 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
308 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
310 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
311 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
312 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
313 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
315 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
317 static struct tok isis_mt_values
[] = {
318 { 0, "IPv4 unicast"},
319 { 1, "In-Band Management"},
320 { 2, "IPv6 unicast"},
322 { 4095, "Development, Experimental or Proprietary"},
326 static struct tok isis_iih_circuit_type_values
[] = {
327 { 1, "Level 1 only"},
328 { 2, "Level 2 only"},
329 { 3, "Level 1, Level 2"},
333 #define ISIS_LSP_TYPE_UNUSED0 0
334 #define ISIS_LSP_TYPE_LEVEL_1 1
335 #define ISIS_LSP_TYPE_UNUSED2 2
336 #define ISIS_LSP_TYPE_LEVEL_2 3
338 static struct tok isis_lsp_istype_values
[] = {
339 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
340 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
341 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
342 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
347 * Katz's point to point adjacency TLV uses codes to tell us the state of
348 * the remote adjacency. Enumerate them.
351 #define ISIS_PTP_ADJ_UP 0
352 #define ISIS_PTP_ADJ_INIT 1
353 #define ISIS_PTP_ADJ_DOWN 2
355 static struct tok isis_ptp_adjancey_values
[] = {
356 { ISIS_PTP_ADJ_UP
, "Up" },
357 { ISIS_PTP_ADJ_INIT
, "Initializing" },
358 { ISIS_PTP_ADJ_DOWN
, "Down" },
362 struct isis_tlv_ptp_adj
{
363 u_int8_t adjacency_state
;
364 u_int8_t extd_local_circuit_id
[4];
365 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
366 u_int8_t neighbor_extd_local_circuit_id
[4];
369 static int osi_cksum(const u_int8_t
*, u_int
);
370 static int clnp_print(const u_int8_t
*, u_int
);
371 static void esis_print(const u_int8_t
*, u_int
);
372 static int isis_print(const u_int8_t
*, u_int
);
374 struct isis_metric_block
{
375 u_int8_t metric_default
;
376 u_int8_t metric_delay
;
377 u_int8_t metric_expense
;
378 u_int8_t metric_error
;
381 struct isis_tlv_is_reach
{
382 struct isis_metric_block isis_metric_block
;
383 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
386 struct isis_tlv_es_reach
{
387 struct isis_metric_block isis_metric_block
;
388 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
391 struct isis_tlv_ip_reach
{
392 struct isis_metric_block isis_metric_block
;
397 static struct tok isis_is_reach_virtual_values
[] = {
398 { 0, "IsNotVirtual"},
403 static struct tok isis_restart_flag_values
[] = {
404 { 0x1, "Restart Request"},
405 { 0x2, "Restart Acknowledgement"},
409 struct isis_common_header
{
412 u_int8_t version
; /* Protocol version */
414 u_int8_t pdu_type
; /* 3 MSbits are reserved */
415 u_int8_t pdu_version
; /* Packet format version */
420 struct isis_iih_lan_header
{
421 u_int8_t circuit_type
;
422 u_int8_t source_id
[SYSTEM_ID_LEN
];
423 u_int8_t holding_time
[2];
426 u_int8_t lan_id
[NODE_ID_LEN
];
429 struct isis_iih_ptp_header
{
430 u_int8_t circuit_type
;
431 u_int8_t source_id
[SYSTEM_ID_LEN
];
432 u_int8_t holding_time
[2];
437 struct isis_lsp_header
{
439 u_int8_t remaining_lifetime
[2];
440 u_int8_t lsp_id
[LSP_ID_LEN
];
441 u_int8_t sequence_number
[4];
442 u_int8_t checksum
[2];
446 struct isis_csnp_header
{
448 u_int8_t source_id
[NODE_ID_LEN
];
449 u_int8_t start_lsp_id
[LSP_ID_LEN
];
450 u_int8_t end_lsp_id
[LSP_ID_LEN
];
453 struct isis_psnp_header
{
455 u_int8_t source_id
[NODE_ID_LEN
];
458 struct isis_tlv_lsp
{
459 u_int8_t remaining_lifetime
[2];
460 u_int8_t lsp_id
[LSP_ID_LEN
];
461 u_int8_t sequence_number
[4];
462 u_int8_t checksum
[2];
466 print_nsap(register const u_int8_t
*pptr
, register int nsap_length
)
469 static char nsap_ascii_output
[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")];
470 char *junk_buf
= nsap_ascii_output
;
472 if (nsap_length
< 1 || nsap_length
> NSAP_MAX_LENGTH
) {
473 snprintf(nsap_ascii_output
, sizeof(nsap_ascii_output
),
475 return (nsap_ascii_output
);
478 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
479 if (!TTEST2(*pptr
, 1))
482 sizeof(nsap_ascii_output
) - (junk_buf
- nsap_ascii_output
),
484 junk_buf
+= strlen(junk_buf
);
485 if (((nsap_idx
& 1) == 0) &&
486 (nsap_idx
+ 1 < nsap_length
)) {
491 return (nsap_ascii_output
);
494 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
495 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
496 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
497 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
498 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
499 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
501 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
503 const struct isis_common_header
*header
;
505 header
= (const struct isis_common_header
*)p
;
507 if (caplen
<= 1) { /* enough bytes on the wire ? */
512 printf("%s",tok2str(osi_nlpid_values
,"Unknown NLPID (0x%02x)",*p
));
517 if (!clnp_print(p
, length
))
518 print_unknown_data(p
,"\n\t",caplen
);
522 esis_print(p
, length
);
526 if (!isis_print(p
, length
))
527 print_unknown_data(p
,"\n\t",caplen
);
531 (void)printf(", length: %u", length
);
535 (void)printf(", length: %u", length
);
537 print_unknown_data(p
,"\n\t",caplen
);
542 #define CLNP_PDU_ER 1
543 #define CLNP_PDU_DT 28
544 #define CLNP_PDU_MD 29
545 #define CLNP_PDU_ERQ 30
546 #define CLNP_PDU_ERP 31
548 static struct tok clnp_pdu_values
[] = {
549 { CLNP_PDU_ER
, "Error Report"},
550 { CLNP_PDU_MD
, "MD"},
551 { CLNP_PDU_DT
, "Data"},
552 { CLNP_PDU_ERQ
, "Echo Request"},
553 { CLNP_PDU_ERP
, "Echo Response"},
557 struct clnp_header_t
{
559 u_int8_t length_indicator
;
561 u_int8_t lifetime
; /* units of 500ms */
563 u_int8_t segment_length
[2];
569 * Decode CLNP packets. Return 0 on error.
572 static int clnp_print (const u_int8_t
*pptr
, u_int length
)
574 const u_int8_t
*optr
,*source_address
,*dest_address
;
575 u_int li
,source_address_length
,dest_address_length
, clnp_pdu_type
;
576 const struct clnp_header_t
*clnp_header
;
578 clnp_header
= (const struct clnp_header_t
*) pptr
;
579 li
= clnp_header
->length_indicator
;
583 * Sanity checking of the header.
588 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
590 pptr
+= sizeof(struct clnp_header_t
);
591 dest_address_length
= *pptr
;
592 dest_address
= pptr
+ 1;
594 pptr
+= (1 + dest_address_length
);
595 source_address_length
= *pptr
;
596 source_address
= pptr
+1;
598 pptr
+= (1 + source_address_length
);
601 printf(", %s > %s, length %u",
602 print_nsap(source_address
, source_address_length
),
603 print_nsap(dest_address
, dest_address_length
),
607 printf(", length %u", length
);
609 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, PDU length: %u, checksum: 0x%04x ",
610 tok2str(clnp_pdu_values
,
613 clnp_header
->length_indicator
,
614 clnp_header
->version
,
615 clnp_header
->lifetime
/2,
616 (clnp_header
->lifetime
%2)*5,
617 EXTRACT_16BITS(clnp_header
->segment_length
),
618 EXTRACT_16BITS(clnp_header
->cksum
));
620 /* do not attempt to verify the checksum if it is zero */
621 if (EXTRACT_16BITS(clnp_header
->cksum
) == 0)
622 printf("(unverified)");
623 else printf("(%s)", osi_cksum(optr
, li
) ? "incorrect" : "correct");
625 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
626 source_address_length
,
627 print_nsap(source_address
, source_address_length
),
629 print_nsap(dest_address
, dest_address_length
));
631 /* dump the remaining header data */
632 print_unknown_data(pptr
,"\n\t",clnp_header
->length_indicator
-(pptr
-optr
));
634 switch (clnp_pdu_type
) {
643 /* dump the PDU specific data */
644 print_unknown_data(optr
+clnp_header
->length_indicator
,"\n\t ",length
-clnp_header
->length_indicator
);
652 #define ESIS_PDU_REDIRECT 6
653 #define ESIS_PDU_ESH 2
654 #define ESIS_PDU_ISH 4
656 static struct tok esis_pdu_values
[] = {
657 { ESIS_PDU_REDIRECT
, "redirect"},
658 { ESIS_PDU_ESH
, "ESH"},
659 { ESIS_PDU_ISH
, "ISH"},
663 struct esis_header_t
{
665 u_int8_t length_indicator
;
669 u_int8_t holdtime
[2];
674 esis_print(const u_int8_t
*pptr
, u_int length
)
676 const u_int8_t
*optr
;
677 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
678 const struct esis_header_t
*esis_header
;
684 printf(" no header at all!");
688 esis_header
= (const struct esis_header_t
*) pptr
;
689 li
= esis_header
->length_indicator
;
693 * Sanity checking of the header.
696 if (esis_header
->nlpid
!= NLPID_ESIS
) {
697 printf(", nlpid 0x%02x packet not supported", esis_header
->nlpid
);
701 if (esis_header
->version
!= ESIS_VERSION
) {
702 printf(", version %d packet not supported", esis_header
->version
);
707 printf(", length indicator(%d) > PDU size (%d)!", li
, length
);
711 if (li
< sizeof(struct esis_header_t
) + 2) {
712 printf(", length indicator < min PDU size %d:", li
);
713 while (--length
!= 0)
714 printf("%02X", *pptr
++);
718 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
721 printf(", %s, length %u",
722 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
726 printf(", length %u\n\t%s (%u)",
728 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
731 printf(", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" );
732 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header
->cksum
));
733 /* do not attempt to verify the checksum if it is zero */
734 if (EXTRACT_16BITS(esis_header
->cksum
) == 0)
735 printf("(unverified)");
736 else printf("(%s)", osi_cksum(pptr
, li
) ? "incorrect" : "correct");
738 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header
->holdtime
),li
);
741 print_unknown_data(optr
,"\n\t",sizeof(struct esis_header_t
));
743 pptr
+= sizeof(struct esis_header_t
);
744 li
-= sizeof(struct esis_header_t
);
746 switch (esis_pdu_type
) {
747 case ESIS_PDU_REDIRECT
: {
748 const u_int8_t
*dst
, *snpa
, *tptr
;
750 dst
= pptr
; pptr
+= *pptr
+ 1;
753 printf("\n\t %s", isonsap_string(dst
));
754 snpa
= pptr
; pptr
+= *pptr
+ 1;
755 tptr
= pptr
; pptr
+= *pptr
+ 1;
760 printf("\n\t %s", etheraddr_string(&snpa
[1]));
762 printf("\n\t %s", isonsap_string(tptr
));
767 source_address_number
= *pptr
;
771 printf("\n\t Number of Source Addresses: %u", source_address_number
);
773 while (source_address_number
> 0) {
774 source_address_length
= *pptr
;
775 printf("\n\t NET (length: %u): %s",
776 source_address_length
,
777 print_nsap(pptr
+1, source_address_length
));
779 pptr
+= source_address_length
+1;
780 li
-= source_address_length
+1;
781 source_address_number
--;
787 source_address_length
= *pptr
;
788 printf("\n\t NET (length: %u): %s", source_address_length
, print_nsap(pptr
+1, source_address_length
));
789 pptr
+= source_address_length
+1;
790 li
-= source_address_length
+1;
797 print_unknown_data(pptr
,"\n\t ",snapend
-pptr
);
802 /* now walk the options */
805 const u_int8_t
*tptr
;
807 if (snapend
- pptr
< 2)
810 printf(", bad opts/li");
817 printf(", opt (%d) too long", op
);
826 printf("\n\t %s Option #%u, length %u, value: ",
827 tok2str(esis_option_values
,"Unknown",op
),
833 case ESIS_OPTION_ES_CONF_TIME
:
834 printf("%us", EXTRACT_16BITS(tptr
));
838 case ESIS_OPTION_PROTOCOLS
:
840 printf("%s (0x%02x)",
841 tok2str(osi_nlpid_values
,
845 if (opli
>1) /* further NPLIDs ? - put comma */
853 * FIXME those are the defined Options that lack a decoder
854 * you are welcome to contribute code ;-)
857 case ESIS_OPTION_QOS_MAINTENANCE
:
858 case ESIS_OPTION_SECURITY
:
859 case ESIS_OPTION_PRIORITY
:
860 case ESIS_OPTION_ADDRESS_MASK
:
861 case ESIS_OPTION_SNPA_MASK
:
864 print_unknown_data(tptr
,"\n\t ",opli
);
868 print_unknown_data(pptr
,"\n\t ",opli
);
873 /* shared routine for printing system, node and lsp-ids */
875 isis_print_id(const u_int8_t
*cp
, int id_len
)
878 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
881 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
882 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
884 if (i
== 2 || i
== 4)
887 if (id_len
>= NODE_ID_LEN
) {
888 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
891 if (id_len
== LSP_ID_LEN
)
892 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
896 /* print the 4-byte metric block which is common found in the old-style TLVs */
898 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
900 printf(", Default Metric: %d, %s",
901 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
902 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
903 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
904 printf("\n\t\t Delay Metric: %d, %s",
905 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
906 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
907 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
908 printf("\n\t\t Expense Metric: %d, %s",
909 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
910 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
911 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
912 printf("\n\t\t Error Metric: %d, %s",
913 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
914 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
916 return(1); /* everything is ok */
920 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
923 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
925 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
928 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
929 printf("short IPv4 Reachability (%d vs %lu)",
931 (unsigned long)sizeof(*tlv_ip_reach
));
935 if (!TTEST(*tlv_ip_reach
))
938 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
940 if (prefix_len
== -1)
941 printf("%sIPv4 prefix: %s mask %s",
943 ipaddr_string((tlv_ip_reach
->prefix
)),
944 ipaddr_string((tlv_ip_reach
->mask
)));
946 printf("%sIPv4 prefix: %15s/%u",
948 ipaddr_string((tlv_ip_reach
->prefix
)),
951 printf(", Distribution: %s, Metric: %u, %s",
952 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
953 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
954 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
956 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
957 printf("%s Delay Metric: %u, %s",
959 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
960 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
962 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
963 printf("%s Expense Metric: %u, %s",
965 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
966 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
968 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
969 printf("%s Error Metric: %u, %s",
971 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
972 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
974 length
-= sizeof(struct isis_tlv_ip_reach
);
981 * this is the common IP-REACH subTLV decoder it is called
982 * from various EXTD-IP REACH TLVs (135,235,236,237)
986 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
988 /* first lets see if we know the subTLVs name*/
989 printf("%s%s subTLV #%u, length: %u",
991 tok2str(isis_ext_ip_reach_subtlv_values
,
997 if (!TTEST2(*tptr
,subl
))
1001 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1002 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1004 printf(", 0x%08x (=%u)",
1005 EXTRACT_32BITS(tptr
),
1006 EXTRACT_32BITS(tptr
));
1011 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1013 printf(", 0x%08x%08x",
1014 EXTRACT_32BITS(tptr
),
1015 EXTRACT_32BITS(tptr
+4));
1021 if(!print_unknown_data(tptr
,"\n\t\t ",
1029 printf("%spacket exceeded snapshot",ident
);
1034 * this is the common IS-REACH subTLV decoder it is called
1035 * from isis_print_ext_is_reach()
1039 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
1041 int priority_level
,bandwidth_constraint
;
1042 union { /* int to float conversion buffer for several subTLVs */
1047 /* first lets see if we know the subTLVs name*/
1048 printf("%s%s subTLV #%u, length: %u",
1050 tok2str(isis_ext_is_reach_subtlv_values
,
1056 if (!TTEST2(*tptr
,subl
))
1060 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1061 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1062 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1063 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
1064 if (subl
== 8) /* draft-ietf-isis-gmpls-extensions */
1065 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
1067 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1068 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1069 printf(", %s", ipaddr_string(tptr
));
1071 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1072 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1073 bw
.i
= EXTRACT_32BITS(tptr
);
1074 printf(", %.3f Mbps", bw
.f
*8/1000000 );
1076 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1077 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1078 bw
.i
= EXTRACT_32BITS(tptr
);
1079 printf("%s priority level %d: %.3f Mbps",
1086 case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE
:
1087 printf("%sBandwidth Constraints Model ID: (%u)",ident
, *tptr
);
1089 /* for now lets just print the first 8 BCs -
1090 * FIXME is this dep. on the BC model ?
1092 for (bandwidth_constraint
= 0; bandwidth_constraint
< 8; bandwidth_constraint
++) {
1093 bw
.i
= EXTRACT_32BITS(tptr
);
1094 printf("%s Bandwidth constraint %d: %.3f Mbps",
1096 bandwidth_constraint
,
1101 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1102 printf(", %u", EXTRACT_24BITS(tptr
));
1104 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1105 printf(", %s, Priority %u",
1106 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1109 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1110 printf("%s Interface Switching Capability:%s",
1112 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
1113 printf(", LSP Encoding: %s",
1114 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
1116 printf("%s Max LSP Bandwidth:",ident
);
1117 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1118 bw
.i
= EXTRACT_32BITS(tptr
);
1119 printf("%s priority level %d: %.3f Mbps",
1126 /* there is some optional stuff left to decode but this is as of yet
1127 not specified so just lets hexdump what is left */
1129 if(!print_unknown_data(tptr
,"\n\t\t ",
1135 if(!print_unknown_data(tptr
,"\n\t\t ",
1143 printf("%spacket exceeded snapshot",ident
);
1149 * this is the common IS-REACH decoder it is called
1150 * from various EXTD-IS REACH style TLVs (22,24,222)
1154 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
1156 char ident_buffer
[20];
1157 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1158 int proc_bytes
= 0; /* how many bytes did we process ? */
1160 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1163 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1164 tptr
+=(NODE_ID_LEN
);
1166 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1167 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
1169 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1173 if (!TTEST2(*tptr
, 1))
1175 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1176 proc_bytes
=NODE_ID_LEN
+3+1;
1177 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1178 if (subtlv_sum_len
) {
1179 printf(" (%u)",subtlv_sum_len
);
1180 while (subtlv_sum_len
>0) {
1181 if (!TTEST2(*tptr
,2))
1183 subtlv_type
=*(tptr
++);
1184 subtlv_len
=*(tptr
++);
1185 /* prepend the ident string */
1186 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1187 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
1190 subtlv_sum_len
-=(subtlv_len
+2);
1191 proc_bytes
+=(subtlv_len
+2);
1198 * this is the common Multi Topology ID decoder
1199 * it is called from various MT-TLVs (222,229,235,237)
1203 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1205 if (!TTEST2(*tptr
, 2))
1210 tok2str(isis_mt_values
,
1211 "Reserved for IETF Consensus",
1212 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1214 printf(" Topology (0x%03x), Flags: [%s]",
1215 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1216 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1222 * this is the common extended IP reach decoder
1223 * it is called from TLVs (135,235,236,237)
1224 * we process the TLV and optional subTLVs and return
1225 * the amount of processed bytes
1229 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1231 char ident_buffer
[20];
1232 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1233 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1235 if (!TTEST2(*tptr
, 4))
1237 metric
= EXTRACT_32BITS(tptr
);
1242 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1244 status_byte
=*(tptr
++);
1245 bit_length
= status_byte
&0x3f;
1248 } else if (afi
== IPV6
) {
1249 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1251 status_byte
=*(tptr
++);
1252 bit_length
=*(tptr
++);
1256 return (0); /* somebody is fooling us */
1258 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1260 if (!TTEST2(*tptr
, byte_length
))
1262 memset(prefix
, 0, 16); /* clear the copy buffer */
1263 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1265 processed
+=byte_length
;
1268 printf("%sIPv4 prefix: %15s/%u",
1270 ipaddr_string(prefix
),
1274 printf("%sIPv6 prefix: %s/%u",
1276 ip6addr_string(prefix
),
1280 printf(", Distribution: %s, Metric: %u",
1281 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
1284 if (afi
== IPV4
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
1285 printf(", sub-TLVs present");
1289 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
1290 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1293 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1294 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1295 /* assume that one prefix can hold more
1296 than one subTLV - therefore the first byte must reflect
1297 the aggregate bytecount of the subTLVs for this prefix
1299 if (!TTEST2(*tptr
, 1))
1302 processed
+=sublen
+1;
1303 printf(" (%u)",sublen
); /* print out subTLV length */
1306 if (!TTEST2(*tptr
,2))
1308 subtlvtype
=*(tptr
++);
1309 subtlvlen
=*(tptr
++);
1310 /* prepend the ident string */
1311 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1312 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1315 sublen
-=(subtlvlen
+2);
1323 * Decode IS-IS packets. Return 0 on error.
1326 static int isis_print (const u_int8_t
*p
, u_int length
)
1328 const struct isis_common_header
*isis_header
;
1330 const struct isis_iih_lan_header
*header_iih_lan
;
1331 const struct isis_iih_ptp_header
*header_iih_ptp
;
1332 const struct isis_lsp_header
*header_lsp
;
1333 const struct isis_csnp_header
*header_csnp
;
1334 const struct isis_psnp_header
*header_psnp
;
1336 const struct isis_tlv_lsp
*tlv_lsp
;
1337 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1338 const struct isis_tlv_is_reach
*tlv_is_reach
;
1339 const struct isis_tlv_es_reach
*tlv_es_reach
;
1341 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1342 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1343 const u_int8_t
*optr
, *pptr
, *tptr
;
1344 u_short packet_len
,pdu_len
;
1348 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1349 need it for parsing the checksum TLV */
1350 isis_header
= (const struct isis_common_header
*)p
;
1351 TCHECK(*isis_header
);
1352 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1353 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1354 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1355 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1356 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1357 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1360 * Sanity checking of the header.
1363 if (isis_header
->version
!= ISIS_VERSION
) {
1364 printf(", version %d packet not supported", isis_header
->version
);
1368 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
1369 printf(", system ID length of %d is not supported",
1370 isis_header
->id_length
);
1374 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
1375 printf(", version %d packet not supported", isis_header
->pdu_version
);
1379 max_area
= isis_header
->max_area
;
1382 max_area
= 3; /* silly shit */
1385 printf(", bad packet -- 255 areas");
1391 id_length
= isis_header
->id_length
;
1394 id_length
= 6; /* silly shit again */
1396 case 1: /* 1-8 are valid sys-ID lenghts */
1406 id_length
= 0; /* entirely useless */
1412 /* toss any non 6-byte sys-ID len PDUs */
1413 if (id_length
!= 6 ) {
1414 printf(", bad packet -- illegal sys-ID length (%u)", id_length
);
1418 pdu_type
=isis_header
->pdu_type
;
1420 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1422 printf(", %s", tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1426 case ISIS_PDU_L1_LAN_IIH
:
1427 case ISIS_PDU_L2_LAN_IIH
:
1428 printf(", src-id %s",
1429 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1430 printf(", lan-id %s, prio %u",
1431 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
1432 header_iih_lan
->priority
);
1434 case ISIS_PDU_PTP_IIH
:
1435 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1437 case ISIS_PDU_L1_LSP
:
1438 case ISIS_PDU_L2_LSP
:
1439 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1440 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1441 EXTRACT_32BITS(header_lsp
->sequence_number
),
1442 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1444 case ISIS_PDU_L1_CSNP
:
1445 case ISIS_PDU_L2_CSNP
:
1446 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,SYSTEM_ID_LEN
));
1448 case ISIS_PDU_L1_PSNP
:
1449 case ISIS_PDU_L2_PSNP
:
1450 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,SYSTEM_ID_LEN
));
1454 printf(", length %u", length
);
1459 /* ok they seem to want to know everything - lets fully decode it */
1460 printf(", length: %u",length
);
1462 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1463 tok2str(isis_pdu_values
,
1466 isis_header
->fixed_len
,
1467 isis_header
->version
,
1468 isis_header
->pdu_version
,
1470 isis_header
->id_length
,
1472 isis_header
->max_area
);
1475 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1476 return(0); /* for optionally debugging the common header */
1481 case ISIS_PDU_L1_LAN_IIH
:
1482 case ISIS_PDU_L2_LAN_IIH
:
1483 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1484 printf(", bogus fixed header length %u should be %lu",
1485 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1489 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1490 if (packet_len
>pdu_len
) {
1491 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1495 TCHECK(*header_iih_lan
);
1496 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1497 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1498 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1499 tok2str(isis_iih_circuit_type_values
,
1500 "unknown circuit type 0x%02x",
1501 header_iih_lan
->circuit_type
));
1503 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1504 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1505 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
1509 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1513 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1514 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1517 case ISIS_PDU_PTP_IIH
:
1518 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1519 printf(", bogus fixed header length %u should be %lu",
1520 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1524 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1525 if (packet_len
>pdu_len
) {
1526 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1530 TCHECK(*header_iih_ptp
);
1531 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1532 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1533 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1534 tok2str(isis_iih_circuit_type_values
,
1535 "unknown circuit type 0x%02x",
1536 header_iih_ptp
->circuit_type
));
1538 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1539 header_iih_ptp
->circuit_id
,
1543 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1547 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1548 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1551 case ISIS_PDU_L1_LSP
:
1552 case ISIS_PDU_L2_LSP
:
1553 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1554 printf(", bogus fixed header length %u should be %lu",
1555 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1559 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1560 if (packet_len
>pdu_len
) {
1561 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1565 TCHECK(*header_lsp
);
1566 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1567 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1568 EXTRACT_32BITS(header_lsp
->sequence_number
),
1569 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
1570 EXTRACT_16BITS(header_lsp
->checksum
));
1572 /* if this is a purge do not attempt to verify the checksum */
1573 if ( EXTRACT_16BITS(header_lsp
->remaining_lifetime
) == 0 &&
1574 EXTRACT_16BITS(header_lsp
->checksum
) == 0)
1575 printf(" (purged)");
1577 /* verify the checksum -
1578 * checking starts at the lsp-id field at byte position [12]
1579 * hence the length needs to be reduced by 12 bytes */
1580 printf(" (%s)", (osi_cksum((u_int8_t
*)header_lsp
->lsp_id
, length
-12)) ? "incorrect" : "correct");
1582 printf(", PDU length: %u, Flags: [ %s",
1584 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1586 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1587 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1588 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1589 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1590 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1591 printf("ATT bit set, ");
1593 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1594 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1597 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1601 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1602 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1605 case ISIS_PDU_L1_CSNP
:
1606 case ISIS_PDU_L2_CSNP
:
1607 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1608 printf(", bogus fixed header length %u should be %lu",
1609 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1613 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1614 if (packet_len
>pdu_len
) {
1615 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1619 TCHECK(*header_csnp
);
1620 printf("\n\t source-id: %s, PDU length: %u",
1621 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
1623 printf("\n\t start lsp-id: %s",
1624 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
1625 printf("\n\t end lsp-id: %s",
1626 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
1629 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1633 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1634 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1637 case ISIS_PDU_L1_PSNP
:
1638 case ISIS_PDU_L2_PSNP
:
1639 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1640 printf("- bogus fixed header length %u should be %lu",
1641 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1645 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1646 if (packet_len
>pdu_len
) {
1647 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1651 TCHECK(*header_psnp
);
1652 printf("\n\t source-id: %s, PDU length: %u",
1653 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
1657 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1661 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1662 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1666 if(!print_unknown_data(pptr
,"\n\t ",length
))
1672 * Now print the TLV's.
1675 while (packet_len
>= 2) {
1676 if (pptr
== snapend
) {
1680 if (!TTEST2(*pptr
, 2)) {
1681 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1682 (long)(pptr
-snapend
));
1687 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
1690 if (tlv_len
> packet_len
) {
1694 /* first lets see if we know the TLVs name*/
1695 printf("\n\t %s TLV #%u, length: %u",
1696 tok2str(isis_tlv_values
,
1702 /* now check if we have a decoder otherwise do a hexdump at the end*/
1704 case ISIS_TLV_AREA_ADDR
:
1705 if (!TTEST2(*tptr
, 1))
1708 while (tmp
&& alen
< tmp
) {
1709 printf("\n\t Area address (length: %u): %s",
1711 print_nsap(tptr
, alen
));
1714 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1716 if (!TTEST2(*tptr
, 1))
1721 case ISIS_TLV_ISNEIGH
:
1722 while (tmp
>= ETHER_ADDR_LEN
) {
1723 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1725 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
1726 tmp
-= ETHER_ADDR_LEN
;
1727 tptr
+= ETHER_ADDR_LEN
;
1731 case ISIS_TLV_ISNEIGH_VARLEN
:
1732 if (!TTEST2(*tptr
, 1))
1734 lan_alen
= *tptr
++; /* LAN adress length */
1736 printf("\n\t LAN address length %u bytes ",lan_alen
);
1737 while (tmp
>= lan_alen
) {
1738 if (!TTEST2(*tptr
, lan_alen
))
1740 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
1746 case ISIS_TLV_PADDING
:
1749 case ISIS_TLV_MT_IS_REACH
:
1750 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1751 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1752 if (mt_len
== 0) /* did something go wrong ? */
1757 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1758 if (ext_is_len
== 0) /* did something go wrong ? */
1766 case ISIS_TLV_IS_ALIAS_ID
:
1767 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
1768 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1769 if (ext_is_len
== 0) /* did something go wrong ? */
1776 case ISIS_TLV_EXT_IS_REACH
:
1777 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1778 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1779 if (ext_is_len
== 0) /* did something go wrong ? */
1785 case ISIS_TLV_IS_REACH
:
1786 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1789 tok2str(isis_is_reach_virtual_values
,
1790 "bogus virtual flag 0x%02x",
1792 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1793 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1794 if (!TTEST(*tlv_is_reach
))
1796 printf("\n\t IS Neighbor: %s",
1797 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
1798 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1799 tmp
-= sizeof(struct isis_tlv_is_reach
);
1804 case ISIS_TLV_ESNEIGH
:
1805 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1806 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1807 if (!TTEST(*tlv_es_reach
))
1809 printf("\n\t ES Neighbor: %s",
1810 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1811 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1812 tmp
-= sizeof(struct isis_tlv_es_reach
);
1817 /* those two TLVs share the same format */
1818 case ISIS_TLV_INT_IP_REACH
:
1819 case ISIS_TLV_EXT_IP_REACH
:
1820 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
1824 case ISIS_TLV_EXTD_IP_REACH
:
1826 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1827 if (ext_ip_len
== 0) /* did something go wrong ? */
1834 case ISIS_TLV_MT_IP_REACH
:
1836 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1837 if (mt_len
== 0) /* did something go wrong ? */
1842 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1843 if (ext_ip_len
== 0) /* did something go wrong ? */
1851 case ISIS_TLV_IP6_REACH
:
1853 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1854 if (ext_ip_len
== 0) /* did something go wrong ? */
1861 case ISIS_TLV_MT_IP6_REACH
:
1863 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1864 if (mt_len
== 0) /* did something go wrong ? */
1869 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1870 if (ext_ip_len
== 0) /* did something go wrong ? */
1877 case ISIS_TLV_IP6ADDR
:
1879 if (!TTEST2(*tptr
, 16))
1882 printf("\n\t IPv6 interface address: %s",
1883 ip6addr_string(tptr
));
1891 if (!TTEST2(*tptr
, 1))
1895 tok2str(isis_subtlv_auth_values
,
1896 "unknown Authentication type 0x%02x",
1900 case ISIS_SUBTLV_AUTH_SIMPLE
:
1901 for(i
=1;i
<tlv_len
;i
++) {
1902 if (!TTEST2(*(tptr
+i
), 1))
1904 printf("%c",*(tptr
+i
));
1907 case ISIS_SUBTLV_AUTH_MD5
:
1908 for(i
=1;i
<tlv_len
;i
++) {
1909 if (!TTEST2(*(tptr
+i
), 1))
1911 printf("%02x",*(tptr
+i
));
1913 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
1914 printf(", (malformed subTLV) ");
1916 case ISIS_SUBTLV_AUTH_PRIVATE
:
1918 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
1924 case ISIS_TLV_PTP_ADJ
:
1925 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
1927 if (!TTEST2(*tptr
, 1))
1929 printf("\n\t Adjacency State: %s (%u)",
1930 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
1934 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
1935 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
1936 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
1938 printf("\n\t Extended Local circuit-ID: 0x%08x",
1939 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
1940 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
1942 if(tmp
>=SYSTEM_ID_LEN
) {
1943 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
1945 printf("\n\t Neighbor System-ID: %s",
1946 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
1949 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
1950 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
1951 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
1953 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
1954 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
1958 case ISIS_TLV_PROTOCOLS
:
1959 printf("\n\t NLPID(s): ");
1961 if (!TTEST2(*(tptr
), 1))
1963 printf("%s (0x%02x)",
1964 tok2str(osi_nlpid_values
,
1968 if (tmp
>1) /* further NPLIDs ? - put comma */
1975 case ISIS_TLV_TE_ROUTER_ID
:
1976 if (!TTEST2(*pptr
, 4))
1978 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
1981 case ISIS_TLV_IPADDR
:
1983 if (!TTEST2(*tptr
, 4))
1985 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1991 case ISIS_TLV_HOSTNAME
:
1992 printf("\n\t Hostname: ");
1994 if (!TTEST2(*tptr
, 1))
1996 printf("%c",*tptr
++);
2001 case ISIS_TLV_SHARED_RISK_GROUP
:
2002 if (!TTEST2(*tptr
, NODE_ID_LEN
))
2004 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
2005 tptr
+=(NODE_ID_LEN
);
2008 if (!TTEST2(*tptr
, 1))
2010 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
2013 if (!TTEST2(*tptr
,4))
2015 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2019 if (!TTEST2(*tptr
,4))
2021 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
2026 if (!TTEST2(*tptr
, 4))
2028 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
2035 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2037 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2039 printf("\n\t lsp-id: %s",
2040 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
2041 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
2043 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
2044 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2046 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
2047 if (!TTEST2(tlv_lsp
->checksum
, 2))
2049 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
2050 tmp
-=sizeof(struct isis_tlv_lsp
);
2055 case ISIS_TLV_CHECKSUM
:
2056 if (!TTEST2(*tptr
, 2))
2058 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
2059 /* do not attempt to verify the checksum if it is zero
2060 * most likely a HMAC-MD5 TLV is also present and
2061 * to avoid conflicts the checksum TLV is zeroed.
2062 * see rfc3358 for details
2064 if (EXTRACT_16BITS(tptr
) == 0)
2065 printf("(unverified)");
2066 else printf("(%s)", osi_cksum(optr
, length
) ? "incorrect" : "correct");
2069 case ISIS_TLV_MT_SUPPORTED
:
2071 /* length can only be a multiple of 2, otherwise there is
2072 something broken -> so decode down until length is 1 */
2074 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2075 if (mt_len
== 0) /* did something go wrong ? */
2080 printf("\n\t malformed MT-ID");
2086 case ISIS_TLV_RESTART_SIGNALING
:
2087 if (!TTEST2(*tptr
, 3))
2089 printf("\n\t Flags [%s], Remaining holding time %us",
2090 bittok2str(isis_restart_flag_values
, "none", *tptr
),
2091 EXTRACT_16BITS(tptr
+1));
2095 case ISIS_TLV_IDRP_INFO
:
2096 if (!TTEST2(*tptr
, 1))
2098 printf("\n\t Inter-Domain Information Type: %s",
2099 tok2str(isis_subtlv_idrp_values
,
2103 case ISIS_SUBTLV_IDRP_ASN
:
2104 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
2106 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
2108 case ISIS_SUBTLV_IDRP_LOCAL
:
2109 case ISIS_SUBTLV_IDRP_RES
:
2111 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
2117 case ISIS_TLV_LSP_BUFFERSIZE
:
2118 if (!TTEST2(*tptr
, 2))
2120 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
2123 case ISIS_TLV_PART_DIS
:
2124 while (tmp
>= SYSTEM_ID_LEN
) {
2125 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2127 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2128 tptr
+=SYSTEM_ID_LEN
;
2133 case ISIS_TLV_PREFIX_NEIGH
:
2134 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2136 printf("\n\t Metric Block");
2137 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2138 tptr
+=sizeof(struct isis_metric_block
);
2139 tmp
-=sizeof(struct isis_metric_block
);
2142 if (!TTEST2(*tptr
, 1))
2144 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2146 if (!TTEST2(*tptr
, prefix_len
/2))
2148 printf("\n\t\tAddress: %s/%u",
2149 print_nsap(tptr
,prefix_len
/2),
2156 case ISIS_TLV_IIH_SEQNR
:
2157 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
2159 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
2162 case ISIS_TLV_VENDOR_PRIVATE
:
2163 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
2165 vendor_id
= EXTRACT_24BITS(tptr
);
2166 printf("\n\t Vendor: %s (%u)",
2167 tok2str(oui_values
,"Unknown",vendor_id
),
2171 if (tmp
> 0) /* hexdump the rest */
2172 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
2176 * FIXME those are the defined TLVs that lack a decoder
2177 * you are welcome to contribute code ;-)
2180 case ISIS_TLV_DECNET_PHASE4
:
2181 case ISIS_TLV_LUCENT_PRIVATE
:
2182 case ISIS_TLV_IPAUTH
:
2183 case ISIS_TLV_NORTEL_PRIVATE1
:
2184 case ISIS_TLV_NORTEL_PRIVATE2
:
2188 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
2193 /* do we want to see an additionally hexdump ? */
2195 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2200 packet_len
-= tlv_len
;
2203 if (packet_len
!= 0) {
2204 printf("\n\t %u straggler bytes", packet_len
);
2209 fputs("[|isis]", stdout
);
2213 printf("\n\t\t packet exceeded snapshot");
2218 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2222 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2224 int32_t c0
= 0, c1
= 0;
2226 while ((int)--len
>= 0) {