* Routines for dissector Decode As handlers
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __DECODE_AS_H__
#define __DECODE_AS_H__
#include "ws_symbol_export.h"
#include "ftypes/ftypes.h"
#include "packet_info.h"
#ifdef __cplusplus
extern "C" {
#endif
*/
#define MAX_DECODE_AS_PROMPT_LEN 200
#define DECODE_AS_ENTRY "decode_as_entry"
#define DECODE_AS_NONE "(none)"
* Filename of the "decode as" entry preferences
*/
#define DECODE_AS_ENTRIES_FILE_NAME "decode_as_entries"
typedef void (*build_label_func)(packet_info *pinfo, char* result);
typedef void * (*build_valid_func)(packet_info *pinfo);
typedef void (*decode_as_add_to_list_func)(const char *table_name, const char *proto_name, void *value, void *user_data);
typedef void (*decode_as_populate_list_func)(const char *table_name, decode_as_add_to_list_func add_to_list, void *ui_element);
typedef void (*decode_as_free_func)(void *value);
typedef bool (*decode_as_reset_func)(const char *name, const void *pattern);
typedef bool (*decode_as_change_func)(const char *name, const void *pattern, const void *handle, const char *list_name);
Contains all of the function pointers (typically just 1) that
provide the text explaining the name and use of the value field that will
be passed to the dissector table to change the dissection output.
*/
typedef struct decode_as_value_s {
build_label_func label_func;
unsigned num_values;
build_valid_func* build_values;
} decode_as_value_t;
Pulls everything together including the dissector (protocol) name, the
"layer type" of the dissector, the dissector table name, the function pointer
values as well as handlers for populating, applying and reseting the changes
to the dissector table through Decode As GUI functionality. For dissector
tables that are an integer or string type, the provided "default" handling
functions should suffice.
*/
typedef struct decode_as_s {
const char *name;
const char *table_name;
unsigned num_items;
unsigned 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;
WS_DLL_PUBLIC void register_decode_as(decode_as_t* reg);
struct dissector_table;
* 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.
*
* @param proto The protocol ID to create the dissector table.
* @param table_name The table name in which this dissector is found.
* @param ui_name UI name for created dissector table.
* @param label_func Pointer to optional function to generate prompt text
* for dissector. If NULL, "Next level protocol as" is used.
*
* @return Created dissector table with Decode As support
*/
WS_DLL_PUBLIC struct dissector_table* register_decode_as_next_proto(int proto, const char *table_name, const char *ui_name, build_label_func label_func);
WS_DLL_PUBLIC void decode_as_default_populate_list(const char *table_name, decode_as_add_to_list_func add_to_list, void *ui_element);
WS_DLL_PUBLIC bool decode_as_default_reset(const char *name, const void *pattern);
WS_DLL_PUBLIC bool decode_as_default_change(const char *name, const void *pattern, const void *handle, const char *list_name);
* For UI code only. Should not be directly accessed by dissectors.
*/
WS_DLL_PUBLIC GList *decode_as_list;
* This is called by epan_load_settings(); programs should call that
* rather than individually calling the routines it calls.
*/
extern void load_decode_as_entries(void);
*/
WS_DLL_PUBLIC int save_decode_as_entries(char** err);
*/
WS_DLL_PUBLIC void decode_clear_all(void);
*/
WS_DLL_PUBLIC void decode_cleanup(void);
* 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 selector_type The type of the selector in that dissector table
*
* @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 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 char *table_name, ftenum_t selector_type,
void *key, void *value,
void *user_data);
#ifdef __cplusplus
}
#endif
#endif