1
0
mirror of https://github.com/simh/simh.git synced 2026-01-11 23:52:58 +00:00

ETHER: Add build support leveraging libpcap shared object without pcap.h

Some host systems come with the libpcap shared object installed.  If that
is the case, since the default build behavior is to dynamically load libpcap,
builds can now potentially avoid a forced install of the libpcap-devel package.
This commit is contained in:
Mark Pizzolato 2024-04-17 11:12:42 -10:00
parent b22fb8eefa
commit 997952e712
2 changed files with 65 additions and 15 deletions

View File

@ -998,6 +998,10 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
endif
endif
else # pcap desired but pcap.h not found
ifneq (,$(call find_lib,$(PCAPLIB)))
PCAP_LIB_VERSION = $(shell strings $(call find_lib,$(PCAPLIB)) | grep 'libpcap version' | awk '{ print $$3}')
PCAP_LIB_BASE_VERSION = $(firstword $(subst ., ,$(PCAP_LIB_VERSION)))
endif
NEEDED_PKGS += DPKG_PCAP
# On non-Linux platforms, we'll still try to provide deprecated support for libpcap in /usr/local
INCPATHSAVE := ${INCPATH}
@ -1053,19 +1057,27 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
LIBEXT = $(LIBEXTSAVE)
else
INCPATH = $(INCPATHSAVE)
$(info *** Warning ***)
$(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) $(BUILD_MULTIPLE_VERB) being built WITHOUT)
$(info *** Warning *** libpcap networking support)
$(info *** Warning ***)
$(info *** Warning *** To build simulator(s) with libpcap networking support you)
$(info *** Warning *** should install the libpcap development components for)
$(info *** Warning *** for your $(OSNAME) system.)
ifeq (,$(or $(findstring Linux,$(OSTYPE)),$(findstring OSX,$(OSNAME))))
$(info *** Warning *** You should read 0readme_ethernet.txt and follow the instructions)
$(info *** Warning *** regarding the needed libpcap development components for your)
$(info *** Warning *** $(OSNAME) platform.)
ifeq (1,$(PCAP_LIB_BASE_VERSION))
$(info using libpcap $(PCAP_LIB_VERSION) without an available pcap.h)
NETWORK_CCDEFS = -DUSE_SHARED -DHAVE_PCAP_NETWORK -DPCAP_LIB_VERSION=$(PCAP_LIB_VERSION)
NETWORK_FEATURES = - dynamic networking support using libpcap components from www.tcpdump.org and locally installed libpcap.${LIBEXT}
NETWORK_LAN_FEATURES += PCAP
NEEDED_PKGS := $(filter-out DPKG_PCAP,$(NEEDED_PKGS))
else
$(info *** Warning ***)
$(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) $(BUILD_MULTIPLE_VERB) being built WITHOUT)
$(info *** Warning *** libpcap networking support)
$(info *** Warning ***)
$(info *** Warning *** To build simulator(s) with libpcap networking support you)
$(info *** Warning *** should install the libpcap development components for)
$(info *** Warning *** for your $(OSNAME) system.)
ifeq (,$(or $(findstring Linux,$(OSTYPE)),$(findstring OSX,$(OSNAME))))
$(info *** Warning *** You should read 0readme_ethernet.txt and follow the instructions)
$(info *** Warning *** regarding the needed libpcap development components for your)
$(info *** Warning *** $(OSNAME) platform.)
endif
$(info *** Warning ***)
endif
$(info *** Warning ***)
endif
endif
# Consider other network connections

View File

@ -999,7 +999,7 @@ t_stat sim_ether_test (DEVICE *dptr, const char *cptr)
#include <net/bpf.h>
#endif
#if defined (HAVE_PCAP_NETWORK)
#if defined (HAVE_PCAP_NETWORK) && !defined (PCAP_LIB_VERSION)
/*============================================================================*/
/* WIN32, Linux, and xBSD routines use WinPcap and libpcap packages */
/* OpenVMS Alpha uses a WinPcap port and an associated execlet */
@ -1012,8 +1012,46 @@ struct pcap_pkthdr {
uint32 len; /* length this packet (off wire) */
};
#define PCAP_ERRBUF_SIZE 256
typedef void * pcap_t; /* Pseudo Type to avoid compiler errors */
#define DLT_EN10MB 1 /* Dummy Value to avoid compiler errors */
typedef void * pcap_t; /* Pseudo Type to avoid compiler errors */
#define DLT_EN10MB 1 /* Dummy Value to avoid compiler errors */
#if defined (PCAP_LIB_VERSION) && defined (USE_SHARED)
typedef uint32 bpf_u_int32; /* Pseudo Type to avoid compiler errors */
typedef struct pcap_if {
struct pcap_if *next;
char *name; /* name to hand to "pcap_open_live()" */
char *description; /* textual description of interface, or NULL */
struct pcap_addr *addresses;
bpf_u_int32 flags; /* PCAP_IF_ interface flags */
} pcap_if_t; /* Pseudo Type to avoid compiler errors */
#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */
struct bpf_program { void *pgm; }; /* Pseudo Type to avoid compiler errors */
typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
const u_char *);
void pcap_close (pcap_t *);
#define BPF_CONST_STRING 1
int pcap_compile (pcap_t *, struct bpf_program *, const char *, int, unsigned int);
int pcap_datalink (pcap_t *);
int pcap_dispatch (pcap_t *, int, pcap_handler, u_char *);
int pcap_findalldevs (pcap_if_t **, char *);
void pcap_freealldevs (pcap_if_t *);
void pcap_freecode (struct bpf_program *);
char* pcap_geterr (pcap_t *);
int pcap_lookupnet (const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
pcap_t* pcap_open_live (const char *, int, int, int, char *);
#ifdef _WIN32
int pcap_setmintocopy (pcap_t* handle, int);
HANDLE pcap_getevent (pcap_t *);
#else
#ifdef MUST_DO_SELECT
int pcap_get_selectable_fd (pcap_t *);
#endif
int pcap_fileno (pcap_t *);
#endif
int pcap_sendpacket (pcap_t* handle, const u_char* msg, int len);
int pcap_setfilter (pcap_t *, struct bpf_program *);
int pcap_setnonblock(pcap_t* a, int nonblock, char *errbuf);
#endif
#endif /* HAVE_PCAP_NETWORK */
/*