As subject:
I have developed a HSRP printer, but am unsure how to integrate it into the
TCPDump code. I have included first draft code versions.
What do I need to do?? I think I need to amend interface.h?
Cheers,
--Gareth
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
/*
* Initial contribution from Gareth Bromley <[EMAIL PROTECTED]>
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 0.10 2001/09/24
18:04:00 XXX Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
#include "hsrp.h"
#include "ip.h"
#include "extract.h" /* must come after interface.h */
static struct tok op2str[] = {
{ HSRP_HELLO, "hello" },
{ HSRP_COUP, "coup" },
{ HSRP_RESIGN, "resign" },
{ 0, NULL }
};
static struct tok state2str[] = {
{ HSRP_INITIAL, "initial" },
{ HSRP_LEARN, "learn" },
{ HSRP_LISTEN, "listen" },
{ HSRP_SPEAK, "speak" },
{ HSRP_STANDBY, "standby" },
{ HSRP_ACTIVE, "active" },
{ 0, NULL }
};
/* Default string if data is truncated */
static char tstr[] = " [|hsrp]";
void
hsrp_print(register const u_char *cp, u_int length)
{
register const struct hsrp *hsrp;
hsrp = (struct hsrphdr *)cp;
/* Print operation requested */
TCHECK(hsrp->hs_opcode);
printf("Opcode:");
switch (hsrp->hs_opcode) {
case HSRP_HELLO:
/* Hello message */
printf(" (hello)");
break;
case HSRP_COUP:
/* Coup */
printf(" (coup)");
break;
case HSRP_RESIGN:
/* Resign */
printf(" (resign)");
break;
default:
printf(" hsrp-#%d", hsrp->hs_opcode);
}
/* Print HSRP state */
TCHECK(hsrp->hs_state);
printf("state: ");
switch (hsrp->hs_state) {
case HSRP_INITIAL:
/* Initial */
printf("initial");
break;
case HSRP_LEARN:
/* Learn */
printf("learn");
break;
case HSRP_LISTEN:
/* Listen */
printf("listen");
break;
case HSRP_SPEAK:
/* Speak*/
printf("speak");
break;
case HSRP_STANDBY:
/* Standby */
printf("standby");
break;
case HSRP_ACTIVE:
/* Active */
printf("active");
break;
default:
printf(" hsrp-#%d", hsrp->hs_state);
}
/* Print out Hello time */
/* Print out hold time */
/* Print out Priority */
/* Print out Group */
/* Print out Authentication password ;) */
/* Print out virtual IP */
printf(" vip:%s\n",ipaddr_string(&hsrp->hs_vip));
return;
trunc:
fputs(tstr, stdout);
}
/* Cisco HSRP definitions */
/* HSRP Header */
struct hsrphdr {
u_int8_t hs_ver; /* protocol version number */
u_int8_t hs_opcode; /* Op Code */
u_int8_t hs_state; /* State */
u_int8_t hs_helltime; /* Hellotime */
u_int8_t hs_holdtime; /* Holdtime */
u_int8_t hs_pri; /* Priority */
u_int8_t hs_group; /* Group */
u_int8_t hs_res; /* Reserved */
uchar hs_authdata[8]; /* Authdata */
u_int32_t hs_vip; /* Virtual IP Address */
};
/* HSRP Port numbers */
#define IPPORT_HSRP 1985
/* HSRP OP CODE Messages */
#define HSRP_HELLO 0
#define HSRP_COUP 1
#define HSRP_RESIGN 2
/* HSRP State defines */
#define HSRP_INITIAL 0
#define HSRP_LEARN 1
#define HSRP_LISTEN 2
#define HSRP_SPEAK 4
#define HSRP_STANDBY 8
#define HSRP_ACTIVE 16
/* HSRP Default authentication data */
/* c i s c o NUL NUL NUL */
uchar hs_defaulthauth[8] = {0x63, 0x69, 0x73, 0x63, 0x6F, 0x00, 0x00, 0x00};