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
ipv6-interface-container.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2009 Strasbourg University
3
* 2013 Universita' di Firenze
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
8
* Tommaso Pecorella <tommaso.pecorella@unifi.it>
9
*/
10
11
#ifndef IPV6_INTERFACE_CONTAINER_H
12
#define IPV6_INTERFACE_CONTAINER_H
13
14
#include "ns3/ipv6-address.h"
15
#include "ns3/ipv6.h"
16
17
#include <stdint.h>
18
#include <vector>
19
20
namespace
ns3
21
{
22
23
/**
24
* @ingroup ipv6
25
*
26
* @brief Keep track of a set of IPv6 interfaces.
27
*/
28
class
Ipv6InterfaceContainer
29
{
30
public
:
31
/**
32
* @brief Container Const Iterator for pairs of Ipv6 smart pointer / Interface Index.
33
*/
34
typedef
std::vector<std::pair<Ptr<Ipv6>,
uint32_t
>>::const_iterator
Iterator
;
35
36
/**
37
* @brief Constructor.
38
*/
39
Ipv6InterfaceContainer
();
40
41
/**
42
* @returns the number of Ptr<Ipv6> and interface pairs stored in this
43
* Ipv6InterfaceContainer.
44
*
45
* Pairs can be retrieved from the container in two ways. First,
46
* directly by an index into the container, and second, using an iterator.
47
* This method is used in the direct method and is typically used to
48
* define an ending condition in a for-loop that runs through the stored
49
* Nodes
50
*
51
* @code
52
* uint32_t nNodes = container.GetN ();
53
* for (uint32_t i = 0 i < nNodes; ++i)
54
* {
55
* std::pair<Ptr<Ipv6>, uint32_t> pair = container.Get (i);
56
* method (pair.first, pair.second); // use the pair
57
* }
58
* @endcode
59
*/
60
uint32_t
GetN
()
const
;
61
62
/**
63
* @brief Get the interface index for the specified node index.
64
* @param i index of the node
65
* @return interface index
66
*/
67
uint32_t
GetInterfaceIndex
(
uint32_t
i)
const
;
68
69
/**
70
* @brief Get the address for the specified index.
71
* @param i interface index
72
* @param j address index, generally index 0 is the link-local address
73
* @return IPv6 address
74
*/
75
Ipv6Address
GetAddress
(
uint32_t
i,
uint32_t
j)
const
;
76
77
/**
78
* @brief Get the link-local address for the specified index.
79
* @param i index
80
* @return the link-local address, or "::" if the interface has no link local address.
81
*/
82
Ipv6Address
GetLinkLocalAddress
(
uint32_t
i);
83
84
/**
85
* @brief Get the link-local address for the node with the specified global address.
86
* @param address the address to find.
87
* @return the link-local address, or "::" if the interface has no link local address.
88
*/
89
Ipv6Address
GetLinkLocalAddress
(
Ipv6Address
address);
90
91
/**
92
* @brief Add a couple IPv6/interface.
93
* @param ipv6 IPv6 address
94
* @param interface interface index
95
*/
96
void
Add
(
Ptr<Ipv6>
ipv6,
uint32_t
interface);
97
98
/**
99
* @brief Get an iterator which refers to the first pair in the
100
* container.
101
*
102
* Pairs can be retrieved from the container in two ways. First,
103
* directly by an index into the container, and second, using an iterator.
104
* This method is used in the iterator method and is typically used in a
105
* for-loop to run through the pairs
106
*
107
* @code
108
* Ipv6InterfaceContainer::Iterator i;
109
* for (i = container.Begin (); i != container.End (); ++i)
110
* {
111
* std::pair<Ptr<Ipv6>, uint32_t> pair = *i;
112
* method (pair.first, pair.second); // use the pair
113
* }
114
* @endcode
115
*
116
* @returns an iterator which refers to the first pair in the container.
117
*/
118
Iterator
Begin
()
const
;
119
120
/**
121
* @brief Get an iterator which indicates past-the-last Node in the
122
* container.
123
*
124
* Nodes can be retrieved from the container in two ways. First,
125
* directly by an index into the container, and second, using an iterator.
126
* This method is used in the iterator method and is typically used in a
127
* for-loop to run through the Nodes
128
*
129
* @code
130
* NodeContainer::Iterator i;
131
* for (i = container.Begin (); i != container.End (); ++i)
132
* {
133
* std::pair<Ptr<Ipv6>, uint32_t> pair = *i;
134
* method (pair.first, pair.second); // use the pair
135
* }
136
* @endcode
137
*
138
* @returns an iterator which indicates an ending condition for a loop.
139
*/
140
Iterator
End
()
const
;
141
142
/**
143
* @brief Fusion with another Ipv6InterfaceContainer.
144
* @param c container
145
*/
146
void
Add
(
const
Ipv6InterfaceContainer
& c);
147
148
/**
149
* @brief Add a couple of name/interface.
150
* @param ipv6Name name of a node
151
* @param interface interface index to add
152
*/
153
void
Add
(std::string ipv6Name,
uint32_t
interface);
154
155
/**
156
* Get the std::pair of an Ptr<Ipv6> and interface stored at the location
157
* specified by the index.
158
*
159
* @param i the index of the container entry to retrieve.
160
* @return the std::pair of a Ptr<Ipv6> and an interface index
161
*
162
* @note The returned Ptr<Ipv6> cannot be used directly to fetch the
163
* Ipv6Interface using the returned index (the GetInterface () method
164
* is provided in class Ipv6L3Protocol, and not class Ipv6). An
165
* example usage is provided below.
166
*
167
* @code
168
* Ipv6InterfaceContainer c;
169
* ...
170
* std::pair<Ptr<Ipv6>, uint32_t> returnValue = c.Get (0);
171
* Ptr<Ipv6> ipv6 = returnValue.first;
172
* uint32_t index = returnValue.second;
173
* Ptr<Ipv6Interface> iface = DynamicCast<Ipv6L3Protocol> (ipv6)->GetInterface (index);
174
* @endcode
175
*/
176
std::pair<Ptr<Ipv6>,
uint32_t
>
Get
(
uint32_t
i)
const
;
177
178
/**
179
* @brief Set the state of the stack (act as a router or as an host) for the specified index.
180
* This automatically sets all the node's interfaces to the same forwarding state.
181
* @param i index
182
* @param state true : is a router, false : is an host
183
*/
184
void
SetForwarding
(
uint32_t
i,
bool
state);
185
186
/**
187
* @brief Set the default route for all the devices (except the router itself).
188
* @param router the default router index
189
*/
190
void
SetDefaultRouteInAllNodes
(
uint32_t
router);
191
192
/**
193
* @brief Set the default route for all the devices (except the router itself).
194
* Note that the route will be set to the link-local address of the node with the specified
195
* address.
196
* @param routerAddr the default router address
197
*/
198
void
SetDefaultRouteInAllNodes
(
Ipv6Address
routerAddr);
199
200
/**
201
* @brief Set the default route for the specified index.
202
* @param i index
203
* @param router the default router
204
*/
205
void
SetDefaultRoute
(
uint32_t
i,
uint32_t
router);
206
207
/**
208
* @brief Set the default route for the specified index.
209
* Note that the route will be set to the link-local address of the node with the specified
210
* address.
211
* @param i index
212
* @param routerAddr the default router address
213
*/
214
void
SetDefaultRoute
(
uint32_t
i,
Ipv6Address
routerAddr);
215
216
private
:
217
/**
218
* @brief Container for pairs of Ipv6 smart pointer / Interface Index.
219
*/
220
typedef
std::vector<std::pair<Ptr<Ipv6>,
uint32_t
>>
InterfaceVector
;
221
222
/**
223
* @brief List of IPv6 stack and interfaces index.
224
*/
225
InterfaceVector
m_interfaces
;
226
};
227
228
}
/* namespace ns3 */
229
230
#endif
/* IPV6_INTERFACE_CONTAINER_H */
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Ipv6InterfaceContainer
Keep track of a set of IPv6 interfaces.
Definition
ipv6-interface-container.h:29
ns3::Ipv6InterfaceContainer::SetForwarding
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
Definition
ipv6-interface-container.cc:86
ns3::Ipv6InterfaceContainer::GetInterfaceIndex
uint32_t GetInterfaceIndex(uint32_t i) const
Get the interface index for the specified node index.
Definition
ipv6-interface-container.cc:44
ns3::Ipv6InterfaceContainer::Ipv6InterfaceContainer
Ipv6InterfaceContainer()
Constructor.
Definition
ipv6-interface-container.cc:21
ns3::Ipv6InterfaceContainer::SetDefaultRouteInAllNodes
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
Definition
ipv6-interface-container.cc:93
ns3::Ipv6InterfaceContainer::SetDefaultRoute
void SetDefaultRoute(uint32_t i, uint32_t router)
Set the default route for the specified index.
Definition
ipv6-interface-container.cc:162
ns3::Ipv6InterfaceContainer::m_interfaces
InterfaceVector m_interfaces
List of IPv6 stack and interfaces index.
Definition
ipv6-interface-container.h:225
ns3::Ipv6InterfaceContainer::InterfaceVector
std::vector< std::pair< Ptr< Ipv6 >, uint32_t > > InterfaceVector
Container for pairs of Ipv6 smart pointer / Interface Index.
Definition
ipv6-interface-container.h:220
ns3::Ipv6InterfaceContainer::Iterator
std::vector< std::pair< Ptr< Ipv6 >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of Ipv6 smart pointer / Interface Index.
Definition
ipv6-interface-container.h:34
ns3::Ipv6InterfaceContainer::GetAddress
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
Definition
ipv6-interface-container.cc:50
ns3::Ipv6InterfaceContainer::GetLinkLocalAddress
Ipv6Address GetLinkLocalAddress(uint32_t i)
Get the link-local address for the specified index.
Definition
ipv6-interface-container.cc:224
ns3::Ipv6InterfaceContainer::GetN
uint32_t GetN() const
Definition
ipv6-interface-container.cc:38
ns3::Ipv6InterfaceContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Definition
ipv6-interface-container.cc:32
ns3::Ipv6InterfaceContainer::Add
void Add(Ptr< Ipv6 > ipv6, uint32_t interface)
Add a couple IPv6/interface.
Definition
ipv6-interface-container.cc:58
ns3::Ipv6InterfaceContainer::Get
std::pair< Ptr< Ipv6 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.
Definition
ipv6-interface-container.cc:80
ns3::Ipv6InterfaceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first pair in the container.
Definition
ipv6-interface-container.cc:26
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
helper
ipv6-interface-container.h
Generated on Wed Dec 11 2024 09:20:49 for ns-3 by
1.11.0