1999-10-08 07:47:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, 1996
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
|
|
|
* provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
* features or use of this software display the following acknowledgement:
|
|
|
|
* ``This product includes software developed by the University of California,
|
|
|
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
|
|
* the University nor the names of its contributors may be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
2003-11-16 17:36:07 +08:00
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] _U_ =
|
2006-02-13 09:31:35 +08:00
|
|
|
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp $ (LBL)";
|
2003-11-16 17:36:07 +08:00
|
|
|
#endif
|
1999-11-21 17:36:43 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
1999-10-08 07:47:09 +08:00
|
|
|
#endif
|
|
|
|
|
2002-08-01 16:52:55 +08:00
|
|
|
#include <tcpdump-stdinc.h>
|
2003-12-15 21:15:25 +08:00
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
#define PIMV2_TYPE_HELLO 0
|
|
|
|
#define PIMV2_TYPE_REGISTER 1
|
|
|
|
#define PIMV2_TYPE_REGISTER_STOP 2
|
|
|
|
#define PIMV2_TYPE_JOIN_PRUNE 3
|
|
|
|
#define PIMV2_TYPE_BOOTSTRAP 4
|
|
|
|
#define PIMV2_TYPE_ASSERT 5
|
|
|
|
#define PIMV2_TYPE_GRAFT 6
|
|
|
|
#define PIMV2_TYPE_GRAFT_ACK 7
|
|
|
|
#define PIMV2_TYPE_CANDIDATE_RP 8
|
|
|
|
#define PIMV2_TYPE_PRUNE_REFRESH 9
|
|
|
|
|
|
|
|
static struct tok pimv2_type_values[] = {
|
|
|
|
{ PIMV2_TYPE_HELLO, "Hello" },
|
|
|
|
{ PIMV2_TYPE_REGISTER, "Register" },
|
|
|
|
{ PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
|
|
|
|
{ PIMV2_TYPE_JOIN_PRUNE, "Join / Prune" },
|
|
|
|
{ PIMV2_TYPE_BOOTSTRAP, "Bootstrap" },
|
|
|
|
{ PIMV2_TYPE_ASSERT, "Assert" },
|
|
|
|
{ PIMV2_TYPE_GRAFT, "Graft" },
|
|
|
|
{ PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
|
|
|
|
{ PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
|
|
|
|
{ PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PIMV2_HELLO_OPTION_HOLDTIME 1
|
|
|
|
#define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
|
|
|
|
#define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
|
|
|
|
#define PIMV2_HELLO_OPTION_DR_PRIORITY 19
|
|
|
|
#define PIMV2_HELLO_OPTION_GENID 20
|
|
|
|
#define PIMV2_HELLO_OPTION_REFRESH_CAP 21
|
|
|
|
#define PIMV2_HELLO_OPTION_BIDIR_CAP 22
|
|
|
|
#define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
|
|
|
|
#define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
|
|
|
|
|
|
|
|
static struct tok pimv2_hello_option_values[] = {
|
|
|
|
{ PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
|
|
|
|
{ PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
|
|
|
|
{ PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
|
|
|
|
{ PIMV2_HELLO_OPTION_DR_PRIORITY, "DR Priority" },
|
|
|
|
{ PIMV2_HELLO_OPTION_GENID, "Generation ID" },
|
|
|
|
{ PIMV2_HELLO_OPTION_REFRESH_CAP, "State Refresh Capability" },
|
|
|
|
{ PIMV2_HELLO_OPTION_BIDIR_CAP, "Bi-Directional Capability" },
|
|
|
|
{ PIMV2_HELLO_OPTION_ADDRESS_LIST, "Address List" },
|
|
|
|
{ PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD, "Address List (Old)" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
|
|
|
|
2006-02-13 09:31:35 +08:00
|
|
|
#define PIMV2_REGISTER_FLAG_LEN 4
|
|
|
|
#define PIMV2_REGISTER_FLAG_BORDER 0x80000000
|
|
|
|
#define PIMV2_REGISTER_FLAG_NULL 0x40000000
|
|
|
|
|
|
|
|
static struct tok pimv2_register_flag_values[] = {
|
|
|
|
{ PIMV2_REGISTER_FLAG_BORDER, "Border" },
|
|
|
|
{ PIMV2_REGISTER_FLAG_NULL, "Null" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
1999-10-08 07:47:09 +08:00
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
/*
|
|
|
|
* XXX: We consider a case where IPv6 is not ready yet for portability,
|
|
|
|
* but PIM dependent defintions should be independent of IPv6...
|
|
|
|
*/
|
2000-01-19 12:57:12 +08:00
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
struct pim {
|
2000-01-19 12:57:12 +08:00
|
|
|
u_int8_t pim_typever;
|
2000-02-17 05:49:23 +08:00
|
|
|
/* upper 4bit: PIM version number; 2 for PIMv2 */
|
|
|
|
/* lower 4bit: the PIM message type, currently they are:
|
2000-01-19 12:57:12 +08:00
|
|
|
* Hello, Register, Register-Stop, Join/Prune,
|
|
|
|
* Bootstrap, Assert, Graft (PIM-DM only),
|
|
|
|
* Graft-Ack (PIM-DM only), C-RP-Adv
|
|
|
|
*/
|
2000-02-17 05:49:23 +08:00
|
|
|
#define PIM_VER(x) (((x) & 0xf0) >> 4)
|
|
|
|
#define PIM_TYPE(x) ((x) & 0x0f)
|
1999-10-30 13:11:06 +08:00
|
|
|
u_char pim_rsv; /* Reserved */
|
|
|
|
u_short pim_cksum; /* IP style check sum */
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
|
1999-10-08 07:47:09 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
#include "addrtoname.h"
|
1999-11-22 15:25:26 +08:00
|
|
|
#include "extract.h"
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2000-09-23 16:54:24 +08:00
|
|
|
#include "ip.h"
|
|
|
|
|
2009-10-12 16:16:58 +08:00
|
|
|
static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
1999-11-22 15:25:26 +08:00
|
|
|
static void
|
|
|
|
pimv1_join_prune_print(register const u_char *bp, register u_int len)
|
|
|
|
{
|
2001-01-28 16:27:28 +08:00
|
|
|
int maddrlen, addrlen, ngroups, njoin, nprune;
|
|
|
|
int njp;
|
|
|
|
|
|
|
|
/* If it's a single group and a single source, use 1-line output. */
|
|
|
|
if (TTEST2(bp[0], 30) && bp[11] == 1 &&
|
|
|
|
((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
|
|
|
|
int hold;
|
|
|
|
|
|
|
|
(void)printf(" RPF %s ", ipaddr_string(bp));
|
|
|
|
hold = EXTRACT_16BITS(&bp[6]);
|
|
|
|
if (hold != 180) {
|
|
|
|
(void)printf("Hold ");
|
|
|
|
relts_print(hold);
|
|
|
|
}
|
|
|
|
(void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
|
|
|
|
ipaddr_string(&bp[26]), bp[25] & 0x3f,
|
|
|
|
ipaddr_string(&bp[12]));
|
|
|
|
if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
|
|
|
|
(void)printf("/%s", ipaddr_string(&bp[16]));
|
|
|
|
(void)printf(") %s%s %s",
|
1999-11-22 15:25:26 +08:00
|
|
|
(bp[24] & 0x01) ? "Sparse" : "Dense",
|
|
|
|
(bp[25] & 0x80) ? " WC" : "",
|
|
|
|
(bp[25] & 0x40) ? "RP" : "SPT");
|
2001-01-28 16:27:28 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-07-12 04:15:31 +08:00
|
|
|
TCHECK2(bp[0], sizeof(struct in_addr));
|
2001-05-10 13:30:20 +08:00
|
|
|
if (vflag > 1)
|
|
|
|
(void)printf("\n");
|
|
|
|
(void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
|
2001-01-28 16:27:28 +08:00
|
|
|
TCHECK2(bp[6], 2);
|
2001-05-10 13:30:20 +08:00
|
|
|
if (vflag > 1)
|
|
|
|
(void)printf("\n");
|
|
|
|
(void)printf(" Hold time: ");
|
2001-01-28 16:27:28 +08:00
|
|
|
relts_print(EXTRACT_16BITS(&bp[6]));
|
2001-05-10 13:30:20 +08:00
|
|
|
if (vflag < 2)
|
|
|
|
return;
|
2001-01-28 16:27:28 +08:00
|
|
|
bp += 8;
|
|
|
|
len -= 8;
|
|
|
|
|
|
|
|
TCHECK2(bp[0], 4);
|
|
|
|
maddrlen = bp[1];
|
|
|
|
addrlen = bp[2];
|
|
|
|
ngroups = bp[3];
|
|
|
|
bp += 4;
|
|
|
|
len -= 4;
|
|
|
|
while (ngroups--) {
|
2005-04-21 06:05:08 +08:00
|
|
|
/*
|
|
|
|
* XXX - does the address have length "addrlen" and the
|
|
|
|
* mask length "maddrlen"?
|
|
|
|
*/
|
2005-07-12 04:15:31 +08:00
|
|
|
TCHECK2(bp[0], sizeof(struct in_addr));
|
2001-01-28 16:27:28 +08:00
|
|
|
(void)printf("\n\tGroup: %s", ipaddr_string(bp));
|
2005-07-12 04:15:31 +08:00
|
|
|
TCHECK2(bp[4], sizeof(struct in_addr));
|
2001-01-28 16:27:28 +08:00
|
|
|
if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
|
|
|
|
(void)printf("/%s", ipaddr_string(&bp[4]));
|
|
|
|
TCHECK2(bp[8], 4);
|
|
|
|
njoin = EXTRACT_16BITS(&bp[8]);
|
|
|
|
nprune = EXTRACT_16BITS(&bp[10]);
|
|
|
|
(void)printf(" joined: %d pruned: %d", njoin, nprune);
|
|
|
|
bp += 12;
|
|
|
|
len -= 12;
|
|
|
|
for (njp = 0; njp < (njoin + nprune); njp++) {
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
const char *type;
|
2001-01-28 16:27:28 +08:00
|
|
|
|
|
|
|
if (njp < njoin)
|
|
|
|
type = "Join ";
|
|
|
|
else
|
|
|
|
type = "Prune";
|
|
|
|
TCHECK2(bp[0], 6);
|
|
|
|
(void)printf("\n\t%s %s%s%s%s/%d", type,
|
1999-11-22 15:25:26 +08:00
|
|
|
(bp[0] & 0x01) ? "Sparse " : "Dense ",
|
|
|
|
(bp[1] & 0x80) ? "WC " : "",
|
|
|
|
(bp[1] & 0x40) ? "RP " : "SPT ",
|
2001-01-28 16:27:28 +08:00
|
|
|
ipaddr_string(&bp[2]), bp[1] & 0x3f);
|
|
|
|
bp += 6;
|
|
|
|
len -= 6;
|
|
|
|
}
|
1999-11-22 15:25:26 +08:00
|
|
|
}
|
2001-01-28 16:27:28 +08:00
|
|
|
return;
|
1999-11-22 15:25:26 +08:00
|
|
|
trunc:
|
2001-01-28 16:27:28 +08:00
|
|
|
(void)printf("[|pim]");
|
|
|
|
return;
|
1999-11-22 15:25:26 +08:00
|
|
|
}
|
|
|
|
|
1999-10-08 07:47:09 +08:00
|
|
|
void
|
1999-11-22 15:25:26 +08:00
|
|
|
pimv1_print(register const u_char *bp, register u_int len)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2001-01-28 16:27:28 +08:00
|
|
|
register const u_char *ep;
|
|
|
|
register u_char type;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2001-01-28 16:27:28 +08:00
|
|
|
ep = (const u_char *)snapend;
|
|
|
|
if (bp >= ep)
|
|
|
|
return;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2003-11-19 17:42:04 +08:00
|
|
|
TCHECK(bp[1]);
|
2001-01-28 16:27:28 +08:00
|
|
|
type = bp[1];
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2001-01-28 16:27:28 +08:00
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
(void)printf(" Query");
|
|
|
|
if (TTEST(bp[8])) {
|
|
|
|
switch (bp[8] >> 4) {
|
|
|
|
case 0:
|
|
|
|
(void)printf(" Dense-mode");
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
case 1:
|
|
|
|
(void)printf(" Sparse-mode");
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
case 2:
|
|
|
|
(void)printf(" Sparse-Dense-mode");
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
default:
|
|
|
|
(void)printf(" mode-%d", bp[8] >> 4);
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
}
|
1999-11-22 15:25:26 +08:00
|
|
|
}
|
2001-01-28 16:27:28 +08:00
|
|
|
if (vflag) {
|
|
|
|
TCHECK2(bp[10],2);
|
|
|
|
(void)printf(" (Hold-time ");
|
|
|
|
relts_print(EXTRACT_16BITS(&bp[10]));
|
|
|
|
(void)printf(")");
|
|
|
|
}
|
|
|
|
break;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2001-01-28 16:27:28 +08:00
|
|
|
case 1:
|
|
|
|
(void)printf(" Register");
|
|
|
|
TCHECK2(bp[8], 20); /* ip header */
|
|
|
|
(void)printf(" for %s > %s", ipaddr_string(&bp[20]),
|
|
|
|
ipaddr_string(&bp[24]));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
(void)printf(" Register-Stop");
|
2005-07-12 04:15:31 +08:00
|
|
|
TCHECK2(bp[12], sizeof(struct in_addr));
|
2001-01-28 16:27:28 +08:00
|
|
|
(void)printf(" for %s > %s", ipaddr_string(&bp[8]),
|
|
|
|
ipaddr_string(&bp[12]));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
(void)printf(" Join/Prune");
|
|
|
|
if (vflag)
|
|
|
|
pimv1_join_prune_print(&bp[8], len - 8);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
(void)printf(" RP-reachable");
|
|
|
|
if (vflag) {
|
|
|
|
TCHECK2(bp[22], 2);
|
|
|
|
(void)printf(" group %s",
|
1999-11-22 15:25:26 +08:00
|
|
|
ipaddr_string(&bp[8]));
|
2001-01-28 16:27:28 +08:00
|
|
|
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
|
|
|
|
(void)printf("/%s", ipaddr_string(&bp[12]));
|
|
|
|
(void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
|
|
|
|
relts_print(EXTRACT_16BITS(&bp[22]));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
(void)printf(" Assert");
|
2005-07-12 04:15:31 +08:00
|
|
|
TCHECK2(bp[16], sizeof(struct in_addr));
|
2001-01-28 16:27:28 +08:00
|
|
|
(void)printf(" for %s > %s", ipaddr_string(&bp[16]),
|
|
|
|
ipaddr_string(&bp[8]));
|
1999-11-22 15:25:26 +08:00
|
|
|
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
|
|
|
|
(void)printf("/%s", ipaddr_string(&bp[12]));
|
2001-01-28 16:27:28 +08:00
|
|
|
TCHECK2(bp[24], 4);
|
|
|
|
(void)printf(" %s pref %d metric %d",
|
|
|
|
(bp[20] & 0x80) ? "RP-tree" : "SPT",
|
1999-11-22 15:25:26 +08:00
|
|
|
EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
|
|
|
|
EXTRACT_32BITS(&bp[24]));
|
2001-01-28 16:27:28 +08:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
(void)printf(" Graft");
|
|
|
|
if (vflag)
|
|
|
|
pimv1_join_prune_print(&bp[8], len - 8);
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
(void)printf(" Graft-ACK");
|
|
|
|
if (vflag)
|
|
|
|
pimv1_join_prune_print(&bp[8], len - 8);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
(void)printf(" Mode");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
(void)printf(" [type %d]", type);
|
|
|
|
break;
|
1999-11-22 15:25:26 +08:00
|
|
|
}
|
2001-01-28 16:27:28 +08:00
|
|
|
if ((bp[4] >> 4) != 1)
|
|
|
|
(void)printf(" [v%d]", bp[4] >> 4);
|
|
|
|
return;
|
1999-11-22 15:25:26 +08:00
|
|
|
|
|
|
|
trunc:
|
2001-01-28 16:27:28 +08:00
|
|
|
(void)printf("[|pim]");
|
|
|
|
return;
|
1999-11-22 15:25:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* auto-RP is a cisco protocol, documented at
|
2001-07-05 05:36:15 +08:00
|
|
|
* ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
|
|
|
|
*
|
|
|
|
* This implements version 1+, dated Sept 9, 1998.
|
1999-11-22 15:25:26 +08:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
cisco_autorp_print(register const u_char *bp, register u_int len)
|
|
|
|
{
|
2001-01-28 16:27:28 +08:00
|
|
|
int type;
|
|
|
|
int numrps;
|
|
|
|
int hold;
|
1999-11-22 15:25:26 +08:00
|
|
|
|
2001-01-28 16:27:28 +08:00
|
|
|
TCHECK(bp[0]);
|
|
|
|
(void)printf(" auto-rp ");
|
|
|
|
type = bp[0];
|
|
|
|
switch (type) {
|
|
|
|
case 0x11:
|
|
|
|
(void)printf("candidate-advert");
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
case 0x12:
|
|
|
|
(void)printf("mapping");
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
default:
|
|
|
|
(void)printf("type-0x%02x", type);
|
1999-11-22 15:25:26 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-01-28 16:27:28 +08:00
|
|
|
|
|
|
|
TCHECK(bp[1]);
|
|
|
|
numrps = bp[1];
|
|
|
|
|
|
|
|
TCHECK2(bp[2], 2);
|
|
|
|
(void)printf(" Hold ");
|
|
|
|
hold = EXTRACT_16BITS(&bp[2]);
|
|
|
|
if (hold)
|
|
|
|
relts_print(EXTRACT_16BITS(&bp[2]));
|
|
|
|
else
|
|
|
|
printf("FOREVER");
|
|
|
|
|
|
|
|
/* Next 4 bytes are reserved. */
|
|
|
|
|
|
|
|
bp += 8; len -= 8;
|
|
|
|
|
|
|
|
/*XXX skip unless -v? */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rest of packet:
|
|
|
|
* numrps entries of the form:
|
|
|
|
* 32 bits: RP
|
|
|
|
* 6 bits: reserved
|
|
|
|
* 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
|
|
|
|
* 8 bits: # of entries for this RP
|
|
|
|
* each entry: 7 bits: reserved, 1 bit: negative,
|
|
|
|
* 8 bits: mask 32 bits: source
|
|
|
|
* lather, rinse, repeat.
|
|
|
|
*/
|
|
|
|
while (numrps--) {
|
|
|
|
int nentries;
|
|
|
|
char s;
|
|
|
|
|
|
|
|
TCHECK2(bp[0], 4);
|
|
|
|
(void)printf(" RP %s", ipaddr_string(bp));
|
|
|
|
TCHECK(bp[4]);
|
|
|
|
switch (bp[4] & 0x3) {
|
|
|
|
case 0: printf(" PIMv?");
|
|
|
|
break;
|
|
|
|
case 1: printf(" PIMv1");
|
|
|
|
break;
|
|
|
|
case 2: printf(" PIMv2");
|
|
|
|
break;
|
|
|
|
case 3: printf(" PIMv1+2");
|
|
|
|
break;
|
|
|
|
}
|
2001-07-05 05:36:15 +08:00
|
|
|
if (bp[4] & 0xfc)
|
|
|
|
(void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
|
2001-01-28 16:27:28 +08:00
|
|
|
TCHECK(bp[5]);
|
|
|
|
nentries = bp[5];
|
|
|
|
bp += 6; len -= 6;
|
|
|
|
s = ' ';
|
|
|
|
for (; nentries; nentries--) {
|
|
|
|
TCHECK2(bp[0], 6);
|
|
|
|
(void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
|
|
|
|
ipaddr_string(&bp[2]), bp[1]);
|
2001-07-05 05:36:15 +08:00
|
|
|
if (bp[0] & 0xfe)
|
|
|
|
(void)printf("[rsvd=0x%02x]", bp[0] & 0xfe);
|
2001-01-28 16:27:28 +08:00
|
|
|
s = ',';
|
|
|
|
bp += 6; len -= 6;
|
|
|
|
}
|
1999-11-22 15:25:26 +08:00
|
|
|
}
|
2001-01-28 16:27:28 +08:00
|
|
|
return;
|
1999-11-22 15:25:26 +08:00
|
|
|
|
|
|
|
trunc:
|
2001-01-28 16:27:28 +08:00
|
|
|
(void)printf("[|autorp]");
|
|
|
|
return;
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
void
|
2009-10-12 16:16:58 +08:00
|
|
|
pim_print(register const u_char *bp, register u_int len, u_int cksum)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
|
|
|
register const u_char *ep;
|
|
|
|
register struct pim *pim = (struct pim *)bp;
|
|
|
|
|
|
|
|
ep = (const u_char *)snapend;
|
|
|
|
if (bp >= ep)
|
|
|
|
return;
|
|
|
|
#ifdef notyet /* currently we see only version and type */
|
|
|
|
TCHECK(pim->pim_rsv);
|
|
|
|
#endif
|
|
|
|
|
2000-04-24 20:59:39 +08:00
|
|
|
switch (PIM_VER(pim->pim_typever)) {
|
2003-12-15 21:15:25 +08:00
|
|
|
case 2:
|
|
|
|
if (!vflag) {
|
2006-02-13 09:31:35 +08:00
|
|
|
printf("PIMv%u, %s, length %u",
|
2003-12-15 21:15:25 +08:00
|
|
|
PIM_VER(pim->pim_typever),
|
|
|
|
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
|
|
|
|
len);
|
|
|
|
return;
|
|
|
|
} else {
|
2006-02-13 09:31:35 +08:00
|
|
|
printf("PIMv%u, length %u\n\t%s",
|
2003-12-15 21:15:25 +08:00
|
|
|
PIM_VER(pim->pim_typever),
|
|
|
|
len,
|
2004-09-30 00:49:31 +08:00
|
|
|
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
|
2009-10-12 16:16:58 +08:00
|
|
|
pimv2_print(bp, len, cksum);
|
2003-12-15 21:15:25 +08:00
|
|
|
}
|
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
default:
|
2006-02-13 09:31:35 +08:00
|
|
|
printf("PIMv%u, length %u",
|
2003-12-15 21:15:25 +08:00
|
|
|
PIM_VER(pim->pim_typever),
|
|
|
|
len);
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-15 00:58:03 +08:00
|
|
|
/*
|
|
|
|
* PIMv2 uses encoded address representations.
|
|
|
|
*
|
|
|
|
* The last PIM-SM I-D before RFC2117 was published specified the
|
|
|
|
* following representation for unicast addresses. However, RFC2117
|
|
|
|
* specified no encoding for unicast addresses with the unicast
|
|
|
|
* address length specified in the header. Therefore, we have to
|
|
|
|
* guess which encoding is being used (Cisco's PIMv2 implementation
|
|
|
|
* uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
|
|
|
|
* field into a 'unicast-address-length-in-bytes' field. We guess
|
|
|
|
* that it's the draft encoding if this reserved field is zero.
|
|
|
|
*
|
|
|
|
* RFC2362 goes back to the encoded format, and calls the addr length
|
|
|
|
* field "reserved" again.
|
|
|
|
*
|
|
|
|
* The first byte is the address family, from:
|
|
|
|
*
|
|
|
|
* 0 Reserved
|
|
|
|
* 1 IP (IP version 4)
|
|
|
|
* 2 IP6 (IP version 6)
|
|
|
|
* 3 NSAP
|
|
|
|
* 4 HDLC (8-bit multidrop)
|
|
|
|
* 5 BBN 1822
|
|
|
|
* 6 802 (includes all 802 media plus Ethernet "canonical format")
|
|
|
|
* 7 E.163
|
|
|
|
* 8 E.164 (SMDS, Frame Relay, ATM)
|
|
|
|
* 9 F.69 (Telex)
|
|
|
|
* 10 X.121 (X.25, Frame Relay)
|
|
|
|
* 11 IPX
|
|
|
|
* 12 Appletalk
|
|
|
|
* 13 Decnet IV
|
|
|
|
* 14 Banyan Vines
|
|
|
|
* 15 E.164 with NSAP format subaddress
|
|
|
|
*
|
|
|
|
* In addition, the second byte is an "Encoding". 0 is the default
|
|
|
|
* encoding for the address family, and no other encodings are currently
|
|
|
|
* specified.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int pimv2_addr_len;
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
enum pimv2_addrtype {
|
|
|
|
pimv2_unicast, pimv2_group, pimv2_source
|
|
|
|
};
|
|
|
|
|
1999-12-15 00:58:03 +08:00
|
|
|
/* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Addr Family | Encoding Type | Unicast Address |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Addr Family | Encoding Type | Reserved | Mask Len |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Group multicast Address |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Source Address |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
1999-10-30 13:11:06 +08:00
|
|
|
static int
|
|
|
|
pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
|
|
|
|
{
|
|
|
|
int af;
|
1999-12-15 00:58:03 +08:00
|
|
|
int len, hdrlen;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
1999-12-15 00:58:03 +08:00
|
|
|
TCHECK(bp[0]);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
1999-12-15 00:58:03 +08:00
|
|
|
if (pimv2_addr_len == 0) {
|
|
|
|
TCHECK(bp[1]);
|
|
|
|
switch (bp[0]) {
|
2001-01-28 16:27:28 +08:00
|
|
|
case 1:
|
1999-12-15 00:58:03 +08:00
|
|
|
af = AF_INET;
|
2005-07-12 04:15:31 +08:00
|
|
|
len = sizeof(struct in_addr);
|
1999-12-15 00:58:03 +08:00
|
|
|
break;
|
1999-10-30 13:11:06 +08:00
|
|
|
#ifdef INET6
|
2001-01-28 16:27:28 +08:00
|
|
|
case 2:
|
1999-12-15 00:58:03 +08:00
|
|
|
af = AF_INET6;
|
2005-07-12 04:15:31 +08:00
|
|
|
len = sizeof(struct in6_addr);
|
1999-12-15 00:58:03 +08:00
|
|
|
break;
|
1999-10-30 13:11:06 +08:00
|
|
|
#endif
|
2001-01-28 16:27:28 +08:00
|
|
|
default:
|
1999-12-15 00:58:03 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (bp[1] != 0)
|
|
|
|
return -1;
|
|
|
|
hdrlen = 2;
|
|
|
|
} else {
|
|
|
|
switch (pimv2_addr_len) {
|
2005-07-12 04:15:31 +08:00
|
|
|
case sizeof(struct in_addr):
|
1999-12-15 00:58:03 +08:00
|
|
|
af = AF_INET;
|
|
|
|
break;
|
|
|
|
#ifdef INET6
|
2005-07-12 04:15:31 +08:00
|
|
|
case sizeof(struct in6_addr):
|
1999-12-15 00:58:03 +08:00
|
|
|
af = AF_INET6;
|
|
|
|
break;
|
|
|
|
#endif
|
2001-01-28 16:27:28 +08:00
|
|
|
default:
|
1999-12-15 00:58:03 +08:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
len = pimv2_addr_len;
|
|
|
|
hdrlen = 0;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
1999-12-15 00:58:03 +08:00
|
|
|
bp += hdrlen;
|
1999-10-30 13:11:06 +08:00
|
|
|
switch (at) {
|
2001-01-28 16:27:28 +08:00
|
|
|
case pimv2_unicast:
|
1999-12-15 00:58:03 +08:00
|
|
|
TCHECK2(bp[0], len);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (af == AF_INET) {
|
|
|
|
if (!silent)
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf("%s", ipaddr_string(bp));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
#ifdef INET6
|
|
|
|
else if (af == AF_INET6) {
|
|
|
|
if (!silent)
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf("%s", ip6addr_string(bp));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
#endif
|
1999-12-15 00:58:03 +08:00
|
|
|
return hdrlen + len;
|
2001-01-28 16:27:28 +08:00
|
|
|
case pimv2_group:
|
|
|
|
case pimv2_source:
|
1999-12-15 00:58:03 +08:00
|
|
|
TCHECK2(bp[0], len + 2);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (af == AF_INET) {
|
1999-12-15 00:58:03 +08:00
|
|
|
if (!silent) {
|
|
|
|
(void)printf("%s", ipaddr_string(bp + 2));
|
|
|
|
if (bp[1] != 32)
|
|
|
|
(void)printf("/%u", bp[1]);
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
#ifdef INET6
|
|
|
|
else if (af == AF_INET6) {
|
1999-12-15 00:58:03 +08:00
|
|
|
if (!silent) {
|
|
|
|
(void)printf("%s", ip6addr_string(bp + 2));
|
|
|
|
if (bp[1] != 128)
|
|
|
|
(void)printf("/%u", bp[1]);
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
#endif
|
1999-12-15 00:58:03 +08:00
|
|
|
if (bp[0] && !silent) {
|
|
|
|
if (at == pimv2_group) {
|
|
|
|
(void)printf("(0x%02x)", bp[0]);
|
|
|
|
} else {
|
|
|
|
(void)printf("(%s%s%s",
|
|
|
|
bp[0] & 0x04 ? "S" : "",
|
|
|
|
bp[0] & 0x02 ? "W" : "",
|
|
|
|
bp[0] & 0x01 ? "R" : "");
|
|
|
|
if (bp[0] & 0xf8) {
|
|
|
|
(void) printf("+0x%02x", bp[0] & 0xf8);
|
|
|
|
}
|
|
|
|
(void)printf(")");
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
1999-12-15 00:58:03 +08:00
|
|
|
return hdrlen + 2 + len;
|
1999-10-30 13:11:06 +08:00
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
1999-12-15 00:58:03 +08:00
|
|
|
trunc:
|
|
|
|
return -1;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-10-12 16:16:58 +08:00
|
|
|
pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
|
|
|
register const u_char *ep;
|
|
|
|
register struct pim *pim = (struct pim *)bp;
|
|
|
|
int advance;
|
|
|
|
|
|
|
|
ep = (const u_char *)snapend;
|
|
|
|
if (bp >= ep)
|
|
|
|
return;
|
2000-02-17 05:49:23 +08:00
|
|
|
if (ep > bp + len)
|
|
|
|
ep = bp + len;
|
1999-10-30 13:11:06 +08:00
|
|
|
TCHECK(pim->pim_rsv);
|
1999-12-15 00:58:03 +08:00
|
|
|
pimv2_addr_len = pim->pim_rsv;
|
|
|
|
if (pimv2_addr_len != 0)
|
2003-12-15 21:15:25 +08:00
|
|
|
(void)printf(", RFC2117-encoding");
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2006-02-13 09:31:35 +08:00
|
|
|
printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum));
|
|
|
|
if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
|
|
|
|
printf("(unverified)");
|
|
|
|
} else {
|
2009-10-12 16:16:58 +08:00
|
|
|
printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
|
2006-02-13 09:31:35 +08:00
|
|
|
}
|
|
|
|
|
2000-01-19 12:57:12 +08:00
|
|
|
switch (PIM_TYPE(pim->pim_typever)) {
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_HELLO:
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
|
|
|
u_int16_t otype, olen;
|
|
|
|
bp += 4;
|
|
|
|
while (bp < ep) {
|
1999-12-15 00:58:03 +08:00
|
|
|
TCHECK2(bp[0], 4);
|
|
|
|
otype = EXTRACT_16BITS(&bp[0]);
|
|
|
|
olen = EXTRACT_16BITS(&bp[2]);
|
|
|
|
TCHECK2(bp[0], 4 + olen);
|
2003-12-15 21:15:25 +08:00
|
|
|
|
2006-02-13 09:31:35 +08:00
|
|
|
printf("\n\t %s Option (%u), length %u, Value: ",
|
2003-12-15 21:15:25 +08:00
|
|
|
tok2str( pimv2_hello_option_values,"Unknown",otype),
|
2004-03-18 22:12:18 +08:00
|
|
|
otype,
|
|
|
|
olen);
|
2003-12-15 21:15:25 +08:00
|
|
|
bp += 4;
|
|
|
|
|
1999-12-15 00:58:03 +08:00
|
|
|
switch (otype) {
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_HELLO_OPTION_HOLDTIME:
|
|
|
|
relts_print(EXTRACT_16BITS(bp));
|
|
|
|
break;
|
1999-12-15 00:58:03 +08:00
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
|
2002-10-19 10:43:04 +08:00
|
|
|
if (olen != 4) {
|
2003-12-15 21:15:25 +08:00
|
|
|
(void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
|
2002-10-19 10:43:04 +08:00
|
|
|
} else {
|
|
|
|
char t_bit;
|
|
|
|
u_int16_t lan_delay, override_interval;
|
2003-12-15 21:15:25 +08:00
|
|
|
lan_delay = EXTRACT_16BITS(bp);
|
|
|
|
override_interval = EXTRACT_16BITS(bp+2);
|
2002-10-19 10:43:04 +08:00
|
|
|
t_bit = (lan_delay & 0x8000)? 1 : 0;
|
|
|
|
lan_delay &= ~0x8000;
|
2003-12-15 21:15:25 +08:00
|
|
|
(void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
|
2002-10-19 10:43:04 +08:00
|
|
|
t_bit, lan_delay, override_interval);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
|
|
|
|
case PIMV2_HELLO_OPTION_DR_PRIORITY:
|
|
|
|
switch (olen) {
|
|
|
|
case 0:
|
|
|
|
printf("Bi-Directional Capability (Old)");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
printf("%u", EXTRACT_32BITS(bp));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIMV2_HELLO_OPTION_GENID:
|
|
|
|
(void)printf("0x%08x", EXTRACT_32BITS(bp));
|
1999-12-15 00:58:03 +08:00
|
|
|
break;
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_HELLO_OPTION_REFRESH_CAP:
|
|
|
|
(void)printf("v%d", *bp);
|
|
|
|
if (*(bp+1) != 0) {
|
|
|
|
(void)printf(", interval ");
|
|
|
|
relts_print(*(bp+1));
|
2001-05-11 10:12:32 +08:00
|
|
|
}
|
2003-12-15 21:15:25 +08:00
|
|
|
if (EXTRACT_16BITS(bp+2) != 0) {
|
|
|
|
(void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
|
1999-12-15 00:58:03 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
1999-12-15 00:58:03 +08:00
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_HELLO_OPTION_BIDIR_CAP:
|
2001-04-27 10:18:27 +08:00
|
|
|
break;
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
|
|
|
|
case PIMV2_HELLO_OPTION_ADDRESS_LIST:
|
2003-10-29 10:07:57 +08:00
|
|
|
if (vflag > 1) {
|
2003-12-15 21:15:25 +08:00
|
|
|
const u_char *ptr = bp;
|
|
|
|
while (ptr < (bp+olen)) {
|
2003-10-29 10:07:57 +08:00
|
|
|
int advance;
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
printf("\n\t ");
|
2003-10-29 10:07:57 +08:00
|
|
|
advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
|
|
|
|
if (advance < 0) {
|
|
|
|
printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr += advance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-12-15 00:58:03 +08:00
|
|
|
default:
|
2003-12-15 21:15:25 +08:00
|
|
|
if (vflag <= 1)
|
|
|
|
print_unknown_data(bp,"\n\t ",olen);
|
|
|
|
break;
|
1999-12-15 00:58:03 +08:00
|
|
|
}
|
2003-12-15 21:15:25 +08:00
|
|
|
/* do we want to see an additionally hexdump ? */
|
|
|
|
if (vflag> 1)
|
|
|
|
print_unknown_data(bp,"\n\t ",olen);
|
|
|
|
bp += olen;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_REGISTER:
|
2001-01-28 16:27:28 +08:00
|
|
|
{
|
1999-10-30 13:11:06 +08:00
|
|
|
struct ip *ip;
|
|
|
|
|
2006-02-13 09:31:35 +08:00
|
|
|
if (!TTEST2(*(bp+4), PIMV2_REGISTER_FLAG_LEN))
|
|
|
|
goto trunc;
|
|
|
|
|
|
|
|
printf(", Flags [ %s ]\n\t",
|
|
|
|
tok2str(pimv2_register_flag_values,
|
|
|
|
"none",
|
|
|
|
EXTRACT_32BITS(bp+4)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2006-02-13 09:31:35 +08:00
|
|
|
bp += 8; len -= 8;
|
1999-10-30 13:11:06 +08:00
|
|
|
/* encapsulated multicast packet */
|
|
|
|
ip = (struct ip *)bp;
|
2000-10-03 10:54:54 +08:00
|
|
|
switch (IP_V(ip)) {
|
2006-02-13 09:31:35 +08:00
|
|
|
case 0: /* Null header */
|
|
|
|
(void)printf("IP-Null-header %s > %s",
|
|
|
|
ipaddr_string(&ip->ip_src),
|
|
|
|
ipaddr_string(&ip->ip_dst));
|
|
|
|
break;
|
|
|
|
|
2001-01-28 16:27:28 +08:00
|
|
|
case 4: /* IPv4 */
|
2005-04-07 05:32:38 +08:00
|
|
|
ip_print(gndo, bp, len);
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
#ifdef INET6
|
2001-01-28 16:27:28 +08:00
|
|
|
case 6: /* IPv6 */
|
1999-10-30 13:11:06 +08:00
|
|
|
ip6_print(bp, len);
|
|
|
|
break;
|
|
|
|
#endif
|
2006-02-13 09:31:35 +08:00
|
|
|
default:
|
|
|
|
(void)printf("IP ver %d", IP_V(ip));
|
|
|
|
break;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_REGISTER_STOP:
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += 4; len -= 4;
|
|
|
|
if (bp >= ep)
|
|
|
|
break;
|
|
|
|
(void)printf(" group=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
if (bp >= ep)
|
|
|
|
break;
|
|
|
|
(void)printf(" source=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
break;
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_JOIN_PRUNE:
|
|
|
|
case PIMV2_TYPE_GRAFT:
|
|
|
|
case PIMV2_TYPE_GRAFT_ACK:
|
2004-03-18 22:12:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* |PIM Ver| Type | Addr length | Checksum |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Unicast-Upstream Neighbor Address |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Reserved | Num groups | Holdtime |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Encoded-Multicast Group Address-1 |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Number of Joined Sources | Number of Pruned Sources |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Encoded-Joined Source Address-1 |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | . |
|
|
|
|
* | . |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Encoded-Joined Source Address-n |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Encoded-Pruned Source Address-1 |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | . |
|
|
|
|
* | . |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Encoded-Pruned Source Address-n |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | . |
|
|
|
|
* | . |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Encoded-Multicast Group Address-n |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
|
|
|
u_int8_t ngroup;
|
|
|
|
u_int16_t holdtime;
|
|
|
|
u_int16_t njoin;
|
|
|
|
u_int16_t nprune;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
bp += 4; len -= 4;
|
2000-01-19 12:57:12 +08:00
|
|
|
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
|
1999-10-30 13:11:06 +08:00
|
|
|
if (bp >= ep)
|
|
|
|
break;
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf(", upstream-neighbor: ");
|
1999-10-30 13:11:06 +08:00
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
}
|
|
|
|
if (bp + 4 > ep)
|
|
|
|
break;
|
|
|
|
ngroup = bp[1];
|
1999-12-15 00:58:03 +08:00
|
|
|
holdtime = EXTRACT_16BITS(&bp[2]);
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf("\n\t %u group(s)", ngroup);
|
2000-01-19 12:57:12 +08:00
|
|
|
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf(", holdtime: ");
|
1999-10-30 13:11:06 +08:00
|
|
|
if (holdtime == 0xffff)
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf("infinite");
|
1999-10-30 13:11:06 +08:00
|
|
|
else
|
1999-12-15 00:58:03 +08:00
|
|
|
relts_print(holdtime);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
bp += 4; len -= 4;
|
|
|
|
for (i = 0; i < ngroup; i++) {
|
|
|
|
if (bp >= ep)
|
|
|
|
goto jp_done;
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf("\n\t group #%u: ", i+1);
|
1999-10-30 13:11:06 +08:00
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto jp_done;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
if (bp + 4 > ep) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto jp_done;
|
|
|
|
}
|
1999-12-15 00:58:03 +08:00
|
|
|
njoin = EXTRACT_16BITS(&bp[0]);
|
|
|
|
nprune = EXTRACT_16BITS(&bp[2]);
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += 4; len -= 4;
|
|
|
|
for (j = 0; j < njoin; j++) {
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf("\n\t joined source #%u: ",j+1);
|
1999-10-30 13:11:06 +08:00
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto jp_done;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
}
|
|
|
|
for (j = 0; j < nprune; j++) {
|
2004-03-18 22:12:18 +08:00
|
|
|
(void)printf("\n\t pruned source #%u: ",j+1);
|
1999-10-30 13:11:06 +08:00
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto jp_done;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jp_done:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_BOOTSTRAP:
|
2001-01-28 16:27:28 +08:00
|
|
|
{
|
1999-10-30 13:11:06 +08:00
|
|
|
int i, j, frpcnt;
|
|
|
|
bp += 4;
|
|
|
|
|
|
|
|
/* Fragment Tag, Hash Mask len, and BSR-priority */
|
|
|
|
if (bp + sizeof(u_int16_t) >= ep) break;
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf(" tag=%x", EXTRACT_16BITS(bp));
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += sizeof(u_int16_t);
|
|
|
|
if (bp >= ep) break;
|
|
|
|
(void)printf(" hashmlen=%d", bp[0]);
|
|
|
|
if (bp + 1 >= ep) break;
|
|
|
|
(void)printf(" BSRprio=%d", bp[1]);
|
|
|
|
bp += 2;
|
|
|
|
|
|
|
|
/* Encoded-Unicast-BSR-Address */
|
|
|
|
if (bp >= ep) break;
|
|
|
|
(void)printf(" BSR=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
|
|
|
|
for (i = 0; bp < ep; i++) {
|
|
|
|
/* Encoded-Group Address */
|
|
|
|
(void)printf(" (group%d: ", i);
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
|
|
|
|
< 0) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto bs_done;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
|
|
|
|
/* RP-Count, Frag RP-Cnt, and rsvd */
|
|
|
|
if (bp >= ep) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto bs_done;
|
|
|
|
}
|
2000-08-18 02:38:24 +08:00
|
|
|
(void)printf(" RPcnt=%d", bp[0]);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (bp + 1 >= ep) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto bs_done;
|
|
|
|
}
|
2000-08-18 02:38:24 +08:00
|
|
|
(void)printf(" FRPcnt=%d", frpcnt = bp[1]);
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += 4;
|
|
|
|
|
|
|
|
for (j = 0; j < frpcnt && bp < ep; j++) {
|
|
|
|
/* each RP info */
|
|
|
|
(void)printf(" RP%d=", j);
|
|
|
|
if ((advance = pimv2_addr_print(bp,
|
|
|
|
pimv2_unicast,
|
|
|
|
0)) < 0) {
|
|
|
|
(void)printf("...)");
|
|
|
|
goto bs_done;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
|
1999-11-17 22:58:13 +08:00
|
|
|
if (bp + 1 >= ep) {
|
1999-10-30 13:11:06 +08:00
|
|
|
(void)printf("...)");
|
|
|
|
goto bs_done;
|
|
|
|
}
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf(",holdtime=");
|
|
|
|
relts_print(EXTRACT_16BITS(bp));
|
1999-11-17 22:58:13 +08:00
|
|
|
if (bp + 2 >= ep) {
|
1999-10-30 13:11:06 +08:00
|
|
|
(void)printf("...)");
|
|
|
|
goto bs_done;
|
|
|
|
}
|
1999-11-17 22:58:13 +08:00
|
|
|
(void)printf(",prio=%d", bp[2]);
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += 4;
|
|
|
|
}
|
|
|
|
(void)printf(")");
|
|
|
|
}
|
|
|
|
bs_done:
|
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
}
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_ASSERT:
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += 4; len -= 4;
|
|
|
|
if (bp >= ep)
|
|
|
|
break;
|
|
|
|
(void)printf(" group=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
if (bp >= ep)
|
|
|
|
break;
|
|
|
|
(void)printf(" src=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance; len -= advance;
|
|
|
|
if (bp + 8 > ep)
|
|
|
|
break;
|
1999-12-15 00:58:03 +08:00
|
|
|
if (bp[0] & 0x80)
|
1999-10-30 13:11:06 +08:00
|
|
|
(void)printf(" RPT");
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff);
|
|
|
|
(void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_CANDIDATE_RP:
|
2001-01-28 16:27:28 +08:00
|
|
|
{
|
1999-10-30 13:11:06 +08:00
|
|
|
int i, pfxcnt;
|
|
|
|
bp += 4;
|
|
|
|
|
|
|
|
/* Prefix-Cnt, Priority, and Holdtime */
|
|
|
|
if (bp >= ep) break;
|
|
|
|
(void)printf(" prefix-cnt=%d", bp[0]);
|
|
|
|
pfxcnt = bp[0];
|
|
|
|
if (bp + 1 >= ep) break;
|
|
|
|
(void)printf(" prio=%d", bp[1]);
|
|
|
|
if (bp + 3 >= ep) break;
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf(" holdtime=");
|
|
|
|
relts_print(EXTRACT_16BITS(&bp[2]));
|
1999-10-30 13:11:06 +08:00
|
|
|
bp += 4;
|
|
|
|
|
|
|
|
/* Encoded-Unicast-RP-Address */
|
|
|
|
if (bp >= ep) break;
|
|
|
|
(void)printf(" RP=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
|
|
|
|
/* Encoded-Group Addresses */
|
|
|
|
for (i = 0; i < pfxcnt && bp < ep; i++) {
|
|
|
|
(void)printf(" Group%d=", i);
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
|
|
|
|
< 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
}
|
|
|
|
break;
|
2001-01-28 16:27:28 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2003-12-15 21:15:25 +08:00
|
|
|
case PIMV2_TYPE_PRUNE_REFRESH:
|
1999-12-15 00:58:03 +08:00
|
|
|
(void)printf(" src=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
(void)printf(" grp=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
(void)printf(" forwarder=");
|
|
|
|
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
|
|
|
|
(void)printf("...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp += advance;
|
|
|
|
TCHECK2(bp[0], 2);
|
|
|
|
(void)printf(" TUNR ");
|
|
|
|
relts_print(EXTRACT_16BITS(bp));
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
default:
|
2000-01-19 12:57:12 +08:00
|
|
|
(void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
1999-12-15 00:58:03 +08:00
|
|
|
|
|
|
|
trunc:
|
|
|
|
(void)printf("[|pim]");
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2005-04-07 05:32:38 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local Variables:
|
|
|
|
* c-style: whitesmith
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|