A Discrete-Event Network Simulator
API
ipv6-static-routing.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #ifndef IPV6_STATIC_ROUTING_H
22 #define IPV6_STATIC_ROUTING_H
23 
24 #include <stdint.h>
25 
26 #include <list>
27 
28 #include "ns3/ptr.h"
29 #include "ns3/ipv6-address.h"
30 #include "ns3/ipv6.h"
31 #include "ns3/ipv6-header.h"
32 #include "ns3/ipv6-routing-protocol.h"
33 
34 namespace ns3 {
35 
36 class Packet;
37 class NetDevice;
38 class Ipv6Interface;
39 class Ipv6Route;
40 class Node;
41 class Ipv6RoutingTableEntry;
42 class Ipv6MulticastRoutingTableEntry;
43 
64 {
65 public:
70  static TypeId GetTypeId ();
71 
73  virtual ~Ipv6StaticRouting ();
74 
83  void AddHostRouteTo (Ipv6Address dest, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0);
84 
91  void AddHostRouteTo (Ipv6Address dest, uint32_t interface, uint32_t metric = 0);
92 
101  void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, uint32_t metric = 0);
102 
112  void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric = 0);
113 
121  void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface, uint32_t metric = 0);
122 
130  void SetDefaultRoute (Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address ("::"), uint32_t metric = 0);
131 
136  uint32_t GetNRoutes () const;
137 
145 
151  Ipv6RoutingTableEntry GetRoute (uint32_t i) const;
152 
158  uint32_t GetMetric (uint32_t index) const;
159 
164  void RemoveRoute (uint32_t i);
165 
173  void RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uint32_t ifIndex, Ipv6Address prefixToUse);
174 
183  void AddMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
184 
189  void SetDefaultMulticastRoute (uint32_t outputInterface);
190 
195  uint32_t GetNMulticastRoutes () const;
196 
203 
211  bool RemoveMulticastRoute (Ipv6Address origin, Ipv6Address group, uint32_t inputInterface);
212 
217  void RemoveMulticastRoute (uint32_t i);
218 
225  bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex);
226 
227  virtual Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
228 
229  virtual bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
232 
233  virtual void NotifyInterfaceUp (uint32_t interface);
234  virtual void NotifyInterfaceDown (uint32_t interface);
235  virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address);
236  virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address);
237  virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
238  virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
239  virtual void SetIpv6 (Ptr<Ipv6> ipv6);
240  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
241 
242 protected:
246  virtual void DoDispose ();
247 
248 private:
250  typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> > NetworkRoutes;
251 
253  typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
254 
256  typedef std::list<std::pair <Ipv6RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
257 
259  typedef std::list<Ipv6MulticastRoutingTableEntry *> MulticastRoutes;
260 
262  typedef std::list<Ipv6MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
263 
265  typedef std::list<Ipv6MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
266 
273  bool LookupRoute (const Ipv6RoutingTableEntry &route, uint32_t metric);
274 
282 
290  Ptr<Ipv6MulticastRoute> LookupStatic (Ipv6Address origin, Ipv6Address group, uint32_t ifIndex);
291 
296 
301 
306 };
307 
308 } /* namespace ns3 */
309 
310 #endif /* IPV6_STATIC_ROUTING_H */
311 
Callback template class.
Definition: callback.h:1279
Describes an IPv6 address.
Definition: ipv6-address.h:50
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Packet header for IPv6.
Definition: ipv6-header.h:36
IPv6 address associated with an interface.
A record of an IPv6 multicast route.
Describes an IPv6 prefix.
Definition: ipv6-address.h:456
Abstract base class for IPv6 routing protocols.
A record of an IPv6 route.
Static routing protocol for IP version 6 stacks.
std::list< Ipv6MulticastRoutingTableEntry * > MulticastRoutes
Container for the multicast routes.
virtual void SetIpv6(Ptr< Ipv6 > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
virtual void DoDispose()
Dispose this object.
Ipv6RoutingTableEntry GetRoute(uint32_t i) const
Get a specified route.
virtual void NotifyInterfaceDown(uint32_t interface)
Notify when specified interface goes DOWN.
void RemoveRoute(uint32_t i)
Remove a route from the routing table.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv6Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
static TypeId GetTypeId()
The interface Id associated with this class.
virtual Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
Ptr< Ipv6Route > LookupStatic(Ipv6Address dest, Ptr< NetDevice >=0)
Lookup in the forwarding table for destination.
bool HasNetworkDest(Ipv6Address dest, uint32_t interfaceIndex)
If the destination is already present in network destination list.
bool LookupRoute(const Ipv6RoutingTableEntry &route, uint32_t metric)
Checks if a route is already present in the forwarding table.
std::list< Ipv6MulticastRoutingTableEntry * >::const_iterator MulticastRoutesCI
Const Iterator for container for the multicast routes.
virtual void NotifyInterfaceUp(uint32_t interface)
Notify when specified interface goes UP.
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.
virtual void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify a new route.
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > >::iterator NetworkRoutesI
Iterator for container for the network routes.
Ipv6RoutingTableEntry GetDefaultRoute()
Get the default route.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.
virtual void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.
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 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 SetDefaultMulticastRoute(uint32_t outputInterface)
Set the default multicast route.
std::list< std::pair< Ipv6RoutingTableEntry *, uint32_t > >::const_iterator NetworkRoutesCI
Const Iterator for container for the network routes.
uint32_t GetMetric(uint32_t index) const
Get a metric for route from the static unicast routing table.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
Ptr< Ipv6 > m_ipv6
Ipv6 reference.
std::list< Ipv6MulticastRoutingTableEntry * >::iterator MulticastRoutesI
Iterator for container for the multicast routes.
virtual void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify route removing.
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:74
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:109
@ S
second
Definition: nstime.h:114
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.