A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dhcp6-options.cc
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#include "dhcp6-options.h"
11
12#include "dhcp6-duid.h"
13
14#include "ns3/address-utils.h"
15#include "ns3/assert.h"
16#include "ns3/log.h"
17#include "ns3/loopback-net-device.h"
18#include "ns3/ptr.h"
19#include "ns3/simulator.h"
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("Dhcp6Options");
25
31
32Options::Options(OptionType code, uint16_t length)
33{
34 NS_LOG_FUNCTION(this << static_cast<uint16_t>(code) << length);
35 m_optionCode = code;
36 m_optionLength = length;
37}
38
41{
42 return m_optionCode;
43}
44
45void
47{
48 NS_LOG_FUNCTION(this << static_cast<uint16_t>(code));
49 m_optionCode = code;
50}
51
52uint16_t
54{
55 return m_optionLength;
56}
57
58void
60{
61 NS_LOG_FUNCTION(this << length);
62 m_optionLength = length;
63}
64
68
69void
71{
72 NS_LOG_FUNCTION(this);
73 m_duid = duid;
74}
75
76Duid
78{
79 return m_duid;
80}
81
87
93
94void
96{
97 NS_LOG_FUNCTION(this << static_cast<uint16_t>(statusCode));
98 m_statusCode = statusCode;
99}
100
101std::string
106
107void
108StatusCodeOption::SetStatusMessage(std::string statusMessage)
109{
110 NS_LOG_FUNCTION(this);
111 m_statusMessage = statusMessage;
112}
113
120
122 uint32_t preferredLifetime,
123 uint32_t validLifetime)
124{
125 m_iaAddress = iaAddress;
126 m_preferredLifetime = preferredLifetime;
127 m_validLifetime = validLifetime;
128}
129
132{
133 return m_iaAddress;
134}
135
136void
138{
139 NS_LOG_FUNCTION(this << iaAddress);
140 m_iaAddress = iaAddress;
141}
142
148
149void
151{
152 NS_LOG_FUNCTION(this << preferredLifetime);
153 m_preferredLifetime = preferredLifetime;
154}
155
161
162void
164{
165 NS_LOG_FUNCTION(this << validLifetime);
166 m_validLifetime = validLifetime;
167}
168
170{
171 m_iaid = 0;
172 m_t1 = 0;
173 m_t2 = 0;
174}
175
178{
179 return m_iaid;
180}
181
182void
184{
185 NS_LOG_FUNCTION(this << iaid);
186 m_iaid = iaid;
187}
188
191{
192 return m_t1;
193}
194
195void
197{
198 NS_LOG_FUNCTION(this << t1);
199 m_t1 = t1;
200}
201
204{
205 return m_t2;
206}
207
208void
210{
211 NS_LOG_FUNCTION(this << t2);
212 m_t2 = t2;
213}
214
216{
217 m_requestedOptions = std::vector<OptionType>();
218}
219
220std::vector<Options::OptionType>
225
226void
228{
229 m_requestedOptions.push_back(requestedOption);
230}
231
232template <typename T>
237
238template <typename T>
239T
244
245template <typename T>
246void
248{
249 NS_LOG_FUNCTION(this << optionValue);
250 m_optionValue = optionValue;
251}
252
257
263
264void
266{
267 NS_LOG_FUNCTION(this << serverAddress);
268 m_serverAddress = serverAddress;
269}
270
271// Public template function declarations.
272
273template class IntegerOptions<uint16_t>;
274template class IntegerOptions<uint8_t>;
275
276} // namespace ns3
Implements the unique identifier for DHCPv6.
Definition dhcp6-duid.h:27
void SetPreferredLifetime(uint32_t preferredLifetime)
Set the preferred lifetime.
IaAddressOption()
Default constructor.
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...
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.
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.
T m_optionValue
Indicates the elapsed time or preference value.
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.
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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.