forked from osmocom/wireshark
Allow json dissector to receive a string through dissector data and give dissector data priority over pinfo->private_data (to discourage it's use)
svn path=/trunk/; revision=53042
This commit is contained in:
parent
ac09e775c9
commit
8dc0db8d72
|
@ -101,8 +101,8 @@ typedef struct {
|
||||||
|
|
||||||
} json_parser_data_t;
|
} json_parser_data_t;
|
||||||
|
|
||||||
static void
|
static int
|
||||||
dissect_json(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
dissect_json(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
||||||
{
|
{
|
||||||
proto_tree *json_tree = NULL;
|
proto_tree *json_tree = NULL;
|
||||||
proto_item *ti = NULL;
|
proto_item *ti = NULL;
|
||||||
|
@ -114,18 +114,24 @@ dissect_json(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
data_name = pinfo->match_string;
|
data_name = pinfo->match_string;
|
||||||
if (!(data_name && data_name[0])) {
|
if (! (data_name && data_name[0])) {
|
||||||
/*
|
/*
|
||||||
* No information from "match_string"
|
* No information from "match_string"
|
||||||
*/
|
*/
|
||||||
|
data_name = (char *)data;
|
||||||
|
if (! (data_name && data_name[0])) {
|
||||||
|
/*
|
||||||
|
* No information from dissector data
|
||||||
|
*/
|
||||||
data_name = (char *)(pinfo->private_data);
|
data_name = (char *)(pinfo->private_data);
|
||||||
if (!(data_name && data_name[0])) {
|
if (! (data_name && data_name[0])) {
|
||||||
/*
|
/*
|
||||||
* No information from "private_data"
|
* No information from "private_data"
|
||||||
*/
|
*/
|
||||||
data_name = NULL;
|
data_name = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tree) {
|
if (tree) {
|
||||||
ti = proto_tree_add_item(tree, hfi_json, tvb, 0, -1, ENC_NA);
|
ti = proto_tree_add_item(tree, hfi_json, tvb, 0, -1, ENC_NA);
|
||||||
|
@ -164,6 +170,8 @@ dissect_json(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
} else if (data_name) {
|
} else if (data_name) {
|
||||||
col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "(%s)", data_name);
|
col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "(%s)", data_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return tvb_length(tvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void before_object(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) {
|
static void before_object(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) {
|
||||||
|
@ -578,7 +586,7 @@ proto_register_json(void) {
|
||||||
proto_register_fields(proto_json, hfi, array_length(hfi));
|
proto_register_fields(proto_json, hfi, array_length(hfi));
|
||||||
proto_register_subtree_array(ett, array_length(ett));
|
proto_register_subtree_array(ett, array_length(ett));
|
||||||
|
|
||||||
register_dissector("json", dissect_json, proto_json);
|
new_register_dissector("json", dissect_json, proto_json);
|
||||||
|
|
||||||
init_json_parser();
|
init_json_parser();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* packet-text-media.c
|
/* packet-text-media.c
|
||||||
* Routines for text-based media dissection.
|
* Routines for text-based media dissection.
|
||||||
*
|
*
|
||||||
* NOTE - The media type is either found in pinfo->match_string
|
* NOTE - The media type is either found in pinfo->match_string,
|
||||||
* or in pinfo->private_data.
|
* pinfo->private_data, or passed into the dissector (preferred)
|
||||||
*
|
*
|
||||||
* (C) Olivier Biot, 2004.
|
* (C) Olivier Biot, 2004.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue