diff options
Diffstat (limited to 'epan/packet.h')
-rw-r--r-- | epan/packet.h | 101 |
1 files changed, 81 insertions, 20 deletions
diff --git a/epan/packet.h b/epan/packet.h index 6cf5e975a3..0fc32cb6db 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -1,4 +1,4 @@ -/* packet.h +/** @file * Definitions for packet disassembly structures and routines * * Wireshark - Network traffic analyzer @@ -10,6 +10,7 @@ #ifndef __PACKET_H__ #define __PACKET_H__ +#include <wireshark.h> #include <wiretap/wtap_opttypes.h> #include "proto.h" @@ -22,8 +23,6 @@ #include "guid-utils.h" #include "tfs.h" #include "unit_strings.h" -#include "ws_symbol_export.h" -#include "wsutil/glib-compat.h" #ifdef __cplusplus extern "C" { @@ -48,6 +47,12 @@ struct epan_range; ((guint)(offset) + (guint)(len) > (guint)(offset) && \ (guint)(offset) + (guint)(len) <= (guint)(captured_len)) +/* 0 is case insenstive for backwards compatibility with tables that + * used FALSE or BASE_NONE for case sensitive, which was the default. + */ +#define STRING_CASE_SENSITIVE 0 +#define STRING_CASE_INSENSITIVE 1 + extern void packet_init(void); extern void packet_cache_proto_handles(void); extern void packet_cleanup(void); @@ -167,9 +172,9 @@ WS_DLL_PUBLIC void dissector_all_tables_foreach_table (DATFunc_table func, /* a protocol uses the function to register a sub-dissector table * - * 'param' is the display base for integer tables, and TRUE/FALSE for - * string tables (true indicating case-insensitive, false indicating - * case-sensitive) + * 'param' is the display base for integer tables, STRING_CASE_SENSITIVE + * or STRING_CASE_INSENSITIVE for string tables, and ignored for other + * table types. */ WS_DLL_PUBLIC dissector_table_t register_dissector_table(const char *name, const char *ui_name, const int proto, const ftenum_t type, const int param); @@ -179,7 +184,8 @@ WS_DLL_PUBLIC dissector_table_t register_dissector_table(const char *name, * to store subdissectors. */ WS_DLL_PUBLIC dissector_table_t register_custom_dissector_table(const char *name, - const char *ui_name, const int proto, GHashFunc hash_func, GEqualFunc key_equal_func); + const char *ui_name, const int proto, GHashFunc hash_func, GEqualFunc key_equal_func, + GDestroyNotify key_destroy_func); /** Register a dissector table alias. * This is for dissectors whose original name has changed, e.g. SSL to TLS. @@ -246,6 +252,13 @@ WS_DLL_PUBLIC void dissector_change_uint(const char *abbrev, const guint32 patte /* Reset an entry in a uint dissector table to its initial value. */ WS_DLL_PUBLIC void dissector_reset_uint(const char *name, const guint32 pattern); +/* Return TRUE if an entry in a uint dissector table is found and has been + * changed (i.e. dissector_change_uint() has been called, such as from + * Decode As, prefs registered via dissector_add_uint_[range_]with_preference), + * etc.), otherwise return FALSE. + */ +WS_DLL_PUBLIC gboolean dissector_is_uint_changed(dissector_table_t const sub_dissectors, const guint32 uint_val); + /* Look for a given value in a given uint dissector table and, if found, call the dissector with the arguments supplied, and return the number of bytes consumed, otherwise return 0. */ @@ -295,6 +308,12 @@ WS_DLL_PUBLIC void dissector_change_string(const char *name, const gchar *patter /* Reset an entry in a string sub-dissector table to its initial value. */ WS_DLL_PUBLIC void dissector_reset_string(const char *name, const gchar *pattern); +/* Return TRUE if an entry in a string dissector table is found and has been + * changed (i.e. dissector_change_string() has been called, such as from + * Decode As), otherwise return FALSE. + */ +WS_DLL_PUBLIC gboolean dissector_is_string_changed(dissector_table_t const subdissectors, const gchar *string); + /* Look for a given string in a given dissector table and, if found, call the dissector with the arguments supplied, and return the number of bytes consumed, otherwise return 0. */ @@ -364,6 +383,10 @@ WS_DLL_PUBLIC int dissector_try_guid(dissector_table_t sub_dissectors, WS_DLL_PUBLIC int dissector_try_guid_new(dissector_table_t sub_dissectors, guid_key* guid_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name, void *data); +/* Delete a GUID from a dissector table. */ +WS_DLL_PUBLIC void dissector_delete_guid(const char *name, guid_key* guid_val, + dissector_handle_t handle); + /** Look for a given value in a given guid dissector table and, if found, * return the current dissector handle for that value. * @@ -412,9 +435,10 @@ WS_DLL_PUBLIC void dissector_add_for_decode_as_with_preference(const char *name, */ WS_DLL_PUBLIC GSList *dissector_table_get_dissector_handles(dissector_table_t dissector_table); -/** Get a handle to dissector out of a dissector table +/** Get a handle to dissector out of a dissector table given the description + * of what the dissector dissects. */ -WS_DLL_PUBLIC dissector_handle_t dissector_table_get_dissector_handle(dissector_table_t dissector_table, const gchar* short_name); +WS_DLL_PUBLIC dissector_handle_t dissector_table_get_dissector_handle(dissector_table_t dissector_table, const gchar* description); /** Get a dissector table's type */ @@ -424,6 +448,10 @@ WS_DLL_PUBLIC ftenum_t dissector_table_get_type(dissector_table_t dissector_tabl */ WS_DLL_PUBLIC void dissector_table_allow_decode_as(dissector_table_t dissector_table); +/** Returns TRUE if dissector table allows "Decode As" + */ +WS_DLL_PUBLIC gboolean dissector_table_supports_decode_as(dissector_table_t dissector_table); + /* List of "heuristic" dissectors (which get handed a packet, look at it, and either recognize it as being for their protocol, dissect it, and return TRUE, or don't recognize it and return FALSE) to be called @@ -441,13 +469,28 @@ typedef struct heur_dtbl_entry { const gchar *display_name; /* the string used to present heuristic to user */ gchar *short_name; /* string used for "internal" use to uniquely identify heuristic */ gboolean enabled; + bool enabled_by_default; } heur_dtbl_entry_t; /** A protocol uses this function to register a heuristic sub-dissector list. * Call this in the parent dissectors proto_register function. * * @param name the name of this protocol - * @param proto the value obtained when regestering the protocol + * @param proto the value obtained when registering the protocol + */ +WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list_with_description(const char *name, const char *ui_name, const int proto); + +/** Get description of heuristic sub-dissector list. + * + * @param list the dissector list + */ +WS_DLL_PUBLIC const char *heur_dissector_list_get_description(heur_dissector_list_t list); + +/** A protocol uses this function to register a heuristic sub-dissector list. + * Call this in the parent dissectors proto_register function. + * + * @param name the name of this protocol + * @param proto the value obtained when registering the protocol */ WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list(const char *name, const int proto); @@ -479,7 +522,7 @@ WS_DLL_PUBLIC void heur_dissector_table_foreach(const char *table_name, WS_DLL_PUBLIC void dissector_all_heur_tables_foreach_table (DATFunc_heur_table func, gpointer user_data, GCompareFunc compare_key_func); -/* true if a heur_dissector list of that anme exists to be registered into */ +/* true if a heur_dissector list of that name exists to be registered into */ WS_DLL_PUBLIC gboolean has_heur_dissector_list(const gchar *name); /** Try all the dissectors in a given heuristic dissector list. This is done, @@ -536,6 +579,9 @@ WS_DLL_PUBLIC void heur_dissector_delete(const char *name, heur_dissector_t diss /** Register a new dissector. */ WS_DLL_PUBLIC dissector_handle_t register_dissector(const char *name, dissector_t dissector, const int proto); +/** Register a new dissector with a description. */ +WS_DLL_PUBLIC dissector_handle_t register_dissector_with_description(const char *name, const char *description, dissector_t dissector, const int proto); + /** Register a new dissector with a callback pointer. */ WS_DLL_PUBLIC dissector_handle_t register_dissector_with_data(const char *name, dissector_cb_t dissector, const int proto, void *cb_data); @@ -543,11 +589,18 @@ WS_DLL_PUBLIC dissector_handle_t register_dissector_with_data(const char *name, void deregister_dissector(const char *name); /** Get the long name of the protocol for a dissector handle. */ -extern const char *dissector_handle_get_long_name(const dissector_handle_t handle); +WS_DLL_PUBLIC const char *dissector_handle_get_protocol_long_name(const dissector_handle_t handle); /** Get the short name of the protocol for a dissector handle. */ +WS_DLL_PUBLIC const char *dissector_handle_get_protocol_short_name(const dissector_handle_t handle); + +/* For backwards source and binary compatibility */ +G_DEPRECATED_FOR(dissector_handle_get_protocol_short_name) WS_DLL_PUBLIC const char *dissector_handle_get_short_name(const dissector_handle_t handle); +/** Get the description for what the dissector for a dissector handle dissects. */ +WS_DLL_PUBLIC const char *dissector_handle_get_description(const dissector_handle_t handle); + /** Get the index of the protocol for a dissector handle. */ WS_DLL_PUBLIC int dissector_handle_get_protocol_index(const dissector_handle_t handle); @@ -557,7 +610,7 @@ WS_DLL_PUBLIC GList* get_dissector_names(void); /** Find a dissector by name. */ WS_DLL_PUBLIC dissector_handle_t find_dissector(const char *name); -/** Find a dissector by name and add parent protocol as a depedency*/ +/** Find a dissector by name and add parent protocol as a dependency. */ WS_DLL_PUBLIC dissector_handle_t find_dissector_add_dependency(const char *name, const int parent_proto); /** Get a dissector name from handle. */ @@ -568,6 +621,13 @@ WS_DLL_PUBLIC dissector_handle_t create_dissector_handle(dissector_t dissector, const int proto); WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name(dissector_t dissector, const int proto, const char* name); +WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name_and_description(dissector_t dissector, + const int proto, const char* name, const char* description); +WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_data(dissector_cb_t dissector, + const int proto, void* cb_data); + +/* Dump all registered dissectors to the standard output */ +WS_DLL_PUBLIC void dissector_dump_dissectors(void); /** Call a dissector through a handle and if no dissector was found * pass it over to the "data" dissector instead. @@ -635,7 +695,7 @@ WS_DLL_PUBLIC gboolean register_depend_dissector(const char* parent, const char* /** Unregister a protocol dependency * This is done automatically when removing from a dissector or * heuristic table. This is for "manual" deregistration for things - * like Lua + * like Lua. * * @param parent "Parent" protocol short name * @param dependent "Dependent" protocol short name @@ -672,16 +732,17 @@ WS_DLL_PUBLIC void set_actual_length(tvbuff_t *tvb, const guint specified_len); WS_DLL_PUBLIC void register_init_routine(void (*func)(void)); /** - * Allows protocols to register "cleanup" routines which are called + * Allows protocols to register "cleanup" routines, which are called * after closing a capture file (or when preferences are changed, in * that case these routines are called before the init routines are * executed). It can be used to release resources that are allocated in - * register_init_routine. + * an "init" routine. */ WS_DLL_PUBLIC void register_cleanup_routine(void (*func)(void)); /* - * Register a shutdown routine to call once just before program exit + * Allows protocols to register "shutdown" routines, which are called + * once, just before program exit */ WS_DLL_PUBLIC void register_shutdown_routine(void (*func)(void)); @@ -706,7 +767,7 @@ WS_DLL_PUBLIC void postseq_cleanup_all_protocols(void); * subsystems, liked dfilters, have finished initializing. This is * useful for dissector registration routines which need to compile * display filters. dfilters can't initialize itself until all protocols - * have registereed themselvs. */ + * have registered themselves. */ WS_DLL_PUBLIC void register_final_registration_routine(void (*func)(void)); @@ -738,11 +799,11 @@ 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 + * This information is used to ensure that the depended-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. */ -WS_DLL_PUBLIC void mark_frame_as_depended_upon(packet_info *pinfo, guint32 frame_num); +WS_DLL_PUBLIC void mark_frame_as_depended_upon(frame_data *fd, guint32 frame_num); /* Structure passed to the frame dissector */ typedef struct frame_data_s |