Add a "proto_register_dcerpc_smb()" which registers ett_ values for
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 18 Apr 2002 00:29:17 +0000 (00:29 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 18 Apr 2002 00:29:17 +0000 (00:29 +0000)
"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".

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5196 f5534014-38df-0310-8fa8-9805f1628bb7

Makefile.am
Makefile.nmake
packet-dcerpc-netlogon.c
packet-dcerpc-nt.c
packet-dcerpc-nt.h
packet-dcerpc-samr.c
packet-dcerpc-spoolss.c

index a950616b447270e0677e715070242e4422a7dc64..323619221d62af3880503775f00931c7750a3508 100644 (file)
@@ -1,7 +1,7 @@
 # Makefile.am
 # Automake file for Ethereal
 #
 # 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>
 #
 # 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-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  \
        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-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 \
        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          \
        llcsaps.h      \
        nlpid.h        \
        oui.h          \
-       packet-dcerpc-nt.h \
-       packet-dcerpc-nt.c \
        pcap-util.c    \
        pcap-util.h    \
        ppptypes.h     \
        pcap-util.c    \
        pcap-util.h    \
        ppptypes.h     \
index d2fde5dfd71a16b2c4a10af4c85cc40bc10b55fc..5c939b070190c632732d14d9f46dc3e8b031d14f 100644 (file)
@@ -1,7 +1,7 @@
 ## Makefile for building ethereal.exe with Microsoft C and nmake
 ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
 #
 ## 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>
 
 include config.nmake
 include <win32.mak>
@@ -27,8 +27,8 @@ DISSECTOR_SRC = \
        packet-afs.c   \
        packet-aim.c   \
        packet-arp.c   \
        packet-afs.c   \
        packet-aim.c   \
        packet-arp.c   \
-       packet-ascend.c\
        packet-asap.c  \
        packet-asap.c  \
+       packet-ascend.c\
        packet-atalk.c \
        packet-atm.c   \
        packet-auto_rp.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-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  \
        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      \
        getopt.obj       \
        in_cksum.obj     \
        ipproto.obj      \
-       packet-dcerpc-nt.obj \
        pcap-util.obj    \
        prefs.obj        \
        print.obj        \
        pcap-util.obj    \
        prefs.obj        \
        print.obj        \
index 9a7d08e85b0d23577a7927bb3692a131d2dea488..62ebbcc649d8f18d99c8de59d33985b6d9d756ea 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *  2002 structure and command dissectors by Ronnie Sahlberg
  *
  * 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>
  *
  * 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;
 
 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 }
 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 },
 };
 
         {0, NULL, NULL,  NULL },
 };
 
-static void netlogon_init(void)
-{
-       /* Initialise DCERPC/SMB data structures */
-
-       dcerpc_smb_init();
-}
-
 void 
 proto_register_dcerpc_netlogon(void)
 {
 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));
         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
 }
 
 void
index e10469df1d7dbad28a46dd7d953d028ebb096714..66d99b55bac79316665584610b6b9380609b24b9 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for DCERPC over SMB packet disassembly
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *
  * 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>
  *
  * 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
  */
 
  * 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,
        };
 
 
        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));
 
        /* 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
 }
 
 /* Check if there is unparsed data remaining in a frame and display an
index 49dffb26496e6fe5a59e0ffa36f22868ac59ffeb..4a7dfb08e4e3b04c1c6dd85988b0687a7e79a58c 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for DCERPC over SMB packet disassembly
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *
  * 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>
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #ifndef __PACKET_DCERPC_NT_H
 #define __PACKET_DCEPRC_NT_H
 
 #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);
 /* 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);
 
 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
 /* Dissect NT specific things */
 
 int
index 8a2845961cb7770c4e8c6a6699bf41a26802e30e..30c50bb275d86ee8f051bc37b4fc8b5ea60481d1 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2001, Tim Potter <tpot@samba.org>
  *   2002 Added all command dissectors  Ronnie Sahlberg
  *
  * 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>
  *
  * 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 },
 };
 
         {0, NULL, NULL,  NULL },
 };
 
-static void samr_init(void)
-{
-       /* Initialise DCERPC/SMB data structures */
-
-       dcerpc_smb_init();
-}
-
 void 
 proto_register_dcerpc_samr(void)
 {
 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));
 
         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
 }
 
 void
index a1f9a9fdb7e9d309099b69c6f906598bc5df2e7d..1da0790fc91b6e64720d33df0f0b02d29f4483ee 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for SMB \PIPE\spoolss packet disassembly
  * Copyright 2001-2002, Tim Potter <tpot@samba.org>
  *
  * 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>
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -3064,13 +3064,6 @@ static dcerpc_sub_dissector dcerpc_spoolss_dissectors[] = {
  * Dissector initialisation function
  */
 
  * Dissector initialisation function
  */
 
-static void spoolss_init(void)
-{
-       /* Initialise DCERPC/SMB data structures */
-
-       dcerpc_smb_init();
-}
-
 /* Protocol registration */
 
 static int proto_dcerpc_spoolss = -1;
 /* 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));
                 "Microsoft Spool Subsystem", "SPOOLSS", "spoolss");
 
         proto_register_subtree_array(ett, array_length(ett));
-
-       register_init_routine(spoolss_init);
 }
 
 /* Protocol handoff */
 }
 
 /* Protocol handoff */