A Discrete-Event Network Simulator
API
ipv4-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) 2006 Georgia Tech Research Corporation
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: George F. Riley<riley@ece.gatech.edu>
19 * Gustavo Carneiro <gjc@inescporto.pt>
20 */
21
22#ifndef IPV4_STATIC_ROUTING_H
23#define IPV4_STATIC_ROUTING_H
24
25#include <list>
26#include <utility>
27#include <stdint.h>
28#include "ns3/ipv4-address.h"
29#include "ns3/ipv4-header.h"
30#include "ns3/socket.h"
31#include "ns3/ptr.h"
32#include "ns3/ipv4.h"
33#include "ns3/ipv4-routing-protocol.h"
34
35namespace ns3 {
36
37class Packet;
38class NetDevice;
39class Ipv4Interface;
40class Ipv4Address;
41class Ipv4Header;
42class Ipv4RoutingTableEntry;
43class Ipv4MulticastRoutingTableEntry;
44class Node;
45
66{
67public:
72 static TypeId GetTypeId (void);
73
75 virtual ~Ipv4StaticRouting ();
76
78
79 virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
82
83 virtual void NotifyInterfaceUp (uint32_t interface);
84 virtual void NotifyInterfaceDown (uint32_t interface);
85 virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
87 virtual void SetIpv4 (Ptr<Ipv4> ipv4);
88 virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
89
102 void AddNetworkRouteTo (Ipv4Address network,
103 Ipv4Mask networkMask,
104 Ipv4Address nextHop,
105 uint32_t interface,
106 uint32_t metric = 0);
107
119 void AddNetworkRouteTo (Ipv4Address network,
120 Ipv4Mask networkMask,
121 uint32_t interface,
122 uint32_t metric = 0);
123
135 void AddHostRouteTo (Ipv4Address dest,
136 Ipv4Address nextHop,
137 uint32_t interface,
138 uint32_t metric = 0);
149 void AddHostRouteTo (Ipv4Address dest,
150 uint32_t interface,
151 uint32_t metric = 0);
171 void SetDefaultRoute (Ipv4Address nextHop,
172 uint32_t interface,
173 uint32_t metric = 0);
174
182 uint32_t GetNRoutes (void) const;
183
194
209
217 uint32_t GetMetric (uint32_t index) const;
218
231 void RemoveRoute (uint32_t i);
232
257 void AddMulticastRoute (Ipv4Address origin,
258 Ipv4Address group,
259 uint32_t inputInterface,
260 std::vector<uint32_t> outputInterfaces);
261
286 void SetDefaultMulticastRoute (uint32_t outputInterface);
287
295 uint32_t GetNMulticastRoutes (void) const;
296
312
339 Ipv4Address group,
340 uint32_t inputInterface);
341
355 void RemoveMulticastRoute (uint32_t index);
356
357protected:
358 virtual void DoDispose (void);
359
360private:
362 typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> > NetworkRoutes;
363
365 typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
366
368 typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
369
371 typedef std::list<Ipv4MulticastRoutingTableEntry *> MulticastRoutes;
372
374 typedef std::list<Ipv4MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
375
377 typedef std::list<Ipv4MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
378
385 bool LookupRoute (const Ipv4RoutingTableEntry &route, uint32_t metric);
386
394
403 uint32_t interface);
404
409
414
419};
420
421} // Namespace ns3
422
423#endif /* IPV4_STATIC_ROUTING_H */
Callback template class.
Definition: callback.h:1279
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting.
Abstract base class for IPv4 routing protocols.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Static routing protocol for IP version 4 stacks.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
virtual void NotifyInterfaceDown(uint32_t interface)
void RemoveRoute(uint32_t i)
Remove a route from the static unicast routing table.
virtual void NotifyInterfaceUp(uint32_t interface)
bool LookupRoute(const Ipv4RoutingTableEntry &route, uint32_t metric)
Checks if a route is already present in the forwarding table.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
Ipv4RoutingTableEntry GetDefaultRoute(void)
Get the default route with lowest metric from the static routing table.
uint32_t GetNRoutes(void) const
Get the number of individual unicast routes that have been added to the routing table.
void SetDefaultMulticastRoute(uint32_t outputInterface)
Add a default multicast route to the static routing table.
virtual void DoDispose(void)
Destructor implementation.
void AddMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
Add a multicast route to the static routing table.
MulticastRoutes m_multicastRoutes
the forwarding table for multicast.
std::list< Ipv4MulticastRoutingTableEntry * >::const_iterator MulticastRoutesCI
Const Iterator for container for the multicast routes.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
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.
std::list< std::pair< Ipv4RoutingTableEntry *, uint32_t > >::const_iterator NetworkRoutesCI
Const Iterator for container for the network routes.
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
NetworkRoutes m_networkRoutes
the forwarding table for network.
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
std::list< Ipv4MulticastRoutingTableEntry * > MulticastRoutes
Container for the multicast routes.
Ipv4RoutingTableEntry GetRoute(uint32_t i) const
Get a route from the static unicast routing table.
uint32_t GetNMulticastRoutes(void) const
Get the number of individual multicast routes that have been added to the routing table.
Ptr< Ipv4Route > LookupStatic(Ipv4Address dest, Ptr< NetDevice > oif=0)
Lookup in the forwarding table for destination.
std::list< std::pair< Ipv4RoutingTableEntry *, uint32_t > > NetworkRoutes
Container for the network routes.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
Ptr< Ipv4 > m_ipv4
Ipv4 reference.
Ipv4MulticastRoutingTableEntry GetMulticastRoute(uint32_t i) const
Get a route from the static multicast routing table.
static TypeId GetTypeId(void)
The interface Id associated with this class.
void AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a host route to the static routing table.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
std::list< Ipv4MulticastRoutingTableEntry * >::iterator MulticastRoutesI
Iterator for container for the multicast routes.
std::list< std::pair< Ipv4RoutingTableEntry *, uint32_t > >::iterator NetworkRoutesI
Iterator for container for the network routes.
bool RemoveMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface)
Remove a route from the static multicast routing table.
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.