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  NS_LOG_INFO ("Start PreferredTimer for " << m_prefix);
125 }
126 
128 {
129  NS_LOG_INFO ("Start ValidTimer for " << m_prefix);
133 }
134 
136 {
137  NS_LOG_INFO ("Stop PreferredTimer for " << m_prefix);
139 }
140 
142 {
143  NS_LOG_INFO ("Stop ValidTimer for " << m_prefix);
144  m_validTimer.Cancel ();
145 }
146 
148 {
149  NS_LOG_INFO ("The prefix " << m_prefix << " will be removed on interface " << m_interface);
151  ipv6->RemoveAutoconfiguredAddress (m_interface, m_prefix, m_mask, m_defaultGatewayRouter);
152 }
153 
155 {
156  m_preferred = true;
157 }
158 
160 {
161  m_preferred = false;
162  m_valid = true;
163 }
164 
166 {
167  return m_id;
168 }
169 
171 {
172  return m_preferred;
173 }
174 
176 {
177  return m_valid;
178 }
179 
181 {
182  return m_prefix;
183 }
184 
186 {
187  m_prefix = prefix;
188 }
189 
191 {
192  return m_mask;
193 }
194 
196 {
197  m_mask = mask;
198 }
199 
200 } /* namespace ns3 */
201