]>
The Tcpdump Group git mirrors - tcpdump/blob - print-hsrp.c
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.1 2001-09-17 06:22:33 guy 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 char *op_code_str
[] = {
56 /* HSRP states and associated names. */
73 * 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
74 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 * | Version | Op Code | State | Hellotime |
76 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * | Holdtime | Priority | Group | Reserved |
78 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 * | Authentication Data |
80 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 * | Authentication Data |
82 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83 * | Virtual IP Address |
84 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87 #define HSRP_AUTH_SIZE 8
89 /* HSRP protocol header. */
94 u_char hsrp_hellotime
;
99 u_char hsrp_authdata
[HSRP_AUTH_SIZE
];
100 struct in_addr hsrp_virtaddr
;
104 hsrp_print(register const u_char
*bp
, register u_int len
)
107 struct hsrp
*hp
= (struct hsrp
*) bp
;
110 TCHECK(hp
->hsrp_version
);
111 printf("HSRPv%d", hp
->hsrp_version
);
112 if (hp
->hsrp_version
!= 0)
114 TCHECK(hp
->hsrp_op_code
);
116 op_code
= hp
->hsrp_op_code
;
117 if (op_code
< (sizeof(op_code_str
) / sizeof(op_code_str
[0]))) {
118 printf("%s ", op_code_str
[op_code
]);
120 printf("unknown (%d) ", op_code
);
123 TCHECK(hp
->hsrp_state
);
124 state
= hp
->hsrp_state
;
125 for (i
= 0; i
< (sizeof(states
) / sizeof(states
[0])); i
++) {
126 if (state
== states
[i
].value
)
129 if (i
< (sizeof(states
) / sizeof(states
[0]))) {
130 printf("state=%s ", states
[i
].str
);
132 printf("state=Unknown (%d) ", state
);
134 TCHECK(hp
->hsrp_group
);
135 printf("group=%d ", hp
->hsrp_group
);
136 TCHECK(hp
->hsrp_reserved
);
137 if (hp
->hsrp_reserved
!= 0) {
138 printf("[reserved=%d!] ", hp
->hsrp_reserved
);
140 TCHECK2(hp
->hsrp_virtaddr
, sizeof(hp
->hsrp_virtaddr
));
141 printf("addr=%s", ipaddr_string(&hp
->hsrp_virtaddr
));
143 printf(" hellotime=");
144 relts_print(hp
->hsrp_hellotime
);
145 printf(" holdtime=");
146 relts_print(hp
->hsrp_holdtime
);
147 printf(" priority=%d", hp
->hsrp_priority
);
149 fn_printn(hp
->hsrp_authdata
, sizeof(hp
->hsrp_authdata
), NULL
);