A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv6-autoconfigured-prefix.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008-2009 Telecom Bretagne
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: Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/node.h"
23 
24 #include "ipv6-l3-protocol.h"
26 
27 NS_LOG_COMPONENT_DEFINE ("Ipv6AutoconfiguredPrefix");
28 
29 namespace ns3
30 {
31 
33 
34 Ipv6AutoconfiguredPrefix::Ipv6AutoconfiguredPrefix (Ptr<Node> node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router)
35 {
36  m_node = node;
37  m_interface = interface;
38  m_validLifeTime = validLifeTime;
39  m_preferredLifeTime = preferredLifeTime;
40  m_id = m_prefixId;
41  m_prefixId++;
42  m_preferred = false;
43  m_valid = false;
44  m_prefix = prefix;
45  m_mask = mask;
46  m_defaultGatewayRouter = router;
47 }
48 
50 {
51 }
52 
54 {
55  m_defaultGatewayRouter = router;
56 }
57 
59 {
61 }
62 
63 void Ipv6AutoconfiguredPrefix::SetInterface (uint32_t interface)
64 {
65  m_interface = interface;
66 }
67 
69 {
70  return m_interface;
71 }
72 
74 {
76 }
77 
79 {
80  return m_preferredLifeTime;
81 }
82 
84 {
85  m_validLifeTime = t;
86 }
87 
89 {
90  return m_validLifeTime;
91 }
92 
94 {
95  m_preferred = true;
96 }
97 
99 {
100  m_preferred = false;
101  m_valid = true;
102 }
103 
105 {
106  NS_LOG_INFO ("Preferred Time expired for " << m_prefix);
107  m_preferred = false;
108  MarkValidTime ();
109  StartValidTimer ();
110 }
111 
113 {
114  NS_LOG_INFO ("Valid Time expired for " << m_prefix);
115  m_valid = false;
116  RemoveMe ();
117 }
118 
120 {
121  if (m_preferredLifeTime != 0xffffffff)
122  {
123  NS_LOG_INFO ("Start PreferredTimer for " << m_prefix);
127  }
128 }
129 
131 {
132  if (m_validLifeTime != 0xffffffff)
133  {
134  NS_LOG_INFO ("Start ValidTimer for " << m_prefix);
138  }
139 }
140 
142 {
144  {
145  NS_LOG_INFO ("Stop PreferredTimer for " << m_prefix);
147  }
148 }
149 
151 {
152  if (m_validTimer.IsRunning())
153  {
154  NS_LOG_INFO ("Stop ValidTimer for " << m_prefix);
155  m_validTimer.Cancel ();
156  }
157 }
158 
160 {
161  NS_LOG_INFO ("The prefix " << m_prefix << " will be removed on interface " << m_interface);
163  ipv6->RemoveAutoconfiguredAddress (m_interface, m_prefix, m_mask, m_defaultGatewayRouter);
164 }
165 
167 {
168  m_preferred = true;
169 }
170 
172 {
173  m_preferred = false;
174  m_valid = true;
175 }
176 
178 {
179  return m_id;
180 }
181 
183 {
184  return m_preferred;
185 }
186 
188 {
189  return m_valid;
190 }
191 
193 {
194  return m_prefix;
195 }
196 
198 {
199  m_prefix = prefix;
200 }
201 
203 {
204  return m_mask;
205 }
206 
208 {
209  m_mask = mask;
210 }
211 
212 } /* namespace ns3 */
213