A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-routing-table-entry.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
7 */
8
10
11#include "ns3/assert.h"
12
13namespace ns3
14{
15
19
21 : m_dest(route.m_dest),
22 m_destNetworkPrefix(route.m_destNetworkPrefix),
23 m_gateway(route.m_gateway),
24 m_interface(route.m_interface),
25 m_prefixToUse(route.m_prefixToUse)
26{
27}
28
30 : m_dest(route->m_dest),
31 m_destNetworkPrefix(route->m_destNetworkPrefix),
32 m_gateway(route->m_gateway),
33 m_interface(route->m_interface),
34 m_prefixToUse(route->m_prefixToUse)
35{
36}
37
39 Ipv6Address gateway,
40 uint32_t interface)
41 : m_dest(dest),
42 m_destNetworkPrefix(Ipv6Prefix::GetZero()),
43 m_gateway(gateway),
44 m_interface(interface),
45 m_prefixToUse(Ipv6Address("::"))
46{
47}
48
50 : m_dest(dest),
51 m_destNetworkPrefix(Ipv6Prefix::GetOnes()),
52 m_gateway(Ipv6Address::GetZero()),
53 m_interface(interface),
54 m_prefixToUse(Ipv6Address("::"))
55{
56}
57
59 Ipv6Prefix networkPrefix,
60 Ipv6Address gateway,
61 uint32_t interface,
62 Ipv6Address prefixToUse)
63 : m_dest(network),
64 m_destNetworkPrefix(networkPrefix),
65 m_gateway(gateway),
66 m_interface(interface),
67 m_prefixToUse(prefixToUse)
68{
69}
70
72 Ipv6Prefix networkPrefix,
73 Ipv6Address gateway,
74 uint32_t interface)
75 : m_dest(network),
76 m_destNetworkPrefix(networkPrefix),
77 m_gateway(gateway),
78 m_interface(interface),
79 m_prefixToUse(Ipv6Address::GetZero())
80{
81}
82
84 Ipv6Prefix networkPrefix,
85 uint32_t interface,
86 Ipv6Address prefixToUse)
87 : m_dest(network),
88 m_destNetworkPrefix(networkPrefix),
89 m_gateway(Ipv6Address::GetZero()),
90 m_interface(interface),
91 m_prefixToUse(prefixToUse)
92{
93}
94
96 Ipv6Prefix networkPrefix,
97 uint32_t interface)
98 : m_dest(network),
99 m_destNetworkPrefix(networkPrefix),
100 m_gateway(Ipv6Address::GetZero()),
101 m_interface(interface),
102 m_prefixToUse(Ipv6Address("::"))
103{
104}
105
109
110bool
115
118{
119 return m_dest;
120}
121
127
128void
133
134bool
136{
137 return !IsHost();
138}
139
140bool
145
148{
149 return m_dest;
150}
151
157
158bool
163
166{
167 return m_gateway;
168}
169
172 Ipv6Address nextHop,
173 uint32_t interface,
174 Ipv6Address prefixToUse)
175{
176 return Ipv6RoutingTableEntry(dest, Ipv6Prefix::GetOnes(), nextHop, interface, prefixToUse);
177}
178
181{
182 return Ipv6RoutingTableEntry(dest, interface);
183}
184
187 Ipv6Prefix networkPrefix,
188 Ipv6Address nextHop,
189 uint32_t interface)
190{
191 return Ipv6RoutingTableEntry(network, networkPrefix, nextHop, interface);
192}
193
196 Ipv6Prefix networkPrefix,
197 Ipv6Address nextHop,
198 uint32_t interface,
199 Ipv6Address prefixToUse)
200{
201 return Ipv6RoutingTableEntry(network, networkPrefix, nextHop, interface, prefixToUse);
202}
203
206 Ipv6Prefix networkPrefix,
207 uint32_t interface)
208{
209 return Ipv6RoutingTableEntry(network, networkPrefix, interface, network);
210}
211
214{
215 return Ipv6RoutingTableEntry(Ipv6Address::GetZero(), nextHop, interface);
216}
217
223
224std::ostream&
225operator<<(std::ostream& os, const Ipv6RoutingTableEntry& route)
226{
227 if (route.IsDefault())
228 {
229 NS_ASSERT(route.IsGateway());
230 os << "default out: " << route.GetInterface() << ", next hop: " << route.GetGateway();
231 }
232 else if (route.IsHost())
233 {
234 if (route.IsGateway())
235 {
236 os << "host: " << route.GetDest() << ", out: " << route.GetInterface()
237 << ", next hop: " << route.GetGateway();
238 }
239 else
240 {
241 os << "host: " << route.GetDest() << ", out: " << route.GetInterface();
242 }
243 }
244 else if (route.IsNetwork())
245 {
246 if (route.IsGateway())
247 {
248 os << "network: " << route.GetDestNetwork() << "/ "
249 << int(route.GetDestNetworkPrefix().GetPrefixLength())
250 << ", out: " << route.GetInterface() << ", next hop: " << route.GetGateway();
251 }
252 else
253 {
254 os << "network: " << route.GetDestNetwork() << "/"
255 << int(route.GetDestNetworkPrefix().GetPrefixLength())
256 << ", out: " << route.GetInterface();
257 }
258 }
259 else
260 {
261 NS_ASSERT(false);
262 }
263 return os;
264}
265
269
272 : m_origin(route.m_origin),
273 m_group(route.m_group),
274 m_inputInterface(route.m_inputInterface),
275 m_outputInterfaces(route.m_outputInterfaces)
276{
277}
278
281 : m_origin(route->m_origin),
282 m_group(route->m_group),
283 m_inputInterface(route->m_inputInterface),
284 m_outputInterfaces(route->m_outputInterfaces)
285{
286}
287
289 Ipv6Address origin,
290 Ipv6Address group,
291 uint32_t inputInterface,
292 std::vector<uint32_t> outputInterfaces)
293 : m_origin(origin),
294 m_group(group),
295 m_inputInterface(inputInterface),
296 m_outputInterfaces(outputInterfaces)
297{
298}
299
305
311
317
323
326{
328 "Ipv6MulticastRoutingTableEntry::GetOutputInterface () : index out of bounds");
329
330 return m_outputInterfaces[n];
331}
332
333std::vector<uint32_t>
338
341 Ipv6Address group,
342 uint32_t inputInterface,
343 std::vector<uint32_t> outputInterfaces)
344{
345 return Ipv6MulticastRoutingTableEntry(origin, group, inputInterface, outputInterfaces);
346}
347
348std::ostream&
349operator<<(std::ostream& os, const Ipv6MulticastRoutingTableEntry& route)
350{
351 os << "origin: " << route.GetOrigin() << ", group: " << route.GetGroup()
352 << ", input interface: " << route.GetInputInterface() << ", output interfaces: ";
353
354 for (uint32_t i = 0; i < route.GetNOutputInterfaces(); ++i)
355 {
356 os << route.GetOutputInterface(i) << " ";
357 }
358
359 return os;
360}
361
362} /* namespace ns3 */
Describes an IPv6 address.
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
A record of an IPv6 multicast route.
uint32_t GetInputInterface() const
Get the input interface address.
uint32_t GetOutputInterface(uint32_t n) const
Get a specified output interface.
Ipv6Address GetGroup() const
Get the group.
uint32_t m_inputInterface
The input interface.
Ipv6MulticastRoutingTableEntry()
Constructor.
std::vector< uint32_t > GetOutputInterfaces() const
Get all of the output interfaces of this route.
static Ipv6MulticastRoutingTableEntry CreateMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
Create a multicast route.
std::vector< uint32_t > m_outputInterfaces
The output interfaces.
uint32_t GetNOutputInterfaces() const
Get the number of output interfaces of this route.
Ipv6Address GetOrigin() const
Get the source of this route.
Ipv6Address m_group
The IPv6 address of the group.
Ipv6Address m_origin
The IPv6 address of the source.
Describes an IPv6 prefix.
uint8_t GetPrefixLength() const
Get prefix length.
static Ipv6Prefix GetOnes()
Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).
A record of an IPv6 route.
bool IsNetwork() const
Is the route entry correspond to a network ?
static Ipv6RoutingTableEntry CreateDefaultRoute(Ipv6Address nextHop, uint32_t interface)
Create a default route.
Ipv6Address m_gateway
IPv6 address of the gateway.
bool IsDefault() const
Is it the default route ?
Ipv6RoutingTableEntry()
Constructor.
Ipv6Address GetDest() const
Get the destination.
Ipv6Address GetDestNetwork() const
Get the destination network.
Ipv6Address GetPrefixToUse() const
Get the prefix to use (for multihomed link).
Ipv6Address m_dest
IPv6 address of the destination.
static Ipv6RoutingTableEntry CreateHostRouteTo(Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address())
Create a route to a host.
bool IsHost() const
Is the route entry correspond to a host ?
void SetPrefixToUse(Ipv6Address prefix)
Set the prefix to use.
uint32_t GetInterface() const
Get the interface index.
Ipv6Address m_prefixToUse
Prefix to use.
Ipv6Prefix m_destNetworkPrefix
IPv6 prefix of the destination.
virtual ~Ipv6RoutingTableEntry()
Destructor.
uint32_t m_interface
The interface index.
Ipv6Prefix GetDestNetworkPrefix() const
Get the destination prefix.
static Ipv6RoutingTableEntry CreateNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface)
Create a route to a network.
Ipv6Address GetGateway() const
Get the gateway.
bool IsGateway() const
Is it the gateway ?
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148