Convert ethertype() function into a pure dissector. Bug 9454 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9454)

The main driving force for this was my new Decode As functionality (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9450) that wants a dissector/subdissector table relationship for all dissectors wanting to use Decode As functionality.  The ethertype() function provides the value to the "ethertype" subdissector table, so I think it should be matched to a dissector.  Only odd side effect is the display filter of "ethertype" returns no packets because there is no "item" associated with the dissector.


svn path=/trunk/; revision=53443
This commit is contained in:
Michael Mann 2013-11-20 02:28:14 +00:00
parent ea278d3bf8
commit f34e11fabe
13 changed files with 197 additions and 49 deletions

View File

@ -75,6 +75,7 @@ static gboolean top_dissect = TRUE;
static dissector_handle_t eth_handle;
static dissector_handle_t data_handle;
static dissector_handle_t ethertype_handle;
static const true_false_string ig_tfs = {
"Group address (multicast/broadcast)",
@ -366,8 +367,16 @@ dissect_btbnep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
if (bnep_type != BNEP_TYPE_CONTROL) {
/* dissect normal network */
if (top_dissect) {
ethertype(type, tvb, offset, pinfo, tree, btbnep_tree,
hf_btbnep_type, 0, 0);
ethertype_data_t ethertype_data;
ethertype_data.etype = type;
ethertype_data.offset_after_ethertype = offset;
ethertype_data.fh_tree = btbnep_tree;
ethertype_data.etype_id = hf_btbnep_type;
ethertype_data.trailer_id = 0;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
} else {
tvbuff_t *next_tvb;
@ -539,6 +548,7 @@ proto_reg_handoff_btbnep(void)
btbnep_handle = find_dissector("btbnep");
eth_handle = find_dissector("eth");
data_handle = find_dissector("data");
ethertype_handle = find_dissector("ethertype");
dissector_add_uint("btl2cap.service", BTSDP_PAN_GN_SERVICE_UUID, btbnep_handle);
dissector_add_uint("btl2cap.service", BTSDP_PAN_NAP_SERVICE_UUID, btbnep_handle);

View File

@ -32,6 +32,8 @@
#include "packet-ieee8023.h"
#endif
static dissector_handle_t ethertype_handle;
static int proto_cmd = -1;
static int hf_cmd_version = -1;
@ -48,6 +50,7 @@ static void
dissect_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
guint16 encap_proto;
ethertype_data_t ethertype_data;
proto_tree *cmd_tree = NULL;
gint offset = 0;
@ -88,8 +91,14 @@ dissect_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
} else {
#endif
ethertype(encap_proto, tvb, 8, pinfo, tree, cmd_tree,
hf_eth_type, hf_cmd_trailer, 0);
ethertype_data.etype = encap_proto;
ethertype_data.offset_after_ethertype = 8;
ethertype_data.fh_tree = cmd_tree;
ethertype_data.etype_id = hf_eth_type;
ethertype_data.trailer_id = hf_cmd_trailer;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
void
@ -130,6 +139,8 @@ proto_reg_handoff_cmd(void)
{
dissector_handle_t cmd_handle;
ethertype_handle = find_dissector("ethertype");
cmd_handle = create_dissector_handle(dissect_cmd, proto_cmd);
dissector_add_uint("ethertype", ETHERTYPE_CMD, cmd_handle);
}

View File

@ -90,6 +90,7 @@ static expert_field ei_eth_fcs_bad = EI_INIT;
static expert_field ei_eth_len = EI_INIT;
static dissector_handle_t fw1_handle;
static dissector_handle_t ethertype_handle;
static dissector_handle_t data_handle;
static heur_dissector_list_t heur_subdissector_list;
static heur_dissector_list_t eth_trailer_subdissector_list;
@ -229,6 +230,7 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
proto_tree *tree;
proto_item *addr_item;
proto_tree *addr_tree=NULL;
ethertype_data_t ethertype_data;
ehdr_num++;
if(ehdr_num>=4){
@ -460,8 +462,14 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 6, 3, ENC_BIG_ENDIAN);
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 6, 3, ENC_BIG_ENDIAN);
ethertype(ehdr->type, tvb, ETH_HEADER_SIZE, pinfo, parent_tree, fh_tree, hf_eth_type,
hf_eth_trailer, fcs_len);
ethertype_data.etype = ehdr->type;
ethertype_data.offset_after_ethertype = ETH_HEADER_SIZE;
ethertype_data.fh_tree = fh_tree;
ethertype_data.etype_id = hf_eth_type;
ethertype_data.trailer_id = hf_eth_trailer;
ethertype_data.fcs_len = fcs_len;
call_dissector_with_data(ethertype_handle, tvb, pinfo, parent_tree, &ethertype_data);
}
return fh_tree;
}
@ -939,6 +947,9 @@ proto_reg_handoff_eth(void)
/* Get a handle for the Firewall-1 dissector. */
fw1_handle = find_dissector("fw1");
/* Get a handle for the ethertype dissector. */
ethertype_handle = find_dissector("ethertype");
/* Get a handle for the generic data dissector. */
data_handle = find_dissector("data");

View File

@ -51,6 +51,8 @@ static dissector_table_t ethertype_dissector_table;
static dissector_handle_t data_handle;
static int proto_ethertype = -1;
const value_string etype_vals[] = {
{ ETHERTYPE_IP, "IP" },
{ ETHERTYPE_IPv6, "IPv6" },
@ -226,10 +228,14 @@ capture_ethertype(guint16 etype, const guchar *pd, int offset, int len,
}
}
/*
void
ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
int etype_id, int trailer_id, int fcs_len)
*/
static int
dissect_ethertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
const char *description;
tvbuff_t *volatile next_tvb;
@ -238,18 +244,17 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
volatile gboolean dissector_found = FALSE;
const char *volatile saved_proto;
void *pd_save;
ethertype_data_t* ethertype_data = (ethertype_data_t*)data;
/* Add the Ethernet type to the protocol tree */
if (tree) {
proto_tree_add_uint(fh_tree, etype_id, tvb,
offset_after_etype - 2, 2, etype);
}
proto_tree_add_uint(ethertype_data->fh_tree, ethertype_data->etype_id, tvb,
ethertype_data->offset_after_ethertype - 2, 2, ethertype_data->etype);
/* Get the captured length and reported length of the data
after the Ethernet type. */
captured_length = tvb_length_remaining(tvb, offset_after_etype);
captured_length = tvb_length_remaining(tvb, ethertype_data->offset_after_ethertype);
reported_length = tvb_reported_length_remaining(tvb,
offset_after_etype);
ethertype_data->offset_after_ethertype);
/* Remember how much data there is after the Ethernet type,
including any trailer and FCS. */
@ -260,18 +265,18 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
(If it's zero, there's no FCS; if it's negative,
we don't know whether there's an FCS, so we'll
guess based on the length of the trailer.) */
if (fcs_len > 0) {
if (ethertype_data->fcs_len > 0) {
if (captured_length >= 0 && reported_length >= 0) {
if (reported_length >= fcs_len)
reported_length -= fcs_len;
if (reported_length >= ethertype_data->fcs_len)
reported_length -= ethertype_data->fcs_len;
if (captured_length > reported_length)
captured_length = reported_length;
}
}
next_tvb = tvb_new_subset(tvb, offset_after_etype, captured_length,
next_tvb = tvb_new_subset(tvb, ethertype_data->offset_after_ethertype, captured_length,
reported_length);
pinfo->ethertype = etype;
pinfo->ethertype = ethertype_data->etype;
/* Look for sub-dissector, and call it if found.
Catch exceptions, so that if the reported length of "next_tvb"
@ -281,7 +286,7 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
pd_save = pinfo->private_data;
TRY {
dissector_found = dissector_try_uint(ethertype_dissector_table,
etype, next_tvb, pinfo, tree);
ethertype_data->etype, next_tvb, pinfo, tree);
}
CATCH_NONFATAL_ERRORS {
/* Somebody threw an exception that means that there
@ -312,16 +317,18 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
call_dissector(data_handle,next_tvb, pinfo, tree);
/* Label protocol */
col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", etype);
col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", ethertype_data->etype);
description = try_val_to_str(etype, etype_vals);
description = try_val_to_str(ethertype_data->etype, etype_vals);
if (description) {
col_add_str(pinfo->cinfo, COL_INFO, description);
}
}
add_dix_trailer(pinfo, tree, fh_tree, trailer_id, tvb, next_tvb, offset_after_etype,
length_before, fcs_len);
add_dix_trailer(pinfo, tree, ethertype_data->fh_tree, ethertype_data->trailer_id, tvb, next_tvb, ethertype_data->offset_after_ethertype,
length_before, ethertype_data->fcs_len);
return tvb_length(tvb);
}
static void
@ -363,6 +370,10 @@ add_dix_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, int t
void
proto_register_ethertype(void)
{
proto_ethertype = proto_register_protocol("Ethertype", "Ethertype", "ethertype");
new_register_dissector("ethertype", dissect_ethertype, proto_ethertype);
/* subdissector code */
ethertype_dissector_table = register_dissector_table("ethertype",
"Ethertype", FT_UINT16, BASE_HEX);

View File

@ -96,6 +96,8 @@ static gboolean fw1_summary_in_tree = TRUE;
static gboolean fw1_with_uuid = FALSE;
static gboolean fw1_iflist_with_chain = FALSE;
static dissector_handle_t ethertype_handle;
/* Initialize the protocol and registered fields */
static int proto_fw1 = -1;
static int hf_fw1_direction = -1;
@ -130,11 +132,11 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
char chain;
char *interface_name;
guint32 iface_len = 10;
guint16 etype;
wmem_strbuf_t *header;
int i;
gboolean found;
static const char fw1_header[] = "FW1 Monitor";
ethertype_data_t ethertype_data;
header = wmem_strbuf_new_label(wmem_epan_scope());
wmem_strbuf_append(header, fw1_header);
@ -211,8 +213,14 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(fh_tree, hf_fw1_uuid, tvb, 8, 4, ENC_BIG_ENDIAN);
}
etype = tvb_get_ntohs(tvb, 12);
ethertype(etype, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree, hf_fw1_type, hf_fw1_trailer, 0);
ethertype_data.etype = tvb_get_ntohs(tvb, 12);
ethertype_data.offset_after_ethertype = ETH_HEADER_SIZE;
ethertype_data.fh_tree = fh_tree;
ethertype_data.etype_id = hf_fw1_type;
ethertype_data.trailer_id = hf_fw1_trailer;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
void
@ -280,3 +288,9 @@ proto_register_fw1(void)
}
register_init_routine(fw1_init);
}
void
proto_reg_handoff_fw1(void)
{
ethertype_handle = find_dissector("ethertype");
}

View File

@ -88,6 +88,8 @@ static const value_string gmhdr_plfm_str[] = {
{ 0, NULL }
};
static dissector_handle_t ethertype_handle;
static gboolean gmhdr_summary_in_tree = TRUE;
static gboolean gmtrailer_summary_in_tree = TRUE;
static gboolean gmhdr_decode_timestamp_trailer = TRUE;
@ -260,8 +262,16 @@ dissect_gmhdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_802_3(encap_proto, is_802_2, tvb, offset, pinfo, tree, gmhdr_tree,
hf_gmhdr_len, hf_gmhdr_trailer, &ei_gmhdr_len, 0);
} else {
ethertype(encap_proto, tvb, offset, pinfo, tree, gmhdr_tree,
hf_gmhdr_etype, hf_gmhdr_trailer, 0);
ethertype_data_t ethertype_data;
ethertype_data.etype = encap_proto;
ethertype_data.offset_after_ethertype = offset;
ethertype_data.fh_tree = gmhdr_tree;
ethertype_data.etype_id = hf_gmhdr_etype;
ethertype_data.trailer_id = hf_gmhdr_trailer;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
}
@ -502,6 +512,8 @@ proto_reg_handoff_gmhdr(void)
{
dissector_handle_t gmhdr_handle;
ethertype_handle = find_dissector("ethertype");
gmhdr_handle = create_dissector_handle(dissect_gmhdr, proto_gmhdr);
dissector_add_uint("ethertype", ETHERTYPE_GIGAMON, gmhdr_handle);
heur_dissector_add("eth.trailer", dissect_gmtrailer, proto_gmhdr);

View File

@ -36,6 +36,8 @@
#include <epan/etypes.h>
#include <epan/prefs.h>
static dissector_handle_t ethertype_handle;
void proto_reg_handoff_ieee8021ah(void);
void dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, proto_tree *parent, int tree_index);
@ -113,6 +115,7 @@ dissect_ieee8021ad(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *volatile ieee8021ad_tag_tree;
int proto_tree_index;
tvbuff_t *volatile next_tvb = NULL;
ethertype_data_t ethertype_data;
/* set tree index */
proto_tree_index = proto_ieee8021ad;
@ -136,6 +139,10 @@ dissect_ieee8021ad(tvbuff_t *tvb, packet_info *pinfo,
}
encap_proto = tvb_get_ntohs(tvb, IEEE8021AD_LEN - 2);
ethertype_data.fh_tree = ieee8021ad_tree;
ethertype_data.etype_id = hf_ieee8021ah_etype;
ethertype_data.trailer_id = hf_ieee8021ah_trailer;
ethertype_data.fcs_len = 0;
/* If it's a 1ah frame, create subtree for B-Tag, rename overall
tree to 802.1ah, pass to 1ah dissector */
@ -188,11 +195,12 @@ dissect_ieee8021ad(tvbuff_t *tvb, packet_info *pinfo,
proto_item_set_text(ptree, "IEEE 802.1ad, S-VID: %d, C-VID: %d", tci & 0x0FFF,
ctci & 0x0FFF);
ethertype_data.etype = tvb_get_ntohs(tvb, IEEE8021AD_LEN * 2 - 2);
ethertype_data.offset_after_ethertype = IEEE8021AD_LEN * 2;
/* 802.1ad tags are always followed by an ethertype; call next
dissector based on ethertype */
encap_proto = tvb_get_ntohs(tvb, IEEE8021AD_LEN * 2 - 2);
ethertype(encap_proto, tvb, IEEE8021AD_LEN * 2, pinfo, tree, ieee8021ad_tree,
hf_ieee8021ah_etype, hf_ieee8021ah_trailer, 0);
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
} else {
/* Something else (shouldn't really happen, but we'll support it anyways) */
if (tree) {
@ -206,10 +214,12 @@ dissect_ieee8021ad(tvbuff_t *tvb, packet_info *pinfo,
/* label should be 802.1ad not .1ah */
proto_item_set_text(ptree, "IEEE 802.1ad, ID: %d", tci & 0x0FFF);
ethertype_data.etype = encap_proto;
ethertype_data.offset_after_ethertype = IEEE8021AD_LEN;
/* 802.1ad tags are always followed by an ethertype; call next
dissector based on ethertype */
ethertype(encap_proto, tvb, IEEE8021AD_LEN, pinfo, tree, ieee8021ad_tree,
hf_ieee8021ah_etype, hf_ieee8021ah_trailer, 0);
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
}
@ -220,6 +230,7 @@ dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
guint16 encap_proto;
proto_tree *ptree;
proto_tree *volatile ieee8021ah_tag_tree;
ethertype_data_t ethertype_data;
/* for parsing out ethernet addrs */
const guint8 *src_addr, *dst_addr;
@ -281,13 +292,18 @@ dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
/* If this was preceded by a 802.1ad tag, must pass original tree
to next dissector, not 802.1ad tree */
ethertype_data.etype = encap_proto;
ethertype_data.fh_tree = tree;
ethertype_data.offset_after_ethertype = IEEE8021AH_LEN;
ethertype_data.etype_id = hf_ieee8021ah_etype;
ethertype_data.trailer_id = hf_ieee8021ah_trailer;
ethertype_data.fcs_len = 0;
if (parent) {
ethertype(encap_proto, tvb, IEEE8021AH_LEN, pinfo, parent, tree,
hf_ieee8021ah_etype, hf_ieee8021ah_trailer, 0);
call_dissector_with_data(ethertype_handle, tvb, pinfo, parent, &ethertype_data);
}
else {
ethertype(encap_proto, tvb, IEEE8021AH_LEN, pinfo, tree, tree,
hf_ieee8021ah_etype, hf_ieee8021ah_trailer, 0);
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
}
@ -431,6 +447,8 @@ proto_reg_handoff_ieee8021ah(void)
ieee8021ad_handle = create_dissector_handle(dissect_ieee8021ad,
proto_ieee8021ad);
dissector_add_uint("ethertype", ETHERTYPE_IEEE_802_1AD, ieee8021ad_handle);
ethertype_handle = find_dissector("ethertype");
prefs_initialized = TRUE;
}
else {

View File

@ -77,6 +77,7 @@ static const value_string ltype_vals[] = {
static dissector_handle_t sll_handle;
static dissector_handle_t ethertype_handle;
static header_field_info *hfi_sll = NULL;
@ -200,6 +201,7 @@ dissect_sll(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_item *ti;
tvbuff_t *next_tvb;
proto_tree *fh_tree = NULL;
ethertype_data_t ethertype_data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SLL");
col_clear(pinfo->cinfo, COL_INFO);
@ -298,8 +300,14 @@ dissect_sll(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
protocol, next_tvb, pinfo, tree);
break;
default:
ethertype(protocol, tvb, SLL_HEADER_SIZE, pinfo, tree,
fh_tree, hfi_sll_etype.id, hfi_sll_trailer.id, 0);
ethertype_data.etype = protocol;
ethertype_data.offset_after_ethertype = SLL_HEADER_SIZE;
ethertype_data.fh_tree = fh_tree;
ethertype_data.etype_id = hfi_sll_etype.id;
ethertype_data.trailer_id = hfi_sll_trailer.id;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
break;
}
}
@ -356,6 +364,7 @@ proto_reg_handoff_sll(void)
*/
gre_dissector_table = find_dissector_table("gre.proto");
data_handle = find_dissector("data");
ethertype_handle = find_dissector("ethertype");
dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_handle);
}

View File

@ -39,6 +39,8 @@
#include "packet-tte.h"
static dissector_handle_t ethertype_handle;
/* Initialize the protocol and registered fields */
static int proto_tte = -1;
@ -62,6 +64,7 @@ static int
dissect_tte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
int is_frame_pcf;
ethertype_data_t ethertype_data;
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *tte_root_item, *tte_macdest_item;
@ -120,9 +123,14 @@ dissect_tte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
col_set_fence(pinfo->cinfo, COL_PROTOCOL);
/* call std Ethernet dissector */
ethertype (tvb_get_ntohs(tvb, TTE_MAC_LENGTH * 2), tvb
, 14, pinfo, tree, NULL, hf_eth_type, 0, 0 );
ethertype_data.etype = tvb_get_ntohs(tvb, TTE_MAC_LENGTH * 2);
ethertype_data.offset_after_ethertype = 14;
ethertype_data.fh_tree = NULL;
ethertype_data.etype_id = hf_eth_type;
ethertype_data.trailer_id = 0;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
return tvb_length(tvb);
}
@ -182,4 +190,6 @@ proto_reg_handoff_tte(void)
hf_eth_dst = proto_registrar_get_id_byname ("eth.dst");
hf_eth_src = proto_registrar_get_id_byname ("eth.src");
hf_eth_type = proto_registrar_get_id_byname ("eth.type");
ethertype_handle = find_dissector("ethertype");
}

View File

@ -45,6 +45,7 @@ static gboolean vlan_summary_in_tree = TRUE;
static dissector_handle_t vlan_handle;
static dissector_handle_t ethertype_handle;
static header_field_info *hfi_vlan = NULL;
@ -173,8 +174,16 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_802_3(encap_proto, is_802_2, tvb, 4, pinfo, tree, vlan_tree,
hfi_vlan_len.id, hfi_vlan_trailer.id, &ei_vlan_len, 0);
} else {
ethertype(encap_proto, tvb, 4, pinfo, tree, vlan_tree,
hfi_vlan_etype.id, hfi_vlan_trailer.id, 0);
ethertype_data_t ethertype_data;
ethertype_data.etype = encap_proto;
ethertype_data.offset_after_ethertype = 4;
ethertype_data.fh_tree = vlan_tree;
ethertype_data.etype_id = hfi_vlan_etype.id;
ethertype_data.trailer_id = hfi_vlan_trailer.id;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
}
@ -242,6 +251,7 @@ proto_reg_handoff_vlan(void)
}
old_q_in_q_ethertype = q_in_q_ethertype;
ethertype_handle = find_dissector("ethertype");
dissector_add_uint("ethertype", q_in_q_ethertype, vlan_handle);
}

View File

@ -48,6 +48,8 @@
#include <epan/packet.h>
#include <epan/etypes.h>
static dissector_handle_t ethertype_handle;
static int proto_vmlab = -1;
static int hf_vmlab_flags_part1 = -1; /* Unknown so far */
@ -72,7 +74,6 @@ static const value_string fragment_vals[] = {
static void
dissect_vmlab(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree* volatile vmlab_tree;
proto_item* ti;
@ -82,6 +83,7 @@ dissect_vmlab(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
const guint8* dst_addr;
guint8 attributes;
guint8 portgroup;
ethertype_data_t ethertype_data;
volatile guint16 encap_proto;
@ -132,8 +134,14 @@ dissect_vmlab(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset += 2;
/* Now call whatever was encapsulated*/
ethertype(encap_proto, tvb, offset, pinfo, tree, vmlab_tree, hf_vmlab_etype, hf_vmlab_trailer, 0);
ethertype_data.etype = encap_proto;
ethertype_data.offset_after_ethertype = offset;
ethertype_data.fh_tree = vmlab_tree;
ethertype_data.etype_id = hf_vmlab_etype;
ethertype_data.trailer_id = hf_vmlab_trailer;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
}
void
@ -178,4 +186,6 @@ proto_reg_handoff_vmlab(void)
vmlab_handle = create_dissector_handle(dissect_vmlab, proto_vmlab);
dissector_add_uint("ethertype", ETHERTYPE_VMLAB, vmlab_handle);
ethertype_handle = find_dissector("ethertype");
}

View File

@ -27,6 +27,8 @@
#include <epan/packet.h>
#include <epan/etypes.h>
static dissector_handle_t ethertype_handle;
static int proto_vntag = -1;
static int hf_vntag_etype = -1;
@ -40,6 +42,7 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
guint16 encap_proto;
proto_tree *vntag_tree = NULL;
ethertype_data_t ethertype_data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "VNTAG");
col_clear(pinfo->cinfo, COL_INFO);
@ -87,9 +90,19 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
dissect_802_3(encap_proto, is_802_2, tvb, 4, pinfo, tree, vntag_tree, hf_vntag_len, hf_vntag_trailer, 0);
} else
} else {
#endif
ethertype_data.etype = encap_proto;
ethertype_data.offset_after_ethertype = 6;
ethertype_data.fh_tree = vntag_tree;
ethertype_data.etype_id = hf_vntag_etype;
ethertype_data.trailer_id = hf_vntag_trailer;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
#if 0
}
#endif
ethertype(encap_proto, tvb, 6, pinfo, tree, vntag_tree, hf_vntag_etype, hf_vntag_trailer, 0);
}
void
@ -127,4 +140,6 @@ proto_reg_handoff_vntag(void)
vntag_handle = create_dissector_handle(dissect_vntag, proto_vntag);
dissector_add_uint("ethertype", 0x8926, vntag_handle);
ethertype_handle = find_dissector("ethertype");
}

View File

@ -459,9 +459,16 @@ extern void dissect_packet(epan_dissect_t *edt,
/* These functions are in packet-ethertype.c */
extern void capture_ethertype(guint16 etype, const guchar *pd, int offset,
int len, packet_counts *ld);
WS_DLL_PUBLIC void ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_ethertype,
packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
int etype_id, int trailer_id, int fcs_len);
/* Structure passed to the ethertype dissector */
typedef struct ethertype_data_s
{
guint16 etype;
int offset_after_ethertype;
proto_tree *fh_tree;
int etype_id;
int trailer_id;
int fcs_len;
} ethertype_data_t;
/*
* Dump layer/selector/dissector records in a fashion similar to the