A Discrete-Event Network Simulator
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
16namespace ns3
17{
18
19/**
20 * @ingroup address
21 * @ingroup ipv6
22 *
23 * @brief IPv6 address associated with an interface.
24 */
26{
27 public:
28 /**
29 * @enum State_e
30 * @brief State of an address associated with an interface.
31 */
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 */
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 */
59
60 /**
61 * @brief Constructor. Prefix is 64 by default.
62 * @param address the IPv6 address to set
63 */
65
66 /**
67 * @brief Constructor.
68 * @param address IPv6 address to set
69 * @param prefix IPv6 prefix
70 */
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 */
86
87 /**
88 * @brief Destructor.
89 */
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 */
115
116 /**
117 * @brief Get the address state.
118 * @return address state
119 */
121
122 /**
123 * @brief Set the scope.
124 * @param scope the scope of address
125 */
127
128 /**
129 * @brief Get address scope.
130 * @return scope
131 */
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 */
183
184 /**
185 * @brief The IPv6 prefix.
186 */
188
189 /**
190 * @brief State of the address.
191 */
193
194 /**
195 * @brief Scope of the address.
196 */
198
199 /**
200 * @brief The address belongs to an on-link network.
201 */
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 */
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 */
235std::ostream& operator<<(std::ostream& os, const Ipv6InterfaceAddress& addr);
236
237/* follow Ipv4InterfaceAddress way, maybe not inline them */
238inline bool
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
245inline bool
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 */
Describes an IPv6 address.
IPv6 address associated with an interface.
void SetScope(Ipv6InterfaceAddress::Scope_e scope)
Set the scope.
Ipv6Address m_address
The IPv6 address.
uint32_t m_nsDadUid
Last DAD probe packet UID.
friend bool operator==(const Ipv6InterfaceAddress &a, const Ipv6InterfaceAddress &b)
Equal to operator.
friend bool operator!=(const Ipv6InterfaceAddress &a, const Ipv6InterfaceAddress &b)
Not equal to operator.
void SetAddress(Ipv6Address address)
Set IPv6 address (and scope).
Ipv6Address GetAddress() const
Get the IPv6 address.
Ipv6InterfaceAddress()
Default constructor.
uint32_t GetNsDadUid() const
Get the latest DAD probe packet UID.
void SetState(Ipv6InterfaceAddress::State_e state)
Set the state.
Ipv6InterfaceAddress::Scope_e GetScope() const
Get address scope.
void SetNsDadUid(uint32_t uid)
Set the latest DAD probe packet UID.
Ipv6Prefix GetPrefix() const
Get the IPv6 prefix.
bool GetOnLink() const
Get the on-link property.
void SetOnLink(bool onLink)
Get the on-link property.
Ipv6InterfaceAddress::State_e GetState() const
Get the address state.
bool m_onLink
The address belongs to an on-link network.
State_e
State of an address associated with an interface.
@ TENTATIVE_OPTIMISTIC
Address is tentative but we are optimistic so we can send packet even if DAD is not yet finished.
@ INVALID
Invalid state (after a DAD failed)
@ HOMEADDRESS
Address is a HomeAddress.
@ DEPRECATED
Address is deprecated and should not be used.
@ TENTATIVE
Address is tentative, no packet can be sent unless DAD finished.
bool IsInSameSubnet(Ipv6Address b) const
Checks if the address is in the same subnet.
Scope_e m_scope
Scope of the address.
State_e m_state
State of the address.
Ipv6Prefix m_prefix
The IPv6 prefix.
@ LINKLOCAL
Link-local address (fe80::/64)
@ GLOBAL
Global address (2000::/3)
Describes an IPv6 prefix.
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition callback.h:658
bool operator==(const EventId &a, const EventId &b)
Definition event-id.h:155
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148