Make AT_VINES a built-in type

Change-Id: I5c11cf4c7bee1b2b7072a6a0db5344a6b8a569ac
Reviewed-on: https://code.wireshark.org/review/29326
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
João Valverde 2018-08-28 21:13:15 +01:00 committed by João Valverde
parent 389339cab2
commit 9d9a873d9a
4 changed files with 46 additions and 38 deletions

View File

@ -40,6 +40,7 @@ typedef enum {
AT_EUI64, /* IEEE EUI-64 */
AT_IB, /* Infiniband GID/LID */
AT_AX25, /* AX.25 */
AT_VINES, /* Banyan Vines address */
AT_END_OF_LIST /* Must be last in list */
} address_type;

View File

@ -479,6 +479,33 @@ static int ax25_len(void)
return AX25_ADDR_LEN;
}
/******************************************************************************
* AT_VINES
******************************************************************************/
static int vines_addr_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_addr_str_len(const address* addr _U_)
{
return 14;
}
static int vines_len(void)
{
return VINES_ADDR_LEN;
}
/******************************************************************************
* END OF PROVIDED ADDRESS TYPES
******************************************************************************/
@ -630,6 +657,18 @@ void address_types_initialize(void)
NULL, /* addr_name_res_str */
NULL, /* addr_name_res_len */
};
static address_type_t vines_address = {
AT_VINES, /* addr_type */
"AT_VINES", /* name */
"Banyan Vines Address", /* pretty_name */
vines_addr_to_str, /* addr_to_str */
vines_addr_str_len,/* addr_str_len */
NULL, /* addr_to_byte */
NULL, /* addr_col_filter */
vines_len, /* addr_fixed_len */
NULL, /* addr_name_res_str */
NULL, /* addr_name_res_len */
};
num_dissector_addr_type = 0;
@ -648,6 +687,7 @@ void address_types_initialize(void)
address_type_register(AT_EUI64, &eui64_address );
address_type_register(AT_IB, &ib_address );
address_type_register(AT_AX25, &ax25_address );
address_type_register(AT_VINES, &vines_address );
}
/* Given an address type id, return an address_type_t* */

View File

@ -254,8 +254,6 @@ 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 {
@ -548,9 +546,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, vines_address_type, VINES_ADDR_LEN, tvb, offset+12);
set_address_tvb(&pinfo->net_src, AT_VINES, VINES_ADDR_LEN, tvb, offset+12);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
set_address_tvb(&pinfo->net_dst, vines_address_type, VINES_ADDR_LEN, tvb, offset+6);
set_address_tvb(&pinfo->net_dst, AT_VINES, VINES_ADDR_LEN, tvb, offset+6);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
/* helpers to transport control */
@ -609,29 +607,6 @@ 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)
{
@ -713,8 +688,6 @@ 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, NULL, vines_len, NULL, NULL);
}
void
@ -1246,7 +1219,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, vines_address_type, 2));
tvb_address_to_str(wmem_packet_scope(), tvb, AT_VINES, 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);
@ -1268,7 +1241,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, vines_address_type, 2));
tvb_address_to_str(wmem_packet_scope(), tvb, AT_VINES, 2));
proto_tree_add_item(vines_arp_tree, hf_vines_arp_address, tvb, 2, VINES_ADDR_LEN, ENC_NA);
}

View File

@ -390,9 +390,6 @@ 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. */
@ -493,9 +490,6 @@ proto_init(GSList *register_all_protocols_list,
((void (*)(register_cb, gpointer))l->data)(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. */
@ -8425,7 +8419,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_VINES:
addr.type = vines_address_type;
addr.type = AT_VINES;
addr.len = VINES_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);