diff --git a/examples/csma-tap-bridge.cc b/examples/csma-tap-bridge.cc index de440437b..64a93c5f8 100644 --- a/examples/csma-tap-bridge.cc +++ b/examples/csma-tap-bridge.cc @@ -71,6 +71,9 @@ main (int argc, char *argv[]) CommandLine cmd; cmd.Parse (argc, argv); + GlobalValue::Bind ("SimulatorImplementationType", + StringValue ("ns3::RealtimeSimulatorImpl")); + // // Create the nodes required by the topology (shown above). // diff --git a/src/devices/tap-bridge/tap-bridge.cc b/src/devices/tap-bridge/tap-bridge.cc index abc1b3712..12965c6a2 100644 --- a/src/devices/tap-bridge/tap-bridge.cc +++ b/src/devices/tap-bridge/tap-bridge.cc @@ -276,7 +276,7 @@ TapBridge::CreateTap (void) // -n The network mask to assign to the new tap device; // -p the path to the unix socket described above. // - // Example tap-sock-creator -dnewdev -g1.2.3.2 -i1.2.3.1 -m08:00:2e:00:01:23 -n255.255.255.0 -pblah + // Example tap-creator -dnewdev -g1.2.3.2 -i1.2.3.1 -m08:00:2e:00:01:23 -n255.255.255.0 -pblah // // We want to get as much of this stuff automagically as possible. // @@ -311,54 +311,65 @@ TapBridge::CreateTap (void) // through the helper. By default, it is set to the empty string // which tells the system to make up a device name such as "tap123". // - std::ostringstream oss; - oss << "-d" << m_tapDeviceName; + std::ostringstream ossDeviceName; + ossDeviceName << "-d" << m_tapDeviceName; // // The gateway-address is something we can't derive, so we rely on it // being configured via an Attribute through the helper. // - oss << " -g" << m_tapGateway; + std::ostringstream ossGateway; + ossGateway << "-g" << m_tapGateway; // // For flexibility, we do allow a client to override any of the values // above via attributes, so only use our found values if the Attribute // is not equal to its default value (empty string or broadcast address). // + std::ostringstream ossIp; if (m_tapIp.IsBroadcast ()) { - oss << " -i" << ipv4Address; + ossIp << "-i" << ipv4Address; } else { - oss << " -i" << m_tapIp; + ossIp << "-i" << m_tapIp; } + std::ostringstream ossMac; if (m_tapMac.IsBroadcast ()) { - oss << " -m" << mac48Address; + ossMac << "-m" << mac48Address; } else { - oss << " -m" << m_tapMac; + ossMac << "-m" << m_tapMac; } + std::ostringstream ossNetmask; if (m_tapNetmask.IsEqual (Ipv4Mask::GetOnes ())) { - oss << " -n" << ipv4Mask; + ossNetmask << "-n" << ipv4Mask; } else { - oss << " -n" << m_tapNetmask; + ossNetmask << "-n" << m_tapNetmask; } - oss << " -p" << path; - NS_LOG_INFO ("creator arguments set to \"" << oss.str () << "\""); - + std::ostringstream ossPath; + ossPath << "-p" << path; // // Execute the socket creation process image. // - status = ::execl (FindCreator ().c_str (), "tap-sock-creator", oss.str ().c_str (), (char *)NULL); + status = ::execl (FindCreator ("tap-creator").c_str (), + FindCreator ("tap-creator").c_str (), // argv[0] (filename) + ossDeviceName.str ().c_str (), // argv[1] (-d) + ossGateway.str ().c_str (), // argv[2] (-g) + ossIp.str ().c_str (), // argv[3] (-i) + ossMac.str ().c_str (), // argv[4] (-m) + ossNetmask.str ().c_str (), // argv[5] (-n) + ossPath.str ().c_str (), // argv[6] (-p) + (char *)NULL); // // If the execl successfully completes, it never returns. If it returns it failed or the OS is @@ -495,20 +506,37 @@ TapBridge::CreateTap (void) } std::string -TapBridge::FindCreator (void) +TapBridge::FindCreator (std::string creatorName) { - struct stat st; - std::string debug = "./build/debug/src/devices/tap-bridge/tap-sock-creator"; - std::string optimized = "./build/optimized/src/devices/tap-bridge/tap-sock-creator"; + NS_LOG_FUNCTION (creatorName); - if (::stat (debug.c_str (), &st) == 0) - { - return debug; - } + std::list locations; - if (::stat (optimized.c_str (), &st) == 0) + // in repo + locations.push_back ("./build/optimized/src/devices/tap-bridge/"); + locations.push_back ("./build/debug/src/devices/tap-bridge/"); + + // in src + locations.push_back ("../build/optimized/src/devices/tap-bridge/"); + locations.push_back ("../build/debug/src/devices/tap-bridge/"); + + // in src/devices + locations.push_back ("../../build/optimized/src/devices/tap-bridge/"); + locations.push_back ("../../build/debug/src/devices/tap-bridge/"); + + // in src/devices/tap-bridge + locations.push_back ("../../../build/optimized/src/devices/tap-bridge/"); + locations.push_back ("../../../build/debug/src/devices/tap-bridge/"); + + for (std::list::const_iterator i = locations.begin (); i != locations.end (); ++i) { - return optimized; + struct stat st; + + if (::stat ((*i + creatorName).c_str (), &st) == 0) + { + NS_LOG_INFO ("Found Creator " << *i + creatorName); + return *i + creatorName; + } } NS_FATAL_ERROR ("TapBridge::FindCreator(): Couldn't find creator"); diff --git a/src/devices/tap-bridge/tap-bridge.h b/src/devices/tap-bridge/tap-bridge.h index d73ae7d8e..5115df26e 100644 --- a/src/devices/tap-bridge/tap-bridge.h +++ b/src/devices/tap-bridge/tap-bridge.h @@ -151,7 +151,7 @@ private: /** * Figure out where the tap creation program lives on the system. */ - std::string FindCreator (void); + std::string FindCreator (std::string creatorName); /** * Spin up the device diff --git a/src/devices/tap-bridge/tap-creator.cc b/src/devices/tap-bridge/tap-creator.cc index 57bcd2719..0ba67a238 100644 --- a/src/devices/tap-bridge/tap-creator.cc +++ b/src/devices/tap-bridge/tap-creator.cc @@ -352,13 +352,12 @@ main (int argc, char *argv[]) opterr = 0; + gVerbose = true; + while ((c = getopt (argc, argv, "vd:g:i:m:n:p:")) != -1) { switch (c) { - case 'v': - gVerbose = true; - break; case 'd': dev = optarg; // name of the new tap device break; @@ -377,6 +376,9 @@ main (int argc, char *argv[]) case 'p': path = optarg; // path back to the tap bridge break; + case 'v': + gVerbose = true; + break; } } @@ -447,7 +449,7 @@ main (int argc, char *argv[]) int sock = CreateTap (dev, gw, ip, mac, netmask); ABORT_IF (sock == -1, "main(): Unable to create tap socket", 1); -#if 1 +#if 0 for (;;) { LOG ("z");