--- a/120410-dce-umip-support.patch Thu Jun 21 17:26:37 2012 +0900
+++ b/120410-dce-umip-support.patch Wed Jul 04 17:06:26 2012 +0900
@@ -1,8 +1,8 @@
support umip(mip6d) with ns-3-linux for NEMO/MIP6
-diff -r 056220694d84 model/dce-fd.cc
---- a/model/dce-fd.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-fd.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-fd.cc
+--- a/model/dce-fd.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-fd.cc Fri Jun 29 18:26:32 2012 +0900
@@ -367,11 +367,30 @@
}
@@ -34,9 +34,9 @@
int dce_bind (int fd, const struct sockaddr *my_addr, socklen_t addrlen)
{
Thread *current = Current ();
-diff -r 056220694d84 model/dce-manager.cc
---- a/model/dce-manager.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-manager.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-manager.cc
+--- a/model/dce-manager.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-manager.cc Fri Jun 29 18:26:32 2012 +0900
@@ -1096,6 +1096,22 @@
libpthread_setup = (void (*)(const struct Libc *))(symbol);
libpthread_setup (libc);
@@ -60,9 +60,9 @@
// finally, call into 'main'.
h = ld->Load (filename, RTLD_GLOBAL);
-diff -r 056220694d84 model/dce-poll.cc
---- a/model/dce-poll.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-poll.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-poll.cc
+--- a/model/dce-poll.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-poll.cc Fri Jun 29 18:26:32 2012 +0900
@@ -180,7 +180,12 @@
}
}
@@ -77,9 +77,9 @@
{
current->err = EINVAL;
return -1;
-diff -r 056220694d84 model/dce-signal.cc
---- a/model/dce-signal.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-signal.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-signal.cc
+--- a/model/dce-signal.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-signal.cc Fri Jun 29 18:26:32 2012 +0900
@@ -3,6 +3,7 @@
#include "process.h"
#include "ns3/log.h"
@@ -106,9 +106,9 @@
int dce_sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
{
Thread *current = Current ();
-diff -r 056220694d84 model/dce-signal.h
---- a/model/dce-signal.h Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-signal.h Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-signal.h
+--- a/model/dce-signal.h Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-signal.h Fri Jun 29 18:26:32 2012 +0900
@@ -17,6 +17,7 @@
int dce_pthread_kill (pthread_t thread, int sig);
void dce_abort ();
@@ -117,9 +117,9 @@
#ifdef __cplusplus
}
-diff -r 056220694d84 model/dce-string.cc
---- a/model/dce-string.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-string.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-string.cc
+--- a/model/dce-string.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-string.cc Fri Jun 29 18:26:32 2012 +0900
@@ -26,3 +26,9 @@
/// \todo Do actual checking
strcpy (__dest, __src);
@@ -130,9 +130,9 @@
+ return strrchr (s, c);
+}
+
-diff -r 056220694d84 model/dce-string.h
---- a/model/dce-string.h Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-string.h Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-string.h
+--- a/model/dce-string.h Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-string.h Fri Jun 29 18:26:32 2012 +0900
@@ -12,6 +12,7 @@
char *dce___strcpy_chk (char *__restrict __dest,
const char *__restrict __src,
@@ -141,9 +141,9 @@
#ifdef __cplusplus
}
-diff -r 056220694d84 model/dce-time.cc
---- a/model/dce-time.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-time.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-time.cc
+--- a/model/dce-time.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-time.cc Fri Jun 29 18:26:32 2012 +0900
@@ -54,3 +54,12 @@
return asctime_r (tm, Current ()->process->asctime_result);
@@ -157,9 +157,9 @@
+ *tp = UtilsTimeToTimespec (UtilsSimulationTimeToTime (Now ()));
+ return 0;
+}
-diff -r 056220694d84 model/dce-time.h
---- a/model/dce-time.h Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce-time.h Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce-time.h
+--- a/model/dce-time.h Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce-time.h Fri Jun 29 18:26:32 2012 +0900
@@ -3,6 +3,7 @@
#include "sys/dce-time.h"
@@ -177,9 +177,9 @@
#ifdef __cplusplus
}
-diff -r 056220694d84 model/dce.cc
---- a/model/dce.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/dce.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/dce.cc
+--- a/model/dce.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/dce.cc Fri Jun 29 18:26:32 2012 +0900
@@ -22,6 +22,8 @@
#include <getopt.h>
#include <limits.h>
@@ -289,9 +289,9 @@
#ifdef HAVE_GETCPUFEATURES
extern "C"
{
-diff -r 056220694d84 model/elf-cache.cc
---- a/model/elf-cache.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/elf-cache.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/elf-cache.cc
+--- a/model/elf-cache.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/elf-cache.cc Fri Jun 29 18:26:32 2012 +0900
@@ -26,6 +26,9 @@
overriden.from = "libpthread.so.0";
overriden.to = "libpthread-ns3.so";
@@ -302,9 +302,9 @@
}
std::string
-diff -r 056220694d84 model/libc-ns3.h
---- a/model/libc-ns3.h Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/libc-ns3.h Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/libc-ns3.h
+--- a/model/libc-ns3.h Fri Jun 29 14:47:27 2012 +0900
++++ b/model/libc-ns3.h Fri Jun 29 18:26:32 2012 +0900
@@ -124,7 +124,8 @@
NATIVE (strcspn)
NATIVE (strspn)
@@ -335,16 +335,17 @@
DCE (getsockname)
DCE (getpeername)
DCE (bind)
-@@ -312,7 +316,7 @@
+@@ -312,7 +316,8 @@
NATIVE_WITH_ALIAS2 (gmtime_r, localtime_r)
NATIVE (mktime)
NATIVE (strftime)
-NATIVE_WITH_ALIAS2 (clock_gettime, __vdso_clock_gettime) // this is wrong. clock should be changed to DCE implementation
-+DCE_WITH_ALIAS2 (clock_gettime, __vdso_clock_gettime)
++//DCE_WITH_ALIAS2 (clock_gettime, __vdso_clock_gettime)
++DCE (clock_gettime)
// SYS/TIME.H
DCE (gettimeofday)
-@@ -320,6 +324,8 @@
+@@ -320,6 +325,8 @@
DCE (setitimer)
DCE (getitimer)
@@ -353,7 +354,7 @@
// SYS/MAP.H
DCE (mmap)
DCE (mmap64)
-@@ -347,6 +353,7 @@
+@@ -347,6 +354,7 @@
NATIVE (sigdelset)
NATIVE (sigismember)
DCE (sigprocmask)
@@ -361,7 +362,7 @@
// PTHREAD.H
DCE (pthread_create)
-@@ -377,6 +384,13 @@
+@@ -377,6 +385,13 @@
DCE (pthread_cond_wait)
DCE (pthread_condattr_destroy)
DCE (pthread_condattr_init)
@@ -375,7 +376,7 @@
// SEMAPHORE.H
DCE (sem_init)
-@@ -420,6 +434,7 @@
+@@ -420,6 +435,7 @@
// NET/IF.H
DCE (if_nametoindex)
@@ -383,7 +384,7 @@
// DIRENT.H
DCE (opendir)
-@@ -479,6 +494,7 @@
+@@ -479,6 +495,7 @@
// NETINET/ETHER.H
NATIVE (ether_aton_r)
@@ -391,18 +392,18 @@
///////////////////// END OF INVENTAIRE //////////////////////////////////////////////////
-diff -r 056220694d84 model/librt-ns3.version
+diff -r d540b4660837 model/librt-ns3.version
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/model/librt-ns3.version Sat Jun 02 00:27:53 2012 +0900
++++ b/model/librt-ns3.version Fri Jun 29 18:26:32 2012 +0900
@@ -0,0 +1,4 @@
+NS3 {
+global:
+ librt_setup;
+};
-diff -r 056220694d84 model/linux-socket-fd-factory.cc
---- a/model/linux-socket-fd-factory.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/linux-socket-fd-factory.cc Sat Jun 02 00:27:53 2012 +0900
-@@ -464,6 +464,7 @@
+diff -r d540b4660837 model/linux-socket-fd-factory.cc
+--- a/model/linux-socket-fd-factory.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/linux-socket-fd-factory.cc Fri Jun 29 18:26:32 2012 +0900
+@@ -466,6 +466,7 @@
void
LinuxSocketFdFactory::SetTask (std::string path, std::string value)
{
@@ -410,7 +411,7 @@
std::vector<std::pair<std::string,struct SimSysFile *> > files = GetSysFileList ();
for (uint32_t i = 0; i < files.size (); i++)
{
-@@ -537,6 +538,7 @@
+@@ -539,6 +540,7 @@
this));
Set (".net.ipv4.conf.all.forwarding", "1");
Set (".net.ipv4.conf.all.log_martians", "1");
@@ -418,9 +419,9 @@
while (!m_earlySysfs.empty ())
{
-diff -r 056220694d84 model/net/dce-if.h
---- a/model/net/dce-if.h Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/net/dce-if.h Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/net/dce-if.h
+--- a/model/net/dce-if.h Fri Jun 29 14:47:27 2012 +0900
++++ b/model/net/dce-if.h Fri Jun 29 18:26:32 2012 +0900
@@ -7,6 +7,7 @@
#endif
@@ -429,9 +430,9 @@
#ifdef __cplusplus
-diff -r 056220694d84 model/ns3-socket-fd-factory.cc
---- a/model/ns3-socket-fd-factory.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/ns3-socket-fd-factory.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/ns3-socket-fd-factory.cc
+--- a/model/ns3-socket-fd-factory.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/model/ns3-socket-fd-factory.cc Fri Jun 29 18:26:32 2012 +0900
@@ -166,6 +166,7 @@
else
{
@@ -440,9 +441,9 @@
}
return socket;
-diff -r 056220694d84 model/sys/dce-socket.h
---- a/model/sys/dce-socket.h Sat Jun 02 00:22:49 2012 +0900
-+++ b/model/sys/dce-socket.h Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 model/sys/dce-socket.h
+--- a/model/sys/dce-socket.h Fri Jun 29 14:47:27 2012 +0900
++++ b/model/sys/dce-socket.h Fri Jun 29 18:26:32 2012 +0900
@@ -28,6 +28,7 @@
ssize_t dce_sendmsg(int s, const struct msghdr *msg, int flags);
int dce_getsockname(int s, struct sockaddr *name, socklen_t *namelen);
@@ -451,9 +452,9 @@
#ifdef __cplusplus
}
-diff -r 056220694d84 test/test-select.cc
---- a/test/test-select.cc Sat Jun 02 00:22:49 2012 +0900
-+++ b/test/test-select.cc Sat Jun 02 00:27:53 2012 +0900
+diff -r d540b4660837 test/test-select.cc
+--- a/test/test-select.cc Fri Jun 29 14:47:27 2012 +0900
++++ b/test/test-select.cc Fri Jun 29 18:26:32 2012 +0900
@@ -43,9 +43,20 @@
struct timeval timeout =
{ 0, 0 };
@@ -476,10 +477,10 @@
}
static bool
-diff -r 056220694d84 wscript
---- a/wscript Sat Jun 02 00:22:49 2012 +0900
-+++ b/wscript Sat Jun 02 00:27:53 2012 +0900
-@@ -71,6 +71,17 @@
+diff -r d540b4660837 wscript
+--- a/wscript Fri Jun 29 14:47:27 2012 +0900
++++ b/wscript Fri Jun 29 18:26:32 2012 +0900
+@@ -74,6 +74,17 @@
conf.end_msg(libpthread, True)
conf.env['LIBPTHREAD_FILE'] = libpthread
@@ -497,7 +498,7 @@
conf.find_program('readversiondef', var='READVERSIONDEF', mandatory=True)
if Options.options.kernel_stack is not None and os.path.isdir(Options.options.kernel_stack):
-@@ -429,6 +440,11 @@
+@@ -441,6 +452,11 @@
rule='%s %s | cat ${SRC[0].abspath()} - > ${TGT}' %
(bld.env['READVERSIONDEF'], bld.env['LIBPTHREAD_FILE']))
@@ -509,7 +510,7 @@
bld.add_group('dce_use_version_files')
# The very small libc used to replace the glibc
-@@ -448,3 +464,13 @@
+@@ -460,5 +476,15 @@
linkflags=['-nostdlib', '-lc',
'-Wl,--version-script=' + os.path.join('model', 'libpthread.version'),
'-Wl,-soname=libpthread.so.0'])
@@ -523,3 +524,5 @@
+ '-Wl,--version-script=' + os.path.join('model', 'librt.version'),
+ '-Wl,-soname=librt.so.1'])
+
+ if bld.env['ENABLE_VDL']:
+ bld.add_subdirs(['utils'])
--- a/himalis.patch Thu Jun 21 17:26:37 2012 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1950 +0,0 @@
-diff -r 9f12d65beb55 example/dce-himalis-handoff.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/example/dce-himalis-handoff.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,296 @@
-+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-+/*
-+ * Copyright (c) 2012 NICT
-+ *
-+ * 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: Hajime Tazaki <tazaki@nict.go.jp>
-+ */
-+
-+#include "ns3/network-module.h"
-+#include "ns3/core-module.h"
-+#include "ns3/internet-module.h"
-+#include "ns3/csma-helper.h"
-+#include "ns3/point-to-point-helper.h"
-+#include "ns3/dce-module.h"
-+#include "ns3/himalis-helper.h"
-+#include "ns3/mobility-module.h"
-+#include "ns3/wifi-module.h"
-+#include "visual-simulator-impl.h"
-+
-+using namespace ns3;
-+
-+NS_LOG_COMPONENT_DEFINE ("HimalisHandoff");
-+
-+// Parameters
-+uint32_t stopTime = 120;
-+bool noMobility = false;
-+
-+std::string host0_srcid = "2001-200-0-e101-0-0-0-beaf";
-+std::string host1_srcid = "2001-200-0-e101-0-0-0-3939";
-+std::string gw0_sim0 = "2001:3939:0:1::1";
-+std::string host0_gw0_sim0 = "2001:3939:0:1::2";
-+std::string gw1_sim0 = "2001:5959:0:1::1";
-+std::string host0_gw1_sim0 = "2001:5959:0:1::2";
-+
-+std::string gw0_sim1 = "2002:4949:0:1::1";
-+std::string host1_sim0 = "2002:4949:0:1::2";
-+
-+std::string gw1_sim1 = "2002:6969:0:1::1";
-+std::string host1_sim1 = "2002:6969:0:1::2";
-+
-+NodeContainer hosts, gw;
-+
-+static void RunIp (Ptr<Node> node, Time at, std::string str)
-+{
-+ DceApplicationHelper process;
-+ ApplicationContainer apps;
-+ process.SetBinary ("ip");
-+ process.SetStackSize (1<<31);
-+ process.ResetArguments();
-+ process.ParseArguments(str.c_str ());
-+ apps = process.Install (node);
-+ apps.Start (at);
-+}
-+
-+static void
-+AssocCallback (Ptr<HimalisHelper> himalis, std::string path, Mac48Address bssid)
-+{
-+ uint8_t gw0[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
-+ uint8_t gw1[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x03};
-+ uint8_t cur[6];
-+
-+ bssid.CopyTo (cur);
-+
-+ std::cout << Simulator::Now ().GetSeconds () << " " << path << " with " << bssid;
-+ // in case gw0
-+ if (memcmp (cur, gw0, 6) == 0)
-+ {
-+ std::cout << " gw0 " << std::endl;
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 addr del " + host0_gw1_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 route del default via "+ gw1_sim0);
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 addr add " + host0_gw0_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 route add default via "+ gw0_sim0);
-+#if 1
-+ himalis->DelIdlRoute (hosts.Get (0), Simulator::Now (),
-+ host0_srcid.c_str (), host1_srcid.c_str ());
-+ himalis->AddIdlRoute (hosts.Get (0), Simulator::Now (),
-+ "host", host0_srcid.c_str (), host1_srcid.c_str (),
-+ host0_gw0_sim0.c_str (), gw0_sim0.c_str (), "sim0");
-+
-+ himalis->DelIdlRoute (hosts.Get (1), Simulator::Now (),
-+ host1_srcid.c_str (), host0_srcid.c_str ());
-+ himalis->AddIdlRoute (hosts.Get (1), Simulator::Now (),
-+ "host", host1_srcid.c_str (), host0_srcid.c_str (),
-+ host1_sim0.c_str (), gw0_sim1.c_str (), "sim0");
-+#endif
-+ }
-+ // in case gw1
-+ else if (memcmp (cur, gw1, 6) == 0)
-+ {
-+ std::cout << " gw1 " << std::endl;
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 addr del " + host0_gw0_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 route del default via "+ gw0_sim0);
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 addr add " + host0_gw1_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (0), Simulator::Now (), "-f inet6 route add default via "+ gw1_sim0);
-+#if 1
-+ himalis->DelIdlRoute (hosts.Get (0), Simulator::Now (),
-+ host0_srcid.c_str (), host1_srcid.c_str ());
-+ himalis->AddIdlRoute (hosts.Get (0), Simulator::Now (),
-+ "host", host0_srcid.c_str (), host1_srcid.c_str (),
-+ host0_gw1_sim0.c_str (), gw1_sim0.c_str (), "sim0");
-+
-+ himalis->DelIdlRoute (hosts.Get (1), Simulator::Now (),
-+ host1_srcid.c_str (), host0_srcid.c_str ());
-+ himalis->AddIdlRoute (hosts.Get (1), Simulator::Now (),
-+ "host", host1_srcid.c_str (), host0_srcid.c_str (),
-+ host1_sim1.c_str (), gw1_sim1.c_str (), "sim1");
-+ himalis->ShowIdlRoute (hosts.Get (1), Simulator::Now ());
-+#endif
-+ }
-+
-+}
-+
-+
-+int main (int argc, char *argv[])
-+{
-+ CommandLine cmd;
-+ cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime);
-+ cmd.AddValue ("noMobility", "Without movement", noMobility);
-+ cmd.Parse (argc, argv);
-+
-+ // nodes
-+ gw.Create (2);
-+ hosts.Create (2);
-+
-+ // movement
-+ NetDeviceContainer devices;
-+ MobilityHelper mobility;
-+ Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
-+ positionAlloc->Add (Vector (0.0, 10.0, 0.0)); // GW0
-+ positionAlloc->Add (Vector (150.0, 10.0, 0.0)); // GW1
-+ positionAlloc->Add (Vector (75.0, -50.0, 0.0)); // CN
-+ mobility.SetPositionAllocator (positionAlloc);
-+ mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
-+ mobility.Install (gw);
-+ mobility.Install (hosts.Get (1));
-+
-+ Ptr<ns3::RandomDiscPositionAllocator> r_position =
-+ CreateObject<RandomDiscPositionAllocator> ();
-+ r_position->SetX (100);
-+ r_position->SetY (50);
-+ r_position->SetRho (UniformVariable (200, 0));
-+ mobility.SetPositionAllocator (r_position);
-+ mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
-+ "Bounds", RectangleValue (Rectangle (0, 200, 30, 60)),
-+ "Speed", RandomVariableValue (ConstantVariable (10)),
-+ "Pause", RandomVariableValue (ConstantVariable (0.2)));
-+ if (noMobility)
-+ {
-+ mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
-+ }
-+ mobility.Install (hosts.Get (0));
-+
-+ // net devices
-+ // wifi
-+ WifiHelper wifi = WifiHelper::Default ();
-+ YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
-+ YansWifiChannelHelper phyChannel = YansWifiChannelHelper::Default ();
-+ Ssid ssid = Ssid ("ns-3-ssid");
-+ NqosWifiMacHelper mac;
-+ wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
-+
-+ phy.SetChannel (phyChannel.Create ());
-+ mac.SetType ("ns3::StaWifiMac",
-+ "Ssid", SsidValue (ssid),
-+ "ActiveProbing", BooleanValue (false));
-+ wifi.Install (phy, mac, hosts.Get (0));
-+ mac.SetType ("ns3::ApWifiMac",
-+ "Ssid", SsidValue (ssid));
-+ wifi.Install (phy, mac, gw);
-+ // ptp netdev
-+ PointToPointHelper p2p;
-+ p2p.Install (NodeContainer (gw.Get (0), hosts.Get (1))); // CN - GW0
-+ p2p.Install (NodeContainer (gw.Get (1), hosts.Get (1))); // CN - GW1
-+
-+
-+
-+ // addresses (locators)
-+ DceManagerHelper dceManager;
-+ HimalisHelper himalis;
-+ dceManager.SetTaskManagerAttribute ("FiberManagerType",
-+ EnumValue (0));
-+ dceManager.SetLoader ("ns3::DlmLoaderFactory");
-+ dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
-+ "Library", StringValue ("liblinux-2.6.32.27-tpidl.so"));
-+ dceManager.Install (NodeContainer (hosts, gw));
-+ himalis.Install (NodeContainer (hosts, gw));
-+
-+ // GW0
-+ RunIp (gw.Get (0), Seconds (0.1), "link set lo up");
-+ RunIp (gw.Get (0), Seconds (0.1), "link set sim0 up");
-+ RunIp (gw.Get (0), Seconds (0.1), "link set sim1 up");
-+ RunIp (gw.Get (0), Seconds (0.2), "-f inet6 addr add " + gw0_sim0 + "/64 dev sim0");
-+ RunIp (gw.Get (0), Seconds (0.15), "-f inet6 addr add " + gw0_sim1 + "/64 dev sim1");
-+ // HIMALIS configuration
-+#if 1
-+ himalis.AddIdlRoute (gw.Get (0), Seconds (0.2), "forward", host0_srcid.c_str (), host1_srcid.c_str (),
-+ gw0_sim1.c_str (), host1_sim0.c_str (), "sim1");
-+ himalis.AddIdlRoute (gw.Get (0), Seconds (0.2), "forward", host1_srcid.c_str (), host0_srcid.c_str (),
-+ gw0_sim0.c_str (), host0_gw0_sim0.c_str (), "sim0");
-+#endif
-+#if 0
-+ himalis.ShowIdlRoute (gw.Get (0), Seconds (0.2));
-+#endif
-+ RunIp (gw.Get (0), Seconds (1.0), "addr list");
-+
-+ // GW1
-+ RunIp (gw.Get (1), Seconds (0.1), "link set lo up");
-+ RunIp (gw.Get (1), Seconds (0.1), "link set sim0 up");
-+ RunIp (gw.Get (1), Seconds (0.1), "link set sim1 up");
-+ RunIp (gw.Get (1), Seconds (0.2), "-f inet6 addr add " + gw1_sim0 + "/64 dev sim0");
-+ RunIp (gw.Get (1), Seconds (0.2), "-f inet6 addr add " + gw1_sim1 + "/64 dev sim1");
-+ // HIMALIS configuration
-+#if 1
-+ himalis.AddIdlRoute (gw.Get (1), Seconds (0.2), "forward", host0_srcid.c_str (), host1_srcid.c_str (),
-+ gw1_sim1.c_str (), host1_sim1.c_str (), "sim1");
-+ himalis.AddIdlRoute (gw.Get (1), Seconds (0.2), "forward", host1_srcid.c_str (), host0_srcid.c_str (),
-+ gw1_sim0.c_str (), host0_gw1_sim0.c_str (), "sim0");
-+#endif
-+#if 0
-+ himalis.ShowIdlRoute (gw.Get (1), Seconds (0.2));
-+#endif
-+ RunIp (gw.Get (1), Seconds (1.0), "addr list");
-+
-+ // Host0 (MN)
-+ RunIp (hosts.Get (0), Seconds (0.1), "link set lo up");
-+ RunIp (hosts.Get (0), Seconds (0.1), "link set sim0 up");
-+ RunIp (hosts.Get (0), Seconds (1.0), "addr list");
-+#if 0
-+ RunIp (hosts.Get (0), Seconds (0.2), "-f inet6 addr add " + host0_gw1_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (0), Seconds (0.2), "-f inet6 route add default via "+ gw1_sim0);
-+ himalis.AddIdlRoute (hosts.Get (0), Seconds (0.2), "host", host0_srcid.c_str (), host1_srcid.c_str (),
-+ host0_gw1_sim0.c_str (), gw1_sim0.c_str (), "sim0");
-+#endif
-+
-+ // Host1 (CN)
-+ RunIp (hosts.Get (1), Seconds (0.1), "link set lo up");
-+ RunIp (hosts.Get (1), Seconds (0.1), "link set sim0 up");
-+ RunIp (hosts.Get (1), Seconds (0.1), "link set sim1 up");
-+ RunIp (hosts.Get (1), Seconds (0.3), "-f inet6 addr add " + host1_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (1), Seconds (0.3), "-f inet6 route add default via " + gw0_sim1);
-+ RunIp (hosts.Get (1), Seconds (0.2), "-f inet6 addr add " + host1_sim1 + "/64 dev sim1");
-+ RunIp (hosts.Get (1), Seconds (0.2), "-f inet6 route add default via " + gw1_sim1);
-+ RunIp (hosts.Get (1), Seconds (1.0), "addr list");
-+#if 0
-+ himalis.AddIdlRoute (hosts.Get (1), Seconds (0.2), "host", host1_srcid.c_str (), host0_srcid.c_str (),
-+ host1_sim0.c_str (), gw0_sim1.c_str (), "sim0");
-+#endif
-+
-+ // Applications
-+ DceApplicationHelper process;
-+ ApplicationContainer apps;
-+#if 1
-+ // server install to host1
-+ process.SetBinary ("idecho-s");
-+ process.ResetArguments ();
-+ process.ParseArguments ("-s " + host1_srcid);
-+ process.SetStackSize (1<<16);
-+ apps = process.Install (hosts.Get (1));
-+ apps.Start (Seconds (4.0));
-+#endif
-+
-+ // client install to host0
-+ process.SetBinary ("idecho-c");
-+ process.ResetArguments ();
-+ process.ParseArguments ("-s " + host0_srcid);
-+ process.ParseArguments ("-d " + host1_srcid);
-+ process.SetStackSize (1<<16);
-+ apps = process.Install (hosts.Get (0));
-+ apps.Start (Seconds (5.0));
-+
-+ p2p.EnablePcapAll ("dce-himalis");
-+ phy.EnablePcapAll ("dce-himalis");
-+
-+ Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc",
-+ MakeBoundCallback (&AssocCallback, &himalis));
-+
-+ Simulator::Stop (Seconds (stopTime));
-+ Simulator::Run ();
-+ Simulator::Destroy ();
-+
-+ NS_LOG_INFO ("End of experiment");
-+
-+ return 0;
-+}
-diff -r 9f12d65beb55 example/dce-himalis-simple.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/example/dce-himalis-simple.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,156 @@
-+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-+/*
-+ * Copyright (c) 2012 NICT
-+ *
-+ * 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: Hajime Tazaki <tazaki@nict.go.jp>
-+ */
-+
-+#include "ns3/network-module.h"
-+#include "ns3/core-module.h"
-+#include "ns3/internet-module.h"
-+#include "ns3/csma-helper.h"
-+#include "ns3/point-to-point-helper.h"
-+#include "ns3/dce-module.h"
-+#include "ns3/himalis-helper.h"
-+
-+using namespace ns3;
-+
-+NS_LOG_COMPONENT_DEFINE ("HimalisSimple");
-+
-+// Parameters
-+uint32_t stopTime = 60;
-+
-+static void RunIp (Ptr<Node> node, Time at, std::string str)
-+{
-+ DceApplicationHelper process;
-+ ApplicationContainer apps;
-+ process.SetBinary ("ip");
-+ process.SetStackSize (1<<31);
-+ process.ResetArguments();
-+ process.ParseArguments(str.c_str ());
-+ apps = process.Install (node);
-+ apps.Start (at);
-+}
-+
-+std::string host0_srcid = "2001-200-0-e101-0-0-0-beaf";
-+std::string host1_srcid = "2001-200-0-e101-0-0-0-3939";
-+std::string gw_sim0 = "2001:3939:0:1::1";
-+std::string host0_sim0 = "2001:3939:0:1::2";
-+std::string gw_sim1_v6 = "2002:4949:0:1::1";
-+std::string host1_sim0_v6 = "2002:4949:0:1::2";
-+std::string gw_sim1_v4 = "11.0.0.1";
-+std::string host1_sim0_v4 = "11.0.0.2";
-+
-+int main (int argc, char *argv[])
-+{
-+ CommandLine cmd;
-+ cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime);
-+ cmd.Parse (argc, argv);
-+
-+ // nodes
-+ NodeContainer hosts, gw;
-+ hosts.Create (2);
-+ gw.Create (1);
-+
-+ // net devices
-+ CsmaHelper csma;
-+ PointToPointHelper p2p;
-+ csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
-+ csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
-+
-+ p2p.Install (NodeContainer (gw, hosts.Get (0))); // Host - GW
-+ p2p.Install (NodeContainer (gw, hosts.Get (1))); // Host - GW
-+
-+ // addresses (locators)
-+ DceManagerHelper dceManager;
-+ HimalisHelper himalis;
-+ // dceManager.SetLoader ("ns3::DlmLoaderFactory");
-+ dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
-+ "Library", StringValue ("liblinux-2.6.32.27-tpidl.so"));
-+ dceManager.Install (NodeContainer (hosts, gw));
-+ himalis.Install (NodeContainer (hosts, gw));
-+
-+ // GW
-+ RunIp (gw.Get (0), Seconds (0.1), "link set lo up");
-+ RunIp (gw.Get (0), Seconds (0.1), "link set sim0 up");
-+ RunIp (gw.Get (0), Seconds (0.1), "link set sim1 up");
-+ RunIp (gw.Get (0), Seconds (0.1), "link set sim2 up");
-+ RunIp (gw.Get (0), Seconds (0.2), "-f inet addr add 10.0.0.1/24 dev sim0");
-+ RunIp (gw.Get (0), Seconds (0.2), "-f inet6 addr add " + gw_sim0 + "/64 dev sim0");
-+ RunIp (gw.Get (0), Seconds (0.2), "-f inet addr add " + gw_sim1_v4 + "/24 dev sim1");
-+ RunIp (gw.Get (0), Seconds (0.2), "-f inet6 addr add " + gw_sim1_v6 + "/64 dev sim1");
-+ // HIMALIS configuration
-+ himalis.AddIdlRoute (gw.Get (0), Seconds (0.2), "forward", host0_srcid.c_str (), host1_srcid.c_str (),
-+ gw_sim1_v4.c_str (), host1_sim0_v4.c_str (), "sim1");
-+ himalis.AddIdlRoute (gw.Get (0), Seconds (0.2), "forward", host1_srcid.c_str (), host0_srcid.c_str (),
-+ "10.0.0.1", "10.0.0.2", "sim0");
-+ // gw_sim0.c_str (), host0_sim0.c_str (), "sim0");
-+ himalis.ShowIdlRoute (gw.Get (0), Seconds (0.2));
-+ RunIp (gw.Get (0), Seconds (1.0), "addr list");
-+
-+ // Host0 (MN)
-+ RunIp (hosts.Get (0), Seconds (0.1), "link set lo up");
-+ RunIp (hosts.Get (0), Seconds (0.1), "link set sim0 up");
-+ RunIp (hosts.Get (0), Seconds (0.2), "-f inet addr add 10.0.0.2/24 dev sim0");
-+ RunIp (hosts.Get (0), Seconds (0.2), "-f inet route add default via 10.0.0.1");
-+ RunIp (hosts.Get (0), Seconds (0.2), "-f inet6 addr add " + host0_sim0 + "/64 dev sim0");
-+ RunIp (hosts.Get (0), Seconds (0.2), "-f inet6 route add default via "+ gw_sim0);
-+ himalis.AddIdlRoute (hosts.Get (0), Seconds (0.2), "host", host0_srcid.c_str (), host1_srcid.c_str (),
-+ "10.0.0.2", "10.0.0.1", "sim0");
-+ // host0_sim0.c_str (), gw_sim0.c_str (), "sim0");
-+ himalis.ShowIdlRoute (hosts.Get (0), Seconds (0.2));
-+ RunIp (hosts.Get (0), Seconds (1.0), "addr list");
-+
-+ // Host1 (CN)
-+ RunIp (hosts.Get (1), Seconds (0.1), "link set lo up");
-+ RunIp (hosts.Get (1), Seconds (0.1), "link set sim0 up");
-+ RunIp (hosts.Get (1), Seconds (0.2), "-f inet addr add " + host1_sim0_v4 + "/24 dev sim0");
-+ RunIp (hosts.Get (1), Seconds (0.2), "-f inet route add default via " + gw_sim1_v4);
-+ RunIp (hosts.Get (1), Seconds (0.2), "-f inet6 addr add " + host1_sim0_v6 + "/64 dev sim0");
-+ RunIp (hosts.Get (1), Seconds (0.2), "-f inet6 route add default via " + gw_sim1_v6);
-+ himalis.AddIdlRoute (hosts.Get (1), Seconds (0.2), "host", host1_srcid.c_str (), host0_srcid.c_str (),
-+ host1_sim0_v4.c_str (), gw_sim1_v4.c_str (), "sim0");
-+
-+ // Applications
-+ DceApplicationHelper process;
-+ ApplicationContainer apps;
-+ // server install to host1
-+ process.SetBinary ("idecho-s");
-+ process.ResetArguments ();
-+ process.ParseArguments ("-s " + host1_srcid);
-+ process.SetStackSize (1<<16);
-+ apps = process.Install (hosts.Get (1));
-+ apps.Start (Seconds (4.0));
-+
-+ // client install to host0
-+ process.SetBinary ("idecho-c");
-+ process.ResetArguments ();
-+ process.ParseArguments ("-s " + host0_srcid);
-+ process.ParseArguments ("-d " + host1_srcid);
-+ process.SetStackSize (1<<16);
-+ apps = process.Install (hosts.Get (0));
-+ apps.Start (Seconds (5.0));
-+
-+ p2p.EnablePcapAll ("dce-himalis");
-+
-+ Simulator::Stop (Seconds (stopTime));
-+ Simulator::Run ();
-+ Simulator::Destroy ();
-+
-+ NS_LOG_INFO ("End of experiment");
-+
-+ return 0;
-+}
-diff -r 9f12d65beb55 example/dce-linux.cc
---- a/example/dce-linux.cc Thu Mar 29 13:55:58 2012 +0900
-+++ b/example/dce-linux.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -103,7 +103,7 @@
- }
-
- DceManagerHelper processManager;
-- // processManager.SetLoader ("ns3::DlmLoaderFactory");
-+ processManager.SetLoader ("ns3::DlmLoaderFactory");
- processManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
- "Library", StringValue ("libfreebsd.git.so"));
- processManager.Install (nodes);
-diff -r 9f12d65beb55 example/himalis/idecho-c.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/example/himalis/idecho-c.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,163 @@
-+/*****************************
-+ * TP/ID/Locator echo client *
-+ * *
-+ * How to make. *
-+ * $ gcc THISFILE -lidlconn *
-+ *****************************/
-+
-+#include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <unistd.h>
-+#include <signal.h>
-+
-+#include <sys/socket.h>
-+#include <sys/types.h>
-+#include <netinet/in.h>
-+#include <arpa/inet.h>
-+
-+#include "idl.h" /* XXX */
-+
-+#define BUFFER_SIZE 1 * 1024 // XXX: avoid stack overflow
-+#define DEFAULT_SERVER_PORT 6001
-+
-+
-+int connect_sockfd;
-+const int one = 1;
-+
-+void err_func(const char *msg)
-+{
-+ perror(msg);
-+ exit(EXIT_FAILURE);
-+}
-+
-+void sigint_handler(int sig)
-+{
-+ close(connect_sockfd);
-+ fprintf(stderr, "-- Disonnected --\n");
-+ exit(EXIT_SUCCESS);
-+}
-+
-+char buf[BUFFER_SIZE], id_src_str[IDL_IDSTRLEN], id_dst_str[IDL_IDSTRLEN];
-+int main(int argc, char **argv)
-+{
-+ int read_siz = 0, write_siz, wrote_siz = 0;
-+ int opt, idlconn_ecode, http_status = -1, connect_sockfd;
-+ struct idl_id src_id, dst_id;
-+ struct sockid_idl idaddr;
-+ unsigned short port = DEFAULT_SERVER_PORT;
-+
-+ while ((opt = getopt(argc, argv, "hd:s:p:")) != -1) {
-+ switch (opt) {
-+ case 'p':
-+ port = (unsigned short)atoi(optarg);
-+ break;
-+ case 's':
-+ memcpy (id_src_str, optarg, strlen (optarg));
-+ break;
-+ case 'd':
-+ memcpy (id_dst_str, optarg, strlen (optarg));
-+ break;
-+ default:
-+ goto missing_operand;
-+ }
-+ }
-+
-+ idl_pton(id_src_str, &src_id);
-+ fprintf(stdout, "Client ID : %s\n", id_src_str);
-+ idl_pton(id_dst_str, &dst_id);
-+ fprintf(stdout, "Server ID : %s\n", id_dst_str);
-+ fprintf(stdout, "Server Port: %d\n", port);
-+
-+ if ((connect_sockfd = socket(PF_IDL,
-+ SOCK_STREAM, 0)) < 0)
-+ err_func("socket");
-+
-+ if (setsockopt(connect_sockfd,
-+ SOL_SOCKET, SO_REUSEADDR, &one, sizeof(int)) < 0)
-+ err_func("setsockopt");
-+
-+ idaddr.sidl_family = IDF_IDL;
-+ idaddr.sidl_port = 0;
-+ memcpy (&idaddr.sidl_id, &src_id, sizeof (src_id));
-+
-+ if (bind(connect_sockfd, (struct sockaddr *)&idaddr, sizeof(idaddr)) < 0)
-+ err_func("bind");
-+
-+ idaddr.sidl_family = IDF_IDL;
-+ idaddr.sidl_port = htons(port);
-+ memcpy (&idaddr.sidl_id, &dst_id, sizeof (dst_id));
-+
-+ if (connect(connect_sockfd, (struct sockaddr *)&idaddr, sizeof(idaddr)) < 0)
-+ err_func("connect");
-+
-+ fprintf(stderr, "-- Connected --\n");
-+
-+ if (SIG_ERR == signal(SIGINT, sigint_handler))
-+ err_func("signal");
-+
-+ do
-+ {
-+ fprintf(stderr, "-> ");
-+#if 0
-+ if (fgets(buf, BUFFER_SIZE, stdin) == NULL) {
-+ if (ferror(stdin))
-+ err_func("fgets");
-+ if (feof(stdin))
-+ break;
-+ }
-+ fflush(stdin);
-+ write_siz = strlen(buf);
-+#endif
-+
-+
-+ do
-+ {
-+ char sendbuf[16] = "send echo\n";
-+ wrote_siz = 0;
-+ write_siz = sizeof (sendbuf);
-+ fprintf(stderr, "send-->%s\n", sendbuf);
-+ int result = send(connect_sockfd,
-+ sendbuf,
-+ write_siz, 0);
-+ if (result < 0)
-+ err_func("send");
-+
-+ wrote_siz += result;
-+ } while (wrote_siz < write_siz);
-+
-+ do
-+ {
-+ int result = recv(connect_sockfd,
-+ buf + read_siz,
-+ wrote_siz - read_siz, 0);
-+ if (result < 0)
-+ err_func("recv");
-+
-+ read_siz += result;
-+
-+ } while (read_siz < write_siz);
-+
-+ buf[read_siz] = '\0';
-+ fprintf(stderr, "<- ");
-+ fprintf(stdout, "%s", buf);
-+ fprintf(stderr, "\n");
-+
-+ wrote_siz = 0;
-+ read_siz = 0;
-+ } while (strncmp(buf, "EXIT\r\n", 6) != 0
-+ && strncmp(buf, "EXIT\n", 5) != 0);
-+
-+ close(connect_sockfd);
-+ fprintf(stderr, "-- Disonnected --\n");
-+ exit(EXIT_SUCCESS);
-+
-+missing_operand:
-+ printf(
-+ "Usage: %s [-n DST HOST NAME] [-d DST DOMAIN NAME]\n"
-+ " -- Optional --\n"
-+ "<-p SERVER PORT> Default server port is 6001.\n"
-+ , argv[0], DEFAULT_SERVER_PORT
-+ );
-+ exit(EXIT_FAILURE);
-+}
-diff -r 9f12d65beb55 example/himalis/idecho-s.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/example/himalis/idecho-s.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,146 @@
-+/*****************************
-+ * TP/ID/Locator echo server *
-+ * *
-+ * How to make. *
-+ * $ gcc THISFILE -lidlconn *
-+ *****************************/
-+
-+#include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <unistd.h>
-+#include <signal.h>
-+
-+#include <sys/socket.h>
-+#include <sys/types.h>
-+#include <netinet/in.h>
-+#include <arpa/inet.h>
-+
-+#include "idl.h" /* XXX */
-+
-+#define BUFFER_SIZE 1 * 1024
-+#define DEFAULT_LISTEN_PORT 6001
-+#define RCV_TIMEOUT_SEC 300
-+
-+int listen_sockfd, accept_sockfd = 0;
-+const int TRUE = 1;
-+
-+void err_func(const char *msg)
-+{
-+ perror(msg);
-+ exit(EXIT_FAILURE);
-+}
-+
-+void sigint_handler(int sig)
-+{
-+ close(listen_sockfd);
-+
-+ if (accept_sockfd != -1) {
-+ close(accept_sockfd);
-+ fprintf(stderr, "-- Disconnected --\n");
-+ }
-+
-+ exit(EXIT_SUCCESS);
-+}
-+
-+char buf[BUFFER_SIZE], id_str[IDL_IDSTRLEN];
-+int main(int argc, char **argv)
-+{
-+ int read_siz, wrote_siz = 0;
-+ int opt;
-+ struct idl_id src_id;
-+ struct sockid_idl idaddr;
-+ socklen_t sidl_siz;
-+ unsigned short port = DEFAULT_LISTEN_PORT;
-+
-+ while ((opt = getopt(argc, argv, "hp:s:")) != -1) {
-+ switch (opt) {
-+ case 'p':
-+ port = (unsigned short)atoi(optarg);
-+ break;
-+ case 's':
-+ memcpy (id_str, optarg, strlen (optarg));
-+ break;
-+ default:
-+ fprintf(stderr, "Usage: %s\n"
-+ " -- Optional--\n"
-+ "<-p PORT> Default listen port is %d.\n"
-+ "<-i ID_STR> Id string.\n"
-+ , argv[0], DEFAULT_LISTEN_PORT);
-+ exit(EXIT_FAILURE);
-+ }
-+ }
-+
-+ idl_pton(id_str, &src_id);
-+ fprintf(stdout, "Server ID : %s\n", id_str);
-+ fprintf(stdout, "Listen Port: %d\n", port);
-+
-+ if ((listen_sockfd = socket(PF_IDL,
-+ SOCK_STREAM, 0)) < 0)
-+ err_func("socket");
-+
-+ if (setsockopt(listen_sockfd,
-+ SOL_SOCKET, SO_REUSEADDR, &TRUE, sizeof(int)) < 0)
-+ err_func("setsockopt");
-+
-+ idaddr.sidl_family = IDF_IDL;
-+ idaddr.sidl_port = htons(port);
-+ memcpy (&idaddr.sidl_id, &src_id, sizeof (src_id));
-+ sidl_siz = sizeof(struct sockid_idl);
-+
-+ if (bind(listen_sockfd, (struct sockaddr *)&idaddr, sidl_siz) < 0)
-+ err_func("bind");
-+
-+ fprintf(stderr, "-- Listening --\n");
-+ if (listen(listen_sockfd, SOMAXCONN) < 0)
-+ err_func("listen");
-+
-+ if (SIG_ERR == signal(SIGINT, sigint_handler))
-+ err_func("signal");
-+
-+ while (1)
-+ {
-+ if ((accept_sockfd = accept(listen_sockfd,
-+ (struct sockaddr *)&idaddr, &sidl_siz)) < 0)
-+ err_func("accept");
-+
-+ if (setsockopt(accept_sockfd,
-+ SOL_SOCKET, SO_REUSEADDR, &TRUE, sizeof(int)) < 0)
-+ err_func("setsockopt");
-+
-+ fprintf(stderr, "-- Connected --\n");
-+ idl_ntop(&idaddr.sidl_id, id_str, IDL_IDSTRLEN);
-+ fprintf(stderr, "Client ID : %s\n", id_str);
-+
-+ do
-+ {
-+ read_siz = recv(accept_sockfd, buf, BUFFER_SIZE, 0);
-+ if (read_siz < 0)
-+ err_func("recv");
-+ if (read_siz < 1)
-+ break;
-+
-+ buf[read_siz] = '\0';
-+ fprintf(stderr, "<- len=%d", read_siz);
-+ fprintf(stdout, "%s\n", buf);
-+
-+ do
-+ {
-+ int result = send(accept_sockfd,
-+ buf + wrote_siz,
-+ read_siz - wrote_siz, 0);
-+ if (result < 0)
-+ err_func("send");
-+
-+ wrote_siz += result;
-+ } while (wrote_siz < read_siz);
-+
-+ wrote_siz = 0;
-+ } while (strncmp(buf, "EXIT\r\n", 6) != 0 &&
-+ strncmp(buf, "EXIT\n", 5) != 0);
-+
-+ fprintf(stderr, "-- Disonnected --\n");
-+ close(accept_sockfd);
-+ accept_sockfd = -1;
-+ }
-+}
-diff -r 9f12d65beb55 example/himalis/idl.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/example/himalis/idl.h Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,331 @@
-+/*
-+ * ID/Locator Split Architectur Implementation
-+ *
-+ * This header file provides interface of connect to another host APIs definition.
-+ */
-+
-+
-+#ifndef _IDL_H
-+#define _IDL_H
-+
-+#include <stdbool.h>
-+#include <string.h>
-+#include <errno.h>
-+
-+#include <linux/types.h>
-+
-+/*
-+ * Socket ID
-+ */
-+#define sockid sockaddr
-+
-+
-+/*
-+ * ID family and protocol family
-+ */
-+#define IDF_IDL (37)
-+#define PF_IDL IDF_IDL
-+
-+
-+/*
-+ * TP/ID/L protocol number
-+ */
-+#define IPPROTO_TPIDL (254)
-+
-+
-+/*
-+ * Misc
-+ */
-+#define IDL_IDLEN 16
-+#define IDL_ID16LEN 8
-+#define IDL_ID32LEN 4
-+#define IDL_IDSTRLEN 40
-+#define IDL_ID_DELIM "-"
-+#define IDL_ID_ABBR_DELIM "--"
-+
-+
-+/*
-+ * The ID/Locator protocol ID structure
-+ */
-+struct idl_id {
-+ union
-+ {
-+ __u8 uidl_id8[16];
-+ __be16 uidl_id16[8];
-+ __be32 uidl_id32[4];
-+ } idl_u;
-+#define sidl_id8 idl_u.uidl_id8
-+#define sidl_id16 idl_u.uidl_id16
-+#define sidl_id32 idl_u.uidl_id32
-+};
-+
-+
-+/*
-+ * Socket ID for The ID/Locator system
-+ */
-+struct sockid_idl {
-+ unsigned short int sidl_family; /* IDF_IDL or PF_IDL */
-+ __be16 sidl_port; /* Transport layer port */
-+ __be32 sidl__flowinfo; /* Flow information (reserved field) */
-+ struct idl_id sidl_id; /* ID */
-+ __u32 sidl__scope_id; /* scope id (reserved field) */
-+};
-+
-+
-+/*
-+ * Network format ID to printable format
-+ */
-+static inline int idl_ntop(const struct idl_id *id, char *id_str, size_t id_str_len)
-+{
-+ __be16 *id16p = (__be16 *) id;
-+ int i, j, n, abberv_len = 0;
-+ char *outp = id_str;
-+ bool abbrev = false;
-+
-+ if (id == NULL || id_str == NULL || id_str_len < 2) {
-+ errno = EINVAL;
-+ return -1;
-+ }
-+
-+ for (i = j = 0; i < IDL_ID16LEN; i++) {
-+ while (i < IDL_ID16LEN && id16p[i] == 0) {
-+ i++;
-+ j++;
-+ }
-+
-+ if (j > abberv_len)
-+ abberv_len = j;
-+
-+ j = 0;
-+ }
-+
-+ for (i = j = 0; i < IDL_ID16LEN; i++) {
-+ if (!abbrev && id16p[i] == 0) {
-+ while (i < IDL_ID16LEN && id16p[i] == 0) {
-+ i++;
-+ j++;
-+ }
-+ if (j == abberv_len) {
-+ n = snprintf(outp, id_str_len, "%s", i > IDL_ID16LEN - 1 ? IDL_ID_ABBR_DELIM : IDL_ID_DELIM);
-+ if (n < 0 || n >= id_str_len) {
-+ errno = ENOMEM;
-+ return -1;
-+ }
-+ outp += n;
-+ id_str_len -= n;
-+ abbrev = true;
-+ }
-+ else {
-+ i -= j;
-+ j = 0;
-+ }
-+ }
-+
-+ if (i < IDL_ID16LEN) {
-+ n = snprintf(outp, id_str_len, "%s%x", i ? IDL_ID_DELIM : "", ntohs(id16p[i]));
-+
-+ if (n < 0 || n >= id_str_len) {
-+ errno = ENOMEM;
-+ return -1;
-+ }
-+ outp += n;
-+ id_str_len -= n;
-+ }
-+ }
-+
-+ return 0;
-+}
-+
-+
-+/*
-+ * Printable format ID to network format
-+ */
-+static inline int __idl_ip6like_pton(const char *id_str, struct idl_id *id)
-+{
-+ size_t id_str_len = strlen(id_str);
-+ int i = 0;
-+
-+ memset(id, 0, sizeof(*id));
-+
-+ if (id_str_len == 2) {
-+ if (strcmp(id_str, "::") == 0)
-+ return 0;
-+ else {
-+ errno = EINVAL;
-+ return -1;
-+ }
-+ }
-+
-+ if (id_str_len < 2 || id_str_len > IDL_IDSTRLEN) {
-+ errno = EINVAL;
-+ return -1;
-+ }
-+
-+ const char *cursor = id_str;
-+ const char *abbrev_delim;
-+ char *next_delim;
-+ int j = IDL_ID16LEN, abbrev_len = 0, delim_cnt = 0;
-+ long id_elm;
-+
-+ if ((abbrev_delim = strstr(id_str, "::")) != NULL) {
-+ if (strstr(abbrev_delim + 1, "::")) {
-+ errno = EINVAL; // Because, "::" cannot duplicate
-+ return -1;
-+ }
-+
-+ abbrev_len = IDL_ID16LEN;
-+ while((cursor = strchr(cursor, *":")) != NULL) {
-+ abbrev_len--;
-+ cursor++;
-+ }
-+
-+ if (abbrev_len < 0 || abbrev_len > IDL_ID16LEN - 2) {
-+ errno = EINVAL; // "--" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ cursor = id_str; // Initialize
-+ if (abbrev_delim == id_str) {
-+ i = abbrev_len + 1;
-+ cursor += 2;
-+ }
-+ }
-+ else {
-+ while((cursor = strchr(cursor, *":")) != NULL) {
-+ delim_cnt++;
-+ cursor++;
-+ }
-+
-+ if (delim_cnt != IDL_ID16LEN -1) {
-+ errno = EINVAL; // "::" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ if (*id_str == *":" ||
-+ *(id_str + id_str_len - 1) == *":") {
-+ errno = EINVAL; // "::" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ i = 0;
-+ cursor = id_str; // Initialize
-+ }
-+
-+ for (; i < j; i++) {
-+ id_elm = strtol(cursor, &next_delim, 16);
-+ if (id_elm < 0 || id_elm > 0xffff) {
-+ errno = EINVAL; // "::" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ id->sidl_id16[i] = htons((__be16)id_elm);
-+
-+ if (next_delim == abbrev_delim) {
-+ i += abbrev_len;
-+ next_delim++;
-+ }
-+
-+ cursor = next_delim + 1;
-+ }
-+
-+ return 0;
-+}
-+
-+
-+/*
-+ * Printable format ID to network format
-+ */
-+static inline int idl_pton(const char *id_str, struct idl_id *id)
-+{
-+ size_t id_str_len = strlen(id_str);
-+ int i = 0;
-+
-+ memset(id, 0, sizeof(*id));
-+
-+ if (id_str_len == 2) {
-+ if (strcmp(id_str, IDL_ID_ABBR_DELIM) == 0) // This meens "--"
-+ return 0;
-+ else {
-+ errno = EINVAL;
-+ return -1;
-+ }
-+ }
-+
-+ if (id_str_len < 2 || id_str_len > IDL_IDSTRLEN) {
-+ errno = EINVAL;
-+ return -1;
-+ }
-+
-+ const char *cursor = id_str;
-+ const char *abbrev_delim;
-+ char *next_delim;
-+ int j = IDL_ID16LEN, abbrev_len = 0, delim_cnt = 0;
-+ long id_elm;
-+
-+ if ((abbrev_delim = strstr(id_str, IDL_ID_ABBR_DELIM)) != NULL) {
-+ if (strstr(abbrev_delim + 1, IDL_ID_ABBR_DELIM)) {
-+ errno = EINVAL; // Because, "--" cannot duplicate
-+ return -1;
-+ }
-+
-+ abbrev_len = IDL_ID16LEN;
-+ while((cursor = strchr(cursor, *IDL_ID_DELIM)) != NULL) {
-+ abbrev_len--;
-+ cursor++;
-+ }
-+
-+ if (abbrev_len < 0 || abbrev_len > IDL_ID16LEN - 2) {
-+ errno = EINVAL; // "--" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ cursor = id_str; // Initialize
-+ if (abbrev_delim == id_str) {
-+ i = abbrev_len + 1;
-+ cursor += 2;
-+ }
-+ }
-+ else {
-+ while((cursor = strchr(cursor, *IDL_ID_DELIM)) != NULL) {
-+ delim_cnt++;
-+ cursor++;
-+ }
-+
-+ if (delim_cnt != IDL_ID16LEN -1) {
-+ errno = EINVAL; // "--" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ if (*id_str == *IDL_ID_DELIM ||
-+ *(id_str + id_str_len - 1) == *IDL_ID_DELIM) {
-+ errno = EINVAL; // "--" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ i = 0;
-+ cursor = id_str; // Initialize
-+ }
-+
-+ for (; i < j; i++) {
-+ id_elm = strtol(cursor, &next_delim, 16);
-+ if (id_elm < 0 || id_elm > 0xffff) {
-+ errno = EINVAL; // "--" can include 0 to 6 x 16 bit
-+ return -1;
-+ }
-+
-+ id->sidl_id16[i] = htons((__be16)id_elm);
-+
-+ if (next_delim == abbrev_delim) {
-+ i += abbrev_len;
-+ next_delim++;
-+ }
-+
-+ cursor = next_delim + 1;
-+ }
-+
-+ return 0;
-+}
-+
-+#endif /* _IDL_H */
-+
-+
-diff -r 9f12d65beb55 helper/himalis-helper.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/helper/himalis-helper.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,212 @@
-+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-+/*
-+ * Copyright (c) 2012 NICT
-+ *
-+ * 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: Hajime Tazaki <tazaki@nict.go.jp>
-+ */
-+
-+#include <Python.h>
-+#include "himalis-helper.h"
-+#include "ns3/object-factory.h"
-+#include "ns3/names.h"
-+#include "ns3/log.h"
-+#include "ns3/event-id.h"
-+#include "ns3/simulator.h"
-+
-+NS_LOG_COMPONENT_DEFINE ("HimalisHelper");
-+
-+namespace ns3 {
-+
-+
-+
-+
-+HimalisHelper::HimalisHelper ()
-+{
-+ InitIdlRoutePy ();
-+}
-+
-+HimalisHelper::~HimalisHelper ()
-+{
-+ Py_Finalize();
-+}
-+
-+PyObject *m_pycode = NULL;
-+
-+void
-+HimalisHelper::InitIdlRoutePy ()
-+{
-+ Py_Initialize();
-+ const char *argv[] = {"python", NULL};
-+ PySys_SetArgv(1, (char **)argv);
-+
-+ try
-+ {
-+ m_pycode = PyImport_ImportModule("idlroute");
-+ int i=0;
-+
-+ if(m_pycode == NULL)
-+ {
-+ PyErr_Print();
-+ throw "Unappropriate Python syntax";
-+ }
-+ }
-+ catch(const char* msg)
-+ {
-+ NS_LOG_WARN ("ERROR :" << msg );
-+ }
-+ catch(...)
-+ {
-+ NS_LOG_WARN ("ERROR : Something Error");
-+ }
-+}
-+
-+void
-+HimalisHelper::AddIdlRoute (Ptr<Node> node, Time at, const char * host_or_fw,
-+ const char * src_id, const char * dst_id,
-+ const char * src_addr, const char * dst_addr,
-+ const char *dev_name)
-+{
-+ std::string format = "(ssssss)";
-+ PyObject* cmd_buf = NULL;
-+ std::string value;
-+
-+ try{
-+ cmd_buf = PyObject_CallMethod(m_pycode, (char *)"mk_add_route_cmd\0", (char *)format.c_str (),
-+ host_or_fw, src_id, dst_id, src_addr, dst_addr, dev_name);
-+ if(cmd_buf == NULL)
-+ {
-+
-+ PyErr_Print();
-+ throw "Unappropriate Python syntax";
-+ NS_LOG_WARN ("ERROR :" << cmd_buf );
-+ }
-+ if (cmd_buf != Py_None && PyString_CheckExact(cmd_buf))
-+ value = std::string(PyString_AsString(cmd_buf));
-+ else
-+ value = "None";
-+ }
-+ catch(const char* msg)
-+ {
-+ NS_LOG_WARN ("ERROR :" << msg );
-+ return;
-+ }
-+
-+ NS_LOG_DEBUG ("return value from python = " << value);
-+
-+ Ptr<LinuxSocketFdFactory> kern = node->GetObject<LinuxSocketFdFactory>();
-+ std::string key (".net.idl.idlrt");
-+ Simulator::ScheduleWithContext (node->GetId (), at,
-+ MakeEvent (&LinuxSocketFdFactory::Set, kern,
-+ key, value));
-+
-+ Py_DECREF(cmd_buf);
-+}
-+
-+void
-+HimalisHelper::DelIdlRoute (Ptr<Node> node, Time at,
-+ const char * src_id, const char * dst_id)
-+{
-+ std::string value;
-+ const char *format = "(ss)";
-+
-+ PyObject* cmd_buf = PyObject_CallMethod(m_pycode, (char *)"mk_del_route_cmd",
-+ (char *)format,
-+ src_id, dst_id);
-+ if(cmd_buf == NULL)
-+ {
-+ PyErr_Print();
-+ throw "Unappropriate Python syntax";
-+ }
-+ if (cmd_buf != Py_None && PyString_CheckExact(cmd_buf))
-+ value = std::string(PyString_AsString(cmd_buf));
-+ else
-+ value = "None";
-+
-+ NS_LOG_DEBUG ("return value from python = " << value);
-+ Ptr<LinuxSocketFdFactory> kern = node->GetObject<LinuxSocketFdFactory>();
-+ std::string key (".net.idl.idlrt");
-+ Simulator::ScheduleWithContext (node->GetId (), at,
-+ MakeEvent (&LinuxSocketFdFactory::Set, kern,
-+ key, value));
-+ Py_DECREF(cmd_buf);
-+}
-+
-+void
-+PrintIdlRoute (Ptr<Node> node)
-+{
-+ std::string key (".net.idl.idlrt");
-+ Ptr<LinuxSocketFdFactory> kern = node->GetObject<LinuxSocketFdFactory>();
-+ std::string buffer = kern->Get (key);
-+ NS_LOG_INFO ("ShowIdlRoute " << buffer);
-+}
-+
-+void
-+HimalisHelper::ShowIdlRoute (Ptr<Node> node, Time at)
-+{
-+ Ptr<LinuxSocketFdFactory> kern = node->GetObject<LinuxSocketFdFactory>();
-+ Simulator::ScheduleWithContext (node->GetId (), at,
-+ &LinuxSocketFdFactory::ScheduleTask, kern,
-+ MakeEvent (PrintIdlRoute, node));
-+}
-+
-+void
-+HimalisHelper::SetAttribute (std::string name, const AttributeValue &value)
-+{
-+}
-+
-+
-+ApplicationContainer
-+HimalisHelper::Install (Ptr<Node> node)
-+{
-+ return ApplicationContainer (InstallPriv (node));
-+}
-+
-+ApplicationContainer
-+HimalisHelper::Install (std::string nodeName)
-+{
-+ Ptr<Node> node = Names::Find<Node> (nodeName);
-+ return ApplicationContainer (InstallPriv (node));
-+}
-+
-+ApplicationContainer
-+HimalisHelper::Install (NodeContainer c)
-+{
-+ ApplicationContainer apps;
-+ for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
-+ {
-+ apps.Add (InstallPriv (*i));
-+ }
-+
-+ return apps;
-+}
-+
-+ApplicationContainer
-+HimalisHelper::InstallPriv (Ptr<Node> node)
-+{
-+ DceApplicationHelper process;
-+ ApplicationContainer apps;
-+
-+ return apps;
-+ process.SetBinary ("zebra");
-+ // process.AddArguments ("-i", "/usr/local/etc/zebra.pid");
-+ process.SetStackSize (1<<16);
-+ apps.Add (process.Install (node));
-+ apps.Get(0)->SetStartTime (Seconds (10.0 + 0.01 * node->GetId ()));
-+ node->AddApplication (apps.Get (0));
-+ return apps;
-+}
-+
-+} // namespace ns3
-diff -r 9f12d65beb55 helper/himalis-helper.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/helper/himalis-helper.h Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,103 @@
-+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-+/*
-+ * Copyright (c) 2012 NICT
-+ *
-+ * 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: Hajime Tazaki <tazaki@nict.go.jp>
-+ */
-+#ifndef HIMALIS_HELPER_H
-+#define HIMALIS_HELPER_H
-+
-+#include "dce-manager-helper.h"
-+#include "dce-application-helper.h"
-+#include "linux-socket-fd-factory.h"
-+
-+namespace ns3 {
-+
-+/**
-+ * \brief create a himalis routing daemon as an application and associate it to a node
-+ *
-+ * This class creates one or multiple instances of ns3::Himalis and associates
-+ * it/them to one/multiple node(s).
-+ */
-+class HimalisHelper : public Object
-+{
-+public:
-+ /**
-+ * Create a HimalisHelper which is used to make life easier for people wanting
-+ * to use himalis Applications.
-+ *
-+ */
-+ HimalisHelper ();
-+ ~HimalisHelper ();
-+
-+
-+ void InitIdlRoutePy ();
-+ /**
-+ * Install a himalis application on each Node in the provided NodeContainer.
-+ *
-+ * \param nodes The NodeContainer containing all of the nodes to get a himalis
-+ * application via ProcessManager.
-+ *
-+ * \returns A list of himalis applications, one for each input node
-+ */
-+ ApplicationContainer Install (NodeContainer nodes);
-+
-+ /**
-+ * Install a himalis application on the provided Node. The Node is specified
-+ * directly by a Ptr<Node>
-+ *
-+ * \param node The node to install the HimalisApplication on.
-+ *
-+ * \returns An ApplicationContainer holding the himalis application created.
-+ */
-+ ApplicationContainer Install (Ptr<Node> node);
-+
-+ /**
-+ * Install a himalis application on the provided Node. The Node is specified
-+ * by a string that must have previosly been associated with a Node using the
-+ * Object Name Service.
-+ *
-+ * \param nodeName The node to install the ProcessApplication on.
-+ *
-+ * \returns An ApplicationContainer holding the himalis application created.
-+ */
-+ ApplicationContainer Install (std::string nodeName);
-+
-+ /**
-+ * \brief Configure ping applications attribute
-+ * \param name attribute's name
-+ * \param value attribute's value
-+ */
-+ void SetAttribute (std::string name, const AttributeValue &value);
-+
-+ void AddIdlRoute (Ptr<Node> node, Time at, const char * host_or_fw,
-+ const char * src_id, const char * dst_id,
-+ const char * src_addr, const char * dst_addr,
-+ const char *dev_name);
-+ void DelIdlRoute (Ptr<Node> node, Time at,
-+ const char * src_id, const char * dst_id);
-+ void ShowIdlRoute (Ptr<Node> node, Time at);
-+
-+private:
-+ /**
-+ * \internal
-+ */
-+ ApplicationContainer InstallPriv (Ptr<Node> node);
-+};
-+
-+} // namespace ns3
-+
-+#endif /* HIMALIS_HELPER_H */
-diff -r 9f12d65beb55 idlroute
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/idlroute Thu Mar 29 13:58:16 2012 +0900
-@@ -0,0 +1,328 @@
-+#! /usr/bin/python
-+# -*- coding: utf-8 -*-
-+
-+import os
-+import sys
-+import socket
-+import fcntl
-+import struct
-+
-+
-+IDF_IDLOC = socket.AF_INET6
-+PROC_DELIMITER = ','
-+PROC_IDL_ROUTE = '/proc/net/idlrt'
-+
-+ADD = 'add'
-+DEL = 'del'
-+HOST = 'host'
-+FORWARD = 'frwd'
-+IPV4 = 'ipv4'
-+IPV6 = 'ipv6'
-+
-+FLAG_HOST = 1
-+FLAG_FORWARD = 2
-+FLAG_IPV4 = 4
-+FLAG_IPV6 = 8
-+
-+PROC_IF_INET6 = '/proc/net/if_inet6'
-+PROC_NET_DEV = '/proc/net/dev'
-+
-+ID_DELIMITER = '-'
-+
-+def usage():
-+ print '\
-+Usage: idlroute [show|stat|add|delete] opt...\n\
-+\n\
-+ Show route\n\
-+ show\n\
-+\n\
-+ Show traffic status\n\
-+ stat [SRC_ID] [DST_ID]\n\
-+\n\
-+ Add host route\n\
-+ add host [SRC_ID] [DST_ID] [SRC_LOCATOR] [DST_LOCATOR]\n\
-+\n\
-+ Add forward route\n\
-+ add forward [SRC_ID] [DST_ID] [NEXT_SRC_LOCATOR] [NEXT_DST_LOCATOR]\n\
-+\n\
-+ Delete route\n\
-+ delete [SRC_ID] [DST_ID]\n\
-+ * No particular order: [SRC_ID] [DST_ID] <-> [DST_ID] [SRC_ID]\n\
-+ * If there is an ID entry for opposite way, then both are deleted.\n'
-+
-+
-+def search_dev_by_ipv4_addr(addr):
-+ dev_names = []
-+ addr_dict = {}
-+
-+ f = open(PROC_NET_DEV, 'r')
-+ # Format of PROC_NET_DEV
-+ # Inter-| Receive
-+ # face |bytes packets errs drop fifo frame compressed ...
-+ # lo: 240 4 0 0 0 0 0 ...
-+ # eth0: 7246766 70183 0 0 0 0 0 ...
-+ # ...
-+ lines = f.readlines()
-+ f.close
-+
-+ for line in lines[2:]:
-+ dev_names.append(line.split()[0].split(":")[0])
-+
-+ for dev_name in dev_names:
-+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-+ try:
-+ addr_dict[socket.inet_ntoa(fcntl.ioctl(
-+ s.fileno(),0x8915, # SIOCGIFADDR
-+ struct.pack('256s', dev_name[:15]))[20:24])
-+ ] = dev_name
-+ except:
-+ pass
-+
-+ try:
-+ return addr_dict[addr]
-+ except:
-+ return None
-+
-+
-+def search_dev_by_ipv6_addr(addr):
-+ dev_name = None
-+
-+ f = open(PROC_IF_INET6, 'r')
-+ # Format of PROC_IF_INET6
-+ # 20010c901b8d03095a946bfffe1c76d0 03 40 00 00 eth0
-+ # ...
-+ lines = f.readlines()
-+ f.close
-+
-+ for line in lines:
-+ addr_dev = line.split()
-+ if (addr == addr_dev[0]):
-+ dev_name = addr_dev[5]
-+ break
-+
-+ return dev_name
-+
-+
-+def mk_add_route_cmd(host_or_fw, id_1, id_2, src_addr, dst_addr, exp_dev_name):
-+ buff = ADD + PROC_DELIMITER
-+ if (host_or_fw == 'host'):
-+ buff += HOST + PROC_DELIMITER
-+ src_id = id_1;
-+ dst_id = id_2;
-+ elif (host_or_fw == 'forward'):
-+ buff += FORWARD + PROC_DELIMITER
-+ src_id = id_2;
-+ dst_id = id_1;
-+ else:
-+ print 'Error: Bad params.'
-+ return 1
-+
-+ try:
-+ buff += ''.join(map(lambda B: '%02x' % B, struct.unpack('16B',
-+ socket.inet_pton(socket.AF_INET6,
-+ src_id.replace(ID_DELIMITER, ":"))))) + PROC_DELIMITER
-+ buff += ''.join(map(lambda B: '%02x' % B, struct.unpack('16B',
-+ socket.inet_pton(socket.AF_INET6,
-+ dst_id.replace(ID_DELIMITER, ":"))))) + PROC_DELIMITER
-+ except:
-+ print 'Error: Illegal ID format.'
-+ return 1
-+
-+ # If source addr is IPv6.
-+ try:
-+ src_addr = ''.join(map(lambda B: '%02x' % B,
-+ struct.unpack('16B',
-+ socket.inet_pton(socket.AF_INET6, src_addr))))
-+ dev_name = search_dev_by_ipv6_addr(src_addr)
-+ except:
-+ # Else if source addr is IPv4.
-+ try:
-+ dev_name = search_dev_by_ipv4_addr(src_addr)
-+ src_addr = '00000000000000000000ffff' \
-+ + ''.join(map(lambda B: '%02x' % B, struct.unpack('4B',
-+ socket.inet_pton(socket.AF_INET, src_addr))))
-+ except:
-+ print 'Error: Illegal IP address format.'
-+ return 1
-+
-+ # If destination addr is IPv6 then.
-+ try:
-+ dst_addr = ''.join(map(lambda B: '%02x' % B,
-+ struct.unpack('16B',
-+ socket.inet_pton(socket.AF_INET6, dst_addr))))
-+ except:
-+ # Else if destination addr is IPv4.
-+ try:
-+ dst_addr = '00000000000000000000ffff' \
-+ + ''.join(map(lambda B: '%02x' % B, struct.unpack('4B',
-+ socket.inet_pton(socket.AF_INET, dst_addr))))
-+ except:
-+ print 'Error: Illegal IP address format.'
-+ return 1
-+
-+ if (dev_name == None):
-+ dev_name = exp_dev_name
-+ if (exp_dev_name == None):
-+ print 'Error: Network interface not found.'
-+ return 1
-+
-+ buff += src_addr + PROC_DELIMITER
-+ buff += dst_addr + PROC_DELIMITER
-+ buff += dev_name
-+ return buff
-+
-+def add_route(host_or_fw, id_1, id_2, src_addr, dst_addr):
-+ buff = mk_add_route_cmd(host_or_fw, id_1, id_2, src_addr, dst_addr)
-+ try:
-+ f = open(PROC_IDL_ROUTE, 'w')
-+ f.write(buff)
-+ f.close()
-+ except (IOError):
-+ print 'Error: I/O error.'
-+
-+
-+def mk_del_route_cmd(src_id, dst_id):
-+ buff = DEL + PROC_DELIMITER
-+ try:
-+ buff += ''.join(map(lambda B: '%02x' % B, struct.unpack('16B',
-+ socket.inet_pton(socket.AF_INET6, src_id.replace(ID_DELIMITER, ":"))))) + PROC_DELIMITER
-+ buff += ''.join(map(lambda B: '%02x' % B, struct.unpack('16B',
-+ socket.inet_pton(socket.AF_INET6, dst_id.replace(ID_DELIMITER, ":")))))
-+
-+ except:
-+ print 'Error: Illegal ID format.'
-+ return "ERROR"
-+ return buff
-+
-+def del_route(src_id, dst_id):
-+ buff = mk_del_route_cmd(src_id, dst_id)
-+ f = open(PROC_IDL_ROUTE, 'w')
-+ f.write(buff)
-+ f.close()
-+
-+
-+def show_route():
-+ f = open(PROC_IDL_ROUTE, 'r')
-+ lines = f.readlines()
-+ f.close()
-+
-+ print 'Flags Source ID Destination ID Source locator Destination locator'
-+ for line in lines:
-+ host_or_fw = ' '
-+ ip_version = ' '
-+ forward = False
-+
-+ rec = line.split(',')
-+
-+ # Flags
-+ flags = int(rec[0], 16)
-+ if (flags & FLAG_HOST):
-+ host_or_fw = 'H'
-+ if (flags & FLAG_FORWARD):
-+ host_or_fw = 'F'
-+ forward = True
-+ if (flags & FLAG_IPV4):
-+ ip_version = '4'
-+ if (flags & FLAG_IPV6):
-+ ip_version = '6'
-+
-+ # IDs
-+ id_1 = socket.inet_ntop(socket.AF_INET6, \
-+ socket.inet_pton(socket.AF_INET6, rec[1])).replace(":", ID_DELIMITER)
-+ id_2 = socket.inet_ntop(socket.AF_INET6, \
-+ socket.inet_pton(socket.AF_INET6, rec[2])).replace(":", ID_DELIMITER)
-+
-+ # Locators
-+ src_addr = socket.inet_ntop(socket.AF_INET6, \
-+ socket.inet_pton(socket.AF_INET6, rec[3]))
-+ dst_addr = socket.inet_ntop(socket.AF_INET6,
-+ socket.inet_pton(socket.AF_INET6, rec[4]))
-+
-+ if (ip_version == '4'):
-+ src_addr = src_addr.split('::ffff:')[-1]
-+ dst_addr = dst_addr.split('::ffff:')[-1]
-+
-+ # Host
-+ if (forward == False):
-+ print '%s%s %-24s %-24s %-24s %-24s' % \
-+ (host_or_fw, ip_version,
-+ id_1, id_2, src_addr, dst_addr)
-+ # Forward
-+ else:
-+ print '%s%s %-24s %-24s %-24s %-24s' % \
-+ (host_or_fw, ip_version,
-+ id_2, id_1, src_addr, dst_addr)
-+
-+
-+def stat_route(src_id, dst_id):
-+ src_id = socket.inet_ntop(socket.AF_INET6,
-+ socket.inet_pton(socket.AF_INET6, src_id.replace(ID_DELIMITER, ":")))
-+ dst_id = socket.inet_ntop(socket.AF_INET6,
-+ socket.inet_pton(socket.AF_INET6, dst_id.replace(ID_DELIMITER, ":")))
-+
-+ f = open(PROC_IDL_ROUTE, 'r')
-+ lines = f.readlines()
-+ f.close()
-+
-+ for line in lines:
-+ rec = line.split(',')
-+ # Host
-+ if int(rec[0], 16) & FLAG_HOST:
-+ src_id_in_rec = rec[1]
-+ dst_id_in_rec = rec[2]
-+ # Forward
-+ else:
-+ src_id_in_rec = rec[2]
-+ dst_id_in_rec = rec[1]
-+
-+ if (src_id == socket.inet_ntop(socket.AF_INET6, \
-+ socket.inet_pton(socket.AF_INET6, src_id_in_rec))
-+ and dst_id == socket.inet_ntop(socket.AF_INET6, \
-+ socket.inet_pton(socket.AF_INET6, dst_id_in_rec))):
-+
-+ rx = int(rec[6], 16)
-+ tx = int(rec[7], 16)
-+ print 'total rx tx'
-+ print '%-8d %-8d %-8d' % (rx + tx, rx, tx)
-+ f.close
-+ return 0
-+
-+ f.close
-+ print 'Info: No route info.'
-+ return 1
-+
-+
-+def main(argc, argv):
-+ if argc == 7 and argv[1] == 'add': # ADD
-+ if (os.getuid() != 0):
-+ print 'Error: Permission denied.'
-+ return 1
-+ else:
-+ add_route(argv[2], argv[3], argv[4], argv[5], argv[6])
-+ elif argc == 4 and (argv[1] == 'delete'
-+ or argv[1] == 'del'): # DEL
-+ if (os.getuid() != 0):
-+ print 'Error: Permission denied.'
-+ return 1
-+ else:
-+ del_route(argv[2], argv[3])
-+ del_route(argv[3], argv[2])
-+ elif argc == 2 and argv[1] == 'show': # SHOW
-+ show_route()
-+ elif argc == 4 and argv[1] == 'stat': # STAT
-+ exit(stat_route(argv[2], argv[3]))
-+ else:
-+ usage()
-+ return 1
-+
-+
-+if __name__ == "__main__":
-+ argv = sys.argv # コマンドライン引数を格納したリストの取得
-+ argc = len(argv) # 引数の個数
-+
-+ if os.path.exists(PROC_IDL_ROUTE):
-+ main(argc, argv)
-+ else:
-+ print 'The kernel is running which does not support ID/Locator.'
-+
-+
-diff -r 9f12d65beb55 model/cooja-loader-factory.cc
---- a/model/cooja-loader-factory.cc Thu Mar 29 13:55:58 2012 +0900
-+++ b/model/cooja-loader-factory.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -214,7 +214,7 @@
- if (sharedModule == 0)
- {
- void *handle = dlopen (cached.cachedFilename.c_str (),
-- RTLD_LAZY | RTLD_DEEPBIND | RTLD_LOCAL);
-+ RTLD_LAZY | RTLD_DEEPBIND | RTLD_GLOBAL);
- NS_ASSERT_MSG (handle != 0, "Could not open " << cached.cachedFilename << " " << dlerror ());
- struct link_map *link_map;
- dlinfo (handle, RTLD_DI_LINKMAP, &link_map);
-diff -r 9f12d65beb55 model/libc-ns3.h
---- a/model/libc-ns3.h Thu Mar 29 13:55:58 2012 +0900
-+++ b/model/libc-ns3.h Thu Mar 29 13:58:16 2012 +0900
-@@ -103,6 +103,8 @@
- NATIVE_EXPLICIT (strrchr, char * (*) (char *, int))
- NATIVE (strcasecmp)
- NATIVE (strncasecmp)
-+NATIVE (strfry)
-+NATIVE_EXPLICIT (strstr, char * (*) (char *, __const char *))
-
- DCE_WITH_ALIAS (strdup)
- DCE (strndup)
-diff -r 9f12d65beb55 model/linux-socket-fd-factory.cc
---- a/model/linux-socket-fd-factory.cc Thu Mar 29 13:55:58 2012 +0900
-+++ b/model/linux-socket-fd-factory.cc Thu Mar 29 13:58:16 2012 +0900
-@@ -461,6 +461,7 @@
- void
- LinuxSocketFdFactory::SetTask (std::string path, std::string value)
- {
-+ NS_LOG_FUNCTION (path << value);
- std::vector<std::pair<std::string,struct SimSysFile *> > files = GetSysFileList ();
- for (uint32_t i = 0; i < files.size (); i++)
- {
-@@ -488,6 +489,27 @@
- }
- }
-
-+std::string
-+LinuxSocketFdFactory::Get (std::string path)
-+{
-+ NS_LOG_FUNCTION (path);
-+ std::string ret;
-+ std::vector<std::pair<std::string,struct SimSysFile *> > files = GetSysFileList ();
-+ for (uint32_t i = 0; i < files.size (); i++)
-+ {
-+ if (files[i].first == path)
-+ {
-+ char buffer[512];
-+ memset (buffer, 0, sizeof(buffer));
-+ m_exported->sys_file_read (files[i].second, buffer, sizeof(buffer), 0);
-+ NS_LOG_FUNCTION ("sysctl read: " << buffer);
-+ ret = std::string (buffer);
-+ break;
-+ }
-+ }
-+ return ret;
-+}
-+
- void
- LinuxSocketFdFactory::InitializeStack (void)
- {
-@@ -525,8 +547,9 @@
- this));
- Set (".net.ipv4.conf.all.forwarding", "1");
- Set (".net.ipv4.conf.all.log_martians", "1");
-- // Set (".net.ipv6.conf.all.forwarding", "1");
-+ Set (".net.ipv6.conf.all.forwarding", "1");
- Set (".net.ipv6.conf.all.proxy_ndp", "1");
-+ Set (".net.idl.idlrt", "BEAFBEAF");
-
- while (!m_earlySysfs.empty ())
- {
-diff -r 9f12d65beb55 model/linux-socket-fd-factory.h
---- a/model/linux-socket-fd-factory.h Thu Mar 29 13:55:58 2012 +0900
-+++ b/model/linux-socket-fd-factory.h Thu Mar 29 13:58:16 2012 +0900
-@@ -43,7 +43,8 @@
- virtual UnixFd *CreateSocket (int domain, int type, int protocol);
-
- void Set (std::string path, std::string value);
--
-+ std::string Get (std::string path);
-+ void ScheduleTask (EventImpl *event);
-
- private:
- friend class LinuxSocketFd;
-@@ -118,7 +119,6 @@
- void SetTask (std::string path, std::string value);
- static void TaskSwitch (enum Task::SwitchType type, void *context);
- static void ScheduleTaskTrampoline (void *context);
-- void ScheduleTask (EventImpl *event);
- void EventTrampoline (void (*fn)(void *context),
- void *context, void (*pre_fn)(void),
- Ptr<EventIdHolder> event);
-diff -r 9f12d65beb55 utils/setenv.zsh
---- a/utils/setenv.zsh Thu Mar 29 13:55:58 2012 +0900
-+++ b/utils/setenv.zsh Thu Mar 29 13:58:16 2012 +0900
-@@ -6,8 +6,9 @@
- 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/
--export LD_LIBRARY_PATH PKG_CONFIG_PATH PATH PYTHONPATH
-+DCE_PATH="$BASE/ns-3-dce/build/bin_dce"
-+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/:$BASE/ns-3-dce
-+export LD_LIBRARY_PATH PKG_CONFIG_PATH PATH PYTHONPATH DCE_PATH
- cd $BASE/ns-3-dce
-
-
-diff -r 9f12d65beb55 wscript
---- a/wscript Thu Mar 29 13:55:58 2012 +0900
-+++ b/wscript Thu Mar 29 13:58:16 2012 +0900
-@@ -35,6 +35,7 @@
- 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.env.append_value('CXXFLAGS', '-I/usr/include/python2.6')
- conf.env.append_value('LINKFLAGS', '-pthread')
- conf.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=' +
- os.path.abspath ('../build/lib/ldso'))
-@@ -186,6 +187,8 @@
- ['unix-client', []],
- ['udp-echo-server', []],
- ['udp-echo-client', []],
-+ ['idl-server', []],
-+ ['idl-client', []],
- ]
- for name,lib in dce_examples:
- module.add_example(**dce_kw(target = 'bin/' + name,
-@@ -289,6 +292,23 @@
- target='bin/dce-fga-crawdad',
- source=['example/dce-fga-crawdad.cc'])
-
-+ module.add_example(**dce_kw(target = 'bin_dce/idecho-s',
-+ source = ['example/himalis/idecho-s.cc'],
-+ cflags = ['-fPIC -I../ns-3-linux/net-next2.6/include']))
-+
-+
-+ module.add_example(**dce_kw(target = 'bin_dce/idecho-c',
-+ source = ['example/himalis/idecho-c.cc'],
-+ cflags = ['-fPIC -I../ns-3-linux/net-next2.6/include']))
-+
-+ module.add_example(needed = ['core', 'dce', 'csma', 'point-to-point','visualizer'],
-+ target='bin/dce-himalis-simple',
-+ source=['example/dce-himalis-simple.cc'])
-+
-+ module.add_example(needed = ['core', 'dce', 'csma', 'point-to-point','visualizer'],
-+ target='bin/dce-himalis-handoff',
-+ source=['example/dce-himalis-handoff.cc'])
-+
- def build(bld):
- build_netlink(bld)
-
-@@ -389,6 +409,7 @@
- 'helper/dce-application-helper.h',
- 'helper/quagga-helper.h',
- 'helper/mip6d-helper.h',
-+ 'helper/himalis-helper.h',
- ]
- module_source = module_source + kernel_source
- module_headers = module_headers + kernel_headers
-@@ -398,7 +419,7 @@
- headers=module_headers,
- use=uselib,
- includes=kernel_includes,
-- lib=['dl'])
-+ lib=['dl', 'python2.6'])
- # lib=['dl','efence'])
- build_dce_tests(module, bld.env['KERNEL_STACK'])
- build_dce_examples(module)