src/devices/emu/emu-net-device.cc
changeset 4417 973e0e873127
parent 4370 a64e987a727a
child 4424 af26433b13bc
--- a/src/devices/emu/emu-net-device.cc	Sun Apr 26 15:36:59 2009 -0700
+++ b/src/devices/emu/emu-net-device.cc	Sun Apr 26 18:20:07 2009 -0700
@@ -385,7 +385,10 @@
       //
       // Execute the socket creation process image.
       //
-      status = ::execl (FindCreator ().c_str (), "emu-sock-creator", oss.str ().c_str (), (char *)NULL);
+      status = ::execl (FindCreator ("emu-sock-creator").c_str (), 
+                        "emu-sock-creator",                             // argv[0] (filename)
+                        oss.str ().c_str (),                            // argv[1] (-p<path?
+                        (char *)NULL);
 
       //
       // If the execl successfully completes, it never returns.  If it returns it failed or the OS is
@@ -520,20 +523,41 @@
 }
 
 std::string
-EmuNetDevice::FindCreator (void)
+EmuNetDevice::FindCreator (std::string creatorName)
 {
-  struct stat st;
-  std::string debug = "./build/debug/src/devices/emu/emu-sock-creator";
-  std::string optimized = "./build/optimized/src/devices/emu/emu-sock-creator";
+  NS_LOG_FUNCTION (creatorName);
+
+  std::list<std::string> locations;
+
+  // The path to the bits if we're sitting there with them
+  locations.push_back ("./");
+  locations.push_back ("./");
+
+  // The path to the bits if we're sitting in the root of the repo
+  locations.push_back ("./build/optimized/src/devices/emu/");
+  locations.push_back ("./build/debug/src/devices/emu/");
+
+  // if at the level of src (or build)
+  locations.push_back ("../build/optimized/src/devices/emu/");
+  locations.push_back ("../build/debug/src/devices/emu/");
 
-  if (::stat (debug.c_str (), &st) == 0)
+  // src/devices (or build/debug)
+  locations.push_back ("../../build/optimized/src/devices/emu/");
+  locations.push_back ("../../build/debug/src/devices/emu/");
+
+  // src/devices/emu (or build/debug/examples)
+  locations.push_back ("../../../build/optimized/src/devices/emu/");
+  locations.push_back ("../../../build/debug/src/devices/emu/");
+
+  for (std::list<std::string>::const_iterator i = locations.begin (); i != locations.end (); ++i)
     {
-      return debug;
-    }
+      struct stat st;
 
-  if (::stat (optimized.c_str (), &st) == 0)
-    {
-      return optimized;
+      if (::stat ((*i + creatorName).c_str (), &st) == 0)
+	{
+          NS_LOG_INFO ("Found Creator " << *i + creatorName);                  
+	  return *i + creatorName;
+	}
     }
 
   NS_FATAL_ERROR ("EmuNetDevice::FindCreator(): Couldn't find creator");
@@ -586,13 +610,6 @@
   //
   Ptr<Packet> originalPacket = packet->Copy ();
 
-  //
-  // Checksum the packet
-  //
-  EthernetTrailer trailer;
-  packet->RemoveTrailer (trailer);
-  trailer.CheckFcs (packet);
-
   EthernetHeader header (false);
   packet->RemoveHeader (header);