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 9 * this paragraph in its entirety in the documentation or other materials 10 * provided with the distribution, and (3) all advertising materials mentioning 11 * features or use of this software display the following acknowledgement: 12 * ``This product includes software developed by the University of California, 13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 * the University nor the names of its contributors may be used to endorse 15 * or promote products derived from this software without specific prior 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 & CLNP support. 25 * 26 * $FreeBSD$ 27 */ 28 29 #define NETDISSECT_REWORKED 30 #ifdef HAVE_CONFIG_H 31 #include "config.h" 32 #endif 33 34 #include <tcpdump-stdinc.h> 35 36 #include <string.h> 37 38 #include "interface.h" 39 #include "addrtoname.h" 40 #include "ether.h" 41 #include "nlpid.h" 42 #include "extract.h" 43 #include "gmpls.h" 44 #include "oui.h" 45 #include "signature.h" 46 47 /* 48 * IS-IS is defined in ISO 10589. Look there for protocol definitions. 49 */ 50 51 #define SYSTEM_ID_LEN ETHER_ADDR_LEN 52 #define NODE_ID_LEN SYSTEM_ID_LEN+1 53 #define LSP_ID_LEN SYSTEM_ID_LEN+2 54 55 #define ISIS_VERSION 1 56 #define ESIS_VERSION 1 57 #define CLNP_VERSION 1 58 59 #define ISIS_PDU_TYPE_MASK 0x1F 60 #define ESIS_PDU_TYPE_MASK 0x1F 61 #define CLNP_PDU_TYPE_MASK 0x1F 62 #define CLNP_FLAG_MASK 0xE0 63 #define ISIS_LAN_PRIORITY_MASK 0x7F 64 65 #define ISIS_PDU_L1_LAN_IIH 15 66 #define ISIS_PDU_L2_LAN_IIH 16 67 #define ISIS_PDU_PTP_IIH 17 68 #define ISIS_PDU_L1_LSP 18 69 #define ISIS_PDU_L2_LSP 20 70 #define ISIS_PDU_L1_CSNP 24 71 #define ISIS_PDU_L2_CSNP 25 72 #define ISIS_PDU_L1_PSNP 26 73 #define ISIS_PDU_L2_PSNP 27 74 75 static const struct tok isis_pdu_values[] = { 76 { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"}, 77 { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"}, 78 { ISIS_PDU_PTP_IIH, "p2p IIH"}, 79 { ISIS_PDU_L1_LSP, "L1 LSP"}, 80 { ISIS_PDU_L2_LSP, "L2 LSP"}, 81 { ISIS_PDU_L1_CSNP, "L1 CSNP"}, 82 { ISIS_PDU_L2_CSNP, "L2 CSNP"}, 83 { ISIS_PDU_L1_PSNP, "L1 PSNP"}, 84 { ISIS_PDU_L2_PSNP, "L2 PSNP"}, 85 { 0, NULL} 86 }; 87 88 /* 89 * A TLV is a tuple of a type, length and a value and is normally used for 90 * encoding information in all sorts of places. This is an enumeration of 91 * the well known types. 92 * 93 * list taken from rfc3359 plus some memory from veterans ;-) 94 */ 95 96 #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */ 97 #define ISIS_TLV_IS_REACH 2 /* iso10589 */ 98 #define ISIS_TLV_ESNEIGH 3 /* iso10589 */ 99 #define ISIS_TLV_PART_DIS 4 /* iso10589 */ 100 #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */ 101 #define ISIS_TLV_ISNEIGH 6 /* iso10589 */ 102 #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */ 103 #define ISIS_TLV_PADDING 8 /* iso10589 */ 104 #define ISIS_TLV_LSP 9 /* iso10589 */ 105 #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */ 106 #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */ 107 #define ISIS_TLV_CHECKSUM_MINLEN 2 108 #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */ 109 #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2 110 #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */ 111 #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */ 112 #define ISIS_TLV_DECNET_PHASE4 42 113 #define ISIS_TLV_LUCENT_PRIVATE 66 114 #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */ 115 #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */ 116 #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */ 117 #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */ 118 #define ISIS_TLV_IDRP_INFO_MINLEN 1 119 #define ISIS_TLV_IPADDR 132 /* rfc1195 */ 120 #define ISIS_TLV_IPAUTH 133 /* rfc1195 */ 121 #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */ 122 #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */ 123 #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */ 124 #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */ 125 #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */ 126 #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */ 127 #define ISIS_TLV_NORTEL_PRIVATE1 176 128 #define ISIS_TLV_NORTEL_PRIVATE2 177 129 #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */ 130 #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1 131 #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2 132 #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */ 133 #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */ 134 #define ISIS_TLV_MT_SUPPORTED_MINLEN 2 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_IIH_SEQNR_MINLEN 4 142 #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */ 143 #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3 144 145 static const struct tok isis_tlv_values[] = { 146 { ISIS_TLV_AREA_ADDR, "Area address(es)"}, 147 { ISIS_TLV_IS_REACH, "IS Reachability"}, 148 { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"}, 149 { ISIS_TLV_PART_DIS, "Partition DIS"}, 150 { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"}, 151 { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"}, 152 { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"}, 153 { ISIS_TLV_PADDING, "Padding"}, 154 { ISIS_TLV_LSP, "LSP entries"}, 155 { ISIS_TLV_AUTH, "Authentication"}, 156 { ISIS_TLV_CHECKSUM, "Checksum"}, 157 { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"}, 158 { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"}, 159 { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"}, 160 { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"}, 161 { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"}, 162 { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"}, 163 { ISIS_TLV_PROTOCOLS, "Protocols supported"}, 164 { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"}, 165 { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"}, 166 { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"}, 167 { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"}, 168 { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"}, 169 { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"}, 170 { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"}, 171 { ISIS_TLV_MT_PORT_CAP, "Multi-Topology-Aware Port Capability"}, 172 { ISIS_TLV_MT_CAPABILITY, "Multi-Topology Capability"}, 173 { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"}, 174 { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"}, 175 { ISIS_TLV_HOSTNAME, "Hostname"}, 176 { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"}, 177 { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"}, 178 { ISIS_TLV_MT_SUPPORTED, "Multi Topology"}, 179 { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"}, 180 { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"}, 181 { ISIS_TLV_IP6_REACH, "IPv6 reachability"}, 182 { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"}, 183 { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"}, 184 { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"}, 185 { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"}, 186 { 0, NULL } 187 }; 188 189 #define ESIS_OPTION_PROTOCOLS 129 190 #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */ 191 #define ESIS_OPTION_SECURITY 197 /* iso9542 */ 192 #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */ 193 #define ESIS_OPTION_PRIORITY 205 /* iso9542 */ 194 #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */ 195 #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */ 196 197 static const struct tok esis_option_values[] = { 198 { ESIS_OPTION_PROTOCOLS, "Protocols supported"}, 199 { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" }, 200 { ESIS_OPTION_SECURITY, "Security" }, 201 { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" }, 202 { ESIS_OPTION_PRIORITY, "Priority" }, 203 { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" }, 204 { ESIS_OPTION_SNPA_MASK, "SNPA Mask" }, 205 { 0, NULL } 206 }; 207 208 #define CLNP_OPTION_DISCARD_REASON 193 209 #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */ 210 #define CLNP_OPTION_SECURITY 197 /* iso8473 */ 211 #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */ 212 #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */ 213 #define CLNP_OPTION_PADDING 204 /* iso8473 */ 214 #define CLNP_OPTION_PRIORITY 205 /* iso8473 */ 215 216 static const struct tok clnp_option_values[] = { 217 { CLNP_OPTION_DISCARD_REASON, "Discard Reason"}, 218 { CLNP_OPTION_PRIORITY, "Priority"}, 219 { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"}, 220 { CLNP_OPTION_SECURITY, "Security"}, 221 { CLNP_OPTION_SOURCE_ROUTING, "Source Routing"}, 222 { CLNP_OPTION_ROUTE_RECORDING, "Route Recording"}, 223 { CLNP_OPTION_PADDING, "Padding"}, 224 { 0, NULL } 225 }; 226 227 static const struct tok clnp_option_rfd_class_values[] = { 228 { 0x0, "General"}, 229 { 0x8, "Address"}, 230 { 0x9, "Source Routeing"}, 231 { 0xa, "Lifetime"}, 232 { 0xb, "PDU Discarded"}, 233 { 0xc, "Reassembly"}, 234 { 0, NULL } 235 }; 236 237 static const struct tok clnp_option_rfd_general_values[] = { 238 { 0x0, "Reason not specified"}, 239 { 0x1, "Protocol procedure error"}, 240 { 0x2, "Incorrect checksum"}, 241 { 0x3, "PDU discarded due to congestion"}, 242 { 0x4, "Header syntax error (cannot be parsed)"}, 243 { 0x5, "Segmentation needed but not permitted"}, 244 { 0x6, "Incomplete PDU received"}, 245 { 0x7, "Duplicate option"}, 246 { 0, NULL } 247 }; 248 249 static const struct tok clnp_option_rfd_address_values[] = { 250 { 0x0, "Destination address unreachable"}, 251 { 0x1, "Destination address unknown"}, 252 { 0, NULL } 253 }; 254 255 static const struct tok clnp_option_rfd_source_routeing_values[] = { 256 { 0x0, "Unspecified source routeing error"}, 257 { 0x1, "Syntax error in source routeing field"}, 258 { 0x2, "Unknown address in source routeing field"}, 259 { 0x3, "Path not acceptable"}, 260 { 0, NULL } 261 }; 262 263 static const struct tok clnp_option_rfd_lifetime_values[] = { 264 { 0x0, "Lifetime expired while data unit in transit"}, 265 { 0x1, "Lifetime expired during reassembly"}, 266 { 0, NULL } 267 }; 268 269 static const struct tok clnp_option_rfd_pdu_discard_values[] = { 270 { 0x0, "Unsupported option not specified"}, 271 { 0x1, "Unsupported protocol version"}, 272 { 0x2, "Unsupported security option"}, 273 { 0x3, "Unsupported source routeing option"}, 274 { 0x4, "Unsupported recording of route option"}, 275 { 0, NULL } 276 }; 277 278 static const struct tok clnp_option_rfd_reassembly_values[] = { 279 { 0x0, "Reassembly interference"}, 280 { 0, NULL } 281 }; 282 283 /* array of 16 error-classes */ 284 static const struct tok *clnp_option_rfd_error_class[] = { 285 clnp_option_rfd_general_values, 286 NULL, 287 NULL, 288 NULL, 289 NULL, 290 NULL, 291 NULL, 292 NULL, 293 clnp_option_rfd_address_values, 294 clnp_option_rfd_source_routeing_values, 295 clnp_option_rfd_lifetime_values, 296 clnp_option_rfd_pdu_discard_values, 297 clnp_option_rfd_reassembly_values, 298 NULL, 299 NULL, 300 NULL 301 }; 302 303 #define CLNP_OPTION_OPTION_QOS_MASK 0x3f 304 #define CLNP_OPTION_SCOPE_MASK 0xc0 305 #define CLNP_OPTION_SCOPE_SA_SPEC 0x40 306 #define CLNP_OPTION_SCOPE_DA_SPEC 0x80 307 #define CLNP_OPTION_SCOPE_GLOBAL 0xc0 308 309 static const struct tok clnp_option_scope_values[] = { 310 { CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"}, 311 { CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"}, 312 { CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"}, 313 { 0, NULL } 314 }; 315 316 static const struct tok clnp_option_sr_rr_values[] = { 317 { 0x0, "partial"}, 318 { 0x1, "complete"}, 319 { 0, NULL } 320 }; 321 322 static const struct tok clnp_option_sr_rr_string_values[] = { 323 { CLNP_OPTION_SOURCE_ROUTING, "source routing"}, 324 { CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"}, 325 { 0, NULL } 326 }; 327 328 static const struct tok clnp_option_qos_global_values[] = { 329 { 0x20, "reserved"}, 330 { 0x10, "sequencing vs. delay"}, 331 { 0x08, "congested"}, 332 { 0x04, "delay vs. cost"}, 333 { 0x02, "error vs. delay"}, 334 { 0x01, "error vs. cost"}, 335 { 0, NULL } 336 }; 337 338 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */ 339 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */ 340 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */ 341 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */ 342 #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */ 343 #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */ 344 #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */ 345 #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */ 346 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */ 347 #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */ 348 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */ 349 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */ 350 #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */ 351 #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */ 352 353 #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */ 354 355 static const struct tok isis_ext_is_reach_subtlv_values[] = { 356 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" }, 357 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, 358 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" }, 359 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" }, 360 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" }, 361 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" }, 362 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" }, 363 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" }, 364 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" }, 365 { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE, "Link Attribute" }, 366 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" }, 367 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" }, 368 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" }, 369 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" }, 370 { ISIS_SUBTLV_SPB_METRIC, "SPB Metric" }, 371 { 250, "Reserved for cisco specific extensions" }, 372 { 251, "Reserved for cisco specific extensions" }, 373 { 252, "Reserved for cisco specific extensions" }, 374 { 253, "Reserved for cisco specific extensions" }, 375 { 254, "Reserved for cisco specific extensions" }, 376 { 255, "Reserved for future expansion" }, 377 { 0, NULL } 378 }; 379 380 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */ 381 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */ 382 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */ 383 384 static const struct tok isis_ext_ip_reach_subtlv_values[] = { 385 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" }, 386 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" }, 387 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" }, 388 { 0, NULL } 389 }; 390 391 static const struct tok isis_subtlv_link_attribute_values[] = { 392 { 0x01, "Local Protection Available" }, 393 { 0x02, "Link excluded from local protection path" }, 394 { 0x04, "Local maintenance required"}, 395 { 0, NULL } 396 }; 397 398 #define ISIS_SUBTLV_AUTH_SIMPLE 1 399 #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */ 400 #define ISIS_SUBTLV_AUTH_MD5 54 401 #define ISIS_SUBTLV_AUTH_MD5_LEN 16 402 #define ISIS_SUBTLV_AUTH_PRIVATE 255 403 404 static const struct tok isis_subtlv_auth_values[] = { 405 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"}, 406 { ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"}, 407 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"}, 408 { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"}, 409 { 0, NULL } 410 }; 411 412 #define ISIS_SUBTLV_IDRP_RES 0 413 #define ISIS_SUBTLV_IDRP_LOCAL 1 414 #define ISIS_SUBTLV_IDRP_ASN 2 415 416 static const struct tok isis_subtlv_idrp_values[] = { 417 { ISIS_SUBTLV_IDRP_RES, "Reserved"}, 418 { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"}, 419 { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"}, 420 { 0, NULL} 421 }; 422 423 #define ISIS_SUBTLV_SPB_MCID 4 424 #define ISIS_SUBTLV_SPB_DIGEST 5 425 #define ISIS_SUBTLV_SPB_BVID 6 426 427 #define ISIS_SUBTLV_SPB_INSTANCE 1 428 #define ISIS_SUBTLV_SPBM_SI 3 429 430 #define ISIS_SPB_MCID_LEN 51 431 #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102 432 #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33 433 #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6 434 #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19 435 #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8 436 437 static const struct tok isis_mt_port_cap_subtlv_values[] = { 438 { ISIS_SUBTLV_SPB_MCID, "SPB MCID" }, 439 { ISIS_SUBTLV_SPB_DIGEST, "SPB Digest" }, 440 { ISIS_SUBTLV_SPB_BVID, "SPB BVID" }, 441 { 0, NULL } 442 }; 443 444 static const struct tok isis_mt_capability_subtlv_values[] = { 445 { ISIS_SUBTLV_SPB_INSTANCE, "SPB Instance" }, 446 { ISIS_SUBTLV_SPBM_SI, "SPBM Service Identifier and Unicast Address" }, 447 { 0, NULL } 448 }; 449 450 struct isis_spb_mcid { 451 uint8_t format_id; 452 uint8_t name[32]; 453 uint8_t revision_lvl[2]; 454 uint8_t digest[16]; 455 }; 456 457 struct isis_subtlv_spb_mcid { 458 struct isis_spb_mcid mcid; 459 struct isis_spb_mcid aux_mcid; 460 }; 461 462 struct isis_subtlv_spb_instance { 463 uint8_t cist_root_id[8]; 464 uint8_t cist_external_root_path_cost[4]; 465 uint8_t bridge_priority[2]; 466 uint8_t spsourceid[4]; 467 uint8_t no_of_trees; 468 }; 469 470 #define CLNP_SEGMENT_PART 0x80 471 #define CLNP_MORE_SEGMENTS 0x40 472 #define CLNP_REQUEST_ER 0x20 473 474 static const struct tok clnp_flag_values[] = { 475 { CLNP_SEGMENT_PART, "Segmentation permitted"}, 476 { CLNP_MORE_SEGMENTS, "more Segments"}, 477 { CLNP_REQUEST_ER, "request Error Report"}, 478 { 0, NULL} 479 }; 480 481 #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4) 482 #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3) 483 #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80) 484 #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78) 485 #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40) 486 #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20) 487 #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10) 488 #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8) 489 490 #define ISIS_MASK_MTID(x) ((x)&0x0fff) 491 #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000) 492 493 static const struct tok isis_mt_flag_values[] = { 494 { 0x4000, "ATT bit set"}, 495 { 0x8000, "Overload bit set"}, 496 { 0, NULL} 497 }; 498 499 #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80) 500 #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40) 501 502 #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40) 503 #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20) 504 505 #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80) 506 #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40) 507 #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80) 508 #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f) 509 510 #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1) 511 512 static const struct tok isis_mt_values[] = { 513 { 0, "IPv4 unicast"}, 514 { 1, "In-Band Management"}, 515 { 2, "IPv6 unicast"}, 516 { 3, "Multicast"}, 517 { 4095, "Development, Experimental or Proprietary"}, 518 { 0, NULL } 519 }; 520 521 static const struct tok isis_iih_circuit_type_values[] = { 522 { 1, "Level 1 only"}, 523 { 2, "Level 2 only"}, 524 { 3, "Level 1, Level 2"}, 525 { 0, NULL} 526 }; 527 528 #define ISIS_LSP_TYPE_UNUSED0 0 529 #define ISIS_LSP_TYPE_LEVEL_1 1 530 #define ISIS_LSP_TYPE_UNUSED2 2 531 #define ISIS_LSP_TYPE_LEVEL_2 3 532 533 static const struct tok isis_lsp_istype_values[] = { 534 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"}, 535 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"}, 536 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"}, 537 { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"}, 538 { 0, NULL } 539 }; 540 541 /* 542 * Katz's point to point adjacency TLV uses codes to tell us the state of 543 * the remote adjacency. Enumerate them. 544 */ 545 546 #define ISIS_PTP_ADJ_UP 0 547 #define ISIS_PTP_ADJ_INIT 1 548 #define ISIS_PTP_ADJ_DOWN 2 549 550 static const struct tok isis_ptp_adjancey_values[] = { 551 { ISIS_PTP_ADJ_UP, "Up" }, 552 { ISIS_PTP_ADJ_INIT, "Initializing" }, 553 { ISIS_PTP_ADJ_DOWN, "Down" }, 554 { 0, NULL} 555 }; 556 557 struct isis_tlv_ptp_adj { 558 uint8_t adjacency_state; 559 uint8_t extd_local_circuit_id[4]; 560 uint8_t neighbor_sysid[SYSTEM_ID_LEN]; 561 uint8_t neighbor_extd_local_circuit_id[4]; 562 }; 563 564 static void osi_print_cksum(netdissect_options *, const uint8_t *pptr, uint16_t checksum, 565 u_int checksum_offset, u_int length); 566 static int clnp_print(netdissect_options *, const uint8_t *, u_int); 567 static void esis_print(netdissect_options *, const uint8_t *, u_int); 568 static int isis_print(netdissect_options *, const uint8_t *, u_int); 569 570 struct isis_metric_block { 571 uint8_t metric_default; 572 uint8_t metric_delay; 573 uint8_t metric_expense; 574 uint8_t metric_error; 575 }; 576 577 struct isis_tlv_is_reach { 578 struct isis_metric_block isis_metric_block; 579 uint8_t neighbor_nodeid[NODE_ID_LEN]; 580 }; 581 582 struct isis_tlv_es_reach { 583 struct isis_metric_block isis_metric_block; 584 uint8_t neighbor_sysid[SYSTEM_ID_LEN]; 585 }; 586 587 struct isis_tlv_ip_reach { 588 struct isis_metric_block isis_metric_block; 589 uint8_t prefix[4]; 590 uint8_t mask[4]; 591 }; 592 593 static const struct tok isis_is_reach_virtual_values[] = { 594 { 0, "IsNotVirtual"}, 595 { 1, "IsVirtual"}, 596 { 0, NULL } 597 }; 598 599 static const struct tok isis_restart_flag_values[] = { 600 { 0x1, "Restart Request"}, 601 { 0x2, "Restart Acknowledgement"}, 602 { 0x4, "Suppress adjacency advertisement"}, 603 { 0, NULL } 604 }; 605 606 struct isis_common_header { 607 uint8_t nlpid; 608 uint8_t fixed_len; 609 uint8_t version; /* Protocol version */ 610 uint8_t id_length; 611 uint8_t pdu_type; /* 3 MSbits are reserved */ 612 uint8_t pdu_version; /* Packet format version */ 613 uint8_t reserved; 614 uint8_t max_area; 615 }; 616 617 struct isis_iih_lan_header { 618 uint8_t circuit_type; 619 uint8_t source_id[SYSTEM_ID_LEN]; 620 uint8_t holding_time[2]; 621 uint8_t pdu_len[2]; 622 uint8_t priority; 623 uint8_t lan_id[NODE_ID_LEN]; 624 }; 625 626 struct isis_iih_ptp_header { 627 uint8_t circuit_type; 628 uint8_t source_id[SYSTEM_ID_LEN]; 629 uint8_t holding_time[2]; 630 uint8_t pdu_len[2]; 631 uint8_t circuit_id; 632 }; 633 634 struct isis_lsp_header { 635 uint8_t pdu_len[2]; 636 uint8_t remaining_lifetime[2]; 637 uint8_t lsp_id[LSP_ID_LEN]; 638 uint8_t sequence_number[4]; 639 uint8_t checksum[2]; 640 uint8_t typeblock; 641 }; 642 643 struct isis_csnp_header { 644 uint8_t pdu_len[2]; 645 uint8_t source_id[NODE_ID_LEN]; 646 uint8_t start_lsp_id[LSP_ID_LEN]; 647 uint8_t end_lsp_id[LSP_ID_LEN]; 648 }; 649 650 struct isis_psnp_header { 651 uint8_t pdu_len[2]; 652 uint8_t source_id[NODE_ID_LEN]; 653 }; 654 655 struct isis_tlv_lsp { 656 uint8_t remaining_lifetime[2]; 657 uint8_t lsp_id[LSP_ID_LEN]; 658 uint8_t sequence_number[4]; 659 uint8_t checksum[2]; 660 }; 661 662 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header)) 663 #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header)) 664 #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header)) 665 #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header)) 666 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header)) 667 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header)) 668 669 void isoclns_print(netdissect_options *ndo, 670 const uint8_t *p, u_int length, u_int caplen) 671 { 672 if (caplen <= 1) { /* enough bytes on the wire ? */ 673 ND_PRINT((ndo, "|OSI")); 674 return; 675 } 676 677 if (ndo->ndo_eflag) 678 ND_PRINT((ndo, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", *p), *p)); 679 680 switch (*p) { 681 682 case NLPID_CLNP: 683 if (!clnp_print(ndo, p, length)) 684 print_unknown_data(ndo, p, "\n\t", caplen); 685 break; 686 687 case NLPID_ESIS: 688 esis_print(ndo, p, length); 689 return; 690 691 case NLPID_ISIS: 692 if (!isis_print(ndo, p, length)) 693 print_unknown_data(ndo, p, "\n\t", caplen); 694 break; 695 696 case NLPID_NULLNS: 697 ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length)); 698 break; 699 700 case NLPID_Q933: 701 q933_print(ndo, p + 1, length - 1); 702 break; 703 704 case NLPID_IP: 705 ip_print(ndo, p + 1, length - 1); 706 break; 707 708 #ifdef INET6 709 case NLPID_IP6: 710 ip6_print(ndo, p + 1, length - 1); 711 break; 712 #endif 713 714 case NLPID_PPP: 715 ppp_print(ndo, p + 1, length - 1); 716 break; 717 718 default: 719 if (!ndo->ndo_eflag) 720 ND_PRINT((ndo, "OSI NLPID 0x%02x unknown", *p)); 721 ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length)); 722 if (caplen > 1) 723 print_unknown_data(ndo, p, "\n\t", caplen); 724 break; 725 } 726 } 727 728 #define CLNP_PDU_ER 1 729 #define CLNP_PDU_DT 28 730 #define CLNP_PDU_MD 29 731 #define CLNP_PDU_ERQ 30 732 #define CLNP_PDU_ERP 31 733 734 static const struct tok clnp_pdu_values[] = { 735 { CLNP_PDU_ER, "Error Report"}, 736 { CLNP_PDU_MD, "MD"}, 737 { CLNP_PDU_DT, "Data"}, 738 { CLNP_PDU_ERQ, "Echo Request"}, 739 { CLNP_PDU_ERP, "Echo Response"}, 740 { 0, NULL } 741 }; 742 743 struct clnp_header_t { 744 uint8_t nlpid; 745 uint8_t length_indicator; 746 uint8_t version; 747 uint8_t lifetime; /* units of 500ms */ 748 uint8_t type; 749 uint8_t segment_length[2]; 750 uint8_t cksum[2]; 751 }; 752 753 struct clnp_segment_header_t { 754 uint8_t data_unit_id[2]; 755 uint8_t segment_offset[2]; 756 uint8_t total_length[2]; 757 }; 758 759 /* 760 * clnp_print 761 * Decode CLNP packets. Return 0 on error. 762 */ 763 764 static int 765 clnp_print(netdissect_options *ndo, 766 const uint8_t *pptr, u_int length) 767 { 768 const uint8_t *optr,*source_address,*dest_address; 769 u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags; 770 const struct clnp_header_t *clnp_header; 771 const struct clnp_segment_header_t *clnp_segment_header; 772 uint8_t rfd_error_major,rfd_error_minor; 773 774 clnp_header = (const struct clnp_header_t *) pptr; 775 ND_TCHECK(*clnp_header); 776 777 li = clnp_header->length_indicator; 778 optr = pptr; 779 780 if (!ndo->ndo_eflag) 781 ND_PRINT((ndo, "CLNP")); 782 783 /* 784 * Sanity checking of the header. 785 */ 786 787 if (clnp_header->version != CLNP_VERSION) { 788 ND_PRINT((ndo, "version %d packet not supported", clnp_header->version)); 789 return (0); 790 } 791 792 /* FIXME further header sanity checking */ 793 794 clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK; 795 clnp_flags = clnp_header->type & CLNP_FLAG_MASK; 796 797 pptr += sizeof(struct clnp_header_t); 798 li -= sizeof(struct clnp_header_t); 799 dest_address_length = *pptr; 800 dest_address = pptr + 1; 801 802 pptr += (1 + dest_address_length); 803 li -= (1 + dest_address_length); 804 source_address_length = *pptr; 805 source_address = pptr +1; 806 807 pptr += (1 + source_address_length); 808 li -= (1 + source_address_length); 809 810 if (ndo->ndo_vflag < 1) { 811 ND_PRINT((ndo, "%s%s > %s, %s, length %u", 812 ndo->ndo_eflag ? "" : ", ", 813 isonsap_string(source_address, source_address_length), 814 isonsap_string(dest_address, dest_address_length), 815 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type), 816 length)); 817 return (1); 818 } 819 ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length)); 820 821 ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x", 822 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type), 823 clnp_header->length_indicator, 824 clnp_header->version, 825 clnp_header->lifetime/2, 826 (clnp_header->lifetime%2)*5, 827 EXTRACT_16BITS(clnp_header->segment_length), 828 EXTRACT_16BITS(clnp_header->cksum))); 829 830 osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7, 831 clnp_header->length_indicator); 832 833 ND_PRINT((ndo, "\n\tFlags [%s]", 834 bittok2str(clnp_flag_values, "none", clnp_flags))); 835 836 ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s", 837 source_address_length, 838 isonsap_string(source_address, source_address_length), 839 dest_address_length, 840 isonsap_string(dest_address, dest_address_length))); 841 842 if (clnp_flags & CLNP_SEGMENT_PART) { 843 clnp_segment_header = (const struct clnp_segment_header_t *) pptr; 844 ND_TCHECK(*clnp_segment_header); 845 ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u", 846 EXTRACT_16BITS(clnp_segment_header->data_unit_id), 847 EXTRACT_16BITS(clnp_segment_header->segment_offset), 848 EXTRACT_16BITS(clnp_segment_header->total_length))); 849 pptr+=sizeof(const struct clnp_segment_header_t); 850 li-=sizeof(const struct clnp_segment_header_t); 851 } 852 853 /* now walk the options */ 854 while (li >= 2) { 855 u_int op, opli; 856 const uint8_t *tptr; 857 858 ND_TCHECK2(*pptr, 2); 859 if (li < 2) { 860 ND_PRINT((ndo, ", bad opts/li")); 861 return (0); 862 } 863 op = *pptr++; 864 opli = *pptr++; 865 li -= 2; 866 ND_TCHECK2(*pptr, opli); 867 if (opli > li) { 868 ND_PRINT((ndo, ", opt (%d) too long", op)); 869 return (0); 870 } 871 li -= opli; 872 tptr = pptr; 873 tlen = opli; 874 875 ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ", 876 tok2str(clnp_option_values,"Unknown",op), 877 op, 878 opli)); 879 880 switch (op) { 881 882 883 case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */ 884 case CLNP_OPTION_SOURCE_ROUTING: 885 ND_PRINT((ndo, "%s %s", 886 tok2str(clnp_option_sr_rr_values,"Unknown",*tptr), 887 tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op))); 888 nsap_offset=*(tptr+1); 889 if (nsap_offset == 0) { 890 ND_PRINT((ndo, " Bad NSAP offset (0)")); 891 break; 892 } 893 nsap_offset-=1; /* offset to nsap list */ 894 if (nsap_offset > tlen) { 895 ND_PRINT((ndo, " Bad NSAP offset (past end of option)")); 896 break; 897 } 898 tptr+=nsap_offset; 899 tlen-=nsap_offset; 900 while (tlen > 0) { 901 source_address_length=*tptr; 902 if (tlen < source_address_length+1) { 903 ND_PRINT((ndo, "\n\t NSAP address goes past end of option")); 904 break; 905 } 906 if (source_address_length > 0) { 907 source_address=(tptr+1); 908 ND_TCHECK2(*source_address, source_address_length); 909 ND_PRINT((ndo, "\n\t NSAP address (length %u): %s", 910 source_address_length, 911 isonsap_string(source_address, source_address_length))); 912 } 913 tlen-=source_address_length+1; 914 } 915 break; 916 917 case CLNP_OPTION_PRIORITY: 918 ND_PRINT((ndo, "0x%1x", *tptr&0x0f)); 919 break; 920 921 case CLNP_OPTION_QOS_MAINTENANCE: 922 ND_PRINT((ndo, "\n\t Format Code: %s", 923 tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK))); 924 925 if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL) 926 ND_PRINT((ndo, "\n\t QoS Flags [%s]", 927 bittok2str(clnp_option_qos_global_values, 928 "none", 929 *tptr&CLNP_OPTION_OPTION_QOS_MASK))); 930 break; 931 932 case CLNP_OPTION_SECURITY: 933 ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u", 934 tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK), 935 *(tptr+1))); 936 break; 937 938 case CLNP_OPTION_DISCARD_REASON: 939 rfd_error_major = (*tptr&0xf0) >> 4; 940 rfd_error_minor = *tptr&0x0f; 941 ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)", 942 tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major), 943 rfd_error_major, 944 tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor), 945 rfd_error_minor)); 946 break; 947 948 case CLNP_OPTION_PADDING: 949 ND_PRINT((ndo, "padding data")); 950 break; 951 952 /* 953 * FIXME those are the defined Options that lack a decoder 954 * you are welcome to contribute code ;-) 955 */ 956 957 default: 958 print_unknown_data(ndo, tptr, "\n\t ", opli); 959 break; 960 } 961 if (ndo->ndo_vflag > 1) 962 print_unknown_data(ndo, pptr, "\n\t ", opli); 963 pptr += opli; 964 } 965 966 switch (clnp_pdu_type) { 967 968 case CLNP_PDU_ER: /* fall through */ 969 case CLNP_PDU_ERP: 970 ND_TCHECK(*pptr); 971 if (*(pptr) == NLPID_CLNP) { 972 ND_PRINT((ndo, "\n\t-----original packet-----\n\t")); 973 /* FIXME recursion protection */ 974 clnp_print(ndo, pptr, length - clnp_header->length_indicator); 975 break; 976 } 977 978 case CLNP_PDU_DT: 979 case CLNP_PDU_MD: 980 case CLNP_PDU_ERQ: 981 982 default: 983 /* dump the PDU specific data */ 984 if (length-(pptr-optr) > 0) { 985 ND_PRINT((ndo, "\n\t undecoded non-header data, length %u", length-clnp_header->length_indicator)); 986 print_unknown_data(ndo, pptr, "\n\t ", length - (pptr - optr)); 987 } 988 } 989 990 return (1); 991 992 trunc: 993 ND_PRINT((ndo, "[|clnp]")); 994 return (1); 995 996 } 997 998 999 #define ESIS_PDU_REDIRECT 6 1000 #define ESIS_PDU_ESH 2 1001 #define ESIS_PDU_ISH 4 1002 1003 static const struct tok esis_pdu_values[] = { 1004 { ESIS_PDU_REDIRECT, "redirect"}, 1005 { ESIS_PDU_ESH, "ESH"}, 1006 { ESIS_PDU_ISH, "ISH"}, 1007 { 0, NULL } 1008 }; 1009 1010 struct esis_header_t { 1011 uint8_t nlpid; 1012 uint8_t length_indicator; 1013 uint8_t version; 1014 uint8_t reserved; 1015 uint8_t type; 1016 uint8_t holdtime[2]; 1017 uint8_t cksum[2]; 1018 }; 1019 1020 static void 1021 esis_print(netdissect_options *ndo, 1022 const uint8_t *pptr, u_int length) 1023 { 1024 const uint8_t *optr; 1025 u_int li,esis_pdu_type,source_address_length, source_address_number; 1026 const struct esis_header_t *esis_header; 1027 1028 if (!ndo->ndo_eflag) 1029 ND_PRINT((ndo, "ES-IS")); 1030 1031 if (length <= 2) { 1032 ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!")); 1033 return; 1034 } 1035 1036 esis_header = (const struct esis_header_t *) pptr; 1037 ND_TCHECK(*esis_header); 1038 li = esis_header->length_indicator; 1039 optr = pptr; 1040 1041 /* 1042 * Sanity checking of the header. 1043 */ 1044 1045 if (esis_header->nlpid != NLPID_ESIS) { 1046 ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid)); 1047 return; 1048 } 1049 1050 if (esis_header->version != ESIS_VERSION) { 1051 ND_PRINT((ndo, " version %d packet not supported", esis_header->version)); 1052 return; 1053 } 1054 1055 if (li > length) { 1056 ND_PRINT((ndo, " length indicator(%d) > PDU size (%d)!", li, length)); 1057 return; 1058 } 1059 1060 if (li < sizeof(struct esis_header_t) + 2) { 1061 ND_PRINT((ndo, " length indicator < min PDU size %d:", li)); 1062 while (--length != 0) 1063 ND_PRINT((ndo, "%02X", *pptr++)); 1064 return; 1065 } 1066 1067 esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK; 1068 1069 if (ndo->ndo_vflag < 1) { 1070 ND_PRINT((ndo, "%s%s, length %u", 1071 ndo->ndo_eflag ? "" : ", ", 1072 tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type), 1073 length)); 1074 return; 1075 } else 1076 ND_PRINT((ndo, "%slength %u\n\t%s (%u)", 1077 ndo->ndo_eflag ? "" : ", ", 1078 length, 1079 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type), 1080 esis_pdu_type)); 1081 1082 ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" )); 1083 ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum))); 1084 1085 osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li); 1086 1087 ND_PRINT((ndo, ", holding time: %us, length indicator: %u", 1088 EXTRACT_16BITS(esis_header->holdtime), li)); 1089 1090 if (ndo->ndo_vflag > 1) 1091 print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t)); 1092 1093 pptr += sizeof(struct esis_header_t); 1094 li -= sizeof(struct esis_header_t); 1095 1096 switch (esis_pdu_type) { 1097 case ESIS_PDU_REDIRECT: { 1098 const uint8_t *dst, *snpa, *neta; 1099 u_int dstl, snpal, netal; 1100 1101 ND_TCHECK(*pptr); 1102 if (li < 1) { 1103 ND_PRINT((ndo, ", bad redirect/li")); 1104 return; 1105 } 1106 dstl = *pptr; 1107 pptr++; 1108 li--; 1109 ND_TCHECK2(*pptr, dstl); 1110 if (li < dstl) { 1111 ND_PRINT((ndo, ", bad redirect/li")); 1112 return; 1113 } 1114 dst = pptr; 1115 pptr += dstl; 1116 li -= dstl; 1117 ND_PRINT((ndo, "\n\t %s", isonsap_string(dst, dstl))); 1118 1119 ND_TCHECK(*pptr); 1120 if (li < 1) { 1121 ND_PRINT((ndo, ", bad redirect/li")); 1122 return; 1123 } 1124 snpal = *pptr; 1125 pptr++; 1126 li--; 1127 ND_TCHECK2(*pptr, snpal); 1128 if (li < snpal) { 1129 ND_PRINT((ndo, ", bad redirect/li")); 1130 return; 1131 } 1132 snpa = pptr; 1133 pptr += snpal; 1134 li -= snpal; 1135 ND_TCHECK(*pptr); 1136 if (li < 1) { 1137 ND_PRINT((ndo, ", bad redirect/li")); 1138 return; 1139 } 1140 netal = *pptr; 1141 pptr++; 1142 ND_TCHECK2(*pptr, netal); 1143 if (li < netal) { 1144 ND_PRINT((ndo, ", bad redirect/li")); 1145 return; 1146 } 1147 neta = pptr; 1148 pptr += netal; 1149 li -= netal; 1150 1151 if (netal == 0) 1152 ND_PRINT((ndo, "\n\t %s", etheraddr_string(ndo, snpa))); 1153 else 1154 ND_PRINT((ndo, "\n\t %s", isonsap_string(neta, netal))); 1155 break; 1156 } 1157 1158 case ESIS_PDU_ESH: 1159 ND_TCHECK(*pptr); 1160 if (li < 1) { 1161 ND_PRINT((ndo, ", bad esh/li")); 1162 return; 1163 } 1164 source_address_number = *pptr; 1165 pptr++; 1166 li--; 1167 1168 ND_PRINT((ndo, "\n\t Number of Source Addresses: %u", source_address_number)); 1169 1170 while (source_address_number > 0) { 1171 ND_TCHECK(*pptr); 1172 if (li < 1) { 1173 ND_PRINT((ndo, ", bad esh/li")); 1174 return; 1175 } 1176 source_address_length = *pptr; 1177 pptr++; 1178 li--; 1179 1180 ND_TCHECK2(*pptr, source_address_length); 1181 if (li < source_address_length) { 1182 ND_PRINT((ndo, ", bad esh/li")); 1183 return; 1184 } 1185 ND_PRINT((ndo, "\n\t NET (length: %u): %s", 1186 source_address_length, 1187 isonsap_string(pptr, source_address_length))); 1188 pptr += source_address_length; 1189 li -= source_address_length; 1190 source_address_number--; 1191 } 1192 1193 break; 1194 1195 case ESIS_PDU_ISH: { 1196 ND_TCHECK(*pptr); 1197 if (li < 1) { 1198 ND_PRINT((ndo, ", bad ish/li")); 1199 return; 1200 } 1201 source_address_length = *pptr; 1202 pptr++; 1203 li--; 1204 ND_TCHECK2(*pptr, source_address_length); 1205 if (li < source_address_length) { 1206 ND_PRINT((ndo, ", bad ish/li")); 1207 return; 1208 } 1209 ND_PRINT((ndo, "\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length))); 1210 pptr += source_address_length; 1211 li -= source_address_length; 1212 break; 1213 } 1214 1215 default: 1216 if (ndo->ndo_vflag <= 1) { 1217 if (pptr < ndo->ndo_snapend) 1218 print_unknown_data(ndo, pptr, "\n\t ", ndo->ndo_snapend - pptr); 1219 } 1220 return; 1221 } 1222 1223 /* now walk the options */ 1224 while (li != 0) { 1225 u_int op, opli; 1226 const uint8_t *tptr; 1227 1228 if (li < 2) { 1229 ND_PRINT((ndo, ", bad opts/li")); 1230 return; 1231 } 1232 ND_TCHECK2(*pptr, 2); 1233 op = *pptr++; 1234 opli = *pptr++; 1235 li -= 2; 1236 if (opli > li) { 1237 ND_PRINT((ndo, ", opt (%d) too long", op)); 1238 return; 1239 } 1240 li -= opli; 1241 tptr = pptr; 1242 1243 ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ", 1244 tok2str(esis_option_values,"Unknown",op), 1245 op, 1246 opli)); 1247 1248 switch (op) { 1249 1250 case ESIS_OPTION_ES_CONF_TIME: 1251 if (opli == 2) { 1252 ND_TCHECK2(*pptr, 2); 1253 ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr))); 1254 } else 1255 ND_PRINT((ndo, "(bad length)")); 1256 break; 1257 1258 case ESIS_OPTION_PROTOCOLS: 1259 while (opli>0) { 1260 ND_TCHECK(*pptr); 1261 ND_PRINT((ndo, "%s (0x%02x)", 1262 tok2str(nlpid_values, 1263 "unknown", 1264 *tptr), 1265 *tptr)); 1266 if (opli>1) /* further NPLIDs ? - put comma */ 1267 ND_PRINT((ndo, ", ")); 1268 tptr++; 1269 opli--; 1270 } 1271 break; 1272 1273 /* 1274 * FIXME those are the defined Options that lack a decoder 1275 * you are welcome to contribute code ;-) 1276 */ 1277 1278 case ESIS_OPTION_QOS_MAINTENANCE: 1279 case ESIS_OPTION_SECURITY: 1280 case ESIS_OPTION_PRIORITY: 1281 case ESIS_OPTION_ADDRESS_MASK: 1282 case ESIS_OPTION_SNPA_MASK: 1283 1284 default: 1285 print_unknown_data(ndo, tptr, "\n\t ", opli); 1286 break; 1287 } 1288 if (ndo->ndo_vflag > 1) 1289 print_unknown_data(ndo, pptr, "\n\t ", opli); 1290 pptr += opli; 1291 } 1292 trunc: 1293 return; 1294 } 1295 1296 static void 1297 isis_print_mcid(netdissect_options *ndo, 1298 const struct isis_spb_mcid *mcid) 1299 { 1300 int i; 1301 1302 ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id)); 1303 1304 for(i=0; i<32; i++) 1305 { 1306 ND_PRINT((ndo, "%c", mcid->name[i])); 1307 if(mcid->name[i] == '\0') 1308 break; 1309 } 1310 1311 ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl))); 1312 1313 ND_PRINT((ndo, ", Digest: ")); 1314 1315 for(i=0;i<16;i++) 1316 ND_PRINT((ndo, "%.2x ", mcid->digest[i])); 1317 } 1318 1319 static int 1320 isis_print_mt_port_cap_subtlv(netdissect_options *ndo, 1321 const uint8_t *tptr, int len) 1322 { 1323 int stlv_type, stlv_len; 1324 const struct isis_subtlv_spb_mcid *subtlv_spb_mcid; 1325 int i; 1326 1327 while (len > 0) 1328 { 1329 stlv_type = *(tptr++); 1330 stlv_len = *(tptr++); 1331 1332 /* first lets see if we know the subTLVs name*/ 1333 ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u", 1334 tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type), 1335 stlv_type, 1336 stlv_len)); 1337 1338 /*len -= TLV_TYPE_LEN_OFFSET;*/ 1339 len = len -2; 1340 1341 switch (stlv_type) 1342 { 1343 case ISIS_SUBTLV_SPB_MCID: 1344 { 1345 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN)) 1346 goto trunctlv; 1347 1348 subtlv_spb_mcid = (struct isis_subtlv_spb_mcid *)tptr; 1349 1350 ND_PRINT((ndo, "\n\t MCID: ")); 1351 isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid)); 1352 1353 /*tptr += SPB_MCID_MIN_LEN; 1354 len -= SPB_MCID_MIN_LEN; */ 1355 1356 ND_PRINT((ndo, "\n\t AUX-MCID: ")); 1357 isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid)); 1358 1359 /*tptr += SPB_MCID_MIN_LEN; 1360 len -= SPB_MCID_MIN_LEN; */ 1361 tptr = tptr + sizeof(struct isis_subtlv_spb_mcid); 1362 len = len - sizeof(struct isis_subtlv_spb_mcid); 1363 1364 break; 1365 } 1366 1367 case ISIS_SUBTLV_SPB_DIGEST: 1368 { 1369 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN)) 1370 goto trunctlv; 1371 1372 ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d", 1373 (*(tptr) >> 5), (((*tptr)>> 4) & 0x01), 1374 ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03))); 1375 1376 tptr++; 1377 1378 ND_PRINT((ndo, "\n\t Digest: ")); 1379 1380 for(i=1;i<=8; i++) 1381 { 1382 ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr))); 1383 if (i%4 == 0 && i != 8) 1384 ND_PRINT((ndo, "\n\t ")); 1385 tptr = tptr + 4; 1386 } 1387 1388 len = len - ISIS_SUBTLV_SPB_DIGEST_MIN_LEN; 1389 1390 break; 1391 } 1392 1393 case ISIS_SUBTLV_SPB_BVID: 1394 { 1395 if (!ND_TTEST2(*(tptr), stlv_len)) 1396 goto trunctlv; 1397 1398 while (len) 1399 { 1400 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN)) 1401 goto trunctlv; 1402 1403 ND_PRINT((ndo, "\n\t ECT: %08x", 1404 EXTRACT_32BITS(tptr))); 1405 1406 tptr = tptr+4; 1407 1408 ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ", 1409 (EXTRACT_16BITS (tptr) >> 4) , 1410 (EXTRACT_16BITS (tptr) >> 3) & 0x01, 1411 (EXTRACT_16BITS (tptr) >> 2) & 0x01)); 1412 1413 tptr = tptr + 2; 1414 len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN; 1415 } 1416 1417 break; 1418 } 1419 1420 default: 1421 break; 1422 } 1423 } 1424 1425 return 0; 1426 1427 trunctlv: 1428 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); 1429 return(1); 1430 } 1431 1432 static int 1433 isis_print_mt_capability_subtlv(netdissect_options *ndo, 1434 const uint8_t *tptr, int len) 1435 { 1436 int stlv_type, stlv_len, tmp; 1437 1438 while (len > 0) 1439 { 1440 stlv_type = *(tptr++); 1441 stlv_len = *(tptr++); 1442 1443 /* first lets see if we know the subTLVs name*/ 1444 ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u", 1445 tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type), 1446 stlv_type, 1447 stlv_len)); 1448 1449 len = len - 2; 1450 1451 switch (stlv_type) 1452 { 1453 case ISIS_SUBTLV_SPB_INSTANCE: 1454 1455 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN)) 1456 goto trunctlv; 1457 1458 ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr))); 1459 tptr = tptr+4; 1460 ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr))); 1461 tptr = tptr+4; 1462 ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr))); 1463 tptr = tptr+4; 1464 ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr))); 1465 tptr = tptr + 2; 1466 ND_PRINT((ndo, "\n\t RES: %d", 1467 EXTRACT_16BITS(tptr) >> 5)); 1468 ND_PRINT((ndo, ", V: %d", 1469 (EXTRACT_16BITS(tptr) >> 4) & 0x0001)); 1470 ND_PRINT((ndo, ", SPSource-ID: %d", 1471 (EXTRACT_32BITS(tptr) & 0x000fffff))); 1472 tptr = tptr+4; 1473 ND_PRINT((ndo, ", No of Trees: %x", *(tptr))); 1474 1475 tmp = *(tptr++); 1476 1477 len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN; 1478 1479 while (tmp) 1480 { 1481 if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN)) 1482 goto trunctlv; 1483 1484 ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d", 1485 *(tptr) >> 7, (*(tptr) >> 6) & 0x01, 1486 (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f))); 1487 1488 tptr++; 1489 1490 ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr))); 1491 1492 tptr = tptr + 4; 1493 1494 ND_PRINT((ndo, ", BVID: %d, SPVID: %d", 1495 (EXTRACT_24BITS(tptr) >> 12) & 0x000fff, 1496 EXTRACT_24BITS(tptr) & 0x000fff)); 1497 1498 tptr = tptr + 3; 1499 len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN; 1500 tmp--; 1501 } 1502 1503 break; 1504 1505 case ISIS_SUBTLV_SPBM_SI: 1506 1507 if (!ND_TTEST2(*(tptr), 6)) 1508 goto trunctlv; 1509 1510 ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr))); 1511 tptr = tptr+4; 1512 ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr))); 1513 tptr = tptr+2; 1514 1515 ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12, 1516 (EXTRACT_16BITS(tptr)) & 0x0fff)); 1517 1518 tptr = tptr+2; 1519 len = len - 8; 1520 stlv_len = stlv_len - 8; 1521 1522 while (stlv_len) 1523 { 1524 ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d", 1525 (EXTRACT_32BITS(tptr) >> 31), 1526 (EXTRACT_32BITS(tptr) >> 30) & 0x01, 1527 (EXTRACT_32BITS(tptr) >> 24) & 0x03f, 1528 (EXTRACT_32BITS(tptr)) & 0x0ffffff)); 1529 1530 tptr = tptr + 4; 1531 len = len - 4; 1532 stlv_len = stlv_len - 4; 1533 } 1534 1535 break; 1536 1537 default: 1538 break; 1539 } 1540 } 1541 return 0; 1542 1543 trunctlv: 1544 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); 1545 return(1); 1546 } 1547 1548 /* shared routine for printing system, node and lsp-ids */ 1549 static char * 1550 isis_print_id(const uint8_t *cp, int id_len) 1551 { 1552 int i; 1553 static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")]; 1554 char *pos = id; 1555 1556 for (i = 1; i <= SYSTEM_ID_LEN; i++) { 1557 snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++); 1558 pos += strlen(pos); 1559 if (i == 2 || i == 4) 1560 *pos++ = '.'; 1561 } 1562 if (id_len >= NODE_ID_LEN) { 1563 snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++); 1564 pos += strlen(pos); 1565 } 1566 if (id_len == LSP_ID_LEN) 1567 snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp); 1568 return (id); 1569 } 1570 1571 /* print the 4-byte metric block which is common found in the old-style TLVs */ 1572 static int 1573 isis_print_metric_block(netdissect_options *ndo, 1574 const struct isis_metric_block *isis_metric_block) 1575 { 1576 ND_PRINT((ndo, ", Default Metric: %d, %s", 1577 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default), 1578 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal")); 1579 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay)) 1580 ND_PRINT((ndo, "\n\t\t Delay Metric: %d, %s", 1581 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay), 1582 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal")); 1583 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense)) 1584 ND_PRINT((ndo, "\n\t\t Expense Metric: %d, %s", 1585 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense), 1586 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal")); 1587 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error)) 1588 ND_PRINT((ndo, "\n\t\t Error Metric: %d, %s", 1589 ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error), 1590 ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal")); 1591 1592 return(1); /* everything is ok */ 1593 } 1594 1595 static int 1596 isis_print_tlv_ip_reach(netdissect_options *ndo, 1597 const uint8_t *cp, const char *ident, int length) 1598 { 1599 int prefix_len; 1600 const struct isis_tlv_ip_reach *tlv_ip_reach; 1601 1602 tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp; 1603 1604 while (length > 0) { 1605 if ((size_t)length < sizeof(*tlv_ip_reach)) { 1606 ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)", 1607 length, 1608 (unsigned long)sizeof(*tlv_ip_reach))); 1609 return (0); 1610 } 1611 1612 if (!ND_TTEST(*tlv_ip_reach)) 1613 return (0); 1614 1615 prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask)); 1616 1617 if (prefix_len == -1) 1618 ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s", 1619 ident, 1620 ipaddr_string(ndo, (tlv_ip_reach->prefix)), 1621 ipaddr_string(ndo, (tlv_ip_reach->mask)))); 1622 else 1623 ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u", 1624 ident, 1625 ipaddr_string(ndo, (tlv_ip_reach->prefix)), 1626 prefix_len)); 1627 1628 ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s", 1629 ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up", 1630 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default), 1631 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal")); 1632 1633 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay)) 1634 ND_PRINT((ndo, "%s Delay Metric: %u, %s", 1635 ident, 1636 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay), 1637 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal")); 1638 1639 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense)) 1640 ND_PRINT((ndo, "%s Expense Metric: %u, %s", 1641 ident, 1642 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense), 1643 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal")); 1644 1645 if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error)) 1646 ND_PRINT((ndo, "%s Error Metric: %u, %s", 1647 ident, 1648 ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error), 1649 ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal")); 1650 1651 length -= sizeof(struct isis_tlv_ip_reach); 1652 tlv_ip_reach++; 1653 } 1654 return (1); 1655 } 1656 1657 /* 1658 * this is the common IP-REACH subTLV decoder it is called 1659 * from various EXTD-IP REACH TLVs (135,235,236,237) 1660 */ 1661 1662 static int 1663 isis_print_ip_reach_subtlv(netdissect_options *ndo, 1664 const uint8_t *tptr, int subt, int subl, 1665 const char *ident) { 1666 1667 /* first lets see if we know the subTLVs name*/ 1668 ND_PRINT((ndo, "%s%s subTLV #%u, length: %u", 1669 ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt), 1670 subt, subl)); 1671 1672 if (!ND_TTEST2(*tptr,subl)) 1673 goto trunctlv; 1674 1675 switch(subt) { 1676 case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */ 1677 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32: 1678 while (subl >= 4) { 1679 ND_PRINT((ndo, ", 0x%08x (=%u)", 1680 EXTRACT_32BITS(tptr), 1681 EXTRACT_32BITS(tptr))); 1682 tptr+=4; 1683 subl-=4; 1684 } 1685 break; 1686 case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64: 1687 while (subl >= 8) { 1688 ND_PRINT((ndo, ", 0x%08x%08x", 1689 EXTRACT_32BITS(tptr), 1690 EXTRACT_32BITS(tptr+4))); 1691 tptr+=8; 1692 subl-=8; 1693 } 1694 break; 1695 default: 1696 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl)) 1697 return(0); 1698 break; 1699 } 1700 return(1); 1701 1702 trunctlv: 1703 ND_PRINT((ndo, "%spacket exceeded snapshot", ident)); 1704 return(0); 1705 } 1706 1707 /* 1708 * this is the common IS-REACH subTLV decoder it is called 1709 * from isis_print_ext_is_reach() 1710 */ 1711 1712 static int 1713 isis_print_is_reach_subtlv(netdissect_options *ndo, 1714 const uint8_t *tptr, u_int subt, u_int subl, 1715 const char *ident) { 1716 1717 u_int te_class,priority_level,gmpls_switch_cap; 1718 union { /* int to float conversion buffer for several subTLVs */ 1719 float f; 1720 uint32_t i; 1721 } bw; 1722 1723 /* first lets see if we know the subTLVs name*/ 1724 ND_PRINT((ndo, "%s%s subTLV #%u, length: %u", 1725 ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt), 1726 subt, subl)); 1727 1728 if (!ND_TTEST2(*tptr,subl)) 1729 goto trunctlv; 1730 1731 switch(subt) { 1732 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP: 1733 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID: 1734 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID: 1735 if (subl >= 4) { 1736 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr))); 1737 if (subl == 8) /* rfc4205 */ 1738 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4))); 1739 } 1740 break; 1741 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: 1742 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: 1743 if (subl >= sizeof(struct in_addr)) 1744 ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr))); 1745 break; 1746 case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW : 1747 case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW: 1748 if (subl >= 4) { 1749 bw.i = EXTRACT_32BITS(tptr); 1750 ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000)); 1751 } 1752 break; 1753 case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW : 1754 if (subl >= 32) { 1755 for (te_class = 0; te_class < 8; te_class++) { 1756 bw.i = EXTRACT_32BITS(tptr); 1757 ND_PRINT((ndo, "%s TE-Class %u: %.3f Mbps", 1758 ident, 1759 te_class, 1760 bw.f * 8 / 1000000)); 1761 tptr+=4; 1762 } 1763 } 1764 break; 1765 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */ 1766 case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD: 1767 ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)", 1768 ident, 1769 tok2str(diffserv_te_bc_values, "unknown", *tptr), 1770 *tptr)); 1771 tptr++; 1772 /* decode BCs until the subTLV ends */ 1773 for (te_class = 0; te_class < (subl-1)/4; te_class++) { 1774 bw.i = EXTRACT_32BITS(tptr); 1775 ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps", 1776 ident, 1777 te_class, 1778 bw.f * 8 / 1000000)); 1779 tptr+=4; 1780 } 1781 break; 1782 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC: 1783 if (subl >= 3) 1784 ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr))); 1785 break; 1786 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE: 1787 if (subl == 2) { 1788 ND_PRINT((ndo, ", [ %s ] (0x%04x)", 1789 bittok2str(isis_subtlv_link_attribute_values, 1790 "Unknown", 1791 EXTRACT_16BITS(tptr)), 1792 EXTRACT_16BITS(tptr))); 1793 } 1794 break; 1795 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE: 1796 if (subl >= 2) { 1797 ND_PRINT((ndo, ", %s, Priority %u", 1798 bittok2str(gmpls_link_prot_values, "none", *tptr), 1799 *(tptr+1))); 1800 } 1801 break; 1802 case ISIS_SUBTLV_SPB_METRIC: 1803 if (subl >= 6) { 1804 ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr))); 1805 tptr=tptr+3; 1806 ND_PRINT((ndo, ", P: %u", *(tptr))); 1807 tptr++; 1808 ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr))); 1809 } 1810 break; 1811 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR: 1812 if (subl >= 36) { 1813 gmpls_switch_cap = *tptr; 1814 ND_PRINT((ndo, "%s Interface Switching Capability:%s", 1815 ident, 1816 tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap))); 1817 ND_PRINT((ndo, ", LSP Encoding: %s", 1818 tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1)))); 1819 tptr+=4; 1820 ND_PRINT((ndo, "%s Max LSP Bandwidth:", ident)); 1821 for (priority_level = 0; priority_level < 8; priority_level++) { 1822 bw.i = EXTRACT_32BITS(tptr); 1823 ND_PRINT((ndo, "%s priority level %d: %.3f Mbps", 1824 ident, 1825 priority_level, 1826 bw.f * 8 / 1000000)); 1827 tptr+=4; 1828 } 1829 subl-=36; 1830 switch (gmpls_switch_cap) { 1831 case GMPLS_PSC1: 1832 case GMPLS_PSC2: 1833 case GMPLS_PSC3: 1834 case GMPLS_PSC4: 1835 bw.i = EXTRACT_32BITS(tptr); 1836 ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000)); 1837 ND_PRINT((ndo, "%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr + 4))); 1838 break; 1839 case GMPLS_TSC: 1840 bw.i = EXTRACT_32BITS(tptr); 1841 ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000)); 1842 ND_PRINT((ndo, "%s Indication %s", ident, 1843 tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr + 4)))); 1844 break; 1845 default: 1846 /* there is some optional stuff left to decode but this is as of yet 1847 not specified so just lets hexdump what is left */ 1848 if(subl>0){ 1849 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl)) 1850 return(0); 1851 } 1852 } 1853 } 1854 break; 1855 default: 1856 if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl)) 1857 return(0); 1858 break; 1859 } 1860 return(1); 1861 1862 trunctlv: 1863 ND_PRINT((ndo, "%spacket exceeded snapshot", ident)); 1864 return(0); 1865 } 1866 1867 1868 /* 1869 * this is the common IS-REACH decoder it is called 1870 * from various EXTD-IS REACH style TLVs (22,24,222) 1871 */ 1872 1873 static int 1874 isis_print_ext_is_reach(netdissect_options *ndo, 1875 const uint8_t *tptr, const char *ident, int tlv_type) { 1876 1877 char ident_buffer[20]; 1878 int subtlv_type,subtlv_len,subtlv_sum_len; 1879 int proc_bytes = 0; /* how many bytes did we process ? */ 1880 1881 if (!ND_TTEST2(*tptr, NODE_ID_LEN)) 1882 return(0); 1883 1884 ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN))); 1885 tptr+=(NODE_ID_LEN); 1886 1887 if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */ 1888 if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */ 1889 return(0); 1890 ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr))); 1891 tptr+=3; 1892 } 1893 1894 if (!ND_TTEST2(*tptr, 1)) 1895 return(0); 1896 subtlv_sum_len=*(tptr++); /* read out subTLV length */ 1897 proc_bytes=NODE_ID_LEN+3+1; 1898 ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no ")); 1899 if (subtlv_sum_len) { 1900 ND_PRINT((ndo, " (%u)", subtlv_sum_len)); 1901 while (subtlv_sum_len>0) { 1902 if (!ND_TTEST2(*tptr,2)) 1903 return(0); 1904 subtlv_type=*(tptr++); 1905 subtlv_len=*(tptr++); 1906 /* prepend the ident string */ 1907 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); 1908 if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer)) 1909 return(0); 1910 tptr+=subtlv_len; 1911 subtlv_sum_len-=(subtlv_len+2); 1912 proc_bytes+=(subtlv_len+2); 1913 } 1914 } 1915 return(proc_bytes); 1916 } 1917 1918 /* 1919 * this is the common Multi Topology ID decoder 1920 * it is called from various MT-TLVs (222,229,235,237) 1921 */ 1922 1923 static int 1924 isis_print_mtid(netdissect_options *ndo, 1925 const uint8_t *tptr, const char *ident) { 1926 1927 if (!ND_TTEST2(*tptr, 2)) 1928 return(0); 1929 1930 ND_PRINT((ndo, "%s%s", 1931 ident, 1932 tok2str(isis_mt_values, 1933 "Reserved for IETF Consensus", 1934 ISIS_MASK_MTID(EXTRACT_16BITS(tptr))))); 1935 1936 ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]", 1937 ISIS_MASK_MTID(EXTRACT_16BITS(tptr)), 1938 bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr))))); 1939 1940 return(2); 1941 } 1942 1943 /* 1944 * this is the common extended IP reach decoder 1945 * it is called from TLVs (135,235,236,237) 1946 * we process the TLV and optional subTLVs and return 1947 * the amount of processed bytes 1948 */ 1949 1950 static int 1951 isis_print_extd_ip_reach(netdissect_options *ndo, 1952 const uint8_t *tptr, const char *ident, uint16_t afi) { 1953 1954 char ident_buffer[20]; 1955 #ifdef INET6 1956 uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ 1957 #else 1958 uint8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */ 1959 #endif 1960 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; 1961 1962 if (!ND_TTEST2(*tptr, 4)) 1963 return (0); 1964 metric = EXTRACT_32BITS(tptr); 1965 processed=4; 1966 tptr+=4; 1967 1968 if (afi == AF_INET) { 1969 if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */ 1970 return (0); 1971 status_byte=*(tptr++); 1972 bit_length = status_byte&0x3f; 1973 if (bit_length > 32) { 1974 ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u", 1975 ident, 1976 bit_length)); 1977 return (0); 1978 } 1979 processed++; 1980 #ifdef INET6 1981 } else if (afi == AF_INET6) { 1982 if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */ 1983 return (0); 1984 status_byte=*(tptr++); 1985 bit_length=*(tptr++); 1986 if (bit_length > 128) { 1987 ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u", 1988 ident, 1989 bit_length)); 1990 return (0); 1991 } 1992 processed+=2; 1993 #endif 1994 } else 1995 return (0); /* somebody is fooling us */ 1996 1997 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */ 1998 1999 if (!ND_TTEST2(*tptr, byte_length)) 2000 return (0); 2001 memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ 2002 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ 2003 tptr+=byte_length; 2004 processed+=byte_length; 2005 2006 if (afi == AF_INET) 2007 ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u", 2008 ident, 2009 ipaddr_string(ndo, prefix), 2010 bit_length)); 2011 #ifdef INET6 2012 if (afi == AF_INET6) 2013 ND_PRINT((ndo, "%sIPv6 prefix: %s/%u", 2014 ident, 2015 ip6addr_string(ndo, prefix), 2016 bit_length)); 2017 #endif 2018 2019 ND_PRINT((ndo, ", Distribution: %s, Metric: %u", 2020 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up", 2021 metric)); 2022 2023 if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) 2024 ND_PRINT((ndo, ", sub-TLVs present")); 2025 #ifdef INET6 2026 if (afi == AF_INET6) 2027 ND_PRINT((ndo, ", %s%s", 2028 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal", 2029 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "")); 2030 #endif 2031 2032 if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) 2033 #ifdef INET6 2034 || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte)) 2035 #endif 2036 ) { 2037 /* assume that one prefix can hold more 2038 than one subTLV - therefore the first byte must reflect 2039 the aggregate bytecount of the subTLVs for this prefix 2040 */ 2041 if (!ND_TTEST2(*tptr, 1)) 2042 return (0); 2043 sublen=*(tptr++); 2044 processed+=sublen+1; 2045 ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */ 2046 2047 while (sublen>0) { 2048 if (!ND_TTEST2(*tptr,2)) 2049 return (0); 2050 subtlvtype=*(tptr++); 2051 subtlvlen=*(tptr++); 2052 /* prepend the ident string */ 2053 snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); 2054 if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer)) 2055 return(0); 2056 tptr+=subtlvlen; 2057 sublen-=(subtlvlen+2); 2058 } 2059 } 2060 return (processed); 2061 } 2062 2063 /* 2064 * isis_print 2065 * Decode IS-IS packets. Return 0 on error. 2066 */ 2067 2068 static int 2069 isis_print(netdissect_options *ndo, 2070 const uint8_t *p, u_int length) 2071 { 2072 const struct isis_common_header *isis_header; 2073 2074 const struct isis_iih_lan_header *header_iih_lan; 2075 const struct isis_iih_ptp_header *header_iih_ptp; 2076 struct isis_lsp_header *header_lsp; 2077 const struct isis_csnp_header *header_csnp; 2078 const struct isis_psnp_header *header_psnp; 2079 2080 const struct isis_tlv_lsp *tlv_lsp; 2081 const struct isis_tlv_ptp_adj *tlv_ptp_adj; 2082 const struct isis_tlv_is_reach *tlv_is_reach; 2083 const struct isis_tlv_es_reach *tlv_es_reach; 2084 2085 uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len; 2086 uint8_t ext_is_len, ext_ip_len, mt_len; 2087 const uint8_t *optr, *pptr, *tptr; 2088 u_short packet_len,pdu_len, key_id; 2089 u_int i,vendor_id; 2090 int sigcheck; 2091 2092 packet_len=length; 2093 optr = p; /* initialize the _o_riginal pointer to the packet start - 2094 need it for parsing the checksum TLV and authentication 2095 TLV verification */ 2096 isis_header = (const struct isis_common_header *)p; 2097 ND_TCHECK(*isis_header); 2098 pptr = p+(ISIS_COMMON_HEADER_SIZE); 2099 header_iih_lan = (const struct isis_iih_lan_header *)pptr; 2100 header_iih_ptp = (const struct isis_iih_ptp_header *)pptr; 2101 header_lsp = (struct isis_lsp_header *)pptr; 2102 header_csnp = (const struct isis_csnp_header *)pptr; 2103 header_psnp = (const struct isis_psnp_header *)pptr; 2104 2105 if (!ndo->ndo_eflag) 2106 ND_PRINT((ndo, "IS-IS")); 2107 2108 /* 2109 * Sanity checking of the header. 2110 */ 2111 2112 if (isis_header->version != ISIS_VERSION) { 2113 ND_PRINT((ndo, "version %d packet not supported", isis_header->version)); 2114 return (0); 2115 } 2116 2117 if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) { 2118 ND_PRINT((ndo, "system ID length of %d is not supported", 2119 isis_header->id_length)); 2120 return (0); 2121 } 2122 2123 if (isis_header->pdu_version != ISIS_VERSION) { 2124 ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version)); 2125 return (0); 2126 } 2127 2128 max_area = isis_header->max_area; 2129 switch(max_area) { 2130 case 0: 2131 max_area = 3; /* silly shit */ 2132 break; 2133 case 255: 2134 ND_PRINT((ndo, "bad packet -- 255 areas")); 2135 return (0); 2136 default: 2137 break; 2138 } 2139 2140 id_length = isis_header->id_length; 2141 switch(id_length) { 2142 case 0: 2143 id_length = 6; /* silly shit again */ 2144 break; 2145 case 1: /* 1-8 are valid sys-ID lenghts */ 2146 case 2: 2147 case 3: 2148 case 4: 2149 case 5: 2150 case 6: 2151 case 7: 2152 case 8: 2153 break; 2154 case 255: 2155 id_length = 0; /* entirely useless */ 2156 break; 2157 default: 2158 break; 2159 } 2160 2161 /* toss any non 6-byte sys-ID len PDUs */ 2162 if (id_length != 6 ) { 2163 ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length)); 2164 return (0); 2165 } 2166 2167 pdu_type=isis_header->pdu_type; 2168 2169 /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/ 2170 if (ndo->ndo_vflag < 1) { 2171 ND_PRINT((ndo, "%s%s", 2172 ndo->ndo_eflag ? "" : ", ", 2173 tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type))); 2174 2175 switch (pdu_type) { 2176 2177 case ISIS_PDU_L1_LAN_IIH: 2178 case ISIS_PDU_L2_LAN_IIH: 2179 ND_PRINT((ndo, ", src-id %s", 2180 isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN))); 2181 ND_PRINT((ndo, ", lan-id %s, prio %u", 2182 isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN), 2183 header_iih_lan->priority)); 2184 break; 2185 case ISIS_PDU_PTP_IIH: 2186 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN))); 2187 break; 2188 case ISIS_PDU_L1_LSP: 2189 case ISIS_PDU_L2_LSP: 2190 ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us", 2191 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), 2192 EXTRACT_32BITS(header_lsp->sequence_number), 2193 EXTRACT_16BITS(header_lsp->remaining_lifetime))); 2194 break; 2195 case ISIS_PDU_L1_CSNP: 2196 case ISIS_PDU_L2_CSNP: 2197 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN))); 2198 break; 2199 case ISIS_PDU_L1_PSNP: 2200 case ISIS_PDU_L2_PSNP: 2201 ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN))); 2202 break; 2203 2204 } 2205 ND_PRINT((ndo, ", length %u", length)); 2206 2207 return(1); 2208 } 2209 2210 /* ok they seem to want to know everything - lets fully decode it */ 2211 ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length)); 2212 2213 ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)", 2214 tok2str(isis_pdu_values, 2215 "unknown, type %u", 2216 pdu_type), 2217 isis_header->fixed_len, 2218 isis_header->version, 2219 isis_header->pdu_version, 2220 id_length, 2221 isis_header->id_length, 2222 max_area, 2223 isis_header->max_area)); 2224 2225 if (ndo->ndo_vflag > 1) { 2226 if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */ 2227 return(0); /* for optionally debugging the common header */ 2228 } 2229 2230 switch (pdu_type) { 2231 2232 case ISIS_PDU_L1_LAN_IIH: 2233 case ISIS_PDU_L2_LAN_IIH: 2234 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) { 2235 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu", 2236 isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE)); 2237 return (0); 2238 } 2239 2240 pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len); 2241 if (packet_len>pdu_len) { 2242 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ 2243 length=pdu_len; 2244 } 2245 2246 ND_TCHECK(*header_iih_lan); 2247 ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]", 2248 isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN), 2249 EXTRACT_16BITS(header_iih_lan->holding_time), 2250 tok2str(isis_iih_circuit_type_values, 2251 "unknown circuit type 0x%02x", 2252 header_iih_lan->circuit_type))); 2253 2254 ND_PRINT((ndo, "\n\t lan-id: %s, Priority: %u, PDU length: %u", 2255 isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN), 2256 (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK, 2257 pdu_len)); 2258 2259 if (ndo->ndo_vflag > 1) { 2260 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE)) 2261 return(0); 2262 } 2263 2264 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); 2265 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); 2266 break; 2267 2268 case ISIS_PDU_PTP_IIH: 2269 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) { 2270 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu", 2271 isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE)); 2272 return (0); 2273 } 2274 2275 pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len); 2276 if (packet_len>pdu_len) { 2277 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ 2278 length=pdu_len; 2279 } 2280 2281 ND_TCHECK(*header_iih_ptp); 2282 ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]", 2283 isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN), 2284 EXTRACT_16BITS(header_iih_ptp->holding_time), 2285 tok2str(isis_iih_circuit_type_values, 2286 "unknown circuit type 0x%02x", 2287 header_iih_ptp->circuit_type))); 2288 2289 ND_PRINT((ndo, "\n\t circuit-id: 0x%02x, PDU length: %u", 2290 header_iih_ptp->circuit_id, 2291 pdu_len)); 2292 2293 if (ndo->ndo_vflag > 1) { 2294 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE)) 2295 return(0); 2296 } 2297 2298 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); 2299 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); 2300 break; 2301 2302 case ISIS_PDU_L1_LSP: 2303 case ISIS_PDU_L2_LSP: 2304 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) { 2305 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu", 2306 isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE)); 2307 return (0); 2308 } 2309 2310 pdu_len=EXTRACT_16BITS(header_lsp->pdu_len); 2311 if (packet_len>pdu_len) { 2312 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ 2313 length=pdu_len; 2314 } 2315 2316 ND_TCHECK(*header_lsp); 2317 ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x", 2318 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), 2319 EXTRACT_32BITS(header_lsp->sequence_number), 2320 EXTRACT_16BITS(header_lsp->remaining_lifetime), 2321 EXTRACT_16BITS(header_lsp->checksum))); 2322 2323 2324 osi_print_cksum(ndo, (uint8_t *)header_lsp->lsp_id, 2325 EXTRACT_16BITS(header_lsp->checksum), 12, length-12); 2326 2327 /* 2328 * Clear checksum and lifetime prior to signature verification. 2329 */ 2330 header_lsp->checksum[0] = 0; 2331 header_lsp->checksum[1] = 0; 2332 header_lsp->remaining_lifetime[0] = 0; 2333 header_lsp->remaining_lifetime[1] = 0; 2334 2335 2336 ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s", 2337 pdu_len, 2338 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "")); 2339 2340 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { 2341 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "")); 2342 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "")); 2343 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "")); 2344 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "")); 2345 ND_PRINT((ndo, "ATT bit set, ")); 2346 } 2347 ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "")); 2348 ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)", 2349 ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)))); 2350 2351 if (ndo->ndo_vflag > 1) { 2352 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE)) 2353 return(0); 2354 } 2355 2356 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); 2357 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); 2358 break; 2359 2360 case ISIS_PDU_L1_CSNP: 2361 case ISIS_PDU_L2_CSNP: 2362 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) { 2363 ND_PRINT((ndo, ", bogus fixed header length %u should be %lu", 2364 isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE)); 2365 return (0); 2366 } 2367 2368 pdu_len=EXTRACT_16BITS(header_csnp->pdu_len); 2369 if (packet_len>pdu_len) { 2370 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ 2371 length=pdu_len; 2372 } 2373 2374 ND_TCHECK(*header_csnp); 2375 ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u", 2376 isis_print_id(header_csnp->source_id, NODE_ID_LEN), 2377 pdu_len)); 2378 ND_PRINT((ndo, "\n\t start lsp-id: %s", 2379 isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN))); 2380 ND_PRINT((ndo, "\n\t end lsp-id: %s", 2381 isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN))); 2382 2383 if (ndo->ndo_vflag > 1) { 2384 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE)) 2385 return(0); 2386 } 2387 2388 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); 2389 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); 2390 break; 2391 2392 case ISIS_PDU_L1_PSNP: 2393 case ISIS_PDU_L2_PSNP: 2394 if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) { 2395 ND_PRINT((ndo, "- bogus fixed header length %u should be %lu", 2396 isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE)); 2397 return (0); 2398 } 2399 2400 pdu_len=EXTRACT_16BITS(header_psnp->pdu_len); 2401 if (packet_len>pdu_len) { 2402 packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ 2403 length=pdu_len; 2404 } 2405 2406 ND_TCHECK(*header_psnp); 2407 ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u", 2408 isis_print_id(header_psnp->source_id, NODE_ID_LEN), 2409 pdu_len)); 2410 2411 if (ndo->ndo_vflag > 1) { 2412 if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE)) 2413 return(0); 2414 } 2415 2416 packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); 2417 pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); 2418 break; 2419 2420 default: 2421 if (!print_unknown_data(ndo, pptr, "\n\t ", length)) 2422 return(0); 2423 return (0); 2424 } 2425 2426 /* 2427 * Now print the TLV's. 2428 */ 2429 2430 while (packet_len >= 2) { 2431 if (pptr == ndo->ndo_snapend) { 2432 return (1); 2433 } 2434 2435 if (!ND_TTEST2(*pptr, 2)) { 2436 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot (%ld) bytes", 2437 (long)(pptr - ndo->ndo_snapend))); 2438 return (1); 2439 } 2440 tlv_type = *pptr++; 2441 tlv_len = *pptr++; 2442 tmp =tlv_len; /* copy temporary len & pointer to packet data */ 2443 tptr = pptr; 2444 packet_len -= 2; 2445 if (tlv_len > packet_len) { 2446 break; 2447 } 2448 2449 /* first lets see if we know the TLVs name*/ 2450 ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u", 2451 tok2str(isis_tlv_values, 2452 "unknown", 2453 tlv_type), 2454 tlv_type, 2455 tlv_len)); 2456 2457 if (tlv_len == 0) /* something is malformed */ 2458 continue; 2459 2460 /* now check if we have a decoder otherwise do a hexdump at the end*/ 2461 switch (tlv_type) { 2462 case ISIS_TLV_AREA_ADDR: 2463 if (!ND_TTEST2(*tptr, 1)) 2464 goto trunctlv; 2465 alen = *tptr++; 2466 while (tmp && alen < tmp) { 2467 ND_PRINT((ndo, "\n\t Area address (length: %u): %s", 2468 alen, 2469 isonsap_string(tptr, alen))); 2470 tptr += alen; 2471 tmp -= alen + 1; 2472 if (tmp==0) /* if this is the last area address do not attemt a boundary check */ 2473 break; 2474 if (!ND_TTEST2(*tptr, 1)) 2475 goto trunctlv; 2476 alen = *tptr++; 2477 } 2478 break; 2479 case ISIS_TLV_ISNEIGH: 2480 while (tmp >= ETHER_ADDR_LEN) { 2481 if (!ND_TTEST2(*tptr, ETHER_ADDR_LEN)) 2482 goto trunctlv; 2483 ND_PRINT((ndo, "\n\t SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN))); 2484 tmp -= ETHER_ADDR_LEN; 2485 tptr += ETHER_ADDR_LEN; 2486 } 2487 break; 2488 2489 case ISIS_TLV_ISNEIGH_VARLEN: 2490 if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */ 2491 goto trunctlv; 2492 lan_alen = *tptr++; /* LAN address length */ 2493 if (lan_alen == 0) { 2494 ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)")); 2495 break; 2496 } 2497 tmp --; 2498 ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen)); 2499 while (tmp >= lan_alen) { 2500 if (!ND_TTEST2(*tptr, lan_alen)) 2501 goto trunctlv; 2502 ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen))); 2503 tmp -= lan_alen; 2504 tptr +=lan_alen; 2505 } 2506 break; 2507 2508 case ISIS_TLV_PADDING: 2509 break; 2510 2511 case ISIS_TLV_MT_IS_REACH: 2512 mt_len = isis_print_mtid(ndo, tptr, "\n\t "); 2513 if (mt_len == 0) /* did something go wrong ? */ 2514 goto trunctlv; 2515 tptr+=mt_len; 2516 tmp-=mt_len; 2517 while (tmp >= 2+NODE_ID_LEN+3+1) { 2518 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type); 2519 if (ext_is_len == 0) /* did something go wrong ? */ 2520 goto trunctlv; 2521 2522 tmp-=ext_is_len; 2523 tptr+=ext_is_len; 2524 } 2525 break; 2526 2527 case ISIS_TLV_IS_ALIAS_ID: 2528 while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */ 2529 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type); 2530 if (ext_is_len == 0) /* did something go wrong ? */ 2531 goto trunctlv; 2532 tmp-=ext_is_len; 2533 tptr+=ext_is_len; 2534 } 2535 break; 2536 2537 case ISIS_TLV_EXT_IS_REACH: 2538 while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */ 2539 ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type); 2540 if (ext_is_len == 0) /* did something go wrong ? */ 2541 goto trunctlv; 2542 tmp-=ext_is_len; 2543 tptr+=ext_is_len; 2544 } 2545 break; 2546 case ISIS_TLV_IS_REACH: 2547 if (!ND_TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */ 2548 goto trunctlv; 2549 ND_PRINT((ndo, "\n\t %s", 2550 tok2str(isis_is_reach_virtual_values, 2551 "bogus virtual flag 0x%02x", 2552 *tptr++))); 2553 tlv_is_reach = (const struct isis_tlv_is_reach *)tptr; 2554 while (tmp >= sizeof(struct isis_tlv_is_reach)) { 2555 if (!ND_TTEST(*tlv_is_reach)) 2556 goto trunctlv; 2557 ND_PRINT((ndo, "\n\t IS Neighbor: %s", 2558 isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN))); 2559 isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block); 2560 tmp -= sizeof(struct isis_tlv_is_reach); 2561 tlv_is_reach++; 2562 } 2563 break; 2564 2565 case ISIS_TLV_ESNEIGH: 2566 tlv_es_reach = (const struct isis_tlv_es_reach *)tptr; 2567 while (tmp >= sizeof(struct isis_tlv_es_reach)) { 2568 if (!ND_TTEST(*tlv_es_reach)) 2569 goto trunctlv; 2570 ND_PRINT((ndo, "\n\t ES Neighbor: %s", 2571 isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN))); 2572 isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block); 2573 tmp -= sizeof(struct isis_tlv_es_reach); 2574 tlv_es_reach++; 2575 } 2576 break; 2577 2578 /* those two TLVs share the same format */ 2579 case ISIS_TLV_INT_IP_REACH: 2580 case ISIS_TLV_EXT_IP_REACH: 2581 if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len)) 2582 return (1); 2583 break; 2584 2585 case ISIS_TLV_EXTD_IP_REACH: 2586 while (tmp>0) { 2587 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET); 2588 if (ext_ip_len == 0) /* did something go wrong ? */ 2589 goto trunctlv; 2590 tptr+=ext_ip_len; 2591 tmp-=ext_ip_len; 2592 } 2593 break; 2594 2595 case ISIS_TLV_MT_IP_REACH: 2596 mt_len = isis_print_mtid(ndo, tptr, "\n\t "); 2597 if (mt_len == 0) { /* did something go wrong ? */ 2598 goto trunctlv; 2599 } 2600 tptr+=mt_len; 2601 tmp-=mt_len; 2602 2603 while (tmp>0) { 2604 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET); 2605 if (ext_ip_len == 0) /* did something go wrong ? */ 2606 goto trunctlv; 2607 tptr+=ext_ip_len; 2608 tmp-=ext_ip_len; 2609 } 2610 break; 2611 2612 #ifdef INET6 2613 case ISIS_TLV_IP6_REACH: 2614 while (tmp>0) { 2615 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6); 2616 if (ext_ip_len == 0) /* did something go wrong ? */ 2617 goto trunctlv; 2618 tptr+=ext_ip_len; 2619 tmp-=ext_ip_len; 2620 } 2621 break; 2622 2623 case ISIS_TLV_MT_IP6_REACH: 2624 mt_len = isis_print_mtid(ndo, tptr, "\n\t "); 2625 if (mt_len == 0) { /* did something go wrong ? */ 2626 goto trunctlv; 2627 } 2628 tptr+=mt_len; 2629 tmp-=mt_len; 2630 2631 while (tmp>0) { 2632 ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6); 2633 if (ext_ip_len == 0) /* did something go wrong ? */ 2634 goto trunctlv; 2635 tptr+=ext_ip_len; 2636 tmp-=ext_ip_len; 2637 } 2638 break; 2639 2640 case ISIS_TLV_IP6ADDR: 2641 while (tmp>=sizeof(struct in6_addr)) { 2642 if (!ND_TTEST2(*tptr, sizeof(struct in6_addr))) 2643 goto trunctlv; 2644 2645 ND_PRINT((ndo, "\n\t IPv6 interface address: %s", 2646 ip6addr_string(ndo, tptr))); 2647 2648 tptr += sizeof(struct in6_addr); 2649 tmp -= sizeof(struct in6_addr); 2650 } 2651 break; 2652 #endif 2653 case ISIS_TLV_AUTH: 2654 if (!ND_TTEST2(*tptr, 1)) 2655 goto trunctlv; 2656 2657 ND_PRINT((ndo, "\n\t %s: ", 2658 tok2str(isis_subtlv_auth_values, 2659 "unknown Authentication type 0x%02x", 2660 *tptr))); 2661 2662 switch (*tptr) { 2663 case ISIS_SUBTLV_AUTH_SIMPLE: 2664 for(i=1;i<tlv_len;i++) { 2665 if (!ND_TTEST2(*(tptr + i), 1)) 2666 goto trunctlv; 2667 ND_PRINT((ndo, "%c", *(tptr + i))); 2668 } 2669 break; 2670 case ISIS_SUBTLV_AUTH_MD5: 2671 for(i=1;i<tlv_len;i++) { 2672 if (!ND_TTEST2(*(tptr + i), 1)) 2673 goto trunctlv; 2674 ND_PRINT((ndo, "%02x", *(tptr + i))); 2675 } 2676 if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1) 2677 ND_PRINT((ndo, ", (malformed subTLV) ")); 2678 2679 #ifdef HAVE_LIBCRYPTO 2680 sigcheck = signature_verify(ndo, optr, length, 2681 (unsigned char *)tptr + 1); 2682 #else 2683 sigcheck = CANT_CHECK_SIGNATURE; 2684 #endif 2685 ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck))); 2686 2687 break; 2688 case ISIS_SUBTLV_AUTH_GENERIC: 2689 key_id = EXTRACT_16BITS((tptr+1)); 2690 ND_PRINT((ndo, "%u, password: ", key_id)); 2691 for(i=1 + sizeof(uint16_t);i<tlv_len;i++) { 2692 if (!ND_TTEST2(*(tptr + i), 1)) 2693 goto trunctlv; 2694 ND_PRINT((ndo, "%02x", *(tptr + i))); 2695 } 2696 break; 2697 case ISIS_SUBTLV_AUTH_PRIVATE: 2698 default: 2699 if (!print_unknown_data(ndo, tptr + 1, "\n\t\t ", tlv_len - 1)) 2700 return(0); 2701 break; 2702 } 2703 break; 2704 2705 case ISIS_TLV_PTP_ADJ: 2706 tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr; 2707 if(tmp>=1) { 2708 if (!ND_TTEST2(*tptr, 1)) 2709 goto trunctlv; 2710 ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)", 2711 tok2str(isis_ptp_adjancey_values, "unknown", *tptr), 2712 *tptr)); 2713 tmp--; 2714 } 2715 if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) { 2716 if (!ND_TTEST2(tlv_ptp_adj->extd_local_circuit_id, 2717 sizeof(tlv_ptp_adj->extd_local_circuit_id))) 2718 goto trunctlv; 2719 ND_PRINT((ndo, "\n\t Extended Local circuit-ID: 0x%08x", 2720 EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id))); 2721 tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id); 2722 } 2723 if(tmp>=SYSTEM_ID_LEN) { 2724 if (!ND_TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)) 2725 goto trunctlv; 2726 ND_PRINT((ndo, "\n\t Neighbor System-ID: %s", 2727 isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))); 2728 tmp-=SYSTEM_ID_LEN; 2729 } 2730 if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) { 2731 if (!ND_TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id, 2732 sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id))) 2733 goto trunctlv; 2734 ND_PRINT((ndo, "\n\t Neighbor Extended Local circuit-ID: 0x%08x", 2735 EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id))); 2736 } 2737 break; 2738 2739 case ISIS_TLV_PROTOCOLS: 2740 ND_PRINT((ndo, "\n\t NLPID(s): ")); 2741 while (tmp>0) { 2742 if (!ND_TTEST2(*(tptr), 1)) 2743 goto trunctlv; 2744 ND_PRINT((ndo, "%s (0x%02x)", 2745 tok2str(nlpid_values, 2746 "unknown", 2747 *tptr), 2748 *tptr)); 2749 if (tmp>1) /* further NPLIDs ? - put comma */ 2750 ND_PRINT((ndo, ", ")); 2751 tptr++; 2752 tmp--; 2753 } 2754 break; 2755 2756 case ISIS_TLV_MT_PORT_CAP: 2757 { 2758 if (!ND_TTEST2(*(tptr), 2)) 2759 goto trunctlv; 2760 2761 ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d", 2762 (EXTRACT_16BITS (tptr) >> 12), 2763 (EXTRACT_16BITS (tptr) & 0x0fff))); 2764 2765 tmp = tmp-2; 2766 tptr = tptr+2; 2767 2768 if (tmp) 2769 isis_print_mt_port_cap_subtlv(ndo, tptr, tmp); 2770 2771 break; 2772 } 2773 2774 case ISIS_TLV_MT_CAPABILITY: 2775 2776 if (!ND_TTEST2(*(tptr), 2)) 2777 goto trunctlv; 2778 2779 ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d", 2780 (EXTRACT_16BITS(tptr) >> 15) & 0x01, 2781 (EXTRACT_16BITS(tptr) >> 12) & 0x07, 2782 EXTRACT_16BITS(tptr) & 0x0fff)); 2783 2784 tmp = tmp-2; 2785 tptr = tptr+2; 2786 2787 if (tmp) 2788 isis_print_mt_capability_subtlv(ndo, tptr, tmp); 2789 2790 break; 2791 2792 case ISIS_TLV_TE_ROUTER_ID: 2793 if (!ND_TTEST2(*pptr, sizeof(struct in_addr))) 2794 goto trunctlv; 2795 ND_PRINT((ndo, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr))); 2796 break; 2797 2798 case ISIS_TLV_IPADDR: 2799 while (tmp>=sizeof(struct in_addr)) { 2800 if (!ND_TTEST2(*tptr, sizeof(struct in_addr))) 2801 goto trunctlv; 2802 ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr))); 2803 tptr += sizeof(struct in_addr); 2804 tmp -= sizeof(struct in_addr); 2805 } 2806 break; 2807 2808 case ISIS_TLV_HOSTNAME: 2809 ND_PRINT((ndo, "\n\t Hostname: ")); 2810 while (tmp>0) { 2811 if (!ND_TTEST2(*tptr, 1)) 2812 goto trunctlv; 2813 ND_PRINT((ndo, "%c", *tptr++)); 2814 tmp--; 2815 } 2816 break; 2817 2818 case ISIS_TLV_SHARED_RISK_GROUP: 2819 if (tmp < NODE_ID_LEN) 2820 break; 2821 if (!ND_TTEST2(*tptr, NODE_ID_LEN)) 2822 goto trunctlv; 2823 ND_PRINT((ndo, "\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN))); 2824 tptr+=(NODE_ID_LEN); 2825 tmp-=(NODE_ID_LEN); 2826 2827 if (tmp < 1) 2828 break; 2829 if (!ND_TTEST2(*tptr, 1)) 2830 goto trunctlv; 2831 ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered")); 2832 tmp--; 2833 2834 if (tmp < sizeof(struct in_addr)) 2835 break; 2836 if (!ND_TTEST2(*tptr, sizeof(struct in_addr))) 2837 goto trunctlv; 2838 ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr))); 2839 tptr+=sizeof(struct in_addr); 2840 tmp-=sizeof(struct in_addr); 2841 2842 if (tmp < sizeof(struct in_addr)) 2843 break; 2844 if (!ND_TTEST2(*tptr, sizeof(struct in_addr))) 2845 goto trunctlv; 2846 ND_PRINT((ndo, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo, tptr))); 2847 tptr+=sizeof(struct in_addr); 2848 tmp-=sizeof(struct in_addr); 2849 2850 while (tmp>=4) { 2851 if (!ND_TTEST2(*tptr, 4)) 2852 goto trunctlv; 2853 ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr))); 2854 tptr+=4; 2855 tmp-=4; 2856 } 2857 break; 2858 2859 case ISIS_TLV_LSP: 2860 tlv_lsp = (const struct isis_tlv_lsp *)tptr; 2861 while(tmp>=sizeof(struct isis_tlv_lsp)) { 2862 if (!ND_TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1])) 2863 goto trunctlv; 2864 ND_PRINT((ndo, "\n\t lsp-id: %s", 2865 isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN))); 2866 if (!ND_TTEST2(tlv_lsp->sequence_number, 4)) 2867 goto trunctlv; 2868 ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number))); 2869 if (!ND_TTEST2(tlv_lsp->remaining_lifetime, 2)) 2870 goto trunctlv; 2871 ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime))); 2872 if (!ND_TTEST2(tlv_lsp->checksum, 2)) 2873 goto trunctlv; 2874 ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum))); 2875 tmp-=sizeof(struct isis_tlv_lsp); 2876 tlv_lsp++; 2877 } 2878 break; 2879 2880 case ISIS_TLV_CHECKSUM: 2881 if (tmp < ISIS_TLV_CHECKSUM_MINLEN) 2882 break; 2883 if (!ND_TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN)) 2884 goto trunctlv; 2885 ND_PRINT((ndo, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr))); 2886 /* do not attempt to verify the checksum if it is zero 2887 * most likely a HMAC-MD5 TLV is also present and 2888 * to avoid conflicts the checksum TLV is zeroed. 2889 * see rfc3358 for details 2890 */ 2891 osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr, length); 2892 break; 2893 2894 case ISIS_TLV_MT_SUPPORTED: 2895 if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) 2896 break; 2897 while (tmp>1) { 2898 /* length can only be a multiple of 2, otherwise there is 2899 something broken -> so decode down until length is 1 */ 2900 if (tmp!=1) { 2901 mt_len = isis_print_mtid(ndo, tptr, "\n\t "); 2902 if (mt_len == 0) /* did something go wrong ? */ 2903 goto trunctlv; 2904 tptr+=mt_len; 2905 tmp-=mt_len; 2906 } else { 2907 ND_PRINT((ndo, "\n\t malformed MT-ID")); 2908 break; 2909 } 2910 } 2911 break; 2912 2913 case ISIS_TLV_RESTART_SIGNALING: 2914 /* first attempt to decode the flags */ 2915 if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN) 2916 break; 2917 if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN)) 2918 goto trunctlv; 2919 ND_PRINT((ndo, "\n\t Flags [%s]", 2920 bittok2str(isis_restart_flag_values, "none", *tptr))); 2921 tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; 2922 tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; 2923 2924 /* is there anything other than the flags field? */ 2925 if (tmp == 0) 2926 break; 2927 2928 if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) 2929 break; 2930 if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)) 2931 goto trunctlv; 2932 2933 ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr))); 2934 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; 2935 tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; 2936 2937 /* is there an additional sysid field present ?*/ 2938 if (tmp == SYSTEM_ID_LEN) { 2939 if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN)) 2940 goto trunctlv; 2941 ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN))); 2942 } 2943 break; 2944 2945 case ISIS_TLV_IDRP_INFO: 2946 if (tmp < ISIS_TLV_IDRP_INFO_MINLEN) 2947 break; 2948 if (!ND_TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN)) 2949 goto trunctlv; 2950 ND_PRINT((ndo, "\n\t Inter-Domain Information Type: %s", 2951 tok2str(isis_subtlv_idrp_values, 2952 "Unknown (0x%02x)", 2953 *tptr))); 2954 switch (*tptr++) { 2955 case ISIS_SUBTLV_IDRP_ASN: 2956 if (!ND_TTEST2(*tptr, 2)) /* fetch AS number */ 2957 goto trunctlv; 2958 ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr))); 2959 break; 2960 case ISIS_SUBTLV_IDRP_LOCAL: 2961 case ISIS_SUBTLV_IDRP_RES: 2962 default: 2963 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_len - 1)) 2964 return(0); 2965 break; 2966 } 2967 break; 2968 2969 case ISIS_TLV_LSP_BUFFERSIZE: 2970 if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN) 2971 break; 2972 if (!ND_TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN)) 2973 goto trunctlv; 2974 ND_PRINT((ndo, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr))); 2975 break; 2976 2977 case ISIS_TLV_PART_DIS: 2978 while (tmp >= SYSTEM_ID_LEN) { 2979 if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN)) 2980 goto trunctlv; 2981 ND_PRINT((ndo, "\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN))); 2982 tptr+=SYSTEM_ID_LEN; 2983 tmp-=SYSTEM_ID_LEN; 2984 } 2985 break; 2986 2987 case ISIS_TLV_PREFIX_NEIGH: 2988 if (tmp < sizeof(struct isis_metric_block)) 2989 break; 2990 if (!ND_TTEST2(*tptr, sizeof(struct isis_metric_block))) 2991 goto trunctlv; 2992 ND_PRINT((ndo, "\n\t Metric Block")); 2993 isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr); 2994 tptr+=sizeof(struct isis_metric_block); 2995 tmp-=sizeof(struct isis_metric_block); 2996 2997 while(tmp>0) { 2998 if (!ND_TTEST2(*tptr, 1)) 2999 goto trunctlv; 3000 prefix_len=*tptr++; /* read out prefix length in semioctets*/ 3001 if (prefix_len < 2) { 3002 ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len)); 3003 break; 3004 } 3005 tmp--; 3006 if (tmp < prefix_len/2) 3007 break; 3008 if (!ND_TTEST2(*tptr, prefix_len / 2)) 3009 goto trunctlv; 3010 ND_PRINT((ndo, "\n\t\tAddress: %s/%u", 3011 isonsap_string(tptr, prefix_len / 2), prefix_len * 4)); 3012 tptr+=prefix_len/2; 3013 tmp-=prefix_len/2; 3014 } 3015 break; 3016 3017 case ISIS_TLV_IIH_SEQNR: 3018 if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN) 3019 break; 3020 if (!ND_TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */ 3021 goto trunctlv; 3022 ND_PRINT((ndo, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr))); 3023 break; 3024 3025 case ISIS_TLV_VENDOR_PRIVATE: 3026 if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN) 3027 break; 3028 if (!ND_TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */ 3029 goto trunctlv; 3030 vendor_id = EXTRACT_24BITS(tptr); 3031 ND_PRINT((ndo, "\n\t Vendor: %s (%u)", 3032 tok2str(oui_values, "Unknown", vendor_id), 3033 vendor_id)); 3034 tptr+=3; 3035 tmp-=3; 3036 if (tmp > 0) /* hexdump the rest */ 3037 if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp)) 3038 return(0); 3039 break; 3040 /* 3041 * FIXME those are the defined TLVs that lack a decoder 3042 * you are welcome to contribute code ;-) 3043 */ 3044 3045 case ISIS_TLV_DECNET_PHASE4: 3046 case ISIS_TLV_LUCENT_PRIVATE: 3047 case ISIS_TLV_IPAUTH: 3048 case ISIS_TLV_NORTEL_PRIVATE1: 3049 case ISIS_TLV_NORTEL_PRIVATE2: 3050 3051 default: 3052 if (ndo->ndo_vflag <= 1) { 3053 if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len)) 3054 return(0); 3055 } 3056 break; 3057 } 3058 /* do we want to see an additionally hexdump ? */ 3059 if (ndo->ndo_vflag> 1) { 3060 if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len)) 3061 return(0); 3062 } 3063 3064 pptr += tlv_len; 3065 packet_len -= tlv_len; 3066 } 3067 3068 if (packet_len != 0) { 3069 ND_PRINT((ndo, "\n\t %u straggler bytes", packet_len)); 3070 } 3071 return (1); 3072 3073 trunc: 3074 ND_PRINT((ndo, "[|isis]")); 3075 return (1); 3076 3077 trunctlv: 3078 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); 3079 return(1); 3080 } 3081 3082 static void 3083 osi_print_cksum(netdissect_options *ndo, 3084 const uint8_t *pptr, uint16_t checksum, 3085 u_int checksum_offset, u_int length) 3086 { 3087 uint16_t calculated_checksum; 3088 3089 /* do not attempt to verify the checksum if it is zero */ 3090 if (!checksum) { 3091 ND_PRINT((ndo, "(unverified)")); 3092 } else { 3093 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length); 3094 if (checksum == calculated_checksum) { 3095 ND_PRINT((ndo, " (correct)")); 3096 } else { 3097 ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum)); 3098 } 3099 } 3100 } 3101 3102 /* 3103 * Local Variables: 3104 * c-style: whitesmith 3105 * c-basic-offset: 8 3106 * End: 3107 */ 3108