A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sixlowpan-nd-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Università di Firenze, Italy
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 *
7 *
8 * Author: Alessio Bonadio <alessio.bonadio@gmail.com>
9 * Tommaso Pecorella <tommaso.pecorella@unifi.it>
10 * Adnan Rashid <adnanrashidpk@gmail.com>
11 */
12
13#ifndef SIXLOWPAN_ND_HEADER_H
14#define SIXLOWPAN_ND_HEADER_H
15
16#include "ns3/header.h"
17#include "ns3/icmpv6-header.h"
18#include "ns3/ipv6-address.h"
19#include "ns3/mac64-address.h"
20
21#include <vector>
22
23namespace ns3
24{
25
26/**
27 * @ingroup sixlowpan
28 * @brief ICMPv6 Extended Duplicate Address Request or Confirmation header (see \RFC{8505}).
29 */
31{
32 public:
33 /**
34 * @brief Constructor.
35 */
37
38 /**
39 * @brief Constructor.
40 * @param request duplicate address request or duplicate address confirm
41 */
43
44 /**
45 * @brief Constructor (DAR).
46 * @param time the registration lifetime (units of 60 seconds)
47 * @param rovr the ROVR value.
48 * @param address the registered address
49 */
51 std::vector<uint8_t> rovr,
52 Ipv6Address address);
53
54 /**
55 * @brief Constructor (DAC).
56 * @param status the status (DAC)
57 * @param time the registration lifetime (units of 60 seconds)
58 * @param rovr the ROVR value.
59 * @param address the registered address
60 */
62 uint16_t time,
63 std::vector<uint8_t> rovr,
64 Ipv6Address address);
65
66 /**
67 * @brief Destructor.
68 */
70
71 /**
72 * @brief Get the UID of this class.
73 * @return UID
74 */
75 static TypeId GetTypeId();
76
77 /**
78 * @brief Get the instance type ID.
79 * @return instance type ID
80 */
81 TypeId GetInstanceTypeId() const override;
82
83 /**
84 * @brief Get the status field.
85 * @return status value
86 */
87 uint8_t GetStatus() const;
88
89 /**
90 * @brief Set the status field.
91 * @param status the status value
92 */
93 void SetStatus(uint8_t status);
94
95 /**
96 * @brief Get the transaction ID field.
97 * @return Transaction ID value
98 */
99 uint8_t GetTransaction_ID() const;
100
101 /**
102 * @brief Set the transaction ID field.
103 * @param tid the transaction ID value
104 */
105 void SetTransaction_ID(uint8_t tid);
106
107 /**
108 * @brief Get the registration lifetime field.
109 * @return registration lifetime value (units of 60 seconds)
110 */
111 uint16_t GetRegTime() const;
112
113 /**
114 * @brief Set the registration lifetime field.
115 * @param time the registration lifetime value (units of 60 seconds)
116 */
117 void SetRegTime(uint16_t time);
118
119 /**
120 * @brief Get the ROVR field.
121 * @return the ROVR
122 */
123 std::vector<uint8_t> GetRovr() const;
124
125 /**
126 * @brief Set the ROVR field.
127 * @param rovr the ROVR value
128 */
129 void SetRovr(const std::vector<uint8_t>& rovr);
130
131 /**
132 * @brief Get the registered address field.
133 * @return registered address value
134 */
136
137 /**
138 * @brief Set the registered address field.
139 * @param registered the registered address value
140 */
141 void SetRegAddress(Ipv6Address registered);
142
143 /**
144 * @brief Print information.
145 * @param os output stream
146 */
147 void Print(std::ostream& os) const override;
148
149 /**
150 * @brief Get the serialized size.
151 * @return serialized size
152 */
153 uint32_t GetSerializedSize() const override;
154
155 /**
156 * @brief Serialize the packet.
157 * @param start start offset
158 */
159 void Serialize(Buffer::Iterator start) const override;
160
161 /**
162 * @brief Deserialize the packet.
163 * @param start start offset
164 * @return length of packet
165 */
166 uint32_t Deserialize(Buffer::Iterator start) override;
167
168 private:
169 /**
170 * @brief The status value.
171 */
172 uint8_t m_status;
173
174 /**
175 * @brief The Transaction ID value.
176 */
177 uint16_t m_tid;
178
179 /**
180 * @brief The registration lifetime value (units of 60 seconds).
181 */
182 uint16_t m_regTime;
183 /**
184 * @brief The ROVR value.
185 */
186 std::vector<uint8_t> m_rovr;
187
188 /**
189 * @brief The registered address value.
190 */
192};
193
194/**
195 * @ingroup sixlowpan
196 * @brief ICMPv6 Extended Address Registration Option header \RFC{8505}.
197 *
198 @verbatim
199 0 1 2 3
200 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
201 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
202 | Type | Length | Status | Opaque |
203 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
204 | Rsvd | I |R|T| TID | Registration Lifetime |
205 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206 | |
207 ... Registration Ownership Verifier (ROVR) ...
208 | |
209 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
210 @endverbatim
211 */
213{
214 public:
215 /**
216 * @brief Constructor.
217 */
219
220 /**
221 * @brief Constructor.
222 * @param time the registration lifetime (units of 60 seconds)
223 * @param rovr the ROVR value
224 * @param tid the TID value
225 */
227 const std::vector<uint8_t>& rovr,
228 uint8_t tid);
229
230 /**
231 * @brief Constructor.
232 * @param status the status value
233 * @param time the registration lifetime (units of 60 seconds)
234 * @param rovr the ROVR value
235 * @param tid the TID value
236 */
238 uint16_t time,
239 const std::vector<uint8_t>& rovr,
240 uint8_t tid);
241
242 /**
243 * @brief Destructor.
244 */
246
247 /**
248 * @brief Get the UID of this class.
249 * @return UID
250 */
251 static TypeId GetTypeId();
252
253 /**
254 * @brief Get the instance type ID.
255 * @return instance type ID
256 */
257 TypeId GetInstanceTypeId() const override;
258
259 /**
260 * @brief Get the status field.
261 * @return status value
262 */
263 uint8_t GetStatus() const;
264
265 /**
266 * @brief Set the status field.
267 * @param status the status value
268 */
269 void SetStatus(uint8_t status);
270
271 /**
272 * @brief Get the opaque field.
273 * @return opaque value
274 */
275 uint8_t GetOpaque() const;
276
277 /**
278 * @brief Set the opaque field.
279 * @param opaque the opaque value
280 */
281 void SetOpaque(uint8_t opaque);
282
283 /**
284 * @brief Get the I-TwoBit field.
285 * @return I-TwoBit value
286 */
287 uint8_t GetI() const;
288
289 /**
290 * @brief Set the I-TwoBit field.
291 * @param twobits the TwoBit value
292 */
293 void SetI(uint8_t twobits);
294
295 /**
296 * @brief Get the R flag.
297 * @return R flag
298 */
299 bool GetFlagR() const;
300
301 /**
302 * @brief Set the R flag.
303 * @param r value
304 */
305 void SetFlagR(bool r);
306
307 /**
308 * @brief Get the transaction ID field.
309 * @return Transaction ID value
310 */
311 uint8_t GetTransactionId() const;
312
313 /**
314 * @brief Set the transaction ID field.
315 * @param tid the transaction ID value
316 */
317 void SetTransactionId(uint8_t tid);
318
319 /**
320 * @brief Get the registration lifetime field.
321 * @return registration lifetime value (units of 60 seconds)
322 */
323 uint16_t GetRegTime() const;
324
325 /**
326 * @brief Set the registration lifetime field.
327 * @param time the registration lifetime value (units of 60 seconds)
328 */
329 void SetRegTime(uint16_t time);
330
331 /**
332 * @brief Get the ROVR field.
333 * @return the ROVR
334 */
335 std::vector<uint8_t> GetRovr() const;
336
337 /**
338 * @brief Set the ROVR field.
339 * @param rovr the ROVR value
340 */
341 void SetRovr(const std::vector<uint8_t>& rovr);
342
343 /**
344 * @brief Print information.
345 * @param os output stream
346 */
347 void Print(std::ostream& os) const override;
348
349 /**
350 * @brief Get the serialized size.
351 * @return serialized size
352 */
353 uint32_t GetSerializedSize() const override;
354
355 /**
356 * @brief Serialize the packet.
357 * @param start start offset
358 */
359 void Serialize(Buffer::Iterator start) const override;
360
361 /**
362 * @brief Deserialize the packet.
363 * @param start start offset
364 * @return length of packet
365 */
366 uint32_t Deserialize(Buffer::Iterator start) override;
367
368 private:
369 /**
370 * @brief The status value.
371 */
372 uint8_t m_status;
373
374 /**
375 * @brief The opaque value.
376 */
377 uint8_t m_opaque;
378
379 /**
380 * @brief The I Two bit value.
381 */
382 uint8_t m_i;
383
384 /**
385 * @brief The R flag.
386 */
388
389 /**
390 * @brief The Transaction ID value.
391 */
392 uint16_t m_tid;
393
394 /**
395 * @brief The registration lifetime value (units of 60 seconds).
396 */
397 uint16_t m_regTime;
398
399 /**
400 * @brief The ROVR value.
401 */
402 std::vector<uint8_t> m_rovr;
403};
404
405/**
406 * @ingroup sixlowpan
407 * @brief ICMPv6 SixLowPan Context Option header (see \RFC{8505}).
408 */
410{
411 public:
412 /**
413 * @brief Constructor.
414 */
416
417 /**
418 * @brief Constructor.
419 * @param c the c flag
420 * @param cid the context identifier
421 * @param time the valid lifetime (units of 60 seconds)
422 * @param prefix the context prefix
423 */
424 Icmpv6OptionSixLowPanContext(bool c, uint8_t cid, uint16_t time, Ipv6Prefix prefix);
425
426 /**
427 * @brief Destructor.
428 */
430
431 /**
432 * @brief Get the UID of this class.
433 * @return UID
434 */
435 static TypeId GetTypeId();
436
437 /**
438 * @brief Get the instance type ID.
439 * @return instance type ID
440 */
441 TypeId GetInstanceTypeId() const override;
442
443 /**
444 * @brief Get the context length field.
445 * @return context length value
446 */
447 uint8_t GetContextLen() const;
448
449 /**
450 * @brief Is compression flag ?
451 * @return true if context is valid for use in compression, false otherwise
452 */
453 bool IsFlagC() const;
454
455 /**
456 * @brief Set the C flag.
457 * @param c the C flag
458 */
459 void SetFlagC(bool c);
460
461 /**
462 * @brief Get the context identifier field.
463 * @return context identifier value
464 */
465 uint8_t GetCid() const;
466
467 /**
468 * @brief Set the context identifier field.
469 * @param cid the context identifier value
470 */
471 void SetCid(uint8_t cid);
472
473 /**
474 * @brief Get the valid lifetime field.
475 * @return valid lifetime value (units of 60 seconds)
476 */
477 uint16_t GetValidTime() const;
478
479 /**
480 * @brief Set the valid lifetime field.
481 * @param time the valid lifetime value (units of 60 seconds)
482 */
483 void SetValidTime(uint16_t time);
484
485 /**
486 * @brief Get the context prefix field.
487 * @return context prefix value
488 */
490
491 /**
492 * @brief Set the context prefix field.
493 * @param prefix the context prefix value
494 */
495 void SetContextPrefix(Ipv6Prefix prefix);
496
497 /**
498 * @brief Print information.
499 * @param os output stream
500 */
501 void Print(std::ostream& os) const override;
502
503 /**
504 * @brief Get the serialized size.
505 * @return serialized size
506 */
507 uint32_t GetSerializedSize() const override;
508
509 /**
510 * @brief Serialize the packet.
511 * @param start start offset
512 */
513 void Serialize(Buffer::Iterator start) const override;
514
515 /**
516 * @brief Deserialize the packet.
517 * @param start start offset
518 * @return length of packet
519 */
520 uint32_t Deserialize(Buffer::Iterator start) override;
521
522 private:
523 /**
524 * @brief The context length value.
525 */
527
528 /**
529 * @brief The compression flag, indicates that this context is valid for use in compression.
530 */
531 bool m_c;
532
533 /**
534 * @brief The context identifier value.
535 */
536 uint8_t m_cid;
537
538 /**
539 * @brief The valid lifetime value (units of 60 seconds).
540 */
541 uint16_t m_validTime;
542
543 /**
544 * @brief The context prefix value.
545 */
547};
548
549/**
550 * @ingroup sixlowpan
551 * @brief ICMPv6 Authoritative Border Router Option header (see \RFC{8505}).
552 */
554{
555 public:
556 /**
557 * @brief Constructor.
558 */
560
561 /**
562 * @brief Constructor.
563 * @param version the version value
564 * @param time the valid lifetime (units of 60 seconds)
565 * @param address the 6LBR address
566 */
568 uint16_t time,
569 Ipv6Address address);
570
571 /**
572 * @brief Destructor.
573 */
575
576 /**
577 * @brief Get the UID of this class.
578 * @return UID
579 */
580 static TypeId GetTypeId();
581
582 /**
583 * @brief Get the instance type ID.
584 * @return instance type ID
585 */
586 TypeId GetInstanceTypeId() const override;
587
588 /**
589 * @brief Get the version field.
590 * @return version value
591 */
592 uint32_t GetVersion() const;
593
594 /**
595 * @brief Set the version field.
596 * @param version the version value
597 */
598 void SetVersion(uint32_t version);
599
600 /**
601 * @brief Get the valid lifetime field.
602 * @return valid lifetime value (units of 60 seconds)
603 */
604 uint16_t GetValidLifeTime() const;
605
606 /**
607 * @brief Set the valid lifetime field.
608 * @param time the valid lifetime value (units of 60 seconds)
609 */
610 void SetValidLifeTime(uint16_t time);
611
612 /**
613 * @brief Get the 6LBR address field.
614 * @return 6LBR address value
615 */
617
618 /**
619 * @brief Set the 6LBR address field.
620 * @param router the 6LBR address value
621 */
622 void SetRouterAddress(Ipv6Address router);
623
624 /**
625 * @brief Print information.
626 * @param os output stream
627 */
628 void Print(std::ostream& os) const override;
629
630 /**
631 * @brief Get the serialized size.
632 * @return serialized size
633 */
634 uint32_t GetSerializedSize() const override;
635
636 /**
637 * @brief Serialize the packet.
638 * @param start start offset
639 */
640 void Serialize(Buffer::Iterator start) const override;
641
642 /**
643 * @brief Deserialize the packet.
644 * @param start start offset
645 * @return length of packet
646 */
647 uint32_t Deserialize(Buffer::Iterator start) override;
648
649 private:
650 /**
651 * @brief The version value.
652 */
654
655 /**
656 * @brief The valid lifetime value (units of 60 seconds).
657 */
658 uint16_t m_validTime;
659
660 /**
661 * @brief The 6LBR address value.
662 */
664};
665
666} /* namespace ns3 */
667
668#endif /* SIXLOWPAN_ND_HEADER_H */
uint32_t r
iterator in a Buffer instance
Definition buffer.h:98
Icmpv6Header()
Constructor.
Icmpv6OptionHeader()
Constructor.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
Print information.
uint16_t m_validTime
The valid lifetime value (units of 60 seconds).
static TypeId GetTypeId()
Get the UID of this class.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetValidLifeTime(uint16_t time)
Set the valid lifetime field.
uint32_t GetVersion() const
Get the version field.
void SetVersion(uint32_t version)
Set the version field.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint16_t GetValidLifeTime() const
Get the valid lifetime field.
void SetRouterAddress(Ipv6Address router)
Set the 6LBR address field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Ipv6Address GetRouterAddress() const
Get the 6LBR address field.
uint8_t GetCid() const
Get the context identifier field.
bool m_c
The compression flag, indicates that this context is valid for use in compression.
Ipv6Prefix GetContextPrefix() const
Get the context prefix field.
void Print(std::ostream &os) const override
Print information.
uint8_t m_cid
The context identifier value.
void SetFlagC(bool c)
Set the C flag.
Ipv6Prefix m_prefix
The context prefix value.
void SetContextPrefix(Ipv6Prefix prefix)
Set the context prefix field.
uint8_t m_contextLen
The context length value.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
static TypeId GetTypeId()
Get the UID of this class.
uint8_t GetContextLen() const
Get the context length field.
void SetValidTime(uint16_t time)
Set the valid lifetime field.
uint16_t m_validTime
The valid lifetime value (units of 60 seconds).
void SetCid(uint8_t cid)
Set the context identifier field.
bool IsFlagC() const
Is compression flag ?
uint32_t GetSerializedSize() const override
Get the serialized size.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
~Icmpv6OptionSixLowPanContext() override
Destructor.
uint16_t GetValidTime() const
Get the valid lifetime field.
uint32_t GetSerializedSize() const override
Get the serialized size.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetStatus(uint8_t status)
Set the status field.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint8_t GetTransactionId() const
Get the transaction ID field.
uint16_t m_regTime
The registration lifetime value (units of 60 seconds).
void SetRovr(const std::vector< uint8_t > &rovr)
Set the ROVR field.
std::vector< uint8_t > GetRovr() const
Get the ROVR field.
uint16_t GetRegTime() const
Get the registration lifetime field.
void SetI(uint8_t twobits)
Set the I-TwoBit field.
void SetTransactionId(uint8_t tid)
Set the transaction ID field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetRegTime(uint16_t time)
Set the registration lifetime field.
void Print(std::ostream &os) const override
Print information.
void SetOpaque(uint8_t opaque)
Set the opaque field.
Ipv6Address m_regAddress
The registered address value.
uint16_t GetRegTime() const
Get the registration lifetime field.
void SetRegAddress(Ipv6Address registered)
Set the registered address field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Ipv6Address GetRegAddress() const
Get the registered address field.
uint8_t GetTransaction_ID() const
Get the transaction ID field.
void SetStatus(uint8_t status)
Set the status field.
void SetTransaction_ID(uint8_t tid)
Set the transaction ID field.
uint16_t m_regTime
The registration lifetime value (units of 60 seconds).
uint32_t GetSerializedSize() const override
Get the serialized size.
static TypeId GetTypeId()
Get the UID of this class.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetRovr(const std::vector< uint8_t > &rovr)
Set the ROVR field.
void SetRegTime(uint16_t time)
Set the registration lifetime field.
std::vector< uint8_t > GetRovr() const
Get the ROVR field.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Print(std::ostream &os) const override
Print information.
Describes an IPv6 address.
Describes an IPv6 prefix.
a unique identifier for an interface.
Definition type-id.h:50
Every class exported by the ns3 library is enclosed in the ns3 namespace.