Added support for integrated Tap networking interfaces on OSX

This commit is contained in:
Mark Pizzolato 2011-10-29 14:13:33 -07:00
parent ec4f002531
commit eaddb7d24a
3 changed files with 50 additions and 9 deletions

View file

@ -43,9 +43,9 @@ bridge, or route TAP devices for you.
Integrated Universal TUN/TAP support can be used for host<->simulator network Integrated Universal TUN/TAP support can be used for host<->simulator network
traffic (on the platforms where it is available) by using the SIMH command: traffic (on the platforms where it is available) by using the SIMH command:
"attach xq tap:tapN" (i.e. attach xq tap:tap0). Platforms that this has been "attach xq tap:tapN" (i.e. attach xq tap:tap0). Platforms that this has been
tested on include: Linux, FreeBSD, OpenBSD, NetBSD. Each of these platforms tested on include: Linux, FreeBSD, OpenBSD, NetBSD and OSX. Each of these
has some way to create a tap pseudo device and then bridge it with a physical platforms has some way to create a tap pseudo device (and possibly then to
network interface. bridge it with a physical network interface).
The following steps were performed to get a working SIMH vax simulator The following steps were performed to get a working SIMH vax simulator
sharing a physical NIC and allowing Host<->SIMH vax communications: sharing a physical NIC and allowing Host<->SIMH vax communications:
@ -117,6 +117,29 @@ NetBSD (NetBSD 5.0.2)
# Run simulator and "attach xq tap:tap0" # Run simulator and "attach xq tap:tap0"
OSX (Snow Leopard)
OSX Does NOT have native support for tun/tap interfaces. It also does not have native
support for bridging.
Mattias Nissler has created tun/tap functionality available at http://tuntaposx,sourceforge.net/
We'll punt on bridging for the sake of this example and move on to use a basic tap
based internal network so a host and guest can communicate directly.
Download the install package from:
http://sourceforge.net/projects/tuntaposx/files/tuntap/20090913/tuntap_20090913.tar.gz
Expand the tarball to a directory.
Invoke the package installer tuntap_20090913.pkg
Click through the various prompts accepting things and eventually installing the package.
# Run simulator and:
sim> attach xq tap:tap0
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.
As far as I can tell you must run as root for this to work.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Windows notes: Windows notes:
@ -331,14 +354,15 @@ Dave
Change Log Change Log
=============================================================================== ===============================================================================
07-Jul-11 MB VMS Pcap (from Mike Burke) 29-Oct-11 MP Added support for integrated Tap networking interfaces on OSX
- Fixed Alpha issues
- Added OpenVMS Integrety support
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
12-Aug-11 MP Cleaned up payload length determination 12-Aug-11 MP Cleaned up payload length determination
Fixed race condition detecting reflections when threaded Fixed race condition detecting reflections when threaded
reading and writing is enabled reading and writing is enabled
07-Jul-11 MB VMS Pcap (from Mike Burke)
- Fixed Alpha issues
- Added OpenVMS Integrety support
20-Apr-11 MP Fixed save/restore behavior 20-Apr-11 MP Fixed save/restore behavior
12-Jan-11 DTH Added SHOW XU FILTERS modifier 12-Jan-11 DTH Added SHOW XU FILTERS modifier
11-Jan-11 DTH Corrected DEUNA/DELUA SELFTEST command, enabling use by 11-Jan-11 DTH Corrected DEUNA/DELUA SELFTEST command, enabling use by

View file

@ -66,7 +66,7 @@ ifeq ($(WIN32),)
# Provide support for Tap networking on Linux # Provide support for Tap networking on Linux
NETWORK_TAP_CCDEFS = -DUSE_TAP_NETWORK NETWORK_TAP_CCDEFS = -DUSE_TAP_NETWORK
endif endif
ifeq (bsdtuntap,$(shell if $(TEST) -e /usr/include/net/if_tun.h; 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_TAP_CCDEFS = -DUSE_TAP_NETWORK -DUSE_BSDTUNTAP
endif endif

View file

@ -787,7 +787,7 @@ void eth_show_dev (FILE* st, ETH_DEV* dev)
#elif defined(USE_BSDTUNTAP) #elif defined(USE_BSDTUNTAP)
#include <sys/types.h> #include <sys/types.h>
#include <net/if_types.h> #include <net/if_types.h>
#include <net/if_tun.h> #include <net/if.h>
#else /* We don't know how to do this on the current platform */ #else /* We don't know how to do this on the current platform */
#undef USE_TAP_NETWORK #undef USE_TAP_NETWORK
#endif #endif
@ -1399,6 +1399,23 @@ t_stat eth_open(ETH_DEV* dev, char* name, DEVICE* dptr, uint32 dbit)
dev->fd_handle = tun; dev->fd_handle = tun;
strcpy(savname, savname+4); strcpy(savname, savname+4);
} }
#if defined (__APPLE__)
if (1) {
struct ifreq ifr;
int s;
memset (&ifr, 0, sizeof(ifr));
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, savname+4, sizeof(ifr.ifr_name));
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) >= 0) {
ifr.ifr_flags |= IFF_UP;
ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr);
}
close(s);
}
}
#endif
} else { } else {
strncpy(errbuf, strerror(errno), sizeof(errbuf)-1); strncpy(errbuf, strerror(errno), sizeof(errbuf)-1);
} }
@ -1465,7 +1482,7 @@ t_stat eth_open(ETH_DEV* dev, char* name, DEVICE* dptr, uint32 dbit)
#endif #endif
#endif /* !defined (USE_READER_THREAD */ #endif /* !defined (USE_READER_THREAD */
#if defined (__APPLE__) #if defined (__APPLE__)
if (1) { if (dev->pcap_mode) {
/* Deliver packets immediately, needed for OS X 10.6.2 and later /* Deliver packets immediately, needed for OS X 10.6.2 and later
* (Snow-Leopard). * (Snow-Leopard).
* See this thread on libpcap and Mac Os X 10.6 Snow Leopard on * See this thread on libpcap and Mac Os X 10.6 Snow Leopard on