helper/linux-stack-helper.cc
author Hajime Tazaki <tazaki@sfc.wide.ad.jp>
Tue, 07 Jan 2014 00:26:21 +0900
changeset 541 de7335a01743
parent 498 a616e41af00d
child 668 06b23f4d262c
permissions -rw-r--r--
Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     2
/*
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     3
 * Copyright (c) 2012 INRIA
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     4
 *
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     7
 * published by the Free Software Foundation;
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     8
 *
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    12
 * GNU General Public License for more details.
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    13
 *
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    17
 *
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    18
 * Author: Frédéric Urbani
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    19
 */
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    20
#include "linux-stack-helper.h"
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    21
#include "ipv4-linux.h"
541
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    22
#include "ipv6-linux.h"
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
    23
#include "linux-socket-fd-factory.h"
403
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
    24
#include "dce-application-helper.h"
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    25
#include "ns3/node.h"
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    26
#include "ns3/node-container.h"
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    27
#include "ns3/names.h"
541
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    28
#include "ns3/ipv4-list-routing-helper.h"
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    29
#include "ns3/ipv4-static-routing-helper.h"
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    30
#include "ns3/ipv4-global-routing-helper.h"
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    31
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    32
namespace ns3 {
541
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    33
LinuxStackHelper::LinuxStackHelper ()
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    34
  : m_routing (0)
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    35
{
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    36
  Initialize ();
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    37
}
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    38
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    39
// private method called by both constructor and Reset ()
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    40
void
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    41
LinuxStackHelper::Initialize ()
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    42
{
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    43
  Ipv4StaticRoutingHelper staticRouting;
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    44
  Ipv4GlobalRoutingHelper globalRouting;
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    45
  Ipv4ListRoutingHelper listRouting;
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    46
  listRouting.Add (staticRouting, 0);
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    47
  listRouting.Add (globalRouting, -10);
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    48
  SetRoutingHelper (listRouting);
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    49
}
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    50
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    51
LinuxStackHelper::~LinuxStackHelper ()
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    52
{
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    53
  delete m_routing;
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    54
}
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    55
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    56
void 
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    57
LinuxStackHelper::SetRoutingHelper (const Ipv4RoutingHelper &routing)
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    58
{
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    59
  delete m_routing;
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    60
  m_routing = routing.Copy ();
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    61
}
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    62
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    63
void
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    64
LinuxStackHelper::Install (Ptr<Node> node)
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    65
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    66
#ifdef KERNEL_STACK
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    67
  Ipv4Linux::InstallNode (node);
541
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    68
#if 0
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    69
  // Set routing
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    70
  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    71
  Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    72
  ipv4->SetRoutingProtocol (ipv4Routing);
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    73
#endif
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
    74
  Ipv6Linux::InstallNode (node);
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    75
#endif
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    76
}
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    77
void
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    78
LinuxStackHelper::Install (std::string nodeName)
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    79
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    80
#ifdef KERNEL_STACK
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    81
  Ptr<Node> node = Names::Find<Node> (nodeName);
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    82
  Install (node);
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    83
#endif
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    84
}
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    85
void
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    86
LinuxStackHelper::Install (NodeContainer c)
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    87
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    88
#ifdef KERNEL_STACK
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    89
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    90
    {
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    91
      Install (*i);
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    92
    }
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    93
#endif
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    94
}
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    95
void
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    96
LinuxStackHelper::InstallAll (void)
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    97
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
    98
#ifdef KERNEL_STACK
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
    99
  Install (NodeContainer::GetGlobal ());
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   100
#endif
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
   101
}
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   102
403
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   103
void
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   104
LinuxStackHelper::PopulateRoutingTables ()
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   105
{
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   106
#ifdef KERNEL_STACK
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   107
  NodeContainer c =  NodeContainer::GetGlobal ();
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   108
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   109
    {
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   110
      Ptr<Node> node = *i;
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   111
      Ptr<Ipv4Linux> ipv4 = node->GetObject<Ipv4Linux> ();
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   112
      ipv4->PopulateRoutingTable ();
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   113
    }
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   114
#endif
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   115
}
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   116
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   117
void
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   118
LinuxStackHelper::RunIp (Ptr<Node> node, Time at, std::string str)
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   119
{
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   120
#ifdef KERNEL_STACK
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   121
  DceApplicationHelper process;
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   122
  ApplicationContainer apps;
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   123
  process.SetBinary ("ip");
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   124
  process.SetStackSize (1 << 16);
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   125
  process.ResetArguments ();
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   126
  process.ParseArguments (str.c_str ());
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   127
  apps = process.Install (node);
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   128
  apps.Start (at);
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   129
#endif
6998fb05cf4f Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 367
diff changeset
   130
}
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   131
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   132
void
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   133
LinuxStackHelper::SysctlGetCallback (Ptr<Node> node, std::string path,
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   134
                                     void (*callback)(std::string, std::string))
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   135
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   136
#ifdef KERNEL_STACK
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   137
  Ptr<LinuxSocketFdFactory> sock = node->GetObject<LinuxSocketFdFactory> ();
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   138
  if (!sock)
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   139
    {
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   140
      callback ("error", "no socket factory");
498
a616e41af00d check the existence of LinuxStackHelper before sysctl
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 434
diff changeset
   141
      NS_ASSERT_MSG (0, "No LinuxSocketFdFactory is installed. "
a616e41af00d check the existence of LinuxStackHelper before sysctl
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 434
diff changeset
   142
                     "You may need to do it via DceManagerHelper::Install ()");
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   143
      return;
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   144
    }
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   145
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   146
  std::string value = sock->Get (path);
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   147
  callback (path, value);
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   148
  return;
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   149
#endif
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   150
}
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   151
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   152
void
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   153
LinuxStackHelper::SysctlGet (Ptr<Node> node, Time at, std::string path,
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   154
                             void (*callback)(std::string, std::string))
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   155
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   156
#ifdef KERNEL_STACK
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   157
  Ptr<LinuxSocketFdFactory> sock = node->GetObject<LinuxSocketFdFactory> ();
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   158
  if (!sock)
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   159
    {
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   160
      callback ("error", "no socket factory");
498
a616e41af00d check the existence of LinuxStackHelper before sysctl
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 434
diff changeset
   161
      NS_ASSERT_MSG (0, "No LinuxSocketFdFactory is installed. "
a616e41af00d check the existence of LinuxStackHelper before sysctl
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 434
diff changeset
   162
                     "You may need to do it via DceManagerHelper::Install ()");
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   163
      return;
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   164
    }
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   165
  Simulator::ScheduleWithContext (node->GetId (), at,
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   166
                                  &LinuxSocketFdFactory::ScheduleTask, sock,
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   167
                                  MakeEvent (&LinuxStackHelper::SysctlGetCallback,
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   168
                                             node, path, callback));
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   169
  return;
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   170
#endif
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   171
}
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   172
void
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   173
LinuxStackHelper::SysctlSet (NodeContainer c, std::string path, std::string value)
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   174
{
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   175
#ifdef KERNEL_STACK
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   176
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   177
    {
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   178
      Ptr<Node> node = *i;
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 353
diff changeset
   179
      Ptr<LinuxSocketFdFactory> sock = node->GetObject<LinuxSocketFdFactory> ();
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   180
      if (!sock)
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   181
        {
498
a616e41af00d check the existence of LinuxStackHelper before sysctl
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 434
diff changeset
   182
          NS_ASSERT_MSG (0, "No LinuxSocketFdFactory is installed. "
a616e41af00d check the existence of LinuxStackHelper before sysctl
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 434
diff changeset
   183
                         "You may need to do it via DceManagerHelper::Install ()");
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   184
        }
541
de7335a01743 Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 498
diff changeset
   185
      // i.e., TaskManager::Current() needs it.
434
6b27d1a51b68 change sysctl -w timing so that user's script can override the default values
Hajime Tazaki <tazaki@nict.go.jp>
parents: 403
diff changeset
   186
      Simulator::ScheduleWithContext (node->GetId (), Seconds (0.1),
345
a506e22e51e1 fix SysctlSet issue
Hajime Tazaki <tazaki@nict.go.jp>
parents: 330
diff changeset
   187
                                      MakeEvent (&LinuxSocketFdFactory::Set, sock,
a506e22e51e1 fix SysctlSet issue
Hajime Tazaki <tazaki@nict.go.jp>
parents: 330
diff changeset
   188
                                                 path, value));
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   189
    }
353
d1f08de2c55b remove ifdef KERNEL_STACK in scenarios.
frederic.urbani@inria.fr
parents: 345
diff changeset
   190
#endif
330
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   191
}
c7fa4f378af8 Add a sysctl interface of Linux via LinuxStackHelper
Hajime Tazaki <tazaki@nict.go.jp>
parents: 239
diff changeset
   192
239
46380fd02339 Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff changeset
   193
} // namespace ns3