2 * Copyright (C) 2001 Julian Cowley
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 /* Cisco Hot Standby Router Protocol (HSRP). */
33 static const char rcsid[] =
34 "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.2 2001/10/08 16:12:37 fenner Exp $";
41 #include <sys/types.h>
44 #include <netinet/in.h>
46 #include "interface.h"
47 #include "addrtoname.h"
49 /* HSRP op code types. */
50 static const char *op_code_str[] = {
56 /* HSRP states and associated names. */
57 static struct tok states[] = {
71 * 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
72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * | Version | Op Code | State | Hellotime |
74 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 * | Holdtime | Priority | Group | Reserved |
76 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * | Authentication Data |
78 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 * | Authentication Data |
80 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 * | Virtual IP Address |
82 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 #define HSRP_AUTH_SIZE 8
87 /* HSRP protocol header. */
92 u_char hsrp_hellotime;
97 u_char hsrp_authdata[HSRP_AUTH_SIZE];
98 struct in_addr hsrp_virtaddr;
102 hsrp_print(register const u_char *bp, register u_int len)
104 struct hsrp *hp = (struct hsrp *) bp;
106 TCHECK(hp->hsrp_version);
107 printf("HSRPv%d", hp->hsrp_version);
108 if (hp->hsrp_version != 0)
110 TCHECK(hp->hsrp_op_code);
112 printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code));
114 TCHECK(hp->hsrp_state);
115 printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state));
116 TCHECK(hp->hsrp_group);
117 printf("group=%d ", hp->hsrp_group);
118 TCHECK(hp->hsrp_reserved);
119 if (hp->hsrp_reserved != 0) {
120 printf("[reserved=%d!] ", hp->hsrp_reserved);
122 TCHECK2(hp->hsrp_virtaddr, sizeof(hp->hsrp_virtaddr));
123 printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr));
125 printf(" hellotime=");
126 relts_print(hp->hsrp_hellotime);
127 printf(" holdtime=");
128 relts_print(hp->hsrp_holdtime);
129 printf(" priority=%d", hp->hsrp_priority);
131 fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), NULL);