update a lot draft default tip
authorHajime Tazaki <tazaki@nict.go.jp>
Thu, 20 Jun 2013 09:56:26 +0900
changeset 26 0fca5307fd86
parent 25 7d5166e0dc25
update a lot
bgp-caida.patch
cradle-bulk.patch
dce-debug.patch
dce-sctp.patch
dce_test_improve.patch
fedora8-nontimerfd.patch
linux-stack-rework.patch
modulize-quagga-mip6.patch
more-test.patch
mpitest.patch
new-tutorial.patch
perf-update.patch
poll-rework.patch
pyscan.patch
python-binding.patch
series
task-mgr-rework.patch
valg.patch
waf-module-find.patch
--- a/bgp-caida.patch	Mon Aug 06 20:45:50 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-diff -r 137184880c3b example/dce-quagga-bgpd-caida.cc
---- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/example/dce-quagga-bgpd-caida.cc	Tue Jan 24 17:31:19 2012 +0900
-@@ -0,0 +1,159 @@
-+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-+
-+#include "ns3/network-module.h"
-+#include "ns3/core-module.h"
-+#include "ns3/internet-module.h"
-+#include "ns3/dce-module.h"
-+#include "ns3/quagga-helper.h"
-+#include "ns3/point-to-point-helper.h"
-+#include "../helper/ipv4-dce-routing-helper.h"
-+#include "ns3/topology-read-module.h"
-+#include <sys/resource.h>
-+
-+using namespace ns3;
-+NS_LOG_COMPONENT_DEFINE ("DceQuaggaBgpd");
-+
-+// Parameters
-+uint32_t nNodes = 2;
-+uint32_t stopTime = 6000;
-+
-+static void
-+SetRlimit ()
-+{
-+  int ret;
-+  struct rlimit limit;
-+  limit.rlim_cur = 1000000;
-+  limit.rlim_max = 1000000;
-+
-+  ret = setrlimit(RLIMIT_NOFILE, &limit);
-+  if (ret == -1)
-+    {
-+       perror ("setrlimit");
-+    }
-+  return;
-+}
-+
-+static void RunIp (Ptr<Node> node, Time at, std::string str)
-+{
-+  DceApplicationHelper process;
-+  ApplicationContainer apps;
-+  process.SetBinary ("ip");
-+  process.SetStackSize (1<<16);
-+  process.ResetArguments();
-+  process.ParseArguments(str.c_str ());
-+  apps = process.Install (node);
-+  apps.Start (at);
-+}
-+
-+static void AddAddress (Ptr<Node> node, Time at, const char *name, const char *address)
-+{
-+  std::ostringstream oss;
-+  oss << "-f inet addr add " << address << " dev " << name;
-+  RunIp (node, at, oss.str ());
-+}
-+
-+int main (int argc, char *argv[]) {
-+  // 
-+  //  Step 0
-+  //  Node Basic Configuration
-+  // 
-+
-+  CommandLine cmd;
-+  cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime);
-+  cmd.Parse (argc,argv);
-+
-+  // 
-+  //  Step 1
-+  //  Node Basic Configuration
-+  // 
-+  Ptr<TopologyReader> inFile = 0;
-+  TopologyReaderHelper topoHelp;
-+  NodeContainer nodes;
-+  
-+  std::string format ("Caida");
-+  std::string input ("./asrel-as2500.txt");
-+
-+  topoHelp.SetFileName(input);
-+  topoHelp.SetFileType(format);
-+  inFile = topoHelp.GetTopologyReader();
-+
-+  if (inFile != 0)
-+    {
-+      nodes = inFile->Read ();
-+    }
-+
-+  if (nodes.GetN () == 0)
-+    {
-+      NS_LOG_ERROR ("Problems reading node information the topology file. Failing.");
-+      return -1;
-+    }
-+  if (inFile->LinksSize () == 0)
-+    {
-+      NS_LOG_ERROR ("Problems reading the topology file. Failing.");
-+      return -1;
-+    }
-+  NS_LOG_INFO ("Caida topology created with " << nodes.GetN () << " nodes and " << 
-+               inFile->LinksSize () << " links (from " << input << ")");
-+
-+  // Address conf In virtual topology
-+  PointToPointHelper p2p;
-+  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
-+  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
-+
-+  int totlinks = inFile->LinksSize ();
-+  NS_LOG_INFO ("creating node containers");
-+  NodeContainer nc[totlinks];
-+  TopologyReader::ConstLinksIterator iter;
-+  int i = 0;
-+  for ( iter = inFile->LinksBegin (); iter != inFile->LinksEnd (); iter++, i++ )
-+    {
-+      nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
-+    }
-+
-+  DceManagerHelper processManager;
-+  processManager.SetLoader ("ns3::DlmLoaderFactory");
-+  processManager.SetTaskManagerAttribute ("FiberManagerType", 
-+                                          EnumValue (0));
-+  processManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
-+                                 "Library", StringValue ("libnet-next-2.6.so"));
-+  processManager.Install (nodes);
-+  QuaggaHelper quagga;
-+  quagga.EnableBgp (nodes);
-+
-+  NS_LOG_INFO ("creating net device containers");
-+  NetDeviceContainer ndc[totlinks];
-+  for (int i = 0; i < totlinks; i++)
-+    {
-+      ndc[i] = p2p.Install (nc[i]);
-+
-+#if 0
-+      // IP address configuration
-+      AddAddress (nodes.Get (0), Seconds (0.1), "sim0", "10.0.0.1/24");
-+      RunIp (nodes.Get (0), Seconds (0.11), "link set lo up");
-+      RunIp (nodes.Get (0), Seconds (0.11), "link set sim0 up");
-+
-+      AddAddress (nodes.Get (1), Seconds (0.1), "sim0", "10.0.0.2/24");
-+      RunIp (nodes.Get (1), Seconds (0.11), "link set lo up");
-+      RunIp (nodes.Get (1), Seconds (0.11), "link set sim0 up");
-+
-+      quagga.BgpAddNeighbor (nodes.Get (0), "10.0.0.2", quagga.GetAsn(nodes.Get (1)));
-+      quagga.BgpAddNeighbor (nodes.Get (1), "10.0.0.1", quagga.GetAsn(nodes.Get (0)));
-+      quagga.Install (nodes);  
-+#endif
-+    }
-+
-+
-+  //  p2p.EnablePcapAll ("dce-quagga-bgpd-caida");
-+
-+  // 
-+  // Now It's ready to GO!
-+  // 
-+  if (stopTime != 0)
-+    {
-+      Simulator::Stop (Seconds (stopTime));
-+    }
-+  Simulator::Run ();
-+  Simulator::Destroy ();
-+
-+  return 0;
-+}
-diff -r 137184880c3b wscript
---- a/wscript	Tue Jan 24 16:33:26 2012 +0900
-+++ b/wscript	Tue Jan 24 17:31:19 2012 +0900
-@@ -266,6 +266,10 @@
-                        target='bin/dce-quagga-ospfd',
-                        source=['example/dce-quagga-ospfd.cc'])
- 
-+    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'visualizer', 'topology-read'],
-+                       target='bin/dce-quagga-bgpd-caida',
-+                       source=['example/dce-quagga-bgpd-caida.cc'])
-+
-     module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
-                        target='bin/dce-quagga-bgpd',
-                        source=['example/dce-quagga-bgpd.cc'])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cradle-bulk.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,251 @@
+diff --git a/example/dce-cradle-simple.cc b/example/dce-cradle-simple.cc
+--- a/example/dce-cradle-simple.cc
++++ b/example/dce-cradle-simple.cc
+@@ -34,6 +34,8 @@
+ std::string m_rate = "100Bps";
+ bool m_dual = false;
+ std::string m_ccid = "2";
++bool m_bulk = false;
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -57,6 +59,7 @@
+   cmd.AddValue ("rate", "tx rate", m_rate);
+   cmd.AddValue ("dual", "dual flow or not (default: uni-directional)", m_dual);
+   cmd.AddValue ("ccid", "CCID if dccp (default: 2)", m_ccid);
++  cmd.AddValue ("bulk", "use BulkSendApp instead of OnOffApp", m_bulk);
+   cmd.Parse (argc, argv);
+ 
+   NodeContainer nodes;
+@@ -89,17 +92,35 @@
+   ApplicationContainer apps;
+   OnOffHelper onoff = OnOffHelper (proto_sw[m_proto],
+                                    InetSocketAddress (interfaces.GetAddress (1), 9));
+-  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
+-  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
+-  onoff.SetAttribute ("PacketSize", StringValue ("1024"));
+-  onoff.SetAttribute ("DataRate", StringValue (m_rate));
+-  apps = onoff.Install (nodes.Get (0));
+-  apps.Start (Seconds (4.0));
+-  if (m_dual)
++  if (!m_bulk)
+     {
+-      onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (interfaces.GetAddress (0), 9)));
+-      apps = onoff.Install (nodes.Get (1));
+-      apps.Start (Seconds (4.1));
++      onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
++      onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
++      onoff.SetAttribute ("PacketSize", StringValue ("1024"));
++      onoff.SetAttribute ("DataRate", StringValue (m_rate));
++      apps = onoff.Install (nodes.Get (0));
++      apps.Start (Seconds (4.0));
++      if (m_dual)
++        {
++          onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (interfaces.GetAddress (0), 9)));
++          apps = onoff.Install (nodes.Get (1));
++          apps.Start (Seconds (4.1));
++        }
++    }
++  else
++    {
++      BulkSendHelper bulk (proto_sw[m_proto],
++                           InetSocketAddress (interfaces.GetAddress (1), 9));
++      // Set the amount of data to send in bytes.  Zero is unlimited.
++      bulk.SetAttribute ("MaxBytes", UintegerValue (1024));
++      apps = bulk.Install (nodes.Get (0));
++      apps.Start (Seconds (4.0));
++      if (m_dual)
++        {
++          bulk.SetAttribute ("Remote", AddressValue (InetSocketAddress (interfaces.GetAddress (0), 9)));
++          apps = bulk.Install (nodes.Get (1));
++          apps.Start (Seconds (4.1));
++        }
+     }
+ 
+   PacketSinkHelper sink = PacketSinkHelper (proto_sw[m_proto],
+diff --git a/example/dce-tcp-ns3-nsc-comparison.cc b/example/dce-tcp-ns3-nsc-comparison.cc
+--- a/example/dce-tcp-ns3-nsc-comparison.cc
++++ b/example/dce-tcp-ns3-nsc-comparison.cc
+@@ -40,6 +40,7 @@
+ bool enablePcap = false;
+ std::string m_pktSize = "1024";
+ bool m_frag = false;
++bool m_bulk = false;
+ 
+ int
+ main (int argc, char *argv[])
+@@ -55,6 +56,7 @@
+   cmd.AddValue ("enablePcap", "pcap", enablePcap);
+   cmd.AddValue ("pktSize", "packet size", m_pktSize);
+   cmd.AddValue ("frag", "fragment", m_frag);
++  cmd.AddValue ("bulk", "use BulkSendApp instead of OnOffApp", m_bulk);
+   cmd.Parse (argc, argv);
+ 
+   SeedManager::SetSeed (m_seed);
+@@ -91,10 +93,10 @@
+     }
+   else if (m_stack == "dce-dccp")
+     {
+-      internetStack.Install (routers);
+       dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory",
+                                   "Library", StringValue ("liblinux.so"));
+       sock_factory = "ns3::LinuxDccpSocketFactory";
++      stack.Install (routers);
+       stack.Install (lefts);
+       stack.Install (rights);
+     }
+@@ -215,17 +217,34 @@
+                                    InetSocketAddress (Ipv4Address ("10.2.0.2"), 2000));
+   onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
+   onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
++  onoff.SetAttribute ("PacketSize", StringValue (m_pktSize));
++  onoff.SetAttribute ("DataRate", StringValue ("1Mbps"));
++
++  BulkSendHelper bulk = BulkSendHelper (sock_factory,
++                                        InetSocketAddress ("10.2.0.2", 2000));
++  // Set the amount of data to send in bytes.  Zero is unlimited.
++  bulk.SetAttribute ("MaxBytes", UintegerValue (0));
++  bulk.SetAttribute ("SendSize", UintegerValue (atoi (m_pktSize.c_str ())));
+ 
+   // Flow 1 - n
+   for (uint32_t i = 0; i < m_nNodes; i++)
+     {
+       std::ostringstream oss;
+       oss << "10.2." << i << ".2";
+-      onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (Ipv4Address (oss.str ().c_str ()), 2000)));
+-      onoff.SetAttribute ("PacketSize", StringValue (m_pktSize));
+-      onoff.SetAttribute ("DataRate", StringValue ("1Mbps"));
+-      onoff.SetAttribute ("StartTime", TimeValue (Seconds (startTime)));
+-      apps = onoff.Install (lefts.Get (i));
++      if (!m_bulk)
++        {
++          onoff.SetAttribute ("Remote", 
++                              AddressValue (InetSocketAddress (Ipv4Address (oss.str ().c_str ()), 2000)));
++          onoff.SetAttribute ("StartTime", TimeValue (Seconds (startTime)));
++          apps = onoff.Install (lefts.Get (i));
++        }
++      else
++        {
++          bulk.SetAttribute ("Remote", 
++                             AddressValue (InetSocketAddress (Ipv4Address (oss.str ().c_str ()), 2000)));
++          apps = bulk.Install (lefts.Get (i));
++          apps.Start (Seconds (startTime));
++        }
+     }
+ 
+   PacketSinkHelper sink = PacketSinkHelper (sock_factory,
+diff --git a/example/examples-to-run.py b/example/examples-to-run.py
+--- a/example/examples-to-run.py
++++ b/example/examples-to-run.py
+@@ -30,8 +30,15 @@
+     ("dce-cradle-simple --rate=10kbps --proto=tcp", "True", "True"),
+     ("dce-cradle-simple --rate=10kbps --proto=dccp", "True", "True"),
+     ("dce-cradle-simple --rate=10kbps --proto=dccp -ccid=3", "True", "True"),
++    ("dce-cradle-simple --bulk=1 --rate=10kbps --proto=tcp", "True", "True"),
++    ("dce-cradle-simple --bulk=1 --rate=10kbps --proto=dccp", "True", "True"),
++    ("dce-cradle-simple --bulk=1 --rate=10kbps --proto=dccp -ccid=3", "True", "True"),
+     ("dce-tcp-ns3-nsc-comparison", "True", "True"), 
+     ("dce-tcp-ns3-nsc-comparison --stack=dce", "True", "True"),
++    ("dce-tcp-ns3-nsc-comparison --bulk=1", "True", "True"), 
++    ("dce-tcp-ns3-nsc-comparison --stack=dce --bulk=1", "True", "True"),
++    ("dce-tcp-ns3-nsc-comparison --stack=dce-dccp", "True", "True"),
++    ("dce-tcp-ns3-nsc-comparison --stack=dce-dccp --bulk=1", "True", "True"),
+     ("dce-ping-mt1 --kernel=1", "True", "True"),
+     ("dce-mt2 --kernel=1", "True", "True"),
+     ("dce-mt3 --kernel=1", "True", "True"),
+diff --git a/model/linux/linux-socket-impl.cc b/model/linux/linux-socket-impl.cc
+--- a/model/linux/linux-socket-impl.cc
++++ b/model/linux/linux-socket-impl.cc
+@@ -138,11 +138,11 @@
+   return tid;
+ }
+ 
+-bool m_conn_inprogress = false;
+ LinuxSocketImpl::LinuxSocketImpl ()
+ {
+   NS_LOG_FUNCTION_NOARGS ();
+   m_listening = false;
++  m_conn_inprogress = false;
+   m_pid = -1;
+   SetNs3ToPosixConverter (MakeCallback (&LinuxSocketImpl::Ns3AddressToPosixAddress, this));
+   SetPosixToNs3Converter (MakeCallback (&LinuxSocketImpl::PosixAddressToNs3Address, this));
+@@ -197,7 +197,27 @@
+ enum Socket::SocketType
+ LinuxSocketImpl::GetSocketType (void) const
+ {
+-  return NS3_SOCK_DGRAM;
++  switch (m_socktype)
++    {
++    case SOCK_STREAM:
++    case SOCK_DCCP:
++      {
++        return NS3_SOCK_STREAM;
++        break;
++      }
++    case SOCK_DGRAM:
++      {
++        return NS3_SOCK_DGRAM;
++        break;
++      }
++    case SOCK_RAW:
++      {
++        return NS3_SOCK_RAW;
++        break;
++      }
++    default:
++        break;
++    }
+ }
+ 
+ uint16_t
+@@ -514,7 +534,7 @@
+       LeaveFakeTask (pid);
+ 
+       // Notify the data
+-      mask &= (POLLIN | POLLERR | POLLHUP | POLLRDHUP);
++      mask &= (POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDHUP);
+       if (mask)
+         {
+           Ptr<LinuxSocketFdFactory> factory = 0;
+@@ -577,14 +597,27 @@
+                   Current ()->process->manager->Wait ();
+                 }
+ 
+-              NS_LOG_INFO ("notify recv");
+-              NotifyDataRecv ();
++              else if (mask & POLLIN || mask & POLLERR)
++                {
++                  NS_LOG_INFO ("notify recv");
++                  NotifyDataRecv ();
++                }
++              else if (mask & POLLOUT)
++                {
++                  Simulator::ScheduleWithContext (m_node->GetId (), Seconds (0.0),
++                                                  MakeEvent (&LinuxSocketImpl::NotifySend, this, 0));
++                  NS_LOG_INFO ("wait send for next poll event");
++                  table->Wait (Seconds (0));
++                  NS_LOG_INFO ("awaken");
++                }
+             }
+         }
+       // if not masked
+       else
+         {
++          NS_LOG_INFO ("wait for next poll event");
+           table->Wait (Seconds (0));
++          NS_LOG_INFO ("awaken");
+         }
+ 
+       // next loop
+diff --git a/model/linux/linux-socket-impl.h b/model/linux/linux-socket-impl.h
+--- a/model/linux/linux-socket-impl.h
++++ b/model/linux/linux-socket-impl.h
+@@ -109,6 +109,7 @@
+   uint16_t m_socktype;
+   uint16_t m_protocol;
+   bool m_listening;
++  bool m_conn_inprogress;
+   uint16_t m_pid;
+   EventId m_poll;
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dce-debug.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,11 @@
+diff --git a/model/dce-debug.cc b/model/dce-debug.cc
+--- a/model/dce-debug.cc
++++ b/model/dce-debug.cc
+@@ -27,7 +27,6 @@
+ uint32_t dce_debug_nodeid (void)
+ {
+   NS_LOG_FUNCTION (Current () << UtilsGetNodeId ());
+-  NS_ASSERT (Current () != 0);
+   return UtilsGetNodeId ();
+ }
+ const char * dce_debug_processname (void)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dce-sctp.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,455 @@
+diff -r 4f91d96592e9 -r 8bc8c14ee22c example/dce-sctp-simple.cc
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/example/dce-sctp-simple.cc	Fri Oct 12 10:45:01 2012 +0900
+@@ -0,0 +1,80 @@
++#include "ns3/core-module.h"
++#include "ns3/network-module.h"
++#include "ns3/dce-module.h"
++#include "ns3/point-to-point-module.h"
++#include "ns3/internet-module.h"
++#include <fstream>
++
++using namespace ns3;
++
++static void RunIp (Ptr<Node> node, Time at, std::string str)
++{
++  DceApplicationHelper process;
++  ApplicationContainer apps;
++  process.SetBinary ("ip");
++  process.SetStackSize (1<<16);
++  process.ResetArguments();
++  process.ParseArguments(str.c_str ());
++  apps = process.Install (node);
++  apps.Start (at);
++}
++
++int main (int argc, char *argv[])
++{
++  CommandLine cmd;
++  cmd.Parse (argc, argv);
++
++  NodeContainer nodes;
++  nodes.Create (2);
++
++  NetDeviceContainer devices;
++
++  PointToPointHelper p2p;
++  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Gbps"));
++  p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
++  devices = p2p.Install (nodes);
++  p2p.EnablePcapAll ("dce-sctp-simple");
++
++  DceManagerHelper processManager;
++  processManager.SetTaskManagerAttribute ("FiberManagerType",
++                                          StringValue ("UcontextFiberManager"));
++  // processManager.SetLoader ("ns3::DlmLoaderFactory");
++  processManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
++  LinuxStackHelper stack;
++  stack.Install (nodes);
++
++  Ipv4AddressHelper address;
++  address.SetBase ("10.0.0.0", "255.255.255.0");
++  Ipv4InterfaceContainer interfaces = address.Assign (devices);
++
++  processManager.Install (nodes);
++
++
++  for (int n=0; n < 2; n++)
++    {
++      RunIp (nodes.Get (n), Seconds (0.2), "link show");
++      RunIp (nodes.Get (n), Seconds (0.3), "route show table all");
++      RunIp (nodes.Get (n), Seconds (0.4), "addr list");
++    }
++
++  DceApplicationHelper process;
++  ApplicationContainer apps;
++
++  process.SetBinary ("sctp-server");
++  process.ResetArguments ();
++  process.SetStackSize (1<<16);
++  apps = process.Install (nodes.Get (0));
++  apps.Start (Seconds (1.0));
++
++  process.SetBinary ("sctp-client");
++  process.ResetArguments ();
++  process.ParseArguments ("10.0.0.1");
++  apps = process.Install (nodes.Get (1));
++  apps.Start (Seconds (1.5));
++
++  Simulator::Stop (Seconds (2000000.0));
++  Simulator::Run ();
++  Simulator::Destroy ();
++
++  return 0;
++}
+diff -r 4f91d96592e9 -r 8bc8c14ee22c example/sctp-client.cc
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/example/sctp-client.cc	Fri Oct 12 10:45:01 2012 +0900
+@@ -0,0 +1,89 @@
++// 
++// libstcp1-dev is needed
++// 
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>        /* for memset */
++#include <unistd.h>        /* for memset */
++#include <sys/socket.h>
++#include <sys/types.h>
++#include <arpa/inet.h>
++#include <netinet/in.h>
++#include <netinet/sctp.h>
++
++int
++main (int argc, char **argv)
++{
++  int connect_sock, stat, port, slen, i, flags;
++  struct sctp_initmsg initmsg;
++  struct sockaddr_in server_addr;
++  struct sctp_event_subscribe s_events;
++  struct sctp_status s_status;
++  struct sctp_sndrcvinfo s_sndrcvinfo;
++  char buffer[1024];
++
++  port = 3007;
++
++  connect_sock = socket (AF_INET, SOCK_STREAM, IPPROTO_SCTP);
++  memset (&initmsg, 0, sizeof (initmsg));
++  initmsg.sinit_num_ostreams = 3;          // Number of Output Stream
++  initmsg.sinit_max_instreams = 3;      // Number of Input Stream
++  initmsg.sinit_max_attempts = 4;
++  stat = setsockopt (connect_sock, IPPROTO_SCTP, SCTP_INITMSG,
++                     &initmsg, sizeof (initmsg) );
++  if (stat < 0)
++    {
++      perror ("setsockopt error");
++      exit (-1);
++    }
++
++  memset (&server_addr, 0, sizeof (server_addr));
++  server_addr.sin_family = AF_INET;
++  server_addr.sin_port = htons (port);
++  server_addr.sin_addr.s_addr = inet_addr (argv[1]);
++
++  stat = connect (connect_sock, (struct sockaddr *)&server_addr, 
++                  sizeof (server_addr) );
++  if (stat < 0)
++    {
++      perror ("connect error");
++      exit (-1);
++    }
++
++  memset (&s_events, 0, sizeof (s_events));
++  s_events.sctp_data_io_event = 1;
++  stat = setsockopt (connect_sock, SOL_SCTP, SCTP_EVENTS,
++                     (const void *)&s_events, sizeof (s_events));
++  if (stat < 0)
++    {
++      perror ("event error");
++      exit (-1);
++    }
++
++  slen = sizeof (s_status);
++  stat = getsockopt (connect_sock, SOL_SCTP, SCTP_STATUS,
++                     (void *)&s_status, (socklen_t *)&slen );
++
++  printf ("assoc id  = %d\n", s_status.sstat_assoc_id );
++  printf ("state     = %d\n", s_status.sstat_state );
++  printf ("instrms   = %d\n", s_status.sstat_instrms );
++  printf ("outstrms  = %d\n", s_status.sstat_outstrms );
++
++
++  for (i = 0 ; i < 2 ; i++)
++    {
++      stat = sctp_recvmsg (connect_sock, (void *)buffer, sizeof (buffer),
++                           (struct sockaddr *)NULL, 0, &s_sndrcvinfo, &flags );
++      printf ("stat = %d\n", stat);
++      if (stat > 0)
++        {
++          buffer[stat] = 0;
++          printf ("(Stream %d) %s\n", s_sndrcvinfo.sinfo_stream, buffer);
++        }
++    }
++  /* Close our socket and exit */
++  close (connect_sock);
++  return 0;
++}
++
++
+diff -r 4f91d96592e9 -r 8bc8c14ee22c example/sctp-client.cc~
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/example/sctp-client.cc~	Fri Oct 12 10:45:01 2012 +0900
+@@ -0,0 +1,87 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>        /* for memset */
++#include <unistd.h>        /* for memset */
++#include <sys/socket.h>
++#include <sys/types.h>
++#include <arpa/inet.h>
++#include <netinet/in.h>
++#include <netinet/sctp.h>
++
++void my_exit (char *str)
++{
++  perror (str);
++  exit (1);
++}
++
++int main (int argc, char **argv)
++{
++  int connect_sock, stat, port, slen, i, flags;
++  struct sctp_initmsg initmsg;
++  struct sockaddr_in server_addr;
++  struct sctp_event_subscribe s_events;
++  struct sctp_status s_status;
++  struct sctp_sndrcvinfo s_sndrcvinfo;
++  char buffer[1024];
++
++  port = 3007;
++
++  connect_sock = socket (AF_INET, SOCK_STREAM, IPPROTO_SCTP);
++  memset (&initmsg, 0, sizeof(initmsg));
++  initmsg.sinit_num_ostreams = 3;          // Number of Output Stream
++  initmsg.sinit_max_instreams = 3;      // Number of Input Stream
++  initmsg.sinit_max_attempts = 4;
++  stat = setsockopt (connect_sock, IPPROTO_SCTP, SCTP_INITMSG,
++                     &initmsg, sizeof(initmsg) );
++  if (stat < 0)
++    {
++      my_exit ("setsockopt error");
++    }
++
++  memset (&server_addr, 0, sizeof(server_addr));
++  server_addr.sin_family = AF_INET;
++  server_addr.sin_port = htons (port);
++  server_addr.sin_addr.s_addr = inet_addr ("127.0.0.1");
++
++  stat = connect (connect_sock, (struct sockaddr *)&server_addr, sizeof(server_addr) );
++  if (stat < 0)
++    {
++      my_exit ("connect error");
++    }
++
++  memset (&s_events, 0, sizeof(s_events));
++  s_events.sctp_data_io_event = 1;
++  stat = setsockopt (connect_sock, SOL_SCTP, SCTP_EVENTS,
++                     (const void *)&s_events, sizeof(s_events));
++  if (stat < 0)
++    {
++      my_exit ("event error");
++    }
++
++  slen = sizeof(s_status);
++  stat = getsockopt (connect_sock, SOL_SCTP, SCTP_STATUS,
++                     (void *)&s_status, (socklen_t *)&slen );
++
++  printf ("assoc id  = %d\n", s_status.sstat_assoc_id );
++  printf ("state     = %d\n", s_status.sstat_state );
++  printf ("instrms   = %d\n", s_status.sstat_instrms );
++  printf ("outstrms  = %d\n", s_status.sstat_outstrms );
++
++
++  for (i = 0 ; i < 2 ; i++)
++    {
++      stat = sctp_recvmsg (connect_sock, (void *)buffer, sizeof(buffer),
++                           (struct sockaddr *)NULL, 0, &s_sndrcvinfo, &flags );
++      printf ("stat = %d\n", stat);
++      if (stat > 0)
++        {
++          buffer[stat] = 0;
++          printf ("(Stream %d) %s\n", s_sndrcvinfo.sinfo_stream, buffer);
++        }
++    }
++  /* Close our socket and exit */
++  close (connect_sock);
++  return 0;
++}
++
++
+diff -r 4f91d96592e9 -r 8bc8c14ee22c example/sctp-server.cc
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/example/sctp-server.cc	Fri Oct 12 10:45:01 2012 +0900
+@@ -0,0 +1,78 @@
++// 
++// libstcp1-dev is needed
++// 
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/socket.h>
++#include <sys/types.h>
++#include <arpa/inet.h>
++#include <netinet/in.h>
++#include <netinet/sctp.h>
++
++void
++echo_main (int sock)
++{
++  int stat;
++  char buffer[1024];
++
++  printf ("sock: %d\n", sock);
++
++  // Stream No.0
++  sprintf (buffer, "This is a test of stream 0");
++  stat = sctp_sendmsg (sock, buffer, (size_t)strlen (buffer),
++                       NULL, 0, 0, 0, 0, 0, 0);
++
++  // Stream No.1
++  sprintf (buffer, "This is a test of stream 1");
++  stat = sctp_sendmsg (sock, buffer, (size_t)strlen (buffer),
++                       NULL, 0, 0, 0, 1, 0, 0);
++}
++
++int
++main (int argc, char **argv)
++{
++  int sock_listen, sock_server, stat;
++  struct sockaddr_in server_addr;
++  struct sctp_initmsg s_initmsg;
++  int echo_port;
++
++  echo_port = 3007;
++
++  sock_listen = socket (AF_INET, SOCK_STREAM, IPPROTO_SCTP);
++
++  memset (&server_addr, 0, sizeof(server_addr));
++  server_addr.sin_family = AF_INET;
++  server_addr.sin_addr.s_addr = htonl (INADDR_ANY);
++  server_addr.sin_port = htons (echo_port);
++
++  stat = bind (sock_listen, (struct sockaddr *)&server_addr, sizeof(server_addr));
++
++  // SCTP parameter
++  memset (&s_initmsg, 0, sizeof(s_initmsg));
++  s_initmsg.sinit_num_ostreams = 5;
++  s_initmsg.sinit_max_instreams = 5;
++  s_initmsg.sinit_max_attempts = 5;
++
++  stat = setsockopt (sock_listen, IPPROTO_SCTP, SCTP_INITMSG,
++                     &s_initmsg, sizeof(s_initmsg));
++  if (stat < 0)
++    {
++      perror ("Socket Option error");
++      exit (-1);
++    }
++
++  listen (sock_listen, 5);
++  while (1)
++    {
++      printf ("SCTP server accepting\n");
++      sock_server = accept (sock_listen, (struct sockaddr *)NULL, (socklen_t *)NULL);
++
++      echo_main (sock_server);
++    }
++
++  close (sock_listen);
++  return 0;
++}
++
+diff -r 4f91d96592e9 -r 8bc8c14ee22c example/sctp-server.cc~
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/example/sctp-server.cc~	Fri Oct 12 10:45:01 2012 +0900
+@@ -0,0 +1,78 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/socket.h>
++#include <sys/types.h>
++#include <arpa/inet.h>
++#include <netinet/in.h>
++#include <netinet/sctp.h>
++
++void
++echo_main (int sock)
++{
++  int stat;
++  char buffer[1024];
++
++  printf ("sock: %d\n", sock);
++
++  // Stream No.0
++  sprintf (buffer, "This is a test of stream 0");
++  stat = sctp_sendmsg (sock, buffer, (size_t)strlen (buffer),
++                       NULL, 0, 0, 0, 0, 0, 0);
++
++  // Stream No.1
++  sprintf (buffer, "This is a test of stream 1");
++  stat = sctp_sendmsg (sock, buffer, (size_t)strlen (buffer),
++                       NULL, 0, 0, 0, 1, 0, 0);
++}
++
++int
++main (int argc, char **argv)
++{
++  int sock_listen, sock_server, stat;
++  struct sockaddr_in server_addr;
++  struct sctp_initmsg s_initmsg;
++  int echo_port;
++
++  echo_port = 3007;
++
++  sock_listen = socket (AF_INET, SOCK_STREAM, IPPROTO_SCTP);
++
++  memset (&server_addr, 0, sizeof(server_addr));
++  server_addr.sin_family = AF_INET;
++  server_addr.sin_addr.s_addr = htonl (INADDR_ANY);
++  server_addr.sin_port = htons (echo_port);
++
++  // bind() ¤Ë¤è¤ë¥½¥±¥Ã¥È¤È¥¢¥É¥ì¥¹¤Î´Ø·¸¤Å¤±
++  stat = bind (sock_listen, (struct sockaddr *)&server_addr, sizeof(server_addr));
++
++  // SCTP ¤Î¥Ñ¥é¥á¡¼¥¿
++  memset (&s_initmsg, 0, sizeof(s_initmsg)); // ¹½Â¤ÂÎÊÑ¿ô¤Î¥¯¥ê¥¢
++  s_initmsg.sinit_num_ostreams = 5;  // Á÷¿®¥¹¥È¥ê¡¼¥à¿ô
++  s_initmsg.sinit_max_instreams = 5; // ¼õ¿®²Äǽ¥¹¥È¥ê¡¼¥à¿ô¤ÎºÇÂçÃÍ
++  s_initmsg.sinit_max_attempts = 5;  // INIT ºÆÁ÷¤ÎºÇÂç¿ô
++
++  // setsockopt() ¤Ë¤è¤ë¥Ñ¥é¥á¡¼¥¿¤ÎÀßÄê
++  stat = setsockopt (sock_listen, IPPROTO_SCTP, SCTP_INITMSG,
++                     &s_initmsg, sizeof(s_initmsg));
++  if (stat < 0)
++    {
++      my_exit ("Socket Option error");
++    }
++
++  // listen() ¤Ë¤è¤ëÀܳÍ×µáÂÔµ¡
++  listen (sock_listen, 5);
++  while (1)
++    {
++      printf ("SCTP server accepting\n");
++      // accept() ¤Ë¤è¤ëÀܳÍ×µá¤Î¼õÉÕ
++      sock_server = accept (sock_listen, (struct sockaddr *)NULL, (int *)NULL);
++
++      // ¥¯¥é¥¤¥¢¥ó¥È½èÍý¤ò¹Ô¤¦´Ø¿ô¤Î¸Æ¤Ó½Ð¤·
++      echo_main (sock_server);
++    }
++
++  close (sock_listen);
++  return 0;
++}
++
+diff -r 4f91d96592e9 -r 8bc8c14ee22c wscript
+--- a/wscript	Thu Oct 11 12:14:09 2012 +0900
++++ b/wscript	Fri Oct 12 10:45:01 2012 +0900
+@@ -232,6 +232,8 @@
+                     ['unix-client', []],
+                     ['udp-echo-server', []],
+                     ['udp-echo-client', []],
++                    ['sctp-server', ['sctp']],
++                    ['sctp-client', ['sctp']],
+ #                    ['little-cout', []],
+                     ]
+     for name,lib in dce_examples:
+@@ -316,6 +318,10 @@
+                        target='bin/dce-linux',
+                        source=['example/dce-linux.cc'])
+ 
++    module.add_example(needed = ['core', 'network', 'dce', 'point-to-point' ],
++                       target='bin/dce-sctp-simple',
++                       source=['example/dce-sctp-simple.cc'])
++
+ # Add a script to build system 
+ def build_a_script(bld, name, needed = [], **kw):
+     external = [i for i in needed if not i == name]
--- a/dce_test_improve.patch	Mon Aug 06 20:45:50 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-improve test-case to cover pthread/ucontext, dlm/cooja, with vdl/no-vdl
-
-diff -r 9c972df8a320 test/dce-manager-test.cc
---- a/test/dce-manager-test.cc	Mon Jul 09 17:35:31 2012 +0200
-+++ b/test/dce-manager-test.cc	Tue Jul 10 00:56:45 2012 +0900
-@@ -25,7 +25,8 @@
- class DceManagerTestCase : public TestCase
- {
- public:
--  DceManagerTestCase (std::string filename, Time maxDuration, std::string stdinFilename, bool useNet, bool useK);
-+  DceManagerTestCase (std::string filename, Time maxDuration, std::string stdinFilename, 
-+                      bool useNet, bool useK);
- private:
-   virtual void DoRun (void);
-   static void Finished (int *pstatus, uint16_t pid, int status);
-@@ -37,9 +38,16 @@
-   bool m_useNet;
- };
- 
--DceManagerTestCase::DceManagerTestCase (std::string filename, Time maxDuration, std::string stdin, bool useNet, bool useK)
--  : TestCase ("Check that process \"" + filename + "\" completes correctly."),
--    m_filename (filename), m_stdinFilename ( stdin), m_maxDuration ( maxDuration ), m_useKernel (useK), m_useNet (useNet)
-+DceManagerTestCase::DceManagerTestCase (std::string filename, Time maxDuration, 
-+                                        std::string stdin, bool useNet, bool useK)
-+  : TestCase ("Check that process \"" + filename +
-+              (useK ? " (kernel" : " (ns3)") + 
-+              "\" completes correctly."),
-+    m_filename (filename), 
-+    m_stdinFilename (stdin),
-+    m_maxDuration (maxDuration),
-+    m_useKernel (useK),
-+    m_useNet (useNet)
- {
- //  mtrace ();
- }
-@@ -83,7 +91,6 @@
-           apps = dce.Install (nodes.Get (0));
-           apps.Start (Seconds (3.0));
- 
--          //dceManager.SetTaskManagerAttribute( "FiberManagerType", StringValue ( "UcontextFiberManager" ) );
-         } else
-         {
-           dceManager.Install (nodes);
-@@ -164,7 +171,7 @@
-       {  "test-random", 0, "", false },
-       {  "test-local-socket", 0, "", false },
-       {  "test-poll", 3200, "", true },
--      //      {  "test-tcp-socket", 320, "", true },
-+      {  "test-tcp-socket", 320, "", true },
-       {  "test-exec", 0, "" , false},
-       /* {  "test-raw-socket", 320, "", true },*/
-       {  "test-iperf", 0, "" , false},
-@@ -193,7 +200,10 @@
- 
-   for (unsigned int i = 0; i < sizeof(tests)/sizeof(testPair); i++)
-     {
--      AddTestCase (new DceManagerTestCase (tests[i].name,  Seconds (tests[i].duration), tests[i].stdinfile, tests[i].useNet, useKernel () ) );
-+      AddTestCase (new DceManagerTestCase (tests[i].name,  Seconds (tests[i].duration), 
-+                                           tests[i].stdinfile, 
-+                                           tests[i].useNet, 
-+                                           useKernel ()));
-     }
- }
- 
-diff -r 9c972df8a320 utils/test.sh
---- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/utils/test.sh	Tue Jul 10 00:56:45 2012 +0900
-@@ -0,0 +1,20 @@
-+#!/bin/sh
-+
-+. ./utils/setenv.sh
-+#VERBOSE=""
-+
-+echo -n "Cooja (non-vdl) + Pthread:  "
-+NS_ATTRIBUTE_DEFAULT='ns3::TaskManager::FiberManagerType=PthreadFiberManager' ./build/bin/ns3test-dce $VERBOSE
-+echo -n "Cooja (non-vdl) + Ucontext: "
-+NS_ATTRIBUTE_DEFAULT='ns3::TaskManager::FiberManagerType=UcontextFiberManager' ./build/bin/ns3test-dce $VERBOSE
-+
-+echo -n "Cooja (vdl) + Pthread:      "
-+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::CoojaLoaderFactory[];ns3::TaskManager::FiberManagerType=PthreadFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
-+
-+echo -n "Cooja (vdl) + Ucontext:     "
-+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::CoojaLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
-+
-+echo -n "Dlm (vdl) + Pthread:        "
-+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=PthreadFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
-+echo -n "Dlm (vdl) + Ucontext:       "
-+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
-diff -r 9c972df8a320 wscript
---- a/wscript	Mon Jul 09 17:35:31 2012 +0200
-+++ b/wscript	Tue Jul 10 00:56:45 2012 +0900
-@@ -136,8 +136,12 @@
- def build_dce_tests(module, kern):
-     if kern:
-         module.add_runner_test(needed=['core', 'dce', 'internet'],  source=['test/dce-manager-test.cc', 'test/with-kernel.cc'])
-+        module.add_runner_test(needed=['core', 'dce', 'internet'],  source=['test/dce-manager-test.cc', 'test/with-kernel.cc'],
-+                               linkflags = ['-Wl,--dynamic-linker=' + os.path.abspath ('../build/lib/ldso')], name='vdl')
-     else:
-         module.add_runner_test(needed=['core', 'dce', 'internet'], source=['test/dce-manager-test.cc','test/without-kernel.cc'])
-+        module.add_runner_test(needed=['core', 'dce', 'internet'], source=['test/dce-manager-test.cc','test/without-kernel.cc'],
-+                               linkflags = ['-Wl,--dynamic-linker=' + os.path.abspath ('../build/lib/ldso')], name='vdl')
-     	    
-     module.add_test(features='cxx cxxshlib', source=['test/test-macros.cc'], 
-                     target='lib/test', linkflags=['-Wl,-soname=libtest.so'])
--- a/fedora8-nontimerfd.patch	Mon Aug 06 20:45:50 2012 +0900
+++ b/fedora8-nontimerfd.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -1,8 +1,8 @@
 support Fedora8, timerfd check in configure, macro improvements, fix the issue of scandir imcompatibility
 
-diff -r 4c90fdff71a0 model/dce-dirent.cc
---- a/model/dce-dirent.cc	Mon Jul 16 13:56:16 2012 +0200
-+++ b/model/dce-dirent.cc	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 model/dce-dirent.cc
+--- a/model/dce-dirent.cc	Thu Sep 20 10:12:35 2012 +0900
++++ b/model/dce-dirent.cc	Thu Sep 20 10:13:19 2012 +0900
 @@ -236,9 +236,16 @@
    rewinddir (dirp);
    ds->fd = saveFd;
@@ -20,9 +20,9 @@
  {
    NS_LOG_FUNCTION (Current () << UtilsGetNodeId () );
    NS_ASSERT (Current () != 0);
-diff -r 4c90fdff71a0 model/dce-dirent.h
---- a/model/dce-dirent.h	Mon Jul 16 13:56:16 2012 +0200
-+++ b/model/dce-dirent.h	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 model/dce-dirent.h
+--- a/model/dce-dirent.h	Thu Sep 20 10:12:35 2012 +0900
++++ b/model/dce-dirent.h	Thu Sep 20 10:13:19 2012 +0900
 @@ -35,9 +35,24 @@
  int dce_closedir (DIR *dirp);
  int dce_dirfd (DIR *dirp);
@@ -48,9 +48,9 @@
  
  #ifdef __cplusplus
  }
-diff -r 4c90fdff71a0 model/libc-dce.cc
---- a/model/libc-dce.cc	Mon Jul 16 13:56:16 2012 +0200
-+++ b/model/libc-dce.cc	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 model/libc-dce.cc
+--- a/model/libc-dce.cc	Thu Sep 20 10:12:35 2012 +0900
++++ b/model/libc-dce.cc	Thu Sep 20 10:13:19 2012 +0900
 @@ -12,7 +12,9 @@
  #include "sys/dce-mman.h"
  #include "sys/dce-stat.h"
@@ -61,7 +61,7 @@
  #include "dce-unistd.h"
  #include "dce-netdb.h"
  #include "dce-pthread.h"
-@@ -67,7 +69,9 @@
+@@ -68,7 +70,9 @@
  #include <sys/ioctl.h>
  #include <sys/io.h>
  #include <sys/mman.h>
@@ -71,7 +71,7 @@
  #include <sys/time.h>
  #include <sys/types.h>
  #include <sys/resource.h>
-@@ -142,6 +146,7 @@
+@@ -146,6 +150,7 @@
  #define DCE(name) (*libc)->name ## _fn = (func_t)(__typeof(&name))dce_ ## name;
  #define DCET(rtype,name) DCE(name)
  #define DCE_EXPLICIT(name,rtype,...) (*libc)->name ## _fn = dce_ ## name;
@@ -79,9 +79,9 @@
  
  #define NATIVE(name)							\
    (*libc)->name ## _fn = (func_t)name;
-diff -r 4c90fdff71a0 model/libc-ns3.h
---- a/model/libc-ns3.h	Mon Jul 16 13:56:16 2012 +0200
-+++ b/model/libc-ns3.h	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 model/libc-ns3.h
+--- a/model/libc-ns3.h	Thu Sep 20 10:12:35 2012 +0900
++++ b/model/libc-ns3.h	Thu Sep 20 10:13:19 2012 +0900
 @@ -108,7 +108,7 @@
  NATIVE (strerror_r)
  NATIVE (strcoll)
@@ -91,7 +91,7 @@
  NATIVE (bcopy)
  NATIVE (memcmp)
  NATIVE (memmove)
-@@ -426,11 +426,14 @@
+@@ -440,11 +440,14 @@
  // CTYPE.H
  NATIVE (toupper)
  NATIVE (tolower)
@@ -106,7 +106,7 @@
  
  // NET/IF.H
  DCE (if_nametoindex)
-@@ -541,6 +544,7 @@
+@@ -570,6 +573,7 @@
  #undef NATIVE_WITH_ALIAS
  #undef NATIVE_WITH_ALIAS2
  #undef NATIVE_EXPLICIT
@@ -114,9 +114,9 @@
  #undef DCE_WITH_ALIAS
  #undef DCE_WITH_ALIAS2
  
-diff -r 4c90fdff71a0 model/libc.cc
---- a/model/libc.cc	Mon Jul 16 13:56:16 2012 +0200
-+++ b/model/libc.cc	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 model/libc.cc
+--- a/model/libc.cc	Thu Sep 20 10:12:35 2012 +0900
++++ b/model/libc.cc	Thu Sep 20 10:13:19 2012 +0900
 @@ -79,6 +79,12 @@
  	GCC_BUILTIN_APPLY(internal,name)			\
  	weak_alias(internal, name);
@@ -130,9 +130,9 @@
  
  // Note: it looks like that the stdio.h header does
  // not define putc and getc as macros if you include
-diff -r 4c90fdff71a0 model/libc.h
---- a/model/libc.h	Mon Jul 16 13:56:16 2012 +0200
-+++ b/model/libc.h	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 model/libc.h
+--- a/model/libc.h	Thu Sep 20 10:12:35 2012 +0900
++++ b/model/libc.h	Thu Sep 20 10:13:19 2012 +0900
 @@ -13,6 +13,7 @@
  #define DCET(rtype, name) DCE(name)
  
@@ -140,11 +140,11 @@
 +#define NATIVE_EXPLICIT2(name,rtype,...) rtype (*name ## _fn)(__VA_ARGS__);
  #include "libc-ns3.h"
  
- };
-diff -r 4c90fdff71a0 test/dce-manager-test.cc
---- a/test/dce-manager-test.cc	Mon Jul 16 13:56:16 2012 +0200
-+++ b/test/dce-manager-test.cc	Wed Jul 18 14:28:29 2012 +0900
-@@ -156,7 +156,9 @@
+   char* (*strpbrk_fn) (const char *s, const char *accept);
+diff -r ce273c5b2ef9 test/dce-manager-test.cc
+--- a/test/dce-manager-test.cc	Thu Sep 20 10:12:35 2012 +0900
++++ b/test/dce-manager-test.cc	Thu Sep 20 10:13:19 2012 +0900
+@@ -163,7 +163,9 @@
        {  "test-netdb", 3600, "", true },
        {  "test-env", 0, "", false }, 
        {  "test-cond", 0, "", false}, 
@@ -154,9 +154,9 @@
        {  "test-stdlib", 0, "", false},
        {  "test-fork", 0, "", false },
        {  "test-select", 3600, "", true },
-diff -r 4c90fdff71a0 test/test-poll.cc
---- a/test/test-poll.cc	Mon Jul 16 13:56:16 2012 +0200
-+++ b/test/test-poll.cc	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 test/test-poll.cc
+--- a/test/test-poll.cc	Thu Sep 20 10:12:35 2012 +0900
++++ b/test/test-poll.cc	Thu Sep 20 10:13:19 2012 +0900
 @@ -1,7 +1,6 @@
  #include <stdlib.h>
  #include <sys/time.h>
@@ -165,9 +165,9 @@
  #include <unistd.h>
  #include <pthread.h>
  #include <stdio.h>
-diff -r 4c90fdff71a0 test/test-select.cc
---- a/test/test-select.cc	Mon Jul 16 13:56:16 2012 +0200
-+++ b/test/test-select.cc	Wed Jul 18 14:28:29 2012 +0900
+diff -r ce273c5b2ef9 test/test-select.cc
+--- a/test/test-select.cc	Thu Sep 20 10:12:35 2012 +0900
++++ b/test/test-select.cc	Thu Sep 20 10:13:19 2012 +0900
 @@ -2,7 +2,9 @@
  #include <sys/time.h>
  #include <sys/types.h>
@@ -225,18 +225,18 @@
        launch (client1, server1);
        launch (client2, server2);
        launch (client3, server3);
-diff -r 4c90fdff71a0 wscript
---- a/wscript	Mon Jul 16 13:56:16 2012 +0200
-+++ b/wscript	Wed Jul 18 14:28:29 2012 +0900
-@@ -37,6 +37,7 @@
+diff -r ce273c5b2ef9 wscript
+--- a/wscript	Thu Sep 20 10:12:35 2012 +0900
++++ b/wscript	Thu Sep 20 10:13:19 2012 +0900
+@@ -46,6 +46,7 @@
      conf.check(header_name='sys/types.h', define_name='HAVE_SYS_TYPES_H', mandatory=False)
      conf.check(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H', mandatory=False)
      conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H', mandatory=False)
 +    conf.check(header_name='sys/timerfd.h', define_name='HAVE_SYS_TIMER_H', mandatory=False)
  
-     conf.env.prepend_value('LINKFLAGS', '-Wl,--no-as-needed')
-     conf.env.append_value('LINKFLAGS', '-pthread')
-@@ -91,7 +92,9 @@
+     if Options.options.enable_mpi:
+          conf.env.append_value ('DEFINES', 'DCE_MPI=1')
+@@ -104,7 +105,9 @@
  
      if Options.options.kernel_stack is not None and os.path.isdir(Options.options.kernel_stack):
          conf.check(header_name='sim.h',
@@ -247,7 +247,7 @@
        #  conf.check()
          conf.env['KERNEL_STACK'] = Options.options.kernel_stack
  
-@@ -172,7 +175,6 @@
+@@ -189,7 +192,6 @@
               ['test-netdb', []],
               ['test-env', []],
               ['test-cond', ['PTHREAD']],
@@ -255,7 +255,7 @@
               ['test-stdlib', []],
               ['test-select', ['PTHREAD']],
               ['test-random', []],
-@@ -194,6 +196,10 @@
+@@ -211,6 +213,10 @@
               ['test-tsearch', []],
               ['test-signal', []],
               ]
@@ -266,7 +266,7 @@
      for name,uselib in tests:
          module.add_test(**dce_kw(target='bin_dce/' + name, source = ['test/' + name + '.cc'],
                                   use = uselib + ['lib/test']))
-@@ -201,7 +207,6 @@
+@@ -218,7 +224,6 @@
  def build_dce_examples(module):
      dce_examples = [['udp-server', []],
                      ['udp-client', []],
@@ -274,7 +274,7 @@
                      ['tcp-server', []],
                      ['tcp-client', []],
                      ['tcp-loopback', []],
-@@ -211,6 +216,9 @@
+@@ -228,6 +233,9 @@
                      ['udp-echo-client', []],
  #                    ['little-cout', []],
                      ]
@@ -284,7 +284,7 @@
      for name,lib in dce_examples:
          module.add_example(**dce_kw(target = 'bin_dce/' + name, 
                                      source = ['example/' + name + '.cc'],
-@@ -359,7 +367,6 @@
+@@ -376,7 +384,6 @@
          'model/dce-string.cc',
          'model/dce-env.cc',
          'model/dce-pthread-cond.cc',
@@ -292,7 +292,7 @@
          'model/dce-time.cc',
          'model/dce-stat.cc',
          'model/dce-syslog.cc',
-@@ -424,6 +431,10 @@
+@@ -443,6 +450,10 @@
          'helper/linux-stack-helper.h',
          'helper/ipv4-dce-routing-helper.h',
          ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-stack-rework.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,1054 @@
+diff -r b4f69e2ed0b3 example/simple-point-to-point-olsr.cc
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/example/simple-point-to-point-olsr.cc	Thu Dec 13 12:27:12 2012 +0900
+@@ -0,0 +1,180 @@
++/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
++/*
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation;
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++ *
++ */
++
++//
++// Simple example of OLSR routing over some point-to-point links
++//
++// Network topology
++//
++//   n0
++//     \ 5 Mb/s, 2ms
++//      \          1.5Mb/s, 10ms
++//       n2 -------------------------n3---------n4
++//      /
++//     / 5 Mb/s, 2ms
++//   n1
++//
++// - all links are point-to-point links with indicated one-way BW/delay
++// - CBR/UDP flows from n0 to n4, and from n3 to n1
++// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
++//   (i.e., DataRate of 448,000 bps)
++// - DropTail queues 
++// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr"
++
++#include <iostream>
++#include <fstream>
++#include <string>
++#include <cassert>
++
++#include "ns3/core-module.h"
++#include "ns3/network-module.h"
++#include "ns3/internet-module.h"
++#include "ns3/point-to-point-module.h"
++#include "ns3/applications-module.h"
++#include "ns3/olsr-helper.h"
++#include "ns3/ipv4-static-routing-helper.h"
++#include "ns3/ipv4-list-routing-helper.h"
++#include "ns3/dce-module.h"
++
++using namespace ns3;
++
++NS_LOG_COMPONENT_DEFINE ("SimplePointToPointOlsrExample");
++
++int 
++main (int argc, char *argv[])
++{
++  // Users may find it convenient to turn on explicit debugging
++  // for selected modules; the below lines suggest how to do this
++#if 0 
++  LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
++#endif
++
++  // Set up some default values for the simulation.  Use the 
++
++  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
++  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
++
++  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);
++
++  // Allow the user to override any of the defaults and the above
++  // DefaultValue::Bind ()s at run-time, via command-line arguments
++  CommandLine cmd;
++  cmd.Parse (argc, argv);
++
++  // Here, we will explicitly create four nodes.  In more sophisticated
++  // topologies, we could configure a node factory.
++  NS_LOG_INFO ("Create nodes.");
++  NodeContainer c;
++  c.Create (5);
++  NodeContainer n02 = NodeContainer (c.Get (0), c.Get (2));
++  NodeContainer n12 = NodeContainer (c.Get (1), c.Get (2));
++  NodeContainer n32 = NodeContainer (c.Get (3), c.Get (2));
++  NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4));
++
++  // Enable OLSR
++  NS_LOG_INFO ("Enabling OLSR Routing.");
++  OlsrHelper olsr;
++
++  Ipv4StaticRoutingHelper staticRouting;
++
++  Ipv4ListRoutingHelper list;
++  list.Add (staticRouting, 0);
++  list.Add (olsr, 10);
++
++  DceManagerHelper dceManager;
++  dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
++                             "Library", StringValue ("liblinux.so"));
++  LinuxStackHelper internet;
++  internet.SetRoutingHelper (list); // has effect on the next Install ()
++  internet.Install (c);
++
++  // We create the channels first without any IP addressing information
++  NS_LOG_INFO ("Create channels.");
++  PointToPointHelper p2p;
++  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
++  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
++  NetDeviceContainer nd02 = p2p.Install (n02);
++  NetDeviceContainer nd12 = p2p.Install (n12);
++  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
++  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
++  NetDeviceContainer nd32 = p2p.Install (n32);
++  NetDeviceContainer nd34 = p2p.Install (n34);
++
++  // Later, we add IP addresses.
++  NS_LOG_INFO ("Assign IP Addresses.");
++  Ipv4AddressHelper ipv4;
++  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
++  Ipv4InterfaceContainer i02 = ipv4.Assign (nd02);
++
++  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
++  Ipv4InterfaceContainer i12 = ipv4.Assign (nd12);
++
++  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
++  Ipv4InterfaceContainer i32 = ipv4.Assign (nd32);
++
++  ipv4.SetBase ("10.1.4.0", "255.255.255.0");
++  Ipv4InterfaceContainer i34 = ipv4.Assign (nd34);
++
++  dceManager.Install (c);
++
++  // Create the OnOff application to send UDP datagrams of size
++  // 210 bytes at a rate of 448 Kb/s from n0 to n4
++  NS_LOG_INFO ("Create Applications.");
++  uint16_t port = 9;   // Discard port (RFC 863)
++
++  OnOffHelper onoff ("ns3::LinuxUdpSocketFactory", 
++                     InetSocketAddress (i34.GetAddress (1), port));
++  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
++  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
++
++  ApplicationContainer apps = onoff.Install (c.Get (0));
++  apps.Start (Seconds (1.0));
++  apps.Stop (Seconds (10.0));
++
++  // Create a packet sink to receive these packets
++  PacketSinkHelper sink ("ns3::LinuxUdpSocketFactory",
++                         InetSocketAddress (Ipv4Address::GetAny (), port));
++
++  apps = sink.Install (c.Get (3));
++  apps.Start (Seconds (1.0));
++  apps.Stop (Seconds (10.0));
++
++  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
++  onoff.SetAttribute ("Remote",
++                      AddressValue (InetSocketAddress (i12.GetAddress (0), port)));
++  apps = onoff.Install (c.Get (3));
++  apps.Start (Seconds (1.1));
++  apps.Stop (Seconds (10.0));
++
++  // Create a packet sink to receive these packets
++  apps = sink.Install (c.Get (1));
++  apps.Start (Seconds (1.1));
++  apps.Stop (Seconds (10.0));
++
++  AsciiTraceHelper ascii;
++  p2p.EnableAsciiAll (ascii.CreateFileStream ("simple-point-to-point-olsr.tr"));
++  p2p.EnablePcapAll ("simple-point-to-point-olsr");
++
++  Simulator::Stop (Seconds (30));
++
++  NS_LOG_INFO ("Run Simulation.");
++  Simulator::Run ();
++  Simulator::Destroy ();
++  NS_LOG_INFO ("Done.");
++
++  return 0;
++}
+diff -r b4f69e2ed0b3 helper/linux-stack-helper.cc
+--- a/helper/linux-stack-helper.cc	Thu Dec 13 12:07:18 2012 +0900
++++ b/helper/linux-stack-helper.cc	Thu Dec 13 12:27:12 2012 +0900
+@@ -19,16 +19,56 @@
+  */
+ #include "linux-stack-helper.h"
+ #include "ipv4-linux.h"
++#include "ipv6-linux.h"
+ #include "linux-socket-fd-factory.h"
+ #include "ns3/node.h"
+ #include "ns3/node-container.h"
+ #include "ns3/names.h"
++#include "ns3/ipv4-list-routing-helper.h"
++#include "ns3/ipv4-static-routing-helper.h"
++#include "ns3/ipv4-global-routing-helper.h"
+ 
+ namespace ns3 {
++LinuxStackHelper::LinuxStackHelper ()
++  : m_routing (0)
++{
++  Initialize ();
++}
++
++// private method called by both constructor and Reset ()
++void
++LinuxStackHelper::Initialize ()
++{
++  Ipv4StaticRoutingHelper staticRouting;
++  Ipv4GlobalRoutingHelper globalRouting;
++  Ipv4ListRoutingHelper listRouting;
++  listRouting.Add (staticRouting, 0);
++  listRouting.Add (globalRouting, -10);
++  SetRoutingHelper (listRouting);
++}
++
++LinuxStackHelper::~LinuxStackHelper ()
++{
++  delete m_routing;
++}
++
++void 
++LinuxStackHelper::SetRoutingHelper (const Ipv4RoutingHelper &routing)
++{
++  delete m_routing;
++  m_routing = routing.Copy ();
++}
++
+ void
+ LinuxStackHelper::Install (Ptr<Node> node)
+ {
+   Ipv4Linux::InstallNode (node);
++  // Set routing
++  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
++  Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
++  ipv4->SetRoutingProtocol (ipv4Routing);
++
++  Ipv6Linux::InstallNode (node);
+ }
+ void
+ LinuxStackHelper::Install (std::string nodeName)
+@@ -94,7 +134,11 @@
+         {
+           continue;
+         }
+-      sock->Set (path, value);      
++      // i.e., TaskManager::Current() needs it.
++      Simulator::ScheduleWithContext (node->GetId (), Seconds (0.0),
++                                      &LinuxSocketFdFactory::ScheduleTask, sock,
++                                      MakeEvent (&LinuxSocketFdFactory::Set, sock,
++                                                 path, value));
+     }
+ }
+ 
+diff -r b4f69e2ed0b3 helper/linux-stack-helper.h
+--- a/helper/linux-stack-helper.h	Thu Dec 13 12:07:18 2012 +0900
++++ b/helper/linux-stack-helper.h	Thu Dec 13 12:27:12 2012 +0900
+@@ -27,6 +27,7 @@
+ class Node;
+ class NodeContainer;
+ class Time;
++class Ipv4RoutingHelper;
+ 
+ /**
+  * \brief aggregate Ipv4Linux to nodes
+@@ -40,6 +41,10 @@
+ class LinuxStackHelper
+ {
+ public:
++
++  LinuxStackHelper ();
++  ~LinuxStackHelper ();
++
+   /**
+    * Aggregate ns3::Ipv4Linux classe onto the provided node.
+    * This method will assert if called on a node that
+@@ -47,7 +52,7 @@
+    *
+    * \param nodeName The name of the node on which to install the stack.
+    */
+-  static void Install (std::string nodeName);
++  void Install (std::string nodeName);
+ 
+   /**
+    * Aggregate ns3::Ipv4Linux classe onto the provided node.
+@@ -56,7 +61,7 @@
+    *
+    * \param node The node on which to install the stack.
+    */
+-  static void Install (Ptr<Node> node);
++  void Install (Ptr<Node> node);
+ 
+   /**
+    * Aggregate ns3::Ipv4Linux class onto the provided node.
+@@ -66,17 +71,30 @@
+    * \param c NodeContainer that holds the set of nodes on which to install the
+    * new stacks.
+    */
+-  static void Install (NodeContainer c);
++  void Install (NodeContainer c);
+ 
+   /**
+    * Aggregate ns3::Ipv4Linux to all nodes in the simulation
+    */
+-  static void InstallAll (void);
++  void InstallAll (void);
++
++  /**
++   * \param routing a new routing helper
++   *
++   * Set the routing helper to use during Install. The routing
++   * helper is really an object factory which is used to create 
++   * an object of type ns3::Ipv4RoutingProtocol per node. This routing
++   * object is then associated to a single ns3::Ipv4 object through its 
++   * ns3::Ipv4::SetRoutingProtocol.
++   */
++  void SetRoutingHelper (const Ipv4RoutingHelper &routing);
+ 
+   void SysctlSet (NodeContainer c, std::string path, std::string value);
+   static void SysctlGet (Ptr<Node> node, Time at, std::string path, 
+                          void (*callback)(std::string, std::string));
+ private:
++  void Initialize ();
++  const Ipv4RoutingHelper *m_routing;
+   static void SysctlGetCallback (Ptr<Node> node, std::string path, 
+                                  void (*callback)(std::string, std::string));
+   
+diff -r b4f69e2ed0b3 model/linux/ipv6-linux.cc
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/model/linux/ipv6-linux.cc	Thu Dec 13 12:27:12 2012 +0900
+@@ -0,0 +1,397 @@
++/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
++/*
++ * Copyright (c) 2012 INRIA
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation;
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++ *
++ * Author: Frédéric Urbani
++ *         Hajime Tazaki <tazaki@nict.go.jp>
++ */
++
++#include "ipv6-linux.h"
++#include "ns3/log.h"
++#include "ns3/node.h"
++#include "ns3/ipv6-list-routing-helper.h"
++#include "ns3/ipv6-static-routing-helper.h"
++//#include "ns3/ipv6-global-routing-helper.h"
++#include "ns3/ipv6-interface.h"
++//#include "linux-dccp6-socket-factory-impl.h"
++
++NS_LOG_COMPONENT_DEFINE ("Ipv6Linux");
++
++namespace ns3 {
++
++NS_OBJECT_ENSURE_REGISTERED (Ipv6Linux);
++
++TypeId
++Ipv6Linux::GetTypeId (void)
++{
++  static TypeId tid = TypeId ("ns3::Ipv6Linux")
++    .SetParent<Ipv6> ()
++    .AddConstructor<Ipv6Linux> ();
++
++  return tid;
++}
++
++Ipv6Linux::Ipv6Linux()
++{
++  NS_LOG_FUNCTION (this);
++}
++
++Ipv6Linux::~Ipv6Linux ()
++{
++  NS_LOG_FUNCTION (this);
++}
++
++void
++Ipv6Linux::SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol)
++{
++  NS_LOG_FUNCTION (this);
++  m_routingProtocol = routingProtocol;
++  m_routingProtocol->SetIpv6 (this);
++}
++
++Ptr<Ipv6RoutingProtocol>
++Ipv6Linux::GetRoutingProtocol (void) const
++{
++  NS_LOG_FUNCTION (this);
++  return m_routingProtocol;
++}
++
++uint32_t
++Ipv6Linux::AddInterface (Ptr<NetDevice> device)
++{
++  NS_LOG_FUNCTION (this << &device);
++
++  Ptr<Ipv6Interface> interface = CreateObject<Ipv6Interface> ();
++  interface->SetDevice (device);
++  interface->SetForwarding (m_ipForward);
++  return AddIpv6Interface (interface);
++}
++uint32_t
++Ipv6Linux::AddIpv6Interface (Ptr<Ipv6Interface>interface)
++{
++  NS_LOG_FUNCTION (this << interface);
++  uint32_t index = m_interfaces.size ();
++  m_interfaces.push_back (interface);
++  return index;
++}
++
++uint32_t
++Ipv6Linux::GetNInterfaces (void) const
++{
++  NS_LOG_FUNCTION (this);
++  return m_interfaces.size ();
++}
++
++int32_t
++Ipv6Linux::GetInterfaceForAddress (Ipv6Address address) const
++{
++  NS_LOG_FUNCTION (this);
++
++  int32_t interface = 0;
++  for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin ();
++       i != m_interfaces.end ();
++       i++, interface++)
++    {
++      for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
++        {
++          if ((*i)->GetAddress (j).GetAddress () == address)
++            {
++              return interface;
++            }
++        }
++    }
++
++  return -1;
++}
++
++void
++Ipv6Linux::Send (Ptr<Packet> packet, Ipv6Address source,
++                   Ipv6Address destination, uint8_t protocol, Ptr<Ipv6Route> route)
++{
++  NS_LOG_FUNCTION (this << "empty method.");
++}
++
++void
++Ipv6Linux::SendWithHeader (Ptr<Packet> packet, Ipv6Header ipHeader, Ptr<Ipv6Route> route)
++{
++  NS_LOG_FUNCTION (this << "empty method.");
++}
++
++#if 0
++void
++Ipv6Linux::Insert (Ptr<IpL4Protocol> protocol)
++{
++  NS_LOG_FUNCTION (this << "empty method.");
++}
++#endif
++
++
++int32_t
++Ipv6Linux::GetInterfaceForPrefix (Ipv6Address address, Ipv6Prefix mask) const
++{
++  NS_LOG_FUNCTION (this);
++  int32_t interface = 0;
++  for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin ();
++       i != m_interfaces.end ();
++       i++, interface++)
++    {
++      for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
++        {
++          if ((*i)->GetAddress (j).GetAddress ().CombinePrefix (mask) == address.CombinePrefix (mask))
++            {
++              return interface;
++            }
++        }
++    }
++
++  return -1;
++}
++
++Ptr<NetDevice>
++Ipv6Linux::GetNetDevice (uint32_t i)
++{
++  NS_LOG_FUNCTION (this);
++  return GetInterface (i)->GetDevice ();
++}
++
++int32_t
++Ipv6Linux::GetInterfaceForDevice (Ptr<const NetDevice> device) const
++{
++  NS_LOG_FUNCTION (this);
++  int32_t interface = 0;
++  for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin ();
++       i != m_interfaces.end ();
++       i++, interface++)
++    {
++      if ((*i)->GetDevice () == device)
++        {
++          return interface;
++        }
++    }
++
++  return -1;
++}
++
++bool
++Ipv6Linux::AddAddress (uint32_t i, Ipv6InterfaceAddress address)
++{
++  NS_LOG_FUNCTION (this << i << address);
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  bool retVal = interface->AddAddress (address);
++  if (m_routingProtocol != 0)
++    {
++      m_routingProtocol->NotifyAddAddress (i, address);
++    }
++  return retVal;
++}
++
++uint32_t
++Ipv6Linux::GetNAddresses (uint32_t interface) const
++{
++  Ptr<Ipv6Interface> iface = GetInterface (interface);
++  return iface->GetNAddresses ();
++}
++
++Ipv6InterfaceAddress
++Ipv6Linux::GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const
++{
++  NS_LOG_FUNCTION (this);
++  Ptr<Ipv6Interface> interface = GetInterface (interfaceIndex);
++  return interface->GetAddress (addressIndex);
++}
++
++bool
++Ipv6Linux::RemoveAddress (uint32_t i, uint32_t addressIndex)
++{
++  NS_LOG_FUNCTION (this << i << addressIndex);
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  Ipv6InterfaceAddress address = interface->RemoveAddress (addressIndex);
++  if (address != Ipv6InterfaceAddress ())
++    {
++      if (m_routingProtocol != 0)
++        {
++          m_routingProtocol->NotifyRemoveAddress (i, address);
++        }
++      return true;
++    }
++  return false;
++}
++
++void
++Ipv6Linux::SetMetric (uint32_t i, uint16_t metric)
++{
++  NS_LOG_FUNCTION (this << i << metric);
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  interface->SetMetric (metric);
++}
++
++uint16_t
++Ipv6Linux::GetMetric (uint32_t i) const
++{
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  return interface->GetMetric ();
++}
++
++uint16_t
++Ipv6Linux::GetMtu (uint32_t i) const
++{
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  return interface->GetDevice ()->GetMtu ();
++}
++
++bool
++Ipv6Linux::IsUp (uint32_t i) const
++{
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  return interface->IsUp ();
++}
++
++void
++Ipv6Linux::SetUp (uint32_t i)
++{
++  NS_LOG_FUNCTION (this << i);
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  interface->SetUp ();
++
++  if (m_routingProtocol != 0)
++    {
++      m_routingProtocol->NotifyInterfaceUp (i);
++    }
++}
++
++void
++Ipv6Linux::SetDown (uint32_t ifaceIndex)
++{
++  NS_LOG_FUNCTION (this << ifaceIndex);
++  Ptr<Ipv6Interface> interface = GetInterface (ifaceIndex);
++  interface->SetDown ();
++
++  if (m_routingProtocol != 0)
++    {
++      m_routingProtocol->NotifyInterfaceDown (ifaceIndex);
++    }
++}
++
++bool
++Ipv6Linux::IsForwarding (uint32_t i) const
++{
++  NS_LOG_FUNCTION (this << i);
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  NS_LOG_LOGIC ("Forwarding state: " << interface->IsForwarding ());
++  return interface->IsForwarding ();
++}
++
++void
++Ipv6Linux::SetForwarding (uint32_t i, bool val)
++{
++  NS_LOG_FUNCTION (this << i);
++  Ptr<Ipv6Interface> interface = GetInterface (i);
++  interface->SetForwarding (val);
++}
++
++void
++Ipv6Linux::SetIpForward (bool forward)
++{
++  NS_LOG_FUNCTION (this << forward);
++  m_ipForward = forward;
++  for (Ipv6InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
++    {
++      (*i)->SetForwarding (forward);
++    }
++}
++
++bool
++Ipv6Linux::GetIpForward (void) const
++{
++  return m_ipForward;
++}
++
++void
++Ipv6Linux::SetWeakEsModel (bool model)
++{
++  m_weakEsModel = model;
++}
++
++bool
++Ipv6Linux::GetWeakEsModel (void) const
++{
++  return m_weakEsModel;
++}
++
++void
++Ipv6Linux::InstallNode (Ptr<Node> node)
++{
++  ObjectFactory factory;
++  factory.SetTypeId ("ns3::Ipv6Linux");
++  Ptr<Object> protocol = factory.Create <Object> ();
++  node->AggregateObject (protocol);
++  // Set routing
++  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
++  Ipv6ListRoutingHelper listRoutingv6;
++  Ipv6StaticRoutingHelper staticRoutingv6;
++  listRoutingv6.Add (staticRoutingv6, 0);
++  Ptr<Ipv6RoutingProtocol> ipv6Routing = listRoutingv6.Create (node);
++  ipv6->SetRoutingProtocol (ipv6Routing);
++  // Socket related stuff
++  // Ptr<LinuxDccp6SocketFactoryImpl> dccpFactory = CreateObject<LinuxDccp6SocketFactoryImpl> ();
++  // node->AggregateObject (dccpFactory);
++}
++Ptr<Ipv6Interface>
++Ipv6Linux::GetInterface (uint32_t index) const
++{
++  if (index < m_interfaces.size ())
++    {
++      return m_interfaces[index];
++    }
++  return 0;
++}
++
++#if 0
++Ptr<IpL4Protocol>
++Ipv6Linux::GetProtocol (int protocolNumber) const
++{
++  return 0;
++}
++#endif
++
++Ptr<Socket>
++Ipv6Linux::CreateRawSocket (void)
++{
++  return 0;
++}
++
++/**
++ * Do nothing
++ */
++void
++Ipv6Linux::DeleteRawSocket (Ptr<Socket> socket)
++{
++
++}
++
++void
++Ipv6Linux::RegisterExtensions ()
++{
++  NS_ASSERT (0);
++}
++
++void 
++Ipv6Linux::RegisterOptions ()
++{
++  NS_ASSERT (0);
++}
++
++}
+diff -r b4f69e2ed0b3 model/linux/ipv6-linux.h
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/model/linux/ipv6-linux.h	Thu Dec 13 12:27:12 2012 +0900
+@@ -0,0 +1,280 @@
++/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
++/*
++ * Copyright (c) 2012 INRIA
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation;
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++ *
++ * Author: Frédéric Urbani
++ */
++
++#ifndef IPV6_LINUX_H
++#define IPV6_LINUX_H
++
++#include "ns3/ipv6.h"
++#include "ns3/ipv6-routing-protocol.h"
++
++namespace ns3 {
++class Ipv6Interface;
++
++/**
++ * \brief This implementation of Ipv6 for nodes using a real Linux Stack.
++ *
++ * The main goal of this class is not to do the stack job which is done by the real code ....
++ * but it is used to not redo the wheel and in particular to be able to reuse these 2 standards NS-3 Helpers for two tasks:
++ *   1 - assign address to devices using Ipv6AddressHelper,
++ *   2 - create the static routes using Ipv6GlobalRoutingHelper
++ *
++ */
++class Ipv6Linux : public Ipv6
++{
++public:
++  static TypeId GetTypeId (void);
++  Ipv6Linux ();
++  virtual ~Ipv6Linux ();
++
++  /**
++   * \brief Register a new routing protocol to be used by this Ipv6 stack
++   *
++   * This call will replace any routing protocol that has been previously
++   * registered.  If you want to add multiple routing protocols, you must
++   * add them to a Ipv6ListRoutingProtocol directly.
++   *
++   * \param routingProtocol smart pointer to Ipv6RoutingProtocol object
++   */
++  virtual void SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol);
++
++  /**
++   * \brief Get the routing protocol to be used by this Ipv6 stack
++   *
++   * \returns smart pointer to Ipv6RoutingProtocol object, or null pointer if none
++   */
++  virtual Ptr<Ipv6RoutingProtocol> GetRoutingProtocol (void) const;
++
++  /**
++   * \param device device to add to the list of Ipv6 interfaces
++   *        which can be used as output interfaces during packet forwarding.
++   * \returns the index of the Ipv6 interface added.
++   *
++   * Once a device has been added, it can never be removed: if you want
++   * to disable it, you can invoke Ipv6::SetDown which will
++   * make sure that it is never used during packet forwarding.
++   */
++  virtual uint32_t AddInterface (Ptr<NetDevice> device);
++
++  /**
++   * \returns the number of interfaces added by the user.
++   */
++  virtual uint32_t GetNInterfaces (void) const;
++
++  /**
++   * \brief Return the interface number of the interface that has been
++   *        assigned the specified IP address.
++   *
++   * \param address The IP address being searched for
++   * \returns The interface number of the Ipv6 interface with the given
++   *          address or -1 if not found.
++   *
++   * Each IP interface has one or more IP addresses associated with it.
++   * This method searches the list of interfaces for one that holds a
++   * particular address.  This call takes an IP address as a parameter and
++   * returns the interface number of the first interface that has been assigned
++   * that address, or -1 if not found.  There must be an exact match; this
++   * method will not match broadcast or multicast addresses.
++   */
++  virtual int32_t GetInterfaceForAddress (Ipv6Address address) const;
++
++  /**
++   * Do nothing
++   */
++  virtual void Send (Ptr<Packet> packet, Ipv6Address source,
++                     Ipv6Address destination, uint8_t protocol, Ptr<Ipv6Route> route);
++
++  /**
++   * Do nothing
++   */
++  virtual void SendWithHeader (Ptr<Packet> packet, Ipv6Header ipHeader, Ptr<Ipv6Route> route);
++
++  /**
++   * Do nothing
++   */
++  //  virtual void Insert (Ptr<IpL4Protocol> protocol);
++
++  /**
++   * \brief Return the interface number of first interface found that
++   *  has an Ipv6 address within the prefix specified by the input
++   *  address and mask parameters
++   *
++   * \param address The IP address assigned to the interface of interest.
++   * \param mask The IP prefix to use in the mask
++   * \returns The interface number of the Ipv6 interface with the given
++   *          address or -1 if not found.
++   *
++   * Each IP interface has one or more IP addresses associated with it.
++   * This method searches the list of interfaces for the first one found
++   * that holds an address that is included within the prefix
++   * formed by the input address and mask parameters.  The value -1 is
++   * returned if no match is found.
++   */
++  virtual int32_t GetInterfaceForPrefix (Ipv6Address address,
++                                         Ipv6Prefix mask) const;
++
++  /**
++   * \param interface The interface number of an Ipv6 interface.
++   * \returns The NetDevice associated with the Ipv6 interface number.
++   */
++  virtual Ptr<NetDevice> GetNetDevice (uint32_t interface);
++
++  /**
++   * \param device The NetDevice for an Ipv6Interface
++   * \returns The interface number of an Ipv6 interface or -1 if not found.
++   */
++  virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
++
++  /**
++   * \param interface Interface number of an Ipv6 interface
++   * \param address Ipv6InterfaceAddress address to associate with the underlying Ipv6 interface
++   * \returns true if the operation succeeded
++   */
++  virtual bool AddAddress (uint32_t interface, Ipv6InterfaceAddress address);
++
++  /**
++   * \param interface Interface number of an Ipv6 interface
++   * \returns the number of Ipv6InterfaceAddress entries for the interface.
++   */
++  virtual uint32_t GetNAddresses (uint32_t interface) const;
++
++  /**
++   * Because addresses can be removed, the addressIndex is not guaranteed
++   * to be static across calls to this method.
++   *
++   * \param interface Interface number of an Ipv6 interface
++   * \param addressIndex index of Ipv6InterfaceAddress
++   * \returns the Ipv6InterfaceAddress associated to the interface and addressIndex
++   */
++  virtual Ipv6InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const;
++
++  /**
++   * Remove the address at addressIndex on named interface.  The addressIndex
++   * for all higher indices will decrement by one after this method is called;
++   * so, for example, to remove 5 addresses from an interface i, one could
++   * call RemoveAddress (i, 0); 5 times.
++   *
++   * \param interface Interface number of an Ipv6 interface
++   * \param addressIndex index of Ipv6InterfaceAddress to remove
++   * \returns true if the operation succeeded
++   */
++  virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex);
++
++  /**
++   * \param interface The interface number of an Ipv6 interface
++   * \param metric routing metric (cost) associated to the underlying
++   *          Ipv6 interface
++   */
++  virtual void SetMetric (uint32_t interface, uint16_t metric);
++
++  /**
++   * \param interface The interface number of an Ipv6 interface
++   * \returns routing metric (cost) associated to the underlying
++   *          Ipv6 interface
++   */
++  virtual uint16_t GetMetric (uint32_t interface) const;
++
++  /**
++   * \param interface Interface number of Ipv6 interface
++   * \returns the Maximum Transmission Unit (in bytes) associated
++   *          to the underlying Ipv6 interface
++   */
++  virtual uint16_t GetMtu (uint32_t interface) const;
++
++  /**
++   * \param interface Interface number of Ipv6 interface
++   * \returns true if the underlying interface is in the "up" state,
++   *          false otherwise.
++   */
++  virtual bool IsUp (uint32_t interface) const;
++
++  /**
++   * \param interface Interface number of Ipv6 interface
++   *
++   * Set the interface into the "up" state. In this state, it is
++   * considered valid during Ipv6 forwarding.
++   */
++  virtual void SetUp (uint32_t interface);
++
++  /**
++   * \param interface Interface number of Ipv6 interface
++   *
++   * Set the interface into the "down" state. In this state, it is
++   * ignored during Ipv6 forwarding.
++   */
++  virtual void SetDown (uint32_t interface);
++
++  /**
++   * \param interface Interface number of Ipv6 interface
++   * \returns true if IP forwarding enabled for input datagrams on this device
++   */
++  virtual bool IsForwarding (uint32_t interface) const;
++
++  /**
++   * \param interface Interface number of Ipv6 interface
++   * \param val Value to set the forwarding flag
++   *
++   * If set to true, IP forwarding is enabled for input datagrams on this device
++   */
++  virtual void SetForwarding (uint32_t interface, bool val);
++
++  /**
++   * Do nothing
++   */
++  //  virtual Ptr<IpL4Protocol> GetProtocol (int protocolNumber) const ;
++
++  /**
++   * Do nothing
++   */
++  virtual Ptr<Socket> CreateRawSocket (void);
++
++  /**
++   * Do nothing
++   */
++  virtual void DeleteRawSocket (Ptr<Socket> socket);
++
++  static void InstallNode (Ptr<Node> node);
++
++  /**
++   * \brief Register the IPv6 Extensions.
++   */
++  virtual void RegisterExtensions ();
++
++  /**
++   * \brief Register the IPv6 Options.
++   */
++  virtual void RegisterOptions ();
++
++private:
++  // Indirect the Ipv6 attributes through private pure virtual methods
++  virtual void SetIpForward (bool forward);
++  virtual bool GetIpForward (void) const;
++  virtual void SetWeakEsModel (bool model);
++  virtual bool GetWeakEsModel (void) const;
++  uint32_t AddIpv6Interface (Ptr<Ipv6Interface> interface);
++  Ptr<Ipv6Interface> GetInterface (uint32_t i) const;
++
++  typedef std::vector<Ptr<Ipv6Interface> > Ipv6InterfaceList;
++  Ptr<Ipv6RoutingProtocol> m_routingProtocol;
++  bool m_ipForward;
++  bool m_weakEsModel;
++  Ipv6InterfaceList m_interfaces;
++};
++}
++#endif // IPV6_LINUX_H
+diff -r b4f69e2ed0b3 wscript
+--- a/wscript	Thu Dec 13 12:07:18 2012 +0900
++++ b/wscript	Thu Dec 13 12:27:12 2012 +0900
+@@ -35,7 +35,7 @@
+     ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)
+     ns3waf.check_modules(conf, ['point-to-point-layout'], mandatory = False)
+     ns3waf.check_modules(conf, ['mpi'], mandatory = False)
+-    ns3waf.check_modules(conf, ['applications'], mandatory = False)
++    ns3waf.check_modules(conf, ['applications', 'olsr'], mandatory = False)
+     conf.check_tool('compiler_cc')
+     conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H', mandatory=False)
+     conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H', mandatory=False)
+@@ -281,6 +281,10 @@
+                        target='bin/dce-tcp-ns3-nsc-comparison',
+                        source=['example/dce-tcp-ns3-nsc-comparison.cc'])
+ 
++    module.add_example(needed = ['point-to-point', 'internet', 'olsr', 'applications', 'wifi', 'dce'],
++                       target='bin/simple-point-to-point-olsr',
++                       source=['example/simple-point-to-point-olsr.cc'])
++
+ # Add a script to build system 
+ def build_a_script(bld, name, needed = [], **kw):
+     external = [i for i in needed if not i == name]
+@@ -395,6 +399,7 @@
+         'model/dce-at.cc',
+         'model/exec-utils.cc',
+         'model/linux/ipv4-linux.cc',
++        'model/linux/ipv6-linux.cc',
+         'model/dce-vfs.cc',
+         'model/elf-ldd.cc',
+         'model/dce-termio.cc',
+@@ -423,6 +428,7 @@
+         'model/dce-application.h',
+         'model/ipv4-dce-routing.h',
+         'model/linux/ipv4-linux.h',
++        'model/linux/ipv6-linux.h',
+         'model/process-delay-model.h',
+         'model/linux/linux-socket-impl.h',
+         'model/linux/linux-ipv4-raw-socket-factory.h',
--- a/modulize-quagga-mip6.patch	Mon Aug 06 20:45:50 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-diff -r 4ab96eb6171d model/linux-socket-fd.cc
---- a/model/linux-socket-fd.cc	Thu Mar 29 13:58:26 2012 +0900
-+++ b/model/linux-socket-fd.cc	Fri Apr 06 15:16:09 2012 +0900
-@@ -215,4 +215,10 @@
-   return m_factory->Poll (m_socket, ptable);
- }
- 
-+int
-+LinuxSocketFd::Ftruncate (off_t length)
-+{
-+  return -1;
-+}
-+
- } // namespace ns3
-diff -r 4ab96eb6171d model/linux-socket-fd.h
---- a/model/linux-socket-fd.h	Thu Mar 29 13:58:26 2012 +0900
-+++ b/model/linux-socket-fd.h	Fri Apr 06 15:16:09 2012 +0900
-@@ -49,6 +49,7 @@
-   virtual int Gettime (struct itimerspec *cur_value) const;
- 
-   virtual bool HangupReceived (void) const;
-+  virtual int Ftruncate(off_t);
- 
-   virtual int Poll (PollTable* ptable);
- 
-diff -r 4ab96eb6171d model/ns3-socket-fd-factory.cc
---- a/model/ns3-socket-fd-factory.cc	Thu Mar 29 13:58:26 2012 +0900
-+++ b/model/ns3-socket-fd-factory.cc	Fri Apr 06 15:16:09 2012 +0900
-@@ -140,6 +140,20 @@
-           break;
-         }
-     }
-+  else if (domain == PF_INET6)
-+    {
-+      switch (type) {
-+        case SOCK_RAW: {
-+        TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
-+        Ptr<SocketFactory> factory = GetObject<SocketFactory> (tid);
-+        sock = factory->CreateSocket ();
-+        sock->SetAttribute ("Protocol", UintegerValue (protocol));
-+        socket = new UnixDatagramSocketFd (sock);
-+          } break;
-+      default:
-+        break;
-+      }
-+    }
-   else
-     {
-       //      NS_FATAL_ERROR ("unsupported domain");
-diff -r 4ab96eb6171d model/unix-socket-fd.cc
---- a/model/unix-socket-fd.cc	Thu Mar 29 13:58:26 2012 +0900
-+++ b/model/unix-socket-fd.cc	Fri Apr 06 15:16:09 2012 +0900
-@@ -33,6 +33,7 @@
- #include "ns3/boolean.h"
- #include "ns3/simulator.h"
- #include "ns3/netlink-socket-address.h"
-+#include <linux/netlink.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <linux/icmp.h> // need ICMP_FILTER
-diff -r 4ab96eb6171d wscript
---- a/wscript	Thu Mar 29 13:58:26 2012 +0900
-+++ b/wscript	Fri Apr 06 15:16:09 2012 +0900
-@@ -240,17 +240,10 @@
-                        target='bin/dce-iperf',
-                        source=['example/dce-iperf.cc', 'example/ccnx/misc-tools.cc'])
-     
--    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'point-to-point-layout'],
--                       target='bin/dce-zebra-simple',
--                       source=['example/dce-zebra-simple.cc'])
--
-     module.add_example(needed = ['core', 'internet', 'dce' ], 
-                        target='bin/dce-bash-simple',
-                        source=['example/bash/dce-bash-simple.cc'])
-                                                 
--    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'applications', 'topology-read', 'visualizer'],
--                       target='bin/dce-quagga-ospfd-rocketfuel',
--                       source=['example/dce-quagga-ospfd-rocketfuel.cc'])
- 
- def build_dce_kernel_examples(module):
-     module.add_example(needed = ['core', 'network', 'dce'], 
-@@ -261,33 +254,6 @@
-                        target='bin/dce-linux',
-                        source=['example/dce-linux.cc'])
- 
--    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
--                       target='bin/dce-quagga-ospfd',
--                       source=['example/dce-quagga-ospfd.cc'])
--
--    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'visualizer', 'topology-read'],
--                       target='bin/dce-quagga-bgpd-caida',
--                       source=['example/dce-quagga-bgpd-caida.cc'])
--
--    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
--                       target='bin/dce-quagga-bgpd',
--                       source=['example/dce-quagga-bgpd.cc'])
--
--    module.add_example(needed = ['core', 'internet', 'dce', 'csma', 'mobility', 'wifi', 'visualizer'],
--                       target='bin/dce-mip6d',
--                       source=['example/dce-mip6d.cc'])
--
--    module.add_example(needed = ['core', 'internet', 'dce', 'csma', 'mobility', 'wifi', 'visualizer'],
--                       target='bin/dce-dsmip6d',
--                       source=['example/dce-dsmip6d.cc'])
--
--    module.add_example(needed = ['core', 'internet', 'dce', 'csma', 'mobility', 'wifi', 'visualizer', 'topology-read'],
--                       target='bin/dce-fga',
--                       source=['example/dce-fga.cc'])
--
--    module.add_example(needed = ['core', 'internet', 'dce', 'csma', 'mobility', 'wifi', 'visualizer', 'topology-read'],
--                       target='bin/dce-fga-crawdad',
--                       source=['example/dce-fga-crawdad.cc'])
- 
- def build(bld):
-     build_netlink(bld)
-@@ -374,8 +340,6 @@
-         'helper/ipv4-dce-routing-helper.cc',
-         'helper/dce-manager-helper.cc',
-         'helper/dce-application-helper.cc',
--        'helper/quagga-helper.cc',
--        'helper/mip6d-helper.cc',
-         ]
-     module_headers = [
-         'model/dce-manager.h',
-@@ -385,10 +349,9 @@
-         'model/loader-factory.h',
-         'model/dce-application.h',
-         'model/ipv4-dce-routing.h',
-+        'helper/ipv4-dce-routing-helper.h',
-         'helper/dce-manager-helper.h',
-         'helper/dce-application-helper.h',
--        'helper/quagga-helper.h',
--        'helper/mip6d-helper.h',
-         ]
-     module_source = module_source + kernel_source
-     module_headers = module_headers + kernel_headers
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/more-test.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,304 @@
+diff --git a/example/dce-tcp-ns3-nsc-comparison.cc b/example/dce-tcp-ns3-nsc-comparison.cc
+--- a/example/dce-tcp-ns3-nsc-comparison.cc
++++ b/example/dce-tcp-ns3-nsc-comparison.cc
+@@ -202,6 +202,16 @@
+   // dceManager.RunIp (rights.Get (1), Seconds (0.2), "route add default via 10.2.1.1");
+   // dceManager.RunIp (rights.Get (0), Seconds (0.2), "route show");
+ 
++  // dceManager.RunIp (lefts.Get (0), Seconds (0.2), "route add default via 10.0.0.2");
++  // dceManager.RunIp (lefts.Get (1), Seconds (0.2), "route add default via 10.0.1.2");
++  // dceManager.RunIp (routers.Get (0), Seconds (0.2), "route add 10.2.0.0/16 via 10.1.0.2");
++  // dceManager.RunIp (routers.Get (1), Seconds (0.2), "route add 10.0.0.0/16 via 10.1.0.1");
++  // dceManager.RunIp (routers.Get (1), Seconds (0.2), "route show");
++  // dceManager.RunIp (routers.Get (1), Seconds (0.2), "link set lo up");
++  // dceManager.RunIp (rights.Get (0), Seconds (0.2), "route add 0.0.0.0/0 via 10.2.0.1");
++  // dceManager.RunIp (rights.Get (1), Seconds (0.2), "route add default via 10.2.1.1");
++  // dceManager.RunIp (rights.Get (0), Seconds (0.2), "route show");
++
+   ApplicationContainer apps;
+   DceApplicationHelper process;
+ 
+diff --git a/example/dce-trinity.cc b/example/dce-trinity.cc
+new file mode 100644
+--- /dev/null
++++ b/example/dce-trinity.cc
+@@ -0,0 +1,99 @@
++#include "ns3/core-module.h"
++#include "ns3/network-module.h"
++#include "ns3/dce-module.h"
++#include "ns3/point-to-point-module.h"
++#include "ns3/csma-module.h"
++#include "ns3/wifi-module.h"
++#include "ns3/mobility-module.h"
++#include "ns3/internet-module.h"
++#include <fstream>
++
++using namespace ns3;
++NS_LOG_COMPONENT_DEFINE ("DceLinux");
++
++static void RunIp (Ptr<Node> node, Time at, std::string str)
++{
++  DceApplicationHelper process;
++  ApplicationContainer apps;
++  process.SetBinary ("ip");
++  process.SetStackSize (1<<16);
++  process.ResetArguments();
++  process.ParseArguments(str.c_str ());
++  apps = process.Install (node);
++  apps.Start (at);
++}
++
++void
++PrintTcpFlags (std::string key, std::string value)
++{
++  NS_LOG_INFO (key << "=" << value);
++}
++
++int main (int argc, char *argv[])
++{
++  CommandLine cmd;
++  char linkType = 'p'; // P2P
++  bool reliable = true;
++
++  cmd.Parse (argc, argv);
++  NodeContainer nodes;
++  nodes.Create (2);
++
++  NetDeviceContainer devices;
++  PointToPointHelper p2p;
++  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Gbps"));
++  p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
++  devices = p2p.Install (nodes);
++  p2p.EnablePcapAll ("trinity");
++
++  DceManagerHelper processManager;
++  // processManager.SetLoader ("ns3::DlmLoaderFactory");
++  //  processManager.SetLoader ("ns3::CopyLoaderFactory");
++  processManager.SetTaskManagerAttribute ("FiberManagerType",
++                                          StringValue ("UcontextFiberManager"));
++  processManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
++  LinuxStackHelper stack;
++  stack.Install (nodes);
++
++  Ipv4AddressHelper address;
++  address.SetBase ("10.0.0.0", "255.255.255.0");
++  Ipv4InterfaceContainer interfaces = address.Assign (devices);
++
++  processManager.Install (nodes);
++
++
++  for (int n=0; n < 2; n++)
++    {
++      RunIp (nodes.Get (n), Seconds (0.2), "link show");
++      RunIp (nodes.Get (n), Seconds (0.3), "route show table all");
++      RunIp (nodes.Get (n), Seconds (0.4), "addr list");
++    }
++
++  DceApplicationHelper process;
++  ApplicationContainer apps;
++
++  process.SetBinary ("tcp-server");
++  process.ResetArguments ();
++  process.SetStackSize (1<<16);
++  apps = process.Install (nodes.Get (0));
++  apps.Start (Seconds (1.0));
++
++  process.SetBinary ("trinity");
++  process.SetUid (1000);
++  //process.SetBinary ("tcp-client");
++  process.ResetArguments ();
++  //  process.ParseArguments ("-L");
++  //process.ParseArguments ("10.0.0.1");
++  apps = process.Install (nodes.Get (1));
++  apps.Start (Seconds (1.5));
++
++  // print tcp sysctl value
++  LinuxStackHelper::SysctlGet (nodes.Get (0), Seconds (1.0), 
++                               ".net.ipv4.tcp_available_congestion_control", &PrintTcpFlags);
++
++  Simulator::Stop (Seconds (200.0));
++  Simulator::Run ();
++  Simulator::Destroy ();
++
++  return 0;
++}
+diff --git a/model/dce-alloc.cc b/model/dce-alloc.cc
+--- a/model/dce-alloc.cc
++++ b/model/dce-alloc.cc
+@@ -77,3 +77,8 @@
+ {
+   return sysconf (_SC_PAGESIZE);
+ }
++void *dce_memalign(size_t boundary, size_t size)
++{
++  // XXX
++  return dce_malloc (size);
++}
+diff --git a/model/dce-stdlib.h b/model/dce-stdlib.h
+--- a/model/dce-stdlib.h
++++ b/model/dce-stdlib.h
+@@ -24,6 +24,7 @@
+ int dce_clearenv (void);
+ int dce_mkstemp (char *temp);
+ int dce_rename (const char *oldpath, const char *newpath);
++void *dce_memalign(size_t boundary, size_t size);
+ 
+ #ifdef __cplusplus
+ }
+diff --git a/model/libc-dce.cc b/model/libc-dce.cc
+--- a/model/libc-dce.cc
++++ b/model/libc-dce.cc
+@@ -96,6 +96,10 @@
+ #include <langinfo.h>
+ #include <sys/vfs.h>
+ #include <termio.h>
++#include <sys/ipc.h>
++#include <sys/shm.h>
++#include <malloc.h>
++#include <sys/prctl.h>
+ 
+ extern void __cxa_finalize (void *d);
+ extern int __cxa_atexit (void (*func)(void *), void *arg, void *d);
+diff --git a/model/libc-ns3.h b/model/libc-ns3.h
+--- a/model/libc-ns3.h
++++ b/model/libc-ns3.h
+@@ -104,6 +104,7 @@
+ DCE (abort)
+ DCE (mkstemp)
+ DCE (rename)
++DCE (memalign)
+ 
+ // STRING.H
+ NATIVE (strerror)
+@@ -315,6 +316,7 @@
+ DCE (open)
+ DCE (open64)
+ DCE (unlinkat)
++DCE (creat)
+ 
+ // TIME.H
+ DCE (nanosleep)
+@@ -546,6 +548,15 @@
+ DCE (tcgetattr)
+ DCE (tcsetattr)
+ 
++/* shm.h */
++NATIVE (shmget)
++NATIVE (shmat)
++NATIVE (shmctl)
++NATIVE (shmdt)
++
++NATIVE (prctl)
++NATIVE (chmod)
++
+ ///////////////////// END OF INVENTAIRE //////////////////////////////////////////////////
+ 
+ // ctype.h
+diff --git a/utils/run-all-test-coverage.sh b/utils/run-all-test-coverage.sh
+--- a/utils/run-all-test-coverage.sh
++++ b/utils/run-all-test-coverage.sh
+@@ -1,27 +1,68 @@
+ #!/bin/bash
+-set -x
++#set -x
+ 
+-export NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager'
+ 
+-../build/bin/ns3test-dce-vdl
+-./build/bin/dce-runner ../build/bin/dce-dccp
+-./build/bin/dce-runner ../build/bin/dce-iperf --kernel=1
+-../build/bin/ns3test-dce-quagga-vdl |& grep -v sockopt
+-./build/bin/dce-runner ../build/bin/dce-quagga-radvd
+-./build/bin/dce-runner ../build/bin/dce-quagga-bgpd
+-./build/bin/dce-runner ../build/bin/dce-quagga-ospfd --netStack=linux 
+-./build/bin/dce-runner ../build/bin/dce-quagga-ospf6d --netStack=linux 
+-#./build/bin/dce-runner ../build/bin/dce-quagga-ospfd-rocketfuel --netStack=linux  
+-./build/bin/dce-runner ../build/bin/dce-quagga-ripd
+-./build/bin/dce-runner ../build/bin/dce-quagga-ripngd
+-./build/bin/dce-runner ../build/bin/dce-umip-cmip6
+-./build/bin/dce-runner ../build/bin/dce-umip-nemo |& grep -v bytes
+-../build/bin/ns3test-dce-umip-vdl
+-./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=icmp
+-./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=udp
+-./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=tcp
+-./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=dccp
+-./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=dccp -ccid=3
+-./build/bin/dce-runner ../build/bin/dce-tcp-ns3-nsc-comparison --stack=dce
++echo ${NS_ATTRIBUTE_DEFAULT}
+ 
+ 
++run_test() {
++
++$2 >& /dev/null
++case "$?" in
++0)
++    echo $1 " PASS " $2
++    ;;
++1)
++    echo $1 " FAIL " $2
++    ;;
++*)
++    echo $1 " CRASH " $2
++    ;;
++esac
++
++}
++
++SEED=`seq 1 10 100`
++SEED=`seq 1 10 30`
++RUNS=`seq 1 1 5`
++ERROR_RATES=`seq 0.0 0.0001 0.0005`
++
++for seed in ${SEED}
++do
++for run in ${RUNS}
++do
++for err in ${ERROR_RATES}
++do
++
++export NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager;ns3::LinuxSocketFdFactory::ErrorRate='$err';'
++echo $NS_ATTRIBUTE_DEFAULT
++export NS_GLOBAL_VALUE='RngSeed=$seed:RngRun=$run'
++echo $NS_GLOBAL_VALUE
++echo "RndSeed=$seed, RngRun=$run, ErrRatio=$err"
++
++run_test "DCE"  "../build/bin/ns3test-dce-vdl"
++run_test "DCCP" "./build/bin/dce-runner ../build/bin/dce-dccp"
++run_test "iperf" "./build/bin/dce-runner ../build/bin/dce-iperf --kernel=1"
++run_test "quagga" "../build/bin/ns3test-dce-quagga-vdl"
++run_test "radvd" "./build/bin/dce-runner ../build/bin/dce-quagga-radvd"
++run_test "bgpd" "./build/bin/dce-runner ../build/bin/dce-quagga-bgpd"
++run_test "ospfd" "./build/bin/dce-runner ../build/bin/dce-quagga-ospfd --netStack=linux"
++run_test "ospf6d" "./build/bin/dce-runner ../build/bin/dce-quagga-ospf6d --netStack=linux" 
++#run_test "Test1" "./build/bin/dce-runner ../build/bin/dce-quagga-ospfd-rocketfuel --netStack=linux"
++run_test "ripd" "./build/bin/dce-runner ../build/bin/dce-quagga-ripd"
++run_test "ripngd" "./build/bin/dce-runner ../build/bin/dce-quagga-ripngd"
++run_test "cmip6" "./build/bin/dce-runner ../build/bin/dce-umip-cmip6"
++run_test "nemo" "./build/bin/dce-runner ../build/bin/dce-umip-nemo"
++run_test "umip" "../build/bin/ns3test-dce-umip-vdl"
++run_test "icmp" "./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=icmp"
++run_test "udp" "./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=udp"
++run_test "tcp" "./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=tcp"
++run_test "dccp" "./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=dccp"
++run_test "dccp ccid=3" "./build/bin/dce-runner ../build/bin/dce-ns3-onoff --rate=10kbps --proto=dccp -ccid=3"
++run_test "dumbbel" "./build/bin/dce-runner ../build/bin/dce-tcp-ns3-nsc-comparison --stack=dce"
++run_test "fuzzer" "./build/bin/dce-runner ./build/bin/dce-trinity"
++
++
++done
++done
++done
+diff --git a/wscript b/wscript
+--- a/wscript
++++ b/wscript
+@@ -342,6 +342,10 @@
+                        target='bin/dce-tcp-ns3-nsc-comparison',
+                        source=['example/dce-tcp-ns3-nsc-comparison.cc'])
+ 
++    module.add_example(needed = ['core', 'network', 'dce', 'wifi', 'point-to-point', 'csma', 'mobility' ],
++                       target='bin/dce-trinity',
++                       source=['example/dce-trinity.cc'])
++
+ # Add a script to build system 
+ def build_a_script(bld, name, needed = [], **kw):
+     external = [i for i in needed if not i == name]
--- a/mpitest.patch	Mon Aug 06 20:45:50 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-diff -r fc08a4cc768f example/dce-quagga-ospfd-rocketfuel.cc
---- a/example/dce-quagga-ospfd-rocketfuel.cc	Thu Mar 29 13:55:22 2012 +0900
-+++ b/example/dce-quagga-ospfd-rocketfuel.cc	Thu Mar 29 13:55:54 2012 +0900
-@@ -13,15 +13,18 @@
- 
- #include <sys/resource.h>
- 
-+#define NS3_OPENMPI
-+#define NS3_MPI
- #ifdef NS3_MPI
- #include <mpi.h>
-+#include "ns3/mpi-interface.h"
- #endif
- using namespace ns3;
- 
- NS_LOG_COMPONENT_DEFINE ("quagga-ospfd-rocketfuel");
- 
- // Parameters
--uint32_t stopTime = 60;
-+uint32_t stopTime = 3600;
- 
- static void
- SetRlimit ()
-@@ -148,7 +151,7 @@
-       p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
-       ndc[i] = p2p.Install (nc[i]);
-     }
--  //  p2p.EnablePcapAll ("quagga-rocketfuel");
-+//  p2p.EnablePcapAll ("quagga-rocketfuel");
- 
-   NS_LOG_INFO ("creating ipv4 interfaces");
-   Ipv4InterfaceContainer ipic[totlinks];
-@@ -166,6 +169,7 @@
-   NS_LOG_INFO ("creating quagga process");
-   //run quagga programs in every node
-   DceManagerHelper processManager;
-+  processManager.SetLoader ("ns3::DlmLoaderFactory");
-   QuaggaHelper quagga;
- 
-   // 
-@@ -195,6 +199,7 @@
-           //     std::cout << "[" << systemId << "] start quagga Node " << i << std::endl;
-           processManager.Install (nodes.Get (i));
-           quagga.EnableOspf (nodes.Get (i));
-+          quagga.EnableOspfDebug (nodes.Get (i));
-           quagga.Install (nodes.Get (i));
-         }
-     }
-diff -r fc08a4cc768f helper/quagga-helper.cc
---- a/helper/quagga-helper.cc	Thu Mar 29 13:55:22 2012 +0900
-+++ b/helper/quagga-helper.cc	Thu Mar 29 13:55:54 2012 +0900
-@@ -829,9 +829,9 @@
- 
-       process.SetBinary ("ospfd");
-       process.AddArguments ("-f", ospf_conf->GetFilename ());
--      process.AddArguments ("-i", "/usr/local/etc/ospfd.pid");
-+//      process.AddArguments ("-i", "/usr/local/etc/ospfd.pid");
-       apps.Add (process.Install (node));
--      apps.Get(1)->SetStartTime (Seconds (2.0 + 0.1 * node->GetId ()));
-+      apps.Get(1)->SetStartTime (Seconds (20.0 + 0.1 * node->GetId ()));
-       node->AddApplication (apps.Get (1));
-     }
- 
-diff -r fc08a4cc768f utils/setenv.zsh
---- a/utils/setenv.zsh	Thu Mar 29 13:55:22 2012 +0900
-+++ b/utils/setenv.zsh	Thu Mar 29 13:55:54 2012 +0900
-@@ -3,7 +3,7 @@
- # Set environnement for ns3 dce
- cd `dirname ${BASH_SOURCE:-$0}`/../..
- BASE=$PWD
--LD_LIBRARY_PATH="$BASE/ns-3-dce/build/lib:$BASE/build/lib:$BASE/build/bin:$BASE/ns-3-dce/build/bin:."
-+LD_LIBRARY_PATH="$BASE/ns-3-dce/build/lib:$BASE/build/lib:$BASE/build/bin:$BASE/ns-3-dce/build/bin:.:/usr/local/mpi/gcc/openmpi-1.4.3/lib/"
- PKG_CONFIG_PATH="$BASE/build/lib/pkgconfig"
- PATH="$BASE/build/bin:$BASE/build/sbin:/home/tazaki/hgworks/ns-3-dce-thehajime/build/bin:/home/tazaki/hgworks/ns-3-dce-thehajime/build/sbin:$PATH"
- PYTHONPATH=$BASE/ns-3-dev/build/debug/bindings/python:$BASE/ns-3-dev/src/visualizer:$BASE/pybindgen-0.15.0.795:$BASE/build/lib/python2.6/site-packages/
-diff -r fc08a4cc768f wscript
---- a/wscript	Thu Mar 29 13:55:22 2012 +0900
-+++ b/wscript	Thu Mar 29 13:55:54 2012 +0900
-@@ -248,7 +248,7 @@
-                        target='bin/dce-bash-simple',
-                        source=['example/bash/dce-bash-simple.cc'])
-                                                 
--    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'applications', 'topology-read'],
-+    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'applications', 'topology-read', 'visualizer'],
-                        target='bin/dce-quagga-ospfd-rocketfuel',
-                        source=['example/dce-quagga-ospfd-rocketfuel.cc'])
- 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/new-tutorial.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,462 @@
+diff -r 096bb07cdd73 doc/source/index.rst
+--- a/doc/source/index.rst	Tue Sep 25 14:07:05 2012 +0900
++++ b/doc/source/index.rst	Tue Sep 25 18:34:48 2012 +0900
+@@ -14,4 +14,5 @@
+    getting-started
+    how-it-works
+    dce-readme
++   tutorial
+     
+diff -r 096bb07cdd73 doc/source/tutorial/index.rst
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/doc/source/tutorial/index.rst	Tue Sep 25 18:34:48 2012 +0900
+@@ -0,0 +1,449 @@
++.. only:: html or latex
++ns-3 DCE Tutorial
++=================
++
++This is the *ns-3 DCE (Direct Code Execution) Tutorial*. 
++
++Introduction
++------------
++Direct Code Execution (DCE) is ...
++
++
++Contributing
++************
++How to contribute to DCE development?
++
++Tutorial Organization
++*********************
++
++The tutorial assumes that new users might initially follow a path such as the
++following:
++
++* Try to download and build a copy;
++* Try to run a few sample programs;
++* Look at simulation output, and try to adjust it.
++* Try to employ your own application as a simulation model.
++* Then, debugging if the simulation fails.
++
++As a result, we have tried to organize the tutorial along the above
++broad sequences of events.
++
++
++Getting Started
++---------------
++Downloading ns-3-dce
++********************
++::
++
++  $ mkdir test_build_ns3_dce
++  $ cd test_build_ns3_dce
++  $ hg clone http://code.nsnam.org/furbani/ns-3-dce 
++
++
++Building options
++****************
++
++DCE offers two major modes of operation:
++ 1. The basic mode, where DCE use the NS3 TCP stacks,
++ 2. The advanced mode, where DCE uses a linux network stack instead.
++
++Building and Testing ns-3-dce
++*****************************
++Then you can build the DCE and related/required codes and libraries:
++
++::
++
++  $ ns-3-dce/utils/clone_and_compile_ns3_dce.sh
++
++if you're going to use linux kernel (i.e., advanced mode), '-k' option will bring you all builds and tests.
++
++::
++
++  $ ns-3-dce/utils/clone_and_compile_ns3_dce.sh -k
++
++Once the building starts, the following outputs will be shown.
++
++::
++
++  $ ns-3-dce/utils/clone_and_compile_ns3_dce.sh
++  clone readversiondef
++  ...
++  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
++  ...
++  Launch NS3TEST-DCE
++  PASS process-manager 16.030ms
++    PASS Check that process "test-empty" completes correctly. 1.220ms
++    PASS Check that process "test-sleep" completes correctly. 0.030ms
++    PASS Check that process "test-pthread" completes correctly. 0.020ms
++    PASS Check that process "test-mutex" completes correctly. 0.110ms
++    PASS Check that process "test-once" completes correctly. 0.030ms
++    PASS Check that process "test-pthread-key" completes correctly. 0.020ms
++    PASS Check that process "test-sem" completes correctly. 0.040ms
++    PASS Check that process "test-malloc" completes correctly. 0.030ms
++    PASS Check that process "test-malloc-2" completes correctly. 0.020ms
++    PASS Check that process "test-fd-simple" completes correctly. 0.030ms
++    PASS Check that process "test-strerror" completes correctly. 0.030ms
++    PASS Check that process "test-stdio" completes correctly. 0.030ms
++    PASS Check that process "test-string" completes correctly. 0.030ms
++    PASS Check that process "test-netdb" completes correctly. 0.220ms
++    PASS Check that process "test-env" completes correctly. 0.030ms
++    PASS Check that process "test-cond" completes correctly. 0.100ms
++    PASS Check that process "test-timer-fd" completes correctly. 0.030ms
++    PASS Check that process "test-stdlib" completes correctly. 0.030ms
++    PASS Check that process "test-select" completes correctly. 0.080ms
++    PASS Check that process "test-nanosleep" completes correctly. 0.030ms
++    PASS Check that process "test-random" completes correctly. 0.030ms
++    PASS Check that process "test-fork" completes correctly. 0.030ms
++    PASS Check that process "test-local-socket" completes correctly. 12.840ms
++    PASS Check that process "test-poll" completes correctly. 0.090ms
++    PASS Check that process "test-tcp-socket" completes correctly. 0.880ms
++
++
++\# The script includes the test for DCE.
++
++DCE is compiled after a few minutes and if the tests completed successfully, you should see the directories:
++
++::
++
++  $ ls
++  build  ns-3-dev  ns-3-dce  readversiondef ns-3-linux iproute2-2.6.33
++
++Where:
++ 1. *build* contains the result of compilation: some binaries some libs and some include files usable to do your simulations scripts.
++
++ 2. *ns-3-dev* contains the current sources of NS3, 
++
++ 3. *ns-3-dce* contains the DCE sources,
++
++ 4. *readversiondef* contains source of a tool used by DCE build system. 
++
++ 5. *ns-3-linux* (only in advanced mode) contains source of a linux kernel + some glue code for DCE / Kernel communication.
++
++ 6. *iproute2-2.6.33* (only in advanced mode) contains source of *ip* tool needed to be compiled for DCE in order to configure ip routes of the slave kernel used by DCE.
++
++Running Examples
++****************
++Unlike usual ns-3, DCE is currently not integrated with 'waf' command to execute simulation scripts. You need to run your script by executing the binary of the program with appropriately configured ENVIRONMENT variables (i.e., PATH, LD_LIBRARY_PATH and PKG_CONFIG_PATH).
++
++::
++
++  $ source ns-3-dce/utils/setenv.sh
++
++then you can execute the simulation script:
++
++::
++  $ dce-udp-simple
++
++
++Example: DCE UDP EXAMPLE
++########################
++
++This example execute the binaries named udp-client and udp-server under NS3 using DCE.
++
++These 2 binaries are writen using libc api in order to send and receive udp packets.
++
++Please take time to look at the source dce-udp-simple.cc which is our NS3 simulation "script":
++
++::
++
++  int main (int argc, char *argv[])
++  {
++    CommandLine cmd;
++    cmd.Parse (argc, argv);
++  
++    NodeContainer nodes;
++    nodes.Create (1);
++  
++    InternetStackHelper stack;
++    stack.Install (nodes);
++  
++    DceManagerHelper dceManager;
++    dceManager.Install (nodes);
++  
++    DceApplicationHelper dce;
++    ApplicationContainer apps;
++  
++    dce.SetStackSize (1<<20);
++  
++    dce.SetBinary ("udp-server");
++    dce.ResetArguments();
++    apps = dce.Install (nodes.Get (0));
++    apps.Start (Seconds (4.0));
++  
++    dce.SetBinary ("udp-client");
++    dce.ResetArguments();
++    dce.AddArgument ("127.0.0.1");
++    apps = dce.Install (nodes.Get (0));
++    apps.Start (Seconds (4.5));
++  
++    Simulator::Stop (Seconds(1000100.0));
++    Simulator::Run ();
++    Simulator::Destroy ();
++  
++    return 0;
++  }
++  
++You can notice that we create a NS-3 Node with an Internet Stack (please refer to `NS-3 <http://www.nsnam.org/documentation/>`_ doc. for more info),
++and we can also see 2 new Helpers:
++
++ 1. DceManagerHelper which is used to Manage DCE loading system in each node where DCE will be used.
++ 2. DceApplicationHelper which is used to describe real application to be lauched by DCE within NS-3 simulation environnement.
++ 
++As you have already set the environnement variables you can launch this simulation from anywhere:
++
++::
++
++  $ cd /tmp
++  $ mkdir my_test
++  $ cd my_test
++  $ dce-udp-simple
++  $ ls 
++    elf-cache  files-0
++  $ ls -lR files-0
++    files-0:
++    total 4
++    drwxr-x--- 3 furbani planete 4096 Sep  2 17:02 var
++
++    files-0/var:
++    total 4
++    drwxr-x--- 4 furbani planete 4096 Sep  2 17:02 log
++
++    files-0/var/log:
++    total 8
++    drwxr-x--- 2 furbani planete 4096 Sep  2 17:02 53512
++    drwxr-x--- 2 furbani planete 4096 Sep  2 17:02 53513
++
++    files-0/var/log/53512:
++    total 12
++    -rw------- 1 furbani planete  12 Sep  2 17:02 cmdline
++    -rw------- 1 furbani planete 185 Sep  2 17:02 status
++    -rw------- 1 furbani planete   0 Sep  2 17:02 stderr
++    -rw------- 1 furbani planete  21 Sep  2 17:02 stdout
++
++    files-0/var/log/53513:
++    total 12
++    -rw------- 1 furbani planete  22 Sep  2 17:02 cmdline
++    -rw------- 1 furbani planete 185 Sep  2 17:02 status
++    -rw------- 1 furbani planete   0 Sep  2 17:02 stderr
++    -rw------- 1 furbani planete  22 Sep  2 17:02 stdout
++
++This simulation produces two directories, the content of elf-cache is not important now for us, but files-0 is.
++files-0 contains first node's file system, it also contains the output files of the dce applications launched on this node. In the /var/log directory there is some directories named with the virtual pid of corresponding DCE applications. Under these directories there is always 4 files:
++
++1. cmdline: which contains the command line of the corresponding DCE application, in order to help you to retrieve what is it,
++2. stdout: contains the stdout produced by the execution of the corresponding application,
++3. stderr: contains the stderr produced by the execution of the corresponding application.
++4. status: contains a status of the corresponding process with its start time. This file also contains the end time and exit code if applicable.
++              
++Before launching a simulation, you may also create files-xx directories and provide files required by the applications to be executed correctly.
++
++DCE LINUX Example
++#################
++
++This example shows how to use DCE in advanced mode, with a linux kernel IP stack.
++It uses also the binaries *udp-server* and *udp-client* like the above example, there is also *tcp-server* and *tcp-client* if you choose the reliable transport option.
++Two other binaries are needed: the linux kernel stack named *libnet-next-2.6.so* and the tool needed to configure this kernel stack named *ip*.
++This example simulates an exchange of data between too nodes, using TCP or UDP, and the nodes are linked by one of three possible links , Wifi, Point 2 point or CSMA.
++The main executable is named *dce-linux*, it cames with too options:
++
++1. linkType allow to choose the link type between c, w or p for Csma, Wifi or Point 2 point,
++2. reliable allow to choose transport between TCP (1) or UDP (0).
++
++The following code snippet show how to enable DCE advanced mode (you can see it in the source file dce-linux.cc under example directory):
++
++::
++
++  DceManagerHelper processManager;
++  processManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("libnet-next-2.6.so"));
++  processManager.Install (nodes);
++
++  for (int n=0; n < 2; n++)
++    {
++      AddAddress (nodes.Get (n), Seconds (0.1), "sim0", "10.0.0.", 2 + n, "/8" );
++      RunIp (nodes.Get (n), Seconds (0.11), ( 'p' == linkType )? "link set sim0 up arp off":"link set sim0 up arp on");
++      RunIp (nodes.Get (n), Seconds (0.2), "link show");
++      RunIp (nodes.Get (n), Seconds (0.3), "route show table all");
++      RunIp (nodes.Get (n), Seconds (0.4), "addr list");
++    }
++
++The first important call is *SetNetworkStack* used to indicate which file contains the linux kernel stack.
++Then in the for loop we setup on each nodes the network interfaces using the ip executable to configure the kernel stack.
++Because this source code factorizes some call, it is not very readeable so below there is the corresponding calls to ip executable with the arguments:
++
++::
++
++   ip -f inet addr add 10.0.0.2 dev sim0        // set the ip adresse of the first (sim0) net device of the corresponding node
++   ip link set sim0 up arp on                   // enable the use of the device use arp off instead for P2P link
++   ip link show
++   ip route show table all
++   ip addr list
++
++
++Employing Your Own Applications
++-------------------------------
++The next tutorial presents how to execute your applications in ns-3 via DCE. We use 'ping' command as an example of this section. The example is included in the code repository under 'myscripts/ping/' directory.
++
++Rebuild the application as a special binary file
++************************************************
++DCE requires the special build, Position Independent Executable (PIE), for the loading binary in the ns-3 simulation.
++
++Let's start building a custom 'ping' command binary.
++
++First of all, we need to download the source code as follows (note: this information is validated at 25th September, 2012).
++
++::
++
++ $ wget http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2
++
++then extract the file.
++
++::
++
++ $ tar xfj iputils-s20101006.tar.bz2
++ $ cd iputils-s20101006
++
++Then, build 'ping' command with specific compiler/linker options:
++
++::
++
++  $ sed "s/CFLAGS+=/CFLAGS=/" Makefile > a
++  $ mv a Makefile
++  $ make CFLAGS=-fPIC LDFLAGS=-pie ping
++
++where the line 1 and 2 replace the Makefile in order to override the variable.
++
++Now you will have a self-build 'ping' command.
++
++::
++
++  $ ls -l ping
++  -rwxr-xr-x 1 tazaki 56773 2012-09-25 17:40 ping*
++
++You can verify whether the compiler and linker option was appropriately specified by the following command (readelf tells you).
++
++::
++
++  $ readelf -h ping |grep Type
++  Type:                              DYN (Shared object file)
++
++**DYN** indicates the binary file has compiled and linked as position independent code.
++
++
++It's ready to put your custom file at the directory in DCE_PATH variable. If you've already set the environment variable (e.g., by setenv.sh), then you can copy the 'ping' file to the directory.
++
++::
++
++  $ echo $DCE_PATH
++  /where/is/ns-3-dce/build/bin_dce:/where/is/ns-3-dce/build/bin:/where/is/ns-3-dce/../build/bin
++  $ cp ping /where/is/ns-3-dce/build/bin_dce
++
++
++That's it!
++
++
++Writing the simulation script
++*****************************
++The next step to play your code with DCE is 'preparing the script'. You will find the example in 'myscripts/ping/dce-ping.cc'.
++
++The file contains the complete showcase to use 'ping' command in the ns-3 simulation, the fundamental part of using the binary is showing in the followings:
++
++::
++
++      dce.SetBinary ("ping");
++      dce.ResetArguments();
++      dce.ResetEnvironment();
++      dce.AddArgument ("-c 10");
++      dce.AddArgument ("-s 1000");
++      dce.AddArgument ("10.1.1.2");
++
++where *SetBinary* indicates the name of the binary loaded into the simulation, and *AddArgument* indicates the command line arguments to execute the command.
++
++Then you will need to build this script. The 'wscript' is used to define how to build as follows and put it in the specific directory.
++
++::
++
++  import ns3waf
++  import os
++  
++  def configure(conf):
++      ns3waf.check_modules(conf, ['core', 'internet', 'point-to-point', 'netanim'], mandatory = True)
++  
++  def build(bld):
++      bld.build_a_script('dce', needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim' ],
++  				  target='bin/dce-ping',
++  				  source=['dce-ping.cc', 'misc-tools.cc'],
++  				  )
++
++The files are located like following, 
++
++::
++
++  $ ls myscripts/ping 
++  dce-ping.cc  misc-tools.cc  misc-tools.h  wscript
++
++then built it.
++
++::
++
++  $ ./waf configure
++  $ ./waf
++
++Now it's ready to do the simulation.
++
++::
++
++  $ dce-ping
++
++You can take a look the stdout of the ping command.
++
++::
++
++  $ cat files-0/var/log/3154/stdout 
++  PING 10.1.1.2 (10.1.1.2) 1000(1028) bytes of data.
++  1008 bytes from 10.1.1.2: icmp_req=1 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=2 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=3 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=4 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=5 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=6 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=7 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=8 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=9 ttl=64 time=5.29 ms
++  1008 bytes from 10.1.1.2: icmp_req=10 ttl=64 time=5.29 ms
++  
++  --- 10.1.1.2 ping statistics ---
++  10 packets transmitted, 10 received, 0% packet loss, time 9002ms
++  rtt min/avg/max/mdev = 5.295/5.295/5.296/0.097 ms
++
++
++
++
++Debugging the Program
++*********************
++
++
++Extending DCE core
++------------------
++
++
++.. .. toctree::
++..    :maxdepth: 2
++
++..    introduction
++..    resources
++..    getting-started
++..    conceptual-overview
++..    tweaking
++..    building-topologies
++..    tracing
++..    conclusion
++
++
++
++.. 	what should we do to use it?
++.. 	 - download
++.. 	 - install
++.. 	 - example
++.. 	 - debug example
++.. 	 - employ own code
++.. 	 - how to extend core
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perf-update.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,103 @@
+diff --git a/example/dce-cradle-simple.cc b/example/dce-cradle-simple.cc
+--- a/example/dce-cradle-simple.cc
++++ b/example/dce-cradle-simple.cc
+@@ -63,8 +63,8 @@
+   nodes.Create (2);
+ 
+   PointToPointHelper pointToPoint;
+-  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
+-  pointToPoint.SetChannelAttribute ("Delay", StringValue ("100ms"));
++  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("1Gbps"));
++  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ns"));
+ 
+   NetDeviceContainer devices;
+   devices = pointToPoint.Install (nodes);
+diff --git a/example/dce-iperf.cc b/example/dce-iperf.cc
+--- a/example/dce-iperf.cc
++++ b/example/dce-iperf.cc
+@@ -31,6 +31,11 @@
+ //        in source named Thread.c at line 412 in method named thread_rest
+ //        you must add a sleep (1); to break the infinite loop....
+ // ===========================================================================
++void
++PrintTcpFlags (std::string key, std::string value)
++{
++  std::cout << key << "=" << value << std::endl;
++}
+ int main (int argc, char *argv[])
+ {
+   bool useKernel = 0;
+@@ -46,8 +51,8 @@
+   nodes.Create (2);
+ 
+   PointToPointHelper pointToPoint;
+-  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+-  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms"));
++  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("1Gbps"));
++  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ns"));
+ 
+   NetDeviceContainer devices;
+   devices = pointToPoint.Install (nodes);
+@@ -66,6 +71,7 @@
+       dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
+       LinuxStackHelper stack;
+       stack.Install (nodes);
++
+ #else
+       NS_LOG_ERROR ("Linux kernel stack for DCE is not available. build with dce-linux module.");
+       // silently exit
+@@ -88,6 +94,32 @@
+ 
+   dceManager.Install (nodes);
+ 
++  LinuxStackHelper stack;
++#if 0
++      stack.SysctlSet (nodes, ".net.core.rmem_max",
++                       "26214400");
++      stack.SysctlSet (nodes, ".net.core.wmem_max",
++                       "26214400");
++      stack.SysctlSet (nodes, ".net.ipv4.udp_rmem_min",
++                       "4194304");
++      stack.SysctlSet (nodes, ".net.ipv4.udp_wmem_min",
++                       "4194304");
++  LinuxStackHelper::SysctlGet (nodes.Get (0), Seconds (1),
++                               ".net.ipv4.udp_rmem_min", &PrintTcpFlags);
++  LinuxStackHelper::SysctlGet (nodes.Get (0), Seconds (1),
++                               ".net.ipv4.udp_wmem_min", &PrintTcpFlags);
++  LinuxStackHelper::SysctlGet (nodes.Get (0), Seconds (1),
++                               ".net.core.rmem_max", &PrintTcpFlags);
++  LinuxStackHelper::SysctlGet (nodes.Get (0), Seconds (1),
++                               ".net.core.wmem_max", &PrintTcpFlags);
++#endif
++// sysctl -w net.ipv4.tcp_dctcp_enable=1
++// sysctl -w net.ipv4.net.ipv4.tcp_ecn=1
++#if 0
++  stack.SysctlSet (nodes, ".net.ipv4.tcp_dctcp_enable", "1");
++  stack.SysctlSet (nodes, ".net.ipv4.net.ipv4.tcp_ecn", "1");
++#endif
++
+   DceApplicationHelper dce;
+   ApplicationContainer apps;
+ 
+@@ -101,6 +133,10 @@
+   dce.AddArgument ("10.1.1.2");
+   dce.AddArgument ("-i");
+   dce.AddArgument ("1");
++  //  dce.AddArgument ("-l");
++  //  dce.AddArgument ("64");
++  dce.AddArgument ("-w");
++  dce.AddArgument ("100000");
+   dce.AddArgument ("--time");
+   dce.AddArgument ("10");
+   if (useUdp)
+@@ -119,6 +155,10 @@
+   dce.ResetArguments ();
+   dce.ResetEnvironment ();
+   dce.AddArgument ("-s");
++  dce.AddArgument ("-w");
++  dce.AddArgument ("1000000");
++  // dce.AddArgument ("-l");
++  // dce.AddArgument ("64");
+   dce.AddArgument ("-P");
+   dce.AddArgument ("1");
+   if (useUdp)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/poll-rework.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,68 @@
+diff -r 957c0c1b6549 -r 403f06f014ab model/dce-poll.cc
+--- a/model/dce-poll.cc	Mon Oct 15 13:51:29 2012 +0900
++++ b/model/dce-poll.cc	Fri Oct 19 19:07:45 2012 +0900
+@@ -19,7 +19,7 @@
+ {
+   int count = -1;
+   int timed_out = 0;
+-  Time endtime;
++  Time start_time, endtime;
+   // key fd
+   std::map <int, FileUsage*> toUnRef;
+   Thread *current = Current ();
+@@ -30,6 +30,8 @@
+   NS_ASSERT (current != 0);
+   int validFdCount = 0;
+ 
++  start_time = Now ();
++
+   if (0 == timeout)
+     {
+       currentTable = 0;
+@@ -37,7 +39,7 @@
+     }
+   else if (timeout > 0)
+     {
+-      endtime = Now () + MilliSeconds (timeout);
++      endtime = start_time + MilliSeconds (timeout);
+     }
+ 
+   for (uint32_t i = 0; i < nfds; ++i)
+@@ -77,6 +79,10 @@
+                   count++;
+                   currentTable = 0;
+                 }
++              if (mask < 0)
++                {
++                  NS_ASSERT (0);
++                }
+             }
+         }
+       currentTable = 0; // Register only first time.
+@@ -118,7 +124,7 @@
+     }
+ 
+   // Try to break infinite loop in poll with a 0 timeout !
+-  if ( ( 0 == count ) && ( 0 == timeout ) )
++  if (start_time == Now ())
+     {
+       UtilsAdvanceTime (current);
+     }
+diff -r 957c0c1b6549 -r 403f06f014ab model/utils.cc
+--- a/model/utils.cc	Mon Oct 15 13:51:29 2012 +0900
++++ b/model/utils.cc	Fri Oct 19 19:07:45 2012 +0900
+@@ -272,10 +272,10 @@
+ 
+   if (now == current->lastTime)
+     {
+-//      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1ms.");
+-      //current->process->manager->Wait (Time ( MilliSeconds (1) ) );
+-      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1µs.");
+-      current->process->manager->Wait (Time ( MicroSeconds (1) ) );
++      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1ms.");
++      current->process->manager->Wait (Time ( MilliSeconds (4) ) ); // 250HZ?
++//      NS_LOG_DEBUG ("UtilsAdvanceTime current thread wait 1µs.");
++      //      current->process->manager->Wait (Time ( MicroSeconds (1) ) );
+     }
+ 
+   current->lastTime = Now ();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pyscan.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,157 @@
+diff --git a/wscript b/wscript
+--- a/wscript
++++ b/wscript
+@@ -44,6 +44,16 @@
+                    help=('Change the default command template to run programs and unit tests with valgrind'),
+                    action="store_true", default=False,
+                    dest='valgrind')
++    opt.add_option('--apiscan',
++                   help=("Rescan the API for the indicated module(s), for Python bindings.  "
++                         "Needs working GCCXML / pygccxml environment.  "
++                         "The metamodule 'all' expands to all available ns-3 modules."),
++                   default=None, dest='apiscan', metavar="MODULE[,MODULE...]")
++#    opt.add_option('--with-pybindgen',
++#                   help=('Path to an existing pybindgen source tree to use.'),
++#                   default=None,
++#                   dest='with_pybindgen', type="string")
++
+                                   
+ def search_file(files):
+     for f in files:
+@@ -554,6 +564,8 @@
+                 gen.post()
+         bld.env['PRINT_BUILT_MODULES_AT_END'] = False 
+ 
++    wutils.ns3_python_bindings(bld) 
++
+ from waflib import Context, Build
+ class Ns3ShellContext(Context.Context):
+     """run a shell with an environment suitably modified to run locally built programs"""
+diff --git a/wutils.py b/wutils.py
+--- a/wutils.py
++++ b/wutils.py
+@@ -251,4 +251,124 @@
+         execvec.append("--SimulatorImplementationType=ns3::VisualSimulatorImpl")
+     return run_argv([env['PYTHON'][0]] + execvec, env, cwd=cwd)
+ 
++def ns3_python_bindings(bld):
+ 
++    # this method is called from a module wscript, so remember bld.path is not bindings/python!
++    module_abs_src_path = bld.path.abspath()
++    module = os.path.basename(module_abs_src_path)
++    env = bld.env
++    env.append_value("MODULAR_BINDINGS_MODULES", "ns3-"+module)
++
++    if Options.options.apiscan == False:
++        return
++
++    env['ENABLE_PYTHON_BINDINGS'] = True
++    if not env['ENABLE_PYTHON_BINDINGS']:
++        return
++
++    bindings_dir = bld.path.find_dir("bindings")
++    if bindings_dir is None or not os.path.exists(bindings_dir.abspath()):
++        warnings.warn("(in %s) Requested to build modular python bindings, but apidefs dir not found "
++                      "=> skipped the bindings." % str(bld.path),
++                      Warning, stacklevel=2)
++        return
++
++    #if ("ns3-%s" % (module,)) not in env.NS3_ENABLED_MODULES:
++    #    #print "bindings for module %s which is not enabled, skip" % module
++    #    return
++
++    env.append_value('PYTHON_MODULES_BUILT', module)
++    apidefs = env['PYTHON_BINDINGS_APIDEFS'].replace("-", "_")
++
++    #debug = ('PYBINDGEN_DEBUG' in os.environ)
++    debug = True # XXX
++    source = [bld.srcnode.find_resource('bindings/python/ns3modulegen-modular.py').relpath_gen(bld.path),
++              "bindings/modulegen__%s.py" % apidefs]
++
++    if bindings_dir.find_resource("modulegen_customizations.py") is not None:
++        source.append("bindings/modulegen_customizations.py")
++
++    # the local customization file may or not exist
++    if bld.path.find_resource("bindings/modulegen_local.py"):
++        source.append("bindings/modulegen_local.py")
++
++    module_py_name = module.replace('-', '_')
++    module_target_dir = bld.srcnode.find_dir("bindings/python/ns").relpath_gen(bld.path)
++
++    # if bindings/<module>.py exists, it becomes the module frontend, and the C extension befomes _<module>
++    if bld.path.find_resource("bindings/%s.py" % (module_py_name,)) is not None:
++        bld.new_task_gen(
++            features='copy',
++            source=("bindings/%s.py" % (module_py_name,)),
++            target=('%s/%s.py' % (module_target_dir, module_py_name)))
++        extension_name = '_%s' % (module_py_name,)
++        bld.install_files('${PYTHONARCHDIR}/ns', ["bindings/%s.py" % (module_py_name,)])
++    else:
++        extension_name = module_py_name
++
++    target = ['bindings/ns3module.cc', 'bindings/ns3module.h', 'bindings/ns3modulegen.log']
++    #if not debug:
++    #    target.append('ns3modulegen.log')
++
++    argv = ['NS3_ENABLED_FEATURES=${FEATURES}',
++            'GCC_RTTI_ABI_COMPLETE=${GCC_RTTI_ABI_COMPLETE}',
++            '${PYTHON}']
++    #if debug:
++    #    argv.extend(["-m", "pdb"])
++    
++    argv.extend(['${SRC[0]}', module_abs_src_path, apidefs, extension_name, '${TGT[0]}'])
++
++    argv.extend(['2>', '${TGT[2]}']) # 2> ns3modulegen.log
++
++    features = []
++    for (name, caption, was_enabled, reason_not_enabled) in env['NS3_OPTIONAL_FEATURES']:
++        if was_enabled:
++            features.append(name)
++
++    bindgen = bld.new_task_gen(features=['command'], source=source, target=target, command=argv)
++    bindgen.env['FEATURES'] = ','.join(features)
++    bindgen.dep_vars = ['FEATURES', "GCC_RTTI_ABI_COMPLETE"]
++    bindgen.before = 'cxx'
++    bindgen.after = 'gen_ns3_module_header'
++    bindgen.name = "pybindgen(ns3 module %s)" % module
++    bindgen.install_path = None
++
++    # generate the extension module
++    pymod = bld.new_task_gen(features='cxx cxxshlib pyext')
++    pymod.source = ['bindings/ns3module.cc']
++    pymod.target = '%s/%s' % (module_target_dir, extension_name)
++    pymod.name = 'ns3module_%s' % module
++    pymod.use = ["%s" % mod for mod in pymod.env['NS3_ENABLED_MODULES']] #  Should be '"ns3-"+module', but see bug 1117
++    if pymod.env['ENABLE_STATIC_NS3']:
++        if sys.platform == 'darwin':
++            pymod.env.append_value('LINKFLAGS', '-Wl,-all_load')
++            for mod in pymod.usel:
++                #mod = mod.split("--lib")[0]
++                pymod.env.append_value('LINKFLAGS', '-l' + mod)
++        else:
++            pymod.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic')
++            for mod in pymod.use:
++                #mod = mod.split("--lib")[0]
++                pymod.env.append_value('LINKFLAGS', '-l' + mod)
++            pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
++    defines = list(pymod.env['DEFINES'])
++    defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H'])
++    if Options.platform == 'win32':
++        try:
++            defines.remove('_DEBUG') # causes undefined symbols on win32
++        except ValueError:
++            pass
++    pymod.env['DEFINES'] = defines
++    pymod.includes = '# bindings'
++    pymod.install_path = '${PYTHONARCHDIR}/ns'
++
++    # Workaround to a WAF bug, remove this when ns-3 upgrades to WAF > 1.6.10
++    # https://www.nsnam.org/bugzilla/show_bug.cgi?id=1335
++    # http://code.google.com/p/waf/issues/detail?id=1098
++    if Utils.unversioned_sys_platform() == 'darwin':
++        pymod.mac_bundle = True
++
++    return pymod
++
++#    bld.ns3_python_bindings = types.MethodType(ns3_python_bindings, bld)
++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python-binding.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,4120 @@
+diff --git a/bindings/callbacks_list.py b/bindings/callbacks_list.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/callbacks_list.py
+@@ -0,0 +1,1 @@
++callback_classes = [
+diff --git a/bindings/modulegen__gcc_ILP32.py b/bindings/modulegen__gcc_ILP32.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/modulegen__gcc_ILP32.py
+@@ -0,0 +1,33 @@
++from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
++
++
++import pybindgen.settings
++import warnings
++
++class ErrorHandler(pybindgen.settings.ErrorHandler):
++    def handle_error(self, wrapper, exception, traceback_):
++        warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
++        return True
++pybindgen.settings.error_handler = ErrorHandler()
++
++
++import sys
++
++def module_init():
++    root_module = Module('ns.dce_netlink', cpp_namespace='::ns3')
++    return root_module
++
++def register_types(module):
++    root_module = module.get_root()
++    
++    
++    ## Register a nested module for the namespace FatalImpl
++    
++    nested_module = module.add_cpp_namespace('FatalImpl')
++    register_types_ns3_FatalImpl(nested_module)
++    
++
++def register_types_ns3_FatalImpl(module):
++    root_module = module.get_root()
++    
++
+diff --git a/bindings/modulegen__gcc_LP64.py b/bindings/modulegen__gcc_LP64.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/modulegen__gcc_LP64.py
+@@ -0,0 +1,391 @@
++from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
++
++
++import pybindgen.settings
++import warnings
++
++class ErrorHandler(pybindgen.settings.ErrorHandler):
++    def handle_error(self, wrapper, exception, traceback_):
++        warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
++        return True
++pybindgen.settings.error_handler = ErrorHandler()
++
++
++import sys
++
++def module_init():
++    root_module = Module('ns.dce', cpp_namespace='::ns3')
++    return root_module
++
++def register_types(module):
++    root_module = module.get_root()
++    
++    ## dce-application-helper.h (module 'dce'): ns3::DceApplicationHelper [class]
++    module.add_class('DceApplicationHelper', allow_subclassing=True)
++    ## linux-stack-helper.h (module 'dce'): ns3::LinuxStackHelper [class]
++    module.add_class('LinuxStackHelper')
++    ## loader-factory.h (module 'dce'): ns3::Loader [class]
++    module.add_class('Loader', allow_subclassing=True)
++    ## dce-manager-helper.h (module 'dce'): ns3::ProcStatus [class]
++    module.add_class('ProcStatus')
++    ## task-manager.h (module 'dce'): ns3::Sleeper [class]
++    module.add_class('Sleeper')
++    ## task-manager.h (module 'dce'): ns3::Task [class]
++    module.add_class('Task', destructor_visibility='private')
++    ## task-manager.h (module 'dce'): ns3::Task::SwitchType [enumeration]
++    module.add_enum('SwitchType', ['TO', 'FROM'], outer_class=root_module['ns3::Task'])
++    ## ccn-client-helper.h (module 'dce'): ns3::CcnClientHelper [class]
++    module.add_class('CcnClientHelper', parent=root_module['ns3::DceApplicationHelper'])
++    
++    ## Register a nested module for the namespace FatalImpl
++    
++    nested_module = module.add_cpp_namespace('FatalImpl')
++    register_types_ns3_FatalImpl(nested_module)
++    
++
++def register_types_ns3_FatalImpl(module):
++    root_module = module.get_root()
++    
++
++def register_methods(root_module):
++    register_Ns3DceApplicationHelper_methods(root_module, root_module['ns3::DceApplicationHelper'])
++    register_Ns3LinuxStackHelper_methods(root_module, root_module['ns3::LinuxStackHelper'])
++    register_Ns3Loader_methods(root_module, root_module['ns3::Loader'])
++    register_Ns3ProcStatus_methods(root_module, root_module['ns3::ProcStatus'])
++    register_Ns3Sleeper_methods(root_module, root_module['ns3::Sleeper'])
++    register_Ns3Task_methods(root_module, root_module['ns3::Task'])
++    register_Ns3CcnClientHelper_methods(root_module, root_module['ns3::CcnClientHelper'])
++    return
++
++def register_Ns3DceApplicationHelper_methods(root_module, cls):
++    ## dce-application-helper.h (module 'dce'): ns3::DceApplicationHelper::DceApplicationHelper(ns3::DceApplicationHelper const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::DceApplicationHelper const &', 'arg0')])
++    ## dce-application-helper.h (module 'dce'): ns3::DceApplicationHelper::DceApplicationHelper() [constructor]
++    cls.add_constructor([])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArgument(std::string arg) [member function]
++    cls.add_method('AddArgument', 
++                   'void', 
++                   [param('std::string', 'arg')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1, std::string a2) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1'), param('std::string', 'a2')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1, std::string a2, std::string a3) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1'), param('std::string', 'a2'), param('std::string', 'a3')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1, std::string a2, std::string a3, std::string a4) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1'), param('std::string', 'a2'), param('std::string', 'a3'), param('std::string', 'a4')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1, std::string a2, std::string a3, std::string a4, std::string a5) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1'), param('std::string', 'a2'), param('std::string', 'a3'), param('std::string', 'a4'), param('std::string', 'a5')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1, std::string a2, std::string a3, std::string a4, std::string a5, std::string a6) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1'), param('std::string', 'a2'), param('std::string', 'a3'), param('std::string', 'a4'), param('std::string', 'a5'), param('std::string', 'a6')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddArguments(std::string a0, std::string a1, std::string a2, std::string a3, std::string a4, std::string a5, std::string a6, std::string a7) [member function]
++    cls.add_method('AddArguments', 
++                   'void', 
++                   [param('std::string', 'a0'), param('std::string', 'a1'), param('std::string', 'a2'), param('std::string', 'a3'), param('std::string', 'a4'), param('std::string', 'a5'), param('std::string', 'a6'), param('std::string', 'a7')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::AddEnvironment(std::string name, std::string value) [member function]
++    cls.add_method('AddEnvironment', 
++                   'void', 
++                   [param('std::string', 'name'), param('std::string', 'value')])
++    ## dce-application-helper.h (module 'dce'): ns3::ApplicationContainer ns3::DceApplicationHelper::Install(ns3::NodeContainer c) [member function]
++    cls.add_method('Install', 
++                   'ns3::ApplicationContainer', 
++                   [param('ns3::NodeContainer', 'c')], 
++                   is_virtual=True)
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::ParseArguments(std::string args) [member function]
++    cls.add_method('ParseArguments', 
++                   'void', 
++                   [param('std::string', 'args')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::ResetArguments() [member function]
++    cls.add_method('ResetArguments', 
++                   'void', 
++                   [])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::ResetEnvironment() [member function]
++    cls.add_method('ResetEnvironment', 
++                   'void', 
++                   [])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetBinary(std::string filename) [member function]
++    cls.add_method('SetBinary', 
++                   'void', 
++                   [param('std::string', 'filename')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetEgid(uid_t i) [member function]
++    cls.add_method('SetEgid', 
++                   'void', 
++                   [param('uid_t', 'i')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetEuid(uid_t i) [member function]
++    cls.add_method('SetEuid', 
++                   'void', 
++                   [param('uid_t', 'i')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetFinishedCallback(ns3::Callback<void, unsigned short, int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> cb) [member function]
++    cls.add_method('SetFinishedCallback', 
++                   'void', 
++                   [param('ns3::Callback< void, unsigned short, int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'cb')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetGid(uid_t i) [member function]
++    cls.add_method('SetGid', 
++                   'void', 
++                   [param('uid_t', 'i')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetStackSize(uint32_t stackSize) [member function]
++    cls.add_method('SetStackSize', 
++                   'void', 
++                   [param('uint32_t', 'stackSize')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetStdinFile(std::string filename) [member function]
++    cls.add_method('SetStdinFile', 
++                   'void', 
++                   [param('std::string', 'filename')])
++    ## dce-application-helper.h (module 'dce'): void ns3::DceApplicationHelper::SetUid(uid_t i) [member function]
++    cls.add_method('SetUid', 
++                   'void', 
++                   [param('uid_t', 'i')])
++    return
++
++def register_Ns3LinuxStackHelper_methods(root_module, cls):
++    ## linux-stack-helper.h (module 'dce'): ns3::LinuxStackHelper::LinuxStackHelper() [constructor]
++    cls.add_constructor([])
++    ## linux-stack-helper.h (module 'dce'): ns3::LinuxStackHelper::LinuxStackHelper(ns3::LinuxStackHelper const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::LinuxStackHelper const &', 'arg0')])
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::Install(std::string nodeName) [member function]
++    cls.add_method('Install', 
++                   'void', 
++                   [param('std::string', 'nodeName')], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::Install(ns3::Ptr<ns3::Node> node) [member function]
++    cls.add_method('Install', 
++                   'void', 
++                   [param('ns3::Ptr< ns3::Node >', 'node')], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::Install(ns3::NodeContainer c) [member function]
++    cls.add_method('Install', 
++                   'void', 
++                   [param('ns3::NodeContainer', 'c')], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::InstallAll() [member function]
++    cls.add_method('InstallAll', 
++                   'void', 
++                   [], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::PopulateRoutingTables() [member function]
++    cls.add_method('PopulateRoutingTables', 
++                   'void', 
++                   [], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::RunIp(ns3::Ptr<ns3::Node> node, ns3::Time at, std::string str) [member function]
++    cls.add_method('RunIp', 
++                   'void', 
++                   [param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Time', 'at'), param('std::string', 'str')], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): static void ns3::LinuxStackHelper::SysctlGet(ns3::Ptr<ns3::Node> node, ns3::Time at, std::string path, void (*)( ::std::string,::std::string ) * callback) [member function]
++    cls.add_method('SysctlGet', 
++                   'void', 
++                   [param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Time', 'at'), param('std::string', 'path'), param('void ( * ) ( std::string, std::string ) *', 'callback')], 
++                   is_static=True)
++    ## linux-stack-helper.h (module 'dce'): void ns3::LinuxStackHelper::SysctlSet(ns3::NodeContainer c, std::string path, std::string value) [member function]
++    cls.add_method('SysctlSet', 
++                   'void', 
++                   [param('ns3::NodeContainer', 'c'), param('std::string', 'path'), param('std::string', 'value')])
++    return
++
++def register_Ns3Loader_methods(root_module, cls):
++    ## loader-factory.h (module 'dce'): ns3::Loader::Loader() [constructor]
++    cls.add_constructor([])
++    ## loader-factory.h (module 'dce'): ns3::Loader::Loader(ns3::Loader const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::Loader const &', 'arg0')])
++    ## loader-factory.h (module 'dce'): ns3::Loader * ns3::Loader::Clone() [member function]
++    cls.add_method('Clone', 
++                   'ns3::Loader *', 
++                   [], 
++                   is_pure_virtual=True, is_virtual=True)
++    ## loader-factory.h (module 'dce'): void * ns3::Loader::Load(std::string filename, int flag) [member function]
++    cls.add_method('Load', 
++                   'void *', 
++                   [param('std::string', 'filename'), param('int', 'flag')], 
++                   is_pure_virtual=True, is_virtual=True)
++    ## loader-factory.h (module 'dce'): void * ns3::Loader::Lookup(void * module, std::string symbol) [member function]
++    cls.add_method('Lookup', 
++                   'void *', 
++                   [param('void *', 'module'), param('std::string', 'symbol')], 
++                   is_pure_virtual=True, is_virtual=True)
++    ## loader-factory.h (module 'dce'): void ns3::Loader::NotifyEndExecute() [member function]
++    cls.add_method('NotifyEndExecute', 
++                   'void', 
++                   [], 
++                   is_virtual=True)
++    ## loader-factory.h (module 'dce'): void ns3::Loader::NotifyStartExecute() [member function]
++    cls.add_method('NotifyStartExecute', 
++                   'void', 
++                   [], 
++                   is_virtual=True)
++    ## loader-factory.h (module 'dce'): void ns3::Loader::Unload(void * module) [member function]
++    cls.add_method('Unload', 
++                   'void', 
++                   [param('void *', 'module')], 
++                   is_pure_virtual=True, is_virtual=True)
++    ## loader-factory.h (module 'dce'): void ns3::Loader::UnloadAll() [member function]
++    cls.add_method('UnloadAll', 
++                   'void', 
++                   [], 
++                   is_pure_virtual=True, is_virtual=True)
++    return
++
++def register_Ns3ProcStatus_methods(root_module, cls):
++    ## dce-manager-helper.h (module 'dce'): ns3::ProcStatus::ProcStatus(ns3::ProcStatus const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::ProcStatus const &', 'arg0')])
++    ## dce-manager-helper.h (module 'dce'): ns3::ProcStatus::ProcStatus(int n, int e, int p, int64_t ns, int64_t ne, long int rs, long int re, double nd, long int rd, std::string cmd) [constructor]
++    cls.add_constructor([param('int', 'n'), param('int', 'e'), param('int', 'p'), param('int64_t', 'ns'), param('int64_t', 'ne'), param('long int', 'rs'), param('long int', 're'), param('double', 'nd'), param('long int', 'rd'), param('std::string', 'cmd')])
++    ## dce-manager-helper.h (module 'dce'): std::string ns3::ProcStatus::GetCmdLine() const [member function]
++    cls.add_method('GetCmdLine', 
++                   'std::string', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): int ns3::ProcStatus::GetExitCode() const [member function]
++    cls.add_method('GetExitCode', 
++                   'int', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): int ns3::ProcStatus::GetNode() const [member function]
++    cls.add_method('GetNode', 
++                   'int', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): int ns3::ProcStatus::GetPid() const [member function]
++    cls.add_method('GetPid', 
++                   'int', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): long int ns3::ProcStatus::GetRealDuration() const [member function]
++    cls.add_method('GetRealDuration', 
++                   'long int', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): long int ns3::ProcStatus::GetRealEndTime() const [member function]
++    cls.add_method('GetRealEndTime', 
++                   'long int', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): long int ns3::ProcStatus::GetRealStartTime() const [member function]
++    cls.add_method('GetRealStartTime', 
++                   'long int', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): double ns3::ProcStatus::GetSimulatedDuration() const [member function]
++    cls.add_method('GetSimulatedDuration', 
++                   'double', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): int64_t ns3::ProcStatus::GetSimulatedEndTime() const [member function]
++    cls.add_method('GetSimulatedEndTime', 
++                   'int64_t', 
++                   [], 
++                   is_const=True)
++    ## dce-manager-helper.h (module 'dce'): int64_t ns3::ProcStatus::GetSimulatedStartTime() const [member function]
++    cls.add_method('GetSimulatedStartTime', 
++                   'int64_t', 
++                   [], 
++                   is_const=True)
++    return
++
++def register_Ns3Sleeper_methods(root_module, cls):
++    ## task-manager.h (module 'dce'): ns3::Sleeper::m_task [variable]
++    cls.add_instance_attribute('m_task', 'ns3::Task * const', is_const=True)
++    ## task-manager.h (module 'dce'): ns3::Sleeper::m_timeout [variable]
++    cls.add_instance_attribute('m_timeout', 'ns3::Time const', is_const=True)
++    ## task-manager.h (module 'dce'): ns3::Sleeper::Sleeper(ns3::Sleeper const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::Sleeper const &', 'arg0')])
++    ## task-manager.h (module 'dce'): ns3::Sleeper::Sleeper(ns3::Task * t, ns3::Time to) [constructor]
++    cls.add_constructor([param('ns3::Task *', 't'), param('ns3::Time', 'to')])
++    return
++
++def register_Ns3Task_methods(root_module, cls):
++    ## task-manager.h (module 'dce'): ns3::Task::Task() [constructor]
++    cls.add_constructor([])
++    ## task-manager.h (module 'dce'): ns3::Task::Task(ns3::Task const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::Task const &', 'arg0')])
++    ## task-manager.h (module 'dce'): void * ns3::Task::GetContext() const [member function]
++    cls.add_method('GetContext', 
++                   'void *', 
++                   [], 
++                   is_const=True)
++    ## task-manager.h (module 'dce'): void * ns3::Task::GetExtraContext() const [member function]
++    cls.add_method('GetExtraContext', 
++                   'void *', 
++                   [], 
++                   is_const=True)
++    ## task-manager.h (module 'dce'): bool ns3::Task::IsActive() const [member function]
++    cls.add_method('IsActive', 
++                   'bool', 
++                   [], 
++                   is_const=True)
++    ## task-manager.h (module 'dce'): bool ns3::Task::IsBlocked() const [member function]
++    cls.add_method('IsBlocked', 
++                   'bool', 
++                   [], 
++                   is_const=True)
++    ## task-manager.h (module 'dce'): bool ns3::Task::IsDead() const [member function]
++    cls.add_method('IsDead', 
++                   'bool', 
++                   [], 
++                   is_const=True)
++    ## task-manager.h (module 'dce'): bool ns3::Task::IsRunning() const [member function]
++    cls.add_method('IsRunning', 
++                   'bool', 
++                   [], 
++                   is_const=True)
++    ## task-manager.h (module 'dce'): void ns3::Task::SetContext(void * ctx) [member function]
++    cls.add_method('SetContext', 
++                   'void', 
++                   [param('void *', 'ctx')])
++    ## task-manager.h (module 'dce'): void ns3::Task::SetExtraContext(void * ctx) [member function]
++    cls.add_method('SetExtraContext', 
++                   'void', 
++                   [param('void *', 'ctx')])
++    ## task-manager.h (module 'dce'): void ns3::Task::SetSwitchNotifier(void (*)( ::ns3::Task::SwitchType,void * ) * fn, void * context) [member function]
++    cls.add_method('SetSwitchNotifier', 
++                   'void', 
++                   [param('void ( * ) ( ns3::Task::SwitchType, void * ) *', 'fn'), param('void *', 'context')])
++    return
++
++def register_Ns3CcnClientHelper_methods(root_module, cls):
++    ## ccn-client-helper.h (module 'dce'): ns3::CcnClientHelper::CcnClientHelper(ns3::CcnClientHelper const & arg0) [copy constructor]
++    cls.add_constructor([param('ns3::CcnClientHelper const &', 'arg0')])
++    ## ccn-client-helper.h (module 'dce'): ns3::CcnClientHelper::CcnClientHelper() [constructor]
++    cls.add_constructor([])
++    ## ccn-client-helper.h (module 'dce'): void ns3::CcnClientHelper::AddFile(std::string from, std::string to) [member function]
++    cls.add_method('AddFile', 
++                   'void', 
++                   [param('std::string', 'from'), param('std::string', 'to')])
++    ## ccn-client-helper.h (module 'dce'): ns3::ApplicationContainer ns3::CcnClientHelper::Install(ns3::NodeContainer c) [member function]
++    cls.add_method('Install', 
++                   'ns3::ApplicationContainer', 
++                   [param('ns3::NodeContainer', 'c')], 
++                   is_virtual=True)
++    return
++
++def register_functions(root_module):
++    module = root_module
++    register_functions_ns3_FatalImpl(module.get_submodule('FatalImpl'), root_module)
++    return
++
++def register_functions_ns3_FatalImpl(module, root_module):
++    return
++
++def main():
++    out = FileCodeSink(sys.stdout)
++    root_module = module_init()
++    register_types(root_module)
++    register_methods(root_module)
++    register_functions(root_module)
++    root_module.generate(out)
++
++if __name__ == '__main__':
++    main()
++
+diff --git a/bindings/ns/_placeholder_ b/bindings/ns/_placeholder_
+new file mode 100644
+diff --git a/bindings/ns3modulegen-modular.py b/bindings/ns3modulegen-modular.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/ns3modulegen-modular.py
+@@ -0,0 +1,132 @@
++import warnings
++import sys
++import os
++import pybindgen.settings
++from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
++from pybindgen.module import MultiSectionFactory
++import ns3modulegen_core_customizations
++
++pybindgen.settings.wrapper_registry = pybindgen.settings.StdMapWrapperRegistry
++
++import traceback
++
++class ErrorHandler(pybindgen.settings.ErrorHandler):
++
++    def __init__(self, apidefs_file):
++        self.apidefs_file = apidefs_file
++
++    def handle_error(self, wrapper, exception, traceback_):
++        stack = getattr(wrapper, 'stack_where_defined', [])
++        stack.reverse()
++        for l in stack:
++            if l[0] == self.apidefs_file:
++                warnings.warn_explicit("exception %r in wrapper %s" % (exception, wrapper),
++                                       Warning, l[0], l[1])
++                break
++        else:
++            warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
++        return True
++
++
++#print >> sys.stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>> ", bool(eval(os.environ["GCC_RTTI_ABI_COMPLETE"]))
++pybindgen.settings.gcc_rtti_abi_complete = bool(eval(os.environ["GCC_RTTI_ABI_COMPLETE"]))
++
++class MyMultiSectionFactory(MultiSectionFactory):
++    def __init__(self, main_file_name):
++        super(MyMultiSectionFactory, self).__init__()
++        self.main_file_name = main_file_name
++        self.main_sink = FileCodeSink(open(main_file_name, "wt"))
++        self.header_name = "ns3module.h"
++        header_file_name = os.path.join(os.path.dirname(self.main_file_name), self.header_name)
++        #print >> sys.stderr, ">>>>>>>>>>>>>>>>>", header_file_name, main_file_name
++        self.header_sink = FileCodeSink(open(header_file_name, "wt"))
++    def get_section_code_sink(self, section_name):
++        return self.main_sink
++    def get_main_code_sink(self):
++        return self.main_sink
++    def get_common_header_code_sink(self):
++        return self.header_sink
++    def get_common_header_include(self):
++        return '"%s"' % self.header_name
++    def close(self):
++        self.header_sink.file.close()
++        self.main_sink.file.close()
++
++
++
++def main(argv):
++    module_abs_src_path, target, extension_name, output_cc_file_name = argv[1:]
++    if module_abs_src_path.endswith('build'):
++        module_name = extension_name
++    else:
++        module_name = os.path.basename(module_abs_src_path).replace('ns-3-','')
++    print module_name
++    print extension_name
++    out = MyMultiSectionFactory(output_cc_file_name)
++
++    sys.path.insert(0, os.path.join(module_abs_src_path, "bindings"))
++    try:
++        module_apidefs = __import__("modulegen__%s" % target)
++        del sys.modules["modulegen__%s" % target]
++        try:
++            module_customization = __import__("modulegen_customizations")
++            del sys.modules["modulegen_customizations"]
++        except ImportError:
++            module_customization = object()
++
++        try:
++            from callbacks_list import callback_classes
++        except ImportError, ex:
++            print >> sys.stderr, "***************", repr(ex)
++            callback_classes = []
++        else:
++            print >> sys.stderr, ">>>>>>>>>>>>>>>>", repr(callback_classes)
++
++    finally:
++        sys.path.pop(0)
++
++    apidefs_file, dummy = os.path.splitext(module_apidefs.__file__)
++    apidefs_file += '.py'
++    pybindgen.settings.error_handler = ErrorHandler(apidefs_file)
++
++    root_module = module_apidefs.module_init()
++    root_module.set_name(extension_name)
++    root_module.add_include('"ns3/%s-module.h"' % module_name)
++
++    ns3modulegen_core_customizations.add_std_ios_openmode(root_module)
++
++    # -----------
++    module_apidefs.register_types(root_module)
++
++    if hasattr(module_customization, 'post_register_types'):
++        module_customization.post_register_types(root_module)
++
++    # register Callback<...> type handlers
++    ns3modulegen_core_customizations.generate_callback_classes(root_module.after_forward_declarations,
++                                                               callback_classes)
++
++    # -----------
++    module_apidefs.register_methods(root_module)
++
++    if hasattr(module_customization, 'post_register_methods'):
++        module_customization.post_register_methods(root_module)
++
++    ns3modulegen_core_customizations.Object_customizations(root_module)
++    ns3modulegen_core_customizations.Attribute_customizations(root_module)
++
++
++    # -----------
++    module_apidefs.register_functions(root_module)
++    
++    if hasattr(module_customization, 'post_register_functions'):
++        module_customization.post_register_functions(root_module)
++
++
++    # -----------
++    root_module.generate(out)
++
++if __name__ == '__main__':
++    import sys
++    main(sys.argv)
++
++    
+diff --git a/bindings/ns3modulegen_core_customizations.pyc b/bindings/ns3modulegen_core_customizations.pyc
+new file mode 100644
+index 0000000000000000000000000000000000000000..ce57d2480927177d87cce5535d01e7b1eb9f3422
+GIT binary patch
+literal 18612
+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
+
+diff --git a/bindings/ns3modulescan-modular.py b/bindings/ns3modulescan-modular.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/ns3modulescan-modular.py
+@@ -0,0 +1,281 @@
++#! /usr/bin/env python
++
++import sys
++import os.path
++
++import pybindgen.settings
++from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection, WrapperWarning, find_declaration_from_name
++from pybindgen.typehandlers.codesink import FileCodeSink
++from pygccxml.declarations import templates
++from pygccxml.declarations.enumeration import enumeration_t
++from pygccxml.declarations.class_declaration import class_t
++from pygccxml.declarations.calldef import free_function_t, member_function_t, constructor_t, calldef_t
++
++
++## we need the smart pointer type transformation to be active even
++## during gccxml scanning.
++import ns3modulegen_core_customizations
++
++
++## silence gccxmlparser errors; we only want error handling in the
++## generated python script, not while scanning.
++class ErrorHandler(pybindgen.settings.ErrorHandler):
++    def handle_error(self, dummy_wrapper, dummy_exception, dummy_traceback_):
++        return True
++pybindgen.settings.error_handler = ErrorHandler()
++import warnings
++warnings.filterwarnings(category=WrapperWarning, action='ignore')
++
++
++import ns3modulescan
++type_annotations = ns3modulescan.type_annotations
++
++
++def get_ns3_relative_path(path):
++    l = []
++    head = path
++    while head:
++        new_head, tail = os.path.split(head)
++        if new_head == head:
++            raise ValueError
++        head = new_head
++        if tail == 'ns3':
++            return os.path.join(*l)
++        l.insert(0, tail)
++    raise AssertionError("is the path %r inside ns3?!" % path)
++
++class PreScanHook:
++
++    def __init__(self, headers_map, module):
++        self.headers_map = headers_map
++        self.module = module
++
++    def __call__(self, module_parser,
++                 pygccxml_definition,
++                 global_annotations,
++                 parameter_annotations):
++        try:
++            ns3_header = get_ns3_relative_path(pygccxml_definition.location.file_name)
++        except ValueError: # the header is not from ns3
++            return # ignore the definition, it's not ns-3 def.
++
++        definition_module = self.headers_map[ns3_header]
++
++        ## Note: we don't include line numbers in the comments because
++        ## those numbers are very likely to change frequently, which would
++        ## cause needless changes, since the generated python files are
++        ## kept under version control.
++
++        #global_annotations['pygen_comment'] = "%s:%i: %s" % \
++        #    (ns3_header, pygccxml_definition.location.line, pygccxml_definition)
++        global_annotations['pygen_comment'] = "%s (module %r): %s" % \
++            (ns3_header, definition_module, pygccxml_definition)
++
++
++        ## handle ns3::Object::GetObject (left to its own devices,
++        ## pybindgen will generate a mangled name containing the template
++        ## argument type name).
++        if isinstance(pygccxml_definition, member_function_t) \
++                and pygccxml_definition.parent.name == 'Object' \
++                and pygccxml_definition.name == 'GetObject':
++            template_args = templates.args(pygccxml_definition.demangled_name)
++            if template_args == ['ns3::Object']:
++                global_annotations['template_instance_names'] = 'ns3::Object=>GetObject'
++
++        ## Don't wrap Simulator::Schedule* (manually wrapped)
++        if isinstance(pygccxml_definition, member_function_t) \
++                and pygccxml_definition.parent.name == 'Simulator' \
++                and pygccxml_definition.name.startswith('Schedule'):
++            global_annotations['ignore'] = None
++
++        # manually wrapped
++        if isinstance(pygccxml_definition, member_function_t) \
++                and pygccxml_definition.parent.name == 'Simulator' \
++                and pygccxml_definition.name == 'Run':
++            global_annotations['ignore'] = True
++
++        ## http://www.gccxml.org/Bug/view.php?id=9915
++        if isinstance(pygccxml_definition, calldef_t):
++            for arg in pygccxml_definition.arguments:
++                if arg.default_value is None:
++                    continue
++                elif arg.default_value == "ns3::MilliSeconds( )":
++                    arg.default_value = "ns3::MilliSeconds(0)"
++                elif arg.default_value == "ns3::Seconds( )":
++                    arg.default_value = "ns3::Seconds(0)"
++
++        ## classes
++        if isinstance(pygccxml_definition, class_t):
++            print >> sys.stderr, pygccxml_definition
++            # no need for helper classes to allow subclassing in Python, I think...
++            #if pygccxml_definition.name.endswith('Helper'):
++            #    global_annotations['allow_subclassing'] = 'false'
++
++            #
++            # If a class is template instantiation, even if the
++            # template was defined in some other module, if a template
++            # argument belongs to this module then the template
++            # instantiation will belong to this module.
++            # 
++            if templates.is_instantiation(pygccxml_definition.decl_string):
++                cls_name, template_parameters = templates.split(pygccxml_definition.name)
++                template_parameters_decls = [find_declaration_from_name(module_parser.global_ns, templ_param)
++                                             for templ_param in template_parameters]
++                #print >> sys.stderr, "********************", cls_name, repr(template_parameters_decls)
++                
++                template_parameters_modules = []
++                for templ in template_parameters_decls:
++                    if not hasattr(templ, 'location'):
++                        continue
++                    try:
++                        h = get_ns3_relative_path(templ.location.file_name)
++                    except ValueError:
++                        continue
++                    template_parameters_modules.append(self.headers_map[h])
++
++                for templ_mod in template_parameters_modules:
++                    if templ_mod == self.module:
++                        definition_module = templ_mod
++                        break
++                #print >> sys.stderr, "********************", cls_name, repr(template_parameters_modules)
++
++
++            if definition_module != self.module:
++                global_annotations['import_from_module'] = 'ns.%s' % (definition_module.replace('-', '_'),)
++
++            if pygccxml_definition.decl_string.startswith('::ns3::SimpleRefCount<'):
++                global_annotations['incref_method'] = 'Ref'
++                global_annotations['decref_method'] = 'Unref'
++                global_annotations['peekref_method'] = 'GetReferenceCount'
++                global_annotations['automatic_type_narrowing'] = 'true'
++                return
++
++            if pygccxml_definition.decl_string.startswith('::ns3::Callback<'):
++                # manually handled in ns3modulegen_core_customizations.py
++                global_annotations['ignore'] = None
++                return
++
++            if pygccxml_definition.decl_string.startswith('::ns3::TracedCallback<'):
++                global_annotations['ignore'] = None
++                return
++
++            if pygccxml_definition.decl_string.startswith('::ns3::Ptr<'):
++                # handled by pybindgen "type transformation"
++                global_annotations['ignore'] = None
++                return
++
++            # table driven class customization
++            try:
++                annotations = type_annotations[pygccxml_definition.decl_string]
++            except KeyError:
++                pass
++            else:
++                global_annotations.update(annotations)
++
++        ## enums
++        if isinstance(pygccxml_definition, enumeration_t):
++            if definition_module != self.module:
++                global_annotations['import_from_module'] = 'ns.%s' % definition_module
++
++        ## free functions
++        if isinstance(pygccxml_definition, free_function_t):
++
++            if definition_module != self.module:
++                global_annotations['ignore'] = None
++                return
++
++            if pygccxml_definition.name == 'PeekPointer':
++                global_annotations['ignore'] = None
++                return
++
++        ## table driven methods/constructors/functions customization
++        if isinstance(pygccxml_definition, (free_function_t, member_function_t, constructor_t)):
++            try:
++                annotations = type_annotations[str(pygccxml_definition)]
++            except KeyError:
++                pass
++            else:
++                for key,value in annotations.items():
++                    if key == 'params':
++                        parameter_annotations.update (value)
++                        del annotations['params']
++                global_annotations.update(annotations)
++
++
++# def post_scan_hook(dummy_module_parser, dummy_pygccxml_definition, pybindgen_wrapper):
++#     ## classes
++#     if isinstance(pybindgen_wrapper, CppClass):
++#         if pybindgen_wrapper.name.endswith('Checker'):
++#             print >> sys.stderr, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", pybindgen_wrapper
++#             #pybindgen_wrapper.set_instance_creation_function(AttributeChecker_instance_creation_function)
++
++
++def scan_callback_classes(module_parser, callback_classes_file):
++    callback_classes_file.write("callback_classes = [\n")
++    for cls in module_parser.module_namespace.classes(function=module_parser.location_filter,
++                                                      recursive=False):
++        if not cls.name.startswith("Callback<"):
++            continue
++        assert templates.is_instantiation(cls.decl_string), "%s is not a template instantiation" % cls
++        dummy_cls_name, template_parameters = templates.split(cls.decl_string)
++        callback_classes_file.write("    %r,\n" % template_parameters)
++    callback_classes_file.write("]\n")
++
++
++def ns3_module_scan(top_builddir, module_name, headers_map, output_file_name, cflags):
++    module_parser = ModuleParser('ns.%s' % module_name.replace('-', '_'), 'ns3')
++    module_parser.add_pre_scan_hook(PreScanHook(headers_map, module_name))
++    #module_parser.add_post_scan_hook(post_scan_hook)
++
++    gccxml_options = dict(
++        include_paths=[top_builddir],
++         define_symbols={
++            #'NS3_ASSERT_ENABLE': None,
++            #'NS3_LOG_ENABLE': None,
++            },
++        cflags=('--gccxml-cxxflags "%s -DPYTHON_SCAN"' % cflags)
++        )
++
++    try:
++        os.unlink(output_file_name)
++    except OSError:
++        pass
++    try:
++        os.makedirs(os.path.dirname(output_file_name))
++    except OSError:
++        pass
++    output_file = open(output_file_name, "wt")
++    output_sink = FileCodeSink(output_file)
++
++    # if there exists a scan-header.h file in src/<module>/bindings,
++    # scan it, otherwise scan ns3/xxxx-module.h.
++    scan_header = os.path.join(os.path.dirname(output_file_name), "scan-header.h")
++    if not os.path.exists(scan_header):
++        scan_header = os.path.join(top_builddir, "ns3", "%s-module.h" % module_name)
++
++    module_parser.parse_init([scan_header],
++                             None, whitelist_paths=[top_builddir],
++                             #includes=['"ns3/everything.h"'],
++                             pygen_sink=output_sink,
++                             gccxml_options=gccxml_options)
++    module_parser.scan_types()
++
++    callback_classes_file = open(os.path.join(os.path.dirname(output_file_name), "callbacks_list.py"), "wt")
++    scan_callback_classes(module_parser, callback_classes_file)
++    callback_classes_file.close()
++
++
++    module_parser.scan_methods()
++    module_parser.scan_functions()
++    module_parser.parse_finalize()
++
++    output_file.close()
++    os.chmod(output_file_name, 0400)
++
++
++if __name__ == '__main__':
++    if len(sys.argv) != 6:
++        print "ns3modulescan-modular.py top_builddir module_path module_headers output_file_name cflags"
++        sys.exit(1)
++    ns3_module_scan(sys.argv[1], sys.argv[2], eval(sys.argv[3]), sys.argv[4], sys.argv[5])
++    sys.exit(0)
+diff --git a/bindings/ns3modulescan-modular.py~ b/bindings/ns3modulescan-modular.py~
+new file mode 100644
+--- /dev/null
++++ b/bindings/ns3modulescan-modular.py~
+@@ -0,0 +1,282 @@
++#! /usr/bin/env python
++
++import sys
++import os.path
++
++import pybindgen.settings
++from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection, WrapperWarning, find_declaration_from_name
++from pybindgen.typehandlers.codesink import FileCodeSink
++from pygccxml.declarations import templates
++from pygccxml.declarations.enumeration import enumeration_t
++from pygccxml.declarations.class_declaration import class_t
++from pygccxml.declarations.calldef import free_function_t, member_function_t, constructor_t, calldef_t
++
++
++## we need the smart pointer type transformation to be active even
++## during gccxml scanning.
++import ns3modulegen_core_customizations
++
++
++## silence gccxmlparser errors; we only want error handling in the
++## generated python script, not while scanning.
++class ErrorHandler(pybindgen.settings.ErrorHandler):
++    def handle_error(self, dummy_wrapper, dummy_exception, dummy_traceback_):
++        return True
++pybindgen.settings.error_handler = ErrorHandler()
++import warnings
++warnings.filterwarnings(category=WrapperWarning, action='ignore')
++
++
++import ns3modulescan
++type_annotations = ns3modulescan.type_annotations
++
++
++def get_ns3_relative_path(path):
++    l = []
++    head = path
++    while head:
++        new_head, tail = os.path.split(head)
++        if new_head == head:
++            raise ValueError
++        head = new_head
++        if tail == 'ns3':
++            return os.path.join(*l)
++        l.insert(0, tail)
++    raise AssertionError("is the path %r inside ns3?!" % path)
++
++class PreScanHook:
++
++    def __init__(self, headers_map, module):
++        self.headers_map = headers_map
++        self.module = module
++
++    def __call__(self, module_parser,
++                 pygccxml_definition,
++                 global_annotations,
++                 parameter_annotations):
++	print "==="% pygccxml_definition
++        try:
++            ns3_header = get_ns3_relative_path(pygccxml_definition.location.file_name)
++        except ValueError: # the header is not from ns3
++            return # ignore the definition, it's not ns-3 def.
++
++        definition_module = self.headers_map[ns3_header]
++
++        ## Note: we don't include line numbers in the comments because
++        ## those numbers are very likely to change frequently, which would
++        ## cause needless changes, since the generated python files are
++        ## kept under version control.
++
++        #global_annotations['pygen_comment'] = "%s:%i: %s" % \
++        #    (ns3_header, pygccxml_definition.location.line, pygccxml_definition)
++        global_annotations['pygen_comment'] = "%s (module %r): %s" % \
++            (ns3_header, definition_module, pygccxml_definition)
++
++
++        ## handle ns3::Object::GetObject (left to its own devices,
++        ## pybindgen will generate a mangled name containing the template
++        ## argument type name).
++        if isinstance(pygccxml_definition, member_function_t) \
++                and pygccxml_definition.parent.name == 'Object' \
++                and pygccxml_definition.name == 'GetObject':
++            template_args = templates.args(pygccxml_definition.demangled_name)
++            if template_args == ['ns3::Object']:
++                global_annotations['template_instance_names'] = 'ns3::Object=>GetObject'
++
++        ## Don't wrap Simulator::Schedule* (manually wrapped)
++        if isinstance(pygccxml_definition, member_function_t) \
++                and pygccxml_definition.parent.name == 'Simulator' \
++                and pygccxml_definition.name.startswith('Schedule'):
++            global_annotations['ignore'] = None
++
++        # manually wrapped
++        if isinstance(pygccxml_definition, member_function_t) \
++                and pygccxml_definition.parent.name == 'Simulator' \
++                and pygccxml_definition.name == 'Run':
++            global_annotations['ignore'] = True
++
++        ## http://www.gccxml.org/Bug/view.php?id=9915
++        if isinstance(pygccxml_definition, calldef_t):
++            for arg in pygccxml_definition.arguments:
++                if arg.default_value is None:
++                    continue
++                elif arg.default_value == "ns3::MilliSeconds( )":
++                    arg.default_value = "ns3::MilliSeconds(0)"
++                elif arg.default_value == "ns3::Seconds( )":
++                    arg.default_value = "ns3::Seconds(0)"
++
++        ## classes
++        if isinstance(pygccxml_definition, class_t):
++            print >> sys.stderr, pygccxml_definition
++            # no need for helper classes to allow subclassing in Python, I think...
++            #if pygccxml_definition.name.endswith('Helper'):
++            #    global_annotations['allow_subclassing'] = 'false'
++
++            #
++            # If a class is template instantiation, even if the
++            # template was defined in some other module, if a template
++            # argument belongs to this module then the template
++            # instantiation will belong to this module.
++            # 
++            if templates.is_instantiation(pygccxml_definition.decl_string):
++                cls_name, template_parameters = templates.split(pygccxml_definition.name)
++                template_parameters_decls = [find_declaration_from_name(module_parser.global_ns, templ_param)
++                                             for templ_param in template_parameters]
++                #print >> sys.stderr, "********************", cls_name, repr(template_parameters_decls)
++                
++                template_parameters_modules = []
++                for templ in template_parameters_decls:
++                    if not hasattr(templ, 'location'):
++                        continue
++                    try:
++                        h = get_ns3_relative_path(templ.location.file_name)
++                    except ValueError:
++                        continue
++                    template_parameters_modules.append(self.headers_map[h])
++
++                for templ_mod in template_parameters_modules:
++                    if templ_mod == self.module:
++                        definition_module = templ_mod
++                        break
++                #print >> sys.stderr, "********************", cls_name, repr(template_parameters_modules)
++
++
++            if definition_module != self.module:
++                global_annotations['import_from_module'] = 'ns.%s' % (definition_module.replace('-', '_'),)
++
++            if pygccxml_definition.decl_string.startswith('::ns3::SimpleRefCount<'):
++                global_annotations['incref_method'] = 'Ref'
++                global_annotations['decref_method'] = 'Unref'
++                global_annotations['peekref_method'] = 'GetReferenceCount'
++                global_annotations['automatic_type_narrowing'] = 'true'
++                return
++
++            if pygccxml_definition.decl_string.startswith('::ns3::Callback<'):
++                # manually handled in ns3modulegen_core_customizations.py
++                global_annotations['ignore'] = None
++                return
++
++            if pygccxml_definition.decl_string.startswith('::ns3::TracedCallback<'):
++                global_annotations['ignore'] = None
++                return
++
++            if pygccxml_definition.decl_string.startswith('::ns3::Ptr<'):
++                # handled by pybindgen "type transformation"
++                global_annotations['ignore'] = None
++                return
++
++            # table driven class customization
++            try:
++                annotations = type_annotations[pygccxml_definition.decl_string]
++            except KeyError:
++                pass
++            else:
++                global_annotations.update(annotations)
++
++        ## enums
++        if isinstance(pygccxml_definition, enumeration_t):
++            if definition_module != self.module:
++                global_annotations['import_from_module'] = 'ns.%s' % definition_module
++
++        ## free functions
++        if isinstance(pygccxml_definition, free_function_t):
++
++            if definition_module != self.module:
++                global_annotations['ignore'] = None
++                return
++
++            if pygccxml_definition.name == 'PeekPointer':
++                global_annotations['ignore'] = None
++                return
++
++        ## table driven methods/constructors/functions customization
++        if isinstance(pygccxml_definition, (free_function_t, member_function_t, constructor_t)):
++            try:
++                annotations = type_annotations[str(pygccxml_definition)]
++            except KeyError:
++                pass
++            else:
++                for key,value in annotations.items():
++                    if key == 'params':
++                        parameter_annotations.update (value)
++                        del annotations['params']
++                global_annotations.update(annotations)
++
++
++# def post_scan_hook(dummy_module_parser, dummy_pygccxml_definition, pybindgen_wrapper):
++#     ## classes
++#     if isinstance(pybindgen_wrapper, CppClass):
++#         if pybindgen_wrapper.name.endswith('Checker'):
++#             print >> sys.stderr, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", pybindgen_wrapper
++#             #pybindgen_wrapper.set_instance_creation_function(AttributeChecker_instance_creation_function)
++
++
++def scan_callback_classes(module_parser, callback_classes_file):
++    callback_classes_file.write("callback_classes = [\n")
++    for cls in module_parser.module_namespace.classes(function=module_parser.location_filter,
++                                                      recursive=False):
++        if not cls.name.startswith("Callback<"):
++            continue
++        assert templates.is_instantiation(cls.decl_string), "%s is not a template instantiation" % cls
++        dummy_cls_name, template_parameters = templates.split(cls.decl_string)
++        callback_classes_file.write("    %r,\n" % template_parameters)
++    callback_classes_file.write("]\n")
++
++
++def ns3_module_scan(top_builddir, module_name, headers_map, output_file_name, cflags):
++    module_parser = ModuleParser('ns.%s' % module_name.replace('-', '_'), 'ns3')
++    module_parser.add_pre_scan_hook(PreScanHook(headers_map, module_name))
++    #module_parser.add_post_scan_hook(post_scan_hook)
++
++    gccxml_options = dict(
++        include_paths=[top_builddir],
++         define_symbols={
++            #'NS3_ASSERT_ENABLE': None,
++            #'NS3_LOG_ENABLE': None,
++            },
++        cflags=('--gccxml-cxxflags "%s -DPYTHON_SCAN"' % cflags)
++        )
++
++    try:
++        os.unlink(output_file_name)
++    except OSError:
++        pass
++    try:
++        os.makedirs(os.path.dirname(output_file_name))
++    except OSError:
++        pass
++    output_file = open(output_file_name, "wt")
++    output_sink = FileCodeSink(output_file)
++
++    # if there exists a scan-header.h file in src/<module>/bindings,
++    # scan it, otherwise scan ns3/xxxx-module.h.
++    scan_header = os.path.join(os.path.dirname(output_file_name), "scan-header.h")
++    if not os.path.exists(scan_header):
++        scan_header = os.path.join(top_builddir, "ns3", "%s-module.h" % module_name)
++
++    module_parser.parse_init([scan_header],
++                             None, whitelist_paths=[top_builddir],
++                             #includes=['"ns3/everything.h"'],
++                             pygen_sink=output_sink,
++                             gccxml_options=gccxml_options)
++    module_parser.scan_types()
++
++    callback_classes_file = open(os.path.join(os.path.dirname(output_file_name), "callbacks_list.py"), "wt")
++    scan_callback_classes(module_parser, callback_classes_file)
++    callback_classes_file.close()
++
++
++    module_parser.scan_methods()
++    module_parser.scan_functions()
++    module_parser.parse_finalize()
++
++    output_file.close()
++    os.chmod(output_file_name, 0400)
++
++
++if __name__ == '__main__':
++    if len(sys.argv) != 6:
++        print "ns3modulescan-modular.py top_builddir module_path module_headers output_file_name cflags"
++        sys.exit(1)
++    ns3_module_scan(sys.argv[1], sys.argv[2], eval(sys.argv[3]), sys.argv[4], sys.argv[5])
++    sys.exit(0)
+diff --git a/bindings/ns3modulescan.py b/bindings/ns3modulescan.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/ns3modulescan.py
+@@ -0,0 +1,333 @@
++#! /usr/bin/env python
++
++import sys
++import os.path
++
++import pybindgen.settings
++from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection, WrapperWarning
++from pybindgen.typehandlers.codesink import FileCodeSink
++from pygccxml.declarations import templates
++from pygccxml.declarations.class_declaration import class_t
++from pygccxml.declarations.calldef import free_function_t, member_function_t, constructor_t, calldef_t
++
++
++## we need the smart pointer type transformation to be active even
++## during gccxml scanning.
++import ns3modulegen_core_customizations
++
++
++## silence gccxmlparser errors; we only want error handling in the
++## generated python script, not while scanning.
++class ErrorHandler(pybindgen.settings.ErrorHandler):
++    def handle_error(self, dummy_wrapper, dummy_exception, dummy_traceback_):
++        return True
++pybindgen.settings.error_handler = ErrorHandler()
++import warnings
++warnings.filterwarnings(category=WrapperWarning, action='ignore')
++
++type_annotations = {
++    '::ns3::AttributeChecker': {
++        'automatic_type_narrowing': 'true',
++        'allow_subclassing': 'false',
++        },
++    '::ns3::AttributeValue': {
++        'automatic_type_narrowing': 'true',
++        'allow_subclassing': 'false',
++        },
++
++    '::ns3::CommandLine': {
++        'allow_subclassing': 'true', # needed so that AddValue is able to set attributes on the object
++        },
++
++    '::ns3::NscTcpL4Protocol': {
++        'ignore': 'true', # this class is implementation detail
++        },
++
++
++    'ns3::RandomVariable::RandomVariable(ns3::RandomVariableBase const & variable) [constructor]': {
++        'ignore': None,
++        },
++    'ns3::RandomVariableBase * ns3::RandomVariable::Peek() const [member function]': {
++        'ignore': None,
++        },
++    'void ns3::RandomVariable::GetSeed(uint32_t * seed) const [member function]': {
++        'params': {'seed':{'direction':'out',
++                           'array_length':'6'}}
++        },
++    'bool ns3::TypeId::LookupAttributeByName(std::string name, ns3::TypeId::AttributeInformation * info) const [member function]': {
++        'params': {'info':{'transfer_ownership': 'false'}}
++        },
++    'static bool ns3::TypeId::LookupByNameFailSafe(std::string name, ns3::TypeId * tid) [member function]': {
++        'ignore': None, # manually wrapped in 
++        },
++    'bool ns3::TraceSourceAccessor::ConnectWithoutContext(ns3::ObjectBase * obj, ns3::CallbackBase const & cb) const [member function]': {
++        'params': {'obj': {'transfer_ownership':'false'}}
++        },
++    'bool ns3::TraceSourceAccessor::Connect(ns3::ObjectBase * obj, std::string context, ns3::CallbackBase const & cb) const [member function]': {
++        'params': {'obj': {'transfer_ownership':'false'}}
++        },
++    'bool ns3::TraceSourceAccessor::DisconnectWithoutContext(ns3::ObjectBase * obj, ns3::CallbackBase const & cb) const [member function]': {
++        'params': {'obj': {'transfer_ownership':'false'}}
++        },
++    'bool ns3::TraceSourceAccessor::Disconnect(ns3::ObjectBase * obj, std::string context, ns3::CallbackBase const & cb) const [member function]': {
++        'params': {'obj': {'transfer_ownership':'false'}}
++        },
++    'bool ns3::AttributeAccessor::Set(ns3::ObjectBase * object, ns3::AttributeValue const & value) const [member function]': {
++        'params': {'object': {'transfer_ownership':'false'}}
++        },
++    'ns3::EmpiricalVariable::EmpiricalVariable(ns3::RandomVariableBase const & variable) [constructor]': {
++        'ignore': None
++        },
++    'static ns3::AttributeList * ns3::AttributeList::GetGlobal() [member function]': {
++        'caller_owns_return': 'false'
++        },
++    'void ns3::CommandLine::Parse(int argc, char * * argv) const [member function]': {
++        'ignore': None # manually wrapped
++        },
++    'extern void ns3::PythonCompleteConstruct(ns3::Ptr<ns3::Object> object, ns3::TypeId typeId, ns3::AttributeList const & attributes) [free function]': {
++        'ignore': None # used transparently by, should not be wrapped
++        },
++
++    'ns3::Ptr<ns3::Ipv4RoutingProtocol> ns3::Ipv4ListRouting::GetRoutingProtocol(uint32_t index, int16_t & priority) const [member function]': {
++        'params': {'priority':{'direction':'out'}}
++        },
++    'ns3::Ipv4RoutingTableEntry * ns3::GlobalRouter::GetInjectedRoute(uint32_t i) [member function]': {
++        'params': {'return': { 'caller_owns_return': 'false',}},
++        },
++    'ns3::Ipv4RoutingTableEntry * ns3::Ipv4GlobalRouting::GetRoute(uint32_t i) const [member function]': {
++        'params': {'return': { 'caller_owns_return': 'false',}},
++        },
++
++    '::ns3::TestCase': {
++        'ignore': 'true', # we don't need to write test cases in Python
++        },
++    '::ns3::TestRunner': {
++        'ignore': 'true', # we don't need to write test cases in Python
++        },
++    '::ns3::TestSuite': {
++        'ignore': 'true', # we don't need to write test cases in Python
++        },
++    
++    }
++
++def get_ns3_relative_path(path):
++    l = []
++    head = path
++    while head:
++        head, tail = os.path.split(head)
++        if tail == 'ns3':
++            return os.path.join(*l)
++        l.insert(0, tail)
++    raise AssertionError("is the path %r inside ns3?!" % path)
++
++
++def pre_scan_hook(dummy_module_parser,
++                  pygccxml_definition,
++                  global_annotations,
++                  parameter_annotations):
++    ns3_header = get_ns3_relative_path(pygccxml_definition.location.file_name)
++
++    ## Note: we don't include line numbers in the comments because
++    ## those numbers are very likely to change frequently, which would
++    ## cause needless changes, since the generated python files are
++    ## kept under version control.
++
++    #global_annotations['pygen_comment'] = "%s:%i: %s" % \
++    #    (ns3_header, pygccxml_definition.location.line, pygccxml_definition)
++    global_annotations['pygen_comment'] = "%s: %s" % \
++        (ns3_header, pygccxml_definition)
++
++
++    ## handle ns3::Object::GetObject (left to its own devices,
++    ## pybindgen will generate a mangled name containing the template
++    ## argument type name).
++    if isinstance(pygccxml_definition, member_function_t) \
++            and pygccxml_definition.parent.name == 'Object' \
++            and pygccxml_definition.name == 'GetObject':
++        template_args = templates.args(pygccxml_definition.demangled_name)
++        if template_args == ['ns3::Object']:
++            global_annotations['template_instance_names'] = 'ns3::Object=>GetObject'
++
++    ## Don't wrap Simulator::Schedule* (manually wrapped)
++    if isinstance(pygccxml_definition, member_function_t) \
++            and pygccxml_definition.parent.name == 'Simulator' \
++            and pygccxml_definition.name.startswith('Schedule'):
++        global_annotations['ignore'] = None
++
++    # manually wrapped
++    if isinstance(pygccxml_definition, member_function_t) \
++            and pygccxml_definition.parent.name == 'Simulator' \
++            and pygccxml_definition.name == 'Run':
++        global_annotations['ignore'] = True
++
++    ## http://www.gccxml.org/Bug/view.php?id=9915
++    if isinstance(pygccxml_definition, calldef_t):
++        for arg in pygccxml_definition.arguments:
++            if arg.default_value is None:
++                continue
++            if "ns3::MilliSeconds( )" == arg.default_value:
++                arg.default_value = "ns3::MilliSeconds(0)"
++            if "ns3::Seconds( )" == arg.default_value:
++                arg.default_value = "ns3::Seconds(0)"
++
++    ## classes
++    if isinstance(pygccxml_definition, class_t):
++        # no need for helper classes to allow subclassing in Python, I think...
++        #if pygccxml_definition.name.endswith('Helper'):
++        #    global_annotations['allow_subclassing'] = 'false'
++
++        if pygccxml_definition.decl_string.startswith('::ns3::SimpleRefCount<'):
++            global_annotations['incref_method'] = 'Ref'
++            global_annotations['decref_method'] = 'Unref'
++            global_annotations['peekref_method'] = 'GetReferenceCount'
++            global_annotations['automatic_type_narrowing'] = 'true'
++            return
++
++        if pygccxml_definition.decl_string.startswith('::ns3::Callback<'):
++            # manually handled in ns3modulegen_core_customizations.py
++            global_annotations['ignore'] = None
++            return
++
++        if pygccxml_definition.decl_string.startswith('::ns3::TracedCallback<'):
++            global_annotations['ignore'] = None
++            return
++
++        if pygccxml_definition.decl_string.startswith('::ns3::Ptr<'):
++            # handled by pybindgen "type transformation"
++            global_annotations['ignore'] = None
++            return
++
++        # table driven class customization
++        try:
++            annotations = type_annotations[pygccxml_definition.decl_string]
++        except KeyError:
++            pass
++        else:
++            global_annotations.update(annotations)
++
++    ## free functions
++    if isinstance(pygccxml_definition, free_function_t):
++        if pygccxml_definition.name == 'PeekPointer':
++            global_annotations['ignore'] = None
++            return
++
++    ## table driven methods/constructors/functions customization
++    if isinstance(pygccxml_definition, (free_function_t, member_function_t, constructor_t)):
++        try:
++            annotations = type_annotations[str(pygccxml_definition)]
++        except KeyError:
++            pass
++        else:
++            for key,value in annotations.items():
++                if key == 'params':
++                    parameter_annotations.update (value)
++                    del annotations['params']
++            global_annotations.update(annotations)
++
++
++# def post_scan_hook(dummy_module_parser, dummy_pygccxml_definition, pybindgen_wrapper):
++#     ## classes
++#     if isinstance(pybindgen_wrapper, CppClass):
++#         if pybindgen_wrapper.name.endswith('Checker'):
++#             print >> sys.stderr, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", pybindgen_wrapper
++#             #pybindgen_wrapper.set_instance_creation_function(AttributeChecker_instance_creation_function)
++
++
++def scan_callback_classes(module_parser, callback_classes_file):
++    callback_classes_file.write("callback_classes = [\n")
++    for cls in module_parser.module_namespace.classes(function=module_parser.location_filter,
++                                                      recursive=False):
++        if not cls.name.startswith("Callback<"):
++            continue
++        assert templates.is_instantiation(cls.decl_string), "%s is not a template instantiation" % cls
++        dummy_cls_name, template_parameters = templates.split(cls.decl_string)
++        callback_classes_file.write("    %r,\n" % template_parameters)
++    callback_classes_file.write("]\n")
++
++
++class MyPygenClassifier(PygenClassifier):
++    def __init__(self, headers_map, section_precendences):
++        self.headers_map = headers_map
++        self.section_precendences = section_precendences
++
++    def classify(self, pygccxml_definition):
++        name = os.path.basename(pygccxml_definition.location.file_name)
++        try:
++            return self.headers_map[name]
++        except KeyError:
++            return '__main__'
++
++    def get_section_precedence(self, section_name):
++        if section_name == '__main__':
++            return -1
++        return self.section_precendences[section_name]
++
++
++def ns3_module_scan(top_builddir, pygen_file_name, everything_h, cflags):
++
++    ns3_modules = eval(sys.stdin.readline())
++
++    ## do a topological sort on the modules graph
++    from topsort import topsort
++    graph = []
++    module_names = ns3_modules.keys()
++    module_names.sort()
++    for ns3_module_name in module_names:
++        ns3_module_deps = list(ns3_modules[ns3_module_name][0])
++        ns3_module_deps.sort()
++        for dep in ns3_module_deps:
++            graph.append((dep, ns3_module_name))
++    sorted_ns3_modules = topsort(graph)
++    #print >> sys.stderr, "******* topological sort: ", sorted_ns3_modules
++
++    sections = [PygenSection('__main__', FileCodeSink(open(pygen_file_name, "wt")))]
++    headers_map = {} # header_name -> section_name
++    section_precendences = {} # section_name -> precedence
++    for prec, ns3_module in enumerate(sorted_ns3_modules):
++        section_name = "ns3_module_%s" % ns3_module.replace('-', '_')
++        file_name = os.path.join(os.path.dirname(pygen_file_name), "%s.py" % section_name)
++        sections.append(PygenSection(section_name, FileCodeSink(open(file_name, "wt")),
++                                     section_name + "__local"))
++        for header in ns3_modules[ns3_module][1]:
++            headers_map[header] = section_name
++        section_precendences[section_name] = prec
++
++    module_parser = ModuleParser('ns3', 'ns3')
++
++    module_parser.add_pre_scan_hook(pre_scan_hook)
++    #module_parser.add_post_scan_hook(post_scan_hook)
++
++    gccxml_options = dict(
++        include_paths=[top_builddir],
++         define_symbols={
++            #'NS3_ASSERT_ENABLE': None,
++            #'NS3_LOG_ENABLE': None,
++            },
++        cflags=('--gccxml-cxxflags "%s -DPYTHON_SCAN"' % cflags)
++        )
++
++    module_parser.parse_init([everything_h],
++                             None, whitelist_paths=[top_builddir, os.path.dirname(everything_h)],
++                             #includes=['"ns3/everything.h"'],
++                             pygen_sink=sections,
++                             pygen_classifier=MyPygenClassifier(headers_map, section_precendences),
++                             gccxml_options=gccxml_options)
++    module_parser.scan_types()
++
++    callback_classes_file = open(os.path.join(os.path.dirname(pygen_file_name), "callbacks_list.py"), "wt")
++    scan_callback_classes(module_parser, callback_classes_file)
++    callback_classes_file.close()
++
++
++    module_parser.scan_methods()
++    module_parser.scan_functions()
++    module_parser.parse_finalize()
++
++    for section in sections:
++        section.code_sink.file.close()
++
++
++
++if __name__ == '__main__':
++    ns3_module_scan(sys.argv[1], sys.argv[3], sys.argv[2], sys.argv[4])
++
+diff --git a/bindings/ns3modulescan.pyc b/bindings/ns3modulescan.pyc
+new file mode 100644
+index 0000000000000000000000000000000000000000..c7d2db0c669ed9783e23ca852462136e50bdfe0e
+GIT binary patch
+literal 10599
+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
+
+diff --git a/bindings/ns__init__.py b/bindings/ns__init__.py
+new file mode 100644
+--- /dev/null
++++ b/bindings/ns__init__.py
+@@ -0,0 +1,1 @@
++
+diff --git a/bindings/wscript b/bindings/wscript
+new file mode 100644
+--- /dev/null
++++ b/bindings/wscript
+@@ -0,0 +1,655 @@
++## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
++import types
++import re
++import os
++import subprocess
++import shutil
++import sys
++import warnings
++
++import Task
++import Options
++import Configure
++import TaskGen
++import Logs
++import Build
++import Utils
++import ns3waf
++
++from waflib.Errors import WafError
++
++## https://launchpad.net/pybindgen/
++REQUIRED_PYBINDGEN_VERSION = (0, 15, 0, 809)
++REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
++
++
++from TaskGen import feature, after
++import Task
++
++def add_to_python_path(path):
++    if os.environ.get('PYTHONPATH', ''):
++        os.environ['PYTHONPATH'] = path + os.pathsep + os.environ.get('PYTHONPATH')
++    else:
++        os.environ['PYTHONPATH'] = path
++
++def set_pybindgen_pythonpath(env):
++    env['WITH_PYBINDGEN'] = '../pybindgen'
++    if env['WITH_PYBINDGEN']:
++        add_to_python_path(env['WITH_PYBINDGEN'])
++
++def options(opt):
++    opt.tool_options('python')
++    opt.add_option('--apiscan',
++                   help=("Rescan the API for the indicated module(s), for Python bindings.  "
++                         "Needs working GCCXML / pygccxml environment.  "
++                         "The metamodule 'all' expands to all available ns-3 modules."),
++                   default=None, dest='apiscan', metavar="MODULE[,MODULE...]")
++
++def _check_nonfatal(conf, *args, **kwargs):
++    try:
++        return conf.check(*args, **kwargs)
++    except conf.errors.ConfigurationError:
++        return None
++
++def configure(conf):
++    # conf.env['ENABLE_PYTHON_BINDINGS'] = False
++    # if Options.options.python_disable:
++    #     conf.report_optional_feature("python", "Python Bindings", False,
++    #                                  "disabled by user request")
++    #     return
++    # Disable python in static builds (bug #1253)
++    if ((conf.env['ENABLE_STATIC_NS3']) or \
++      (conf.env['ENABLE_SHARED_AND_STATIC_NS3'])):
++        conf.report_optional_feature("python", "Python Bindings", False,
++                                     "bindings incompatible with static build")
++        return
++
++    enabled_modules = list(conf.env['NS3_ENABLED_MODULES'])
++    enabled_modules.sort()
++    available_modules = list(conf.env['NS3_MODULES'])
++    available_modules.sort()
++    all_modules_enabled = (enabled_modules == available_modules)
++
++    conf.check_tool('misc', tooldir=['waf-tools'])
++
++    if sys.platform == 'cygwin':
++        conf.report_optional_feature("python", "Python Bindings", False,
++                                     "unsupported platform 'cygwin'")
++        Logs.warn("Python is not supported in CygWin environment.  Try MingW instead.")
++        return
++
++
++    ## Check for Python
++
++    # if Options.options.with_python is not None:
++    #     conf.env.PYTHON = Options.options.with_python
++
++    try:
++        conf.check_tool('python')
++    except Configure.ConfigurationError, ex:
++        conf.report_optional_feature("python", "Python Bindings", False,
++                                     "The python interpreter was not found")
++        return
++    try:
++        conf.check_python_version((2,3))
++    except Configure.ConfigurationError, ex:
++        conf.report_optional_feature("python", "Python Bindings", False,
++                                     "The python found version is too low (2.3 required)")
++        return
++    try:
++        conf.check_python_headers()
++    except Configure.ConfigurationError, ex:
++        conf.report_optional_feature("python", "Python Bindings", False,
++                                     "Python library or headers missing")
++        return
++
++    # stupid Mac OSX Python wants to build extensions as "universal
++    # binaries", i386, x86_64, and ppc, but this way the type
++    # __uint128_t is not available.  We need to disable the multiarch
++    # crap by removing the -arch parameters.
++    for flags_var in ["CFLAGS_PYEXT", "CFLAGS_PYEMBED", "CXXFLAGS_PYEMBED",
++                      "CXXFLAGS_PYEXT", "LINKFLAGS_PYEMBED", "LINKFLAGS_PYEXT"]:
++        flags = conf.env[flags_var]
++        i = 0
++        while i < len(flags):
++            if flags[i] == '-arch':
++                del flags[i]
++                del flags[i]
++                continue
++            i += 1
++        conf.env[flags_var] = flags
++
++    # -fvisibility=hidden optimization
++    # if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0]
++    #     and conf.check_compilation_flag('-fvisibility=hidden')):
++        conf.env.append_value('CXXFLAGS_PYEXT', '-fvisibility=hidden')
++        conf.env.append_value('CCFLAGS_PYEXT', '-fvisibility=hidden')
++
++    # if conf.check_compilation_flag('-Wno-array-bounds'):
++        conf.env.append_value('CXXFLAGS_PYEXT', '-Wno-array-bounds')
++
++    # Check for the location of pybindgen
++    # if Options.options.with_pybindgen is not None:
++    #     if os.path.isdir(Options.options.with_pybindgen):
++    #         conf.msg("Checking for pybindgen location", ("%s (given)" % Options.options.with_pybindgen))
++    #         conf.env['WITH_PYBINDGEN'] = os.path.abspath(Options.options.with_pybindgen)
++    # else:
++    #     # ns-3-dev uses ../pybindgen, while ns-3 releases use ../REQUIRED_PYBINDGEN_VERSION
++    #     pybindgen_dir = os.path.join('..', "pybindgen")
++    #     pybindgen_release_str = "pybindgen-" + '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION])
++    #     pybindgen_release_dir = os.path.join('..', pybindgen_release_str)
++    #     if os.path.isdir(pybindgen_dir):
++    #         conf.msg("Checking for pybindgen location", ("%s (guessed)" % pybindgen_dir))
++    #         conf.env['WITH_PYBINDGEN'] = os.path.abspath(pybindgen_dir)
++    #     elif os.path.isdir(pybindgen_release_dir):
++    #         conf.msg("Checking for pybindgen location", ("%s (guessed)" % pybindgen_release_dir))
++    #         conf.env['WITH_PYBINDGEN'] = os.path.abspath(pybindgen_release_dir)
++    #     del pybindgen_dir
++    #     del pybindgen_release_dir
++    # if not conf.env['WITH_PYBINDGEN']:
++    #     conf.msg("Checking for pybindgen location", False)
++
++    # Check for pybindgen
++
++    set_pybindgen_pythonpath(conf.env)
++
++    # try:
++    #     conf.check_python_module('pybindgen')
++    # except Configure.ConfigurationError:
++    #     Logs.warn("pybindgen missing => no python bindings")
++    #     conf.report_optional_feature("python", "Python Bindings", False,
++    #                                  "PyBindGen missing")
++    #     return
++    # else:
++    #     out = subprocess.Popen([conf.env['PYTHON'][0], "-c",
++    #                             "import pybindgen.version; "
++    #                             "print '.'.join([str(x) for x in pybindgen.version.__version__])"],
++    #                             stdout=subprocess.PIPE).communicate()[0]
++    #     pybindgen_version_str = out.strip()
++    #     pybindgen_version = tuple([int(x) for x in pybindgen_version_str.split('.')])
++    #     conf.msg('Checking for pybindgen version', pybindgen_version_str)
++    #     if not (pybindgen_version == REQUIRED_PYBINDGEN_VERSION):
++    #         Logs.warn("pybindgen (found %s), (need %s)" %
++    #                 (pybindgen_version_str,
++    #                  '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION])))
++    #         conf.report_optional_feature("python", "Python Bindings", False,
++    #                                      "PyBindGen version not correct and newer version could not be retrieved")
++    #         return
++
++
++    def test(t1, t2):
++        test_program = '''
++#include <stdint.h>
++#include <vector>
++
++int main ()
++{
++   std::vector< %(type1)s > t = std::vector< %(type2)s > ();
++   return 0;
++}
++''' % dict(type1=t1, type2=t2)
++
++        try:
++            ret = conf.run_c_code(code=test_program,
++                                  env=conf.env.copy(), compile_filename='test.cc',
++                                  features='cxx cprogram', execute=False)
++        except Configure.ConfigurationError:
++            ret = 1
++        conf.msg('Checking for types %s and %s equivalence' % (t1, t2), (ret and 'no' or 'yes'))
++        return not ret
++
++    uint64_is_long = test("uint64_t", "unsigned long")
++    uint64_is_long_long = test("uint64_t", "unsigned long long")
++
++    if uint64_is_long:
++        conf.env['PYTHON_BINDINGS_APIDEFS'] = 'gcc-LP64'
++    elif uint64_is_long_long:
++        conf.env['PYTHON_BINDINGS_APIDEFS'] = 'gcc-ILP32'
++    else:
++        conf.env['PYTHON_BINDINGS_APIDEFS'] = None
++    if conf.env['PYTHON_BINDINGS_APIDEFS'] is None:
++        msg = 'none available'
++    else:
++        msg = conf.env['PYTHON_BINDINGS_APIDEFS']
++
++    conf.msg('Checking for the apidefs that can be used for Python bindings', msg)
++
++    if conf.env['PYTHON_BINDINGS_APIDEFS'] is None:
++        ns3waf._report_optional_feature(conf, "python", "Python Bindings", False,
++                                     "No apidefs are available that can be used in this system")
++        return
++
++
++    ## If all has gone well, we finally enable the Python bindings
++    conf.env['ENABLE_PYTHON_BINDINGS'] = True
++    ns3waf._report_optional_feature(conf, "python", "Python Bindings", True, None)
++
++
++    # check cxxabi stuff (which Mac OS X Lion breaks)
++    fragment = r"""
++# include <cxxabi.h>
++int main ()
++{
++   const abi::__si_class_type_info *_typeinfo  __attribute__((unused)) = NULL;
++   return 0;
++}
++"""
++    gcc_rtti_abi = _check_nonfatal(conf, fragment=fragment, msg="Checking for internal GCC cxxabi",
++                                  okmsg="complete", errmsg='incomplete',
++                                  mandatory=False)
++    conf.env["GCC_RTTI_ABI_COMPLETE"] = str(bool(gcc_rtti_abi))
++
++
++
++    ## Check for pygccxml
++    try:
++        conf.check_python_module('pygccxml')
++    except Configure.ConfigurationError:
++        ns3waf._report_optional_feature(conf, "pygccxml", "Python API Scanning Support", False,
++                                     "Missing 'pygccxml' Python module")
++        return
++
++    out = subprocess.Popen([conf.env['PYTHON'][0], "-c",
++                            "import pygccxml; print pygccxml.__version__"],
++                            stdout=subprocess.PIPE).communicate()[0]
++    pygccxml_version_str = out.strip()
++    pygccxml_version = tuple([int(x) for x in pygccxml_version_str.split('.')])
++    conf.msg('Checking for pygccxml version', pygccxml_version_str)
++    if not (pygccxml_version >= REQUIRED_PYGCCXML_VERSION):
++        Logs.warn("pygccxml (found %s) is too old (need %s) => "
++                "automatic scanning of API definitions will not be possible" %
++                (pygccxml_version_str,
++                 '.'.join([str(x) for x in REQUIRED_PYGCCXML_VERSION])))
++        ns3waf._report_optional_feature(conf, "pygccxml", "Python API Scanning Support", False,
++                                     "pygccxml too old")
++        return
++    
++
++    ## Check gccxml version
++    try:
++        gccxml = conf.find_program('gccxml', var='GCCXML')
++    except WafError:
++        gccxml = None
++    if not gccxml:
++        Logs.warn("gccxml missing; automatic scanning of API definitions will not be possible")
++        ns3waf._report_optional_feature(conf, "pygccxml", "Python API Scanning Support", False,
++                                     "gccxml missing")
++        return
++
++    gccxml_version_line = os.popen(gccxml + " --version").readline().strip()
++    m = re.match( "^GCC-XML version (\d\.\d(\.\d)?)$", gccxml_version_line)
++    gccxml_version = m.group(1)
++    gccxml_version_ok = ([int(s) for s in gccxml_version.split('.')] >= [0, 9])
++    conf.msg('Checking for gccxml version', gccxml_version)
++    if not gccxml_version_ok:
++        Logs.warn("gccxml too old, need version >= 0.9; automatic scanning of API definitions will not be possible")
++        ns3waf._report_optional_feature(conf, "pygccxml", "Python API Scanning Support", False,
++                                     "gccxml too old")
++        return
++
++    ## If we reached
++    conf.env['ENABLE_PYTHON_SCANNING'] = True
++    ns3waf._report_optional_feature(conf, "pygccxml", "Python API Scanning Support", True, None)
++
++# ---------------------
++def get_headers_map(headers, module):
++    headers_map = {} # header => module
++    for header in headers:
++        headers_map[os.path.basename(header)] = module
++    return headers_map
++# def get_headers_map(bld, module):
++#     headers_map = {} # header => module
++#     for ns3headers in bld.all_task_gen:
++#         if 'ns3header' in getattr(ns3headers, "headers", []):
++#             if ns3headers.name.find('lib/ns3-') is -1:
++#                 continue
++#             if ns3headers.name.find('-test') is not -1:
++#                 continue
++#             for h in ns3headers.to_list(ns3headers.headers):
++#                 print "h = %s" % h
++#                 headers_map[os.path.basename(h)] = ns3headers.module
++#     return headers_map
++
++def get_module_path(bld, module):
++    for ns3headers in bld.all_task_gen:
++        if 'ns3header' in getattr(ns3headers, "features", []):
++            if ns3headers.module == module:
++                break
++    else:
++        raise ValueError("Module %r not found" % module)
++    return ns3headers.path.abspath()
++
++def python_bin_scan(bld, target, module):
++    for root, dirs, files in os.walk(str(module.bld.bldnode)):
++        for f in files:
++            if os.path.basename(module.headers[0]) == f:
++                # XXX: FIXME
++                top_builddir = os.path.dirname(os.path.join(root, f)).replace('/ns3','')
++                out_topdir = os.path.dirname(os.path.join(root, f)).replace('build/','./').replace('include/ns3','')
++
++    argv = [
++        'python',
++        os.path.join('bindings', 'ns3modulescan-modular.py'), # scanning script
++        top_builddir, #'build/include', 
++        module.name.split('lib/ns3-')[1], #self.module,
++        repr(get_headers_map(module.headers, module.name.split('lib/ns3-')[1])), #repr(get_headers_map(bld, module)),
++        os.path.join(out_topdir, "bindings", 'modulegen__%s.py' % (target)), # output file
++        # XXX: FIXME
++        "-I../build/include/ns3-dev -I./build/include/", #self.cflags,
++        ]
++    print argv
++    scan = subprocess.Popen(argv, stdin=subprocess.PIPE)
++    retval = scan.wait()
++    return retval
++
++class apiscan_task(Task.TaskBase):
++    """Uses gccxml to scan the file 'everything.h' and extract API definitions.
++    """
++    after = 'gen_ns3_module_header ns3header'
++    before = 'cc cxx command'
++    color = "BLUE"
++    def __init__(self, curdirnode, env, bld, target, cflags, module):
++        self.bld = bld
++        super(apiscan_task, self).__init__(generator=self)
++        self.curdirnode = curdirnode
++        self.env = env
++        self.target = target
++        self.cflags = cflags
++        self.module = module
++
++    def display(self):
++        return 'api-scan-%s\n' % (self.target,)
++
++    def run(self):
++        top_builddir = self.bld.bldnode.abspath()
++        #module_path = get_module_path(self.bld, self.module)
++        #headers_map = get_headers_map(self.bld)
++        # scan_header = os.path.join(top_builddir, "ns3", "%s-module.h" % self.module)
++
++        # if not os.path.exists(scan_header):
++        #     Logs.error("Cannot apiscan module %r: %s does not exist" % (self.module, scan_header))
++        #     return 0
++
++        # python scan
++	retval = python_bin_scan(self.bld, self.target, self.module)
++        return retval
++
++
++def get_modules_and_headers(bld):
++    """
++    Gets a dict of
++       module_name => ([module_dep1, module_dep2, ...], [module_header1, module_header2, ...])
++    tuples, one for each module.
++    """
++
++    retval = {}
++    for module in bld.all_task_gen:
++        if not module.name.startswith('ns3-'):
++            continue
++        if module.name.endswith('-test'):
++            continue
++        module_name = module.name[4:] # strip the ns3- prefix
++        ## find the headers object for this module
++        headers = []
++        for ns3headers in bld.all_task_gen:
++            if 'ns3header' not in getattr(ns3headers, "features", []):
++                continue
++            if ns3headers.module != module_name:
++                continue
++            for source in ns3headers.to_list(ns3headers.headers):
++                headers.append(os.path.basename(source))
++        retval[module_name] = (list(module.module_deps), headers)
++    return retval
++
++
++
++
++class python_scan_task_collector(Task.TaskBase):
++    """Tasks that waits for the python-scan-* tasks to complete and then signals WAF to exit
++    """
++    after = 'apiscan'
++    before = 'cc cxx'
++    color = "BLUE"
++    def __init__(self, curdirnode, env, bld):
++        self.bld = bld
++        super(python_scan_task_collector, self).__init__(generator=self)
++        self.curdirnode = curdirnode
++        self.env = env
++
++    def display(self):
++        return 'python-scan-collector\n'
++
++    def run(self):
++        # signal stop (we generated files into the source dir and WAF
++        # can't cope with it, so we have to force the user to restart
++        # WAF)
++        self.bld.producer.stop = 1
++        return 0
++
++
++
++class gen_ns3_compat_pymod_task(Task.Task):
++    """Generates a 'ns3.py' compatibility module."""
++    before = 'cc cxx'
++    color = 'BLUE'
++    
++    def run(self):
++        assert len(self.outputs) == 1
++        outfile = file(self.outputs[0].abspath(), "w")
++        print >> outfile, "import warnings"
++        print >> outfile, 'warnings.warn("the ns3 module is a compatibility layer '\
++            'and should not be used in newly written code", DeprecationWarning, stacklevel=2)'
++        print >> outfile
++        for module in self.bld.env['PYTHON_MODULES_BUILT']:
++            print >> outfile, "from ns.%s import *" % (module.replace('-', '_'))
++        outfile.close()
++        return 0
++
++
++def _ns3_python_apiscan(bld):
++    env = bld.env
++    #if not env['ENABLE_PYTHON_SCANNING']:
++    #    raise WafError("Cannot re-scan python bindings: (py)gccxml not available")
++    scan_targets = []
++    if sys.platform == 'cygwin':
++        scan_targets.append(('gcc_cygwin', ''))
++    else:
++        import struct
++        if struct.calcsize('I') == 4 and struct.calcsize('L') == 8 and struct.calcsize('P') == 8:
++            scan_targets.extend([('gcc_ILP32', '-m32'), ('gcc_LP64', '-m64')])
++        elif struct.calcsize('I') == 4 and struct.calcsize('L') == 4 and struct.calcsize('P') == 4:
++            scan_targets.append(('gcc_ILP32', ''))
++        else:
++            raise WafError("Cannot scan python bindings for unsupported data model")
++
++    test_module_path = bld.path.find_dir("./test")
++    scan_modules = []
++    for mod in bld.all_task_gen:
++        if hasattr(mod, 'name') is False:
++            continue
++        if mod.name.find('lib/ns3-') is -1:
++            continue
++        if mod.name.find('-test') is not -1:
++            continue
++        #bindings_enabled = (mod.name in env.MODULAR_BINDINGS_MODULES)
++        bindings_enabled = True
++        #print mod.name, bindings_enabled
++        if bindings_enabled:
++            if Options.options.apiscan == 'all':
++                #scan_modules.append(mod.name.split('lib/ns3-')[1])
++                scan_modules.append(mod)
++            else:
++                if mod.name.split('lib/ns3-')[1] == Options.options.apiscan:
++                    scan_modules.append(mod)
++    print "Modules to scan: ", [mod.name for mod in scan_modules]
++    for target, cflags in scan_targets:
++        group = bld.get_group(bld.current_group)
++        for module in scan_modules:
++            group.append(apiscan_task(bld.path, env, bld, target, cflags, module))
++    group.append(python_scan_task_collector(bld.path, env, bld))
++    return
++
++def _ns3_python_bindings(bld, module):
++    for root, dirs, files in os.walk(str(module.bld.bldnode)):
++        for f in files:
++            if os.path.basename(module.headers[0]) == f:
++                # XXX: FIXME
++                out_binding_dir = os.path.dirname(os.path.join(root, f)).replace('/include/ns3','').replace('build','./')
++                include_dir = '../' + os.path.dirname(os.path.join(root, f)).replace('/ns3','').replace('build','./')
++
++    # this method is called from a module wscript, so remember bld.path is not bindings/python!
++    module_abs_src_path = os.path.abspath(os.path.join('build', out_binding_dir))
++    # module = os.path.basename(module_abs_src_path)
++    env = bld.env
++    # env.append_value("MODULAR_BINDINGS_MODULES", "ns3-"+module)
++
++    # if Options.options.apiscan:
++    #     return
++
++    # if not env['ENABLE_PYTHON_BINDINGS']:
++    #     return
++
++    bindings_dir = bld.path
++    if bindings_dir is None or not os.path.exists(bindings_dir.abspath()):
++        warnings.warn("(in %s) Requested to build modular python bindings, but apidefs dir not found "
++                      "=> skipped the bindings." % str(bld.path),
++                      Warning, stacklevel=2)
++        return
++
++    # if ("ns3-%s" % (module,)) not in env.NS3_ENABLED_MODULES:
++    #     #print "bindings for module %s which is not enabled, skip" % module
++    #     return
++
++    #env.append_value('PYTHON_MODULES_BUILT', module)
++    apidefs = env['PYTHON_BINDINGS_APIDEFS'].replace("-", "_")
++
++    #debug = ('PYBINDGEN_DEBUG' in os.environ)
++    debug = True # XXX
++    source = [bld.srcnode.find_resource('bindings/ns3modulegen-modular.py').relpath_gen(bld.path),
++              "modulegen__%s.py" % apidefs]
++
++    if bindings_dir.find_resource("modulegen_customizations.py") is not None:
++        source.append("bindings/modulegen_customizations.py")
++
++    # the local customization file may or not exist
++    if bld.path.find_resource("bindings/modulegen_local.py"):
++        source.append("bindings/modulegen_local.py")
++
++    module_py_name = module.name.split('lib/ns3-')[1].replace('-', '_')
++    module_target_dir = bld.srcnode.find_dir("bindings/ns").relpath_gen(bld.path)
++
++    # if bindings/<module>.py exists, it becomes the module frontend, and the C extension befomes _<module>
++    if bld.path.find_resource("bindings/%s.py" % (module_py_name,)) is not None:
++        bld.new_task_gen(
++            features='copy',
++            source=("bindings/%s.py" % (module_py_name,)),
++            target=('%s/%s.py' % (module_target_dir, module_py_name)))
++        extension_name = '_%s' % (module_py_name,)
++        bld.install_files('${PYTHONARCHDIR}/ns', ["bindings/%s.py" % (module_py_name,)])
++    else:
++        extension_name = module_py_name
++
++    target = ['../' + out_binding_dir + '/bindings/ns3module.cc', 
++              '../' + out_binding_dir + '/bindings/ns3module.h', 
++              '../' + out_binding_dir + '/bindings/ns3modulegen.log']
++    #if not debug:
++    #    target.append('ns3modulegen.log')
++
++    argv = ['NS3_ENABLED_FEATURES=${FEATURES}',
++            'GCC_RTTI_ABI_COMPLETE=${GCC_RTTI_ABI_COMPLETE}',
++            '${PYTHON}']
++    #if debug:
++    #    argv.extend(["-m", "pdb"])
++
++    argv.extend(['${SRC[0]}', module_abs_src_path, apidefs, extension_name, '${TGT[0]}'])
++
++    argv.extend(['2>', '${TGT[2]}']) # 2> ns3modulegen.log
++
++    features = []
++    for (name, caption, was_enabled, reason_not_enabled) in env['NS3_OPTIONAL_FEATURES']:
++        if was_enabled:
++            features.append(name)
++
++    bindgen = bld.new_task_gen(features=['command'], source=source, target=target, command=argv)
++    bindgen.env['FEATURES'] = ','.join(features)
++    bindgen.dep_vars = ['FEATURES', "GCC_RTTI_ABI_COMPLETE"]
++    bindgen.before = 'cxx'
++    bindgen.after = 'gen_ns3_module_header'
++    bindgen.name = "pybindgen(ns3 module %s)" % module.name.split('lib/ns3-')[1]
++    bindgen.install_path = None
++
++    # generate the extension module
++    pymod = bld.new_task_gen(features='cxx cxxshlib pyext')
++    pymod.source = ['../' + out_binding_dir + '/bindings/ns3module.cc']
++    pymod.target = '%s/%s' % (module_target_dir, extension_name)
++    pymod.name = 'ns3module_%s' % module.name.split('lib/ns3-')[1]
++    pymod.use = ["%s" % mod for mod in pymod.env['NS3_ENABLED_MODULES']] #  Should be '"ns3-"+module', but see bug 1117
++    if pymod.env['ENABLE_STATIC_NS3']:
++        if sys.platform == 'darwin':
++            pymod.env.append_value('LINKFLAGS', '-Wl,-all_load')
++            for mod in pymod.usel:
++                #mod = mod.split("--lib")[0]
++                pymod.env.append_value('LINKFLAGS', '-l' + mod)
++        else:
++            pymod.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic')
++            for mod in pymod.use:
++                #mod = mod.split("--lib")[0]
++                pymod.env.append_value('LINKFLAGS', '-l' + mod)
++            pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
++    defines = list(pymod.env['DEFINES'])
++    defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H'])
++    if Options.platform == 'win32':
++        try:
++            defines.remove('_DEBUG') # causes undefined symbols on win32
++        except ValueError:
++            pass
++    pymod.env['DEFINES'] = defines
++    # XXX: FIXME
++    pymod.includes = '# ../include # ../../build/include/ns3-dev # ' + include_dir #'# bindings'
++    pymod.install_path = '${PYTHONARCHDIR}/ns'
++
++    # Workaround to a WAF bug, remove this when ns-3 upgrades to WAF > 1.6.10
++    # https://www.nsnam.org/bugzilla/show_bug.cgi?id=1335
++    # http://code.google.com/p/waf/issues/detail?id=1098
++    if Utils.unversioned_sys_platform() == 'darwin':
++        pymod.mac_bundle = True
++
++    return pymod
++
++def build(bld):
++    #if Options.options.python_disable:
++    #    return
++
++    bld.ns3_python_apiscan = types.MethodType(_ns3_python_apiscan, bld)
++    bld.ns3_python_bindings = types.MethodType(_ns3_python_bindings, bld)
++    env = bld.env
++    curdir = bld.path.abspath()
++
++    set_pybindgen_pythonpath(env)
++
++    if Options.options.apiscan:
++        bld.ns3_python_apiscan()
++        return
++
++    if env['ENABLE_PYTHON_BINDINGS']:
++        task = gen_ns3_compat_pymod_task(env=env.derive())
++        task.set_outputs(bld.path.find_or_declare("ns3.py"))
++        task.dep_vars = ['PYTHON_MODULES_BUILT']
++        task.bld = bld
++        grp = bld.get_group(bld.current_group)
++        grp.append(task)
++
++        bld.new_task_gen(features='copy',
++                         source="ns__init__.py",
++                         target='ns/__init__.py')
++        bld.install_as('${PYTHONARCHDIR}/ns/__init__.py', 'ns__init__.py')
++
++        for mod in bld.all_task_gen:
++            if hasattr(mod, 'name') is False:
++                continue
++            if mod.name.find('lib/ns3-') is -1:
++                continue
++            if mod.name.find('-test') is not -1:
++                continue
++            bld.ns3_python_bindings(mod)
++
+diff --git a/example/dce-tcp-simple.py b/example/dce-tcp-simple.py
+new file mode 100644
+--- /dev/null
++++ b/example/dce-tcp-simple.py
+@@ -0,0 +1,21 @@
++# -*- coding: utf-8 -*-
++
++from ns.dce import *
++from ns.core import *
++from ns.network import *
++from ns.internet import *
++
++nodes = NodeContainer()
++nodes.Create (1)
++stack = InternetStackHelper()
++stack.Install (nodes)
++dceManager = DceManagerHelper()
++dceManager.Install (nodes);
++dce = DceApplicationHelper()
++apps = ApplicationContainer ()
++dce.SetBinary ("/ns3-dev-tcp-loopback-debug")
++dce.SetStackSize (1<<20)
++apps = dce.Install (nodes)
++apps.Start (Seconds (4.0))
++Simulator.Stop (Seconds(10.0))
++Simulator.Run ()
+diff --git a/test/netlink-socket-test.cc b/test/netlink-socket-test.cc
+--- a/test/netlink-socket-test.cc
++++ b/test/netlink-socket-test.cc
+@@ -33,8 +33,8 @@
+ #include "ns3/assert.h"
+ #include "ns3/log.h"
+ #include "ns3/socket.h"
+-#include "netlink-message.h"
+-#include "netlink-socket-address.h"
++#include "../netlink/netlink-message.h"
++#include "../netlink/netlink-socket-address.h"
+ #include <sys/socket.h>
+ #include <string>
+ #include <list>
+diff --git a/waf-tools/boost.py b/waf-tools/boost.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/boost.py
+@@ -0,0 +1,278 @@
++#!/usr/bin/env python
++# encoding: utf-8
++#
++# partially based on boost.py written by Gernot Vormayr
++# written by Ruediger Sonderfeld <ruediger@c-plusplus.de>, 2008
++# modified by Bjoern Michaelsen, 2008
++# modified by Luca Fossati, 2008
++# rewritten for waf 1.5.1, Thomas Nagy, 2008
++# rewritten for waf 1.6.2, Sylvain Rouquette, 2011
++
++'''
++To add the boost tool to the waf file:
++$ ./waf-light --tools=compat15,boost
++	or, if you have waf >= 1.6.2
++$ ./waf update --files=boost
++
++The wscript will look like:
++
++def options(opt):
++	opt.load('compiler_cxx boost')
++
++def configure(conf):
++	conf.load('compiler_cxx boost')
++	conf.check_boost(lib='system filesystem', mt=True, static=True)
++
++def build(bld):
++	bld(source='main.cpp', target='app', use='BOOST')
++'''
++
++import sys
++import re
++from waflib import Utils, Logs
++from waflib.Configure import conf
++from waflib.Errors import WafError
++
++BOOST_LIBS = ('/usr/lib', '/usr/local/lib',
++			  '/opt/local/lib', '/sw/lib', '/lib')
++BOOST_INCLUDES = ('/usr/include', '/usr/local/include',
++				  '/opt/local/include', '/sw/include')
++BOOST_VERSION_FILE = 'boost/version.hpp'
++BOOST_VERSION_CODE = '''
++#include <iostream>
++#include <boost/version.hpp>
++int main() { std::cout << BOOST_LIB_VERSION << std::endl; }
++'''
++
++# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
++PLATFORM = Utils.unversioned_sys_platform()
++detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
++detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'
++detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'
++BOOST_TOOLSETS = {
++	'borland':  'bcb',
++	'clang':	detect_clang,
++	'como':	 'como',
++	'cw':	   'cw',
++	'darwin':   'xgcc',
++	'edg':	  'edg',
++	'g++':	  detect_mingw,
++	'gcc':	  detect_mingw,
++	'icpc':	 detect_intel,
++	'intel':	detect_intel,
++	'kcc':	  'kcc',
++	'kylix':	'bck',
++	'mipspro':  'mp',
++	'mingw':	'mgw',
++	'msvc':	 'vc',
++	'qcc':	  'qcc',
++	'sun':	  'sw',
++	'sunc++':   'sw',
++	'tru64cxx': 'tru',
++	'vacpp':	'xlc'
++}
++
++
++def options(opt):
++	opt.add_option('--boost-includes', type='string',
++				   default='', dest='boost_includes',
++				   help='''path to the boost directory where the includes are
++				   e.g. /boost_1_45_0/include''')
++	opt.add_option('--boost-libs', type='string',
++				   default='', dest='boost_libs',
++				   help='''path to the directory where the boost libs are
++				   e.g. /boost_1_45_0/stage/lib''')
++	opt.add_option('--boost-static', action='store_true',
++				   default=False, dest='boost_static',
++				   help='link static libraries')
++	opt.add_option('--boost-mt', action='store_true',
++				   default=False, dest='boost_mt',
++				   help='select multi-threaded libraries')
++	opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
++				   help='''select libraries with tags (dgsyp, d for debug),
++				   see doc Boost, Getting Started, chapter 6.1''')
++	opt.add_option('--boost-toolset', type='string',
++				   default='', dest='boost_toolset',
++				   help='force a toolset e.g. msvc, vc90, \
++						gcc, mingw, mgw45 (default: auto)')
++	py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
++	opt.add_option('--boost-python', type='string',
++				   default=py_version, dest='boost_python',
++				   help='select the lib python with this version \
++						(default: %s)' % py_version)
++
++
++@conf
++def __boost_get_version_file(self, dir):
++	try:
++		return self.root.find_dir(dir).find_node(BOOST_VERSION_FILE)
++	except:
++		return None
++
++
++@conf
++def boost_get_version(self, dir):
++	"""silently retrieve the boost version number"""
++	re_but = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"$', re.M)
++	try:
++		val = re_but.search(self.__boost_get_version_file(dir).read()).group(1)
++	except:
++		val = self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[dir],
++							 execute=True, define_ret=True)
++	return val
++
++
++@conf
++def boost_get_includes(self, *k, **kw):
++	includes = k and k[0] or kw.get('includes', None)
++	if includes and self.__boost_get_version_file(includes):
++		return includes
++	for dir in BOOST_INCLUDES:
++		if self.__boost_get_version_file(dir):
++			return dir
++	if includes:
++		self.fatal('headers not found in %s' % includes)
++	else:
++		self.fatal('headers not found, use --boost-includes=/path/to/boost')
++
++
++@conf
++def boost_get_toolset(self, cc):
++	toolset = cc
++	if not cc:
++		build_platform = Utils.unversioned_sys_platform()
++		if build_platform in BOOST_TOOLSETS:
++			cc = build_platform
++		else:
++			cc = self.env.CXX_NAME
++	if cc in BOOST_TOOLSETS:
++		toolset = BOOST_TOOLSETS[cc]
++	return isinstance(toolset, str) and toolset or toolset(self.env)
++
++
++@conf
++def __boost_get_libs_path(self, *k, **kw):
++	''' return the lib path and all the files in it '''
++	if 'files' in kw:
++		return self.root.find_dir('.'), Utils.to_list(kw['files'])
++	libs = k and k[0] or kw.get('libs', None)
++	if libs:
++		path = self.root.find_dir(libs)
++		files = path.ant_glob('*boost_*')
++	if not libs or not files:
++		for dir in BOOST_LIBS:
++			try:
++				path = self.root.find_dir(dir)
++				files = path.ant_glob('*boost_*')
++				if files:
++					break
++				path = self.root.find_dir(dir + '64')
++				files = path.ant_glob('*boost_*')
++				if files:
++					break
++			except:
++				path = None
++	if not path:
++		if libs:
++			self.fatal('libs not found in %s' % libs)
++		else:
++			self.fatal('libs not found, \
++					   use --boost-includes=/path/to/boost/lib')
++	return path, files
++
++
++@conf
++def boost_get_libs(self, *k, **kw):
++	'''
++	return the lib path and the required libs
++	according to the parameters
++	'''
++	path, files = self.__boost_get_libs_path(**kw)
++	t = []
++	if kw.get('mt', False):
++		t.append('mt')
++	if kw.get('abi', None):
++		t.append(kw['abi'])
++	tags = t and '(-%s)+' % '-'.join(t) or ''
++	toolset = '(-%s[0-9]{0,3})+' % self.boost_get_toolset(kw.get('toolset', ''))
++	version = '(-%s)+' % self.env.BOOST_VERSION
++
++	def find_lib(re_lib, files):
++		for file in files:
++			if re_lib.search(file.name):
++				return file
++		return None
++
++	def format_lib_name(name):
++		if name.startswith('lib'):
++			name = name[3:]
++		return name.split('.')[0]
++
++	libs = []
++	for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
++		py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
++		# Trying libraries, from most strict match to least one
++		for pattern in ['boost_%s%s%s%s%s' % (lib, toolset, tags, py, version),
++						'boost_%s%s%s%s' % (lib, tags, py, version),
++						'boost_%s%s%s' % (lib, tags, version),
++						# Give up trying to find the right version
++						'boost_%s%s%s%s' % (lib, toolset, tags, py),
++						'boost_%s%s%s' % (lib, tags, py),
++						'boost_%s%s' % (lib, tags)]:
++			file = find_lib(re.compile(pattern), files)
++			if file:
++				libs.append(format_lib_name(file.name))
++				break
++		else:
++			self.fatal('lib %s not found in %s' % (lib, path))
++
++	return path.abspath(), libs
++
++
++@conf
++def check_boost(self, *k, **kw):
++	"""
++	initialize boost
++
++	You can pass the same parameters as the command line (without "--boost-"),
++	but the command line has the priority.
++	"""
++	if not self.env['CXX']:
++		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
++
++	params = {'lib': k and k[0] or kw.get('lib', None)}
++	for key, value in self.options.__dict__.items():
++		if not key.startswith('boost_'):
++			continue
++		key = key[len('boost_'):]
++		params[key] = value and value or kw.get(key, '')
++
++	var = kw.get('uselib_store', 'BOOST')
++
++	self.start_msg('Checking boost includes')
++	try:
++		self.env['INCLUDES_%s' % var] = self.boost_get_includes(**params)
++		self.env.BOOST_VERSION = self.boost_get_version(self.env['INCLUDES_%s' % var])
++	except WafError:
++		self.end_msg("not found", 'YELLOW')
++		raise
++	self.end_msg(self.env.BOOST_VERSION)
++	if Logs.verbose:
++		Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])
++
++	if not params['lib']:
++		return
++	self.start_msg('Checking boost libs')
++	try:
++		suffix = params.get('static', 'ST') or ''
++		path, libs = self.boost_get_libs(**params)
++	except WafError:
++		self.end_msg("not found", 'YELLOW')
++		raise
++	self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
++	self.env['%sLIB_%s' % (suffix, var)] = libs
++	self.end_msg('ok')
++	if Logs.verbose:
++		Logs.pprint('CYAN', '	path : %s' % path)
++		Logs.pprint('CYAN', '	libs : %s' % libs)
++
+diff --git a/waf-tools/cflags.py b/waf-tools/cflags.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/cflags.py
+@@ -0,0 +1,192 @@
++import Logs
++import Options
++import Utils
++
++
++class CompilerTraits(object):
++	def get_warnings_flags(self, level):
++		"""get_warnings_flags(level) -> list of cflags"""
++		raise NotImplementedError
++
++	def get_optimization_flags(self, level):
++		"""get_optimization_flags(level) -> list of cflags"""
++		raise NotImplementedError
++
++	def get_debug_flags(self, level):
++		"""get_debug_flags(level) -> (list of cflags, list of cppdefines)"""
++		raise NotImplementedError
++
++
++class GccTraits(CompilerTraits):
++	def __init__(self):
++		super(GccTraits, self).__init__()
++		# cumulative list of warnings per level
++		self.warnings_flags = [['-Wall'], ['-Werror'], ['-Wextra']]
++
++	def get_warnings_flags(self, level):
++		warnings = []
++		for l in range(level):
++			if l < len(self.warnings_flags):
++				warnings.extend(self.warnings_flags[l])
++			else:
++				break
++		return warnings
++
++	def get_optimization_flags(self, level):
++		if level == 0:
++			return ['-O0']
++		elif level == 1:
++			return ['-O']
++		elif level == 2:
++			return ['-O2']
++		elif level == 3:
++			return ['-O3']
++
++	def get_debug_flags(self, level):
++		if level == 0:
++			return (['-g0'], ['NDEBUG'])
++		elif level == 1:
++			return (['-g'], [])
++		elif level >= 2:
++			return (['-ggdb', '-g3'], ['_DEBUG'])
++		
++
++class IccTraits(CompilerTraits):
++	def __init__(self):
++		super(IccTraits, self).__init__()
++		# cumulative list of warnings per level
++		# icc is _very_ verbose with -Wall, -Werror is barely achievable
++		self.warnings_flags = [[], [], ['-Wall']]
++		
++	def get_warnings_flags(self, level):
++		warnings = []
++		for l in range(level):
++			if l < len(self.warnings_flags):
++				warnings.extend(self.warnings_flags[l])
++			else:
++				break
++		return warnings
++
++	def get_optimization_flags(self, level):
++		if level == 0:
++			return ['-O0']
++		elif level == 1:
++			return ['-O']
++		elif level == 2:
++			return ['-O2']
++		elif level == 3:
++			return ['-O3']
++
++	def get_debug_flags(self, level):
++		if level == 0:
++			return (['-g0'], ['NDEBUG'])
++		elif level == 1:
++			return (['-g'], [])
++		elif level >= 2:
++			return (['-ggdb', '-g3'], ['_DEBUG'])
++		
++
++
++class MsvcTraits(CompilerTraits):
++	def __init__(self):
++		super(MsvcTraits, self).__init__()
++		# cumulative list of warnings per level
++		self.warnings_flags = [['/W2'], ['/WX'], ['/Wall']]
++
++	def get_warnings_flags(self, level):
++		warnings = []
++		for l in range(level):
++			if l < len(self.warnings_flags):
++				warnings.extend(self.warnings_flags[l])
++			else:
++				break
++		return warnings
++
++	def get_optimization_flags(self, level):
++		if level == 0:
++			return ['/Od']
++		elif level == 1:
++			return []
++		elif level == 2:
++			return ['/O2']
++		elif level == 3:
++			return ['/Ox']
++
++	def get_debug_flags(self, level):
++		if level == 0:
++			return ([], ['NDEBUG'])
++		elif level == 1:
++			return (['/ZI', '/RTC1'], [])
++		elif level >= 2:
++			return (['/ZI', '/RTC1'], ['_DEBUG'])
++
++
++
++gcc = GccTraits()
++icc = IccTraits()
++msvc = MsvcTraits()
++
++# how to map env['COMPILER_CC'] or env['COMPILER_CXX'] into a traits object
++compiler_mapping = {
++	'gcc': gcc,
++	'g++': gcc,
++	'msvc': msvc,
++	'icc': icc,
++	'icpc': icc,
++}
++
++profiles = {
++	# profile name: [optimization_level, warnings_level, debug_level]
++	'default': [2, 1, 1],
++	'debug': [0, 2, 3],
++	'release': [3, 1, 0],
++	}
++
++default_profile = 'default'
++
++def options(opt):
++	assert default_profile in profiles
++	opt.add_option('-d', '--build-profile',
++		       action='store',
++		       default=default_profile,
++		       help=("Specify the build profile.  "
++			     "Build profiles control the default compilation flags"
++			     " used for C/C++ programs, if CCFLAGS/CXXFLAGS are not"
++			     " set set in the environment. [Allowed Values: %s]"
++			     % ", ".join([repr(p) for p in profiles.keys()])),
++		       choices=profiles.keys(),
++		       dest='build_profile')
++
++def configure(conf):
++	cc = conf.env['COMPILER_CC'] or None
++	cxx = conf.env['COMPILER_CXX'] or None
++	if not (cc or cxx):
++		raise Utils.WafError("neither COMPILER_CC nor COMPILER_CXX are defined; "
++				     "maybe the compiler_cc or compiler_cxx tool has not been configured yet?")
++	
++	try:
++		compiler = compiler_mapping[cc]
++	except KeyError:
++		try:
++			compiler = compiler_mapping[cxx]
++		except KeyError:
++			Logs.warn("No compiler flags support for compiler %r or %r"
++				  % (cc, cxx))
++			return
++
++	opt_level, warn_level, dbg_level = profiles[Options.options.build_profile]
++
++	optimizations = compiler.get_optimization_flags(opt_level)
++	debug, debug_defs = compiler.get_debug_flags(dbg_level)
++	warnings = compiler.get_warnings_flags(warn_level)
++	
++	if cc and not conf.env['CCFLAGS']:
++		conf.env.append_value('CCFLAGS', optimizations)
++		conf.env.append_value('CCFLAGS', debug)
++		conf.env.append_value('CCFLAGS', warnings)
++		conf.env.append_value('CCDEFINES', debug_defs)
++	if cxx and not conf.env['CXXFLAGS']:
++		conf.env.append_value('CXXFLAGS', optimizations)
++		conf.env.append_value('CXXFLAGS', debug)
++		conf.env.append_value('CXXFLAGS', warnings)
++		conf.env.append_value('CXXDEFINES', debug_defs)
+diff --git a/waf-tools/command.py b/waf-tools/command.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/command.py
+@@ -0,0 +1,134 @@
++import TaskGen# import feature, taskgen_method, before_method, task_gen
++import Node, Task, Utils, Build
++import subprocess
++import Options
++
++import shellcmd
++#shellcmd.subprocess = pproc # the WAF version of the subprocess module is supposedly less buggy
++
++from Logs import debug, error
++shellcmd.debug = debug
++
++import Task
++
++import re
++
++
++arg_rx = re.compile(r"(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})", re.M)
++
++class command_task(Task.Task):
++	color = "BLUE"
++	def __init__(self, env, generator):
++		Task.Task.__init__(self, env=env, normal=1, generator=generator)
++
++	def __str__(self):
++		"string to display to the user"
++		env = self.env
++		src_str = ' '.join([a.nice_path(env) for a in self.inputs])
++		tgt_str = ' '.join([a.nice_path(env) for a in self.outputs])
++		if self.outputs:
++			sep = ' -> '
++		else:
++			sep = ''
++
++		pipeline = shellcmd.Pipeline()
++		pipeline.parse(self.generator.command)
++		cmd = pipeline.get_abbreviated_command()
++		return 'command (%s): %s%s%s\n' % (cmd, src_str, sep, tgt_str)
++
++	def _subst_arg(self, arg, direction, namespace):
++		"""
++		@param arg: the command argument (or stdin/stdout/stderr) to substitute
++		@param direction: direction of the argument: 'in', 'out', or None
++		"""
++		def repl(match):
++			if match.group('dollar'):
++				return "$"
++			elif match.group('subst'):
++				var = match.group('var')
++				code = match.group('code')
++				result = eval(var+code, namespace)
++				if isinstance(result, Node.Node):
++					if var == 'TGT':
++						return result.get_bld().abspath()
++					elif var == 'SRC':
++						return result.srcpath()
++					else:
++						raise ValueError("Bad subst variable %r" % var)
++				elif result is self.inputs:
++					if len(self.inputs) == 1:
++						return result[0].srcpath()
++					else:
++						raise ValueError("${SRC} requested but have multiple sources; which one?")
++				elif result is self.outputs:
++					if len(self.outputs) == 1:
++						return result[0].get_bld().abspath()
++					else:
++						raise ValueError("${TGT} requested but have multiple targets; which one?")
++				elif isinstance(result, list):
++					assert len(result) == 1
++					return result[0]
++				else:
++					return result
++			return None
++
++		return arg_rx.sub(repl, arg)
++
++	def run(self):
++		pipeline = shellcmd.Pipeline()
++		pipeline.parse(self.generator.command)
++		namespace = self.env.get_merged_dict()
++		if self.generator.variables is not None:
++			namespace.update(self.generator.variables)
++		namespace.update(env=self.env, SRC=self.inputs, TGT=self.outputs)
++		for cmd in pipeline.pipeline:
++			if isinstance(cmd, shellcmd.Command):
++				if isinstance(cmd.stdin, basestring):
++					cmd.stdin = self._subst_arg(cmd.stdin, 'in', namespace)
++				if isinstance(cmd.stdout, basestring):
++					cmd.stdout = self._subst_arg(cmd.stdout, 'out', namespace)
++				if isinstance(cmd.stderr, basestring):
++					cmd.stderr = self._subst_arg(cmd.stderr, 'out', namespace)
++				for argI in xrange(len(cmd.argv)):
++					cmd.argv[argI] = self._subst_arg(cmd.argv[argI], None, namespace)
++				if cmd.env_vars is not None:
++					env_vars = dict()
++					for name, value in cmd.env_vars.iteritems():
++						env_vars[name] = self._subst_arg(value, None, namespace)
++					cmd.env_vars = env_vars
++			elif isinstance(cmd, shellcmd.Chdir):
++				cmd.dir = self._subst_arg(cmd.dir, None, namespace)
++		return pipeline.run(verbose=(Options.options.verbose > 0))
++
++@TaskGen.taskgen_method
++@TaskGen.feature('command')
++def init_command(self):
++	Utils.def_attrs(self,
++					# other variables that can be used in the command: ${VARIABLE}
++					variables = None,
++					rule='')
++
++
++
++@TaskGen.feature('command')
++@TaskGen.after_method('process_rule')
++def apply_command(self):
++	#self.meths.remove('apply_core')
++	# create the task
++	task = self.create_task('command')
++	setattr(task, "dep_vars", getattr(self, "dep_vars", None))
++	# process the sources
++	inputs = []
++	for node in self.source:
++		inputs.append(node)
++	task.set_inputs(inputs)
++	task.set_outputs([self.path.find_or_declare(tgt) for tgt in self.to_list(self.target)])
++	self.source = ''
++	#Task.file_deps = Task.extract_deps
++
++
++
++# class command_taskgen(task_gen):
++# 	def __init__(self, *k, **kw):
++# 		task_gen.__init__(self, *k, **kw)
++# 		self.features.append('command')
+diff --git a/waf-tools/misc.py b/waf-tools/misc.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/misc.py
+@@ -0,0 +1,416 @@
++#!/usr/bin/env python
++# encoding: utf-8
++# Thomas Nagy, 2006-2010 (ita)
++
++"""
++This tool is totally deprecated
++
++Try using:
++	.pc.in files for .pc files
++	the feature intltool_in - see demos/intltool
++	make-like rules
++"""
++
++import shutil, re, os
++from waflib import TaskGen, Node, Task, Utils, Build, Errors
++from waflib.TaskGen import feature, after_method, before_method
++from waflib.Logs import debug
++
++def copy_attrs(orig, dest, names, only_if_set=False):
++	"""
++	copy class attributes from an object to another
++	"""
++	for a in Utils.to_list(names):
++		u = getattr(orig, a, ())
++		if u or not only_if_set:
++			setattr(dest, a, u)
++
++def copy_func(tsk):
++	"Make a file copy. This might be used to make other kinds of file processing (even calling a compiler is possible)"
++	env = tsk.env
++	infile = tsk.inputs[0].abspath()
++	outfile = tsk.outputs[0].abspath()
++	try:
++		shutil.copy2(infile, outfile)
++	except (OSError, IOError):
++		return 1
++	else:
++		if tsk.chmod: os.chmod(outfile, tsk.chmod)
++		return 0
++
++def action_process_file_func(tsk):
++	"Ask the function attached to the task to process it"
++	if not tsk.fun: raise Errors.WafError('task must have a function attached to it for copy_func to work!')
++	return tsk.fun(tsk)
++
++@feature('cmd')
++def apply_cmd(self):
++	"call a command everytime"
++	if not self.fun: raise Errors.WafError('cmdobj needs a function!')
++	tsk = Task.TaskBase()
++	tsk.fun = self.fun
++	tsk.env = self.env
++	self.tasks.append(tsk)
++	tsk.install_path = self.install_path
++
++@feature('copy')
++@before_method('process_source')
++def apply_copy(self):
++	Utils.def_attrs(self, fun=copy_func)
++	self.default_install_path = 0
++
++	lst = self.to_list(self.source)
++	self.meths.remove('process_source')
++
++	for filename in lst:
++		node = self.path.find_resource(filename)
++		if not node: raise Errors.WafError('cannot find input file %s for processing' % filename)
++
++		target = self.target
++		if not target or len(lst)>1: target = node.name
++
++		# TODO the file path may be incorrect
++		newnode = self.path.find_or_declare(target)
++
++		tsk = self.create_task('copy', node, newnode)
++		tsk.fun = self.fun
++		tsk.chmod = getattr(self, 'chmod', Utils.O644)
++
++		if not tsk.env:
++			tsk.debug()
++			raise Errors.WafError('task without an environment')
++
++def subst_func(tsk):
++	"Substitutes variables in a .in file"
++
++	m4_re = re.compile('@(\w+)@', re.M)
++
++	code = tsk.inputs[0].read() #Utils.readf(infile)
++
++	# replace all % by %% to prevent errors by % signs in the input file while string formatting
++	code = code.replace('%', '%%')
++
++	s = m4_re.sub(r'%(\1)s', code)
++
++	env = tsk.env
++	di = getattr(tsk, 'dict', {}) or getattr(tsk.generator, 'dict', {})
++	if not di:
++		names = m4_re.findall(code)
++		for i in names:
++			di[i] = env.get_flat(i) or env.get_flat(i.upper())
++
++	tsk.outputs[0].write(s % di)
++
++@feature('subst')
++@before_method('process_source')
++def apply_subst(self):
++	Utils.def_attrs(self, fun=subst_func)
++	lst = self.to_list(self.source)
++	self.meths.remove('process_source')
++
++	self.dict = getattr(self, 'dict', {})
++
++	for filename in lst:
++		node = self.path.find_resource(filename)
++		if not node: raise Errors.WafError('cannot find input file %s for processing' % filename)
++
++		if self.target:
++			newnode = self.path.find_or_declare(self.target)
++		else:
++			newnode = node.change_ext('')
++
++		try:
++			self.dict = self.dict.get_merged_dict()
++		except AttributeError:
++			pass
++
++		if self.dict and not self.env['DICT_HASH']:
++			self.env = self.env.derive()
++			keys = list(self.dict.keys())
++			keys.sort()
++			lst = [self.dict[x] for x in keys]
++			self.env['DICT_HASH'] = str(Utils.h_list(lst))
++
++		tsk = self.create_task('copy', node, newnode)
++		tsk.fun = self.fun
++		tsk.dict = self.dict
++		tsk.dep_vars = ['DICT_HASH']
++		tsk.chmod = getattr(self, 'chmod', Utils.O644)
++
++		if not tsk.env:
++			tsk.debug()
++			raise Errors.WafError('task without an environment')
++
++####################
++## command-output ####
++####################
++
++class cmd_arg(object):
++	"""command-output arguments for representing files or folders"""
++	def __init__(self, name, template='%s'):
++		self.name = name
++		self.template = template
++		self.node = None
++
++class input_file(cmd_arg):
++	def find_node(self, base_path):
++		assert isinstance(base_path, Node.Node)
++		self.node = base_path.find_resource(self.name)
++		if self.node is None:
++			raise Errors.WafError("Input file %s not found in " % (self.name, base_path))
++
++	def get_path(self, env, absolute):
++		if absolute:
++			return self.template % self.node.abspath()
++		else:
++			return self.template % self.node.srcpath()
++
++class output_file(cmd_arg):
++	def find_node(self, base_path):
++		assert isinstance(base_path, Node.Node)
++		self.node = base_path.find_or_declare(self.name)
++		if self.node is None:
++			raise Errors.WafError("Output file %s not found in " % (self.name, base_path))
++
++	def get_path(self, env, absolute):
++		if absolute:
++			return self.template % self.node.abspath()
++		else:
++			return self.template % self.node.bldpath()
++
++class cmd_dir_arg(cmd_arg):
++	def find_node(self, base_path):
++		assert isinstance(base_path, Node.Node)
++		self.node = base_path.find_dir(self.name)
++		if self.node is None:
++			raise Errors.WafError("Directory %s not found in " % (self.name, base_path))
++
++class input_dir(cmd_dir_arg):
++	def get_path(self, dummy_env, dummy_absolute):
++		return self.template % self.node.abspath()
++
++class output_dir(cmd_dir_arg):
++	def get_path(self, env, dummy_absolute):
++		return self.template % self.node.abspath()
++
++
++class command_output(Task.Task):
++	color = "BLUE"
++	def __init__(self, env, command, command_node, command_args, stdin, stdout, cwd, os_env, stderr):
++		Task.Task.__init__(self, env=env)
++		assert isinstance(command, (str, Node.Node))
++		self.command = command
++		self.command_args = command_args
++		self.stdin = stdin
++		self.stdout = stdout
++		self.cwd = cwd
++		self.os_env = os_env
++		self.stderr = stderr
++
++		if command_node is not None: self.dep_nodes = [command_node]
++		self.dep_vars = [] # additional environment variables to look
++
++	def run(self):
++		task = self
++		#assert len(task.inputs) > 0
++
++		def input_path(node, template):
++			if task.cwd is None:
++				return template % node.bldpath()
++			else:
++				return template % node.abspath()
++		def output_path(node, template):
++			fun = node.abspath
++			if task.cwd is None: fun = node.bldpath
++			return template % fun()
++
++		if isinstance(task.command, Node.Node):
++			argv = [input_path(task.command, '%s')]
++		else:
++			argv = [task.command]
++
++		for arg in task.command_args:
++			if isinstance(arg, str):
++				argv.append(arg)
++			else:
++				assert isinstance(arg, cmd_arg)
++				argv.append(arg.get_path(task.env, (task.cwd is not None)))
++
++		if task.stdin:
++			stdin = open(input_path(task.stdin, '%s'))
++		else:
++			stdin = None
++
++		if task.stdout:
++			stdout = open(output_path(task.stdout, '%s'), "w")
++		else:
++			stdout = None
++
++		if task.stderr:
++			stderr = open(output_path(task.stderr, '%s'), "w")
++		else:
++			stderr = None
++
++		if task.cwd is None:
++			cwd = ('None (actually %r)' % os.getcwd())
++		else:
++			cwd = repr(task.cwd)
++		debug("command-output: cwd=%s, stdin=%r, stdout=%r, argv=%r" %
++			     (cwd, stdin, stdout, argv))
++
++		if task.os_env is None:
++			os_env = os.environ
++		else:
++			os_env = task.os_env
++		command = Utils.subprocess.Popen(argv, stdin=stdin, stdout=stdout, stderr=stderr, cwd=task.cwd, env=os_env)
++		return command.wait()
++
++@feature('command-output')
++def init_cmd_output(self):
++	Utils.def_attrs(self,
++		stdin = None,
++		stdout = None,
++		stderr = None,
++		# the command to execute
++		command = None,
++
++		# whether it is an external command; otherwise it is assumed
++		# to be an executable binary or script that lives in the
++		# source or build tree.
++		command_is_external = False,
++
++		# extra parameters (argv) to pass to the command (excluding
++		# the command itself)
++		argv = [],
++
++		# dependencies to other objects -> this is probably not what you want (ita)
++		# values must be 'task_gen' instances (not names!)
++		dependencies = [],
++
++		# dependencies on env variable contents
++		dep_vars = [],
++
++		# input files that are implicit, i.e. they are not
++		# stdin, nor are they mentioned explicitly in argv
++		hidden_inputs = [],
++
++		# output files that are implicit, i.e. they are not
++		# stdout, nor are they mentioned explicitly in argv
++		hidden_outputs = [],
++
++		# change the subprocess to this cwd (must use obj.input_dir() or output_dir() here)
++		cwd = None,
++
++		# OS environment variables to pass to the subprocess
++		# if None, use the default environment variables unchanged
++		os_env = None)
++
++@feature('command-output')
++@after_method('init_cmd_output')
++def apply_cmd_output(self):
++	if self.command is None:
++		raise Errors.WafError("command-output missing command")
++	if self.command_is_external:
++		cmd = self.command
++		cmd_node = None
++	else:
++		cmd_node = self.path.find_resource(self.command)
++		assert cmd_node is not None, ('''Could not find command '%s' in source tree.
++Hint: if this is an external command,
++use command_is_external=True''') % (self.command,)
++		cmd = cmd_node
++
++	if self.cwd is None:
++		cwd = None
++	else:
++		assert isinstance(cwd, CmdDirArg)
++		self.cwd.find_node(self.path)
++
++	args = []
++	inputs = []
++	outputs = []
++
++	for arg in self.argv:
++		if isinstance(arg, cmd_arg):
++			arg.find_node(self.path)
++			if isinstance(arg, input_file):
++				inputs.append(arg.node)
++			if isinstance(arg, output_file):
++				outputs.append(arg.node)
++
++	if self.stdout is None:
++		stdout = None
++	else:
++		assert isinstance(self.stdout, str)
++		stdout = self.path.find_or_declare(self.stdout)
++		if stdout is None:
++			raise Errors.WafError("File %s not found" % (self.stdout,))
++		outputs.append(stdout)
++
++	if self.stderr is None:
++		stderr = None
++	else:
++		assert isinstance(self.stderr, str)
++		stderr = self.path.find_or_declare(self.stderr)
++		if stderr is None:
++			raise Errors.WafError("File %s not found" % (self.stderr,))
++		outputs.append(stderr)
++
++	if self.stdin is None:
++		stdin = None
++	else:
++		assert isinstance(self.stdin, str)
++		stdin = self.path.find_resource(self.stdin)
++		if stdin is None:
++			raise Errors.WafError("File %s not found" % (self.stdin,))
++		inputs.append(stdin)
++
++	for hidden_input in self.to_list(self.hidden_inputs):
++		node = self.path.find_resource(hidden_input)
++		if node is None:
++			raise Errors.WafError("File %s not found in dir %s" % (hidden_input, self.path))
++		inputs.append(node)
++
++	for hidden_output in self.to_list(self.hidden_outputs):
++		node = self.path.find_or_declare(hidden_output)
++		if node is None:
++			raise Errors.WafError("File %s not found in dir %s" % (hidden_output, self.path))
++		outputs.append(node)
++
++	if not (inputs or getattr(self, 'no_inputs', None)):
++		raise Errors.WafError('command-output objects must have at least one input file or give self.no_inputs')
++	if not (outputs or getattr(self, 'no_outputs', None)):
++		raise Errors.WafError('command-output objects must have at least one output file or give self.no_outputs')
++
++	cwd = self.bld.variant_dir
++	task = command_output(self.env, cmd, cmd_node, self.argv, stdin, stdout, cwd, self.os_env, stderr)
++	task.generator = self
++	copy_attrs(self, task, 'before after ext_in ext_out', only_if_set=True)
++	self.tasks.append(task)
++
++	task.inputs = inputs
++	task.outputs = outputs
++	task.dep_vars = self.to_list(self.dep_vars)
++
++	for dep in self.dependencies:
++		assert dep is not self
++		dep.post()
++		for dep_task in dep.tasks:
++			task.set_run_after(dep_task)
++
++	if not task.inputs:
++		# the case for svnversion, always run, and update the output nodes
++		task.runnable_status = type(Task.TaskBase.run)(runnable_status, task, task.__class__) # always run
++		task.post_run = type(Task.TaskBase.run)(post_run, task, task.__class__)
++
++	# TODO the case with no outputs?
++
++def post_run(self):
++	for x in self.outputs:
++		x.sig = Utils.h_file(x.abspath())
++
++def runnable_status(self):
++	return self.RUN_ME
++
++Task.task_factory('copy', vars=[], func=action_process_file_func)
++
+diff --git a/waf-tools/pkgconfig.py b/waf-tools/pkgconfig.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/pkgconfig.py
+@@ -0,0 +1,78 @@
++# -*- mode: python; encoding: utf-8 -*-
++# Gustavo Carneiro (gjamc) 2008
++
++import Options
++import Configure
++import subprocess
++import config_c
++import sys
++
++def configure(conf):
++	pkg_config = conf.find_program('pkg-config', var='PKG_CONFIG')
++	if not pkg_config: return
++
++@Configure.conf
++def pkg_check_modules(conf, uselib_name, expression, mandatory=True):
++	pkg_config = conf.env['PKG_CONFIG']
++	if not pkg_config:
++		if mandatory:
++			conf.fatal("pkg-config is not available")
++		else:
++			return False
++
++	if Options.options.verbose:
++		extra_msg = ' (%s)' % expression
++	else:
++		extra_msg = ''
++
++	conf.start_msg('Checking for pkg-config flags for %s%s' % (uselib_name, extra_msg))
++
++	argv = [pkg_config, '--cflags', '--libs', expression]
++	cmd = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
++	out, err = cmd.communicate()
++	retval = cmd.wait()
++
++	conf.to_log('%r: %r (exit code %i)\n%s' % (argv, out, retval, err))
++
++	if retval != 0:
++		conf.end_msg(False)
++		sys.stderr.write(err)
++	else:
++		if Options.options.verbose:
++			conf.end_msg(out)
++		else:
++			conf.end_msg(True)
++
++	if retval == 0:
++		conf.parse_flags(out, uselib_name, conf.env)
++		conf.env[uselib_name] = True
++		return True
++
++	else:
++
++		conf.env[uselib_name] = False
++		if mandatory:
++			raise Configure.ConfigurationError('pkg-config check failed')
++		else:
++			return False
++
++@Configure.conf
++def pkg_check_module_variable(conf, module, variable):
++	pkg_config = conf.env['PKG_CONFIG']
++	if not pkg_config:
++		conf.fatal("pkg-config is not available")
++
++	argv = [pkg_config, '--variable', variable, module]
++	cmd = subprocess.Popen(argv, stdout=subprocess.PIPE)
++	out, dummy = cmd.communicate()
++	retval = cmd.wait()
++	out = out.rstrip() # strip the trailing newline
++
++	msg_checking = ("Checking for pkg-config variable %r in %s" % (variable, module,))
++	conf.check_message_custom(msg_checking, '', out)
++	conf.log.write('%r: %r (exit code %i)\n' % (argv, out, retval))
++
++	if retval == 0:
++		return out
++	else:
++		raise Configure.ConfigurationError('pkg-config check failed')
+diff --git a/waf-tools/relocation.py b/waf-tools/relocation.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/relocation.py
+@@ -0,0 +1,85 @@
++#! /usr/bin/env python
++# encoding: utf-8
++
++"""
++Waf 1.6
++
++Try to detect if the project directory was relocated, and if it was,
++change the node representing the project directory. Just call:
++
++ waf configure build
++
++Note that if the project directory name changes, the signatures for the tasks using
++files in that directory will change, causing a partial build.
++"""
++
++import os
++from waflib import Build, ConfigSet, Task, Utils, Errors
++from waflib.TaskGen import feature, before_method, after_method
++
++EXTRA_LOCK = '.old_srcdir'
++
++old1 = Build.BuildContext.store
++def store(self):
++	old1(self)
++	db = os.path.join(self.variant_dir, EXTRA_LOCK)
++	env = ConfigSet.ConfigSet()
++	env.SRCDIR = self.srcnode.abspath()
++	env.store(db)
++Build.BuildContext.store = store
++
++old2 = Build.BuildContext.init_dirs
++def init_dirs(self):
++
++	if not (os.path.isabs(self.top_dir) and os.path.isabs(self.out_dir)):
++		raise Errors.WafError('The project was not configured: run "waf configure" first!')
++
++	srcdir = None
++	db = os.path.join(self.variant_dir, EXTRA_LOCK)
++	env = ConfigSet.ConfigSet()
++	try:
++		env.load(db)
++		srcdir = env.SRCDIR
++	except:
++		pass
++
++	if srcdir:
++		d = self.root.find_node(srcdir)
++		if d and srcdir != self.top_dir and getattr(d, 'children', ''):
++			srcnode = self.root.make_node(self.top_dir)
++			print("relocating the source directory %r -> %r" % (srcdir, self.top_dir))
++			srcnode.children = {}
++
++			for (k, v) in d.children.items():
++				srcnode.children[k] = v
++				v.parent = srcnode
++			d.children = {}
++
++	old2(self)
++
++Build.BuildContext.init_dirs = init_dirs
++
++
++def uid(self):
++	try:
++		return self.uid_
++	except AttributeError:
++		# this is not a real hot zone, but we want to avoid surprizes here
++		m = Utils.md5()
++		up = m.update
++		up(self.__class__.__name__.encode())
++		for x in self.inputs + self.outputs:
++			up(x.path_from(x.ctx.srcnode).encode())
++		self.uid_ = m.digest()
++		return self.uid_
++Task.Task.uid = uid
++
++@feature('c', 'cxx', 'd', 'go', 'asm', 'fc', 'includes')
++@after_method('propagate_uselib_vars', 'process_source')
++def apply_incpaths(self):
++	lst = self.to_incnodes(self.to_list(getattr(self, 'includes', [])) + self.env['INCLUDES'])
++	self.includes_nodes = lst
++	bld = self.bld
++	self.env['INCPATHS'] = [x.is_child_of(bld.srcnode) and x.path_from(bld.srcnode) or x.abspath() for x in lst]
++
++
+diff --git a/waf-tools/shellcmd.py b/waf-tools/shellcmd.py
+new file mode 100644
+--- /dev/null
++++ b/waf-tools/shellcmd.py
+@@ -0,0 +1,356 @@
++# Copyright (C) 2008 Gustavo J. A. M. Carneiro  <gjcarneiro@gmail.com>
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++
++import shlex
++import subprocess
++import sys
++import re
++import os
++
++env_var_rx = re.compile(r"^([a-zA-Z0-9_]+)=(\S+)$")
++
++def debug(message):
++    print >> sys.stderr, message
++
++
++if sys.platform == 'win32':
++    dev_null = open("NUL:", "w")
++else:
++    dev_null = open("/dev/null", "w")
++
++fcntl = fd = fl = None
++try:
++    import fcntl
++except ImportError:
++    pass
++else:
++    fd = dev_null.fileno()
++    fl = fcntl.fcntl(fd, fcntl.F_GETFD)
++    fcntl.fcntl(fd, fcntl.F_SETFD, fl | fcntl.FD_CLOEXEC)
++del fcntl, fd, fl
++
++def _open_out_file(filename):
++    if filename in ['NUL:', '/dev/null']:
++        return dev_null
++    else:
++        return open(filename, 'wb')
++
++
++class Node(object):
++    pass
++
++class Op(Node):
++    pass
++
++class Pipe(Op):
++    pass
++
++class And(Op):
++    pass
++
++class Or(Op):
++    pass
++
++class Command(Node):
++    class PIPE(object):
++        pass # PIPE is a constant
++    class STDOUT(object):
++        pass # PIPE is a constant
++
++    def __init__(self, name):
++        super(Command, self).__init__()
++        self.name = name # command name
++        self.argv = [name] # command argv
++        self.stdin = None
++        self.stdout = None
++        self.stderr = None
++        self.env_vars = None
++
++    def __repr__(self):
++        return "Command(%r, argv=%r, stdin=%r, stdout=%r, stderr=%r)" \
++            % (self.name, self.argv, self.stdin, self.stdout, self.stderr)
++
++class Chdir(Node):
++    def __init__(self):
++        super(Chdir, self).__init__()
++        self.dir = None
++
++    def __repr__(self):
++        return "Chdir(%r)" \
++            % (self.dir)
++
++class Pipeline(object):
++    def __init__(self):
++        self.current_command = None
++        self.pipeline = []
++
++    def _commit_command(self):
++        assert self.current_command is not None
++        self.pipeline.append(self.current_command)
++        self.current_command = None
++
++    def get_abbreviated_command(self):
++        l = []
++        for node in self.pipeline:
++            if isinstance(node, Command):
++                l.append(node.name)
++            if isinstance(node, Chdir):
++                l.append('cd %s' % node.dir)
++            elif isinstance(node, Pipe):
++                l.append('|')
++            elif isinstance(node, And):
++                l.append('&&')
++            elif isinstance(node, And):
++                l.append('||')
++        return ' '.join(l)
++
++    def parse(self, command):
++        self.current_command = None
++        self.pipeline = []
++
++        if isinstance(command, list):
++            tokens = list(command)
++        else:
++            tokens = shlex.split(command)
++        debug("command: shlex: %r" % (tokens,))
++
++        BEGIN, COMMAND, CHDIR, STDERR, STDOUT, STDIN = range(6)
++        state = BEGIN
++        self.current_command = None
++        env_vars = dict()
++
++        while tokens:
++            token = tokens.pop(0)
++            if state == BEGIN:
++                env_var_match = env_var_rx.match(token)
++                if env_var_match is not None:
++                    env_vars[env_var_match.group(1)] = env_var_match.group(2)
++                else:
++                    assert self.current_command is None
++                    if token == 'cd':
++                        self.current_command = Chdir()
++                        assert not env_vars
++                        state = CHDIR
++                    else:
++                        self.current_command = Command(token)
++                        if env_vars:
++                            self.current_command.env_vars = env_vars
++                            env_vars = dict()
++                        state = COMMAND
++            elif state == COMMAND:
++                if token == '>':
++                    state = STDOUT
++                elif token == '2>':
++                    state = STDERR
++                elif token == '2>&1':
++                    assert self.current_command.stderr is None
++                    self.current_command.stderr = Command.STDOUT
++                elif token == '<':
++                    state = STDIN
++                elif token == '|':
++                    assert self.current_command.stdout is None
++                    self.current_command.stdout = Command.PIPE
++                    self._commit_command()
++                    self.pipeline.append(Pipe())
++                    state = BEGIN
++                elif token == '&&':
++                    self._commit_command()
++                    self.pipeline.append(And())
++                    state = BEGIN
++                elif token == '||':
++                    self._commit_command()
++                    self.pipeline.append(Or())
++                    state = BEGIN
++                else:
++                    self.current_command.argv.append(token)
++            elif state == CHDIR:
++                if token == '&&':
++                    self._commit_command()
++                    self.pipeline.append(And())
++                    state = BEGIN
++                else:
++                    assert self.current_command.dir is None
++                    self.current_command.dir = token
++            elif state == STDOUT:
++                assert self.current_command.stdout is None
++                self.current_command.stdout = token
++                state = COMMAND
++            elif state == STDERR:
++                assert self.current_command.stderr is None
++                self.current_command.stderr = token
++                state = COMMAND
++            elif state == STDIN:
++                assert self.current_command.stdin is None
++                self.current_command.stdin = token
++                state = COMMAND
++        self._commit_command()
++        return self.pipeline
++
++    def _exec_piped_commands(self, commands):
++        retvals = []
++        for cmd in commands:
++            retvals.append(cmd.wait())
++        retval = 0
++        for r in retvals:
++            if r:
++                retval = retvals[-1]
++                break
++        return retval
++
++    def run(self, verbose=False):
++        pipeline = list(self.pipeline)
++        files_to_close = []
++        piped_commands = []
++        piped_commands_display = []
++        BEGIN, PIPE = range(2)
++        state = BEGIN
++        cwd = '.'
++        while pipeline:
++            node = pipeline.pop(0)
++
++            if isinstance(node, Chdir):
++                next_op = pipeline.pop(0)
++                assert isinstance(next_op, And)
++                cwd = os.path.join(cwd, node.dir)
++                if verbose:
++                    piped_commands_display.append("cd %s &&" % node.dir)
++                continue
++            
++            assert isinstance(node, (Command, Chdir))
++            cmd = node
++            if verbose:
++                if cmd.env_vars:
++                    env_vars_str = ' '.join(['%s=%s' % (key, val) for key, val in cmd.env_vars.iteritems()])
++                    piped_commands_display.append("%s %s" % (env_vars_str, ' '.join(cmd.argv)))
++                else:
++                    piped_commands_display.append(' '.join(cmd.argv))
++
++            if state == PIPE:
++                stdin = piped_commands[-1].stdout
++            elif cmd.stdin is not None:
++                stdin = open(cmd.stdin, "r")
++                if verbose:
++                    piped_commands_display.append('< %s' % cmd.stdin)
++                files_to_close.append(stdin)
++            else:
++                stdin = None
++
++            if cmd.stdout is None:
++                stdout = None
++            elif cmd.stdout is Command.PIPE:
++                stdout = subprocess.PIPE
++            else:
++                stdout = _open_out_file(cmd.stdout)
++                files_to_close.append(stdout)
++                if verbose:
++                    piped_commands_display.append('> %s' % cmd.stdout)
++
++            if cmd.stderr is None:
++                stderr = None
++            elif cmd.stderr is Command.PIPE:
++                stderr = subprocess.PIPE
++            elif cmd.stderr is Command.STDOUT:
++                stderr = subprocess.STDOUT
++                if verbose:
++                    piped_commands_display.append('2>&1')
++            else:
++                stderr = _open_out_file(cmd.stderr)
++                files_to_close.append(stderr)
++                if verbose:
++                    piped_commands_display.append('2> %s' % cmd.stderr)
++
++            if cmd.env_vars:
++                env = dict(os.environ)
++                env.update(cmd.env_vars)
++            else:
++                env = None
++
++            if cwd == '.':
++                proc_cwd = None
++            else:
++                proc_cwd = cwd
++
++            debug("command: subprocess.Popen(argv=%r, stdin=%r, stdout=%r, stderr=%r, env_vars=%r, cwd=%r)"
++                  % (cmd.argv, stdin, stdout, stderr, cmd.env_vars, proc_cwd))
++            proc = subprocess.Popen(cmd.argv, stdin=stdin, stdout=stdout, stderr=stderr, env=env, cwd=proc_cwd)
++            del stdin, stdout, stderr
++            piped_commands.append(proc)
++
++            try:
++                next_node = pipeline.pop(0)
++            except IndexError:
++                try:
++                    retval = self._exec_piped_commands(piped_commands)
++                    if verbose:
++                        print "%s: exit code %i" % (' '.join(piped_commands_display), retval)
++                finally:
++                    for f in files_to_close:
++                        if f is not dev_null:
++                            f.close()
++                    files_to_close = []
++                return retval
++            else:
++
++                if isinstance(next_node, Pipe):
++                    state = PIPE
++                    piped_commands_display.append('|')
++
++                elif isinstance(next_node, Or):
++                    try:
++                        this_retval = self._exec_piped_commands(piped_commands)
++                    finally:
++                        for f in files_to_close:
++                            if f is not dev_null:
++                                f.close()
++                        files_to_close = []
++                    if this_retval == 0:
++                        if verbose:
++                            print "%s: exit code %i (|| is short-circuited)" % (' '.join(piped_commands_display), retval)
++                        return this_retval
++                    if verbose:
++                        print "%s: exit code %i (|| proceeds)" % (' '.join(piped_commands_display), retval)
++                    state = BEGIN
++                    piped_commands = []
++                    piped_commands_display = []
++
++                elif isinstance(next_node, And):
++                    try:
++                        this_retval = self._exec_piped_commands(piped_commands)
++                    finally:
++                        for f in files_to_close:
++                            if f is not dev_null:
++                                f.close()
++                        files_to_close = []
++                    if this_retval != 0:
++                        if verbose:
++                            print "%s: exit code %i (&& is short-circuited)" % (' '.join(piped_commands_display), retval)
++                        return this_retval
++                    if verbose:
++                        print "%s: exit code %i (&& proceeds)" % (' '.join(piped_commands_display), retval)
++                    state = BEGIN
++                    piped_commands = []
++                    piped_commands_display = []
++
++
++
++def _main():
++    pipeline = Pipeline()
++    pipeline.parse('./foo.py 2>&1 < xxx | cat && ls')
++    print pipeline.run()
++
++if __name__ == '__main__':
++    _main()
++
+diff --git a/wscript b/wscript
+--- a/wscript
++++ b/wscript
+@@ -54,10 +54,21 @@
+     opt.add_option('--visualize',
+                    help=('Modify --run arguments to enable the visualizer'),
+                    action="store_true", default=False, dest='visualize')
++    opt.add_option('--command-template',
++                   help=('Template of the command used to run the program given by --run;'
++                         ' It should be a shell command string containing %s inside,'
++                         ' which will be replaced by the actual program.'),
++                   type="string", default=None, dest='command_template')
++    opt.add_option('--pyrun',
++                   help=('Run a python program using locally built ns3 python module;'
++                         ' argument is the path to the python program, optionally followed'
++                         ' by command-line options that are passed to the program.'),
++                   type="string", default='', dest='pyrun')
+     opt.add_option('--valgrind',
+                    help=('Change the default command template to run programs and unit tests with valgrind'),
+                    action="store_true", default=False,
+                    dest='valgrind')
++    opt.sub_options('bindings/')
+                                   
+ def search_file(files):
+     for f in files:
+@@ -81,6 +92,8 @@
+     ns3waf.check_modules(conf, ['visualizer'], mandatory = False)
+     ns3waf.check_modules(conf, ['applications'], mandatory = False)
+     conf.check_tool('compiler_cc')
++    conf.check_tool('command', ['waf-tools'])
++    conf.check_tool('copy', ['waf-tools'])
+     conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H', mandatory=False)
+     conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H', mandatory=False)
+     conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H', mandatory=False)
+@@ -123,6 +136,7 @@
+         pass
+ 
+     conf.recurse(os.path.join('utils'))
++    conf.sub_config('bindings')
+     ns3waf.print_feature_summary(conf)
+     
+ def build_netlink(bld):
+@@ -139,7 +153,7 @@
+         'netlink/netlink-socket-address.h',
+         ]
+     module = ns3waf.create_module(bld, 
+-                                  name='netlink',
++                                  name='dce-netlink',
+                                   needed = ['internet', 'core'],
+                                   source=module_source,
+                                   headers=module_headers)
+@@ -514,7 +528,7 @@
+         ]
+     module_source = module_source + kernel_source
+     module_headers = module_headers + kernel_headers
+-    uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet', 'netlink'])
++    uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet', 'dce-netlink'])
+     module = ns3waf.create_module(bld, name='dce',
+                                   source=module_source,
+                                   headers=module_headers,
+@@ -526,18 +540,22 @@
+     build_dce_examples(module, bld)
+ 
+     # no idea to solve this two-way dependency (dce <-> netlink)
+-    module.add_runner_test(needed = ['internet', 'point-to-point', 'core', 'dce'], 
++    module.add_runner_test(needed = ['core', 'internet', 'point-to-point', 'dce'], 
+                            use=uselib,
+-                           includes=['netlink'],
++                           includes=['dce-netlink'],
+                            source=['test/netlink-socket-test.cc'],
+-                           name='netlink')
++                           name='dce-netlink')
+ 
+     if bld.env['KERNEL_STACK']:
+         build_dce_kernel_examples(module)
+     
+     bld.build_a_script = types.MethodType(build_a_script, bld)
++    bld.__class__.all_task_gen = property(_get_all_task_gen)
++    # sub-modules
++    add_myscripts(bld)
++    # python bindings
++    bld.add_subdirs(['bindings'])
+ 
+-    add_myscripts(bld)
+     # build test-runner
+     module.add_test(**dce_kw(target='bin/test-runner', 
+                              source = ['utils/test-runner.cc'],
+@@ -605,7 +623,6 @@
+     out.close()
+ 
+     wutils.bld = bld
+-    bld.__class__.all_task_gen = property(_get_all_task_gen)
+     Options.cwd_launch = bld.path.abspath()
+     if Options.options.run:
+         # Check that the requested program name is valid
+@@ -751,3 +768,7 @@
+                            visualize=Options.options.visualize)
+         raise SystemExit(0)
+ 
++    if Options.options.pyrun:
++        wutils.run_python_program(Options.options.pyrun, env,
++                                  visualize=Options.options.visualize)
++        raise SystemExit(0)
+diff --git a/wutils.py b/wutils.py
+--- a/wutils.py
++++ b/wutils.py
+@@ -114,7 +114,7 @@
+     proc_env['DCE_ROOT'] = os.pathsep.join([os.path.join(bld.out_dir), \
+                                                 os.path.join(bld.env.PREFIX)])
+ 
+-    pymoddir = bld.path.find_dir('bindings/python')
++    pymoddir = bld.path.find_dir('bindings')
+     if pymoddir is not None:
+         pymoddir = pymoddir.get_bld().abspath()
+     else:
--- a/series	Mon Aug 06 20:45:50 2012 +0900
+++ b/series	Thu Jun 20 09:56:26 2013 +0900
@@ -1,12 +1,19 @@
+dce-debug.patch
+cradle-bulk.patch
+perf-update.patch
+valg.patch
+python-binding.patch
+waf-module-find.patch
+more-test.patch
+linux-stack-rework.patch
+poll-rework.patch
+dce-sctp.patch
+new-tutorial.patch
 fedora8-nontimerfd.patch
-dce_test_improve.patch
 hana-dce.patch
 dns_unbound.patch
 dns_bind9.patch
 fedora8-nontimerfd-etc.patch
 dlm-loader-fix.patch
 floating_groupd.patch
-mpitest.patch
-bgp-caida.patch
-modulize-quagga-mip6.patch
 dce-freebsd.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/task-mgr-rework.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,129 @@
+TaskManager refactor: avoid using Simulator::Schedule()
+
+diff --git a/model/dce.cc b/model/dce.cc
+--- a/model/dce.cc
++++ b/model/dce.cc
+@@ -502,8 +502,9 @@
+ {
+   if (!process->itimerInterval.IsZero ())
+     {
+-      process->itimer = Simulator::Schedule (process->itimerInterval,
+-                                             &Itimer, process);
++      process->itimer = Simulator::ScheduleWithContext (Simulator::GetContext (),
++                                                        process->itimerInterval,
++                                                        &Itimer, process);
+     }
+   // wakeup one thread
+   UtilsSendSignal (process, SIGALRM);
+@@ -551,8 +552,9 @@
+     {
+       return 0;
+     }
+-  current->process->itimer = Simulator::Schedule (UtilsTimevalToTime (value->it_value),
+-                                                  &Itimer, current->process);
++  current->process->itimer = Simulator::ScheduleWithContext (Simulator::GetContext (),
++                                                             UtilsTimevalToTime (value->it_value),
++                                                             &Itimer, current->process);
+   return 0;
+ }
+ char * dce_getcwd (char *buf, size_t size)
+diff --git a/model/linux-socket-fd-factory.cc b/model/linux-socket-fd-factory.cc
+--- a/model/linux-socket-fd-factory.cc
++++ b/model/linux-socket-fd-factory.cc
+@@ -198,9 +198,9 @@
+ {
+   LinuxSocketFdFactory *self = (LinuxSocketFdFactory *)kernel;
+   Ptr<EventIdHolder> ev = Create<EventIdHolder> ();
+-  EventId event = Simulator::Schedule (NanoSeconds (ns),
+-                                       &LinuxSocketFdFactory::EventTrampoline,
+-                                       self, fn, context, pre_fn, ev);
++  EventId event = Simulator::ScheduleWithContext (Simulator::GetContext (), NanoSeconds (ns),
++                                                  &LinuxSocketFdFactory::EventTrampoline,
++                                                  self, fn, context, pre_fn, ev);
+   ev->id = event;
+   return &ev->id;
+ }
+diff --git a/model/task-manager.cc b/model/task-manager.cc
+--- a/model/task-manager.cc
++++ b/model/task-manager.cc
+@@ -9,6 +9,7 @@
+ #include "ns3/simulator.h"
+ #include "ns3/node.h"
+ #include "ns3/node-list.h"
++#include "ns3/event-id.h"
+ #include "dce-manager.h"
+ #include "dce-stdio.h"
+ #include "process.h"
+@@ -295,7 +296,8 @@
+   m_scheduler->Enqueue (task);
+   if (!m_nextSchedule.IsRunning ())
+     {
+-      m_nextSchedule = Simulator::ScheduleNow (&TaskManager::Schedule, this);
++      m_nextSchedule = Simulator::ScheduleWithContext (Simulator::GetContext (), Seconds (0.0),
++                                                       &TaskManager::Schedule, this);
+     }
+ }
+ 
+@@ -321,7 +323,9 @@
+   current->m_state = Task::BLOCKED;
+   if (!timeout.IsZero ())
+     {
+-      current->m_waitTimer = Simulator::Schedule (timeout, &TaskManager::EndWait, this, current);
++      current->m_waitTimer = Simulator::ScheduleWithContext (Simulator::GetContext (), timeout,
++                                                             &TaskManager::EndWait, this, current);
++
+     }
+   Schedule ();
+   current->m_waitTimer.Cancel ();
+@@ -355,7 +359,8 @@
+   m_deadTasks.push_back (current);
+   if (!m_nextGc.IsRunning ())
+     {
+-      m_nextGc = Simulator::ScheduleNow (&TaskManager::GarbageCollectDeadTasks, this);
++      m_nextGc = Simulator::ScheduleWithContext (Simulator::GetContext (), Simulator::Now (),
++                                                 &TaskManager::GarbageCollectDeadTasks, this);
+     }
+   Schedule ();
+ }
+@@ -417,7 +422,9 @@
+         {
+           // but before leaving, we check if we have further processes active, and,
+           // if so, make sure we will schedule them later.
+-          Simulator::Schedule (delay, &TaskManager::Schedule, this);
++          Thread* thread = (Thread *)next->GetContext ();
++          Simulator::ScheduleWithContext (Simulator::GetContext (), delay,
++                                          &TaskManager::Schedule, this);
+         }
+       struct Fiber *fiber = m_current->m_fiber;
+       if (m_current->m_switchNotifier != 0)
+diff --git a/model/unix-timer-fd.cc b/model/unix-timer-fd.cc
+--- a/model/unix-timer-fd.cc
++++ b/model/unix-timer-fd.cc
+@@ -207,9 +207,10 @@
+ {
+   if (!m_period.IsZero ())
+     {
+-      m_timer = Simulator::Schedule (m_period,
+-                                     &UnixTimerFd::TimerExpired,
+-                                     this);
++      m_timer = Simulator::ScheduleWithContext (Simulator::GetContext (), 
++                                                m_period,
++                                                &UnixTimerFd::TimerExpired,
++                                                this);
+     }
+   m_skipped++;
+   if (m_waiter != 0)
+@@ -233,9 +234,10 @@
+   Time initial = UtilsTimespecToTime (new_value->it_value);
+   if (!initial.IsZero ())
+     {
+-      m_timer = Simulator::Schedule (initial,
+-                                     &UnixTimerFd::TimerExpired,
+-                                     this);
++      m_timer = Simulator::ScheduleWithContext (Simulator::GetContext (),
++                                                initial,
++                                                &UnixTimerFd::TimerExpired,
++                                                this);
+     }
+   return 0;
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/valg.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,140 @@
+diff --git a/helper/dce-manager-helper.cc b/helper/dce-manager-helper.cc
+--- a/helper/dce-manager-helper.cc
++++ b/helper/dce-manager-helper.cc
+@@ -117,6 +117,7 @@
+       node->AggregateObject (loader);
+       node->AggregateObject (manager);
+       node->AggregateObject (networkStack);
++      node->AggregateObject (delay);
+       node->AggregateObject (CreateObject<LocalSocketFdFactory> ());
+       manager->AggregateObject (CreateObject<DceNodeContext> ());
+       manager->SetVirtualPath (GetVirtualPath ());
+diff --git a/model/dce-manager.cc b/model/dce-manager.cc
+--- a/model/dce-manager.cc
++++ b/model/dce-manager.cc
+@@ -17,6 +17,7 @@
+  *
+  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+  */
++#include "libc.h"
+ #include "dce-manager.h"
+ #include "process.h"
+ #include "task-manager.h"
+@@ -60,6 +61,20 @@
+ 
+ NS_LOG_COMPONENT_DEFINE ("DceManager");
+ 
++static struct Libc *libc = 0;
++extern "C" {
++struct ::Libc *
++GetLibc (void)
++{
++  if (libc != 0)
++    {
++      return libc;
++    }
++  libc_dce (&libc);
++  return libc;
++}
++}
++
+ namespace ns3 {
+ 
+ NS_OBJECT_ENSURE_REGISTERED (DceManager);
+@@ -88,6 +103,7 @@
+   return tid;
+ }
+ 
++
+ DceManager::DceManager ()
+ {
+   NS_LOG_FUNCTION (this);
+@@ -112,21 +128,10 @@
+       DeleteProcess (tmp, PEC_NS3_END);
+     }
+   mapCopy.clear ();
++  delete libc;
+   Object::DoDispose ();
+ }
+ 
+-struct ::Libc *
+-DceManager::GetLibc (void)
+-{
+-  static struct ::Libc *libc = 0;
+-  if (libc != 0)
+-    {
+-      return libc;
+-    }
+-  libc_dce (&libc);
+-  return libc;
+-}
+-
+ void
+ DceManager::EnsureDirectoryExists (struct Thread *current, std::string dirName)
+ {
+@@ -172,7 +177,7 @@
+   //        after the main call !
+   int err = 0;
+   int (*main)(int, char **) = 0;
+-  GetLibc ();
++  ::GetLibc ();
+   UnixFd *unixFd = 0;
+ 
+   if (current->process->stdinFilename.length () > 0)
+@@ -1193,7 +1198,7 @@
+ {
+   void *h = ld->Load ("libc-ns3.so", RTLD_GLOBAL);
+   void *symbol = 0;
+-  struct ::Libc *libc = GetLibc ();
++  struct ::Libc *libc = ::GetLibc ();
+ 
+   if (h == 0)
+     {
+diff --git a/model/task-manager.cc b/model/task-manager.cc
+--- a/model/task-manager.cc
++++ b/model/task-manager.cc
+@@ -114,13 +114,6 @@
+ TaskManager::~TaskManager ()
+ {
+   NS_LOG_FUNCTION (this);
+-  GarbageCollectDeadTasks ();
+-  m_fiberManager->Delete (m_mainFiber);
+-  delete m_fiberManager;
+-
+-  m_mainFiber = 0;
+-  m_fiberManager = 0;
+-  m_scheduler = 0;
+ }
+ 
+ void TaskManager::DoDispose (void)
+@@ -160,6 +153,15 @@
+             }
+         }
+     }
++
++  GarbageCollectDeadTasks ();
++  m_fiberManager->Delete (m_mainFiber);
++  delete m_fiberManager;
++
++  m_mainFiber = 0;
++  m_fiberManager = 0;
++  m_scheduler = 0;
++
+   Object::DoDispose ();
+ }
+ 
+diff --git a/testpy.supp b/testpy.supp
+--- a/testpy.supp
++++ b/testpy.supp
+@@ -1,5 +1,8 @@
+ {
+-  Supress invalid read size errors in SendPreq() when using HwmpProtocolMac
+-  Memcheck:Addr8
+-  fun:*HwmpProtocolMac*SendPreq*
++   Ignore dlopen bug.
++   Memcheck:Leak
++   fun:calloc
++   fun:_dlerror_run
++   fun:dlclose
++   ...
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/waf-module-find.patch	Thu Jun 20 09:56:26 2013 +0900
@@ -0,0 +1,27 @@
+diff --git a/ns3waf/__init__.py b/ns3waf/__init__.py
+--- a/ns3waf/__init__.py
++++ b/ns3waf/__init__.py
+@@ -149,8 +149,23 @@
+                                 args='--cflags --libs', mandatory=mandatory,
+                                 msg="Checking for ns3-%s" % module.lower(),
+                                 uselib_store='NS3_%s' % module.upper())
++
+         if not retval is None:
+             found.append(module)
++        # else:
++        #     import glob
++        #     retry_found = False
++        #     conf.start_msg(" Rechecking for ns3-%s" % module.lower())
++        #     for lib in glob.glob(conf.env['NS3_DIR'] + '/libns3-dev-%s-%s.so'  % (module.lower() , conf.env['LIB_SUFFIX'])):
++        #         conf.end_msg("found")
++        #         found.append(module)
++        #         retry_found = True
++
++        #     if retry_found is False:
++        #         conf.end_msg("not found")
++        #         if mandatory:
++        #             conf.fatal('The configuration failed')
++
+     import copy
+     if not 'NS3_MODULES_FOUND' in conf.env:
+         conf.env['NS3_MODULES_FOUND'] = []