print-isoclns.c (162021) | print-isoclns.c (172686) |
---|---|
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 162021 2006-09-04 20:25:04Z sam $ | 26 * $FreeBSD: head/contrib/tcpdump/print-isoclns.c 172686 2007-10-16 02:31:48Z mlaier $ |
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.19 2005/09/20 10:15:22 hannes Exp $ (LBL)"; | 31 "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.25 2007/03/02 09:20:27 hannes Exp $ (LBL)"; |
32#endif 33 34#ifdef HAVE_CONFIG_H 35#include "config.h" 36#endif 37 38#include <tcpdump-stdinc.h> 39 --- 432 unchanged lines hidden (view full) --- 472#define ISIS_LSP_TYPE_LEVEL_1 1 473#define ISIS_LSP_TYPE_UNUSED2 2 474#define ISIS_LSP_TYPE_LEVEL_2 3 475 476static struct tok isis_lsp_istype_values[] = { 477 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"}, 478 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"}, 479 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"}, | 32#endif 33 34#ifdef HAVE_CONFIG_H 35#include "config.h" 36#endif 37 38#include <tcpdump-stdinc.h> 39 --- 432 unchanged lines hidden (view full) --- 472#define ISIS_LSP_TYPE_LEVEL_1 1 473#define ISIS_LSP_TYPE_UNUSED2 2 474#define ISIS_LSP_TYPE_LEVEL_2 3 475 476static struct tok isis_lsp_istype_values[] = { 477 { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"}, 478 { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"}, 479 { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"}, |
480 { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"}, | 480 { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"}, |
481 { 0, NULL } 482}; 483 484/* 485 * Katz's point to point adjacency TLV uses codes to tell us the state of 486 * the remote adjacency. Enumerate them. 487 */ 488 --- 1124 unchanged lines hidden (view full) --- 1613 * we process the TLV and optional subTLVs and return 1614 * the amount of processed bytes 1615 */ 1616 1617static int 1618isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) { 1619 1620 char ident_buffer[20]; | 481 { 0, NULL } 482}; 483 484/* 485 * Katz's point to point adjacency TLV uses codes to tell us the state of 486 * the remote adjacency. Enumerate them. 487 */ 488 --- 1124 unchanged lines hidden (view full) --- 1613 * we process the TLV and optional subTLVs and return 1614 * the amount of processed bytes 1615 */ 1616 1617static int 1618isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) { 1619 1620 char ident_buffer[20]; |
1621#ifdef INET6 |
|
1621 u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ | 1622 u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ |
1623#else 1624 u_int8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */ 1625#endif |
|
1622 u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; 1623 1624 if (!TTEST2(*tptr, 4)) 1625 return (0); 1626 metric = EXTRACT_32BITS(tptr); 1627 processed=4; 1628 tptr+=4; 1629 1630 if (afi == IPV4) { 1631 if (!TTEST2(*tptr, 1)) /* fetch status byte */ 1632 return (0); 1633 status_byte=*(tptr++); 1634 bit_length = status_byte&0x3f; | 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 1634 if (afi == IPV4) { 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 } |
|
1635 processed++; 1636#ifdef INET6 1637 } else if (afi == IPV6) { 1638 if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */ 1639 return (0); 1640 status_byte=*(tptr++); 1641 bit_length=*(tptr++); | 1645 processed++; 1646#ifdef INET6 1647 } else if (afi == IPV6) { 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); 1656 return (0); 1657 } |
|
1642 processed+=2; 1643#endif 1644 } else 1645 return (0); /* somebody is fooling us */ 1646 1647 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */ 1648 1649 if (!TTEST2(*tptr, byte_length)) 1650 return (0); | 1658 processed+=2; 1659#endif 1660 } else 1661 return (0); /* somebody is fooling us */ 1662 1663 byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */ 1664 1665 if (!TTEST2(*tptr, byte_length)) 1666 return (0); |
1651 memset(prefix, 0, sizeof(struct in6_addr)); /* clear the copy buffer */ | 1667 memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ |
1652 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ 1653 tptr+=byte_length; 1654 processed+=byte_length; 1655 1656 if (afi == IPV4) 1657 printf("%sIPv4 prefix: %15s/%u", 1658 ident, 1659 ipaddr_string(prefix), --- 429 unchanged lines hidden (view full) --- 2089 printf("\n\t %s TLV #%u, length: %u", 2090 tok2str(isis_tlv_values, 2091 "unknown", 2092 tlv_type), 2093 tlv_type, 2094 tlv_len); 2095 2096 if (tlv_len == 0) /* something is malformed */ | 1668 memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ 1669 tptr+=byte_length; 1670 processed+=byte_length; 1671 1672 if (afi == IPV4) 1673 printf("%sIPv4 prefix: %15s/%u", 1674 ident, 1675 ipaddr_string(prefix), --- 429 unchanged lines hidden (view full) --- 2105 printf("\n\t %s TLV #%u, length: %u", 2106 tok2str(isis_tlv_values, 2107 "unknown", 2108 tlv_type), 2109 tlv_type, 2110 tlv_len); 2111 2112 if (tlv_len == 0) /* something is malformed */ |
2097 break; | 2113 continue; |
2098 2099 /* now check if we have a decoder otherwise do a hexdump at the end*/ 2100 switch (tlv_type) { 2101 case ISIS_TLV_AREA_ADDR: 2102 if (!TTEST2(*tptr, 1)) 2103 goto trunctlv; 2104 alen = *tptr++; 2105 while (tmp && alen < tmp) { --- 122 unchanged lines hidden (view full) --- 2228 if (ext_ip_len == 0) /* did something go wrong ? */ 2229 goto trunctlv; 2230 tptr+=ext_ip_len; 2231 tmp-=ext_ip_len; 2232 } 2233 break; 2234 2235 case ISIS_TLV_MT_IP_REACH: | 2114 2115 /* now check if we have a decoder otherwise do a hexdump at the end*/ 2116 switch (tlv_type) { 2117 case ISIS_TLV_AREA_ADDR: 2118 if (!TTEST2(*tptr, 1)) 2119 goto trunctlv; 2120 alen = *tptr++; 2121 while (tmp && alen < tmp) { --- 122 unchanged lines hidden (view full) --- 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: |
2236 while (tmp>0) { 2237 mt_len = isis_print_mtid(tptr, "\n\t "); 2238 if (mt_len == 0) /* did something go wrong ? */ 2239 goto trunctlv; 2240 tptr+=mt_len; 2241 tmp-=mt_len; | 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; |
2242 | 2258 |
2259 while (tmp>0) { |
|
2243 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); 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 --- 4 unchanged lines hidden (view full) --- 2255 if (ext_ip_len == 0) /* did something go wrong ? */ 2256 goto trunctlv; 2257 tptr+=ext_ip_len; 2258 tmp-=ext_ip_len; 2259 } 2260 break; 2261 2262 case ISIS_TLV_MT_IP6_REACH: | 2260 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); 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 --- 4 unchanged lines hidden (view full) --- 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: |
2263 while (tmp>0) { 2264 mt_len = isis_print_mtid(tptr, "\n\t "); 2265 if (mt_len == 0) /* did something go wrong ? */ 2266 goto trunctlv; 2267 tptr+=mt_len; 2268 tmp-=mt_len; | 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; |
2269 | 2286 |
2287 while (tmp>0) { |
|
2270 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); 2271 if (ext_ip_len == 0) /* did something go wrong ? */ 2272 goto trunctlv; 2273 tptr+=ext_ip_len; 2274 tmp-=ext_ip_len; 2275 } 2276 break; 2277 --- 233 unchanged lines hidden (view full) --- 2511 if (tmp == 0) 2512 break; 2513 2514 if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) 2515 break; 2516 if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)) 2517 goto trunctlv; 2518 | 2288 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); 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 --- 233 unchanged lines hidden (view full) --- 2529 if (tmp == 0) 2530 break; 2531 2532 if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) 2533 break; 2534 if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)) 2535 goto trunctlv; 2536 |
2519 printf(", Remaining holding time %us", EXTRACT_16BITS(tptr+1)); | 2537 printf(", Remaining holding time %us", EXTRACT_16BITS(tptr)); |
2520 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; 2521 tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; 2522 2523 /* is there an additional sysid field present ?*/ 2524 if (tmp == SYSTEM_ID_LEN) { 2525 if (!TTEST2(*tptr, SYSTEM_ID_LEN)) 2526 goto trunctlv; 2527 printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN)); --- 166 unchanged lines hidden --- | 2538 tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; 2539 tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; 2540 2541 /* is there an additional sysid field present ?*/ 2542 if (tmp == SYSTEM_ID_LEN) { 2543 if (!TTEST2(*tptr, SYSTEM_ID_LEN)) 2544 goto trunctlv; 2545 printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN)); --- 166 unchanged lines hidden --- |