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