diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-10-15 05:21:07 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-10-15 05:21:07 +0000 |
commit | 86576ce6ac55614848fea0b539899c07ba7999a2 (patch) | |
tree | f4b8267442ded365149398de908005bd7a117491 /epan | |
parent | e0e71226743cabaed94a6bd090f033009e0023c9 (diff) |
When registering a protocol, make sure there are no other protocols with
the same long name, short name, or filter name, and abort if there are.
Fix the duplicate names that found (and another name error found while
fixing one of those errors).
svn path=/trunk/; revision=6425
Diffstat (limited to 'epan')
-rw-r--r-- | epan/proto.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/epan/proto.c b/epan/proto.c index fb55c190ad..b90c804a50 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.74 2002/08/28 20:40:44 jmayer Exp $ + * $Id: proto.c,v 1.75 2002/10/15 05:21:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1992,6 +1992,33 @@ proto_item_add_subtree(proto_item *pi, gint idx) { } static gint +proto_match_short_name(gconstpointer p_arg, gconstpointer name_arg) +{ + const protocol_t *p = p_arg; + const char *name = name_arg; + + return g_strcasecmp(p->short_name, name_arg); +} + +static gint +proto_match_name(gconstpointer p_arg, gconstpointer name_arg) +{ + const protocol_t *p = p_arg; + const char *name = name_arg; + + return g_strcasecmp(p->name, name_arg); +} + +static gint +proto_match_filter_name(gconstpointer p_arg, gconstpointer name_arg) +{ + const protocol_t *p = p_arg; + const char *name = name_arg; + + return g_strcasecmp(p->filter_name, name_arg); +} + +static gint proto_compare_name(gconstpointer p1_arg, gconstpointer p2_arg) { const protocol_t *p1 = p1_arg; @@ -2007,6 +2034,16 @@ proto_register_protocol(char *name, char *short_name, char *filter_name) header_field_info *hfinfo; int proto_id; + /* + * Make sure there's not already a protocol with any of those + * names. Crash if there is, as that's an error in the code, + * and the code has to be fixed not to register more than one + * protocol with the same name. + */ + g_assert(g_list_find_custom(protocols, name, proto_match_name) == NULL); + g_assert(g_list_find_custom(protocols, short_name, proto_match_short_name) == NULL); + g_assert(g_list_find_custom(protocols, filter_name, proto_match_filter_name) == NULL); + /* Add this protocol to the list of known protocols; the list is sorted by protocol short name. */ protocol = g_malloc(sizeof (protocol_t)); |