Deleted Added
full compact
print-isoclns.c (127675) print-isoclns.c (146778)
1/*
2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
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

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
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.
20 *
21 * Original code by Matt Thomas, Digital Equipment Corporation
22 *
23 * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
1/*
2 * Copyright (c) 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
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

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
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.
20 *
21 * Original code by Matt Thomas, Digital Equipment Corporation
22 *
23 * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
24 * complete IS-IS support.
24 * complete IS-IS & CLNP support.
25 *
25 *
26 * $FreeBSD: head/contrib/tcpdump/print-isoclns.c 127675 2004-03-31 14:57:24Z bms $
26 * $FreeBSD: head/contrib/tcpdump/print-isoclns.c 146778 2005-05-29 19:09:28Z sam $
27 */
28
29#ifndef lint
30static const char rcsid[] _U_ =
27 */
28
29#ifndef lint
30static const char rcsid[] _U_ =
31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.106.2.5 2004/03/24 01:45:26 guy Exp $ (LBL)";
31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133 2005/04/06 21:32:40 mcr Exp $ (LBL)";
32#endif
33
34#ifdef HAVE_CONFIG_H
35#include "config.h"
36#endif
37
38#include <tcpdump-stdinc.h>
39
40#include <stdio.h>
41#include <string.h>
42
43#include "interface.h"
44#include "addrtoname.h"
45#include "ethertype.h"
46#include "ether.h"
32#endif
33
34#ifdef HAVE_CONFIG_H
35#include "config.h"
36#endif
37
38#include <tcpdump-stdinc.h>
39
40#include <stdio.h>
41#include <string.h>
42
43#include "interface.h"
44#include "addrtoname.h"
45#include "ethertype.h"
46#include "ether.h"
47#include "nlpid.h"
47#include "extract.h"
48#include "gmpls.h"
48#include "extract.h"
49#include "gmpls.h"
50#include "oui.h"
49
51
50#define NLPID_CLNS 129 /* 0x81 */
51#define NLPID_ESIS 130 /* 0x82 */
52#define NLPID_ISIS 131 /* 0x83 */
53#define NLPID_IP6 0x8e
54#define NLPID_IP 0xcc
55#define NLPID_NULLNS 0
56
57#define IPV4 1 /* AFI value */
58#define IPV6 2 /* AFI value */
59
60/*
61 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
62 */
63
64#define SYSTEM_ID_LEN ETHER_ADDR_LEN
65#define NODE_ID_LEN SYSTEM_ID_LEN+1
66#define LSP_ID_LEN SYSTEM_ID_LEN+2
67
68#define ISIS_VERSION 1
52#define IPV4 1 /* AFI value */
53#define IPV6 2 /* AFI value */
54
55/*
56 * IS-IS is defined in ISO 10589. Look there for protocol definitions.
57 */
58
59#define SYSTEM_ID_LEN ETHER_ADDR_LEN
60#define NODE_ID_LEN SYSTEM_ID_LEN+1
61#define LSP_ID_LEN SYSTEM_ID_LEN+2
62
63#define ISIS_VERSION 1
69#define PDU_TYPE_MASK 0x1F
70#define PRIORITY_MASK 0x7F
64#define ESIS_VERSION 1
65#define CLNP_VERSION 1
71
66
72#define L1_LAN_IIH 15
73#define L2_LAN_IIH 16
74#define PTP_IIH 17
75#define L1_LSP 18
76#define L2_LSP 20
77#define L1_CSNP 24
78#define L2_CSNP 25
79#define L1_PSNP 26
80#define L2_PSNP 27
67#define ISIS_PDU_TYPE_MASK 0x1F
68#define ESIS_PDU_TYPE_MASK 0x1F
69#define CLNP_PDU_TYPE_MASK 0x1F
70#define CLNP_FLAG_MASK 0xE0
71#define ISIS_LAN_PRIORITY_MASK 0x7F
81
72
73#define ISIS_PDU_L1_LAN_IIH 15
74#define ISIS_PDU_L2_LAN_IIH 16
75#define ISIS_PDU_PTP_IIH 17
76#define ISIS_PDU_L1_LSP 18
77#define ISIS_PDU_L2_LSP 20
78#define ISIS_PDU_L1_CSNP 24
79#define ISIS_PDU_L2_CSNP 25
80#define ISIS_PDU_L1_PSNP 26
81#define ISIS_PDU_L2_PSNP 27
82
82static struct tok isis_pdu_values[] = {
83static struct tok isis_pdu_values[] = {
83 { L1_LAN_IIH, "L1 Lan IIH"},
84 { L2_LAN_IIH, "L2 Lan IIH"},
85 { PTP_IIH, "p2p IIH"},
86 { L1_LSP, "L1 LSP"},
87 { L2_LSP, "L2 LSP"},
88 { L1_CSNP, "L1 CSNP"},
89 { L2_CSNP, "L2 CSNP"},
90 { L1_PSNP, "L1 PSNP"},
91 { L2_PSNP, "L2 PSNP"},
84 { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
85 { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
86 { ISIS_PDU_PTP_IIH, "p2p IIH"},
87 { ISIS_PDU_L1_LSP, "L1 LSP"},
88 { ISIS_PDU_L2_LSP, "L2 LSP"},
89 { ISIS_PDU_L1_CSNP, "L1 CSNP"},
90 { ISIS_PDU_L2_CSNP, "L2 CSNP"},
91 { ISIS_PDU_L1_PSNP, "L1 PSNP"},
92 { ISIS_PDU_L2_PSNP, "L2 PSNP"},
92 { 0, NULL}
93};
94
95/*
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.
99 *
100 * list taken from rfc3359 plus some memory from veterans ;-)
101 */
102
93 { 0, NULL}
94};
95
96/*
97 * A TLV is a tuple of a type, length and a value and is normally used for
98 * encoding information in all sorts of places. This is an enumeration of
99 * the well known types.
100 *
101 * list taken from rfc3359 plus some memory from veterans ;-)
102 */
103
103#define TLV_AREA_ADDR 1 /* iso10589 */
104#define TLV_IS_REACH 2 /* iso10589 */
105#define TLV_ESNEIGH 3 /* iso10589 */
106#define TLV_PART_DIS 4 /* iso10589 */
107#define TLV_PREFIX_NEIGH 5 /* iso10589 */
108#define TLV_ISNEIGH 6 /* iso10589 */
109#define TLV_ISNEIGH_VARLEN 7 /* iso10589 */
110#define TLV_PADDING 8 /* iso10589 */
111#define TLV_LSP 9 /* iso10589 */
112#define TLV_AUTH 10 /* iso10589, rfc3567 */
113#define TLV_CHECKSUM 12 /* rfc3358 */
114#define TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
115#define TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
116#define TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
117#define TLV_DECNET_PHASE4 42
118#define TLV_LUCENT_PRIVATE 66
119#define TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
120#define TLV_PROTOCOLS 129 /* rfc1195 */
121#define TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
122#define TLV_IDRP_INFO 131 /* rfc1195 */
123#define TLV_IPADDR 132 /* rfc1195 */
124#define TLV_IPAUTH 133 /* rfc1195 */
125#define TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
126#define TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
127#define TLV_HOSTNAME 137 /* rfc2763 */
128#define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
129#define TLV_NORTEL_PRIVATE1 176
130#define TLV_NORTEL_PRIVATE2 177
131#define TLV_HOLDTIME 198 /* ES-IS */
132#define TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
133#define TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
134#define TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
135#define TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
136#define TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
137#define TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
138#define TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
139#define TLV_PTP_ADJ 240 /* rfc3373 */
140#define TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
141#define TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-proprietary-tlv-00 */
104#define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
105#define ISIS_TLV_IS_REACH 2 /* iso10589 */
106#define ISIS_TLV_ESNEIGH 3 /* iso10589 */
107#define ISIS_TLV_PART_DIS 4 /* iso10589 */
108#define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
109#define ISIS_TLV_ISNEIGH 6 /* iso10589 */
110#define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
111#define ISIS_TLV_PADDING 8 /* iso10589 */
112#define ISIS_TLV_LSP 9 /* iso10589 */
113#define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
114#define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
115#define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
116#define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
117#define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
118#define ISIS_TLV_DECNET_PHASE4 42
119#define ISIS_TLV_LUCENT_PRIVATE 66
120#define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
121#define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
122#define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
123#define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
124#define ISIS_TLV_IPADDR 132 /* rfc1195 */
125#define ISIS_TLV_IPAUTH 133 /* rfc1195 */
126#define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
127#define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
128#define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
129#define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
130#define ISIS_TLV_NORTEL_PRIVATE1 176
131#define ISIS_TLV_NORTEL_PRIVATE2 177
132#define ISIS_TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
133#define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
134#define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
135#define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
136#define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
137#define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
138#define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
139#define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
140#define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
141#define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
142
143static struct tok isis_tlv_values[] = {
142
143static struct tok isis_tlv_values[] = {
144 { TLV_AREA_ADDR, "Area address(es)"},
145 { TLV_IS_REACH, "IS Reachability"},
146 { TLV_ESNEIGH, "ES Neighbor(s)"},
147 { TLV_PART_DIS, "Partition DIS"},
148 { TLV_PREFIX_NEIGH, "Prefix Neighbors"},
149 { TLV_ISNEIGH, "IS Neighbor(s)"},
150 { TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
151 { TLV_PADDING, "Padding"},
152 { TLV_LSP, "LSP entries"},
153 { TLV_AUTH, "Authentication"},
154 { TLV_CHECKSUM, "Checksum"},
155 { TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
156 { TLV_EXT_IS_REACH, "Extended IS Reachability"},
157 { TLV_IS_ALIAS_ID, "IS Alias ID"},
158 { TLV_DECNET_PHASE4, "DECnet Phase IV"},
159 { TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
160 { TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
161 { TLV_PROTOCOLS, "Protocols supported"},
162 { TLV_EXT_IP_REACH, "IPv4 External Reachability"},
163 { TLV_IDRP_INFO, "Inter-Domain Information Type"},
164 { TLV_IPADDR, "IPv4 Interface address(es)"},
165 { TLV_IPAUTH, "IPv4 authentication (deprecated)"},
166 { TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
167 { TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
168 { TLV_HOSTNAME, "Hostname"},
169 { TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
170 { TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
171 { TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
172 { TLV_HOLDTIME, "Holdtime"},
173 { TLV_RESTART_SIGNALING, "Restart Signaling"},
174 { TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
175 { TLV_MT_SUPPORTED, "Multi Topology"},
176 { TLV_IP6ADDR, "IPv6 Interface address(es)"},
177 { TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
178 { TLV_IP6_REACH, "IPv6 reachability"},
179 { TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
180 { TLV_PTP_ADJ, "Point-to-point Adjacency State"},
181 { TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
182 { TLV_VENDOR_PRIVATE, "Vendor Private"},
144 { ISIS_TLV_AREA_ADDR, "Area address(es)"},
145 { ISIS_TLV_IS_REACH, "IS Reachability"},
146 { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
147 { ISIS_TLV_PART_DIS, "Partition DIS"},
148 { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
149 { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
150 { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
151 { ISIS_TLV_PADDING, "Padding"},
152 { ISIS_TLV_LSP, "LSP entries"},
153 { ISIS_TLV_AUTH, "Authentication"},
154 { ISIS_TLV_CHECKSUM, "Checksum"},
155 { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
156 { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
157 { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
158 { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
159 { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
160 { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
161 { ISIS_TLV_PROTOCOLS, "Protocols supported"},
162 { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
163 { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
164 { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
165 { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
166 { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
167 { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
168 { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
169 { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
170 { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
171 { ISIS_TLV_HOSTNAME, "Hostname"},
172 { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
173 { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
174 { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
175 { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
176 { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
177 { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
178 { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
179 { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
180 { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
181 { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
183 { 0, NULL }
184};
185
182 { 0, NULL }
183};
184
186#define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
187#define SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
188#define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
189#define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
190#define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
191#define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
192#define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
193#define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
194#define SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
195#define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
196#define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
185#define ESIS_OPTION_PROTOCOLS 129
186#define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
187#define ESIS_OPTION_SECURITY 197 /* iso9542 */
188#define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
189#define ESIS_OPTION_PRIORITY 205 /* iso9542 */
190#define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
191#define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
197
192
193static struct tok esis_option_values[] = {
194 { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
195 { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
196 { ESIS_OPTION_SECURITY, "Security" },
197 { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
198 { ESIS_OPTION_PRIORITY, "Priority" },
199 { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
200 { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
201 { 0, NULL }
202};
203
204#define CLNP_OPTION_DISCARD_REASON 193
205#define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
206#define CLNP_OPTION_PRIORITY 205 /* iso8473 */
207
208static struct tok clnp_option_values[] = {
209 { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
210 { CLNP_OPTION_PRIORITY, "Priority"},
211 { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
212 { 0, NULL }
213};
214
215static struct tok clnp_option_rfd_class_values[] = {
216 { 0x0, "General"},
217 { 0x8, "Address"},
218 { 0x9, "Source Routeing"},
219 { 0xa, "Lifetime"},
220 { 0xb, "PDU Discarded"},
221 { 0xc, "Reassembly"},
222 { 0, NULL }
223};
224
225static struct tok clnp_option_rfd_general_values[] = {
226 { 0x0, "Reason not specified"},
227 { 0x1, "Protocol procedure error"},
228 { 0x2, "Incorrect checksum"},
229 { 0x3, "PDU discarded due to congestion"},
230 { 0x4, "Header syntax error (cannot be parsed)"},
231 { 0x5, "Segmentation needed but not permitted"},
232 { 0x6, "Incomplete PDU received"},
233 { 0x7, "Duplicate option"},
234 { 0, NULL }
235};
236
237static struct tok clnp_option_rfd_address_values[] = {
238 { 0x0, "Destination address unreachable"},
239 { 0x1, "Destination address unknown"},
240 { 0, NULL }
241};
242
243static struct tok clnp_option_rfd_source_routeing_values[] = {
244 { 0x0, "Unspecified source routeing error"},
245 { 0x1, "Syntax error in source routeing field"},
246 { 0x2, "Unknown address in source routeing field"},
247 { 0x3, "Path not acceptable"},
248 { 0, NULL }
249};
250
251static struct tok clnp_option_rfd_lifetime_values[] = {
252 { 0x0, "Lifetime expired while data unit in transit"},
253 { 0x1, "Lifetime expired during reassembly"},
254 { 0, NULL }
255};
256
257static struct tok clnp_option_rfd_pdu_discard_values[] = {
258 { 0x0, "Unsupported option not specified"},
259 { 0x1, "Unsupported protocol version"},
260 { 0x2, "Unsupported security option"},
261 { 0x3, "Unsupported source routeing option"},
262 { 0x4, "Unsupported recording of route option"},
263 { 0, NULL }
264};
265
266static struct tok clnp_option_rfd_reassembly_values[] = {
267 { 0x0, "Reassembly interference"},
268 { 0, NULL }
269};
270
271/* array of 16 error-classes */
272static struct tok *clnp_option_rfd_error_class[] = {
273 clnp_option_rfd_general_values,
274 NULL,
275 NULL,
276 NULL,
277 NULL,
278 NULL,
279 NULL,
280 NULL,
281 clnp_option_rfd_address_values,
282 clnp_option_rfd_source_routeing_values,
283 clnp_option_rfd_lifetime_values,
284 clnp_option_rfd_pdu_discard_values,
285 clnp_option_rfd_reassembly_values,
286 NULL,
287 NULL,
288 NULL
289};
290
291
292#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
293#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
294#define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
295#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
296#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
297#define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
298#define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
299#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
300#define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE 12 /* draft-ietf-tewg-diff-te-proto-06 */
301#define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
302#define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
303#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
304
198static struct tok isis_ext_is_reach_subtlv_values[] = {
305static struct tok isis_ext_is_reach_subtlv_values[] = {
199 { SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
200 { SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
201 { SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
202 { SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
203 { SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
204 { SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
205 { SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
206 { SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
207 { SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
208 { SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
209 { SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
210 { 250, "Reserved for cisco specific extensions" },
211 { 251, "Reserved for cisco specific extensions" },
212 { 252, "Reserved for cisco specific extensions" },
213 { 253, "Reserved for cisco specific extensions" },
214 { 254, "Reserved for cisco specific extensions" },
215 { 255, "Reserved for future expansion" },
306 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
307 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
308 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
309 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
310 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
311 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
312 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
313 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
314 { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE, "Diffserv TE" },
315 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
316 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
317 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
318 { 250, "Reserved for cisco specific extensions" },
319 { 251, "Reserved for cisco specific extensions" },
320 { 252, "Reserved for cisco specific extensions" },
321 { 253, "Reserved for cisco specific extensions" },
322 { 254, "Reserved for cisco specific extensions" },
323 { 255, "Reserved for future expansion" },
216 { 0, NULL }
217};
218
324 { 0, NULL }
325};
326
219#define SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1
220#define SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2
327#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
328#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
329#define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
221
222static struct tok isis_ext_ip_reach_subtlv_values[] = {
330
331static struct tok isis_ext_ip_reach_subtlv_values[] = {
223 { SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
224 { SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
332 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
333 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
334 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
225 { 0, NULL }
226};
227
335 { 0, NULL }
336};
337
228#define SUBTLV_AUTH_SIMPLE 1
229#define SUBTLV_AUTH_MD5 54
230#define SUBTLV_AUTH_MD5_LEN 16
231#define SUBTLV_AUTH_PRIVATE 255
338#define ISIS_SUBTLV_AUTH_SIMPLE 1
339#define ISIS_SUBTLV_AUTH_MD5 54
340#define ISIS_SUBTLV_AUTH_MD5_LEN 16
341#define ISIS_SUBTLV_AUTH_PRIVATE 255
232
233static struct tok isis_subtlv_auth_values[] = {
342
343static struct tok isis_subtlv_auth_values[] = {
234 { SUBTLV_AUTH_SIMPLE, "simple text password"},
235 { SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
236 { SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
344 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
345 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
346 { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
237 { 0, NULL }
238};
239
347 { 0, NULL }
348};
349
240#define SUBTLV_IDRP_RES 0
241#define SUBTLV_IDRP_LOCAL 1
242#define SUBTLV_IDRP_ASN 2
350#define ISIS_SUBTLV_IDRP_RES 0
351#define ISIS_SUBTLV_IDRP_LOCAL 1
352#define ISIS_SUBTLV_IDRP_ASN 2
243
244static struct tok isis_subtlv_idrp_values[] = {
353
354static struct tok isis_subtlv_idrp_values[] = {
245 { SUBTLV_IDRP_RES, "Reserved"},
246 { SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
247 { SUBTLV_IDRP_ASN, "AS Number Tag"},
355 { ISIS_SUBTLV_IDRP_RES, "Reserved"},
356 { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
357 { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
248 { 0, NULL}
249};
250
358 { 0, NULL}
359};
360
251#define ISIS_8BIT_MASK(x) ((x)&0xff)
361#define CLNP_SEGMENT_PART 0x80
362#define CLNP_MORE_SEGMENTS 0x40
363#define CLNP_REQUEST_ER 0x20
252
364
365static struct tok clnp_flag_values[] = {
366 { CLNP_SEGMENT_PART, "Segmentation permitted"},
367 { CLNP_MORE_SEGMENTS, "more Segments"},
368 { CLNP_REQUEST_ER, "request Error Report"},
369 { 0, NULL}
370};
371
253#define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
254#define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
255#define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
256#define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
257#define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
258#define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
259#define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
260#define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)

--- 44 unchanged lines hidden (view full) ---

305static struct tok isis_lsp_istype_values[] = {
306 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
307 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
308 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
309 { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"},
310 { 0, NULL }
311};
312
372#define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
373#define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
374#define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
375#define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
376#define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
377#define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
378#define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
379#define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)

--- 44 unchanged lines hidden (view full) ---

424static struct tok isis_lsp_istype_values[] = {
425 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
426 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
427 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
428 { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"},
429 { 0, NULL }
430};
431
313static struct tok osi_nlpid_values[] = {
314 { NLPID_CLNS, "CLNS"},
315 { NLPID_IP, "IPv4"},
316 { NLPID_IP6, "IPv6"},
317 { 0, NULL }
318};
319
320/*
321 * Katz's point to point adjacency TLV uses codes to tell us the state of
322 * the remote adjacency. Enumerate them.
323 */
324
325#define ISIS_PTP_ADJ_UP 0
326#define ISIS_PTP_ADJ_INIT 1
327#define ISIS_PTP_ADJ_DOWN 2
328
432/*
433 * Katz's point to point adjacency TLV uses codes to tell us the state of
434 * the remote adjacency. Enumerate them.
435 */
436
437#define ISIS_PTP_ADJ_UP 0
438#define ISIS_PTP_ADJ_INIT 1
439#define ISIS_PTP_ADJ_DOWN 2
440
329
330static struct tok isis_ptp_adjancey_values[] = {
331 { ISIS_PTP_ADJ_UP, "Up" },
332 { ISIS_PTP_ADJ_INIT, "Initializing" },
333 { ISIS_PTP_ADJ_DOWN, "Down" },
334 { 0, NULL}
335};
336
337struct isis_tlv_ptp_adj {
338 u_int8_t adjacency_state;
339 u_int8_t extd_local_circuit_id[4];
340 u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
341 u_int8_t neighbor_extd_local_circuit_id[4];
342};
343
344static int osi_cksum(const u_int8_t *, u_int);
441static struct tok isis_ptp_adjancey_values[] = {
442 { ISIS_PTP_ADJ_UP, "Up" },
443 { ISIS_PTP_ADJ_INIT, "Initializing" },
444 { ISIS_PTP_ADJ_DOWN, "Down" },
445 { 0, NULL}
446};
447
448struct isis_tlv_ptp_adj {
449 u_int8_t adjacency_state;
450 u_int8_t extd_local_circuit_id[4];
451 u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
452 u_int8_t neighbor_extd_local_circuit_id[4];
453};
454
455static int osi_cksum(const u_int8_t *, u_int);
456static int clnp_print(const u_int8_t *, u_int);
345static void esis_print(const u_int8_t *, u_int);
346static int isis_print(const u_int8_t *, u_int);
347
348struct isis_metric_block {
349 u_int8_t metric_default;
350 u_int8_t metric_delay;
351 u_int8_t metric_expense;
352 u_int8_t metric_error;

--- 78 unchanged lines hidden (view full) ---

431
432struct isis_tlv_lsp {
433 u_int8_t remaining_lifetime[2];
434 u_int8_t lsp_id[LSP_ID_LEN];
435 u_int8_t sequence_number[4];
436 u_int8_t checksum[2];
437};
438
457static void esis_print(const u_int8_t *, u_int);
458static int isis_print(const u_int8_t *, u_int);
459
460struct isis_metric_block {
461 u_int8_t metric_default;
462 u_int8_t metric_delay;
463 u_int8_t metric_expense;
464 u_int8_t metric_error;

--- 78 unchanged lines hidden (view full) ---

543
544struct isis_tlv_lsp {
545 u_int8_t remaining_lifetime[2];
546 u_int8_t lsp_id[LSP_ID_LEN];
547 u_int8_t sequence_number[4];
548 u_int8_t checksum[2];
549};
550
439static char *
440print_nsap(register const u_int8_t *pptr, register int nsap_length)
441{
442 int nsap_idx;
443 static char nsap_ascii_output[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")];
444 char *junk_buf = nsap_ascii_output;
445
446 if (nsap_length < 1 || nsap_length > 20) {
447 snprintf(nsap_ascii_output, sizeof(nsap_ascii_output),
448 "illegal length");
449 return (nsap_ascii_output);
450 }
451
452 for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
453 if (!TTEST2(*pptr, 1))
454 return (0);
455 snprintf(junk_buf,
456 sizeof(nsap_ascii_output) - (junk_buf - nsap_ascii_output),
457 "%02x", *pptr++);
458 junk_buf += strlen(junk_buf);
459 if (((nsap_idx & 1) == 0) &&
460 (nsap_idx + 1 < nsap_length)) {
461 *junk_buf++ = '.';
462 }
463 }
464 *(junk_buf) = '\0';
465 return (nsap_ascii_output);
466}
467
468#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
469#define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
470#define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
471#define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
472#define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
473#define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
474
475void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
476{
477 const struct isis_common_header *header;
478
479 header = (const struct isis_common_header *)p;
480
551#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
552#define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
553#define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
554#define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
555#define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
556#define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
557
558void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
559{
560 const struct isis_common_header *header;
561
562 header = (const struct isis_common_header *)p;
563
481 printf("%sOSI", caplen < 1 ? "|" : "");
564 if (caplen <= 1) { /* enough bytes on the wire ? */
565 printf("|OSI");
566 return;
567 }
482
568
483 if (caplen < 1) /* enough bytes on the wire ? */
484 return;
485
569 if (eflag)
570 printf("OSI NLPID %s (0x%02x): ",
571 tok2str(nlpid_values,"Unknown",*p),
572 *p);
573
486 switch (*p) {
487
574 switch (*p) {
575
488 case NLPID_CLNS:
489 (void)printf(", CLNS, length %u", length);
576 case NLPID_CLNP:
577 if (!clnp_print(p, length))
578 print_unknown_data(p,"\n\t",caplen);
490 break;
491
492 case NLPID_ESIS:
493 esis_print(p, length);
494 return;
495
496 case NLPID_ISIS:
497 if (!isis_print(p, length))
498 print_unknown_data(p,"\n\t",caplen);
499 break;
500
501 case NLPID_NULLNS:
579 break;
580
581 case NLPID_ESIS:
582 esis_print(p, length);
583 return;
584
585 case NLPID_ISIS:
586 if (!isis_print(p, length))
587 print_unknown_data(p,"\n\t",caplen);
588 break;
589
590 case NLPID_NULLNS:
502 (void)printf(", ISO NULLNS, length: %u", length);
591 (void)printf(", length: %u", length);
503 break;
504
592 break;
593
594 case NLPID_Q933:
595 q933_print(p+1, length-1);
596 break;
597
598 case NLPID_IP:
599 ip_print(gndo, p+1, length-1);
600 break;
601
602#ifdef INET6
603 case NLPID_IP6:
604 ip6_print(p+1, length-1);
605 break;
606#endif
607
608 case NLPID_PPP:
609 ppp_print(p+1, length-1);
610 break;
611
505 default:
612 default:
506 (void)printf(", Unknown NLPID 0x%02x, length: %u", p[0], length);
613 if (!eflag)
614 printf("OSI NLPID 0x%02x unknown",*p);
615 (void)printf(", length: %u", length);
507 if (caplen > 1)
508 print_unknown_data(p,"\n\t",caplen);
509 break;
510 }
511}
512
616 if (caplen > 1)
617 print_unknown_data(p,"\n\t",caplen);
618 break;
619 }
620}
621
513#define ESIS_REDIRECT 6
514#define ESIS_ESH 2
515#define ESIS_ISH 4
622#define CLNP_PDU_ER 1
623#define CLNP_PDU_DT 28
624#define CLNP_PDU_MD 29
625#define CLNP_PDU_ERQ 30
626#define CLNP_PDU_ERP 31
516
627
517static struct tok esis_values[] = {
518 { ESIS_REDIRECT, "redirect"},
519 { ESIS_ESH, "ESH"},
520 { ESIS_ISH, "ISH"},
628static struct tok clnp_pdu_values[] = {
629 { CLNP_PDU_ER, "Error Report"},
630 { CLNP_PDU_MD, "MD"},
631 { CLNP_PDU_DT, "Data"},
632 { CLNP_PDU_ERQ, "Echo Request"},
633 { CLNP_PDU_ERP, "Echo Response"},
521 { 0, NULL }
522};
523
634 { 0, NULL }
635};
636
524struct esis_hdr {
637struct clnp_header_t {
638 u_int8_t nlpid;
639 u_int8_t length_indicator;
640 u_int8_t version;
641 u_int8_t lifetime; /* units of 500ms */
642 u_int8_t type;
643 u_int8_t segment_length[2];
644 u_int8_t cksum[2];
645};
646
647struct clnp_segment_header_t {
648 u_int8_t data_unit_id[2];
649 u_int8_t segment_offset[2];
650 u_int8_t total_length[2];
651};
652
653/*
654 * clnp_print
655 * Decode CLNP packets. Return 0 on error.
656 */
657
658static int clnp_print (const u_int8_t *pptr, u_int length)
659{
660 const u_int8_t *optr,*source_address,*dest_address;
661 u_int li,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
662 const struct clnp_header_t *clnp_header;
663 const struct clnp_segment_header_t *clnp_segment_header;
664 u_int8_t rfd_error_major,rfd_error_minor;
665
666 clnp_header = (const struct clnp_header_t *) pptr;
667 TCHECK(*clnp_header);
668
669 li = clnp_header->length_indicator;
670 optr = pptr;
671
672 if (!eflag)
673 printf("CLNP");
674
675 /*
676 * Sanity checking of the header.
677 */
678
679 if (clnp_header->version != CLNP_VERSION) {
680 printf("version %d packet not supported", clnp_header->version);
681 return (0);
682 }
683
684 /* FIXME further header sanity checking */
685
686 clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
687 clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
688
689 pptr += sizeof(struct clnp_header_t);
690 li -= sizeof(struct clnp_header_t);
691 dest_address_length = *pptr;
692 dest_address = pptr + 1;
693
694 pptr += (1 + dest_address_length);
695 li -= (1 + dest_address_length);
696 source_address_length = *pptr;
697 source_address = pptr +1;
698
699 pptr += (1 + source_address_length);
700 li -= (1 + source_address_length);
701
702 if (vflag < 1) {
703 printf("%s%s > %s, %s, length %u",
704 eflag ? "" : ", ",
705 isonsap_string(source_address, source_address_length),
706 isonsap_string(dest_address, dest_address_length),
707 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
708 length);
709 return (1);
710 }
711 printf("%slength %u",eflag ? "" : ", ",length);
712
713 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ",
714 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
715 clnp_header->length_indicator,
716 clnp_header->version,
717 clnp_header->lifetime/2,
718 (clnp_header->lifetime%2)*5,
719 EXTRACT_16BITS(clnp_header->segment_length),
720 EXTRACT_16BITS(clnp_header->cksum));
721
722 /* do not attempt to verify the checksum if it is zero */
723 if (EXTRACT_16BITS(clnp_header->cksum) == 0)
724 printf("(unverified)");
725 else printf("(%s)", osi_cksum(optr, clnp_header->length_indicator) ? "incorrect" : "correct");
726
727 printf("\n\tFlags [%s]",
728 bittok2str(clnp_flag_values,"none",clnp_flags));
729
730 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
731 source_address_length,
732 isonsap_string(source_address, source_address_length),
733 dest_address_length,
734 isonsap_string(dest_address,dest_address_length));
735
736 if (clnp_flags & CLNP_SEGMENT_PART) {
737 clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
738 printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
739 EXTRACT_16BITS(clnp_segment_header->data_unit_id),
740 EXTRACT_16BITS(clnp_segment_header->segment_offset),
741 EXTRACT_16BITS(clnp_segment_header->total_length));
742 pptr+=sizeof(const struct clnp_segment_header_t);
743 li-=sizeof(const struct clnp_segment_header_t);
744 }
745
746 /* now walk the options */
747 while (li >= 2) {
748 u_int op, opli;
749 const u_int8_t *tptr;
750
751 if (snapend - pptr < 2)
752 return (0);
753 if (li < 2) {
754 printf(", bad opts/li");
755 return (0);
756 }
757 op = *pptr++;
758 opli = *pptr++;
759 li -= 2;
760 if (opli > li) {
761 printf(", opt (%d) too long", op);
762 return (0);
763 }
764 li -= opli;
765 tptr = pptr;
766
767 if (snapend < pptr)
768 return(0);
769
770 printf("\n\t %s Option #%u, length %u, value: ",
771 tok2str(clnp_option_values,"Unknown",op),
772 op,
773 opli);
774
775 switch (op) {
776
777 case CLNP_OPTION_PRIORITY:
778 printf("%u", *tptr);
779 break;
780
781 case CLNP_OPTION_DISCARD_REASON:
782 rfd_error_major = (*tptr&0xf0) >> 4;
783 rfd_error_minor = *tptr&0x0f;
784 printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
785 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
786 rfd_error_major,
787 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
788 rfd_error_minor);
789 break;
790
791 /*
792 * FIXME those are the defined Options that lack a decoder
793 * you are welcome to contribute code ;-)
794 */
795
796 default:
797 print_unknown_data(tptr,"\n\t ",opli);
798 break;
799 }
800 if (vflag > 1)
801 print_unknown_data(pptr,"\n\t ",opli);
802 pptr += opli;
803 }
804
805 switch (clnp_pdu_type) {
806
807 case CLNP_PDU_ER: /* fall through */
808 case CLNP_PDU_ERP:
809 if (*(pptr) == NLPID_CLNP) {
810 printf("\n\t-----original packet-----\n\t");
811 /* FIXME recursion protection */
812 clnp_print(pptr, length-clnp_header->length_indicator);
813 break;
814 }
815
816 case CLNP_PDU_DT:
817 case CLNP_PDU_MD:
818 case CLNP_PDU_ERQ:
819
820 default:
821 /* dump the PDU specific data */
822 if (length-(pptr-optr) > 0) {
823 printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator);
824 print_unknown_data(pptr,"\n\t ",length-(pptr-optr));
825 }
826 }
827
828 return (1);
829
830 trunc:
831 fputs("[|clnp]", stdout);
832 return (1);
833
834}
835
836
837#define ESIS_PDU_REDIRECT 6
838#define ESIS_PDU_ESH 2
839#define ESIS_PDU_ISH 4
840
841static struct tok esis_pdu_values[] = {
842 { ESIS_PDU_REDIRECT, "redirect"},
843 { ESIS_PDU_ESH, "ESH"},
844 { ESIS_PDU_ISH, "ISH"},
845 { 0, NULL }
846};
847
848struct esis_header_t {
849 u_int8_t nlpid;
850 u_int8_t length_indicator;
525 u_int8_t version;
526 u_int8_t reserved;
527 u_int8_t type;
851 u_int8_t version;
852 u_int8_t reserved;
853 u_int8_t type;
528 u_int8_t tmo[2];
854 u_int8_t holdtime[2];
529 u_int8_t cksum[2];
530};
531
532static void
855 u_int8_t cksum[2];
856};
857
858static void
533esis_print(const u_int8_t *p, u_int length)
859esis_print(const u_int8_t *pptr, u_int length)
534{
860{
535 const u_int8_t *ep;
536 u_int li;
537 const struct esis_hdr *eh;
861 const u_int8_t *optr;
862 u_int li,esis_pdu_type,source_address_length, source_address_number;
863 const struct esis_header_t *esis_header;
538
864
865 if (!eflag)
866 printf("ES-IS");
867
539 if (length <= 2) {
540 if (qflag)
868 if (length <= 2) {
869 if (qflag)
541 printf(" bad pkt!");
870 printf("bad pkt!");
542 else
871 else
543 printf(" no header at all!");
872 printf("no header at all!");
544 return;
545 }
873 return;
874 }
546 li = p[1];
547 eh = (const struct esis_hdr *) &p[2];
548 ep = p + li;
875
876 esis_header = (const struct esis_header_t *) pptr;
877 li = esis_header->length_indicator;
878 optr = pptr;
879
880 /*
881 * Sanity checking of the header.
882 */
883
884 if (esis_header->nlpid != NLPID_ESIS) {
885 printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
886 return;
887 }
888
889 if (esis_header->version != ESIS_VERSION) {
890 printf(" version %d packet not supported", esis_header->version);
891 return;
892 }
893
549 if (li > length) {
894 if (li > length) {
550 if (qflag)
551 printf(" bad pkt!");
552 else
553 printf(" LI(%d) > PDU size (%d)!", li, length);
554 return;
895 printf(" length indicator(%d) > PDU size (%d)!", li, length);
896 return;
555 }
897 }
556 if (li < sizeof(struct esis_hdr) + 2) {
557 if (qflag)
558 printf(" bad pkt!");
559 else {
560 printf(" too short for esis header %d:", li);
561 while (--length != 0)
562 printf("%02X", *p++);
563 }
564 return;
898
899 if (li < sizeof(struct esis_header_t) + 2) {
900 printf(" length indicator < min PDU size %d:", li);
901 while (--length != 0)
902 printf("%02X", *pptr++);
903 return;
565 }
566
904 }
905
567 printf(", ES-IS, %s, length %u",
568 tok2str(esis_values,"unknown type: %u",eh->type & 0x1f),
569 length);
906 esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
570
907
571 if(vflag < 1)
572 return;
908 if (vflag < 1) {
909 printf("%s%s, length %u",
910 eflag ? "" : ", ",
911 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
912 length);
913 return;
914 } else
915 printf("%slength %u\n\t%s (%u)",
916 eflag ? "" : ", ",
917 length,
918 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
919 esis_pdu_type);
573
920
574 if (vflag && osi_cksum(p, li)) {
575 printf(" bad cksum (got 0x%02x%02x)",
576 eh->cksum[1], eh->cksum[0]);
577 default_print(p, length);
578 return;
579 }
580 if (eh->version != 1) {
581 printf(" unsupported version %d", eh->version);
582 return;
583 }
584 p += sizeof(*eh) + 2;
585 li -= sizeof(*eh) + 2; /* protoid * li */
921 printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
922 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header->cksum));
923 /* do not attempt to verify the checksum if it is zero */
924 if (EXTRACT_16BITS(esis_header->cksum) == 0)
925 printf("(unverified)");
926 else printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct");
586
927
587 switch (eh->type & 0x1f) {
588 case ESIS_REDIRECT: {
589 const u_int8_t *dst, *snpa, *is;
928 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
590
929
591 dst = p; p += *p + 1;
592 if (p > snapend)
930 if (vflag > 1)
931 print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
932
933 pptr += sizeof(struct esis_header_t);
934 li -= sizeof(struct esis_header_t);
935
936 switch (esis_pdu_type) {
937 case ESIS_PDU_REDIRECT: {
938 const u_int8_t *dst, *snpa, *tptr;
939
940 dst = pptr; pptr += *pptr + 1;
941 if (pptr > snapend)
593 return;
942 return;
594 printf("\n\t\t %s", isonsap_string(dst));
595 snpa = p; p += *p + 1;
596 is = p; p += *p + 1;
597 if (p > snapend)
943 printf("\n\t %s", isonsap_string(dst+1,*dst));
944 snpa = pptr; pptr += *pptr + 1;
945 tptr = pptr; pptr += *pptr + 1;
946 if (pptr > snapend)
598 return;
947 return;
599 if (p > ep) {
600 printf(" [bad li]");
601 return;
602 }
603 if (is[0] == 0)
604 printf(" > %s", etheraddr_string(&snpa[1]));
948
949 if (tptr[0] == 0)
950 printf("\n\t %s", etheraddr_string(&snpa[1]));
605 else
951 else
606 printf(" > %s", isonsap_string(is));
607 li = ep - p;
952 printf("\n\t %s", isonsap_string(tptr+1,*tptr));
608 break;
609 }
610
953 break;
954 }
955
611 case ESIS_ESH:
612 break;
956 case ESIS_PDU_ESH:
957 source_address_number = *pptr;
958 pptr++;
959 li--;
613
960
614 case ESIS_ISH: {
615 const u_int8_t *is;
961 printf("\n\t Number of Source Addresses: %u", source_address_number);
962
963 while (source_address_number > 0) {
964 source_address_length = *pptr;
965 printf("\n\t NET (length: %u): %s",
966 source_address_length,
967 isonsap_string(pptr+1,source_address_length));
616
968
617 is = p; p += *p + 1;
618 if (p > ep) {
619 printf(" [bad li]");
620 return;
621 }
622 if (p > snapend)
623 return;
624 if (!qflag)
625 printf("\n\tNET: %s", print_nsap(is+1,*is));
626 li = ep - p;
627 break;
969 pptr += source_address_length+1;
970 li -= source_address_length+1;
971 source_address_number--;
972 }
973
974 break;
975
976 case ESIS_PDU_ISH: {
977 source_address_length = *pptr;
978 printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr+1, source_address_length));
979 pptr += source_address_length+1;
980 li -= source_address_length +1;
981 break;
628 }
629
630 default:
631 if (vflag <= 1) {
982 }
983
984 default:
985 if (vflag <= 1) {
632 if (p < snapend)
633 print_unknown_data(p,"\n\t ",snapend-p);
986 if (pptr < snapend)
987 print_unknown_data(pptr,"\n\t ",snapend-pptr);
634 }
635 return;
636 }
637
988 }
989 return;
990 }
991
638 /* hexdump - FIXME ? */
639 if (vflag > 1) {
640 if (p < snapend)
641 print_unknown_data(p,"\n\t ",snapend-p);
642 }
643 if (vflag)
644 while (p < ep && li) {
645 u_int op, opli;
646 const u_int8_t *q;
992 /* now walk the options */
993 while (li >= 2) {
994 u_int op, opli;
995 const u_int8_t *tptr;
996
997 if (snapend - pptr < 2)
998 return;
999 if (li < 2) {
1000 printf(", bad opts/li");
1001 return;
1002 }
1003 op = *pptr++;
1004 opli = *pptr++;
1005 li -= 2;
1006 if (opli > li) {
1007 printf(", opt (%d) too long", op);
1008 return;
1009 }
1010 li -= opli;
1011 tptr = pptr;
1012
1013 if (snapend < pptr)
1014 return;
1015
1016 printf("\n\t %s Option #%u, length %u, value: ",
1017 tok2str(esis_option_values,"Unknown",op),
1018 op,
1019 opli);
647
1020
648 if (snapend - p < 2)
649 return;
650 if (li < 2) {
651 printf(", bad opts/li");
652 return;
653 }
654 op = *p++;
655 opli = *p++;
656 li -= 2;
657 if (opli > li) {
658 printf(", opt (%d) too long", op);
659 return;
660 }
661 li -= opli;
662 q = p;
663 p += opli;
1021 switch (op) {
664
1022
665 if (snapend < p)
666 return;
1023 case ESIS_OPTION_ES_CONF_TIME:
1024 printf("%us", EXTRACT_16BITS(tptr));
1025 break;
1026
667
1027
668 if (op == TLV_HOLDTIME && opli == 2) {
669 printf("\n\tholdtime: %us", EXTRACT_16BITS(q));
670 continue;
671 }
1028 case ESIS_OPTION_PROTOCOLS:
1029 while (opli>0) {
1030 printf("%s (0x%02x)",
1031 tok2str(nlpid_values,
1032 "unknown",
1033 *tptr),
1034 *tptr);
1035 if (opli>1) /* further NPLIDs ? - put comma */
1036 printf(", ");
1037 tptr++;
1038 opli--;
1039 }
1040 break;
672
1041
673 if (op == TLV_PROTOCOLS && opli >= 1) {
674 printf("\n\t%s (length: %u): %s",
675 tok2str(isis_tlv_values, "unknown", op),
676 opli,
677 tok2str(osi_nlpid_values,"Unknown 0x%02x",*q));
678 continue;
679 }
1042 /*
1043 * FIXME those are the defined Options that lack a decoder
1044 * you are welcome to contribute code ;-)
1045 */
680
1046
681 print_unknown_data(q,"\n\t ",opli);
682 }
683}
1047 case ESIS_OPTION_QOS_MAINTENANCE:
1048 case ESIS_OPTION_SECURITY:
1049 case ESIS_OPTION_PRIORITY:
1050 case ESIS_OPTION_ADDRESS_MASK:
1051 case ESIS_OPTION_SNPA_MASK:
684
1052
1053 default:
1054 print_unknown_data(tptr,"\n\t ",opli);
1055 break;
1056 }
1057 if (vflag > 1)
1058 print_unknown_data(pptr,"\n\t ",opli);
1059 pptr += opli;
1060 }
1061}
1062
685/* shared routine for printing system, node and lsp-ids */
686static char *
687isis_print_id(const u_int8_t *cp, int id_len)
688{
689 int i;
690 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
691 char *pos = id;
692

--- 112 unchanged lines hidden (view full) ---

805 subt),
806 subt,
807 subl);
808
809 if (!TTEST2(*tptr,subl))
810 goto trunctlv;
811
812 switch(subt) {
1063/* shared routine for printing system, node and lsp-ids */
1064static char *
1065isis_print_id(const u_int8_t *cp, int id_len)
1066{
1067 int i;
1068 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
1069 char *pos = id;
1070

--- 112 unchanged lines hidden (view full) ---

1183 subt),
1184 subt,
1185 subl);
1186
1187 if (!TTEST2(*tptr,subl))
1188 goto trunctlv;
1189
1190 switch(subt) {
813 case SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
1191 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
1192 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
814 while (subl >= 4) {
815 printf(", 0x%08x (=%u)",
816 EXTRACT_32BITS(tptr),
817 EXTRACT_32BITS(tptr));
818 tptr+=4;
819 subl-=4;
820 }
821 break;
1193 while (subl >= 4) {
1194 printf(", 0x%08x (=%u)",
1195 EXTRACT_32BITS(tptr),
1196 EXTRACT_32BITS(tptr));
1197 tptr+=4;
1198 subl-=4;
1199 }
1200 break;
822 case SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
1201 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
823 while (subl >= 8) {
824 printf(", 0x%08x%08x",
825 EXTRACT_32BITS(tptr),
826 EXTRACT_32BITS(tptr+4));
827 tptr+=8;
828 subl-=8;
829 }
830 break;

--- 13 unchanged lines hidden (view full) ---

844/*
845 * this is the common IS-REACH subTLV decoder it is called
846 * from isis_print_ext_is_reach()
847 */
848
849static int
850isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
851
1202 while (subl >= 8) {
1203 printf(", 0x%08x%08x",
1204 EXTRACT_32BITS(tptr),
1205 EXTRACT_32BITS(tptr+4));
1206 tptr+=8;
1207 subl-=8;
1208 }
1209 break;

--- 13 unchanged lines hidden (view full) ---

1223/*
1224 * this is the common IS-REACH subTLV decoder it is called
1225 * from isis_print_ext_is_reach()
1226 */
1227
1228static int
1229isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
1230
852 int priority_level;
1231 int priority_level,bandwidth_constraint;
853 union { /* int to float conversion buffer for several subTLVs */
854 float f;
855 u_int32_t i;
856 } bw;
857
858 /* first lets see if we know the subTLVs name*/
859 printf("%s%s subTLV #%u, length: %u",
860 ident,
861 tok2str(isis_ext_is_reach_subtlv_values,
862 "unknown",
863 subt),
864 subt,
865 subl);
866
867 if (!TTEST2(*tptr,subl))
868 goto trunctlv;
869
870 switch(subt) {
1232 union { /* int to float conversion buffer for several subTLVs */
1233 float f;
1234 u_int32_t i;
1235 } bw;
1236
1237 /* first lets see if we know the subTLVs name*/
1238 printf("%s%s subTLV #%u, length: %u",
1239 ident,
1240 tok2str(isis_ext_is_reach_subtlv_values,
1241 "unknown",
1242 subt),
1243 subt,
1244 subl);
1245
1246 if (!TTEST2(*tptr,subl))
1247 goto trunctlv;
1248
1249 switch(subt) {
871 case SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
872 case SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
873 case SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
1250 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
1251 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
1252 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
874 if (subl >= 4) {
875 printf(", 0x%08x", EXTRACT_32BITS(tptr));
876 if (subl == 8) /* draft-ietf-isis-gmpls-extensions */
877 printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
878 }
879 break;
1253 if (subl >= 4) {
1254 printf(", 0x%08x", EXTRACT_32BITS(tptr));
1255 if (subl == 8) /* draft-ietf-isis-gmpls-extensions */
1256 printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
1257 }
1258 break;
880 case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
881 case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
1259 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
1260 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
882 if (subl >= 4)
883 printf(", %s", ipaddr_string(tptr));
884 break;
1261 if (subl >= 4)
1262 printf(", %s", ipaddr_string(tptr));
1263 break;
885 case SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
886 case SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
1264 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
1265 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
887 if (subl >= 4) {
888 bw.i = EXTRACT_32BITS(tptr);
889 printf(", %.3f Mbps", bw.f*8/1000000 );
890 }
891 break;
1266 if (subl >= 4) {
1267 bw.i = EXTRACT_32BITS(tptr);
1268 printf(", %.3f Mbps", bw.f*8/1000000 );
1269 }
1270 break;
892 case SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
1271 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
893 if (subl >= 32) {
894 for (priority_level = 0; priority_level < 8; priority_level++) {
895 bw.i = EXTRACT_32BITS(tptr);
896 printf("%s priority level %d: %.3f Mbps",
897 ident,
898 priority_level,
899 bw.f*8/1000000 );
900 tptr+=4;
901 }
902 }
903 break;
1272 if (subl >= 32) {
1273 for (priority_level = 0; priority_level < 8; priority_level++) {
1274 bw.i = EXTRACT_32BITS(tptr);
1275 printf("%s priority level %d: %.3f Mbps",
1276 ident,
1277 priority_level,
1278 bw.f*8/1000000 );
1279 tptr+=4;
1280 }
1281 }
1282 break;
904 case SUBTLV_EXT_IS_REACH_TE_METRIC:
1283 case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE:
1284 printf("%sBandwidth Constraints Model ID: %s (%u)",
1285 ident,
1286 tok2str(diffserv_te_bc_values, "unknown", *tptr),
1287 *tptr);
1288 tptr++;
1289 /* decode BCs until the subTLV ends */
1290 for (bandwidth_constraint = 0; bandwidth_constraint < (subl-1)/4; bandwidth_constraint++) {
1291 bw.i = EXTRACT_32BITS(tptr);
1292 printf("%s Bandwidth constraint %d: %.3f Mbps",
1293 ident,
1294 bandwidth_constraint,
1295 bw.f*8/1000000 );
1296 tptr+=4;
1297 }
1298 break;
1299 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
905 if (subl >= 3)
906 printf(", %u", EXTRACT_24BITS(tptr));
907 break;
1300 if (subl >= 3)
1301 printf(", %u", EXTRACT_24BITS(tptr));
1302 break;
908 case SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
1303 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
909 if (subl >= 2) {
910 printf(", %s, Priority %u",
911 bittok2str(gmpls_link_prot_values, "none", *tptr),
912 *(tptr+1));
913 }
914 break;
1304 if (subl >= 2) {
1305 printf(", %s, Priority %u",
1306 bittok2str(gmpls_link_prot_values, "none", *tptr),
1307 *(tptr+1));
1308 }
1309 break;
915 case SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
1310 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
916 if (subl >= 36) {
917 printf("%s Interface Switching Capability:%s",
918 ident,
919 tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)));
920 printf(", LSP Encoding: %s",
921 tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
922 tptr+=4;
923 printf("%s Max LSP Bandwidth:",ident);

--- 42 unchanged lines hidden (view full) ---

966 int proc_bytes = 0; /* how many bytes did we process ? */
967
968 if (!TTEST2(*tptr, NODE_ID_LEN))
969 return(0);
970
971 printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
972 tptr+=(NODE_ID_LEN);
973
1311 if (subl >= 36) {
1312 printf("%s Interface Switching Capability:%s",
1313 ident,
1314 tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)));
1315 printf(", LSP Encoding: %s",
1316 tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
1317 tptr+=4;
1318 printf("%s Max LSP Bandwidth:",ident);

--- 42 unchanged lines hidden (view full) ---

1361 int proc_bytes = 0; /* how many bytes did we process ? */
1362
1363 if (!TTEST2(*tptr, NODE_ID_LEN))
1364 return(0);
1365
1366 printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
1367 tptr+=(NODE_ID_LEN);
1368
974 if (tlv_type != TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
1369 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
975 if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
976 return(0);
977 printf(", Metric: %d",EXTRACT_24BITS(tptr));
978 tptr+=3;
979 }
980
981 if (!TTEST2(*tptr, 1))
982 return(0);

--- 145 unchanged lines hidden (view full) ---

1128
1129/*
1130 * isis_print
1131 * Decode IS-IS packets. Return 0 on error.
1132 */
1133
1134static int isis_print (const u_int8_t *p, u_int length)
1135{
1370 if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
1371 return(0);
1372 printf(", Metric: %d",EXTRACT_24BITS(tptr));
1373 tptr+=3;
1374 }
1375
1376 if (!TTEST2(*tptr, 1))
1377 return(0);

--- 145 unchanged lines hidden (view full) ---

1523
1524/*
1525 * isis_print
1526 * Decode IS-IS packets. Return 0 on error.
1527 */
1528
1529static int isis_print (const u_int8_t *p, u_int length)
1530{
1136 const struct isis_common_header *header;
1531 const struct isis_common_header *isis_header;
1137
1138 const struct isis_iih_lan_header *header_iih_lan;
1139 const struct isis_iih_ptp_header *header_iih_ptp;
1140 const struct isis_lsp_header *header_lsp;
1141 const struct isis_csnp_header *header_csnp;
1142 const struct isis_psnp_header *header_psnp;
1143
1144 const struct isis_tlv_lsp *tlv_lsp;
1145 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
1146 const struct isis_tlv_is_reach *tlv_is_reach;
1147 const struct isis_tlv_es_reach *tlv_es_reach;
1148
1149 u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
1150 u_int8_t ext_is_len, ext_ip_len, mt_len;
1151 const u_int8_t *optr, *pptr, *tptr;
1152 u_short packet_len,pdu_len;
1532
1533 const struct isis_iih_lan_header *header_iih_lan;
1534 const struct isis_iih_ptp_header *header_iih_ptp;
1535 const struct isis_lsp_header *header_lsp;
1536 const struct isis_csnp_header *header_csnp;
1537 const struct isis_psnp_header *header_psnp;
1538
1539 const struct isis_tlv_lsp *tlv_lsp;
1540 const struct isis_tlv_ptp_adj *tlv_ptp_adj;
1541 const struct isis_tlv_is_reach *tlv_is_reach;
1542 const struct isis_tlv_es_reach *tlv_es_reach;
1543
1544 u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
1545 u_int8_t ext_is_len, ext_ip_len, mt_len;
1546 const u_int8_t *optr, *pptr, *tptr;
1547 u_short packet_len,pdu_len;
1153 u_int i;
1548 u_int i,vendor_id;
1154
1155 packet_len=length;
1156 optr = p; /* initialize the _o_riginal pointer to the packet start -
1157 need it for parsing the checksum TLV */
1549
1550 packet_len=length;
1551 optr = p; /* initialize the _o_riginal pointer to the packet start -
1552 need it for parsing the checksum TLV */
1158 header = (const struct isis_common_header *)p;
1159 TCHECK(*header);
1553 isis_header = (const struct isis_common_header *)p;
1554 TCHECK(*isis_header);
1160 pptr = p+(ISIS_COMMON_HEADER_SIZE);
1161 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
1162 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
1163 header_lsp = (const struct isis_lsp_header *)pptr;
1164 header_csnp = (const struct isis_csnp_header *)pptr;
1165 header_psnp = (const struct isis_psnp_header *)pptr;
1166
1555 pptr = p+(ISIS_COMMON_HEADER_SIZE);
1556 header_iih_lan = (const struct isis_iih_lan_header *)pptr;
1557 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
1558 header_lsp = (const struct isis_lsp_header *)pptr;
1559 header_csnp = (const struct isis_csnp_header *)pptr;
1560 header_psnp = (const struct isis_psnp_header *)pptr;
1561
1562 if (!eflag)
1563 printf("IS-IS");
1564
1167 /*
1168 * Sanity checking of the header.
1169 */
1170
1565 /*
1566 * Sanity checking of the header.
1567 */
1568
1171 if (header->version != ISIS_VERSION) {
1172 printf(", version %d packet not supported", header->version);
1569 if (isis_header->version != ISIS_VERSION) {
1570 printf("version %d packet not supported", isis_header->version);
1173 return (0);
1174 }
1175
1571 return (0);
1572 }
1573
1176 if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) {
1177 printf(", system ID length of %d is not supported",
1178 header->id_length);
1574 if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
1575 printf("system ID length of %d is not supported",
1576 isis_header->id_length);
1179 return (0);
1180 }
1181
1577 return (0);
1578 }
1579
1182 if (header->pdu_version != ISIS_VERSION) {
1183 printf(", version %d packet not supported", header->pdu_version);
1580 if (isis_header->pdu_version != ISIS_VERSION) {
1581 printf("version %d packet not supported", isis_header->pdu_version);
1184 return (0);
1185 }
1186
1582 return (0);
1583 }
1584
1187 max_area = header->max_area;
1585 max_area = isis_header->max_area;
1188 switch(max_area) {
1189 case 0:
1190 max_area = 3; /* silly shit */
1191 break;
1192 case 255:
1586 switch(max_area) {
1587 case 0:
1588 max_area = 3; /* silly shit */
1589 break;
1590 case 255:
1193 printf(", bad packet -- 255 areas");
1591 printf("bad packet -- 255 areas");
1194 return (0);
1195 default:
1196 break;
1197 }
1198
1592 return (0);
1593 default:
1594 break;
1595 }
1596
1199 id_length = header->id_length;
1597 id_length = isis_header->id_length;
1200 switch(id_length) {
1201 case 0:
1202 id_length = 6; /* silly shit again */
1203 break;
1204 case 1: /* 1-8 are valid sys-ID lenghts */
1205 case 2:
1206 case 3:
1207 case 4:

--- 6 unchanged lines hidden (view full) ---

1214 id_length = 0; /* entirely useless */
1215 break;
1216 default:
1217 break;
1218 }
1219
1220 /* toss any non 6-byte sys-ID len PDUs */
1221 if (id_length != 6 ) {
1598 switch(id_length) {
1599 case 0:
1600 id_length = 6; /* silly shit again */
1601 break;
1602 case 1: /* 1-8 are valid sys-ID lenghts */
1603 case 2:
1604 case 3:
1605 case 4:

--- 6 unchanged lines hidden (view full) ---

1612 id_length = 0; /* entirely useless */
1613 break;
1614 default:
1615 break;
1616 }
1617
1618 /* toss any non 6-byte sys-ID len PDUs */
1619 if (id_length != 6 ) {
1222 printf(", bad packet -- illegal sys-ID length (%u)", id_length);
1620 printf("bad packet -- illegal sys-ID length (%u)", id_length);
1223 return (0);
1224 }
1225
1621 return (0);
1622 }
1623
1226 pdu_type=header->pdu_type;
1624 pdu_type=isis_header->pdu_type;
1227
1228 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1229 if (vflag < 1) {
1625
1626 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
1627 if (vflag < 1) {
1230 printf(", IS-IS, %s",
1628 printf("%s%s",
1629 eflag ? "" : ", ",
1231 tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
1232
1233 switch (pdu_type) {
1234
1630 tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
1631
1632 switch (pdu_type) {
1633
1235 case L1_LAN_IIH:
1236 case L2_LAN_IIH:
1634 case ISIS_PDU_L1_LAN_IIH:
1635 case ISIS_PDU_L2_LAN_IIH:
1237 printf(", src-id %s",
1238 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
1239 printf(", lan-id %s, prio %u",
1240 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
1241 header_iih_lan->priority);
1242 break;
1636 printf(", src-id %s",
1637 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
1638 printf(", lan-id %s, prio %u",
1639 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
1640 header_iih_lan->priority);
1641 break;
1243 case PTP_IIH:
1642 case ISIS_PDU_PTP_IIH:
1244 printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
1245 break;
1643 printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
1644 break;
1246 case L1_LSP:
1247 case L2_LSP:
1645 case ISIS_PDU_L1_LSP:
1646 case ISIS_PDU_L2_LSP:
1248 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1249 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
1250 EXTRACT_32BITS(header_lsp->sequence_number),
1251 EXTRACT_16BITS(header_lsp->remaining_lifetime));
1252 break;
1647 printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
1648 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
1649 EXTRACT_32BITS(header_lsp->sequence_number),
1650 EXTRACT_16BITS(header_lsp->remaining_lifetime));
1651 break;
1253 case L1_CSNP:
1254 case L2_CSNP:
1255 printf(", src-id %s", isis_print_id(header_csnp->source_id,SYSTEM_ID_LEN));
1652 case ISIS_PDU_L1_CSNP:
1653 case ISIS_PDU_L2_CSNP:
1654 printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
1256 break;
1655 break;
1257 case L1_PSNP:
1258 case L2_PSNP:
1259 printf(", src-id %s", isis_print_id(header_psnp->source_id,SYSTEM_ID_LEN));
1656 case ISIS_PDU_L1_PSNP:
1657 case ISIS_PDU_L2_PSNP:
1658 printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
1260 break;
1261
1262 }
1263 printf(", length %u", length);
1264
1265 return(1);
1266 }
1267
1268 /* ok they seem to want to know everything - lets fully decode it */
1659 break;
1660
1661 }
1662 printf(", length %u", length);
1663
1664 return(1);
1665 }
1666
1667 /* ok they seem to want to know everything - lets fully decode it */
1269 printf(", IS-IS, length: %u",length);
1668 printf("%slength %u", eflag ? "" : ", ",length);
1270
1271 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1272 tok2str(isis_pdu_values,
1273 "unknown, type %u",
1274 pdu_type),
1669
1670 printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
1671 tok2str(isis_pdu_values,
1672 "unknown, type %u",
1673 pdu_type),
1275 header->fixed_len,
1276 header->version,
1277 header->pdu_version,
1674 isis_header->fixed_len,
1675 isis_header->version,
1676 isis_header->pdu_version,
1278 id_length,
1677 id_length,
1279 header->id_length,
1678 isis_header->id_length,
1280 max_area,
1679 max_area,
1281 header->max_area);
1680 isis_header->max_area);
1282
1283 if (vflag > 1) {
1284 if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
1285 return(0); /* for optionally debugging the common header */
1286 }
1287
1288 switch (pdu_type) {
1289
1681
1682 if (vflag > 1) {
1683 if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
1684 return(0); /* for optionally debugging the common header */
1685 }
1686
1687 switch (pdu_type) {
1688
1290 case L1_LAN_IIH:
1291 case L2_LAN_IIH:
1292 if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
1689 case ISIS_PDU_L1_LAN_IIH:
1690 case ISIS_PDU_L2_LAN_IIH:
1691 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
1293 printf(", bogus fixed header length %u should be %lu",
1692 printf(", bogus fixed header length %u should be %lu",
1294 header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
1693 isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
1295 return (0);
1296 }
1297
1298 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
1299 if (packet_len>pdu_len) {
1300 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1301 length=pdu_len;
1302 }
1303
1304 TCHECK(*header_iih_lan);
1305 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1306 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
1307 EXTRACT_16BITS(header_iih_lan->holding_time),
1308 tok2str(isis_iih_circuit_type_values,
1309 "unknown circuit type 0x%02x",
1310 header_iih_lan->circuit_type));
1311
1312 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1313 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
1694 return (0);
1695 }
1696
1697 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
1698 if (packet_len>pdu_len) {
1699 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1700 length=pdu_len;
1701 }
1702
1703 TCHECK(*header_iih_lan);
1704 printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
1705 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
1706 EXTRACT_16BITS(header_iih_lan->holding_time),
1707 tok2str(isis_iih_circuit_type_values,
1708 "unknown circuit type 0x%02x",
1709 header_iih_lan->circuit_type));
1710
1711 printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
1712 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
1314 (header_iih_lan->priority) & PRIORITY_MASK,
1713 (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
1315 pdu_len);
1316
1317 if (vflag > 1) {
1318 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE))
1319 return(0);
1320 }
1321
1322 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1323 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1324 break;
1325
1714 pdu_len);
1715
1716 if (vflag > 1) {
1717 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE))
1718 return(0);
1719 }
1720
1721 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1722 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
1723 break;
1724
1326 case PTP_IIH:
1327 if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
1725 case ISIS_PDU_PTP_IIH:
1726 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
1328 printf(", bogus fixed header length %u should be %lu",
1727 printf(", bogus fixed header length %u should be %lu",
1329 header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
1728 isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
1330 return (0);
1331 }
1332
1333 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
1334 if (packet_len>pdu_len) {
1335 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1336 length=pdu_len;
1337 }

--- 14 unchanged lines hidden (view full) ---

1352 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE))
1353 return(0);
1354 }
1355
1356 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1357 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1358 break;
1359
1729 return (0);
1730 }
1731
1732 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
1733 if (packet_len>pdu_len) {
1734 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1735 length=pdu_len;
1736 }

--- 14 unchanged lines hidden (view full) ---

1751 if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE))
1752 return(0);
1753 }
1754
1755 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1756 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
1757 break;
1758
1360 case L1_LSP:
1361 case L2_LSP:
1362 if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
1759 case ISIS_PDU_L1_LSP:
1760 case ISIS_PDU_L2_LSP:
1761 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
1363 printf(", bogus fixed header length %u should be %lu",
1762 printf(", bogus fixed header length %u should be %lu",
1364 header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
1763 isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
1365 return (0);
1366 }
1367
1368 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
1369 if (packet_len>pdu_len) {
1370 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1371 length=pdu_len;
1372 }

--- 33 unchanged lines hidden (view full) ---

1406 if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE))
1407 return(0);
1408 }
1409
1410 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1411 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1412 break;
1413
1764 return (0);
1765 }
1766
1767 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
1768 if (packet_len>pdu_len) {
1769 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1770 length=pdu_len;
1771 }

--- 33 unchanged lines hidden (view full) ---

1805 if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE))
1806 return(0);
1807 }
1808
1809 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1810 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
1811 break;
1812
1414 case L1_CSNP:
1415 case L2_CSNP:
1416 if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
1813 case ISIS_PDU_L1_CSNP:
1814 case ISIS_PDU_L2_CSNP:
1815 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
1417 printf(", bogus fixed header length %u should be %lu",
1816 printf(", bogus fixed header length %u should be %lu",
1418 header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
1817 isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
1419 return (0);
1420 }
1421
1422 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
1423 if (packet_len>pdu_len) {
1424 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1425 length=pdu_len;
1426 }

--- 11 unchanged lines hidden (view full) ---

1438 if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
1439 return(0);
1440 }
1441
1442 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
1443 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
1444 break;
1445
1818 return (0);
1819 }
1820
1821 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
1822 if (packet_len>pdu_len) {
1823 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1824 length=pdu_len;
1825 }

--- 11 unchanged lines hidden (view full) ---

1837 if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
1838 return(0);
1839 }
1840
1841 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
1842 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
1843 break;
1844
1446 case L1_PSNP:
1447 case L2_PSNP:
1448 if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
1845 case ISIS_PDU_L1_PSNP:
1846 case ISIS_PDU_L2_PSNP:
1847 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
1449 printf("- bogus fixed header length %u should be %lu",
1848 printf("- bogus fixed header length %u should be %lu",
1450 header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
1849 isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
1451 return (0);
1452 }
1453
1454 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
1455 if (packet_len>pdu_len) {
1456 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1457 length=pdu_len;
1458 }

--- 46 unchanged lines hidden (view full) ---

1505 tok2str(isis_tlv_values,
1506 "unknown",
1507 tlv_type),
1508 tlv_type,
1509 tlv_len);
1510
1511 /* now check if we have a decoder otherwise do a hexdump at the end*/
1512 switch (tlv_type) {
1850 return (0);
1851 }
1852
1853 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
1854 if (packet_len>pdu_len) {
1855 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
1856 length=pdu_len;
1857 }

--- 46 unchanged lines hidden (view full) ---

1904 tok2str(isis_tlv_values,
1905 "unknown",
1906 tlv_type),
1907 tlv_type,
1908 tlv_len);
1909
1910 /* now check if we have a decoder otherwise do a hexdump at the end*/
1911 switch (tlv_type) {
1513 case TLV_AREA_ADDR:
1912 case ISIS_TLV_AREA_ADDR:
1514 if (!TTEST2(*tptr, 1))
1515 goto trunctlv;
1516 alen = *tptr++;
1517 while (tmp && alen < tmp) {
1518 printf("\n\t Area address (length: %u): %s",
1519 alen,
1913 if (!TTEST2(*tptr, 1))
1914 goto trunctlv;
1915 alen = *tptr++;
1916 while (tmp && alen < tmp) {
1917 printf("\n\t Area address (length: %u): %s",
1918 alen,
1520 print_nsap(tptr, alen));
1919 isonsap_string(tptr,alen));
1521 tptr += alen;
1522 tmp -= alen + 1;
1523 if (tmp==0) /* if this is the last area address do not attemt a boundary check */
1524 break;
1525 if (!TTEST2(*tptr, 1))
1526 goto trunctlv;
1527 alen = *tptr++;
1528 }
1529 break;
1920 tptr += alen;
1921 tmp -= alen + 1;
1922 if (tmp==0) /* if this is the last area address do not attemt a boundary check */
1923 break;
1924 if (!TTEST2(*tptr, 1))
1925 goto trunctlv;
1926 alen = *tptr++;
1927 }
1928 break;
1530 case TLV_ISNEIGH:
1929 case ISIS_TLV_ISNEIGH:
1531 while (tmp >= ETHER_ADDR_LEN) {
1532 if (!TTEST2(*tptr, ETHER_ADDR_LEN))
1533 goto trunctlv;
1534 printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
1535 tmp -= ETHER_ADDR_LEN;
1536 tptr += ETHER_ADDR_LEN;
1537 }
1538 break;
1539
1930 while (tmp >= ETHER_ADDR_LEN) {
1931 if (!TTEST2(*tptr, ETHER_ADDR_LEN))
1932 goto trunctlv;
1933 printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
1934 tmp -= ETHER_ADDR_LEN;
1935 tptr += ETHER_ADDR_LEN;
1936 }
1937 break;
1938
1540 case TLV_ISNEIGH_VARLEN:
1939 case ISIS_TLV_ISNEIGH_VARLEN:
1541 if (!TTEST2(*tptr, 1))
1542 goto trunctlv;
1543 lan_alen = *tptr++; /* LAN adress length */
1544 tmp --;
1545 printf("\n\t LAN address length %u bytes ",lan_alen);
1546 while (tmp >= lan_alen) {
1547 if (!TTEST2(*tptr, lan_alen))
1548 goto trunctlv;
1549 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
1550 tmp -= lan_alen;
1551 tptr +=lan_alen;
1552 }
1553 break;
1554
1940 if (!TTEST2(*tptr, 1))
1941 goto trunctlv;
1942 lan_alen = *tptr++; /* LAN adress length */
1943 tmp --;
1944 printf("\n\t LAN address length %u bytes ",lan_alen);
1945 while (tmp >= lan_alen) {
1946 if (!TTEST2(*tptr, lan_alen))
1947 goto trunctlv;
1948 printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
1949 tmp -= lan_alen;
1950 tptr +=lan_alen;
1951 }
1952 break;
1953
1555 case TLV_PADDING:
1954 case ISIS_TLV_PADDING:
1556 break;
1557
1955 break;
1956
1558 case TLV_MT_IS_REACH:
1957 case ISIS_TLV_MT_IS_REACH:
1559 while (tmp >= 2+NODE_ID_LEN+3+1) {
1560 mt_len = isis_print_mtid(tptr, "\n\t ");
1561 if (mt_len == 0) /* did something go wrong ? */
1562 goto trunctlv;
1563 tptr+=mt_len;
1564 tmp-=mt_len;
1565
1566 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1567 if (ext_is_len == 0) /* did something go wrong ? */
1568 goto trunctlv;
1569
1570 tmp-=ext_is_len;
1571 tptr+=ext_is_len;
1572 }
1573 break;
1574
1958 while (tmp >= 2+NODE_ID_LEN+3+1) {
1959 mt_len = isis_print_mtid(tptr, "\n\t ");
1960 if (mt_len == 0) /* did something go wrong ? */
1961 goto trunctlv;
1962 tptr+=mt_len;
1963 tmp-=mt_len;
1964
1965 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1966 if (ext_is_len == 0) /* did something go wrong ? */
1967 goto trunctlv;
1968
1969 tmp-=ext_is_len;
1970 tptr+=ext_is_len;
1971 }
1972 break;
1973
1575 case TLV_IS_ALIAS_ID:
1974 case ISIS_TLV_IS_ALIAS_ID:
1576 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
1577 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1578 if (ext_is_len == 0) /* did something go wrong ? */
1579 goto trunctlv;
1580 tmp-=ext_is_len;
1581 tptr+=ext_is_len;
1582 }
1583 break;
1584
1975 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
1976 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1977 if (ext_is_len == 0) /* did something go wrong ? */
1978 goto trunctlv;
1979 tmp-=ext_is_len;
1980 tptr+=ext_is_len;
1981 }
1982 break;
1983
1585 case TLV_EXT_IS_REACH:
1984 case ISIS_TLV_EXT_IS_REACH:
1586 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
1587 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1588 if (ext_is_len == 0) /* did something go wrong ? */
1589 goto trunctlv;
1590 tmp-=ext_is_len;
1591 tptr+=ext_is_len;
1592 }
1593 break;
1985 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
1986 ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
1987 if (ext_is_len == 0) /* did something go wrong ? */
1988 goto trunctlv;
1989 tmp-=ext_is_len;
1990 tptr+=ext_is_len;
1991 }
1992 break;
1594 case TLV_IS_REACH:
1993 case ISIS_TLV_IS_REACH:
1595 if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
1596 goto trunctlv;
1597 printf("\n\t %s",
1598 tok2str(isis_is_reach_virtual_values,
1599 "bogus virtual flag 0x%02x",
1600 *tptr++));
1601 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
1602 while (tmp >= sizeof(struct isis_tlv_is_reach)) {
1603 if (!TTEST(*tlv_is_reach))
1604 goto trunctlv;
1605 printf("\n\t IS Neighbor: %s",
1606 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
1607 isis_print_metric_block(&tlv_is_reach->isis_metric_block);
1608 tmp -= sizeof(struct isis_tlv_is_reach);
1609 tlv_is_reach++;
1610 }
1611 break;
1612
1994 if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
1995 goto trunctlv;
1996 printf("\n\t %s",
1997 tok2str(isis_is_reach_virtual_values,
1998 "bogus virtual flag 0x%02x",
1999 *tptr++));
2000 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
2001 while (tmp >= sizeof(struct isis_tlv_is_reach)) {
2002 if (!TTEST(*tlv_is_reach))
2003 goto trunctlv;
2004 printf("\n\t IS Neighbor: %s",
2005 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
2006 isis_print_metric_block(&tlv_is_reach->isis_metric_block);
2007 tmp -= sizeof(struct isis_tlv_is_reach);
2008 tlv_is_reach++;
2009 }
2010 break;
2011
1613 case TLV_ESNEIGH:
2012 case ISIS_TLV_ESNEIGH:
1614 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
1615 while (tmp >= sizeof(struct isis_tlv_es_reach)) {
1616 if (!TTEST(*tlv_es_reach))
1617 goto trunctlv;
1618 printf("\n\t ES Neighbor: %s",
1619 isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
1620 isis_print_metric_block(&tlv_es_reach->isis_metric_block);
1621 tmp -= sizeof(struct isis_tlv_es_reach);
1622 tlv_es_reach++;
1623 }
1624 break;
1625
1626 /* those two TLVs share the same format */
2013 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
2014 while (tmp >= sizeof(struct isis_tlv_es_reach)) {
2015 if (!TTEST(*tlv_es_reach))
2016 goto trunctlv;
2017 printf("\n\t ES Neighbor: %s",
2018 isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
2019 isis_print_metric_block(&tlv_es_reach->isis_metric_block);
2020 tmp -= sizeof(struct isis_tlv_es_reach);
2021 tlv_es_reach++;
2022 }
2023 break;
2024
2025 /* those two TLVs share the same format */
1627 case TLV_INT_IP_REACH:
1628 case TLV_EXT_IP_REACH:
2026 case ISIS_TLV_INT_IP_REACH:
2027 case ISIS_TLV_EXT_IP_REACH:
1629 if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
1630 return (1);
1631 break;
1632
2028 if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
2029 return (1);
2030 break;
2031
1633 case TLV_EXTD_IP_REACH:
2032 case ISIS_TLV_EXTD_IP_REACH:
1634 while (tmp>0) {
1635 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
1636 if (ext_ip_len == 0) /* did something go wrong ? */
1637 goto trunctlv;
1638 tptr+=ext_ip_len;
1639 tmp-=ext_ip_len;
1640 }
1641 break;
1642
2033 while (tmp>0) {
2034 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
2035 if (ext_ip_len == 0) /* did something go wrong ? */
2036 goto trunctlv;
2037 tptr+=ext_ip_len;
2038 tmp-=ext_ip_len;
2039 }
2040 break;
2041
1643 case TLV_MT_IP_REACH:
2042 case ISIS_TLV_MT_IP_REACH:
1644 while (tmp>0) {
1645 mt_len = isis_print_mtid(tptr, "\n\t ");
1646 if (mt_len == 0) /* did something go wrong ? */
1647 goto trunctlv;
1648 tptr+=mt_len;
1649 tmp-=mt_len;
1650
1651 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
1652 if (ext_ip_len == 0) /* did something go wrong ? */
1653 goto trunctlv;
1654 tptr+=ext_ip_len;
1655 tmp-=ext_ip_len;
1656 }
1657 break;
1658
1659#ifdef INET6
2043 while (tmp>0) {
2044 mt_len = isis_print_mtid(tptr, "\n\t ");
2045 if (mt_len == 0) /* did something go wrong ? */
2046 goto trunctlv;
2047 tptr+=mt_len;
2048 tmp-=mt_len;
2049
2050 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
2051 if (ext_ip_len == 0) /* did something go wrong ? */
2052 goto trunctlv;
2053 tptr+=ext_ip_len;
2054 tmp-=ext_ip_len;
2055 }
2056 break;
2057
2058#ifdef INET6
1660 case TLV_IP6_REACH:
2059 case ISIS_TLV_IP6_REACH:
1661 while (tmp>0) {
1662 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
1663 if (ext_ip_len == 0) /* did something go wrong ? */
1664 goto trunctlv;
1665 tptr+=ext_ip_len;
1666 tmp-=ext_ip_len;
1667 }
1668 break;
1669
2060 while (tmp>0) {
2061 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
2062 if (ext_ip_len == 0) /* did something go wrong ? */
2063 goto trunctlv;
2064 tptr+=ext_ip_len;
2065 tmp-=ext_ip_len;
2066 }
2067 break;
2068
1670 case TLV_MT_IP6_REACH:
2069 case ISIS_TLV_MT_IP6_REACH:
1671 while (tmp>0) {
1672 mt_len = isis_print_mtid(tptr, "\n\t ");
1673 if (mt_len == 0) /* did something go wrong ? */
1674 goto trunctlv;
1675 tptr+=mt_len;
1676 tmp-=mt_len;
1677
1678 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
1679 if (ext_ip_len == 0) /* did something go wrong ? */
1680 goto trunctlv;
1681 tptr+=ext_ip_len;
1682 tmp-=ext_ip_len;
1683 }
1684 break;
1685
2070 while (tmp>0) {
2071 mt_len = isis_print_mtid(tptr, "\n\t ");
2072 if (mt_len == 0) /* did something go wrong ? */
2073 goto trunctlv;
2074 tptr+=mt_len;
2075 tmp-=mt_len;
2076
2077 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
2078 if (ext_ip_len == 0) /* did something go wrong ? */
2079 goto trunctlv;
2080 tptr+=ext_ip_len;
2081 tmp-=ext_ip_len;
2082 }
2083 break;
2084
1686 case TLV_IP6ADDR:
2085 case ISIS_TLV_IP6ADDR:
1687 while (tmp>0) {
1688 if (!TTEST2(*tptr, 16))
1689 goto trunctlv;
1690
1691 printf("\n\t IPv6 interface address: %s",
1692 ip6addr_string(tptr));
1693
1694 tptr += 16;
1695 tmp -= 16;
1696 }
1697 break;
1698#endif
2086 while (tmp>0) {
2087 if (!TTEST2(*tptr, 16))
2088 goto trunctlv;
2089
2090 printf("\n\t IPv6 interface address: %s",
2091 ip6addr_string(tptr));
2092
2093 tptr += 16;
2094 tmp -= 16;
2095 }
2096 break;
2097#endif
1699 case TLV_AUTH:
2098 case ISIS_TLV_AUTH:
1700 if (!TTEST2(*tptr, 1))
1701 goto trunctlv;
1702
1703 printf("\n\t %s: ",
1704 tok2str(isis_subtlv_auth_values,
1705 "unknown Authentication type 0x%02x",
1706 *tptr));
1707
1708 switch (*tptr) {
2099 if (!TTEST2(*tptr, 1))
2100 goto trunctlv;
2101
2102 printf("\n\t %s: ",
2103 tok2str(isis_subtlv_auth_values,
2104 "unknown Authentication type 0x%02x",
2105 *tptr));
2106
2107 switch (*tptr) {
1709 case SUBTLV_AUTH_SIMPLE:
2108 case ISIS_SUBTLV_AUTH_SIMPLE:
1710 for(i=1;i<tlv_len;i++) {
1711 if (!TTEST2(*(tptr+i), 1))
1712 goto trunctlv;
1713 printf("%c",*(tptr+i));
1714 }
1715 break;
2109 for(i=1;i<tlv_len;i++) {
2110 if (!TTEST2(*(tptr+i), 1))
2111 goto trunctlv;
2112 printf("%c",*(tptr+i));
2113 }
2114 break;
1716 case SUBTLV_AUTH_MD5:
2115 case ISIS_SUBTLV_AUTH_MD5:
1717 for(i=1;i<tlv_len;i++) {
1718 if (!TTEST2(*(tptr+i), 1))
1719 goto trunctlv;
1720 printf("%02x",*(tptr+i));
1721 }
2116 for(i=1;i<tlv_len;i++) {
2117 if (!TTEST2(*(tptr+i), 1))
2118 goto trunctlv;
2119 printf("%02x",*(tptr+i));
2120 }
1722 if (tlv_len != SUBTLV_AUTH_MD5_LEN+1)
2121 if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
1723 printf(", (malformed subTLV) ");
1724 break;
2122 printf(", (malformed subTLV) ");
2123 break;
1725 case SUBTLV_AUTH_PRIVATE:
2124 case ISIS_SUBTLV_AUTH_PRIVATE:
1726 default:
1727 if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
1728 return(0);
1729 break;
1730 }
1731 break;
1732
2125 default:
2126 if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
2127 return(0);
2128 break;
2129 }
2130 break;
2131
1733 case TLV_PTP_ADJ:
2132 case ISIS_TLV_PTP_ADJ:
1734 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
1735 if(tmp>=1) {
1736 if (!TTEST2(*tptr, 1))
1737 goto trunctlv;
1738 printf("\n\t Adjacency State: %s (%u)",
1739 tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
1740 *tptr);
1741 tmp--;

--- 17 unchanged lines hidden (view full) ---

1759 if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
1760 sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
1761 goto trunctlv;
1762 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
1763 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
1764 }
1765 break;
1766
2133 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
2134 if(tmp>=1) {
2135 if (!TTEST2(*tptr, 1))
2136 goto trunctlv;
2137 printf("\n\t Adjacency State: %s (%u)",
2138 tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
2139 *tptr);
2140 tmp--;

--- 17 unchanged lines hidden (view full) ---

2158 if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
2159 sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
2160 goto trunctlv;
2161 printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
2162 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
2163 }
2164 break;
2165
1767 case TLV_PROTOCOLS:
2166 case ISIS_TLV_PROTOCOLS:
1768 printf("\n\t NLPID(s): ");
1769 while (tmp>0) {
1770 if (!TTEST2(*(tptr), 1))
1771 goto trunctlv;
1772 printf("%s (0x%02x)",
2167 printf("\n\t NLPID(s): ");
2168 while (tmp>0) {
2169 if (!TTEST2(*(tptr), 1))
2170 goto trunctlv;
2171 printf("%s (0x%02x)",
1773 tok2str(osi_nlpid_values,
2172 tok2str(nlpid_values,
1774 "unknown",
1775 *tptr),
1776 *tptr);
1777 if (tmp>1) /* further NPLIDs ? - put comma */
1778 printf(", ");
1779 tptr++;
1780 tmp--;
1781 }
1782 break;
1783
2173 "unknown",
2174 *tptr),
2175 *tptr);
2176 if (tmp>1) /* further NPLIDs ? - put comma */
2177 printf(", ");
2178 tptr++;
2179 tmp--;
2180 }
2181 break;
2182
1784 case TLV_TE_ROUTER_ID:
2183 case ISIS_TLV_TE_ROUTER_ID:
1785 if (!TTEST2(*pptr, 4))
1786 goto trunctlv;
1787 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
1788 break;
1789
2184 if (!TTEST2(*pptr, 4))
2185 goto trunctlv;
2186 printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
2187 break;
2188
1790 case TLV_IPADDR:
2189 case ISIS_TLV_IPADDR:
1791 while (tmp>0) {
1792 if (!TTEST2(*tptr, 4))
1793 goto trunctlv;
1794 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
1795 tptr += 4;
1796 tmp -= 4;
1797 }
1798 break;
1799
2190 while (tmp>0) {
2191 if (!TTEST2(*tptr, 4))
2192 goto trunctlv;
2193 printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
2194 tptr += 4;
2195 tmp -= 4;
2196 }
2197 break;
2198
1800 case TLV_HOSTNAME:
2199 case ISIS_TLV_HOSTNAME:
1801 printf("\n\t Hostname: ");
1802 while (tmp>0) {
1803 if (!TTEST2(*tptr, 1))
1804 goto trunctlv;
1805 printf("%c",*tptr++);
1806 tmp--;
1807 }
1808 break;
1809
2200 printf("\n\t Hostname: ");
2201 while (tmp>0) {
2202 if (!TTEST2(*tptr, 1))
2203 goto trunctlv;
2204 printf("%c",*tptr++);
2205 tmp--;
2206 }
2207 break;
2208
1810 case TLV_SHARED_RISK_GROUP:
2209 case ISIS_TLV_SHARED_RISK_GROUP:
1811 if (!TTEST2(*tptr, NODE_ID_LEN))
1812 goto trunctlv;
1813 printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
1814 tptr+=(NODE_ID_LEN);
1815 tmp-=(NODE_ID_LEN);
1816
1817 if (!TTEST2(*tptr, 1))
1818 goto trunctlv;

--- 16 unchanged lines hidden (view full) ---

1835 if (!TTEST2(*tptr, 4))
1836 goto trunctlv;
1837 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
1838 tptr+=4;
1839 tmp-=4;
1840 }
1841 break;
1842
2210 if (!TTEST2(*tptr, NODE_ID_LEN))
2211 goto trunctlv;
2212 printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
2213 tptr+=(NODE_ID_LEN);
2214 tmp-=(NODE_ID_LEN);
2215
2216 if (!TTEST2(*tptr, 1))
2217 goto trunctlv;

--- 16 unchanged lines hidden (view full) ---

2234 if (!TTEST2(*tptr, 4))
2235 goto trunctlv;
2236 printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
2237 tptr+=4;
2238 tmp-=4;
2239 }
2240 break;
2241
1843 case TLV_LSP:
2242 case ISIS_TLV_LSP:
1844 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
1845 while(tmp>0) {
1846 if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
1847 goto trunctlv;
1848 printf("\n\t lsp-id: %s",
1849 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
1850 if (!TTEST2(tlv_lsp->sequence_number, 4))
1851 goto trunctlv;

--- 4 unchanged lines hidden (view full) ---

1856 if (!TTEST2(tlv_lsp->checksum, 2))
1857 goto trunctlv;
1858 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
1859 tmp-=sizeof(struct isis_tlv_lsp);
1860 tlv_lsp++;
1861 }
1862 break;
1863
2243 tlv_lsp = (const struct isis_tlv_lsp *)tptr;
2244 while(tmp>0) {
2245 if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
2246 goto trunctlv;
2247 printf("\n\t lsp-id: %s",
2248 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
2249 if (!TTEST2(tlv_lsp->sequence_number, 4))
2250 goto trunctlv;

--- 4 unchanged lines hidden (view full) ---

2255 if (!TTEST2(tlv_lsp->checksum, 2))
2256 goto trunctlv;
2257 printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
2258 tmp-=sizeof(struct isis_tlv_lsp);
2259 tlv_lsp++;
2260 }
2261 break;
2262
1864 case TLV_CHECKSUM:
2263 case ISIS_TLV_CHECKSUM:
1865 if (!TTEST2(*tptr, 2))
1866 goto trunctlv;
1867 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
1868 /* do not attempt to verify the checksum if it is zero
1869 * most likely a HMAC-MD5 TLV is also present and
1870 * to avoid conflicts the checksum TLV is zeroed.
1871 * see rfc3358 for details
1872 */
1873 if (EXTRACT_16BITS(tptr) == 0)
1874 printf("(unverified)");
1875 else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct");
1876 break;
1877
2264 if (!TTEST2(*tptr, 2))
2265 goto trunctlv;
2266 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
2267 /* do not attempt to verify the checksum if it is zero
2268 * most likely a HMAC-MD5 TLV is also present and
2269 * to avoid conflicts the checksum TLV is zeroed.
2270 * see rfc3358 for details
2271 */
2272 if (EXTRACT_16BITS(tptr) == 0)
2273 printf("(unverified)");
2274 else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct");
2275 break;
2276
1878 case TLV_MT_SUPPORTED:
2277 case ISIS_TLV_MT_SUPPORTED:
1879 while (tmp>1) {
1880 /* length can only be a multiple of 2, otherwise there is
1881 something broken -> so decode down until length is 1 */
1882 if (tmp!=1) {
1883 mt_len = isis_print_mtid(tptr, "\n\t ");
1884 if (mt_len == 0) /* did something go wrong ? */
1885 goto trunctlv;
1886 tptr+=mt_len;
1887 tmp-=mt_len;
1888 } else {
1889 printf("\n\t malformed MT-ID");
1890 break;
1891 }
1892 }
1893 break;
1894
2278 while (tmp>1) {
2279 /* length can only be a multiple of 2, otherwise there is
2280 something broken -> so decode down until length is 1 */
2281 if (tmp!=1) {
2282 mt_len = isis_print_mtid(tptr, "\n\t ");
2283 if (mt_len == 0) /* did something go wrong ? */
2284 goto trunctlv;
2285 tptr+=mt_len;
2286 tmp-=mt_len;
2287 } else {
2288 printf("\n\t malformed MT-ID");
2289 break;
2290 }
2291 }
2292 break;
2293
1895 case TLV_RESTART_SIGNALING:
2294 case ISIS_TLV_RESTART_SIGNALING:
1896 if (!TTEST2(*tptr, 3))
1897 goto trunctlv;
1898 printf("\n\t Flags [%s], Remaining holding time %us",
1899 bittok2str(isis_restart_flag_values, "none", *tptr),
1900 EXTRACT_16BITS(tptr+1));
1901 tptr+=3;
1902 break;
1903
2295 if (!TTEST2(*tptr, 3))
2296 goto trunctlv;
2297 printf("\n\t Flags [%s], Remaining holding time %us",
2298 bittok2str(isis_restart_flag_values, "none", *tptr),
2299 EXTRACT_16BITS(tptr+1));
2300 tptr+=3;
2301 break;
2302
1904 case TLV_IDRP_INFO:
2303 case ISIS_TLV_IDRP_INFO:
1905 if (!TTEST2(*tptr, 1))
1906 goto trunctlv;
1907 printf("\n\t Inter-Domain Information Type: %s",
1908 tok2str(isis_subtlv_idrp_values,
1909 "Unknown (0x%02x)",
1910 *tptr));
1911 switch (*tptr++) {
2304 if (!TTEST2(*tptr, 1))
2305 goto trunctlv;
2306 printf("\n\t Inter-Domain Information Type: %s",
2307 tok2str(isis_subtlv_idrp_values,
2308 "Unknown (0x%02x)",
2309 *tptr));
2310 switch (*tptr++) {
1912 case SUBTLV_IDRP_ASN:
2311 case ISIS_SUBTLV_IDRP_ASN:
1913 if (!TTEST2(*tptr, 2)) /* fetch AS number */
1914 goto trunctlv;
1915 printf("AS Number: %u",EXTRACT_16BITS(tptr));
1916 break;
2312 if (!TTEST2(*tptr, 2)) /* fetch AS number */
2313 goto trunctlv;
2314 printf("AS Number: %u",EXTRACT_16BITS(tptr));
2315 break;
1917 case SUBTLV_IDRP_LOCAL:
1918 case SUBTLV_IDRP_RES:
2316 case ISIS_SUBTLV_IDRP_LOCAL:
2317 case ISIS_SUBTLV_IDRP_RES:
1919 default:
1920 if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
1921 return(0);
1922 break;
1923 }
1924 break;
1925
2318 default:
2319 if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
2320 return(0);
2321 break;
2322 }
2323 break;
2324
1926 case TLV_LSP_BUFFERSIZE:
2325 case ISIS_TLV_LSP_BUFFERSIZE:
1927 if (!TTEST2(*tptr, 2))
1928 goto trunctlv;
1929 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
1930 break;
1931
2326 if (!TTEST2(*tptr, 2))
2327 goto trunctlv;
2328 printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
2329 break;
2330
1932 case TLV_PART_DIS:
2331 case ISIS_TLV_PART_DIS:
1933 while (tmp >= SYSTEM_ID_LEN) {
1934 if (!TTEST2(*tptr, SYSTEM_ID_LEN))
1935 goto trunctlv;
1936 printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
1937 tptr+=SYSTEM_ID_LEN;
1938 tmp-=SYSTEM_ID_LEN;
1939 }
1940 break;
1941
2332 while (tmp >= SYSTEM_ID_LEN) {
2333 if (!TTEST2(*tptr, SYSTEM_ID_LEN))
2334 goto trunctlv;
2335 printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
2336 tptr+=SYSTEM_ID_LEN;
2337 tmp-=SYSTEM_ID_LEN;
2338 }
2339 break;
2340
1942 case TLV_PREFIX_NEIGH:
2341 case ISIS_TLV_PREFIX_NEIGH:
1943 if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
1944 goto trunctlv;
1945 printf("\n\t Metric Block");
1946 isis_print_metric_block((const struct isis_metric_block *)tptr);
1947 tptr+=sizeof(struct isis_metric_block);
1948 tmp-=sizeof(struct isis_metric_block);
1949
1950 while(tmp>0) {
1951 if (!TTEST2(*tptr, 1))
1952 goto trunctlv;
1953 prefix_len=*tptr++; /* read out prefix length in semioctets*/
1954 tmp--;
1955 if (!TTEST2(*tptr, prefix_len/2))
1956 goto trunctlv;
1957 printf("\n\t\tAddress: %s/%u",
2342 if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
2343 goto trunctlv;
2344 printf("\n\t Metric Block");
2345 isis_print_metric_block((const struct isis_metric_block *)tptr);
2346 tptr+=sizeof(struct isis_metric_block);
2347 tmp-=sizeof(struct isis_metric_block);
2348
2349 while(tmp>0) {
2350 if (!TTEST2(*tptr, 1))
2351 goto trunctlv;
2352 prefix_len=*tptr++; /* read out prefix length in semioctets*/
2353 tmp--;
2354 if (!TTEST2(*tptr, prefix_len/2))
2355 goto trunctlv;
2356 printf("\n\t\tAddress: %s/%u",
1958 print_nsap(tptr,prefix_len/2),
2357 isonsap_string(tptr,prefix_len/2),
1959 prefix_len*4);
1960 tptr+=prefix_len/2;
1961 tmp-=prefix_len/2;
1962 }
1963 break;
1964
2358 prefix_len*4);
2359 tptr+=prefix_len/2;
2360 tmp-=prefix_len/2;
2361 }
2362 break;
2363
1965 case TLV_IIH_SEQNR:
2364 case ISIS_TLV_IIH_SEQNR:
1966 if (!TTEST2(*tptr, 4)) /* check if four bytes are on the wire */
1967 goto trunctlv;
1968 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
1969 break;
1970
2365 if (!TTEST2(*tptr, 4)) /* check if four bytes are on the wire */
2366 goto trunctlv;
2367 printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
2368 break;
2369
1971 case TLV_VENDOR_PRIVATE:
2370 case ISIS_TLV_VENDOR_PRIVATE:
1972 if (!TTEST2(*tptr, 3)) /* check if enough byte for a full oui */
1973 goto trunctlv;
2371 if (!TTEST2(*tptr, 3)) /* check if enough byte for a full oui */
2372 goto trunctlv;
1974 printf("\n\t Vendor OUI Code: 0x%06x", EXTRACT_24BITS(tptr) );
2373 vendor_id = EXTRACT_24BITS(tptr);
2374 printf("\n\t Vendor: %s (%u)",
2375 tok2str(oui_values,"Unknown",vendor_id),
2376 vendor_id);
1975 tptr+=3;
1976 tmp-=3;
1977 if (tmp > 0) /* hexdump the rest */
1978 if(!print_unknown_data(tptr,"\n\t\t",tmp))
1979 return(0);
1980 break;
1981 /*
1982 * FIXME those are the defined TLVs that lack a decoder
1983 * you are welcome to contribute code ;-)
1984 */
1985
2377 tptr+=3;
2378 tmp-=3;
2379 if (tmp > 0) /* hexdump the rest */
2380 if(!print_unknown_data(tptr,"\n\t\t",tmp))
2381 return(0);
2382 break;
2383 /*
2384 * FIXME those are the defined TLVs that lack a decoder
2385 * you are welcome to contribute code ;-)
2386 */
2387
1986 case TLV_DECNET_PHASE4:
1987 case TLV_LUCENT_PRIVATE:
1988 case TLV_IPAUTH:
1989 case TLV_NORTEL_PRIVATE1:
1990 case TLV_NORTEL_PRIVATE2:
2388 case ISIS_TLV_DECNET_PHASE4:
2389 case ISIS_TLV_LUCENT_PRIVATE:
2390 case ISIS_TLV_IPAUTH:
2391 case ISIS_TLV_NORTEL_PRIVATE1:
2392 case ISIS_TLV_NORTEL_PRIVATE2:
1991
1992 default:
1993 if (vflag <= 1) {
1994 if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
1995 return(0);
1996 }
1997 break;
1998 }

--- 33 unchanged lines hidden (view full) ---

2032 while ((int)--len >= 0) {
2033 c0 += *tptr++;
2034 c0 %= 255;
2035 c1 += c0;
2036 c1 %= 255;
2037 }
2038 return (c0 | c1);
2039}
2393
2394 default:
2395 if (vflag <= 1) {
2396 if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
2397 return(0);
2398 }
2399 break;
2400 }

--- 33 unchanged lines hidden (view full) ---

2434 while ((int)--len >= 0) {
2435 c0 += *tptr++;
2436 c0 %= 255;
2437 c1 += c0;
2438 c1 %= 255;
2439 }
2440 return (c0 | c1);
2441}
2442
2443
2444/*
2445 * Local Variables:
2446 * c-style: whitesmith
2447 * c-basic-offset: 8
2448 * End:
2449 */