A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ipv6-interface-container.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008-2009 Strasbourg University
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
*/
20
21
#include "ns3/node-list.h"
22
#include "ns3/names.h"
23
24
#include "
ipv6-interface-container.h
"
25
#include "ns3/ipv6-static-routing-helper.h"
26
27
namespace
ns3
28
{
29
30
Ipv6InterfaceContainer::Ipv6InterfaceContainer
()
31
{
32
}
33
34
Ipv6InterfaceContainer::Iterator
35
Ipv6InterfaceContainer::Begin
(
void
)
const
36
{
37
return
m_interfaces
.begin ();
38
}
39
40
Ipv6InterfaceContainer::Iterator
41
Ipv6InterfaceContainer::End
(
void
)
const
42
{
43
return
m_interfaces
.end ();
44
}
45
46
uint32_t
Ipv6InterfaceContainer::GetN
()
const
47
{
48
return
m_interfaces
.size ();
49
}
50
51
uint32_t
Ipv6InterfaceContainer::GetInterfaceIndex
(uint32_t i)
const
52
{
53
return
m_interfaces
[i].second;
54
}
55
56
Ipv6Address
Ipv6InterfaceContainer::GetAddress
(uint32_t i, uint32_t j)
const
57
{
58
Ptr<Ipv6>
ipv6 =
m_interfaces
[i].first;
59
uint32_t
interface
=
m_interfaces
[i].second;
60
return
ipv6->
GetAddress
(interface, j).
GetAddress
();
61
}
62
63
void
Ipv6InterfaceContainer::Add
(
Ptr<Ipv6>
ipv6, uint32_t interface)
64
{
65
m_interfaces
.push_back (std::make_pair (ipv6, interface));
66
}
67
68
void
Ipv6InterfaceContainer::Add
(std::string ipv6Name, uint32_t interface)
69
{
70
Ptr<Ipv6>
ipv6 = Names::Find<Ipv6> (ipv6Name);
71
m_interfaces
.push_back (std::make_pair (ipv6, interface));
72
}
73
74
void
Ipv6InterfaceContainer::Add
(
Ipv6InterfaceContainer
& c)
75
{
76
for
(InterfaceVector::const_iterator it = c.
m_interfaces
.begin (); it != c.
m_interfaces
.end (); it++)
77
{
78
m_interfaces
.push_back (*it);
79
}
80
}
81
82
void
Ipv6InterfaceContainer::SetRouter
(uint32_t i,
bool
router)
83
{
84
Ptr<Ipv6>
ipv6 =
m_interfaces
[i].first;
85
ipv6->
SetForwarding
(
m_interfaces
[i].second, router);
86
87
if
(router)
88
{
89
uint32_t other;
90
/* assume first global address is index 1 (0 is link-local) */
91
Ipv6Address
routerAddress = ipv6->
GetAddress
(
m_interfaces
[i].second, 1).
GetAddress
();
92
93
for
(other = 0; other <
m_interfaces
.size (); other++)
94
{
95
if
(other != i)
96
{
97
Ptr<Ipv6StaticRouting>
routing = 0;
98
Ipv6StaticRoutingHelper
routingHelper;
99
100
ipv6 =
m_interfaces
[other].first;
101
routing = routingHelper.
GetStaticRouting
(ipv6);
102
routing->SetDefaultRoute (routerAddress,
m_interfaces
[other].second);
103
}
104
}
105
}
106
}
107
108
void
Ipv6InterfaceContainer::SetDefaultRoute
(uint32_t i, uint32_t router)
109
{
110
Ptr<Ipv6>
ipv6 =
m_interfaces
[i].first;
111
Ptr<Ipv6>
ipv6Router =
m_interfaces
[router].first;
112
Ipv6Address
routerAddress = ipv6Router->
GetAddress
(
m_interfaces
[router].second, 1).
GetAddress
();
113
Ptr<Ipv6StaticRouting>
routing = 0;
114
Ipv6StaticRoutingHelper
routingHelper;
115
116
routing = routingHelper.
GetStaticRouting
(ipv6);
117
routing->SetDefaultRoute (routerAddress,
m_interfaces
[i].second);
118
}
119
120
}
/* namespace ns3 */
121
src
internet
helper
ipv6-interface-container.cc
Generated on Fri Dec 21 2012 19:00:36 for ns-3 by
1.8.1.2