diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 1999-11-21 14:43:53 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 1999-11-21 14:43:53 +0000 |
commit | 34c9f8241c4b90afde5acce7211b7895a6e219ad (patch) | |
tree | 799db60e6c7d29589ae0d24371731aa65714ceb4 | |
parent | eb65d4fdb9286a6d339b01e9c4b60a5441aa3aa3 (diff) | |
download | wireshark-34c9f8241c4b90afde5acce7211b7895a6e219ad.tar.gz wireshark-34c9f8241c4b90afde5acce7211b7895a6e219ad.tar.bz2 wireshark-34c9f8241c4b90afde5acce7211b7895a6e219ad.zip |
Added Heikki Vatiainen's <hessu@cs.tut.fi> VRRP dissector.
svn path=/trunk/; revision=1083
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | ipproto.c | 3 | ||||
-rw-r--r-- | packet-ip.c | 5 | ||||
-rw-r--r-- | packet-ip.h | 3 | ||||
-rw-r--r-- | packet-vrrp.c | 213 | ||||
-rw-r--r-- | packet.h | 3 |
6 files changed, 225 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index c4340e86f3..fbbfce641f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.113 1999/11/19 09:55:37 guy Exp $ +# $Id: Makefile.am,v 1.114 1999/11/21 14:43:51 gram Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@zing.org> @@ -133,6 +133,7 @@ DISSECTOR_SOURCES = \ packet-vines.c \ packet-vines.h \ packet-vlan.c \ + packet-vrrp.c \ packet-x25.c \ packet-yhoo.c \ packet-yhoo.h \ @@ -1,7 +1,7 @@ /* ipproto.c * Routines for converting IPv4 protocol/v6 nxthdr field into string * - * $Id: ipproto.c,v 1.3 1999/10/22 08:02:21 guy Exp $ + * $Id: ipproto.c,v 1.4 1999/11/21 14:43:52 gram Exp $ * * Gilbert Ramirez <gram@verdict.uthscsa.edu> * @@ -88,6 +88,7 @@ static const value_string ipproto_val[] = { { IP_PROTO_ENCAP, "ENCAP" }, { IP_PROTO_PIM, "PIM" }, { IP_PROTO_IPCOMP, "IPComp" }, + { IP_PROTO_VRRP, "VRRP" }, { 0, NULL }, }; diff --git a/packet-ip.c b/packet-ip.c index 9f58e2edb5..fe3d877a6f 100644 --- a/packet-ip.c +++ b/packet-ip.c @@ -1,7 +1,7 @@ /* packet-ip.c * Routines for IP and miscellaneous IP protocol packet disassembly * - * $Id: packet-ip.c,v 1.63 1999/11/17 01:35:57 guy Exp $ + * $Id: packet-ip.c,v 1.64 1999/11/21 14:43:52 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -948,6 +948,9 @@ again: case IP_PROTO_IPCOMP: dissect_ipcomp(pd, offset, fd, tree); break; + case IP_PROTO_VRRP: + dissect_vrrp(pd, offset, fd, tree); + break; default: dissect_data(pd, offset, fd, tree); break; diff --git a/packet-ip.h b/packet-ip.h index 606ca91dcf..2d686fd527 100644 --- a/packet-ip.h +++ b/packet-ip.h @@ -1,7 +1,7 @@ /* packet-ip.h * Definitions for IP packet disassembly structures and routines * - * $Id: packet-ip.h,v 1.8 1999/11/16 11:42:34 guy Exp $ + * $Id: packet-ip.h,v 1.9 1999/11/21 14:43:53 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -56,6 +56,7 @@ #define IP_PROTO_ENCAP 98 /* encapsulation header */ #define IP_PROTO_PIM 103 /* Protocol Independent Mcast */ #define IP_PROTO_IPCOMP 108 /* IP payload compression */ +#define IP_PROTO_VRRP 112 /* Virtual Router Redundancy Protocol */ typedef enum { NO_LENGTH, /* option has no data, hence no length */ diff --git a/packet-vrrp.c b/packet-vrrp.c new file mode 100644 index 0000000000..83354285f8 --- /dev/null +++ b/packet-vrrp.c @@ -0,0 +1,213 @@ +/* packet-vrrp.c + * Routines for the Virtual Router Redundancy Protocol (VRRP) + * RFC2338 + * + * Heikki Vatiainen <hessu@cs.tut.fi> + * + * $Id: packet-vrrp.c,v 1.1 1999/11/21 14:43:53 gram Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@unicom.net> + * Copyright 1998 Gerald Combs + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif + +#include <string.h> +#include <glib.h> +#include "packet.h" + +static gint proto_vrrp = -1; +static gint ett_vrrp = -1; +static gint ett_vrrp_ver_type = -1; + +static gint hf_vrrp_ver_type = -1; +static gint hf_vrrp_version = -1; +static gint hf_vrrp_type = -1; + +struct vrrp_header { +#define VRRP_VERSION_MASK 0xf0 +#define VRRP_TYPE_MASK 0x0f + guint8 ver_type; + guint8 vrouter_id; + guint8 priority; + guint8 count_ip_addrs; + guint8 auth_type; + guint8 adver_int; + guint16 checksum; + /* One or more IP addresses */ + /* 8 octets of authentication data */ +#define VRRP_AUTH_DATA_LEN 8 +}; + + +#define VRRP_TYPE_ADVERTISEMENT 1 +static const value_string vrrp_type_vals[] = { + {VRRP_TYPE_ADVERTISEMENT, "Advertisement"} +}; + +#define VRRP_AUTH_TYPE_NONE 0 +#define VRRP_AUTH_TYPE_SIMPLE_TEXT 1 +#define VRRP_AUTH_TYPE_IP_AUTH_HDR 2 +static const value_string vrrp_auth_vals[] = { + {VRRP_AUTH_TYPE_NONE, "No Authentication"}, + {VRRP_AUTH_TYPE_SIMPLE_TEXT, "Simple Text Authentication"}, + {VRRP_AUTH_TYPE_IP_AUTH_HDR, "IP Authentication Header"} +}; + +#define VRRP_PRIORITY_MASTER_STOPPING 0 +/* Values between 1 and 254 inclusive are for backup VRRP routers */ +#define VRRP_PRIORITY_DEFAULT 100 +#define VRRP_PRIORITY_OWNER 255 +static const value_string vrrp_prio_vals[] = { + {VRRP_PRIORITY_MASTER_STOPPING, "Current Master has stopped participating in VRRP"}, + {VRRP_PRIORITY_DEFAULT, "Default priority for a backup VRRP router"}, + {VRRP_PRIORITY_OWNER, "This VRRP router owns the virtual router's IP address(es)"} +}; + + +void dissect_vrrp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) +{ + struct vrrp_header vrh; + gboolean short_hdr = FALSE; + gboolean short_packet = FALSE; + guint calculated_len = -1; /* initialize to silence false warning from gcc */ + + if (sizeof(struct vrrp_header) > END_OF_FRAME) + short_hdr = short_packet = TRUE; + else { + memcpy(&vrh, pd + offset, sizeof(struct vrrp_header)); + calculated_len = sizeof(struct vrrp_header) + vrh.count_ip_addrs*4 + VRRP_AUTH_DATA_LEN; + if (calculated_len > END_OF_FRAME) + short_packet = TRUE; + } + + if (check_col(fd, COL_PROTOCOL)) + col_add_str(fd, COL_PROTOCOL, "VRRP"); + + if (check_col(fd, COL_INFO)) { + if (short_hdr) + col_add_fstr(fd, COL_INFO, "Short packet header, length %u", END_OF_FRAME); + else if (short_packet) + col_add_fstr(fd, COL_INFO, "Packet length mismatch, calculated %u, real %u", + calculated_len, END_OF_FRAME); + else + col_add_fstr(fd, COL_INFO, "%s (v%u)", "Announcement", hi_nibble(vrh.ver_type)); + } + + if (tree) { + proto_item *ti, *tv; + proto_tree *vrrp_tree, *ver_type_tree; + guint8 ip_count, auth_len, auth_buf[VRRP_AUTH_DATA_LEN+1]; + + if (short_hdr) { + dissect_data(pd, offset, fd, tree); + return; + } + + ti = proto_tree_add_item(tree, proto_vrrp, offset, END_OF_FRAME, NULL); + vrrp_tree = proto_item_add_subtree(ti, ett_vrrp); + + tv = proto_tree_add_item_format(vrrp_tree, hf_vrrp_ver_type, offset, 1, + vrh.ver_type, "Version %u, Packet type %u (%s)", + hi_nibble(vrh.ver_type), lo_nibble(vrh.ver_type), + val_to_str(lo_nibble(vrh.ver_type), vrrp_type_vals, "Unknown")); + ver_type_tree = proto_item_add_subtree(tv, ett_vrrp_ver_type); + proto_tree_add_item(ver_type_tree, hf_vrrp_version, offset, 1, vrh.ver_type); + proto_tree_add_item(ver_type_tree, hf_vrrp_type, offset, 1, vrh.ver_type); + offset++; + + proto_tree_add_text(vrrp_tree, offset++, 1, "Virtual Router ID: %u", vrh.vrouter_id); + proto_tree_add_text(vrrp_tree, offset++, 1, "Priority: %u (%s)", vrh.priority, + val_to_str(vrh.priority, vrrp_prio_vals, "Non-default backup priority")); + proto_tree_add_text(vrrp_tree, offset++, 1, "Count IP Addrs: %u", vrh.count_ip_addrs); + proto_tree_add_text(vrrp_tree, offset++, 1, "Authentication Type: %u (%s)", vrh.auth_type, + val_to_str(vrh.auth_type, vrrp_auth_vals, "Unknown")); + proto_tree_add_text(vrrp_tree, offset++, 1, "Advertisement Interval: %u second%s", + vrh.adver_int, plurality(vrh.adver_int, "", "s")); + proto_tree_add_text(vrrp_tree, offset, 2, "Checksum: 0x%x", htons(vrh.checksum)); + offset+=2; + + if (short_packet) { + dissect_data(pd, offset, fd, vrrp_tree); + return; + } + + ip_count = vrh.count_ip_addrs; + while (ip_count > 0) { + proto_tree_add_text(vrrp_tree, offset, 4, "Virtual Router IP address: %s", + ip_to_str(pd+offset)); + offset+=4; + ip_count--; + } + + if (vrh.auth_type != VRRP_AUTH_TYPE_SIMPLE_TEXT) + return; /* Contents of the authentication data is undefined */ + + strncpy(auth_buf, pd+offset, VRRP_AUTH_DATA_LEN); + auth_buf[VRRP_AUTH_DATA_LEN] = '\0'; + auth_len = strlen(auth_buf); + if (auth_len > 0) + proto_tree_add_text(vrrp_tree, offset, auth_len, "Authentication string: `%s'", auth_buf); + offset+=8; + + } + + return; +} + +void proto_register_vrrp(void) +{ + static hf_register_info hf[] = { + { &hf_vrrp_ver_type, + {"VRRP message version and type", "vrrp.typever", + FT_UINT8, BASE_DEC, NULL, 0x0, + "VRRP version and type"}}, + + { &hf_vrrp_version, + {"VRRP protocol version", "vrrp.version", + FT_UINT8, BASE_DEC, NULL, VRRP_VERSION_MASK, + "VRRP version"}}, + + { &hf_vrrp_type, + {"VRRP packet type", "vrrp.type", + FT_UINT8, BASE_DEC, VALS(vrrp_type_vals), VRRP_TYPE_MASK, + "VRRP type"}} + }; + + static gint *ett[] = { + &ett_vrrp, + &ett_vrrp_ver_type + }; + + proto_vrrp = proto_register_protocol("Virtual Router Redundancy Protocol", "vrrp"); + proto_register_field_array(proto_vrrp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + return; +} @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.147 1999/11/20 05:35:14 gram Exp $ + * $Id: packet.h,v 1.148 1999/11/21 14:43:53 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -388,6 +388,7 @@ void dissect_vines_ipc(const u_char *, int, frame_data *, proto_tree *); void dissect_vines_rtp(const u_char *, int, frame_data *, proto_tree *); void dissect_vines_spp(const u_char *, int, frame_data *, proto_tree *); void dissect_vlan(const u_char *, int, frame_data *, proto_tree *); +void dissect_vrrp(const u_char *, int, frame_data *, proto_tree *); void dissect_payload_ppp(const u_char *, int, frame_data *, proto_tree *); void dissect_x25(const u_char *, int, frame_data *, proto_tree *); void dissect_yhoo(const u_char *, int, frame_data *, proto_tree *); |