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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
7
*/
8
9
#include "
ipv4-interface-container.h
"
10
11
#include "ns3/names.h"
12
#include "ns3/node-list.h"
13
14
namespace
ns3
15
{
16
17
Ipv4InterfaceContainer::Ipv4InterfaceContainer
()
18
{
19
}
20
21
void
22
Ipv4InterfaceContainer::Add
(
const
Ipv4InterfaceContainer
& other)
23
{
24
for
(
auto
i = other.
m_interfaces
.begin(); i != other.
m_interfaces
.end(); i++)
25
{
26
m_interfaces
.push_back(*i);
27
}
28
}
29
30
Ipv4InterfaceContainer::Iterator
31
Ipv4InterfaceContainer::Begin
()
const
32
{
33
return
m_interfaces
.begin();
34
}
35
36
Ipv4InterfaceContainer::Iterator
37
Ipv4InterfaceContainer::End
()
const
38
{
39
return
m_interfaces
.end();
40
}
41
42
uint32_t
43
Ipv4InterfaceContainer::GetN
()
const
44
{
45
return
m_interfaces
.size();
46
}
47
48
Ipv4Address
49
Ipv4InterfaceContainer::GetAddress
(
uint32_t
i,
uint32_t
j)
const
50
{
51
Ptr<Ipv4>
ipv4 =
m_interfaces
[i].first;
52
uint32_t
interface
=
m_interfaces
[i].
second
;
53
return
ipv4->GetAddress(interface, j).GetLocal();
54
}
55
56
void
57
Ipv4InterfaceContainer::SetMetric
(
uint32_t
i, uint16_t metric)
58
{
59
Ptr<Ipv4>
ipv4 =
m_interfaces
[i].first;
60
uint32_t
interface
=
m_interfaces
[i].
second
;
61
ipv4->SetMetric(interface, metric);
62
}
63
64
void
65
Ipv4InterfaceContainer::Add
(
Ptr<Ipv4>
ipv4,
uint32_t
interface)
66
{
67
m_interfaces
.emplace_back(ipv4, interface);
68
}
69
70
void
71
Ipv4InterfaceContainer::Add
(std::pair<
Ptr<Ipv4>
,
uint32_t
> a)
72
{
73
Add
(a.first, a.second);
74
}
75
76
void
77
Ipv4InterfaceContainer::Add
(std::string ipv4Name,
uint32_t
interface)
78
{
79
Ptr<Ipv4>
ipv4 =
Names::Find<Ipv4>
(ipv4Name);
80
m_interfaces
.emplace_back(ipv4, interface);
81
}
82
83
std::pair<Ptr<Ipv4>,
uint32_t
>
84
Ipv4InterfaceContainer::Get
(
uint32_t
i)
const
85
{
86
return
m_interfaces
[i];
87
}
88
89
}
// namespace ns3
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition
ipv4-interface-container.h:45
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:50
ns3::Ipv4InterfaceContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Definition
ipv4-interface-container.cc:37
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:84
ns3::Ipv4InterfaceContainer::SetMetric
void SetMetric(uint32_t i, uint16_t metric)
Set a metric for the given interface.
Definition
ipv4-interface-container.cc:57
ns3::Ipv4InterfaceContainer::m_interfaces
InterfaceVector m_interfaces
List of IPv4 stack and interfaces index.
Definition
ipv4-interface-container.h:209
ns3::Ipv4InterfaceContainer::Add
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Definition
ipv4-interface-container.cc:22
ns3::Ipv4InterfaceContainer::GetAddress
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Definition
ipv4-interface-container.cc:49
ns3::Ipv4InterfaceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first pair in the container.
Definition
ipv4-interface-container.cc:31
ns3::Ipv4InterfaceContainer::Ipv4InterfaceContainer
Ipv4InterfaceContainer()
Create an empty Ipv4InterfaceContainer.
Definition
ipv4-interface-container.cc:17
ns3::Ipv4InterfaceContainer::GetN
uint32_t GetN() const
Definition
ipv4-interface-container.cc:43
ns3::Names::Find
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition
names.h:443
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
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 Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0