forked from osmocom/wireshark
add proto_all_finfos() that will return a GPtrArray containing every finfo found in a tree.
svn path=/trunk/; revision=17741
This commit is contained in:
parent
c9179bea2e
commit
850dfe8fa2
|
@ -429,6 +429,7 @@ prefs_set_pref
|
||||||
process_reassembled_data
|
process_reassembled_data
|
||||||
process_stat_cmd_arg
|
process_stat_cmd_arg
|
||||||
protocols_module DATA
|
protocols_module DATA
|
||||||
|
proto_all_finfos
|
||||||
proto_can_match_selected
|
proto_can_match_selected
|
||||||
proto_can_toggle_protocol
|
proto_can_toggle_protocol
|
||||||
proto_construct_dfilter_string
|
proto_construct_dfilter_string
|
||||||
|
|
48
epan/proto.c
48
epan/proto.c
|
@ -1033,6 +1033,7 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, int hfindex,
|
||||||
/* If the proto_tree wants to keep a record of this finfo
|
/* If the proto_tree wants to keep a record of this finfo
|
||||||
* for quick lookup, then record it. */
|
* for quick lookup, then record it. */
|
||||||
if (new_fi->hfinfo->ref_count) {
|
if (new_fi->hfinfo->ref_count) {
|
||||||
|
/*HERE*/
|
||||||
hash = PTREE_DATA(tree)->interesting_hfids;
|
hash = PTREE_DATA(tree)->interesting_hfids;
|
||||||
ptrs = g_hash_table_lookup(hash, GINT_TO_POINTER(hfindex));
|
ptrs = g_hash_table_lookup(hash, GINT_TO_POINTER(hfindex));
|
||||||
if (ptrs) {
|
if (ptrs) {
|
||||||
|
@ -2708,6 +2709,7 @@ proto_tree_add_pi(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
||||||
/* If the proto_tree wants to keep a record of this finfo
|
/* If the proto_tree wants to keep a record of this finfo
|
||||||
* for quick lookup, then record it. */
|
* for quick lookup, then record it. */
|
||||||
if (fi->hfinfo->ref_count) {
|
if (fi->hfinfo->ref_count) {
|
||||||
|
/*HERE*/
|
||||||
hash = PTREE_DATA(tree)->interesting_hfids;
|
hash = PTREE_DATA(tree)->interesting_hfids;
|
||||||
ptrs = g_hash_table_lookup(hash, GINT_TO_POINTER(hfindex));
|
ptrs = g_hash_table_lookup(hash, GINT_TO_POINTER(hfindex));
|
||||||
if (ptrs) {
|
if (ptrs) {
|
||||||
|
@ -4572,12 +4574,13 @@ proto_get_finfo_ptr_array(proto_tree *tree, int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Helper struct and function for proto_find_info() */
|
/* Helper struct for proto_find_info() and proto_all_finfos() */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GPtrArray *array;
|
GPtrArray *array;
|
||||||
int id;
|
int id;
|
||||||
} ffdata_t;
|
} ffdata_t;
|
||||||
|
|
||||||
|
/* Helper function for proto_find_info() */
|
||||||
static gboolean
|
static gboolean
|
||||||
find_finfo(proto_node *node, gpointer data)
|
find_finfo(proto_node *node, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -4587,27 +4590,54 @@ find_finfo(proto_node *node, gpointer data)
|
||||||
g_ptr_array_add(((ffdata_t*)data)->array, fi);
|
g_ptr_array_add(((ffdata_t*)data)->array, fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't stop traversing. */
|
/* Don't stop traversing. */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return GPtrArray* of field_info pointers for all hfindex that appear in a tree.
|
/* Return GPtrArray* of field_info pointers for all hfindex that appear in a tree.
|
||||||
* This works on any proto_tree, primed or unprimed, but actually searches
|
* This works on any proto_tree, primed or unprimed, but actually searches
|
||||||
* the tree, so it is slower than using proto_get_finfo_ptr_array on a primed tree.
|
* the tree, so it is slower than using proto_get_finfo_ptr_array on a primed tree.
|
||||||
* The caller does need to free the returned GPtrArray with
|
* The caller does need to free the returned GPtrArray with
|
||||||
* g_ptr_array_free(<array>, FALSE).
|
* g_ptr_array_free(<array>, FALSE).
|
||||||
*/
|
*/
|
||||||
GPtrArray*
|
GPtrArray*
|
||||||
proto_find_finfo(proto_tree *tree, int id)
|
proto_find_finfo(proto_tree *tree, int id)
|
||||||
{
|
{
|
||||||
ffdata_t ffdata;
|
ffdata_t ffdata;
|
||||||
|
|
||||||
ffdata.array = g_ptr_array_new();
|
ffdata.array = g_ptr_array_new();
|
||||||
ffdata.id = id;
|
ffdata.id = id;
|
||||||
|
|
||||||
proto_tree_traverse_pre_order(tree, find_finfo, &ffdata);
|
proto_tree_traverse_pre_order(tree, find_finfo, &ffdata);
|
||||||
|
|
||||||
|
return ffdata.array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Helper function for proto_all_finfos() */
|
||||||
|
static gboolean
|
||||||
|
every_finfo(proto_node *node, gpointer data)
|
||||||
|
{
|
||||||
|
field_info *fi = PITEM_FINFO(node);
|
||||||
|
if (fi && fi->hfinfo) {
|
||||||
|
g_ptr_array_add(((ffdata_t*)data)->array, fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't stop traversing. */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return GPtrArray* of field_info pointers containing all hfindexes that appear in a tree. */
|
||||||
|
GPtrArray*
|
||||||
|
proto_all_finfos(proto_tree *tree)
|
||||||
|
{
|
||||||
|
ffdata_t ffdata;
|
||||||
|
|
||||||
|
ffdata.array = g_ptr_array_new();
|
||||||
|
ffdata.id = 0;
|
||||||
|
|
||||||
|
proto_tree_traverse_pre_order(tree, every_finfo, &ffdata);
|
||||||
|
|
||||||
return ffdata.array;
|
return ffdata.array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1475,6 +1475,10 @@ extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex);
|
||||||
* proto_get_finfo_ptr_array because it has to search through the tree. */
|
* proto_get_finfo_ptr_array because it has to search through the tree. */
|
||||||
extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex);
|
extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex);
|
||||||
|
|
||||||
|
/* Return GPtrArray* of field_info pointers containg all hfindexes that appear in
|
||||||
|
* tree. */
|
||||||
|
extern GPtrArray* proto_all_finfos(proto_tree *tree);
|
||||||
|
|
||||||
/** Dumps a glossary of the protocol registrations to STDOUT */
|
/** Dumps a glossary of the protocol registrations to STDOUT */
|
||||||
extern void proto_registrar_dump_protocols(void);
|
extern void proto_registrar_dump_protocols(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue