if_nmaetoindex update
authorHajime Tazaki <tazaki@nict.go.jp>
Wed, 11 Apr 2012 00:11:36 +0900
changeset 171c3c791066b8
parent 16 26675cdba3ce
child 18 1811be862c59
if_nmaetoindex update
120410-dce-umip-support.patch
     1.1 --- a/120410-dce-umip-support.patch	Tue Apr 10 18:07:08 2012 +0900
     1.2 +++ b/120410-dce-umip-support.patch	Wed Apr 11 00:11:36 2012 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  
     1.5  diff -r e503e546d382 model/dce-fd.cc
     1.6  --- a/model/dce-fd.cc	Mon Apr 09 10:03:33 2012 +0900
     1.7 -+++ b/model/dce-fd.cc	Tue Apr 10 14:47:37 2012 +0900
     1.8 ++++ b/model/dce-fd.cc	Wed Apr 11 00:10:58 2012 +0900
     1.9  @@ -367,11 +367,30 @@
    1.10       }
    1.11   
    1.12 @@ -36,7 +36,7 @@
    1.13     Thread *current = Current ();
    1.14  diff -r e503e546d382 model/dce-manager.cc
    1.15  --- a/model/dce-manager.cc	Mon Apr 09 10:03:33 2012 +0900
    1.16 -+++ b/model/dce-manager.cc	Tue Apr 10 14:47:37 2012 +0900
    1.17 ++++ b/model/dce-manager.cc	Wed Apr 11 00:10:58 2012 +0900
    1.18  @@ -1096,6 +1096,22 @@
    1.19             libpthread_setup = (void (*)(const struct Libc *))(symbol);
    1.20             libpthread_setup (libc);
    1.21 @@ -62,7 +62,7 @@
    1.22   
    1.23  diff -r e503e546d382 model/dce-poll.cc
    1.24  --- a/model/dce-poll.cc	Mon Apr 09 10:03:33 2012 +0900
    1.25 -+++ b/model/dce-poll.cc	Tue Apr 10 14:47:37 2012 +0900
    1.26 ++++ b/model/dce-poll.cc	Wed Apr 11 00:10:58 2012 +0900
    1.27  @@ -180,7 +180,12 @@
    1.28           }
    1.29       }
    1.30 @@ -79,7 +79,7 @@
    1.31         return -1;
    1.32  diff -r e503e546d382 model/dce-signal.cc
    1.33  --- a/model/dce-signal.cc	Mon Apr 09 10:03:33 2012 +0900
    1.34 -+++ b/model/dce-signal.cc	Tue Apr 10 14:47:37 2012 +0900
    1.35 ++++ b/model/dce-signal.cc	Wed Apr 11 00:10:58 2012 +0900
    1.36  @@ -3,6 +3,7 @@
    1.37   #include "process.h"
    1.38   #include "ns3/log.h"
    1.39 @@ -109,7 +109,7 @@
    1.40     Thread *current = Current ();
    1.41  diff -r e503e546d382 model/dce-signal.h
    1.42  --- a/model/dce-signal.h	Mon Apr 09 10:03:33 2012 +0900
    1.43 -+++ b/model/dce-signal.h	Tue Apr 10 14:47:37 2012 +0900
    1.44 ++++ b/model/dce-signal.h	Wed Apr 11 00:10:58 2012 +0900
    1.45  @@ -17,6 +17,7 @@
    1.46   int dce_pthread_kill (pthread_t thread, int sig);
    1.47   void dce_abort ();
    1.48 @@ -120,7 +120,7 @@
    1.49   }
    1.50  diff -r e503e546d382 model/dce-time.cc
    1.51  --- a/model/dce-time.cc	Mon Apr 09 10:03:33 2012 +0900
    1.52 -+++ b/model/dce-time.cc	Tue Apr 10 14:47:37 2012 +0900
    1.53 ++++ b/model/dce-time.cc	Wed Apr 11 00:10:58 2012 +0900
    1.54  @@ -54,3 +54,12 @@
    1.55   
    1.56     return asctime_r (tm, Current ()->process->asctime_result);
    1.57 @@ -136,7 +136,7 @@
    1.58  +}
    1.59  diff -r e503e546d382 model/dce-time.h
    1.60  --- a/model/dce-time.h	Mon Apr 09 10:03:33 2012 +0900
    1.61 -+++ b/model/dce-time.h	Tue Apr 10 14:47:37 2012 +0900
    1.62 ++++ b/model/dce-time.h	Wed Apr 11 00:10:58 2012 +0900
    1.63  @@ -3,6 +3,7 @@
    1.64   
    1.65   #include "sys/dce-time.h"
    1.66 @@ -156,7 +156,7 @@
    1.67   }
    1.68  diff -r e503e546d382 model/dce.cc
    1.69  --- a/model/dce.cc	Mon Apr 09 10:03:33 2012 +0900
    1.70 -+++ b/model/dce.cc	Tue Apr 10 14:47:37 2012 +0900
    1.71 ++++ b/model/dce.cc	Wed Apr 11 00:10:58 2012 +0900
    1.72  @@ -22,6 +22,8 @@
    1.73   #include <getopt.h>
    1.74   #include <limits.h>
    1.75 @@ -166,27 +166,65 @@
    1.76   #include "dce-random.h"
    1.77   #include "net/dce-if.h"
    1.78   #include "ns3/node.h"
    1.79 -@@ -639,6 +641,43 @@
    1.80 +@@ -30,6 +32,7 @@
    1.81 + #include "ns3/names.h"
    1.82 + #include "ns3/random-variable.h"
    1.83 + #include "ns3/ipv4-l3-protocol.h"
    1.84 ++#include "socket-fd-factory.h"
    1.85 + 
    1.86 + NS_LOG_COMPONENT_DEFINE ("Dce");
    1.87 + 
    1.88 +@@ -639,20 +642,60 @@
    1.89   }
    1.90   unsigned dce_if_nametoindex (const char *ifname)
    1.91   {
    1.92 -+  struct ifreq ifr;
    1.93 -+  int fd = dce_socket (AF_INET, SOCK_DGRAM, 0);
    1.94 -+  if (fd < 0)
    1.95 +-  int index = 0;
    1.96 +-  Ptr<Node> node = Current ()->process->manager->GetObject<Node> ();
    1.97 +-  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
    1.98 ++  Thread *current = Current ();
    1.99 ++  Ptr<SocketFdFactory> factory = 0;
   1.100 ++  factory = current->process->manager->GetObject<SocketFdFactory> ();
   1.101 + 
   1.102 +-  for (uint32_t i = 0; i < node->GetNDevices (); ++i)
   1.103 ++  if (factory->GetInstanceTypeId () == TypeId::LookupByName ("ns3::LinuxSocketFdFactory"))
   1.104 +     {
   1.105 +-      Ptr<NetDevice> dev = node->GetDevice (i);
   1.106 +-      if (ifname == Names::FindName (dev))
   1.107 ++      struct ifreq ifr;
   1.108 ++      int fd = dce_socket (AF_INET, SOCK_DGRAM, 0);
   1.109 ++      if (fd < 0)
   1.110 +         {
   1.111 +-          index = ipv4->GetInterfaceForDevice (dev);
   1.112 +-          return index;
   1.113 ++          return 0;
   1.114 +         }
   1.115 ++
   1.116 ++      strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
   1.117 ++      if (dce_ioctl (fd, SIOCGIFINDEX, (char *)&ifr) < 0)
   1.118 ++        {
   1.119 ++          current->err = errno;
   1.120 ++          return -1;
   1.121 ++        }
   1.122 ++      return ifr.ifr_ifindex;
   1.123 +     }
   1.124 +-  return 0;
   1.125 ++  else
   1.126  +    {
   1.127 ++      int index = 0;
   1.128 ++      Ptr<Node> node = Current ()->process->manager->GetObject<Node> ();
   1.129 ++      Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
   1.130 ++
   1.131 ++      for (uint32_t i = 0; i < node->GetNDevices (); ++i)
   1.132 ++        {
   1.133 ++          Ptr<NetDevice> dev = node->GetDevice (i);
   1.134 ++          if (ifname == Names::FindName (dev))
   1.135 ++            {
   1.136 ++              index = ipv4->GetInterfaceForDevice (dev);
   1.137 ++              return index;
   1.138 ++            }
   1.139 ++        }
   1.140  +      return 0;
   1.141  +    }
   1.142 -+
   1.143 -+  strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
   1.144 -+  if (dce_ioctl (fd, SIOCGIFINDEX, (char *)&ifr) < 0)
   1.145 -+    {
   1.146 -+      // int saved_errno = errno;
   1.147 -+      // close_not_cancel_no_status (fd);
   1.148 -+      // if (saved_errno == EINVAL)
   1.149 -+      //   __set_errno (ENOSYS);
   1.150 -+      return 0;
   1.151 -+    }
   1.152 -+  return ifr.ifr_ifindex;
   1.153  +}
   1.154  +char *dce_if_indextoname (unsigned ifindex, char *ifname)
   1.155  +{
   1.156 @@ -203,22 +241,10 @@
   1.157  +      return 0;
   1.158  +    }
   1.159  +  return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
   1.160 -+}
   1.161 -+#if 0
   1.162 -+unsigned dce_if_nametoindex (const char *ifname)
   1.163 -+{
   1.164 -   int index = 0;
   1.165 -   Ptr<Node> node = Current ()->process->manager->GetObject<Node> ();
   1.166 -   Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
   1.167 -@@ -654,6 +693,7 @@
   1.168 -     }
   1.169 -   return 0;
   1.170   }
   1.171 -+#endif
   1.172   pid_t dce_fork (void)
   1.173   {
   1.174 -   Thread *thread = Current ();
   1.175 -@@ -849,6 +889,21 @@
   1.176 +@@ -849,6 +892,21 @@
   1.177     static char loc[] = "";
   1.178     return loc;
   1.179   }
   1.180 @@ -242,7 +268,7 @@
   1.181   {
   1.182  diff -r e503e546d382 model/elf-cache.cc
   1.183  --- a/model/elf-cache.cc	Mon Apr 09 10:03:33 2012 +0900
   1.184 -+++ b/model/elf-cache.cc	Tue Apr 10 14:47:37 2012 +0900
   1.185 ++++ b/model/elf-cache.cc	Wed Apr 11 00:10:58 2012 +0900
   1.186  @@ -26,6 +26,9 @@
   1.187     overriden.from = "libpthread.so.0";
   1.188     overriden.to = "libpthread-ns3.so";
   1.189 @@ -255,7 +281,7 @@
   1.190   std::string
   1.191  diff -r e503e546d382 model/libc-dce.cc
   1.192  --- a/model/libc-dce.cc	Mon Apr 09 10:03:33 2012 +0900
   1.193 -+++ b/model/libc-dce.cc	Tue Apr 10 14:47:37 2012 +0900
   1.194 ++++ b/model/libc-dce.cc	Wed Apr 11 00:10:58 2012 +0900
   1.195  @@ -52,6 +52,7 @@
   1.196   #include <netdb.h>
   1.197   #include <net/if.h>
   1.198 @@ -266,7 +292,7 @@
   1.199   #include <signal.h>
   1.200  diff -r e503e546d382 model/libc-ns3.h
   1.201  --- a/model/libc-ns3.h	Mon Apr 09 10:03:33 2012 +0900
   1.202 -+++ b/model/libc-ns3.h	Tue Apr 10 14:47:37 2012 +0900
   1.203 ++++ b/model/libc-ns3.h	Wed Apr 11 00:10:58 2012 +0900
   1.204  @@ -73,6 +73,7 @@
   1.205   NATIVE (ntohl)
   1.206   NATIVE (ntohs)
   1.207 @@ -343,7 +369,7 @@
   1.208   NATIVE (__sigsetjmp)
   1.209  diff -r e503e546d382 model/librt-ns3.version
   1.210  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   1.211 -+++ b/model/librt-ns3.version	Tue Apr 10 14:47:37 2012 +0900
   1.212 ++++ b/model/librt-ns3.version	Wed Apr 11 00:10:58 2012 +0900
   1.213  @@ -0,0 +1,4 @@
   1.214  +NS3 {
   1.215  +global:
   1.216 @@ -351,7 +377,7 @@
   1.217  +};
   1.218  diff -r e503e546d382 model/linux-socket-fd-factory.cc
   1.219  --- a/model/linux-socket-fd-factory.cc	Mon Apr 09 10:03:33 2012 +0900
   1.220 -+++ b/model/linux-socket-fd-factory.cc	Tue Apr 10 14:47:37 2012 +0900
   1.221 ++++ b/model/linux-socket-fd-factory.cc	Wed Apr 11 00:10:58 2012 +0900
   1.222  @@ -537,6 +537,8 @@
   1.223                                                         this));
   1.224     Set (".net.ipv4.conf.all.forwarding", "1");
   1.225 @@ -363,7 +389,7 @@
   1.226       {
   1.227  diff -r e503e546d382 model/linux-socket-fd.cc
   1.228  --- a/model/linux-socket-fd.cc	Mon Apr 09 10:03:33 2012 +0900
   1.229 -+++ b/model/linux-socket-fd.cc	Tue Apr 10 14:47:37 2012 +0900
   1.230 ++++ b/model/linux-socket-fd.cc	Wed Apr 11 00:10:58 2012 +0900
   1.231  @@ -177,6 +177,7 @@
   1.232         return 0;
   1.233         break;
   1.234 @@ -374,7 +400,7 @@
   1.235         return -1;
   1.236  diff -r e503e546d382 model/net/dce-if.h
   1.237  --- a/model/net/dce-if.h	Mon Apr 09 10:03:33 2012 +0900
   1.238 -+++ b/model/net/dce-if.h	Tue Apr 10 14:47:37 2012 +0900
   1.239 ++++ b/model/net/dce-if.h	Wed Apr 11 00:10:58 2012 +0900
   1.240  @@ -7,6 +7,7 @@
   1.241   #endif
   1.242   
   1.243 @@ -385,7 +411,7 @@
   1.244   #ifdef __cplusplus
   1.245  diff -r e503e546d382 model/ns3-socket-fd-factory.cc
   1.246  --- a/model/ns3-socket-fd-factory.cc	Mon Apr 09 10:03:33 2012 +0900
   1.247 -+++ b/model/ns3-socket-fd-factory.cc	Tue Apr 10 14:47:37 2012 +0900
   1.248 ++++ b/model/ns3-socket-fd-factory.cc	Wed Apr 11 00:10:58 2012 +0900
   1.249  @@ -142,7 +142,8 @@
   1.250       }
   1.251     else
   1.252 @@ -398,7 +424,7 @@
   1.253     return socket;
   1.254  diff -r e503e546d382 model/sys/dce-socket.h
   1.255  --- a/model/sys/dce-socket.h	Mon Apr 09 10:03:33 2012 +0900
   1.256 -+++ b/model/sys/dce-socket.h	Tue Apr 10 14:47:37 2012 +0900
   1.257 ++++ b/model/sys/dce-socket.h	Wed Apr 11 00:10:58 2012 +0900
   1.258  @@ -28,6 +28,7 @@
   1.259   ssize_t dce_sendmsg(int s, const struct msghdr *msg, int flags);
   1.260   int dce_getsockname(int s, struct sockaddr *name, socklen_t *namelen);
   1.261 @@ -409,7 +435,7 @@
   1.262   }
   1.263  diff -r e503e546d382 wscript
   1.264  --- a/wscript	Mon Apr 09 10:03:33 2012 +0900
   1.265 -+++ b/wscript	Tue Apr 10 14:47:37 2012 +0900
   1.266 ++++ b/wscript	Wed Apr 11 00:10:58 2012 +0900
   1.267  @@ -26,7 +26,7 @@
   1.268       ns3waf.check_modules(conf, ['point-to-point', 'tap-bridge', 'netanim'], mandatory = False)
   1.269       ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)