src/olsr/helper/olsr-helper.cc
author Lalith Suresh <suresh.lalith@gmail.com>
Fri, 04 Mar 2011 01:26:54 +0000
changeset 6852 8f1a53d3f6ca
parent 6634 src/routing/olsr/helper/olsr-helper.cc@ef874c63c6b1
child 7184 a15feb312428
permissions -rw-r--r--
Moves devices/* and routing/* to src/
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2833
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     2
/*
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     3
 * Copyright (c) 2008 INRIA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     4
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     7
 * published by the Free Software Foundation;
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     8
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    12
 * GNU General Public License for more details.
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    13
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    15
 * along with this program; if not, write to the Free Software
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    17
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2702
diff changeset
    19
 */
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "olsr-helper.h"
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4358
diff changeset
    21
#include "ns3/olsr-routing-protocol.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/node-list.h"
4147
5d8530130930 rename object-names.{cc,h} to names.{cc,h} per convention
Craig Dowell <craigdo@ee.washington.edu>
parents: 4140
diff changeset
    23
#include "ns3/names.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4364
diff changeset
    24
#include "ns3/ipv4-list-routing.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
namespace ns3 {
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
OlsrHelper::OlsrHelper ()
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
{
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4358
diff changeset
    30
  m_agentFactory.SetTypeId ("ns3::olsr::RoutingProtocol");
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
}
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    33
OlsrHelper::OlsrHelper (const OlsrHelper &o)
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    34
  : m_agentFactory (o.m_agentFactory)
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    35
{
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    36
  m_interfaceExclusions = o.m_interfaceExclusions;
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    37
}
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    38
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    39
OlsrHelper* 
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    40
OlsrHelper::Copy (void) const 
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    41
{
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    42
  return new OlsrHelper (*this); 
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    43
}
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 4616
diff changeset
    44
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    45
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    46
OlsrHelper::ExcludeInterface (Ptr<Node> node, uint32_t interface)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    47
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    48
  std::map< Ptr<Node>, std::set<uint32_t> >::iterator it = m_interfaceExclusions.find (node);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    49
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    50
  if(it == m_interfaceExclusions.end ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    51
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    52
      std::set<uint32_t> interfaces;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    53
      interfaces.insert (interface);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    54
    
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    55
      m_interfaceExclusions.insert (std::make_pair (node, std::set<uint32_t> (interfaces) ));
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    56
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    57
  else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    58
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    59
      it->second.insert (interface);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    60
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    61
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    62
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    63
Ptr<Ipv4RoutingProtocol> 
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    64
OlsrHelper::Create (Ptr<Node> node) const
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
{
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    66
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    67
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    68
  std::map<Ptr<Node>, std::set<uint32_t> >::const_iterator it = m_interfaceExclusions.find (node);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    69
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    70
  if(it != m_interfaceExclusions.end ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    71
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    72
      agent->SetInterfaceExclusions (it->second);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    73
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5353
diff changeset
    74
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    75
  node->AggregateObject (agent);
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    76
  return agent;
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
}
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
void 
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    80
OlsrHelper::Set (std::string name, const AttributeValue &value)
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
{
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4560
diff changeset
    82
  m_agentFactory.Set (name, value);
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
}
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
} // namespace ns3