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.127 2005-03-07 14:36:16 hannes Exp $ (LBL)";
36 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
43 #include "ethertype.h"
50 #define IPV4 1 /* AFI value */
51 #define IPV6 2 /* AFI value */
54 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
57 #define SYSTEM_ID_LEN ETHER_ADDR_LEN
58 #define NODE_ID_LEN SYSTEM_ID_LEN+1
59 #define LSP_ID_LEN SYSTEM_ID_LEN+2
60 #define NSAP_MAX_LENGTH 20
62 #define ISIS_VERSION 1
63 #define ESIS_VERSION 1
64 #define CLNP_VERSION 1
66 #define ISIS_PDU_TYPE_MASK 0x1F
67 #define ESIS_PDU_TYPE_MASK 0x1F
68 #define CLNP_PDU_TYPE_MASK 0x1F
69 #define CLNP_FLAG_MASK 0xE0
70 #define ISIS_LAN_PRIORITY_MASK 0x7F
72 #define ISIS_PDU_L1_LAN_IIH 15
73 #define ISIS_PDU_L2_LAN_IIH 16
74 #define ISIS_PDU_PTP_IIH 17
75 #define ISIS_PDU_L1_LSP 18
76 #define ISIS_PDU_L2_LSP 20
77 #define ISIS_PDU_L1_CSNP 24
78 #define ISIS_PDU_L2_CSNP 25
79 #define ISIS_PDU_L1_PSNP 26
80 #define ISIS_PDU_L2_PSNP 27
82 static struct tok isis_pdu_values
[] = {
83 { ISIS_PDU_L1_LAN_IIH
, "L1 Lan IIH"},
84 { ISIS_PDU_L2_LAN_IIH
, "L2 Lan IIH"},
85 { ISIS_PDU_PTP_IIH
, "p2p IIH"},
86 { ISIS_PDU_L1_LSP
, "L1 LSP"},
87 { ISIS_PDU_L2_LSP
, "L2 LSP"},
88 { ISIS_PDU_L1_CSNP
, "L1 CSNP"},
89 { ISIS_PDU_L2_CSNP
, "L2 CSNP"},
90 { ISIS_PDU_L1_PSNP
, "L1 PSNP"},
91 { ISIS_PDU_L2_PSNP
, "L2 PSNP"},
96 * A TLV is a tuple of a type, length and a value and is normally used for
97 * encoding information in all sorts of places. This is an enumeration of
98 * the well known types.
100 * list taken from rfc3359 plus some memory from veterans ;-)
103 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
104 #define ISIS_TLV_IS_REACH 2 /* iso10589 */
105 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
106 #define ISIS_TLV_PART_DIS 4 /* iso10589 */
107 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
108 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
109 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
110 #define ISIS_TLV_PADDING 8 /* iso10589 */
111 #define ISIS_TLV_LSP 9 /* iso10589 */
112 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
113 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
114 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
115 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
116 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
117 #define ISIS_TLV_DECNET_PHASE4 42
118 #define ISIS_TLV_LUCENT_PRIVATE 66
119 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
120 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
121 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
122 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
123 #define ISIS_TLV_IPADDR 132 /* rfc1195 */
124 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
125 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
126 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
127 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
128 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
129 #define ISIS_TLV_NORTEL_PRIVATE1 176
130 #define ISIS_TLV_NORTEL_PRIVATE2 177
131 #define ISIS_TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
132 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
133 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
134 #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
135 #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
136 #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
137 #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
138 #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
139 #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
140 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
142 static struct tok isis_tlv_values
[] = {
143 { ISIS_TLV_AREA_ADDR
, "Area address(es)"},
144 { ISIS_TLV_IS_REACH
, "IS Reachability"},
145 { ISIS_TLV_ESNEIGH
, "ES Neighbor(s)"},
146 { ISIS_TLV_PART_DIS
, "Partition DIS"},
147 { ISIS_TLV_PREFIX_NEIGH
, "Prefix Neighbors"},
148 { ISIS_TLV_ISNEIGH
, "IS Neighbor(s)"},
149 { ISIS_TLV_ISNEIGH_VARLEN
, "IS Neighbor(s) (variable length)"},
150 { ISIS_TLV_PADDING
, "Padding"},
151 { ISIS_TLV_LSP
, "LSP entries"},
152 { ISIS_TLV_AUTH
, "Authentication"},
153 { ISIS_TLV_CHECKSUM
, "Checksum"},
154 { ISIS_TLV_LSP_BUFFERSIZE
, "LSP Buffersize"},
155 { ISIS_TLV_EXT_IS_REACH
, "Extended IS Reachability"},
156 { ISIS_TLV_IS_ALIAS_ID
, "IS Alias ID"},
157 { ISIS_TLV_DECNET_PHASE4
, "DECnet Phase IV"},
158 { ISIS_TLV_LUCENT_PRIVATE
, "Lucent Proprietary"},
159 { ISIS_TLV_INT_IP_REACH
, "IPv4 Internal Reachability"},
160 { ISIS_TLV_PROTOCOLS
, "Protocols supported"},
161 { ISIS_TLV_EXT_IP_REACH
, "IPv4 External Reachability"},
162 { ISIS_TLV_IDRP_INFO
, "Inter-Domain Information Type"},
163 { ISIS_TLV_IPADDR
, "IPv4 Interface address(es)"},
164 { ISIS_TLV_IPAUTH
, "IPv4 authentication (deprecated)"},
165 { ISIS_TLV_TE_ROUTER_ID
, "Traffic Engineering Router ID"},
166 { ISIS_TLV_EXTD_IP_REACH
, "Extended IPv4 Reachability"},
167 { ISIS_TLV_SHARED_RISK_GROUP
, "Shared Risk Link Group"},
168 { ISIS_TLV_NORTEL_PRIVATE1
, "Nortel Proprietary"},
169 { ISIS_TLV_NORTEL_PRIVATE2
, "Nortel Proprietary"},
170 { ISIS_TLV_HOSTNAME
, "Hostname"},
171 { ISIS_TLV_RESTART_SIGNALING
, "Restart Signaling"},
172 { ISIS_TLV_MT_IS_REACH
, "Multi Topology IS Reachability"},
173 { ISIS_TLV_MT_SUPPORTED
, "Multi Topology"},
174 { ISIS_TLV_IP6ADDR
, "IPv6 Interface address(es)"},
175 { ISIS_TLV_MT_IP_REACH
, "Multi-Topology IPv4 Reachability"},
176 { ISIS_TLV_IP6_REACH
, "IPv6 reachability"},
177 { ISIS_TLV_MT_IP6_REACH
, "Multi-Topology IP6 Reachability"},
178 { ISIS_TLV_PTP_ADJ
, "Point-to-point Adjacency State"},
179 { ISIS_TLV_IIH_SEQNR
, "Hello PDU Sequence Number"},
180 { ISIS_TLV_VENDOR_PRIVATE
, "Vendor Private"},
184 #define ESIS_OPTION_PROTOCOLS 129
185 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
186 #define ESIS_OPTION_SECURITY 197 /* iso9542 */
187 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
188 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
189 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
190 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
192 static struct tok esis_option_values
[] = {
193 { ESIS_OPTION_PROTOCOLS
, "Protocols supported"},
194 { ESIS_OPTION_QOS_MAINTENANCE
, "QoS Maintenance" },
195 { ESIS_OPTION_SECURITY
, "Security" },
196 { ESIS_OPTION_ES_CONF_TIME
, "ES Configuration Time" },
197 { ESIS_OPTION_PRIORITY
, "Priority" },
198 { ESIS_OPTION_ADDRESS_MASK
, "Addressk Mask" },
199 { ESIS_OPTION_SNPA_MASK
, "SNPA Mask" },
203 #define CLNP_OPTION_DISCARD_REASON 193
204 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
205 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
207 static struct tok clnp_option_values
[] = {
208 { CLNP_OPTION_DISCARD_REASON
, "Discard Reason"},
209 { CLNP_OPTION_PRIORITY
, "Priority"},
210 { CLNP_OPTION_QOS_MAINTENANCE
, "QoS Maintenance"},
214 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
215 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
216 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
217 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
218 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
219 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
220 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
221 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
222 #define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE 12 /* draft-ietf-tewg-diff-te-proto-06 */
223 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
224 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
225 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
227 static struct tok isis_ext_is_reach_subtlv_values
[] = {
228 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
, "Administrative groups" },
229 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
230 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
, "Link Remote Identifier" },
231 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
, "IPv4 interface address" },
232 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
, "IPv4 neighbor address" },
233 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
, "Maximum link bandwidth" },
234 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
, "Reservable link bandwidth" },
235 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
, "Unreserved bandwidth" },
236 { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE
, "Diffserv TE" },
237 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
, "Traffic Engineering Metric" },
238 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
, "Link Protection Type" },
239 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
240 { 250, "Reserved for cisco specific extensions" },
241 { 251, "Reserved for cisco specific extensions" },
242 { 252, "Reserved for cisco specific extensions" },
243 { 253, "Reserved for cisco specific extensions" },
244 { 254, "Reserved for cisco specific extensions" },
245 { 255, "Reserved for future expansion" },
249 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
250 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
251 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
253 static struct tok isis_ext_ip_reach_subtlv_values
[] = {
254 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
, "32-Bit Administrative tag" },
255 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
, "64-Bit Administrative tag" },
256 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
, "Management Prefix Color" },
260 #define ISIS_SUBTLV_AUTH_SIMPLE 1
261 #define ISIS_SUBTLV_AUTH_MD5 54
262 #define ISIS_SUBTLV_AUTH_MD5_LEN 16
263 #define ISIS_SUBTLV_AUTH_PRIVATE 255
265 static struct tok isis_subtlv_auth_values
[] = {
266 { ISIS_SUBTLV_AUTH_SIMPLE
, "simple text password"},
267 { ISIS_SUBTLV_AUTH_MD5
, "HMAC-MD5 password"},
268 { ISIS_SUBTLV_AUTH_PRIVATE
, "Routing Domain private password"},
272 #define ISIS_SUBTLV_IDRP_RES 0
273 #define ISIS_SUBTLV_IDRP_LOCAL 1
274 #define ISIS_SUBTLV_IDRP_ASN 2
276 static struct tok isis_subtlv_idrp_values
[] = {
277 { ISIS_SUBTLV_IDRP_RES
, "Reserved"},
278 { ISIS_SUBTLV_IDRP_LOCAL
, "Routing-Domain Specific"},
279 { ISIS_SUBTLV_IDRP_ASN
, "AS Number Tag"},
283 #define CLNP_SEGMENT_PART 0x80
284 #define CLNP_MORE_SEGMENTS 0x40
285 #define CLNP_REQUEST_ER 0x20
287 static struct tok clnp_flag_values
[] = {
288 { CLNP_SEGMENT_PART
, "Segmentation permitted"},
289 { CLNP_MORE_SEGMENTS
, "more Segments"},
290 { CLNP_REQUEST_ER
, "request Error Report"},
294 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
295 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
296 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
297 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
298 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
299 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
300 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
301 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
303 #define ISIS_MASK_MTID(x) ((x)&0x0fff)
304 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
306 static struct tok isis_mt_flag_values
[] = {
307 { 0x4000, "sub-TLVs present"},
308 { 0x8000, "ATT bit set"},
312 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
313 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
315 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
316 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
318 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
319 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
320 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
321 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
323 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
325 static struct tok isis_mt_values
[] = {
326 { 0, "IPv4 unicast"},
327 { 1, "In-Band Management"},
328 { 2, "IPv6 unicast"},
330 { 4095, "Development, Experimental or Proprietary"},
334 static struct tok isis_iih_circuit_type_values
[] = {
335 { 1, "Level 1 only"},
336 { 2, "Level 2 only"},
337 { 3, "Level 1, Level 2"},
341 #define ISIS_LSP_TYPE_UNUSED0 0
342 #define ISIS_LSP_TYPE_LEVEL_1 1
343 #define ISIS_LSP_TYPE_UNUSED2 2
344 #define ISIS_LSP_TYPE_LEVEL_2 3
346 static struct tok isis_lsp_istype_values
[] = {
347 { ISIS_LSP_TYPE_UNUSED0
, "Unused 0x0 (invalid)"},
348 { ISIS_LSP_TYPE_LEVEL_1
, "L1 IS"},
349 { ISIS_LSP_TYPE_UNUSED2
, "Unused 0x2 (invalid)"},
350 { ISIS_LSP_TYPE_LEVEL_2
, "L1L2 IS"},
355 * Katz's point to point adjacency TLV uses codes to tell us the state of
356 * the remote adjacency. Enumerate them.
359 #define ISIS_PTP_ADJ_UP 0
360 #define ISIS_PTP_ADJ_INIT 1
361 #define ISIS_PTP_ADJ_DOWN 2
363 static struct tok isis_ptp_adjancey_values
[] = {
364 { ISIS_PTP_ADJ_UP
, "Up" },
365 { ISIS_PTP_ADJ_INIT
, "Initializing" },
366 { ISIS_PTP_ADJ_DOWN
, "Down" },
370 struct isis_tlv_ptp_adj
{
371 u_int8_t adjacency_state
;
372 u_int8_t extd_local_circuit_id
[4];
373 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
374 u_int8_t neighbor_extd_local_circuit_id
[4];
377 static int osi_cksum(const u_int8_t
*, u_int
);
378 static int clnp_print(const u_int8_t
*, u_int
);
379 static void esis_print(const u_int8_t
*, u_int
);
380 static int isis_print(const u_int8_t
*, u_int
);
382 struct isis_metric_block
{
383 u_int8_t metric_default
;
384 u_int8_t metric_delay
;
385 u_int8_t metric_expense
;
386 u_int8_t metric_error
;
389 struct isis_tlv_is_reach
{
390 struct isis_metric_block isis_metric_block
;
391 u_int8_t neighbor_nodeid
[NODE_ID_LEN
];
394 struct isis_tlv_es_reach
{
395 struct isis_metric_block isis_metric_block
;
396 u_int8_t neighbor_sysid
[SYSTEM_ID_LEN
];
399 struct isis_tlv_ip_reach
{
400 struct isis_metric_block isis_metric_block
;
405 static struct tok isis_is_reach_virtual_values
[] = {
406 { 0, "IsNotVirtual"},
411 static struct tok isis_restart_flag_values
[] = {
412 { 0x1, "Restart Request"},
413 { 0x2, "Restart Acknowledgement"},
417 struct isis_common_header
{
420 u_int8_t version
; /* Protocol version */
422 u_int8_t pdu_type
; /* 3 MSbits are reserved */
423 u_int8_t pdu_version
; /* Packet format version */
428 struct isis_iih_lan_header
{
429 u_int8_t circuit_type
;
430 u_int8_t source_id
[SYSTEM_ID_LEN
];
431 u_int8_t holding_time
[2];
434 u_int8_t lan_id
[NODE_ID_LEN
];
437 struct isis_iih_ptp_header
{
438 u_int8_t circuit_type
;
439 u_int8_t source_id
[SYSTEM_ID_LEN
];
440 u_int8_t holding_time
[2];
445 struct isis_lsp_header
{
447 u_int8_t remaining_lifetime
[2];
448 u_int8_t lsp_id
[LSP_ID_LEN
];
449 u_int8_t sequence_number
[4];
450 u_int8_t checksum
[2];
454 struct isis_csnp_header
{
456 u_int8_t source_id
[NODE_ID_LEN
];
457 u_int8_t start_lsp_id
[LSP_ID_LEN
];
458 u_int8_t end_lsp_id
[LSP_ID_LEN
];
461 struct isis_psnp_header
{
463 u_int8_t source_id
[NODE_ID_LEN
];
466 struct isis_tlv_lsp
{
467 u_int8_t remaining_lifetime
[2];
468 u_int8_t lsp_id
[LSP_ID_LEN
];
469 u_int8_t sequence_number
[4];
470 u_int8_t checksum
[2];
474 print_nsap(register const u_int8_t
*pptr
, register int nsap_length
)
477 static char nsap_ascii_output
[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")];
478 char *junk_buf
= nsap_ascii_output
;
480 if (nsap_length
< 1 || nsap_length
> NSAP_MAX_LENGTH
) {
481 snprintf(nsap_ascii_output
, sizeof(nsap_ascii_output
),
483 return (nsap_ascii_output
);
486 for (nsap_idx
= 0; nsap_idx
< nsap_length
; nsap_idx
++) {
487 if (!TTEST2(*pptr
, 1))
490 sizeof(nsap_ascii_output
) - (junk_buf
- nsap_ascii_output
),
492 junk_buf
+= strlen(junk_buf
);
493 if (((nsap_idx
& 1) == 0) &&
494 (nsap_idx
+ 1 < nsap_length
)) {
499 return (nsap_ascii_output
);
502 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
503 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
504 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
505 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
506 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
507 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
509 void isoclns_print(const u_int8_t
*p
, u_int length
, u_int caplen
)
511 const struct isis_common_header
*header
;
513 header
= (const struct isis_common_header
*)p
;
515 if (caplen
<= 1) { /* enough bytes on the wire ? */
521 printf("OSI NLPID %s (0x%02x): ",
522 tok2str(nlpid_values
,"Unknown",*p
),
528 if (!clnp_print(p
, length
))
529 print_unknown_data(p
,"\n\t",caplen
);
533 esis_print(p
, length
);
537 if (!isis_print(p
, length
))
538 print_unknown_data(p
,"\n\t",caplen
);
542 (void)printf(", length: %u", length
);
546 q933_print(p
+1, length
-1);
550 ip_print(p
+1, length
-1);
555 ip6_print(p
+1, length
-1);
560 ppp_print(p
+1, length
-1);
565 printf("OSI NLPID 0x%02x unknown",*p
);
566 (void)printf(", length: %u", length
);
568 print_unknown_data(p
,"\n\t",caplen
);
573 #define CLNP_PDU_ER 1
574 #define CLNP_PDU_DT 28
575 #define CLNP_PDU_MD 29
576 #define CLNP_PDU_ERQ 30
577 #define CLNP_PDU_ERP 31
579 static struct tok clnp_pdu_values
[] = {
580 { CLNP_PDU_ER
, "Error Report"},
581 { CLNP_PDU_MD
, "MD"},
582 { CLNP_PDU_DT
, "Data"},
583 { CLNP_PDU_ERQ
, "Echo Request"},
584 { CLNP_PDU_ERP
, "Echo Response"},
588 struct clnp_header_t
{
590 u_int8_t length_indicator
;
592 u_int8_t lifetime
; /* units of 500ms */
594 u_int8_t segment_length
[2];
598 struct clnp_segment_header_t
{
599 u_int8_t data_unit_id
[2];
600 u_int8_t segment_offset
[2];
601 u_int8_t total_length
[2];
606 * Decode CLNP packets. Return 0 on error.
609 static int clnp_print (const u_int8_t
*pptr
, u_int length
)
611 const u_int8_t
*optr
,*source_address
,*dest_address
;
612 u_int li
,source_address_length
,dest_address_length
, clnp_pdu_type
, clnp_flags
;
613 const struct clnp_header_t
*clnp_header
;
614 const struct clnp_segment_header_t
*clnp_segment_header
;
616 clnp_header
= (const struct clnp_header_t
*) pptr
;
617 TCHECK(*clnp_header
);
619 li
= clnp_header
->length_indicator
;
626 * Sanity checking of the header.
629 if (clnp_header
->version
!= CLNP_VERSION
) {
630 printf("version %d packet not supported", clnp_header
->version
);
634 /* FIXME further header sanity checking */
636 clnp_pdu_type
= clnp_header
->type
& CLNP_PDU_TYPE_MASK
;
637 clnp_flags
= clnp_header
->type
& CLNP_FLAG_MASK
;
639 pptr
+= sizeof(struct clnp_header_t
);
640 li
-= sizeof(struct clnp_header_t
);
641 dest_address_length
= *pptr
;
642 dest_address
= pptr
+ 1;
644 pptr
+= (1 + dest_address_length
);
645 li
-= (1 + dest_address_length
);
646 source_address_length
= *pptr
;
647 source_address
= pptr
+1;
649 pptr
+= (1 + source_address_length
);
650 li
-= (1 + source_address_length
);
655 print_nsap(source_address
, source_address_length
));
656 printf("> %s, length %u",
657 print_nsap(dest_address
, dest_address_length
),
661 printf("%slength %u",eflag
? "" : ", ",length
);
663 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ",
664 tok2str(clnp_pdu_values
,
667 clnp_header
->length_indicator
,
668 clnp_header
->version
,
669 clnp_header
->lifetime
/2,
670 (clnp_header
->lifetime
%2)*5,
671 EXTRACT_16BITS(clnp_header
->segment_length
),
672 EXTRACT_16BITS(clnp_header
->cksum
));
674 /* do not attempt to verify the checksum if it is zero */
675 if (EXTRACT_16BITS(clnp_header
->cksum
) == 0)
676 printf("(unverified)");
677 else printf("(%s)", osi_cksum(optr
, li
) ? "incorrect" : "correct");
679 printf("\n\tFlags [%s]",
680 bittok2str(clnp_flag_values
,"none",clnp_flags
));
682 printf("\n\tsource address (length %u): %s",
683 source_address_length
,
684 print_nsap(source_address
, source_address_length
));
685 printf("\n\tdest address (length %u): %s",
687 print_nsap(dest_address
, dest_address_length
));
689 if (clnp_flags
& CLNP_SEGMENT_PART
) {
690 clnp_segment_header
= (const struct clnp_segment_header_t
*) pptr
;
691 printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
692 EXTRACT_16BITS(clnp_segment_header
->data_unit_id
),
693 EXTRACT_16BITS(clnp_segment_header
->segment_offset
),
694 EXTRACT_16BITS(clnp_segment_header
->total_length
));
695 pptr
+=sizeof(const struct clnp_segment_header_t
);
696 li
-=sizeof(const struct clnp_segment_header_t
);
699 /* now walk the options */
702 const u_int8_t
*tptr
;
704 if (snapend
- pptr
< 2)
707 printf(", bad opts/li");
714 printf(", opt (%d) too long", op
);
723 printf("\n\t %s Option #%u, length %u, value: ",
724 tok2str(clnp_option_values
,"Unknown",op
),
730 case CLNP_OPTION_PRIORITY
:
735 * FIXME those are the defined Options that lack a decoder
736 * you are welcome to contribute code ;-)
739 case CLNP_OPTION_DISCARD_REASON
:
742 print_unknown_data(tptr
,"\n\t ",opli
);
746 print_unknown_data(pptr
,"\n\t ",opli
);
750 switch (clnp_pdu_type
) {
759 /* dump the PDU specific data */
760 printf("\n\t undecoded non-header data");
761 print_unknown_data(optr
+clnp_header
->length_indicator
,"\n\t ",length
-clnp_header
->length_indicator
);
768 fputs("[|clnp]", stdout
);
774 #define ESIS_PDU_REDIRECT 6
775 #define ESIS_PDU_ESH 2
776 #define ESIS_PDU_ISH 4
778 static struct tok esis_pdu_values
[] = {
779 { ESIS_PDU_REDIRECT
, "redirect"},
780 { ESIS_PDU_ESH
, "ESH"},
781 { ESIS_PDU_ISH
, "ISH"},
785 struct esis_header_t
{
787 u_int8_t length_indicator
;
791 u_int8_t holdtime
[2];
796 esis_print(const u_int8_t
*pptr
, u_int length
)
798 const u_int8_t
*optr
;
799 u_int li
,esis_pdu_type
,source_address_length
, source_address_number
;
800 const struct esis_header_t
*esis_header
;
809 printf("no header at all!");
813 esis_header
= (const struct esis_header_t
*) pptr
;
814 li
= esis_header
->length_indicator
;
818 * Sanity checking of the header.
821 if (esis_header
->nlpid
!= NLPID_ESIS
) {
822 printf(" nlpid 0x%02x packet not supported", esis_header
->nlpid
);
826 if (esis_header
->version
!= ESIS_VERSION
) {
827 printf(" version %d packet not supported", esis_header
->version
);
832 printf(" length indicator(%d) > PDU size (%d)!", li
, length
);
836 if (li
< sizeof(struct esis_header_t
) + 2) {
837 printf(" length indicator < min PDU size %d:", li
);
838 while (--length
!= 0)
839 printf("%02X", *pptr
++);
843 esis_pdu_type
= esis_header
->type
& ESIS_PDU_TYPE_MASK
;
846 printf("%s%s, length %u",
848 tok2str(esis_pdu_values
,"unknown type (%u)",esis_pdu_type
),
852 printf("%slength %u\n\t%s (%u)",
855 tok2str(esis_pdu_values
,"unknown type: %u", esis_pdu_type
),
858 printf(", v: %u%s", esis_header
->version
, esis_header
->version
== ESIS_VERSION
? "" : "unsupported" );
859 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header
->cksum
));
860 /* do not attempt to verify the checksum if it is zero */
861 if (EXTRACT_16BITS(esis_header
->cksum
) == 0)
862 printf("(unverified)");
863 else printf("(%s)", osi_cksum(pptr
, li
) ? "incorrect" : "correct");
865 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header
->holdtime
),li
);
868 print_unknown_data(optr
,"\n\t",sizeof(struct esis_header_t
));
870 pptr
+= sizeof(struct esis_header_t
);
871 li
-= sizeof(struct esis_header_t
);
873 switch (esis_pdu_type
) {
874 case ESIS_PDU_REDIRECT
: {
875 const u_int8_t
*dst
, *snpa
, *tptr
;
877 dst
= pptr
; pptr
+= *pptr
+ 1;
880 printf("\n\t %s", isonsap_string(dst
));
881 snpa
= pptr
; pptr
+= *pptr
+ 1;
882 tptr
= pptr
; pptr
+= *pptr
+ 1;
887 printf("\n\t %s", etheraddr_string(&snpa
[1]));
889 printf("\n\t %s", isonsap_string(tptr
));
894 source_address_number
= *pptr
;
898 printf("\n\t Number of Source Addresses: %u", source_address_number
);
900 while (source_address_number
> 0) {
901 source_address_length
= *pptr
;
902 printf("\n\t NET (length: %u): %s",
903 source_address_length
,
904 print_nsap(pptr
+1, source_address_length
));
906 pptr
+= source_address_length
+1;
907 li
-= source_address_length
+1;
908 source_address_number
--;
914 source_address_length
= *pptr
;
915 printf("\n\t NET (length: %u): %s", source_address_length
, print_nsap(pptr
+1, source_address_length
));
916 pptr
+= source_address_length
+1;
917 li
-= source_address_length
+1;
924 print_unknown_data(pptr
,"\n\t ",snapend
-pptr
);
929 /* now walk the options */
932 const u_int8_t
*tptr
;
934 if (snapend
- pptr
< 2)
937 printf(", bad opts/li");
944 printf(", opt (%d) too long", op
);
953 printf("\n\t %s Option #%u, length %u, value: ",
954 tok2str(esis_option_values
,"Unknown",op
),
960 case ESIS_OPTION_ES_CONF_TIME
:
961 printf("%us", EXTRACT_16BITS(tptr
));
965 case ESIS_OPTION_PROTOCOLS
:
967 printf("%s (0x%02x)",
968 tok2str(nlpid_values
,
972 if (opli
>1) /* further NPLIDs ? - put comma */
980 * FIXME those are the defined Options that lack a decoder
981 * you are welcome to contribute code ;-)
984 case ESIS_OPTION_QOS_MAINTENANCE
:
985 case ESIS_OPTION_SECURITY
:
986 case ESIS_OPTION_PRIORITY
:
987 case ESIS_OPTION_ADDRESS_MASK
:
988 case ESIS_OPTION_SNPA_MASK
:
991 print_unknown_data(tptr
,"\n\t ",opli
);
995 print_unknown_data(pptr
,"\n\t ",opli
);
1000 /* shared routine for printing system, node and lsp-ids */
1002 isis_print_id(const u_int8_t
*cp
, int id_len
)
1005 static char id
[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1008 for (i
= 1; i
<= SYSTEM_ID_LEN
; i
++) {
1009 snprintf(pos
, sizeof(id
) - (pos
- id
), "%02x", *cp
++);
1011 if (i
== 2 || i
== 4)
1014 if (id_len
>= NODE_ID_LEN
) {
1015 snprintf(pos
, sizeof(id
) - (pos
- id
), ".%02x", *cp
++);
1018 if (id_len
== LSP_ID_LEN
)
1019 snprintf(pos
, sizeof(id
) - (pos
- id
), "-%02x", *cp
);
1023 /* print the 4-byte metric block which is common found in the old-style TLVs */
1025 isis_print_metric_block (const struct isis_metric_block
*isis_metric_block
)
1027 printf(", Default Metric: %d, %s",
1028 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_default
),
1029 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_default
) ? "External" : "Internal");
1030 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_delay
))
1031 printf("\n\t\t Delay Metric: %d, %s",
1032 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_delay
),
1033 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_delay
) ? "External" : "Internal");
1034 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_expense
))
1035 printf("\n\t\t Expense Metric: %d, %s",
1036 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_expense
),
1037 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_expense
) ? "External" : "Internal");
1038 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block
->metric_error
))
1039 printf("\n\t\t Error Metric: %d, %s",
1040 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block
->metric_error
),
1041 ISIS_LSP_TLV_METRIC_IE(isis_metric_block
->metric_error
) ? "External" : "Internal");
1043 return(1); /* everything is ok */
1047 isis_print_tlv_ip_reach (const u_int8_t
*cp
, const char *ident
, int length
)
1050 const struct isis_tlv_ip_reach
*tlv_ip_reach
;
1052 tlv_ip_reach
= (const struct isis_tlv_ip_reach
*)cp
;
1054 while (length
> 0) {
1055 if ((size_t)length
< sizeof(*tlv_ip_reach
)) {
1056 printf("short IPv4 Reachability (%d vs %lu)",
1058 (unsigned long)sizeof(*tlv_ip_reach
));
1062 if (!TTEST(*tlv_ip_reach
))
1065 prefix_len
= mask2plen(EXTRACT_32BITS(tlv_ip_reach
->mask
));
1067 if (prefix_len
== -1)
1068 printf("%sIPv4 prefix: %s mask %s",
1070 ipaddr_string((tlv_ip_reach
->prefix
)),
1071 ipaddr_string((tlv_ip_reach
->mask
)));
1073 printf("%sIPv4 prefix: %15s/%u",
1075 ipaddr_string((tlv_ip_reach
->prefix
)),
1078 printf(", Distribution: %s, Metric: %u, %s",
1079 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "down" : "up",
1080 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_default
),
1081 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_default
) ? "External" : "Internal");
1083 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_delay
))
1084 printf("%s Delay Metric: %u, %s",
1086 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_delay
),
1087 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_delay
) ? "External" : "Internal");
1089 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_expense
))
1090 printf("%s Expense Metric: %u, %s",
1092 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_expense
),
1093 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_expense
) ? "External" : "Internal");
1095 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach
->isis_metric_block
.metric_error
))
1096 printf("%s Error Metric: %u, %s",
1098 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach
->isis_metric_block
.metric_error
),
1099 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach
->isis_metric_block
.metric_error
) ? "External" : "Internal");
1101 length
-= sizeof(struct isis_tlv_ip_reach
);
1108 * this is the common IP-REACH subTLV decoder it is called
1109 * from various EXTD-IP REACH TLVs (135,235,236,237)
1113 isis_print_ip_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
1115 /* first lets see if we know the subTLVs name*/
1116 printf("%s%s subTLV #%u, length: %u",
1118 tok2str(isis_ext_ip_reach_subtlv_values
,
1124 if (!TTEST2(*tptr
,subl
))
1128 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR
: /* fall through */
1129 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32
:
1131 printf(", 0x%08x (=%u)",
1132 EXTRACT_32BITS(tptr
),
1133 EXTRACT_32BITS(tptr
));
1138 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64
:
1140 printf(", 0x%08x%08x",
1141 EXTRACT_32BITS(tptr
),
1142 EXTRACT_32BITS(tptr
+4));
1148 if(!print_unknown_data(tptr
,"\n\t\t ",
1156 printf("%spacket exceeded snapshot",ident
);
1161 * this is the common IS-REACH subTLV decoder it is called
1162 * from isis_print_ext_is_reach()
1166 isis_print_is_reach_subtlv (const u_int8_t
*tptr
,int subt
,int subl
,const char *ident
) {
1168 int priority_level
,bandwidth_constraint
;
1169 union { /* int to float conversion buffer for several subTLVs */
1174 /* first lets see if we know the subTLVs name*/
1175 printf("%s%s subTLV #%u, length: %u",
1177 tok2str(isis_ext_is_reach_subtlv_values
,
1183 if (!TTEST2(*tptr
,subl
))
1187 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP
:
1188 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID
:
1189 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID
:
1191 printf(", 0x%08x", EXTRACT_32BITS(tptr
));
1192 if (subl
== 8) /* draft-ietf-isis-gmpls-extensions */
1193 printf(", 0x%08x", EXTRACT_32BITS(tptr
+4));
1196 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR
:
1197 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR
:
1199 printf(", %s", ipaddr_string(tptr
));
1201 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW
:
1202 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW
:
1204 bw
.i
= EXTRACT_32BITS(tptr
);
1205 printf(", %.3f Mbps", bw
.f
*8/1000000 );
1208 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW
:
1210 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1211 bw
.i
= EXTRACT_32BITS(tptr
);
1212 printf("%s priority level %d: %.3f Mbps",
1220 case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE
:
1221 printf("%sBandwidth Constraints Model ID: %s (%u)",
1223 tok2str(diffserv_te_bc_values
, "unknown", *tptr
),
1226 /* decode BCs until the subTLV ends */
1227 for (bandwidth_constraint
= 0; bandwidth_constraint
< (subl
-1)/4; bandwidth_constraint
++) {
1228 bw
.i
= EXTRACT_32BITS(tptr
);
1229 printf("%s Bandwidth constraint %d: %.3f Mbps",
1231 bandwidth_constraint
,
1236 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC
:
1238 printf(", %u", EXTRACT_24BITS(tptr
));
1240 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE
:
1242 printf(", %s, Priority %u",
1243 bittok2str(gmpls_link_prot_values
, "none", *tptr
),
1247 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR
:
1249 printf("%s Interface Switching Capability:%s",
1251 tok2str(gmpls_switch_cap_values
, "Unknown", *(tptr
)));
1252 printf(", LSP Encoding: %s",
1253 tok2str(gmpls_encoding_values
, "Unknown", *(tptr
+1)));
1255 printf("%s Max LSP Bandwidth:",ident
);
1256 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
1257 bw
.i
= EXTRACT_32BITS(tptr
);
1258 printf("%s priority level %d: %.3f Mbps",
1265 /* there is some optional stuff left to decode but this is as of yet
1266 not specified so just lets hexdump what is left */
1268 if(!print_unknown_data(tptr
,"\n\t\t ",
1275 if(!print_unknown_data(tptr
,"\n\t\t ",
1283 printf("%spacket exceeded snapshot",ident
);
1289 * this is the common IS-REACH decoder it is called
1290 * from various EXTD-IS REACH style TLVs (22,24,222)
1294 isis_print_ext_is_reach (const u_int8_t
*tptr
,const char *ident
, int tlv_type
) {
1296 char ident_buffer
[20];
1297 int subtlv_type
,subtlv_len
,subtlv_sum_len
;
1298 int proc_bytes
= 0; /* how many bytes did we process ? */
1300 if (!TTEST2(*tptr
, NODE_ID_LEN
))
1303 printf("%sIS Neighbor: %s", ident
, isis_print_id(tptr
, NODE_ID_LEN
));
1304 tptr
+=(NODE_ID_LEN
);
1306 if (tlv_type
!= ISIS_TLV_IS_ALIAS_ID
) { /* the Alias TLV Metric field is implicit 0 */
1307 if (!TTEST2(*tptr
, 3)) /* and is therefore skipped */
1309 printf(", Metric: %d",EXTRACT_24BITS(tptr
));
1313 if (!TTEST2(*tptr
, 1))
1315 subtlv_sum_len
=*(tptr
++); /* read out subTLV length */
1316 proc_bytes
=NODE_ID_LEN
+3+1;
1317 printf(", %ssub-TLVs present",subtlv_sum_len
? "" : "no ");
1318 if (subtlv_sum_len
) {
1319 printf(" (%u)",subtlv_sum_len
);
1320 while (subtlv_sum_len
>0) {
1321 if (!TTEST2(*tptr
,2))
1323 subtlv_type
=*(tptr
++);
1324 subtlv_len
=*(tptr
++);
1325 /* prepend the ident string */
1326 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1327 if(!isis_print_is_reach_subtlv(tptr
,subtlv_type
,subtlv_len
,ident_buffer
))
1330 subtlv_sum_len
-=(subtlv_len
+2);
1331 proc_bytes
+=(subtlv_len
+2);
1338 * this is the common Multi Topology ID decoder
1339 * it is called from various MT-TLVs (222,229,235,237)
1343 isis_print_mtid (const u_int8_t
*tptr
,const char *ident
) {
1345 if (!TTEST2(*tptr
, 2))
1350 tok2str(isis_mt_values
,
1351 "Reserved for IETF Consensus",
1352 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
))));
1354 printf(" Topology (0x%03x), Flags: [%s]",
1355 ISIS_MASK_MTID(EXTRACT_16BITS(tptr
)),
1356 bittok2str(isis_mt_flag_values
, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr
))));
1362 * this is the common extended IP reach decoder
1363 * it is called from TLVs (135,235,236,237)
1364 * we process the TLV and optional subTLVs and return
1365 * the amount of processed bytes
1369 isis_print_extd_ip_reach (const u_int8_t
*tptr
, const char *ident
, u_int16_t afi
) {
1371 char ident_buffer
[20];
1372 u_int8_t prefix
[16]; /* shared copy buffer for IPv4 and IPv6 prefixes */
1373 u_int metric
, status_byte
, bit_length
, byte_length
, sublen
, processed
, subtlvtype
, subtlvlen
;
1375 if (!TTEST2(*tptr
, 4))
1377 metric
= EXTRACT_32BITS(tptr
);
1382 if (!TTEST2(*tptr
, 1)) /* fetch status byte */
1384 status_byte
=*(tptr
++);
1385 bit_length
= status_byte
&0x3f;
1388 } else if (afi
== IPV6
) {
1389 if (!TTEST2(*tptr
, 1)) /* fetch status & prefix_len byte */
1391 status_byte
=*(tptr
++);
1392 bit_length
=*(tptr
++);
1396 return (0); /* somebody is fooling us */
1398 byte_length
= (bit_length
+ 7) / 8; /* prefix has variable length encoding */
1400 if (!TTEST2(*tptr
, byte_length
))
1402 memset(prefix
, 0, 16); /* clear the copy buffer */
1403 memcpy(prefix
,tptr
,byte_length
); /* copy as much as is stored in the TLV */
1405 processed
+=byte_length
;
1408 printf("%sIPv4 prefix: %15s/%u",
1410 ipaddr_string(prefix
),
1414 printf("%sIPv6 prefix: %s/%u",
1416 ip6addr_string(prefix
),
1420 printf(", Distribution: %s, Metric: %u",
1421 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte
) ? "down" : "up",
1424 if (afi
== IPV4
&& ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
))
1425 printf(", sub-TLVs present");
1429 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte
) ? "External" : "Internal",
1430 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) ? ", sub-TLVs present" : "");
1433 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte
) && afi
== IPV4
) ||
1434 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte
) && afi
== IPV6
)) {
1435 /* assume that one prefix can hold more
1436 than one subTLV - therefore the first byte must reflect
1437 the aggregate bytecount of the subTLVs for this prefix
1439 if (!TTEST2(*tptr
, 1))
1442 processed
+=sublen
+1;
1443 printf(" (%u)",sublen
); /* print out subTLV length */
1446 if (!TTEST2(*tptr
,2))
1448 subtlvtype
=*(tptr
++);
1449 subtlvlen
=*(tptr
++);
1450 /* prepend the ident string */
1451 snprintf(ident_buffer
, sizeof(ident_buffer
), "%s ",ident
);
1452 if(!isis_print_ip_reach_subtlv(tptr
,subtlvtype
,subtlvlen
,ident_buffer
))
1455 sublen
-=(subtlvlen
+2);
1463 * Decode IS-IS packets. Return 0 on error.
1466 static int isis_print (const u_int8_t
*p
, u_int length
)
1468 const struct isis_common_header
*isis_header
;
1470 const struct isis_iih_lan_header
*header_iih_lan
;
1471 const struct isis_iih_ptp_header
*header_iih_ptp
;
1472 const struct isis_lsp_header
*header_lsp
;
1473 const struct isis_csnp_header
*header_csnp
;
1474 const struct isis_psnp_header
*header_psnp
;
1476 const struct isis_tlv_lsp
*tlv_lsp
;
1477 const struct isis_tlv_ptp_adj
*tlv_ptp_adj
;
1478 const struct isis_tlv_is_reach
*tlv_is_reach
;
1479 const struct isis_tlv_es_reach
*tlv_es_reach
;
1481 u_int8_t pdu_type
, max_area
, id_length
, tlv_type
, tlv_len
, tmp
, alen
, lan_alen
, prefix_len
;
1482 u_int8_t ext_is_len
, ext_ip_len
, mt_len
;
1483 const u_int8_t
*optr
, *pptr
, *tptr
;
1484 u_short packet_len
,pdu_len
;
1488 optr
= p
; /* initialize the _o_riginal pointer to the packet start -
1489 need it for parsing the checksum TLV */
1490 isis_header
= (const struct isis_common_header
*)p
;
1491 TCHECK(*isis_header
);
1492 pptr
= p
+(ISIS_COMMON_HEADER_SIZE
);
1493 header_iih_lan
= (const struct isis_iih_lan_header
*)pptr
;
1494 header_iih_ptp
= (const struct isis_iih_ptp_header
*)pptr
;
1495 header_lsp
= (const struct isis_lsp_header
*)pptr
;
1496 header_csnp
= (const struct isis_csnp_header
*)pptr
;
1497 header_psnp
= (const struct isis_psnp_header
*)pptr
;
1503 * Sanity checking of the header.
1506 if (isis_header
->version
!= ISIS_VERSION
) {
1507 printf("version %d packet not supported", isis_header
->version
);
1511 if ((isis_header
->id_length
!= SYSTEM_ID_LEN
) && (isis_header
->id_length
!= 0)) {
1512 printf("system ID length of %d is not supported",
1513 isis_header
->id_length
);
1517 if (isis_header
->pdu_version
!= ISIS_VERSION
) {
1518 printf("version %d packet not supported", isis_header
->pdu_version
);
1522 max_area
= isis_header
->max_area
;
1525 max_area
= 3; /* silly shit */
1528 printf("bad packet -- 255 areas");
1534 id_length
= isis_header
->id_length
;
1537 id_length
= 6; /* silly shit again */
1539 case 1: /* 1-8 are valid sys-ID lenghts */
1549 id_length
= 0; /* entirely useless */
1555 /* toss any non 6-byte sys-ID len PDUs */
1556 if (id_length
!= 6 ) {
1557 printf("bad packet -- illegal sys-ID length (%u)", id_length
);
1561 pdu_type
=isis_header
->pdu_type
;
1563 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1567 tok2str(isis_pdu_values
,"unknown PDU-Type %u",pdu_type
));
1571 case ISIS_PDU_L1_LAN_IIH
:
1572 case ISIS_PDU_L2_LAN_IIH
:
1573 printf(", src-id %s",
1574 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
));
1575 printf(", lan-id %s, prio %u",
1576 isis_print_id(header_iih_lan
->lan_id
,NODE_ID_LEN
),
1577 header_iih_lan
->priority
);
1579 case ISIS_PDU_PTP_IIH
:
1580 printf(", src-id %s", isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
));
1582 case ISIS_PDU_L1_LSP
:
1583 case ISIS_PDU_L2_LSP
:
1584 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1585 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1586 EXTRACT_32BITS(header_lsp
->sequence_number
),
1587 EXTRACT_16BITS(header_lsp
->remaining_lifetime
));
1589 case ISIS_PDU_L1_CSNP
:
1590 case ISIS_PDU_L2_CSNP
:
1591 printf(", src-id %s", isis_print_id(header_csnp
->source_id
,NODE_ID_LEN
));
1593 case ISIS_PDU_L1_PSNP
:
1594 case ISIS_PDU_L2_PSNP
:
1595 printf(", src-id %s", isis_print_id(header_psnp
->source_id
,NODE_ID_LEN
));
1599 printf(", length %u", length
);
1604 /* ok they seem to want to know everything - lets fully decode it */
1605 printf("%slength %u", eflag
? "" : ", ",length
);
1607 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1608 tok2str(isis_pdu_values
,
1611 isis_header
->fixed_len
,
1612 isis_header
->version
,
1613 isis_header
->pdu_version
,
1615 isis_header
->id_length
,
1617 isis_header
->max_area
);
1620 if(!print_unknown_data(optr
,"\n\t",8)) /* provide the _o_riginal pointer */
1621 return(0); /* for optionally debugging the common header */
1626 case ISIS_PDU_L1_LAN_IIH
:
1627 case ISIS_PDU_L2_LAN_IIH
:
1628 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
)) {
1629 printf(", bogus fixed header length %u should be %lu",
1630 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE
);
1634 pdu_len
=EXTRACT_16BITS(header_iih_lan
->pdu_len
);
1635 if (packet_len
>pdu_len
) {
1636 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1640 TCHECK(*header_iih_lan
);
1641 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1642 isis_print_id(header_iih_lan
->source_id
,SYSTEM_ID_LEN
),
1643 EXTRACT_16BITS(header_iih_lan
->holding_time
),
1644 tok2str(isis_iih_circuit_type_values
,
1645 "unknown circuit type 0x%02x",
1646 header_iih_lan
->circuit_type
));
1648 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1649 isis_print_id(header_iih_lan
->lan_id
, NODE_ID_LEN
),
1650 (header_iih_lan
->priority
) & ISIS_LAN_PRIORITY_MASK
,
1654 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE
))
1658 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1659 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_LAN_HEADER_SIZE
);
1662 case ISIS_PDU_PTP_IIH
:
1663 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
)) {
1664 printf(", bogus fixed header length %u should be %lu",
1665 isis_header
->fixed_len
, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE
);
1669 pdu_len
=EXTRACT_16BITS(header_iih_ptp
->pdu_len
);
1670 if (packet_len
>pdu_len
) {
1671 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1675 TCHECK(*header_iih_ptp
);
1676 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1677 isis_print_id(header_iih_ptp
->source_id
,SYSTEM_ID_LEN
),
1678 EXTRACT_16BITS(header_iih_ptp
->holding_time
),
1679 tok2str(isis_iih_circuit_type_values
,
1680 "unknown circuit type 0x%02x",
1681 header_iih_ptp
->circuit_type
));
1683 printf("\n\t circuit-id: 0x%02x, PDU length: %u",
1684 header_iih_ptp
->circuit_id
,
1688 if(!print_unknown_data(pptr
,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE
))
1692 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1693 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_IIH_PTP_HEADER_SIZE
);
1696 case ISIS_PDU_L1_LSP
:
1697 case ISIS_PDU_L2_LSP
:
1698 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
)) {
1699 printf(", bogus fixed header length %u should be %lu",
1700 isis_header
->fixed_len
, (unsigned long)ISIS_LSP_HEADER_SIZE
);
1704 pdu_len
=EXTRACT_16BITS(header_lsp
->pdu_len
);
1705 if (packet_len
>pdu_len
) {
1706 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1710 TCHECK(*header_lsp
);
1711 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
1712 isis_print_id(header_lsp
->lsp_id
, LSP_ID_LEN
),
1713 EXTRACT_32BITS(header_lsp
->sequence_number
),
1714 EXTRACT_16BITS(header_lsp
->remaining_lifetime
),
1715 EXTRACT_16BITS(header_lsp
->checksum
));
1717 /* if this is a purge do not attempt to verify the checksum */
1718 if ( EXTRACT_16BITS(header_lsp
->remaining_lifetime
) == 0 &&
1719 EXTRACT_16BITS(header_lsp
->checksum
) == 0)
1720 printf(" (purged)");
1722 /* verify the checksum -
1723 * checking starts at the lsp-id field at byte position [12]
1724 * hence the length needs to be reduced by 12 bytes */
1725 printf(" (%s)", (osi_cksum((u_int8_t
*)header_lsp
->lsp_id
, length
-12)) ? "incorrect" : "correct");
1727 printf(", PDU length: %u, Flags: [ %s",
1729 ISIS_MASK_LSP_OL_BIT(header_lsp
->typeblock
) ? "Overload bit set, " : "");
1731 if (ISIS_MASK_LSP_ATT_BITS(header_lsp
->typeblock
)) {
1732 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp
->typeblock
) ? "default " : "");
1733 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp
->typeblock
) ? "delay " : "");
1734 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp
->typeblock
) ? "expense " : "");
1735 printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp
->typeblock
) ? "error " : "");
1736 printf("ATT bit set, ");
1738 printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp
->typeblock
) ? "P bit set, " : "");
1739 printf("%s ]", tok2str(isis_lsp_istype_values
,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp
->typeblock
)));
1742 if(!print_unknown_data(pptr
,"\n\t ",ISIS_LSP_HEADER_SIZE
))
1746 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1747 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_LSP_HEADER_SIZE
);
1750 case ISIS_PDU_L1_CSNP
:
1751 case ISIS_PDU_L2_CSNP
:
1752 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
)) {
1753 printf(", bogus fixed header length %u should be %lu",
1754 isis_header
->fixed_len
, (unsigned long)ISIS_CSNP_HEADER_SIZE
);
1758 pdu_len
=EXTRACT_16BITS(header_csnp
->pdu_len
);
1759 if (packet_len
>pdu_len
) {
1760 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1764 TCHECK(*header_csnp
);
1765 printf("\n\t source-id: %s, PDU length: %u",
1766 isis_print_id(header_csnp
->source_id
, NODE_ID_LEN
),
1768 printf("\n\t start lsp-id: %s",
1769 isis_print_id(header_csnp
->start_lsp_id
, LSP_ID_LEN
));
1770 printf("\n\t end lsp-id: %s",
1771 isis_print_id(header_csnp
->end_lsp_id
, LSP_ID_LEN
));
1774 if(!print_unknown_data(pptr
,"\n\t ",ISIS_CSNP_HEADER_SIZE
))
1778 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1779 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_CSNP_HEADER_SIZE
);
1782 case ISIS_PDU_L1_PSNP
:
1783 case ISIS_PDU_L2_PSNP
:
1784 if (isis_header
->fixed_len
!= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
)) {
1785 printf("- bogus fixed header length %u should be %lu",
1786 isis_header
->fixed_len
, (unsigned long)ISIS_PSNP_HEADER_SIZE
);
1790 pdu_len
=EXTRACT_16BITS(header_psnp
->pdu_len
);
1791 if (packet_len
>pdu_len
) {
1792 packet_len
=pdu_len
; /* do TLV decoding as long as it makes sense */
1796 TCHECK(*header_psnp
);
1797 printf("\n\t source-id: %s, PDU length: %u",
1798 isis_print_id(header_psnp
->source_id
, NODE_ID_LEN
),
1802 if(!print_unknown_data(pptr
,"\n\t ",ISIS_PSNP_HEADER_SIZE
))
1806 packet_len
-= (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1807 pptr
= p
+ (ISIS_COMMON_HEADER_SIZE
+ISIS_PSNP_HEADER_SIZE
);
1811 if(!print_unknown_data(pptr
,"\n\t ",length
))
1817 * Now print the TLV's.
1820 while (packet_len
>= 2) {
1821 if (pptr
== snapend
) {
1825 if (!TTEST2(*pptr
, 2)) {
1826 printf("\n\t\t packet exceeded snapshot (%ld) bytes",
1827 (long)(pptr
-snapend
));
1832 tmp
=tlv_len
; /* copy temporary len & pointer to packet data */
1835 if (tlv_len
> packet_len
) {
1839 /* first lets see if we know the TLVs name*/
1840 printf("\n\t %s TLV #%u, length: %u",
1841 tok2str(isis_tlv_values
,
1847 /* now check if we have a decoder otherwise do a hexdump at the end*/
1849 case ISIS_TLV_AREA_ADDR
:
1850 if (!TTEST2(*tptr
, 1))
1853 while (tmp
&& alen
< tmp
) {
1854 printf("\n\t Area address (length: %u): %s",
1856 print_nsap(tptr
, alen
));
1859 if (tmp
==0) /* if this is the last area address do not attemt a boundary check */
1861 if (!TTEST2(*tptr
, 1))
1866 case ISIS_TLV_ISNEIGH
:
1867 while (tmp
>= ETHER_ADDR_LEN
) {
1868 if (!TTEST2(*tptr
, ETHER_ADDR_LEN
))
1870 printf("\n\t SNPA: %s",isis_print_id(tptr
,ETHER_ADDR_LEN
));
1871 tmp
-= ETHER_ADDR_LEN
;
1872 tptr
+= ETHER_ADDR_LEN
;
1876 case ISIS_TLV_ISNEIGH_VARLEN
:
1877 if (!TTEST2(*tptr
, 1))
1879 lan_alen
= *tptr
++; /* LAN adress length */
1881 printf("\n\t LAN address length %u bytes ",lan_alen
);
1882 while (tmp
>= lan_alen
) {
1883 if (!TTEST2(*tptr
, lan_alen
))
1885 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr
,lan_alen
));
1891 case ISIS_TLV_PADDING
:
1894 case ISIS_TLV_MT_IS_REACH
:
1895 while (tmp
>= 2+NODE_ID_LEN
+3+1) {
1896 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1897 if (mt_len
== 0) /* did something go wrong ? */
1902 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1903 if (ext_is_len
== 0) /* did something go wrong ? */
1911 case ISIS_TLV_IS_ALIAS_ID
:
1912 while (tmp
>= NODE_ID_LEN
+1) { /* is it worth attempting a decode ? */
1913 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1914 if (ext_is_len
== 0) /* did something go wrong ? */
1921 case ISIS_TLV_EXT_IS_REACH
:
1922 while (tmp
>= NODE_ID_LEN
+3+1) { /* is it worth attempting a decode ? */
1923 ext_is_len
= isis_print_ext_is_reach(tptr
,"\n\t ",tlv_type
);
1924 if (ext_is_len
== 0) /* did something go wrong ? */
1930 case ISIS_TLV_IS_REACH
:
1931 if (!TTEST2(*tptr
,1)) /* check if there is one byte left to read out the virtual flag */
1934 tok2str(isis_is_reach_virtual_values
,
1935 "bogus virtual flag 0x%02x",
1937 tlv_is_reach
= (const struct isis_tlv_is_reach
*)tptr
;
1938 while (tmp
>= sizeof(struct isis_tlv_is_reach
)) {
1939 if (!TTEST(*tlv_is_reach
))
1941 printf("\n\t IS Neighbor: %s",
1942 isis_print_id(tlv_is_reach
->neighbor_nodeid
, NODE_ID_LEN
));
1943 isis_print_metric_block(&tlv_is_reach
->isis_metric_block
);
1944 tmp
-= sizeof(struct isis_tlv_is_reach
);
1949 case ISIS_TLV_ESNEIGH
:
1950 tlv_es_reach
= (const struct isis_tlv_es_reach
*)tptr
;
1951 while (tmp
>= sizeof(struct isis_tlv_es_reach
)) {
1952 if (!TTEST(*tlv_es_reach
))
1954 printf("\n\t ES Neighbor: %s",
1955 isis_print_id(tlv_es_reach
->neighbor_sysid
,SYSTEM_ID_LEN
));
1956 isis_print_metric_block(&tlv_es_reach
->isis_metric_block
);
1957 tmp
-= sizeof(struct isis_tlv_es_reach
);
1962 /* those two TLVs share the same format */
1963 case ISIS_TLV_INT_IP_REACH
:
1964 case ISIS_TLV_EXT_IP_REACH
:
1965 if (!isis_print_tlv_ip_reach(pptr
, "\n\t ", tlv_len
))
1969 case ISIS_TLV_EXTD_IP_REACH
:
1971 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1972 if (ext_ip_len
== 0) /* did something go wrong ? */
1979 case ISIS_TLV_MT_IP_REACH
:
1981 mt_len
= isis_print_mtid(tptr
, "\n\t ");
1982 if (mt_len
== 0) /* did something go wrong ? */
1987 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV4
);
1988 if (ext_ip_len
== 0) /* did something go wrong ? */
1996 case ISIS_TLV_IP6_REACH
:
1998 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
1999 if (ext_ip_len
== 0) /* did something go wrong ? */
2006 case ISIS_TLV_MT_IP6_REACH
:
2008 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2009 if (mt_len
== 0) /* did something go wrong ? */
2014 ext_ip_len
= isis_print_extd_ip_reach(tptr
, "\n\t ", IPV6
);
2015 if (ext_ip_len
== 0) /* did something go wrong ? */
2022 case ISIS_TLV_IP6ADDR
:
2024 if (!TTEST2(*tptr
, 16))
2027 printf("\n\t IPv6 interface address: %s",
2028 ip6addr_string(tptr
));
2036 if (!TTEST2(*tptr
, 1))
2040 tok2str(isis_subtlv_auth_values
,
2041 "unknown Authentication type 0x%02x",
2045 case ISIS_SUBTLV_AUTH_SIMPLE
:
2046 for(i
=1;i
<tlv_len
;i
++) {
2047 if (!TTEST2(*(tptr
+i
), 1))
2049 printf("%c",*(tptr
+i
));
2052 case ISIS_SUBTLV_AUTH_MD5
:
2053 for(i
=1;i
<tlv_len
;i
++) {
2054 if (!TTEST2(*(tptr
+i
), 1))
2056 printf("%02x",*(tptr
+i
));
2058 if (tlv_len
!= ISIS_SUBTLV_AUTH_MD5_LEN
+1)
2059 printf(", (malformed subTLV) ");
2061 case ISIS_SUBTLV_AUTH_PRIVATE
:
2063 if(!print_unknown_data(tptr
+1,"\n\t\t ",tlv_len
-1))
2069 case ISIS_TLV_PTP_ADJ
:
2070 tlv_ptp_adj
= (const struct isis_tlv_ptp_adj
*)tptr
;
2072 if (!TTEST2(*tptr
, 1))
2074 printf("\n\t Adjacency State: %s (%u)",
2075 tok2str(isis_ptp_adjancey_values
, "unknown", *tptr
),
2079 if(tmp
>sizeof(tlv_ptp_adj
->extd_local_circuit_id
)) {
2080 if (!TTEST2(tlv_ptp_adj
->extd_local_circuit_id
,
2081 sizeof(tlv_ptp_adj
->extd_local_circuit_id
)))
2083 printf("\n\t Extended Local circuit-ID: 0x%08x",
2084 EXTRACT_32BITS(tlv_ptp_adj
->extd_local_circuit_id
));
2085 tmp
-=sizeof(tlv_ptp_adj
->extd_local_circuit_id
);
2087 if(tmp
>=SYSTEM_ID_LEN
) {
2088 if (!TTEST2(tlv_ptp_adj
->neighbor_sysid
, SYSTEM_ID_LEN
))
2090 printf("\n\t Neighbor System-ID: %s",
2091 isis_print_id(tlv_ptp_adj
->neighbor_sysid
,SYSTEM_ID_LEN
));
2094 if(tmp
>=sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)) {
2095 if (!TTEST2(tlv_ptp_adj
->neighbor_extd_local_circuit_id
,
2096 sizeof(tlv_ptp_adj
->neighbor_extd_local_circuit_id
)))
2098 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2099 EXTRACT_32BITS(tlv_ptp_adj
->neighbor_extd_local_circuit_id
));
2103 case ISIS_TLV_PROTOCOLS
:
2104 printf("\n\t NLPID(s): ");
2106 if (!TTEST2(*(tptr
), 1))
2108 printf("%s (0x%02x)",
2109 tok2str(nlpid_values
,
2113 if (tmp
>1) /* further NPLIDs ? - put comma */
2120 case ISIS_TLV_TE_ROUTER_ID
:
2121 if (!TTEST2(*pptr
, 4))
2123 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr
));
2126 case ISIS_TLV_IPADDR
:
2128 if (!TTEST2(*tptr
, 4))
2130 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2136 case ISIS_TLV_HOSTNAME
:
2137 printf("\n\t Hostname: ");
2139 if (!TTEST2(*tptr
, 1))
2141 printf("%c",*tptr
++);
2146 case ISIS_TLV_SHARED_RISK_GROUP
:
2147 if (!TTEST2(*tptr
, NODE_ID_LEN
))
2149 printf("\n\t IS Neighbor: %s", isis_print_id(tptr
, NODE_ID_LEN
));
2150 tptr
+=(NODE_ID_LEN
);
2153 if (!TTEST2(*tptr
, 1))
2155 printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr
++) ? "numbered" : "unnumbered");
2158 if (!TTEST2(*tptr
,4))
2160 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr
));
2164 if (!TTEST2(*tptr
,4))
2166 printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr
));
2171 if (!TTEST2(*tptr
, 4))
2173 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr
));
2180 tlv_lsp
= (const struct isis_tlv_lsp
*)tptr
;
2182 if (!TTEST((tlv_lsp
->lsp_id
)[LSP_ID_LEN
-1]))
2184 printf("\n\t lsp-id: %s",
2185 isis_print_id(tlv_lsp
->lsp_id
, LSP_ID_LEN
));
2186 if (!TTEST2(tlv_lsp
->sequence_number
, 4))
2188 printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp
->sequence_number
));
2189 if (!TTEST2(tlv_lsp
->remaining_lifetime
, 2))
2191 printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp
->remaining_lifetime
));
2192 if (!TTEST2(tlv_lsp
->checksum
, 2))
2194 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp
->checksum
));
2195 tmp
-=sizeof(struct isis_tlv_lsp
);
2200 case ISIS_TLV_CHECKSUM
:
2201 if (!TTEST2(*tptr
, 2))
2203 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr
));
2204 /* do not attempt to verify the checksum if it is zero
2205 * most likely a HMAC-MD5 TLV is also present and
2206 * to avoid conflicts the checksum TLV is zeroed.
2207 * see rfc3358 for details
2209 if (EXTRACT_16BITS(tptr
) == 0)
2210 printf("(unverified)");
2211 else printf("(%s)", osi_cksum(optr
, length
) ? "incorrect" : "correct");
2214 case ISIS_TLV_MT_SUPPORTED
:
2216 /* length can only be a multiple of 2, otherwise there is
2217 something broken -> so decode down until length is 1 */
2219 mt_len
= isis_print_mtid(tptr
, "\n\t ");
2220 if (mt_len
== 0) /* did something go wrong ? */
2225 printf("\n\t malformed MT-ID");
2231 case ISIS_TLV_RESTART_SIGNALING
:
2232 if (!TTEST2(*tptr
, 3))
2234 printf("\n\t Flags [%s], Remaining holding time %us",
2235 bittok2str(isis_restart_flag_values
, "none", *tptr
),
2236 EXTRACT_16BITS(tptr
+1));
2240 case ISIS_TLV_IDRP_INFO
:
2241 if (!TTEST2(*tptr
, 1))
2243 printf("\n\t Inter-Domain Information Type: %s",
2244 tok2str(isis_subtlv_idrp_values
,
2248 case ISIS_SUBTLV_IDRP_ASN
:
2249 if (!TTEST2(*tptr
, 2)) /* fetch AS number */
2251 printf("AS Number: %u",EXTRACT_16BITS(tptr
));
2253 case ISIS_SUBTLV_IDRP_LOCAL
:
2254 case ISIS_SUBTLV_IDRP_RES
:
2256 if(!print_unknown_data(tptr
,"\n\t ",tlv_len
-1))
2262 case ISIS_TLV_LSP_BUFFERSIZE
:
2263 if (!TTEST2(*tptr
, 2))
2265 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr
));
2268 case ISIS_TLV_PART_DIS
:
2269 while (tmp
>= SYSTEM_ID_LEN
) {
2270 if (!TTEST2(*tptr
, SYSTEM_ID_LEN
))
2272 printf("\n\t %s",isis_print_id(tptr
,SYSTEM_ID_LEN
));
2273 tptr
+=SYSTEM_ID_LEN
;
2278 case ISIS_TLV_PREFIX_NEIGH
:
2279 if (!TTEST2(*tptr
, sizeof(struct isis_metric_block
)))
2281 printf("\n\t Metric Block");
2282 isis_print_metric_block((const struct isis_metric_block
*)tptr
);
2283 tptr
+=sizeof(struct isis_metric_block
);
2284 tmp
-=sizeof(struct isis_metric_block
);
2287 if (!TTEST2(*tptr
, 1))
2289 prefix_len
=*tptr
++; /* read out prefix length in semioctets*/
2291 if (!TTEST2(*tptr
, prefix_len
/2))
2293 printf("\n\t\tAddress: %s/%u",
2294 print_nsap(tptr
,prefix_len
/2),
2301 case ISIS_TLV_IIH_SEQNR
:
2302 if (!TTEST2(*tptr
, 4)) /* check if four bytes are on the wire */
2304 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr
) );
2307 case ISIS_TLV_VENDOR_PRIVATE
:
2308 if (!TTEST2(*tptr
, 3)) /* check if enough byte for a full oui */
2310 vendor_id
= EXTRACT_24BITS(tptr
);
2311 printf("\n\t Vendor: %s (%u)",
2312 tok2str(oui_values
,"Unknown",vendor_id
),
2316 if (tmp
> 0) /* hexdump the rest */
2317 if(!print_unknown_data(tptr
,"\n\t\t",tmp
))
2321 * FIXME those are the defined TLVs that lack a decoder
2322 * you are welcome to contribute code ;-)
2325 case ISIS_TLV_DECNET_PHASE4
:
2326 case ISIS_TLV_LUCENT_PRIVATE
:
2327 case ISIS_TLV_IPAUTH
:
2328 case ISIS_TLV_NORTEL_PRIVATE1
:
2329 case ISIS_TLV_NORTEL_PRIVATE2
:
2333 if(!print_unknown_data(pptr
,"\n\t\t",tlv_len
))
2338 /* do we want to see an additionally hexdump ? */
2340 if(!print_unknown_data(pptr
,"\n\t ",tlv_len
))
2345 packet_len
-= tlv_len
;
2348 if (packet_len
!= 0) {
2349 printf("\n\t %u straggler bytes", packet_len
);
2354 fputs("[|isis]", stdout
);
2358 printf("\n\t\t packet exceeded snapshot");
2363 * Verify the checksum. See 8473-1, Appendix C, section C.4.
2367 osi_cksum(const u_int8_t
*tptr
, u_int len
)
2369 int32_t c0
= 0, c1
= 0;
2371 while ((int)--len
>= 0) {