print-isoclns.c (172686) | print-isoclns.c (190207) |
---|---|
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 unchanged lines hidden (view full) --- 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 * | 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 unchanged lines hidden (view full) --- 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: head/contrib/tcpdump/print-isoclns.c 172686 2007-10-16 02:31:48Z mlaier $ | 26 * $FreeBSD: head/contrib/tcpdump/print-isoclns.c 190207 2009-03-21 18:30:25Z rpaulo $ |
27 */ 28 29#ifndef lint 30static const char rcsid[] _U_ = | 27 */ 28 29#ifndef lint 30static const char rcsid[] _U_ = |
31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.25 2007/03/02 09:20:27 hannes Exp $ (LBL)"; | 31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.163 2007-03-02 09:16:19 hannes Exp $ (LBL)"; |
32#endif 33 34#ifdef HAVE_CONFIG_H 35#include "config.h" 36#endif 37 38#include <tcpdump-stdinc.h> 39 --- 4 unchanged lines hidden (view full) --- 44#include "addrtoname.h" 45#include "ethertype.h" 46#include "ether.h" 47#include "nlpid.h" 48#include "extract.h" 49#include "gmpls.h" 50#include "oui.h" 51 | 32#endif 33 34#ifdef HAVE_CONFIG_H 35#include "config.h" 36#endif 37 38#include <tcpdump-stdinc.h> 39 --- 4 unchanged lines hidden (view full) --- 44#include "addrtoname.h" 45#include "ethertype.h" 46#include "ether.h" 47#include "nlpid.h" 48#include "extract.h" 49#include "gmpls.h" 50#include "oui.h" 51 |
52#define IPV4 1 /* AFI value */ 53#define IPV6 2 /* AFI value */ 54 | |
55/* 56 * IS-IS is defined in ISO 10589. Look there for protocol definitions. 57 */ 58 59#define SYSTEM_ID_LEN ETHER_ADDR_LEN 60#define NODE_ID_LEN SYSTEM_ID_LEN+1 61#define LSP_ID_LEN SYSTEM_ID_LEN+2 62 --- 272 unchanged lines hidden (view full) --- 335 { 0x08, "congested"}, 336 { 0x04, "delay vs. cost"}, 337 { 0x02, "error vs. delay"}, 338 { 0x01, "error vs. cost"}, 339 { 0, NULL } 340}; 341 342#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */ | 52/* 53 * IS-IS is defined in ISO 10589. Look there for protocol definitions. 54 */ 55 56#define SYSTEM_ID_LEN ETHER_ADDR_LEN 57#define NODE_ID_LEN SYSTEM_ID_LEN+1 58#define LSP_ID_LEN SYSTEM_ID_LEN+2 59 --- 272 unchanged lines hidden (view full) --- 332 { 0x08, "congested"}, 333 { 0x04, "delay vs. cost"}, 334 { 0x02, "error vs. delay"}, 335 { 0x01, "error vs. cost"}, 336 { 0, NULL } 337}; 338 339#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */ |
343#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */ | 340#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */ |
344#define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */ 345#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */ 346#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */ 347#define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */ 348#define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */ 349#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */ 350#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */ 351#define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */ | 341#define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */ 342#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */ 343#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */ 344#define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */ 345#define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */ 346#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */ 347#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */ 348#define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */ |
352#define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */ 353#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */ | 349#define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */ 350#define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */ 351#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */ |
354#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */ 355 356static struct tok isis_ext_is_reach_subtlv_values[] = { 357 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" }, 358 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, 359 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" }, 360 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" }, 361 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" }, 362 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" }, 363 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" }, 364 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" }, 365 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" }, | 352#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */ 353 354static struct tok isis_ext_is_reach_subtlv_values[] = { 355 { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" }, 356 { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, 357 { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" }, 358 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" }, 359 { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" }, 360 { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" }, 361 { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" }, 362 { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" }, 363 { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" }, |
364 { 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 { 250, "Reserved for cisco specific extensions" }, 371 { 251, "Reserved for cisco specific extensions" }, 372 { 252, "Reserved for cisco specific extensions" }, 373 { 253, "Reserved for cisco specific extensions" }, --- 8 unchanged lines hidden (view full) --- 382 383static struct tok isis_ext_ip_reach_subtlv_values[] = { 384 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" }, 385 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" }, 386 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" }, 387 { 0, NULL } 388}; 389 | 365 { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" }, 366 { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" }, 367 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" }, 368 { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" }, 369 { 250, "Reserved for cisco specific extensions" }, 370 { 251, "Reserved for cisco specific extensions" }, 371 { 252, "Reserved for cisco specific extensions" }, 372 { 253, "Reserved for cisco specific extensions" }, --- 8 unchanged lines hidden (view full) --- 381 382static struct tok isis_ext_ip_reach_subtlv_values[] = { 383 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" }, 384 { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" }, 385 { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" }, 386 { 0, NULL } 387}; 388 |
389static struct tok isis_subtlv_link_attribute_values[] = { 390 { 0x01, "Local Protection Available" }, 391 { 0x02, "Link excluded from local protection path" }, 392 { 0x04, "Local maintenance required"}, 393 { 0, NULL } 394}; 395 |
|
390#define ISIS_SUBTLV_AUTH_SIMPLE 1 391#define ISIS_SUBTLV_AUTH_MD5 54 392#define ISIS_SUBTLV_AUTH_MD5_LEN 16 393#define ISIS_SUBTLV_AUTH_PRIVATE 255 394 395static struct tok isis_subtlv_auth_values[] = { 396 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"}, 397 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"}, --- 101 unchanged lines hidden (view full) --- 499 500struct isis_tlv_ptp_adj { 501 u_int8_t adjacency_state; 502 u_int8_t extd_local_circuit_id[4]; 503 u_int8_t neighbor_sysid[SYSTEM_ID_LEN]; 504 u_int8_t neighbor_extd_local_circuit_id[4]; 505}; 506 | 396#define ISIS_SUBTLV_AUTH_SIMPLE 1 397#define ISIS_SUBTLV_AUTH_MD5 54 398#define ISIS_SUBTLV_AUTH_MD5_LEN 16 399#define ISIS_SUBTLV_AUTH_PRIVATE 255 400 401static struct tok isis_subtlv_auth_values[] = { 402 { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"}, 403 { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"}, --- 101 unchanged lines hidden (view full) --- 505 506struct isis_tlv_ptp_adj { 507 u_int8_t adjacency_state; 508 u_int8_t extd_local_circuit_id[4]; 509 u_int8_t neighbor_sysid[SYSTEM_ID_LEN]; 510 u_int8_t neighbor_extd_local_circuit_id[4]; 511}; 512 |
507static int osi_cksum(const u_int8_t *, u_int); | 513static void osi_print_cksum(const u_int8_t *pptr, u_int16_t checksum, 514 u_int checksum_offset, u_int length); |
508static int clnp_print(const u_int8_t *, u_int); 509static void esis_print(const u_int8_t *, u_int); 510static int isis_print(const u_int8_t *, u_int); 511 512struct isis_metric_block { 513 u_int8_t metric_default; 514 u_int8_t metric_delay; 515 u_int8_t metric_expense; --- 246 unchanged lines hidden (view full) --- 762 isonsap_string(source_address, source_address_length), 763 isonsap_string(dest_address, dest_address_length), 764 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type), 765 length); 766 return (1); 767 } 768 printf("%slength %u",eflag ? "" : ", ",length); 769 | 515static int clnp_print(const u_int8_t *, u_int); 516static void esis_print(const u_int8_t *, u_int); 517static int isis_print(const u_int8_t *, u_int); 518 519struct isis_metric_block { 520 u_int8_t metric_default; 521 u_int8_t metric_delay; 522 u_int8_t metric_expense; --- 246 unchanged lines hidden (view full) --- 769 isonsap_string(source_address, source_address_length), 770 isonsap_string(dest_address, dest_address_length), 771 tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type), 772 length); 773 return (1); 774 } 775 printf("%slength %u",eflag ? "" : ", ",length); 776 |
770 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ", | 777 printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x", |
771 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type), 772 clnp_header->length_indicator, 773 clnp_header->version, 774 clnp_header->lifetime/2, 775 (clnp_header->lifetime%2)*5, 776 EXTRACT_16BITS(clnp_header->segment_length), 777 EXTRACT_16BITS(clnp_header->cksum)); 778 | 778 tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type), 779 clnp_header->length_indicator, 780 clnp_header->version, 781 clnp_header->lifetime/2, 782 (clnp_header->lifetime%2)*5, 783 EXTRACT_16BITS(clnp_header->segment_length), 784 EXTRACT_16BITS(clnp_header->cksum)); 785 |
779 /* do not attempt to verify the checksum if it is zero */ 780 if (EXTRACT_16BITS(clnp_header->cksum) == 0) 781 printf("(unverified)"); 782 else printf("(%s)", osi_cksum(optr, clnp_header->length_indicator) ? "incorrect" : "correct"); | 786 osi_print_cksum(optr, EXTRACT_16BITS(clnp_header->cksum), 7, 787 clnp_header->length_indicator); |
783 784 printf("\n\tFlags [%s]", 785 bittok2str(clnp_flag_values,"none",clnp_flags)); 786 787 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s", 788 source_address_length, 789 isonsap_string(source_address, source_address_length), 790 dest_address_length, --- 237 unchanged lines hidden (view full) --- 1028 } else 1029 printf("%slength %u\n\t%s (%u)", 1030 eflag ? "" : ", ", 1031 length, 1032 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type), 1033 esis_pdu_type); 1034 1035 printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ); | 788 789 printf("\n\tFlags [%s]", 790 bittok2str(clnp_flag_values,"none",clnp_flags)); 791 792 printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s", 793 source_address_length, 794 isonsap_string(source_address, source_address_length), 795 dest_address_length, --- 237 unchanged lines hidden (view full) --- 1033 } else 1034 printf("%slength %u\n\t%s (%u)", 1035 eflag ? "" : ", ", 1036 length, 1037 tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type), 1038 esis_pdu_type); 1039 1040 printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ); |
1036 printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header->cksum)); 1037 /* do not attempt to verify the checksum if it is zero */ 1038 if (EXTRACT_16BITS(esis_header->cksum) == 0) 1039 printf("(unverified)"); 1040 else 1041 printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct"); | 1041 printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)); |
1042 | 1042 |
1043 osi_print_cksum(pptr, EXTRACT_16BITS(esis_header->cksum), 7, li); 1044 |
|
1043 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li); 1044 1045 if (vflag > 1) 1046 print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t)); 1047 1048 pptr += sizeof(struct esis_header_t); 1049 li -= sizeof(struct esis_header_t); 1050 --- 357 unchanged lines hidden (view full) --- 1408/* 1409 * this is the common IS-REACH subTLV decoder it is called 1410 * from isis_print_ext_is_reach() 1411 */ 1412 1413static int 1414isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) { 1415 | 1045 printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li); 1046 1047 if (vflag > 1) 1048 print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t)); 1049 1050 pptr += sizeof(struct esis_header_t); 1051 li -= sizeof(struct esis_header_t); 1052 --- 357 unchanged lines hidden (view full) --- 1410/* 1411 * this is the common IS-REACH subTLV decoder it is called 1412 * from isis_print_ext_is_reach() 1413 */ 1414 1415static int 1416isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) { 1417 |
1416 u_int te_class,priority_level; | 1418 u_int te_class,priority_level,gmpls_switch_cap; |
1417 union { /* int to float conversion buffer for several subTLVs */ 1418 float f; 1419 u_int32_t i; 1420 } bw; 1421 1422 /* first lets see if we know the subTLVs name*/ 1423 printf("%s%s subTLV #%u, length: %u", 1424 ident, --- 7 unchanged lines hidden (view full) --- 1432 goto trunctlv; 1433 1434 switch(subt) { 1435 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP: 1436 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID: 1437 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID: 1438 if (subl >= 4) { 1439 printf(", 0x%08x", EXTRACT_32BITS(tptr)); | 1419 union { /* int to float conversion buffer for several subTLVs */ 1420 float f; 1421 u_int32_t i; 1422 } bw; 1423 1424 /* first lets see if we know the subTLVs name*/ 1425 printf("%s%s subTLV #%u, length: %u", 1426 ident, --- 7 unchanged lines hidden (view full) --- 1434 goto trunctlv; 1435 1436 switch(subt) { 1437 case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP: 1438 case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID: 1439 case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID: 1440 if (subl >= 4) { 1441 printf(", 0x%08x", EXTRACT_32BITS(tptr)); |
1440 if (subl == 8) /* draft-ietf-isis-gmpls-extensions */ | 1442 if (subl == 8) /* rfc4205 */ |
1441 printf(", 0x%08x", EXTRACT_32BITS(tptr+4)); 1442 } 1443 break; 1444 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: 1445 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: 1446 if (subl >= sizeof(struct in_addr)) 1447 printf(", %s", ipaddr_string(tptr)); 1448 break; --- 32 unchanged lines hidden (view full) --- 1481 bw.f*8/1000000 ); 1482 tptr+=4; 1483 } 1484 break; 1485 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC: 1486 if (subl >= 3) 1487 printf(", %u", EXTRACT_24BITS(tptr)); 1488 break; | 1443 printf(", 0x%08x", EXTRACT_32BITS(tptr+4)); 1444 } 1445 break; 1446 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: 1447 case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: 1448 if (subl >= sizeof(struct in_addr)) 1449 printf(", %s", ipaddr_string(tptr)); 1450 break; --- 32 unchanged lines hidden (view full) --- 1483 bw.f*8/1000000 ); 1484 tptr+=4; 1485 } 1486 break; 1487 case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC: 1488 if (subl >= 3) 1489 printf(", %u", EXTRACT_24BITS(tptr)); 1490 break; |
1491 case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE: 1492 if (subl == 2) { 1493 printf(", [ %s ] (0x%04x)", 1494 bittok2str(isis_subtlv_link_attribute_values, 1495 "Unknown", 1496 EXTRACT_16BITS(tptr)), 1497 EXTRACT_16BITS(tptr)); 1498 } 1499 break; |
|
1489 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE: 1490 if (subl >= 2) { 1491 printf(", %s, Priority %u", 1492 bittok2str(gmpls_link_prot_values, "none", *tptr), 1493 *(tptr+1)); 1494 } 1495 break; 1496 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR: 1497 if (subl >= 36) { | 1500 case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE: 1501 if (subl >= 2) { 1502 printf(", %s, Priority %u", 1503 bittok2str(gmpls_link_prot_values, "none", *tptr), 1504 *(tptr+1)); 1505 } 1506 break; 1507 case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR: 1508 if (subl >= 36) { |
1509 gmpls_switch_cap = *tptr; |
|
1498 printf("%s Interface Switching Capability:%s", 1499 ident, | 1510 printf("%s Interface Switching Capability:%s", 1511 ident, |
1500 tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))); | 1512 tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)); |
1501 printf(", LSP Encoding: %s", 1502 tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); 1503 tptr+=4; 1504 printf("%s Max LSP Bandwidth:",ident); 1505 for (priority_level = 0; priority_level < 8; priority_level++) { 1506 bw.i = EXTRACT_32BITS(tptr); 1507 printf("%s priority level %d: %.3f Mbps", 1508 ident, 1509 priority_level, 1510 bw.f*8/1000000 ); 1511 tptr+=4; 1512 } 1513 subl-=36; | 1513 printf(", LSP Encoding: %s", 1514 tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); 1515 tptr+=4; 1516 printf("%s Max LSP Bandwidth:",ident); 1517 for (priority_level = 0; priority_level < 8; priority_level++) { 1518 bw.i = EXTRACT_32BITS(tptr); 1519 printf("%s priority level %d: %.3f Mbps", 1520 ident, 1521 priority_level, 1522 bw.f*8/1000000 ); 1523 tptr+=4; 1524 } 1525 subl-=36; |
1514 /* there is some optional stuff left to decode but this is as of yet 1515 not specified so just lets hexdump what is left */ 1516 if(subl>0){ 1517 if(!print_unknown_data(tptr,"\n\t\t ", 1518 subl)) | 1526 switch (gmpls_switch_cap) { 1527 case GMPLS_PSC1: 1528 case GMPLS_PSC2: 1529 case GMPLS_PSC3: 1530 case GMPLS_PSC4: 1531 bw.i = EXTRACT_32BITS(tptr); 1532 printf("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000); 1533 printf("%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr+4)); 1534 break; 1535 case GMPLS_TSC: 1536 bw.i = EXTRACT_32BITS(tptr); 1537 printf("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000); 1538 printf("%s Indication %s", ident, 1539 tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr+4))); 1540 break; 1541 default: 1542 /* there is some optional stuff left to decode but this is as of yet 1543 not specified so just lets hexdump what is left */ 1544 if(subl>0){ 1545 if(!print_unknown_data(tptr,"\n\t\t ", 1546 subl)) |
1519 return(0); | 1547 return(0); |
1548 } |
|
1520 } 1521 } 1522 break; 1523 default: 1524 if(!print_unknown_data(tptr,"\n\t\t ", 1525 subl)) 1526 return(0); 1527 break; --- 98 unchanged lines hidden (view full) --- 1626 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; 1627 1628 if (!TTEST2(*tptr, 4)) 1629 return (0); 1630 metric = EXTRACT_32BITS(tptr); 1631 processed=4; 1632 tptr+=4; 1633 | 1549 } 1550 } 1551 break; 1552 default: 1553 if(!print_unknown_data(tptr,"\n\t\t ", 1554 subl)) 1555 return(0); 1556 break; --- 98 unchanged lines hidden (view full) --- 1655 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; 1656 1657 if (!TTEST2(*tptr, 4)) 1658 return (0); 1659 metric = EXTRACT_32BITS(tptr); 1660 processed=4; 1661 tptr+=4; 1662 |
1634 if (afi == IPV4) { | 1663 if (afi == AF_INET) { |
1635 if (!TTEST2(*tptr, 1)) /* fetch status byte */ 1636 return (0); 1637 status_byte=*(tptr++); 1638 bit_length = status_byte&0x3f; 1639 if (bit_length > 32) { 1640 printf("%sIPv4 prefix: bad bit length %u", 1641 ident, 1642 bit_length); 1643 return (0); 1644 } 1645 processed++; 1646#ifdef INET6 | 1664 if (!TTEST2(*tptr, 1)) /* fetch status byte */ 1665 return (0); 1666 status_byte=*(tptr++); 1667 bit_length = status_byte&0x3f; 1668 if (bit_length > 32) { 1669 printf("%sIPv4 prefix: bad bit length %u", 1670 ident, 1671 bit_length); 1672 return (0); 1673 } 1674 processed++; 1675#ifdef INET6 |
1647 } else if (afi == IPV6) { | 1676 } else if (afi == AF_INET6) { |
1648 if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */ 1649 return (0); 1650 status_byte=*(tptr++); 1651 bit_length=*(tptr++); 1652 if (bit_length > 128) { 1653 printf("%sIPv6 prefix: bad bit length %u", 1654 ident, 1655 bit_length); --- 8 unchanged lines hidden (view full) --- 1664 1665 if (!TTEST2(*tptr, byte_length)) 1666 return (0); 1667 memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ 1668 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ 1669 tptr+=byte_length; 1670 processed+=byte_length; 1671 | 1677 if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */ 1678 return (0); 1679 status_byte=*(tptr++); 1680 bit_length=*(tptr++); 1681 if (bit_length > 128) { 1682 printf("%sIPv6 prefix: bad bit length %u", 1683 ident, 1684 bit_length); --- 8 unchanged lines hidden (view full) --- 1693 1694 if (!TTEST2(*tptr, byte_length)) 1695 return (0); 1696 memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ 1697 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ 1698 tptr+=byte_length; 1699 processed+=byte_length; 1700 |
1672 if (afi == IPV4) | 1701 if (afi == AF_INET) |
1673 printf("%sIPv4 prefix: %15s/%u", 1674 ident, 1675 ipaddr_string(prefix), 1676 bit_length); 1677#ifdef INET6 | 1702 printf("%sIPv4 prefix: %15s/%u", 1703 ident, 1704 ipaddr_string(prefix), 1705 bit_length); 1706#ifdef INET6 |
1678 if (afi == IPV6) | 1707 if (afi == AF_INET6) |
1679 printf("%sIPv6 prefix: %s/%u", 1680 ident, 1681 ip6addr_string(prefix), 1682 bit_length); 1683#endif 1684 1685 printf(", Distribution: %s, Metric: %u", 1686 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up", 1687 metric); 1688 | 1708 printf("%sIPv6 prefix: %s/%u", 1709 ident, 1710 ip6addr_string(prefix), 1711 bit_length); 1712#endif 1713 1714 printf(", Distribution: %s, Metric: %u", 1715 ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up", 1716 metric); 1717 |
1689 if (afi == IPV4 && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) | 1718 if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) |
1690 printf(", sub-TLVs present"); 1691#ifdef INET6 | 1719 printf(", sub-TLVs present"); 1720#ifdef INET6 |
1692 if (afi == IPV6) | 1721 if (afi == AF_INET6) |
1693 printf(", %s%s", 1694 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal", 1695 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""); 1696#endif 1697 | 1722 printf(", %s%s", 1723 ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal", 1724 ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""); 1725#endif 1726 |
1698 if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte) && afi == IPV4) || 1699 (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == IPV6)) { | 1727 if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) 1728#ifdef INET6 1729 || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte)) 1730#endif 1731 ) { |
1700 /* assume that one prefix can hold more 1701 than one subTLV - therefore the first byte must reflect 1702 the aggregate bytecount of the subTLVs for this prefix 1703 */ 1704 if (!TTEST2(*tptr, 1)) 1705 return (0); 1706 sublen=*(tptr++); 1707 processed+=sublen+1; --- 266 unchanged lines hidden (view full) --- 1974 1975 TCHECK(*header_lsp); 1976 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x", 1977 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), 1978 EXTRACT_32BITS(header_lsp->sequence_number), 1979 EXTRACT_16BITS(header_lsp->remaining_lifetime), 1980 EXTRACT_16BITS(header_lsp->checksum)); 1981 | 1732 /* assume that one prefix can hold more 1733 than one subTLV - therefore the first byte must reflect 1734 the aggregate bytecount of the subTLVs for this prefix 1735 */ 1736 if (!TTEST2(*tptr, 1)) 1737 return (0); 1738 sublen=*(tptr++); 1739 processed+=sublen+1; --- 266 unchanged lines hidden (view full) --- 2006 2007 TCHECK(*header_lsp); 2008 printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x", 2009 isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), 2010 EXTRACT_32BITS(header_lsp->sequence_number), 2011 EXTRACT_16BITS(header_lsp->remaining_lifetime), 2012 EXTRACT_16BITS(header_lsp->checksum)); 2013 |
1982 /* if this is a purge do not attempt to verify the checksum */ 1983 if ( EXTRACT_16BITS(header_lsp->remaining_lifetime) == 0 && 1984 EXTRACT_16BITS(header_lsp->checksum) == 0) 1985 printf(" (purged)"); 1986 else 1987 /* verify the checksum - 1988 * checking starts at the lsp-id field at byte position [12] 1989 * hence the length needs to be reduced by 12 bytes */ 1990 printf(" (%s)", (osi_cksum((u_int8_t *)header_lsp->lsp_id, length-12)) ? "incorrect" : "correct"); | |
1991 | 2014 |
2015 osi_print_cksum((u_int8_t *)header_lsp->lsp_id, 2016 EXTRACT_16BITS(header_lsp->checksum), 12, length-12); 2017 |
|
1992 printf(", PDU length: %u, Flags: [ %s", 1993 pdu_len, 1994 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""); 1995 1996 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { 1997 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""); 1998 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""); 1999 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""); --- 235 unchanged lines hidden (view full) --- 2235 case ISIS_TLV_INT_IP_REACH: 2236 case ISIS_TLV_EXT_IP_REACH: 2237 if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len)) 2238 return (1); 2239 break; 2240 2241 case ISIS_TLV_EXTD_IP_REACH: 2242 while (tmp>0) { | 2018 printf(", PDU length: %u, Flags: [ %s", 2019 pdu_len, 2020 ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""); 2021 2022 if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { 2023 printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""); 2024 printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""); 2025 printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""); --- 235 unchanged lines hidden (view full) --- 2261 case ISIS_TLV_INT_IP_REACH: 2262 case ISIS_TLV_EXT_IP_REACH: 2263 if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len)) 2264 return (1); 2265 break; 2266 2267 case ISIS_TLV_EXTD_IP_REACH: 2268 while (tmp>0) { |
2243 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); | 2269 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET); |
2244 if (ext_ip_len == 0) /* did something go wrong ? */ 2245 goto trunctlv; 2246 tptr+=ext_ip_len; 2247 tmp-=ext_ip_len; 2248 } 2249 break; 2250 2251 case ISIS_TLV_MT_IP_REACH: 2252 mt_len = isis_print_mtid(tptr, "\n\t "); 2253 if (mt_len == 0) { /* did something go wrong ? */ 2254 goto trunctlv; 2255 } 2256 tptr+=mt_len; 2257 tmp-=mt_len; 2258 2259 while (tmp>0) { | 2270 if (ext_ip_len == 0) /* did something go wrong ? */ 2271 goto trunctlv; 2272 tptr+=ext_ip_len; 2273 tmp-=ext_ip_len; 2274 } 2275 break; 2276 2277 case ISIS_TLV_MT_IP_REACH: 2278 mt_len = isis_print_mtid(tptr, "\n\t "); 2279 if (mt_len == 0) { /* did something go wrong ? */ 2280 goto trunctlv; 2281 } 2282 tptr+=mt_len; 2283 tmp-=mt_len; 2284 2285 while (tmp>0) { |
2260 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); | 2286 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET); |
2261 if (ext_ip_len == 0) /* did something go wrong ? */ 2262 goto trunctlv; 2263 tptr+=ext_ip_len; 2264 tmp-=ext_ip_len; 2265 } 2266 break; 2267 2268#ifdef INET6 2269 case ISIS_TLV_IP6_REACH: 2270 while (tmp>0) { | 2287 if (ext_ip_len == 0) /* did something go wrong ? */ 2288 goto trunctlv; 2289 tptr+=ext_ip_len; 2290 tmp-=ext_ip_len; 2291 } 2292 break; 2293 2294#ifdef INET6 2295 case ISIS_TLV_IP6_REACH: 2296 while (tmp>0) { |
2271 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); | 2297 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET6); |
2272 if (ext_ip_len == 0) /* did something go wrong ? */ 2273 goto trunctlv; 2274 tptr+=ext_ip_len; 2275 tmp-=ext_ip_len; 2276 } 2277 break; 2278 2279 case ISIS_TLV_MT_IP6_REACH: 2280 mt_len = isis_print_mtid(tptr, "\n\t "); 2281 if (mt_len == 0) { /* did something go wrong ? */ 2282 goto trunctlv; 2283 } 2284 tptr+=mt_len; 2285 tmp-=mt_len; 2286 2287 while (tmp>0) { | 2298 if (ext_ip_len == 0) /* did something go wrong ? */ 2299 goto trunctlv; 2300 tptr+=ext_ip_len; 2301 tmp-=ext_ip_len; 2302 } 2303 break; 2304 2305 case ISIS_TLV_MT_IP6_REACH: 2306 mt_len = isis_print_mtid(tptr, "\n\t "); 2307 if (mt_len == 0) { /* did something go wrong ? */ 2308 goto trunctlv; 2309 } 2310 tptr+=mt_len; 2311 tmp-=mt_len; 2312 2313 while (tmp>0) { |
2288 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); | 2314 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET6); |
2289 if (ext_ip_len == 0) /* did something go wrong ? */ 2290 goto trunctlv; 2291 tptr+=ext_ip_len; 2292 tmp-=ext_ip_len; 2293 } 2294 break; 2295 2296 case ISIS_TLV_IP6ADDR: --- 188 unchanged lines hidden (view full) --- 2485 if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN)) 2486 goto trunctlv; 2487 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)); 2488 /* do not attempt to verify the checksum if it is zero 2489 * most likely a HMAC-MD5 TLV is also present and 2490 * to avoid conflicts the checksum TLV is zeroed. 2491 * see rfc3358 for details 2492 */ | 2315 if (ext_ip_len == 0) /* did something go wrong ? */ 2316 goto trunctlv; 2317 tptr+=ext_ip_len; 2318 tmp-=ext_ip_len; 2319 } 2320 break; 2321 2322 case ISIS_TLV_IP6ADDR: --- 188 unchanged lines hidden (view full) --- 2511 if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN)) 2512 goto trunctlv; 2513 printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)); 2514 /* do not attempt to verify the checksum if it is zero 2515 * most likely a HMAC-MD5 TLV is also present and 2516 * to avoid conflicts the checksum TLV is zeroed. 2517 * see rfc3358 for details 2518 */ |
2493 if (EXTRACT_16BITS(tptr) == 0) 2494 printf("(unverified)"); 2495 else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct"); | 2519 osi_print_cksum(optr, EXTRACT_16BITS(tptr), tptr-optr, length); |
2496 break; 2497 2498 case ISIS_TLV_MT_SUPPORTED: 2499 if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) 2500 break; 2501 while (tmp>1) { 2502 /* length can only be a multiple of 2, otherwise there is 2503 something broken -> so decode down until length is 1 */ --- 175 unchanged lines hidden (view full) --- 2679 fputs("[|isis]", stdout); 2680 return (1); 2681 2682 trunctlv: 2683 printf("\n\t\t packet exceeded snapshot"); 2684 return(1); 2685} 2686 | 2520 break; 2521 2522 case ISIS_TLV_MT_SUPPORTED: 2523 if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) 2524 break; 2525 while (tmp>1) { 2526 /* length can only be a multiple of 2, otherwise there is 2527 something broken -> so decode down until length is 1 */ --- 175 unchanged lines hidden (view full) --- 2703 fputs("[|isis]", stdout); 2704 return (1); 2705 2706 trunctlv: 2707 printf("\n\t\t packet exceeded snapshot"); 2708 return(1); 2709} 2710 |
2687/* 2688 * Verify the checksum. See 8473-1, Appendix C, section C.4. 2689 */ 2690 2691static int 2692osi_cksum(const u_int8_t *tptr, u_int len) | 2711static void 2712osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum, 2713 u_int checksum_offset, u_int length) |
2693{ | 2714{ |
2694 int32_t c0 = 0, c1 = 0; | 2715 u_int16_t calculated_checksum; |
2695 | 2716 |
2696 while ((int)--len >= 0) { 2697 c0 += *tptr++; 2698 c0 %= 255; 2699 c1 += c0; 2700 c1 %= 255; 2701 } 2702 return (c0 | c1); | 2717 /* do not attempt to verify the checksum if it is zero */ 2718 if (!checksum) { 2719 printf("(unverified)"); 2720 } else { 2721 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length); 2722 if (checksum == calculated_checksum) { 2723 printf(" (correct)"); 2724 } else { 2725 printf(" (incorrect should be 0x%04x)", calculated_checksum); 2726 } 2727 } |
2703} 2704 | 2728} 2729 |
2705 | |
2706/* 2707 * Local Variables: 2708 * c-style: whitesmith 2709 * c-basic-offset: 8 2710 * End: 2711 */ | 2730/* 2731 * Local Variables: 2732 * c-style: whitesmith 2733 * c-basic-offset: 8 2734 * End: 2735 */ |