2001-02-01 20:31:21 +00:00
|
|
|
/*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
2008-01-08 22:54:51 +00:00
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-02-01 20:31:21 +00:00
|
|
|
* Copyright 2001 Gerald Combs
|
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2001-02-01 20:31:21 +00:00
|
|
|
*/
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "ftypes/ftypes.h"
|
2019-01-27 17:02:03 +00:00
|
|
|
#include "ftypes/ftypes-int.h"
|
2001-02-01 20:21:25 +00:00
|
|
|
#include "syntax-tree.h"
|
|
|
|
|
2019-01-27 17:02:03 +00:00
|
|
|
static void
|
|
|
|
fvalue_free(gpointer value)
|
|
|
|
{
|
|
|
|
fvalue_t *fvalue = (fvalue_t*)value;
|
|
|
|
|
|
|
|
/* If the data was not claimed with stnode_steal_data(), free it. */
|
|
|
|
if (fvalue) {
|
|
|
|
FVALUE_FREE(fvalue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-21 10:06:17 +00:00
|
|
|
static void
|
|
|
|
pcre_free(gpointer value)
|
|
|
|
{
|
2021-10-15 22:47:28 +00:00
|
|
|
fvalue_regex_t *pcre = value;
|
2021-03-21 10:06:17 +00:00
|
|
|
|
|
|
|
/* If the data was not claimed with stnode_steal_data(), free it. */
|
|
|
|
if (pcre) {
|
|
|
|
/*
|
|
|
|
* They're reference-counted, so just drop the reference
|
|
|
|
* count; it'll get freed when the reference count drops
|
|
|
|
* to 0.
|
|
|
|
*/
|
2021-10-15 22:47:28 +00:00
|
|
|
fvalue_regex_free(pcre);
|
2021-03-21 10:06:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-26 15:28:39 +00:00
|
|
|
static char *
|
2021-10-11 11:45:13 +00:00
|
|
|
fvalue_tostr(const void *data, gboolean pretty)
|
2021-09-26 15:28:39 +00:00
|
|
|
{
|
|
|
|
fvalue_t *fvalue = (fvalue_t*)data;
|
|
|
|
|
|
|
|
char *s, *repr;
|
|
|
|
|
|
|
|
s = fvalue_to_string_repr(NULL, fvalue, FTREPR_DFILTER, BASE_NONE);
|
2021-10-11 11:45:13 +00:00
|
|
|
if (pretty)
|
|
|
|
repr = g_strdup(s);
|
|
|
|
else
|
|
|
|
repr = g_strdup_printf("%s[%s]", fvalue_type_name(fvalue), s);
|
2021-09-26 15:28:39 +00:00
|
|
|
g_free(s);
|
|
|
|
return repr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2021-10-11 11:45:13 +00:00
|
|
|
field_tostr(const void *data, gboolean pretty _U_)
|
2021-09-26 15:28:39 +00:00
|
|
|
{
|
|
|
|
header_field_info *hfinfo = (header_field_info *)data;
|
|
|
|
|
|
|
|
return g_strdup(hfinfo->abbrev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2021-10-11 11:45:13 +00:00
|
|
|
pcre_tostr(const void *data, gboolean pretty _U_)
|
2021-09-26 15:28:39 +00:00
|
|
|
{
|
2021-10-15 22:47:28 +00:00
|
|
|
const fvalue_regex_t *pcre = data;
|
2021-09-26 15:28:39 +00:00
|
|
|
|
2021-10-15 22:47:28 +00:00
|
|
|
return g_strdup(fvalue_regex_pattern(pcre));
|
2021-09-26 15:28:39 +00:00
|
|
|
}
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
void
|
|
|
|
sttype_register_pointer(void)
|
|
|
|
{
|
|
|
|
static sttype_t field_type = {
|
|
|
|
STTYPE_FIELD,
|
|
|
|
"FIELD",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2021-09-26 15:28:39 +00:00
|
|
|
NULL,
|
|
|
|
field_tostr
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
|
|
|
static sttype_t fvalue_type = {
|
|
|
|
STTYPE_FVALUE,
|
|
|
|
"FVALUE",
|
|
|
|
NULL,
|
2019-01-27 17:02:03 +00:00
|
|
|
fvalue_free,
|
2021-09-26 15:28:39 +00:00
|
|
|
NULL,
|
|
|
|
fvalue_tostr
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
2021-03-21 10:06:17 +00:00
|
|
|
static sttype_t pcre_type = {
|
|
|
|
STTYPE_PCRE,
|
|
|
|
"PCRE",
|
|
|
|
NULL,
|
|
|
|
pcre_free,
|
2021-09-26 15:28:39 +00:00
|
|
|
NULL,
|
|
|
|
pcre_tostr
|
2021-03-21 10:06:17 +00:00
|
|
|
};
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
sttype_register(&field_type);
|
|
|
|
sttype_register(&fvalue_type);
|
2021-03-21 10:06:17 +00:00
|
|
|
sttype_register(&pcre_type);
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
2015-02-13 19:02:43 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2015-02-13 19:02:43 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|