diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-04-18 00:29:17 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-04-18 00:29:17 +0000 |
commit | 92e27e03c14844a3a7f559ea7e70c2ad8e5482d8 (patch) | |
tree | a1c94f2a9a8e62f393b8ad3c5a7e1bf8082aad61 /packet-dcerpc-nt.c | |
parent | a7c4e209cb65cfdef6881760c97c845fa81821ac (diff) |
Add a "proto_register_dcerpc_smb()" which registers ett_ values for
"packet-dcerpc-nt.c", and registers "dcerpc_smb_init()" as an
initialization routine. Take the ett_ registration out of the latter
routine, and also take out the "do this only once" stuff.
Get rid of the initialization routines for netlogon, samr, and spoolss;
they just call "dcerpc_smb_init()", which is now an initialization
routine of its own.
The policy hash initialization should be done before every capture, so
it should be done in an initialization routine, and should not do any
"do this only once" stuff. It should also be called only once before
every capture, rather than 3 times.
The ett_ initialization should, however, be done at the same time all
other ett_ initialization is done - at protocol registration time - so
it should be done in a "proto_register_" routine.
This fixes a bug I saw wherein
1) the tree for Unicode strings was open by default
and
2) if you closed one and then exited, Ethereal would crash.
The problem is that "proto_register_subtree_array()" doesn't expand the
array, it just bumps the number of registered ett_ values; the array is
allocated in "proto_init()". As such, if you register ett_ values with
"proto_register_subtree_array()" *after* "proto_init()" is called - and,
even for the first capture, initialization routines are called after
"proto_init()" is called - you will get ett_ numbers that go past the
number of elements in the array.
Move the declaration of "ett_nt_unicode_string" to "packet-dcerpc-nt.h",
as it's exported from "packet-dcerpc-nt.c".
Get rid of the declaration of "dcerpc_smb_init()" in
"packet-dcerpc-nt.h", and make it static, as it's no longer called from
outside "packet-dcerpc-nt.c".
svn path=/trunk/; revision=5196
Diffstat (limited to 'packet-dcerpc-nt.c')
-rw-r--r-- | packet-dcerpc-nt.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/packet-dcerpc-nt.c b/packet-dcerpc-nt.c index e10469df1d..66d99b55ba 100644 --- a/packet-dcerpc-nt.c +++ b/packet-dcerpc-nt.c @@ -2,7 +2,7 @@ * Routines for DCERPC over SMB packet disassembly * Copyright 2001, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc-nt.c,v 1.26 2002/04/17 07:52:26 tpot Exp $ + * $Id: packet-dcerpc-nt.c,v 1.27 2002/04/18 00:29:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -861,28 +861,33 @@ static void init_pol_hash(void) * Initialise global DCERPC/SMB data structures */ -void dcerpc_smb_init(void) +static void dcerpc_smb_init(void) { - static gboolean done_init; + /* Initialise policy handle hash */ + + init_pol_hash(); +} +/* + * Register ett_ values, and register "dcerpc_smb_init()" as an + * initialisation routine. + */ +void proto_register_dcerpc_smb(void) +{ static gint *ett[] = { &ett_nt_unicode_string, &ett_nt_policy_hnd, }; - if (done_init) - return; - - /* Initialise policy handle hash */ - - init_pol_hash(); - /* Register ett's */ proto_register_subtree_array(ett, array_length(ett)); - done_init = TRUE; + /* Register a routine to be called whenever initialisation + is done. */ + + register_init_routine(dcerpc_smb_init); } /* Check if there is unparsed data remaining in a frame and display an |