A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
packetbb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 Drexel University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tom Wambold <tom5760@gmail.com>
7 */
8/* These classes implement RFC 5444 - The Generalized Mobile Ad Hoc Network
9 * (MANET) Packet/PbbMessage Format
10 * See: https://datatracker.ietf.org/doc/html/rfc5444 for details */
11
12#ifndef PACKETBB_H
13#define PACKETBB_H
14
15#include "ns3/address.h"
16#include "ns3/buffer.h"
17#include "ns3/header.h"
18#include "ns3/ptr.h"
19#include "ns3/simple-ref-count.h"
20
21#include <list>
22
23namespace ns3
24{
25
26/* Forward declare objects */
27class PbbMessage;
28class PbbAddressBlock;
29class PbbTlv;
30class PbbAddressTlv;
31
32/** Used in Messages to determine whether it contains IPv4 or IPv6 addresses */
34{
35 IPV4 = 3,
36 IPV6 = 15,
37};
38
39/**
40 * @brief A block of packet or message TLVs (PbbTlv).
41 *
42 * Acts similar to a C++ STL container. Should not be used for Address TLVs.
43 */
45{
46 public:
47 /// PbbTlv container iterator
48 typedef std::list<Ptr<PbbTlv>>::iterator Iterator;
49 /// PbbTlv container const iterator
50 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstIterator;
51
54
55 /**
56 * @return an iterator to the first TLV in this block.
57 */
59
60 /**
61 * @return a const iterator to the first TLV in this block.
62 */
63 ConstIterator Begin() const;
64
65 /**
66 * @return an iterator to the past-the-end element in this block.
67 */
68 Iterator End();
69
70 /**
71 * @return a const iterator to the past-the-end element in this block.
72 */
73 ConstIterator End() const;
74
75 /**
76 * @return the number of TLVs in this block.
77 */
78 int Size() const;
79
80 /**
81 * @return true if there are no TLVs in this block, false otherwise.
82 */
83 bool Empty() const;
84
85 /**
86 * @return a smart pointer to the first TLV in this block.
87 */
88 Ptr<PbbTlv> Front() const;
89
90 /**
91 * @return a smart pointer to the last TLV in this block.
92 */
93 Ptr<PbbTlv> Back() const;
94
95 /**
96 * @brief Prepends a TLV to the front of this block.
97 * @param tlv a smart pointer to the TLV to prepend.
98 */
99 void PushFront(Ptr<PbbTlv> tlv);
100
101 /**
102 * @brief Removes a TLV from the front of this block.
103 */
104 void PopFront();
105
106 /**
107 * @brief Appends a TLV to the back of this block.
108 * @param tlv a smart pointer to the TLV to append.
109 */
110 void PushBack(Ptr<PbbTlv> tlv);
111
112 /**
113 * @brief Removes a TLV from the back of this block.
114 */
115 void PopBack();
116
117 /**
118 * @brief Inserts a TLV at the specified position in this block.
119 * @param position an Iterator pointing to the position in this block to
120 * insert the TLV.
121 * @param tlv a smart pointer to the TLV to insert.
122 * @return An iterator pointing to the newly inserted TLV.
123 */
124 Iterator Insert(Iterator position, const Ptr<PbbTlv> tlv);
125
126 /**
127 * @brief Removes the TLV at the specified position.
128 * @param position an Iterator pointing to the TLV to erase.
129 * @return an iterator pointing to the next TLV in the block.
130 */
131 Iterator Erase(Iterator position);
132
133 /**
134 * @brief Removes all TLVs from [first, last) (includes first, not includes
135 * last).
136 * @param first an Iterator pointing to the first TLV to erase (inclusive).
137 * @param last an Iterator pointing to the element past the last TLV to erase.
138 * @return an iterator pointing to the next TLV in the block.
139 */
141
142 /**
143 * @brief Removes all TLVs from this block.
144 */
145 void Clear();
146
147 /**
148 * @return The size (in bytes) needed to serialize this block.
149 */
151
152 /**
153 * @brief Serializes this block into the specified buffer.
154 * @param start a reference to the point in a buffer to begin serializing.
155 *
156 * Users should not need to call this. Blocks will be serialized by their
157 * containing packet.
158 */
159 void Serialize(Buffer::Iterator& start) const;
160
161 /**
162 * @brief Deserializes a block from the specified buffer.
163 * @param start a reference to the point in a buffer to begin deserializing.
164 *
165 * Users should not need to call this. Blocks will be deserialized by their
166 * containing packet.
167 */
168 void Deserialize(Buffer::Iterator& start);
169
170 /**
171 * @brief Pretty-prints the contents of this block.
172 * @param os a stream object to print to.
173 */
174 void Print(std::ostream& os) const;
175
176 /**
177 * @brief Pretty-prints the contents of this block, with specified indentation.
178 * @param os a stream object to print to.
179 * @param level level of indentation.
180 *
181 * This probably never needs to be called by users. This is used when
182 * recursively printing sub-objects.
183 */
184 void Print(std::ostream& os, int level) const;
185
186 /**
187 * @brief Equality operator for PbbTlvBlock
188 * @param other PbbTlvBlock to compare this one to
189 * @returns true if the blocks are equal
190 */
191 bool operator==(const PbbTlvBlock& other) const;
192
193 private:
194 std::list<Ptr<PbbTlv>> m_tlvList; //!< PbbTlv container
195};
196
197/**
198 * @brief A block of Address TLVs (PbbAddressTlv).
199 *
200 * Acts similar to a C++ STL container.
201 */
203{
204 public:
205 /// PbbAddressTlv iterator for PbbAddressTlvBlock
206 typedef std::list<Ptr<PbbAddressTlv>>::iterator Iterator;
207 /// PbbAddressTlv const iterator for PbbAddressTlvBlock
208 typedef std::list<Ptr<PbbAddressTlv>>::const_iterator ConstIterator;
209
212
213 /**
214 * @return an iterator to the first Address TLV in this block.
215 */
216 Iterator Begin();
217
218 /**
219 * @return a const iterator to the first Address TLV in this block.
220 */
221 ConstIterator Begin() const;
222
223 /**
224 * @return an iterator to the past-the-end element in this block.
225 */
226 Iterator End();
227
228 /**
229 * @return a const iterator to the past-the-end element in this block.
230 */
231 ConstIterator End() const;
232
233 /**
234 * @return the number of Address TLVs in this block.
235 */
236 int Size() const;
237
238 /**
239 * @return true if there are no Address TLVs in this block, false otherwise.
240 */
241 bool Empty() const;
242
243 /**
244 * @return the first Address TLV in this block.
245 */
247
248 /**
249 * @return the last AddressTLV in this block.
250 */
251 Ptr<PbbAddressTlv> Back() const;
252
253 /**
254 * @brief Prepends an Address TLV to the front of this block.
255 * @param tlv a smart pointer to the Address TLV to prepend.
256 */
258
259 /**
260 * @brief Removes an AddressTLV from the front of this block.
261 */
262 void PopFront();
263
264 /**
265 * @brief Appends an Address TLV to the back of this block.
266 * @param tlv a smart pointer to the Address TLV to append.
267 */
269
270 /**
271 * @brief Removes an Address TLV from the back of this block.
272 */
273 void PopBack();
274
275 /**
276 * @brief Inserts an Address TLV at the specified position in this block.
277 * @param position an Iterator pointing to the position in this block to
278 * insert the Address TLV.
279 * @param tlv a smart pointer to the Address TLV to insert.
280 * @return An iterator pointing to the newly inserted Address TLV.
281 */
282 Iterator Insert(Iterator position, const Ptr<PbbAddressTlv> tlv);
283
284 /**
285 * @brief Removes the Address TLV at the specified position.
286 * @param position an Iterator pointing to the Address TLV to erase.
287 * @return an iterator pointing to the next Address TLV in the block.
288 */
289 Iterator Erase(Iterator position);
290
291 /**
292 * @brief Removes all Address TLVs from [first, last) (includes first, not
293 * includes last).
294 * @param first an Iterator pointing to the first Address TLV to erase
295 * (inclusive).
296 * @param last an Iterator pointing to the element past the last Address TLV
297 * to erase.
298 * @return an iterator pointing to the next Address TLV in the block.
299 */
301
302 /**
303 * @brief Removes all Address TLVs from this block.
304 */
305 void Clear();
306
307 /**
308 * @return The size (in bytes) needed to serialize this block.
309 */
311
312 /**
313 * @brief Serializes this block into the specified buffer.
314 * @param start a reference to the point in a buffer to begin serializing.
315 *
316 * Users should not need to call this. Blocks will be serialized by their
317 * containing packet.
318 */
319 void Serialize(Buffer::Iterator& start) const;
320
321 /**
322 * @brief Deserializes a block from the specified buffer.
323 * @param start a reference to the point in a buffer to begin deserializing.
324 *
325 * Users should not need to call this. Blocks will be deserialized by their
326 * containing packet.
327 */
328 void Deserialize(Buffer::Iterator& start);
329
330 /**
331 * @brief Pretty-prints the contents of this block.
332 * @param os a stream object to print to.
333 */
334 void Print(std::ostream& os) const;
335
336 /**
337 * @brief Pretty-prints the contents of this block, with specified indentation.
338 * @param os a stream object to print to.
339 * @param level level of indentation.
340 *
341 * This probably never needs to be called by users. This is used when
342 * recursively printing sub-objects.
343 */
344 void Print(std::ostream& os, int level) const;
345
346 /**
347 * @brief Equality operator for PbbAddressTlvBlock
348 * @param other PbbAddressTlvBlock to compare to this one
349 * @returns true if PbbAddressTlvBlock are equal
350 */
351 bool operator==(const PbbAddressTlvBlock& other) const;
352
353 private:
354 std::list<Ptr<PbbAddressTlv>> m_tlvList; //!< PbbAddressTlv container
355};
356
357/**
358 * @brief Main PacketBB Packet object.
359 *
360 * A PacketBB packet is made up of zero or more packet TLVs (PbbTlv), and zero
361 * or more messages (PbbMessage).
362 *
363 * See: \RFC{5444} for details.
364 */
365class PbbPacket : public SimpleRefCount<PbbPacket, Header>
366{
367 public:
368 /// PbbTlv iterator for PbbPacket
369 typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
370 /// PbbTlv const iterator for PbbPacket
371 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
372 /// PbbMessage Iterator for PbbPacket
373 typedef std::list<Ptr<PbbMessage>>::iterator MessageIterator;
374 /// PbbMessage Const Iterator for PbbPacket
375 typedef std::list<Ptr<PbbMessage>>::const_iterator ConstMessageIterator;
376
377 PbbPacket();
378 ~PbbPacket() override;
379
380 /**
381 * @return the version of PacketBB that constructed this packet.
382 *
383 * This will always return 0 for packets constructed using this API.
384 */
385 uint8_t GetVersion() const;
386
387 /**
388 * @brief Sets the sequence number of this packet.
389 * @param number the sequence number.
390 */
391 void SetSequenceNumber(uint16_t number);
392
393 /**
394 * @return the sequence number of this packet.
395 *
396 * Calling this while HasSequenceNumber is False is undefined. Make sure you
397 * check it first. This will be checked by an assert in debug builds.
398 */
399 uint16_t GetSequenceNumber() const;
400
401 /**
402 * @brief Tests whether or not this packet has a sequence number.
403 * @return true if this packet has a sequence number, false otherwise.
404 *
405 * This should be called before calling GetSequenceNumber to make sure there
406 * actually is one.
407 */
408 bool HasSequenceNumber() const;
409
410 /**
411 * @brief Forces a packet to write a TLV list even if it's empty, ignoring
412 * the phastlv bit.
413 *
414 * This is mainly used to check the Deserialization of a questionable
415 * but correct packet (see test 3).
416 *
417 * @param forceTlv true will force TLV to be written even if no TLV is set.
418 */
419 void ForceTlv(bool forceTlv);
420
421 /* Manipulating Packet TLVs */
422
423 /**
424 * @return an iterator to the first Packet TLV in this packet.
425 */
427
428 /**
429 * @return a const iterator to the first Packet TLV in this packet.
430 */
432
433 /**
434 * @return an iterator to the past-the-end element in this packet TLV block.
435 */
437
438 /**
439 * @return a const iterator to the past-the-end element in this packet TLV
440 * block.
441 */
442 ConstTlvIterator TlvEnd() const;
443
444 /**
445 * @return the number of packet TLVs in this packet.
446 */
447 int TlvSize() const;
448
449 /**
450 * @return true if there are no packet TLVs in this packet, false otherwise.
451 */
452 bool TlvEmpty() const;
453
454 /**
455 * @return a smart pointer to the first packet TLV in this packet.
456 */
458
459 /**
460 * @return a const smart pointer to the first packet TLV in this packet.
461 */
462 const Ptr<PbbTlv> TlvFront() const;
463
464 /**
465 * @return a smart pointer to the last packet TLV in this packet.
466 */
468
469 /**
470 * @return a const smart pointer to the last packet TLV in this packet.
471 */
472 const Ptr<PbbTlv> TlvBack() const;
473
474 /**
475 * @brief Prepends a packet TLV to the front of this packet.
476 * @param tlv a smart pointer to the packet TLV to prepend.
477 */
478 void TlvPushFront(Ptr<PbbTlv> tlv);
479
480 /**
481 * @brief Removes a packet TLV from the front of this packet.
482 */
483 void TlvPopFront();
484
485 /**
486 * @brief Appends a packet TLV to the back of this packet.
487 * @param tlv a smart pointer to the packet TLV to append.
488 */
489 void TlvPushBack(Ptr<PbbTlv> tlv);
490
491 /**
492 * @brief Removes a packet TLV from the back of this block.
493 */
494 void TlvPopBack();
495
496 /**
497 * @brief Removes the packet TLV at the specified position.
498 * @param position an Iterator pointing to the packet TLV to erase.
499 * @return an iterator pointing to the next packet TLV in the block.
500 */
501 TlvIterator Erase(TlvIterator position);
502
503 /**
504 * @brief Removes all packet TLVs from [first, last) (includes first, not
505 * includes last).
506 * @param first an Iterator pointing to the first packet TLV to erase
507 * (inclusive).
508 * @param last an Iterator pointing to the element past the last packet TLV
509 * to erase.
510 * @return an iterator pointing to the next packet TLV in the block.
511 */
513
514 /**
515 * @brief Removes all packet TLVs from this packet.
516 */
517 void TlvClear();
518
519 /* Manipulating Packet Messages */
520
521 /**
522 * @return an iterator to the first message in this packet.
523 */
525
526 /**
527 * @return a const iterator to the first message in this packet.
528 */
530
531 /**
532 * @return an iterator to the past-the-end element in this message block.
533 */
535
536 /**
537 * @return a const iterator to the past-the-end element in this message
538 * block.
539 */
541
542 /**
543 * @return the number of messages in this packet.
544 */
545 int MessageSize() const;
546
547 /**
548 * @return true if there are no messages in this packet, false otherwise.
549 */
550 bool MessageEmpty() const;
551
552 /**
553 * @return a smart pointer to the first message in this packet.
554 */
556
557 /**
558 * @return a const smart pointer to the first message in this packet.
559 */
560 const Ptr<PbbMessage> MessageFront() const;
561
562 /**
563 * @return a smart pointer to the last message in this packet.
564 */
566
567 /**
568 * @return a const smart pointer to the last message in this packet.
569 */
570 const Ptr<PbbMessage> MessageBack() const;
571
572 /**
573 * @brief Prepends a message to the front of this packet.
574 * @param message a smart pointer to the message to prepend.
575 */
576 void MessagePushFront(Ptr<PbbMessage> message);
577
578 /**
579 * @brief Removes a message from the front of this packet.
580 */
581 void MessagePopFront();
582
583 /**
584 * @brief Appends a message to the back of this packet.
585 * @param message a smart pointer to the message to append.
586 */
587 void MessagePushBack(Ptr<PbbMessage> message);
588
589 /**
590 * @brief Removes a message from the back of this packet.
591 */
592 void MessagePopBack();
593
594 /**
595 * @brief Removes the message at the specified position.
596 * @param position an Iterator pointing to the message to erase.
597 * @return an iterator pointing to the next message in the packet.
598 */
600
601 /**
602 * @brief Removes all messages from [first, last) (includes first, not
603 * includes last).
604 * @param first an Iterator pointing to the first message to erase (inclusive).
605 * @param last an Iterator pointing to the element past the last message to erase.
606 * @return an iterator pointing to the next message in the block.
607 */
609
610 /**
611 * @brief Removes all messages from this packet.
612 */
613 void MessageClear();
614
615 /**
616 * @brief Get the type ID.
617 * @return the object TypeId
618 */
619 static TypeId GetTypeId();
620 TypeId GetInstanceTypeId() const override;
621
622 /**
623 * @return The size (in bytes) needed to serialize this packet.
624 */
625 uint32_t GetSerializedSize() const override;
626
627 /**
628 * @brief Serializes this packet into the specified buffer.
629 * @param start a reference to the point in a buffer to begin serializing.
630 */
631 void Serialize(Buffer::Iterator start) const override;
632
633 /**
634 * @brief Deserializes a packet from the specified buffer.
635 * @param start start offset
636 * @return the number of bytes deserialized
637 *
638 * If this returns a number smaller than the total number of bytes in the
639 * buffer, there was an error.
640 */
641 uint32_t Deserialize(Buffer::Iterator start) override;
642
643 /**
644 * @brief Pretty-prints the contents of this block.
645 * @param os a stream object to print to.
646 */
647 void Print(std::ostream& os) const override;
648
649 /**
650 * @brief Equality operator for PbbPacket
651 * @param other PbbPacket to compare to this one
652 * @returns true if PbbPacket are equal
653 */
654 bool operator==(const PbbPacket& other) const;
655
656 private:
657 PbbTlvBlock m_tlvList; //!< PbbTlv container
658 std::list<Ptr<PbbMessage>> m_messageList; //!< PbbTlvBlock container
659
660 uint8_t m_version; //!< version
661
662 bool m_hasseqnum; //!< Sequence number present
663 uint16_t m_seqnum; //!< Sequence number
664 bool m_forceTlv; //!< Force writing a TLV list (even if it's empty)
665};
666
667/**
668 * @brief A message within a PbbPacket packet.
669 *
670 * There may be any number of messages in one packet packet. This is a pure
671 * virtual base class, when creating a message, you should instantiate either
672 * PbbMessageIpv4 or PbbMessageIpv6.
673 */
674class PbbMessage : public SimpleRefCount<PbbMessage>
675{
676 public:
677 /// PbbTlv iterator
678 typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
679 /// PbbTlv const iterator
680 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
681 /// PbbAddressBlock iterator
682 typedef std::list<Ptr<PbbAddressBlock>>::iterator AddressBlockIterator;
683 /// PbbAddressBlock const iterator
684 typedef std::list<Ptr<PbbAddressBlock>>::const_iterator ConstAddressBlockIterator;
685
686 PbbMessage();
687 virtual ~PbbMessage();
688
689 /**
690 * @brief Sets the type for this message.
691 * @param type the type to set.
692 */
693 void SetType(uint8_t type);
694
695 /**
696 * @return the type assigned to this packet
697 */
698 uint8_t GetType() const;
699
700 /**
701 * @brief Sets the address for the node that created this packet.
702 * @param address the originator address.
703 */
704 void SetOriginatorAddress(Address address);
705
706 /**
707 * @return the address of the node that created this packet.
708 *
709 * Calling this while HasOriginatorAddress is False is undefined. Make sure
710 * you check it first. This will be checked by an assert in debug builds.
711 */
713
714 /**
715 * @brief Tests whether or not this message has an originator address.
716 * @return true if this message has an originator address, false otherwise.
717 */
718 bool HasOriginatorAddress() const;
719
720 /**
721 * @brief Sets the maximum number of hops this message should travel
722 * @param hoplimit the limit to set
723 */
724 void SetHopLimit(uint8_t hoplimit);
725
726 /**
727 * @return the maximum number of hops this message should travel.
728 *
729 * Calling this while HasHopLimit is False is undefined. Make sure you check
730 * it first. This will be checked by an assert in debug builds.
731 */
732 uint8_t GetHopLimit() const;
733
734 /**
735 * @brief Tests whether or not this message has a hop limit.
736 * @return true if this message has a hop limit, false otherwise.
737 *
738 * If this is set, messages should not hop further than this limit.
739 */
740 bool HasHopLimit() const;
741
742 /**
743 * @brief Sets the current number of hops this message has traveled.
744 * @param hopcount the current number of hops
745 */
746 void SetHopCount(uint8_t hopcount);
747
748 /**
749 * @return the current number of hops this message has traveled.
750 *
751 * Calling this while HasHopCount is False is undefined. Make sure you check
752 * it first. This will be checked by an assert in debug builds.
753 */
754 uint8_t GetHopCount() const;
755
756 /**
757 * @brief Tests whether or not this message has a hop count.
758 * @return true if this message has a hop limit, false otherwise.
759 */
760 bool HasHopCount() const;
761
762 /**
763 * @brief Sets the sequence number of this message.
764 * @param seqnum the sequence number to set.
765 */
766 void SetSequenceNumber(uint16_t seqnum);
767
768 /**
769 * @return the sequence number of this message.
770 *
771 * Calling this while HasSequenceNumber is False is undefined. Make sure you
772 * check it first. This will be checked by an assert in debug builds.
773 */
774 uint16_t GetSequenceNumber() const;
775
776 /**
777 * @brief Tests whether or not this message has a sequence number.
778 * @return true if this message has a sequence number, false otherwise.
779 */
780 bool HasSequenceNumber() const;
781
782 /* Manipulating PbbMessage TLVs */
783
784 /**
785 * @return an iterator to the first message TLV in this message.
786 */
788
789 /**
790 * @return a const iterator to the first message TLV in this message.
791 */
793
794 /**
795 * @return an iterator to the past-the-end message TLV element in this
796 * message.
797 */
799
800 /**
801 * @return a const iterator to the past-the-end message TLV element in this
802 * message.
803 */
804 ConstTlvIterator TlvEnd() const;
805
806 /**
807 * @return the number of message TLVs in this message.
808 */
809 int TlvSize() const;
810
811 /**
812 * @return true if there are no message TLVs in this message, false otherwise.
813 */
814 bool TlvEmpty() const;
815
816 /**
817 * @return a smart pointer to the first message TLV in this message.
818 */
820
821 /**
822 * @return a const smart pointer to the first message TLV in this message.
823 */
824 const Ptr<PbbTlv> TlvFront() const;
825
826 /**
827 * @return a smart pointer to the last message TLV in this message.
828 */
830
831 /**
832 * @return a const smart pointer to the last message TLV in this message.
833 */
834 const Ptr<PbbTlv> TlvBack() const;
835
836 /**
837 * @brief Prepends a message TLV to the front of this message.
838 * @param tlv a smart pointer to the message TLV to prepend.
839 */
840 void TlvPushFront(Ptr<PbbTlv> tlv);
841
842 /**
843 * @brief Removes a message TLV from the front of this message.
844 */
845 void TlvPopFront();
846
847 /**
848 * @brief Appends a message TLV to the back of this message.
849 * @param tlv a smart pointer to the message TLV to append.
850 */
851 void TlvPushBack(Ptr<PbbTlv> tlv);
852
853 /**
854 * @brief Removes a message TLV from the back of this message.
855 */
856 void TlvPopBack();
857
858 /**
859 * @brief Removes the message TLV at the specified position.
860 * @param position an Iterator pointing to the message TLV to erase.
861 * @return an iterator pointing to the next TLV in the block.
862 */
864
865 /**
866 * @brief Removes all message TLVs from [first, last) (includes first, not
867 * includes last).
868 * @param first an Iterator pointing to the first message TLV to erase
869 * (inclusive).
870 * @param last an Iterator pointing to the element past the last message TLV
871 * to erase.
872 * @return an iterator pointing to the next message TLV in the message.
873 */
875
876 /**
877 * @brief Removes all message TLVs from this block.
878 */
879 void TlvClear();
880
881 /* Manipulating Address Block and Address TLV pairs */
882
883 /**
884 * @return an iterator to the first address block in this message.
885 */
887
888 /**
889 * @return a const iterator to the first address block in this message.
890 */
892
893 /**
894 * @return an iterator to the past-the-end address block element in this
895 * message.
896 */
898
899 /**
900 * @return a const iterator to the past-the-end address block element in this
901 * message.
902 */
904
905 /**
906 * @return the number of address blocks in this message.
907 */
908 int AddressBlockSize() const;
909
910 /**
911 * @return true if there are no address blocks in this message, false
912 * otherwise.
913 */
914 bool AddressBlockEmpty() const;
915
916 /**
917 * @return a smart pointer to the first address block in this message.
918 */
920
921 /**
922 * @return a const smart pointer to the first address block in this message.
923 */
925
926 /**
927 * @return a smart pointer to the last address block in this message.
928 */
930
931 /**
932 * @return a const smart pointer to the last address block in this message.
933 */
935
936 /**
937 * @brief Prepends an address block to the front of this message.
938 * @param block a smart pointer to the address block to prepend.
939 */
941
942 /**
943 * @brief Removes an address block from the front of this message.
944 */
946
947 /**
948 * @brief Appends an address block to the front of this message.
949 * @param block a smart pointer to the address block to append.
950 */
952
953 /**
954 * @brief Removes an address block from the back of this message.
955 */
956 void AddressBlockPopBack();
957
958 /**
959 * @brief Removes the address block at the specified position.
960 * @param position an Iterator pointing to the address block to erase.
961 * @return an iterator pointing to the next address block in the message.
962 */
964
965 /**
966 * @brief Removes all address blocks from [first, last) (includes first, not
967 * includes last).
968 * @param first an Iterator pointing to the first address block to erase
969 * (inclusive).
970 * @param last an Iterator pointing to the element past the last address
971 * block to erase.
972 * @return an iterator pointing to the next address block in the message.
973 */
975
976 /**
977 * @brief Removes all address blocks from this message.
978 */
979 void AddressBlockClear();
980
981 /**
982 * @brief Deserializes a message, returning the correct object depending on
983 * whether it is an IPv4 message or an IPv6 message.
984 * @param start a reference to the point in a buffer to begin deserializing.
985 * @return A pointer to the deserialized message, or 0 on error.
986 *
987 * Users should not need to call this. Blocks will be deserialized by their
988 * containing packet.
989 */
991
992 /**
993 * @return The size (in bytes) needed to serialize this message.
994 */
996
997 /**
998 * @brief Serializes this message into the specified buffer.
999 * @param start a reference to the point in a buffer to begin serializing.
1000 *
1001 * Users should not need to call this. Blocks will be deserialized by their
1002 * containing packet.
1003 */
1004 void Serialize(Buffer::Iterator& start) const;
1005
1006 /**
1007 * @brief Deserializes a message from the specified buffer.
1008 * @param start a reference to the point in a buffer to begin deserializing.
1009 *
1010 * Users should not need to call this. Blocks will be deserialized by their
1011 * containing packet.
1012 */
1013 void Deserialize(Buffer::Iterator& start);
1014
1015 /**
1016 * @brief Pretty-prints the contents of this message.
1017 * @param os a stream object to print to.
1018 */
1019 void Print(std::ostream& os) const;
1020
1021 /**
1022 * @brief Pretty-prints the contents of this message, with specified
1023 * indentation.
1024 * @param os a stream object to print to.
1025 * @param level level of indentation.
1026 *
1027 * This probably never needs to be called by users. This is used when
1028 * recursively printing sub-objects.
1029 */
1030 void Print(std::ostream& os, int level) const;
1031
1032 /**
1033 * @brief Equality operator for PbbMessage
1034 * @param other PbbMessage to compare to this one
1035 * @returns true if PbbMessages are equal
1036 */
1037 bool operator==(const PbbMessage& other) const;
1038
1039 protected:
1040 /**
1041 * @brief Returns address length (IPV4 3 or IPV6 15)
1042 *
1043 * Returns message size in bytes - 1
1044 * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
1045 *
1046 * @returns Address length (IPV4 3 or IPV6 15)
1047 */
1048 virtual PbbAddressLength GetAddressLength() const = 0;
1049
1050 /**
1051 * @brief Serialize the originator address
1052 * @param start the buffer iterator start
1053 */
1054 virtual void SerializeOriginatorAddress(Buffer::Iterator& start) const = 0;
1055 /**
1056 * @brief Deserialize the originator address
1057 * @param start the buffer iterator start
1058 * @returns the deserialized address
1059 */
1061 /**
1062 * @brief Print the originator address
1063 * @param os the output stream
1064 */
1065 virtual void PrintOriginatorAddress(std::ostream& os) const = 0;
1066
1067 /**
1068 * @brief Deserialize an address block
1069 * @param start the buffer iterator start
1070 * @returns the deserialized address block
1071 */
1073
1074 private:
1075 PbbTlvBlock m_tlvList; //!< PbbTlvBlock
1076 std::list<Ptr<PbbAddressBlock>> m_addressBlockList; //!< PbbAddressBlock container
1077
1078 uint8_t m_type; //!< the type for this message
1079 PbbAddressLength m_addrSize; //!< the address size
1080
1081 bool m_hasOriginatorAddress; //!< Originator address present
1082 Address m_originatorAddress; //!< originator address
1083
1084 bool m_hasHopLimit; //!< Hop limit present
1085 uint8_t m_hopLimit; //!< Hop limit
1086
1087 bool m_hasHopCount; //!< Hop count present
1088 uint8_t m_hopCount; //!< Hop count
1089
1090 bool m_hasSequenceNumber; //!< Sequence number present
1091 uint16_t m_sequenceNumber; //!< Sequence number
1092};
1093
1094/**
1095 * @brief Concrete IPv4 specific PbbMessage.
1096 *
1097 * This message will only contain IPv4 addresses.
1098 */
1100{
1101 public:
1103
1104 protected:
1105 /**
1106 * @brief Returns address length (IPV4 3 or IPV6 15)
1107 *
1108 * Returns message size in bytes - 1
1109 * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
1110 *
1111 * @returns Address length (IPV4 3 or IPV6 15)
1112 */
1113 PbbAddressLength GetAddressLength() const override;
1114
1115 void SerializeOriginatorAddress(Buffer::Iterator& start) const override;
1117 void PrintOriginatorAddress(std::ostream& os) const override;
1118
1120};
1121
1122/**
1123 * @brief Concrete IPv6 specific PbbMessage class.
1124 *
1125 * This message will only contain IPv6 addresses.
1126 */
1128{
1129 public:
1131
1132 protected:
1133 /**
1134 * @brief Returns address length (IPV4 3 or IPV6 15)
1135 *
1136 * Returns message size in bytes - 1
1137 * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
1138 *
1139 * @returns Address length (IPV4 3 or IPV6 15)
1140 */
1141 PbbAddressLength GetAddressLength() const override;
1142
1143 void SerializeOriginatorAddress(Buffer::Iterator& start) const override;
1145 void PrintOriginatorAddress(std::ostream& os) const override;
1146
1148};
1149
1150/**
1151 * @brief An Address Block and its associated Address TLV Blocks.
1152 *
1153 * This is a pure virtual base class, when creating address blocks, you should
1154 * instantiate either PbbAddressBlockIpv4 or PbbAddressBlockIpv6.
1155 */
1156class PbbAddressBlock : public SimpleRefCount<PbbAddressBlock>
1157{
1158 public:
1159 /// Address iterator
1160 typedef std::list<Address>::iterator AddressIterator;
1161 /// Address const iterator
1162 typedef std::list<Address>::const_iterator ConstAddressIterator;
1163
1164 /// Prefix iterator
1165 typedef std::list<uint8_t>::iterator PrefixIterator;
1166 /// Prefix const iterator
1167 typedef std::list<uint8_t>::const_iterator ConstPrefixIterator;
1168
1169 /// tlvblock iterator
1171 /// tlvblock const iterator
1173
1175 virtual ~PbbAddressBlock();
1176
1177 /* Manipulating the address block */
1178
1179 /**
1180 * @return an iterator to the first address in this block.
1181 */
1183
1184 /**
1185 * @return a const iterator to the first address in this block.
1186 */
1188
1189 /**
1190 * @return an iterator to the last address in this block.
1191 */
1193
1194 /**
1195 * @return a const iterator to the last address in this block.
1196 */
1198
1199 /**
1200 * @return the number of addresses in this block.
1201 */
1202 int AddressSize() const;
1203
1204 /**
1205 * @return true if there are no addresses in this block, false otherwise.
1206 */
1207 bool AddressEmpty() const;
1208
1209 /**
1210 * @return the first address in this block.
1211 */
1212 Address AddressFront() const;
1213
1214 /**
1215 * @return the last address in this block.
1216 */
1217 Address AddressBack() const;
1218
1219 /**
1220 * @brief Prepends an address to the front of this block.
1221 * @param address the address to prepend.
1222 */
1223 void AddressPushFront(Address address);
1224
1225 /**
1226 * @brief Removes an address from the front of this block.
1227 */
1228 void AddressPopFront();
1229
1230 /**
1231 * @brief Appends an address to the back of this block.
1232 * @param address the address to append.
1233 */
1234 void AddressPushBack(Address address);
1235
1236 /**
1237 * @brief Removes an address from the back of this block.
1238 */
1239 void AddressPopBack();
1240
1241 /**
1242 * @brief Inserts an address at the specified position in this block.
1243 * @param position an Iterator pointing to the position in this block to
1244 * insert the address.
1245 * @param value the address to insert.
1246 * @return An iterator pointing to the newly inserted address.
1247 */
1249
1250 /**
1251 * @brief Removes the address at the specified position.
1252 * @param position an Iterator pointing to the address to erase.
1253 * @return an iterator pointing to the next address in the block.
1254 */
1256
1257 /**
1258 * @brief Removes all addresses from [first, last) (includes first, not
1259 * includes last).
1260 * @param first an Iterator pointing to the first address to erase
1261 * (inclusive).
1262 * @param last an Iterator pointing to the element past the last address to
1263 * erase.
1264 * @return an iterator pointing to the next address in the block.
1265 */
1267
1268 /**
1269 * @brief Removes all addresses from this block.
1270 */
1271 void AddressClear();
1272
1273 /* Prefix methods */
1274
1275 /**
1276 * @return an iterator to the first prefix in this block.
1277 */
1279
1280 /**
1281 * @return a const iterator to the first prefix in this block.
1282 */
1284
1285 /**
1286 * @return an iterator to the last prefix in this block.
1287 */
1289
1290 /**
1291 * @return a const iterator to the last prefix in this block.
1292 */
1294
1295 /**
1296 * @return the number of prefixes in this block.
1297 */
1298 int PrefixSize() const;
1299
1300 /**
1301 * @return true if there are no prefixes in this block, false otherwise.
1302 */
1303 bool PrefixEmpty() const;
1304
1305 /**
1306 * @return the first prefix in this block.
1307 */
1308 uint8_t PrefixFront() const;
1309
1310 /**
1311 * @return the last prefix in this block.
1312 */
1313 uint8_t PrefixBack() const;
1314
1315 /**
1316 * @brief Prepends a prefix to the front of this block.
1317 * @param prefix the prefix to prepend.
1318 */
1319 void PrefixPushFront(uint8_t prefix);
1320
1321 /**
1322 * @brief Removes a prefix from the front of this block.
1323 */
1324 void PrefixPopFront();
1325
1326 /**
1327 * @brief Appends a prefix to the back of this block.
1328 * @param prefix the prefix to append.
1329 */
1330 void PrefixPushBack(uint8_t prefix);
1331
1332 /**
1333 * @brief Removes a prefix from the back of this block.
1334 */
1335 void PrefixPopBack();
1336
1337 /**
1338 * @brief Inserts a prefix at the specified position in this block.
1339 * @param position an Iterator pointing to the position in this block to
1340 * insert the prefix.
1341 * @param value the prefix to insert.
1342 * @return An iterator pointing to the newly inserted prefix.
1343 */
1344 PrefixIterator PrefixInsert(PrefixIterator position, const uint8_t value);
1345
1346 /**
1347 * @brief Removes the prefix at the specified position.
1348 * @param position an Iterator pointing to the prefix to erase.
1349 * @return an iterator pointing to the next prefix in the block.
1350 */
1352
1353 /**
1354 * @brief Removes all prefixes from [first, last) (includes first, not
1355 * includes last).
1356 * @param first an Iterator pointing to the first prefix to erase
1357 * (inclusive).
1358 * @param last an Iterator pointing to the element past the last prefix to
1359 * erase.
1360 * @return an iterator pointing to the next prefix in the block.
1361 */
1363
1364 /**
1365 * @brief Removes all prefixes from this block.
1366 */
1367 void PrefixClear();
1368
1369 /* Manipulating the TLV block */
1370
1371 /**
1372 * @return an iterator to the first address TLV in this block.
1373 */
1375
1376 /**
1377 * @return a const iterator to the first address TLV in this block.
1378 */
1379 ConstTlvIterator TlvBegin() const;
1380
1381 /**
1382 * @return an iterator to the last address TLV in this block.
1383 */
1385
1386 /**
1387 * @return a const iterator to the last address TLV in this block.
1388 */
1389 ConstTlvIterator TlvEnd() const;
1390
1391 /**
1392 * @return the number of address TLVs in this block.
1393 */
1394 int TlvSize() const;
1395
1396 /**
1397 * @return true if there are no address TLVs in this block, false otherwise.
1398 */
1399 bool TlvEmpty() const;
1400
1401 /**
1402 * @return a smart pointer to the first address TLV in this block.
1403 */
1405
1406 /**
1407 * @return a const smart pointer to the first address TLV in this message.
1408 */
1409 const Ptr<PbbAddressTlv> TlvFront() const;
1410
1411 /**
1412 * @return a smart pointer to the last address TLV in this message.
1413 */
1415
1416 /**
1417 * @return a const smart pointer to the last address TLV in this message.
1418 */
1419 const Ptr<PbbAddressTlv> TlvBack() const;
1420
1421 /**
1422 * @brief Prepends an address TLV to the front of this message.
1423 * @param address a smart pointer to the address TLV to prepend.
1424 */
1425 void TlvPushFront(Ptr<PbbAddressTlv> address);
1426
1427 /**
1428 * @brief Removes an address TLV from the front of this message.
1429 */
1430 void TlvPopFront();
1431
1432 /**
1433 * @brief Appends an address TLV to the back of this message.
1434 * @param address a smart pointer to the address TLV to append.
1435 */
1436 void TlvPushBack(Ptr<PbbAddressTlv> address);
1437
1438 /**
1439 * @brief Removes an address TLV from the back of this message.
1440 */
1441 void TlvPopBack();
1442
1443 /**
1444 * @brief Inserts an address TLV at the specified position in this block.
1445 * @param position an Iterator pointing to the position in this block to
1446 * insert the address TLV.
1447 * @param value the prefix to insert.
1448 * @return An iterator pointing to the newly inserted address TLV.
1449 */
1451
1452 /**
1453 * @brief Removes the address TLV at the specified position.
1454 * @param position an Iterator pointing to the address TLV to erase.
1455 * @return an iterator pointing to the next address TLV in the block.
1456 */
1458
1459 /**
1460 * @brief Removes all address TLVs from [first, last) (includes first, not
1461 * includes last).
1462 * @param first an Iterator pointing to the first address TLV to erase
1463 * (inclusive).
1464 * @param last an Iterator pointing to the element past the last address TLV
1465 * to erase.
1466 * @return an iterator pointing to the next address TLV in the message.
1467 */
1469
1470 /**
1471 * @brief Removes all address TLVs from this block.
1472 */
1473 void TlvClear();
1474
1475 /**
1476 * @return The size (in bytes) needed to serialize this address block.
1477 */
1479
1480 /**
1481 * @brief Serializes this address block into the specified buffer.
1482 * @param start a reference to the point in a buffer to begin serializing.
1483 *
1484 * Users should not need to call this. Blocks will be deserialized by their
1485 * containing packet.
1486 */
1487 void Serialize(Buffer::Iterator& start) const;
1488
1489 /**
1490 * @brief Deserializes an address block from the specified buffer.
1491 * @param start a reference to the point in a buffer to begin deserializing.
1492 *
1493 * Users should not need to call this. Blocks will be deserialized by their
1494 * containing packet.
1495 */
1496 void Deserialize(Buffer::Iterator& start);
1497
1498 /**
1499 * @brief Pretty-prints the contents of this address block.
1500 * @param os a stream object to print to.
1501 */
1502 void Print(std::ostream& os) const;
1503
1504 /**
1505 * @brief Pretty-prints the contents of this address block, with specified
1506 * indentation.
1507 * @param os a stream object to print to.
1508 * @param level level of indentation.
1509 *
1510 * This probably never needs to be called by users. This is used when
1511 * recursively printing sub-objects.
1512 */
1513 void Print(std::ostream& os, int level) const;
1514
1515 /**
1516 * @brief Equality operator for PbbAddressBlock
1517 * @param other PbbAddressBlock to compare to this one
1518 * @returns true if PbbMessages are equal
1519 */
1520 bool operator==(const PbbAddressBlock& other) const;
1521
1522 protected:
1523 /**
1524 * @brief Returns address length
1525 * @returns Address length
1526 */
1527 virtual uint8_t GetAddressLength() const = 0;
1528 /**
1529 * @brief Serialize one or more addresses
1530 * @param buffer the buffer to serialize to
1531 * @param iter the iterator to the addresses
1532 */
1533 virtual void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const = 0;
1534 /**
1535 * @brief Deserialize one address
1536 * @param buffer the buffer to deserialize from
1537 * @returns the address
1538 */
1539 virtual Address DeserializeAddress(uint8_t* buffer) const = 0;
1540 /**
1541 * @brief Print one or more addresses
1542 * @param os the output stream
1543 * @param iter the iterator to the addresses
1544 */
1545 virtual void PrintAddress(std::ostream& os, ConstAddressIterator iter) const = 0;
1546
1547 private:
1548 /**
1549 * @brief Get the prefix flags
1550 * @return the prefix flags
1551 */
1552 uint8_t GetPrefixFlags() const;
1553 /**
1554 * @brief Get head and tail
1555 * @param head the head
1556 * @param headlen the head length
1557 * @param tail the tail
1558 * @param taillen the tail length
1559 */
1560 void GetHeadTail(uint8_t* head, uint8_t& headlen, uint8_t* tail, uint8_t& taillen) const;
1561
1562 /**
1563 * @brief Check if the tail is empty
1564 * @param tail the tail
1565 * @param taillen the tail length
1566 * @returns true if the tail is empty
1567 */
1568 bool HasZeroTail(const uint8_t* tail, uint8_t taillen) const;
1569
1570 std::list<Address> m_addressList; //!< Addresses container
1571 std::list<uint8_t> m_prefixList; //!< Prefixes container
1572 PbbAddressTlvBlock m_addressTlvList; //!< PbbAddressTlv container
1573};
1574
1575/**
1576 * @brief Concrete IPv4 specific PbbAddressBlock.
1577 *
1578 * This address block will only contain IPv4 addresses.
1579 */
1581{
1582 public:
1584 ~PbbAddressBlockIpv4() override;
1585
1586 protected:
1587 /**
1588 * @brief Returns address length
1589 * @returns Address length
1590 */
1591 uint8_t GetAddressLength() const override;
1592 void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const override;
1593 Address DeserializeAddress(uint8_t* buffer) const override;
1594 void PrintAddress(std::ostream& os, ConstAddressIterator iter) const override;
1595};
1596
1597/**
1598 * @brief Concrete IPv6 specific PbbAddressBlock.
1599 *
1600 * This address block will only contain IPv6 addresses.
1601 */
1603{
1604 public:
1606 ~PbbAddressBlockIpv6() override;
1607
1608 protected:
1609 /**
1610 * @brief Returns address length
1611 * @returns Address length
1612 */
1613 uint8_t GetAddressLength() const override;
1614 void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const override;
1615 Address DeserializeAddress(uint8_t* buffer) const override;
1616 void PrintAddress(std::ostream& os, ConstAddressIterator iter) const override;
1617};
1618
1619/**
1620 * @brief A packet or message TLV
1621 */
1622class PbbTlv : public SimpleRefCount<PbbTlv>
1623{
1624 public:
1625 PbbTlv();
1626 virtual ~PbbTlv();
1627
1628 /**
1629 * @brief Sets the type of this TLV.
1630 * @param type the type value to set.
1631 */
1632 void SetType(uint8_t type);
1633
1634 /**
1635 * @return the type of this TLV.
1636 */
1637 uint8_t GetType() const;
1638
1639 /**
1640 * @brief Sets the type extension of this TLV.
1641 * @param type the type extension value to set.
1642 *
1643 * The type extension is like a sub-type used to further distinguish between
1644 * TLVs of the same type.
1645 */
1646 void SetTypeExt(uint8_t type);
1647
1648 /**
1649 * @return the type extension for this TLV.
1650 *
1651 * Calling this while HasTypeExt is False is undefined. Make sure you check
1652 * it first. This will be checked by an assert in debug builds.
1653 */
1654 uint8_t GetTypeExt() const;
1655
1656 /**
1657 * @brief Tests whether or not this TLV has a type extension.
1658 * @return true if this TLV has a type extension, false otherwise.
1659 *
1660 * This should be called before calling GetTypeExt to make sure there
1661 * actually is one.
1662 */
1663 bool HasTypeExt() const;
1664
1665 /**
1666 * @brief Sets the value of this message to the specified buffer.
1667 * @param start a buffer instance.
1668 *
1669 * The buffer is _not_ copied until this TLV is serialized. You should not
1670 * change the contents of the buffer you pass in to this function.
1671 */
1672 void SetValue(Buffer start);
1673
1674 /**
1675 * @brief Sets the value of this message to a buffer with the specified data.
1676 * @param buffer a pointer to data to put in the TLVs buffer.
1677 * @param size the size of the buffer.
1678 *
1679 * The buffer *is copied* into a *new buffer instance*. You can free the
1680 * data in the buffer provided anytime you wish.
1681 */
1682 void SetValue(const uint8_t* buffer, uint32_t size);
1683
1684 /**
1685 * @return a Buffer pointing to the value of this TLV.
1686 *
1687 * Calling this while HasValue is False is undefined. Make sure you check it
1688 * first. This will be checked by an assert in debug builds.
1689 */
1690 Buffer GetValue() const;
1691
1692 /**
1693 * @brief Tests whether or not this TLV has a value.
1694 * @return true if this tlv has a TLV, false otherwise.
1695 *
1696 * This should be called before calling GetTypeExt to make sure there
1697 * actually is one.
1698 */
1699 bool HasValue() const;
1700
1701 /**
1702 * @return The size (in bytes) needed to serialize this TLV.
1703 */
1705
1706 /**
1707 * @brief Serializes this TLV into the specified buffer.
1708 * @param start a reference to the point in a buffer to begin serializing.
1709 *
1710 * Users should not need to call this. TLVs will be serialized by their
1711 * containing blocks.
1712 */
1713 void Serialize(Buffer::Iterator& start) const;
1714
1715 /**
1716 * @brief Deserializes a TLV from the specified buffer.
1717 * @param start a reference to the point in a buffer to begin deserializing.
1718 *
1719 * Users should not need to call this. TLVs will be deserialized by their
1720 * containing blocks.
1721 */
1722 void Deserialize(Buffer::Iterator& start);
1723
1724 /**
1725 * @brief Pretty-prints the contents of this TLV.
1726 * @param os a stream object to print to.
1727 */
1728 void Print(std::ostream& os) const;
1729
1730 /**
1731 * @brief Pretty-prints the contents of this TLV, with specified indentation.
1732 * @param os a stream object to print to.
1733 * @param level level of indentation.
1734 *
1735 * This probably never needs to be called by users. This is used when
1736 * recursively printing sub-objects.
1737 */
1738 void Print(std::ostream& os, int level) const;
1739
1740 /**
1741 * @brief Equality operator for PbbTlv
1742 * @param other PbbTlv to compare to this one
1743 * @returns true if PbbTlv are equal
1744 */
1745 bool operator==(const PbbTlv& other) const;
1746
1747 protected:
1748 /**
1749 * @brief Set an index as starting point
1750 * @param index the starting index
1751 */
1752 void SetIndexStart(uint8_t index);
1753 /**
1754 * @brief Get the starting point index
1755 * @returns the starting index
1756 */
1757 uint8_t GetIndexStart() const;
1758 /**
1759 * @brief Checks if there is a starting index
1760 * @returns true if the start index has been set
1761 */
1762 bool HasIndexStart() const;
1763
1764 /**
1765 * @brief Set an index as stop point
1766 * @param index the stop index
1767 */
1768 void SetIndexStop(uint8_t index);
1769 /**
1770 * @brief Get the stop point index
1771 * @returns the stop index
1772 */
1773 uint8_t GetIndexStop() const;
1774 /**
1775 * @brief Checks if there is a stop index
1776 * @returns true if the stop index has been set
1777 */
1778 bool HasIndexStop() const;
1779
1780 /**
1781 * @brief Set the multivalue parameter
1782 * @param isMultivalue the multivalue status
1783 */
1784 void SetMultivalue(bool isMultivalue);
1785 /**
1786 * @brief Check the multivalue parameter
1787 * @returns the multivalue status
1788 */
1789 bool IsMultivalue() const;
1790
1791 private:
1792 uint8_t m_type; //!< Type of this TLV.
1793
1794 bool m_hasTypeExt; //!< Extended type present.
1795 uint8_t m_typeExt; //!< Extended type.
1796
1797 bool m_hasIndexStart; //!< Start index present.
1798 uint8_t m_indexStart; //!< Start index.
1799
1800 bool m_hasIndexStop; //!< Stop index present.
1801 uint8_t m_indexStop; //!< Stop index.
1802
1803 bool m_isMultivalue; //!< Is multivalue.
1804 bool m_hasValue; //!< Has value.
1805 Buffer m_value; //!< Value.
1806};
1807
1808/**
1809 * @brief An Address TLV
1810 */
1811class PbbAddressTlv : public PbbTlv
1812{
1813 public:
1814 /**
1815 * @brief Sets the index of the first address in the associated address block
1816 * that this address TLV applies to.
1817 * @param index the index of the first address.
1818 */
1819 void SetIndexStart(uint8_t index);
1820
1821 /**
1822 * @return the first (inclusive) index of the address in the corresponding
1823 * address block that this TLV applies to.
1824 *
1825 * Calling this while HasIndexStart is False is undefined. Make sure you
1826 * check it first. This will be checked by an assert in debug builds.
1827 */
1828 uint8_t GetIndexStart() const;
1829
1830 /**
1831 * @brief Tests whether or not this address TLV has a start index.
1832 * @return true if this address TLV has a start index, false otherwise.
1833 *
1834 * This should be called before calling GetIndexStart to make sure there
1835 * actually is one.
1836 */
1837 bool HasIndexStart() const;
1838
1839 /**
1840 * @brief Sets the index of the last address in the associated address block
1841 * that this address TLV applies to.
1842 * @param index the index of the last address.
1843 */
1844 void SetIndexStop(uint8_t index);
1845
1846 /**
1847 * @return the last (inclusive) index of the address in the corresponding
1848 * PbbAddressBlock that this TLV applies to.
1849 *
1850 * Calling this while HasIndexStop is False is undefined. Make sure you
1851 * check it first. This will be checked by an assert in debug builds.
1852 */
1853 uint8_t GetIndexStop() const;
1854
1855 /**
1856 * @brief Tests whether or not this address TLV has a stop index.
1857 * @return true if this address TLV has a stop index, false otherwise.
1858 *
1859 * This should be called before calling GetIndexStop to make sure there
1860 * actually is one.
1861 */
1862 bool HasIndexStop() const;
1863
1864 /**
1865 * @brief Sets whether or not this address TLV is "multivalue"
1866 * @param isMultivalue whether or not this address TLV should be multivalue.
1867 *
1868 * If true, this means the value associated with this TLV should be divided
1869 * evenly into (GetIndexStop() - GetIndexStart() + 1) values. Otherwise, the
1870 * value is one single value that applies to each address in the range.
1871 */
1872 void SetMultivalue(bool isMultivalue);
1873
1874 /**
1875 * @brief Tests whether or not this address TLV is "multivalue"
1876 * @return whether this address TLV is multivalue or not.
1877 */
1878 bool IsMultivalue() const;
1879};
1880
1881} /* namespace ns3 */
1882
1883#endif /* PACKETBB_H */
a polymophic address class
Definition address.h:114
iterator in a Buffer instance
Definition buffer.h:89
automatically resized byte buffer
Definition buffer.h:83
An Address Block and its associated Address TLV Blocks.
Definition packetbb.h:1157
void PrefixPopFront()
Removes a prefix from the front of this block.
Definition packetbb.cc:1967
Address AddressFront() const
Definition packetbb.cc:1838
std::list< uint8_t >::iterator PrefixIterator
Prefix iterator.
Definition packetbb.h:1165
int TlvSize() const
Definition packetbb.cc:2047
void AddressPopFront()
Removes an address from the front of this block.
Definition packetbb.cc:1859
uint8_t GetPrefixFlags() const
Get the prefix flags.
Definition packetbb.cc:2395
void PrefixPushFront(uint8_t prefix)
Prepends a prefix to the front of this block.
Definition packetbb.cc:1960
void Print(std::ostream &os) const
Pretty-prints the contents of this address block.
Definition packetbb.cc:2320
PrefixIterator PrefixEnd()
Definition packetbb.cc:1918
std::list< Address > m_addressList
Addresses container.
Definition packetbb.h:1570
TlvIterator TlvInsert(TlvIterator position, const Ptr< PbbTlv > value)
Inserts an address TLV at the specified position in this block.
void PrefixClear()
Removes all prefixes from this block.
Definition packetbb.cc:2010
uint32_t GetSerializedSize() const
Definition packetbb.cc:2138
void Serialize(Buffer::Iterator &start) const
Serializes this address block into the specified buffer.
Definition packetbb.cc:2186
PbbAddressTlvBlock::Iterator TlvIterator
tlvblock iterator
Definition packetbb.h:1170
bool PrefixEmpty() const
Definition packetbb.cc:1939
Ptr< PbbAddressTlv > TlvBack()
Definition packetbb.cc:2075
virtual void PrintAddress(std::ostream &os, ConstAddressIterator iter) const =0
Print one or more addresses.
Ptr< PbbAddressTlv > TlvFront()
Definition packetbb.cc:2061
void GetHeadTail(uint8_t *head, uint8_t &headlen, uint8_t *tail, uint8_t &taillen) const
Get head and tail.
Definition packetbb.cc:2413
void TlvPopBack()
Removes an address TLV from the back of this message.
Definition packetbb.cc:2110
TlvIterator TlvBegin()
Definition packetbb.cc:2019
AddressIterator AddressInsert(AddressIterator position, const Address value)
Inserts an address at the specified position in this block.
virtual void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const =0
Serialize one or more addresses.
std::list< Address >::const_iterator ConstAddressIterator
Address const iterator.
Definition packetbb.h:1162
bool TlvEmpty() const
Definition packetbb.cc:2054
int PrefixSize() const
Definition packetbb.cc:1932
void TlvPushBack(Ptr< PbbAddressTlv > address)
Appends an address TLV to the back of this message.
Definition packetbb.cc:2103
Address AddressBack() const
Definition packetbb.cc:1845
void AddressClear()
Removes all addresses from this block.
Definition packetbb.cc:1895
void AddressPushBack(Address address)
Appends an address to the back of this block.
Definition packetbb.cc:1866
AddressIterator AddressErase(AddressIterator position)
Removes the address at the specified position.
Definition packetbb.cc:1880
bool HasZeroTail(const uint8_t *tail, uint8_t taillen) const
Check if the tail is empty.
Definition packetbb.cc:2474
std::list< uint8_t > m_prefixList
Prefixes container.
Definition packetbb.h:1571
void PrefixPushBack(uint8_t prefix)
Appends a prefix to the back of this block.
Definition packetbb.cc:1974
void PrefixPopBack()
Removes a prefix from the back of this block.
Definition packetbb.cc:1981
uint8_t PrefixFront() const
Definition packetbb.cc:1946
PrefixIterator PrefixBegin()
Definition packetbb.cc:1904
void AddressPopBack()
Removes an address from the back of this block.
Definition packetbb.cc:1873
PrefixIterator PrefixErase(PrefixIterator position)
Removes the prefix at the specified position.
Definition packetbb.cc:1995
virtual Address DeserializeAddress(uint8_t *buffer) const =0
Deserialize one address.
uint8_t PrefixBack() const
Definition packetbb.cc:1953
void TlvClear()
Removes all address TLVs from this block.
Definition packetbb.cc:2131
PbbAddressTlvBlock::ConstIterator ConstTlvIterator
tlvblock const iterator
Definition packetbb.h:1172
PrefixIterator PrefixInsert(PrefixIterator position, const uint8_t value)
Inserts a prefix at the specified position in this block.
Definition packetbb.cc:1988
void TlvPushFront(Ptr< PbbAddressTlv > address)
Prepends an address TLV to the front of this message.
Definition packetbb.cc:2089
void TlvPopFront()
Removes an address TLV from the front of this message.
Definition packetbb.cc:2096
virtual ~PbbAddressBlock()
Definition packetbb.cc:1788
virtual uint8_t GetAddressLength() const =0
Returns address length.
void Deserialize(Buffer::Iterator &start)
Deserializes an address block from the specified buffer.
Definition packetbb.cc:2266
AddressIterator AddressBegin()
Definition packetbb.cc:1796
TlvIterator TlvErase(TlvIterator position)
Removes the address TLV at the specified position.
Definition packetbb.cc:2117
std::list< uint8_t >::const_iterator ConstPrefixIterator
Prefix const iterator.
Definition packetbb.h:1167
void AddressPushFront(Address address)
Prepends an address to the front of this block.
Definition packetbb.cc:1852
std::list< Address >::iterator AddressIterator
Address iterator.
Definition packetbb.h:1160
AddressIterator AddressEnd()
Definition packetbb.cc:1810
bool AddressEmpty() const
Definition packetbb.cc:1831
bool operator==(const PbbAddressBlock &other) const
Equality operator for PbbAddressBlock.
Definition packetbb.cc:2355
TlvIterator TlvEnd()
Definition packetbb.cc:2033
PbbAddressTlvBlock m_addressTlvList
PbbAddressTlv container.
Definition packetbb.h:1572
int AddressSize() const
Definition packetbb.cc:1824
uint8_t GetAddressLength() const override
Returns address length.
Definition packetbb.cc:2501
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition packetbb.cc:2522
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition packetbb.cc:2508
~PbbAddressBlockIpv4() override
Definition packetbb.cc:2495
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition packetbb.cc:2515
~PbbAddressBlockIpv6() override
Definition packetbb.cc:2535
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition packetbb.cc:2548
uint8_t GetAddressLength() const override
Returns address length.
Definition packetbb.cc:2541
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition packetbb.cc:2562
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition packetbb.cc:2555
A block of Address TLVs (PbbAddressTlv).
Definition packetbb.h:203
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition packetbb.cc:427
void PushBack(Ptr< PbbAddressTlv > tlv)
Appends an Address TLV to the back of this block.
Definition packetbb.cc:368
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition packetbb.cc:468
Iterator Erase(Iterator position)
Removes the Address TLV at the specified position.
Definition packetbb.cc:389
std::list< Ptr< PbbAddressTlv > > m_tlvList
PbbAddressTlv container.
Definition packetbb.h:354
void PopFront()
Removes an AddressTLV from the front of this block.
Definition packetbb.cc:361
std::list< Ptr< PbbAddressTlv > >::const_iterator ConstIterator
PbbAddressTlv const iterator for PbbAddressTlvBlock.
Definition packetbb.h:208
void Clear()
Removes all Address TLVs from this block.
Definition packetbb.cc:403
std::list< Ptr< PbbAddressTlv > >::iterator Iterator
PbbAddressTlv iterator for PbbAddressTlvBlock.
Definition packetbb.h:206
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition packetbb.cc:450
uint32_t GetSerializedSize() const
Definition packetbb.cc:414
Ptr< PbbAddressTlv > Front() const
Definition packetbb.cc:340
Ptr< PbbAddressTlv > Back() const
Definition packetbb.cc:347
Iterator Insert(Iterator position, const Ptr< PbbAddressTlv > tlv)
Inserts an Address TLV at the specified position in this block.
Definition packetbb.cc:382
void PushFront(Ptr< PbbAddressTlv > tlv)
Prepends an Address TLV to the front of this block.
Definition packetbb.cc:354
void PopBack()
Removes an Address TLV from the back of this block.
Definition packetbb.cc:375
bool operator==(const PbbAddressTlvBlock &other) const
Equality operator for PbbAddressTlvBlock.
Definition packetbb.cc:498
An Address TLV.
Definition packetbb.h:1812
bool HasIndexStart() const
Tests whether or not this address TLV has a start index.
Definition packetbb.cc:2962
bool IsMultivalue() const
Tests whether or not this address TLV is "multivalue".
Definition packetbb.cc:2997
void SetMultivalue(bool isMultivalue)
Sets whether or not this address TLV is "multivalue".
Definition packetbb.cc:2990
void SetIndexStart(uint8_t index)
Sets the index of the first address in the associated address block that this address TLV applies to.
Definition packetbb.cc:2948
bool HasIndexStop() const
Tests whether or not this address TLV has a stop index.
Definition packetbb.cc:2983
uint8_t GetIndexStop() const
Definition packetbb.cc:2976
uint8_t GetIndexStart() const
Definition packetbb.cc:2955
void SetIndexStop(uint8_t index)
Sets the index of the last address in the associated address block that this address TLV applies to.
Definition packetbb.cc:2969
A message within a PbbPacket packet.
Definition packetbb.h:675
void AddressBlockPushFront(Ptr< PbbAddressBlock > block)
Prepends an address block to the front of this message.
Definition packetbb.cc:1318
uint16_t m_sequenceNumber
Sequence number.
Definition packetbb.h:1091
virtual PbbAddressLength GetAddressLength() const =0
Returns address length (IPV4 3 or IPV6 15).
Definition packetbb.cc:1026
std::list< Ptr< PbbAddressBlock > >::iterator AddressBlockIterator
PbbAddressBlock iterator.
Definition packetbb.h:682
bool HasOriginatorAddress() const
Tests whether or not this message has an originator address.
Definition packetbb.cc:1049
bool m_hasHopLimit
Hop limit present.
Definition packetbb.h:1084
void TlvPopFront()
Removes a message TLV from the front of this message.
Definition packetbb.cc:1204
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a message TLV to the front of this message.
Definition packetbb.cc:1197
Address m_originatorAddress
originator address
Definition packetbb.h:1082
uint8_t GetType() const
Definition packetbb.cc:1019
bool HasHopLimit() const
Tests whether or not this message has a hop limit.
Definition packetbb.cc:1072
int AddressBlockSize() const
Definition packetbb.cc:1276
AddressBlockIterator AddressBlockBegin()
Definition packetbb.cc:1248
void Deserialize(Buffer::Iterator &start)
Deserializes a message from the specified buffer.
Definition packetbb.cc:1496
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator.
Definition packetbb.h:680
AddressBlockIterator AddressBlockEnd()
Definition packetbb.cc:1262
void SetType(uint8_t type)
Sets the type for this message.
Definition packetbb.cc:1012
std::list< Ptr< PbbAddressBlock > >::const_iterator ConstAddressBlockIterator
PbbAddressBlock const iterator.
Definition packetbb.h:684
void Serialize(Buffer::Iterator &start) const
Serializes this message into the specified buffer.
Definition packetbb.cc:1409
Ptr< PbbTlv > TlvFront()
Definition packetbb.cc:1169
TlvIterator TlvErase(TlvIterator position)
Removes the message TLV at the specified position.
Definition packetbb.cc:1225
std::list< Ptr< PbbAddressBlock > > m_addressBlockList
PbbAddressBlock container.
Definition packetbb.h:1076
void SetOriginatorAddress(Address address)
Sets the address for the node that created this packet.
Definition packetbb.cc:1033
void SetHopLimit(uint8_t hoplimit)
Sets the maximum number of hops this message should travel.
Definition packetbb.cc:1056
static Ptr< PbbMessage > DeserializeMessage(Buffer::Iterator &start)
Deserializes a message, returning the correct object depending on whether it is an IPv4 message or an...
Definition packetbb.cc:1464
Address GetOriginatorAddress() const
Definition packetbb.cc:1041
void TlvClear()
Removes all message TLVs from this block.
Definition packetbb.cc:1239
uint8_t m_hopLimit
Hop limit.
Definition packetbb.h:1085
void AddressBlockPushBack(Ptr< PbbAddressBlock > block)
Appends an address block to the front of this message.
Definition packetbb.cc:1332
TlvIterator TlvBegin()
Definition packetbb.cc:1127
void TlvPopBack()
Removes a message TLV from the back of this message.
Definition packetbb.cc:1218
uint16_t GetSequenceNumber() const
Definition packetbb.cc:1110
bool m_hasOriginatorAddress
Originator address present.
Definition packetbb.h:1081
virtual void PrintOriginatorAddress(std::ostream &os) const =0
Print the originator address.
bool HasSequenceNumber() const
Tests whether or not this message has a sequence number.
Definition packetbb.cc:1118
uint8_t GetHopLimit() const
Definition packetbb.cc:1064
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator.
Definition packetbb.h:678
virtual Address DeserializeOriginatorAddress(Buffer::Iterator &start) const =0
Deserialize the originator address.
void SetHopCount(uint8_t hopcount)
Sets the current number of hops this message has traveled.
Definition packetbb.cc:1079
void Print(std::ostream &os) const
Pretty-prints the contents of this message.
Definition packetbb.cc:1538
void SetSequenceNumber(uint16_t seqnum)
Sets the sequence number of this message.
Definition packetbb.cc:1102
int TlvSize() const
Definition packetbb.cc:1155
bool m_hasHopCount
Hop count present.
Definition packetbb.h:1087
void AddressBlockClear()
Removes all address blocks from this message.
Definition packetbb.cc:1361
virtual ~PbbMessage()
Definition packetbb.cc:1005
virtual Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const =0
Deserialize an address block.
PbbTlvBlock m_tlvList
PbbTlvBlock.
Definition packetbb.h:1075
void TlvPushBack(Ptr< PbbTlv > tlv)
Appends a message TLV to the back of this message.
Definition packetbb.cc:1211
virtual void SerializeOriginatorAddress(Buffer::Iterator &start) const =0
Serialize the originator address.
AddressBlockIterator AddressBlockErase(AddressBlockIterator position)
Removes the address block at the specified position.
Definition packetbb.cc:1346
Ptr< PbbAddressBlock > AddressBlockBack()
Definition packetbb.cc:1304
uint8_t GetHopCount() const
Definition packetbb.cc:1087
void AddressBlockPopFront()
Removes an address block from the front of this message.
Definition packetbb.cc:1325
bool operator==(const PbbMessage &other) const
Equality operator for PbbMessage.
Definition packetbb.cc:1591
PbbAddressLength m_addrSize
the address size
Definition packetbb.h:1079
uint8_t m_hopCount
Hop count.
Definition packetbb.h:1088
bool m_hasSequenceNumber
Sequence number present.
Definition packetbb.h:1090
uint32_t GetSerializedSize() const
Definition packetbb.cc:1372
TlvIterator TlvEnd()
Definition packetbb.cc:1141
Ptr< PbbAddressBlock > AddressBlockFront()
Definition packetbb.cc:1290
bool AddressBlockEmpty() const
Definition packetbb.cc:1283
bool TlvEmpty() const
Definition packetbb.cc:1162
bool HasHopCount() const
Tests whether or not this message has a hop count.
Definition packetbb.cc:1095
Ptr< PbbTlv > TlvBack()
Definition packetbb.cc:1183
uint8_t m_type
the type for this message
Definition packetbb.h:1078
void AddressBlockPopBack()
Removes an address block from the back of this message.
Definition packetbb.cc:1339
void PrintOriginatorAddress(std::ostream &os) const override
Print the originator address.
Definition packetbb.cc:1715
void SerializeOriginatorAddress(Buffer::Iterator &start) const override
Serialize the originator address.
Definition packetbb.cc:1694
PbbAddressLength GetAddressLength() const override
Returns address length (IPV4 3 or IPV6 15).
Definition packetbb.cc:1687
Address DeserializeOriginatorAddress(Buffer::Iterator &start) const override
Deserialize the originator address.
Definition packetbb.cc:1704
Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const override
Deserialize an address block.
Definition packetbb.cc:1722
Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const override
Deserialize an address block.
Definition packetbb.cc:1773
void PrintOriginatorAddress(std::ostream &os) const override
Print the originator address.
Definition packetbb.cc:1766
void SerializeOriginatorAddress(Buffer::Iterator &start) const override
Serialize the originator address.
Definition packetbb.cc:1745
PbbAddressLength GetAddressLength() const override
Returns address length (IPV4 3 or IPV6 15).
Definition packetbb.cc:1738
Address DeserializeOriginatorAddress(Buffer::Iterator &start) const override
Deserialize the originator address.
Definition packetbb.cc:1755
std::list< Ptr< PbbMessage > >::iterator MessageIterator
PbbMessage Iterator for PbbPacket.
Definition packetbb.h:373
~PbbPacket() override
Definition packetbb.cc:527
uint8_t m_version
version
Definition packetbb.h:660
TlvIterator TlvBegin()
Definition packetbb.cc:573
std::list< Ptr< PbbMessage > >::const_iterator ConstMessageIterator
PbbMessage Const Iterator for PbbPacket.
Definition packetbb.h:375
MessageIterator MessageEnd()
Definition packetbb.cc:708
std::list< Ptr< PbbMessage > > m_messageList
PbbTlvBlock container.
Definition packetbb.h:658
bool m_hasseqnum
Sequence number present.
Definition packetbb.h:662
void TlvPushBack(Ptr< PbbTlv > tlv)
Appends a packet TLV to the back of this packet.
Definition packetbb.cc:657
bool TlvEmpty() const
Definition packetbb.cc:608
void TlvClear()
Removes all packet TLVs from this packet.
Definition packetbb.cc:685
static TypeId GetTypeId()
Get the type ID.
Definition packetbb.cc:817
void TlvPopBack()
Removes a packet TLV from the back of this block.
Definition packetbb.cc:664
void TlvPopFront()
Removes a packet TLV from the front of this packet.
Definition packetbb.cc:650
void MessagePushBack(Ptr< PbbMessage > message)
Appends a message to the back of this packet.
Definition packetbb.cc:778
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator for PbbPacket.
Definition packetbb.h:369
Ptr< PbbTlv > TlvFront()
Definition packetbb.cc:615
TlvIterator TlvEnd()
Definition packetbb.cc:587
void MessageClear()
Removes all messages from this packet.
Definition packetbb.cc:806
Ptr< PbbMessage > MessageFront()
Definition packetbb.cc:736
void SetSequenceNumber(uint16_t number)
Sets the sequence number of this packet.
Definition packetbb.cc:541
void MessagePopFront()
Removes a message from the front of this packet.
Definition packetbb.cc:771
void ForceTlv(bool forceTlv)
Forces a packet to write a TLV list even if it's empty, ignoring the phastlv bit.
Definition packetbb.cc:564
uint32_t GetSerializedSize() const override
Definition packetbb.cc:833
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a packet TLV to the front of this packet.
Definition packetbb.cc:643
bool MessageEmpty() const
Definition packetbb.cc:729
uint16_t GetSequenceNumber() const
Definition packetbb.cc:549
void MessagePopBack()
Removes a message from the back of this packet.
Definition packetbb.cc:785
bool HasSequenceNumber() const
Tests whether or not this packet has a sequence number.
Definition packetbb.cc:557
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition packetbb.cc:827
Ptr< PbbTlv > TlvBack()
Definition packetbb.cc:629
MessageIterator MessageBegin()
Definition packetbb.cc:694
MessageIterator Erase(MessageIterator first, MessageIterator last)
Removes all messages from [first, last) (includes first, not includes last).
TlvIterator Erase(TlvIterator position)
Removes the packet TLV at the specified position.
Definition packetbb.cc:671
MessageIterator Erase(MessageIterator position)
Removes the message at the specified position.
void MessagePushFront(Ptr< PbbMessage > message)
Prepends a message to the front of this packet.
Definition packetbb.cc:764
int TlvSize() const
Definition packetbb.cc:601
void Serialize(Buffer::Iterator start) const override
Serializes this packet into the specified buffer.
Definition packetbb.cc:858
Ptr< PbbMessage > MessageBack()
Definition packetbb.cc:750
void Print(std::ostream &os) const override
Pretty-prints the contents of this block.
Definition packetbb.cc:925
uint16_t m_seqnum
Sequence number.
Definition packetbb.h:663
uint8_t GetVersion() const
Definition packetbb.cc:534
uint32_t Deserialize(Buffer::Iterator start) override
Deserializes a packet from the specified buffer.
Definition packetbb.cc:891
bool m_forceTlv
Force writing a TLV list (even if it's empty).
Definition packetbb.h:664
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator for PbbPacket.
Definition packetbb.h:371
int MessageSize() const
Definition packetbb.cc:722
PbbTlvBlock m_tlvList
PbbTlv container.
Definition packetbb.h:657
bool operator==(const PbbPacket &other) const
Equality operator for PbbPacket.
Definition packetbb.cc:948
A block of packet or message TLVs (PbbTlv).
Definition packetbb.h:45
Iterator Erase(Iterator position)
Removes the TLV at the specified position.
Definition packetbb.cc:156
void PushBack(Ptr< PbbTlv > tlv)
Appends a TLV to the back of this block.
Definition packetbb.cc:135
bool operator==(const PbbTlvBlock &other) const
Equality operator for PbbTlvBlock.
Definition packetbb.cc:265
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition packetbb.cc:194
Iterator End()
Definition packetbb.cc:79
Ptr< PbbTlv > Front() const
Definition packetbb.cc:107
void PushFront(Ptr< PbbTlv > tlv)
Prepends a TLV to the front of this block.
Definition packetbb.cc:121
std::list< Ptr< PbbTlv > >::iterator Iterator
PbbTlv container iterator.
Definition packetbb.h:48
Iterator Begin()
Definition packetbb.cc:65
Ptr< PbbTlv > Back() const
Definition packetbb.cc:114
void Clear()
Removes all TLVs from this block.
Definition packetbb.cc:170
Iterator Insert(Iterator position, const Ptr< PbbTlv > tlv)
Inserts a TLV at the specified position in this block.
Definition packetbb.cc:149
void PopFront()
Removes a TLV from the front of this block.
Definition packetbb.cc:128
std::list< Ptr< PbbTlv > >::const_iterator ConstIterator
PbbTlv container const iterator.
Definition packetbb.h:50
uint32_t GetSerializedSize() const
Definition packetbb.cc:181
bool Empty() const
Definition packetbb.cc:100
int Size() const
Definition packetbb.cc:93
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition packetbb.cc:217
std::list< Ptr< PbbTlv > > m_tlvList
PbbTlv container.
Definition packetbb.h:194
void PopBack()
Removes a TLV from the back of this block.
Definition packetbb.cc:142
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition packetbb.cc:235
A packet or message TLV.
Definition packetbb.h:1623
bool m_isMultivalue
Is multivalue.
Definition packetbb.h:1803
uint8_t m_indexStop
Stop index.
Definition packetbb.h:1801
void SetValue(Buffer start)
Sets the value of this message to the specified buffer.
Definition packetbb.cc:2684
uint8_t GetIndexStop() const
Get the stop point index.
Definition packetbb.cc:2655
bool HasTypeExt() const
Tests whether or not this TLV has a type extension.
Definition packetbb.cc:2617
uint8_t GetIndexStart() const
Get the starting point index.
Definition packetbb.cc:2632
bool HasValue() const
Tests whether or not this TLV has a value.
Definition packetbb.cc:2709
bool HasIndexStart() const
Checks if there is a starting index.
Definition packetbb.cc:2640
uint8_t m_indexStart
Start index.
Definition packetbb.h:1798
uint8_t m_type
Type of this TLV.
Definition packetbb.h:1792
Buffer m_value
Value.
Definition packetbb.h:1805
bool m_hasIndexStart
Start index present.
Definition packetbb.h:1797
bool operator==(const PbbTlv &other) const
Equality operator for PbbTlv.
Definition packetbb.cc:2901
void Serialize(Buffer::Iterator &start) const
Serializes this TLV into the specified buffer.
Definition packetbb.cc:2754
bool IsMultivalue() const
Check the multivalue parameter.
Definition packetbb.cc:2677
void SetType(uint8_t type)
Sets the type of this TLV.
Definition packetbb.cc:2587
bool m_hasIndexStop
Stop index present.
Definition packetbb.h:1800
uint8_t GetTypeExt() const
Definition packetbb.cc:2609
void SetIndexStop(uint8_t index)
Set an index as stop point.
Definition packetbb.cc:2647
bool HasIndexStop() const
Checks if there is a stop index.
Definition packetbb.cc:2663
void SetMultivalue(bool isMultivalue)
Set the multivalue parameter.
Definition packetbb.cc:2670
void Print(std::ostream &os) const
Pretty-prints the contents of this TLV.
Definition packetbb.cc:2856
virtual ~PbbTlv()
Definition packetbb.cc:2580
void SetIndexStart(uint8_t index)
Set an index as starting point.
Definition packetbb.cc:2624
Buffer GetValue() const
Definition packetbb.cc:2701
uint8_t m_typeExt
Extended type.
Definition packetbb.h:1795
bool m_hasTypeExt
Extended type present.
Definition packetbb.h:1794
uint8_t GetType() const
Definition packetbb.cc:2594
uint32_t GetSerializedSize() const
Definition packetbb.cc:2716
void SetTypeExt(uint8_t type)
Sets the type extension of this TLV.
Definition packetbb.cc:2601
void Deserialize(Buffer::Iterator &start)
Deserializes a TLV from the specified buffer.
Definition packetbb.cc:2811
bool m_hasValue
Has value.
Definition packetbb.h:1804
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
Definition first.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.
PbbAddressLength
Used in Messages to determine whether it contains IPv4 or IPv6 addresses.
Definition packetbb.h:34
@ IPV6
Definition packetbb.h:36
@ IPV4
Definition packetbb.h:35