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 | |
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
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | Makefile.nmake | 6 | ||||
-rw-r--r-- | packet-dcerpc-netlogon.c | 13 | ||||
-rw-r--r-- | packet-dcerpc-nt.c | 27 | ||||
-rw-r--r-- | packet-dcerpc-nt.h | 10 | ||||
-rw-r--r-- | packet-dcerpc-samr.c | 11 | ||||
-rw-r--r-- | packet-dcerpc-spoolss.c | 11 |
7 files changed, 31 insertions, 53 deletions
diff --git a/Makefile.am b/Makefile.am index a950616b44..323619221d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.421 2002/04/15 21:47:59 guy Exp $ +# $Id: Makefile.am,v 1.422 2002/04/18 00:29:16 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -105,6 +105,7 @@ DISSECTOR_SRC = \ packet-dcerpc-mgmt.c \ packet-dcerpc-ndr.c \ packet-dcerpc-netlogon.c \ + packet-dcerpc-nt.c \ packet-dcerpc-oxid.c \ packet-dcerpc-reg.c \ packet-dcerpc-remact.c \ @@ -358,6 +359,7 @@ noinst_HEADERS = \ packet-dcerpc-dfs.h \ packet-dcerpc-lsa.h \ packet-dcerpc-netlogon.h \ + packet-dcerpc-nt.h \ packet-dcerpc-reg.h \ packet-dcerpc-samr.h \ packet-dcerpc-spoolss.h \ @@ -478,8 +480,6 @@ ETHEREAL_COMMON_SRC = \ llcsaps.h \ nlpid.h \ oui.h \ - packet-dcerpc-nt.h \ - packet-dcerpc-nt.c \ pcap-util.c \ pcap-util.h \ ppptypes.h \ diff --git a/Makefile.nmake b/Makefile.nmake index d2fde5dfd7..5c939b0701 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake # -# $Id: Makefile.nmake,v 1.179 2002/04/15 21:47:59 guy Exp $ +# $Id: Makefile.nmake,v 1.180 2002/04/18 00:29:16 guy Exp $ include config.nmake include <win32.mak> @@ -27,8 +27,8 @@ DISSECTOR_SRC = \ packet-afs.c \ packet-aim.c \ packet-arp.c \ - packet-ascend.c\ packet-asap.c \ + packet-ascend.c\ packet-atalk.c \ packet-atm.c \ packet-auto_rp.c \ @@ -56,6 +56,7 @@ DISSECTOR_SRC = \ packet-dcerpc-mgmt.c \ packet-dcerpc-ndr.c \ packet-dcerpc-netlogon.c \ + packet-dcerpc-nt.c \ packet-dcerpc-oxid.c \ packet-dcerpc-reg.c \ packet-dcerpc-remact.c \ @@ -272,7 +273,6 @@ ETHEREAL_COMMON_OBJECTS = \ getopt.obj \ in_cksum.obj \ ipproto.obj \ - packet-dcerpc-nt.obj \ pcap-util.obj \ prefs.obj \ print.obj \ diff --git a/packet-dcerpc-netlogon.c b/packet-dcerpc-netlogon.c index 9a7d08e85b..62ebbcc649 100644 --- a/packet-dcerpc-netlogon.c +++ b/packet-dcerpc-netlogon.c @@ -3,7 +3,7 @@ * Copyright 2001, Tim Potter <tpot@samba.org> * 2002 structure and command dissectors by Ronnie Sahlberg * - * $Id: packet-dcerpc-netlogon.c,v 1.15 2002/04/17 09:32:48 sahlberg Exp $ + * $Id: packet-dcerpc-netlogon.c,v 1.16 2002/04/18 00:29:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -186,8 +186,6 @@ static gint ett_BLOB = -1; static gint ett_rid_array = -1; static gint ett_attrib_array = -1; -extern gint ett_nt_unicode_string; - static e_uuid_t uuid_dcerpc_netlogon = { 0x12345678, 0x1234, 0xabcd, { 0xef, 0x00, 0x01, 0x23, 0x45, 0x67, 0xcf, 0xfb } @@ -5134,13 +5132,6 @@ static dcerpc_sub_dissector dcerpc_netlogon_dissectors[] = { {0, NULL, NULL, NULL }, }; -static void netlogon_init(void) -{ - /* Initialise DCERPC/SMB data structures */ - - dcerpc_smb_init(); -} - void proto_register_dcerpc_netlogon(void) { @@ -5559,8 +5550,6 @@ static hf_register_info hf[] = { proto_register_field_array(proto_dcerpc_netlogon, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - register_init_routine(netlogon_init); } void 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 diff --git a/packet-dcerpc-nt.h b/packet-dcerpc-nt.h index 49dffb2649..4a7dfb08e4 100644 --- a/packet-dcerpc-nt.h +++ b/packet-dcerpc-nt.h @@ -2,7 +2,7 @@ * Routines for DCERPC over SMB packet disassembly * Copyright 2001, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc-nt.h,v 1.20 2002/04/17 10:29:09 sahlberg Exp $ + * $Id: packet-dcerpc-nt.h,v 1.21 2002/04/18 00:29:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -26,6 +26,11 @@ #ifndef __PACKET_DCERPC_NT_H #define __PACKET_DCEPRC_NT_H +/* + * ett_ value for Unicode strings. + */ +extern gint ett_nt_unicode_string; + /* Routines for parsing simple types */ int prs_align(int offset, int n); @@ -143,9 +148,6 @@ void dcerpc_smb_check_long_frame(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree); -void -dcerpc_smb_init(void); - /* Dissect NT specific things */ int diff --git a/packet-dcerpc-samr.c b/packet-dcerpc-samr.c index 8a2845961c..30c50bb275 100644 --- a/packet-dcerpc-samr.c +++ b/packet-dcerpc-samr.c @@ -3,7 +3,7 @@ * Copyright 2001, Tim Potter <tpot@samba.org> * 2002 Added all command dissectors Ronnie Sahlberg * - * $Id: packet-dcerpc-samr.c,v 1.31 2002/04/17 11:32:24 tpot Exp $ + * $Id: packet-dcerpc-samr.c,v 1.32 2002/04/18 00:29:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -4664,13 +4664,6 @@ static dcerpc_sub_dissector dcerpc_samr_dissectors[] = { {0, NULL, NULL, NULL }, }; -static void samr_init(void) -{ - /* Initialise DCERPC/SMB data structures */ - - dcerpc_smb_init(); -} - void proto_register_dcerpc_samr(void) { @@ -5042,8 +5035,6 @@ proto_register_dcerpc_samr(void) proto_register_field_array (proto_dcerpc_samr, hf, array_length (hf)); proto_register_subtree_array(ett, array_length(ett)); - - register_init_routine(samr_init); } void diff --git a/packet-dcerpc-spoolss.c b/packet-dcerpc-spoolss.c index a1f9a9fdb7..1da0790fc9 100644 --- a/packet-dcerpc-spoolss.c +++ b/packet-dcerpc-spoolss.c @@ -2,7 +2,7 @@ * Routines for SMB \PIPE\spoolss packet disassembly * Copyright 2001-2002, Tim Potter <tpot@samba.org> * - * $Id: packet-dcerpc-spoolss.c,v 1.16 2002/04/09 04:41:40 tpot Exp $ + * $Id: packet-dcerpc-spoolss.c,v 1.17 2002/04/18 00:29:17 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -3064,13 +3064,6 @@ static dcerpc_sub_dissector dcerpc_spoolss_dissectors[] = { * Dissector initialisation function */ -static void spoolss_init(void) -{ - /* Initialise DCERPC/SMB data structures */ - - dcerpc_smb_init(); -} - /* Protocol registration */ static int proto_dcerpc_spoolss = -1; @@ -3110,8 +3103,6 @@ proto_register_dcerpc_spoolss(void) "Microsoft Spool Subsystem", "SPOOLSS", "spoolss"); proto_register_subtree_array(ett, array_length(ett)); - - register_init_routine(spoolss_init); } /* Protocol handoff */ |