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