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.115 2004-01-02 09:32:13 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_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
226 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
227 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
229 static struct tok isis_ext_is_reach_subtlv_values
[] = {
230 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
231 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
232 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
233 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
234 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
235 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
236 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
237 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
238 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
239 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
240 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
241 { 250, "Reserved for cisco specific extensions" },
242 { 251, "Reserved for cisco specific extensions" },
243 { 252, "Reserved for cisco specific extensions" },
244 { 253, "Reserved for cisco specific extensions" },
245 { 254, "Reserved for cisco specific extensions" },
246 { 255, "Reserved for future expansion" },
250 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
251 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
252 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
254 static struct tok isis_ext_ip_reach_subtlv_values
[] = {
255 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
256 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
257 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
261 #define ISIS_SUBTLV_AUTH_SIMPLE 1
262 #define ISIS_SUBTLV_AUTH_MD5 54
263 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
264 #define ISIS_SUBTLV_AUTH_PRIVATE 255
266 static struct tok isis_subtlv_auth_values
[] = {
267 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
268 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
269 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
273 #define ISIS_SUBTLV_IDRP_RES 0
274 #define ISIS_SUBTLV_IDRP_LOCAL 1
275 #define ISIS_SUBTLV_IDRP_ASN 2
277 static struct tok isis_subtlv_idrp_values
[] = {
278 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
279 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
280 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
284 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
285 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
286 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
287 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
288 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
289 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
290 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
291 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
293 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
294 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
296 static struct tok isis_mt_flag_values
[] = {
297 { 0x4000, "sub-TLVs present"},
298 { 0x8000, "ATT bit set"},
302 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
303 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
305 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
306 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
308 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
309 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
310 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
311 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
313 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
315 static struct tok isis_mt_values
[] = {
316 { 0, "IPv4 unicast"},
317 { 1, "In-Band Management"},
318 { 2, "IPv6 unicast"},
320 { 4095, "Development, Experimental or Proprietary"},
324 static struct tok isis_iih_circuit_type_values
[] = {
325 { 1, "Level 1 only"},
326 { 2, "Level 2 only"},
327 { 3, "Level 1, Level 2"},
331 #define ISIS_LSP_TYPE_UNUSED0 0
332 #define ISIS_LSP_TYPE_LEVEL_1 1
333 #define ISIS_LSP_TYPE_UNUSED2 2
334 #define ISIS_LSP_TYPE_LEVEL_2 3
336 static struct tok isis_lsp_istype_values
[] = {
337 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
338 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
339 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
340 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
345 * Katz's point to point adjacency TLV uses codes to tell us the state of
346 * the remote adjacency. Enumerate them.
349 #define ISIS_PTP_ADJ_UP 0
350 #define ISIS_PTP_ADJ_INIT 1
351 #define ISIS_PTP_ADJ_DOWN 2
353 static struct tok isis_ptp_adjancey_values
[] = {
354 { ISIS_PTP_ADJ_UP
, "Up" },
355 { ISIS_PTP_ADJ_INIT
, "Initializing" },
356 { ISIS_PTP_ADJ_DOWN
, "Down" },
360 struct isis_tlv_ptp_adj
{
361 u_int8_t adjacency_state
;
362 u_int8_t extd_local_circuit_id
[4];
363 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
364 u_int8_t neighbor_extd_local_circuit_id
[4];
367 static int osi_cksum(const u_int8_t
*, u_int
);
368 static int clnp_print(const u_int8_t
*, u_int
);
369 static void esis_print(const u_int8_t
*, u_int
);
370 static int isis_print(const u_int8_t
*, u_int
);
372 struct isis_metric_block
{
373 u_int8_t metric_default
;
374 u_int8_t metric_delay
;
375 u_int8_t metric_expense
;
376 u_int8_t metric_error
;
379 struct isis_tlv_is_reach
{
380 struct isis_metric_block isis_metric_block
;
381 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
384 struct isis_tlv_es_reach
{
385 struct isis_metric_block isis_metric_block
;
386 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
389 struct isis_tlv_ip_reach
{
390 struct isis_metric_block isis_metric_block
;
395 static struct tok isis_is_reach_virtual_values
[] = {
396 { 0, "IsNotVirtual"},
401 static struct tok isis_restart_flag_values
[] = {
402 { 0x1, "Restart Request"},
403 { 0x2, "Restart Acknowledgement"},
407 struct isis_common_header
{
410 u_int8_t version
; /* Protocol version */
412 u_int8_t pdu_type
; /* 3 MSbits are reserved */
413 u_int8_t pdu_version
; /* Packet format version */
418 struct isis_iih_lan_header
{
419 u_int8_t circuit_type
;
420 u_int8_t source_id
[SYSTEM_ID_LEN
];
421 u_int8_t holding_time
[2];
424 u_int8_t lan_id
[NODE_ID_LEN
];
427 struct isis_iih_ptp_header
{
428 u_int8_t circuit_type
;
429 u_int8_t source_id
[SYSTEM_ID_LEN
];
430 u_int8_t holding_time
[2];
435 struct isis_lsp_header
{
437 u_int8_t remaining_lifetime
[2];
438 u_int8_t lsp_id
[LSP_ID_LEN
];
439 u_int8_t sequence_number
[4];
440 u_int8_t checksum
[2];
444 struct isis_csnp_header
{
446 u_int8_t source_id
[NODE_ID_LEN
];
447 u_int8_t start_lsp_id
[LSP_ID_LEN
];
448 u_int8_t end_lsp_id
[LSP_ID_LEN
];
451 struct isis_psnp_header
{
453 u_int8_t source_id
[NODE_ID_LEN
];
456 struct isis_tlv_lsp
{
457 u_int8_t remaining_lifetime
[2];
458 u_int8_t lsp_id
[LSP_ID_LEN
];
459 u_int8_t sequence_number
[4];
460 u_int8_t checksum
[2];
464 print_nsap(register const u_int8_t
*pptr
, register int nsap_length
)
467 static char nsap_ascii_output
[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")];
468 char *junk_buf
= nsap_ascii_output
;
470 if (nsap_length
< 1 || nsap_length
> NSAP_MAX_LENGTH
) {
471 snprintf(nsap_ascii_output
, sizeof(nsap_ascii_output
),
473 return (nsap_ascii_output
);
476 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
477 if (!TTEST2(*pptr
, 1))
480 sizeof(nsap_ascii_output
) - (junk_buf
- nsap_ascii_output
),
482 junk_buf
+= strlen(junk_buf
);
483 if (((nsap_idx
& 1) == 0) &&
484 (nsap_idx
+ 1 < nsap_length
)) {
489 return (nsap_ascii_output
);
492 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
493 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
494 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
495 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
496 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
497 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
499 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
501 const struct isis_common_header
*header
;
503 header
= (const struct isis_common_header
*)p
;
505 if (caplen
<= 1) { /* enough bytes on the wire ? */
510 printf("OSI, %s",tok2str(osi_nlpid_values
,"Unknown NLPID (0x%02x)",*p
));
515 if (!clnp_print(p
, length
))
516 print_unknown_data(p
,"\n\t",caplen
);
520 esis_print(p
, length
);
524 if (!isis_print(p
, length
))
525 print_unknown_data(p
,"\n\t",caplen
);
529 (void)printf(", length: %u", length
);
533 (void)printf(", length: %u", length
);
535 print_unknown_data(p
,"\n\t",caplen
);
540 #define CLNP_PDU_ER 1
541 #define CLNP_PDU_DT 28
542 #define CLNP_PDU_MD 29
543 #define CLNP_PDU_ERQ 30
544 #define CLNP_PDU_ERP 31
546 static struct tok clnp_pdu_values
[] = {
547 { CLNP_PDU_ER
, "Error Report"},
548 { CLNP_PDU_MD
, "MD"},
549 { CLNP_PDU_DT
, "Data"},
550 { CLNP_PDU_ERQ
, "Echo Request"},
551 { CLNP_PDU_ERP
, "Echo Response"},
555 struct clnp_header_t
{
557 u_int8_t length_indicator
;
559 u_int8_t lifetime
; /* units of 500ms */
561 u_int8_t segment_length
[2];
567 * Decode CLNP packets. Return 0 on error.
570 static int clnp_print (const u_int8_t
*pptr
, u_int length
)
572 const u_int8_t
*optr
,*source_address
,*dest_address
;
573 u_int li
,source_address_length
,dest_address_length
, clnp_pdu_type
;
574 const struct clnp_header_t
*clnp_header
;
576 clnp_header
= (const struct clnp_header_t
*) pptr
;
577 li
= clnp_header
->length_indicator
;
581 * Sanity checking of the header.
586 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
588 pptr
+= sizeof(struct clnp_header_t
);
589 dest_address_length
= *pptr
;
590 dest_address
= pptr
+ 1;
592 pptr
+= (1 + dest_address_length
);
593 source_address_length
= *pptr
;
594 source_address
= pptr
+1;
596 pptr
+= (1 + source_address_length
);
599 printf(", %s > %s, length %u",
600 print_nsap(source_address
, source_address_length
),
601 print_nsap(dest_address
, dest_address_length
),
605 printf(", length %u", length
);
607 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, PDU length: %u, checksum: 0x%04x ",
608 tok2str(clnp_pdu_values
,
611 clnp_header
->length_indicator
,
612 clnp_header
->version
,
613 clnp_header
->lifetime
/2,
614 (clnp_header
->lifetime
%2)*5,
615 EXTRACT_16BITS(clnp_header
->segment_length
),
616 EXTRACT_16BITS(clnp_header
->cksum
));
618 /* do not attempt to verify the checksum if it is zero */
619 if (EXTRACT_16BITS(clnp_header
->cksum
) == 0)
620 printf("(unverified)");
621 else printf("(%s)", osi_cksum(optr
, li
) ? "incorrect" : "correct");
623 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
624 source_address_length
,
625 print_nsap(source_address
, source_address_length
),
627 print_nsap(dest_address
, dest_address_length
));
629 /* dump the remaining header data */
630 print_unknown_data(pptr
,"\n\t",clnp_header
->length_indicator
-(pptr
-optr
));
632 switch (clnp_pdu_type
) {
641 /* dump the PDU specific data */
642 print_unknown_data(optr
+clnp_header
->length_indicator
,"\n\t ",length
-clnp_header
->length_indicator
);
650 #define ESIS_PDU_REDIRECT 6
651 #define ESIS_PDU_ESH 2
652 #define ESIS_PDU_ISH 4
654 static struct tok esis_pdu_values
[] = {
655 { ESIS_PDU_REDIRECT
, "redirect"},
656 { ESIS_PDU_ESH
, "ESH"},
657 { ESIS_PDU_ISH
, "ISH"},
661 struct esis_header_t
{
663 u_int8_t length_indicator
;
667 u_int8_t holdtime
[2];
672 esis_print(const u_int8_t
*pptr
, u_int length
)
674 const u_int8_t
*optr
;
675 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
676 const struct esis_header_t
*esis_header
;
682 printf(" no header at all!");
686 esis_header
= (const struct esis_header_t
*) pptr
;
687 li
= esis_header
->length_indicator
;
691 * Sanity checking of the header.
694 if (esis_header
->nlpid
!= NLPID_ESIS
) {
695 printf(", nlpid 0x%02x packet not supported", esis_header
->nlpid
);
699 if (esis_header
->version
!= ESIS_VERSION
) {
700 printf(", version %d packet not supported", esis_header
->version
);
705 printf(", length indicator(%d) > PDU size (%d)!", li
, length
);
709 if (li
< sizeof(struct esis_header_t
) + 2) {
710 printf(", length indicator < min PDU size %d:", li
);
711 while (--length
!= 0)
712 printf("%02X", *pptr
++);
716 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
719 printf(", %s, length %u",
720 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
724 printf(", length %u\n\t%s (%u)",
726 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
729 printf(", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" );
730 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header
->cksum
));
731 /* do not attempt to verify the checksum if it is zero */
732 if (EXTRACT_16BITS(esis_header
->cksum
) == 0)
733 printf("(unverified)");
734 else printf("(%s)", osi_cksum(pptr
, li
) ? "incorrect" : "correct");
736 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header
->holdtime
),li
);
739 print_unknown_data(optr
,"\n\t",sizeof(struct esis_header_t
));
741 pptr
+= sizeof(struct esis_header_t
);
742 li
-= sizeof(struct esis_header_t
);
744 switch (esis_pdu_type
) {
745 case ESIS_PDU_REDIRECT
: {
746 const u_int8_t
*dst
, *snpa
, *tptr
;
748 dst
= pptr
; pptr
+= *pptr
+ 1;
751 printf("\n\t %s", isonsap_string(dst
));
752 snpa
= pptr
; pptr
+= *pptr
+ 1;
753 tptr
= pptr
; pptr
+= *pptr
+ 1;
758 printf("\n\t %s", etheraddr_string(&snpa
[1]));
760 printf("\n\t %s", isonsap_string(tptr
));
765 source_address_number
= *pptr
;
769 printf("\n\t Number of Source Addresses: %u", source_address_number
);
771 while (source_address_number
> 0) {
772 source_address_length
= *pptr
;
773 printf("\n\t NET (length: %u): %s",
774 source_address_length
,
775 print_nsap(pptr
+1, source_address_length
));
777 pptr
+= source_address_length
+1;
778 li
-= source_address_length
+1;
779 source_address_number
--;
785 source_address_length
= *pptr
;
786 printf("\n\t NET (length: %u): %s", source_address_length
, print_nsap(pptr
+1, source_address_length
));
787 pptr
+= source_address_length
+1;
788 li
-= source_address_length
+1;
795 print_unknown_data(pptr
,"\n\t ",snapend
-pptr
);
800 /* now walk the options */
803 const u_int8_t
*tptr
;
805 if (snapend
- pptr
< 2)
808 printf(", bad opts/li");
815 printf(", opt (%d) too long", op
);
824 printf("\n\t %s Option #%u, length %u, value: ",
825 tok2str(esis_option_values
,"Unknown",op
),
831 case ESIS_OPTION_ES_CONF_TIME
:
832 printf("%us", EXTRACT_16BITS(tptr
));
836 case ESIS_OPTION_PROTOCOLS
:
838 printf("%s (0x%02x)",
839 tok2str(osi_nlpid_values
,
843 if (opli
>1) /* further NPLIDs ? - put comma */
851 * FIXME those are the defined Options that lack a decoder
852 * you are welcome to contribute code ;-)
855 case ESIS_OPTION_QOS_MAINTENANCE
:
856 case ESIS_OPTION_SECURITY
:
857 case ESIS_OPTION_PRIORITY
:
858 case ESIS_OPTION_ADDRESS_MASK
:
859 case ESIS_OPTION_SNPA_MASK
:
862 print_unknown_data(tptr
,"\n\t ",opli
);
866 print_unknown_data(pptr
,"\n\t ",opli
);
871 /* shared routine for printing system, node and lsp-ids */
873 isis_print_id(const u_int8_t
*cp
, int id_len
)
876 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
879 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
880 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
882 if (i
== 2 || i
== 4)
885 if (id_len
>= NODE_ID_LEN
) {
886 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
889 if (id_len
== LSP_ID_LEN
)
890 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
894 /* print the 4-byte metric block which is common found in the old-style TLVs */
896 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
898 printf(", Default Metric: %d, %s",
899 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
900 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
901 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
902 printf("\n\t\t Delay Metric: %d, %s",
903 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
904 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
905 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
906 printf("\n\t\t Expense Metric: %d, %s",
907 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
908 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
909 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
910 printf("\n\t\t Error Metric: %d, %s",
911 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
912 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
914 return(1); /* everything is ok */
918 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
921 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
923 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
926 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
927 printf("short IPv4 Reachability (%d vs %lu)",
929 (unsigned long)sizeof(*tlv_ip_reach
));
933 if (!TTEST(*tlv_ip_reach
))
936 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
938 if (prefix_len
== -1)
939 printf("%sIPv4 prefix: %s mask %s",
941 ipaddr_string((tlv_ip_reach
->prefix
)),
942 ipaddr_string((tlv_ip_reach
->mask
)));
944 printf("%sIPv4 prefix: %15s/%u",
946 ipaddr_string((tlv_ip_reach
->prefix
)),
949 printf(", Distribution: %s, Metric: %u, %s",
950 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
951 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
952 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
954 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
955 printf("%s Delay Metric: %u, %s",
957 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
958 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
960 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
961 printf("%s Expense Metric: %u, %s",
963 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
964 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
966 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
967 printf("%s Error Metric: %u, %s",
969 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
970 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
972 length
-= sizeof(struct isis_tlv_ip_reach
);
979 * this is the common IP-REACH subTLV decoder it is called
980 * from various EXTD-IP REACH TLVs (135,235,236,237)
984 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
986 /* first lets see if we know the subTLVs name*/
987 printf("%s%s subTLV #%u, length: %u",
989 tok2str(isis_ext_ip_reach_subtlv_values
,
995 if (!TTEST2(*tptr
,subl
))
999 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1000 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1002 printf(", 0x%08x (=%u)",
1003 EXTRACT_32BITS(tptr
),
1004 EXTRACT_32BITS(tptr
));
1009 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1011 printf(", 0x%08x%08x",
1012 EXTRACT_32BITS(tptr
),
1013 EXTRACT_32BITS(tptr
+4));
1019 if(!print_unknown_data(tptr
,"\n\t\t ",
1027 printf("%spacket exceeded snapshot",ident
);
1032 * this is the common IS-REACH subTLV decoder it is called
1033 * from isis_print_ext_is_reach()
1037 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
1040 union { /* int to float conversion buffer for several subTLVs */
1045 /* first lets see if we know the subTLVs name*/
1046 printf("%s%s subTLV #%u, length: %u",
1048 tok2str(isis_ext_is_reach_subtlv_values
,
1054 if (!TTEST2(*tptr
,subl
))
1058 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1059 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1060 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1061 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
1062 if (subl
== 8) /* draft-ietf-isis-gmpls-extensions */
1063 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
1065 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1066 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1067 printf(", %s", ipaddr_string(tptr
));
1069 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1070 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1071 bw
.i
= EXTRACT_32BITS(tptr
);
1072 printf(", %.3f Mbps", bw
.f
*8/1000000 );
1074 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1075 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1076 bw
.i
= EXTRACT_32BITS(tptr
);
1077 printf("%s priority level %d: %.3f Mbps",
1084 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1085 printf(", %u", EXTRACT_24BITS(tptr
));
1087 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1088 printf(", %s, Priority %u",
1089 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1092 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1093 printf("%s Interface Switching Capability:%s",
1095 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
1096 printf(", LSP Encoding: %s",
1097 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
1099 printf("%s Max LSP Bandwidth:",ident
);
1100 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1101 bw
.i
= EXTRACT_32BITS(tptr
);
1102 printf("%s priority level %d: %.3f Mbps",
1109 /* there is some optional stuff left to decode but this is as of yet
1110 not specified so just lets hexdump what is left */
1112 if(!print_unknown_data(tptr
,"\n\t\t ",
1118 if(!print_unknown_data(tptr
,"\n\t\t ",
1126 printf("%spacket exceeded snapshot",ident
);
1132 * this is the common IS-REACH decoder it is called
1133 * from various EXTD-IS REACH style TLVs (22,24,222)
1137 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
1139 char ident_buffer
[20];
1140 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1141 int proc_bytes
= 0; /* how many bytes did we process ? */
1143 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1146 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1147 tptr
+=(NODE_ID_LEN
);
1149 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1150 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
1152 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1156 if (!TTEST2(*tptr
, 1))
1158 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1159 proc_bytes
=NODE_ID_LEN
+3+1;
1160 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1161 if (subtlv_sum_len
) {
1162 printf(" (%u)",subtlv_sum_len
);
1163 while (subtlv_sum_len
>0) {
1164 if (!TTEST2(*tptr
,2))
1166 subtlv_type
=*(tptr
++);
1167 subtlv_len
=*(tptr
++);
1168 /* prepend the ident string */
1169 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1170 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
1173 subtlv_sum_len
-=(subtlv_len
+2);
1174 proc_bytes
+=(subtlv_len
+2);
1181 * this is the common Multi Topology ID decoder
1182 * it is called from various MT-TLVs (222,229,235,237)
1186 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1188 if (!TTEST2(*tptr
, 2))
1193 tok2str(isis_mt_values
,
1194 "Reserved for IETF Consensus",
1195 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1197 printf(" Topology (0x%03x), Flags: [%s]",
1198 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1199 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1205 * this is the common extended IP reach decoder
1206 * it is called from TLVs (135,235,236,237)
1207 * we process the TLV and optional subTLVs and return
1208 * the amount of processed bytes
1212 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1214 char ident_buffer
[20];
1215 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1216 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1218 if (!TTEST2(*tptr
, 4))
1220 metric
= EXTRACT_32BITS(tptr
);
1225 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1227 status_byte
=*(tptr
++);
1228 bit_length
= status_byte
&0x3f;
1231 } else if (afi
== IPV6
) {
1232 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1234 status_byte
=*(tptr
++);
1235 bit_length
=*(tptr
++);
1239 return (0); /* somebody is fooling us */
1241 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1243 if (!TTEST2(*tptr
, byte_length
))
1245 memset(prefix
, 0, 16); /* clear the copy buffer */
1246 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1248 processed
+=byte_length
;
1251 printf("%sIPv4 prefix: %15s/%u",
1253 ipaddr_string(prefix
),
1257 printf("%sIPv6 prefix: %s/%u",
1259 ip6addr_string(prefix
),
1263 printf(", Distribution: %s, Metric: %u",
1264 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
1267 if (afi
== IPV4
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
1268 printf(", sub-TLVs present");
1272 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
1273 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1276 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1277 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1278 /* assume that one prefix can hold more
1279 than one subTLV - therefore the first byte must reflect
1280 the aggregate bytecount of the subTLVs for this prefix
1282 if (!TTEST2(*tptr
, 1))
1285 processed
+=sublen
+1;
1286 printf(" (%u)",sublen
); /* print out subTLV length */
1289 if (!TTEST2(*tptr
,2))
1291 subtlvtype
=*(tptr
++);
1292 subtlvlen
=*(tptr
++);
1293 /* prepend the ident string */
1294 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1295 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1298 sublen
-=(subtlvlen
+2);
1306 * Decode IS-IS packets. Return 0 on error.
1309 static int isis_print (const u_int8_t
*p
, u_int length
)
1311 const struct isis_common_header
*isis_header
;
1313 const struct isis_iih_lan_header
*header_iih_lan
;
1314 const struct isis_iih_ptp_header
*header_iih_ptp
;
1315 const struct isis_lsp_header
*header_lsp
;
1316 const struct isis_csnp_header
*header_csnp
;
1317 const struct isis_psnp_header
*header_psnp
;
1319 const struct isis_tlv_lsp
*tlv_lsp
;
1320 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1321 const struct isis_tlv_is_reach
*tlv_is_reach
;
1322 const struct isis_tlv_es_reach
*tlv_es_reach
;
1324 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1325 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1326 const u_int8_t
*optr
, *pptr
, *tptr
;
1327 u_short packet_len
,pdu_len
;
1331 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1332 need it for parsing the checksum TLV */
1333 isis_header
= (const struct isis_common_header
*)p
;
1334 TCHECK(*isis_header
);
1335 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1336 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1337 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1338 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1339 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1340 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1343 * Sanity checking of the header.
1346 if (isis_header
->version
!= ISIS_VERSION
) {
1347 printf(", version %d packet not supported", isis_header
->version
);
1351 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
1352 printf(", system ID length of %d is not supported",
1353 isis_header
->id_length
);
1357 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
1358 printf(", version %d packet not supported", isis_header
->pdu_version
);
1362 max_area
= isis_header
->max_area
;
1365 max_area
= 3; /* silly shit */
1368 printf(", bad packet -- 255 areas");
1374 id_length
= isis_header
->id_length
;
1377 id_length
= 6; /* silly shit again */
1379 case 1: /* 1-8 are valid sys-ID lenghts */
1389 id_length
= 0; /* entirely useless */
1395 /* toss any non 6-byte sys-ID len PDUs */
1396 if (id_length
!= 6 ) {
1397 printf(", bad packet -- illegal sys-ID length (%u)", id_length
);
1401 pdu_type
=isis_header
->pdu_type
;
1403 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1405 printf(", %s", tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1409 case ISIS_PDU_L1_LAN_IIH
:
1410 case ISIS_PDU_L2_LAN_IIH
:
1411 printf(", src-id %s",
1412 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1413 printf(", lan-id %s, prio %u",
1414 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
1415 header_iih_lan
->priority
);
1417 case ISIS_PDU_PTP_IIH
:
1418 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1420 case ISIS_PDU_L1_LSP
:
1421 case ISIS_PDU_L2_LSP
:
1422 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1423 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1424 EXTRACT_32BITS(header_lsp
->sequence_number
),
1425 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1427 case ISIS_PDU_L1_CSNP
:
1428 case ISIS_PDU_L2_CSNP
:
1429 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,SYSTEM_ID_LEN
));
1431 case ISIS_PDU_L1_PSNP
:
1432 case ISIS_PDU_L2_PSNP
:
1433 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,SYSTEM_ID_LEN
));
1437 printf(", length %u", length
);
1442 /* ok they seem to want to know everything - lets fully decode it */
1443 printf(", length: %u",length
);
1445 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1446 tok2str(isis_pdu_values
,
1449 isis_header
->fixed_len
,
1450 isis_header
->version
,
1451 isis_header
->pdu_version
,
1453 isis_header
->id_length
,
1455 isis_header
->max_area
);
1458 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1459 return(0); /* for optionally debugging the common header */
1464 case ISIS_PDU_L1_LAN_IIH
:
1465 case ISIS_PDU_L2_LAN_IIH
:
1466 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1467 printf(", bogus fixed header length %u should be %lu",
1468 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1472 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1473 if (packet_len
>pdu_len
) {
1474 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1478 TCHECK(*header_iih_lan
);
1479 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1480 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1481 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1482 tok2str(isis_iih_circuit_type_values
,
1483 "unknown circuit type 0x%02x",
1484 header_iih_lan
->circuit_type
));
1486 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1487 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1488 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
1492 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1496 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1497 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1500 case ISIS_PDU_PTP_IIH
:
1501 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1502 printf(", bogus fixed header length %u should be %lu",
1503 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1507 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1508 if (packet_len
>pdu_len
) {
1509 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1513 TCHECK(*header_iih_ptp
);
1514 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1515 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1516 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1517 tok2str(isis_iih_circuit_type_values
,
1518 "unknown circuit type 0x%02x",
1519 header_iih_ptp
->circuit_type
));
1521 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1522 header_iih_ptp
->circuit_id
,
1526 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1530 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1531 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1534 case ISIS_PDU_L1_LSP
:
1535 case ISIS_PDU_L2_LSP
:
1536 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1537 printf(", bogus fixed header length %u should be %lu",
1538 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1542 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1543 if (packet_len
>pdu_len
) {
1544 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1548 TCHECK(*header_lsp
);
1549 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1550 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1551 EXTRACT_32BITS(header_lsp
->sequence_number
),
1552 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
1553 EXTRACT_16BITS(header_lsp
->checksum
));
1555 /* if this is a purge do not attempt to verify the checksum */
1556 if ( EXTRACT_16BITS(header_lsp
->remaining_lifetime
) == 0 &&
1557 EXTRACT_16BITS(header_lsp
->checksum
) == 0)
1558 printf(" (purged)");
1560 /* verify the checksum -
1561 * checking starts at the lsp-id field at byte position [12]
1562 * hence the length needs to be reduced by 12 bytes */
1563 printf(" (%s)", (osi_cksum((u_int8_t
*)header_lsp
->lsp_id
, length
-12)) ? "incorrect" : "correct");
1565 printf(", PDU length: %u, Flags: [ %s",
1567 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1569 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1570 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1571 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1572 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1573 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1574 printf("ATT bit set, ");
1576 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1577 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1580 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1584 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1585 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1588 case ISIS_PDU_L1_CSNP
:
1589 case ISIS_PDU_L2_CSNP
:
1590 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1591 printf(", bogus fixed header length %u should be %lu",
1592 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1596 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1597 if (packet_len
>pdu_len
) {
1598 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1602 TCHECK(*header_csnp
);
1603 printf("\n\t source-id: %s, PDU length: %u",
1604 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
1606 printf("\n\t start lsp-id: %s",
1607 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
1608 printf("\n\t end lsp-id: %s",
1609 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
1612 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1616 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1617 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1620 case ISIS_PDU_L1_PSNP
:
1621 case ISIS_PDU_L2_PSNP
:
1622 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1623 printf("- bogus fixed header length %u should be %lu",
1624 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1628 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1629 if (packet_len
>pdu_len
) {
1630 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1634 TCHECK(*header_psnp
);
1635 printf("\n\t source-id: %s, PDU length: %u",
1636 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
1640 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1644 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1645 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1649 if(!print_unknown_data(pptr
,"\n\t ",length
))
1655 * Now print the TLV's.
1658 while (packet_len
>= 2) {
1659 if (pptr
== snapend
) {
1663 if (!TTEST2(*pptr
, 2)) {
1664 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1665 (long)(pptr
-snapend
));
1670 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
1673 if (tlv_len
> packet_len
) {
1677 /* first lets see if we know the TLVs name*/
1678 printf("\n\t %s TLV #%u, length: %u",
1679 tok2str(isis_tlv_values
,
1685 /* now check if we have a decoder otherwise do a hexdump at the end*/
1687 case ISIS_TLV_AREA_ADDR
:
1688 if (!TTEST2(*tptr
, 1))
1691 while (tmp
&& alen
< tmp
) {
1692 printf("\n\t Area address (length: %u): %s",
1694 print_nsap(tptr
, alen
));
1697 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1699 if (!TTEST2(*tptr
, 1))
1704 case ISIS_TLV_ISNEIGH
:
1705 while (tmp
>= ETHER_ADDR_LEN
) {
1706 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1708 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
1709 tmp
-= ETHER_ADDR_LEN
;
1710 tptr
+= ETHER_ADDR_LEN
;
1714 case ISIS_TLV_ISNEIGH_VARLEN
:
1715 if (!TTEST2(*tptr
, 1))
1717 lan_alen
= *tptr
++; /* LAN adress length */
1719 printf("\n\t LAN address length %u bytes ",lan_alen
);
1720 while (tmp
>= lan_alen
) {
1721 if (!TTEST2(*tptr
, lan_alen
))
1723 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
1729 case ISIS_TLV_PADDING
:
1732 case ISIS_TLV_MT_IS_REACH
:
1733 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1734 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1735 if (mt_len
== 0) /* did something go wrong ? */
1740 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1741 if (ext_is_len
== 0) /* did something go wrong ? */
1749 case ISIS_TLV_IS_ALIAS_ID
:
1750 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
1751 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1752 if (ext_is_len
== 0) /* did something go wrong ? */
1759 case ISIS_TLV_EXT_IS_REACH
:
1760 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1761 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1762 if (ext_is_len
== 0) /* did something go wrong ? */
1768 case ISIS_TLV_IS_REACH
:
1769 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1772 tok2str(isis_is_reach_virtual_values
,
1773 "bogus virtual flag 0x%02x",
1775 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1776 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1777 if (!TTEST(*tlv_is_reach
))
1779 printf("\n\t IS Neighbor: %s",
1780 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
1781 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1782 tmp
-= sizeof(struct isis_tlv_is_reach
);
1787 case ISIS_TLV_ESNEIGH
:
1788 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1789 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1790 if (!TTEST(*tlv_es_reach
))
1792 printf("\n\t ES Neighbor: %s",
1793 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1794 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1795 tmp
-= sizeof(struct isis_tlv_es_reach
);
1800 /* those two TLVs share the same format */
1801 case ISIS_TLV_INT_IP_REACH
:
1802 case ISIS_TLV_EXT_IP_REACH
:
1803 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
1807 case ISIS_TLV_EXTD_IP_REACH
:
1809 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1810 if (ext_ip_len
== 0) /* did something go wrong ? */
1817 case ISIS_TLV_MT_IP_REACH
:
1819 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1820 if (mt_len
== 0) /* did something go wrong ? */
1825 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1826 if (ext_ip_len
== 0) /* did something go wrong ? */
1834 case ISIS_TLV_IP6_REACH
:
1836 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1837 if (ext_ip_len
== 0) /* did something go wrong ? */
1844 case ISIS_TLV_MT_IP6_REACH
:
1846 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1847 if (mt_len
== 0) /* did something go wrong ? */
1852 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1853 if (ext_ip_len
== 0) /* did something go wrong ? */
1860 case ISIS_TLV_IP6ADDR
:
1862 if (!TTEST2(*tptr
, 16))
1865 printf("\n\t IPv6 interface address: %s",
1866 ip6addr_string(tptr
));
1874 if (!TTEST2(*tptr
, 1))
1878 tok2str(isis_subtlv_auth_values
,
1879 "unknown Authentication type 0x%02x",
1883 case ISIS_SUBTLV_AUTH_SIMPLE
:
1884 for(i
=1;i
<tlv_len
;i
++) {
1885 if (!TTEST2(*(tptr
+i
), 1))
1887 printf("%c",*(tptr
+i
));
1890 case ISIS_SUBTLV_AUTH_MD5
:
1891 for(i
=1;i
<tlv_len
;i
++) {
1892 if (!TTEST2(*(tptr
+i
), 1))
1894 printf("%02x",*(tptr
+i
));
1896 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
1897 printf(", (malformed subTLV) ");
1899 case ISIS_SUBTLV_AUTH_PRIVATE
:
1901 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
1907 case ISIS_TLV_PTP_ADJ
:
1908 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
1910 if (!TTEST2(*tptr
, 1))
1912 printf("\n\t Adjacency State: %s (%u)",
1913 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
1917 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
1918 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
1919 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
1921 printf("\n\t Extended Local circuit-ID: 0x%08x",
1922 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
1923 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
1925 if(tmp
>=SYSTEM_ID_LEN
) {
1926 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
1928 printf("\n\t Neighbor System-ID: %s",
1929 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
1932 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
1933 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
1934 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
1936 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
1937 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
1941 case ISIS_TLV_PROTOCOLS
:
1942 printf("\n\t NLPID(s): ");
1944 if (!TTEST2(*(tptr
), 1))
1946 printf("%s (0x%02x)",
1947 tok2str(osi_nlpid_values
,
1951 if (tmp
>1) /* further NPLIDs ? - put comma */
1958 case ISIS_TLV_TE_ROUTER_ID
:
1959 if (!TTEST2(*pptr
, 4))
1961 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
1964 case ISIS_TLV_IPADDR
:
1966 if (!TTEST2(*tptr
, 4))
1968 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
1974 case ISIS_TLV_HOSTNAME
:
1975 printf("\n\t Hostname: ");
1977 if (!TTEST2(*tptr
, 1))
1979 printf("%c",*tptr
++);
1984 case ISIS_TLV_SHARED_RISK_GROUP
:
1985 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1987 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
1988 tptr
+=(NODE_ID_LEN
);
1991 if (!TTEST2(*tptr
, 1))
1993 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
1996 if (!TTEST2(*tptr
,4))
1998 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2002 if (!TTEST2(*tptr
,4))
2004 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
2009 if (!TTEST2(*tptr
, 4))
2011 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
2018 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2020 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2022 printf("\n\t lsp-id: %s",
2023 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
2024 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
2026 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
2027 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2029 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
2030 if (!TTEST2(tlv_lsp
->checksum
, 2))
2032 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
2033 tmp
-=sizeof(struct isis_tlv_lsp
);
2038 case ISIS_TLV_CHECKSUM
:
2039 if (!TTEST2(*tptr
, 2))
2041 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
2042 /* do not attempt to verify the checksum if it is zero
2043 * most likely a HMAC-MD5 TLV is also present and
2044 * to avoid conflicts the checksum TLV is zeroed.
2045 * see rfc3358 for details
2047 if (EXTRACT_16BITS(tptr
) == 0)
2048 printf("(unverified)");
2049 else printf("(%s)", osi_cksum(optr
, length
) ? "incorrect" : "correct");
2052 case ISIS_TLV_MT_SUPPORTED
:
2054 /* length can only be a multiple of 2, otherwise there is
2055 something broken -> so decode down until length is 1 */
2057 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2058 if (mt_len
== 0) /* did something go wrong ? */
2063 printf("\n\t malformed MT-ID");
2069 case ISIS_TLV_RESTART_SIGNALING
:
2070 if (!TTEST2(*tptr
, 3))
2072 printf("\n\t Flags [%s], Remaining holding time %us",
2073 bittok2str(isis_restart_flag_values
, "none", *tptr
),
2074 EXTRACT_16BITS(tptr
+1));
2078 case ISIS_TLV_IDRP_INFO
:
2079 if (!TTEST2(*tptr
, 1))
2081 printf("\n\t Inter-Domain Information Type: %s",
2082 tok2str(isis_subtlv_idrp_values
,
2086 case ISIS_SUBTLV_IDRP_ASN
:
2087 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
2089 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
2091 case ISIS_SUBTLV_IDRP_LOCAL
:
2092 case ISIS_SUBTLV_IDRP_RES
:
2094 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
2100 case ISIS_TLV_LSP_BUFFERSIZE
:
2101 if (!TTEST2(*tptr
, 2))
2103 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
2106 case ISIS_TLV_PART_DIS
:
2107 while (tmp
>= SYSTEM_ID_LEN
) {
2108 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2110 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2111 tptr
+=SYSTEM_ID_LEN
;
2116 case ISIS_TLV_PREFIX_NEIGH
:
2117 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2119 printf("\n\t Metric Block");
2120 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2121 tptr
+=sizeof(struct isis_metric_block
);
2122 tmp
-=sizeof(struct isis_metric_block
);
2125 if (!TTEST2(*tptr
, 1))
2127 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2129 if (!TTEST2(*tptr
, prefix_len
/2))
2131 printf("\n\t\tAddress: %s/%u",
2132 print_nsap(tptr
,prefix_len
/2),
2139 case ISIS_TLV_IIH_SEQNR
:
2140 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
2142 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
2145 case ISIS_TLV_VENDOR_PRIVATE
:
2146 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
2148 vendor_id
= EXTRACT_24BITS(tptr
);
2149 printf("\n\t Vendor: %s (%u)",
2150 tok2str(oui_values
,"Unknown",vendor_id
),
2154 if (tmp
> 0) /* hexdump the rest */
2155 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
2159 * FIXME those are the defined TLVs that lack a decoder
2160 * you are welcome to contribute code ;-)
2163 case ISIS_TLV_DECNET_PHASE4
:
2164 case ISIS_TLV_LUCENT_PRIVATE
:
2165 case ISIS_TLV_IPAUTH
:
2166 case ISIS_TLV_NORTEL_PRIVATE1
:
2167 case ISIS_TLV_NORTEL_PRIVATE2
:
2171 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
2176 /* do we want to see an additionally hexdump ? */
2178 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2183 packet_len
-= tlv_len
;
2186 if (packet_len
!= 0) {
2187 printf("\n\t %u straggler bytes", packet_len
);
2192 fputs("[|isis]", stdout
);
2196 printf("\n\t\t packet exceeded snapshot");
2201 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2205 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2207 int32_t c0
= 0, c1
= 0;
2209 while ((int)--len
>= 0) {