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 * @brief Inequality operator for PbbTlvBlock
194 * @param other PbbTlvBlock to compare this one to
195 * @returns true if the blocks are not equal
196 */
197 bool operator!=(const PbbTlvBlock& other) const;
198
199 private:
200 std::list<Ptr<PbbTlv>> m_tlvList; //!< PbbTlv container
201};
202
203/**
204 * @brief A block of Address TLVs (PbbAddressTlv).
205 *
206 * Acts similar to a C++ STL container.
207 */
209{
210 public:
211 /// PbbAddressTlv iterator for PbbAddressTlvBlock
212 typedef std::list<Ptr<PbbAddressTlv>>::iterator Iterator;
213 /// PbbAddressTlv const iterator for PbbAddressTlvBlock
214 typedef std::list<Ptr<PbbAddressTlv>>::const_iterator ConstIterator;
215
218
219 /**
220 * @return an iterator to the first Address TLV in this block.
221 */
222 Iterator Begin();
223
224 /**
225 * @return a const iterator to the first Address TLV in this block.
226 */
227 ConstIterator Begin() const;
228
229 /**
230 * @return an iterator to the past-the-end element in this block.
231 */
232 Iterator End();
233
234 /**
235 * @return a const iterator to the past-the-end element in this block.
236 */
237 ConstIterator End() const;
238
239 /**
240 * @return the number of Address TLVs in this block.
241 */
242 int Size() const;
243
244 /**
245 * @return true if there are no Address TLVs in this block, false otherwise.
246 */
247 bool Empty() const;
248
249 /**
250 * @return the first Address TLV in this block.
251 */
253
254 /**
255 * @return the last AddressTLV in this block.
256 */
257 Ptr<PbbAddressTlv> Back() const;
258
259 /**
260 * @brief Prepends an Address TLV to the front of this block.
261 * @param tlv a smart pointer to the Address TLV to prepend.
262 */
264
265 /**
266 * @brief Removes an AddressTLV from the front of this block.
267 */
268 void PopFront();
269
270 /**
271 * @brief Appends an Address TLV to the back of this block.
272 * @param tlv a smart pointer to the Address TLV to append.
273 */
275
276 /**
277 * @brief Removes an Address TLV from the back of this block.
278 */
279 void PopBack();
280
281 /**
282 * @brief Inserts an Address TLV at the specified position in this block.
283 * @param position an Iterator pointing to the position in this block to
284 * insert the Address TLV.
285 * @param tlv a smart pointer to the Address TLV to insert.
286 * @return An iterator pointing to the newly inserted Address TLV.
287 */
288 Iterator Insert(Iterator position, const Ptr<PbbAddressTlv> tlv);
289
290 /**
291 * @brief Removes the Address TLV at the specified position.
292 * @param position an Iterator pointing to the Address TLV to erase.
293 * @return an iterator pointing to the next Address TLV in the block.
294 */
295 Iterator Erase(Iterator position);
296
297 /**
298 * @brief Removes all Address TLVs from [first, last) (includes first, not
299 * includes last).
300 * @param first an Iterator pointing to the first Address TLV to erase
301 * (inclusive).
302 * @param last an Iterator pointing to the element past the last Address TLV
303 * to erase.
304 * @return an iterator pointing to the next Address TLV in the block.
305 */
307
308 /**
309 * @brief Removes all Address TLVs from this block.
310 */
311 void Clear();
312
313 /**
314 * @return The size (in bytes) needed to serialize this block.
315 */
317
318 /**
319 * @brief Serializes this block into the specified buffer.
320 * @param start a reference to the point in a buffer to begin serializing.
321 *
322 * Users should not need to call this. Blocks will be serialized by their
323 * containing packet.
324 */
325 void Serialize(Buffer::Iterator& start) const;
326
327 /**
328 * @brief Deserializes a block from the specified buffer.
329 * @param start a reference to the point in a buffer to begin deserializing.
330 *
331 * Users should not need to call this. Blocks will be deserialized by their
332 * containing packet.
333 */
334 void Deserialize(Buffer::Iterator& start);
335
336 /**
337 * @brief Pretty-prints the contents of this block.
338 * @param os a stream object to print to.
339 */
340 void Print(std::ostream& os) const;
341
342 /**
343 * @brief Pretty-prints the contents of this block, with specified indentation.
344 * @param os a stream object to print to.
345 * @param level level of indentation.
346 *
347 * This probably never needs to be called by users. This is used when
348 * recursively printing sub-objects.
349 */
350 void Print(std::ostream& os, int level) const;
351
352 /**
353 * @brief Equality operator for PbbAddressTlvBlock
354 * @param other PbbAddressTlvBlock to compare to this one
355 * @returns true if PbbAddressTlvBlock are equal
356 */
357 bool operator==(const PbbAddressTlvBlock& other) const;
358
359 /**
360 * @brief Inequality operator for PbbAddressTlvBlock
361 * @param other PbbAddressTlvBlock to compare to this one
362 * @returns true if PbbAddressTlvBlock are not equal
363 */
364 bool operator!=(const PbbAddressTlvBlock& other) const;
365
366 private:
367 std::list<Ptr<PbbAddressTlv>> m_tlvList; //!< PbbAddressTlv container
368};
369
370/**
371 * @brief Main PacketBB Packet object.
372 *
373 * A PacketBB packet is made up of zero or more packet TLVs (PbbTlv), and zero
374 * or more messages (PbbMessage).
375 *
376 * See: \RFC{5444} for details.
377 */
378class PbbPacket : public SimpleRefCount<PbbPacket, Header>
379{
380 public:
381 /// PbbTlv iterator for PbbPacket
382 typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
383 /// PbbTlv const iterator for PbbPacket
384 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
385 /// PbbMessage Iterator for PbbPacket
386 typedef std::list<Ptr<PbbMessage>>::iterator MessageIterator;
387 /// PbbMessage Const Iterator for PbbPacket
388 typedef std::list<Ptr<PbbMessage>>::const_iterator ConstMessageIterator;
389
390 PbbPacket();
391 ~PbbPacket() override;
392
393 /**
394 * @return the version of PacketBB that constructed this packet.
395 *
396 * This will always return 0 for packets constructed using this API.
397 */
398 uint8_t GetVersion() const;
399
400 /**
401 * @brief Sets the sequence number of this packet.
402 * @param number the sequence number.
403 */
404 void SetSequenceNumber(uint16_t number);
405
406 /**
407 * @return the sequence number of this packet.
408 *
409 * Calling this while HasSequenceNumber is False is undefined. Make sure you
410 * check it first. This will be checked by an assert in debug builds.
411 */
412 uint16_t GetSequenceNumber() const;
413
414 /**
415 * @brief Tests whether or not this packet has a sequence number.
416 * @return true if this packet has a sequence number, false otherwise.
417 *
418 * This should be called before calling GetSequenceNumber to make sure there
419 * actually is one.
420 */
421 bool HasSequenceNumber() const;
422
423 /**
424 * @brief Forces a packet to write a TLV list even if it's empty, ignoring
425 * the phastlv bit.
426 *
427 * This is mainly used to check the Deserialization of a questionable
428 * but correct packet (see test 3).
429 *
430 * @param forceTlv true will force TLV to be written even if no TLV is set.
431 */
432 void ForceTlv(bool forceTlv);
433
434 /* Manipulating Packet TLVs */
435
436 /**
437 * @return an iterator to the first Packet TLV in this packet.
438 */
440
441 /**
442 * @return a const iterator to the first Packet TLV in this packet.
443 */
445
446 /**
447 * @return an iterator to the past-the-end element in this packet TLV block.
448 */
450
451 /**
452 * @return a const iterator to the past-the-end element in this packet TLV
453 * block.
454 */
455 ConstTlvIterator TlvEnd() const;
456
457 /**
458 * @return the number of packet TLVs in this packet.
459 */
460 int TlvSize() const;
461
462 /**
463 * @return true if there are no packet TLVs in this packet, false otherwise.
464 */
465 bool TlvEmpty() const;
466
467 /**
468 * @return a smart pointer to the first packet TLV in this packet.
469 */
471
472 /**
473 * @return a const smart pointer to the first packet TLV in this packet.
474 */
475 const Ptr<PbbTlv> TlvFront() const;
476
477 /**
478 * @return a smart pointer to the last packet TLV in this packet.
479 */
481
482 /**
483 * @return a const smart pointer to the last packet TLV in this packet.
484 */
485 const Ptr<PbbTlv> TlvBack() const;
486
487 /**
488 * @brief Prepends a packet TLV to the front of this packet.
489 * @param tlv a smart pointer to the packet TLV to prepend.
490 */
491 void TlvPushFront(Ptr<PbbTlv> tlv);
492
493 /**
494 * @brief Removes a packet TLV from the front of this packet.
495 */
496 void TlvPopFront();
497
498 /**
499 * @brief Appends a packet TLV to the back of this packet.
500 * @param tlv a smart pointer to the packet TLV to append.
501 */
502 void TlvPushBack(Ptr<PbbTlv> tlv);
503
504 /**
505 * @brief Removes a packet TLV from the back of this block.
506 */
507 void TlvPopBack();
508
509 /**
510 * @brief Removes the packet TLV at the specified position.
511 * @param position an Iterator pointing to the packet TLV to erase.
512 * @return an iterator pointing to the next packet TLV in the block.
513 */
514 TlvIterator Erase(TlvIterator position);
515
516 /**
517 * @brief Removes all packet TLVs from [first, last) (includes first, not
518 * includes last).
519 * @param first an Iterator pointing to the first packet TLV to erase
520 * (inclusive).
521 * @param last an Iterator pointing to the element past the last packet TLV
522 * to erase.
523 * @return an iterator pointing to the next packet TLV in the block.
524 */
526
527 /**
528 * @brief Removes all packet TLVs from this packet.
529 */
530 void TlvClear();
531
532 /* Manipulating Packet Messages */
533
534 /**
535 * @return an iterator to the first message in this packet.
536 */
538
539 /**
540 * @return a const iterator to the first message in this packet.
541 */
543
544 /**
545 * @return an iterator to the past-the-end element in this message block.
546 */
548
549 /**
550 * @return a const iterator to the past-the-end element in this message
551 * block.
552 */
554
555 /**
556 * @return the number of messages in this packet.
557 */
558 int MessageSize() const;
559
560 /**
561 * @return true if there are no messages in this packet, false otherwise.
562 */
563 bool MessageEmpty() const;
564
565 /**
566 * @return a smart pointer to the first message in this packet.
567 */
569
570 /**
571 * @return a const smart pointer to the first message in this packet.
572 */
573 const Ptr<PbbMessage> MessageFront() const;
574
575 /**
576 * @return a smart pointer to the last message in this packet.
577 */
579
580 /**
581 * @return a const smart pointer to the last message in this packet.
582 */
583 const Ptr<PbbMessage> MessageBack() const;
584
585 /**
586 * @brief Prepends a message to the front of this packet.
587 * @param message a smart pointer to the message to prepend.
588 */
589 void MessagePushFront(Ptr<PbbMessage> message);
590
591 /**
592 * @brief Removes a message from the front of this packet.
593 */
594 void MessagePopFront();
595
596 /**
597 * @brief Appends a message to the back of this packet.
598 * @param message a smart pointer to the message to append.
599 */
600 void MessagePushBack(Ptr<PbbMessage> message);
601
602 /**
603 * @brief Removes a message from the back of this packet.
604 */
605 void MessagePopBack();
606
607 /**
608 * @brief Removes the message at the specified position.
609 * @param position an Iterator pointing to the message to erase.
610 * @return an iterator pointing to the next message in the packet.
611 */
613
614 /**
615 * @brief Removes all messages from [first, last) (includes first, not
616 * includes last).
617 * @param first an Iterator pointing to the first message to erase (inclusive).
618 * @param last an Iterator pointing to the element past the last message to erase.
619 * @return an iterator pointing to the next message in the block.
620 */
622
623 /**
624 * @brief Removes all messages from this packet.
625 */
626 void MessageClear();
627
628 /**
629 * @brief Get the type ID.
630 * @return the object TypeId
631 */
632 static TypeId GetTypeId();
633 TypeId GetInstanceTypeId() const override;
634
635 /**
636 * @return The size (in bytes) needed to serialize this packet.
637 */
638 uint32_t GetSerializedSize() const override;
639
640 /**
641 * @brief Serializes this packet into the specified buffer.
642 * @param start a reference to the point in a buffer to begin serializing.
643 */
644 void Serialize(Buffer::Iterator start) const override;
645
646 /**
647 * @brief Deserializes a packet from the specified buffer.
648 * @param start start offset
649 * @return the number of bytes deserialized
650 *
651 * If this returns a number smaller than the total number of bytes in the
652 * buffer, there was an error.
653 */
654 uint32_t Deserialize(Buffer::Iterator start) override;
655
656 /**
657 * @brief Pretty-prints the contents of this block.
658 * @param os a stream object to print to.
659 */
660 void Print(std::ostream& os) const override;
661
662 /**
663 * @brief Equality operator for PbbPacket
664 * @param other PbbPacket to compare to this one
665 * @returns true if PbbPacket are equal
666 */
667 bool operator==(const PbbPacket& other) const;
668
669 /**
670 * @brief Inequality operator for PbbPacket
671 * @param other PbbPacket to compare to this one
672 * @returns true if PbbPacket are not equal
673 */
674 bool operator!=(const PbbPacket& other) const;
675
676 protected:
677 private:
678 PbbTlvBlock m_tlvList; //!< PbbTlv container
679 std::list<Ptr<PbbMessage>> m_messageList; //!< PbbTlvBlock container
680
681 uint8_t m_version; //!< version
682
683 bool m_hasseqnum; //!< Sequence number present
684 uint16_t m_seqnum; //!< Sequence number
685 bool m_forceTlv; //!< Force writing a TLV list (even if it's empty)
686};
687
688/**
689 * @brief A message within a PbbPacket packet.
690 *
691 * There may be any number of messages in one packet packet. This is a pure
692 * virtual base class, when creating a message, you should instantiate either
693 * PbbMessageIpv4 or PbbMessageIpv6.
694 */
695class PbbMessage : public SimpleRefCount<PbbMessage>
696{
697 public:
698 /// PbbTlv iterator
699 typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
700 /// PbbTlv const iterator
701 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
702 /// PbbAddressBlock iterator
703 typedef std::list<Ptr<PbbAddressBlock>>::iterator AddressBlockIterator;
704 /// PbbAddressBlock const iterator
705 typedef std::list<Ptr<PbbAddressBlock>>::const_iterator ConstAddressBlockIterator;
706
707 PbbMessage();
708 virtual ~PbbMessage();
709
710 /**
711 * @brief Sets the type for this message.
712 * @param type the type to set.
713 */
714 void SetType(uint8_t type);
715
716 /**
717 * @return the type assigned to this packet
718 */
719 uint8_t GetType() const;
720
721 /**
722 * @brief Sets the address for the node that created this packet.
723 * @param address the originator address.
724 */
725 void SetOriginatorAddress(Address address);
726
727 /**
728 * @return the address of the node that created this packet.
729 *
730 * Calling this while HasOriginatorAddress is False is undefined. Make sure
731 * you check it first. This will be checked by an assert in debug builds.
732 */
734
735 /**
736 * @brief Tests whether or not this message has an originator address.
737 * @return true if this message has an originator address, false otherwise.
738 */
739 bool HasOriginatorAddress() const;
740
741 /**
742 * @brief Sets the maximum number of hops this message should travel
743 * @param hoplimit the limit to set
744 */
745 void SetHopLimit(uint8_t hoplimit);
746
747 /**
748 * @return the maximum number of hops this message should travel.
749 *
750 * Calling this while HasHopLimit is False is undefined. Make sure you check
751 * it first. This will be checked by an assert in debug builds.
752 */
753 uint8_t GetHopLimit() const;
754
755 /**
756 * @brief Tests whether or not this message has a hop limit.
757 * @return true if this message has a hop limit, false otherwise.
758 *
759 * If this is set, messages should not hop further than this limit.
760 */
761 bool HasHopLimit() const;
762
763 /**
764 * @brief Sets the current number of hops this message has traveled.
765 * @param hopcount the current number of hops
766 */
767 void SetHopCount(uint8_t hopcount);
768
769 /**
770 * @return the current number of hops this message has traveled.
771 *
772 * Calling this while HasHopCount is False is undefined. Make sure you check
773 * it first. This will be checked by an assert in debug builds.
774 */
775 uint8_t GetHopCount() const;
776
777 /**
778 * @brief Tests whether or not this message has a hop count.
779 * @return true if this message has a hop limit, false otherwise.
780 */
781 bool HasHopCount() const;
782
783 /**
784 * @brief Sets the sequence number of this message.
785 * @param seqnum the sequence number to set.
786 */
787 void SetSequenceNumber(uint16_t seqnum);
788
789 /**
790 * @return the sequence number of this message.
791 *
792 * Calling this while HasSequenceNumber is False is undefined. Make sure you
793 * check it first. This will be checked by an assert in debug builds.
794 */
795 uint16_t GetSequenceNumber() const;
796
797 /**
798 * @brief Tests whether or not this message has a sequence number.
799 * @return true if this message has a sequence number, false otherwise.
800 */
801 bool HasSequenceNumber() const;
802
803 /* Manipulating PbbMessage TLVs */
804
805 /**
806 * @return an iterator to the first message TLV in this message.
807 */
809
810 /**
811 * @return a const iterator to the first message TLV in this message.
812 */
814
815 /**
816 * @return an iterator to the past-the-end message TLV element in this
817 * message.
818 */
820
821 /**
822 * @return a const iterator to the past-the-end message TLV element in this
823 * message.
824 */
825 ConstTlvIterator TlvEnd() const;
826
827 /**
828 * @return the number of message TLVs in this message.
829 */
830 int TlvSize() const;
831
832 /**
833 * @return true if there are no message TLVs in this message, false otherwise.
834 */
835 bool TlvEmpty() const;
836
837 /**
838 * @return a smart pointer to the first message TLV in this message.
839 */
841
842 /**
843 * @return a const smart pointer to the first message TLV in this message.
844 */
845 const Ptr<PbbTlv> TlvFront() const;
846
847 /**
848 * @return a smart pointer to the last message TLV in this message.
849 */
851
852 /**
853 * @return a const smart pointer to the last message TLV in this message.
854 */
855 const Ptr<PbbTlv> TlvBack() const;
856
857 /**
858 * @brief Prepends a message TLV to the front of this message.
859 * @param tlv a smart pointer to the message TLV to prepend.
860 */
861 void TlvPushFront(Ptr<PbbTlv> tlv);
862
863 /**
864 * @brief Removes a message TLV from the front of this message.
865 */
866 void TlvPopFront();
867
868 /**
869 * @brief Appends a message TLV to the back of this message.
870 * @param tlv a smart pointer to the message TLV to append.
871 */
872 void TlvPushBack(Ptr<PbbTlv> tlv);
873
874 /**
875 * @brief Removes a message TLV from the back of this message.
876 */
877 void TlvPopBack();
878
879 /**
880 * @brief Removes the message TLV at the specified position.
881 * @param position an Iterator pointing to the message TLV to erase.
882 * @return an iterator pointing to the next TLV in the block.
883 */
885
886 /**
887 * @brief Removes all message TLVs from [first, last) (includes first, not
888 * includes last).
889 * @param first an Iterator pointing to the first message TLV to erase
890 * (inclusive).
891 * @param last an Iterator pointing to the element past the last message TLV
892 * to erase.
893 * @return an iterator pointing to the next message TLV in the message.
894 */
896
897 /**
898 * @brief Removes all message TLVs from this block.
899 */
900 void TlvClear();
901
902 /* Manipulating Address Block and Address TLV pairs */
903
904 /**
905 * @return an iterator to the first address block in this message.
906 */
908
909 /**
910 * @return a const iterator to the first address block in this message.
911 */
913
914 /**
915 * @return an iterator to the past-the-end address block element in this
916 * message.
917 */
919
920 /**
921 * @return a const iterator to the past-the-end address block element in this
922 * message.
923 */
925
926 /**
927 * @return the number of address blocks in this message.
928 */
929 int AddressBlockSize() const;
930
931 /**
932 * @return true if there are no address blocks in this message, false
933 * otherwise.
934 */
935 bool AddressBlockEmpty() const;
936
937 /**
938 * @return a smart pointer to the first address block in this message.
939 */
941
942 /**
943 * @return a const smart pointer to the first address block in this message.
944 */
946
947 /**
948 * @return a smart pointer to the last address block in this message.
949 */
951
952 /**
953 * @return a const smart pointer to the last address block in this message.
954 */
956
957 /**
958 * @brief Prepends an address block to the front of this message.
959 * @param block a smart pointer to the address block to prepend.
960 */
962
963 /**
964 * @brief Removes an address block from the front of this message.
965 */
967
968 /**
969 * @brief Appends an address block to the front of this message.
970 * @param block a smart pointer to the address block to append.
971 */
973
974 /**
975 * @brief Removes an address block from the back of this message.
976 */
977 void AddressBlockPopBack();
978
979 /**
980 * @brief Removes the address block at the specified position.
981 * @param position an Iterator pointing to the address block to erase.
982 * @return an iterator pointing to the next address block in the message.
983 */
985
986 /**
987 * @brief Removes all address blocks from [first, last) (includes first, not
988 * includes last).
989 * @param first an Iterator pointing to the first address block to erase
990 * (inclusive).
991 * @param last an Iterator pointing to the element past the last address
992 * block to erase.
993 * @return an iterator pointing to the next address block in the message.
994 */
996
997 /**
998 * @brief Removes all address blocks from this message.
999 */
1000 void AddressBlockClear();
1001
1002 /**
1003 * @brief Deserializes a message, returning the correct object depending on
1004 * whether it is an IPv4 message or an IPv6 message.
1005 * @param start a reference to the point in a buffer to begin deserializing.
1006 * @return A pointer to the deserialized message, or 0 on error.
1007 *
1008 * Users should not need to call this. Blocks will be deserialized by their
1009 * containing packet.
1010 */
1012
1013 /**
1014 * @return The size (in bytes) needed to serialize this message.
1015 */
1017
1018 /**
1019 * @brief Serializes this message into the specified buffer.
1020 * @param start a reference to the point in a buffer to begin serializing.
1021 *
1022 * Users should not need to call this. Blocks will be deserialized by their
1023 * containing packet.
1024 */
1025 void Serialize(Buffer::Iterator& start) const;
1026
1027 /**
1028 * @brief Deserializes a message from the specified buffer.
1029 * @param start a reference to the point in a buffer to begin deserializing.
1030 *
1031 * Users should not need to call this. Blocks will be deserialized by their
1032 * containing packet.
1033 */
1034 void Deserialize(Buffer::Iterator& start);
1035
1036 /**
1037 * @brief Pretty-prints the contents of this message.
1038 * @param os a stream object to print to.
1039 */
1040 void Print(std::ostream& os) const;
1041
1042 /**
1043 * @brief Pretty-prints the contents of this message, with specified
1044 * indentation.
1045 * @param os a stream object to print to.
1046 * @param level level of indentation.
1047 *
1048 * This probably never needs to be called by users. This is used when
1049 * recursively printing sub-objects.
1050 */
1051 void Print(std::ostream& os, int level) const;
1052
1053 /**
1054 * @brief Equality operator for PbbMessage
1055 * @param other PbbMessage to compare to this one
1056 * @returns true if PbbMessages are equal
1057 */
1058 bool operator==(const PbbMessage& other) const;
1059 /**
1060 * @brief Inequality operator for PbbMessage
1061 * @param other PbbMessage to compare to this one
1062 * @returns true if PbbMessages are not equal
1063 */
1064 bool operator!=(const PbbMessage& other) const;
1065
1066 protected:
1067 /**
1068 * @brief Returns address length (IPV4 3 or IPV6 15)
1069 *
1070 * Returns message size in bytes - 1
1071 * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
1072 *
1073 * @returns Address length (IPV4 3 or IPV6 15)
1074 */
1075 virtual PbbAddressLength GetAddressLength() const = 0;
1076
1077 /**
1078 * @brief Serialize the originator address
1079 * @param start the buffer iterator start
1080 */
1081 virtual void SerializeOriginatorAddress(Buffer::Iterator& start) const = 0;
1082 /**
1083 * @brief Deserialize the originator address
1084 * @param start the buffer iterator start
1085 * @returns the deserialized address
1086 */
1088 /**
1089 * @brief Print the originator address
1090 * @param os the output stream
1091 */
1092 virtual void PrintOriginatorAddress(std::ostream& os) const = 0;
1093
1094 /**
1095 * @brief Deserialize an address block
1096 * @param start the buffer iterator start
1097 * @returns the deserialized address block
1098 */
1100
1101 private:
1102 PbbTlvBlock m_tlvList; //!< PbbTlvBlock
1103 std::list<Ptr<PbbAddressBlock>> m_addressBlockList; //!< PbbAddressBlock container
1104
1105 uint8_t m_type; //!< the type for this message
1106 PbbAddressLength m_addrSize; //!< the address size
1107
1108 bool m_hasOriginatorAddress; //!< Originator address present
1109 Address m_originatorAddress; //!< originator address
1110
1111 bool m_hasHopLimit; //!< Hop limit present
1112 uint8_t m_hopLimit; //!< Hop limit
1113
1114 bool m_hasHopCount; //!< Hop count present
1115 uint8_t m_hopCount; //!< Hop count
1116
1117 bool m_hasSequenceNumber; //!< Sequence number present
1118 uint16_t m_sequenceNumber; //!< Sequence number
1119};
1120
1121/**
1122 * @brief Concrete IPv4 specific PbbMessage.
1123 *
1124 * This message will only contain IPv4 addresses.
1125 */
1127{
1128 public:
1130
1131 protected:
1132 /**
1133 * @brief Returns address length (IPV4 3 or IPV6 15)
1134 *
1135 * Returns message size in bytes - 1
1136 * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
1137 *
1138 * @returns Address length (IPV4 3 or IPV6 15)
1139 */
1140 PbbAddressLength GetAddressLength() const override;
1141
1142 void SerializeOriginatorAddress(Buffer::Iterator& start) const override;
1144 void PrintOriginatorAddress(std::ostream& os) const override;
1145
1147};
1148
1149/**
1150 * @brief Concrete IPv6 specific PbbMessage class.
1151 *
1152 * This message will only contain IPv6 addresses.
1153 */
1155{
1156 public:
1158
1159 protected:
1160 /**
1161 * @brief Returns address length (IPV4 3 or IPV6 15)
1162 *
1163 * Returns message size in bytes - 1
1164 * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
1165 *
1166 * @returns Address length (IPV4 3 or IPV6 15)
1167 */
1168 PbbAddressLength GetAddressLength() const override;
1169
1170 void SerializeOriginatorAddress(Buffer::Iterator& start) const override;
1172 void PrintOriginatorAddress(std::ostream& os) const override;
1173
1175};
1176
1177/**
1178 * @brief An Address Block and its associated Address TLV Blocks.
1179 *
1180 * This is a pure virtual base class, when creating address blocks, you should
1181 * instantiate either PbbAddressBlockIpv4 or PbbAddressBlockIpv6.
1182 */
1183class PbbAddressBlock : public SimpleRefCount<PbbAddressBlock>
1184{
1185 public:
1186 /// Address iterator
1187 typedef std::list<Address>::iterator AddressIterator;
1188 /// Address const iterator
1189 typedef std::list<Address>::const_iterator ConstAddressIterator;
1190
1191 /// Prefix iterator
1192 typedef std::list<uint8_t>::iterator PrefixIterator;
1193 /// Prefix const iterator
1194 typedef std::list<uint8_t>::const_iterator ConstPrefixIterator;
1195
1196 /// tlvblock iterator
1198 /// tlvblock const iterator
1200
1202 virtual ~PbbAddressBlock();
1203
1204 /* Manipulating the address block */
1205
1206 /**
1207 * @return an iterator to the first address in this block.
1208 */
1210
1211 /**
1212 * @return a const iterator to the first address in this block.
1213 */
1215
1216 /**
1217 * @return an iterator to the last address in this block.
1218 */
1220
1221 /**
1222 * @return a const iterator to the last address in this block.
1223 */
1225
1226 /**
1227 * @return the number of addresses in this block.
1228 */
1229 int AddressSize() const;
1230
1231 /**
1232 * @return true if there are no addresses in this block, false otherwise.
1233 */
1234 bool AddressEmpty() const;
1235
1236 /**
1237 * @return the first address in this block.
1238 */
1239 Address AddressFront() const;
1240
1241 /**
1242 * @return the last address in this block.
1243 */
1244 Address AddressBack() const;
1245
1246 /**
1247 * @brief Prepends an address to the front of this block.
1248 * @param address the address to prepend.
1249 */
1250 void AddressPushFront(Address address);
1251
1252 /**
1253 * @brief Removes an address from the front of this block.
1254 */
1255 void AddressPopFront();
1256
1257 /**
1258 * @brief Appends an address to the back of this block.
1259 * @param address the address to append.
1260 */
1261 void AddressPushBack(Address address);
1262
1263 /**
1264 * @brief Removes an address from the back of this block.
1265 */
1266 void AddressPopBack();
1267
1268 /**
1269 * @brief Inserts an address at the specified position in this block.
1270 * @param position an Iterator pointing to the position in this block to
1271 * insert the address.
1272 * @param value the address to insert.
1273 * @return An iterator pointing to the newly inserted address.
1274 */
1276
1277 /**
1278 * @brief Removes the address at the specified position.
1279 * @param position an Iterator pointing to the address to erase.
1280 * @return an iterator pointing to the next address in the block.
1281 */
1283
1284 /**
1285 * @brief Removes all addresses from [first, last) (includes first, not
1286 * includes last).
1287 * @param first an Iterator pointing to the first address to erase
1288 * (inclusive).
1289 * @param last an Iterator pointing to the element past the last address to
1290 * erase.
1291 * @return an iterator pointing to the next address in the block.
1292 */
1294
1295 /**
1296 * @brief Removes all addresses from this block.
1297 */
1298 void AddressClear();
1299
1300 /* Prefix methods */
1301
1302 /**
1303 * @return an iterator to the first prefix in this block.
1304 */
1306
1307 /**
1308 * @return a const iterator to the first prefix in this block.
1309 */
1311
1312 /**
1313 * @return an iterator to the last prefix in this block.
1314 */
1316
1317 /**
1318 * @return a const iterator to the last prefix in this block.
1319 */
1321
1322 /**
1323 * @return the number of prefixes in this block.
1324 */
1325 int PrefixSize() const;
1326
1327 /**
1328 * @return true if there are no prefixes in this block, false otherwise.
1329 */
1330 bool PrefixEmpty() const;
1331
1332 /**
1333 * @return the first prefix in this block.
1334 */
1335 uint8_t PrefixFront() const;
1336
1337 /**
1338 * @return the last prefix in this block.
1339 */
1340 uint8_t PrefixBack() const;
1341
1342 /**
1343 * @brief Prepends a prefix to the front of this block.
1344 * @param prefix the prefix to prepend.
1345 */
1346 void PrefixPushFront(uint8_t prefix);
1347
1348 /**
1349 * @brief Removes a prefix from the front of this block.
1350 */
1351 void PrefixPopFront();
1352
1353 /**
1354 * @brief Appends a prefix to the back of this block.
1355 * @param prefix the prefix to append.
1356 */
1357 void PrefixPushBack(uint8_t prefix);
1358
1359 /**
1360 * @brief Removes a prefix from the back of this block.
1361 */
1362 void PrefixPopBack();
1363
1364 /**
1365 * @brief Inserts a prefix at the specified position in this block.
1366 * @param position an Iterator pointing to the position in this block to
1367 * insert the prefix.
1368 * @param value the prefix to insert.
1369 * @return An iterator pointing to the newly inserted prefix.
1370 */
1371 PrefixIterator PrefixInsert(PrefixIterator position, const uint8_t value);
1372
1373 /**
1374 * @brief Removes the prefix at the specified position.
1375 * @param position an Iterator pointing to the prefix to erase.
1376 * @return an iterator pointing to the next prefix in the block.
1377 */
1379
1380 /**
1381 * @brief Removes all prefixes from [first, last) (includes first, not
1382 * includes last).
1383 * @param first an Iterator pointing to the first prefix to erase
1384 * (inclusive).
1385 * @param last an Iterator pointing to the element past the last prefix to
1386 * erase.
1387 * @return an iterator pointing to the next prefix in the block.
1388 */
1390
1391 /**
1392 * @brief Removes all prefixes from this block.
1393 */
1394 void PrefixClear();
1395
1396 /* Manipulating the TLV block */
1397
1398 /**
1399 * @return an iterator to the first address TLV in this block.
1400 */
1402
1403 /**
1404 * @return a const iterator to the first address TLV in this block.
1405 */
1406 ConstTlvIterator TlvBegin() const;
1407
1408 /**
1409 * @return an iterator to the last address TLV in this block.
1410 */
1412
1413 /**
1414 * @return a const iterator to the last address TLV in this block.
1415 */
1416 ConstTlvIterator TlvEnd() const;
1417
1418 /**
1419 * @return the number of address TLVs in this block.
1420 */
1421 int TlvSize() const;
1422
1423 /**
1424 * @return true if there are no address TLVs in this block, false otherwise.
1425 */
1426 bool TlvEmpty() const;
1427
1428 /**
1429 * @return a smart pointer to the first address TLV in this block.
1430 */
1432
1433 /**
1434 * @return a const smart pointer to the first address TLV in this message.
1435 */
1436 const Ptr<PbbAddressTlv> TlvFront() const;
1437
1438 /**
1439 * @return a smart pointer to the last address TLV in this message.
1440 */
1442
1443 /**
1444 * @return a const smart pointer to the last address TLV in this message.
1445 */
1446 const Ptr<PbbAddressTlv> TlvBack() const;
1447
1448 /**
1449 * @brief Prepends an address TLV to the front of this message.
1450 * @param address a smart pointer to the address TLV to prepend.
1451 */
1452 void TlvPushFront(Ptr<PbbAddressTlv> address);
1453
1454 /**
1455 * @brief Removes an address TLV from the front of this message.
1456 */
1457 void TlvPopFront();
1458
1459 /**
1460 * @brief Appends an address TLV to the back of this message.
1461 * @param address a smart pointer to the address TLV to append.
1462 */
1463 void TlvPushBack(Ptr<PbbAddressTlv> address);
1464
1465 /**
1466 * @brief Removes an address TLV from the back of this message.
1467 */
1468 void TlvPopBack();
1469
1470 /**
1471 * @brief Inserts an address TLV at the specified position in this block.
1472 * @param position an Iterator pointing to the position in this block to
1473 * insert the address TLV.
1474 * @param value the prefix to insert.
1475 * @return An iterator pointing to the newly inserted address TLV.
1476 */
1478
1479 /**
1480 * @brief Removes the address TLV at the specified position.
1481 * @param position an Iterator pointing to the address TLV to erase.
1482 * @return an iterator pointing to the next address TLV in the block.
1483 */
1485
1486 /**
1487 * @brief Removes all address TLVs from [first, last) (includes first, not
1488 * includes last).
1489 * @param first an Iterator pointing to the first address TLV to erase
1490 * (inclusive).
1491 * @param last an Iterator pointing to the element past the last address TLV
1492 * to erase.
1493 * @return an iterator pointing to the next address TLV in the message.
1494 */
1496
1497 /**
1498 * @brief Removes all address TLVs from this block.
1499 */
1500 void TlvClear();
1501
1502 /**
1503 * @return The size (in bytes) needed to serialize this address block.
1504 */
1506
1507 /**
1508 * @brief Serializes this address block into the specified buffer.
1509 * @param start a reference to the point in a buffer to begin serializing.
1510 *
1511 * Users should not need to call this. Blocks will be deserialized by their
1512 * containing packet.
1513 */
1514 void Serialize(Buffer::Iterator& start) const;
1515
1516 /**
1517 * @brief Deserializes an address block from the specified buffer.
1518 * @param start a reference to the point in a buffer to begin deserializing.
1519 *
1520 * Users should not need to call this. Blocks will be deserialized by their
1521 * containing packet.
1522 */
1523 void Deserialize(Buffer::Iterator& start);
1524
1525 /**
1526 * @brief Pretty-prints the contents of this address block.
1527 * @param os a stream object to print to.
1528 */
1529 void Print(std::ostream& os) const;
1530
1531 /**
1532 * @brief Pretty-prints the contents of this address block, with specified
1533 * indentation.
1534 * @param os a stream object to print to.
1535 * @param level level of indentation.
1536 *
1537 * This probably never needs to be called by users. This is used when
1538 * recursively printing sub-objects.
1539 */
1540 void Print(std::ostream& os, int level) const;
1541
1542 /**
1543 * @brief Equality operator for PbbAddressBlock
1544 * @param other PbbAddressBlock to compare to this one
1545 * @returns true if PbbMessages are equal
1546 */
1547 bool operator==(const PbbAddressBlock& other) const;
1548
1549 /**
1550 * @brief Inequality operator for PbbAddressBlock
1551 * @param other PbbAddressBlock to compare to this one
1552 * @returns true if PbbAddressBlock are not equal
1553 */
1554 bool operator!=(const PbbAddressBlock& other) const;
1555
1556 protected:
1557 /**
1558 * @brief Returns address length
1559 * @returns Address length
1560 */
1561 virtual uint8_t GetAddressLength() const = 0;
1562 /**
1563 * @brief Serialize one or more addresses
1564 * @param buffer the buffer to serialize to
1565 * @param iter the iterator to the addresses
1566 */
1567 virtual void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const = 0;
1568 /**
1569 * @brief Deserialize one address
1570 * @param buffer the buffer to deserialize from
1571 * @returns the address
1572 */
1573 virtual Address DeserializeAddress(uint8_t* buffer) const = 0;
1574 /**
1575 * @brief Print one or more addresses
1576 * @param os the output stream
1577 * @param iter the iterator to the addresses
1578 */
1579 virtual void PrintAddress(std::ostream& os, ConstAddressIterator iter) const = 0;
1580
1581 private:
1582 /**
1583 * @brief Get the prefix flags
1584 * @return the prefix flags
1585 */
1586 uint8_t GetPrefixFlags() const;
1587 /**
1588 * @brief Get head and tail
1589 * @param head the head
1590 * @param headlen the head length
1591 * @param tail the tail
1592 * @param taillen the tail length
1593 */
1594 void GetHeadTail(uint8_t* head, uint8_t& headlen, uint8_t* tail, uint8_t& taillen) const;
1595
1596 /**
1597 * @brief Check if the tail is empty
1598 * @param tail the tail
1599 * @param taillen the tail length
1600 * @returns true if the tail is empty
1601 */
1602 bool HasZeroTail(const uint8_t* tail, uint8_t taillen) const;
1603
1604 std::list<Address> m_addressList; //!< Addresses container
1605 std::list<uint8_t> m_prefixList; //!< Prefixes container
1606 PbbAddressTlvBlock m_addressTlvList; //!< PbbAddressTlv container
1607};
1608
1609/**
1610 * @brief Concrete IPv4 specific PbbAddressBlock.
1611 *
1612 * This address block will only contain IPv4 addresses.
1613 */
1615{
1616 public:
1618 ~PbbAddressBlockIpv4() override;
1619
1620 protected:
1621 /**
1622 * @brief Returns address length
1623 * @returns Address length
1624 */
1625 uint8_t GetAddressLength() const override;
1626 void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const override;
1627 Address DeserializeAddress(uint8_t* buffer) const override;
1628 void PrintAddress(std::ostream& os, ConstAddressIterator iter) const override;
1629};
1630
1631/**
1632 * @brief Concrete IPv6 specific PbbAddressBlock.
1633 *
1634 * This address block will only contain IPv6 addresses.
1635 */
1637{
1638 public:
1640 ~PbbAddressBlockIpv6() override;
1641
1642 protected:
1643 /**
1644 * @brief Returns address length
1645 * @returns Address length
1646 */
1647 uint8_t GetAddressLength() const override;
1648 void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const override;
1649 Address DeserializeAddress(uint8_t* buffer) const override;
1650 void PrintAddress(std::ostream& os, ConstAddressIterator iter) const override;
1651};
1652
1653/**
1654 * @brief A packet or message TLV
1655 */
1656class PbbTlv : public SimpleRefCount<PbbTlv>
1657{
1658 public:
1659 PbbTlv();
1660 virtual ~PbbTlv();
1661
1662 /**
1663 * @brief Sets the type of this TLV.
1664 * @param type the type value to set.
1665 */
1666 void SetType(uint8_t type);
1667
1668 /**
1669 * @return the type of this TLV.
1670 */
1671 uint8_t GetType() const;
1672
1673 /**
1674 * @brief Sets the type extension of this TLV.
1675 * @param type the type extension value to set.
1676 *
1677 * The type extension is like a sub-type used to further distinguish between
1678 * TLVs of the same type.
1679 */
1680 void SetTypeExt(uint8_t type);
1681
1682 /**
1683 * @return the type extension for this TLV.
1684 *
1685 * Calling this while HasTypeExt is False is undefined. Make sure you check
1686 * it first. This will be checked by an assert in debug builds.
1687 */
1688 uint8_t GetTypeExt() const;
1689
1690 /**
1691 * @brief Tests whether or not this TLV has a type extension.
1692 * @return true if this TLV has a type extension, false otherwise.
1693 *
1694 * This should be called before calling GetTypeExt to make sure there
1695 * actually is one.
1696 */
1697 bool HasTypeExt() const;
1698
1699 /**
1700 * @brief Sets the value of this message to the specified buffer.
1701 * @param start a buffer instance.
1702 *
1703 * The buffer is _not_ copied until this TLV is serialized. You should not
1704 * change the contents of the buffer you pass in to this function.
1705 */
1706 void SetValue(Buffer start);
1707
1708 /**
1709 * @brief Sets the value of this message to a buffer with the specified data.
1710 * @param buffer a pointer to data to put in the TLVs buffer.
1711 * @param size the size of the buffer.
1712 *
1713 * The buffer *is copied* into a *new buffer instance*. You can free the
1714 * data in the buffer provided anytime you wish.
1715 */
1716 void SetValue(const uint8_t* buffer, uint32_t size);
1717
1718 /**
1719 * @return a Buffer pointing to the value of this TLV.
1720 *
1721 * Calling this while HasValue is False is undefined. Make sure you check it
1722 * first. This will be checked by an assert in debug builds.
1723 */
1724 Buffer GetValue() const;
1725
1726 /**
1727 * @brief Tests whether or not this TLV has a value.
1728 * @return true if this tlv has a TLV, false otherwise.
1729 *
1730 * This should be called before calling GetTypeExt to make sure there
1731 * actually is one.
1732 */
1733 bool HasValue() const;
1734
1735 /**
1736 * @return The size (in bytes) needed to serialize this TLV.
1737 */
1739
1740 /**
1741 * @brief Serializes this TLV into the specified buffer.
1742 * @param start a reference to the point in a buffer to begin serializing.
1743 *
1744 * Users should not need to call this. TLVs will be serialized by their
1745 * containing blocks.
1746 */
1747 void Serialize(Buffer::Iterator& start) const;
1748
1749 /**
1750 * @brief Deserializes a TLV from the specified buffer.
1751 * @param start a reference to the point in a buffer to begin deserializing.
1752 *
1753 * Users should not need to call this. TLVs will be deserialized by their
1754 * containing blocks.
1755 */
1756 void Deserialize(Buffer::Iterator& start);
1757
1758 /**
1759 * @brief Pretty-prints the contents of this TLV.
1760 * @param os a stream object to print to.
1761 */
1762 void Print(std::ostream& os) const;
1763
1764 /**
1765 * @brief Pretty-prints the contents of this TLV, with specified indentation.
1766 * @param os a stream object to print to.
1767 * @param level level of indentation.
1768 *
1769 * This probably never needs to be called by users. This is used when
1770 * recursively printing sub-objects.
1771 */
1772 void Print(std::ostream& os, int level) const;
1773
1774 /**
1775 * @brief Equality operator for PbbTlv
1776 * @param other PbbTlv to compare to this one
1777 * @returns true if PbbTlv are equal
1778 */
1779 bool operator==(const PbbTlv& other) const;
1780
1781 /**
1782 * @brief Inequality operator for PbbTlv
1783 * @param other PbbTlv to compare to this one
1784 * @returns true if PbbTlv are not equal
1785 */
1786 bool operator!=(const PbbTlv& other) const;
1787
1788 protected:
1789 /**
1790 * @brief Set an index as starting point
1791 * @param index the starting index
1792 */
1793 void SetIndexStart(uint8_t index);
1794 /**
1795 * @brief Get the starting point index
1796 * @returns the starting index
1797 */
1798 uint8_t GetIndexStart() const;
1799 /**
1800 * @brief Checks if there is a starting index
1801 * @returns true if the start index has been set
1802 */
1803 bool HasIndexStart() const;
1804
1805 /**
1806 * @brief Set an index as stop point
1807 * @param index the stop index
1808 */
1809 void SetIndexStop(uint8_t index);
1810 /**
1811 * @brief Get the stop point index
1812 * @returns the stop index
1813 */
1814 uint8_t GetIndexStop() const;
1815 /**
1816 * @brief Checks if there is a stop index
1817 * @returns true if the stop index has been set
1818 */
1819 bool HasIndexStop() const;
1820
1821 /**
1822 * @brief Set the multivalue parameter
1823 * @param isMultivalue the multivalue status
1824 */
1825 void SetMultivalue(bool isMultivalue);
1826 /**
1827 * @brief Check the multivalue parameter
1828 * @returns the multivalue status
1829 */
1830 bool IsMultivalue() const;
1831
1832 private:
1833 uint8_t m_type; //!< Type of this TLV.
1834
1835 bool m_hasTypeExt; //!< Extended type present.
1836 uint8_t m_typeExt; //!< Extended type.
1837
1838 bool m_hasIndexStart; //!< Start index present.
1839 uint8_t m_indexStart; //!< Start index.
1840
1841 bool m_hasIndexStop; //!< Stop index present.
1842 uint8_t m_indexStop; //!< Stop index.
1843
1844 bool m_isMultivalue; //!< Is multivalue.
1845 bool m_hasValue; //!< Has value.
1846 Buffer m_value; //!< Value.
1847};
1848
1849/**
1850 * @brief An Address TLV
1851 */
1852class PbbAddressTlv : public PbbTlv
1853{
1854 public:
1855 /**
1856 * @brief Sets the index of the first address in the associated address block
1857 * that this address TLV applies to.
1858 * @param index the index of the first address.
1859 */
1860 void SetIndexStart(uint8_t index);
1861
1862 /**
1863 * @return the first (inclusive) index of the address in the corresponding
1864 * address block that this TLV applies to.
1865 *
1866 * Calling this while HasIndexStart is False is undefined. Make sure you
1867 * check it first. This will be checked by an assert in debug builds.
1868 */
1869 uint8_t GetIndexStart() const;
1870
1871 /**
1872 * @brief Tests whether or not this address TLV has a start index.
1873 * @return true if this address TLV has a start index, false otherwise.
1874 *
1875 * This should be called before calling GetIndexStart to make sure there
1876 * actually is one.
1877 */
1878 bool HasIndexStart() const;
1879
1880 /**
1881 * @brief Sets the index of the last address in the associated address block
1882 * that this address TLV applies to.
1883 * @param index the index of the last address.
1884 */
1885 void SetIndexStop(uint8_t index);
1886
1887 /**
1888 * @return the last (inclusive) index of the address in the corresponding
1889 * PbbAddressBlock that this TLV applies to.
1890 *
1891 * Calling this while HasIndexStop is False is undefined. Make sure you
1892 * check it first. This will be checked by an assert in debug builds.
1893 */
1894 uint8_t GetIndexStop() const;
1895
1896 /**
1897 * @brief Tests whether or not this address TLV has a stop index.
1898 * @return true if this address TLV has a stop index, false otherwise.
1899 *
1900 * This should be called before calling GetIndexStop to make sure there
1901 * actually is one.
1902 */
1903 bool HasIndexStop() const;
1904
1905 /**
1906 * @brief Sets whether or not this address TLV is "multivalue"
1907 * @param isMultivalue whether or not this address TLV should be multivalue.
1908 *
1909 * If true, this means the value associated with this TLV should be divided
1910 * evenly into (GetIndexStop() - GetIndexStart() + 1) values. Otherwise, the
1911 * value is one single value that applies to each address in the range.
1912 */
1913 void SetMultivalue(bool isMultivalue);
1914
1915 /**
1916 * @brief Tests whether or not this address TLV is "multivalue"
1917 * @return whether this address TLV is multivalue or not.
1918 */
1919 bool IsMultivalue() const;
1920};
1921
1922} /* namespace ns3 */
1923
1924#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:1184
void PrefixPopFront()
Removes a prefix from the front of this block.
Definition packetbb.cc:1991
Address AddressFront() const
Definition packetbb.cc:1862
std::list< uint8_t >::iterator PrefixIterator
Prefix iterator.
Definition packetbb.h:1192
int TlvSize() const
Definition packetbb.cc:2071
void AddressPopFront()
Removes an address from the front of this block.
Definition packetbb.cc:1883
uint8_t GetPrefixFlags() const
Get the prefix flags.
Definition packetbb.cc:2425
void PrefixPushFront(uint8_t prefix)
Prepends a prefix to the front of this block.
Definition packetbb.cc:1984
void Print(std::ostream &os) const
Pretty-prints the contents of this address block.
Definition packetbb.cc:2344
PrefixIterator PrefixEnd()
Definition packetbb.cc:1942
std::list< Address > m_addressList
Addresses container.
Definition packetbb.h:1604
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:2034
uint32_t GetSerializedSize() const
Definition packetbb.cc:2162
bool operator!=(const PbbAddressBlock &other) const
Inequality operator for PbbAddressBlock.
Definition packetbb.cc:2419
void Serialize(Buffer::Iterator &start) const
Serializes this address block into the specified buffer.
Definition packetbb.cc:2210
PbbAddressTlvBlock::Iterator TlvIterator
tlvblock iterator
Definition packetbb.h:1197
bool PrefixEmpty() const
Definition packetbb.cc:1963
Ptr< PbbAddressTlv > TlvBack()
Definition packetbb.cc:2099
virtual void PrintAddress(std::ostream &os, ConstAddressIterator iter) const =0
Print one or more addresses.
Ptr< PbbAddressTlv > TlvFront()
Definition packetbb.cc:2085
void GetHeadTail(uint8_t *head, uint8_t &headlen, uint8_t *tail, uint8_t &taillen) const
Get head and tail.
Definition packetbb.cc:2443
void TlvPopBack()
Removes an address TLV from the back of this message.
Definition packetbb.cc:2134
TlvIterator TlvBegin()
Definition packetbb.cc:2043
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:1189
bool TlvEmpty() const
Definition packetbb.cc:2078
int PrefixSize() const
Definition packetbb.cc:1956
void TlvPushBack(Ptr< PbbAddressTlv > address)
Appends an address TLV to the back of this message.
Definition packetbb.cc:2127
Address AddressBack() const
Definition packetbb.cc:1869
void AddressClear()
Removes all addresses from this block.
Definition packetbb.cc:1919
void AddressPushBack(Address address)
Appends an address to the back of this block.
Definition packetbb.cc:1890
AddressIterator AddressErase(AddressIterator position)
Removes the address at the specified position.
Definition packetbb.cc:1904
bool HasZeroTail(const uint8_t *tail, uint8_t taillen) const
Check if the tail is empty.
Definition packetbb.cc:2504
std::list< uint8_t > m_prefixList
Prefixes container.
Definition packetbb.h:1605
void PrefixPushBack(uint8_t prefix)
Appends a prefix to the back of this block.
Definition packetbb.cc:1998
void PrefixPopBack()
Removes a prefix from the back of this block.
Definition packetbb.cc:2005
uint8_t PrefixFront() const
Definition packetbb.cc:1970
PrefixIterator PrefixBegin()
Definition packetbb.cc:1928
void AddressPopBack()
Removes an address from the back of this block.
Definition packetbb.cc:1897
PrefixIterator PrefixErase(PrefixIterator position)
Removes the prefix at the specified position.
Definition packetbb.cc:2019
virtual Address DeserializeAddress(uint8_t *buffer) const =0
Deserialize one address.
uint8_t PrefixBack() const
Definition packetbb.cc:1977
void TlvClear()
Removes all address TLVs from this block.
Definition packetbb.cc:2155
PbbAddressTlvBlock::ConstIterator ConstTlvIterator
tlvblock const iterator
Definition packetbb.h:1199
PrefixIterator PrefixInsert(PrefixIterator position, const uint8_t value)
Inserts a prefix at the specified position in this block.
Definition packetbb.cc:2012
void TlvPushFront(Ptr< PbbAddressTlv > address)
Prepends an address TLV to the front of this message.
Definition packetbb.cc:2113
void TlvPopFront()
Removes an address TLV from the front of this message.
Definition packetbb.cc:2120
virtual ~PbbAddressBlock()
Definition packetbb.cc:1812
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:2290
AddressIterator AddressBegin()
Definition packetbb.cc:1820
TlvIterator TlvErase(TlvIterator position)
Removes the address TLV at the specified position.
Definition packetbb.cc:2141
std::list< uint8_t >::const_iterator ConstPrefixIterator
Prefix const iterator.
Definition packetbb.h:1194
void AddressPushFront(Address address)
Prepends an address to the front of this block.
Definition packetbb.cc:1876
std::list< Address >::iterator AddressIterator
Address iterator.
Definition packetbb.h:1187
AddressIterator AddressEnd()
Definition packetbb.cc:1834
bool AddressEmpty() const
Definition packetbb.cc:1855
bool operator==(const PbbAddressBlock &other) const
Equality operator for PbbAddressBlock.
Definition packetbb.cc:2379
TlvIterator TlvEnd()
Definition packetbb.cc:2057
PbbAddressTlvBlock m_addressTlvList
PbbAddressTlv container.
Definition packetbb.h:1606
int AddressSize() const
Definition packetbb.cc:1848
Concrete IPv4 specific PbbAddressBlock.
Definition packetbb.h:1615
uint8_t GetAddressLength() const override
Returns address length.
Definition packetbb.cc:2531
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition packetbb.cc:2552
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition packetbb.cc:2538
~PbbAddressBlockIpv4() override
Definition packetbb.cc:2525
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition packetbb.cc:2545
Concrete IPv6 specific PbbAddressBlock.
Definition packetbb.h:1637
~PbbAddressBlockIpv6() override
Definition packetbb.cc:2565
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition packetbb.cc:2578
uint8_t GetAddressLength() const override
Returns address length.
Definition packetbb.cc:2571
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition packetbb.cc:2592
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition packetbb.cc:2585
A block of Address TLVs (PbbAddressTlv).
Definition packetbb.h:209
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition packetbb.cc:433
void PushBack(Ptr< PbbAddressTlv > tlv)
Appends an Address TLV to the back of this block.
Definition packetbb.cc:374
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition packetbb.cc:474
Iterator Erase(Iterator position)
Removes the Address TLV at the specified position.
Definition packetbb.cc:395
std::list< Ptr< PbbAddressTlv > > m_tlvList
PbbAddressTlv container.
Definition packetbb.h:367
void PopFront()
Removes an AddressTLV from the front of this block.
Definition packetbb.cc:367
bool operator!=(const PbbAddressTlvBlock &other) const
Inequality operator for PbbAddressTlvBlock.
Definition packetbb.cc:524
std::list< Ptr< PbbAddressTlv > >::const_iterator ConstIterator
PbbAddressTlv const iterator for PbbAddressTlvBlock.
Definition packetbb.h:214
void Clear()
Removes all Address TLVs from this block.
Definition packetbb.cc:409
std::list< Ptr< PbbAddressTlv > >::iterator Iterator
PbbAddressTlv iterator for PbbAddressTlvBlock.
Definition packetbb.h:212
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition packetbb.cc:456
uint32_t GetSerializedSize() const
Definition packetbb.cc:420
Ptr< PbbAddressTlv > Front() const
Definition packetbb.cc:346
Ptr< PbbAddressTlv > Back() const
Definition packetbb.cc:353
Iterator Insert(Iterator position, const Ptr< PbbAddressTlv > tlv)
Inserts an Address TLV at the specified position in this block.
Definition packetbb.cc:388
void PushFront(Ptr< PbbAddressTlv > tlv)
Prepends an Address TLV to the front of this block.
Definition packetbb.cc:360
void PopBack()
Removes an Address TLV from the back of this block.
Definition packetbb.cc:381
bool operator==(const PbbAddressTlvBlock &other) const
Equality operator for PbbAddressTlvBlock.
Definition packetbb.cc:504
An Address TLV.
Definition packetbb.h:1853
bool HasIndexStart() const
Tests whether or not this address TLV has a start index.
Definition packetbb.cc:2998
bool IsMultivalue() const
Tests whether or not this address TLV is "multivalue".
Definition packetbb.cc:3033
void SetMultivalue(bool isMultivalue)
Sets whether or not this address TLV is "multivalue".
Definition packetbb.cc:3026
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:2984
bool HasIndexStop() const
Tests whether or not this address TLV has a stop index.
Definition packetbb.cc:3019
uint8_t GetIndexStop() const
Definition packetbb.cc:3012
uint8_t GetIndexStart() const
Definition packetbb.cc:2991
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:3005
A message within a PbbPacket packet.
Definition packetbb.h:696
void AddressBlockPushFront(Ptr< PbbAddressBlock > block)
Prepends an address block to the front of this message.
Definition packetbb.cc:1336
uint16_t m_sequenceNumber
Sequence number.
Definition packetbb.h:1118
virtual PbbAddressLength GetAddressLength() const =0
Returns address length (IPV4 3 or IPV6 15)
Definition packetbb.cc:1044
std::list< Ptr< PbbAddressBlock > >::iterator AddressBlockIterator
PbbAddressBlock iterator.
Definition packetbb.h:703
bool HasOriginatorAddress() const
Tests whether or not this message has an originator address.
Definition packetbb.cc:1067
bool m_hasHopLimit
Hop limit present.
Definition packetbb.h:1111
void TlvPopFront()
Removes a message TLV from the front of this message.
Definition packetbb.cc:1222
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a message TLV to the front of this message.
Definition packetbb.cc:1215
Address m_originatorAddress
originator address
Definition packetbb.h:1109
uint8_t GetType() const
Definition packetbb.cc:1037
bool HasHopLimit() const
Tests whether or not this message has a hop limit.
Definition packetbb.cc:1090
bool operator!=(const PbbMessage &other) const
Inequality operator for PbbMessage.
Definition packetbb.cc:1698
int AddressBlockSize() const
Definition packetbb.cc:1294
AddressBlockIterator AddressBlockBegin()
Definition packetbb.cc:1266
void Deserialize(Buffer::Iterator &start)
Deserializes a message from the specified buffer.
Definition packetbb.cc:1514
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator.
Definition packetbb.h:701
AddressBlockIterator AddressBlockEnd()
Definition packetbb.cc:1280
void SetType(uint8_t type)
Sets the type for this message.
Definition packetbb.cc:1030
std::list< Ptr< PbbAddressBlock > >::const_iterator ConstAddressBlockIterator
PbbAddressBlock const iterator.
Definition packetbb.h:705
void Serialize(Buffer::Iterator &start) const
Serializes this message into the specified buffer.
Definition packetbb.cc:1427
Ptr< PbbTlv > TlvFront()
Definition packetbb.cc:1187
TlvIterator TlvErase(TlvIterator position)
Removes the message TLV at the specified position.
Definition packetbb.cc:1243
std::list< Ptr< PbbAddressBlock > > m_addressBlockList
PbbAddressBlock container.
Definition packetbb.h:1103
void SetOriginatorAddress(Address address)
Sets the address for the node that created this packet.
Definition packetbb.cc:1051
void SetHopLimit(uint8_t hoplimit)
Sets the maximum number of hops this message should travel.
Definition packetbb.cc:1074
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:1482
Address GetOriginatorAddress() const
Definition packetbb.cc:1059
void TlvClear()
Removes all message TLVs from this block.
Definition packetbb.cc:1257
uint8_t m_hopLimit
Hop limit.
Definition packetbb.h:1112
void AddressBlockPushBack(Ptr< PbbAddressBlock > block)
Appends an address block to the front of this message.
Definition packetbb.cc:1350
TlvIterator TlvBegin()
Definition packetbb.cc:1145
void TlvPopBack()
Removes a message TLV from the back of this message.
Definition packetbb.cc:1236
uint16_t GetSequenceNumber() const
Definition packetbb.cc:1128
bool m_hasOriginatorAddress
Originator address present.
Definition packetbb.h:1108
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:1136
uint8_t GetHopLimit() const
Definition packetbb.cc:1082
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator.
Definition packetbb.h:699
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:1097
void Print(std::ostream &os) const
Pretty-prints the contents of this message.
Definition packetbb.cc:1556
void SetSequenceNumber(uint16_t seqnum)
Sets the sequence number of this message.
Definition packetbb.cc:1120
int TlvSize() const
Definition packetbb.cc:1173
bool m_hasHopCount
Hop count present.
Definition packetbb.h:1114
void AddressBlockClear()
Removes all address blocks from this message.
Definition packetbb.cc:1379
virtual ~PbbMessage()
Definition packetbb.cc:1023
virtual Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const =0
Deserialize an address block.
PbbTlvBlock m_tlvList
PbbTlvBlock.
Definition packetbb.h:1102
void TlvPushBack(Ptr< PbbTlv > tlv)
Appends a message TLV to the back of this message.
Definition packetbb.cc:1229
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:1364
Ptr< PbbAddressBlock > AddressBlockBack()
Definition packetbb.cc:1322
uint8_t GetHopCount() const
Definition packetbb.cc:1105
void AddressBlockPopFront()
Removes an address block from the front of this message.
Definition packetbb.cc:1343
bool operator==(const PbbMessage &other) const
Equality operator for PbbMessage.
Definition packetbb.cc:1609
PbbAddressLength m_addrSize
the address size
Definition packetbb.h:1106
uint8_t m_hopCount
Hop count.
Definition packetbb.h:1115
bool m_hasSequenceNumber
Sequence number present.
Definition packetbb.h:1117
uint32_t GetSerializedSize() const
Definition packetbb.cc:1390
TlvIterator TlvEnd()
Definition packetbb.cc:1159
Ptr< PbbAddressBlock > AddressBlockFront()
Definition packetbb.cc:1308
bool AddressBlockEmpty() const
Definition packetbb.cc:1301
bool TlvEmpty() const
Definition packetbb.cc:1180
bool HasHopCount() const
Tests whether or not this message has a hop count.
Definition packetbb.cc:1113
Ptr< PbbTlv > TlvBack()
Definition packetbb.cc:1201
uint8_t m_type
the type for this message
Definition packetbb.h:1105
void AddressBlockPopBack()
Removes an address block from the back of this message.
Definition packetbb.cc:1357
Concrete IPv4 specific PbbMessage.
Definition packetbb.h:1127
void PrintOriginatorAddress(std::ostream &os) const override
Print the originator address.
Definition packetbb.cc:1739
void SerializeOriginatorAddress(Buffer::Iterator &start) const override
Serialize the originator address.
Definition packetbb.cc:1718
PbbAddressLength GetAddressLength() const override
Returns address length (IPV4 3 or IPV6 15)
Definition packetbb.cc:1711
Address DeserializeOriginatorAddress(Buffer::Iterator &start) const override
Deserialize the originator address.
Definition packetbb.cc:1728
Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const override
Deserialize an address block.
Definition packetbb.cc:1746
Concrete IPv6 specific PbbMessage class.
Definition packetbb.h:1155
Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const override
Deserialize an address block.
Definition packetbb.cc:1797
void PrintOriginatorAddress(std::ostream &os) const override
Print the originator address.
Definition packetbb.cc:1790
void SerializeOriginatorAddress(Buffer::Iterator &start) const override
Serialize the originator address.
Definition packetbb.cc:1769
PbbAddressLength GetAddressLength() const override
Returns address length (IPV4 3 or IPV6 15)
Definition packetbb.cc:1762
Address DeserializeOriginatorAddress(Buffer::Iterator &start) const override
Deserialize the originator address.
Definition packetbb.cc:1779
Main PacketBB Packet object.
Definition packetbb.h:379
std::list< Ptr< PbbMessage > >::iterator MessageIterator
PbbMessage Iterator for PbbPacket.
Definition packetbb.h:386
~PbbPacket() override
Definition packetbb.cc:539
uint8_t m_version
version
Definition packetbb.h:681
TlvIterator TlvBegin()
Definition packetbb.cc:585
std::list< Ptr< PbbMessage > >::const_iterator ConstMessageIterator
PbbMessage Const Iterator for PbbPacket.
Definition packetbb.h:388
MessageIterator MessageEnd()
Definition packetbb.cc:720
std::list< Ptr< PbbMessage > > m_messageList
PbbTlvBlock container.
Definition packetbb.h:679
bool m_hasseqnum
Sequence number present.
Definition packetbb.h:683
void TlvPushBack(Ptr< PbbTlv > tlv)
Appends a packet TLV to the back of this packet.
Definition packetbb.cc:669
bool TlvEmpty() const
Definition packetbb.cc:620
void TlvClear()
Removes all packet TLVs from this packet.
Definition packetbb.cc:697
static TypeId GetTypeId()
Get the type ID.
Definition packetbb.cc:829
void TlvPopBack()
Removes a packet TLV from the back of this block.
Definition packetbb.cc:676
void TlvPopFront()
Removes a packet TLV from the front of this packet.
Definition packetbb.cc:662
void MessagePushBack(Ptr< PbbMessage > message)
Appends a message to the back of this packet.
Definition packetbb.cc:790
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator for PbbPacket.
Definition packetbb.h:382
Ptr< PbbTlv > TlvFront()
Definition packetbb.cc:627
TlvIterator TlvEnd()
Definition packetbb.cc:599
void MessageClear()
Removes all messages from this packet.
Definition packetbb.cc:818
Ptr< PbbMessage > MessageFront()
Definition packetbb.cc:748
void SetSequenceNumber(uint16_t number)
Sets the sequence number of this packet.
Definition packetbb.cc:553
void MessagePopFront()
Removes a message from the front of this packet.
Definition packetbb.cc:783
void ForceTlv(bool forceTlv)
Forces a packet to write a TLV list even if it's empty, ignoring the phastlv bit.
Definition packetbb.cc:576
uint32_t GetSerializedSize() const override
Definition packetbb.cc:845
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a packet TLV to the front of this packet.
Definition packetbb.cc:655
bool MessageEmpty() const
Definition packetbb.cc:741
uint16_t GetSequenceNumber() const
Definition packetbb.cc:561
void MessagePopBack()
Removes a message from the back of this packet.
Definition packetbb.cc:797
bool HasSequenceNumber() const
Tests whether or not this packet has a sequence number.
Definition packetbb.cc:569
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition packetbb.cc:839
Ptr< PbbTlv > TlvBack()
Definition packetbb.cc:641
MessageIterator MessageBegin()
Definition packetbb.cc:706
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:683
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:776
int TlvSize() const
Definition packetbb.cc:613
void Serialize(Buffer::Iterator start) const override
Serializes this packet into the specified buffer.
Definition packetbb.cc:870
Ptr< PbbMessage > MessageBack()
Definition packetbb.cc:762
void Print(std::ostream &os) const override
Pretty-prints the contents of this block.
Definition packetbb.cc:937
bool operator!=(const PbbPacket &other) const
Inequality operator for PbbPacket.
Definition packetbb.cc:1005
uint16_t m_seqnum
Sequence number.
Definition packetbb.h:684
uint8_t GetVersion() const
Definition packetbb.cc:546
uint32_t Deserialize(Buffer::Iterator start) override
Deserializes a packet from the specified buffer.
Definition packetbb.cc:903
bool m_forceTlv
Force writing a TLV list (even if it's empty)
Definition packetbb.h:685
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator for PbbPacket.
Definition packetbb.h:384
int MessageSize() const
Definition packetbb.cc:734
PbbTlvBlock m_tlvList
PbbTlv container.
Definition packetbb.h:678
bool operator==(const PbbPacket &other) const
Equality operator for PbbPacket.
Definition packetbb.cc:960
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:200
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
bool operator!=(const PbbTlvBlock &other) const
Inequality operator for PbbTlvBlock.
Definition packetbb.cc:285
A packet or message TLV.
Definition packetbb.h:1657
bool m_isMultivalue
Is multivalue.
Definition packetbb.h:1844
uint8_t m_indexStop
Stop index.
Definition packetbb.h:1842
void SetValue(Buffer start)
Sets the value of this message to the specified buffer.
Definition packetbb.cc:2714
uint8_t GetIndexStop() const
Get the stop point index.
Definition packetbb.cc:2685
bool operator!=(const PbbTlv &other) const
Inequality operator for PbbTlv.
Definition packetbb.cc:2976
bool HasTypeExt() const
Tests whether or not this TLV has a type extension.
Definition packetbb.cc:2647
uint8_t GetIndexStart() const
Get the starting point index.
Definition packetbb.cc:2662
bool HasValue() const
Tests whether or not this TLV has a value.
Definition packetbb.cc:2739
bool HasIndexStart() const
Checks if there is a starting index.
Definition packetbb.cc:2670
uint8_t m_indexStart
Start index.
Definition packetbb.h:1839
uint8_t m_type
Type of this TLV.
Definition packetbb.h:1833
Buffer m_value
Value.
Definition packetbb.h:1846
bool m_hasIndexStart
Start index present.
Definition packetbb.h:1838
bool operator==(const PbbTlv &other) const
Equality operator for PbbTlv.
Definition packetbb.cc:2931
void Serialize(Buffer::Iterator &start) const
Serializes this TLV into the specified buffer.
Definition packetbb.cc:2784
bool IsMultivalue() const
Check the multivalue parameter.
Definition packetbb.cc:2707
void SetType(uint8_t type)
Sets the type of this TLV.
Definition packetbb.cc:2617
bool m_hasIndexStop
Stop index present.
Definition packetbb.h:1841
uint8_t GetTypeExt() const
Definition packetbb.cc:2639
void SetIndexStop(uint8_t index)
Set an index as stop point.
Definition packetbb.cc:2677
bool HasIndexStop() const
Checks if there is a stop index.
Definition packetbb.cc:2693
void SetMultivalue(bool isMultivalue)
Set the multivalue parameter.
Definition packetbb.cc:2700
void Print(std::ostream &os) const
Pretty-prints the contents of this TLV.
Definition packetbb.cc:2886
virtual ~PbbTlv()
Definition packetbb.cc:2610
void SetIndexStart(uint8_t index)
Set an index as starting point.
Definition packetbb.cc:2654
Buffer GetValue() const
Definition packetbb.cc:2731
uint8_t m_typeExt
Extended type.
Definition packetbb.h:1836
bool m_hasTypeExt
Extended type present.
Definition packetbb.h:1835
uint8_t GetType() const
Definition packetbb.cc:2624
uint32_t GetSerializedSize() const
Definition packetbb.cc:2746
void SetTypeExt(uint8_t type)
Sets the type extension of this TLV.
Definition packetbb.cc:2631
void Deserialize(Buffer::Iterator &start)
Deserializes a TLV from the specified buffer.
Definition packetbb.cc:2841
bool m_hasValue
Has value.
Definition packetbb.h:1845
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
a unique identifier for an interface.
Definition type-id.h:49
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