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
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ipv4-route.cc
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
20
#include "
ipv4-route.h
"
21
#include "ns3/net-device.h"
22
#include "ns3/assert.h"
23
24
namespace
ns3 {
25
26
Ipv4Route::Ipv4Route
()
27
{
28
}
29
30
void
31
Ipv4Route::SetDestination
(
Ipv4Address
dest)
32
{
33
m_dest
= dest;
34
}
35
36
Ipv4Address
37
Ipv4Route::GetDestination
(
void
)
const
38
{
39
return
m_dest
;
40
}
41
42
void
43
Ipv4Route::SetSource
(
Ipv4Address
src)
44
{
45
m_source
= src;
46
}
47
48
Ipv4Address
49
Ipv4Route::GetSource
(
void
)
const
50
{
51
return
m_source
;
52
}
53
54
void
55
Ipv4Route::SetGateway
(
Ipv4Address
gw)
56
{
57
m_gateway
= gw;
58
}
59
60
Ipv4Address
61
Ipv4Route::GetGateway
(
void
)
const
62
{
63
return
m_gateway
;
64
}
65
66
void
67
Ipv4Route::SetOutputDevice
(
Ptr<NetDevice>
outputDevice)
68
{
69
m_outputDevice
= outputDevice;
70
}
71
72
Ptr<NetDevice>
73
Ipv4Route::GetOutputDevice
(
void
)
const
74
{
75
return
m_outputDevice
;
76
}
77
78
std::ostream&
operator<<
(std::ostream& os,
Ipv4Route
const
& route)
79
{
80
os <<
"source="
<< route.
GetSource
() <<
" dest="
<< route.
GetDestination
() <<
" gw="
<< route.
GetGateway
();
81
return
os;
82
}
83
84
Ipv4MulticastRoute::Ipv4MulticastRoute
()
85
{
86
m_ttls
.clear ();
87
}
88
89
void
90
Ipv4MulticastRoute::SetGroup
(
const
Ipv4Address
group
)
91
{
92
m_group
=
group
;
93
}
94
95
Ipv4Address
96
Ipv4MulticastRoute::GetGroup
(
void
)
const
97
{
98
return
m_group
;
99
}
100
101
void
102
Ipv4MulticastRoute::SetOrigin
(
const
Ipv4Address
origin)
103
{
104
m_origin
= origin;
105
}
106
107
Ipv4Address
108
Ipv4MulticastRoute::GetOrigin
(
void
)
const
109
{
110
return
m_origin
;
111
}
112
113
void
114
Ipv4MulticastRoute::SetParent
(uint32_t parent)
115
{
116
m_parent
= parent;
117
}
118
119
uint32_t
120
Ipv4MulticastRoute::GetParent
(
void
)
const
121
{
122
return
m_parent
;
123
}
124
125
void
126
Ipv4MulticastRoute::SetOutputTtl
(uint32_t oif, uint32_t ttl)
127
{
128
if
(ttl >=
MAX_TTL
)
129
{
130
// This TTL value effectively disables the interface
131
std::map<uint32_t, uint32_t>::iterator iter;
132
iter =
m_ttls
.find (oif);
133
if
(iter !=
m_ttls
.end ())
134
{
135
m_ttls
.erase (iter);
136
}
137
}
138
else
139
{
140
m_ttls
[oif] = ttl;
141
}
142
}
143
144
uint32_t
145
Ipv4MulticastRoute::GetOutputTtl
(uint32_t oif)
146
{
147
// We keep this interface around for compatibility (for now)
148
std::map<uint32_t, uint32_t>::const_iterator iter =
m_ttls
.find (oif);
149
if
(iter ==
m_ttls
.end ())
150
return
((uint32_t)
MAX_TTL
);
151
return
(iter->second);
152
}
153
154
std::map<uint32_t, uint32_t>
155
Ipv4MulticastRoute::GetOutputTtlMap
()
const
156
{
157
return
(
m_ttls
);
158
}
159
160
}
// namespace ns3
src
internet
model
ipv4-route.cc
Generated on Tue Nov 13 2012 10:32:14 for ns-3 by
1.8.1.2