A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
internet
helper
ipv4-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 INRIA
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: Mathieu Lacage <mathieu.lacage@cutebugs.net>
19
*/
20
21
#include "
ipv4-interface-container.h
"
22
#include "ns3/node-list.h"
23
#include "ns3/names.h"
24
25
namespace
ns3
{
26
27
Ipv4InterfaceContainer::Ipv4InterfaceContainer
()
28
{
29
}
30
31
void
32
Ipv4InterfaceContainer::Add
(
const
Ipv4InterfaceContainer
& other)
33
{
34
for
(InterfaceVector::const_iterator i = other.
m_interfaces
.begin (); i != other.
m_interfaces
.end (); i++)
35
{
36
m_interfaces
.push_back (*i);
37
}
38
}
39
40
Ipv4InterfaceContainer::Iterator
41
Ipv4InterfaceContainer::Begin
(
void
)
const
42
{
43
return
m_interfaces
.begin ();
44
}
45
46
Ipv4InterfaceContainer::Iterator
47
Ipv4InterfaceContainer::End
(
void
)
const
48
{
49
return
m_interfaces
.end ();
50
}
51
52
uint32_t
53
Ipv4InterfaceContainer::GetN
(
void
)
const
54
{
55
return
m_interfaces
.size ();
56
}
57
58
Ipv4Address
59
Ipv4InterfaceContainer::GetAddress
(uint32_t i, uint32_t j)
const
60
{
61
Ptr<Ipv4>
ipv4 =
m_interfaces
[i].first;
62
uint32_t
interface
=
m_interfaces
[i].
second
;
63
return
ipv4->GetAddress (interface, j).GetLocal ();
64
}
65
66
void
67
Ipv4InterfaceContainer::SetMetric
(uint32_t i, uint16_t metric)
68
{
69
Ptr<Ipv4>
ipv4 =
m_interfaces
[i].first;
70
uint32_t
interface
=
m_interfaces
[i].
second
;
71
ipv4->SetMetric (interface, metric);
72
}
73
void
74
Ipv4InterfaceContainer::Add
(
Ptr<Ipv4>
ipv4, uint32_t interface)
75
{
76
m_interfaces
.push_back (std::make_pair (ipv4, interface));
77
}
78
void
Ipv4InterfaceContainer::Add
(std::pair<
Ptr<Ipv4>
, uint32_t> a)
79
{
80
Add
(a.first, a.second);
81
}
82
void
83
Ipv4InterfaceContainer::Add
(std::string ipv4Name, uint32_t interface)
84
{
85
Ptr<Ipv4>
ipv4 = Names::Find<Ipv4> (ipv4Name);
86
m_interfaces
.push_back (std::make_pair (ipv4, interface));
87
}
88
89
std::pair<Ptr<Ipv4>, uint32_t>
90
Ipv4InterfaceContainer::Get
(uint32_t i)
const
91
{
92
return
m_interfaces
[i];
93
}
94
95
96
}
// namespace ns3
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
ns3::Ipv4InterfaceContainer::Ipv4InterfaceContainer
Ipv4InterfaceContainer()
Create an empty Ipv4InterfaceContainer.
Definition:
ipv4-interface-container.cc:27
second
Definition:
second.py:1
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition:
ipv4-interface-container.h:54
ns3::Ipv4InterfaceContainer::Add
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Definition:
ipv4-interface-container.cc:32
ipv4-interface-container.h
ns3::Ipv4InterfaceContainer::GetAddress
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Definition:
ipv4-interface-container.cc:59
ns3::Ipv4InterfaceContainer::GetN
uint32_t GetN(void) const
Definition:
ipv4-interface-container.cc:53
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4InterfaceContainer::Iterator
std::vector< std::pair< Ptr< Ipv4 >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of Ipv4 smart pointer / Interface Index.
Definition:
ipv4-interface-container.h:60
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:40
ns3::Ipv4InterfaceContainer::SetMetric
void SetMetric(uint32_t i, uint16_t metric)
Set a metric for the given interface.
Definition:
ipv4-interface-container.cc:67
ns3::Ipv4InterfaceContainer::m_interfaces
InterfaceVector m_interfaces
List of IPv4 stack and interfaces index.
Definition:
ipv4-interface-container.h:218
ns3::Ipv4InterfaceContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition:
ipv4-interface-container.cc:47
ns3::Ipv4InterfaceContainer::Get
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index...
Definition:
ipv4-interface-container.cc:90
ns3::Ipv4InterfaceContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first pair in the container.
Definition:
ipv4-interface-container.cc:41
Generated on Wed Nov 7 2018 10:01:53 for ns-3 by
1.8.14