A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
ipv4-route.cc
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
20
#include "ipv4-route.h"
21
#include "ns3/net-device.h"
22
#include "ns3/assert.h"
23
#include "ns3/log.h"
24
25
NS_LOG_COMPONENT_DEFINE
(
"Ipv4Route"
);
26
27
namespace
ns3 {
28
29
Ipv4Route::Ipv4Route ()
30
{
31
NS_LOG_FUNCTION
(
this
);
32
}
33
34
void
35
Ipv4Route::SetDestination
(
Ipv4Address
dest)
36
{
37
NS_LOG_FUNCTION
(
this
<< dest);
38
m_dest = dest;
39
}
40
41
Ipv4Address
42
Ipv4Route::GetDestination
(
void
)
const
43
{
44
NS_LOG_FUNCTION
(
this
);
45
return
m_dest;
46
}
47
48
void
49
Ipv4Route::SetSource
(
Ipv4Address
src)
50
{
51
NS_LOG_FUNCTION
(
this
<< src);
52
m_source = src;
53
}
54
55
Ipv4Address
56
Ipv4Route::GetSource
(
void
)
const
57
{
58
NS_LOG_FUNCTION
(
this
);
59
return
m_source;
60
}
61
62
void
63
Ipv4Route::SetGateway
(
Ipv4Address
gw)
64
{
65
NS_LOG_FUNCTION
(
this
<< gw);
66
m_gateway = gw;
67
}
68
69
Ipv4Address
70
Ipv4Route::GetGateway
(
void
)
const
71
{
72
NS_LOG_FUNCTION
(
this
);
73
return
m_gateway;
74
}
75
76
void
77
Ipv4Route::SetOutputDevice
(
Ptr<NetDevice>
outputDevice)
78
{
79
NS_LOG_FUNCTION
(
this
<< outputDevice);
80
m_outputDevice = outputDevice;
81
}
82
83
Ptr<NetDevice>
84
Ipv4Route::GetOutputDevice
(
void
)
const
85
{
86
NS_LOG_FUNCTION
(
this
);
87
return
m_outputDevice;
88
}
89
90
std::ostream&
operator<<
(std::ostream& os,
Ipv4Route
const
& route)
91
{
92
os <<
"source="
<< route.
GetSource
() <<
" dest="
<< route.
GetDestination
() <<
" gw="
<< route.
GetGateway
();
93
return
os;
94
}
95
96
Ipv4MulticastRoute::Ipv4MulticastRoute ()
97
{
98
NS_LOG_FUNCTION
(
this
);
99
m_ttls.clear ();
100
}
101
102
void
103
Ipv4MulticastRoute::SetGroup
(
const
Ipv4Address
group)
104
{
105
NS_LOG_FUNCTION
(
this
<< group);
106
m_group = group;
107
}
108
109
Ipv4Address
110
Ipv4MulticastRoute::GetGroup
(
void
)
const
111
{
112
NS_LOG_FUNCTION
(
this
);
113
return
m_group;
114
}
115
116
void
117
Ipv4MulticastRoute::SetOrigin
(
const
Ipv4Address
origin)
118
{
119
NS_LOG_FUNCTION
(
this
<< origin);
120
m_origin = origin;
121
}
122
123
Ipv4Address
124
Ipv4MulticastRoute::GetOrigin
(
void
)
const
125
{
126
NS_LOG_FUNCTION
(
this
);
127
return
m_origin;
128
}
129
130
void
131
Ipv4MulticastRoute::SetParent
(uint32_t parent)
132
{
133
NS_LOG_FUNCTION
(
this
<< parent);
134
m_parent = parent;
135
}
136
137
uint32_t
138
Ipv4MulticastRoute::GetParent
(
void
)
const
139
{
140
NS_LOG_FUNCTION
(
this
);
141
return
m_parent;
142
}
143
144
void
145
Ipv4MulticastRoute::SetOutputTtl
(uint32_t oif, uint32_t ttl)
146
{
147
NS_LOG_FUNCTION
(
this
<< oif << ttl);
148
if
(ttl >= MAX_TTL)
149
{
150
// This TTL value effectively disables the interface
151
std::map<uint32_t, uint32_t>::iterator iter;
152
iter = m_ttls.find (oif);
153
if
(iter != m_ttls.end ())
154
{
155
m_ttls.erase (iter);
156
}
157
}
158
else
159
{
160
m_ttls[oif] = ttl;
161
}
162
}
163
164
uint32_t
165
Ipv4MulticastRoute::GetOutputTtl
(uint32_t oif)
166
{
167
NS_LOG_FUNCTION
(
this
<< oif);
168
// We keep this interface around for compatibility (for now)
169
std::map<uint32_t, uint32_t>::const_iterator iter = m_ttls.find (oif);
170
if
(iter == m_ttls.end ())
171
return
((uint32_t)MAX_TTL);
172
return
(iter->second);
173
}
174
175
std::map<uint32_t, uint32_t>
176
Ipv4MulticastRoute::GetOutputTtlMap
()
const
177
{
178
NS_LOG_FUNCTION
(
this
);
179
return
(m_ttls);
180
}
181
182
}
// namespace ns3
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::Ipv4MulticastRoute::SetOrigin
void SetOrigin(const Ipv4Address origin)
Definition:
ipv4-route.cc:117
ns3::Ipv4MulticastRoute::SetGroup
void SetGroup(const Ipv4Address group)
Definition:
ipv4-route.cc:103
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::Ipv4MulticastRoute::SetParent
void SetParent(uint32_t iif)
Definition:
ipv4-route.cc:131
ns3::Ipv4Route::SetSource
void SetSource(Ipv4Address src)
Definition:
ipv4-route.cc:49
ns3::Ipv4Route::GetOutputDevice
Ptr< NetDevice > GetOutputDevice(void) const
Definition:
ipv4-route.cc:84
ns3::Ipv4Route::SetGateway
void SetGateway(Ipv4Address gw)
Definition:
ipv4-route.cc:63
ns3::Ipv4Route::GetSource
Ipv4Address GetSource(void) const
Definition:
ipv4-route.cc:56
ns3::Ipv4Route::GetGateway
Ipv4Address GetGateway(void) const
Definition:
ipv4-route.cc:70
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:43
ns3::Ipv4Route
Ipv4 route cache entry (similar to Linux struct rtable)
Definition:
ipv4-route.h:42
ns3::Ipv4Route::SetOutputDevice
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Definition:
ipv4-route.cc:77
ns3::Ipv4Route::GetDestination
Ipv4Address GetDestination(void) const
Definition:
ipv4-route.cc:42
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::Ipv4MulticastRoute::GetOrigin
Ipv4Address GetOrigin(void) const
Definition:
ipv4-route.cc:124
ns3::Ipv4MulticastRoute::GetOutputTtlMap
std::map< uint32_t, uint32_t > GetOutputTtlMap() const
Definition:
ipv4-route.cc:176
ns3::Ipv4MulticastRoute::GetOutputTtl
uint32_t GetOutputTtl(uint32_t oif) NS_DEPRECATED
Definition:
ipv4-route.cc:165
ns3::Ipv4MulticastRoute::GetGroup
Ipv4Address GetGroup(void) const
Definition:
ipv4-route.cc:110
ns3::Ipv4MulticastRoute::GetParent
uint32_t GetParent(void) const
Definition:
ipv4-route.cc:138
ns3::Ipv4MulticastRoute::SetOutputTtl
void SetOutputTtl(uint32_t oif, uint32_t ttl)
Definition:
ipv4-route.cc:145
ns3::Ipv4Route::SetDestination
void SetDestination(Ipv4Address dest)
Definition:
ipv4-route.cc:35
src
internet
model
ipv4-route.cc
Generated on Sun Mar 16 2014 11:25:04 for ns-3 by
1.8.6