--- a/src/devices/tap-bridge/tap-bridge.cc Tue Feb 10 16:41:54 2009 -0800
+++ b/src/devices/tap-bridge/tap-bridge.cc Wed Feb 11 18:07:52 2009 -0800
@@ -41,6 +41,12 @@
#include <limits>
#include <stdlib.h>
+// #define NO_CREATOR
+
+#ifdef NO_CREATOR
+#include <fcntl.h>
+#endif
+
NS_LOG_COMPONENT_DEFINE ("TapBridge");
namespace ns3 {
@@ -193,6 +199,19 @@
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 @@
}
NS_FATAL_ERROR ("Did not get the raw socket from the socket creator");
}
+#endif // use the tap-creator
}
std::string
--- a/src/devices/tap-bridge/wscript Tue Feb 10 16:41:54 2009 -0800
+++ b/src/devices/tap-bridge/wscript Wed Feb 11 18:07:52 2009 -0800
@@ -32,10 +32,12 @@
'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',
+ ]
--- a/wscript Tue Feb 10 16:41:54 2009 -0800
+++ b/wscript Wed Feb 11 18:07:52 2009 -0800
@@ -240,6 +240,8 @@
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")