Ethereal-dev: [Ethereal-dev] hsrp and vrrp updates
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Heikki Vatiainen <hessu@xxxxxxxxx>
Date: 12 Jul 2001 17:25:02 +0300
Update for VRRP adds more header fields for filtering. Update for HSRP corrects the use of proto_tree_add_item and gets rid of unnecessary proto_tree_add_ipv4 by replacing it with the generic proto_tree_add_item function. Index: packet-hsrp.c =================================================================== RCS file: /cvsroot/ethereal/packet-hsrp.c,v retrieving revision 1.17 diff -u -r1.17 packet-hsrp.c --- packet-hsrp.c 2001/06/18 02:17:46 1.17 +++ packet-hsrp.c 2001/07/12 14:09:29 @@ -126,13 +126,12 @@ int offset; guint8 hellotime, holdtime; guint8 auth_buf[8 + 1]; - guint32 virt_ip_addr; offset = 0; ti = proto_tree_add_item(tree, proto_hsrp, tvb, offset, tvb_length(tvb), FALSE); hsrp_tree = proto_item_add_subtree(ti, ett_hsrp); - proto_tree_add_uint(hsrp_tree, hf_hsrp_version, tvb, offset, 1, tvb_get_guint8(tvb, offset)); + proto_tree_add_item(hsrp_tree, hf_hsrp_version, tvb, offset, 1, FALSE); offset++; proto_tree_add_uint(hsrp_tree, hf_hsrp_opcode, tvb, offset, 1, opcode); offset++; @@ -150,11 +149,11 @@ (holdtime == HSRP_DEFAULT_HOLDTIME) ? "" : "Non-", holdtime); offset++; - proto_tree_add_item(hsrp_tree, hf_hsrp_priority, tvb, offset, 1, tvb_get_guint8(tvb, offset)); + proto_tree_add_item(hsrp_tree, hf_hsrp_priority, tvb, offset, 1, FALSE); offset++; - proto_tree_add_item(hsrp_tree, hf_hsrp_group, tvb, offset, 1, tvb_get_guint8(tvb, offset)); + proto_tree_add_item(hsrp_tree, hf_hsrp_group, tvb, offset, 1, FALSE); offset++; - proto_tree_add_item(hsrp_tree, hf_hsrp_reserved, tvb, offset, 1, tvb_get_guint8(tvb, offset)); + proto_tree_add_item(hsrp_tree, hf_hsrp_reserved, tvb, offset, 1, FALSE); offset++; tvb_memcpy(tvb, auth_buf, offset, 8); auth_buf[sizeof auth_buf - 1] = '\0'; @@ -163,8 +162,7 @@ (tvb_strneql(tvb, offset, "cisco", strlen("cisco"))) == 0 ? "" : "Non-", auth_buf); offset += 8; - tvb_memcpy(tvb, (guint8 *)&virt_ip_addr, offset, 4); - proto_tree_add_ipv4(hsrp_tree, hf_hsrp_virt_ip_addr, tvb, offset, 4, virt_ip_addr); + proto_tree_add_item(hsrp_tree, hf_hsrp_virt_ip_addr, tvb, offset, 4, FALSE); offset += 4; } Index: packet-vrrp.c =================================================================== RCS file: /cvsroot/ethereal/packet-vrrp.c,v retrieving revision 1.16 diff -u -r1.16 packet-vrrp.c --- packet-vrrp.c 2001/06/18 02:17:53 1.16 +++ packet-vrrp.c 2001/07/12 14:09:29 @@ -51,6 +51,12 @@ static gint hf_vrrp_ver_type = -1; static gint hf_vrrp_version = -1; static gint hf_vrrp_type = -1; +static gint hf_vrrp_virt_rtr_id = -1; +static gint hf_vrrp_prio = -1; +static gint hf_vrrp_count_ip = -1; +static gint hf_vrrp_auth_type = -1; +static gint hf_vrrp_adver_int = -1; +static gint hf_vrrp_ip = -1; #define VRRP_VERSION_MASK 0xf0 #define VRRP_TYPE_MASK 0x0f @@ -106,7 +112,7 @@ if (tree) { proto_item *ti, *tv; proto_tree *vrrp_tree, *ver_type_tree; - guint8 priority, ip_count, auth_type, adver_int; + guint8 priority, ip_count, auth_type; guint16 cksum, computed_cksum; guint8 auth_buf[VRRP_AUTH_DATA_LEN+1]; @@ -126,37 +132,29 @@ ver_type); offset++; - proto_tree_add_text(vrrp_tree, tvb, offset, 1, - "Virtual Router ID: %u", - tvb_get_guint8(tvb, offset)); + proto_tree_add_item(vrrp_tree, hf_vrrp_virt_rtr_id, tvb, offset, 1, FALSE); offset++; priority = tvb_get_guint8(tvb, offset); - proto_tree_add_text(vrrp_tree, tvb, offset, 1, "Priority: %u (%s)", - priority, - val_to_str(priority, vrrp_prio_vals, "Non-default backup priority")); + proto_tree_add_uint_format(vrrp_tree, hf_vrrp_prio, tvb, offset, 1, priority, "Priority: %u (%s)", + priority, + val_to_str(priority, vrrp_prio_vals, "Non-default backup priority")); offset++; ip_count = tvb_get_guint8(tvb, offset); - proto_tree_add_text(vrrp_tree, tvb, offset, 1, - "Count IP Addrs: %u", ip_count); + proto_tree_add_uint(vrrp_tree, hf_vrrp_count_ip, tvb, offset, 1, ip_count); offset++; auth_type = tvb_get_guint8(tvb, offset); - proto_tree_add_text(vrrp_tree, tvb, offset, 1, - "Authentication Type: %u (%s)", auth_type, - val_to_str(auth_type, vrrp_auth_vals, "Unknown")); + proto_tree_add_item(vrrp_tree, hf_vrrp_auth_type, tvb, offset, 1, FALSE); offset++; - adver_int = tvb_get_guint8(tvb, offset); - proto_tree_add_text(vrrp_tree, tvb, offset, 1, - "Advertisement Interval: %u second%s", - adver_int, plurality(adver_int, "", "s")); + proto_tree_add_item(vrrp_tree, hf_vrrp_adver_int, tvb, offset, 1, FALSE); offset++; cksum = tvb_get_ntohs(tvb, offset); - vrrp_len = tvb_reported_length(tvb); - if (!pinfo->fragmented && tvb_length(tvb) >= vrrp_len) { + vrrp_len = (gint)tvb_reported_length(tvb); + if (!pinfo->fragmented && (gint)tvb_length(tvb) >= vrrp_len) { /* The packet isn't part of a fragmented datagram and isn't truncated, so we can checksum it. */ cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, vrrp_len); @@ -179,9 +177,7 @@ offset+=2; while (ip_count > 0) { - proto_tree_add_text(vrrp_tree, tvb, offset, 4, - "Virtual Router IP address: %s", - ip_to_str(tvb_get_ptr(tvb, offset, 4))); + proto_tree_add_item(vrrp_tree, hf_vrrp_ip, tvb, offset, 4, FALSE); offset+=4; ip_count--; } @@ -215,7 +211,38 @@ { &hf_vrrp_type, {"VRRP packet type", "vrrp.type", FT_UINT8, BASE_DEC, VALS(vrrp_type_vals), VRRP_TYPE_MASK, - "VRRP type", HFILL }} + "VRRP type", HFILL }}, + + { &hf_vrrp_virt_rtr_id, + {"Virtual Rtr ID", "vrrp.virt_rtr_id", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Virtual router this packet is reporting status for", HFILL }}, + + { &hf_vrrp_prio, + {"Priority", "vrrp.prio", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Sending VRRP router's priority for the virtual router", HFILL }}, + + { &hf_vrrp_count_ip, + {"Count IP Addrs", "vrrp.count_ip_addrs", + FT_UINT8, BASE_DEC, NULL, 0x0, + "The number of IP addresses contained in this VRRP advertisement", HFILL }}, + + { &hf_vrrp_auth_type, + {"Auth Type", "vrrp.auth_type", + FT_UINT8, BASE_DEC, VALS(vrrp_auth_vals), 0x0, + "The authentication method being utilized", HFILL }}, + + { &hf_vrrp_adver_int, + {"Adver Int", "vrrp.adver_int", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Time interval (in seconds) between ADVERTISEMENTS", HFILL }}, + + { &hf_vrrp_ip, + {"IP Address", "vrrp.ip_addr", + FT_IPv4, 0, NULL, 0x0, + "IP address associated with the virtual router", HFILL }}, + }; static gint *ett[] = { -- Heikki Vatiainen * hessu@xxxxxxxxx Tampere University of Technology * Tampere, Finland
- Follow-Ups:
- Re: [Ethereal-dev] hsrp and vrrp updates
- From: Guy Harris
- Re: [Ethereal-dev] hsrp and vrrp updates
- Prev by Date: [Ethereal-dev] ethereal-announce
- Next by Date: [Ethereal-dev] segfault question
- Previous by thread: [Ethereal-dev] ethereal-announce
- Next by thread: Re: [Ethereal-dev] hsrp and vrrp updates
- Index(es):