A Discrete-Event Network Simulator
API
ipv6-routing-table-entry.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18 */
19
21
22#include "ns3/assert.h"
23
24namespace ns3
25{
26
28{
29}
30
32 : m_dest(route.m_dest),
33 m_destNetworkPrefix(route.m_destNetworkPrefix),
34 m_gateway(route.m_gateway),
35 m_interface(route.m_interface),
36 m_prefixToUse(route.m_prefixToUse)
37{
38}
39
41 : m_dest(route->m_dest),
42 m_destNetworkPrefix(route->m_destNetworkPrefix),
43 m_gateway(route->m_gateway),
44 m_interface(route->m_interface),
45 m_prefixToUse(route->m_prefixToUse)
46{
47}
48
50 Ipv6Address gateway,
51 uint32_t interface)
52 : m_dest(dest),
53 m_destNetworkPrefix(Ipv6Prefix::GetZero()),
54 m_gateway(gateway),
55 m_interface(interface),
56 m_prefixToUse(Ipv6Address("::"))
57{
58}
59
61 : m_dest(dest),
62 m_destNetworkPrefix(Ipv6Prefix::GetOnes()),
63 m_gateway(Ipv6Address::GetZero()),
64 m_interface(interface),
65 m_prefixToUse(Ipv6Address("::"))
66{
67}
68
70 Ipv6Prefix networkPrefix,
71 Ipv6Address gateway,
72 uint32_t interface,
73 Ipv6Address prefixToUse)
74 : m_dest(network),
75 m_destNetworkPrefix(networkPrefix),
76 m_gateway(gateway),
77 m_interface(interface),
78 m_prefixToUse(prefixToUse)
79{
80}
81
83 Ipv6Prefix networkPrefix,
84 Ipv6Address gateway,
85 uint32_t interface)
86 : m_dest(network),
87 m_destNetworkPrefix(networkPrefix),
88 m_gateway(gateway),
89 m_interface(interface),
90 m_prefixToUse(Ipv6Address::GetZero())
91{
92}
93
95 Ipv6Prefix networkPrefix,
96 uint32_t interface,
97 Ipv6Address prefixToUse)
98 : m_dest(network),
99 m_destNetworkPrefix(networkPrefix),
100 m_gateway(Ipv6Address::GetZero()),
101 m_interface(interface),
102 m_prefixToUse(prefixToUse)
103{
104}
105
107 Ipv6Prefix networkPrefix,
108 uint32_t interface)
109 : m_dest(network),
110 m_destNetworkPrefix(networkPrefix),
111 m_gateway(Ipv6Address::GetZero()),
112 m_interface(interface),
113 m_prefixToUse(Ipv6Address("::"))
114{
115}
116
118{
119}
120
121bool
123{
125 {
126 return true;
127 }
128 return false;
129}
130
133{
134 return m_dest;
135}
136
139{
140 return m_prefixToUse;
141}
142
143void
145{
146 m_prefixToUse = prefix;
147}
148
149bool
151{
152 return !IsHost();
153}
154
155bool
157{
159 {
160 return true;
161 }
162 return false;
163}
164
167{
168 return m_dest;
169}
170
173{
174 return m_destNetworkPrefix;
175}
176
177bool
179{
181 {
182 return false;
183 }
184 return true;
185}
186
189{
190 return m_gateway;
191}
192
195 Ipv6Address nextHop,
196 uint32_t interface,
197 Ipv6Address prefixToUse)
198{
199 return Ipv6RoutingTableEntry(dest, Ipv6Prefix::GetOnes(), nextHop, interface, prefixToUse);
200}
201
204{
205 return Ipv6RoutingTableEntry(dest, interface);
206}
207
210 Ipv6Prefix networkPrefix,
211 Ipv6Address nextHop,
212 uint32_t interface)
213{
214 return Ipv6RoutingTableEntry(network, networkPrefix, nextHop, interface);
215}
216
219 Ipv6Prefix networkPrefix,
220 Ipv6Address nextHop,
221 uint32_t interface,
222 Ipv6Address prefixToUse)
223{
224 return Ipv6RoutingTableEntry(network, networkPrefix, nextHop, interface, prefixToUse);
225}
226
229 Ipv6Prefix networkPrefix,
230 uint32_t interface)
231{
232 return Ipv6RoutingTableEntry(network, networkPrefix, interface, network);
233}
234
237{
238 return Ipv6RoutingTableEntry(Ipv6Address::GetZero(), nextHop, interface);
239}
240
243{
244 return m_interface;
245}
246
247std::ostream&
248operator<<(std::ostream& os, const Ipv6RoutingTableEntry& route)
249{
250 if (route.IsDefault())
251 {
252 NS_ASSERT(route.IsGateway());
253 os << "default out: " << route.GetInterface() << ", next hop: " << route.GetGateway();
254 }
255 else if (route.IsHost())
256 {
257 if (route.IsGateway())
258 {
259 os << "host: " << route.GetDest() << ", out: " << route.GetInterface()
260 << ", next hop: " << route.GetGateway();
261 }
262 else
263 {
264 os << "host: " << route.GetDest() << ", out: " << route.GetInterface();
265 }
266 }
267 else if (route.IsNetwork())
268 {
269 if (route.IsGateway())
270 {
271 os << "network: " << route.GetDestNetwork() << "/ "
273 << ", out: " << route.GetInterface() << ", next hop: " << route.GetGateway();
274 }
275 else
276 {
277 os << "network: " << route.GetDestNetwork() << "/"
279 << ", out: " << route.GetInterface();
280 }
281 }
282 else
283 {
284 NS_ASSERT(false);
285 }
286 return os;
287}
288
290{
291}
292
295 : m_origin(route.m_origin),
296 m_group(route.m_group),
297 m_inputInterface(route.m_inputInterface),
298 m_outputInterfaces(route.m_outputInterfaces)
299{
300}
301
304 : m_origin(route->m_origin),
305 m_group(route->m_group),
306 m_inputInterface(route->m_inputInterface),
307 m_outputInterfaces(route->m_outputInterfaces)
308{
309}
310
312 Ipv6Address origin,
313 Ipv6Address group,
314 uint32_t inputInterface,
315 std::vector<uint32_t> outputInterfaces)
316 : m_origin(origin),
317 m_group(group),
318 m_inputInterface(inputInterface),
319 m_outputInterfaces(outputInterfaces)
320{
321}
322
325{
326 return m_origin;
327}
328
331{
332 return m_group;
333}
334
337{
338 return m_inputInterface;
339}
340
343{
344 return m_outputInterfaces.size();
345}
346
349{
351 "Ipv6MulticastRoutingTableEntry::GetOutputInterface () : index out of bounds");
352
353 return m_outputInterfaces[n];
354}
355
356std::vector<uint32_t>
358{
359 return m_outputInterfaces;
360}
361
364 Ipv6Address group,
365 uint32_t inputInterface,
366 std::vector<uint32_t> outputInterfaces)
367{
368 return Ipv6MulticastRoutingTableEntry(origin, group, inputInterface, outputInterfaces);
369}
370
371std::ostream&
372operator<<(std::ostream& os, const Ipv6MulticastRoutingTableEntry& route)
373{
374 os << "origin: " << route.GetOrigin() << ", group: " << route.GetGroup()
375 << ", input interface: " << route.GetInputInterface() << ", output interfaces: ";
376
377 for (uint32_t i = 0; i < route.GetNOutputInterfaces(); ++i)
378 {
379 os << route.GetOutputInterface(i) << " ";
380 }
381
382 return os;
383}
384
385} /* namespace ns3 */
Describes an IPv6 address.
Definition: ipv6-address.h:50
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.
Definition: ipv6-address.h:456
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:66
#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:86
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:129