diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-04-03 09:24:12 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-04-03 09:24:12 +0000 |
commit | c7d11f582d5f9acbb790e4f060a84e96b9238239 (patch) | |
tree | cb576aeb954452a7f2f21aebd4d865c7d7f9c9d9 /proto.c | |
parent | 560819cad25245359e17b35f3630f3872e1349c0 (diff) | |
download | wireshark-c7d11f582d5f9acbb790e4f060a84e96b9238239.tar.gz wireshark-c7d11f582d5f9acbb790e4f060a84e96b9238239.tar.bz2 wireshark-c7d11f582d5f9acbb790e4f060a84e96b9238239.zip |
Jeff Foster's patch to support attaching a hash table to a protocol
field, to allow dissectors to register their dissection routine in a
particular field's hash table with a particular "port" value, and to
make the TCP and UDP dissectors support that for their "port" field and
to look up ports in that hash table.
This replaces the hash table that the UDP dissector was using.
There's still more work needed to make this useful - right now, the hash
tables are attached to the protocol field in the register routines for
the TCP and UDP protocols, which means that the register routines for
protocols that run atop TCP and UDP can't use this unless their register
routines happen to be called after those for TCP and/or UDP, and several
other protocols need to attach hash tables to fields, and there's no
single global field for Ethernet types so we can't even attach a hash
table to such a field to allow protocols to register themselves with a
particular Ethertype - but it's a start.
svn path=/trunk/; revision=1779
Diffstat (limited to 'proto.c')
-rw-r--r-- | proto.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.56 2000/03/14 06:03:25 guy Exp $ + * $Id: proto.c,v 1.57 2000/04/03 09:24:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -72,10 +72,6 @@ static gboolean proto_tree_free_node(GNode *node, gpointer data); -static struct header_field_info* -find_hfinfo_record(int hfindex); - - static void fill_label_boolean(field_info *fi, gchar *label_str); static void fill_label_uint(field_info *fi, gchar *label_str); static void fill_label_enumerated_uint(field_info *fi, gchar *label_str); @@ -250,14 +246,29 @@ proto_tree_free_node(GNode *node, gpointer data) return FALSE; /* FALSE = do not end traversal of GNode tree */ } -/* Finds a record in the hf_info_records array. */ -static struct header_field_info* +/* Finds a record in the hf_info_records array by id. */ +struct header_field_info* find_hfinfo_record(int hfindex) { g_assert(hfindex >= 0 && hfindex < gpa_hfinfo->len); return g_ptr_array_index(gpa_hfinfo, hfindex); } +/* Finds a dissector table by field name. */ +dissector_table_t +find_dissector_table(const char *name) +{ + header_field_info *hfinfo; + int i, len; + + len = gpa_hfinfo->len; + for (i = 0; i < len ; i++) { + hfinfo = find_hfinfo_record(i); + if (strcmp(name, hfinfo->abbrev) == 0) + return hfinfo->sub_dissectors; + } + return NULL; +} /* Add a node with no text */ proto_item * @@ -930,6 +941,8 @@ proto_register_protocol(char *name, char *abbrev) hfinfo->blurb = ""; hfinfo->parent = -1; /* this field differentiates protos and fields */ + hfinfo->sub_dissectors = NULL; /* clear sub-dissector table pointer */ + return proto_register_field_init(hfinfo, hfinfo->parent); } |