A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ipv4-interface-container.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
18
*/
19
20
#include "
ipv4-interface-container.h
"
21
22
#include "ns3/names.h"
23
#include "ns3/node-list.h"
24
25
namespace
ns3
26
{
27
28
Ipv4InterfaceContainer::Ipv4InterfaceContainer
()
29
{
30
}
31
32
void
33
Ipv4InterfaceContainer::Add
(
const
Ipv4InterfaceContainer
& other)
34
{
35
for
(InterfaceVector::const_iterator i = other.
m_interfaces
.begin();
36
i != other.
m_interfaces
.end();
37
i++)
38
{
39
m_interfaces
.push_back(*i);
40
}
41
}
42
43
Ipv4InterfaceContainer::Iterator
44
Ipv4InterfaceContainer::Begin
()
const
45
{
46
return
m_interfaces
.begin();
47
}
48
49
Ipv4InterfaceContainer::Iterator
50
Ipv4InterfaceContainer::End
()
const
51
{
52
return
m_interfaces
.end();
53
}
54
55
uint32_t
56
Ipv4InterfaceContainer::GetN
()
const
57
{
58
return
m_interfaces
.size();
59
}
60
61
Ipv4Address
62
Ipv4InterfaceContainer::GetAddress
(
uint32_t
i,
uint32_t
j)
const
63
{
64
Ptr<Ipv4>
ipv4 =
m_interfaces
[i].first;
65
uint32_t
interface
=
m_interfaces
[i].
second
;
66
return
ipv4->GetAddress(interface, j).GetLocal();
67
}
68
69
void
70
Ipv4InterfaceContainer::SetMetric
(
uint32_t
i, uint16_t metric)
71
{
72
Ptr<Ipv4>
ipv4 =
m_interfaces
[i].first;
73
uint32_t
interface
=
m_interfaces
[i].
second
;
74
ipv4->SetMetric(interface, metric);
75
}
76
77
void
78
Ipv4InterfaceContainer::Add
(
Ptr<Ipv4>
ipv4,
uint32_t
interface)
79
{
80
m_interfaces
.emplace_back(ipv4, interface);
81
}
82
83
void
84
Ipv4InterfaceContainer::Add
(std::pair<
Ptr<Ipv4>
,
uint32_t
> a)
85
{
86
Add
(a.first, a.second);
87
}
88
89
void
90
Ipv4InterfaceContainer::Add
(std::string ipv4Name,
uint32_t
interface)
91
{
92
Ptr<Ipv4>
ipv4 = Names::Find<Ipv4>(ipv4Name);
93
m_interfaces
.emplace_back(ipv4, interface);
94
}
95
96
std::pair<Ptr<Ipv4>,
uint32_t
>
97
Ipv4InterfaceContainer::Get
(
uint32_t
i)
const
98
{
99
return
m_interfaces
[i];
100
}
101
102
}
// namespace ns3
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition:
ipv4-interface-container.h:56
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:61
ns3::Ipv4InterfaceContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Definition:
ipv4-interface-container.cc:50
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:97
ns3::Ipv4InterfaceContainer::SetMetric
void SetMetric(uint32_t i, uint16_t metric)
Set a metric for the given interface.
Definition:
ipv4-interface-container.cc:70
ns3::Ipv4InterfaceContainer::m_interfaces
InterfaceVector m_interfaces
List of IPv4 stack and interfaces index.
Definition:
ipv4-interface-container.h:220
ns3::Ipv4InterfaceContainer::Add
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Definition:
ipv4-interface-container.cc:33
ns3::Ipv4InterfaceContainer::GetAddress
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Definition:
ipv4-interface-container.cc:62
ns3::Ipv4InterfaceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first pair in the container.
Definition:
ipv4-interface-container.cc:44
ns3::Ipv4InterfaceContainer::Ipv4InterfaceContainer
Ipv4InterfaceContainer()
Create an empty Ipv4InterfaceContainer.
Definition:
ipv4-interface-container.cc:28
ns3::Ipv4InterfaceContainer::GetN
uint32_t GetN() const
Definition:
ipv4-interface-container.cc:56
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:78
uint32_t
ipv4-interface-container.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second
Definition:
second.py:1
src
internet
helper
ipv4-interface-container.cc
Generated on Sun Jul 2 2023 18:21:38 for ns-3 by
1.9.6