A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ipv6-interface-address.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007-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
#ifndef IPV6_INTERFACE_ADDRESS_H
21
#define IPV6_INTERFACE_ADDRESS_H
22
23
#include "ns3/ipv6-address.h"
24
25
#include <stdint.h>
26
27
namespace
ns3
28
{
29
30
/**
31
* \ingroup address
32
* \ingroup ipv6
33
*
34
* \brief IPv6 address associated with an interface.
35
*/
36
class
Ipv6InterfaceAddress
37
{
38
public
:
39
/**
40
* \enum State_e
41
* \brief State of an address associated with an interface.
42
*/
43
enum
State_e
44
{
45
TENTATIVE
,
/**< Address is tentative, no packet can be sent unless DAD finished */
46
DEPRECATED
,
/**< Address is deprecated and should not be used */
47
PREFERRED
,
/**< Preferred address */
48
PERMANENT
,
/**< Permanent address */
49
HOMEADDRESS
,
/**< Address is a HomeAddress */
50
TENTATIVE_OPTIMISTIC
,
/**< Address is tentative but we are optimistic so we can send packet
51
even if DAD is not yet finished */
52
INVALID
,
/**< Invalid state (after a DAD failed) */
53
};
54
55
/**
56
* \enum Scope_e
57
* \brief Address scope.
58
*/
59
enum
Scope_e
60
{
61
HOST
,
/**< Localhost (::1/128) */
62
LINKLOCAL
,
/**< Link-local address (fe80::/64) */
63
GLOBAL
,
/**< Global address (2000::/3) */
64
};
65
66
/**
67
* \brief Default constructor.
68
*/
69
Ipv6InterfaceAddress
();
70
71
/**
72
* \brief Constructor. Prefix is 64 by default.
73
* \param address the IPv6 address to set
74
*/
75
Ipv6InterfaceAddress
(
Ipv6Address
address);
76
77
/**
78
* \brief Constructor.
79
* \param address IPv6 address to set
80
* \param prefix IPv6 prefix
81
*/
82
Ipv6InterfaceAddress
(
Ipv6Address
address,
Ipv6Prefix
prefix);
83
84
/**
85
* \brief Constructor.
86
* \param address IPv6 address to set
87
* \param prefix IPv6 prefix
88
* \param onLink on-link property
89
*/
90
Ipv6InterfaceAddress
(
Ipv6Address
address,
Ipv6Prefix
prefix,
bool
onLink);
91
92
/**
93
* \brief Copy constructor.
94
* \param o object to copy
95
*/
96
Ipv6InterfaceAddress
(
const
Ipv6InterfaceAddress
& o);
97
98
/**
99
* \brief Destructor.
100
*/
101
~Ipv6InterfaceAddress
();
102
103
/**
104
* \brief Set IPv6 address (and scope).
105
* \param address IPv6 address to set
106
*/
107
void
SetAddress
(
Ipv6Address
address);
108
109
/**
110
* \brief Get the IPv6 address.
111
* \return IPv6 address
112
*/
113
Ipv6Address
GetAddress
()
const
;
114
115
/**
116
* \brief Get the IPv6 prefix.
117
* \return IPv6 prefix
118
*/
119
Ipv6Prefix
GetPrefix
()
const
;
120
121
/**
122
* \brief Set the state.
123
* \param state the state
124
*/
125
void
SetState
(
Ipv6InterfaceAddress::State_e
state);
126
127
/**
128
* \brief Get the address state.
129
* \return address state
130
*/
131
Ipv6InterfaceAddress::State_e
GetState
()
const
;
132
133
/**
134
* \brief Set the scope.
135
* \param scope the scope of address
136
*/
137
void
SetScope
(
Ipv6InterfaceAddress::Scope_e
scope);
138
139
/**
140
* \brief Get address scope.
141
* \return scope
142
*/
143
Ipv6InterfaceAddress::Scope_e
GetScope
()
const
;
144
145
/**
146
* \brief Checks if the address is in the same subnet.
147
* \param b the address to check
148
* \return true if the address is in the same subnet.
149
*/
150
bool
IsInSameSubnet
(
Ipv6Address
b)
const
;
151
152
/**
153
* \brief Set the latest DAD probe packet UID.
154
* \param uid packet uid
155
*/
156
void
SetNsDadUid
(
uint32_t
uid);
157
158
/**
159
* \brief Get the latest DAD probe packet UID.
160
* \return uid
161
*/
162
uint32_t
GetNsDadUid
()
const
;
163
164
/**
165
* \brief Get the on-link property.
166
* \param onLink the on-link property
167
*/
168
void
SetOnLink
(
bool
onLink);
169
170
/**
171
* \brief Get the on-link property.
172
* \return on-link flag
173
*/
174
bool
GetOnLink
()
const
;
175
176
#if 0
177
/**
178
* \brief Start the DAD timer.
179
* \param interface interface
180
*/
181
void
StartDadTimer (
Ptr<Ipv6Interface>
interface);
182
183
/**
184
* \brief Stop the DAD timer.
185
*/
186
void
StopDadTimer ();
187
#endif
188
189
private
:
190
/**
191
* \brief The IPv6 address.
192
*/
193
Ipv6Address
m_address
;
194
195
/**
196
* \brief The IPv6 prefix.
197
*/
198
Ipv6Prefix
m_prefix
;
199
200
/**
201
* \brief State of the address.
202
*/
203
State_e
m_state
;
204
205
/**
206
* \brief Scope of the address.
207
*/
208
Scope_e
m_scope
;
209
210
/**
211
* \brief The address belongs to an on-link network.
212
*/
213
bool
m_onLink
;
214
215
/**
216
* \brief Equal to operator.
217
*
218
* \param a the first operand
219
* \param b the first operand
220
* \returns true if the operands are equal
221
*/
222
friend
bool
operator==
(
const
Ipv6InterfaceAddress
& a,
const
Ipv6InterfaceAddress
& b);
223
224
/**
225
* \brief Not equal to operator.
226
*
227
* \param a the first operand
228
* \param b the first operand
229
* \returns true if the operands are not equal
230
*/
231
friend
bool
operator!=
(
const
Ipv6InterfaceAddress
& a,
const
Ipv6InterfaceAddress
& b);
232
233
/**
234
* \brief Last DAD probe packet UID.
235
*/
236
uint32_t
m_nsDadUid
;
237
};
238
239
/**
240
* \brief Stream insertion operator.
241
*
242
* \param os the reference to the output stream
243
* \param addr the Ipv6InterfaceAddress
244
* \returns the reference to the output stream
245
*/
246
std::ostream&
operator<<
(std::ostream& os,
const
Ipv6InterfaceAddress
& addr);
247
248
/* follow Ipv4InterfaceAddress way, maybe not inline them */
249
inline
bool
250
operator==
(
const
Ipv6InterfaceAddress
& a,
const
Ipv6InterfaceAddress
& b)
251
{
252
return
(a.
m_address
== b.
m_address
&& a.
m_prefix
== b.
m_prefix
&& a.
m_state
== b.
m_state
&&
253
a.
m_scope
== b.
m_scope
);
254
}
255
256
inline
bool
257
operator!=
(
const
Ipv6InterfaceAddress
& a,
const
Ipv6InterfaceAddress
& b)
258
{
259
return
(a.
m_address
!= b.
m_address
|| a.
m_prefix
!= b.
m_prefix
|| a.
m_state
!= b.
m_state
||
260
a.
m_scope
!= b.
m_scope
);
261
}
262
263
}
/* namespace ns3 */
264
265
#endif
/* IPV6_INTERFACE_ADDRESS_H */
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:49
ns3::Ipv6InterfaceAddress
IPv6 address associated with an interface.
Definition:
ipv6-interface-address.h:37
ns3::Ipv6InterfaceAddress::SetScope
void SetScope(Ipv6InterfaceAddress::Scope_e scope)
Set the scope.
Definition:
ipv6-interface-address.cc:147
ns3::Ipv6InterfaceAddress::m_address
Ipv6Address m_address
The IPv6 address.
Definition:
ipv6-interface-address.h:193
ns3::Ipv6InterfaceAddress::m_nsDadUid
uint32_t m_nsDadUid
Last DAD probe packet UID.
Definition:
ipv6-interface-address.h:236
ns3::Ipv6InterfaceAddress::~Ipv6InterfaceAddress
~Ipv6InterfaceAddress()
Destructor.
Definition:
ipv6-interface-address.cc:83
ns3::Ipv6InterfaceAddress::operator==
friend bool operator==(const Ipv6InterfaceAddress &a, const Ipv6InterfaceAddress &b)
Equal to operator.
Definition:
ipv6-interface-address.h:250
ns3::Ipv6InterfaceAddress::operator!=
friend bool operator!=(const Ipv6InterfaceAddress &a, const Ipv6InterfaceAddress &b)
Not equal to operator.
Definition:
ipv6-interface-address.h:257
ns3::Ipv6InterfaceAddress::SetAddress
void SetAddress(Ipv6Address address)
Set IPv6 address (and scope).
Definition:
ipv6-interface-address.cc:96
ns3::Ipv6InterfaceAddress::GetAddress
Ipv6Address GetAddress() const
Get the IPv6 address.
Definition:
ipv6-interface-address.cc:89
ns3::Ipv6InterfaceAddress::Ipv6InterfaceAddress
Ipv6InterfaceAddress()
Default constructor.
Definition:
ipv6-interface-address.cc:32
ns3::Ipv6InterfaceAddress::GetNsDadUid
uint32_t GetNsDadUid() const
Get the latest DAD probe packet UID.
Definition:
ipv6-interface-address.cc:207
ns3::Ipv6InterfaceAddress::SetState
void SetState(Ipv6InterfaceAddress::State_e state)
Set the state.
Definition:
ipv6-interface-address.cc:133
ns3::Ipv6InterfaceAddress::GetScope
Ipv6InterfaceAddress::Scope_e GetScope() const
Get address scope.
Definition:
ipv6-interface-address.cc:154
ns3::Ipv6InterfaceAddress::SetNsDadUid
void SetNsDadUid(uint32_t uid)
Set the latest DAD probe packet UID.
Definition:
ipv6-interface-address.cc:214
ns3::Ipv6InterfaceAddress::GetPrefix
Ipv6Prefix GetPrefix() const
Get the IPv6 prefix.
Definition:
ipv6-interface-address.cc:126
ns3::Ipv6InterfaceAddress::GetOnLink
bool GetOnLink() const
Get the on-link property.
Definition:
ipv6-interface-address.cc:221
ns3::Ipv6InterfaceAddress::SetOnLink
void SetOnLink(bool onLink)
Get the on-link property.
Definition:
ipv6-interface-address.cc:228
ns3::Ipv6InterfaceAddress::GetState
Ipv6InterfaceAddress::State_e GetState() const
Get the address state.
Definition:
ipv6-interface-address.cc:140
ns3::Ipv6InterfaceAddress::m_onLink
bool m_onLink
The address belongs to an on-link network.
Definition:
ipv6-interface-address.h:213
ns3::Ipv6InterfaceAddress::State_e
State_e
State of an address associated with an interface.
Definition:
ipv6-interface-address.h:44
ns3::Ipv6InterfaceAddress::PERMANENT
@ PERMANENT
Permanent address.
Definition:
ipv6-interface-address.h:48
ns3::Ipv6InterfaceAddress::PREFERRED
@ PREFERRED
Preferred address.
Definition:
ipv6-interface-address.h:47
ns3::Ipv6InterfaceAddress::TENTATIVE_OPTIMISTIC
@ TENTATIVE_OPTIMISTIC
Address is tentative but we are optimistic so we can send packet even if DAD is not yet finished.
Definition:
ipv6-interface-address.h:50
ns3::Ipv6InterfaceAddress::INVALID
@ INVALID
Invalid state (after a DAD failed)
Definition:
ipv6-interface-address.h:52
ns3::Ipv6InterfaceAddress::HOMEADDRESS
@ HOMEADDRESS
Address is a HomeAddress.
Definition:
ipv6-interface-address.h:49
ns3::Ipv6InterfaceAddress::DEPRECATED
@ DEPRECATED
Address is deprecated and should not be used.
Definition:
ipv6-interface-address.h:46
ns3::Ipv6InterfaceAddress::TENTATIVE
@ TENTATIVE
Address is tentative, no packet can be sent unless DAD finished.
Definition:
ipv6-interface-address.h:45
ns3::Ipv6InterfaceAddress::IsInSameSubnet
bool IsInSameSubnet(Ipv6Address b) const
Checks if the address is in the same subnet.
Definition:
ipv6-interface-address.cc:161
ns3::Ipv6InterfaceAddress::m_scope
Scope_e m_scope
Scope of the address.
Definition:
ipv6-interface-address.h:208
ns3::Ipv6InterfaceAddress::m_state
State_e m_state
State of the address.
Definition:
ipv6-interface-address.h:203
ns3::Ipv6InterfaceAddress::m_prefix
Ipv6Prefix m_prefix
The IPv6 prefix.
Definition:
ipv6-interface-address.h:198
ns3::Ipv6InterfaceAddress::Scope_e
Scope_e
Address scope.
Definition:
ipv6-interface-address.h:60
ns3::Ipv6InterfaceAddress::LINKLOCAL
@ LINKLOCAL
Link-local address (fe80::/64)
Definition:
ipv6-interface-address.h:62
ns3::Ipv6InterfaceAddress::HOST
@ HOST
Localhost (::1/128)
Definition:
ipv6-interface-address.h:61
ns3::Ipv6InterfaceAddress::GLOBAL
@ GLOBAL
Global address (2000::/3)
Definition:
ipv6-interface-address.h:63
ns3::Ipv6Prefix
Describes an IPv6 prefix.
Definition:
ipv6-address.h:455
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator!=
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition:
callback.h:674
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition:
event-id.h:166
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:159
src
internet
model
ipv6-interface-address.h
Generated on Tue May 28 2024 23:35:57 for ns-3 by
1.9.6