A Discrete-Event Network Simulator
API
ipv4-route.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 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 #ifndef IPV4_ROUTE_H
20 #define IPV4_ROUTE_H
21 
22 #include <list>
23 #include <map>
24 #include <ostream>
25 
26 #include "ns3/simple-ref-count.h"
27 #include "ns3/ipv4-address.h"
28 
29 namespace ns3 {
30 
31 class NetDevice;
32 
41 class Ipv4Route : public SimpleRefCount<Ipv4Route>
42 {
43 public:
44  Ipv4Route ();
45 
49  void SetDestination (Ipv4Address dest);
53  Ipv4Address GetDestination (void) const;
54 
58  void SetSource (Ipv4Address src);
62  Ipv4Address GetSource (void) const;
63 
67  void SetGateway (Ipv4Address gw);
71  Ipv4Address GetGateway (void) const;
72 
78  void SetOutputDevice (Ptr<NetDevice> outputDevice);
82  Ptr<NetDevice> GetOutputDevice (void) const;
83 
84 #ifdef NOTYET
85  // rtable.idev
86  void SetInputIfIndex (uint32_t iif);
87  uint32_t GetInputIfIndex (void) const;
88 #endif
89 
90 private:
95 #ifdef NOTYET
96  uint32_t m_inputIfIndex;
97 #endif
98 };
99 
107 std::ostream& operator<< (std::ostream& os, Ipv4Route const& route);
108 
114 class Ipv4MulticastRoute : public SimpleRefCount<Ipv4MulticastRoute>
115 {
116 public:
118 
122  void SetGroup (const Ipv4Address group);
126  Ipv4Address GetGroup (void) const;
127 
131  void SetOrigin (const Ipv4Address origin);
135  Ipv4Address GetOrigin (void) const;
136 
140  void SetParent (uint32_t iif);
144  uint32_t GetParent (void) const;
145 
150  void SetOutputTtl (uint32_t oif, uint32_t ttl);
151 
155  std::map<uint32_t, uint32_t> GetOutputTtlMap () const;
156 
157  static const uint32_t MAX_INTERFACES = 16;
158  static const uint32_t MAX_TTL = 255;
159 
160 private:
163  uint32_t m_parent;
164  std::map<uint32_t, uint32_t> m_ttls;
165 };
166 
167 } // namespace ns3
168 
169 #endif /* IPV4_ROUTE_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
Definition: ipv4-route.h:115
Ipv4Address m_group
Group.
Definition: ipv4-route.h:161
Ipv4Address GetGroup(void) const
Definition: ipv4-route.cc:110
std::map< uint32_t, uint32_t > GetOutputTtlMap() const
Definition: ipv4-route.cc:165
void SetOrigin(const Ipv4Address origin)
Definition: ipv4-route.cc:117
Ipv4Address m_origin
Source of packet.
Definition: ipv4-route.h:162
void SetOutputTtl(uint32_t oif, uint32_t ttl)
Definition: ipv4-route.cc:145
void SetGroup(const Ipv4Address group)
Definition: ipv4-route.cc:103
static const uint32_t MAX_INTERFACES
Maximum number of multicast interfaces on a router.
Definition: ipv4-route.h:157
uint32_t m_parent
Source interface.
Definition: ipv4-route.h:163
uint32_t GetParent(void) const
Definition: ipv4-route.cc:138
static const uint32_t MAX_TTL
Maximum time-to-live (TTL)
Definition: ipv4-route.h:158
Ipv4Address GetOrigin(void) const
Definition: ipv4-route.cc:124
std::map< uint32_t, uint32_t > m_ttls
Time to Live container.
Definition: ipv4-route.h:164
void SetParent(uint32_t iif)
Definition: ipv4-route.cc:131
IPv4 route cache entry (similar to Linux struct rtable)
Definition: ipv4-route.h:42
Ipv4Address GetDestination(void) const
Definition: ipv4-route.cc:42
Ipv4Address m_source
Source address.
Definition: ipv4-route.h:92
Ipv4Address GetSource(void) const
Definition: ipv4-route.cc:56
void SetGateway(Ipv4Address gw)
Definition: ipv4-route.cc:63
Ptr< NetDevice > GetOutputDevice(void) const
Definition: ipv4-route.cc:84
void SetDestination(Ipv4Address dest)
Definition: ipv4-route.cc:35
void SetSource(Ipv4Address src)
Definition: ipv4-route.cc:49
Ipv4Address GetGateway(void) const
Definition: ipv4-route.cc:70
Ipv4Address m_gateway
Gateway address.
Definition: ipv4-route.h:93
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
Definition: ipv4-route.cc:77
Ptr< NetDevice > m_outputDevice
Output device.
Definition: ipv4-route.h:94
Ipv4Address m_dest
Destination address.
Definition: ipv4-route.h:91
A template-based reference counting class.
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:139