A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv4-global-routing.h
Go to the documentation of this file.
1 // -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-
2 //
3 // Copyright (c) 2008 University of Washington
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 //
19 
20 #ifndef IPV4_GLOBAL_ROUTING_H
21 #define IPV4_GLOBAL_ROUTING_H
22 
23 #include <list>
24 #include <stdint.h>
25 #include "ns3/ipv4-address.h"
26 #include "ns3/ipv4-header.h"
27 #include "ns3/ptr.h"
28 #include "ns3/ipv4.h"
29 #include "ns3/ipv4-routing-protocol.h"
30 #include "ns3/random-variable-stream.h"
31 
32 namespace ns3 {
33 
34 class Packet;
35 class NetDevice;
36 class Ipv4Interface;
37 class Ipv4Address;
38 class Ipv4Header;
39 class Ipv4RoutingTableEntry;
40 class Ipv4MulticastRoutingTableEntry;
41 class Node;
42 
43 
70 {
71 public:
72  static TypeId GetTypeId (void);
82  virtual ~Ipv4GlobalRouting ();
83 
84  // These methods inherited from base class
85  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
86 
87  virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
90  virtual void NotifyInterfaceUp (uint32_t interface);
91  virtual void NotifyInterfaceDown (uint32_t interface);
92  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
93  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
94  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
95  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
96 
107  void AddHostRouteTo (Ipv4Address dest,
108  Ipv4Address nextHop,
109  uint32_t interface);
119  void AddHostRouteTo (Ipv4Address dest,
120  uint32_t interface);
121 
133  void AddNetworkRouteTo (Ipv4Address network,
134  Ipv4Mask networkMask,
135  Ipv4Address nextHop,
136  uint32_t interface);
137 
148  void AddNetworkRouteTo (Ipv4Address network,
149  Ipv4Mask networkMask,
150  uint32_t interface);
151 
161  void AddASExternalRouteTo (Ipv4Address network,
162  Ipv4Mask networkMask,
163  Ipv4Address nextHop,
164  uint32_t interface);
165 
172  uint32_t GetNRoutes (void) const;
173 
194  Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
195 
212  void RemoveRoute (uint32_t i);
213 
222  int64_t AssignStreams (int64_t stream);
223 
224 protected:
225  void DoDispose (void);
226 
227 private:
234 
235  typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
236  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
237  typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
238  typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
239  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
240  typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
241  typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
242  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
243  typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
244 
246 
249  ASExternalRoutes m_ASexternalRoutes; // External routes imported
250 
252 };
253 
254 } // Namespace ns3
255 
256 #endif /* IPV4_GLOBAL_ROUTING_H */