aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-12-13 16:54:16 -0500
committerMichael Mann <mmann78@netscape.net>2015-12-14 12:17:49 +0000
commit0960ac4dfdbfba5a81c56a49cfc6201ecd8f48e3 (patch)
tree3d88cd321da2fade206b9ccddff22b70ecdfae28
parent9319357f5e27c10f2d29e78fcdf9d323c2af36b0 (diff)
Create capture dissector tables.
They are modeled after dissection dissector tables, but for the moment, don't have/need the flexibility. They are intended to be much simpler/faster than full dissection. The two most used/needed are "wtap_encap" and "ethertype", so they were the basis of starting to use and test capture dissector table API. Others may be added in the future. The "capture dissector" function signature needed a bit of tweeking to handling "claiming" of a packet. The current application of this is capture functions returning TRUE if they affected a "type" of packet count. Returning FALSE ends up considering the packet an "other" type. Change-Id: I81d06a6ccb2c03665f087258a46b9d78d513d6cd Reviewed-on: https://code.wireshark.org/review/12607 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--capture_info.c3
-rw-r--r--epan/capture_dissectors.c71
-rw-r--r--epan/capture_dissectors.h12
-rw-r--r--epan/dissectors/Makefile.common3
-rw-r--r--epan/dissectors/packet-ap1394.c10
-rw-r--r--epan/dissectors/packet-arcnet.c36
-rw-r--r--epan/dissectors/packet-arp.c9
-rw-r--r--epan/dissectors/packet-atalk.c11
-rw-r--r--epan/dissectors/packet-atm.c33
-rw-r--r--epan/dissectors/packet-ax25-kiss.c22
-rw-r--r--epan/dissectors/packet-ax25.c27
-rw-r--r--epan/dissectors/packet-ax25.h2
-rw-r--r--epan/dissectors/packet-bpq.c12
-rw-r--r--epan/dissectors/packet-bpq.h30
-rw-r--r--epan/dissectors/packet-chdlc.c21
-rw-r--r--epan/dissectors/packet-chdlc.h2
-rw-r--r--epan/dissectors/packet-clip.c8
-rw-r--r--epan/dissectors/packet-enc.c24
-rw-r--r--epan/dissectors/packet-eth.c31
-rw-r--r--epan/dissectors/packet-eth.h2
-rw-r--r--epan/dissectors/packet-ethertype.c51
-rw-r--r--epan/dissectors/packet-fddi.c23
-rw-r--r--epan/dissectors/packet-fr.c101
-rw-r--r--epan/dissectors/packet-frame.c2
-rw-r--r--epan/dissectors/packet-i2c.c7
-rw-r--r--epan/dissectors/packet-ieee80211-prism.c24
-rw-r--r--epan/dissectors/packet-ieee80211-radiotap.c38
-rw-r--r--epan/dissectors/packet-ieee80211-wlancap.c18
-rw-r--r--epan/dissectors/packet-ieee80211.c57
-rw-r--r--epan/dissectors/packet-ieee80211.h6
-rw-r--r--epan/dissectors/packet-ieee8021ah.c26
-rw-r--r--epan/dissectors/packet-ieee8021ah.h31
-rw-r--r--epan/dissectors/packet-ip.c14
-rw-r--r--epan/dissectors/packet-ip.h2
-rw-r--r--epan/dissectors/packet-ipfc.c14
-rw-r--r--epan/dissectors/packet-ipv6.c70
-rw-r--r--epan/dissectors/packet-ipv6.h2
-rw-r--r--epan/dissectors/packet-ipx.c5
-rw-r--r--epan/dissectors/packet-ipx.h2
-rw-r--r--epan/dissectors/packet-isl.c19
-rw-r--r--epan/dissectors/packet-isl.h2
-rw-r--r--epan/dissectors/packet-llc.c84
-rw-r--r--epan/dissectors/packet-llc.h4
-rw-r--r--epan/dissectors/packet-netbios.c3
-rw-r--r--epan/dissectors/packet-netbios.h2
-rw-r--r--epan/dissectors/packet-netrom.c12
-rw-r--r--epan/dissectors/packet-netrom.h2
-rw-r--r--epan/dissectors/packet-null.c59
-rw-r--r--epan/dissectors/packet-pktap.c35
-rw-r--r--epan/dissectors/packet-ppi.c20
-rw-r--r--epan/dissectors/packet-ppp.c40
-rw-r--r--epan/dissectors/packet-ppp.h2
-rw-r--r--epan/dissectors/packet-raw.c21
-rw-r--r--epan/dissectors/packet-sll.c34
-rw-r--r--epan/dissectors/packet-tr.c26
-rw-r--r--epan/dissectors/packet-tr.h2
-rw-r--r--epan/dissectors/packet-vines.c6
-rw-r--r--epan/dissectors/packet-vines.h2
-rw-r--r--epan/dissectors/packet-vlan.c20
-rw-r--r--epan/dissectors/packet-vlan.h27
-rw-r--r--epan/packet.h3
61 files changed, 530 insertions, 757 deletions
diff --git a/capture_info.c b/capture_info.c
index 1f9f104963..0d4afa380e 100644
--- a/capture_info.c
+++ b/capture_info.c
@@ -251,7 +251,8 @@ static void
capture_info_packet(packet_counts *counts, gint wtap_linktype, const guchar *pd, guint32 caplen, union wtap_pseudo_header *pseudo_header)
{
counts->total++;
- call_capture_dissector(wtap_linktype, pd, 0, caplen, counts, pseudo_header);
+ if (!try_capture_dissector("wtap_encap", wtap_linktype, pd, 0, caplen, counts, pseudo_header))
+ counts->other++;
}
diff --git a/epan/capture_dissectors.c b/epan/capture_dissectors.c
index 738bacbc90..1368c254e0 100644
--- a/epan/capture_dissectors.c
+++ b/epan/capture_dissectors.c
@@ -27,48 +27,93 @@
#include "capture_dissectors.h"
+struct capture_dissector_table {
+ GHashTable *hash_table;
+ const char *ui_name;
+};
+
struct capture_dissector_handle
{
- gint linktype;
+ guint32 pattern;
capture_dissector_t dissector;
protocol_t* protocol;
};
-static GHashTable *registered_capture_dissectors = NULL;
+static GHashTable *capture_dissector_tables = NULL;
+
+static void
+destroy_capture_dissector_table(void *data)
+{
+ struct capture_dissector_table *table = (struct capture_dissector_table *)data;
+
+ g_hash_table_destroy(table->hash_table);
+ g_free(data);
+}
void capture_dissector_init(void)
{
- registered_capture_dissectors = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
+ capture_dissector_tables = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, destroy_capture_dissector_table);
}
void capture_dissector_cleanup(void)
{
- g_hash_table_destroy(registered_capture_dissectors);
- registered_capture_dissectors = NULL;
+ g_hash_table_destroy(capture_dissector_tables);
}
-void register_capture_dissector(gint linktype, capture_dissector_t dissector, const int proto)
+void register_capture_dissector_table(const char *name, const char *ui_name)
{
+ struct capture_dissector_table* sub_dissectors;
+
+ /* Make sure the registration is unique */
+ if(g_hash_table_lookup( capture_dissector_tables, name )) {
+ g_error("The capture dissector table %s (%s) is already registered - are you using a buggy plugin?", name, ui_name);
+ }
+
+ sub_dissectors = g_new(struct capture_dissector_table, 1);
+
+ sub_dissectors->hash_table = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, NULL );
+ sub_dissectors->ui_name = ui_name;
+ g_hash_table_insert( capture_dissector_tables, (gpointer)name, (gpointer) sub_dissectors );
+
+}
+
+void register_capture_dissector(const char* name, const guint32 pattern, capture_dissector_t dissector, const int proto)
+{
+ struct capture_dissector_table* sub_dissectors;
struct capture_dissector_handle *handle;
+ /* Make sure table exists */
+ sub_dissectors = (struct capture_dissector_table*)g_hash_table_lookup( capture_dissector_tables, name );
+ g_assert(sub_dissectors != NULL);
+
/* Make sure the registration is unique */
- g_assert(g_hash_table_lookup(registered_capture_dissectors, GUINT_TO_POINTER(linktype)) == NULL);
+ g_assert(g_hash_table_lookup(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern)) == NULL);
handle = wmem_new(wmem_epan_scope(), struct capture_dissector_handle);
- handle->linktype = linktype;
+ handle->pattern = pattern;
handle->dissector = dissector;
handle->protocol = find_protocol_by_id(proto);
- g_hash_table_insert(registered_capture_dissectors, GUINT_TO_POINTER(linktype), (gpointer) handle);
+ g_hash_table_insert(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern), (gpointer) handle);
}
-void call_capture_dissector(gint linktype, const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header)
+gboolean try_capture_dissector(const char* name, const guint32 pattern, const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header)
{
- struct capture_dissector_handle* handle = (struct capture_dissector_handle *)g_hash_table_lookup(registered_capture_dissectors, GUINT_TO_POINTER(linktype));
+ struct capture_dissector_table* sub_dissectors;
+ struct capture_dissector_handle* handle;
+
+ sub_dissectors = (struct capture_dissector_table*)g_hash_table_lookup( capture_dissector_tables, name );
+ if (sub_dissectors == NULL)
+ {
+ /* XXX - ASSERT? */
+ return FALSE;
+ }
+
+ handle = (struct capture_dissector_handle *)g_hash_table_lookup(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern));
if (handle == NULL)
- return;
+ return FALSE;
- handle->dissector(pd, offset, len, ld, pseudo_header);
+ return handle->dissector(pd, offset, len, ld, pseudo_header);
}
/*
diff --git a/epan/capture_dissectors.h b/epan/capture_dissectors.h
index f5313fabf9..7d8ab37855 100644
--- a/epan/capture_dissectors.h
+++ b/epan/capture_dissectors.h
@@ -33,14 +33,18 @@ extern "C" {
/** @file
*/
-/** callback function definition: is a filter available for this packet? */
-typedef void (*capture_dissector_t)(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
+/** callback function definition for capture dissectors */
+typedef gboolean (*capture_dissector_t)(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
+
+/* a protocol uses the function to register a capture sub-dissector table
+ */
+WS_DLL_PUBLIC void register_capture_dissector_table(const char *name, const char *ui_name);
/** Register a new capture dissector. */
-WS_DLL_PUBLIC void register_capture_dissector(gint linktype, capture_dissector_t dissector, const int proto);
+WS_DLL_PUBLIC void register_capture_dissector(const char* name, const guint32 pattern, capture_dissector_t dissector, const int proto);
-WS_DLL_PUBLIC void call_capture_dissector(gint linktype, const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
+WS_DLL_PUBLIC gboolean try_capture_dissector(const char* name, const guint32 pattern, const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
extern void capture_dissector_init(void);
extern void capture_dissector_cleanup(void);
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common
index 0dec2fa646..f378a5471c 100644
--- a/epan/dissectors/Makefile.common
+++ b/epan/dissectors/Makefile.common
@@ -1427,7 +1427,6 @@ DISSECTOR_INCLUDES = \
packet-bfd.h \
packet-bgp.h \
packet-bluetooth.h \
- packet-bpq.h \
packet-bssap.h \
packet-bssgp.h \
packet-btatt.h \
@@ -1549,7 +1548,6 @@ DISSECTOR_INCLUDES = \
packet-ieee80211-radiotap-iter.h \
packet-ieee80211-radiotap-defs.h \
packet-ieee802154.h \
- packet-ieee8021ah.h \
packet-ieee8023.h \
packet-ieee802a.h \
packet-igmp.h \
@@ -1729,7 +1727,6 @@ DISSECTOR_INCLUDES = \
packet-usb.h \
packet-usb-hid.h \
packet-vines.h \
- packet-vlan.h \
packet-wap.h \
packet-wccp.h \
packet-windows-common.h \
diff --git a/epan/dissectors/packet-ap1394.c b/epan/dissectors/packet-ap1394.c
index 73f3d055e8..e2446255d9 100644
--- a/epan/dissectors/packet-ap1394.c
+++ b/epan/dissectors/packet-ap1394.c
@@ -43,14 +43,13 @@ static dissector_table_t ethertype_subdissector_table;
static dissector_handle_t data_handle;
-static void
+static gboolean
capture_ap1394(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 etype;
if (!BYTES_ARE_IN_FRAME(offset, len, 18)) {
- ld->other++;
- return;
+ return FALSE;
}
/* Skip destination and source addresses */
@@ -58,7 +57,7 @@ capture_ap1394(const guchar *pd, int offset, int len, packet_counts *ld, const u
etype = pntoh16(&pd[offset]);
offset += 2;
- capture_ethertype(etype, pd, offset, len, ld, pseudo_header);
+ return try_capture_dissector("ethertype", etype, pd, offset, len, ld, pseudo_header);
}
static int
@@ -118,8 +117,6 @@ proto_register_ap1394(void)
proto_ap1394 = proto_register_protocol("Apple IP-over-IEEE 1394", "IP/IEEE1394", "ap1394");
proto_register_field_array(proto_ap1394, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
- register_capture_dissector(WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, capture_ap1394, proto_ap1394);
}
void
@@ -133,6 +130,7 @@ proto_reg_handoff_ap1394(void)
ap1394_handle = create_dissector_handle(dissect_ap1394, proto_ap1394);
dissector_add_uint("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, ap1394_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, capture_ap1394, proto_ap1394);
}
/*
diff --git a/epan/dissectors/packet-arcnet.c b/epan/dissectors/packet-arcnet.c
index 7622c4cddb..7749aee0e3 100644
--- a/epan/dissectors/packet-arcnet.c
+++ b/epan/dissectors/packet-arcnet.c
@@ -81,20 +81,18 @@ static int arcnet_len(void)
return 1;
}
-static void
+static gboolean
capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_, gboolean has_exception)
{
if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
+ return FALSE;
}
switch (pd[offset]) {
case ARCNET_PROTO_IP_1051:
/* No fragmentation stuff in the header */
- capture_ip(pd, offset + 1, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, offset + 1, len, ld, pseudo_header);
case ARCNET_PROTO_IP_1201:
/*
@@ -125,8 +123,7 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld,
*/
offset++;
if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
+ return FALSE;
}
if (has_exception && pd[offset] == 0xff) {
/* This is an exception packet. The flag value there is the
@@ -135,8 +132,7 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld,
type appears after the padding. */
offset += 4;
}
- capture_ip(pd, offset + 3, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, offset + 3, len, ld, pseudo_header);
case ARCNET_PROTO_ARP_1051:
case ARCNET_PROTO_ARP_1201:
@@ -151,21 +147,22 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld,
break;
default:
- ld->other++;
- break;
+ return FALSE;
}
+
+ return TRUE;
}
-static void
+static gboolean
capture_arcnet (const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
- capture_arcnet_common(pd, 4, len, ld, pseudo_header, FALSE);
+ return capture_arcnet_common(pd, 4, len, ld, pseudo_header, FALSE);
}
-static void
+static gboolean
capture_arcnet_has_exception(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
- capture_arcnet_common(pd, 2, len, ld, pseudo_header, TRUE);
+ return capture_arcnet_common(pd, 2, len, ld, pseudo_header, TRUE);
}
static void
@@ -396,9 +393,6 @@ proto_register_arcnet (void)
proto_register_field_array (proto_arcnet, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
- register_capture_dissector(WTAP_ENCAP_ARCNET_LINUX, capture_arcnet, proto_arcnet);
- register_capture_dissector(WTAP_ENCAP_ARCNET, capture_arcnet_has_exception, proto_arcnet);
-
arcnet_address_type = address_type_dissector_register("AT_ARCNET", "ARCNET Address", arcnet_to_str, arcnet_str_len, arcnet_col_filter_str, arcnet_len, NULL, NULL);
}
@@ -411,9 +405,11 @@ proto_reg_handoff_arcnet (void)
arcnet_handle = create_dissector_handle (dissect_arcnet, proto_arcnet);
dissector_add_uint ("wtap_encap", WTAP_ENCAP_ARCNET, arcnet_handle);
- arcnet_linux_handle = create_dissector_handle (dissect_arcnet_linux,
- proto_arcnet);
+ arcnet_linux_handle = create_dissector_handle (dissect_arcnet_linux, proto_arcnet);
dissector_add_uint ("wtap_encap", WTAP_ENCAP_ARCNET_LINUX, arcnet_linux_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_ARCNET_LINUX, capture_arcnet, proto_arcnet);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_ARCNET, capture_arcnet_has_exception, proto_arcnet);
data_handle = find_dissector ("data");
}
diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c
index c89621aafd..2df7ec2a8e 100644
--- a/epan/dissectors/packet-arp.c
+++ b/epan/dissectors/packet-arp.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <epan/arptypes.h>
#include <epan/addr_resolv.h>
#include "packet-arp.h"
@@ -1358,6 +1359,13 @@ dissect_ax25arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
return tvb_captured_length(tvb);
}
+gboolean
+capture_arp(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld _U_, const union wtap_pseudo_header *pseudo_header _U_)
+{
+ ld->arp++;
+ return TRUE;
+}
+
static const guint8 mac_allzero[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static int
@@ -2013,6 +2021,7 @@ proto_reg_handoff_arp(void)
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_ARP_1201, arp_handle);
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_RARP_1201, arp_handle);
dissector_add_uint("ax25.pid", AX25_P_ARP, arp_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_ARP, capture_arp, proto_arp);
}
/*
diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c
index efe84ca76c..3255b09d2d 100644
--- a/epan/dissectors/packet-atalk.c
+++ b/epan/dissectors/packet-atalk.c
@@ -1580,10 +1580,12 @@ static const value_string llap_type_vals[] = {
};
static value_string_ext llap_type_vals_ext = VALUE_STRING_EXT_INIT(llap_type_vals);
-static void
-capture_llap(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
+static gboolean
+capture_llap(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld _U_, const union wtap_pseudo_header *pseudo_header _U_)
{
- ld->other++;
+ /* XXX - get its own counter
+ ld->other++; */
+ return FALSE;
}
static int
@@ -2066,8 +2068,6 @@ proto_register_atalk(void)
proto_zip = proto_register_protocol("Zone Information Protocol", "ZIP", "zip");
proto_register_field_array(proto_zip, hf_zip, array_length(hf_zip));
- register_capture_dissector(WTAP_ENCAP_LOCALTALK, capture_llap, proto_llap);
-
atp_module = prefs_register_protocol(proto_atp, NULL);
prefs_register_bool_preference(atp_module, "desegment",
"Reassemble ATP messages spanning multiple DDP packets",
@@ -2125,6 +2125,7 @@ proto_reg_handoff_atalk(void)
llap_handle = create_dissector_handle(dissect_llap, proto_llap);
dissector_add_uint("wtap_encap", WTAP_ENCAP_LOCALTALK, llap_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_LOCALTALK, capture_llap, proto_llap);
register_init_routine( atp_init);
register_cleanup_routine( atp_cleanup);
diff --git a/epan/dissectors/packet-atm.c b/epan/dissectors/packet-atm.c
index dba720bc95..ece373ceff 100644
--- a/epan/dissectors/packet-atm.c
+++ b/epan/dissectors/packet-atm.c
@@ -663,7 +663,7 @@ dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
-static void
+static gboolean
capture_lane(const guchar *pd, int offset _U_,
int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header)
{
@@ -673,19 +673,15 @@ capture_lane(const guchar *pd, int offset _U_,
case TRAF_ST_LANE_802_3:
case TRAF_ST_LANE_802_3_MC:
/* Dissect as Ethernet */
- capture_eth(pd, 2, len, ld, pseudo_header);
- break;
+ return capture_eth(pd, 2, len, ld, pseudo_header);
case TRAF_ST_LANE_802_5:
case TRAF_ST_LANE_802_5_MC:
/* Dissect as Token-Ring */
- capture_tr(pd, 2, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return capture_tr(pd, 2, len, ld, pseudo_header);
}
+
+ return FALSE;
}
static int
@@ -805,7 +801,7 @@ static const value_string ipsilon_type_vals[] = {
{ 0, NULL }
};
-static void
+static gboolean
capture_atm(const guchar *pd, int offset _U_,
int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header)
{
@@ -816,19 +812,13 @@ capture_atm(const guchar *pd, int offset _U_,
/* Dissect as WTAP_ENCAP_ATM_RFC1483 */
/* The ATM iptrace capture that we have shows LLC at this point,
* so that's what I'm calling */
- capture_llc(pd, 0, len, ld, pseudo_header);
- break;
+ return capture_llc(pd, 0, len, ld, pseudo_header);
case TRAF_LANE:
- capture_lane(pd, offset, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return capture_lane(pd, offset, len, ld, pseudo_header);
}
- } else
- ld->other++;
+ }
+ return FALSE;
}
static void
@@ -2008,8 +1998,6 @@ proto_register_atm(void)
register_dissector("atm_oam_cell", dissect_atm_oam_cell, proto_oamaal);
register_dissector("atm_pw_oam_cell", dissect_atm_pw_oam_cell, proto_oamaal);
- register_capture_dissector(WTAP_ENCAP_ATM_PDUS, capture_atm, proto_atm);
-
atm_module = prefs_register_protocol ( proto_atm, NULL );
prefs_register_bool_preference(atm_module, "dissect_lane_as_sscop", "Dissect LANE as SSCOP",
"Autodection between LANE and SSCOP is hard. As default LANE is preferred",
@@ -2044,6 +2032,7 @@ proto_reg_handoff_atm(void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_ATM_PDUS_UNTRUNCATED,
atm_untruncated_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_ATM_PDUS, capture_atm, proto_atm);
}
/*
diff --git a/epan/dissectors/packet-ax25-kiss.c b/epan/dissectors/packet-ax25-kiss.c
index e355bd15d0..aa5a26f808 100644
--- a/epan/dissectors/packet-ax25-kiss.c
+++ b/epan/dissectors/packet-ax25-kiss.c
@@ -178,35 +178,36 @@ static const value_string kiss_frame_types[] = {
{ 0, NULL }
};
-static void
+static gboolean
capture_ax25_kiss( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
int l_offset;
guint8 kiss_cmd;
if ( ! BYTES_ARE_IN_FRAME( offset, len, KISS_HEADER_SIZE ) )
- {
- ld->other++;
- return;
- }
+ return FALSE;
l_offset = offset;
kiss_cmd = pd[ l_offset ];
l_offset += KISS_HEADER_SIZE; /* step over kiss header */
switch ( kiss_cmd & KISS_CMD_MASK )
- {
- case KISS_DATA_FRAME : capture_ax25( pd, l_offset, len, ld, pseudo_header ); break;
+ {
+ case KISS_DATA_FRAME :
+ return capture_ax25( pd, l_offset, len, ld, pseudo_header );
case KISS_TXDELAY : break;
case KISS_PERSISTENCE : break;
case KISS_SLOT_TIME : break;
case KISS_TXTAIL : break;
case KISS_FULLDUPLEX : break;
case KISS_SETHARDWARE : break;
- case KISS_DATA_FRAME_ACK: l_offset += 2; capture_ax25( pd, l_offset, len, ld, pseudo_header ); break;
+ case KISS_DATA_FRAME_ACK:
+ l_offset += 2;
+ return capture_ax25( pd, l_offset, len, ld, pseudo_header );
case KISS_POLL_MODE : break;
case KISS_RETURN : break;
default : break;
- }
+ }
+ return FALSE;
}
/* Code to actually dissect the packets */
@@ -432,8 +433,6 @@ proto_register_ax25_kiss(void)
proto_register_field_array( proto_ax25_kiss, hf, array_length( hf ) );
proto_register_subtree_array( ett, array_length( ett ) );
- register_capture_dissector(WTAP_ENCAP_AX25_KISS, capture_ax25_kiss, proto_ax25_kiss);
-
/* Register preferences module */
ax25_kiss_module = prefs_register_protocol( proto_ax25_kiss, NULL);
@@ -448,6 +447,7 @@ void
proto_reg_handoff_ax25_kiss(void)
{
dissector_add_uint( "wtap_encap", WTAP_ENCAP_AX25_KISS, kiss_handle );
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_AX25_KISS, capture_ax25_kiss, proto_ax25_kiss);
/* only currently implemented for AX.25 */
ax25_handle = find_dissector( "ax25" );
diff --git a/epan/dissectors/packet-ax25.c b/epan/dissectors/packet-ax25.c
index 1539379ac7..03d28b09f3 100644
--- a/epan/dissectors/packet-ax25.c
+++ b/epan/dissectors/packet-ax25.c
@@ -254,7 +254,7 @@ dissect_ax25( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
return tvb_captured_length(tvb);
}
-void
+gboolean
capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint8 control;
@@ -262,10 +262,7 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un
int l_offset;
if ( ! BYTES_ARE_IN_FRAME( offset, len, AX25_HEADER_SIZE ) )
- {
- ld->other++;
- return;
- }
+ return FALSE;
l_offset = offset;
l_offset += AX25_ADDR_LEN; /* step over dst addr point at src addr */
@@ -277,7 +274,7 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un
/* decode the pid field (if appropriate) */
if ( XDLC_IS_INFORMATION( control ) )
- {
+ {
l_offset += 1; /* step over control byte point at pid */
pid = pd[ l_offset ];
@@ -285,19 +282,15 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un
switch ( pid & 0x0ff )
{
case AX25_P_NETROM :
- capture_netrom( pd, l_offset, len, ld, pseudo_header );
- break;
+ return capture_netrom( pd, l_offset, len, ld, pseudo_header );
case AX25_P_IP :
- capture_ip( pd, l_offset, len, ld, pseudo_header );
- break;
+ return capture_ip( pd, l_offset, len, ld, pseudo_header );
case AX25_P_ARP :
ld->arp++;
- break;
- default :
- ld->other++;
- break;
+ return TRUE;
}
- }
+ }
+ return FALSE;
}
void
@@ -435,8 +428,6 @@ proto_register_ax25(void)
proto_register_field_array( proto_ax25, hf, array_length(hf ) );
proto_register_subtree_array(ett, array_length(ett ) );
- register_capture_dissector(WTAP_ENCAP_AX25, capture_ax25, proto_ax25);
-
/* Register dissector table for protocol IDs */
ax25_dissector_table = register_dissector_table("ax25.pid", "AX.25 protocol ID", FT_UINT8, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
}
@@ -447,6 +438,8 @@ proto_reg_handoff_ax25(void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_AX25, ax25_handle);
dissector_add_uint("ip.proto", IP_PROTO_AX25, ax25_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_AX25, capture_ax25, proto_ax25);
+
data_handle = find_dissector( "data" );
}
diff --git a/epan/dissectors/packet-ax25.h b/epan/dissectors/packet-ax25.h
index eb99711428..8f92f7df1b 100644
--- a/epan/dissectors/packet-ax25.h
+++ b/epan/dissectors/packet-ax25.h
@@ -26,6 +26,6 @@
#define __PACKET_AX25_H__
extern
-void capture_ax25(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_ax25(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
#endif
diff --git a/epan/dissectors/packet-bpq.c b/epan/dissectors/packet-bpq.c
index f6b127338e..5c6fb1ff97 100644
--- a/epan/dissectors/packet-bpq.c
+++ b/epan/dissectors/packet-bpq.c
@@ -37,8 +37,8 @@
#include <epan/packet.h>
#include <epan/etypes.h>
+#include <epan/capture_dissectors.h>
-#include "packet-bpq.h"
#include "packet-ax25.h"
#define STRLEN 80
@@ -101,20 +101,17 @@ dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
return tvb_captured_length(tvb);
}
-void
+static gboolean
capture_bpq( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
int l_offset;
if ( ! BYTES_ARE_IN_FRAME( offset, len, BPQ_HEADER_SIZE ) )
- {
- ld->other++;
- return;
- }
+ return FALSE;
l_offset = offset;
l_offset += BPQ_HEADER_SIZE; /* step over bpq header to point at the AX.25 packet*/
- capture_ax25( pd, l_offset, len, ld, pseudo_header );
+ return capture_ax25( pd, l_offset, len, ld, pseudo_header );
}
void
@@ -152,6 +149,7 @@ proto_reg_handoff_bpq(void)
bpq_handle = create_dissector_handle( dissect_bpq, proto_bpq );
dissector_add_uint("ethertype", ETHERTYPE_BPQ, bpq_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_BPQ, capture_bpq, proto_bpq);
/* BPQ is only implemented for AX.25 */
ax25_handle = find_dissector( "ax25" );
diff --git a/epan/dissectors/packet-bpq.h b/epan/dissectors/packet-bpq.h
deleted file mode 100644
index e0d7055cd9..0000000000
--- a/epan/dissectors/packet-bpq.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* packet-bpq.h
- *
- * Routines for Amateur Packet Radio protocol dissection
- * Copyright 2005,2006,2007,2008,2009,2010,2012 R.W. Stearn <richard@rns-stearn.demon.co.uk>
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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.
- *
- * 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.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __PACKET_BPQ_H__
-#define __PACKET_BPQ_H__
-
-void capture_bpq(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
-
-#endif
diff --git a/epan/dissectors/packet-chdlc.c b/epan/dissectors/packet-chdlc.c
index 3706b44d80..d125552dca 100644
--- a/epan/dissectors/packet-chdlc.c
+++ b/epan/dissectors/packet-chdlc.c
@@ -113,20 +113,17 @@ const value_string chdlc_vals[] = {
{0, NULL}
};
-void
+gboolean
capture_chdlc( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_ ) {
- if (!BYTES_ARE_IN_FRAME(offset, len, 4)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 4))
+ return FALSE;
+
switch (pntoh16(&pd[offset + 2])) {
case ETHERTYPE_IP:
- capture_ip(pd, offset + 4, len, ld, pseudo_header);
- break;
- default:
- ld->other++;
- break;
+ return capture_ip(pd, offset + 4, len, ld, pseudo_header);
}
+
+ return FALSE;
}
void
@@ -233,8 +230,6 @@ proto_register_chdlc(void)
proto_register_field_array(proto_chdlc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_capture_dissector(WTAP_ENCAP_CHDLC, capture_chdlc, proto_chdlc);
-
/* subdissector code */
subdissector_table = register_dissector_table("chdlc.protocol",
"Cisco HDLC protocol",
@@ -265,6 +260,8 @@ proto_reg_handoff_chdlc(void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_CHDLC_WITH_PHDR, chdlc_handle);
dissector_add_uint("juniper.proto", JUNIPER_PROTO_CHDLC, chdlc_handle);
dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_CHDLC, chdlc_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_CHDLC, capture_chdlc, proto_chdlc);
}
diff --git a/epan/dissectors/packet-chdlc.h b/epan/dissectors/packet-chdlc.h
index be7f96995c..4cbd7ef4e6 100644
--- a/epan/dissectors/packet-chdlc.h
+++ b/epan/dissectors/packet-chdlc.h
@@ -32,7 +32,7 @@
#define CHDLC_ADDR_MULTICAST 0x8f
extern
-void capture_chdlc(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_chdlc(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
extern const value_string chdlc_vals[];
diff --git a/epan/dissectors/packet-clip.c b/epan/dissectors/packet-clip.c
index 60528c12fa..634ff224b0 100644
--- a/epan/dissectors/packet-clip.c
+++ b/epan/dissectors/packet-clip.c
@@ -43,10 +43,10 @@ static expert_field ei_no_link_info = EI_INIT;
static dissector_handle_t ip_handle;
-static void
+static gboolean
capture_clip( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_ ) {
- capture_ip(pd, offset, len, ld, pseudo_header);
+ return capture_ip(pd, offset, len, ld, pseudo_header);
}
static int
@@ -109,8 +109,6 @@ proto_register_clip(void)
proto_register_subtree_array(ett, array_length(ett));
expert_clip = expert_register_protocol(proto_clip);
expert_register_field_array(expert_clip, ei, array_length(ei));
-
- register_capture_dissector(WTAP_ENCAP_LINUX_ATM_CLIP, capture_clip, proto_clip);
}
void
@@ -126,6 +124,8 @@ proto_reg_handoff_clip(void)
clip_handle = create_dissector_handle(dissect_clip, proto_clip);
/* XXX - no protocol, can't be disabled */
dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, clip_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, capture_clip, proto_clip);
}
/*
diff --git a/epan/dissectors/packet-enc.c b/epan/dissectors/packet-enc.c
index 327f68db61..029fd2baad 100644
--- a/epan/dissectors/packet-enc.c
+++ b/epan/dissectors/packet-enc.c
@@ -65,31 +65,25 @@ static int hf_enc_flags = -1;
static gint ett_enc = -1;
-static void
+static gboolean
capture_enc(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint32 af;
- if (!BYTES_ARE_IN_FRAME(0, len, (int)BSD_ENC_HDRLEN)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, (int)BSD_ENC_HDRLEN))
+ return FALSE;
af = pntoh32(pd + offsetof(struct enchdr, af));
switch (af) {
case BSD_AF_INET:
- capture_ip(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header);
case BSD_AF_INET6_BSD:
- capture_ipv6(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return capture_ipv6(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header);
}
+
+ return FALSE;
}
static const value_string af_vals[] = {
@@ -181,8 +175,6 @@ proto_register_enc(void)
"ENC", "enc");
proto_register_field_array(proto_enc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
- register_capture_dissector(WTAP_ENCAP_ENC, capture_enc, proto_enc);
}
void
@@ -196,6 +188,8 @@ proto_reg_handoff_enc(void)
enc_handle = create_dissector_handle(dissect_enc, proto_enc);
dissector_add_uint("wtap_encap", WTAP_ENCAP_ENC, enc_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_ENC, capture_enc, proto_enc);
}
/*
diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c
index 6b0be85f56..390bb0b783 100644
--- a/epan/dissectors/packet-eth.c
+++ b/epan/dissectors/packet-eth.c
@@ -191,16 +191,14 @@ eth_build_filter(packet_info *pinfo)
#define ETHERNET_802_3 2
#define ETHERNET_SNAP 3
-void
+gboolean
capture_eth(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 etype, length;
int ethhdr_type; /* the type of ethernet frame */
- if (!BYTES_ARE_IN_FRAME(offset, len, ETH_HEADER_SIZE)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, ETH_HEADER_SIZE))
+ return FALSE;
etype = pntoh16(&pd[offset+12]);
@@ -212,8 +210,7 @@ capture_eth(const guchar *pd, int offset, int len, packet_counts *ld, const unio
if ((pd[offset] == 0x01 || pd[offset] == 0x0C) && pd[offset+1] == 0x00
&& pd[offset+2] == 0x0C && pd[offset+3] == 0x00
&& pd[offset+4] == 0x00) {
- capture_isl(pd, offset, len, ld, pseudo_header);
- return;
+ return capture_isl(pd, offset, len, ld, pseudo_header);
}
}
@@ -236,10 +233,8 @@ capture_eth(const guchar *pd, int offset, int len, packet_counts *ld, const unio
* frame; the dissector for those frames registers itself with
* an ethernet type of ETHERTYPE_UNK.
*/
- if (etype > IEEE_802_3_MAX_LEN && etype < ETHERNET_II_MIN_LEN) {
- ld->other++;
- return;
- }
+ if (etype > IEEE_802_3_MAX_LEN && etype < ETHERNET_II_MIN_LEN)
+ return FALSE;
if (etype <= IEEE_802_3_MAX_LEN && etype != ETHERTYPE_UNK) {
length = etype;
@@ -272,15 +267,14 @@ capture_eth(const guchar *pd, int offset, int len, packet_counts *ld, const unio
switch (ethhdr_type) {
case ETHERNET_802_3:
- capture_ipx(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_ipx(pd, offset, len, ld, pseudo_header);
case ETHERNET_802_2:
- capture_llc(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_llc(pd, offset, len, ld, pseudo_header);
case ETHERNET_II:
- capture_ethertype(etype, pd, offset, len, ld, pseudo_header);
- break;
+ return try_capture_dissector("ethertype", etype, pd, offset, len, ld, pseudo_header);
}
+
+ return FALSE;
}
static gboolean check_is_802_2(tvbuff_t *tvb, int fcs_len);
@@ -1014,7 +1008,6 @@ proto_register_eth(void)
register_dissector("eth_withoutfcs", dissect_eth_withoutfcs, proto_eth);
register_dissector("eth_withfcs", dissect_eth_withfcs, proto_eth);
register_dissector("eth", dissect_eth_maybefcs, proto_eth);
- register_capture_dissector(WTAP_ENCAP_ETHERNET, capture_eth, proto_eth);
eth_tap = register_tap("eth");
register_conversation_table(proto_eth, TRUE, eth_conversation_packet, eth_hostlist_packet);
@@ -1057,6 +1050,8 @@ proto_reg_handoff_eth(void)
dissector_add_for_decode_as("udp.port", eth_withoutfcs_handle);
dissector_add_for_decode_as("pcli.payload", eth_withoutfcs_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_ETHERNET, capture_eth, proto_eth);
}
/*
diff --git a/epan/dissectors/packet-eth.h b/epan/dissectors/packet-eth.h
index 2d42ecf2f5..ac1d66fdd0 100644
--- a/epan/dissectors/packet-eth.h
+++ b/epan/dissectors/packet-eth.h
@@ -29,7 +29,7 @@ typedef struct _eth_hdr {
} eth_hdr;
extern
-void capture_eth(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_eth(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
void add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
int trailer_id, tvbuff_t *tvb, tvbuff_t *trailer_tvb,
diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c
index 72ddce9ea6..88bbcaceee 100644
--- a/epan/dissectors/packet-ethertype.c
+++ b/epan/dissectors/packet-ethertype.c
@@ -32,16 +32,8 @@
#include <epan/ppptypes.h>
#include <epan/show_exception.h>
#include <epan/decode_as.h>
-#include "packet-bpq.h"
+#include <epan/capture_dissectors.h>
#include "packet-eth.h"
-#include "packet-ip.h"
-#include "packet-ipv6.h"
-#include "packet-ipx.h"
-#include "packet-vlan.h"
-#include "packet-ieee8021ah.h"
-#include "packet-vines.h"
-#include "packet-llc.h"
-
void proto_register_ethertype(void);
void proto_reg_handoff_ethertype(void);
@@ -204,46 +196,6 @@ static void add_dix_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh
int trailer_id, tvbuff_t *tvb, tvbuff_t *next_tvb, int offset_after_etype,
guint length_before, gint fcs_len);
-void
-capture_ethertype(guint16 etype, const guchar *pd, int offset, int len,
- packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
-{
- switch (etype) {
- case ETHERTYPE_ARP:
- ld->arp++;
- break;
- case ETHERTYPE_IP:
- capture_ip(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_IPv6:
- capture_ipv6(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_IPX:
- capture_ipx(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_VLAN:
- capture_vlan(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_IEEE_802_1AD:
- case ETHERTYPE_IEEE_802_1AH:
- capture_ieee8021ah(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_VINES_IP:
- case ETHERTYPE_VINES_ECHO:
- capture_vines(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_BPQ:
- capture_bpq(pd, offset, len, ld, pseudo_header);
- break;
- case ETHERTYPE_JUMBO_LLC:
- capture_llc(pd, offset, len, ld, pseudo_header);
- break;
- default:
- ld->other++;
- break;
- }
-}
-
/*
void
ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
@@ -400,6 +352,7 @@ proto_register_ethertype(void)
/* subdissector code */
ethertype_dissector_table = register_dissector_table("ethertype",
"Ethertype", FT_UINT16, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
+ register_capture_dissector_table("ethertype", "Ethertype");
register_decode_as(&ethertype_da);
}
diff --git a/epan/dissectors/packet-fddi.c b/epan/dissectors/packet-fddi.c
index afb6b92535..cd28e8ec1e 100644
--- a/epan/dissectors/packet-fddi.c
+++ b/epan/dissectors/packet-fddi.c
@@ -199,15 +199,14 @@ fddi_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, con
return 1;
}
-static void
+static gboolean
capture_fddi(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
int fc;
- if (!BYTES_ARE_IN_FRAME(0, len, FDDI_HEADER_SIZE + FDDI_PADDING)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, FDDI_HEADER_SIZE + FDDI_PADDING))
+ return FALSE;
+
offset = FDDI_PADDING + FDDI_HEADER_SIZE;
fc = (int) pd[FDDI_P_FC+FDDI_PADDING];
@@ -232,14 +231,10 @@ capture_fddi(const guchar *pd, int offset, int len, packet_counts *ld, const uni
case FDDI_FC_LLC_ASYNC + 13 :
case FDDI_FC_LLC_ASYNC + 14 :
case FDDI_FC_LLC_ASYNC + 15 :
- capture_llc(pd, offset, len, ld, pseudo_header);
- return;
- default :
- ld->other++;
- return;
-
+ return capture_llc(pd, offset, len, ld, pseudo_header);
} /* fc */
+ return FALSE;
} /* capture_fddi */
static const gchar *
@@ -519,9 +514,6 @@ proto_register_fddi(void)
*/
register_dissector("fddi", dissect_fddi_not_bitswapped, proto_fddi);
- register_capture_dissector(WTAP_ENCAP_FDDI, capture_fddi, proto_fddi);
- register_capture_dissector(WTAP_ENCAP_FDDI_BITSWAPPED, capture_fddi, proto_fddi);
-
fddi_module = prefs_register_protocol(proto_fddi, NULL);
prefs_register_bool_preference(fddi_module, "padding",
"Add 3-byte padding to all FDDI packets",
@@ -552,6 +544,9 @@ proto_reg_handoff_fddi(void)
create_dissector_handle(dissect_fddi_bitswapped, proto_fddi);
dissector_add_uint("wtap_encap", WTAP_ENCAP_FDDI_BITSWAPPED,
fddi_bitswapped_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_FDDI, capture_fddi, proto_fddi);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_FDDI_BITSWAPPED, capture_fddi, proto_fddi);
}
/*
diff --git a/epan/dissectors/packet-fr.c b/epan/dissectors/packet-fr.c
index bc3d18b945..139bd78221 100644
--- a/epan/dissectors/packet-fr.c
+++ b/epan/dissectors/packet-fr.c
@@ -206,7 +206,7 @@ static const xdlc_cf_items fr_cf_items_ext = {
&hf_fr_ftype_s_u_ext
};
-void
+static gboolean
capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint8 fr_octet;
@@ -217,10 +217,9 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
/*
* OK, fetch the address field - keep going until we get an EA bit.
*/
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_octet = pd[offset];
if (fr_octet & FRELAY_EA) {
/*
@@ -228,8 +227,7 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
* XXX - is this FRF.12 frame relay fragmentation? If so, can
* we handle that?
*/
- ld->other++;
- return;
+ return FALSE;
}
/*
* The first octet contains the upper 6 bits of the DLCI, as well
@@ -242,10 +240,9 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
* The second octet contains 4 more bits of DLCI, as well as FECN,
* BECN, and DE.
*/
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_octet = pd[offset];
addr = (addr << 4) | ((fr_octet & FRELAY_SECOND_DLCI) >> 4);
offset++;
@@ -258,10 +255,9 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
* and lower DLCI or DL-CORE control plus the DLCI or DL-CORE
* control indicator flag if EA is set.
*/
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_octet = pd[offset];
if (!(fr_octet & FRELAY_EA)) {
/*
@@ -269,20 +265,18 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
*/
addr = (addr << 7) | ((fr_octet & FRELAY_THIRD_DLCI) >> 1);
offset++;
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_octet = pd[offset];
while (!(fr_octet & FRELAY_EA)) {
/*
* Bogus! More than 4 octets of address.
*/
offset++;
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_octet = pd[offset];
}
}
@@ -306,10 +300,9 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
switch (fr_encap) {
case FRF_3_2:
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_ctrl = pd[offset];
if (fr_ctrl == XDLC_U) {
offset++;
@@ -320,41 +313,34 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
* protocols which do not have an NLPID assigned or do not
* have a SNAP encapsulation" stuff from RFC 2427.
*/
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_nlpid = pd[offset];
if (fr_nlpid == 0) {
offset++;
- if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 1))
+ return FALSE;
+
fr_nlpid = pd[offset];
}
offset++;
switch (fr_nlpid) {
case NLPID_IP:
- capture_ip(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, offset, len, ld, pseudo_header);
case NLPID_IP6:
- capture_ipv6(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_ipv6(pd, offset, len, ld, pseudo_header);
case NLPID_PPP:
- capture_ppp_hdlc(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_ppp_hdlc(pd, offset, len, ld, pseudo_header);
case NLPID_SNAP:
- capture_snap(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_snap(pd, offset, len, ld, pseudo_header);
default:
- ld->other++;
- break;
+ return FALSE;
}
} else {
if (addr == 0) {
@@ -368,36 +354,34 @@ capture_fr(const guchar *pd, int offset, int len, packet_counts *ld, const union
* XXX - but what is it? Is Q.933 carried inside UI
* frames or other types of frames or both?
*/
- ld->other++;
- return;
+ return FALSE;
}
if (fr_ctrl == (XDLC_U|XDLC_XID)) {
/*
* XID.
*/
- ld->other++;
- return;
+ return FALSE;
}
/*
* If the data does not start with unnumbered information (03) and
* the DLCI# is not 0, then there may be Cisco Frame Relay encapsulation.
*/
- capture_chdlc(pd, offset, len, ld, pseudo_header);
+ return capture_chdlc(pd, offset, len, ld, pseudo_header);
}
break;
case GPRS_NS:
- ld->other++;
- break;
+ return FALSE;
case RAW_ETHER:
if (addr != 0)
- capture_eth(pd, offset, len, ld, pseudo_header);
- else
- ld->other++;
- break;
+ return capture_eth(pd, offset, len, ld, pseudo_header);
+
+ return FALSE;
}
+
+ return FALSE;
}
static void
@@ -988,8 +972,6 @@ proto_register_fr(void)
register_dissector("fr_uncompressed", dissect_fr_uncompressed, proto_fr);
register_dissector("fr", dissect_fr, proto_fr);
register_dissector("fr_stripped_address", dissect_fr_stripped_address, proto_fr);
- register_capture_dissector(WTAP_ENCAP_FRELAY, capture_fr, proto_fr);
- register_capture_dissector(WTAP_ENCAP_FRELAY_WITH_PHDR, capture_fr, proto_fr);
frencap_module = prefs_register_protocol(proto_fr, NULL);
/*
@@ -1021,6 +1003,9 @@ proto_reg_handoff_fr(void)
fr_phdr_handle = create_dissector_handle(dissect_fr_phdr, proto_fr);
dissector_add_uint("wtap_encap", WTAP_ENCAP_FRELAY_WITH_PHDR, fr_phdr_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_FRELAY, capture_fr, proto_fr);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_FRELAY_WITH_PHDR, capture_fr, proto_fr);
+
eth_withfcs_handle = find_dissector("eth_withfcs");
gprs_ns_handle = find_dissector("gprs_ns");
data_handle = find_dissector("data");
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index 4521d24d1b..0776295f6c 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -28,6 +28,7 @@
#endif
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <epan/epan.h>
#include <epan/exceptions.h>
#include <epan/show_exception.h>
@@ -879,6 +880,7 @@ proto_register_frame(void)
"Wiretap encapsulation type", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
wtap_fts_rec_dissector_table = register_dissector_table("wtap_fts_rec",
"Wiretap file type for file-type-specific records", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_ALLOW_DUPLICATE);
+ register_capture_dissector_table("wtap_encap", "Wiretap encapsulation type");
proto_frame = proto_register_protocol("Frame", "Frame", "frame");
proto_pkt_comment = proto_register_protocol("Packet comments", "Pkt_Comment", "pkt_comment");
diff --git a/epan/dissectors/packet-i2c.c b/epan/dissectors/packet-i2c.c
index 63a8bb152c..f62eee079a 100644
--- a/epan/dissectors/packet-i2c.c
+++ b/epan/dissectors/packet-i2c.c
@@ -84,7 +84,7 @@ static gpointer i2c_value(packet_info *pinfo _U_)
return 0;
}
-static void
+static gboolean
capture_i2c(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header)
{
if (pseudo_header->i2c.is_event) {
@@ -92,6 +92,8 @@ capture_i2c(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld
} else {
ld->i2c_data++;
}
+
+ return TRUE;
}
static const char *
@@ -247,8 +249,6 @@ proto_register_i2c(void)
proto_register_field_array(proto_i2c, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_capture_dissector(WTAP_ENCAP_I2C, capture_i2c, proto_i2c);
-
subdissector_table = register_dissector_table("i2c.message", "I2C messages dissector", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
m = prefs_register_protocol(proto_i2c, NULL);
@@ -266,6 +266,7 @@ proto_reg_handoff_i2c(void)
i2c_handle = create_dissector_handle(dissect_i2c, proto_i2c);
dissector_add_uint("wtap_encap", WTAP_ENCAP_I2C, i2c_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_I2C, capture_i2c, proto_i2c);
}
/*
diff --git a/epan/dissectors/packet-ieee80211-prism.c b/epan/dissectors/packet-ieee80211-prism.c
index 6d223d8dee..50b69a9567 100644
--- a/epan/dissectors/packet-ieee80211-prism.c
+++ b/epan/dissectors/packet-ieee80211-prism.c
@@ -237,33 +237,29 @@ prism_rate_return(guint32 rate)
}
-static void
+static gboolean
capture_prism(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint32 cookie;
- if (!BYTES_ARE_IN_FRAME(offset, len, 4)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 4))
+ return FALSE;
/* Some captures with DLT_PRISM have the AVS WLAN header */
cookie = pntoh32(pd);
if ((cookie == WLANCAP_MAGIC_COOKIE_V1) ||
(cookie == WLANCAP_MAGIC_COOKIE_V2)) {
- capture_wlancap(pd, offset, len, ld, pseudo_header);
- return;
+ return capture_wlancap(pd, offset, len, ld, pseudo_header);
}
/* Prism header */
- if (!BYTES_ARE_IN_FRAME(offset, len, PRISM_HEADER_LENGTH)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, PRISM_HEADER_LENGTH))
+ return FALSE;
+
offset += PRISM_HEADER_LENGTH;
/* 802.11 header follows */
- capture_ieee80211(pd, offset, len, ld, pseudo_header);
+ return capture_ieee80211(pd, offset, len, ld, pseudo_header);
}
static int
@@ -558,8 +554,6 @@ void proto_register_ieee80211_prism(void)
"prism");
proto_register_field_array(proto_prism, hf_prism, array_length(hf_prism));
proto_register_subtree_array(tree_array, array_length(tree_array));
-
- register_capture_dissector(WTAP_ENCAP_IEEE_802_11_PRISM, capture_prism, proto_prism);
}
void proto_reg_handoff_ieee80211_prism(void)
@@ -571,6 +565,8 @@ void proto_reg_handoff_ieee80211_prism(void)
ieee80211_handle = find_dissector("wlan");
ieee80211_radio_handle = find_dissector("wlan_radio");
wlancap_handle = find_dissector("wlancap");
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_PRISM, capture_prism, proto_prism);
}
/*
diff --git a/epan/dissectors/packet-ieee80211-radiotap.c b/epan/dissectors/packet-ieee80211-radiotap.c
index 1e08cd6c49..e346422200 100644
--- a/epan/dissectors/packet-ieee80211-radiotap.c
+++ b/epan/dissectors/packet-ieee80211-radiotap.c
@@ -455,7 +455,7 @@ static const true_false_string preamble_type = {
* dissectors, such as tcpdump(8), expect the padding.
*/
-static void
+static gboolean
capture_radiotap(const guchar * pd, int offset, int len, packet_counts * ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 it_len;
@@ -465,26 +465,21 @@ capture_radiotap(const guchar * pd, int offset, int len, packet_counts * ld, con
if (!BYTES_ARE_IN_FRAME(offset, len,
sizeof(struct ieee80211_radiotap_header))) {
- ld->other++;
- return;
+ return FALSE;
}
hdr = (const struct ieee80211_radiotap_header *)pd;
it_len = pletoh16(&hdr->it_len);
- if (!BYTES_ARE_IN_FRAME(offset, len, it_len)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, it_len))
+ return FALSE;
if (it_len > len) {
/* Header length is bigger than total packet length */
- ld->other++;
- return;
+ return FALSE;
}
if (it_len < sizeof(struct ieee80211_radiotap_header)) {
/* Header length is shorter than fixed-length portion of header */
- ld->other++;
- return;
+ return FALSE;
}
present = pletoh32(&hdr->it_present);
@@ -495,8 +490,7 @@ capture_radiotap(const guchar * pd, int offset, int len, packet_counts * ld, con
xpresent = present;
while (xpresent & BIT(IEEE80211_RADIOTAP_EXT)) {
if (!BYTES_ARE_IN_FRAME(offset, 4, it_len)) {
- ld->other++;
- return;
+ return FALSE;
}
xpresent = pletoh32(pd + offset);
offset += 4;
@@ -519,8 +513,7 @@ capture_radiotap(const guchar * pd, int offset, int len, packet_counts * ld, con
if (it_len < 8) {
/* No room in header for this field. */
- ld->other++;
- return;
+ return FALSE;
}
/* That field is present, and it's 8 bytes long. */
offset += 8;
@@ -533,22 +526,20 @@ capture_radiotap(const guchar * pd, int offset, int len, packet_counts * ld, con
if (present & BIT(IEEE80211_RADIOTAP_FLAGS)) {
if (it_len < 1) {
/* No room in header for this field. */
- ld->other++;
- return;
+ return FALSE;
}
/* That field is present; fetch it. */
if (!BYTES_ARE_IN_FRAME(offset, len, 1)) {
- ld->other++;
- return;
+ return FALSE;
}
rflags = pd[offset];
}
/* 802.11 header follows */
if (rflags & IEEE80211_RADIOTAP_F_DATAPAD)
- capture_ieee80211_datapad(pd, offset + it_len, len, ld, pseudo_header);
- else
- capture_ieee80211(pd, offset + it_len, len, ld, pseudo_header);
+ return capture_ieee80211_datapad(pd, offset + it_len, len, ld, pseudo_header);
+
+ return capture_ieee80211(pd, offset + it_len, len, ld, pseudo_header);
}
static int
@@ -2662,7 +2653,6 @@ void proto_register_radiotap(void)
expert_radiotap = expert_register_protocol(proto_radiotap);
expert_register_field_array(expert_radiotap, ei, array_length(ei));
register_dissector("radiotap", dissect_radiotap, proto_radiotap);
- register_capture_dissector(WTAP_ENCAP_IEEE_802_11_RADIOTAP, capture_radiotap, proto_radiotap);
radiotap_tap = register_tap("radiotap");
@@ -2686,6 +2676,8 @@ void proto_reg_handoff_radiotap(void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_RADIOTAP,
radiotap_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_RADIOTAP, capture_radiotap, proto_radiotap);
}
/*
diff --git a/epan/dissectors/packet-ieee80211-wlancap.c b/epan/dissectors/packet-ieee80211-wlancap.c
index ad53c78a30..a3efb2ff1f 100644
--- a/epan/dissectors/packet-ieee80211-wlancap.c
+++ b/epan/dissectors/packet-ieee80211-wlancap.c
@@ -72,27 +72,23 @@ static gint ett_wlancap = -1;
static dissector_handle_t wlancap_handle;
-void
+gboolean
capture_wlancap(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint32 length;
- if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32)*2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32)*2))
+ return FALSE;
length = pntoh32(pd+sizeof(guint32));
- if (!BYTES_ARE_IN_FRAME(offset, len, length)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, length))
+ return FALSE;
offset += length;
/* 802.11 header follows */
- capture_ieee80211(pd, offset, len, ld, pseudo_header);
+ return capture_ieee80211(pd, offset, len, ld, pseudo_header);
}
/*
@@ -849,7 +845,6 @@ void proto_register_ieee80211_wlancap(void)
proto_register_field_array(proto_wlancap, hf_wlancap,
array_length(hf_wlancap));
register_dissector("wlancap", dissect_wlancap, proto_wlancap);
- register_capture_dissector(WTAP_ENCAP_IEEE_802_11_AVS, capture_wlancap, proto_wlancap);
wlancap_handle = create_dissector_handle(dissect_wlancap, proto_wlancap);
dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_AVS,
@@ -860,6 +855,7 @@ void proto_register_ieee80211_wlancap(void)
void proto_reg_handoff_ieee80211_wlancap(void)
{
ieee80211_radio_handle = find_dissector("wlan_radio");
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_AVS, capture_wlancap, proto_wlancap);
}
/*
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index a5e4567247..1cd76a9e9e 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -5620,23 +5620,19 @@ add_mimo_compressed_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb
/* ************************************************************************* */
/* This is the capture function used to update packet counts */
/* ************************************************************************* */
-static void
+static gboolean
capture_ieee80211_common (const guchar * pd, int offset, int len,
packet_counts * ld, const union wtap_pseudo_header *pseudo_header _U_, gboolean datapad)
{
guint16 fcf, hdr_length;
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other += 1;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
fcf = pletoh16 (&pd[offset]);
- if (IS_PROTECTED(FCF_FLAGS(fcf)) && (wlan_ignore_wep == WLAN_IGNORE_WEP_NO)) {
- ld->other += 1;
- return;
- }
+ if (IS_PROTECTED(FCF_FLAGS(fcf)) && (wlan_ignore_wep == WLAN_IGNORE_WEP_NO))
+ return FALSE;
switch (COMPOSE_FRAME_TYPE (fcf)) {
@@ -5670,10 +5666,9 @@ capture_ieee80211_common (const guchar * pd, int offset, int len,
* Look at the Mesh Control subfield of the QoS field and at the
* purported mesh flag fields.
*/
- if (!BYTES_ARE_IN_FRAME(offset, hdr_length, 1)) {
- ld->other += 1;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, hdr_length, 1))
+ return FALSE;
+
mesh_flags = pd[hdr_length];
if (has_mesh_control(fcf, pletoh16(&pd[qosoff]), mesh_flags)) {
/* Yes, add the length of that in as well. */
@@ -5723,10 +5718,9 @@ capture_ieee80211_common (const guchar * pd, int offset, int len,
as an encapsulated IPX frame, and then check whether the
packet starts with 0x00 0x00 and, if so, treat it as an OLPC
frame. */
- if (!BYTES_ARE_IN_FRAME(offset+hdr_length, len, 2)) {
- ld->other += 1;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset+hdr_length, len, 2))
+ return FALSE;
+
if ((pd[offset+hdr_length] != 0xaa) && (pd[offset+hdr_length+1] != 0xaa)) {
#if 0
/* XXX - this requires us to parse the header to find the source
@@ -5735,45 +5729,42 @@ capture_ieee80211_common (const guchar * pd, int offset, int len,
/* We have two MAC addresses after the header. */
if ((memcmp(&pd[offset+hdr_length+6], pinfo->dl_src.data, 6) == 0) ||
(memcmp(&pd[offset+hdr_length+6], pinfo->dl_dst.data, 6) == 0)) {
- capture_eth (pd, offset + hdr_length, len, ld);
- return;
+ return capture_eth (pd, offset + hdr_length, len, ld);
}
}
#endif
if ((pd[offset+hdr_length] == 0xff) && (pd[offset+hdr_length+1] == 0xff))
- capture_ipx (pd, offset+hdr_length, len, ld, pseudo_header);
+ return capture_ipx (pd, offset+hdr_length, len, ld, pseudo_header);
else if ((pd[offset+hdr_length] == 0x00) && (pd[offset+hdr_length+1] == 0x00))
- capture_llc (pd, offset + hdr_length + 2, len, ld, pseudo_header);
+ return capture_llc (pd, offset + hdr_length + 2, len, ld, pseudo_header);
}
else {
- capture_llc (pd, offset + hdr_length, len, ld, pseudo_header);
+ return capture_llc (pd, offset + hdr_length, len, ld, pseudo_header);
}
break;
}
-
- default:
- ld->other += 1;
- break;
}
+
+ return FALSE;
}
/*
* Handle 802.11 with a variable-length link-layer header.
*/
-void
+gboolean
capture_ieee80211 (const guchar * pd, int offset, int len, packet_counts * ld, const union wtap_pseudo_header *pseudo_header _U_)
{
- capture_ieee80211_common (pd, offset, len, ld, pseudo_header, FALSE);
+ return capture_ieee80211_common (pd, offset, len, ld, pseudo_header, FALSE);
}
/*
* Handle 802.11 with a variable-length link-layer header and data padding.
*/
-void
+gboolean
capture_ieee80211_datapad (const guchar * pd, int offset, int len,
packet_counts * ld, const union wtap_pseudo_header *pseudo_header _U_)
{
- capture_ieee80211_common (pd, offset, len, ld, pseudo_header, TRUE);
+ return capture_ieee80211_common (pd, offset, len, ld, pseudo_header, TRUE);
}
@@ -27074,9 +27065,6 @@ proto_register_ieee80211 (void)
register_dissector("wlan_withoutfcs", dissect_ieee80211_withoutfcs, proto_wlan);
register_dissector("wlan_bsfc", dissect_ieee80211_bsfc, proto_wlan);
- register_capture_dissector(WTAP_ENCAP_IEEE_802_11, capture_ieee80211, proto_wlan);
- register_capture_dissector(WTAP_ENCAP_IEEE_802_11_WITH_RADIO, capture_ieee80211, proto_wlan);
-
register_init_routine(wlan_defragment_init);
register_cleanup_routine(wlan_defragment_cleanup);
register_init_routine(wlan_retransmit_init);
@@ -27304,6 +27292,9 @@ proto_reg_handoff_ieee80211(void)
centrino_handle = create_dissector_handle( dissect_ieee80211_centrino, proto_centrino );
dissector_add_uint("ethertype", ETHERTYPE_CENTRINO_PROMISC, centrino_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11, capture_ieee80211, proto_wlan);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_WITH_RADIO, capture_ieee80211, proto_wlan);
+
/* Register handoff to Aruba GRE */
dissector_add_uint("gre.proto", GRE_ARUBA_8200, ieee80211_handle);
dissector_add_uint("gre.proto", GRE_ARUBA_8210, ieee80211_handle);
diff --git a/epan/dissectors/packet-ieee80211.h b/epan/dissectors/packet-ieee80211.h
index d14afa6021..3179f92be8 100644
--- a/epan/dissectors/packet-ieee80211.h
+++ b/epan/dissectors/packet-ieee80211.h
@@ -32,11 +32,11 @@ extern "C" {
#endif /* __cplusplus */
extern
-void capture_ieee80211 (const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
-void capture_ieee80211_datapad (const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_ieee80211 (const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_ieee80211_datapad (const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
extern
-void capture_wlancap(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_wlancap(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
void dissect_wifi_p2p_ie(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
int offset, gint size);
diff --git a/epan/dissectors/packet-ieee8021ah.c b/epan/dissectors/packet-ieee8021ah.c
index 2ac42caf63..e6769638ec 100644
--- a/epan/dissectors/packet-ieee8021ah.c
+++ b/epan/dissectors/packet-ieee8021ah.c
@@ -23,10 +23,10 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <wsutil/pint.h>
#include <epan/addr_resolv.h>
-#include "packet-ieee8021ah.h"
#include "packet-ipx.h"
#include "packet-llc.h"
#include <epan/etypes.h>
@@ -72,31 +72,33 @@ static int hf_ieee8021ah_trailer = -1;
static gint ett_ieee8021ah = -1;
static gint ett_ieee8021ad = -1;
+#define IEEE8021AD_LEN 4
+#define IEEE8021AH_LEN 18
+#define IEEE8021AH_ISIDMASK 0x00FFFFFF
+
/* FUNCTIONS ************************************************************/
-void
+static gboolean
capture_ieee8021ah(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 encap_proto;
- if (!BYTES_ARE_IN_FRAME(offset, len, IEEE8021AH_LEN + 1)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, IEEE8021AH_LEN + 1))
+ return FALSE;
+
encap_proto = pntoh16( &pd[offset + IEEE8021AH_LEN - 2] );
if (encap_proto <= IEEE_802_3_MAX_LEN) {
if ( pd[offset + IEEE8021AH_LEN] == 0xff
&& pd[offset + IEEE8021AH_LEN + 1] == 0xff ) {
- capture_ipx(pd, offset + IEEE8021AH_LEN, len, ld, pseudo_header);
+ return capture_ipx(pd, offset + IEEE8021AH_LEN, len, ld, pseudo_header);
}
else {
- capture_llc(pd, offset + IEEE8021AH_LEN, len, ld, pseudo_header);
+ return capture_llc(pd, offset + IEEE8021AH_LEN, len, ld, pseudo_header);
}
}
- else {
- capture_ethertype(encap_proto, pd, offset + IEEE8021AH_LEN, len, ld, pseudo_header);
- }
+
+ return try_capture_dissector("ethertype", encap_proto, pd, offset + IEEE8021AH_LEN, len, ld, pseudo_header);
}
/* Dissector *************************************************************/
@@ -438,6 +440,8 @@ proto_reg_handoff_ieee8021ah(void)
old_ieee8021ah_ethertype = ieee8021ah_ethertype;
dissector_add_uint("ethertype", ieee8021ah_ethertype, ieee8021ah_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_IEEE_802_1AD, capture_ieee8021ah, proto_ieee8021ah);
+ register_capture_dissector("ethertype", ETHERTYPE_IEEE_802_1AH, capture_ieee8021ah, proto_ieee8021ah);
}
diff --git a/epan/dissectors/packet-ieee8021ah.h b/epan/dissectors/packet-ieee8021ah.h
deleted file mode 100644
index b1ad038807..0000000000
--- a/epan/dissectors/packet-ieee8021ah.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* packet-ieee8021ah.h
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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.
- *
- * 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.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __PACKET_IEEE8021AH_H__
-#define __PACKET_IEEE8021AH_H__
-
-#define IEEE8021AD_LEN 4
-#define IEEE8021AH_LEN 18
-#define IEEE8021AH_ISIDMASK 0x00FFFFFF
-
-void capture_ieee8021ah(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
-
-#endif
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index 894a461409..77debead48 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -28,6 +28,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <epan/addr_resolv.h>
#include <epan/ipproto.h>
#include <epan/expert.h>
@@ -566,12 +567,11 @@ ip_defragment_cleanup(void)
reassembly_table_destroy(&ip_reassembly_table);
}
-void
+gboolean
capture_ip(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) {
- if (!BYTES_ARE_IN_FRAME(offset, len, IPH_MIN_LEN)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, IPH_MIN_LEN))
+ return FALSE;
+
switch (pd[offset + 9]) {
case IP_PROTO_TCP:
ld->tcp++;
@@ -599,6 +599,9 @@ capture_ip(const guchar *pd, int offset, int len, packet_counts *ld, const union
default:
ld->other++;
}
+
+ /* We're incrementing "other", so consider this our packet */
+ return TRUE;
}
#ifdef HAVE_GEOIP
@@ -3215,6 +3218,7 @@ proto_reg_handoff_ip(void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP4, ip_handle);
heur_dissector_add("tipc", dissect_ip_heur, "IP over TIPC", "ip_tipc", proto_ip, HEURISTIC_ENABLE);
+ register_capture_dissector("ethertype", ETHERTYPE_IP, capture_ip, proto_ip);
}
/*
diff --git a/epan/dissectors/packet-ip.h b/epan/dissectors/packet-ip.h
index 8ab6f3962e..441e620640 100644
--- a/epan/dissectors/packet-ip.h
+++ b/epan/dissectors/packet-ip.h
@@ -50,7 +50,7 @@ typedef struct _ws_ip
#define IPDSFIELD_ECN_MASK 0x03
#define IPDSFIELD_ECN(dsfield) ((dsfield) & IPDSFIELD_ECN_MASK)
-void capture_ip(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_ip(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
gboolean ip_try_dissect(gboolean heur_first, tvbuff_t *tvb,
packet_info *pinfo, proto_tree *tree, ws_ip *iph);
diff --git a/epan/dissectors/packet-ipfc.c b/epan/dissectors/packet-ipfc.c
index b7b4f16c6d..711ea29d44 100644
--- a/epan/dissectors/packet-ipfc.c
+++ b/epan/dissectors/packet-ipfc.c
@@ -45,15 +45,13 @@ static int hf_ipfc_network_sa = -1;
static gint ett_ipfc = -1;
static dissector_handle_t llc_handle;
-static void
+static gboolean
capture_ipfc (const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
- if (!BYTES_ARE_IN_FRAME(0, len, 16)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, 16))
+ return FALSE;
- capture_llc(pd, 16, len, ld, pseudo_header);
+ return capture_llc(pd, 16, len, ld, pseudo_header);
}
static int
@@ -114,8 +112,6 @@ proto_register_ipfc (void)
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_ipfc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
- register_capture_dissector(WTAP_ENCAP_IP_OVER_FC, capture_ipfc, proto_ipfc);
}
/* If this dissector uses sub-dissector registration add a registration routine.
@@ -131,6 +127,8 @@ proto_reg_handoff_ipfc (void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_IP_OVER_FC, ipfc_handle);
llc_handle = find_dissector ("llc");
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_IP_OVER_FC, capture_ipfc, proto_ipfc);
}
/*
diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c
index 4466f6c4fb..3a0048fdcb 100644
--- a/epan/dissectors/packet-ipv6.c
+++ b/epan/dissectors/packet-ipv6.c
@@ -28,6 +28,7 @@
#include <math.h>
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <epan/expert.h>
#include <epan/ip_opts.h>
#include <epan/addr_resolv.h>
@@ -524,16 +525,15 @@ static const value_string ipv6_opt_vals[] = {
};
-void
+gboolean
capture_ipv6(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint8 nxt;
int advance;
- if (!BYTES_ARE_IN_FRAME(offset, len, 4+4+16+16)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 4+4+16+16))
+ return FALSE;
+
nxt = pd[offset+6]; /* get the "next header" value */
offset += 4+4+16+16; /* skip past the IPv6 header */
@@ -542,55 +542,47 @@ again:
case IP_PROTO_HOPOPTS:
case IP_PROTO_ROUTING:
case IP_PROTO_DSTOPTS:
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
+
nxt = pd[offset];
advance = (pd[offset+1] + 1) << 3;
- if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, advance))
+ return FALSE;
+
offset += advance;
goto again;
case IP_PROTO_FRAGMENT:
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
+
nxt = pd[offset];
advance = 8;
- if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, advance))
+ return FALSE;
+
offset += advance;
goto again;
case IP_PROTO_AH:
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
+
nxt = pd[offset];
advance = 8 + ((pd[offset+1] - 1) << 2);
- if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, advance))
+ return FALSE;
+
offset += advance;
goto again;
case IP_PROTO_SHIM6:
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
+
nxt = pd[offset];
advance = (pd[offset+1] + 1) << 3;
- if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, advance))
+ return FALSE;
+
offset += advance;
goto again;
}
@@ -620,8 +612,9 @@ again:
ld->vines++;
break;
default:
- ld->other++;
+ return FALSE;
}
+ return TRUE;
}
/**
@@ -3567,6 +3560,7 @@ proto_reg_handoff_ipv6(void)
dissector_add_uint("ipv6.nxt", IP_PROTO_DSTOPTS, ipv6_dstopts_handle);
ip_dissector_table = find_dissector_table("ip.proto");
+ register_capture_dissector("ethertype", ETHERTYPE_IPv6, capture_ipv6, proto_ipv6);
}
/*
diff --git a/epan/dissectors/packet-ipv6.h b/epan/dissectors/packet-ipv6.h
index 514ee749ec..3020ce86fc 100644
--- a/epan/dissectors/packet-ipv6.h
+++ b/epan/dissectors/packet-ipv6.h
@@ -168,7 +168,7 @@ struct ip6_shim {
extern "C" {
#endif /* __cplusplus */
-void capture_ipv6(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_ipv6(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
#ifdef __cplusplus
}
diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c
index a39961e56a..3e6940cf40 100644
--- a/epan/dissectors/packet-ipx.c
+++ b/epan/dissectors/packet-ipx.c
@@ -28,6 +28,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include "packet-ipx.h"
#include "packet-sll.h"
#include <epan/addr_resolv.h>
@@ -272,10 +273,11 @@ static const value_string ipxmsg_sigchar_vals[] = {
{ 0, NULL }
};
-void
+gboolean
capture_ipx(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
ld->ipx++;
+ return TRUE;
}
static int
@@ -1622,6 +1624,7 @@ proto_reg_handoff_ipx(void)
dissector_add_uint("ipx.socket", IPX_SOCKET_IPX_MESSAGE, ipxmsg_handle);
dissector_add_uint("ipx.socket", IPX_SOCKET_IPX_MESSAGE1, ipxmsg_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_IPX, capture_ipx, proto_ipx);
data_handle = find_dissector("data");
}
diff --git a/epan/dissectors/packet-ipx.h b/epan/dissectors/packet-ipx.h
index c5f5ae54e2..770590ebfe 100644
--- a/epan/dissectors/packet-ipx.h
+++ b/epan/dissectors/packet-ipx.h
@@ -147,7 +147,7 @@ struct ipx_rip_packet
extern value_string_ext ipx_socket_vals_ext;
extern value_string_ext novell_server_vals_ext;
-void capture_ipx(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_ipx(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
/*
* Structure passed to SPX subdissectors, containing information from
diff --git a/epan/dissectors/packet-isl.c b/epan/dissectors/packet-isl.c
index e3a34eab16..830cb4ada7 100644
--- a/epan/dissectors/packet-isl.c
+++ b/epan/dissectors/packet-isl.c
@@ -88,15 +88,13 @@ static dissector_handle_t eth_withfcs_handle;
static dissector_handle_t tr_handle;
static dissector_handle_t data_handle;
-void
+gboolean
capture_isl(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint8 type;
- if (!BYTES_ARE_IN_FRAME(offset, len, ISL_HEADER_SIZE)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, ISL_HEADER_SIZE))
+ return FALSE;
type = (pd[offset+5] >> 4)&0x0F;
@@ -104,18 +102,15 @@ capture_isl(const guchar *pd, int offset, int len, packet_counts *ld, const unio
case TYPE_ETHER:
offset += 14+12; /* skip the header */
- capture_eth(pd, offset, len, ld, pseudo_header);
- break;
+ return capture_eth(pd, offset, len, ld, pseudo_header);
case TYPE_TR:
offset += 14+17; /* skip the header */
- capture_tr(pd, offset, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
+ return capture_tr(pd, offset, len, ld, pseudo_header);
break;
}
+
+ return FALSE;
}
static const value_string type_vals[] = {
diff --git a/epan/dissectors/packet-isl.h b/epan/dissectors/packet-isl.h
index 1f08570089..4d31454db1 100644
--- a/epan/dissectors/packet-isl.h
+++ b/epan/dissectors/packet-isl.h
@@ -22,7 +22,7 @@
#ifndef __PACKET_ISL_H__
#define __PACKET_ISL_H__
-void capture_isl(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_isl(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
void dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int fcs_len);
diff --git a/epan/dissectors/packet-llc.c b/epan/dissectors/packet-llc.c
index 402fa94f76..0c226894bc 100644
--- a/epan/dissectors/packet-llc.c
+++ b/epan/dissectors/packet-llc.c
@@ -24,6 +24,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <wiretap/wtap.h>
#include <wsutil/pint.h>
#include <epan/oui.h>
@@ -250,17 +251,16 @@ llc_add_oui(guint32 oui, const char *table_name, const char *table_ui_name,
g_hash_table_insert(oui_info_table, GUINT_TO_POINTER(oui), new_info);
}
-void
+gboolean
capture_llc(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) {
int is_snap;
guint16 control;
int llc_header_len;
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
+
is_snap = (pd[offset] == SAP_SNAP) && (pd[offset+1] == SAP_SNAP);
llc_header_len = 2; /* DSAP + SSAP */
@@ -272,56 +272,43 @@ capture_llc(const guchar *pd, int offset, int len, packet_counts *ld, const unio
*/
control = get_xdlc_control(pd, offset+2, pd[offset+1] & SSAP_CR_BIT);
llc_header_len += XDLC_CONTROL_LEN(control, TRUE);
- if (!BYTES_ARE_IN_FRAME(offset, len, llc_header_len)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, llc_header_len))
+ return FALSE;
+
+ if (!XDLC_IS_INFORMATION(control))
+ return FALSE;
- if (!XDLC_IS_INFORMATION(control)) {
- ld->other++;
- return;
- }
if (is_snap)
- capture_snap(pd, offset+llc_header_len, len, ld, pseudo_header);
- else {
- /* non-SNAP */
- switch (pd[offset]) {
+ return capture_snap(pd, offset+llc_header_len, len, ld, pseudo_header);
- case SAP_IP:
- capture_ip(pd, offset + llc_header_len, len, ld, pseudo_header);
- break;
+ /* non-SNAP */
+ switch (pd[offset]) {
- case SAP_NETWARE1:
- case SAP_NETWARE2:
- capture_ipx(pd, offset + llc_header_len, len, ld, pseudo_header);
- break;
+ case SAP_IP:
+ return capture_ip(pd, offset + llc_header_len, len, ld, pseudo_header);
- case SAP_NETBIOS:
- capture_netbios(pd, offset + llc_header_len, len, ld, pseudo_header);
- break;
+ case SAP_NETWARE1:
+ case SAP_NETWARE2:
+ return capture_ipx(pd, offset + llc_header_len, len, ld, pseudo_header);
- case SAP_VINES1:
- case SAP_VINES2:
- capture_vines(pd, offset + llc_header_len, len, ld, pseudo_header);
- break;
+ case SAP_NETBIOS:
+ return capture_netbios(pd, offset + llc_header_len, len, ld, pseudo_header);
- default:
- ld->other++;
- break;
- }
+ case SAP_VINES1:
+ case SAP_VINES2:
+ return capture_vines(pd, offset + llc_header_len, len, ld, pseudo_header);
}
+ return FALSE;
}
-void
+gboolean
capture_snap(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint32 oui;
guint16 etype;
- if (!BYTES_ARE_IN_FRAME(offset, len, 5)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 5))
+ return FALSE;
oui = pd[offset] << 16 | pd[offset+1] << 8 | pd[offset+2];
etype = pntoh16(&pd[offset+3]);
@@ -337,12 +324,10 @@ capture_snap(const guchar *pd, int offset, int len, packet_counts *ld, const uni
AppleTalk data packets - but used
OUI_ENCAP_ETHER and an Ethernet
packet type for AARP packets. */
- capture_ethertype(etype, pd, offset+5, len, ld, pseudo_header);
- break;
+ return try_capture_dissector("ethertype", etype, pd, offset+5, len, ld, pseudo_header);
case OUI_CISCO:
- capture_ethertype(etype, pd, offset+5, len, ld, pseudo_header);
- break;
+ return try_capture_dissector("ethertype", etype, pd, offset+5, len, ld, pseudo_header);
case OUI_MARVELL:
/*
@@ -351,13 +336,10 @@ capture_snap(const guchar *pd, int offset, int len, packet_counts *ld, const uni
* the payload. (We assume the header is
* 5 bytes, for now).
*/
- capture_ethertype(etype, pd, offset+5+5, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return try_capture_dissector("ethertype", etype, pd, offset+5+5, len, ld, pseudo_header);
}
+
+ return FALSE;
}
/* Used only for U frames */
@@ -945,6 +927,8 @@ proto_reg_handoff_llc(void)
dissector_add_uint("juniper.proto", JUNIPER_PROTO_LLC, llc_handle);
dissector_add_uint("juniper.proto", JUNIPER_PROTO_LLC_SNAP, llc_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_JUMBO_LLC, capture_llc, proto_llc);
+
/*
* Register all the fields for PIDs for various OUIs.
*/
diff --git a/epan/dissectors/packet-llc.h b/epan/dissectors/packet-llc.h
index ea40ed2460..99fa5a2448 100644
--- a/epan/dissectors/packet-llc.h
+++ b/epan/dissectors/packet-llc.h
@@ -24,11 +24,11 @@
#include "ws_symbol_export.h"
-void capture_llc(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_llc(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
extern const value_string sap_vals[];
-void capture_snap(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_snap(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
void dissect_snap(tvbuff_t *, int, packet_info *, proto_tree *,
proto_tree *, int, int, int, int, int);
diff --git a/epan/dissectors/packet-netbios.c b/epan/dissectors/packet-netbios.c
index e0c8d41739..06aa57fc11 100644
--- a/epan/dissectors/packet-netbios.c
+++ b/epan/dissectors/packet-netbios.c
@@ -284,10 +284,11 @@ static const value_string max_frame_size_vals[] = {
};
-void
+gboolean
capture_netbios(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
ld->netbios++;
+ return TRUE;
}
diff --git a/epan/dissectors/packet-netbios.h b/epan/dissectors/packet-netbios.h
index 8011ac3d57..c34ec49ea1 100644
--- a/epan/dissectors/packet-netbios.h
+++ b/epan/dissectors/packet-netbios.h
@@ -30,7 +30,7 @@
/* Length of NetBIOS names */
#define NETBIOS_NAME_LEN 16
-void capture_netbios(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_netbios(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
extern int process_netbios_name(const guchar *name_ptr, char *name_ret, int name_ret_len);
extern int get_netbios_name(tvbuff_t *tvb, int offset,
diff --git a/epan/dissectors/packet-netrom.c b/epan/dissectors/packet-netrom.c
index 7238876e48..6c34abac05 100644
--- a/epan/dissectors/packet-netrom.c
+++ b/epan/dissectors/packet-netrom.c
@@ -488,16 +488,14 @@ dissect_netrom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
return tvb_captured_length(tvb);
}
-void
-capture_netrom( const guchar *pd _U_, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
+gboolean
+capture_netrom( const guchar *pd _U_, int offset, int len, packet_counts *ld _U_, const union wtap_pseudo_header *pseudo_header _U_)
{
if ( ! BYTES_ARE_IN_FRAME( offset, len, NETROM_MIN_SIZE ) )
- {
- ld->other++;
- return;
- }
+ return FALSE;
+
/* XXX - check for IP-over-NetROM here! */
- ld->other++;
+ return FALSE;
}
void
diff --git a/epan/dissectors/packet-netrom.h b/epan/dissectors/packet-netrom.h
index 62f9183e1b..c6e8828914 100644
--- a/epan/dissectors/packet-netrom.h
+++ b/epan/dissectors/packet-netrom.h
@@ -25,6 +25,6 @@
#ifndef __PACKET_NETROM_H__
#define __PACKET_NETROM_H__
-void capture_netrom(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_netrom(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
#endif
diff --git a/epan/dissectors/packet-null.c b/epan/dissectors/packet-null.c
index 41d7b12cad..ee514ebdc9 100644
--- a/epan/dissectors/packet-null.c
+++ b/epan/dissectors/packet-null.c
@@ -65,7 +65,7 @@ static const value_string family_vals[] = {
static dissector_handle_t ppp_hdlc_handle;
static dissector_handle_t data_handle;
-static void
+static gboolean
capture_null( const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_ )
{
guint32 null_header;
@@ -252,23 +252,21 @@ capture_null( const guchar *pd, int offset _U_, int len, packet_counts *ld, cons
* digits would be zero and the next 2 hex digits would not be zero.
* Furthermore, the third hex digit from the bottom would be <
*/
- if (!BYTES_ARE_IN_FRAME(0, len, 2)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, 2))
+ return FALSE;
+
if (pd[0] == 0xFF && pd[1] == 0x03) {
/*
* Hand it to PPP.
*/
- capture_ppp_hdlc(pd, 0, len, ld, pseudo_header);
+ return capture_ppp_hdlc(pd, 0, len, ld, pseudo_header);
} else {
/*
* Treat it as a normal DLT_NULL header.
*/
- if (!BYTES_ARE_IN_FRAME(0, len, (int)sizeof(null_header))) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, (int)sizeof(null_header)))
+ return FALSE;
+
memcpy((char *)&null_header, (const char *)&pd[0], sizeof(null_header));
if ((null_header & 0xFFFF0000) != 0) {
@@ -317,56 +315,47 @@ capture_null( const guchar *pd, int offset _U_, int len, packet_counts *ld, cons
* BSD derivatives have different values?).
*/
if (null_header > IEEE_802_3_MAX_LEN)
- capture_ethertype((guint16) null_header, pd, 4, len, ld, pseudo_header);
+ return try_capture_dissector("ethertype", null_header, pd, 4, len, ld, pseudo_header);
else {
switch (null_header) {
case BSD_AF_INET:
- capture_ip(pd, 4, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, 4, len, ld, pseudo_header);
case BSD_AF_INET6_BSD:
case BSD_AF_INET6_FREEBSD:
case BSD_AF_INET6_DARWIN:
- capture_ipv6(pd, 4, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return capture_ipv6(pd, 4, len, ld, pseudo_header);
}
}
}
+
+ return FALSE;
}
-static void
+static gboolean
capture_loop( const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_ )
{
guint32 loop_family;
- if (!BYTES_ARE_IN_FRAME(0, len, (int)sizeof(loop_family))) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, (int)sizeof(loop_family)))
+ return FALSE;
+
loop_family = pntoh32(&pd[0]);
switch (loop_family) {
case BSD_AF_INET:
- capture_ip(pd, 4, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, 4, len, ld, pseudo_header);
case BSD_AF_INET6_BSD:
case BSD_AF_INET6_FREEBSD:
case BSD_AF_INET6_DARWIN:
- capture_ipv6(pd, 4, len, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return capture_ipv6(pd, 4, len, ld, pseudo_header);
}
+
+ return FALSE;
}
static int
@@ -535,9 +524,6 @@ proto_register_null(void)
proto_register_field_array(proto_null, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_capture_dissector(WTAP_ENCAP_NULL, capture_null, proto_null);
- register_capture_dissector(WTAP_ENCAP_LOOP, capture_loop, proto_null);
-
/* subdissector code */
null_dissector_table = register_dissector_table("null.type",
"Null type", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
@@ -562,6 +548,9 @@ proto_reg_handoff_null(void)
loop_handle = create_dissector_handle(dissect_loop, proto_null);
dissector_add_uint("wtap_encap", WTAP_ENCAP_LOOP, loop_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_NULL, capture_null, proto_null);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_LOOP, capture_loop, proto_null);
}
/*
diff --git a/epan/dissectors/packet-pktap.c b/epan/dissectors/packet-pktap.c
index bf7c08658b..b4508808c3 100644
--- a/epan/dissectors/packet-pktap.c
+++ b/epan/dissectors/packet-pktap.c
@@ -94,22 +94,18 @@ static dissector_handle_t pktap_handle;
* to host byte order in libwiretap.
*/
-static void
+static gboolean
capture_pktap(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint32 hdrlen, rectype, dlt;
hdrlen = pletoh32(pd);
- if (hdrlen < MIN_PKTAP_HDR_LEN || !BYTES_ARE_IN_FRAME(0, len, hdrlen)) {
- ld->other++;
- return;
- }
+ if (hdrlen < MIN_PKTAP_HDR_LEN || !BYTES_ARE_IN_FRAME(0, len, hdrlen))
+ return FALSE;
rectype = pletoh32(pd+4);
- if (rectype != PKT_REC_PACKET) {
- ld->other++;
- return;
- }
+ if (rectype != PKT_REC_PACKET)
+ return FALSE;
dlt = pletoh32(pd+4);
@@ -117,14 +113,11 @@ capture_pktap(const guchar *pd, int offset _U_, int len, packet_counts *ld, cons
switch (dlt) {
case 1: /* DLT_EN10MB */
- capture_eth(pd, hdrlen, len, ld, pseudo_header);
- return;
+ return capture_eth(pd, hdrlen, len, ld, pseudo_header);
- default:
- break;
}
- ld->other++;
+ return FALSE;
}
static int
@@ -278,13 +271,6 @@ proto_register_pktap(void)
expert_pktap = expert_register_protocol(proto_pktap);
expert_register_field_array(expert_pktap, ei, array_length(ei));
- /* XXX - WTAP_ENCAP_USER2 to handle Mavericks' botch wherein it
- uses DLT_USER2 for PKTAP; if you are using DLT_USER2 for your
- own purposes, feel free to call your own capture_ routine for
- WTAP_ENCAP_USER2. */
- register_capture_dissector(WTAP_ENCAP_PKTAP, capture_pktap, proto_pktap);
- register_capture_dissector(WTAP_ENCAP_USER2, capture_pktap, proto_pktap);
-
pktap_handle = register_dissector("pktap", dissect_pktap, proto_pktap);
}
@@ -292,6 +278,13 @@ void
proto_reg_handoff_pktap(void)
{
dissector_add_uint("wtap_encap", WTAP_ENCAP_PKTAP, pktap_handle);
+
+ /* XXX - WTAP_ENCAP_USER2 to handle Mavericks' botch wherein it
+ uses DLT_USER2 for PKTAP; if you are using DLT_USER2 for your
+ own purposes, feel free to call your own capture_ routine for
+ WTAP_ENCAP_USER2. */
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_PKTAP, capture_pktap, proto_pktap);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_USER2, capture_pktap, proto_pktap);
}
/*
diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c
index 1094172bea..78ca36c363 100644
--- a/epan/dissectors/packet-ppi.c
+++ b/epan/dissectors/packet-ppi.c
@@ -386,33 +386,27 @@ static reassembly_table ampdu_reassembly_table;
static gboolean ppi_ampdu_reassemble = TRUE;
-static void
+static gboolean
capture_ppi(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint32 dlt;
guint ppi_len;
ppi_len = pletoh16(pd+2);
- if(ppi_len < PPI_V0_HEADER_LEN || !BYTES_ARE_IN_FRAME(0, len, ppi_len)) {
- ld->other++;
- return;
- }
+ if(ppi_len < PPI_V0_HEADER_LEN || !BYTES_ARE_IN_FRAME(0, len, ppi_len))
+ return FALSE;
dlt = pletoh32(pd+4);
/* XXX - We should probably combine this with capture_info.c:capture_info_packet() */
switch(dlt) {
case 1: /* DLT_EN10MB */
- capture_eth(pd, ppi_len, len, ld, pseudo_header);
- return;
+ return capture_eth(pd, ppi_len, len, ld, pseudo_header);
case 105: /* DLT_DLT_IEEE802_11 */
- capture_ieee80211(pd, ppi_len, len, ld, pseudo_header);
- return;
- default:
- break;
+ return capture_ieee80211(pd, ppi_len, len, ld, pseudo_header);
}
- ld->other++;
+ return FALSE;
}
static void
@@ -1495,7 +1489,6 @@ proto_register_ppi(void)
expert_register_field_array(expert_ppi, ei, array_length(ei));
ppi_handle = register_dissector("ppi", dissect_ppi, proto_ppi);
- register_capture_dissector(WTAP_ENCAP_PPI, capture_ppi, proto_ppi);
register_init_routine(ampdu_reassemble_init);
register_cleanup_routine(ampdu_reassemble_cleanup);
@@ -1520,6 +1513,7 @@ proto_reg_handoff_ppi(void)
ppi_fnet_handle = find_dissector("ppi_fnet");
dissector_add_uint("wtap_encap", WTAP_ENCAP_PPI, ppi_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_PPI, capture_ppi, proto_ppi);
}
/*
diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c
index 5b5585a82e..68a468bbc9 100644
--- a/epan/dissectors/packet-ppp.c
+++ b/epan/dissectors/packet-ppp.c
@@ -1950,35 +1950,28 @@ decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
return next_tvb;
}
-void
+gboolean
capture_ppp_hdlc(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
- if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
- ld->other++;
- return;
- }
- if (pd[0] == CHDLC_ADDR_UNICAST || pd[0] == CHDLC_ADDR_MULTICAST) {
- capture_chdlc(pd, offset, len, ld, pseudo_header);
- return;
- }
- if (!BYTES_ARE_IN_FRAME(offset, len, 4)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, 2))
+ return FALSE;
+
+ if (pd[0] == CHDLC_ADDR_UNICAST || pd[0] == CHDLC_ADDR_MULTICAST)
+ return capture_chdlc(pd, offset, len, ld, pseudo_header);
+
+ if (!BYTES_ARE_IN_FRAME(offset, len, 4))
+ return FALSE;
+
switch (pntoh16(&pd[offset + 2])) {
case PPP_IP:
- capture_ip(pd, offset + 4, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, offset + 4, len, ld, pseudo_header);
case PPP_IPX:
- capture_ipx(pd, offset + 4, len, ld, pseudo_header);
- break;
+ return capture_ipx(pd, offset + 4, len, ld, pseudo_header);
case PPP_VINES:
- capture_vines(pd, offset + 4, len, ld, pseudo_header);
- break;
- default:
- ld->other++;
- break;
+ return capture_vines(pd, offset + 4, len, ld, pseudo_header);
}
+
+ return FALSE;
}
static void
@@ -5598,8 +5591,6 @@ proto_register_ppp_raw_hdlc(void)
"PPP-HDLC", "ppp_hdlc");
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array(proto_ppp_hdlc, hf, array_length(hf));
-
- register_capture_dissector(WTAP_ENCAP_PPP, capture_ppp_hdlc, proto_ppp_hdlc);
}
void
@@ -5613,6 +5604,7 @@ proto_reg_handoff_ppp_raw_hdlc(void)
dissector_add_uint("gre.proto", ETHERTYPE_3GPP2, ppp_raw_hdlc_handle);
heur_dissector_add("usb.bulk", dissect_ppp_usb, "PPP USB bulk endpoint", "ppp_usb_bulk", proto_ppp, HEURISTIC_ENABLE);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_PPP, capture_ppp_hdlc, proto_ppp_hdlc);
}
/*
diff --git a/epan/dissectors/packet-ppp.h b/epan/dissectors/packet-ppp.h
index aeb5e54981..85f4b24602 100644
--- a/epan/dissectors/packet-ppp.h
+++ b/epan/dissectors/packet-ppp.h
@@ -29,7 +29,7 @@
extern gboolean ppp_vj_decomp;/* FALSE = No VJ header decompression,
TRUE = Decompress VJ */
extern
-void capture_ppp_hdlc(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header _U_);
+gboolean capture_ppp_hdlc(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header _U_);
tvbuff_t *decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset);
diff --git a/epan/dissectors/packet-raw.c b/epan/dissectors/packet-raw.c
index f4faf407d9..87655ede01 100644
--- a/epan/dissectors/packet-raw.c
+++ b/epan/dissectors/packet-raw.c
@@ -43,7 +43,7 @@ static dissector_handle_t ipv6_handle;
static dissector_handle_t data_handle;
static dissector_handle_t ppp_hdlc_handle;
-static void
+static gboolean
capture_raw(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
/* So far, the only time we get raw connection types are with Linux and
@@ -55,21 +55,21 @@ capture_raw(const guchar *pd, int offset _U_, int len, packet_counts *ld, const
* sometimes. This check should be removed when 2.2 is out.
*/
if (BYTES_ARE_IN_FRAME(0,len,2) && pd[0] == 0xff && pd[1] == 0x03) {
- capture_ppp_hdlc(pd, 0, len, ld, pseudo_header);
+ return capture_ppp_hdlc(pd, 0, len, ld, pseudo_header);
}
/* The Linux ISDN driver sends a fake MAC address before the PPP header
* on its ippp interfaces... */
else if (BYTES_ARE_IN_FRAME(0,len,8) && pd[6] == 0xff && pd[7] == 0x03) {
- capture_ppp_hdlc(pd, 6, len, ld, pseudo_header);
+ return capture_ppp_hdlc(pd, 6, len, ld, pseudo_header);
}
/* ...except when it just puts out one byte before the PPP header... */
else if (BYTES_ARE_IN_FRAME(0,len,3) && pd[1] == 0xff && pd[2] == 0x03) {
- capture_ppp_hdlc(pd, 1, len, ld, pseudo_header);
+ return capture_ppp_hdlc(pd, 1, len, ld, pseudo_header);
}
/* ...and if the connection is currently down, it sends 10 bytes of zeroes
* instead of a fake MAC address and PPP header. */
else if (BYTES_ARE_IN_FRAME(0,len,10) && memcmp(pd, zeroes, 10) == 0) {
- capture_ip(pd, 10, len, ld, pseudo_header);
+ return capture_ip(pd, 10, len, ld, pseudo_header);
}
else {
/*
@@ -80,18 +80,18 @@ capture_raw(const guchar *pd, int offset _U_, int len, packet_counts *ld, const
case 0x40:
/* IPv4 */
- capture_ip(pd, 0, len, ld, pseudo_header);
- break;
+ return capture_ip(pd, 0, len, ld, pseudo_header);
#if 0
case 0x60:
/* IPv6 */
- capture_ipv6(pd, 0, len, ld, pseudo_header);
- break;
+ return capture_ipv6(pd, 0, len, ld, pseudo_header);
#endif
}
}
}
+
+ return FALSE;
}
static int
@@ -172,8 +172,6 @@ proto_register_raw(void)
proto_raw = proto_register_protocol("Raw packet data", "Raw", "raw");
proto_register_subtree_array(ett, array_length(ett));
-
- register_capture_dissector(WTAP_ENCAP_RAW_IP, capture_raw, proto_raw);
}
void
@@ -191,6 +189,7 @@ proto_reg_handoff_raw(void)
ppp_hdlc_handle = find_dissector("ppp_hdlc");
raw_handle = create_dissector_handle(dissect_raw, proto_raw);
dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP, raw_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_RAW_IP, capture_raw, proto_raw);
}
/*
diff --git a/epan/dissectors/packet-sll.c b/epan/dissectors/packet-sll.c
index 18205f155c..dc1253dcf9 100644
--- a/epan/dissectors/packet-sll.c
+++ b/epan/dissectors/packet-sll.c
@@ -137,15 +137,14 @@ static dissector_table_t sll_linux_dissector_table;
static dissector_table_t gre_dissector_table;
static dissector_handle_t data_handle;
-static void
+static gboolean
capture_sll(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 protocol;
- if (!BYTES_ARE_IN_FRAME(0, len, SLL_HEADER_SIZE)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(0, len, SLL_HEADER_SIZE))
+ return FALSE;
+
protocol = pntoh16(&pd[14]);
if (protocol <= 1536) { /* yes, 1536 - that's how Linux does it */
/*
@@ -158,37 +157,31 @@ capture_sll(const guchar *pd, int offset _U_, int len, packet_counts *ld, const
/*
* 802.2 LLC.
*/
- capture_llc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header);
- break;
+ return capture_llc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header);
case LINUX_SLL_P_ETHERNET:
/*
* Ethernet.
*/
- capture_eth(pd, SLL_HEADER_SIZE, len, ld, pseudo_header);
- break;
+ return capture_eth(pd, SLL_HEADER_SIZE, len, ld, pseudo_header);
case LINUX_SLL_P_802_3:
/*
* Novell IPX inside 802.3 with no 802.2 LLC
* header.
*/
- capture_ipx(pd, SLL_HEADER_SIZE, len, ld, pseudo_header);
- break;
+ return capture_ipx(pd, SLL_HEADER_SIZE, len, ld, pseudo_header);
case LINUX_SLL_P_PPPHDLC:
/*
* PPP HDLC.
*/
- capture_ppp_hdlc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header);
- break;
-
- default:
- ld->other++;
- break;
+ return capture_ppp_hdlc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header);
}
- } else
- capture_ethertype(protocol, pd, SLL_HEADER_SIZE, len, ld, pseudo_header);
+ } else {
+ return try_capture_dissector("ethertype", protocol, pd, SLL_HEADER_SIZE, len, ld, pseudo_header);
+ }
+ return FALSE;
}
static int
@@ -336,8 +329,6 @@ proto_register_sll(void)
proto_register_fields(proto_sll, hfi, array_length(hfi));
proto_register_subtree_array(ett, array_length(ett));
- register_capture_dissector(WTAP_ENCAP_SLL, capture_sll, proto_sll);
-
sll_handle = create_dissector_handle(dissect_sll, proto_sll);
sll_linux_dissector_table = register_dissector_table (
@@ -359,6 +350,7 @@ proto_reg_handoff_sll(void)
ethertype_handle = find_dissector("ethertype");
dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_handle);
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_SLL, capture_sll, hfi_sll->id);
}
/*
diff --git a/epan/dissectors/packet-tr.c b/epan/dissectors/packet-tr.c
index bebdfdfc3a..2227d6ff8e 100644
--- a/epan/dissectors/packet-tr.c
+++ b/epan/dissectors/packet-tr.c
@@ -246,7 +246,7 @@ int check_for_old_linux(const guchar * pd)
static void
add_ring_bridge_pairs(int rcf_len, tvbuff_t*, proto_tree *tree);
-void
+gboolean
capture_tr(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) {
int source_routed = 0;
@@ -260,10 +260,8 @@ capture_tr(const guchar *pd, int offset, int len, packet_counts *ld, const union
guint8 trn_fc; /* field control field */
const guint8 *trn_shost; /* source host */
- if (!BYTES_ARE_IN_FRAME(offset, len, TR_MIN_HEADER_LEN)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, TR_MIN_HEADER_LEN))
+ return FALSE;
if ((x = check_for_old_linux(pd)))
{
@@ -359,20 +357,13 @@ capture_tr(const guchar *pd, int offset, int len, packet_counts *ld, const union
offset += actual_rif_bytes + TR_MIN_HEADER_LEN;
- /* The package is either MAC or LLC */
+ /* The package is either MAC (0) or LLC (1)*/
switch (frame_type) {
- /* MAC */
- case 0:
- ld->other++;
- break;
case 1:
- capture_llc(pd, offset, len, ld, pseudo_header);
- break;
- default:
- /* non-MAC, non-LLC, i.e., "Reserved" */
- ld->other++;
- break;
+ return capture_llc(pd, offset, len, ld, pseudo_header);
}
+
+ return FALSE;
}
@@ -801,7 +792,6 @@ proto_register_tr(void)
&fix_linux_botches);
register_dissector("tr", dissect_tr, proto_tr);
- register_capture_dissector(WTAP_ENCAP_TOKEN_RING, capture_tr, proto_tr);
tr_tap=register_tap("tr");
register_conversation_table(proto_tr, TRUE, tr_conversation_packet, tr_hostlist_packet);
@@ -822,6 +812,8 @@ proto_reg_handoff_tr(void)
tr_handle = find_dissector("tr");
dissector_add_uint("wtap_encap", WTAP_ENCAP_TOKEN_RING, tr_handle);
dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_TOKENRING, tr_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_TOKEN_RING, capture_tr, proto_tr);
}
/*
diff --git a/epan/dissectors/packet-tr.h b/epan/dissectors/packet-tr.h
index 6880f23c7f..1eacd51b3f 100644
--- a/epan/dissectors/packet-tr.h
+++ b/epan/dissectors/packet-tr.h
@@ -32,6 +32,6 @@ typedef struct _tr_hdr {
} tr_hdr;
extern
-void capture_tr(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_tr(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
#endif
diff --git a/epan/dissectors/packet-vines.c b/epan/dissectors/packet-vines.c
index 07e2cc524f..58cf57d01b 100644
--- a/epan/dissectors/packet-vines.c
+++ b/epan/dissectors/packet-vines.c
@@ -83,6 +83,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include "packet-vines.h"
#include <epan/etypes.h>
#include <epan/ppptypes.h>
@@ -308,10 +309,11 @@ typedef struct _e_vipc {
guint16 vipc_err_len;
} e_vipc;
-void
+gboolean
capture_vines(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_)
{
ld->vines++;
+ return TRUE;
}
static dissector_handle_t vines_ip_handle;
@@ -2015,6 +2017,8 @@ proto_reg_handoff_vines_icp(void)
vines_icp_handle = create_dissector_handle(dissect_vines_icp,
proto_vines_icp);
dissector_add_uint("vines_ip.protocol", VIP_PROTO_ICP, vines_icp_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_VINES_IP, capture_vines, proto_vines_ip);
+ register_capture_dissector("ethertype", ETHERTYPE_VINES_ECHO, capture_vines, proto_vines_echo);
}
/*
diff --git a/epan/dissectors/packet-vines.h b/epan/dissectors/packet-vines.h
index b33d7092c5..d7902df0c5 100644
--- a/epan/dissectors/packet-vines.h
+++ b/epan/dissectors/packet-vines.h
@@ -26,6 +26,6 @@
#ifndef __PACKETVINES_H__
#define __PACKETVINES_H__
-void capture_vines(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
+gboolean capture_vines(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
#endif /* packet-vines.h */
diff --git a/epan/dissectors/packet-vlan.c b/epan/dissectors/packet-vlan.c
index 778f512e6a..061840f488 100644
--- a/epan/dissectors/packet-vlan.c
+++ b/epan/dissectors/packet-vlan.c
@@ -25,12 +25,12 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/capture_dissectors.h>
#include <wsutil/pint.h>
#include <epan/expert.h>
#include "packet-ieee8023.h"
#include "packet-ipx.h"
#include "packet-llc.h"
-#include "packet-vlan.h"
#include <epan/etypes.h>
#include <epan/prefs.h>
#include <epan/to_str.h>
@@ -98,23 +98,22 @@ static gint ett_vlan = -1;
static expert_field ei_vlan_len = EI_INIT;
-void
+static gboolean
capture_vlan(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_ ) {
guint16 encap_proto;
- if ( !BYTES_ARE_IN_FRAME(offset,len,5) ) {
- ld->other++;
- return;
- }
+ if ( !BYTES_ARE_IN_FRAME(offset,len,5) )
+ return FALSE;
+
encap_proto = pntoh16( &pd[offset+2] );
if ( encap_proto <= IEEE_802_3_MAX_LEN) {
if ( pd[offset+4] == 0xff && pd[offset+5] == 0xff ) {
- capture_ipx(pd,offset+4,len,ld, pseudo_header);
+ return capture_ipx(pd,offset+4,len,ld, pseudo_header);
} else {
- capture_llc(pd,offset+4,len,ld, pseudo_header);
+ return capture_llc(pd,offset+4,len,ld, pseudo_header);
}
- } else {
- capture_ethertype(encap_proto, pd, offset+4, len, ld, pseudo_header);
}
+
+ return try_capture_dissector("ethertype", encap_proto, pd, offset+4, len, ld, pseudo_header);
}
static void
@@ -269,6 +268,7 @@ proto_reg_handoff_vlan(void)
ethertype_handle = find_dissector("ethertype");
dissector_add_uint("ethertype", q_in_q_ethertype, vlan_handle);
+ register_capture_dissector("ethertype", ETHERTYPE_VLAN, capture_vlan, hfi_vlan->id);
}
/*
diff --git a/epan/dissectors/packet-vlan.h b/epan/dissectors/packet-vlan.h
deleted file mode 100644
index 4523f5ea64..0000000000
--- a/epan/dissectors/packet-vlan.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* packet-vlan.h
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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.
- *
- * 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.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __PACKET_VLAN_H__
-#define __PACKET_VLAN_H__
-
-void capture_vlan(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header);
-
-#endif
diff --git a/epan/packet.h b/epan/packet.h
index 5b98f2396d..a075b6afcf 100644
--- a/epan/packet.h
+++ b/epan/packet.h
@@ -699,9 +699,6 @@ extern void dissect_file(struct epan_dissect *edt,
struct wtap_pkthdr *phdr, tvbuff_t *tvb,
frame_data *fd, column_info *cinfo);
-/* These functions are in packet-ethertype.c */
-extern void capture_ethertype(guint16 etype, const guchar *pd, int offset,
- int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header);
/* Structure passed to the ethertype dissector */
typedef struct ethertype_data_s
{