A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
radvd-interface.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 Strasbourg University
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  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #include "radvd-interface.h"
22 #include <ns3/log.h>
23 
24 namespace ns3
25 {
26 
27 NS_LOG_COMPONENT_DEFINE ("RadvdInterface")
28  ;
29 
30 RadvdInterface::RadvdInterface (uint32_t interface)
31  : m_interface (interface)
32 {
33  NS_LOG_FUNCTION (this << interface);
34  /* initialize default value as specified in radvd.conf manpage */
35  m_sendAdvert = true;
36  m_maxRtrAdvInterval = 600000;
37  m_minRtrAdvInterval = (uint32_t)(double) (0.33 * m_maxRtrAdvInterval);
38  m_minDelayBetweenRAs = 3000;
39  m_managedFlag = false;
40  m_otherConfigFlag = false;
41  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
42  m_reachableTime = 0; /* means unspecified for the router */
43  m_retransTimer = 0; /* means unspecified for the router */
44  m_curHopLimit = 64;
47  m_sourceLLAddress = true;
48  m_homeAgentFlag = false;
49  m_homeAgentInfo = false;
52  m_mobRtrSupportFlag = false;
53  m_intervalOpt = false;
54 }
55 
56 RadvdInterface::RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval)
57  : m_interface (interface)
58 {
59  NS_LOG_FUNCTION (this << interface << maxRtrAdvInterval << minRtrAdvInterval);
60  NS_ASSERT (maxRtrAdvInterval > minRtrAdvInterval);
61  m_sendAdvert = true;
62  m_maxRtrAdvInterval = maxRtrAdvInterval;
63  m_minRtrAdvInterval = minRtrAdvInterval;
64  m_minDelayBetweenRAs = 3000;
65  m_managedFlag = false;
66  m_otherConfigFlag = false;
67  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
68  m_reachableTime = 0; /* means unspecified for the router */
69  m_retransTimer = 0; /* means unspecified for the router */
70  m_curHopLimit = 64;
73  m_sourceLLAddress = true;
74  m_homeAgentFlag = false;
75  m_homeAgentInfo = false;
78  m_mobRtrSupportFlag = false;
79  m_intervalOpt = false;
80 }
81 
83 {
84  NS_LOG_FUNCTION (this);
85  /* clear prefixes */
86  for (RadvdPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it)
87  {
88  (*it) = 0;
89  }
90  m_prefixes.clear ();
91 }
92 
94 {
95  NS_LOG_FUNCTION (this << routerPrefix);
96  m_prefixes.push_back (routerPrefix);
97 }
98 
99 
101 {
102  NS_LOG_FUNCTION (this);
103  return m_interface;
104 }
105 
106 std::list<Ptr<RadvdPrefix> > RadvdInterface::GetPrefixes () const
107 {
108  NS_LOG_FUNCTION (this);
109  return m_prefixes;
110 }
111 
113 {
114  NS_LOG_FUNCTION (this);
115  return m_sendAdvert;
116 }
117 
118 void RadvdInterface::SetSendAdvert (bool sendAdvert)
119 {
120  NS_LOG_FUNCTION (this << sendAdvert);
121  m_sendAdvert = sendAdvert;
122 }
123 
125 {
126  NS_LOG_FUNCTION (this);
127  return m_maxRtrAdvInterval;
128 }
129 
130 void RadvdInterface::SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval)
131 {
132  NS_LOG_FUNCTION (this << maxRtrAdvInterval);
133  m_maxRtrAdvInterval = maxRtrAdvInterval;
134 }
135 
137 {
138  NS_LOG_FUNCTION (this);
139  return m_minRtrAdvInterval;
140 }
141 
142 void RadvdInterface::SetMinRtrAdvInterval (uint32_t minRtrAdvInterval)
143 {
144  NS_LOG_FUNCTION (this << minRtrAdvInterval);
145  m_minRtrAdvInterval = minRtrAdvInterval;
146 }
147 
149 {
150  NS_LOG_FUNCTION (this);
151  return m_minDelayBetweenRAs;
152 }
153 
154 void RadvdInterface::SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs)
155 {
156  NS_LOG_FUNCTION (this << minDelayBetweenRAs);
157  m_minDelayBetweenRAs = minDelayBetweenRAs;
158 }
159 
161 {
162  NS_LOG_FUNCTION (this);
163  return m_managedFlag;
164 }
165 
166 void RadvdInterface::SetManagedFlag (bool managedFlag)
167 {
168  NS_LOG_FUNCTION (this << managedFlag);
169  m_managedFlag = managedFlag;
170 }
171 
173 {
174  NS_LOG_FUNCTION (this);
175  return m_otherConfigFlag;
176 }
177 
178 void RadvdInterface::SetOtherConfigFlag (bool otherConfigFlag)
179 {
180  NS_LOG_FUNCTION (this << otherConfigFlag);
181  m_otherConfigFlag = otherConfigFlag;
182 }
183 
184 uint32_t RadvdInterface::GetLinkMtu () const
185 {
186  NS_LOG_FUNCTION (this);
187  return m_linkMtu;
188 }
189 
190 void RadvdInterface::SetLinkMtu (uint32_t linkMtu)
191 {
192  NS_LOG_FUNCTION (this << linkMtu);
193  m_linkMtu = linkMtu;
194 }
195 
197 {
198  NS_LOG_FUNCTION (this);
199  return m_reachableTime;
200 }
201 
202 void RadvdInterface::SetReachableTime (uint32_t reachableTime)
203 {
204  NS_LOG_FUNCTION (this << reachableTime);
205  m_reachableTime = reachableTime;
206 }
207 
209 {
210  NS_LOG_FUNCTION (this);
211  return m_defaultLifeTime;
212 }
213 
214 void RadvdInterface::SetDefaultLifeTime (uint32_t defaultLifeTime)
215 {
216  NS_LOG_FUNCTION (this << defaultLifeTime);
217  m_defaultLifeTime = defaultLifeTime;
218 }
219 
221 {
222  NS_LOG_FUNCTION (this);
223  return m_retransTimer;
224 }
225 
226 void RadvdInterface::SetRetransTimer (uint32_t retransTimer)
227 {
228  NS_LOG_FUNCTION (this << retransTimer);
229  m_retransTimer = retransTimer;
230 }
231 
233 {
234  NS_LOG_FUNCTION (this);
235  return m_curHopLimit;
236 }
237 
238 void RadvdInterface::SetCurHopLimit (uint8_t curHopLimit)
239 {
240  NS_LOG_FUNCTION (this << curHopLimit);
241  m_curHopLimit = curHopLimit;
242 }
243 
245 {
246  NS_LOG_FUNCTION (this);
247  return m_defaultPreference;
248 }
249 
250 void RadvdInterface::SetDefaultPreference (uint8_t defaultPreference)
251 {
252  NS_LOG_FUNCTION (this << defaultPreference);
253  m_defaultPreference = defaultPreference;
254 }
255 
257 {
258  NS_LOG_FUNCTION (this);
259  return m_sourceLLAddress;
260 }
261 
262 void RadvdInterface::SetSourceLLAddress (bool sourceLLAddress)
263 {
264  NS_LOG_FUNCTION (this << sourceLLAddress);
265  m_sourceLLAddress = sourceLLAddress;
266 }
267 
269 {
270  NS_LOG_FUNCTION (this);
271  return m_homeAgentFlag;
272 }
273 
274 void RadvdInterface::SetHomeAgentFlag (bool homeAgentFlag)
275 {
276  NS_LOG_FUNCTION (this << homeAgentFlag);
277  m_homeAgentFlag = homeAgentFlag;
278 }
279 
281 {
282  NS_LOG_FUNCTION (this);
283  return m_homeAgentInfo;
284 }
285 
286 void RadvdInterface::SetHomeAgentInfo (bool homeAgentInfo)
287 {
288  NS_LOG_FUNCTION (this << homeAgentInfo);
289  m_homeAgentInfo = homeAgentInfo;
290 }
291 
293 {
294  NS_LOG_FUNCTION (this);
295  return m_homeAgentLifeTime;
296 }
297 
298 void RadvdInterface::SetHomeAgentLifeTime (uint32_t homeAgentLifeTime)
299 {
300  NS_LOG_FUNCTION (this << homeAgentLifeTime);
301  m_homeAgentLifeTime = homeAgentLifeTime;
302 }
303 
305 {
306  NS_LOG_FUNCTION (this);
307  return m_homeAgentPreference;
308 }
309 
310 void RadvdInterface::SetHomeAgentPreference (uint32_t homeAgentPreference)
311 {
312  NS_LOG_FUNCTION (this << homeAgentPreference);
313  m_homeAgentPreference = homeAgentPreference;
314 }
315 
317 {
318  NS_LOG_FUNCTION (this);
319  return m_mobRtrSupportFlag;
320 }
321 
322 void RadvdInterface::SetMobRtrSupportFlag (bool mobRtrSupportFlag)
323 {
324  NS_LOG_FUNCTION (this << mobRtrSupportFlag);
325  m_mobRtrSupportFlag = mobRtrSupportFlag;
326 }
327 
329 {
330  NS_LOG_FUNCTION (this);
331  return m_intervalOpt;
332 }
333 
334 void RadvdInterface::SetIntervalOpt (bool intervalOpt)
335 {
336  NS_LOG_FUNCTION (this << intervalOpt);
337  m_intervalOpt = intervalOpt;
338 }
339 } /* namespace ns3 */
340 
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
bool m_sendAdvert
Flag whether or not router sends periodic RA and respond to RS.
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
uint32_t GetLinkMtu() const
Get link MTU.
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
void SetMinDelayBetweenRAs(uint32_t minDelayBetweenRAs)
Set minimum delay between RAs.
uint32_t GetInterface() const
Get interface index for this configuration.
void SetDefaultLifeTime(uint32_t defaultLifeTime)
Set default lifetime.
uint32_t m_linkMtu
Link MTU to use.
bool m_intervalOpt
Flag to add Advertisement Interval option in RA.
uint32_t m_interface
Interface to advertise RA.
#define NS_ASSERT(condition)
Definition: assert.h:64
uint32_t GetRetransTimer() const
Get retransmission timer.
uint8_t GetCurHopLimit() const
Get current hop limit.
uint32_t m_curHopLimit
Current hop limit (TTL).
void SetMobRtrSupportFlag(bool mobRtrSupportFlag)
Set "mobile router support" flag.
void SetSendAdvert(bool sendAdvert)
Set send advert flag.
bool m_otherConfigFlag
Other configuration flag.
bool m_mobRtrSupportFlag
Flag for HA to signals it supports Mobile Router registrations (NEMO Basic).
void AddPrefix(Ptr< RadvdPrefix > routerPrefix)
Add a prefix to advertise on interface.
bool IsManagedFlag() const
Is managed flag enabled ?
bool m_homeAgentInfo
Flag to add Home Agent Information option (Mobile IPv6).
uint32_t m_minDelayBetweenRAs
Minimum delay between RA in milliseconds.
uint32_t GetMinDelayBetweenRAs() const
Get minimum delay between RAs.
bool IsMobRtrSupportFlag() const
Is "mobile router support" flag enabled ?
uint32_t m_homeAgentPreference
Home agent preference.
bool IsHomeAgentInfo() const
Is Home Agent Information option should be included in RA ?
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
uint32_t m_reachableTime
Reachable time in milliseconds.
uint32_t m_retransTimer
Retransmission timer in milliseconds.
void SetRetransTimer(uint32_t retransTimer)
Set retransmission timer.
bool IsIntervalOpt() const
Is advertisement interval option should be included in RA ?
uint8_t m_defaultPreference
Preference associated with default router.
void SetDefaultPreference(uint8_t defaultPreference)
Set default preference.
RadvdPrefixList m_prefixes
List of prefixes to advertise.
void SetReachableTime(uint32_t reachableTime)
Set reachable time.
bool m_sourceLLAddress
Flag to add link-layer address in RA.
void SetHomeAgentPreference(uint32_t homeAgentPreference)
Set home agent preference.
void SetHomeAgentInfo(bool homeAgentFlag)
Set flag to add or not HA information option to RA.
void SetIntervalOpt(bool intervalOpt)
Set flag to add or not advertisement interval to RA.
~RadvdInterface()
Destructor.
bool m_homeAgentFlag
Flag to add HA (home agent) flag in RA.
void SetMinRtrAdvInterval(uint32_t minRtrAdvInterval)
Get minimum RA interval.
bool IsSendAdvert() const
Is send advert enabled (periodic RA and reply to RS) ?
void SetLinkMtu(uint32_t linkMtu)
Set link MTU.
bool m_managedFlag
Managed flag.
uint32_t m_defaultLifeTime
Default life time in seconds.
void SetOtherConfigFlag(bool otherConfigFlag)
Set "other config" flag.
RadvdInterface(uint32_t interface)
Constructor.
std::list< Ptr< RadvdPrefix > >::iterator RadvdPrefixListI
Container Iterator: Ptr to RadvdPrefix.
void SetManagedFlag(bool managedFlag)
Set managed flag.
uint8_t GetDefaultPreference() const
Get default preference.
uint32_t GetHomeAgentPreference() const
Get home agent preference.
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
uint32_t GetDefaultLifeTime() const
Get default lifetime.
void SetHomeAgentFlag(bool homeAgentFlag)
Set "home agent" flag.
void SetMaxRtrAdvInterval(uint32_t maxRtrAdvInterval)
Get maximum RA interval.
uint32_t GetHomeAgentLifeTime() const
Get home agent lifetime.
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
void SetHomeAgentLifeTime(uint32_t homeAgentLifeTime)
Set home agent lifetime.
uint32_t m_homeAgentLifeTime
Home agent lifetime in seconds.
void SetSourceLLAddress(bool sourceLLAddress)
Set flag to add or not LLA to RA.
uint32_t m_minRtrAdvInterval
Minimum RA interval in milliseconds.
void SetCurHopLimit(uint8_t curHopLimit)
Set current hop limit.
uint32_t GetReachableTime() const
Get reachable time.
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
uint32_t m_maxRtrAdvInterval
Maximum RA interval in milliseconds.