Add IPv6 heuristic.
[metze/wireshark/wip.git] / epan / packet.h
index 7222994428ac9d76b5136a1e7bf892631d44a757..d7c25154060b3da155f1b744fa74fa742f83b306 100644 (file)
@@ -113,7 +113,7 @@ typedef void (*dissector_t)(tvbuff_t *, packet_info *, proto_tree *);
  *     we need more data (e.g., from subsequent TCP segments) to
  *     dissect the entire PDU.
  */
-typedef int (*new_dissector_t)(tvbuff_t *, packet_info *, proto_tree *);
+typedef int (*new_dissector_t)(tvbuff_t *, packet_info *, proto_tree *, void *);
 
 /** Type of a heuristic dissector, used in heur_dissector_add().
  *
@@ -123,7 +123,7 @@ typedef int (*new_dissector_t)(tvbuff_t *, packet_info *, proto_tree *);
  * @return TRUE if the packet was recognized by the sub-dissector (stop dissection here)
  */
 typedef gboolean (*heur_dissector_t)(tvbuff_t *tvb, packet_info *pinfo,
-       proto_tree *tree);
+       proto_tree *tree, void *);
 
 typedef void (*DATFunc) (const gchar *table_name, ftenum_t selector_type,
     gpointer key, gpointer value, gpointer user_data);
@@ -149,7 +149,7 @@ extern void dissector_all_tables_foreach_changed (DATFunc func,
 extern void dissector_table_foreach_handle(const char *name, DATFunc_handle func,
     gpointer user_data);
 extern void dissector_all_tables_foreach_table (DATFunc_table func,
-    gpointer user_data);
+    gpointer user_data, GCompareFunc compare_key_func);
 
 /* a protocol uses the function to register a sub-dissector table */
 extern dissector_table_t register_dissector_table(const char *name,
@@ -216,11 +216,11 @@ extern gboolean dissector_try_uint(dissector_table_t sub_dissectors,
    call the dissector with the arguments supplied, and return TRUE,
    otherwise return FALSE. */
 extern gboolean dissector_try_uint_new(dissector_table_t sub_dissectors,
-       const guint32 uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name);
+       const guint32 uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name, void *data);
 
 /* For old code that hasn't yet been changed. */
 #define dissector_try_port_new(sub_dissectors, uint_val, tvb, pinfo, tree, add_proto_name) \
-       dissector_try_uint_new(sub_dissectors, uint_val, tvb, pinfo, tree, add_proto_name)
+       dissector_try_uint_new(sub_dissectors, uint_val, tvb, pinfo, tree, add_proto_name, NULL)
 
 /* Look for a given value in a given uint dissector table and, if found,
    return the dissector handle for that value. */
@@ -273,6 +273,7 @@ typedef GSList *heur_dissector_list_t;
 typedef struct {
        heur_dissector_t dissector;
        protocol_t *protocol;
+       gboolean enabled;
 } heur_dtbl_entry_t;
 
 /** A protocol uses this function to register a heuristic sub-dissector list.
@@ -295,10 +296,11 @@ extern void dissector_all_heur_tables_foreach_table (DATFunc_heur_table func,
  * @param tvb the tv_buff with the (remaining) packet data
  * @param pinfo the packet info of this packet (additional info)
  * @param tree the protocol tree to be build or NULL
+ * @param data parameter to pass to subdissector
  * @return TRUE if the packet was recognized by the sub-dissector (stop dissection here)
  */
 extern gboolean dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
-    tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
+    tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data);
 
 /** Add a sub-dissector to a heuristic dissector list.
  *  Call this in the proto_handoff function of the sub-dissector.
@@ -319,6 +321,16 @@ extern void heur_dissector_add(const char *name, heur_dissector_t dissector,
  */
 extern void heur_dissector_delete(const char *name, heur_dissector_t dissector, const int proto);
 
+/** Enable/Disable a sub-dissector in a heuristic dissector list
+ *  Call this in the prefs_reinit function of the sub-dissector.
+ *
+ * @param name the name of the "parent" protocol, e.g. "tcp"
+ * @param dissector the sub-dissector to be disabled/enabled
+ * @param proto the protocol id of the sub-dissector
+ * @param TRUE/FALSE to enable/disable the sub-dissector
+ */
+extern void heur_dissector_set_enabled(const char *name, heur_dissector_t dissector, const int proto, const gboolean enabled);
+
 /* Register a dissector. */
 extern void register_dissector(const char *name, dissector_t dissector,
     const int proto);
@@ -344,17 +356,20 @@ extern dissector_handle_t new_create_dissector_handle(new_dissector_t dissector,
     const int proto);
 
 /* Call a dissector through a handle and if no dissector was found
- * pass if over to the "data" dissector instead.
+ * pass it over to the "data" dissector instead.
  *
  *   @param handle The dissector to call.
  *   @param  tvb The buffer to dissect.
  *   @param  pinfo Packet Info.
  *   @param  tree The protocol tree.
+ *   @param  data parameter to pass to dissector
  *   @return  If the protocol for that handle isn't enabled call the data
  *   dissector. Otherwise, if the handle refers to a new-style
  *   dissector, call the dissector and return its return value, otherwise call
  *   it and return the length of the tvbuff pointed to by the argument.
  */
+extern int call_dissector_with_data(dissector_handle_t handle, tvbuff_t *tvb,
+    packet_info *pinfo, proto_tree *tree, void *data);
 extern int call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
     packet_info *pinfo, proto_tree *tree);
 
@@ -365,13 +380,14 @@ extern int call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
  *   @param  tvb The buffer to dissect.
  *   @param  pinfo Packet Info.
  *   @param  tree The protocol tree.
+ *   @param  data parameter to pass to dissector
  *   @return  If the protocol for that handle isn't enabled, return 0 without
  *   calling the dissector. Otherwise, if the handle refers to a new-style
  *   dissector, call the dissector and return its return value, otherwise call
  *   it and return the length of the tvbuff pointed to by the argument.
  */
 extern int call_dissector_only(dissector_handle_t handle, tvbuff_t *tvb,
-    packet_info *pinfo, proto_tree *tree);
+    packet_info *pinfo, proto_tree *tree, void *data);
 
 /* Do all one-time initialization. */
 extern void dissect_init(void);
@@ -436,6 +452,14 @@ extern const char* get_data_source_name(data_source *src);
  */
 extern void free_data_sources(packet_info *pinfo);
 
+/* Mark another frame as depended upon by the current frame.
+ *
+ * This information is used to ensure that the dependend-upon frame is saved
+ * if the user does a File->Save-As of only the Displayed packets and the
+ * current frame passed the display filter.
+ */
+extern void mark_frame_as_depended_upon(packet_info *pinfo, guint32 frame_num);
+
 /*
  * Dissectors should never modify the packet data.
  */
@@ -456,6 +480,11 @@ extern void ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_ethertype,
  */
 extern void dissector_dump_decodes(void);
 
+/*
+ * For each heuristic dissector table, dump list of dissectors (filter_names) for that table
+ */
+extern void dissector_dump_heur_decodes(void);
+
 /*
  * post dissectors are to be called by packet-frame.c after every other
  * dissector has been called.