A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-static-routing.h
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
20#ifndef IPV6_STATIC_ROUTING_H
21#define IPV6_STATIC_ROUTING_H
22
23#include "ipv6-header.h"
25#include "ipv6.h"
26
27#include "ns3/ipv6-address.h"
28#include "ns3/ptr.h"
29
30#include <list>
31#include <stdint.h>
32
33namespace ns3
34{
35
36class Packet;
37class NetDevice;
38class Ipv6Interface;
39class Ipv6Route;
40class Node;
41class Ipv6RoutingTableEntry;
42class Ipv6MulticastRoutingTableEntry;
43
64{
65 public:
70 static TypeId GetTypeId();
71
73 ~Ipv6StaticRouting() override;
74
84 Ipv6Address nextHop,
85 uint32_t interface,
86 Ipv6Address prefixToUse = Ipv6Address("::"),
87 uint32_t metric = 0);
88
95 void AddHostRouteTo(Ipv6Address dest, uint32_t interface, uint32_t metric = 0);
96
105 void AddNetworkRouteTo(Ipv6Address network,
106 Ipv6Prefix networkPrefix,
107 Ipv6Address nextHop,
108 uint32_t interface,
109 uint32_t metric = 0);
110
120 void AddNetworkRouteTo(Ipv6Address network,
121 Ipv6Prefix networkPrefix,
122 Ipv6Address nextHop,
123 uint32_t interface,
124 Ipv6Address prefixToUse,
125 uint32_t metric = 0);
126
134 void AddNetworkRouteTo(Ipv6Address network,
135 Ipv6Prefix networkPrefix,
136 uint32_t interface,
137 uint32_t metric = 0);
138
146 void SetDefaultRoute(Ipv6Address nextHop,
147 uint32_t interface,
148 Ipv6Address prefixToUse = Ipv6Address("::"),
149 uint32_t metric = 0);
150
155 uint32_t GetNRoutes() const;
156
164
171
178 uint32_t GetMetric(uint32_t index) const;
179
184 void RemoveRoute(uint32_t i);
185
193 void RemoveRoute(Ipv6Address network,
194 Ipv6Prefix prefix,
195 uint32_t ifIndex,
196 Ipv6Address prefixToUse);
197
206 void AddMulticastRoute(Ipv6Address origin,
207 Ipv6Address group,
208 uint32_t inputInterface,
209 std::vector<uint32_t> outputInterfaces);
210
215 void SetDefaultMulticastRoute(uint32_t outputInterface);
216
222
229
237 bool RemoveMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface);
238
244
251 bool HasNetworkDest(Ipv6Address dest, uint32_t interfaceIndex);
252
254 const Ipv6Header& header,
255 Ptr<NetDevice> oif,
256 Socket::SocketErrno& sockerr) override;
257
259 const Ipv6Header& header,
261 const UnicastForwardCallback& ucb,
262 const MulticastForwardCallback& mcb,
263 const LocalDeliverCallback& lcb,
264 const ErrorCallback& ecb) override;
265
266 void NotifyInterfaceUp(uint32_t interface) override;
267 void NotifyInterfaceDown(uint32_t interface) override;
268 void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
269 void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
271 Ipv6Prefix mask,
272 Ipv6Address nextHop,
273 uint32_t interface,
274 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
276 Ipv6Prefix mask,
277 Ipv6Address nextHop,
278 uint32_t interface,
279 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
280 void SetIpv6(Ptr<Ipv6> ipv6) override;
282 Time::Unit unit = Time::S) const override;
283
284 protected:
288 void DoDispose() override;
289
290 private:
292 typedef std::list<std::pair<Ipv6RoutingTableEntry*, uint32_t>> NetworkRoutes;
293
295 typedef std::list<std::pair<Ipv6RoutingTableEntry*, uint32_t>>::const_iterator NetworkRoutesCI;
296
298 typedef std::list<std::pair<Ipv6RoutingTableEntry*, uint32_t>>::iterator NetworkRoutesI;
299
301 typedef std::list<Ipv6MulticastRoutingTableEntry*> MulticastRoutes;
302
304 typedef std::list<Ipv6MulticastRoutingTableEntry*>::const_iterator MulticastRoutesCI;
305
307 typedef std::list<Ipv6MulticastRoutingTableEntry*>::iterator MulticastRoutesI;
308
315 bool LookupRoute(const Ipv6RoutingTableEntry& route, uint32_t metric);
316
324
333
338
343
348};
349
350} /* namespace ns3 */
351
352#endif /* IPV6_STATIC_ROUTING_H */
Describes an IPv6 address.
Definition: ipv6-address.h:49
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Packet header for IPv6.
Definition: ipv6-header.h:35
IPv6 address associated with an interface.
A record of an IPv6 multicast route.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
Abstract base class for IPv6 routing protocols.
A record of an IPv6 route.
Static routing protocol for IP version 6 stacks.
std::list< Ipv6MulticastRoutingTableEntry * >::const_iterator MulticastRoutesCI
Const Iterator for container for the multicast routes.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
Ipv6RoutingTableEntry GetRoute(uint32_t i) const
Get a specified route.
void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override
Notify when specified interface add an address.
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > >::const_iterator NetworkRoutesCI
Const Iterator for container for the network routes.
void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()) override
Notify route removing.
void RemoveRoute(uint32_t i)
Remove a route from the routing table.
Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override
Notify when specified interface add an address.
static TypeId GetTypeId()
The interface Id associated with this class.
Ptr< Ipv6Route > LookupStatic(Ipv6Address dest, Ptr< NetDevice >=nullptr)
Lookup in the forwarding table for destination.
void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()) override
Notify a new route.
bool HasNetworkDest(Ipv6Address dest, uint32_t interfaceIndex)
If the destination is already present in network destination list.
std::list< Ipv6MulticastRoutingTableEntry * > MulticastRoutes
Container for the multicast routes.
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > >::iterator NetworkRoutesI
Iterator for container for the network routes.
bool LookupRoute(const Ipv6RoutingTableEntry &route, uint32_t metric)
Checks if a route is already present in the forwarding table.
std::list< Ipv6MulticastRoutingTableEntry * >::iterator MulticastRoutesI
Iterator for container for the multicast routes.
void AddMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
Add a multicast route for a given multicast source and group.
void AddHostRouteTo(Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address("::"), uint32_t metric=0)
Add route to host.
uint32_t GetNRoutes() const
Get the number or entries in the routing table.
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > > NetworkRoutes
Container for the network routes.
Ipv6MulticastRoutingTableEntry GetMulticastRoute(uint32_t i) const
Get the specified multicast route.
Ipv6RoutingTableEntry GetDefaultRoute()
Get the default route.
MulticastRoutes m_multicastRoutes
the forwarding table for multicast.
uint32_t GetNMulticastRoutes() const
Get the number of entries in the multicast routing table.
bool RemoveMulticastRoute(Ipv6Address origin, Ipv6Address group, uint32_t inputInterface)
Remove a static multicast route.
void NotifyInterfaceDown(uint32_t interface) override
Notify when specified interface goes DOWN.
void DoDispose() override
Dispose this object.
void AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric=0)
Add route to network.
NetworkRoutes m_networkRoutes
the forwarding table for network.
void NotifyInterfaceUp(uint32_t interface) override
Notify when specified interface goes UP.
void SetDefaultMulticastRoute(uint32_t outputInterface)
Set the default multicast route.
bool RouteInput(Ptr< const Packet > p, const Ipv6Header &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb) override
Route an input packet (to be forwarded or locally delivered)
uint32_t GetMetric(uint32_t index) const
Get a metric for route from the static unicast routing table.
void SetIpv6(Ptr< Ipv6 > ipv6) override
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
Ptr< Ipv6 > m_ipv6
Ipv6 reference.
void SetDefaultRoute(Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address("::"), uint32_t metric=0)
Set the default route.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:84
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:111
@ S
second
Definition: nstime.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.