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