diff options
-rw-r--r-- | epan/proto.c | 28 | ||||
-rw-r--r-- | epan/proto.h | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c index adbcb53dc8..64f6261e20 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -4701,6 +4701,34 @@ proto_register_field_array(const int parent, hf_register_info *hf, const int num } } +/* unregister already registered fields */ +void +proto_unregister_field (const int parent, gint hf_id) +{ + hf_register_info *hf; + protocol_t *proto; + GList *field; + + if (hf_id == -1 || hf_id == 0) + return; + + proto = find_protocol_by_id (parent); + if (!proto || !proto->fields) { + return; + } + + for (field = g_list_first (proto->fields); field; field = g_list_next (field)) { + hf = field->data; + if (*hf->p_id == hf_id) { + /* Found the hf_id in this protocol */ + g_tree_remove (gpa_name_tree, hf->hfinfo.abbrev); + proto->fields = g_list_remove_link (proto->fields, field); + proto->last_field = g_list_last (proto->fields); + break; + } + } +} + /* chars allowed in field abbrev */ static const guchar fld_abbrev_chars[256] = { diff --git a/epan/proto.h b/epan/proto.h index 799c770bd2..3f73af9c56 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -1580,6 +1580,12 @@ extern void proto_initialize_all_prefixes(void); extern void proto_register_field_array(const int parent, hf_register_info *hf, const int num_records); +/** Unregister an already registered field. + @param parent the protocol handle from proto_register_protocol() + @param hf_id the field to unregister */ +extern void +proto_unregister_field (const int parent, gint hf_id); + /** Register a protocol subtree (ett) array. @param indices array of ett indices @param num_indices the number of records in indices */ |