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 RadvdInterface::RadvdInterface (uint32_t interface)
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;
36  m_minRtrAdvInterval = (uint32_t)(double) (0.33 * m_maxRtrAdvInterval);
37  m_minDelayBetweenRAs = 3000;
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;
53 }
54 
55 RadvdInterface::RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval)
56  : m_interface (interface)
57 {
58  NS_LOG_FUNCTION (this << interface << maxRtrAdvInterval << minRtrAdvInterval);
59  NS_ASSERT (maxRtrAdvInterval > minRtrAdvInterval);
60  m_sendAdvert = true;
61  m_maxRtrAdvInterval = maxRtrAdvInterval;
62  m_minRtrAdvInterval = minRtrAdvInterval;
63  m_minDelayBetweenRAs = 3000;
64  m_managedFlag = false;
65  m_otherConfigFlag = false;
66  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
67  m_reachableTime = 0; /* means unspecified for the router */
68  m_retransTimer = 0; /* means unspecified for the router */
69  m_curHopLimit = 64;
72  m_sourceLLAddress = true;
73  m_homeAgentFlag = false;
74  m_homeAgentInfo = false;
77  m_mobRtrSupportFlag = false;
78  m_intervalOpt = false;
79 }
80 
82 {
83  NS_LOG_FUNCTION (this);
84  /* clear prefixes */
85  for (RadvdPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it)
86  {
87  (*it) = 0;
88  }
89  m_prefixes.clear ();
90 }
91 
93 {
94  NS_LOG_FUNCTION (this << routerPrefix);
95  m_prefixes.push_back (routerPrefix);
96 }
97 
98 
100 {
101  NS_LOG_FUNCTION (this);
102  return m_interface;
103 }
104 
105 std::list<Ptr<RadvdPrefix> > RadvdInterface::GetPrefixes () const
106 {
107  NS_LOG_FUNCTION (this);
108  return m_prefixes;
109 }
110 
112 {
113  NS_LOG_FUNCTION (this);
114  return m_sendAdvert;
115 }
116 
117 void RadvdInterface::SetSendAdvert (bool sendAdvert)
118 {
119  NS_LOG_FUNCTION (this << sendAdvert);
120  m_sendAdvert = sendAdvert;
121 }
122 
124 {
125  NS_LOG_FUNCTION (this);
126  return m_maxRtrAdvInterval;
127 }
128 
129 void RadvdInterface::SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval)
130 {
131  NS_LOG_FUNCTION (this << maxRtrAdvInterval);
132  m_maxRtrAdvInterval = maxRtrAdvInterval;
133 }
134 
136 {
137  NS_LOG_FUNCTION (this);
138  return m_minRtrAdvInterval;
139 }
140 
141 void RadvdInterface::SetMinRtrAdvInterval (uint32_t minRtrAdvInterval)
142 {
143  NS_LOG_FUNCTION (this << minRtrAdvInterval);
144  m_minRtrAdvInterval = minRtrAdvInterval;
145 }
146 
148 {
149  NS_LOG_FUNCTION (this);
150  return m_minDelayBetweenRAs;
151 }
152 
153 void RadvdInterface::SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs)
154 {
155  NS_LOG_FUNCTION (this << minDelayBetweenRAs);
156  m_minDelayBetweenRAs = minDelayBetweenRAs;
157 }
158 
160 {
161  NS_LOG_FUNCTION (this);
162  return m_managedFlag;
163 }
164 
165 void RadvdInterface::SetManagedFlag (bool managedFlag)
166 {
167  NS_LOG_FUNCTION (this << managedFlag);
168  m_managedFlag = managedFlag;
169 }
170 
172 {
173  NS_LOG_FUNCTION (this);
174  return m_otherConfigFlag;
175 }
176 
177 void RadvdInterface::SetOtherConfigFlag (bool otherConfigFlag)
178 {
179  NS_LOG_FUNCTION (this << otherConfigFlag);
180  m_otherConfigFlag = otherConfigFlag;
181 }
182 
183 uint32_t RadvdInterface::GetLinkMtu () const
184 {
185  NS_LOG_FUNCTION (this);
186  return m_linkMtu;
187 }
188 
189 void RadvdInterface::SetLinkMtu (uint32_t linkMtu)
190 {
191  NS_LOG_FUNCTION (this << linkMtu);
192  m_linkMtu = linkMtu;
193 }
194 
196 {
197  NS_LOG_FUNCTION (this);
198  return m_reachableTime;
199 }
200 
201 void RadvdInterface::SetReachableTime (uint32_t reachableTime)
202 {
203  NS_LOG_FUNCTION (this << reachableTime);
204  m_reachableTime = reachableTime;
205 }
206 
208 {
209  NS_LOG_FUNCTION (this);
210  return m_defaultLifeTime;
211 }
212 
213 void RadvdInterface::SetDefaultLifeTime (uint32_t defaultLifeTime)
214 {
215  NS_LOG_FUNCTION (this << defaultLifeTime);
216  m_defaultLifeTime = defaultLifeTime;
217 }
218 
220 {
221  NS_LOG_FUNCTION (this);
222  return m_retransTimer;
223 }
224 
225 void RadvdInterface::SetRetransTimer (uint32_t retransTimer)
226 {
227  NS_LOG_FUNCTION (this << retransTimer);
228  m_retransTimer = retransTimer;
229 }
230 
232 {
233  NS_LOG_FUNCTION (this);
234  return m_curHopLimit;
235 }
236 
237 void RadvdInterface::SetCurHopLimit (uint8_t curHopLimit)
238 {
239  NS_LOG_FUNCTION (this << curHopLimit);
240  m_curHopLimit = curHopLimit;
241 }
242 
244 {
245  NS_LOG_FUNCTION (this);
246  return m_defaultPreference;
247 }
248 
249 void RadvdInterface::SetDefaultPreference (uint8_t defaultPreference)
250 {
251  NS_LOG_FUNCTION (this << defaultPreference);
252  m_defaultPreference = defaultPreference;
253 }
254 
256 {
257  NS_LOG_FUNCTION (this);
258  return m_sourceLLAddress;
259 }
260 
261 void RadvdInterface::SetSourceLLAddress (bool sourceLLAddress)
262 {
263  NS_LOG_FUNCTION (this << sourceLLAddress);
264  m_sourceLLAddress = sourceLLAddress;
265 }
266 
268 {
269  NS_LOG_FUNCTION (this);
270  return m_homeAgentFlag;
271 }
272 
273 void RadvdInterface::SetHomeAgentFlag (bool homeAgentFlag)
274 {
275  NS_LOG_FUNCTION (this << homeAgentFlag);
276  m_homeAgentFlag = homeAgentFlag;
277 }
278 
280 {
281  NS_LOG_FUNCTION (this);
282  return m_homeAgentInfo;
283 }
284 
285 void RadvdInterface::SetHomeAgentInfo (bool homeAgentInfo)
286 {
287  NS_LOG_FUNCTION (this << homeAgentInfo);
288  m_homeAgentInfo = homeAgentInfo;
289 }
290 
292 {
293  NS_LOG_FUNCTION (this);
294  return m_homeAgentLifeTime;
295 }
296 
297 void RadvdInterface::SetHomeAgentLifeTime (uint32_t homeAgentLifeTime)
298 {
299  NS_LOG_FUNCTION (this << homeAgentLifeTime);
300  m_homeAgentLifeTime = homeAgentLifeTime;
301 }
302 
304 {
305  NS_LOG_FUNCTION (this);
306  return m_homeAgentPreference;
307 }
308 
309 void RadvdInterface::SetHomeAgentPreference (uint32_t homeAgentPreference)
310 {
311  NS_LOG_FUNCTION (this << homeAgentPreference);
312  m_homeAgentPreference = homeAgentPreference;
313 }
314 
316 {
317  NS_LOG_FUNCTION (this);
318  return m_mobRtrSupportFlag;
319 }
320 
321 void RadvdInterface::SetMobRtrSupportFlag (bool mobRtrSupportFlag)
322 {
323  NS_LOG_FUNCTION (this << mobRtrSupportFlag);
324  m_mobRtrSupportFlag = mobRtrSupportFlag;
325 }
326 
328 {
329  NS_LOG_FUNCTION (this);
330  return m_intervalOpt;
331 }
332 
333 void RadvdInterface::SetIntervalOpt (bool intervalOpt)
334 {
335  NS_LOG_FUNCTION (this << intervalOpt);
336  m_intervalOpt = intervalOpt;
337 }
338 } /* namespace ns3 */
339