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