diff options
author | Tim Potter <tpot@samba.org> | 2003-08-04 02:49:04 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-08-04 02:49:04 +0000 |
commit | 4ccbfa3edca9d6b6abc2ad46f7734be82f5e994e (patch) | |
tree | 63a279850eb8eef07cd8b9f98496347eac14907f /packet-dcerpc.c | |
parent | 77f0aa01033ca862f0ba14692859051eb5b6430f (diff) | |
download | wireshark-4ccbfa3edca9d6b6abc2ad46f7734be82f5e994e.tar.gz wireshark-4ccbfa3edca9d6b6abc2ad46f7734be82f5e994e.tar.bz2 wireshark-4ccbfa3edca9d6b6abc2ad46f7734be82f5e994e.zip |
Guy suggested that the dcerpc opnum value_string code could be simplified
somewhat. Now the dynamic initialisation of the value_string is contained
in the value_string_from_subdissectors() function instead of being
distributed amongst the dcerpc dissectors.
svn path=/trunk/; revision=8123
Diffstat (limited to 'packet-dcerpc.c')
-rw-r--r-- | packet-dcerpc.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/packet-dcerpc.c b/packet-dcerpc.c index 381abc0977..42e480a35e 100644 --- a/packet-dcerpc.c +++ b/packet-dcerpc.c @@ -3,7 +3,7 @@ * Copyright 2001, Todd Sabin <tas@webspan.net> * Copyright 2003, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc.c,v 1.137 2003/07/21 09:10:00 guy Exp $ + * $Id: packet-dcerpc.c,v 1.138 2003/08/04 02:48:59 tpot Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -592,6 +592,7 @@ dcerpc_init_uuid (int proto, int ett, e_uuid_t *uuid, guint16 ver, { dcerpc_uuid_key *key = g_malloc (sizeof (*key)); dcerpc_uuid_value *value = g_malloc (sizeof (*value)); + header_field_info *hf_info; key->uuid = *uuid; key->ver = ver; @@ -603,6 +604,9 @@ dcerpc_init_uuid (int proto, int ett, e_uuid_t *uuid, guint16 ver, value->opnum_hf = opnum_hf; g_hash_table_insert (dcerpc_uuids, key, value); + + hf_info = proto_registrar_get_nth(opnum_hf); + hf_info->strings = value_string_from_subdissectors(procs); } /* Function to find the name of a registered protocol @@ -625,21 +629,27 @@ dcerpc_get_proto_name(e_uuid_t *uuid, guint16 ver) /* Create a value_string consisting of DCERPC opnum and name from a subdissector array. */ -value_string *value_string_from_subdissectors(dcerpc_sub_dissector *sd, - int num_sds) +value_string *value_string_from_subdissectors(dcerpc_sub_dissector *sd) { - value_string *vs; - int i; - - vs = g_malloc((num_sds + 1) * sizeof(value_string)); + value_string *vs = NULL; + int i, num_sd = 0; + + again: + for (i = 0; sd[i].name; i++) { + if (vs) { + vs[i].value = sd[i].num; + vs[i].strptr = sd[i].name; + } else + num_sd++; + } - for (i = 0; i < num_sds; i++) { - vs[i].value = sd[i].num; - vs[i].strptr = sd[i].name; + if (!vs) { + vs = g_malloc((num_sd + 1) * sizeof(value_string)); + goto again; } - vs[num_sds].value = 0; - vs[num_sds].strptr = NULL; + vs[num_sd].value = 0; + vs[num_sd].strptr = NULL; return vs; } |