print-pim.c (111729) | print-pim.c (127675) |
---|---|
1/* 2 * Copyright (c) 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 --- 4 unchanged lines hidden (view full) --- 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 * | 1/* 2 * Copyright (c) 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 --- 4 unchanged lines hidden (view full) --- 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 * $FreeBSD: head/contrib/tcpdump/print-pim.c 111729 2003-03-02 08:25:48Z fenner $ | 21 * $FreeBSD: head/contrib/tcpdump/print-pim.c 127675 2004-03-31 14:57:24Z bms $ |
22 */ 23 24#ifndef lint | 22 */ 23 24#ifndef lint |
25static const char rcsid[] = 26 "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.29.4.1 2002/05/07 18:30:19 fenner Exp $ (LBL)"; | 25static const char rcsid[] _U_ = 26 "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.37.2.4 2004/03/24 02:52:37 guy Exp $ (LBL)"; |
27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 | 27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 |
33#include <sys/param.h> 34#include <sys/time.h> 35#include <sys/socket.h> | 33#include <tcpdump-stdinc.h> |
36 | 34 |
37#include <netinet/in.h> 38 | |
39/* 40 * XXX: We consider a case where IPv6 is not ready yet for portability, 41 * but PIM dependent defintions should be independent of IPv6... 42 */ 43 44struct pim { 45 u_int8_t pim_typever; 46 /* upper 4bit: PIM version number; 2 for PIMv2 */ --- 6 unchanged lines hidden (view full) --- 53#define PIM_TYPE(x) ((x) & 0x0f) 54 u_char pim_rsv; /* Reserved */ 55 u_short pim_cksum; /* IP style check sum */ 56}; 57 58 59#include <stdio.h> 60#include <stdlib.h> | 35/* 36 * XXX: We consider a case where IPv6 is not ready yet for portability, 37 * but PIM dependent defintions should be independent of IPv6... 38 */ 39 40struct pim { 41 u_int8_t pim_typever; 42 /* upper 4bit: PIM version number; 2 for PIMv2 */ --- 6 unchanged lines hidden (view full) --- 49#define PIM_TYPE(x) ((x) & 0x0f) 50 u_char pim_rsv; /* Reserved */ 51 u_short pim_cksum; /* IP style check sum */ 52}; 53 54 55#include <stdio.h> 56#include <stdlib.h> |
61#include <unistd.h> | |
62 63#include "interface.h" 64#include "addrtoname.h" 65#include "extract.h" 66 67#include "ip.h" 68 69static void pimv2_print(register const u_char *bp, register u_int len); --- 45 unchanged lines hidden (view full) --- 115 maddrlen = bp[1]; 116 addrlen = bp[2]; 117 ngroups = bp[3]; 118 bp += 4; 119 len -= 4; 120 while (ngroups--) { 121 TCHECK2(bp[0], 4); 122 (void)printf("\n\tGroup: %s", ipaddr_string(bp)); | 57 58#include "interface.h" 59#include "addrtoname.h" 60#include "extract.h" 61 62#include "ip.h" 63 64static void pimv2_print(register const u_char *bp, register u_int len); --- 45 unchanged lines hidden (view full) --- 110 maddrlen = bp[1]; 111 addrlen = bp[2]; 112 ngroups = bp[3]; 113 bp += 4; 114 len -= 4; 115 while (ngroups--) { 116 TCHECK2(bp[0], 4); 117 (void)printf("\n\tGroup: %s", ipaddr_string(bp)); |
118 TCHECK2(bp[4], 4); |
|
123 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) 124 (void)printf("/%s", ipaddr_string(&bp[4])); 125 TCHECK2(bp[8], 4); 126 njoin = EXTRACT_16BITS(&bp[8]); 127 nprune = EXTRACT_16BITS(&bp[10]); 128 (void)printf(" joined: %d pruned: %d", njoin, nprune); 129 bp += 12; 130 len -= 12; 131 for (njp = 0; njp < (njoin + nprune); njp++) { | 119 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) 120 (void)printf("/%s", ipaddr_string(&bp[4])); 121 TCHECK2(bp[8], 4); 122 njoin = EXTRACT_16BITS(&bp[8]); 123 nprune = EXTRACT_16BITS(&bp[10]); 124 (void)printf(" joined: %d pruned: %d", njoin, nprune); 125 bp += 12; 126 len -= 12; 127 for (njp = 0; njp < (njoin + nprune); njp++) { |
132 char *type; | 128 const char *type; |
133 134 if (njp < njoin) 135 type = "Join "; 136 else 137 type = "Prune"; 138 TCHECK2(bp[0], 6); 139 (void)printf("\n\t%s %s%s%s%s/%d", type, 140 (bp[0] & 0x01) ? "Sparse " : "Dense ", --- 15 unchanged lines hidden (view full) --- 156{ 157 register const u_char *ep; 158 register u_char type; 159 160 ep = (const u_char *)snapend; 161 if (bp >= ep) 162 return; 163 | 129 130 if (njp < njoin) 131 type = "Join "; 132 else 133 type = "Prune"; 134 TCHECK2(bp[0], 6); 135 (void)printf("\n\t%s %s%s%s%s/%d", type, 136 (bp[0] & 0x01) ? "Sparse " : "Dense ", --- 15 unchanged lines hidden (view full) --- 152{ 153 register const u_char *ep; 154 register u_char type; 155 156 ep = (const u_char *)snapend; 157 if (bp >= ep) 158 return; 159 |
160 TCHECK(bp[1]); |
|
164 type = bp[1]; 165 166 switch (type) { 167 case 0: 168 (void)printf(" Query"); 169 if (TTEST(bp[8])) { 170 switch (bp[8] >> 4) { 171 case 0: --- 272 unchanged lines hidden (view full) --- 444 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 445 * | Source Address | 446 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 447 */ 448static int 449pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) 450{ 451 int af; | 161 type = bp[1]; 162 163 switch (type) { 164 case 0: 165 (void)printf(" Query"); 166 if (TTEST(bp[8])) { 167 switch (bp[8] >> 4) { 168 case 0: --- 272 unchanged lines hidden (view full) --- 441 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 442 * | Source Address | 443 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 444 */ 445static int 446pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) 447{ 448 int af; |
452 char *afstr; | 449 const char *afstr; |
453 int len, hdrlen; 454 455 TCHECK(bp[0]); 456 457 if (pimv2_addr_len == 0) { 458 TCHECK(bp[1]); 459 switch (bp[0]) { 460 case 1: --- 120 unchanged lines hidden (view full) --- 581 TCHECK2(bp[0], 4 + olen); 582 switch (otype) { 583 case 1: /* Hold time */ 584 (void)printf(" (Hold-time "); 585 relts_print(EXTRACT_16BITS(&bp[4])); 586 (void)printf(")"); 587 break; 588 | 450 int len, hdrlen; 451 452 TCHECK(bp[0]); 453 454 if (pimv2_addr_len == 0) { 455 TCHECK(bp[1]); 456 switch (bp[0]) { 457 case 1: --- 120 unchanged lines hidden (view full) --- 578 TCHECK2(bp[0], 4 + olen); 579 switch (otype) { 580 case 1: /* Hold time */ 581 (void)printf(" (Hold-time "); 582 relts_print(EXTRACT_16BITS(&bp[4])); 583 (void)printf(")"); 584 break; 585 |
586 case 2: /* LAN Prune Delay */ 587 (void)printf(" (LAN-Prune-Delay: "); 588 if (olen != 4) { 589 (void)printf("!olen=%d!)", olen); 590 } else { 591 char t_bit; 592 u_int16_t lan_delay, override_interval; 593 lan_delay = EXTRACT_16BITS(&bp[4]); 594 override_interval = EXTRACT_16BITS(&bp[6]); 595 t_bit = (lan_delay & 0x8000)? 1 : 0; 596 lan_delay &= ~0x8000; 597 (void)printf("T-bit=%d lan-delay=%dms override-interval=%dms)", 598 t_bit, lan_delay, override_interval); 599 } 600 break; 601 |
|
589 case 18: /* Old DR-Priority */ 590 if (olen == 4) | 602 case 18: /* Old DR-Priority */ 603 if (olen == 4) |
591 (void)printf(" (OLD-DR-Priority: %d)", | 604 (void)printf(" (OLD-DR-Priority: %d)", |
592 EXTRACT_32BITS(&bp[4])); 593 else 594 goto unknown; 595 break; 596 597 598 case 19: /* DR-Priority */ 599 if (olen == 0) { --- 23 unchanged lines hidden (view full) --- 623 } 624 (void)printf(")"); 625 break; 626 627 case 22: /* Bidir-Capable */ 628 (void)printf(" (bidir-capable)"); 629 break; 630 | 605 EXTRACT_32BITS(&bp[4])); 606 else 607 goto unknown; 608 break; 609 610 611 case 19: /* DR-Priority */ 612 if (olen == 0) { --- 23 unchanged lines hidden (view full) --- 636 } 637 (void)printf(")"); 638 break; 639 640 case 22: /* Bidir-Capable */ 641 (void)printf(" (bidir-capable)"); 642 break; 643 |
644 case 24: /* Address List */ 645 case 65001: /* Address List (old implementations) */ 646 (void)printf(" (%saddr-list", 647 otype == 65001 ? "old" : ""); 648 if (vflag > 1) { 649 const u_char *ptr = &bp[4]; 650 while (ptr < &bp[4 + olen]) { 651 int advance; 652 653 printf(" "); 654 advance = pimv2_addr_print(ptr, pimv2_unicast, 0); 655 if (advance < 0) { 656 printf("..."); 657 break; 658 } 659 ptr += advance; 660 } 661 } 662 (void)printf(")"); 663 break; |
|
631 default: 632 unknown: 633 if (vflag) 634 (void)printf(" [Hello option %d]", otype); 635 } 636 bp += 4 + olen; 637 } 638 break; --- 322 unchanged lines hidden --- | 664 default: 665 unknown: 666 if (vflag) 667 (void)printf(" [Hello option %d]", otype); 668 } 669 bp += 4 + olen; 670 } 671 break; --- 322 unchanged lines hidden --- |