]>
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). */
32 #define NETDISSECT_REWORKED
37 #include <tcpdump-stdinc.h>
39 #include "interface.h"
40 #include "addrtoname.h"
42 /* HSRP op code types. */
43 static const char *op_code_str
[] = {
49 /* HSRP states and associated names. */
50 static const struct tok states
[] = {
64 * 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
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 * | Version | Op Code | State | Hellotime |
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 * | Holdtime | Priority | Group | Reserved |
69 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 * | Authentication Data |
71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 * | Authentication Data |
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 * | Virtual IP Address |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 #define HSRP_AUTH_SIZE 8
80 /* HSRP protocol header. */
85 uint8_t hsrp_hellotime
;
86 uint8_t hsrp_holdtime
;
87 uint8_t hsrp_priority
;
89 uint8_t hsrp_reserved
;
90 uint8_t hsrp_authdata
[HSRP_AUTH_SIZE
];
91 struct in_addr hsrp_virtaddr
;
95 hsrp_print(netdissect_options
*ndo
, register const uint8_t *bp
, register u_int len
)
97 struct hsrp
*hp
= (struct hsrp
*) bp
;
99 ND_TCHECK(hp
->hsrp_version
);
100 ND_PRINT((ndo
, "HSRPv%d", hp
->hsrp_version
));
101 if (hp
->hsrp_version
!= 0)
103 ND_TCHECK(hp
->hsrp_op_code
);
104 ND_PRINT((ndo
, "-"));
105 ND_PRINT((ndo
, "%s ", tok2strary(op_code_str
, "unknown (%d)", hp
->hsrp_op_code
)));
106 ND_PRINT((ndo
, "%d: ", len
));
107 ND_TCHECK(hp
->hsrp_state
);
108 ND_PRINT((ndo
, "state=%s ", tok2str(states
, "Unknown (%d)", hp
->hsrp_state
)));
109 ND_TCHECK(hp
->hsrp_group
);
110 ND_PRINT((ndo
, "group=%d ", hp
->hsrp_group
));
111 ND_TCHECK(hp
->hsrp_reserved
);
112 if (hp
->hsrp_reserved
!= 0) {
113 ND_PRINT((ndo
, "[reserved=%d!] ", hp
->hsrp_reserved
));
115 ND_TCHECK(hp
->hsrp_virtaddr
);
116 ND_PRINT((ndo
, "addr=%s", ipaddr_string(ndo
, &hp
->hsrp_virtaddr
)));
117 if (ndo
->ndo_vflag
) {
118 ND_PRINT((ndo
, " hellotime="));
119 relts_print(ndo
, hp
->hsrp_hellotime
);
120 ND_PRINT((ndo
, " holdtime="));
121 relts_print(ndo
, hp
->hsrp_holdtime
);
122 ND_PRINT((ndo
, " priority=%d", hp
->hsrp_priority
));
123 ND_PRINT((ndo
, " auth=\""));
124 if (fn_printn(ndo
, hp
->hsrp_authdata
, sizeof(hp
->hsrp_authdata
),
126 ND_PRINT((ndo
, "\""));
129 ND_PRINT((ndo
, "\""));
133 ND_PRINT((ndo
, "[|hsrp]"));