Implement registration of capture dissectors by name
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>
Wed, 26 Oct 2016 16:07:47 +0000 (17:07 +0100)
committerMichael Mann <mmann78@netscape.net>
Fri, 28 Oct 2016 17:39:04 +0000 (17:39 +0000)
Mirror it after protocol dissector API.

Change-Id: I7985bcfa9e07654c7cf005efec94efc205d7a304
Reviewed-on: https://code.wireshark.org/review/18496
Reviewed-by: Michael Mann <mmann78@netscape.net>
62 files changed:
debian/libwireshark0.symbols
epan/capture_dissectors.c
epan/capture_dissectors.h
epan/dissectors/Makefile.am
epan/dissectors/packet-ap1394.c
epan/dissectors/packet-arcnet.c
epan/dissectors/packet-arp.c
epan/dissectors/packet-arp.h
epan/dissectors/packet-atalk.c
epan/dissectors/packet-atm.c
epan/dissectors/packet-ax25-kiss.c
epan/dissectors/packet-ax25.c
epan/dissectors/packet-ax25.h [deleted file]
epan/dissectors/packet-bpq.c
epan/dissectors/packet-chdlc.c
epan/dissectors/packet-chdlc.h
epan/dissectors/packet-clip.c
epan/dissectors/packet-enc.c
epan/dissectors/packet-eth.c
epan/dissectors/packet-eth.h
epan/dissectors/packet-fddi.c
epan/dissectors/packet-fr.c
epan/dissectors/packet-gre.c
epan/dissectors/packet-i2c.c
epan/dissectors/packet-icmp.c
epan/dissectors/packet-icmpv6.c
epan/dissectors/packet-ieee80211-prism.c
epan/dissectors/packet-ieee80211-radiotap.c
epan/dissectors/packet-ieee80211-wlancap.c
epan/dissectors/packet-ieee80211.c
epan/dissectors/packet-ieee80211.h
epan/dissectors/packet-ieee8021ah.c
epan/dissectors/packet-ip.c
epan/dissectors/packet-ip.h
epan/dissectors/packet-ipfc.c
epan/dissectors/packet-ipsec.c
epan/dissectors/packet-ipv6.c
epan/dissectors/packet-ipv6.h
epan/dissectors/packet-ipx.c
epan/dissectors/packet-ipx.h
epan/dissectors/packet-isl.c
epan/dissectors/packet-isl.h
epan/dissectors/packet-llc.c
epan/dissectors/packet-llc.h
epan/dissectors/packet-netbios.c
epan/dissectors/packet-netrom.c
epan/dissectors/packet-null.c
epan/dissectors/packet-ospf.c
epan/dissectors/packet-pktap.c
epan/dissectors/packet-ppi.c
epan/dissectors/packet-ppp.c
epan/dissectors/packet-ppp.h
epan/dissectors/packet-raw.c
epan/dissectors/packet-sctp.c
epan/dissectors/packet-shim6.c
epan/dissectors/packet-sll.c
epan/dissectors/packet-tcp.c
epan/dissectors/packet-tr.c
epan/dissectors/packet-tr.h
epan/dissectors/packet-udp.c
epan/dissectors/packet-vines.c
epan/dissectors/packet-vlan.c

index 772121415267b3027efff4d9ecb165c4441d0cc6..ad3f5c53fb64df41760634924ebc39ed793b0430 100644 (file)
@@ -94,6 +94,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
  bytes_to_str@Base 1.99.2
  bytestring_to_str@Base 1.9.1
  call_ber_oid_callback@Base 1.9.1
+ call_capture_dissector@Base 2.3.0
  call_data_dissector@Base 2.1.0
  call_dissector@Base 1.9.1
  call_dissector_only@Base 1.9.1
@@ -102,6 +103,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
  call_per_oid_callback@Base 1.99.1
  camelSRTtype_naming@Base 1.9.1
  camel_opr_code_strings@Base 1.9.1
+ capture_dissector_add_uint@Base 2.3.0
  capture_dissector_get_count@Base 2.1.0
  capture_dissector_increment_count@Base 2.1.0
  check_xdlc_control@Base 1.9.1
@@ -194,6 +196,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
  crc32_mpeg2_tvb_seed@Base 1.9.1
  crc32c_tvb_offset_calculate@Base 1.99.0
  crc6_compute_tvb@Base 1.99.0
+ create_capture_dissector_handle@Base 2.3.0
  create_dissector_handle@Base 2.1.0
  create_dissector_handle_with_name@Base 2.1.0
  dcerpc_get_proto_hf_opnum@Base 2.1.0
@@ -563,6 +566,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
  filter_expression_new@Base 1.9.1
  filter_expression_free@Base 1.99.3
  find_and_mark_frame_depended_upon@Base 1.12.0~rc1
+ find_capture_dissector@Base 2.3.0
  find_circuit@Base 1.9.1
  find_conversation@Base 1.9.1
  find_conversation_filter@Base 2.0.0
index 69c358479541044c57daf5357a6e2474557376d6..c8374610827c5b0b1e0eef08c98ffb36affce7a8 100644 (file)
@@ -36,7 +36,7 @@ struct capture_dissector_table {
 
 struct capture_dissector_handle
 {
-    guint32 pattern;
+    const char *name;
     capture_dissector_t dissector;
     protocol_t* protocol;
 };
@@ -46,6 +46,8 @@ typedef struct capture_dissector_count
     guint32 count;
 } capture_dissector_count_t;
 
+static GHashTable *registered_dissectors = NULL;
+
 static GHashTable *capture_dissector_tables = NULL;
 
 static void
@@ -59,12 +61,14 @@ destroy_capture_dissector_table(void *data)
 
 void capture_dissector_init(void)
 {
+    registered_dissectors = g_hash_table_new_full(g_str_hash, g_str_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(capture_dissector_tables);
+    g_hash_table_destroy(registered_dissectors);
 }
 
 void register_capture_dissector_table(const char *name, const char *ui_name)
@@ -84,10 +88,47 @@ void register_capture_dissector_table(const char *name, const char *ui_name)
 
 }
 
-void register_capture_dissector(const char* name, const guint32 pattern, capture_dissector_t dissector, const int proto)
+static capture_dissector_handle_t
+new_capture_dissector_handle(capture_dissector_t dissector, int proto, const char *name)
+{
+    struct capture_dissector_handle* handle;
+
+    handle                = wmem_new(wmem_epan_scope(), struct capture_dissector_handle);
+    handle->name          = name;
+    handle->dissector     = dissector;
+    handle->protocol      = find_protocol_by_id(proto);
+    return handle;
+}
+
+capture_dissector_handle_t
+create_capture_dissector_handle(capture_dissector_t dissector, const int proto)
+{
+    return new_capture_dissector_handle(dissector, proto, NULL);
+}
+
+capture_dissector_handle_t find_capture_dissector(const char *name)
+{
+    return (capture_dissector_handle_t)g_hash_table_lookup(registered_dissectors, name);
+}
+
+capture_dissector_handle_t register_capture_dissector(const char *name, capture_dissector_t dissector, int proto)
+{
+    capture_dissector_handle_t handle;
+
+    /* Make sure the registration is unique */
+    g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
+
+    handle = new_capture_dissector_handle(dissector, proto, name);
+    g_hash_table_insert(registered_dissectors, (gpointer)name, handle);
+    return handle;
+}
+
+void capture_dissector_add_uint(const char *name, const guint32 pattern, capture_dissector_handle_t handle)
 {
     struct capture_dissector_table*    sub_dissectors;
-    struct capture_dissector_handle *handle;
+
+    if (handle == NULL)
+        return;
 
     /* Make sure table exists */
     sub_dissectors = (struct capture_dissector_table*)g_hash_table_lookup( capture_dissector_tables, name );
@@ -102,18 +143,13 @@ void register_capture_dissector(const char* name, const guint32 pattern, capture
     /* Make sure the registration is unique */
     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->pattern       = pattern;
-    handle->dissector     = dissector;
-    handle->protocol      = find_protocol_by_id(proto);
-
     g_hash_table_insert(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern), (gpointer) handle);
 }
 
 gboolean try_capture_dissector(const char* name, const guint32 pattern, const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
 {
     struct capture_dissector_table*    sub_dissectors;
-    struct capture_dissector_handle* handle;
+    capture_dissector_handle_t handle;
 
     sub_dissectors = (struct capture_dissector_table*)g_hash_table_lookup( capture_dissector_tables, name );
     if (sub_dissectors == NULL)
@@ -122,13 +158,20 @@ gboolean try_capture_dissector(const char* name, const guint32 pattern, const gu
         return FALSE;
     }
 
-    handle = (struct capture_dissector_handle *)g_hash_table_lookup(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern));
+    handle = (capture_dissector_handle_t)g_hash_table_lookup(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern));
     if (handle == NULL)
         return FALSE;
 
     return handle->dissector(pd, offset, len, cpinfo, pseudo_header);
 }
 
+gboolean call_capture_dissector(capture_dissector_handle_t handle, const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
+{
+    if (handle == NULL)
+        return FALSE;
+    return handle->dissector(pd, offset, len, cpinfo, pseudo_header);
+}
+
 guint32 capture_dissector_get_count(packet_counts* counts, const int proto)
 {
     capture_dissector_count_t* hash_count = (capture_dissector_count_t*)g_hash_table_lookup(counts->counts_hash, GUINT_TO_POINTER(proto));
index dd0486efdf522272dd38b6ef2f90c00489614162..d4bbf194d882484bf25b873a5dbc21ea06ff92ff 100644 (file)
@@ -34,20 +34,80 @@ extern "C" {
 /** @file
  */
 
+typedef struct capture_dissector_handle* capture_dissector_handle_t;
+
 /** callback function definition for capture dissectors */
 typedef gboolean (*capture_dissector_t)(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
 
 /* a protocol uses the function to register a capture sub-dissector table
+ * @param[in] name Name of capture sub-dissector table.
+ * @param[in] ui_name Name string used when referring to capture sub-dissector table in UI.
  */
 WS_DLL_PUBLIC void register_capture_dissector_table(const char *name, const char *ui_name);
 
+/* Create an anonymous handle for a capture dissector
+ * @param[in] dissector capture dissector function.
+ * @param[in] proto Protocol associated with capture dissector function.
+ * @return  Handle created for capture dissector
+ */
+WS_DLL_PUBLIC capture_dissector_handle_t create_capture_dissector_handle(capture_dissector_t dissector, const int proto);
+
+/* Find a dissector by name
+ * @param[in] name Name of capture dissector
+ * @return  Handle for capture dissector if found, NULL otherwise
+ */
+WS_DLL_PUBLIC capture_dissector_handle_t find_capture_dissector(const char *name);
 
-/** Register a new capture dissector. */
-WS_DLL_PUBLIC void register_capture_dissector(const char* name, const guint32 pattern, capture_dissector_t dissector, const int proto);
+/* Register a new capture dissector
+ * @param[in] name Name of capture dissector function.
+ * @param[in] dissector capture dissector function.
+ * @param[in] proto Protocol associated with capture dissector function.
+ * @return  Handle created for capture dissector
+ */
+WS_DLL_PUBLIC capture_dissector_handle_t register_capture_dissector(const char *name, capture_dissector_t dissector, int proto);
+
+/* Add an entry to a uint capture dissector table
+ * @param[in] name Name of capture dissector table
+ * @param[in] pattern Numerical value associated with capture dissector
+ * @param[in] handle Handle to capture dissector
+ */
+WS_DLL_PUBLIC void capture_dissector_add_uint(const char *name, const guint32 pattern, capture_dissector_handle_t handle);
 
+/* Look for a given value in a given uint capture dissector table and, if found,
+ * call the dissector with the arguments supplied, and return TRUE,
+ * otherwise return FALSE
+ * @param[in] name Name of capture dissector table
+ * @param[in] pattern Numerical value associated with capture dissector
+ * @param[in] pd Data buffer of captured bytes
+ * @param[in] offset Current offset into pd
+ * @param[in] len Length of pd
+ * @param[in] cpinfo Capture statistics
+ * @param[in] pseudo_header Wiretap pseudo header information
+ */
 WS_DLL_PUBLIC gboolean try_capture_dissector(const char* name, const guint32 pattern, const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
 
+/* Call a capture dissector through a handle. If handle is value return TRUE,
+ * otherwise return FALSE
+ * @param[in] handle Capture dissector handle
+ * @param[in] pd Data buffer of captured bytes
+ * @param[in] offset Current offset into pd
+ * @param[in] len Length of pd
+ * @param[in] cpinfo Capture statistics
+ * @param[in] pseudo_header Wiretap pseudo header information
+ */
+WS_DLL_PUBLIC gboolean call_capture_dissector(capture_dissector_handle_t handle, const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
+
+/* Get current capture packet count for a particular protocol
+ * @param[in] counts Packet count structure
+ * @param[in] proto Protocol to retrieve packet count from
+ * @return Number of packets captured for a particular protocol
+ */
 WS_DLL_PUBLIC guint32 capture_dissector_get_count(packet_counts* counts, const int proto);
+
+/* Increment packet capture count by 1 for a particular protocol.
+ * @param[in] cpinfo Capture statistics
+ * @param[in] proto Protocol to increment packet count
+ */
 WS_DLL_PUBLIC void capture_dissector_increment_count(capture_packet_info_t *cpinfo, const int proto);
 
 extern void capture_dissector_init(void);
index f12e9bc18bf556eb7f1cdd7b19eee22fff563f55..75334b57e83d0d63a0f4be3c318652e1f780e86d 100644 (file)
@@ -1467,7 +1467,6 @@ DISSECTOR_INCLUDES = \
        packet-atalk.h          \
        packet-atm.h            \
        packet-atn-ulcs.h       \
-       packet-ax25.h           \
        packet-bacapp.h         \
        packet-ber.h            \
        packet-bfd.h            \
index f0de887207fc9f11badc161d5fe307d2e8ba4feb..bb18ed3fa6e7bf2edbb4e9989996ed6a2ee166f7 100644 (file)
@@ -121,12 +121,15 @@ void
 proto_reg_handoff_ap1394(void)
 {
   dissector_handle_t ap1394_handle;
+  capture_dissector_handle_t ap1394_cap_handle;
 
   ethertype_subdissector_table = find_dissector_table("ethertype");
 
   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);
+
+  ap1394_cap_handle = create_capture_dissector_handle(capture_ap1394, proto_ap1394);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, ap1394_cap_handle);
 }
 
 /*
index eaf7d430773bf495a7fa6448bfca49d0b5e38e42..70512a8226ca1c0209898edbfae515b74d55a4d9 100644 (file)
@@ -53,6 +53,9 @@ static int arcnet_address_type = -1;
 
 static dissector_table_t arcnet_dissector_table;
 
+static capture_dissector_handle_t ip_cap_handle;
+static capture_dissector_handle_t arp_cap_handle;
+
 /* Cache protocol for packet counting */
 static int proto_ipx = -1;
 
@@ -95,7 +98,7 @@ capture_arcnet_common(const guchar *pd, int offset, int len, capture_packet_info
 
   case ARCNET_PROTO_IP_1051:
     /* No fragmentation stuff in the header */
-    return capture_ip(pd, offset + 1, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ip_cap_handle, pd, offset + 1, len, cpinfo, pseudo_header);
 
   case ARCNET_PROTO_IP_1201:
     /*
@@ -135,14 +138,14 @@ capture_arcnet_common(const guchar *pd, int offset, int len, capture_packet_info
          type appears after the padding. */
       offset += 4;
     }
-    return capture_ip(pd, offset + 3, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ip_cap_handle, pd, offset + 3, len, cpinfo, pseudo_header);
 
   case ARCNET_PROTO_ARP_1051:
   case ARCNET_PROTO_ARP_1201:
     /*
      * XXX - do we have to worry about fragmentation for ARP?
      */
-    return capture_arp(pd, offset + 1, len, cpinfo, pseudo_header);
+    return call_capture_dissector(arp_cap_handle, pd, offset + 1, len, cpinfo, pseudo_header);
 
   case ARCNET_PROTO_IPX:
     capture_dissector_increment_count(cpinfo, proto_ipx);
@@ -402,6 +405,7 @@ void
 proto_reg_handoff_arcnet (void)
 {
   dissector_handle_t arcnet_handle, arcnet_linux_handle;
+  capture_dissector_handle_t arcnet_cap_handle;
 
   arcnet_handle = create_dissector_handle (dissect_arcnet, proto_arcnet);
   dissector_add_uint ("wtap_encap", WTAP_ENCAP_ARCNET, arcnet_handle);
@@ -411,8 +415,13 @@ proto_reg_handoff_arcnet (void)
 
   proto_ipx = proto_get_id_by_filter_name("ipx");
 
-  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);
+  arcnet_cap_handle = create_capture_dissector_handle(capture_arcnet, proto_arcnet);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_ARCNET_LINUX, arcnet_cap_handle);
+  arcnet_cap_handle = create_capture_dissector_handle(capture_arcnet_has_exception, proto_arcnet);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_ARCNET, arcnet_cap_handle);
+
+  ip_cap_handle = find_capture_dissector("ip");
+  arp_cap_handle = find_capture_dissector("arp");
 }
 
 /*
index 15ab85bc6761353274b03f7bd46311ae54113294..9d352939d981dd6f3e8bc2ca01dcd831a3d52375 100644 (file)
@@ -105,6 +105,8 @@ static dissector_handle_t arp_handle;
 static dissector_handle_t atmarp_handle;
 static dissector_handle_t ax25arp_handle;
 
+static capture_dissector_handle_t arp_cap_handle;
+
 /* Used for determining if frequency of ARP requests constitute a storm */
 #define STORM    1
 #define NO_STORM 2
@@ -2023,6 +2025,8 @@ proto_register_arp(void)
 
   register_init_routine(&arp_init_protocol);
   register_cleanup_routine(&arp_cleanup_protocol);
+
+  arp_cap_handle = register_capture_dissector("arp", capture_arp, proto_arp);
 }
 
 void
@@ -2035,8 +2039,8 @@ proto_reg_handoff_arp(void)
   dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_RARP_1201, arp_handle);
   dissector_add_uint("ax25.pid", AX25_P_ARP, arp_handle);
   dissector_add_uint("gre.proto", ETHERTYPE_ARP, arp_handle);
-  register_capture_dissector("ethertype", ETHERTYPE_ARP, capture_arp, proto_arp);
-  register_capture_dissector("ax25.pid", AX25_P_ARP, capture_arp, proto_arp);
+  capture_dissector_add_uint("ethertype", ETHERTYPE_ARP, arp_cap_handle);
+  capture_dissector_add_uint("ax25.pid", AX25_P_ARP, arp_cap_handle);
 }
 
 /*
index 6017506ebd54103a72402e01e39b97497afa334f..e7a386e276f53679ad5eb5a71a71e96b08fb8ac9 100644 (file)
@@ -27,7 +27,6 @@
 const gchar *tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type);
 
 void dissect_atm_nsap(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree);
-gboolean capture_arp(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
 
 extern const value_string arp_hrd_vals[];
 
index d8fc4454ce61ccb7a33da38723cd16cad1bc58a5..5939719fde85c49d86934353c437a1fffdd86de9 100644 (file)
@@ -2047,6 +2047,7 @@ proto_reg_handoff_atalk(void)
   dissector_handle_t atp_handle;
   dissector_handle_t zip_ddp_handle;
   dissector_handle_t rtmp_data_handle, llap_handle;
+  capture_dissector_handle_t llap_cap_handle;
 
   ddp_short_handle = create_dissector_handle(dissect_ddp_short, proto_ddp);
   ddp_handle = create_dissector_handle(dissect_ddp, proto_ddp);
@@ -2078,7 +2079,8 @@ 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);
+  llap_cap_handle = create_capture_dissector_handle(capture_llap, proto_llap);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_LOCALTALK, llap_cap_handle);
 
   register_init_routine( atp_init);
   register_cleanup_routine( atp_cleanup);
index ff4bc60f32264845d5c2c2871860e3d697c30fab..26cddc5601dc6171fe532375f628532d88859aba 100644 (file)
@@ -2004,6 +2004,8 @@ proto_register_atm(void)
 void
 proto_reg_handoff_atm(void)
 {
+  capture_dissector_handle_t atm_cap_handle;
+
   /*
    * Get handles for the Ethernet, Token Ring, Frame Relay, LLC,
    * SSCOP, LANE, and ILMI dissectors.
@@ -2023,8 +2025,11 @@ 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);
-  register_capture_dissector("atm.aal5.type", TRAF_LANE, capture_lane, proto_atm_lane);
+
+  atm_cap_handle = create_capture_dissector_handle(capture_atm, proto_atm);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_ATM_PDUS, atm_cap_handle);
+  atm_cap_handle = create_capture_dissector_handle(capture_lane, proto_atm_lane);
+  capture_dissector_add_uint("atm.aal5.type", TRAF_LANE, atm_cap_handle);
 }
 
 /*
index 56a308b21c2166ec37e43a54de77dd764ae99b7a..fb078957c0be16cdf64f860ffe0c68d2d54c816a 100644 (file)
 #include <epan/capture_dissectors.h>
 #include <epan/prefs.h>
 #include <wiretap/wtap.h>
-#include "packet-ax25.h"
 
 #define STRLEN 80
 
@@ -161,6 +160,8 @@ static gint ett_ax25_kiss = -1;
 
 static dissector_handle_t kiss_handle;
 
+static capture_dissector_handle_t ax25_cap_handle;
+
 /* Dissector handles - all the possibles are listed */
 static dissector_handle_t ax25_handle;
 
@@ -193,7 +194,7 @@ capture_ax25_kiss( const guchar *pd, int offset, int len, capture_packet_info_t
        switch ( kiss_cmd & KISS_CMD_MASK )
        {
                case KISS_DATA_FRAME    :
-                       return capture_ax25( pd, l_offset, len, cpinfo, pseudo_header );
+                       return call_capture_dissector( ax25_cap_handle, pd, l_offset, len, cpinfo, pseudo_header );
                case KISS_TXDELAY       : break;
                case KISS_PERSISTENCE   : break;
                case KISS_SLOT_TIME     : break;
@@ -202,7 +203,7 @@ capture_ax25_kiss( const guchar *pd, int offset, int len, capture_packet_info_t
                case KISS_SETHARDWARE   : break;
                case KISS_DATA_FRAME_ACK:
                        l_offset += 2;
-                       return capture_ax25( pd, l_offset, len, cpinfo, pseudo_header );
+                       return call_capture_dissector( ax25_cap_handle, pd, l_offset, len, cpinfo, pseudo_header );
                case KISS_POLL_MODE     : break;
                case KISS_RETURN        : break;
                default                 : break;
@@ -446,11 +447,16 @@ proto_register_ax25_kiss(void)
 void
 proto_reg_handoff_ax25_kiss(void)
 {
+       capture_dissector_handle_t ax25_kiss_cap_handle;
+
        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);
+       ax25_kiss_cap_handle = create_capture_dissector_handle(capture_ax25_kiss, proto_ax25_kiss);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_AX25_KISS, ax25_kiss_cap_handle);
 
        /* only currently implemented for AX.25 */
        ax25_handle = find_dissector_add_dependency( "ax25", proto_ax25_kiss );
+
+       ax25_cap_handle = find_capture_dissector("ax25");
 }
 
 /*
index c9535bbe6580b068e122cf87a454e9c2ed6f0363..8bfb0e3e7f9948991c9cfbc9cc88aeb196097c89 100644 (file)
@@ -51,7 +51,6 @@
 #include <epan/xdlc.h>
 #include <epan/ax25_pids.h>
 #include <epan/ipproto.h>
-#include "packet-ax25.h"
 
 #define STRLEN 80
 
@@ -64,6 +63,8 @@ void proto_reg_handoff_ax25(void);
 /* Dissector table */
 static dissector_table_t ax25_dissector_table;
 
+static capture_dissector_handle_t ax25_cap_handle;
+
 /* Initialize the protocol and registered fields */
 static int proto_ax25          = -1;
 static int hf_ax25_dst         = -1;
@@ -411,6 +412,8 @@ proto_register_ax25(void)
        /* Register dissector table for protocol IDs */
        ax25_dissector_table = register_dissector_table("ax25.pid", "AX.25 protocol ID", proto_ax25, FT_UINT8, BASE_HEX);
        register_capture_dissector_table("ax25.pid", "AX.25");
+
+       ax25_cap_handle = register_capture_dissector("ax25", capture_ax25, proto_ax25);
 }
 
 void
@@ -419,7 +422,7 @@ 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);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_AX25, ax25_cap_handle);
 }
 
 /*
diff --git a/epan/dissectors/packet-ax25.h b/epan/dissectors/packet-ax25.h
deleted file mode 100644 (file)
index dc1ad39..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* packet-ax25.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_AX25_H__
-#define __PACKET_AX25_H__
-
-extern
-gboolean capture_ax25(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
-#endif
index 14399d21cc59b65ac850104ae921ac46e7805dab..8987696710c77f0e9c75d9dde8bd42d382f72c1c 100644 (file)
@@ -39,8 +39,6 @@
 #include <epan/etypes.h>
 #include <epan/capture_dissectors.h>
 
-#include "packet-ax25.h"
-
 #define STRLEN 80
 
 #define BPQ_HEADER_SIZE        2 /* length of bpq_len */
@@ -51,6 +49,8 @@ void proto_reg_handoff_bpq(void);
 static dissector_handle_t bpq_handle;
 static dissector_handle_t ax25_handle;
 
+static capture_dissector_handle_t ax25_cap_handle;
+
 static int proto_bpq            = -1;
 static int hf_bpq_len          = -1;
 
@@ -112,7 +112,7 @@ capture_bpq( const guchar *pd, int offset, int len, capture_packet_info_t *cpinf
 
        l_offset = offset;
        l_offset += BPQ_HEADER_SIZE; /* step over bpq header to point at the AX.25 packet*/
-       return capture_ax25( pd, l_offset, len, cpinfo, pseudo_header );
+       return call_capture_dissector( ax25_cap_handle, pd, l_offset, len, cpinfo, pseudo_header );
 }
 
 void
@@ -146,12 +146,16 @@ proto_register_bpq(void)
 void
 proto_reg_handoff_bpq(void)
 {
+       capture_dissector_handle_t bpq_cap_handle;
+
        dissector_add_uint("ethertype", ETHERTYPE_BPQ, bpq_handle);
-       register_capture_dissector("ethertype", ETHERTYPE_BPQ, capture_bpq, proto_bpq);
+       bpq_cap_handle = create_capture_dissector_handle(capture_bpq, proto_bpq);
+       capture_dissector_add_uint("ethertype", ETHERTYPE_BPQ, bpq_cap_handle);
 
        /* BPQ is only implemented for AX.25 */
        ax25_handle     = find_dissector_add_dependency( "ax25", proto_bpq );
 
+       ax25_cap_handle = find_capture_dissector( "ax25" );
 }
 
 /*
index c0aca21cbf8f7e92de935c5f148d7dc0a4025629..6cb961198570f4d64521585a7ea8bd2984d67054 100644 (file)
@@ -88,6 +88,8 @@ static gint ett_slarp = -1;
 
 static dissector_table_t subdissector_table;
 
+static capture_dissector_handle_t ip_cap_handle;
+
 static const value_string chdlc_address_vals[] = {
   {CHDLC_ADDR_UNICAST,   "Unicast"},
   {CHDLC_ADDR_MULTICAST, "Multicast"},
@@ -118,7 +120,7 @@ capture_chdlc( const guchar *pd, int offset, int len, capture_packet_info_t *cpi
 
   switch (pntoh16(&pd[offset + 2])) {
     case ETHERTYPE_IP:
-      return capture_ip(pd, offset + 4, len, cpinfo, pseudo_header);
+      return call_capture_dissector(ip_cap_handle, pd, offset + 4, len, cpinfo, pseudo_header);
   }
 
   return FALSE;
@@ -245,12 +247,15 @@ proto_register_chdlc(void)
         &chdlc_fcs_decode,
         fcs_options, ENC_BIG_ENDIAN);
 
+  register_capture_dissector("chdlc", capture_chdlc, proto_chdlc);
+
 }
 
 void
 proto_reg_handoff_chdlc(void)
 {
   dissector_handle_t chdlc_handle;
+  capture_dissector_handle_t chdlc_cap_handle;
 
   chdlc_handle = find_dissector("chdlc");
   dissector_add_uint("wtap_encap", WTAP_ENCAP_CHDLC, chdlc_handle);
@@ -258,7 +263,10 @@ proto_reg_handoff_chdlc(void)
   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);
+  chdlc_cap_handle = find_capture_dissector("chdlc");
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_CHDLC, chdlc_cap_handle);
+
+  ip_cap_handle = find_capture_dissector("ip");
 }
 
 
index 917fcb8155855bdbd4d85692f9156170e19b718a..a871cc66d4fd2dc6d14dcce3fde6f731cc55957c 100644 (file)
@@ -31,9 +31,6 @@
 #define CHDLC_ADDR_UNICAST     0x0f
 #define CHDLC_ADDR_MULTICAST   0x8f
 
-extern
-gboolean capture_chdlc(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 extern const value_string chdlc_vals[];
 
 void
index ba7af0e4b9f1c704c6e384703df03d6a18fca4ad..3ec7f97468983fd403e05902ec4b53d6ecc135e7 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 
 #include <epan/packet.h>
-#include <epan/capture_dissectors.h>
 #include <epan/expert.h>
 #include <wiretap/wtap.h>
 
@@ -118,8 +117,6 @@ 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_ip, proto_clip);
 }
 
 /*
index c100f15ec309ae7e9bbf49163aefe867329944d9..16bfe03d9e34d7a6bb1d9cbaf47c20e37f9d5950 100644 (file)
@@ -167,11 +167,13 @@ void
 proto_reg_handoff_enc(void)
 {
   dissector_handle_t enc_handle;
+  capture_dissector_handle_t enc_cap_handle;
 
   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);
+  enc_cap_handle = create_capture_dissector_handle(capture_enc, proto_enc);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_ENC, enc_cap_handle);
 }
 
 /*
index 605acfeddf68c360299146f8f9c79161cdaf8bb9..65b5bf5a701f2c44a79a2ea1cdda2776cc3fbb8e 100644 (file)
@@ -92,6 +92,9 @@ static expert_field ei_eth_len = EI_INIT;
 
 static dissector_handle_t fw1_handle;
 static dissector_handle_t ethertype_handle;
+static capture_dissector_handle_t isl_cap_handle;
+static capture_dissector_handle_t ipx_cap_handle;
+static capture_dissector_handle_t llc_cap_handle;
 static heur_dissector_list_t heur_subdissector_list;
 static heur_dissector_list_t eth_trailer_subdissector_list;
 
@@ -209,7 +212,7 @@ capture_eth(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo
     if ((pd[offset] == 0x01 || pd[offset] == 0x0C) && pd[offset+1] == 0x00
         && pd[offset+2] == 0x0C && pd[offset+3] == 0x00
         && pd[offset+4] == 0x00) {
-      return capture_isl(pd, offset, len, cpinfo, pseudo_header);
+      return call_capture_dissector(isl_cap_handle, pd, offset, len, cpinfo, pseudo_header);
     }
   }
 
@@ -266,9 +269,9 @@ capture_eth(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo
 
   switch (ethhdr_type) {
     case ETHERNET_802_3:
-      return capture_ipx(pd, offset, len, cpinfo, pseudo_header);
+      return call_capture_dissector(ipx_cap_handle, pd, offset, len, cpinfo, pseudo_header);
     case ETHERNET_802_2:
-      return capture_llc(pd, offset, len, cpinfo, pseudo_header);
+      return call_capture_dissector(llc_cap_handle, pd, offset, len, cpinfo, pseudo_header);
     case ETHERNET_II:
       return try_capture_dissector("ethertype", etype, pd, offset, len, cpinfo, pseudo_header);
   }
@@ -995,12 +998,15 @@ proto_register_eth(void)
 
   register_conversation_table(proto_eth, TRUE, eth_conversation_packet, eth_hostlist_packet);
   register_conversation_filter("eth", "Ethernet", eth_filter_valid, eth_build_filter);
+
+  register_capture_dissector("eth", capture_eth, proto_eth);
 }
 
 void
 proto_reg_handoff_eth(void)
 {
   dissector_handle_t eth_handle, eth_withoutfcs_handle, eth_maybefcs_handle;
+  capture_dissector_handle_t eth_cap_handle;
 
   /* Get a handle for the Firewall-1 dissector. */
   fw1_handle = find_dissector_add_dependency("fw1", proto_eth);
@@ -1038,11 +1044,16 @@ proto_reg_handoff_eth(void)
 
   dissector_add_for_decode_as("pcli.payload", eth_withoutfcs_handle);
 
-  register_capture_dissector("wtap_encap", WTAP_ENCAP_ETHERNET, capture_eth, proto_eth);
-  register_capture_dissector("atm_lane", TRAF_ST_LANE_802_3, capture_eth, proto_eth);
-  register_capture_dissector("atm_lane", TRAF_ST_LANE_802_3_MC, capture_eth, proto_eth);
-  register_capture_dissector("ppi", 1 /* DLT_EN10MB */, capture_eth, proto_eth);
-  register_capture_dissector("sll.ltype", LINUX_SLL_P_ETHERNET, capture_eth, proto_eth);
+  eth_cap_handle = find_capture_dissector("eth");
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_ETHERNET, eth_cap_handle);
+  capture_dissector_add_uint("atm_lane", TRAF_ST_LANE_802_3, eth_cap_handle);
+  capture_dissector_add_uint("atm_lane", TRAF_ST_LANE_802_3_MC, eth_cap_handle);
+  capture_dissector_add_uint("ppi", 1 /* DLT_EN10MB */, eth_cap_handle);
+  capture_dissector_add_uint("sll.ltype", LINUX_SLL_P_ETHERNET, eth_cap_handle);
+
+  isl_cap_handle = find_capture_dissector("isl");
+  ipx_cap_handle = find_capture_dissector("ipx");
+  llc_cap_handle = find_capture_dissector("llc");
 }
 
 /*
index d46d4befd04c80ad0d372f1f0c450712ff6571e4..ce1cc6b261d28fcdf5cf868d06be3b60606259a3 100644 (file)
@@ -28,9 +28,6 @@ typedef struct _eth_hdr {
        guint16 type;
 } eth_hdr;
 
-extern
-gboolean capture_eth(const guchar *, int, int, capture_packet_info_t *cpinfo, 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,
                          int fcs_len);
index 98cd5f51e3d376b450eef4e63b414eb106a7d474..c6b45ee8adfacb85413130ebb837e984cdee33dd 100644 (file)
@@ -58,6 +58,8 @@ static int fddi_tap = -1;
 
 static dissector_handle_t fddi_handle, fddi_bitswapped_handle;
 
+static capture_dissector_handle_t llc_cap_handle;
+
 static gboolean fddi_padding = FALSE;
 
 #define FDDI_PADDING            ((fddi_padding) ? 3 : 0)
@@ -232,7 +234,7 @@ capture_fddi(const guchar *pd, int offset, int len, capture_packet_info_t *cpinf
     case FDDI_FC_LLC_ASYNC + 13 :
     case FDDI_FC_LLC_ASYNC + 14 :
     case FDDI_FC_LLC_ASYNC + 15 :
-      return capture_llc(pd, offset, len, cpinfo, pseudo_header);
+      return call_capture_dissector(llc_cap_handle, pd, offset, len, cpinfo, pseudo_header);
   } /* fc */
 
   return FALSE;
@@ -534,6 +536,8 @@ proto_register_fddi(void)
 void
 proto_reg_handoff_fddi(void)
 {
+  capture_dissector_handle_t fddi_cap_handle;
+
   /*
    * Get a handle for the LLC dissector.
    */
@@ -542,8 +546,11 @@ proto_reg_handoff_fddi(void)
   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);
+  fddi_cap_handle = create_capture_dissector_handle(capture_fddi, proto_fddi);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_FDDI, fddi_cap_handle);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_FDDI_BITSWAPPED, fddi_cap_handle);
+
+  llc_cap_handle = find_capture_dissector("llc");
 }
 
 /*
index dc1eb11b48479fa42daea57ef51b4be377d9f640..779da67994e9031fa22c211a2bba6c1a48ebd694 100644 (file)
@@ -123,6 +123,9 @@ static dissector_handle_t eth_withfcs_handle;
 static dissector_handle_t gprs_ns_handle;
 static dissector_handle_t data_handle;
 
+static capture_dissector_handle_t chdlc_cap_handle;
+static capture_dissector_handle_t eth_cap_handle;
+
 static dissector_table_t osinl_incl_subdissector_table;
 
 /*
@@ -325,23 +328,7 @@ capture_fr(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo,
         fr_nlpid = pd[offset];
       }
       offset++;
-      switch (fr_nlpid) {
-
-      case NLPID_IP:
-        return capture_ip(pd, offset, len, cpinfo, pseudo_header);
-
-      case NLPID_IP6:
-        return capture_ipv6(pd, offset, len, cpinfo, pseudo_header);
-
-      case NLPID_PPP:
-        return capture_ppp_hdlc(pd, offset, len, cpinfo, pseudo_header);
-
-      case NLPID_SNAP:
-        return capture_snap(pd, offset, len, cpinfo, pseudo_header);
-
-      default:
-        return FALSE;
-      }
+      return try_capture_dissector("fr.nlpid", fr_nlpid, pd, offset, len, cpinfo, pseudo_header);
     } else {
       if (addr == 0) {
         /*
@@ -367,7 +354,7 @@ capture_fr(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo,
        * If the data does not start with unnumbered information (03) and
        * the DLCI# is not 0, then there may be Cisco Frame Relay encapsulation.
        */
-      return capture_chdlc(pd, offset, len, cpinfo, pseudo_header);
+      return call_capture_dissector(chdlc_cap_handle, pd, offset, len, cpinfo, pseudo_header);
     }
     break;
 
@@ -376,7 +363,7 @@ capture_fr(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo,
 
   case RAW_ETHER:
     if (addr != 0)
-      return capture_eth(pd, offset, len, cpinfo, pseudo_header);
+      return call_capture_dissector(eth_cap_handle, pd, offset, len, cpinfo, pseudo_header);
 
     return FALSE;
   }
@@ -989,12 +976,15 @@ proto_register_fr(void)
   prefs_register_enum_preference(frencap_module, "encap", "Encapsulation",
                                  "Encapsulation", &fr_encap,
                                  fr_encap_options, FALSE);
+
+  register_capture_dissector_table("fr.nlpid", "Frame Relay NLPID");
 }
 
 void
 proto_reg_handoff_fr(void)
 {
   dissector_handle_t fr_handle, fr_phdr_handle;
+  capture_dissector_handle_t fr_cap_handle;
 
   fr_handle = find_dissector("fr");
   dissector_add_uint("gre.proto", ETHERTYPE_RAW_FR, fr_handle);
@@ -1007,14 +997,18 @@ 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);
+  fr_cap_handle = create_capture_dissector_handle(capture_fr, proto_fr);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_FRELAY, fr_cap_handle);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_FRELAY_WITH_PHDR, fr_cap_handle);
 
   eth_withfcs_handle = find_dissector_add_dependency("eth_withfcs", proto_fr);
   gprs_ns_handle = find_dissector_add_dependency("gprs_ns", proto_fr);
   data_handle = find_dissector_add_dependency("data", proto_fr);
 
   osinl_incl_subdissector_table = find_dissector_table("osinl.incl");
+
+  chdlc_cap_handle = find_capture_dissector("chdlc");
+  eth_cap_handle = find_capture_dissector("eth");
 }
 
 /*
index 8f16057d022806715435b74bdc1aa0651e13fc1d..c0607fdd2c95237d3e14aa4f16b07bc8833668c7 100644 (file)
@@ -754,10 +754,12 @@ void
 proto_reg_handoff_gre(void)
 {
     dissector_handle_t gre_handle;
+    capture_dissector_handle_t gre_cap_handle;
 
     gre_handle = create_dissector_handle(dissect_gre, proto_gre);
     dissector_add_uint("ip.proto", IP_PROTO_GRE, gre_handle);
-    register_capture_dissector("ip.proto", IP_PROTO_GRE, capture_gre, proto_gre);
+    gre_cap_handle = create_capture_dissector_handle(capture_gre, proto_gre);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_GRE, gre_cap_handle);
 }
 
 /*
index 2adfd01c97b7d1581f3cac857389d8796c901a39..1aea2199cd788c9ab0795bfb7d5842e35d16d669 100644 (file)
@@ -267,10 +267,12 @@ void
 proto_reg_handoff_i2c(void)
 {
        dissector_handle_t i2c_handle;
+       capture_dissector_handle_t i2c_cap_handle;
 
        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);
+       i2c_cap_handle = create_capture_dissector_handle(capture_i2c, proto_i2c);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_I2C, i2c_cap_handle);
 }
 
 /*
index d09dafe7f22bd2fad0803e9ee7127f360219bf2a..c2ee26491d0109b5729160864ae395000e3fcbce 100644 (file)
@@ -2026,6 +2026,7 @@ void proto_register_icmp(void)
 void proto_reg_handoff_icmp(void)
 {
        dissector_handle_t icmp_handle;
+       capture_dissector_handle_t icmp_cap_handle;
 
        /*
         * Get handle for the IP dissector.
@@ -2034,7 +2035,8 @@ void proto_reg_handoff_icmp(void)
        icmp_handle = find_dissector("icmp");
 
        dissector_add_uint("ip.proto", IP_PROTO_ICMP, icmp_handle);
-       register_capture_dissector("ip.proto", IP_PROTO_ICMP, capture_icmp, proto_icmp);
+       icmp_cap_handle = create_capture_dissector_handle(capture_icmp, proto_icmp);
+       capture_dissector_add_uint("ip.proto", IP_PROTO_ICMP, icmp_cap_handle);
 }
 
 /*
index 82962741b7e31c4109826766ea5352737370691a..7d62eaf5ac65a1fcc204d6d3b284bcd5c2105ec6 100644 (file)
@@ -5982,8 +5982,11 @@ proto_register_icmpv6(void)
 void
 proto_reg_handoff_icmpv6(void)
 {
+    capture_dissector_handle_t icmpv6_cap_handle;
+
     dissector_add_uint("ip.proto", IP_PROTO_ICMPV6, icmpv6_handle);
-    register_capture_dissector("ip.proto", IP_PROTO_ICMPV6, capture_icmpv6, proto_icmpv6);
+    icmpv6_cap_handle = create_capture_dissector_handle(capture_icmpv6, proto_icmpv6);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_ICMPV6, icmpv6_cap_handle);
 
     /*
      * Get a handle for the IPv6 dissector.
index 0cc9f01f170ff34a2a2fc45603e400b2fcc1d194..cd42e877d7976217d0d357a4d5f1b062b361885d 100644 (file)
@@ -39,6 +39,9 @@ static dissector_handle_t wlancap_handle;
 static dissector_handle_t ieee80211_handle;
 static dissector_handle_t ieee80211_radio_handle;
 
+static capture_dissector_handle_t ieee80211_cap_handle;
+static capture_dissector_handle_t wlancap_cap_handle;
+
 static int proto_prism = -1;
 
 /* Prism radio header */
@@ -251,7 +254,7 @@ capture_prism(const guchar *pd, int offset, int len, capture_packet_info_t *cpin
   cookie = pntoh32(pd);
   if ((cookie == WLANCAP_MAGIC_COOKIE_V1) ||
       (cookie == WLANCAP_MAGIC_COOKIE_V2)) {
-    return capture_wlancap(pd, offset, len, cpinfo, pseudo_header);
+    return call_capture_dissector(wlancap_cap_handle, pd, offset, len, cpinfo, pseudo_header);
   }
 
   /* Prism header */
@@ -261,7 +264,7 @@ capture_prism(const guchar *pd, int offset, int len, capture_packet_info_t *cpin
   offset += PRISM_HEADER_LENGTH;
 
   /* 802.11 header follows */
-  return capture_ieee80211(pd, offset, len, cpinfo, pseudo_header);
+  return call_capture_dissector(ieee80211_cap_handle, pd, offset, len, cpinfo, pseudo_header);
 }
 
 static int
@@ -561,12 +564,18 @@ void proto_register_ieee80211_prism(void)
 
 void proto_reg_handoff_ieee80211_prism(void)
 {
+  capture_dissector_handle_t ieee80211_prism_cap_handle;
+
   dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_PRISM, prism_handle);
   ieee80211_handle = find_dissector_add_dependency("wlan", proto_prism);
   ieee80211_radio_handle = find_dissector_add_dependency("wlan_radio", proto_prism);
   wlancap_handle = find_dissector_add_dependency("wlancap", proto_prism);
 
-  register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_PRISM, capture_prism, proto_prism);
+  ieee80211_prism_cap_handle = create_capture_dissector_handle(capture_prism, proto_prism);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_PRISM, ieee80211_prism_cap_handle);
+
+  ieee80211_cap_handle = find_capture_dissector("ieee80211");
+  wlancap_cap_handle = find_capture_dissector("wlancap");
 }
 
 /*
index b55e14456e327ae0f6cc852a1b64c89d5b8226ae..a7b5ce4a8f87bcd95ac7e4b7b809594eed240d0b 100644 (file)
@@ -221,6 +221,9 @@ static expert_field ei_radiotap_present = EI_INIT;
 
 static dissector_handle_t ieee80211_radio_handle;
 
+static capture_dissector_handle_t ieee80211_cap_handle;
+static capture_dissector_handle_t ieee80211_datapad_cap_handle;
+
 static int radiotap_tap = -1;
 
 /* Settings */
@@ -628,9 +631,9 @@ capture_radiotap(const guchar * pd, int offset, int len, capture_packet_info_t *
 
        /* 802.11 header follows */
        if (rflags & IEEE80211_RADIOTAP_F_DATAPAD)
-               return capture_ieee80211_datapad(pd, offset + it_len, len, cpinfo, pseudo_header);
+               return call_capture_dissector(ieee80211_datapad_cap_handle, pd, offset + it_len, len, cpinfo, pseudo_header);
 
-       return capture_ieee80211(pd, offset + it_len, len, cpinfo, pseudo_header);
+       return call_capture_dissector(ieee80211_cap_handle, pd, offset + it_len, len, cpinfo, pseudo_header);
 }
 
 static int
@@ -2776,6 +2779,7 @@ void proto_register_radiotap(void)
 void proto_reg_handoff_radiotap(void)
 {
        dissector_handle_t radiotap_handle;
+       capture_dissector_handle_t radiotap_cap_handle;
 
        /* handle for 802.11+radio information dissector */
        ieee80211_radio_handle = find_dissector_add_dependency("wlan_radio", proto_radiotap);
@@ -2785,7 +2789,11 @@ 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);
+       radiotap_cap_handle = create_capture_dissector_handle(capture_radiotap, proto_radiotap);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_RADIOTAP, radiotap_cap_handle);
+
+       ieee80211_cap_handle = find_capture_dissector("ieee80211");
+       ieee80211_datapad_cap_handle = find_capture_dissector("ieee80211_datapad");
 }
 
 /*
index 56245b936689652bb3203a5fe0ac9af40edcaed6..04691c282dc9370464a4b9011ac39cd8687bdced 100644 (file)
@@ -71,6 +71,8 @@ static int hf_wlancap_padding = -1;
 static gint ett_wlancap = -1;
 
 static dissector_handle_t wlancap_handle;
+static capture_dissector_handle_t wlancap_cap_handle;
+static capture_dissector_handle_t ieee80211_cap_handle;
 
 gboolean
 capture_wlancap(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
@@ -88,7 +90,7 @@ capture_wlancap(const guchar *pd, int offset, int len, capture_packet_info_t *cp
   offset += length;
 
   /* 802.11 header follows */
-  return capture_ieee80211(pd, offset, len, cpinfo, pseudo_header);
+  return call_capture_dissector(ieee80211_cap_handle, pd, offset, len, cpinfo, pseudo_header);
 }
 
 /*
@@ -842,12 +844,16 @@ void proto_register_ieee80211_wlancap(void)
   dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_AVS,
                      wlancap_handle);
   proto_register_subtree_array(tree_array, array_length(tree_array));
+
+  wlancap_cap_handle = register_capture_dissector("wlancap", capture_wlancap, proto_wlancap);
 }
 
 void proto_reg_handoff_ieee80211_wlancap(void)
 {
   ieee80211_radio_handle = find_dissector_add_dependency("wlan_radio", proto_wlancap);
-  register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_AVS, capture_wlancap, proto_wlancap);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_AVS, wlancap_cap_handle);
+
+  ieee80211_cap_handle = find_capture_dissector("ieee80211");
 }
 
 /*
index ce1b3e32af35fbf23ba87f5113f2169e6e88cf8c..c6d14943c2c5340a2c93d4692c45c5c8e25805bf 100644 (file)
@@ -5047,6 +5047,9 @@ static dissector_handle_t llc_handle;
 static dissector_handle_t ipx_handle;
 static dissector_handle_t eth_withoutfcs_handle;
 
+static capture_dissector_handle_t llc_cap_handle;
+static capture_dissector_handle_t ipx_cap_handle;
+
 static int wlan_tap = -1;
 
 static const value_string access_network_type_vals[] = {
@@ -5615,12 +5618,12 @@ capture_ieee80211_common(const guchar * pd, int offset, int len,
         }
 #endif
         if ((pd[offset+hdr_length] == 0xff) && (pd[offset+hdr_length+1] == 0xff))
-          return capture_ipx (pd, offset+hdr_length, len, cpinfo, pseudo_header);
+          return call_capture_dissector (ipx_cap_handle, pd, offset+hdr_length, len, cpinfo, pseudo_header);
         else if ((pd[offset+hdr_length] == 0x00) && (pd[offset+hdr_length+1] == 0x00))
-          return capture_llc (pd, offset + hdr_length + 2, len, cpinfo, pseudo_header);
+          return call_capture_dissector (llc_cap_handle, pd, offset + hdr_length + 2, len, cpinfo, pseudo_header);
       }
       else {
-        return capture_llc (pd, offset + hdr_length, len, cpinfo, pseudo_header);
+        return call_capture_dissector (llc_cap_handle, pd, offset + hdr_length, len, cpinfo, pseudo_header);
       }
       break;
     }
@@ -27155,6 +27158,9 @@ proto_register_ieee80211(void)
   register_dissector("wlan_bsfc",               dissect_ieee80211_bsfc,               proto_wlan);
   register_dissector("wlan_noqos",              dissect_ieee80211_noqos,              proto_wlan);
 
+  register_capture_dissector("ieee80211", capture_ieee80211, proto_wlan);
+  register_capture_dissector("ieee80211_datapad", capture_ieee80211_datapad, proto_wlan);
+
   register_init_routine(wlan_defragment_init);
   register_cleanup_routine(wlan_defragment_cleanup);
   register_init_routine(wlan_retransmit_init);
@@ -27365,6 +27371,7 @@ proto_reg_handoff_ieee80211(void)
 {
   dissector_handle_t data_encap_handle, centrino_handle;
   dissector_handle_t wlan_rsna_eapol_wpa_key_handle, wlan_rsna_eapol_rsn_key_handle, wlan_withoutfcs_handle;
+  capture_dissector_handle_t ieee80211_cap_handle;
 
   /*
    * Get handles for the LLC, IPX and Ethernet  dissectors.
@@ -27373,15 +27380,19 @@ proto_reg_handoff_ieee80211(void)
   ipx_handle            = find_dissector_add_dependency("ipx", proto_wlan);
   eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_wlan);
 
+  llc_cap_handle = find_capture_dissector("llc");
+  ipx_cap_handle = find_capture_dissector("ipx");
+
   ieee80211_handle = find_dissector("wlan");
   dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11, ieee80211_handle);
 
   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_capture_dissector("ppi", 105 /* DLT_DLT_IEEE802_11 */, capture_ieee80211, proto_wlan);
+  ieee80211_cap_handle = find_capture_dissector("ieee80211");
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11, ieee80211_cap_handle);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_IEEE_802_11_WITH_RADIO, ieee80211_cap_handle);
+  capture_dissector_add_uint("ppi", 105 /* DLT_DLT_IEEE802_11 */, ieee80211_cap_handle);
 
   /* Register handoff to Aruba GRE */
   dissector_add_uint("gre.proto", GRE_ARUBA_8200, ieee80211_handle);
index a8128378f59716b28b85925ab303da30a23e6352..03425c3c3c997a9b22a1592e39a158e2ffdd6a57 100644 (file)
 extern "C" {
 #endif /* __cplusplus */
 
-extern
-gboolean capture_ieee80211 (const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-gboolean capture_ieee80211_datapad (const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
-extern
-gboolean capture_wlancap(const guchar *, int, int, capture_packet_info_t *cpinfo, 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);
 int dissect_wifi_p2p_public_action(packet_info *pinfo, proto_tree *tree,
index 921003072ec5cded3a5a70eecdc52bf118a12d76..258de04cb3e380a3cde7a28f9bb79ef295332174 100644 (file)
@@ -37,6 +37,9 @@ void proto_reg_handoff_ieee8021ah(void);
 
 static dissector_handle_t ethertype_handle;
 
+static capture_dissector_handle_t ipx_cap_handle;
+static capture_dissector_handle_t llc_cap_handle;
+
 void dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
                                proto_tree *tree, proto_tree *parent, int tree_index);
 
@@ -91,10 +94,10 @@ capture_ieee8021ah(const guchar *pd, int offset, int len, capture_packet_info_t
     if (encap_proto <= IEEE_802_3_MAX_LEN) {
         if ( pd[offset + IEEE8021AH_LEN] == 0xff
              && pd[offset + IEEE8021AH_LEN + 1] == 0xff ) {
-            return capture_ipx(pd, offset + IEEE8021AH_LEN, len, cpinfo, pseudo_header);
+            return call_capture_dissector(ipx_cap_handle, pd, offset + IEEE8021AH_LEN, len, cpinfo, pseudo_header);
         }
         else {
-            return capture_llc(pd, offset + IEEE8021AH_LEN, len, cpinfo, pseudo_header);
+            return call_capture_dissector(llc_cap_handle, pd, offset + IEEE8021AH_LEN, len, cpinfo, pseudo_header);
         }
     }
 
@@ -422,6 +425,7 @@ proto_reg_handoff_ieee8021ah(void)
     static gboolean           prefs_initialized = FALSE;
     static dissector_handle_t ieee8021ah_handle;
     static unsigned int       old_ieee8021ah_ethertype;
+    static capture_dissector_handle_t ieee8021ah_cap_handle;
 
     if (!prefs_initialized){
         dissector_handle_t ieee8021ad_handle;
@@ -432,8 +436,9 @@ proto_reg_handoff_ieee8021ah(void)
         dissector_add_uint("ethertype", ETHERTYPE_IEEE_802_1AD, ieee8021ad_handle);
         ethertype_handle = find_dissector_add_dependency("ethertype", proto_ieee8021ah);
         find_dissector_add_dependency("ethertype", proto_ieee8021ad);
-        register_capture_dissector("ethertype", ETHERTYPE_IEEE_802_1AD, capture_ieee8021ah, proto_ieee8021ah);
-        register_capture_dissector("ethertype", ETHERTYPE_IEEE_802_1AH, capture_ieee8021ah, proto_ieee8021ah);
+        ieee8021ah_cap_handle = create_capture_dissector_handle(capture_ieee8021ah, proto_ieee8021ah);
+        capture_dissector_add_uint("ethertype", ETHERTYPE_IEEE_802_1AD, ieee8021ah_cap_handle);
+        capture_dissector_add_uint("ethertype", ETHERTYPE_IEEE_802_1AH, ieee8021ah_cap_handle);
 
         prefs_initialized = TRUE;
     }
@@ -443,6 +448,9 @@ proto_reg_handoff_ieee8021ah(void)
 
     old_ieee8021ah_ethertype = ieee8021ah_ethertype;
     dissector_add_uint("ethertype", ieee8021ah_ethertype, ieee8021ah_handle);
+
+    ipx_cap_handle = find_capture_dissector("ipx");
+    llc_cap_handle = find_capture_dissector("llc");
 }
 
 /*
index aac6f96617c97b995d288d3e5e72cf0c2163cf89..c86fb9118a8f62b28a015f91825889acd44e9b07 100644 (file)
@@ -288,6 +288,7 @@ static heur_dissector_list_t heur_subdissector_list;
 static dissector_table_t ip_dissector_table;
 
 static dissector_handle_t ipv6_handle;
+static capture_dissector_handle_t ip_cap_handle;
 
 
 /* IP structs and definitions */
@@ -3127,6 +3128,8 @@ proto_register_ip(void)
   register_decode_as(&ip_da);
   register_conversation_table(proto_ip, TRUE, ip_conversation_packet, ip_hostlist_packet);
   register_conversation_filter("ip", "IPv4", ip_filter_valid, ip_build_filter);
+
+  ip_cap_handle = register_capture_dissector("ip", capture_ip, proto_ip);
 }
 
 void
@@ -3134,6 +3137,8 @@ proto_reg_handoff_ip(void)
 {
   dissector_handle_t ip_handle;
   dissector_handle_t ipv4_handle;
+  capture_dissector_handle_t clip_cap_handle;
+  int proto_clip;
 
   ip_handle = find_dissector("ip");
   ipv6_handle = find_dissector("ipv6");
@@ -3167,11 +3172,21 @@ proto_reg_handoff_ip(void)
   dissector_add_uint("vxlan.next_proto", VXLAN_IPV4, 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);
-  register_capture_dissector("ax25.pid", AX25_P_IP, capture_ip, proto_ip);
-  register_capture_dissector("enc", BSD_AF_INET, capture_ip, proto_ip);
-  register_capture_dissector("ppp_hdlc", PPP_IP, capture_ip, proto_ip);
-  register_capture_dissector("llc.dsap", SAP_IP, capture_ip, proto_ip);
+
+  capture_dissector_add_uint("ethertype", ETHERTYPE_IP, ip_cap_handle);
+  capture_dissector_add_uint("ax25.pid", AX25_P_IP, ip_cap_handle);
+  capture_dissector_add_uint("enc", BSD_AF_INET, ip_cap_handle);
+  capture_dissector_add_uint("ppp_hdlc", PPP_IP, ip_cap_handle);
+  capture_dissector_add_uint("llc.dsap", SAP_IP, ip_cap_handle);
+  capture_dissector_add_uint("null.bsd", BSD_AF_INET, ip_cap_handle);
+  capture_dissector_add_uint("fr.nlpid", NLPID_IP, ip_cap_handle);
+
+  /* Classic IP uses the same capture function, but wants its own
+     protocol associated with it.  To eliminate linking dependencies,
+     just add it here */
+  proto_clip = proto_get_id_by_filter_name( "clip" );
+  clip_cap_handle = register_capture_dissector("clip", capture_ip, proto_clip);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, clip_cap_handle);
 }
 
 /*
index 04ac8b07163766c72e57d3b0885f5786567ba8b8..91a77eea9ca4062a243ba97514c3d5a4c930cccf 100644 (file)
@@ -51,8 +51,6 @@ typedef struct _ws_ip
 #define IPDSFIELD_ECN_MASK      0x03
 #define IPDSFIELD_ECN(dsfield)  ((dsfield) & IPDSFIELD_ECN_MASK)
 
-gboolean capture_ip(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 gboolean ip_try_dissect(gboolean heur_first, guint nxt, tvbuff_t *tvb,
                         packet_info *pinfo, proto_tree *tree, ws_ip *iph);
 
index efceca2bdbc82e70496e27fe8f73127e3eb9302f..ccce5af33e6d89854dfee16fe2b85b1600b38cd4 100644 (file)
@@ -44,6 +44,7 @@ static int hf_ipfc_network_sa = -1;
 /* Initialize the subtree pointers */
 static gint ett_ipfc = -1;
 static dissector_handle_t llc_handle;
+static capture_dissector_handle_t llc_cap_handle;
 
 static gboolean
 capture_ipfc (const guchar *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
@@ -51,7 +52,7 @@ capture_ipfc (const guchar *pd, int offset _U_, int len, capture_packet_info_t *
   if (!BYTES_ARE_IN_FRAME(0, len, 16))
     return FALSE;
 
-  return capture_llc(pd, 16, len, cpinfo, pseudo_header);
+  return call_capture_dissector(llc_cap_handle, pd, 16, len, cpinfo, pseudo_header);
 }
 
 static int
@@ -122,13 +123,17 @@ void
 proto_reg_handoff_ipfc (void)
 {
     dissector_handle_t ipfc_handle;
+    capture_dissector_handle_t ipfc_cap_handle;
 
     ipfc_handle = create_dissector_handle (dissect_ipfc, proto_ipfc);
     dissector_add_uint("wtap_encap", WTAP_ENCAP_IP_OVER_FC, ipfc_handle);
 
     llc_handle = find_dissector_add_dependency("llc", proto_ipfc);
 
-    register_capture_dissector("wtap_encap", WTAP_ENCAP_IP_OVER_FC, capture_ipfc, proto_ipfc);
+    ipfc_cap_handle = create_capture_dissector_handle(capture_ipfc, proto_ipfc);
+    capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_IP_OVER_FC, ipfc_cap_handle);
+
+    llc_cap_handle = find_capture_dissector("llc");
 }
 
 /*
index 6b78e2ea037a144fa39415dd17aa764dd7205cec..0d13dc94768fa53322bcd039699f523e8bf4c257 100644 (file)
@@ -79,6 +79,7 @@ ADD: Additional generic (non-checked) ICV length of 128, 192 and 256.
 #include <epan/exported_pdu.h>
 #include <epan/proto_data.h>
 #include <epan/decode_as.h>
+#include <epan/capture_dissectors.h>
 
 /* If you want to be able to decrypt or Check Authentication of ESP packets you MUST define this : */
 #ifdef HAVE_LIBGCRYPT
@@ -2484,6 +2485,7 @@ void
 proto_reg_handoff_ipsec(void)
 {
   dissector_handle_t esp_handle, ah_handle, ipcomp_handle;
+  capture_dissector_handle_t ah_cap_handle;
 
   data_handle = find_dissector("data");
   ah_handle = find_dissector("ah");
@@ -2494,7 +2496,9 @@ proto_reg_handoff_ipsec(void)
   dissector_add_uint("ip.proto", IP_PROTO_IPCOMP, ipcomp_handle);
 
   ip_dissector_table = find_dissector_table("ip.proto");
-  register_capture_dissector("ip.proto", IP_PROTO_AH, capture_ah, proto_ah);
+
+  ah_cap_handle = create_capture_dissector_handle(capture_ah, proto_ah);
+  capture_dissector_add_uint("ip.proto", IP_PROTO_AH, ah_cap_handle);
 
   exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_3);
 }
index 3b93510feed72033ccec49251a85c65ac49b39b3..78b8533f980719640a817823ed1fea582af17b12 100644 (file)
@@ -3533,6 +3533,8 @@ proto_register_ipv6(void)
 
     register_conversation_table(proto_ipv6, TRUE, ipv6_conversation_packet, ipv6_hostlist_packet);
     register_conversation_filter("ipv6", "IPv6", ipv6_filter_valid, ipv6_build_filter);
+
+    register_capture_dissector("ipv6", capture_ipv6, proto_ipv6);
 }
 
 void
@@ -3543,6 +3545,8 @@ proto_reg_handoff_ipv6(void)
     dissector_handle_t ipv6_routing_handle;
     dissector_handle_t ipv6_fraghdr_handle;
     dissector_handle_t ipv6_dstopts_handle;
+    capture_dissector_handle_t ipv6_cap_handle;
+    capture_dissector_handle_t ipv6_ext_cap_handle;
 
     ipv6_handle = find_dissector("ipv6");
     dissector_add_uint("ethertype", ETHERTYPE_IPv6, ipv6_handle);
@@ -3582,12 +3586,23 @@ proto_reg_handoff_ipv6(void)
     dissector_add_uint("ip.proto", IP_PROTO_DSTOPTS, ipv6_dstopts_handle);
 
     ip_dissector_table = find_dissector_table("ip.proto");
-    register_capture_dissector("ethertype", ETHERTYPE_IPv6, capture_ipv6, proto_ipv6);
-    register_capture_dissector("enc", BSD_AF_INET6_BSD, capture_ipv6, proto_ipv6);
-    register_capture_dissector("ip.proto", IP_PROTO_HOPOPTS, capture_ipv6_exthdr, proto_ipv6_hopopts);
-    register_capture_dissector("ip.proto", IP_PROTO_ROUTING, capture_ipv6_exthdr, proto_ipv6_routing);
-    register_capture_dissector("ip.proto", IP_PROTO_FRAGMENT, capture_ipv6_exthdr, proto_ipv6_fraghdr);
-    register_capture_dissector("ip.proto", IP_PROTO_DSTOPTS, capture_ipv6_exthdr, proto_ipv6_dstopts);
+
+    ipv6_cap_handle = find_capture_dissector("ipv6");
+    capture_dissector_add_uint("ethertype", ETHERTYPE_IPv6, ipv6_cap_handle);
+    capture_dissector_add_uint("enc", BSD_AF_INET6_BSD, ipv6_cap_handle);
+    capture_dissector_add_uint("null.bsd", BSD_AF_INET6_BSD, ipv6_cap_handle);
+    capture_dissector_add_uint("null.bsd", BSD_AF_INET6_FREEBSD, ipv6_cap_handle);
+    capture_dissector_add_uint("null.bsd", BSD_AF_INET6_DARWIN, ipv6_cap_handle);
+    capture_dissector_add_uint("fr.nlpid", NLPID_IP6, ipv6_cap_handle);
+
+    ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_hopopts);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_HOPOPTS, ipv6_ext_cap_handle);
+    ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_routing);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_ROUTING, ipv6_ext_cap_handle);
+    ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_fraghdr);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_FRAGMENT, ipv6_ext_cap_handle);
+    ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_dstopts);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_DSTOPTS, ipv6_ext_cap_handle);
 }
 
 /*
index ce9338d671fa4d13dfe6b617c8e652487a199649..4e95ca75792bc65835a5ba7ef13738f97489cd36 100644 (file)
@@ -25,7 +25,6 @@
 #define __PACKET_IPV6_H_DEFINED__
 
 #include <epan/ipv6.h>
-#include <epan/capture_dissectors.h>
 #include "packet-ip.h"
 
 #ifdef __cplusplus
@@ -45,10 +44,6 @@ typedef struct {
 
 ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo);
 
-gboolean capture_ipv6(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
-gboolean capture_ipv6_exthdr(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 void ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph);
 
 #ifdef __cplusplus
index b5419394ad6c83ecc610ff1d045fd3bd077ddafc..da8f9d837ea30a402c1a783dc892f3f437dba221 100644 (file)
@@ -1584,6 +1584,8 @@ proto_register_ipx(void)
        ipx_tap=register_tap("ipx");
 
        register_conversation_table(proto_ipx, TRUE, ipx_conversation_packet, ipx_hostlist_packet);
+
+       register_capture_dissector("ipx", capture_ipx, proto_ipx);
 }
 
 void
@@ -1592,6 +1594,7 @@ proto_reg_handoff_ipx(void)
        dissector_handle_t ipx_handle, spx_handle;
        dissector_handle_t ipxsap_handle, ipxrip_handle;
        dissector_handle_t serialization_handle, ipxmsg_handle;
+       capture_dissector_handle_t ipx_cap_handle;
 
        ipx_handle = find_dissector("ipx");
        dissector_add_uint_with_preference("udp.port", UDP_PORT_IPX, ipx_handle);
@@ -1624,11 +1627,12 @@ 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);
-       register_capture_dissector("ppp_hdlc", PPP_IPX, capture_ipx, proto_ipx);
-       register_capture_dissector("sll.ltype", LINUX_SLL_P_802_3, capture_ipx, proto_ipx);
-       register_capture_dissector("llc.dsap", SAP_NETWARE1, capture_ipx, proto_ipx);
-       register_capture_dissector("llc.dsap", SAP_NETWARE2, capture_ipx, proto_ipx);
+       ipx_cap_handle = find_capture_dissector("ipx");
+       capture_dissector_add_uint("ethertype", ETHERTYPE_IPX, ipx_cap_handle);
+       capture_dissector_add_uint("ppp_hdlc", PPP_IPX, ipx_cap_handle);
+       capture_dissector_add_uint("sll.ltype", LINUX_SLL_P_802_3, ipx_cap_handle);
+       capture_dissector_add_uint("llc.dsap", SAP_NETWARE1, ipx_cap_handle);
+       capture_dissector_add_uint("llc.dsap", SAP_NETWARE2, ipx_cap_handle);
 }
 
 /*
index 9924f723077bf1c36cadca2f51b2e5b85d95af0a..0e533aa7e7f7a8c7176647e9af9bf956ab705cf2 100644 (file)
@@ -147,8 +147,6 @@ struct ipx_rip_packet
 extern value_string_ext ipx_socket_vals_ext;
 extern value_string_ext novell_server_vals_ext;
 
-gboolean capture_ipx(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 /*
  * Structure passed to SPX subdissectors, containing information from
  * the SPX header that might be useful to the subdissector.
index ecddd03cb057930a571f30935ad8b351f2abd5f9..068bc45e5d8fa8ea9ad3d2bf5145443894eb4253 100644 (file)
@@ -25,6 +25,7 @@
 #include <epan/packet.h>
 #include <epan/exceptions.h>
 #include <epan/show_exception.h>
+#include <epan/capture_dissectors.h>
 
 #include "packet-isl.h"
 #include "packet-eth.h"
@@ -87,6 +88,9 @@ static gint ett_isl_dst = -1;
 static dissector_handle_t eth_withfcs_handle;
 static dissector_handle_t tr_handle;
 
+static capture_dissector_handle_t eth_cap_handle;
+static capture_dissector_handle_t tr_cap_handle;
+
 gboolean
 capture_isl(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
 {
@@ -101,11 +105,11 @@ capture_isl(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo
 
   case TYPE_ETHER:
     offset += 14+12;    /* skip the header */
-    return capture_eth(pd, offset, len, cpinfo, pseudo_header);
+    return call_capture_dissector(eth_cap_handle, pd, offset, len, cpinfo, pseudo_header);
 
   case TYPE_TR:
     offset += 14+17;    /* skip the header */
-    return capture_tr(pd, offset, len, cpinfo, pseudo_header);
+    return call_capture_dissector(tr_cap_handle, pd, offset, len, cpinfo, pseudo_header);
     break;
   }
 
@@ -400,6 +404,8 @@ proto_register_isl(void)
   proto_isl = proto_register_protocol("Cisco ISL", "ISL", "isl");
   proto_register_field_array(proto_isl, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
+
+  register_capture_dissector("isl", capture_isl, proto_isl);
 }
 
 void
@@ -410,6 +416,9 @@ proto_reg_handoff_isl(void)
    */
   eth_withfcs_handle = find_dissector_add_dependency("eth_withfcs", proto_isl);
   tr_handle = find_dissector_add_dependency("tr", proto_isl);
+
+  eth_cap_handle = find_capture_dissector("eth");
+  tr_cap_handle = find_capture_dissector("tr");
 }
 
 /*
index ff5b4153597b8b4411b5d6056c024c43c17e2877..13c8e0b9a427b677f6f638ab1d4771552d0db21f 100644 (file)
@@ -22,8 +22,6 @@
 #ifndef __PACKET_ISL_H__
 #define __PACKET_ISL_H__
 
-gboolean capture_isl(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 void dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
     int fcs_len);
 
index 17a86b7565d7ba8a698a7d3acefbf8567ed25091..9556843c2a962fb4544325089a127958cd0748ed 100644 (file)
@@ -34,6 +34,7 @@
 #include <epan/bridged_pids.h>
 #include <epan/ppptypes.h>
 #include <epan/arcnet_pids.h>
+#include <epan/nlpid.h>
 #include "packet-fc.h"
 #include "packet-ip.h"
 #include "packet-ipx.h"
@@ -246,40 +247,6 @@ 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);
 }
 
-gboolean
-capture_llc(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, 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))
-               return FALSE;
-
-       is_snap = (pd[offset] == SAP_SNAP) && (pd[offset+1] == SAP_SNAP);
-       llc_header_len = 2;     /* DSAP + SSAP */
-
-       /*
-        * XXX - the page referred to in the comment above about the
-        * Command/Response bit also implies that LLC Type 2 always
-        * uses extended operation, so we don't need to determine
-        * whether it's basic or extended operation; is that the case?
-        */
-       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))
-               return FALSE;
-
-       if (!XDLC_IS_INFORMATION(control))
-               return FALSE;
-
-       if (is_snap)
-               return capture_snap(pd, offset+llc_header_len, len, cpinfo, pseudo_header);
-
-       /* non-SNAP */
-       return try_capture_dissector("llc.dsap", pd[offset], pd, offset + llc_header_len, len, cpinfo, pseudo_header);
-}
-
 gboolean
 capture_snap(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
 {
@@ -321,6 +288,40 @@ capture_snap(const guchar *pd, int offset, int len, capture_packet_info_t *cpinf
        return FALSE;
 }
 
+gboolean
+capture_llc(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, 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))
+               return FALSE;
+
+       is_snap = (pd[offset] == SAP_SNAP) && (pd[offset+1] == SAP_SNAP);
+       llc_header_len = 2;     /* DSAP + SSAP */
+
+       /*
+        * XXX - the page referred to in the comment above about the
+        * Command/Response bit also implies that LLC Type 2 always
+        * uses extended operation, so we don't need to determine
+        * whether it's basic or extended operation; is that the case?
+        */
+       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))
+               return FALSE;
+
+       if (!XDLC_IS_INFORMATION(control))
+               return FALSE;
+
+       if (is_snap)
+               return capture_snap(pd, offset+llc_header_len, len, cpinfo, pseudo_header);
+
+       /* non-SNAP */
+       return try_capture_dissector("llc.dsap", pd[offset], pd, offset + llc_header_len, len, cpinfo, pseudo_header);
+}
+
 /* Used only for U frames */
 static const xdlc_cf_items llc_cf_items = {
        NULL,
@@ -815,6 +816,8 @@ proto_register_llc(void)
        register_capture_dissector_table("llc.dsap", "LLC");
 
        register_dissector("llc", dissect_llc, proto_llc);
+
+       register_capture_dissector("llc", capture_llc, proto_llc);
 }
 
 void
@@ -856,6 +859,8 @@ void
 proto_reg_handoff_llc(void)
 {
        dissector_handle_t llc_handle;
+       capture_dissector_handle_t llc_cap_handle;
+       capture_dissector_handle_t llc_snap_handle;
 
        /*
         * Get handles for the BPDU, Ethernet, FDDI, Token Ring and
@@ -897,9 +902,14 @@ 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_capture_dissector("atm.aal5.type", TRAF_LLCMX, capture_llc, proto_llc);
-       register_capture_dissector("sll.ltype", LINUX_SLL_P_802_2, capture_llc, proto_llc);
+       llc_cap_handle = find_capture_dissector("llc");
+       capture_dissector_add_uint("ethertype", ETHERTYPE_JUMBO_LLC, llc_cap_handle);
+       capture_dissector_add_uint("atm.aal5.type", TRAF_LLCMX, llc_cap_handle);
+       capture_dissector_add_uint("sll.ltype", LINUX_SLL_P_802_2, llc_cap_handle);
+
+       llc_snap_handle = register_capture_dissector("llc_snap", capture_snap, proto_llc);
+       capture_dissector_add_uint("fr.nlpid", NLPID_SNAP, llc_snap_handle);
+
 
        /*
         * Register all the fields for PIDs for various OUIs.
index 24c7b9ba3c7b44049c3ad4ab072b5a2309b7dc7a..6986d6d4f738d1d7a56f9648a25c7e389e11ed8d 100644 (file)
 
 #include "ws_symbol_export.h"
 
-gboolean capture_llc(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 extern const value_string sap_vals[];
 
-gboolean capture_snap(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 void dissect_snap(tvbuff_t *, int, packet_info *, proto_tree *,
     proto_tree *, int, int, int, int, int);
 
index 5dc1b97ee4835b5138f22a3d364f44b27a0f0af3..42c3935b8f4b2c0bbe59cebc90b8ab3734f97948 100644 (file)
@@ -1483,11 +1483,12 @@ void
 proto_reg_handoff_netbios(void)
 {
        dissector_handle_t netbios_handle;
+       capture_dissector_handle_t netbios_cap_handle;
 
-       netbios_handle = create_dissector_handle(dissect_netbios,
-           proto_netbios);
+       netbios_handle = create_dissector_handle(dissect_netbios, proto_netbios);
        dissector_add_uint("llc.dsap", SAP_NETBIOS, netbios_handle);
-       register_capture_dissector("llc.dsap", SAP_NETBIOS, capture_netbios, proto_netbios);
+       netbios_cap_handle = create_capture_dissector_handle(capture_netbios, proto_netbios);
+       capture_dissector_add_uint("llc.dsap", SAP_NETBIOS, netbios_cap_handle);
 }
 
 
index 01bd72b2169943f676737b3fb43b5426df99d1a3..da53c33063e4e72361ff377bc897be8abfe2210c 100644 (file)
@@ -615,8 +615,11 @@ proto_register_netrom(void)
 void
 proto_reg_handoff_netrom(void)
 {
+       capture_dissector_handle_t netrom_cap_handle;
+
        dissector_add_uint( "ax25.pid", AX25_P_NETROM, create_dissector_handle( dissect_netrom, proto_netrom ) );
-       register_capture_dissector("ax25.pid", AX25_P_NETROM, capture_netrom, proto_netrom);
+       netrom_cap_handle = create_capture_dissector_handle(capture_netrom, proto_netrom);
+       capture_dissector_add_uint("ax25.pid", AX25_P_NETROM, netrom_cap_handle);
 
        ip_handle   = find_dissector_add_dependency( "ip", proto_netrom );
 }
index 448a2a653ae0298a5ecd3e513029c163e5f1ebd8..647acc04872ef742a540222efd183478ff7945cb 100644 (file)
@@ -63,6 +63,7 @@ static const value_string family_vals[] = {
 };
 
 static dissector_handle_t ppp_hdlc_handle;
+static capture_dissector_handle_t ppp_hdlc_cap_handle;
 
 static gboolean
 capture_null( const guchar *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_ )
@@ -258,7 +259,7 @@ capture_null( const guchar *pd, int offset _U_, int len, capture_packet_info_t *
     /*
      * Hand it to PPP.
      */
-    return capture_ppp_hdlc(pd, 0, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ppp_hdlc_cap_handle, pd, 0, len, cpinfo, pseudo_header);
   } else {
     /*
      * Treat it as a normal DLT_NULL header.
@@ -315,43 +316,8 @@ capture_null( const guchar *pd, int offset _U_, int len, capture_packet_info_t *
      */
     if (null_header > IEEE_802_3_MAX_LEN)
       return try_capture_dissector("ethertype", null_header, pd, 4, len, cpinfo, pseudo_header);
-    else {
-
-      switch (null_header) {
-
-      case BSD_AF_INET:
-        return capture_ip(pd, 4, len, cpinfo, pseudo_header);
-
-      case BSD_AF_INET6_BSD:
-      case BSD_AF_INET6_FREEBSD:
-      case BSD_AF_INET6_DARWIN:
-        return capture_ipv6(pd, 4, len, cpinfo, pseudo_header);
-      }
-    }
-  }
-
-  return FALSE;
-}
-
-static gboolean
-capture_loop( const guchar *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_ )
-{
-  guint32 loop_family;
-
-  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:
-    return capture_ip(pd, 4, len, cpinfo, pseudo_header);
-
-  case BSD_AF_INET6_BSD:
-  case BSD_AF_INET6_FREEBSD:
-  case BSD_AF_INET6_DARWIN:
-    return capture_ipv6(pd, 4, len, cpinfo, pseudo_header);
+    else
+      return try_capture_dissector("null.bsd", null_header, pd, 4, len, cpinfo, pseudo_header);
   }
 
   return FALSE;
@@ -526,12 +492,15 @@ proto_register_null(void)
   /* subdissector code */
   null_dissector_table = register_dissector_table("null.type",
                                                   "Null type", proto_null, FT_UINT32, BASE_DEC);
+
+  register_capture_dissector_table("null.bsd", "Null/Loopback BSD AF");
 }
 
 void
 proto_reg_handoff_null(void)
 {
   dissector_handle_t null_handle, loop_handle;
+  capture_dissector_handle_t null_cap_handle;
 
   /*
    * Get a handle for the PPP-in-HDLC-like-framing dissector and
@@ -547,8 +516,11 @@ 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);
+  null_cap_handle = create_capture_dissector_handle(capture_null, proto_null);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_NULL, null_cap_handle);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_LOOP, null_cap_handle);
+
+  ppp_hdlc_cap_handle = find_capture_dissector("ppp_hdlc");
 }
 
 /*
index 0791fbd2ceb8b747ba868088042208f29e1ab6ae..015cac392d9023364c5193e9cc21d5d11966ccb9 100644 (file)
@@ -3822,10 +3822,12 @@ void
 proto_reg_handoff_ospf(void)
 {
     dissector_handle_t ospf_handle;
+    capture_dissector_handle_t ospf_cap_handle;
 
     ospf_handle = create_dissector_handle(dissect_ospf, proto_ospf);
     dissector_add_uint("ip.proto", IP_PROTO_OSPF, ospf_handle);
-    register_capture_dissector("ip.proto", IP_PROTO_OSPF, capture_ospf, proto_ospf);
+    ospf_cap_handle = create_capture_dissector_handle(capture_ospf, proto_ospf);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_OSPF, ospf_cap_handle);
 }
 
 /*
index a886f8e9d179a8c7a3e5e557568be48b487ac5eb..195115cb0e02459efc35b1db464b54ac4182f837 100644 (file)
@@ -78,6 +78,7 @@ static gint ett_pktap = -1;
 static expert_field ei_pktap_hdrlen_too_short = EI_INIT;
 
 static dissector_handle_t pktap_handle;
+static capture_dissector_handle_t eth_cap_handle;
 
 /*
  * XXX - these are little-endian in the captures I've seen, but Apple
@@ -110,7 +111,7 @@ capture_pktap(const guchar *pd, int offset _U_, int len, capture_packet_info_t *
        switch (dlt) {
 
        case 1: /* DLT_EN10MB */
-               return capture_eth(pd, hdrlen, len, cpinfo, pseudo_header);
+               return call_capture_dissector(eth_cap_handle, pd, hdrlen, len, cpinfo, pseudo_header);
 
        }
 
@@ -274,6 +275,8 @@ proto_register_pktap(void)
 void
 proto_reg_handoff_pktap(void)
 {
+       capture_dissector_handle_t pktap_cap_handle;
+
        dissector_add_uint("wtap_encap", WTAP_ENCAP_PKTAP, pktap_handle);
 
        pcap_pktdata_handle = find_dissector_add_dependency("pcap_pktdata", proto_pktap);
@@ -282,8 +285,11 @@ proto_reg_handoff_pktap(void)
                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);
+       pktap_cap_handle = create_capture_dissector_handle(capture_pktap, proto_pktap);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_PKTAP, pktap_cap_handle);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_USER2, pktap_cap_handle);
+
+       eth_cap_handle = find_capture_dissector("eth");
 }
 
 /*
index f228199de205453fdfd342b07d2a714aa23a357a..d819a23c4b3e8f073fbb63ea991380d36cf8cd48 100644 (file)
@@ -1499,6 +1499,8 @@ proto_register_ppi(void)
 void
 proto_reg_handoff_ppi(void)
 {
+    capture_dissector_handle_t ppi_cap_handle;
+
     ieee80211_radio_handle = find_dissector_add_dependency("wlan_radio", proto_ppi);
     pcap_pktdata_handle = find_dissector_add_dependency("pcap_pktdata", proto_ppi);
     ppi_gps_handle = find_dissector_add_dependency("ppi_gps", proto_ppi);
@@ -1508,7 +1510,8 @@ proto_reg_handoff_ppi(void)
     ppi_fnet_handle = find_dissector_add_dependency("ppi_fnet", proto_ppi);
 
     dissector_add_uint("wtap_encap", WTAP_ENCAP_PPI, ppi_handle);
-    register_capture_dissector("wtap_encap", WTAP_ENCAP_PPI, capture_ppi, proto_ppi);
+    ppi_cap_handle = create_capture_dissector_handle(capture_ppi, proto_ppi);
+    capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_PPI, ppi_cap_handle);
 }
 
 /*
index 9a5333bc98a0bc8d09096a08f797d3427515d0f7..ef421d3dbb61e70359e41ebf04c22fb4e10de00f 100644 (file)
@@ -450,6 +450,8 @@ static dissector_handle_t chdlc_handle;
 static dissector_handle_t eth_withfcs_handle;
 static dissector_handle_t eth_withoutfcs_handle;
 
+static capture_dissector_handle_t chdlc_cap_handle;
+
 static const value_string ppp_direction_vals[] = {
     {P2P_DIR_RECV, "DCE->DTE"},
     {P2P_DIR_SENT, "DTE->DCE"},
@@ -1941,7 +1943,7 @@ capture_ppp_hdlc(const guchar *pd, int offset, int len, capture_packet_info_t *c
         return FALSE;
 
     if (pd[0] == CHDLC_ADDR_UNICAST || pd[0] == CHDLC_ADDR_MULTICAST)
-        return capture_chdlc(pd, offset, len, cpinfo, pseudo_header);
+        return call_capture_dissector(chdlc_cap_handle, pd, offset, len, cpinfo, pseudo_header);
 
     if (!BYTES_ARE_IN_FRAME(offset, len, 4))
         return FALSE;
@@ -5595,12 +5597,14 @@ proto_register_ppp_raw_hdlc(void)
     proto_register_field_array(proto_ppp_hdlc, hf, array_length(hf));
 
     register_capture_dissector_table("ppp_hdlc", "PPP-HDLC");
+    register_capture_dissector("ppp_hdlc", capture_ppp_hdlc, proto_ppp_hdlc);
 }
 
 void
 proto_reg_handoff_ppp_raw_hdlc(void)
 {
     dissector_handle_t ppp_raw_hdlc_handle;
+    capture_dissector_handle_t ppp_hdlc_cap_handle;
 
     ppp_raw_hdlc_handle = create_dissector_handle(dissect_ppp_raw_hdlc, proto_ppp);
 
@@ -5608,8 +5612,13 @@ 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);
-    register_capture_dissector("sll.ltype", LINUX_SLL_P_PPPHDLC, capture_ppp_hdlc, proto_ppp_hdlc);
+
+    ppp_hdlc_cap_handle = find_capture_dissector("ppp_hdlc");
+    capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_PPP, ppp_hdlc_cap_handle);
+    capture_dissector_add_uint("sll.ltype", LINUX_SLL_P_PPPHDLC, ppp_hdlc_cap_handle);
+    capture_dissector_add_uint("fr.nlpid", NLPID_PPP, ppp_hdlc_cap_handle);
+
+    chdlc_cap_handle = find_capture_dissector("chdlc");
 }
 
 /*
index e8a4090e19de17416239067808636c547bbc99cb..33dfadf864b50fcd7a1e3501ca0cb7bcdd68c5e7 100644 (file)
@@ -25,9 +25,6 @@
 #include <epan/params.h>
 #include "ws_symbol_export.h"
 
-extern
-gboolean capture_ppp_hdlc(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_);
-
 tvbuff_t *decode_fcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *fh_tree, int fcs_decode, int proto_offset);
 
 /*
index 08b5c7f109f36cc409a2a171508354241112ebd1..0cbca32f7b6b4e3cc8864bb0d11df2df70617333 100644 (file)
@@ -43,6 +43,10 @@ static dissector_handle_t ip_handle;
 static dissector_handle_t ipv6_handle;
 static dissector_handle_t ppp_hdlc_handle;
 
+static capture_dissector_handle_t ip_cap_handle;
+static capture_dissector_handle_t ipv6_cap_handle;
+static capture_dissector_handle_t ppp_hdlc_cap_handle;
+
 static gboolean
 capture_raw(const guchar *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
 {
@@ -55,21 +59,21 @@ capture_raw(const guchar *pd, int offset _U_, int len, capture_packet_info_t *cp
    * 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) {
-    return capture_ppp_hdlc(pd, 0, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ppp_hdlc_cap_handle, pd, 0, len, cpinfo, 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) {
-    return capture_ppp_hdlc(pd, 6, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ppp_hdlc_cap_handle, pd, 6, len, cpinfo, 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) {
-    return capture_ppp_hdlc(pd, 1, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ppp_hdlc_cap_handle, pd, 1, len, cpinfo, 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) {
-    return capture_ip(pd, 10, len, cpinfo, pseudo_header);
+    return call_capture_dissector(ip_cap_handle, pd, 10, len, cpinfo, pseudo_header);
   }
   else {
     /*
@@ -80,12 +84,12 @@ capture_raw(const guchar *pd, int offset _U_, int len, capture_packet_info_t *cp
 
       case 0x40:
         /* IPv4 */
-        return capture_ip(pd, 0, len, cpinfo, pseudo_header);
+        return call_capture_dissector(ip_cap_handle, pd, 0, len, cpinfo, pseudo_header);
 
 #if 0
       case 0x60:
         /* IPv6 */
-        return capture_ipv6(pd, 0, len, cpinfo, pseudo_header);
+        return call_capture_dissector(ipv6_cap_handle, pd, 0, len, cpinfo, pseudo_header);
 #endif
       }
     }
@@ -179,6 +183,8 @@ proto_register_raw(void)
 void
 proto_reg_handoff_raw(void)
 {
+  capture_dissector_handle_t raw_cap_handle;
+
   /*
    * Get handles for the IP, IPv6, undissected-data, and
    * PPP-in-HDLC-like-framing dissectors.
@@ -187,7 +193,12 @@ proto_reg_handoff_raw(void)
   ipv6_handle = find_dissector_add_dependency("ipv6", proto_raw);
   ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", 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);
+  raw_cap_handle = create_capture_dissector_handle(capture_raw, proto_raw);
+  capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP, raw_cap_handle);
+
+  ip_cap_handle = find_capture_dissector("ip");
+  ipv6_cap_handle = find_capture_dissector("ipv6");
+  ppp_hdlc_cap_handle = find_capture_dissector("ppp_hdlc");
 }
 
 /*
index 22af4ca75b93a00b2251cecb2980ea8183b025ed..9d129185e286f58fca7891d1328fb7787f4cc808 100644 (file)
@@ -5117,12 +5117,14 @@ void
 proto_reg_handoff_sctp(void)
 {
   dissector_handle_t sctp_handle;
+  capture_dissector_handle_t sctp_cap_handle;
 
   sctp_handle = find_dissector("sctp");
   dissector_add_uint("wtap_encap", WTAP_ENCAP_SCTP, sctp_handle);
   dissector_add_uint("ip.proto", IP_PROTO_SCTP, sctp_handle);
   dissector_add_uint_with_preference("udp.port", UDP_TUNNELING_PORT, sctp_handle);
-  register_capture_dissector("ip.proto", IP_PROTO_SCTP, capture_sctp, proto_sctp);
+  sctp_cap_handle = create_capture_dissector_handle(capture_sctp, proto_sctp);
+  capture_dissector_add_uint("ip.proto", IP_PROTO_SCTP, sctp_cap_handle);
 }
 
 /*
index 678012eb6d36841a20efa601021ff0164407d12f..14b9e343f50718094096f7351a1638e435e5899d 100644 (file)
@@ -892,8 +892,6 @@ proto_reg_handoff_shim6(void)
 
     shim6_handle = create_dissector_handle(dissect_shim6, proto_shim6);
     dissector_add_uint("ip.proto", IP_PROTO_SHIM6, shim6_handle);
-
-    register_capture_dissector("ip.proto", IP_PROTO_SHIM6, capture_ipv6_exthdr, proto_shim6);
 }
 
 /*
index 6b06ef31e72241c2939c9ea923c5fdb1e5b1e857..b678b5609157adc548a7955f85fc0710d39c7ef0 100644 (file)
@@ -359,6 +359,8 @@ proto_register_sll(void)
 void
 proto_reg_handoff_sll(void)
 {
+       capture_dissector_handle_t sll_cap_handle;
+
        /*
         * Get handles for the IPX and LLC dissectors.
         */
@@ -367,7 +369,8 @@ proto_reg_handoff_sll(void)
        netlink_handle = find_dissector_add_dependency("netlink", proto_sll);
 
        dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_handle);
-       register_capture_dissector("wtap_encap", WTAP_ENCAP_SLL, capture_sll, hfi_sll->id);
+       sll_cap_handle = create_capture_dissector_handle(capture_sll, proto_sll);
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_cap_handle);
 }
 
 /*
index 0683a88408007b899d5d6ce4d635afdc58593272..8a0e711f9eccd014879b6e14b1d45938ec24e1f0 100644 (file)
@@ -7307,6 +7307,7 @@ void
 proto_reg_handoff_tcp(void)
 {
     dissector_handle_t tcp_handle;
+    capture_dissector_handle_t tcp_cap_handle;
 
     tcp_handle = find_dissector("tcp");
     dissector_add_uint("ip.proto", IP_PROTO_TCP, tcp_handle);
@@ -7315,7 +7316,8 @@ proto_reg_handoff_tcp(void)
     tcp_tap = register_tap("tcp");
     tcp_follow_tap = register_tap("tcp_follow");
 
-    register_capture_dissector("ip.proto", IP_PROTO_TCP, capture_tcp, proto_tcp);
+    tcp_cap_handle = create_capture_dissector_handle(capture_tcp, proto_tcp);
+    capture_dissector_add_uint("ip.proto", IP_PROTO_TCP, tcp_cap_handle);
 
     mptcp_tap = register_tap("mptcp");
     exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_4);
index 6946ec506c7c71fccec5bd777a76610b219947fb..91883aad25be63dc0013af11a870d4a09057d282 100644 (file)
@@ -129,6 +129,8 @@ static const value_string direction_vals[] = {
 static dissector_handle_t trmac_handle;
 static dissector_handle_t llc_handle;
 
+static capture_dissector_handle_t llc_cap_handle;
+
 static const char* tr_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
 {
        if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_ETHER))
@@ -359,7 +361,7 @@ capture_tr(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo,
        /* The package is either MAC (0) or LLC (1)*/
        switch (frame_type) {
                case 1:
-                       return capture_llc(pd, offset, len, cpinfo, pseudo_header);
+                       return call_capture_dissector(llc_cap_handle, pd, offset, len, cpinfo, pseudo_header);
        }
 
        return FALSE;
@@ -794,12 +796,15 @@ proto_register_tr(void)
        tr_tap=register_tap("tr");
 
        register_conversation_table(proto_tr, TRUE, tr_conversation_packet, tr_hostlist_packet);
+
+       register_capture_dissector("tr", capture_tr, proto_tr);
 }
 
 void
 proto_reg_handoff_tr(void)
 {
        dissector_handle_t tr_handle;
+       capture_dissector_handle_t tr_cap_handle;
 
        /*
         * Get handles for the TR MAC and LLC dissectors.
@@ -811,9 +816,12 @@ proto_reg_handoff_tr(void)
        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);
-       register_capture_dissector("atm_lane", TRAF_ST_LANE_802_5, capture_tr, proto_tr);
-       register_capture_dissector("atm_lane", TRAF_ST_LANE_802_5_MC, capture_tr, proto_tr);
+       tr_cap_handle = find_capture_dissector("tr");
+       capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_TOKEN_RING, tr_cap_handle);
+       capture_dissector_add_uint("atm_lane", TRAF_ST_LANE_802_5, tr_cap_handle);
+       capture_dissector_add_uint("atm_lane", TRAF_ST_LANE_802_5_MC, tr_cap_handle);
+
+       llc_cap_handle = find_capture_dissector("llc");
 }
 
 /*
index 2d4ae09bdcfa850a27ab363413caaeb92aef4400..756a19a4e43bae4fbcd4ec88d7acf46341afc0da 100644 (file)
@@ -31,7 +31,4 @@ typedef struct _tr_hdr {
        address src;
 } tr_hdr;
 
-extern
-gboolean capture_tr(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
-
 #endif
index e3dee309abf1d62c96fef0a4c33add5aaebba2cd..c55948839027dbaf43986be132a83420dfaf60e3 100644 (file)
@@ -1267,11 +1267,15 @@ proto_register_udp(void)
 void
 proto_reg_handoff_udp(void)
 {
+  capture_dissector_handle_t udp_cap_handle;
+
   dissector_add_uint("ip.proto", IP_PROTO_UDP, udp_handle);
   dissector_add_uint("ip.proto", IP_PROTO_UDPLITE, udplite_handle);
 
-  register_capture_dissector("ip.proto", IP_PROTO_UDP, capture_udp, hfi_udp->id);
-  register_capture_dissector("ip.proto", IP_PROTO_UDPLITE, capture_udp, hfi_udplite->id);
+  udp_cap_handle = create_capture_dissector_handle(capture_udp, hfi_udp->id);
+  capture_dissector_add_uint("ip.proto", IP_PROTO_UDP, udp_cap_handle);
+  udp_cap_handle = create_capture_dissector_handle(capture_udp, hfi_udplite->id);
+  capture_dissector_add_uint("ip.proto", IP_PROTO_UDPLITE, udp_cap_handle);
 
   udp_tap = register_tap("udp");
   udp_follow_tap = register_tap("udp_follow");
index c2e1c317abaa8f277dc2a7dd91ffd74dc881c1e1..f8f5300fae9cf03f005a9e4e6892f37a352cfeaf 100644 (file)
@@ -2042,16 +2042,20 @@ void
 proto_reg_handoff_vines_icp(void)
 {
        dissector_handle_t vines_icp_handle;
+       capture_dissector_handle_t vines_echo_cap_handle;
+       capture_dissector_handle_t vines_ip_cap_handle;
 
-       vines_icp_handle = create_dissector_handle(dissect_vines_icp,
-           proto_vines_icp);
+       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);
-       register_capture_dissector("ppp_hdlc", PPP_VINES, capture_vines, proto_vines_echo);
-       register_capture_dissector("ip.proto", PPP_VINES, capture_vines, proto_vines_echo);
-       register_capture_dissector("llc.dsap", SAP_VINES1, capture_vines, proto_vines_echo);
-       register_capture_dissector("llc.dsap", SAP_VINES2, capture_vines, proto_vines_echo);
+
+       vines_ip_cap_handle = create_capture_dissector_handle(capture_vines, proto_vines_ip);
+       capture_dissector_add_uint("ethertype", ETHERTYPE_VINES_IP, vines_ip_cap_handle);
+       vines_echo_cap_handle = create_capture_dissector_handle(capture_vines, proto_vines_echo);
+       capture_dissector_add_uint("ethertype", ETHERTYPE_VINES_ECHO, vines_echo_cap_handle);
+       capture_dissector_add_uint("ppp_hdlc", PPP_VINES, vines_echo_cap_handle);
+       capture_dissector_add_uint("ip.proto", PPP_VINES, vines_echo_cap_handle);
+       capture_dissector_add_uint("llc.dsap", SAP_VINES1, vines_echo_cap_handle);
+       capture_dissector_add_uint("llc.dsap", SAP_VINES2, vines_echo_cap_handle);
 }
 
 /*
index d12a74c341892d005527a7c7800e1b7ac13cb1a8..ff9c0209f4fbf221a4a5d7476da45a823964a998 100644 (file)
@@ -47,6 +47,9 @@ static gboolean vlan_summary_in_tree = TRUE;
 static dissector_handle_t vlan_handle;
 static dissector_handle_t ethertype_handle;
 
+static capture_dissector_handle_t llc_cap_handle;
+static capture_dissector_handle_t ipx_cap_handle;
+
 static header_field_info *hfi_vlan = NULL;
 
 #define VLAN_HFI_INIT HFI_INIT(proto_vlan)
@@ -112,9 +115,9 @@ capture_vlan(const guchar *pd, int offset, int len, capture_packet_info_t *cpinf
   encap_proto = pntoh16( &pd[offset+2] );
   if ( encap_proto <= IEEE_802_3_MAX_LEN) {
     if ( pd[offset+4] == 0xff && pd[offset+5] == 0xff ) {
-      return capture_ipx(pd,offset+4,len, cpinfo, pseudo_header);
+      return call_capture_dissector(ipx_cap_handle, pd,offset+4,len, cpinfo, pseudo_header);
     } else {
-      return capture_llc(pd,offset+4,len, cpinfo, pseudo_header);
+      return call_capture_dissector(llc_cap_handle, pd,offset+4,len, cpinfo, pseudo_header);
     }
   }
 
@@ -273,11 +276,13 @@ proto_reg_handoff_vlan(void)
 {
   static gboolean prefs_initialized = FALSE;
   static unsigned int old_q_in_q_ethertype;
+  capture_dissector_handle_t vlan_cap_handle;
 
   if (!prefs_initialized)
   {
     dissector_add_uint("ethertype", ETHERTYPE_VLAN, vlan_handle);
-    register_capture_dissector("ethertype", ETHERTYPE_VLAN, capture_vlan, hfi_vlan->id);
+    vlan_cap_handle = create_capture_dissector_handle(capture_vlan, hfi_vlan->id);
+    capture_dissector_add_uint("ethertype", ETHERTYPE_VLAN, vlan_cap_handle);
 
     prefs_initialized = TRUE;
   }
@@ -290,6 +295,9 @@ proto_reg_handoff_vlan(void)
   ethertype_handle = find_dissector_add_dependency("ethertype", hfi_vlan->id);
 
   dissector_add_uint("ethertype", q_in_q_ethertype, vlan_handle);
+
+  llc_cap_handle = find_capture_dissector("llc");
+  ipx_cap_handle = find_capture_dissector("ipx");
 }
 
 /*