Added support for VDE (Virtual Distributed Ethernet) network packet transport
Fixed filtering for non-pcap network packet transports (i.e. tun/tap, and vde) to properly filter the desired packets.
This commit is contained in:
parent
bfb6e54819
commit
fd5de0d005
4 changed files with 1282 additions and 1095 deletions
|
@ -133,12 +133,36 @@ OSX (Snow Leopard)
|
||||||
Invoke the package installer tuntap_20090913.pkg
|
Invoke the package installer tuntap_20090913.pkg
|
||||||
Click through the various prompts accepting things and eventually installing the package.
|
Click through the various prompts accepting things and eventually installing the package.
|
||||||
|
|
||||||
# Run simulator and:
|
# Build and Run simulator and:
|
||||||
sim> attach xq tap:tap0
|
sim> attach xq tap:tap0
|
||||||
sim> ! ifconfig tap0 192.168.6.1 netmask 255.255.255.0
|
sim> ! ifconfig tap0 192.168.6.1 netmask 255.255.255.0
|
||||||
|
|
||||||
Simulated system uses IP address 192.168.6.2 and host uses 192.167.6.1 and things work.
|
Simulated system uses IP address 192.168.6.2 and host uses 192.167.6.1
|
||||||
As far as I can tell you must run as root for this to work.
|
and things work.
|
||||||
|
You must run as root for this to work.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
An alternative to direct pcap and tun/tap networking on *nix environments is
|
||||||
|
VDE (Virtual Distributed Ethernet).
|
||||||
|
|
||||||
|
Note 1: Using vde based networking is likely more flexible, but it isn't
|
||||||
|
nearly as efficient. Host OS overhead will always be higher when
|
||||||
|
vde networking is used as compared to native pcap and/or tun/tap
|
||||||
|
networking.
|
||||||
|
Note 2: Root access will likely be needed to configure or start the vde
|
||||||
|
environment prior to starting a simulator which may use it.
|
||||||
|
Note 3: Simulators running using VDE networking can run without root
|
||||||
|
privilege.
|
||||||
|
|
||||||
|
Linux (Ubuntu 10.04):
|
||||||
|
apt-get install libvdeplug-dev
|
||||||
|
apt-get install vde2
|
||||||
|
|
||||||
|
vde_switch -s /tmp/switch1 -tap tap0 -m 666
|
||||||
|
ifconfig tap0 192.168.6.1 netmask 255.255.255.0 up
|
||||||
|
|
||||||
|
# Build and Run simulator and:
|
||||||
|
sim> attach xq vde:/tmp/switch1 #simulator uses IP address 192.168.6.2
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -354,6 +378,7 @@ Dave
|
||||||
Change Log
|
Change Log
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
||||||
|
30-Oct-11 MP Added support for vde (Virtual Distributed Ethernet) networking
|
||||||
29-Oct-11 MP Added support for integrated Tap networking interfaces on OSX
|
29-Oct-11 MP Added support for integrated Tap networking interfaces on OSX
|
||||||
17-Aug-11 RMS Fix from Sergey Oboguev relating to XU and XQ Auto Config and
|
17-Aug-11 RMS Fix from Sergey Oboguev relating to XU and XQ Auto Config and
|
||||||
vector assignments
|
vector assignments
|
||||||
|
|
13
makefile
13
makefile
|
@ -13,6 +13,7 @@
|
||||||
#
|
#
|
||||||
ifeq ($(WIN32),)
|
ifeq ($(WIN32),)
|
||||||
#*nix Environments (&& cygwin)
|
#*nix Environments (&& cygwin)
|
||||||
|
GCC = gcc
|
||||||
ifeq (SunOS,$(shell uname))
|
ifeq (SunOS,$(shell uname))
|
||||||
TEST = /bin/test
|
TEST = /bin/test
|
||||||
else
|
else
|
||||||
|
@ -62,13 +63,18 @@ ifeq ($(WIN32),)
|
||||||
NETWORK_CCDEFS = -DUSE_NETWORK
|
NETWORK_CCDEFS = -DUSE_NETWORK
|
||||||
NETWORK_LDFLAGS = -lpcap
|
NETWORK_LDFLAGS = -lpcap
|
||||||
endif
|
endif
|
||||||
|
ifeq (vde,$(shell if $(TEST) -e /usr/include/libvdeplug.h -a \( -e /usr/lib/libvdeplug.$(LIBEXT) -o -e /usr/lib64/libvdeplug.$(LIBEXT) \); then echo vde; fi))
|
||||||
|
# Provide support for vde networking
|
||||||
|
NETWORK_CCDEFS += -DUSE_VDE_NETWORK
|
||||||
|
NETWORK_LDFLAGS += -lvdeplug
|
||||||
|
endif
|
||||||
ifeq (tuntap,$(shell if $(TEST) -e /usr/include/linux/if_tun.h; then echo tuntap; fi))
|
ifeq (tuntap,$(shell if $(TEST) -e /usr/include/linux/if_tun.h; then echo tuntap; fi))
|
||||||
# Provide support for Tap networking on Linux
|
# Provide support for Tap networking on Linux
|
||||||
NETWORK_TAP_CCDEFS = -DUSE_TAP_NETWORK
|
NETWORK_CCDEFS += -DUSE_TAP_NETWORK
|
||||||
endif
|
endif
|
||||||
ifeq (bsdtuntap,$(shell if $(TEST) -e /usr/include/net/if_tun.h -o -e /Library/Extensions/tap.kext; then echo bsdtuntap; fi))
|
ifeq (bsdtuntap,$(shell if $(TEST) -e /usr/include/net/if_tun.h -o -e /Library/Extensions/tap.kext; then echo bsdtuntap; fi))
|
||||||
# Provide support for Tap networking
|
# Provide support for Tap networking
|
||||||
NETWORK_TAP_CCDEFS = -DUSE_TAP_NETWORK -DUSE_BSDTUNTAP
|
NETWORK_CCDEFS += -DUSE_TAP_NETWORK -DUSE_BSDTUNTAP
|
||||||
endif
|
endif
|
||||||
ifneq (binexists,$(shell if $(TEST) -e BIN; then echo binexists; fi))
|
ifneq (binexists,$(shell if $(TEST) -e BIN; then echo binexists; fi))
|
||||||
MKDIRBIN = if $(TEST) ! -e BIN; then mkdir BIN; fi
|
MKDIRBIN = if $(TEST) ! -e BIN; then mkdir BIN; fi
|
||||||
|
@ -79,6 +85,7 @@ ifeq ($(WIN32),)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
#Win32 Environments (via MinGW32)
|
#Win32 Environments (via MinGW32)
|
||||||
|
GCC = gcc
|
||||||
GCC_Path := $(dir $(shell where gcc.exe))
|
GCC_Path := $(dir $(shell where gcc.exe))
|
||||||
ifeq ($(NOASYNCH),)
|
ifeq ($(NOASYNCH),)
|
||||||
ifeq (pthreads,$(shell if exist ..\pthreads\Pre-built.2\include\pthread.h echo pthreads))
|
ifeq (pthreads,$(shell if exist ..\pthreads\Pre-built.2\include\pthread.h echo pthreads))
|
||||||
|
@ -119,7 +126,7 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
CC = gcc -std=c99 -U__STRICT_ANSI__ -g -I . $(NETWORK_CCDEFS) $(NETWORK_TAP_CCDEFS) $(OS_CCDEFS) $(ROMS_OPT)
|
CC = $(GCC) -std=c99 -U__STRICT_ANSI__ -g -I . $(NETWORK_CCDEFS) $(OS_CCDEFS) $(ROMS_OPT)
|
||||||
LDFLAGS = $(OS_LDFLAGS) $(NETWORK_LDFLAGS)
|
LDFLAGS = $(OS_LDFLAGS) $(NETWORK_LDFLAGS)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
1027
sim_ether.c
1027
sim_ether.c
File diff suppressed because it is too large
Load diff
14
sim_ether.h
14
sim_ether.h
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
Modification history:
|
Modification history:
|
||||||
|
|
||||||
|
30-Oct-11 MP Added support for vde (Virtual Distributed Ethernet) networking
|
||||||
18-Apr-11 MP Fixed race condition with self loopback packets in
|
18-Apr-11 MP Fixed race condition with self loopback packets in
|
||||||
multithreaded environments
|
multithreaded environments
|
||||||
09-Dec-10 MP Added support to determine if network address conflicts exist
|
09-Dec-10 MP Added support to determine if network address conflicts exist
|
||||||
|
@ -89,13 +90,13 @@
|
||||||
#if defined (USE_READER_THREAD)
|
#if defined (USE_READER_THREAD)
|
||||||
#if defined (USE_SETNONBLOCK)
|
#if defined (USE_SETNONBLOCK)
|
||||||
#undef USE_SETNONBLOCK
|
#undef USE_SETNONBLOCK
|
||||||
#endif
|
#endif /* USE_SETNONBLOCK */
|
||||||
#undef PCAP_READ_TIMEOUT
|
#undef PCAP_READ_TIMEOUT
|
||||||
#define PCAP_READ_TIMEOUT 15
|
#define PCAP_READ_TIMEOUT 15
|
||||||
#if !defined (xBSD) && !defined(_WIN32) && !defined(VMS)
|
#if (!defined (xBSD) && !defined(_WIN32) && !defined(VMS)) || defined (USE_TAP_NETWORK) || defined (USE_VDE_NETWORK)
|
||||||
#define MUST_DO_SELECT
|
#define MUST_DO_SELECT 1
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* USE_READER_THREAD */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
USE_BPF is defined to let this code leverage the libpcap/OS kernel provided
|
USE_BPF is defined to let this code leverage the libpcap/OS kernel provided
|
||||||
|
@ -175,7 +176,10 @@ struct eth_device {
|
||||||
char* name; /* name of ethernet device */
|
char* name; /* name of ethernet device */
|
||||||
void* handle; /* handle of implementation-specific device */
|
void* handle; /* handle of implementation-specific device */
|
||||||
int fd_handle; /* fd to kernel device (where needed) */
|
int fd_handle; /* fd to kernel device (where needed) */
|
||||||
int pcap_mode; /* Flag indicating if pcap API are being used to move packets */
|
int eth_api; /* Designator for which API is being used to move packets */
|
||||||
|
#define ETH_API_PCAP 0 /* Pcap API in use */
|
||||||
|
#define ETH_API_TAP 1 /* tun/tap API in use */
|
||||||
|
#define ETH_API_VDE 2 /* VDE API in use */
|
||||||
ETH_PCALLBACK read_callback; /* read callback function */
|
ETH_PCALLBACK read_callback; /* read callback function */
|
||||||
ETH_PCALLBACK write_callback; /* write callback function */
|
ETH_PCALLBACK write_callback; /* write callback function */
|
||||||
ETH_PACK* read_packet; /* read packet */
|
ETH_PACK* read_packet; /* read packet */
|
||||||
|
|
Loading…
Add table
Reference in a new issue