#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.15 1999-12-14 16:58:03 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.16 2000-01-19 04:57:12 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
* XXX: We consider a case where IPv6 is not ready yet for portability,
* but PIM dependent defintions should be independent of IPv6...
*/
-#ifdef INET6
-#include <netinet6/pim6.h>
-#else
+
struct pim {
-#if defined(WORDS_BIGENDIAN) || (defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN))
- u_int pim_type:4, /* the PIM message type, currently they are:
- * Hello, Register, Register-Stop, Join/Prune,
- * Bootstrap, Assert, Graft (PIM-DM only),
- * Graft-Ack (PIM-DM only), C-RP-Adv
- */
- pim_ver:4; /* PIM version number; 2 for PIMv2 */
-#else
- u_int pim_ver:4, /* PIM version */
- pim_type:4; /* PIM type */
-#endif
+ u_int8_t pim_typever;
+ /* upper 4bit: the PIM message type, currently they are:
+ * Hello, Register, Register-Stop, Join/Prune,
+ * Bootstrap, Assert, Graft (PIM-DM only),
+ * Graft-Ack (PIM-DM only), C-RP-Adv
+ */
+ /* lower 4bit: PIM version number; 2 for PIMv2 */
+#define PIM_TYPE(x) (((x) & 0xf0) >> 4)
+#define PIM_VER(x) ((x) & 0x0f)
u_char pim_rsv; /* Reserved */
u_short pim_cksum; /* IP style check sum */
};
-#endif
#include <stdio.h>
TCHECK(pim->pim_rsv);
#endif
- switch(pim->pim_ver) {
+ switch(PIM_VER(pim->pim_typever)) {
case 2: /* avoid hardcoding? */
(void)printf("v2");
pimv2_print(bp, len);
break;
default:
- (void)printf("v%d", pim->pim_ver);
+ (void)printf("v%d", PIM_VER(pim->pim_typever));
break;
}
return;
if (pimv2_addr_len != 0)
(void)printf("[RFC2117-encoding] ");
- switch (pim->pim_type) {
+ switch (PIM_TYPE(pim->pim_typever)) {
case 0:
{
u_int16_t otype, olen;
u_int16_t nprune;
int i, j;
- switch (pim->pim_type) {
+ switch (PIM_TYPE(pim->pim_typever)) {
case 3:
(void)printf(" Join/Prune");
break;
break;
}
bp += 4; len -= 4;
- if (pim->pim_type != 7) { /*not for Graft-ACK*/
+ if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
if (bp >= ep)
break;
(void)printf(" upstream-neighbor=");
ngroup = bp[1];
holdtime = EXTRACT_16BITS(&bp[2]);
(void)printf(" groups=%u", ngroup);
- if (pim->pim_type != 7) { /*not for Graft-ACK*/
+ if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
(void)printf(" holdtime=");
if (holdtime == 0xffff)
(void)printf("infty");
default:
- (void)printf(" [type %d]", pim->pim_type);
+ (void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
break;
}