4 * Copyright (c) 2000 William C. Fenner.
7 * Kevin Steves <ks@hp.se> July 2000
9 * - print version, type string and packet length
10 * - print IP address count if > 1 (-v)
11 * - verify checksum (-v)
12 * - print authentication string (-v)
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that: (1) source code
16 * distributions retain the above copyright notice and this paragraph
17 * in its entirety, and (2) distributions including binary code include
18 * the above copyright notice and this paragraph in its entirety in
19 * the documentation or other materials provided with the distribution.
20 * The name of William C. Fenner may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND
23 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
24 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE.
28 #include <sys/cdefs.h>
31 static const char rcsid
[] _U_
=
32 "@(#) Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.9.2.1 2005/05/06 07:57:20 guy Exp";
34 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
42 #include <tcpdump-stdinc.h>
47 #include "interface.h"
49 #include "addrtoname.h"
54 * 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
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * |Version| Type | Virtual Rtr ID| Priority | Count IP Addrs|
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * | Auth Type | Adver Int | Checksum |
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 * | Authentication Data (1) |
69 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 * | Authentication Data (2) |
71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 #define VRRP_TYPE_ADVERTISEMENT 1
77 static const struct tok type2str
[] = {
78 { VRRP_TYPE_ADVERTISEMENT
, "Advertisement" },
83 #define VRRP_AUTH_NONE 0
84 #define VRRP_AUTH_SIMPLE 1
85 #define VRRP_AUTH_AH 2
87 static const struct tok auth2str
[] = {
88 { VRRP_AUTH_NONE
, "none" },
89 { VRRP_AUTH_SIMPLE
, "simple" },
90 { VRRP_AUTH_AH
, "ah" },
95 vrrp_print(register const u_char
*bp
, register u_int len
, int ttl
)
97 int version
, type
, auth_type
;
101 version
= (bp
[0] & 0xf0) >> 4;
103 type_s
= tok2str(type2str
, "unknown type (%u)", type
);
104 printf("VRRPv%u, %s", version
, type_s
);
106 printf(", (ttl %u)", ttl
);
107 if (version
!= 2 || type
!= VRRP_TYPE_ADVERTISEMENT
)
110 printf(", vrid %u, prio %u", bp
[1], bp
[2]);
113 printf(", authtype %s", tok2str(auth2str
, NULL
, auth_type
));
114 printf(", intvl %us, length %u", bp
[5],len
);
120 if (TTEST2(bp
[0], len
) && in_cksum((const u_short
*)bp
, len
, 0))
121 printf(", (bad vrrp cksum %x)",
122 EXTRACT_16BITS(&bp
[6]));
125 printf("(%d)", naddrs
);
129 for (i
= 0; i
< naddrs
; i
++) {
131 printf("%c%s", c
, ipaddr_string(bp
));
135 if (auth_type
== VRRP_AUTH_SIMPLE
) { /* simple text password */
138 if (fn_printn(bp
, 8, snapend
)) {