A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-route.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8#include "ipv4-route.h"
9
10#include "ns3/assert.h"
11#include "ns3/log.h"
12#include "ns3/net-device.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("Ipv4Route");
18
23
24void
26{
27 NS_LOG_FUNCTION(this << dest);
28 m_dest = dest;
29}
30
33{
34 NS_LOG_FUNCTION(this);
35 return m_dest;
36}
37
38void
40{
41 NS_LOG_FUNCTION(this << src);
42 m_source = src;
43}
44
47{
48 NS_LOG_FUNCTION(this);
49 return m_source;
50}
51
52void
54{
55 NS_LOG_FUNCTION(this << gw);
56 m_gateway = gw;
57}
58
61{
62 NS_LOG_FUNCTION(this);
63 return m_gateway;
64}
65
66void
68{
69 NS_LOG_FUNCTION(this << outputDevice);
70 m_outputDevice = outputDevice;
71}
72
75{
76 NS_LOG_FUNCTION(this);
77 return m_outputDevice;
78}
79
80std::ostream&
81operator<<(std::ostream& os, const Ipv4Route& route)
82{
83 os << "source=" << route.GetSource() << " dest=" << route.GetDestination()
84 << " gw=" << route.GetGateway();
85 return os;
86}
87
93
94void
96{
97 NS_LOG_FUNCTION(this << group);
98 m_group = group;
99}
100
103{
104 NS_LOG_FUNCTION(this);
105 return m_group;
106}
107
108void
110{
111 NS_LOG_FUNCTION(this << origin);
112 m_origin = origin;
113}
114
117{
118 NS_LOG_FUNCTION(this);
119 return m_origin;
120}
121
122void
124{
125 NS_LOG_FUNCTION(this << parent);
126 m_parent = parent;
127}
128
131{
132 NS_LOG_FUNCTION(this);
133 return m_parent;
134}
135
136void
138{
139 NS_LOG_FUNCTION(this << oif << ttl);
140 if (ttl >= MAX_TTL)
141 {
142 // This TTL value effectively disables the interface
143 auto iter = m_ttls.find(oif);
144 if (iter != m_ttls.end())
145 {
146 m_ttls.erase(iter);
147 }
148 }
149 else
150 {
151 m_ttls[oif] = ttl;
152 }
153}
154
155std::map<uint32_t, uint32_t>
157{
158 NS_LOG_FUNCTION(this);
159 return m_ttls;
160}
161
162} // namespace ns3
Ipv4 addresses are stored in host order in this class.
uint32_t GetParent() const
Ipv4Address m_group
Group.
Definition ipv4-route.h:151
Ipv4Address GetGroup() const
std::map< uint32_t, uint32_t > GetOutputTtlMap() const
Ipv4Address GetOrigin() const
void SetOrigin(const Ipv4Address origin)
Ipv4Address m_origin
Source of packet.
Definition ipv4-route.h:152
void SetOutputTtl(uint32_t oif, uint32_t ttl)
void SetGroup(const Ipv4Address group)
Definition ipv4-route.cc:95
uint32_t m_parent
Source interface.
Definition ipv4-route.h:153
static const uint32_t MAX_TTL
Maximum time-to-live (TTL)
Definition ipv4-route.h:148
std::map< uint32_t, uint32_t > m_ttls
Time to Live container.
Definition ipv4-route.h:154
void SetParent(uint32_t iif)
IPv4 route cache entry (similar to Linux struct rtable)
Definition ipv4-route.h:31
Ipv4Address m_source
Source address.
Definition ipv4-route.h:81
void SetGateway(Ipv4Address gw)
Definition ipv4-route.cc:53
Ptr< NetDevice > GetOutputDevice() const
Definition ipv4-route.cc:74
Ipv4Address GetGateway() const
Definition ipv4-route.cc:60
void SetDestination(Ipv4Address dest)
Definition ipv4-route.cc:25
void SetSource(Ipv4Address src)
Definition ipv4-route.cc:39
Ipv4Address GetSource() const
Definition ipv4-route.cc:46
Ipv4Address m_gateway
Gateway address.
Definition ipv4-route.h:82
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
Definition ipv4-route.cc:67
Ipv4Address GetDestination() const
Definition ipv4-route.cc:32
Ptr< NetDevice > m_outputDevice
Output device.
Definition ipv4-route.h:83
Ipv4Address m_dest
Destination address.
Definition ipv4-route.h:80
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
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:148