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 /packet.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 'packet.c')
-rw-r--r-- | packet.c | 66 |
1 files changed, 65 insertions, 1 deletions
@@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.69 2000/03/27 17:53:20 gram Exp $ + * $Id: packet.c,v 1.70 2000/04/03 09:24:08 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -1243,3 +1243,67 @@ proto_register_frame(void) proto_register_field_array(proto_frame, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +/*********************** code added for sub-dissector lookup *********************/ + +dissector_t dissector_lookup( dissector_table_t table, guint32 pattern) { + +/* lookup a dissector based upon pattern. */ + + return g_hash_table_lookup( table, GUINT_TO_POINTER( pattern)); +} + + +void dissector_add( char *name, guint32 pattern, dissector_t dissector) { + +/* add an entry, lookup the dissector table for the specified field name, */ +/* if a valid table found, add the subdissector */ + + dissector_table_t sub_dissectors = find_dissector_table( name); + +/* sanity check */ + g_assert( sub_dissectors); + +/* do the table insertion */ + g_hash_table_insert( sub_dissectors, GUINT_TO_POINTER( pattern), + (gpointer)dissector); +} + + +void dissector_delete( char *name, guint32 pattern, dissector_t dissector) { + +/* delete the entry for this dissector at this pattern */ + +/* NOTE: this doesn't use the dissector call variable. It is included to */ +/* be consistant with the dissector_add and more importantly to be used */ +/* if the technique of adding a temporary dissector is implimented. */ +/* If temporary dissectors are deleted, then the original dissector must */ +/* be available. */ + + dissector_table_t sub_dissectors = find_dissector_table( name); + +/* sanity check */ + g_assert( sub_dissectors); + +/* remove the hash table entry */ + g_hash_table_remove( sub_dissectors, GUINT_TO_POINTER( pattern)); +} + + +dissector_table_t register_dissector_table( int id){ + +/* Create and register the dissector array for this field; returns */ +/* a pointer to the dissector table. */ + +/* NOTE: currently use the g_direct_XXX functions so all the hashing is done */ +/* by glib and we don't have to create hashing or comparison funtcions. */ + + + header_field_info *hfinfo = find_hfinfo_record(id); + + g_assert( hfinfo); + + hfinfo->sub_dissectors = g_hash_table_new( g_direct_hash, g_direct_equal); + return hfinfo->sub_dissectors; +} + |