2013-11-20 19:17:08 +00:00
|
|
|
/* decode_as.c
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include "decode_as.h"
|
2013-11-22 00:20:23 +00:00
|
|
|
#include "packet.h"
|
2016-10-07 20:25:01 +00:00
|
|
|
#include "prefs.h"
|
|
|
|
#include "prefs-int.h"
|
|
|
|
#include "wsutil/file_util.h"
|
|
|
|
#include "wsutil/filesystem.h"
|
|
|
|
#include "epan/dissectors/packet-dcerpc.h"
|
2015-10-29 13:23:55 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-10-07 20:25:01 +00:00
|
|
|
#include <errno.h>
|
2013-11-20 19:17:08 +00:00
|
|
|
|
|
|
|
GList *decode_as_list = NULL;
|
|
|
|
|
|
|
|
void register_decode_as(decode_as_t* reg)
|
|
|
|
{
|
2015-10-29 13:23:55 +00:00
|
|
|
dissector_table_t decode_table;
|
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
/* Ensure valid functions */
|
2017-06-23 22:14:00 +00:00
|
|
|
g_assert(reg->populate_list);
|
|
|
|
g_assert(reg->reset_value);
|
|
|
|
g_assert(reg->change_value);
|
2013-11-20 19:17:08 +00:00
|
|
|
|
2015-10-29 13:23:55 +00:00
|
|
|
decode_table = find_dissector_table(reg->table_name);
|
|
|
|
if (decode_table != NULL)
|
|
|
|
{
|
2016-08-30 22:51:54 +00:00
|
|
|
dissector_table_allow_decode_as(decode_table);
|
2015-10-29 13:23:55 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 09:54:07 +00:00
|
|
|
decode_as_list = g_list_prepend(decode_as_list, reg);
|
2013-11-20 19:17:08 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 21:29:51 +00:00
|
|
|
static void next_proto_prompt(packet_info *pinfo _U_, gchar *result)
|
|
|
|
{
|
|
|
|
g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Next level protocol as");
|
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer next_proto_value(packet_info *pinfo _U_)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static build_valid_func next_proto_values[] = { next_proto_value };
|
|
|
|
static decode_as_value_t next_proto_da_values =
|
|
|
|
{ next_proto_prompt, 1, next_proto_values };
|
|
|
|
|
2019-06-12 20:54:01 +00:00
|
|
|
dissector_table_t 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
|
|
|
{
|
|
|
|
decode_as_t *da;
|
|
|
|
|
2017-07-09 17:47:59 +00:00
|
|
|
dissector_table_t dt = register_dissector_table(table_name, ui_name, proto, FT_NONE, BASE_NONE);
|
2017-06-23 21:29:51 +00:00
|
|
|
|
|
|
|
da = wmem_new0(wmem_epan_scope(), decode_as_t);
|
2017-07-09 17:47:59 +00:00
|
|
|
da->name = wmem_strdup(wmem_epan_scope(), proto_get_protocol_filter_name(proto));
|
2017-06-23 21:29:51 +00:00
|
|
|
da->table_name = wmem_strdup(wmem_epan_scope(), table_name);
|
|
|
|
da->num_items = 1;
|
2017-07-09 01:48:36 +00:00
|
|
|
if (label_func == NULL)
|
|
|
|
{
|
|
|
|
da->values = &next_proto_da_values;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
da->values = wmem_new(wmem_epan_scope(), decode_as_value_t);
|
2018-02-13 18:05:31 +00:00
|
|
|
da->values->label_func = label_func;
|
2017-07-09 01:48:36 +00:00
|
|
|
da->values->num_values = 1;
|
|
|
|
da->values->build_values = next_proto_values;
|
|
|
|
}
|
2017-06-23 21:29:51 +00:00
|
|
|
da->populate_list = decode_as_default_populate_list;
|
|
|
|
da->reset_value = decode_as_default_reset;
|
|
|
|
da->change_value = decode_as_default_change;
|
|
|
|
|
|
|
|
register_decode_as(da);
|
2017-07-09 17:47:59 +00:00
|
|
|
return dt;
|
2017-06-23 21:29:51 +00:00
|
|
|
}
|
2013-11-20 19:17:08 +00:00
|
|
|
|
|
|
|
struct decode_as_default_populate
|
|
|
|
{
|
|
|
|
decode_as_add_to_list_func add_to_list;
|
|
|
|
gpointer ui_element;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
decode_proto_add_to_list (const gchar *table_name, gpointer value, gpointer user_data)
|
|
|
|
{
|
|
|
|
struct decode_as_default_populate* populate = (struct decode_as_default_populate*)user_data;
|
|
|
|
const gchar *proto_name;
|
|
|
|
gint i;
|
|
|
|
dissector_handle_t handle;
|
|
|
|
|
|
|
|
|
|
|
|
handle = (dissector_handle_t)value;
|
|
|
|
proto_name = dissector_handle_get_short_name(handle);
|
|
|
|
|
|
|
|
i = dissector_handle_get_protocol_index(handle);
|
|
|
|
if (i >= 0 && !proto_is_protocol_enabled(find_protocol_by_id(i)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
populate->add_to_list(table_name, proto_name, value, populate->ui_element);
|
|
|
|
}
|
|
|
|
|
|
|
|
void decode_as_default_populate_list(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element)
|
|
|
|
{
|
|
|
|
struct decode_as_default_populate populate;
|
|
|
|
|
|
|
|
populate.add_to_list = add_to_list;
|
|
|
|
populate.ui_element = ui_element;
|
|
|
|
|
|
|
|
dissector_table_foreach_handle(table_name, decode_proto_add_to_list, &populate);
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:06:36 +00:00
|
|
|
gboolean decode_as_default_reset(const gchar *name, gconstpointer pattern)
|
2013-11-20 19:17:08 +00:00
|
|
|
{
|
2015-03-08 13:59:32 +00:00
|
|
|
switch (get_dissector_table_selector_type(name)) {
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
dissector_reset_uint(name, GPOINTER_TO_UINT(pattern));
|
|
|
|
return TRUE;
|
2017-07-09 17:44:06 +00:00
|
|
|
case FT_NONE:
|
|
|
|
dissector_reset_payload(name);
|
|
|
|
return TRUE;
|
2015-03-08 13:59:32 +00:00
|
|
|
case FT_STRING:
|
|
|
|
case FT_STRINGZ:
|
|
|
|
case FT_UINT_STRING:
|
|
|
|
case FT_STRINGZPAD:
|
2018-01-18 06:00:30 +00:00
|
|
|
dissector_reset_string(name, (!pattern)?"":(const gchar *) pattern);
|
2015-03-08 13:59:32 +00:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-03-17 19:56:27 +00:00
|
|
|
gboolean decode_as_default_change(const gchar *name, gconstpointer pattern, gconstpointer handle, const gchar *list_name _U_)
|
2013-11-20 19:17:08 +00:00
|
|
|
{
|
2019-03-17 19:56:27 +00:00
|
|
|
const dissector_handle_t* dissector = (const dissector_handle_t*)handle;
|
2015-03-08 13:59:32 +00:00
|
|
|
if (dissector != NULL) {
|
|
|
|
switch (get_dissector_table_selector_type(name)) {
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
dissector_change_uint(name, GPOINTER_TO_UINT(pattern), *dissector);
|
|
|
|
return TRUE;
|
2017-07-09 17:44:06 +00:00
|
|
|
case FT_NONE:
|
|
|
|
dissector_change_payload(name, *dissector);
|
|
|
|
return TRUE;
|
2015-03-08 13:59:32 +00:00
|
|
|
case FT_STRING:
|
|
|
|
case FT_STRINGZ:
|
|
|
|
case FT_UINT_STRING:
|
|
|
|
case FT_STRINGZPAD:
|
2018-01-18 06:00:30 +00:00
|
|
|
dissector_change_string(name, (!pattern)?"":(const gchar *) pattern, *dissector);
|
2015-03-08 13:59:32 +00:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-11-20 19:17:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2013-11-22 00:20:23 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
/* Some useful utilities for Decode As */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A list of dissectors that need to be reset.
|
|
|
|
*/
|
|
|
|
static GSList *dissector_reset_list = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A callback function to parse each "decode as" entry in the file and apply the change
|
|
|
|
*/
|
|
|
|
static prefs_set_pref_e
|
|
|
|
read_set_decode_as_entries(gchar *key, const gchar *value,
|
2017-01-07 13:52:23 +00:00
|
|
|
void *user_data,
|
2016-10-07 20:25:01 +00:00
|
|
|
gboolean return_range_errors _U_)
|
|
|
|
{
|
|
|
|
gchar *values[4] = {NULL, NULL, NULL, NULL};
|
|
|
|
gchar delimiter[4] = {',', ',', ',','\0'};
|
|
|
|
gchar *pch;
|
|
|
|
guint i, j;
|
2017-01-07 13:52:23 +00:00
|
|
|
GHashTable* processed_entries = (GHashTable*)user_data;
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_table_t sub_dissectors;
|
|
|
|
prefs_set_pref_e retval = PREFS_SET_OK;
|
|
|
|
gboolean is_valid = FALSE;
|
|
|
|
|
|
|
|
if (strcmp(key, DECODE_AS_ENTRY) == 0) {
|
|
|
|
/* Parse csv into table, selector, initial, current */
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
pch = strchr(value, delimiter[i]);
|
|
|
|
if (pch == NULL) {
|
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
g_free(values[j]);
|
|
|
|
}
|
|
|
|
return PREFS_SET_SYNTAX_ERR;
|
|
|
|
}
|
|
|
|
values[i] = g_strndup(value, pch - value);
|
|
|
|
value = pch + 1;
|
|
|
|
}
|
|
|
|
sub_dissectors = find_dissector_table(values[0]);
|
|
|
|
if (sub_dissectors != NULL) {
|
|
|
|
dissector_handle_t handle;
|
|
|
|
ftenum_t selector_type;
|
|
|
|
pref_t* pref_value;
|
2016-10-18 13:14:35 +00:00
|
|
|
module_t *module;
|
2017-01-07 13:52:23 +00:00
|
|
|
const char* proto_name;
|
2016-10-07 20:25:01 +00:00
|
|
|
|
|
|
|
selector_type = dissector_table_get_type(sub_dissectors);
|
|
|
|
|
|
|
|
handle = dissector_table_get_dissector_handle(sub_dissectors, values[3]);
|
|
|
|
if (handle != NULL || g_ascii_strcasecmp(values[3], DECODE_AS_NONE) == 0) {
|
|
|
|
is_valid = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_valid) {
|
|
|
|
if (IS_FT_STRING(selector_type)) {
|
|
|
|
dissector_change_string(values[0], values[1], handle);
|
|
|
|
} else {
|
|
|
|
char *p;
|
|
|
|
long long_value;
|
|
|
|
|
|
|
|
long_value = strtol(values[1], &p, 0);
|
|
|
|
if (p == values[0] || *p != '\0' || long_value < 0 ||
|
|
|
|
(unsigned long)long_value > UINT_MAX) {
|
|
|
|
retval = PREFS_SET_SYNTAX_ERR;
|
|
|
|
is_valid = FALSE;
|
|
|
|
} else {
|
|
|
|
dissector_change_uint(values[0], (guint)long_value, handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now apply the value data back to dissector table preference */
|
2017-01-07 13:52:23 +00:00
|
|
|
proto_name = proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle));
|
|
|
|
module = prefs_find_module(proto_name);
|
2016-10-18 13:14:35 +00:00
|
|
|
pref_value = prefs_find_preference(module, values[0]);
|
2016-10-07 20:25:01 +00:00
|
|
|
if (pref_value != NULL) {
|
2017-01-07 13:52:23 +00:00
|
|
|
gboolean replace = FALSE;
|
|
|
|
if (g_hash_table_lookup(processed_entries, proto_name) == NULL) {
|
|
|
|
/* First decode as entry for this protocol, ranges may be replaced */
|
|
|
|
replace = TRUE;
|
|
|
|
|
|
|
|
/* Remember we've processed this protocol */
|
|
|
|
g_hash_table_insert(processed_entries, (gpointer)proto_name, (gpointer)proto_name);
|
2016-10-07 20:25:01 +00:00
|
|
|
}
|
2017-01-07 13:52:23 +00:00
|
|
|
|
|
|
|
prefs_add_decode_as_value(pref_value, (guint)long_value, replace);
|
2018-01-06 04:39:55 +00:00
|
|
|
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
|
2016-10-07 20:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_valid) {
|
|
|
|
decode_build_reset_list(values[0], selector_type, values[1], NULL, NULL);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
retval = PREFS_SET_SYNTAX_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
retval = PREFS_SET_NO_SUCH_PREF;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
g_free(values[i]);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
load_decode_as_entries(void)
|
|
|
|
{
|
|
|
|
char *daf_path;
|
|
|
|
FILE *daf;
|
|
|
|
|
|
|
|
if (dissector_reset_list) {
|
|
|
|
decode_clear_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
daf_path = get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE);
|
|
|
|
if ((daf = ws_fopen(daf_path, "r")) != NULL) {
|
2017-01-07 13:52:23 +00:00
|
|
|
/* Store saved entries for better range processing */
|
|
|
|
GHashTable* processed_entries = g_hash_table_new(g_str_hash, g_str_equal);
|
|
|
|
read_prefs_file(daf_path, daf, read_set_decode_as_entries, processed_entries);
|
|
|
|
g_hash_table_destroy(processed_entries);
|
2016-10-07 20:25:01 +00:00
|
|
|
fclose(daf);
|
|
|
|
}
|
|
|
|
g_free(daf_path);
|
|
|
|
}
|
|
|
|
|
2019-03-15 15:27:04 +00:00
|
|
|
|
|
|
|
/* Make a sorted list of the enties as we are fetching them from a hash table. Then write it out from the sorted list */
|
2016-10-07 20:25:01 +00:00
|
|
|
static void
|
|
|
|
decode_as_write_entry (const gchar *table_name, ftenum_t selector_type,
|
|
|
|
gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
2019-03-15 15:27:04 +00:00
|
|
|
GList **decode_as_rows_list = (GList **)user_data;
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_handle_t current, initial;
|
2019-03-15 15:27:04 +00:00
|
|
|
const gchar *current_proto_name, *initial_proto_name, *decode_as_row;
|
2016-10-07 20:25:01 +00:00
|
|
|
|
|
|
|
current = dtbl_entry_get_handle((dtbl_entry_t *)value);
|
|
|
|
if (current == NULL)
|
|
|
|
current_proto_name = DECODE_AS_NONE;
|
|
|
|
else
|
|
|
|
current_proto_name = dissector_handle_get_short_name(current);
|
|
|
|
initial = dtbl_entry_get_initial_handle((dtbl_entry_t *)value);
|
|
|
|
if (initial == NULL)
|
|
|
|
initial_proto_name = DECODE_AS_NONE;
|
|
|
|
else
|
|
|
|
initial_proto_name = dissector_handle_get_short_name(initial);
|
|
|
|
|
|
|
|
switch (selector_type) {
|
|
|
|
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
/*
|
|
|
|
* XXX - write these in decimal, regardless of the base of
|
|
|
|
* the dissector table's selector, as older versions of
|
|
|
|
* Wireshark used atoi() when reading this file, and
|
|
|
|
* failed to handle hex or octal numbers.
|
|
|
|
*
|
|
|
|
* That will be fixed in future 1.10 and 1.12 releases,
|
|
|
|
* but pre-1.10 releases are at end-of-life and won't
|
|
|
|
* be fixed.
|
|
|
|
*/
|
2019-03-15 15:27:04 +00:00
|
|
|
decode_as_row = g_strdup_printf(
|
|
|
|
DECODE_AS_ENTRY ": %s,%u,%s,%s\n",
|
|
|
|
table_name, GPOINTER_TO_UINT(key), initial_proto_name,
|
|
|
|
current_proto_name);
|
2016-10-07 20:25:01 +00:00
|
|
|
break;
|
2017-07-09 17:44:06 +00:00
|
|
|
case FT_NONE:
|
|
|
|
/*
|
|
|
|
* XXX - Just put a placeholder for the key value. Currently
|
|
|
|
* FT_NONE dissector table uses a single uint value for
|
|
|
|
* a placeholder
|
|
|
|
*/
|
2019-03-15 15:27:04 +00:00
|
|
|
decode_as_row = g_strdup_printf(
|
|
|
|
DECODE_AS_ENTRY ": %s,0,%s,%s\n",
|
|
|
|
table_name, initial_proto_name,
|
|
|
|
current_proto_name);
|
2017-07-09 17:44:06 +00:00
|
|
|
break;
|
2016-10-07 20:25:01 +00:00
|
|
|
|
|
|
|
case FT_STRING:
|
|
|
|
case FT_STRINGZ:
|
|
|
|
case FT_UINT_STRING:
|
|
|
|
case FT_STRINGZPAD:
|
2019-03-15 15:27:04 +00:00
|
|
|
decode_as_row = g_strdup_printf(
|
|
|
|
DECODE_AS_ENTRY ": %s,%s,%s,%s\n",
|
|
|
|
table_name, (gchar *)key, initial_proto_name,
|
|
|
|
current_proto_name);
|
2016-10-07 20:25:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
break;
|
|
|
|
}
|
2019-03-15 15:27:04 +00:00
|
|
|
|
|
|
|
/* Do we need a better sort function ???*/
|
|
|
|
*decode_as_rows_list = g_list_insert_sorted (*decode_as_rows_list, (gpointer)decode_as_row,
|
|
|
|
(GCompareFunc)g_ascii_strcasecmp);
|
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
}
|
|
|
|
|
2019-03-15 15:27:04 +00:00
|
|
|
/* Print the sorted rows to File */
|
|
|
|
static void
|
|
|
|
decode_as_print_rows(gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
FILE *da_file = (FILE *)user_data;
|
|
|
|
const gchar *decode_as_row = (const gchar *)data;
|
|
|
|
|
|
|
|
fprintf(da_file, "%s",decode_as_row);
|
|
|
|
|
|
|
|
}
|
2016-10-07 20:25:01 +00:00
|
|
|
int
|
|
|
|
save_decode_as_entries(gchar** err)
|
|
|
|
{
|
|
|
|
char *pf_dir_path;
|
|
|
|
char *daf_path;
|
|
|
|
FILE *da_file;
|
2019-03-15 15:27:04 +00:00
|
|
|
GList *decode_as_rows_list = NULL;
|
2016-10-07 20:25:01 +00:00
|
|
|
|
|
|
|
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
|
|
|
*err = g_strdup_printf("Can't create directory\n\"%s\"\nfor recent file: %s.",
|
|
|
|
pf_dir_path, g_strerror(errno));
|
|
|
|
g_free(pf_dir_path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
daf_path = get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE);
|
|
|
|
if ((da_file = ws_fopen(daf_path, "w")) == NULL) {
|
|
|
|
*err = g_strdup_printf("Can't open decode_as_entries file\n\"%s\": %s.",
|
|
|
|
daf_path, g_strerror(errno));
|
|
|
|
g_free(daf_path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("# \"Decode As\" entries file for Wireshark " VERSION ".\n"
|
|
|
|
"#\n"
|
|
|
|
"# This file is regenerated each time \"Decode As\" preferences\n"
|
|
|
|
"# are saved within Wireshark. Making manual changes should be safe,\n"
|
|
|
|
"# however.\n", da_file);
|
|
|
|
|
2019-03-15 15:27:04 +00:00
|
|
|
dissector_all_tables_foreach_changed(decode_as_write_entry, &decode_as_rows_list);
|
|
|
|
|
|
|
|
g_list_foreach(decode_as_rows_list, decode_as_print_rows, da_file);
|
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
fclose(da_file);
|
2017-04-19 21:32:14 +00:00
|
|
|
g_free(daf_path);
|
2019-03-15 15:27:04 +00:00
|
|
|
g_list_free_full(decode_as_rows_list, g_free);
|
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Data structure for tracking which dissector need to be reset. This
|
|
|
|
* structure is necessary as a hash table entry cannot be removed
|
|
|
|
* while a g_hash_table_foreach walk is in progress.
|
|
|
|
*/
|
|
|
|
typedef struct dissector_delete_item {
|
|
|
|
/* The name of the dissector table */
|
|
|
|
gchar *ddi_table_name;
|
|
|
|
/* The type of the selector in that dissector table */
|
|
|
|
ftenum_t ddi_selector_type;
|
|
|
|
/* The selector in the dissector table */
|
|
|
|
union {
|
|
|
|
guint sel_uint;
|
|
|
|
char *sel_string;
|
|
|
|
} ddi_selector;
|
|
|
|
} dissector_delete_item_t;
|
|
|
|
|
|
|
|
void
|
|
|
|
decode_build_reset_list (const gchar *table_name, ftenum_t selector_type,
|
|
|
|
gpointer key, gpointer value _U_,
|
|
|
|
gpointer user_data _U_)
|
|
|
|
{
|
|
|
|
dissector_delete_item_t *item;
|
|
|
|
|
|
|
|
item = g_new(dissector_delete_item_t,1);
|
|
|
|
item->ddi_table_name = g_strdup(table_name);
|
|
|
|
item->ddi_selector_type = selector_type;
|
|
|
|
switch (selector_type) {
|
|
|
|
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
item->ddi_selector.sel_uint = GPOINTER_TO_UINT(key);
|
|
|
|
break;
|
|
|
|
|
2017-07-09 17:44:06 +00:00
|
|
|
case FT_NONE:
|
|
|
|
/* Not really needed, but prevents the assert */
|
|
|
|
item->ddi_selector.sel_uint = 0;
|
|
|
|
break;
|
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
case FT_STRING:
|
|
|
|
case FT_STRINGZ:
|
|
|
|
case FT_UINT_STRING:
|
|
|
|
case FT_STRINGZPAD:
|
|
|
|
item->ddi_selector.sel_string = g_strdup((char *)key);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
dissector_reset_list = g_slist_prepend(dissector_reset_list, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear all settings */
|
|
|
|
void
|
|
|
|
decode_clear_all(void)
|
|
|
|
{
|
|
|
|
dissector_delete_item_t *item;
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
dissector_all_tables_foreach_changed(decode_build_reset_list, NULL);
|
|
|
|
|
|
|
|
for (tmp = dissector_reset_list; tmp; tmp = g_slist_next(tmp)) {
|
|
|
|
item = (dissector_delete_item_t *)tmp->data;
|
|
|
|
switch (item->ddi_selector_type) {
|
|
|
|
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
dissector_reset_uint(item->ddi_table_name,
|
|
|
|
item->ddi_selector.sel_uint);
|
|
|
|
break;
|
|
|
|
|
2017-07-09 17:44:06 +00:00
|
|
|
case FT_NONE:
|
|
|
|
dissector_reset_payload(item->ddi_table_name);
|
|
|
|
break;
|
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
case FT_STRING:
|
|
|
|
case FT_STRINGZ:
|
|
|
|
case FT_UINT_STRING:
|
|
|
|
case FT_STRINGZPAD:
|
|
|
|
dissector_reset_string(item->ddi_table_name,
|
|
|
|
item->ddi_selector.sel_string);
|
|
|
|
g_free(item->ddi_selector.sel_string);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
g_free(item->ddi_table_name);
|
|
|
|
g_free(item);
|
|
|
|
}
|
|
|
|
g_slist_free(dissector_reset_list);
|
|
|
|
dissector_reset_list = NULL;
|
|
|
|
|
2017-01-20 09:30:59 +00:00
|
|
|
g_list_free(decode_as_list);
|
2017-01-28 11:47:47 +00:00
|
|
|
decode_as_list = NULL;
|
2017-01-20 09:30:59 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
decode_dcerpc_reset_all();
|
|
|
|
}
|
|
|
|
|
2013-11-29 15:46:50 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|