From fdcbef39546b189449e30e62500f5f632810cdf9 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 2 Jan 2014 13:30:49 -0800 Subject: [PATCH] ETHER: Added support to build with more older versions of libpcap on some platforms. Removed support to use tcpdump.org's libpcap on Linux platforms. --- 0readme_ethernet.txt | 17 ++++++++++--- makefile | 57 +++++++++++++++++++++++++++++++++----------- sim_ether.c | 4 ++-- 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/0readme_ethernet.txt b/0readme_ethernet.txt index bfe3abe2..6eaae774 100644 --- a/0readme_ethernet.txt +++ b/0readme_ethernet.txt @@ -80,6 +80,12 @@ Linux (Ubuntu 10.04): # Run simulator and "attach xq tap:tap0" + +Linux (Fedora Core 18, 20, etc.): + yum install gcc + yum install libpcap-devel + yum install uml-utilities + OpenBSD (OpenBSD 4.6) /sbin/ifconfig tun0 create @@ -207,7 +213,7 @@ Building on Windows: The contents of the windows-build directory can be downloaded from: - https://github.com/downloads/simh/simh/windows-build.zip + https://github.com/simh/windows-build/archive/windows-build.zip There are Windows batch files provided to initiate compiles using the MinGW @@ -269,10 +275,15 @@ for details. Building on Linux, {Free|Net|Open}BSD, OS/X, Solaris, other *nix: - 1. Get/make/install the libpcap-dev package for your operating system. Sources: + 1. Get/make/install the libpcap-dev package (or libpcap-devel) for your + operating system. Sources: All : http://www.tcpdump.org/ Older versions of libpcap can be found, for various systems, at: - Linux : search for your variant on http://rpmfind.net + Linux : + Debian Based distributions: + # apt-get install libpcap-dev + RedHat/Fedora Based distributions: + # yum install libpcap-devel OS/X : Apple Developer's site? HP-UX : ftp://hpux.connect.org.uk/hpux/Networking/Admin/ diff --git a/makefile b/makefile index f0cf3d6b..b92f3195 100644 --- a/makefile +++ b/makefile @@ -50,6 +50,11 @@ # # CC Command (and platform available options). (Poor man's autoconf) # +ifeq (old,$(shell gmake --version /dev/null 2>&1 | grep 'GNU Make' | awk '{ if ($$3 < "3.82") {print "old"} }')) + GMAKE_VERSION = $(shell gmake --version /dev/null 2>&1 | grep 'GNU Make' | awk '{ print $$3 }') + $(warning *** Warning *** GNU Make Version $(GMAKE_VERSION) is too old to) + $(warning *** Warning *** fully process this makefile) +endif # building the pdp11, or any vax simulator could use networking support BUILD_SINGLE := $(MAKECMDGOALS) $(BLANK_SUFFIX) ifneq (,$(or $(findstring pdp11,$(MAKECMDGOALS)),$(findstring vax,$(MAKECMDGOALS)),$(findstring all,$(MAKECMDGOALS)))) @@ -349,7 +354,15 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) endif ifneq (,$(NETWORK_USEFUL)) ifneq (,$(call find_include,pcap)) - NETWORK_CCDEFS += -DHAVE_PCAP_NETWORK -I$(dir $(call find_include,pcap)) + ifneq (,$(shell grep 'pcap/pcap.h' $(call find_include,pcap) | grep include)) + PCAP_H_PATH = $(dir $(call find_include,pcap))pcap/pcap.h + else + PCAP_H_PATH = $(call find_include,pcap) + endif + ifneq (,$(shell grep pcap_compile $(PCAP_H_PATH) | grep const)) + BPF_CONST_STRING = -DBPF_CONST_STRING + endif + NETWORK_CCDEFS += -DHAVE_PCAP_NETWORK -I$(dir $(call find_include,pcap)) $(BPF_CONST_STRING) NETWORK_LAN_FEATURES += PCAP ifneq (,$(call find_lib,$(PCAPLIB))) ifneq ($(USE_NETWORK),) # Network support specified on the GNU make command line @@ -386,13 +399,26 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) LIBEXT = $(LIBEXTSAVE) endif else - # Look for package built from tcpdump.org sources with default install target (or cygwin winpcap) - INCPATH += /usr/local/include - ifneq (,$(call find_include,pcap)) + # On non-Linux platforms, we'll still try to provide deprecated support for libpcap in /usr/local + ifeq (,$(findstring Linux,$(OSTYPE))) + # Look for package built from tcpdump.org sources with default install target (or cygwin winpcap) + INCPATHSAVE := $(INCPATH) + INCPATH += /usr/local/include + PCAP_H_FOUND = $(call find_include,pcap) + endif + ifneq (,$(strip $(PCAP_H_FOUND))) + ifneq (,$(shell grep 'pcap/pcap.h' $(call find_include,pcap) | grep include)) + PCAP_H_PATH = $(dir $(call find_include,pcap))pcap/pcap.h + else + PCAP_H_PATH = $(call find_include,pcap) + endif + ifneq (,$(shell grep pcap_compile $(PCAP_H_PATH) | grep const)) + BPF_CONST_STRING = -DBPF_CONST_STRING + endif LIBEXTSAVE := $(LIBEXT) # first check if binary - shared objects are available/installed in the linker known search paths ifneq (,$(call find_lib,$(PCAPLIB))) - NETWORK_CCDEFS = -DUSE_SHARED -I$(dir $(call find_include,pcap)) + NETWORK_CCDEFS = -DUSE_SHARED -I$(dir $(call find_include,pcap)) $(BPF_CONST_STRING) NETWORK_FEATURES = - dynamic networking support using libpcap components from www.tcpdump.org and locally installed libpcap.$(LIBEXT) $(info using libpcap: $(call find_include,pcap)) else @@ -401,11 +427,11 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) ifneq (,$(call find_lib,$(PCAPLIB))) $(info using libpcap: $(call find_lib,$(PCAPLIB)) $(call find_include,pcap)) ifeq (cygwin,$(OSTYPE)) - NETWORK_CCDEFS = -DUSE_NETWORK -DHAVE_PCAP_NETWORK -I$(dir $(call find_include,pcap)) + NETWORK_CCDEFS = -DUSE_NETWORK -DHAVE_PCAP_NETWORK -I$(dir $(call find_include,pcap)) $(BPF_CONST_STRING) NETWORK_LDFLAGS = -L$(dir $(call find_lib,$(PCAPLIB))) -Wl,-R,$(dir $(call find_lib,$(PCAPLIB))) -l$(PCAPLIB) NETWORK_FEATURES = - static networking support using libpcap components located in the cygwin directories else - NETWORK_CCDEFS := -DUSE_NETWORK -DHAVE_PCAP_NETWORK -isystem -I$(dir $(call find_include,pcap)) $(call find_lib,$(PCAPLIB)) + NETWORK_CCDEFS := -DUSE_NETWORK -DHAVE_PCAP_NETWORK -isystem -I$(dir $(call find_include,pcap)) $(BPF_CONST_STRING) $(call find_lib,$(PCAPLIB)) NETWORK_FEATURES = - networking support using libpcap components from www.tcpdump.org $(info *** Warning ***) $(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) being built with networking support using) @@ -413,7 +439,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) $(info *** Warning *** Some users have had problems using the www.tcpdump.org libpcap) $(info *** Warning *** components for simh networking. For best results, with) $(info *** Warning *** simh networking, it is recommended that you install the) - $(info *** Warning *** libpcap-dev package from your $(OSNAME) distribution) + $(info *** Warning *** libpcap-dev (or libpcap-devel) package from your $(OSNAME) distribution) $(info *** Warning ***) $(info *** Warning *** Building with the components manually installed from www.tcpdump.org) $(info *** Warning *** is officially deprecated. Attempting to do so is unsupported.) @@ -426,6 +452,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) endif LIBEXT = $(LIBEXTSAVE) else + INCPATH = $(INCPATHSAVE) $(info *** Warning ***) $(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) are being built WITHOUT) $(info *** Warning *** libpcap networking support) @@ -460,12 +487,14 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) ifeq (,$(findstring HAVE_VDE_NETWORK,$(NETWORK_CCDEFS))) # Support is available on Linux for libvdeplug. Advise on its usage ifneq (,$(findstring Linux,$(OSTYPE))) - $(info *** Warning ***) - $(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) are being built with) - $(info *** Warning *** minimal libpcap networking support) - $(info *** Warning ***) + ifneq (,$(findstring USE_NETWORK,$(NETWORK_CCDEFS))$(findstring USE_SHARED,$(NETWORK_CCDEFS))) + $(info *** Warning ***) + $(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) are being built with) + $(info *** Warning *** minimal libpcap networking support) + $(info *** Warning ***) + endif $(info *** Warning *** Simulators on your $(OSNAME) platform can also be built with) - $(info *** Warning *** extended Ethernet networking support by using VDE Ethernet.) + $(info *** Warning *** extended LAN Ethernet networking support by using VDE Ethernet.) $(info *** Warning ***) $(info *** Warning *** To build simulator(s) with extended networking support you) $(info *** Warning *** should read 0readme_ethernet.txt and follow the instructions) @@ -490,7 +519,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) NETWORK_CCDEFS += -DUSE_NETWORK endif endif - ifeq (,$(findstring USE_NETWORK,$(NETWORK_CCDEFS))$(findstring USE_SHARED,$(NETWORK_CCDEFS))) + ifeq (,$(findstring USE_NETWORK,$(NETWORK_CCDEFS))$(findstring USE_SHARED,$(NETWORK_CCDEFS))$(findstring HAVE_VDE_NETWORK,$(NETWORK_CCDEFS))) NETWORK_CCDEFS += -DUSE_NETWORK NETWORK_FEATURES = - WITHOUT Local LAN networking support $(info *** Warning ***) diff --git a/sim_ether.c b/sim_ether.c index f764d662..147a358f 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -1090,8 +1090,8 @@ void pcap_close(pcap_t* a) { } } -/* OpenBSD, AIX and OS/X on PowerPC have an ancient declaration of pcap_compile which doesn't have a const in the bpf string argument */ -#if defined (__OpenBSD__) || defined (_AIX) || (defined (__APPLE__) && defined (__POWERPC__)) +/* Some platforms's pcap.h have an ancient declaration of pcap_compile which doesn't have a const in the bpf string argument */ +#if !defined (BPF_CONST_STRING) int pcap_compile(pcap_t* a, struct bpf_program* b, char* c, int d, bpf_u_int32 e) { #else int pcap_compile(pcap_t* a, struct bpf_program* b, const char* c, int d, bpf_u_int32 e) {