1999-11-23 17:09:58 +00:00
|
|
|
/* packet-auto_rp.c
|
|
|
|
* Routines for the Cisco Auto-RP protocol
|
|
|
|
* ftp://ftpeng.cisco.com/ftp/ipmulticast/specs/pim-autorp-spec01.txt
|
|
|
|
*
|
|
|
|
* Heikki Vatiainen <hessu@cs.tut.fi>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1999-11-23 17:09:58 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1999-11-23 17:09:58 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-23 17:09:58 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-23 17:09:58 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-23 17:09:58 +00:00
|
|
|
* 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
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2004-08-06 19:57:49 +00:00
|
|
|
#include <epan/addr_resolv.h>
|
1999-11-23 17:09:58 +00:00
|
|
|
|
|
|
|
static gint proto_auto_rp = -1;
|
|
|
|
static gint ett_auto_rp = -1;
|
|
|
|
static gint ett_auto_rp_ver_type = -1;
|
|
|
|
static gint ett_auto_rp_map = -1;
|
|
|
|
static gint ett_auto_rp_group = -1;
|
|
|
|
|
|
|
|
static gint hf_auto_rp_version = -1;
|
|
|
|
static gint hf_auto_rp_type = -1;
|
2000-11-19 20:01:22 +00:00
|
|
|
static gint hf_auto_rp_count = -1;
|
|
|
|
static gint hf_auto_rp_holdtime = -1;
|
1999-11-23 17:09:58 +00:00
|
|
|
static gint hf_auto_rp_pim_ver = -1;
|
2000-11-19 20:01:22 +00:00
|
|
|
static gint hf_auto_rp_rp_addr = -1;
|
|
|
|
static gint hf_auto_rp_prefix_sgn = -1;
|
|
|
|
static gint hf_auto_rp_mask_len = -1;
|
|
|
|
static gint hf_auto_rp_group_prefix = -1;
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-04-08 07:07:42 +00:00
|
|
|
#define UDP_PORT_PIM_RP_DISC 496
|
|
|
|
|
1999-11-23 17:09:58 +00:00
|
|
|
struct auto_rp_fixed_hdr {
|
|
|
|
#define AUTO_RP_VERSION_MASK 0xf0
|
|
|
|
#define AUTO_RP_TYPE_MASK 0x0f
|
|
|
|
guint8 ver_type; /* pim-autorp-spec01.txt defines version 1+ */
|
|
|
|
guint8 rp_count; /* Number of struct auto_rp_maps that follow the this header */
|
|
|
|
guint16 holdtime; /* Time in seconds this announcement is valid. 0 equals forever */
|
|
|
|
guint32 reserved;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct auto_rp_map_hdr {
|
|
|
|
guint32 rp_address; /* The unicast IPv4 address of this RP */
|
|
|
|
#define AUTO_RP_PIM_VER_MASK 0x03
|
|
|
|
guint8 pim_version; /* RP's highest PIM version. 2-bit field */
|
|
|
|
guint8 group_count; /* Number of encoded group addresses that follow this header */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct auto_rp_enc_grp_hdr { /* Encoded group address */
|
|
|
|
#define AUTO_RP_SIGN_MASK 0x01
|
|
|
|
guint8 prefix_sgn; /* 0 positive, 1 negative group prefix */
|
|
|
|
guint8 mask_len; /* Length of group prefix */
|
|
|
|
guint32 addr; /* Group prefix */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AUTO_RP_VER_1PLUS 1
|
|
|
|
static const value_string auto_rp_ver_vals[] = {
|
|
|
|
{AUTO_RP_VER_1PLUS, "1 or 1+"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AUTO_RP_TYPE_ANNOUNCEMENT 1
|
|
|
|
#define AUTO_RP_TYPE_MAPPING 2
|
|
|
|
static const value_string auto_rp_type_vals[] = {
|
|
|
|
{AUTO_RP_TYPE_ANNOUNCEMENT, "RP announcement"},
|
|
|
|
{AUTO_RP_TYPE_MAPPING, "RP mapping"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AUTO_RP_PIM_VERSION_UNKNOWN 0x00
|
|
|
|
#define AUTO_RP_PIM_VERSION_1 0x01
|
|
|
|
#define AUTO_RP_PIM_VERSION_2 0x02
|
|
|
|
#define AUTO_RP_PIM_VERSION_DUAL 0x03
|
|
|
|
static const value_string auto_rp_pim_ver_vals[] = {
|
|
|
|
{AUTO_RP_PIM_VERSION_UNKNOWN, "Version unknown"},
|
|
|
|
{AUTO_RP_PIM_VERSION_1, "Version 1"},
|
|
|
|
{AUTO_RP_PIM_VERSION_2, "Version 2"},
|
|
|
|
{AUTO_RP_PIM_VERSION_DUAL, "Dual version 1 and 2"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AUTO_RP_GROUP_MASK_SIGN_POS 0
|
|
|
|
#define AUTO_RP_GROUP_MASK_SIGN_NEG 1
|
|
|
|
static const value_string auto_rp_mask_sign_vals[] = {
|
|
|
|
{AUTO_RP_GROUP_MASK_SIGN_POS, "Positive group prefix"},
|
|
|
|
{AUTO_RP_GROUP_MASK_SIGN_NEG, "Negative group prefix"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree);
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
static void dissect_auto_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
1999-11-23 17:09:58 +00:00
|
|
|
{
|
2000-11-19 20:01:22 +00:00
|
|
|
guint8 ver_type, rp_count;
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Auto-RP");
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
ver_type = tvb_get_guint8(tvb, 0);
|
|
|
|
rp_count = tvb_get_guint8(tvb, 1);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s (v%s) for %u RP%s",
|
2000-11-19 20:01:22 +00:00
|
|
|
val_to_str(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"),
|
|
|
|
val_to_str(hi_nibble(ver_type), auto_rp_ver_vals, "Unknown"),
|
|
|
|
rp_count, plurality(rp_count, "", "s"));
|
1999-11-23 17:09:58 +00:00
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
proto_item *ti, *tv;
|
|
|
|
proto_tree *auto_rp_tree, *ver_type_tree;
|
2000-11-19 20:01:22 +00:00
|
|
|
int i, offset;
|
|
|
|
guint16 holdtime;
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
offset = 0;
|
2002-01-24 09:20:54 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_auto_rp, tvb, offset, -1, FALSE);
|
1999-11-23 17:09:58 +00:00
|
|
|
auto_rp_tree = proto_item_add_subtree(ti, ett_auto_rp);
|
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
tv = proto_tree_add_text(auto_rp_tree, tvb, offset, 1, "Version: %s, Packet type: %s",
|
|
|
|
val_to_str(hi_nibble(ver_type), auto_rp_ver_vals, "Unknown"),
|
|
|
|
val_to_str(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"));
|
1999-11-23 17:09:58 +00:00
|
|
|
ver_type_tree = proto_item_add_subtree(tv, ett_auto_rp_ver_type);
|
2000-11-19 20:01:22 +00:00
|
|
|
proto_tree_add_uint(ver_type_tree, hf_auto_rp_version, tvb, offset, 1, ver_type);
|
|
|
|
proto_tree_add_uint(ver_type_tree, hf_auto_rp_type, tvb, offset, 1, ver_type);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
proto_tree_add_uint(auto_rp_tree, hf_auto_rp_count, tvb, offset, 1, rp_count);
|
1999-11-23 17:09:58 +00:00
|
|
|
offset++;
|
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
holdtime = tvb_get_ntohs(tvb, offset);
|
2006-02-16 11:43:38 +00:00
|
|
|
proto_tree_add_uint_format_value(auto_rp_tree, hf_auto_rp_holdtime, tvb, offset, 2, holdtime,
|
|
|
|
"%u second%s", holdtime, plurality(holdtime, "", "s"));
|
1999-11-23 17:09:58 +00:00
|
|
|
offset+=2;
|
2000-11-19 20:01:22 +00:00
|
|
|
|
|
|
|
proto_tree_add_text(auto_rp_tree, tvb, offset, 4, "Reserved: 0x%x", tvb_get_ntohs(tvb, offset));
|
1999-11-23 17:09:58 +00:00
|
|
|
offset+=4;
|
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
for (i = 0; i < rp_count; i++)
|
|
|
|
offset = do_auto_rp_map(tvb, offset, auto_rp_tree);
|
|
|
|
|
2002-02-01 12:05:59 +00:00
|
|
|
if (tvb_offset_exists(tvb, offset))
|
2002-02-01 04:34:17 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, -1, "Trailing junk");
|
1999-11-23 17:09:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_auto_rp(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_auto_rp_version,
|
2000-11-19 20:01:22 +00:00
|
|
|
{"Protocol version", "auto_rp.version",
|
1999-11-23 17:09:58 +00:00
|
|
|
FT_UINT8, BASE_DEC, VALS(auto_rp_ver_vals), AUTO_RP_VERSION_MASK,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Auto-RP protocol version", HFILL }},
|
1999-11-23 17:09:58 +00:00
|
|
|
|
|
|
|
{ &hf_auto_rp_type,
|
2000-11-19 20:01:22 +00:00
|
|
|
{"Packet type", "auto_rp.type",
|
1999-11-23 17:09:58 +00:00
|
|
|
FT_UINT8, BASE_DEC, VALS(auto_rp_type_vals), AUTO_RP_TYPE_MASK,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Auto-RP packet type", HFILL }},
|
2000-11-19 20:01:22 +00:00
|
|
|
|
|
|
|
{ &hf_auto_rp_count,
|
|
|
|
{"RP count", "auto_rp.rp_count",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"The number of RP addresses contained in this message", HFILL }},
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
{ &hf_auto_rp_holdtime,
|
|
|
|
{"Holdtime", "auto_rp.holdtime",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"The amount of time in seconds this announcement is valid", HFILL }},
|
1999-11-23 17:09:58 +00:00
|
|
|
|
|
|
|
{ &hf_auto_rp_pim_ver,
|
2000-11-19 20:01:22 +00:00
|
|
|
{"Version", "auto_rp.pim_ver",
|
1999-11-23 17:09:58 +00:00
|
|
|
FT_UINT8, BASE_DEC, VALS(auto_rp_pim_ver_vals), AUTO_RP_PIM_VER_MASK,
|
2001-06-18 02:18:27 +00:00
|
|
|
"RP's highest PIM version", HFILL }},
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
{ &hf_auto_rp_rp_addr,
|
|
|
|
{"RP address", "auto_rp.rp_addr",
|
|
|
|
FT_IPv4, 0, NULL, 0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"The unicast IP address of the RP", HFILL }},
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
{ &hf_auto_rp_prefix_sgn,
|
|
|
|
{"Sign", "auto_rp.prefix_sign",
|
1999-11-23 17:09:58 +00:00
|
|
|
FT_UINT8, BASE_DEC, VALS(auto_rp_mask_sign_vals), AUTO_RP_SIGN_MASK,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Group prefix sign", HFILL }},
|
2000-11-19 20:01:22 +00:00
|
|
|
|
|
|
|
{ &hf_auto_rp_mask_len,
|
|
|
|
{"Mask length", "auto_rp.mask_len",
|
2003-01-31 03:17:56 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Length of group prefix", HFILL }},
|
2000-11-19 20:01:22 +00:00
|
|
|
|
|
|
|
{ &hf_auto_rp_group_prefix,
|
|
|
|
{"Prefix", "auto_rp.group_prefix",
|
|
|
|
FT_IPv4, 0, NULL, 0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Group prefix", HFILL }}
|
1999-11-23 17:09:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_auto_rp,
|
|
|
|
&ett_auto_rp_ver_type,
|
|
|
|
&ett_auto_rp_map,
|
|
|
|
&ett_auto_rp_group
|
|
|
|
};
|
|
|
|
|
2001-01-03 06:56:03 +00:00
|
|
|
proto_auto_rp = proto_register_protocol("Cisco Auto-RP",
|
|
|
|
"Auto-RP", "auto_rp");
|
1999-11-23 17:09:58 +00:00
|
|
|
proto_register_field_array(proto_auto_rp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-04-08 07:07:42 +00:00
|
|
|
void
|
|
|
|
proto_reg_handoff_auto_rp(void)
|
|
|
|
{
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_handle_t auto_rp_handle;
|
|
|
|
|
|
|
|
auto_rp_handle = create_dissector_handle(dissect_auto_rp,
|
2001-01-09 06:32:10 +00:00
|
|
|
proto_auto_rp);
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_add("udp.port", UDP_PORT_PIM_RP_DISC, auto_rp_handle);
|
2000-04-08 07:07:42 +00:00
|
|
|
}
|
|
|
|
|
1999-11-23 17:09:58 +00:00
|
|
|
/*
|
2000-11-19 20:01:22 +00:00
|
|
|
* Handles one Auto-RP map entry. Returns the new offset.
|
1999-11-23 17:09:58 +00:00
|
|
|
*/
|
2000-11-19 20:01:22 +00:00
|
|
|
static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree)
|
1999-11-23 17:09:58 +00:00
|
|
|
{
|
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *map_tree;
|
2000-11-19 20:01:22 +00:00
|
|
|
guint8 group_count;
|
|
|
|
guint32 rp_addr; /* In network byte order */
|
1999-11-23 17:09:58 +00:00
|
|
|
int i;
|
|
|
|
|
2005-09-11 21:25:37 +00:00
|
|
|
rp_addr = tvb_get_ipv4(tvb, offset);
|
2000-11-19 20:01:22 +00:00
|
|
|
group_count = tvb_get_guint8(tvb, offset + 5);
|
1999-11-23 17:09:58 +00:00
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
/* sizeof map header + n * sizeof encoded group addresses */
|
|
|
|
ti = proto_tree_add_text(auto_rp_tree, tvb, offset, 6 + group_count * 6,
|
|
|
|
"RP %s: %u group%s", ip_to_str((void *)&rp_addr),
|
|
|
|
group_count, plurality(group_count, "", "s"));
|
1999-11-23 17:09:58 +00:00
|
|
|
map_tree = proto_item_add_subtree(ti, ett_auto_rp_map);
|
2000-11-19 20:01:22 +00:00
|
|
|
|
|
|
|
proto_tree_add_ipv4(map_tree, hf_auto_rp_rp_addr, tvb, offset, 4, rp_addr);
|
|
|
|
offset += 4;
|
|
|
|
proto_tree_add_uint(map_tree, hf_auto_rp_pim_ver, tvb, offset, 1, tvb_get_guint8(tvb, offset));
|
1999-11-23 17:09:58 +00:00
|
|
|
offset++;
|
2000-11-19 20:01:22 +00:00
|
|
|
proto_tree_add_text(map_tree, tvb, offset, 1, "Number of groups this RP maps to: %u", group_count);
|
1999-11-23 17:09:58 +00:00
|
|
|
offset++;
|
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
for (i = 0; i < group_count; i++) {
|
1999-11-23 17:09:58 +00:00
|
|
|
proto_item *gi;
|
|
|
|
proto_tree *grp_tree;
|
2000-11-19 20:01:22 +00:00
|
|
|
guint8 sign, mask_len;
|
|
|
|
guint32 group_addr; /* In network byte order */
|
|
|
|
|
|
|
|
sign = tvb_get_guint8(tvb, offset);
|
|
|
|
mask_len = tvb_get_guint8(tvb, offset + 1);
|
2005-09-11 21:25:37 +00:00
|
|
|
group_addr = tvb_get_ipv4(tvb, offset + 2);
|
2000-11-19 20:01:22 +00:00
|
|
|
gi = proto_tree_add_text(map_tree, tvb, offset, 6, "Group %s/%u (%s)",
|
|
|
|
ip_to_str((void *)&group_addr), mask_len,
|
|
|
|
val_to_str(sign&AUTO_RP_SIGN_MASK, auto_rp_mask_sign_vals, ""));
|
1999-11-23 17:09:58 +00:00
|
|
|
grp_tree = proto_item_add_subtree(gi, ett_auto_rp_group);
|
|
|
|
|
2000-11-19 20:01:22 +00:00
|
|
|
proto_tree_add_uint(grp_tree, hf_auto_rp_prefix_sgn, tvb, offset, 1, sign);
|
1999-11-23 17:09:58 +00:00
|
|
|
offset++;
|
2000-11-19 20:01:22 +00:00
|
|
|
proto_tree_add_uint(grp_tree, hf_auto_rp_mask_len, tvb, offset, 1, mask_len);
|
1999-11-23 17:09:58 +00:00
|
|
|
offset++;
|
2000-11-19 20:01:22 +00:00
|
|
|
proto_tree_add_ipv4(grp_tree, hf_auto_rp_group_prefix, tvb, offset, 4, group_addr);
|
|
|
|
offset += 4;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-11-23 17:09:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|