From ee291dcfbed8ab6bbfca67c4ed9166827597276b Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Wed, 11 Feb 2009 18:07:52 -0800 Subject: [PATCH] work around to allow FreeBSD to run tap-bridge --- src/devices/tap-bridge/tap-bridge.cc | 20 ++++++++++++++++++++ src/devices/tap-bridge/wscript | 12 +++++++----- wscript | 2 ++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/devices/tap-bridge/tap-bridge.cc b/src/devices/tap-bridge/tap-bridge.cc index 5dbf8cd5c..1b1bad9a9 100644 --- a/src/devices/tap-bridge/tap-bridge.cc +++ b/src/devices/tap-bridge/tap-bridge.cc @@ -41,6 +41,12 @@ #include #include +// #define NO_CREATOR + +#ifdef NO_CREATOR +#include +#endif + NS_LOG_COMPONENT_DEFINE ("TapBridge"); namespace ns3 { @@ -193,6 +199,19 @@ void TapBridge::CreateTap (void) { NS_LOG_FUNCTION_NOARGS (); + +#ifdef NO_CREATOR + // + // In come cases, can you say FreeBSD, the tap-creator just gets in the way. + // in this case, just define NO_CREATOR, manually set up your tap device and + // just open and use it. + // + std::string tapDeviceName = "/dev/" + m_tapDeviceName; + m_sock = open (tapDeviceName.c_str (), O_RDWR); + NS_ABORT_MSG_IF (m_sock == -1, "TapBridge::CreateTap(): could not open device " << tapDeviceName << + ", errno " << strerror (errno)); +#else // use the tap-creator + // // We want to create a tap device on the host. Unfortunately for us // you have to have root privileges to do that. Instead of running the @@ -473,6 +492,7 @@ TapBridge::CreateTap (void) } NS_FATAL_ERROR ("Did not get the raw socket from the socket creator"); } +#endif // use the tap-creator } std::string diff --git a/src/devices/tap-bridge/wscript b/src/devices/tap-bridge/wscript index 9956f6120..0939c1a98 100644 --- a/src/devices/tap-bridge/wscript +++ b/src/devices/tap-bridge/wscript @@ -32,10 +32,12 @@ def build(bld): 'tap-bridge.h', ]) - obj = bld.create_suid_program('tap-creator') - obj.source = [ - 'tap-creator.cc', - 'tap-encode-decode.cc', - ] + + if not env['PLATFORM'].startswith('freebsd'): + obj = bld.create_suid_program('tap-creator') + obj.source = [ + 'tap-creator.cc', + 'tap-encode-decode.cc', + ] diff --git a/wscript b/wscript index 91497991c..ce133385f 100644 --- a/wscript +++ b/wscript @@ -240,6 +240,8 @@ def configure(conf): env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE') env.append_value('CXXDEFINES', 'NS3_LOG_ENABLE') + env['PLATFORM'] = sys.platform + if sys.platform == 'win32': if env['COMPILER_CXX'] == 'g++': env.append_value("LINKFLAGS", "-Wl,--enable-runtime-pseudo-reloc")