aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/docsis
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-04-17 05:44:00 +0000
committerGuy Harris <guy@alum.mit.edu>2006-04-17 05:44:00 +0000
commitacb0e6d237ee125288dccca62ed29dffaacd4d05 (patch)
treec40dfceda8e6c224c8f7e97acbfec24bcfe82dd9 /plugins/docsis
parent8d17de8776f188626d50e2f66b380c41802adc99 (diff)
Pull the plugin-specific code into "plugin.c", and generate a
"register.c" with "make-reg-dotc"/"make-reg-dotc.py". Pull the lists of dissector .c and .h files into Makefile.common and have Makefile.am and Makefile.nmake use it. svn path=/trunk/; revision=17883
Diffstat (limited to 'plugins/docsis')
-rw-r--r--plugins/docsis/Makefile.am65
-rw-r--r--plugins/docsis/Makefile.common67
-rw-r--r--plugins/docsis/Makefile.nmake63
-rw-r--r--plugins/docsis/packet-docsis.c92
-rw-r--r--plugins/docsis/plugin.c59
5 files changed, 237 insertions, 109 deletions
diff --git a/plugins/docsis/Makefile.am b/plugins/docsis/Makefile.am
index 26468dfd5d..d653db540f 100644
--- a/plugins/docsis/Makefile.am
+++ b/plugins/docsis/Makefile.am
@@ -24,10 +24,17 @@
INCLUDES = -I$(top_srcdir) -I$(includedir)
+include Makefile.common
+
plugindir = @plugindir@
plugin_LTLIBRARIES = docsis.la
-docsis_la_SOURCES = packet-intrngreq.c packet-type29ucd.c packet-docsis.c packet-bpkmattr.c packet-dsarsp.c packet-macmgmt.c packet-rngrsp.c packet-bpkmreq.c packet-dscack.c packet-map.c packet-tlv.c packet-bpkmrsp.c packet-dscreq.c packet-regack.c packet-uccreq.c packet-dscrsp.c packet-regreq.c packet-uccrsp.c packet-dsaack.c packet-dsdreq.c packet-regrsp.c packet-ucd.c packet-dsareq.c packet-dsdrsp.c packet-rngreq.c packet-vendor.c packet-docsis.h packet-tlv.h moduleinfo.h packet-dccack.c packet-dccreq.c packet-dccrsp.c packet-dcd.c
+docsis_la_SOURCES = \
+ plugin.c \
+ register.c \
+ moduleinfo.h \
+ $(DISSECTOR_SRC) \
+ $(DISSECTOR_INCLUDES)
docsis_la_LDFLAGS = -module -avoid-version
docsis_la_LIBADD = @PLUGIN_LIBS@
@@ -36,6 +43,59 @@ docsis_la_LIBADD = @PLUGIN_LIBS@
# add them here.
LIBS =
+#
+# Build "register.c", which contains a function "register_all_protocols()"
+# that calls the register routines for all protocols.
+#
+# We do this by scanning sources. If that turns out to be too slow,
+# maybe we could just require every .o file to have an register routine
+# of a given name (packet-aarp.o -> proto_register_aarp, etc.).
+#
+# Formatting conventions: The name of the proto_register_* routines must
+# start in column zero, or must be preceded only by "void " starting in
+# column zero, and must not be inside #if.
+#
+# DISSECTOR_SRC is assumed to have all the files that need to be scanned.
+#
+# For some unknown reason, having a big "for" loop in the Makefile
+# to scan all the files doesn't work with some "make"s; they seem to
+# pass only the first few names in the list to the shell, for some reason.
+#
+# Therefore, we have a script to generate the "register.c" file.
+#
+# The first argument is the name of the file to write.
+# The second argument is the directory in which the source files live.
+# All subsequent arguments are the files to scan.
+#
+register.c: $(DISSECTOR_SRC) $(top_srcdir)/tools/make-reg-dotc \
+ $(top_srcdir)/tools/make-reg-dotc.py
+ @if test -n $(PYTHON); then \
+ echo Making register.c with python ; \
+ $(PYTHON) $(top_srcdir)/tools/make-reg-dotc.py $(srcdir) $(DISSECTOR_SRC) ; \
+ else \
+ echo Making register.c with shell script ; \
+ $(top_srcdir)/tools/make-reg-dotc register.c $(srcdir) \
+ $(plugin_src) $(DISSECTOR_SRC) ; \
+ fi
+
+#
+# Currently register.c can be included in the distribution because
+# we always build all protocol dissectors. We used to have to check
+# whether or not to build the snmp dissector. If we again need to
+# variably build something, making register.c non-portable, uncomment
+# the dist-hook line below.
+#
+# Oh, yuk. We don't want to include "register.c" in the distribution, as
+# its contents depend on the configuration, and therefore we want it
+# to be built when the first "make" is done; however, Automake insists
+# on putting *all* source into the distribution.
+#
+# We work around this by having a "dist-hook" rule that deletes
+# "register.c", so that "dist" won't pick it up.
+#
+#dist-hook:
+# @rm -f $(distdir)/register.c
+
CLEANFILES = \
docsis \
*~
@@ -44,5 +104,6 @@ MAINTAINERCLEANFILES = \
Makefile.in
EXTRA_DIST = \
- Makefile.nmake \
+ Makefile.common \
+ Makefile.nmake \
README
diff --git a/plugins/docsis/Makefile.common b/plugins/docsis/Makefile.common
new file mode 100644
index 0000000000..50e4723d7f
--- /dev/null
+++ b/plugins/docsis/Makefile.common
@@ -0,0 +1,67 @@
+# Makefile.common for Ethereal/docsis subdissectors
+# Contains the stuff from Makefile.am and Makefile.nmake that is
+# a) common to both files and
+# b) portable between both files
+#
+# $Id$
+#
+# Ethereal - Network traffic analyzer
+# By Gerald Combs <gerald@ethereal.com>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# the name of the plugin
+PLUGIN_NAME = docsis
+
+# the dissector sources (without any helpers)
+DISSECTOR_SRC = \
+ packet-intrngreq.c \
+ packet-type29ucd.c \
+ packet-docsis.c \
+ packet-bpkmattr.c \
+ packet-dsarsp.c \
+ packet-macmgmt.c \
+ packet-rngrsp.c \
+ packet-bpkmreq.c \
+ packet-dscack.c \
+ packet-map.c \
+ packet-tlv.c \
+ packet-bpkmrsp.c \
+ packet-dscreq.c \
+ packet-regack.c \
+ packet-uccreq.c \
+ packet-dscrsp.c \
+ packet-regreq.c \
+ packet-uccrsp.c \
+ packet-dsaack.c \
+ packet-dsdreq.c \
+ packet-regrsp.c \
+ packet-ucd.c \
+ packet-dsareq.c \
+ packet-dsdrsp.c \
+ packet-rngreq.c \
+ packet-vendor.c \
+ packet-dccack.c \
+ packet-dccreq.c \
+ packet-dccrsp.c \
+ packet-dcd.c
+
+# corresponding headers
+DISSECTOR_INCLUDES = \
+ packet-docsis.h \
+ packet-tlv.h
+
+
diff --git a/plugins/docsis/Makefile.nmake b/plugins/docsis/Makefile.nmake
index add44886a2..891cf6442e 100644
--- a/plugins/docsis/Makefile.nmake
+++ b/plugins/docsis/Makefile.nmake
@@ -1,3 +1,5 @@
+# Makefile.nmake
+# nmake file for for Ethereal/docsis subdissectors
#
# $Id$
#
@@ -6,6 +8,8 @@ include ..\..\config.nmake
############### no need to modify below this line #########
+include Makefile.common
+
CFLAGS=/DHAVE_CONFIG_H /I../.. /I../../wiretap $(GLIB_CFLAGS) \
/I$(PCAP_DIR)\include -D_U_="" $(LOCAL_CFLAGS)
@@ -15,26 +19,55 @@ LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)
LINK_PLUGIN_WITH=..\..\epan\libethereal.lib
CFLAGS=/DHAVE_WIN32_LIBETHEREAL_LIB /D_NEED_VAR_IMPORT_ $(CFLAGS)
-OBJECTS=packet-intrngreq.obj packet-type29ucd.obj \
- packet-docsis.obj packet-bpkmattr.obj \
- packet-dsarsp.obj packet-macmgmt.obj \
- packet-rngrsp.obj packet-bpkmreq.obj \
- packet-dscack.obj packet-map.obj \
- packet-tlv.obj packet-bpkmrsp.obj \
- packet-dscreq.obj packet-regack.obj \
- packet-uccreq.obj packet-dscrsp.obj \
- packet-regreq.obj packet-uccrsp.obj \
- packet-dsaack.obj packet-dsdreq.obj \
- packet-regrsp.obj packet-ucd.obj \
- packet-dsareq.obj packet-dsdrsp.obj \
- packet-rngreq.obj packet-vendor.obj \
- packet-dccack.obj packet-dccreq.obj \
- packet-dccrsp.obj packet-dcd.obj
+DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
+
+OBJECTS=$(DISSECTOR_OBJECTS) plugin.obj register.obj
docsis.dll docsis.exp docsis.lib : $(OBJECTS) $(LINK_PLUGIN_WITH)
link -dll /out:docsis.dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
$(GLIB_LIBS)
+#
+# Build "register.c", which contains a function "register_all_protocols()"
+# that calls the register routines for all protocols.
+#
+# We do this by grepping through sources. If that turns out to be too slow,
+# maybe we could just require every .o file to have an register routine
+# of a given name (packet-aarp.o -> proto_register_aarp, etc.).
+#
+# Formatting conventions: The name of the proto_register_* routines must
+# start in column zero, or must be preceded only by "void " starting in
+# column zero, and must not be inside #if.
+#
+# We assume that all dissector routines are in "packet-XXX.c" files.
+#
+# For some unknown reason, having a big "for" loop in the Makefile
+# to scan all the "packet-XXX.c" files doesn't work with some "make"s;
+# they seem to pass only the first few names in the list to the shell,
+# for some reason.
+#
+# Therefore, we have a script to generate the "register.c" file.
+#
+# The first argument is the name of the file to write.
+# The second argument is the directory in which the source files live.
+# All subsequent arguments are the files to scan.
+#
+# On Windows, however, that script runs slowly, as multiple greps
+# and seds are run for each input file, so, if Python is present
+# (as indicated by PYTHON being defined), we run a faster Python
+# script to do that work instead. That script doesn't take the name
+# of the file to write as an argument; it always writes to
+# "register.c".
+#
+register.c: $(DISSECTOR_SRC)
+!IFDEF PYTHON
+ @echo Making register.c (using python)
+ @$(PYTHON) ../../tools/make-reg-dotc.py . $(DISSECTOR_SRC)
+!ELSE
+ @echo Making register.c (using sh)
+ @$(SH) ../../tools/make-reg-dotc register.c . $(DISSECTOR_SRC)
+!ENDIF
+
!ENDIF
clean:
diff --git a/plugins/docsis/packet-docsis.c b/plugins/docsis/packet-docsis.c
index 54eb67530c..5571a6370a 100644
--- a/plugins/docsis/packet-docsis.c
+++ b/plugins/docsis/packet-docsis.c
@@ -49,22 +49,12 @@
# include "config.h"
#endif
-#include "moduleinfo.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <gmodule.h>
-
#include <epan/packet.h>
-
-#ifndef ENABLE_STATIC
-G_MODULE_EXPORT const gchar version[] = VERSION;
-#endif
-
-
#include "packet-docsis.h"
#define FCTYPE_PACKET 0x00
@@ -769,85 +759,3 @@ proto_reg_handoff_docsis (void)
docsis_mgmt_handle = find_dissector ("docsis_mgmt");
eth_withoutfcs_handle = find_dissector ("eth_withoutfcs");
}
-
-/* Start the functions we need for the plugin stuff */
-
-#ifndef ENABLE_STATIC
-
-G_MODULE_EXPORT void
-plugin_register (void)
-{
- /* register the new protocol, protocol fields, and subtrees */
- if (proto_docsis == -1)
- { /* execute protocol initialization only once */
- proto_register_docsis ();
- proto_register_docsis_bpkmattr ();
- proto_register_docsis_dsarsp ();
- proto_register_docsis_mgmt ();
- proto_register_docsis_rngrsp ();
- proto_register_docsis_bpkmreq ();
- proto_register_docsis_dscack ();
- proto_register_docsis_map ();
- proto_register_docsis_tlv ();
- proto_register_docsis_bpkmrsp ();
- proto_register_docsis_dscreq ();
- proto_register_docsis_regack ();
- proto_register_docsis_uccreq ();
- proto_register_docsis_dscrsp ();
- proto_register_docsis_regreq ();
- proto_register_docsis_uccrsp ();
- proto_register_docsis_dsaack ();
- proto_register_docsis_dsdreq ();
- proto_register_docsis_regrsp ();
- proto_register_docsis_ucd ();
- proto_register_docsis_type29ucd ();
- proto_register_docsis_dcd ();
- proto_register_docsis_dccreq ();
- proto_register_docsis_dccrsp ();
- proto_register_docsis_dccack ();
- proto_register_docsis_dsareq ();
- proto_register_docsis_dsdrsp ();
- proto_register_docsis_rngreq ();
- proto_register_docsis_vsif ();
- proto_register_docsis_intrngreq ();
-
- }
-}
-
-G_MODULE_EXPORT void
-plugin_reg_handoff (void)
-{
- proto_reg_handoff_docsis ();
- proto_reg_handoff_docsis_bpkmattr ();
- proto_reg_handoff_docsis_dsarsp ();
- proto_reg_handoff_docsis_mgmt ();
- proto_reg_handoff_docsis_rngreq ();
- proto_reg_handoff_docsis_rngrsp ();
- proto_reg_handoff_docsis_bpkmreq ();
- proto_reg_handoff_docsis_dscack ();
- proto_reg_handoff_docsis_map ();
- proto_reg_handoff_docsis_tlv ();
- proto_reg_handoff_docsis_bpkmrsp ();
- proto_reg_handoff_docsis_dscreq ();
- proto_reg_handoff_docsis_regack ();
- proto_reg_handoff_docsis_uccreq ();
- proto_reg_handoff_docsis_dscrsp ();
- proto_reg_handoff_docsis_regreq ();
- proto_reg_handoff_docsis_uccrsp ();
- proto_reg_handoff_docsis_dsaack ();
- proto_reg_handoff_docsis_dsdreq ();
- proto_reg_handoff_docsis_regrsp ();
- proto_reg_handoff_docsis_ucd ();
- proto_reg_handoff_docsis_type29ucd ();
- proto_reg_handoff_docsis_dcd ();
- proto_reg_handoff_docsis_dccreq ();
- proto_reg_handoff_docsis_dccrsp ();
- proto_reg_handoff_docsis_dccack ();
- proto_reg_handoff_docsis_dsareq ();
- proto_reg_handoff_docsis_dsdrsp ();
- proto_reg_handoff_docsis_vsif ();
- proto_reg_handoff_docsis_intrngreq ();
-
-}
-
-#endif
diff --git a/plugins/docsis/plugin.c b/plugins/docsis/plugin.c
new file mode 100644
index 0000000000..602420cd8b
--- /dev/null
+++ b/plugins/docsis/plugin.c
@@ -0,0 +1,59 @@
+/* plugin.c
+ * Standard plugin boilerplate
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gmodule.h>
+
+#include "moduleinfo.h"
+
+#ifndef ENABLE_STATIC
+G_MODULE_EXPORT const gchar version[] = VERSION;
+
+/* Start the functions we need for the plugin stuff */
+
+extern void register_all_protocols(void);
+extern void register_all_protocol_handoffs(void);
+
+G_MODULE_EXPORT void
+plugin_register (void)
+{
+ static gboolean registered = FALSE;
+
+ /* register the new protocol, protocol fields, and subtrees */
+ if (!registered) {
+ register_all_protocols();
+ registered = TRUE;
+ }
+}
+
+G_MODULE_EXPORT void
+plugin_reg_handoff (void)
+{
+ register_all_protocol_handoffs();
+}
+
+#endif