2013-11-20 19:17:08 +00:00
|
|
|
/* decode_as.h
|
|
|
|
* Routines for dissector Decode As handlers
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2013-11-20 19:17:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DECODE_AS_H__
|
|
|
|
#define __DECODE_AS_H__
|
|
|
|
|
|
|
|
#include "ws_symbol_export.h"
|
|
|
|
|
2013-11-22 00:20:23 +00:00
|
|
|
#include "ftypes/ftypes.h"
|
|
|
|
#include "packet_info.h"
|
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-02-25 20:42:35 +00:00
|
|
|
/** @file
|
2013-11-20 19:17:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_DECODE_AS_PROMPT_LEN 200
|
2013-11-22 00:20:23 +00:00
|
|
|
#define DECODE_AS_ENTRY "decode_as_entry"
|
2013-11-29 03:14:24 +00:00
|
|
|
#define DECODE_AS_NONE "(none)"
|
|
|
|
|
2013-11-22 00:20:23 +00:00
|
|
|
/*
|
|
|
|
* Filename of the "decode as" entry preferences
|
|
|
|
*/
|
|
|
|
#define DECODE_AS_ENTRIES_FILE_NAME "decode_as_entries"
|
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
|
|
|
|
/** callback function definition: return formatted label string */
|
|
|
|
typedef void (*build_label_func)(packet_info *pinfo, gchar* result);
|
|
|
|
|
|
|
|
/** callback function definition: return value used to pass to dissector table */
|
|
|
|
typedef gpointer (*build_valid_func)(packet_info *pinfo);
|
|
|
|
|
|
|
|
typedef void (*decode_as_add_to_list_func)(const gchar *table_name, const gchar *proto_name, gpointer value, gpointer user_data);
|
|
|
|
typedef void (*decode_as_populate_list_func)(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element);
|
|
|
|
typedef void (*decode_as_free_func)(gpointer value);
|
|
|
|
|
|
|
|
/** callback function definition: Clear value from dissector table */
|
2016-01-05 12:06:36 +00:00
|
|
|
typedef gboolean (*decode_as_reset_func)(const gchar *name, gconstpointer pattern);
|
2013-11-20 19:17:08 +00:00
|
|
|
/** callback function definition: Apply value to dissector table */
|
2019-03-17 19:56:27 +00:00
|
|
|
typedef gboolean (*decode_as_change_func)(const gchar *name, gconstpointer pattern, gconstpointer handle, const gchar *list_name);
|
2013-11-20 19:17:08 +00:00
|
|
|
|
|
|
|
typedef struct decode_as_value_s {
|
|
|
|
build_label_func label_func;
|
|
|
|
guint num_values;
|
|
|
|
build_valid_func* build_values;
|
|
|
|
} decode_as_value_t;
|
|
|
|
|
|
|
|
typedef struct decode_as_s {
|
|
|
|
const char *name;
|
|
|
|
const gchar *table_name;
|
|
|
|
guint num_items;
|
|
|
|
guint default_index_value;
|
|
|
|
decode_as_value_t* values;
|
|
|
|
const char* pre_value_str;
|
|
|
|
const char* post_value_str;
|
|
|
|
decode_as_populate_list_func populate_list;
|
|
|
|
decode_as_reset_func reset_value;
|
|
|
|
decode_as_change_func change_value;
|
|
|
|
decode_as_free_func free_func;
|
|
|
|
|
|
|
|
} decode_as_t;
|
|
|
|
|
|
|
|
/** register a "Decode As". A copy of the decode_as_t will be maintained by the decode_as module */
|
|
|
|
WS_DLL_PUBLIC void register_decode_as(decode_as_t* reg);
|
|
|
|
|
2017-07-09 17:47:59 +00:00
|
|
|
/* Forward declaration to prevent requiring packet.h */
|
|
|
|
struct dissector_table;
|
|
|
|
|
2017-06-23 21:29:51 +00:00
|
|
|
/** Register a "Decode As" entry for the special case where there is no
|
2017-07-09 01:48:36 +00:00
|
|
|
* indication for the next protocol (such as port number etc.).
|
|
|
|
* For now, this will use a uint32 dissector table internally and
|
|
|
|
* assign all registered protocols to 0. The framework to do this can
|
|
|
|
* be kept internal to epan.
|
|
|
|
*
|
2017-07-09 17:47:59 +00:00
|
|
|
* @param proto The protocol ID to create the dissector table.
|
2017-07-09 01:48:36 +00:00
|
|
|
* @param table_name The table name in which this dissector is found.
|
2017-07-09 17:47:59 +00:00
|
|
|
* @param ui_name UI name for created dissector table.
|
2018-02-13 18:05:31 +00:00
|
|
|
* @param label_func Pointer to optional function to generate prompt text
|
|
|
|
* for dissector. If NULL, "Next level protocol as" is used.
|
2017-07-09 17:47:59 +00:00
|
|
|
*
|
|
|
|
* @return Created dissector table with Decode As support
|
2017-07-09 01:48:36 +00:00
|
|
|
*/
|
2019-06-12 20:54:01 +00:00
|
|
|
WS_DLL_PUBLIC struct dissector_table* register_decode_as_next_proto(int proto, const gchar *table_name, const gchar *ui_name, build_label_func label_func);
|
2017-06-23 21:29:51 +00:00
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
/* Walk though the dissector table and provide dissector_handle_t for each item in the table */
|
|
|
|
WS_DLL_PUBLIC void decode_as_default_populate_list(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element);
|
|
|
|
/* Clear a FT_UINT32 value from dissector table list */
|
2016-01-05 12:06:36 +00:00
|
|
|
WS_DLL_PUBLIC gboolean decode_as_default_reset(const gchar *name, gconstpointer pattern);
|
2013-11-20 19:17:08 +00:00
|
|
|
/* Add a FT_UINT32 value to dissector table list */
|
2019-03-17 19:56:27 +00:00
|
|
|
WS_DLL_PUBLIC gboolean decode_as_default_change(const gchar *name, gconstpointer pattern, gconstpointer handle, const gchar *list_name);
|
2013-11-20 19:17:08 +00:00
|
|
|
|
2013-12-10 19:23:26 +00:00
|
|
|
/** List of registered decode_as_t structs.
|
|
|
|
* For UI code only. Should not be directly accessed by dissectors.
|
2013-11-22 00:20:23 +00:00
|
|
|
*/
|
2013-12-10 19:23:26 +00:00
|
|
|
WS_DLL_PUBLIC GList *decode_as_list;
|
2013-11-22 00:20:23 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
/* Some useful utilities for Decode As */
|
|
|
|
|
|
|
|
/** Reset the "decode as" entries and reload ones of the current profile.
|
2017-04-09 19:27:57 +00:00
|
|
|
* This is called by epan_load_settings(); programs should call that
|
|
|
|
* rather than individually calling the routines it calls.
|
2016-10-07 20:25:01 +00:00
|
|
|
*/
|
2017-04-09 19:27:57 +00:00
|
|
|
extern void load_decode_as_entries(void);
|
2016-10-07 20:25:01 +00:00
|
|
|
|
|
|
|
/** Write out the "decode as" entries of the current profile.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC int save_decode_as_entries(gchar** err);
|
|
|
|
|
|
|
|
/** Clear all "decode as" settings.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC void decode_clear_all(void);
|
|
|
|
|
|
|
|
/** This routine creates one entry in the list of protocol dissector
|
|
|
|
* that need to be reset. It is called by the g_hash_table_foreach
|
|
|
|
* routine once for each changed entry in a dissector table.
|
|
|
|
* Unfortunately it cannot delete the entry immediately as this screws
|
|
|
|
* up the foreach function, so it builds a list of dissectors to be
|
|
|
|
* reset once the foreach routine finishes.
|
|
|
|
*
|
|
|
|
* @param table_name The table name in which this dissector is found.
|
|
|
|
*
|
|
|
|
* @param key A pointer to the key for this entry in the dissector
|
|
|
|
* hash table. This is generally the numeric selector of the
|
|
|
|
* protocol, i.e. the ethernet type code, IP port number, TCP port
|
|
|
|
* number, etc.
|
|
|
|
*
|
|
|
|
* @param selector_type The type of the selector in that dissector table
|
|
|
|
*
|
|
|
|
* @param value A pointer to the value for this entry in the dissector
|
|
|
|
* hash table. This is an opaque pointer that can only be handed back
|
|
|
|
* to routine in the file packet.c - but it's unused.
|
|
|
|
*
|
|
|
|
* @param user_data Unused.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC void decode_build_reset_list (const gchar *table_name, ftenum_t selector_type,
|
|
|
|
gpointer key, gpointer value _U_,
|
|
|
|
gpointer user_data _U_);
|
|
|
|
|
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* decode_as.h */
|