A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-option-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2009 Strasbourg University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: David Gross <gdavid.devel@gmail.com>
7 */
8
9#ifndef IPV6_OPTION_HEADER_H
10#define IPV6_OPTION_HEADER_H
11
12#include "ns3/header.h"
13
14#include <ostream>
15
16namespace ns3
17{
18
19/**
20 * \ingroup ipv6HeaderExt
21 *
22 * \brief Header for IPv6 Option.
23 */
25{
26 public:
27 /**
28 * \struct Alignment
29 * \brief represents the alignment requirements of an option header
30 *
31 * Represented as factor*n+offset (eg. 8n+2) See \RFC{2460}.
32 * No alignment is represented as 1n+0.
33 */
34 struct Alignment
35 {
36 uint8_t factor; /**< Factor */
37 uint8_t offset; /**< Offset */
38 };
39
40 /**
41 * \brief Get the type identificator.
42 * \return type identificator
43 */
44 static TypeId GetTypeId();
45
46 /**
47 * \brief Get the instance type ID.
48 * \return instance type ID
49 */
50 TypeId GetInstanceTypeId() const override;
51
52 /**
53 * \brief Constructor.
54 */
56
57 /**
58 * \brief Destructor.
59 */
60 ~Ipv6OptionHeader() override;
61
62 /**
63 * \brief Set the type of the option.
64 * \param type the type of the option
65 */
66 void SetType(uint8_t type);
67
68 /**
69 * \brief Get the type of the option.
70 * \return the type of the option
71 */
72 uint8_t GetType() const;
73
74 /**
75 * \brief Set the option length.
76 * \param length the option length
77 */
78 void SetLength(uint8_t length);
79
80 /**
81 * \brief Get the option length.
82 * \return the option length
83 */
84 uint8_t GetLength() const;
85
86 /**
87 * \brief Print some information about the packet.
88 * \param os output stream
89 */
90 void Print(std::ostream& os) const override;
91
92 /**
93 * \brief Get the serialized size of the packet.
94 * \return size
95 */
96 uint32_t GetSerializedSize() const override;
97
98 /**
99 * \brief Serialize the packet.
100 * \param start Buffer iterator
101 */
102 void Serialize(Buffer::Iterator start) const override;
103
104 /**
105 * \brief Deserialize the packet.
106 * \param start Buffer iterator
107 * \return size of the packet
108 */
109 uint32_t Deserialize(Buffer::Iterator start) override;
110
111 /**
112 * \brief Get the Alignment requirement of this option header
113 * \return The required alignment
114 *
115 * Subclasses should only implement this method, if special alignment is
116 * required. Default is no alignment (1n+0).
117 */
118 virtual Alignment GetAlignment() const;
119
120 private:
121 /**
122 * \brief The type of the option.
123 */
124 uint8_t m_type;
125
126 /**
127 * \brief The option length.
128 */
129 uint8_t m_length;
130
131 /**
132 * \brief The anonymous data of this option
133 */
135};
136
137/**
138 * \ingroup ipv6HeaderExt
139 *
140 * \brief Header of IPv6 Option Pad1
141 */
143{
144 public:
145 /**
146 * \brief Get the type identificator.
147 * \return type identificator
148 */
149 static TypeId GetTypeId();
150
151 /**
152 * \brief Get the instance type ID.
153 * \return instance type ID
154 */
155 TypeId GetInstanceTypeId() const override;
156
157 /**
158 * \brief Constructor.
159 */
161
162 /**
163 * \brief Destructor.
164 */
165 ~Ipv6OptionPad1Header() override;
166
167 /**
168 * \brief Print some information about the packet.
169 * \param os output stream
170 */
171 void Print(std::ostream& os) const override;
172
173 /**
174 * \brief Get the serialized size of the packet.
175 * \return size
176 */
177 uint32_t GetSerializedSize() const override;
178
179 /**
180 * \brief Serialize the packet.
181 * \param start Buffer iterator
182 */
183 void Serialize(Buffer::Iterator start) const override;
184
185 /**
186 * \brief Deserialize the packet.
187 * \param start Buffer iterator
188 * \return size of the packet
189 */
190 uint32_t Deserialize(Buffer::Iterator start) override;
191};
192
193/**
194 * \ingroup ipv6HeaderExt
195 *
196 * \brief Header of IPv6 Option Padn
197 */
199{
200 public:
201 /**
202 * \brief Get the type identificator.
203 * \return type identificator
204 */
205 static TypeId GetTypeId();
206
207 /**
208 * \brief Get the instance type ID.
209 * \return instance type ID
210 */
211 TypeId GetInstanceTypeId() const override;
212
213 /**
214 * \brief Constructor.
215 * \param pad Number of bytes to pad (>=2)
216 */
218
219 /**
220 * \brief Destructor.
221 */
222 ~Ipv6OptionPadnHeader() override;
223
224 /**
225 * \brief Print some information about the packet.
226 * \param os output stream
227 */
228 void Print(std::ostream& os) const override;
229
230 /**
231 * \brief Get the serialized size of the packet.
232 * \return size
233 */
234 uint32_t GetSerializedSize() const override;
235
236 /**
237 * \brief Serialize the packet.
238 * \param start Buffer iterator
239 */
240 void Serialize(Buffer::Iterator start) const override;
241
242 /**
243 * \brief Deserialize the packet.
244 * \param start Buffer iterator
245 * \return size of the packet
246 */
247 uint32_t Deserialize(Buffer::Iterator start) override;
248};
249
250/**
251 * \ingroup ipv6HeaderExt
252 *
253 * \brief Header of IPv6 Option Jumbogram
254 */
256{
257 public:
258 /**
259 * \brief Get the type identificator.
260 * \return type identificator
261 */
262 static TypeId GetTypeId();
263
264 /**
265 * \brief Get the instance type ID.
266 * \return instance type ID
267 */
268 TypeId GetInstanceTypeId() const override;
269
270 /**
271 * \brief Constructor.
272 */
274
275 /**
276 * \brief Destructor.
277 */
279
280 /**
281 * \brief Set the data length.
282 * \param dataLength the data length
283 */
284 void SetDataLength(uint32_t dataLength);
285
286 /**
287 * \brief Get the data length.
288 * \return the data length
289 */
290 uint32_t GetDataLength() const;
291
292 /**
293 * \brief Print some information about the packet.
294 * \param os output stream
295 */
296 void Print(std::ostream& os) const override;
297
298 /**
299 * \brief Get the serialized size of the packet.
300 * \return size
301 */
302 uint32_t GetSerializedSize() const override;
303
304 /**
305 * \brief Serialize the packet.
306 * \param start Buffer iterator
307 */
308 void Serialize(Buffer::Iterator start) const override;
309
310 /**
311 * \brief Deserialize the packet.
312 * \param start Buffer iterator
313 * \return size of the packet
314 */
315 uint32_t Deserialize(Buffer::Iterator start) override;
316
317 /**
318 * \brief Get the Alignment requirement of this option header
319 * \return The required alignment
320 */
321 Alignment GetAlignment() const override;
322
323 private:
324 /**
325 * \brief The data length.
326 */
328};
329
330/**
331 * \ingroup ipv6HeaderExt
332 *
333 * \brief Header of IPv6 Option Router Alert
334 */
336{
337 public:
338 /**
339 * \brief Get the type identificator.
340 * \return type identificator
341 */
342 static TypeId GetTypeId();
343
344 /**
345 * \brief Get the instance type ID.
346 * \return instance type ID
347 */
348 TypeId GetInstanceTypeId() const override;
349
350 /**
351 * \brief Constructor.
352 */
354
355 /**
356 * \brief Destructor.
357 */
359
360 /**
361 * \brief Set the field "value".
362 * \param value the value to be set.
363 */
364 void SetValue(uint16_t value);
365
366 /**
367 * \brief Get the field "value".
368 * \return the field "value"
369 */
370 uint16_t GetValue() const;
371
372 /**
373 * \brief Print some information about the packet.
374 * \param os output stream
375 */
376 void Print(std::ostream& os) const override;
377
378 /**
379 * \brief Get the serialized size of the packet.
380 * \return size
381 */
382 uint32_t GetSerializedSize() const override;
383
384 /**
385 * \brief Serialize the packet.
386 * \param start Buffer iterator
387 */
388 void Serialize(Buffer::Iterator start) const override;
389
390 /**
391 * \brief Deserialize the packet.
392 * \param start Buffer iterator
393 * \return size of the packet
394 */
395 uint32_t Deserialize(Buffer::Iterator start) override;
396
397 /**
398 * \brief Get the Alignment requirement of this option header
399 * \return The required alignment
400 */
401 Alignment GetAlignment() const override;
402
403 private:
404 /**
405 * \brief The value.
406 */
407 uint16_t m_value;
408};
409
410} // namespace ns3
411
412#endif /* IPV6_OPTION_HEADER_H */
iterator in a Buffer instance
Definition buffer.h:89
automatically resized byte buffer
Definition buffer.h:83
Protocol header serialization and deserialization.
Definition header.h:33
Header for IPv6 Option.
uint8_t GetLength() const
Get the option length.
uint8_t m_type
The type of the option.
void SetLength(uint8_t length)
Set the option length.
void SetType(uint8_t type)
Set the type of the option.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
uint8_t GetType() const
Get the type of the option.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
uint8_t m_length
The option length.
~Ipv6OptionHeader() override
Destructor.
static TypeId GetTypeId()
Get the type identificator.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Buffer m_data
The anonymous data of this option.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Header of IPv6 Option Jumbogram.
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
~Ipv6OptionJumbogramHeader() override
Destructor.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetDataLength(uint32_t dataLength)
Set the data length.
uint32_t m_dataLength
The data length.
void Print(std::ostream &os) const override
Print some information about the packet.
uint32_t GetDataLength() const
Get the data length.
Header of IPv6 Option Pad1.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
static TypeId GetTypeId()
Get the type identificator.
~Ipv6OptionPad1Header() override
Destructor.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Header of IPv6 Option Padn.
static TypeId GetTypeId()
Get the type identificator.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Ipv6OptionPadnHeader(uint32_t pad=2)
Constructor.
void Print(std::ostream &os) const override
Print some information about the packet.
~Ipv6OptionPadnHeader() override
Destructor.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Header of IPv6 Option Router Alert.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetValue(uint16_t value)
Set the field "value".
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
uint16_t GetValue() const
Get the field "value".
void Print(std::ostream &os) const override
Print some information about the packet.
~Ipv6OptionRouterAlertHeader() override
Destructor.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.
represents the alignment requirements of an option header