A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
radvd-interface.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 Strasbourg University
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18 */
19
20#include "radvd-interface.h"
21
22#include <ns3/log.h>
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("RadvdInterface");
28
30 : m_interface(interface)
31{
32 NS_LOG_FUNCTION(this << interface);
33 /* initialize default value as specified in radvd.conf manpage */
34 m_sendAdvert = true;
35 m_maxRtrAdvInterval = 600000;
38 m_managedFlag = false;
39 m_otherConfigFlag = false;
40 m_linkMtu = 0; /* 0 means not sending MTU option in RA */
41 m_reachableTime = 0; /* means unspecified for the router */
42 m_retransTimer = 0; /* means unspecified for the router */
43 m_curHopLimit = 64;
46 m_sourceLLAddress = true;
47 m_homeAgentFlag = false;
48 m_homeAgentInfo = false;
51 m_mobRtrSupportFlag = false;
52 m_intervalOpt = false;
54}
55
57 uint32_t maxRtrAdvInterval,
58 uint32_t minRtrAdvInterval)
59 : m_interface(interface)
60{
61 NS_LOG_FUNCTION(this << interface << maxRtrAdvInterval << minRtrAdvInterval);
62 NS_ASSERT(maxRtrAdvInterval > minRtrAdvInterval);
63 m_sendAdvert = true;
64 m_maxRtrAdvInterval = maxRtrAdvInterval;
65 m_minRtrAdvInterval = minRtrAdvInterval;
67 m_managedFlag = false;
68 m_otherConfigFlag = false;
69 m_linkMtu = 0; /* 0 means not sending MTU option in RA */
70 m_reachableTime = 0; /* means unspecified for the router */
71 m_retransTimer = 0; /* means unspecified for the router */
72 m_curHopLimit = 64;
75 m_sourceLLAddress = true;
76 m_homeAgentFlag = false;
77 m_homeAgentInfo = false;
80 m_mobRtrSupportFlag = false;
81 m_intervalOpt = false;
83}
84
86{
87 NS_LOG_FUNCTION(this);
88 /* clear prefixes */
89 for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it)
90 {
91 (*it) = nullptr;
92 }
93 m_prefixes.clear();
94}
95
96void
98{
99 NS_LOG_FUNCTION(this << routerPrefix);
100 m_prefixes.push_back(routerPrefix);
101}
102
105{
106 NS_LOG_FUNCTION(this);
107 return m_interface;
108}
109
110std::list<Ptr<RadvdPrefix>>
112{
113 NS_LOG_FUNCTION(this);
114 return m_prefixes;
115}
116
117bool
119{
120 NS_LOG_FUNCTION(this);
121 return m_sendAdvert;
122}
123
124void
126{
127 NS_LOG_FUNCTION(this << sendAdvert);
128 m_sendAdvert = sendAdvert;
129}
130
133{
134 NS_LOG_FUNCTION(this);
135 return m_maxRtrAdvInterval;
136}
137
138void
140{
141 NS_LOG_FUNCTION(this << maxRtrAdvInterval);
142 m_maxRtrAdvInterval = maxRtrAdvInterval;
143}
144
147{
148 NS_LOG_FUNCTION(this);
149 return m_minRtrAdvInterval;
150}
151
152void
154{
155 NS_LOG_FUNCTION(this << minRtrAdvInterval);
156 m_minRtrAdvInterval = minRtrAdvInterval;
157}
158
161{
162 NS_LOG_FUNCTION(this);
164}
165
166void
168{
169 NS_LOG_FUNCTION(this << minDelayBetweenRAs);
170 m_minDelayBetweenRAs = minDelayBetweenRAs;
171}
172
173bool
175{
176 NS_LOG_FUNCTION(this);
177 return m_managedFlag;
178}
179
180void
182{
183 NS_LOG_FUNCTION(this << managedFlag);
184 m_managedFlag = managedFlag;
185}
186
187bool
189{
190 NS_LOG_FUNCTION(this);
191 return m_otherConfigFlag;
192}
193
194void
196{
197 NS_LOG_FUNCTION(this << otherConfigFlag);
198 m_otherConfigFlag = otherConfigFlag;
199}
200
203{
204 NS_LOG_FUNCTION(this);
205 return m_linkMtu;
206}
207
208void
210{
211 NS_LOG_FUNCTION(this << linkMtu);
212 m_linkMtu = linkMtu;
213}
214
217{
218 NS_LOG_FUNCTION(this);
219 return m_reachableTime;
220}
221
222void
224{
225 NS_LOG_FUNCTION(this << reachableTime);
226 m_reachableTime = reachableTime;
227}
228
231{
232 NS_LOG_FUNCTION(this);
233 return m_defaultLifeTime;
234}
235
236void
238{
239 NS_LOG_FUNCTION(this << defaultLifeTime);
240 m_defaultLifeTime = defaultLifeTime;
241}
242
245{
246 NS_LOG_FUNCTION(this);
247 return m_retransTimer;
248}
249
250void
252{
253 NS_LOG_FUNCTION(this << retransTimer);
254 m_retransTimer = retransTimer;
255}
256
257uint8_t
259{
260 NS_LOG_FUNCTION(this);
261 return m_curHopLimit;
262}
263
264void
266{
267 NS_LOG_FUNCTION(this << curHopLimit);
268 m_curHopLimit = curHopLimit;
269}
270
271uint8_t
273{
274 NS_LOG_FUNCTION(this);
275 return m_defaultPreference;
276}
277
278void
279RadvdInterface::SetDefaultPreference(uint8_t defaultPreference)
280{
281 NS_LOG_FUNCTION(this << defaultPreference);
282 m_defaultPreference = defaultPreference;
283}
284
285bool
287{
288 NS_LOG_FUNCTION(this);
289 return m_sourceLLAddress;
290}
291
292void
294{
295 NS_LOG_FUNCTION(this << sourceLLAddress);
296 m_sourceLLAddress = sourceLLAddress;
297}
298
299bool
301{
302 NS_LOG_FUNCTION(this);
303 return m_homeAgentFlag;
304}
305
306void
308{
309 NS_LOG_FUNCTION(this << homeAgentFlag);
310 m_homeAgentFlag = homeAgentFlag;
311}
312
313bool
315{
316 NS_LOG_FUNCTION(this);
317 return m_homeAgentInfo;
318}
319
320void
322{
323 NS_LOG_FUNCTION(this << homeAgentInfo);
324 m_homeAgentInfo = homeAgentInfo;
325}
326
329{
330 NS_LOG_FUNCTION(this);
331 return m_homeAgentLifeTime;
332}
333
334void
336{
337 NS_LOG_FUNCTION(this << homeAgentLifeTime);
338 m_homeAgentLifeTime = homeAgentLifeTime;
339}
340
343{
344 NS_LOG_FUNCTION(this);
346}
347
348void
350{
351 NS_LOG_FUNCTION(this << homeAgentPreference);
352 m_homeAgentPreference = homeAgentPreference;
353}
354
355bool
357{
358 NS_LOG_FUNCTION(this);
359 return m_mobRtrSupportFlag;
360}
361
362void
364{
365 NS_LOG_FUNCTION(this << mobRtrSupportFlag);
366 m_mobRtrSupportFlag = mobRtrSupportFlag;
367}
368
369bool
371{
372 NS_LOG_FUNCTION(this);
373 return m_intervalOpt;
374}
375
376void
378{
379 NS_LOG_FUNCTION(this << intervalOpt);
380 m_intervalOpt = intervalOpt;
381}
382
383Time
385{
386 return m_lastSendTime;
387}
388
389void
391{
392 m_lastSendTime = now;
394 {
396 }
397}
398
399bool
401{
403}
404
405} /* namespace ns3 */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
RadvdInterface(uint32_t interface)
Constructor.
bool IsMobRtrSupportFlag() const
Is "mobile router support" flag enabled ?
void SetMinDelayBetweenRAs(uint32_t minDelayBetweenRAs)
Set minimum delay between RAs.
uint8_t m_initialRtrAdvertisementsLeft
Number of fast announcement to do.
void SetSourceLLAddress(bool sourceLLAddress)
Set flag to add or not LLA to RA.
bool IsIntervalOpt() const
Is advertisement interval option should be included in RA ?
uint32_t m_reachableTime
Reachable time in milliseconds.
uint32_t GetMinDelayBetweenRAs() const
Get minimum delay between RAs.
~RadvdInterface()
Destructor.
uint32_t m_defaultLifeTime
Default life time in seconds.
void SetSendAdvert(bool sendAdvert)
Set send advert flag.
void SetLinkMtu(uint32_t linkMtu)
Set link MTU.
void SetDefaultLifeTime(uint32_t defaultLifeTime)
Set default lifetime.
uint32_t m_maxRtrAdvInterval
Maximum RA interval in milliseconds.
void SetHomeAgentFlag(bool homeAgentFlag)
Set "home agent" flag.
bool m_sourceLLAddress
Flag to add link-layer address in RA.
uint32_t GetDefaultLifeTime() const
Get default lifetime.
bool m_sendAdvert
Flag whether or not router sends periodic RA and respond to RS.
void AddPrefix(Ptr< RadvdPrefix > routerPrefix)
Add a prefix to advertise on interface.
bool IsHomeAgentInfo() const
Is Home Agent Information option should be included in RA ?
uint8_t m_defaultPreference
Preference associated with default router.
void SetMobRtrSupportFlag(bool mobRtrSupportFlag)
Set "mobile router support" flag.
Time GetLastRaTxTime()
Get the last time a RA has been sent.
bool m_homeAgentInfo
Flag to add Home Agent Information option (Mobile IPv6).
void SetLastRaTxTime(Time now)
Set the last RA send time.
uint32_t m_homeAgentLifeTime
Home agent lifetime in seconds.
bool m_intervalOpt
Flag to add Advertisement Interval option in RA.
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
uint32_t GetInterface() const
Get interface index for this configuration.
bool m_otherConfigFlag
Other configuration flag.
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
Time m_lastSendTime
Last RA send time.
uint32_t m_retransTimer
Retransmission timer in milliseconds.
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
void SetHomeAgentPreference(uint32_t homeAgentPreference)
Set home agent preference.
uint32_t GetRetransTimer() const
Get retransmission timer.
RadvdPrefixList m_prefixes
List of prefixes to advertise.
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
uint32_t GetReachableTime() const
Get reachable time.
bool m_managedFlag
Managed flag.
void SetIntervalOpt(bool intervalOpt)
Set flag to add or not advertisement interval to RA.
void SetRetransTimer(uint32_t retransTimer)
Set retransmission timer.
bool IsInitialRtrAdv() const
Checks if the interface is subject to the initial Rtr Advertisements rule.
void SetCurHopLimit(uint8_t curHopLimit)
Set current hop limit.
void SetDefaultPreference(uint8_t defaultPreference)
Set default preference.
void SetMaxRtrAdvInterval(uint32_t maxRtrAdvInterval)
Get maximum RA interval.
uint32_t m_interface
Interface to advertise RA.
bool m_homeAgentFlag
Flag to add HA (home agent) flag in RA.
void SetOtherConfigFlag(bool otherConfigFlag)
Set "other config" flag.
bool IsSendAdvert() const
Is send advert enabled (periodic RA and reply to RS) ?
uint8_t GetDefaultPreference() const
Get default preference.
void SetMinRtrAdvInterval(uint32_t minRtrAdvInterval)
Get minimum RA interval.
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
uint32_t GetHomeAgentLifeTime() const
Get home agent lifetime.
bool m_mobRtrSupportFlag
Flag for HA to signals it supports Mobile Router registrations (NEMO Basic).
uint32_t m_minDelayBetweenRAs
Minimum delay between RA in milliseconds.
uint8_t GetCurHopLimit() const
Get current hop limit.
uint32_t m_curHopLimit
Current hop limit (TTL).
uint32_t GetLinkMtu() const
Get link MTU.
uint32_t m_minRtrAdvInterval
Minimum RA interval in milliseconds.
uint32_t m_homeAgentPreference
Home agent preference.
uint32_t GetHomeAgentPreference() const
Get home agent preference.
void SetManagedFlag(bool managedFlag)
Set managed flag.
void SetHomeAgentInfo(bool homeAgentFlag)
Set flag to add or not HA information option to RA.
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
uint32_t m_linkMtu
Link MTU to use.
bool IsManagedFlag() const
Is managed flag enabled ?
void SetHomeAgentLifeTime(uint32_t homeAgentLifeTime)
Set home agent lifetime.
void SetReachableTime(uint32_t reachableTime)
Set reachable time.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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.