A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dhcp6-options.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 NITK Surathkal
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kavya Bhat <kavyabhat@gmail.com>
7 *
8 */
9
10#ifndef DHCP6_OPTIONS_H
11#define DHCP6_OPTIONS_H
12
13#include "dhcp6-duid.h"
14
15#include "ns3/address.h"
16#include "ns3/buffer.h"
17#include "ns3/header.h"
18#include "ns3/ipv6-address.h"
19#include "ns3/node.h"
20#include "ns3/nstime.h"
21#include "ns3/ptr.h"
22#include "ns3/random-variable-stream.h"
23
24namespace ns3
25{
26
27/**
28 * @ingroup dhcp6
29 *
30 * @class Options
31 * @brief Implements the functionality of DHCPv6 options
32 */
34{
35 public:
36 /**
37 * Enum to identify the status code of the operation.
38 * These symbols and values are defined in [RFC 8415,
39 * section 21.13](https://datatracker.ietf.org/doc/html/rfc8415#section-21.13)
40 */
51
52 /**
53 * Enum to identify the option type.
54 * These symbols and values are defined in [RFC 8415, section 21]
55 * (https://datatracker.ietf.org/doc/html/rfc8415#section-21)
56 */
85
86 /**
87 * @brief Default constructor.
88 */
89 Options();
90
91 /**
92 * @brief Constructor.
93 * @param code The option code.
94 * @param length The option length.
95 */
96 Options(OptionType code, uint16_t length);
97
98 /**
99 * @brief Get the option code.
100 * @return option code
101 */
102 OptionType GetOptionCode() const;
103
104 /**
105 * @brief Set the option code.
106 * @param code The option code to be added.
107 */
108 void SetOptionCode(OptionType code);
109
110 /**
111 * @brief Get the option length.
112 * @return option length
113 */
114 uint16_t GetOptionLength() const;
115
116 /**
117 * @brief Set the option length.
118 * @param length The option length to be parsed.
119 */
120 void SetOptionLength(uint16_t length);
121
122 private:
123 OptionType m_optionCode; //!< Option code
124 uint16_t m_optionLength; //!< Option length
125};
126
127/**
128 * @ingroup dhcp6
129 *
130 * @class IdentifierOption
131 * @brief Implements the client and server identifier options.
132 */
134{
135 public:
136 /**
137 * Default constructor.
138 */
140
141 /**
142 * @brief Set the DUID.
143 * @param duid The DUID.
144 */
145 void SetDuid(Duid duid);
146
147 /**
148 * @brief Get the DUID object.
149 * @return the DUID.
150 */
151 Duid GetDuid() const;
152
153 private:
154 Duid m_duid; //!< Unique identifier of the node.
155};
156
157/**
158 * @ingroup dhcp6
159 *
160 * @class StatusCodeOption
161 * @brief Implements the Status Code option.
162 */
164{
165 public:
166 /**
167 * @brief Default constructor.
168 */
170
171 /**
172 * @brief Get the status code of the operation.
173 * @return the status code.
174 */
176
177 /**
178 * @brief Set the status code of the operation.
179 * @param statusCode the status code of the performed operation.
180 */
181 void SetStatusCode(StatusCodeValues statusCode);
182
183 /**
184 * @brief Get the status message of the operation.
185 * @return the status message
186 */
187 std::string GetStatusMessage() const;
188
189 /**
190 * @brief Set the status message of the operation.
191 * @param statusMessage the status message of the operation.
192 */
193 void SetStatusMessage(std::string statusMessage);
194
195 private:
196 /**
197 * The status code of an operation involving the IA_NA, IA_TA or
198 * IA address.
199 */
201
202 /**
203 * The status message of the operation. This is to be UTF-8 encoded
204 * as per RFC 3629.
205 */
206 std::string m_statusMessage;
207};
208
209/**
210 * @ingroup dhcp6
211 *
212 * @class IaAddressOption
213 * @brief Implements the IA Address options.
214 */
216{
217 public:
218 /**
219 * @brief Default constructor.
220 */
222
223 /**
224 * @brief Constructor.
225 * @param iaAddress The IA Address.
226 * @param preferredLifetime The preferred lifetime of the address.
227 * @param validLifetime The valid lifetime of the address.
228 */
229 IaAddressOption(Ipv6Address iaAddress, uint32_t preferredLifetime, uint32_t validLifetime);
230
231 /**
232 * @brief Get the IA Address.
233 * @return the IPv6 address of the Identity Association
234 */
236
237 /**
238 * @brief Set the IA Address.
239 * @param iaAddress the IPv6 address of this Identity Association.
240 */
241 void SetIaAddress(Ipv6Address iaAddress);
242
243 /**
244 * @brief Get the preferred lifetime.
245 * @return the preferred lifetime
246 */
248
249 /**
250 * @brief Set the preferred lifetime.
251 * @param preferredLifetime the preferred lifetime for this address.
252 */
253 void SetPreferredLifetime(uint32_t preferredLifetime);
254
255 /**
256 * @brief Get the valid lifetime.
257 * @return the lifetime for which the address is valid.
258 */
260
261 /**
262 * @brief Set the valid lifetime.
263 * @param validLifetime the lifetime for which the address is valid.
264 */
265 void SetValidLifetime(uint32_t validLifetime);
266
267 private:
268 Ipv6Address m_iaAddress; //!< the IPv6 address offered to the client.
269 uint32_t m_preferredLifetime; //!< The preferred lifetime of the address, in seconds.
270 uint32_t m_validLifetime; //!< The valid lifetime of the address, in seconds.
271
272 /// (optional) The status code of any operation involving this address
274};
275
276/**
277 * @ingroup dhcp6
278 *
279 * @class IaOptions
280 * @brief Implements the IANA and IATA options.
281 */
282class IaOptions : public Options
283{
284 public:
285 /**
286 * @brief Default constructor.
287 */
288 IaOptions();
289
290 /**
291 * @brief Get the unique identifier for the given IANA or IATA.
292 * @return the ID of the IANA or IATA
293 */
294 uint32_t GetIaid() const;
295
296 /**
297 * @brief Set the unique identifier for the given IANA or IATA.
298 * @param iaid the unique ID for the IANA or IATA.
299 */
300 void SetIaid(uint32_t iaid);
301
302 /**
303 * @brief Get the time interval in seconds after which the client contacts
304 * the server which provided the address to extend the lifetime.
305 * @return the time interval T1
306 */
307 uint32_t GetT1() const;
308
309 /**
310 * @brief Set the time interval in seconds after which the client contacts
311 * the server which provided the address to extend the lifetime.
312 * @param t1 the time interval in seconds.
313 */
314 void SetT1(uint32_t t1);
315
316 /**
317 * @brief Get the time interval in seconds after which the client contacts
318 * any available server to extend the address lifetime.
319 * @return the time interval T2
320 */
321 uint32_t GetT2() const;
322
323 /**
324 * @brief Set the time interval in seconds after which the client contacts
325 * any available server to extend the address lifetime.
326 * @param t2 time interval in seconds.
327 */
328 void SetT2(uint32_t t2);
329
330 /// The list of IA Address options associated with the IANA.
331 std::vector<IaAddressOption> m_iaAddressOption;
332
333 private:
334 /// The unique identifier for the given IA_NA or IA_TA.
336
337 /**
338 * The time interval in seconds after which the client contacts the
339 * server which provided the address to extend the lifetime.
340 */
342
343 /**
344 * The time interval in seconds after which the client contacts any
345 * available server to extend the address lifetime.
346 */
348
349 /// (optional) The status code of any operation involving the IANA.
351};
352
353/**
354 * @ingroup dhcp6
355 *
356 * @class RequestOptions
357 * @brief Implements the Option Request option.
358 */
360{
361 public:
362 /**
363 * @brief Constructor.
364 */
366
367 /**
368 * @brief Get the option values
369 * @return requested option list.
370 */
371 std::vector<OptionType> GetRequestedOptions() const;
372
373 /**
374 * @brief Set the option values.
375 * @param requestedOption option to be requested from the server.
376 */
377 void AddRequestedOption(OptionType requestedOption);
378
379 private:
380 std::vector<OptionType> m_requestedOptions; //!< List of requested options.
381};
382
383/**
384 * @ingroup dhcp6
385 *
386 * @class IntegerOptions
387 * @brief Implements the Preference and Elapsed Time options.
388 */
389template <typename T>
391{
392 public:
393 /**
394 * @brief Constructor.
395 */
397
398 /**
399 * @brief Get the option value
400 * @return elapsed time or preference value.
401 */
402 T GetOptionValue() const;
403
404 /**
405 * @brief Set the option value.
406 * @param optionValue elapsed time or preference value.
407 */
408 void SetOptionValue(T optionValue);
409
410 private:
411 /// Indicates the elapsed time or preference value.
413};
414
415/**
416 * @ingroup dhcp6
417 *
418 * @class ServerUnicastOption
419 * @brief Implements the Server Unicast option.
420 */
422{
423 public:
425
426 /**
427 * @brief Get the server address.
428 * @return The 128 bit server address.
429 */
431
432 /**
433 * @brief Set the server address.
434 * @param serverAddress the 128-bit server address.
435 */
436 void SetServerAddress(Ipv6Address serverAddress);
437
438 private:
439 /**
440 * The 128-bit server address to which the client should send
441 * unicast messages.
442 */
444};
445
446/**
447 * @ingroup dhcp6
448 * Create the typedef PreferenceOption with T as uint8_t
449 */
451
452/**
453 * @ingroup dhcp6
454 * Create the typedef ElapsedTimeOption with T as uint16_t
455 */
457
458} // namespace ns3
459
460#endif
Implements the unique identifier for DHCPv6.
Definition dhcp6-duid.h:27
void SetPreferredLifetime(uint32_t preferredLifetime)
Set the preferred lifetime.
IaAddressOption()
Default constructor.
StatusCodeOption m_statusCodeOption
(optional) The status code of any operation involving this address
Ipv6Address GetIaAddress() const
Get the IA Address.
uint32_t GetValidLifetime() const
Get the valid lifetime.
void SetValidLifetime(uint32_t validLifetime)
Set the valid lifetime.
Ipv6Address m_iaAddress
the IPv6 address offered to the client.
void SetIaAddress(Ipv6Address iaAddress)
Set the IA Address.
uint32_t m_preferredLifetime
The preferred lifetime of the address, in seconds.
uint32_t GetPreferredLifetime() const
Get the preferred lifetime.
uint32_t m_validLifetime
The valid lifetime of the address, in seconds.
uint32_t GetT2() const
Get the time interval in seconds after which the client contacts any available server to extend the a...
std::vector< IaAddressOption > m_iaAddressOption
The list of IA Address options associated with the IANA.
void SetT1(uint32_t t1)
Set the time interval in seconds after which the client contacts the server which provided the addres...
uint32_t GetT1() const
Get the time interval in seconds after which the client contacts the server which provided the addres...
uint32_t m_t1
The time interval in seconds after which the client contacts the server which provided the address to...
IaOptions()
Default constructor.
uint32_t m_t2
The time interval in seconds after which the client contacts any available server to extend the addre...
uint32_t m_iaid
The unique identifier for the given IA_NA or IA_TA.
void SetT2(uint32_t t2)
Set the time interval in seconds after which the client contacts any available server to extend the a...
uint32_t GetIaid() const
Get the unique identifier for the given IANA or IATA.
void SetIaid(uint32_t iaid)
Set the unique identifier for the given IANA or IATA.
StatusCodeOption m_statusCodeOption
(optional) The status code of any operation involving the IANA.
IdentifierOption()
Default constructor.
void SetDuid(Duid duid)
Set the DUID.
Duid GetDuid() const
Get the DUID object.
Duid m_duid
Unique identifier of the node.
Implements the Preference and Elapsed Time options.
void SetOptionValue(T optionValue)
Set the option value.
IntegerOptions()
Constructor.
T GetOptionValue() const
Get the option value.
Describes an IPv6 address.
StatusCodeValues
Enum to identify the status code of the operation.
uint16_t m_optionLength
Option length.
void SetOptionCode(OptionType code)
Set the option code.
OptionType m_optionCode
Option code.
uint16_t GetOptionLength() const
Get the option length.
OptionType GetOptionCode() const
Get the option code.
OptionType
Enum to identify the option type.
Options()
Default constructor.
void SetOptionLength(uint16_t length)
Set the option length.
std::vector< OptionType > GetRequestedOptions() const
Get the option values.
void AddRequestedOption(OptionType requestedOption)
Set the option values.
RequestOptions()
Constructor.
std::vector< OptionType > m_requestedOptions
List of requested options.
Ipv6Address m_serverAddress
The 128-bit server address to which the client should send unicast messages.
void SetServerAddress(Ipv6Address serverAddress)
Set the server address.
Ipv6Address GetServerAddress()
Get the server address.
Implements the Status Code option.
StatusCodeOption()
Default constructor.
std::string m_statusMessage
The status message of the operation.
void SetStatusCode(StatusCodeValues statusCode)
Set the status code of the operation.
StatusCodeValues GetStatusCode() const
Get the status code of the operation.
StatusCodeValues m_statusCode
The status code of an operation involving the IA_NA, IA_TA or IA address.
std::string GetStatusMessage() const
Get the status message of the operation.
void SetStatusMessage(std::string statusMessage)
Set the status message of the operation.
IntegerOptions< uint8_t > PreferenceOption
Create the typedef PreferenceOption with T as uint8_t.
IntegerOptions< uint16_t > ElapsedTimeOption
Create the typedef ElapsedTimeOption with T as uint16_t.
Every class exported by the ns3 library is enclosed in the ns3 namespace.