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.119 2004-03-24 01:40:44 guy 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
:
1064 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
1065 if (subl
== 8) /* draft-ietf-isis-gmpls-extensions */
1066 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
1069 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1070 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1072 printf(", %s", ipaddr_string(tptr
));
1074 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1075 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1077 bw
.i
= EXTRACT_32BITS(tptr
);
1078 printf(", %.3f Mbps", bw
.f
*8/1000000 );
1081 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1083 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1084 bw
.i
= EXTRACT_32BITS(tptr
);
1085 printf("%s priority level %d: %.3f Mbps",
1093 case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE
:
1095 printf("%sBandwidth Constraints Model ID: (%u)",ident
, *tptr
);
1097 /* for now lets just print the first 8 BCs -
1098 * FIXME is this dep. on the BC model ?
1100 for (bandwidth_constraint
= 0; bandwidth_constraint
< 8; bandwidth_constraint
++) {
1101 bw
.i
= EXTRACT_32BITS(tptr
);
1102 printf("%s Bandwidth constraint %d: %.3f Mbps",
1104 bandwidth_constraint
,
1110 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1112 printf(", %u", EXTRACT_24BITS(tptr
));
1114 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1116 printf(", %s, Priority %u",
1117 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1121 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1123 printf("%s Interface Switching Capability:%s",
1125 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
1126 printf(", LSP Encoding: %s",
1127 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
1129 printf("%s Max LSP Bandwidth:",ident
);
1130 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1131 bw
.i
= EXTRACT_32BITS(tptr
);
1132 printf("%s priority level %d: %.3f Mbps",
1139 /* there is some optional stuff left to decode but this is as of yet
1140 not specified so just lets hexdump what is left */
1142 if(!print_unknown_data(tptr
,"\n\t\t ",
1149 if(!print_unknown_data(tptr
,"\n\t\t ",
1157 printf("%spacket exceeded snapshot",ident
);
1163 * this is the common IS-REACH decoder it is called
1164 * from various EXTD-IS REACH style TLVs (22,24,222)
1168 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
1170 char ident_buffer
[20];
1171 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1172 int proc_bytes
= 0; /* how many bytes did we process ? */
1174 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1177 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1178 tptr
+=(NODE_ID_LEN
);
1180 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1181 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
1183 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1187 if (!TTEST2(*tptr
, 1))
1189 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1190 proc_bytes
=NODE_ID_LEN
+3+1;
1191 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1192 if (subtlv_sum_len
) {
1193 printf(" (%u)",subtlv_sum_len
);
1194 while (subtlv_sum_len
>0) {
1195 if (!TTEST2(*tptr
,2))
1197 subtlv_type
=*(tptr
++);
1198 subtlv_len
=*(tptr
++);
1199 /* prepend the ident string */
1200 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1201 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
1204 subtlv_sum_len
-=(subtlv_len
+2);
1205 proc_bytes
+=(subtlv_len
+2);
1212 * this is the common Multi Topology ID decoder
1213 * it is called from various MT-TLVs (222,229,235,237)
1217 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1219 if (!TTEST2(*tptr
, 2))
1224 tok2str(isis_mt_values
,
1225 "Reserved for IETF Consensus",
1226 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1228 printf(" Topology (0x%03x), Flags: [%s]",
1229 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1230 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1236 * this is the common extended IP reach decoder
1237 * it is called from TLVs (135,235,236,237)
1238 * we process the TLV and optional subTLVs and return
1239 * the amount of processed bytes
1243 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1245 char ident_buffer
[20];
1246 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1247 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1249 if (!TTEST2(*tptr
, 4))
1251 metric
= EXTRACT_32BITS(tptr
);
1256 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1258 status_byte
=*(tptr
++);
1259 bit_length
= status_byte
&0x3f;
1262 } else if (afi
== IPV6
) {
1263 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1265 status_byte
=*(tptr
++);
1266 bit_length
=*(tptr
++);
1270 return (0); /* somebody is fooling us */
1272 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1274 if (!TTEST2(*tptr
, byte_length
))
1276 memset(prefix
, 0, 16); /* clear the copy buffer */
1277 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1279 processed
+=byte_length
;
1282 printf("%sIPv4 prefix: %15s/%u",
1284 ipaddr_string(prefix
),
1288 printf("%sIPv6 prefix: %s/%u",
1290 ip6addr_string(prefix
),
1294 printf(", Distribution: %s, Metric: %u",
1295 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
1298 if (afi
== IPV4
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
1299 printf(", sub-TLVs present");
1303 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
1304 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1307 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1308 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1309 /* assume that one prefix can hold more
1310 than one subTLV - therefore the first byte must reflect
1311 the aggregate bytecount of the subTLVs for this prefix
1313 if (!TTEST2(*tptr
, 1))
1316 processed
+=sublen
+1;
1317 printf(" (%u)",sublen
); /* print out subTLV length */
1320 if (!TTEST2(*tptr
,2))
1322 subtlvtype
=*(tptr
++);
1323 subtlvlen
=*(tptr
++);
1324 /* prepend the ident string */
1325 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1326 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1329 sublen
-=(subtlvlen
+2);
1337 * Decode IS-IS packets. Return 0 on error.
1340 static int isis_print (const u_int8_t
*p
, u_int length
)
1342 const struct isis_common_header
*isis_header
;
1344 const struct isis_iih_lan_header
*header_iih_lan
;
1345 const struct isis_iih_ptp_header
*header_iih_ptp
;
1346 const struct isis_lsp_header
*header_lsp
;
1347 const struct isis_csnp_header
*header_csnp
;
1348 const struct isis_psnp_header
*header_psnp
;
1350 const struct isis_tlv_lsp
*tlv_lsp
;
1351 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1352 const struct isis_tlv_is_reach
*tlv_is_reach
;
1353 const struct isis_tlv_es_reach
*tlv_es_reach
;
1355 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1356 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1357 const u_int8_t
*optr
, *pptr
, *tptr
;
1358 u_short packet_len
,pdu_len
;
1362 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1363 need it for parsing the checksum TLV */
1364 isis_header
= (const struct isis_common_header
*)p
;
1365 TCHECK(*isis_header
);
1366 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1367 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1368 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1369 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1370 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1371 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1374 * Sanity checking of the header.
1377 if (isis_header
->version
!= ISIS_VERSION
) {
1378 printf(", version %d packet not supported", isis_header
->version
);
1382 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
1383 printf(", system ID length of %d is not supported",
1384 isis_header
->id_length
);
1388 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
1389 printf(", version %d packet not supported", isis_header
->pdu_version
);
1393 max_area
= isis_header
->max_area
;
1396 max_area
= 3; /* silly shit */
1399 printf(", bad packet -- 255 areas");
1405 id_length
= isis_header
->id_length
;
1408 id_length
= 6; /* silly shit again */
1410 case 1: /* 1-8 are valid sys-ID lenghts */
1420 id_length
= 0; /* entirely useless */
1426 /* toss any non 6-byte sys-ID len PDUs */
1427 if (id_length
!= 6 ) {
1428 printf(", bad packet -- illegal sys-ID length (%u)", id_length
);
1432 pdu_type
=isis_header
->pdu_type
;
1434 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1436 printf(", %s", tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1440 case ISIS_PDU_L1_LAN_IIH
:
1441 case ISIS_PDU_L2_LAN_IIH
:
1442 printf(", src-id %s",
1443 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1444 printf(", lan-id %s, prio %u",
1445 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
1446 header_iih_lan
->priority
);
1448 case ISIS_PDU_PTP_IIH
:
1449 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1451 case ISIS_PDU_L1_LSP
:
1452 case ISIS_PDU_L2_LSP
:
1453 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1454 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1455 EXTRACT_32BITS(header_lsp
->sequence_number
),
1456 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1458 case ISIS_PDU_L1_CSNP
:
1459 case ISIS_PDU_L2_CSNP
:
1460 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,SYSTEM_ID_LEN
));
1462 case ISIS_PDU_L1_PSNP
:
1463 case ISIS_PDU_L2_PSNP
:
1464 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,SYSTEM_ID_LEN
));
1468 printf(", length %u", length
);
1473 /* ok they seem to want to know everything - lets fully decode it */
1474 printf(", length: %u",length
);
1476 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1477 tok2str(isis_pdu_values
,
1480 isis_header
->fixed_len
,
1481 isis_header
->version
,
1482 isis_header
->pdu_version
,
1484 isis_header
->id_length
,
1486 isis_header
->max_area
);
1489 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1490 return(0); /* for optionally debugging the common header */
1495 case ISIS_PDU_L1_LAN_IIH
:
1496 case ISIS_PDU_L2_LAN_IIH
:
1497 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1498 printf(", bogus fixed header length %u should be %lu",
1499 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1503 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1504 if (packet_len
>pdu_len
) {
1505 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1509 TCHECK(*header_iih_lan
);
1510 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1511 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1512 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1513 tok2str(isis_iih_circuit_type_values
,
1514 "unknown circuit type 0x%02x",
1515 header_iih_lan
->circuit_type
));
1517 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1518 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1519 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
1523 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1527 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1528 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1531 case ISIS_PDU_PTP_IIH
:
1532 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1533 printf(", bogus fixed header length %u should be %lu",
1534 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1538 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1539 if (packet_len
>pdu_len
) {
1540 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1544 TCHECK(*header_iih_ptp
);
1545 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1546 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1547 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1548 tok2str(isis_iih_circuit_type_values
,
1549 "unknown circuit type 0x%02x",
1550 header_iih_ptp
->circuit_type
));
1552 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1553 header_iih_ptp
->circuit_id
,
1557 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1561 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1562 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1565 case ISIS_PDU_L1_LSP
:
1566 case ISIS_PDU_L2_LSP
:
1567 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1568 printf(", bogus fixed header length %u should be %lu",
1569 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1573 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1574 if (packet_len
>pdu_len
) {
1575 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1579 TCHECK(*header_lsp
);
1580 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1581 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1582 EXTRACT_32BITS(header_lsp
->sequence_number
),
1583 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
1584 EXTRACT_16BITS(header_lsp
->checksum
));
1586 /* if this is a purge do not attempt to verify the checksum */
1587 if ( EXTRACT_16BITS(header_lsp
->remaining_lifetime
) == 0 &&
1588 EXTRACT_16BITS(header_lsp
->checksum
) == 0)
1589 printf(" (purged)");
1591 /* verify the checksum -
1592 * checking starts at the lsp-id field at byte position [12]
1593 * hence the length needs to be reduced by 12 bytes */
1594 printf(" (%s)", (osi_cksum((u_int8_t
*)header_lsp
->lsp_id
, length
-12)) ? "incorrect" : "correct");
1596 printf(", PDU length: %u, Flags: [ %s",
1598 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1600 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1601 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1602 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1603 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1604 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1605 printf("ATT bit set, ");
1607 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1608 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1611 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1615 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1616 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1619 case ISIS_PDU_L1_CSNP
:
1620 case ISIS_PDU_L2_CSNP
:
1621 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1622 printf(", bogus fixed header length %u should be %lu",
1623 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1627 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1628 if (packet_len
>pdu_len
) {
1629 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1633 TCHECK(*header_csnp
);
1634 printf("\n\t source-id: %s, PDU length: %u",
1635 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
1637 printf("\n\t start lsp-id: %s",
1638 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
1639 printf("\n\t end lsp-id: %s",
1640 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
1643 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1647 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1648 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1651 case ISIS_PDU_L1_PSNP
:
1652 case ISIS_PDU_L2_PSNP
:
1653 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1654 printf("- bogus fixed header length %u should be %lu",
1655 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1659 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1660 if (packet_len
>pdu_len
) {
1661 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1665 TCHECK(*header_psnp
);
1666 printf("\n\t source-id: %s, PDU length: %u",
1667 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
1671 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1675 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1676 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1680 if(!print_unknown_data(pptr
,"\n\t ",length
))
1686 * Now print the TLV's.
1689 while (packet_len
>= 2) {
1690 if (pptr
== snapend
) {
1694 if (!TTEST2(*pptr
, 2)) {
1695 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1696 (long)(pptr
-snapend
));
1701 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
1704 if (tlv_len
> packet_len
) {
1708 /* first lets see if we know the TLVs name*/
1709 printf("\n\t %s TLV #%u, length: %u",
1710 tok2str(isis_tlv_values
,
1716 /* now check if we have a decoder otherwise do a hexdump at the end*/
1718 case ISIS_TLV_AREA_ADDR
:
1719 if (!TTEST2(*tptr
, 1))
1722 while (tmp
&& alen
< tmp
) {
1723 printf("\n\t Area address (length: %u): %s",
1725 print_nsap(tptr
, alen
));
1728 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1730 if (!TTEST2(*tptr
, 1))
1735 case ISIS_TLV_ISNEIGH
:
1736 while (tmp
>= ETHER_ADDR_LEN
) {
1737 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1739 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
1740 tmp
-= ETHER_ADDR_LEN
;
1741 tptr
+= ETHER_ADDR_LEN
;
1745 case ISIS_TLV_ISNEIGH_VARLEN
:
1746 if (!TTEST2(*tptr
, 1))
1748 lan_alen
= *tptr
++; /* LAN adress length */
1750 printf("\n\t LAN address length %u bytes ",lan_alen
);
1751 while (tmp
>= lan_alen
) {
1752 if (!TTEST2(*tptr
, lan_alen
))
1754 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
1760 case ISIS_TLV_PADDING
:
1763 case ISIS_TLV_MT_IS_REACH
:
1764 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1765 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1766 if (mt_len
== 0) /* did something go wrong ? */
1771 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1772 if (ext_is_len
== 0) /* did something go wrong ? */
1780 case ISIS_TLV_IS_ALIAS_ID
:
1781 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
1782 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1783 if (ext_is_len
== 0) /* did something go wrong ? */
1790 case ISIS_TLV_EXT_IS_REACH
:
1791 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1792 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1793 if (ext_is_len
== 0) /* did something go wrong ? */
1799 case ISIS_TLV_IS_REACH
:
1800 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1803 tok2str(isis_is_reach_virtual_values
,
1804 "bogus virtual flag 0x%02x",
1806 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1807 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1808 if (!TTEST(*tlv_is_reach
))
1810 printf("\n\t IS Neighbor: %s",
1811 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
1812 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1813 tmp
-= sizeof(struct isis_tlv_is_reach
);
1818 case ISIS_TLV_ESNEIGH
:
1819 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1820 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1821 if (!TTEST(*tlv_es_reach
))
1823 printf("\n\t ES Neighbor: %s",
1824 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1825 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1826 tmp
-= sizeof(struct isis_tlv_es_reach
);
1831 /* those two TLVs share the same format */
1832 case ISIS_TLV_INT_IP_REACH
:
1833 case ISIS_TLV_EXT_IP_REACH
:
1834 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
1838 case ISIS_TLV_EXTD_IP_REACH
:
1840 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1841 if (ext_ip_len
== 0) /* did something go wrong ? */
1848 case ISIS_TLV_MT_IP_REACH
:
1850 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1851 if (mt_len
== 0) /* did something go wrong ? */
1856 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1857 if (ext_ip_len
== 0) /* did something go wrong ? */
1865 case ISIS_TLV_IP6_REACH
:
1867 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1868 if (ext_ip_len
== 0) /* did something go wrong ? */
1875 case ISIS_TLV_MT_IP6_REACH
:
1877 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1878 if (mt_len
== 0) /* did something go wrong ? */
1883 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1884 if (ext_ip_len
== 0) /* did something go wrong ? */
1891 case ISIS_TLV_IP6ADDR
:
1893 if (!TTEST2(*tptr
, 16))
1896 printf("\n\t IPv6 interface address: %s",
1897 ip6addr_string(tptr
));
1905 if (!TTEST2(*tptr
, 1))
1909 tok2str(isis_subtlv_auth_values
,
1910 "unknown Authentication type 0x%02x",
1914 case ISIS_SUBTLV_AUTH_SIMPLE
:
1915 for(i
=1;i
<tlv_len
;i
++) {
1916 if (!TTEST2(*(tptr
+i
), 1))
1918 printf("%c",*(tptr
+i
));
1921 case ISIS_SUBTLV_AUTH_MD5
:
1922 for(i
=1;i
<tlv_len
;i
++) {
1923 if (!TTEST2(*(tptr
+i
), 1))
1925 printf("%02x",*(tptr
+i
));
1927 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
1928 printf(", (malformed subTLV) ");
1930 case ISIS_SUBTLV_AUTH_PRIVATE
:
1932 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
1938 case ISIS_TLV_PTP_ADJ
:
1939 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
1941 if (!TTEST2(*tptr
, 1))
1943 printf("\n\t Adjacency State: %s (%u)",
1944 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
1948 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
1949 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
1950 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
1952 printf("\n\t Extended Local circuit-ID: 0x%08x",
1953 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
1954 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
1956 if(tmp
>=SYSTEM_ID_LEN
) {
1957 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
1959 printf("\n\t Neighbor System-ID: %s",
1960 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
1963 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
1964 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
1965 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
1967 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
1968 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
1972 case ISIS_TLV_PROTOCOLS
:
1973 printf("\n\t NLPID(s): ");
1975 if (!TTEST2(*(tptr
), 1))
1977 printf("%s (0x%02x)",
1978 tok2str(osi_nlpid_values
,
1982 if (tmp
>1) /* further NPLIDs ? - put comma */
1989 case ISIS_TLV_TE_ROUTER_ID
:
1990 if (!TTEST2(*pptr
, 4))
1992 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
1995 case ISIS_TLV_IPADDR
:
1997 if (!TTEST2(*tptr
, 4))
1999 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2005 case ISIS_TLV_HOSTNAME
:
2006 printf("\n\t Hostname: ");
2008 if (!TTEST2(*tptr
, 1))
2010 printf("%c",*tptr
++);
2015 case ISIS_TLV_SHARED_RISK_GROUP
:
2016 if (!TTEST2(*tptr
, NODE_ID_LEN
))
2018 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
2019 tptr
+=(NODE_ID_LEN
);
2022 if (!TTEST2(*tptr
, 1))
2024 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
2027 if (!TTEST2(*tptr
,4))
2029 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2033 if (!TTEST2(*tptr
,4))
2035 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
2040 if (!TTEST2(*tptr
, 4))
2042 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
2049 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2051 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2053 printf("\n\t lsp-id: %s",
2054 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
2055 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
2057 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
2058 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2060 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
2061 if (!TTEST2(tlv_lsp
->checksum
, 2))
2063 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
2064 tmp
-=sizeof(struct isis_tlv_lsp
);
2069 case ISIS_TLV_CHECKSUM
:
2070 if (!TTEST2(*tptr
, 2))
2072 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
2073 /* do not attempt to verify the checksum if it is zero
2074 * most likely a HMAC-MD5 TLV is also present and
2075 * to avoid conflicts the checksum TLV is zeroed.
2076 * see rfc3358 for details
2078 if (EXTRACT_16BITS(tptr
) == 0)
2079 printf("(unverified)");
2080 else printf("(%s)", osi_cksum(optr
, length
) ? "incorrect" : "correct");
2083 case ISIS_TLV_MT_SUPPORTED
:
2085 /* length can only be a multiple of 2, otherwise there is
2086 something broken -> so decode down until length is 1 */
2088 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2089 if (mt_len
== 0) /* did something go wrong ? */
2094 printf("\n\t malformed MT-ID");
2100 case ISIS_TLV_RESTART_SIGNALING
:
2101 if (!TTEST2(*tptr
, 3))
2103 printf("\n\t Flags [%s], Remaining holding time %us",
2104 bittok2str(isis_restart_flag_values
, "none", *tptr
),
2105 EXTRACT_16BITS(tptr
+1));
2109 case ISIS_TLV_IDRP_INFO
:
2110 if (!TTEST2(*tptr
, 1))
2112 printf("\n\t Inter-Domain Information Type: %s",
2113 tok2str(isis_subtlv_idrp_values
,
2117 case ISIS_SUBTLV_IDRP_ASN
:
2118 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
2120 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
2122 case ISIS_SUBTLV_IDRP_LOCAL
:
2123 case ISIS_SUBTLV_IDRP_RES
:
2125 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
2131 case ISIS_TLV_LSP_BUFFERSIZE
:
2132 if (!TTEST2(*tptr
, 2))
2134 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
2137 case ISIS_TLV_PART_DIS
:
2138 while (tmp
>= SYSTEM_ID_LEN
) {
2139 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2141 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2142 tptr
+=SYSTEM_ID_LEN
;
2147 case ISIS_TLV_PREFIX_NEIGH
:
2148 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2150 printf("\n\t Metric Block");
2151 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2152 tptr
+=sizeof(struct isis_metric_block
);
2153 tmp
-=sizeof(struct isis_metric_block
);
2156 if (!TTEST2(*tptr
, 1))
2158 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2160 if (!TTEST2(*tptr
, prefix_len
/2))
2162 printf("\n\t\tAddress: %s/%u",
2163 print_nsap(tptr
,prefix_len
/2),
2170 case ISIS_TLV_IIH_SEQNR
:
2171 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
2173 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
2176 case ISIS_TLV_VENDOR_PRIVATE
:
2177 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
2179 vendor_id
= EXTRACT_24BITS(tptr
);
2180 printf("\n\t Vendor: %s (%u)",
2181 tok2str(oui_values
,"Unknown",vendor_id
),
2185 if (tmp
> 0) /* hexdump the rest */
2186 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
2190 * FIXME those are the defined TLVs that lack a decoder
2191 * you are welcome to contribute code ;-)
2194 case ISIS_TLV_DECNET_PHASE4
:
2195 case ISIS_TLV_LUCENT_PRIVATE
:
2196 case ISIS_TLV_IPAUTH
:
2197 case ISIS_TLV_NORTEL_PRIVATE1
:
2198 case ISIS_TLV_NORTEL_PRIVATE2
:
2202 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
2207 /* do we want to see an additionally hexdump ? */
2209 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2214 packet_len
-= tlv_len
;
2217 if (packet_len
!= 0) {
2218 printf("\n\t %u straggler bytes", packet_len
);
2223 fputs("[|isis]", stdout
);
2227 printf("\n\t\t packet exceeded snapshot");
2232 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2236 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2238 int32_t c0
= 0, c1
= 0;
2240 while ((int)--len
>= 0) {