Move AT_VINES address type to VINES dissector.

proto.c still has to deal with FT_VINES, but maybe that
can be refactored to the dissector too.

Change-Id: Iee04eed3b75f91cb62bb7b625dd44baeeb9aebb3
Reviewed-on: https://code.wireshark.org/review/16069
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2016-06-21 20:30:35 -04:00 committed by Anders Broman
parent e7b78eb0a6
commit debbf7e930
4 changed files with 40 additions and 47 deletions

View File

@ -46,7 +46,6 @@ typedef enum {
AT_IPv4, /* IPv4 */
AT_IPv6, /* IPv6 */
AT_IPX, /* IPX */
AT_VINES, /* Banyan Vines */
AT_FC, /* Fibre Channel */
AT_FCWWN, /* Fibre Channel WWN */
AT_STRINGZ, /* null-terminated string */

View File

@ -305,34 +305,6 @@ static int ipx_len(void)
return 10;
}
/******************************************************************************
* AT_VINES
* XXX - This functionality should really be in packet-vines.c as a dissector
* address type, but need to resolve "address type" as "field type"
******************************************************************************/
static int vines_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
const guint8 *addr_data = (const guint8 *)addr->data;
gchar *bufp = buf;
bufp = dword_to_hex(bufp, pntoh32(&addr_data[0])); /* 8 bytes */
*bufp++ = '.'; /* 1 byte */
bufp = word_to_hex(bufp, pntoh16(&addr_data[4])); /* 4 bytes */
*bufp++ = '\0'; /* NULL terminate */
return (int)(bufp - buf);
}
static int vines_str_len(const address* addr _U_)
{
return 14;
}
static int vines_len(void)
{
return VINES_ADDR_LEN;
}
/******************************************************************************
* AT_FC
******************************************************************************/
@ -594,18 +566,6 @@ void address_types_initialize(void)
NULL, /* addr_name_res_len */
};
static address_type_t vines_address = {
AT_VINES, /* addr_type */
"AT_VINES", /* name */
"Banyan Vines address", /* pretty_name */
vines_to_str, /* addr_to_str */
vines_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
vines_len, /* addr_fixed_len */
NULL, /* addr_name_res_str */
NULL, /* addr_name_res_len */
};
static address_type_t fc_address = {
AT_FC, /* addr_type */
"AT_FC", /* name */
@ -689,7 +649,6 @@ void address_types_initialize(void)
address_type_register(AT_IPv4, &ipv4_address );
address_type_register(AT_IPv6, &ipv6_address );
address_type_register(AT_IPX, &ipx_address );
address_type_register(AT_VINES, &vines_address );
address_type_register(AT_FC, &fc_address );
address_type_register(AT_FCWWN, &fcwwn_address );
address_type_register(AT_STRINGZ, &stringz_address );

View File

@ -90,6 +90,8 @@
#include <epan/arcnet_pids.h>
#include <epan/llcsaps.h>
#include <epan/to_str.h>
#include <epan/address_types.h>
#include <wsutil/pint.h>
void proto_register_vines_frp(void);
void proto_reg_handoff_vines_frp(void);
@ -264,6 +266,8 @@ static int hf_vines_icp_packet_type = -1;
static gint ett_vines_icp = -1;
static int vines_address_type = -1;
/* VINES IP structs and definitions */
enum {
@ -556,9 +560,9 @@ dissect_vines_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
val_to_str_const(vip_tctl, proto_vals, "Unknown VIP protocol"),
vip_tctl);
set_address_tvb(&pinfo->net_src, AT_VINES, VINES_ADDR_LEN, tvb, offset+12);
set_address_tvb(&pinfo->net_src, vines_address_type, VINES_ADDR_LEN, tvb, offset+12);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
set_address_tvb(&pinfo->net_dst, AT_VINES, VINES_ADDR_LEN, tvb, offset+6);
set_address_tvb(&pinfo->net_dst, vines_address_type, VINES_ADDR_LEN, tvb, offset+6);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
/* helpers to transport control */
@ -617,6 +621,29 @@ dissect_vines_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
return tvb_captured_length(tvb);
}
static int vines_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
const guint8 *addr_data = (const guint8 *)addr->data;
gchar *bufp = buf;
bufp = dword_to_hex(bufp, pntoh32(&addr_data[0])); /* 8 bytes */
*bufp++ = '.'; /* 1 byte */
bufp = word_to_hex(bufp, pntoh16(&addr_data[4])); /* 4 bytes */
*bufp++ = '\0'; /* NULL terminate */
return (int)(bufp - buf);
}
static int vines_str_len(const address* addr _U_)
{
return 14;
}
static int vines_len(void)
{
return VINES_ADDR_LEN;
}
void
proto_register_vines_ip(void)
{
@ -698,6 +725,8 @@ proto_register_vines_ip(void)
vines_ip_handle = create_dissector_handle(dissect_vines_ip,
proto_vines_ip);
vines_address_type = address_type_dissector_register("AT_VINES", "Banyan Vines address", vines_to_str, vines_str_len, NULL, vines_len, NULL, NULL);
}
void
@ -1229,7 +1258,7 @@ dissect_vines_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
if (packet_type == VARP_ASSIGNMENT_RESP) {
col_append_fstr(pinfo->cinfo, COL_INFO,
", Address = %s",
tvb_address_to_str(wmem_packet_scope(), tvb, AT_VINES, 2));
tvb_address_to_str(wmem_packet_scope(), tvb, vines_address_type, 2));
proto_tree_add_item(vines_arp_tree, hf_vines_arp_address, tvb, 2, VINES_ADDR_LEN, ENC_NA);
}
proto_tree_add_item(vines_arp_tree, hf_vines_arp_sequence_number, tvb, 2+VINES_ADDR_LEN, 4, ENC_BIG_ENDIAN);
@ -1251,7 +1280,7 @@ dissect_vines_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
if (packet_type == VARP_ASSIGNMENT_RESP) {
col_append_fstr(pinfo->cinfo, COL_INFO,
", Address = %s",
tvb_address_to_str(wmem_packet_scope(), tvb, AT_VINES, 2));
tvb_address_to_str(wmem_packet_scope(), tvb, vines_address_type, 2));
proto_tree_add_item(vines_arp_tree, hf_vines_arp_address, tvb, 2, VINES_ADDR_LEN, ENC_NA);
}

View File

@ -368,6 +368,9 @@ static void save_same_name_hfinfo(gpointer data)
same_name_hfinfo = (header_field_info*)data;
}
/* Cached value for VINES address type (used for FT_VINES) */
static int vines_address_type = -1;
/* Points to the first element of an array of bits, indexed by
a subtree item type; that array element is TRUE if subtrees of
an item of that type are to be expanded. */
@ -522,6 +525,9 @@ proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_da
do. */
register_all_protocols_func(cb, client_data);
/* Now that the VINES dissector has registered it's address
type, grab the value for the field type */
vines_address_type = address_type_get_by_name("AT_VINES");
#ifdef HAVE_PLUGINS
/* Now call the registration routines for all disssector
plugins. */
@ -7148,7 +7154,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_VINES:
addr.type = AT_VINES;
addr.type = vines_address_type;
addr.len = VINES_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);