aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am97
-rw-r--r--configure.in5
-rw-r--r--proto.c141
-rw-r--r--register.h31
4 files changed, 114 insertions, 160 deletions
diff --git a/Makefile.am b/Makefile.am
index d1b5b416fb..2fbb3ba803 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.90 1999/10/19 06:59:23 guy Exp $
+# $Id: Makefile.am,v 1.91 1999/10/20 06:28:28 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -31,28 +31,7 @@ sysconf_DATA = manuf
# Any POSIX-compatible YACC should honor the -p flag
YFLAGS=-d -p dfilter_
-ethereal_SOURCES = \
- alignment.h \
- capture.c \
- capture.h \
- colors.c \
- colors.h \
- column.c \
- column.h \
- dfilter-int.h \
- dfilter-grammar.y \
- dfilter-scanner.l \
- dfilter.c \
- dfilter.h \
- ethertype.c \
- etypes.h \
- file.c \
- file.h \
- follow.c \
- follow.h \
- globals.h \
- inet_v6defs.h \
- ipproto.c \
+DISSECTOR_SOURCES = \
packet-aarp.c \
packet-arp.c \
packet-ascend.c\
@@ -126,7 +105,30 @@ ethereal_SOURCES = \
packet-vines.h \
packet-x25.c \
packet-yhoo.c \
- packet-yhoo.h \
+ packet-yhoo.h
+
+ethereal_SOURCES = \
+ alignment.h \
+ capture.c \
+ capture.h \
+ colors.c \
+ colors.h \
+ column.c \
+ column.h \
+ dfilter-int.h \
+ dfilter-grammar.y \
+ dfilter-scanner.l \
+ dfilter.c \
+ dfilter.h \
+ ethertype.c \
+ etypes.h \
+ file.c \
+ file.h \
+ follow.c \
+ follow.h \
+ globals.h \
+ inet_v6defs.h \
+ ipproto.c \
packet.c \
packet.h \
prefs.c \
@@ -137,6 +139,8 @@ ethereal_SOURCES = \
proto.h \
ps.c \
ps.h \
+ register.c \
+ register.h \
resolv.c \
resolv.h \
smb.h \
@@ -146,7 +150,8 @@ ethereal_SOURCES = \
util.c \
util.h \
xdlc.c \
- xdlc.h
+ xdlc.h \
+ $(DISSECTOR_SOURCES)
EXTRA_ethereal_SOURCES = \
dfilter-grammar.c \
@@ -172,6 +177,35 @@ ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ \
wiretap/libwiretap.a gtk/libui.a \
@SNMP_A@
+#
+# 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,
+# or in "packet.c".
+#
+register.c: packet.c $(DISSECTOR_SOURCES) @SNMP_C@
+ @echo Making register.c
+ @rm -f register.c-tmp
+ @echo '/* Do not modify this file. */' >register.c-tmp
+ @echo '/* It is created automatically by the Makefile. */'>>register.c-tmp
+ @echo '#include "register.h"' >>register.c-tmp
+ @echo 'void register_all_protocols(void) {' >>register.c-tmp
+ @for f in packet.c $(DISSECTOR_SOURCES) @SNMP_C@; do grep '^proto_register_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \
+ sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
+ @for f in packet.c $(DISSECTOR_SOURCES) @SNMP_C@; do grep '^void proto_register_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \
+ sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
+ @echo '}' >>register.c-tmp
+ @mv register.c-tmp register.c
+
ps.c: print.ps rdps
./rdps $(srcdir)/print.ps ps.c
@@ -185,6 +219,7 @@ randpkt: randpkt.o wiretap/libwiretap.a
$(LINK) -o randpkt randpkt.o wiretap/libwiretap.a `glib-config --libs` -lz
DISTCLEANFILES = \
+ register.c \
rdps \
ps.c \
*~
@@ -209,6 +244,18 @@ EXTRA_DIST = \
randpkt.c \
rdps.c
+#
+# 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 "disk-hook" rule that deletes
+# "register.c", so that "dist" won't pick it up.
+#
+dist-hook:
+ @rm -f $(distdir)/register.c
+
SUBDIRS = wiretap gtk @ethereal_SUBDIRS@
ethereal.1: ethereal doc/ethereal.pod.template
diff --git a/configure.in b/configure.in
index 4bcc514ccf..95f22508a3 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.52 1999/10/14 06:55:08 guy Exp $
+# $Id: configure.in,v 1.53 1999/10/20 06:28:29 guy Exp $
dnl Process this file with autoconf to produce a configure script.
AC_INIT(etypes.h)
@@ -115,6 +115,7 @@ AC_ARG_ENABLE(snmp,
[ --enable-snmp use SNMP library, if available. [default=yes]],,enable_snmp=yes)
SNMP_A=''
+SNMP_C=''
SNMP_O=''
AC_MSG_CHECKING(whether to use SNMP library if available)
if test "x$enable_snmp" = "xno" ; then
@@ -126,10 +127,12 @@ else
AC_CHECK_LIB(snmp, asn_parse_header,
[
SNMP_A=-lsnmp
+ SNMP_C=packet-snmp.c
SNMP_O=packet-snmp.o
], )
fi
AC_SUBST(SNMP_A)
+AC_SUBST(SNMP_C)
AC_SUBST(SNMP_O)
dnl Checks for typedefs, structures, and compiler characteristics.
diff --git a/proto.c b/proto.c
index c6abec679b..becd8327ad 100644
--- a/proto.c
+++ b/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.45 1999/10/17 11:40:14 deniel Exp $
+ * $Id: proto.c,v 1.46 1999/10/20 06:28:28 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -61,6 +61,10 @@
#include "resolv.h"
#endif
+#ifndef __REGISTER_H__
+#include "register.h"
+#endif
+
#include "packet-ipv6.h"
#define cVALS(x) (const value_string*)(x)
@@ -100,72 +104,6 @@ static gboolean check_for_field_within_protocol(GNode *node, gpointer data);
static int proto_register_field_init(header_field_info *hfinfo, int parent);
-/* centralization of registration functions */
-void proto_register_aarp(void);
-void proto_register_arp(void);
-void proto_register_ascend(void);
-void proto_register_atalk(void);
-void proto_register_atm(void);
-void proto_register_bgp(void);
-void proto_register_bootp(void);
-void proto_register_bpdu(void);
-void proto_register_cdp(void);
-void proto_register_clnp(void);
-void proto_register_cotp(void);
-void proto_register_data(void);
-void proto_register_dns(void);
-void proto_register_eth(void);
-void proto_register_fddi(void);
-void proto_register_frame(void);
-void proto_register_ftp(void);
-void proto_register_giop(void);
-void proto_register_gre(void);
-void proto_register_http(void);
-void proto_register_icmp(void);
-void proto_register_icmpv6(void);
-void proto_register_icp(void);
-void proto_register_igmp(void);
-void proto_register_ip(void);
-void proto_register_ipp(void);
-void proto_register_ipsec(void);
-void proto_register_ipv6(void);
-void proto_register_ipx(void);
-void proto_register_isakmp(void);
-void proto_register_lapb(void);
-void proto_register_llc(void);
-void proto_register_lpd(void);
-void proto_register_mp(void);
-void proto_register_nbipx(void);
-void proto_register_nbt(void);
-void proto_register_ncp(void);
-void proto_register_netbios(void);
-void proto_register_nntp(void);
-void proto_register_ntp(void);
-void proto_register_null(void);
-void proto_register_ospf(void);
-void proto_register_pim(void);
-void proto_register_pop(void);
-void proto_register_ppp(void);
-void proto_register_radius(void);
-void proto_register_rip(void);
-void proto_register_ripng(void);
-void proto_register_rsvp(void);
-void proto_register_rtsp(void);
-void proto_register_sdp(void);
-void proto_register_smb(void);
-void proto_register_sna(void);
-#if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD)
-void proto_register_snmp(void);
-#endif
-void proto_register_telnet(void);
-void proto_register_tftp(void);
-void proto_register_tcp(void);
-void proto_register_tr(void);
-void proto_register_trmac(void);
-void proto_register_udp(void);
-void proto_register_x25(void);
-void proto_register_yhoo(void);
-
/* special-case header field used within proto.c */
int hf_text_only = 1;
@@ -219,73 +157,8 @@ proto_init(void)
G_ALLOC_AND_FREE);
gpa_hfinfo = g_ptr_array_new();
- /* Have each dissector register its protocols and fields. The
- * order doesn't matter. Put the calls in alphabetical order
- * just to make it easy. */
- proto_register_aarp();
- proto_register_arp();
- proto_register_ascend();
- proto_register_atalk();
- proto_register_atm();
- proto_register_bgp();
- proto_register_bootp();
- proto_register_bpdu();
- proto_register_cdp();
- proto_register_clnp();
- proto_register_cotp();
- proto_register_data();
- proto_register_dns();
- proto_register_eth();
- proto_register_fddi();
- proto_register_frame();
- proto_register_ftp();
- proto_register_giop();
- proto_register_gre();
- proto_register_http();
- proto_register_icmp();
- proto_register_icmpv6();
- proto_register_icp();
- proto_register_igmp();
- proto_register_ip();
- proto_register_ipp();
- proto_register_ipsec();
- proto_register_ipv6();
- proto_register_ipx();
- proto_register_isakmp();
- proto_register_lapb();
- proto_register_llc();
- proto_register_lpd();
- proto_register_mp();
- proto_register_nbipx();
- proto_register_nbt();
- proto_register_ncp();
- proto_register_netbios();
- proto_register_nntp();
- proto_register_ntp();
- proto_register_null();
- proto_register_ospf();
- proto_register_pim();
- proto_register_pop();
- proto_register_ppp();
- proto_register_radius();
- proto_register_rip();
- proto_register_ripng();
- proto_register_rsvp();
- proto_register_rtsp();
- proto_register_sdp();
- proto_register_smb();
- proto_register_sna();
-#if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD)
- proto_register_snmp();
-#endif
- proto_register_telnet();
- proto_register_tftp();
- proto_register_tcp();
- proto_register_tr();
- proto_register_trmac();
- proto_register_udp();
- proto_register_x25();
- proto_register_yhoo();
+ /* Have each dissector register its protocols and fields. */
+ register_all_protocols();
/* Register one special-case FT_TEXT_ONLY field for use when
converting ethereal to new-style proto_tree. These fields
diff --git a/register.h b/register.h
new file mode 100644
index 0000000000..47f3afde94
--- /dev/null
+++ b/register.h
@@ -0,0 +1,31 @@
+/* register.h
+ * Definitions for protocol registration
+ *
+ * $Id: register.h,v 1.1 1999/10/20 06:28:29 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * 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.
+ */
+
+#ifndef __REGISTER_H__
+#define __REGISTER_H__
+
+extern void register_all_protocols(void);
+
+#endif /* __REGISTER_H__ */