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 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Tom Wambold <tom5760@gmail.com>
19 */
20/* These classes implement RFC 5444 - The Generalized Mobile Ad Hoc Network
21 * (MANET) Packet/PbbMessage Format
22 * See: https://datatracker.ietf.org/doc/html/rfc5444 for details */
23
24#ifndef PACKETBB_H
25#define PACKETBB_H
26
27#include "ns3/address.h"
28#include "ns3/buffer.h"
29#include "ns3/header.h"
30#include "ns3/ptr.h"
31#include "ns3/simple-ref-count.h"
32
33#include <list>
34
35namespace ns3
36{
37
38/* Forward declare objects */
39class PbbMessage;
40class PbbAddressBlock;
41class PbbTlv;
42class PbbAddressTlv;
43
44/** Used in Messages to determine whether it contains IPv4 or IPv6 addresses */
46{
47 IPV4 = 3,
48 IPV6 = 15,
49};
50
51/**
52 * \brief A block of packet or message TLVs (PbbTlv).
53 *
54 * Acts similar to a C++ STL container. Should not be used for Address TLVs.
55 */
57{
58 public:
59 /// PbbTlv container iterator
60 typedef std::list<Ptr<PbbTlv>>::iterator Iterator;
61 /// PbbTlv container const iterator
62 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstIterator;
63
66
67 /**
68 * \return an iterator to the first TLV in this block.
69 */
71
72 /**
73 * \return a const iterator to the first TLV in this block.
74 */
75 ConstIterator Begin() const;
76
77 /**
78 * \return an iterator to the past-the-end element in this block.
79 */
80 Iterator End();
81
82 /**
83 * \return a const iterator to the past-the-end element in this block.
84 */
85 ConstIterator End() const;
86
87 /**
88 * \return the number of TLVs in this block.
89 */
90 int Size() const;
91
92 /**
93 * \return true if there are no TLVs in this block, false otherwise.
94 */
95 bool Empty() const;
96
97 /**
98 * \return a smart pointer to the first TLV in this block.
99 */
100 Ptr<PbbTlv> Front() const;
101
102 /**
103 * \return a smart pointer to the last TLV in this block.
104 */
105 Ptr<PbbTlv> Back() const;
106
107 /**
108 * \brief Prepends a TLV to the front of this block.
109 * \param tlv a smart pointer to the TLV to prepend.
110 */
111 void PushFront(Ptr<PbbTlv> tlv);
112
113 /**
114 * \brief Removes a TLV from the front of this block.
115 */
116 void PopFront();
117
118 /**
119 * \brief Appends a TLV to the back of this block.
120 * \param tlv a smart pointer to the TLV to append.
121 */
122 void PushBack(Ptr<PbbTlv> tlv);
123
124 /**
125 * \brief Removes a TLV from the back of this block.
126 */
127 void PopBack();
128
129 /**
130 * \brief Inserts a TLV at the specified position in this block.
131 * \param position an Iterator pointing to the position in this block to
132 * insert the TLV.
133 * \param tlv a smart pointer to the TLV to insert.
134 * \return An iterator pointing to the newly inserted TLV.
135 */
136 Iterator Insert(Iterator position, const Ptr<PbbTlv> tlv);
137
138 /**
139 * \brief Removes the TLV at the specified position.
140 * \param position an Iterator pointing to the TLV to erase.
141 * \return an iterator pointing to the next TLV in the block.
142 */
143 Iterator Erase(Iterator position);
144
145 /**
146 * \brief Removes all TLVs from [first, last) (includes first, not includes
147 * last).
148 * \param first an Iterator pointing to the first TLV to erase (inclusive).
149 * \param last an Iterator pointing to the element past the last TLV to erase.
150 * \return an iterator pointing to the next TLV in the block.
151 */
153
154 /**
155 * \brief Removes all TLVs from this block.
156 */
157 void Clear();
158
159 /**
160 * \return The size (in bytes) needed to serialize this block.
161 */
163
164 /**
165 * \brief Serializes this block into the specified buffer.
166 * \param start a reference to the point in a buffer to begin serializing.
167 *
168 * Users should not need to call this. Blocks will be serialized by their
169 * containing packet.
170 */
171 void Serialize(Buffer::Iterator& start) const;
172
173 /**
174 * \brief Deserializes a block from the specified buffer.
175 * \param start a reference to the point in a buffer to begin deserializing.
176 *
177 * Users should not need to call this. Blocks will be deserialized by their
178 * containing packet.
179 */
180 void Deserialize(Buffer::Iterator& start);
181
182 /**
183 * \brief Pretty-prints the contents of this block.
184 * \param os a stream object to print to.
185 */
186 void Print(std::ostream& os) const;
187
188 /**
189 * \brief Pretty-prints the contents of this block, with specified indentation.
190 * \param os a stream object to print to.
191 * \param level level of indentation.
192 *
193 * This probably never needs to be called by users. This is used when
194 * recursively printing sub-objects.
195 */
196 void Print(std::ostream& os, int level) const;
197
198 /**
199 * \brief Equality operator for PbbTlvBlock
200 * \param other PbbTlvBlock to compare this one to
201 * \returns true if the blocks are equal
202 */
203 bool operator==(const PbbTlvBlock& other) const;
204 /**
205 * \brief Inequality operator for PbbTlvBlock
206 * \param other PbbTlvBlock to compare this one to
207 * \returns true if the blocks are not equal
208 */
209 bool operator!=(const PbbTlvBlock& other) const;
210
211 private:
212 std::list<Ptr<PbbTlv>> m_tlvList; //!< PbbTlv container
213};
214
215/**
216 * \brief A block of Address TLVs (PbbAddressTlv).
217 *
218 * Acts similar to a C++ STL container.
219 */
221{
222 public:
223 /// PbbAddressTlv iterator for PbbAddressTlvBlock
224 typedef std::list<Ptr<PbbAddressTlv>>::iterator Iterator;
225 /// PbbAddressTlv const iterator for PbbAddressTlvBlock
226 typedef std::list<Ptr<PbbAddressTlv>>::const_iterator ConstIterator;
227
230
231 /**
232 * \return an iterator to the first Address TLV in this block.
233 */
234 Iterator Begin();
235
236 /**
237 * \return a const iterator to the first Address TLV in this block.
238 */
239 ConstIterator Begin() const;
240
241 /**
242 * \return an iterator to the past-the-end element in this block.
243 */
244 Iterator End();
245
246 /**
247 * \return a const iterator to the past-the-end element in this block.
248 */
249 ConstIterator End() const;
250
251 /**
252 * \return the number of Address TLVs in this block.
253 */
254 int Size() const;
255
256 /**
257 * \return true if there are no Address TLVs in this block, false otherwise.
258 */
259 bool Empty() const;
260
261 /**
262 * \return the first Address TLV in this block.
263 */
265
266 /**
267 * \return the last AddressTLV in this block.
268 */
269 Ptr<PbbAddressTlv> Back() const;
270
271 /**
272 * \brief Prepends an Address TLV to the front of this block.
273 * \param tlv a smart pointer to the Address TLV to prepend.
274 */
276
277 /**
278 * \brief Removes an AddressTLV from the front of this block.
279 */
280 void PopFront();
281
282 /**
283 * \brief Appends an Address TLV to the back of this block.
284 * \param tlv a smart pointer to the Address TLV to append.
285 */
287
288 /**
289 * \brief Removes an Address TLV from the back of this block.
290 */
291 void PopBack();
292
293 /**
294 * \brief Inserts an Address TLV at the specified position in this block.
295 * \param position an Iterator pointing to the position in this block to
296 * insert the Address TLV.
297 * \param tlv a smart pointer to the Address TLV to insert.
298 * \return An iterator pointing to the newly inserted Address TLV.
299 */
300 Iterator Insert(Iterator position, const Ptr<PbbAddressTlv> tlv);
301
302 /**
303 * \brief Removes the Address TLV at the specified position.
304 * \param position an Iterator pointing to the Address TLV to erase.
305 * \return an iterator pointing to the next Address TLV in the block.
306 */
307 Iterator Erase(Iterator position);
308
309 /**
310 * \brief Removes all Address TLVs from [first, last) (includes first, not
311 * includes last).
312 * \param first an Iterator pointing to the first Address TLV to erase
313 * (inclusive).
314 * \param last an Iterator pointing to the element past the last Address TLV
315 * to erase.
316 * \return an iterator pointing to the next Address TLV in the block.
317 */
319
320 /**
321 * \brief Removes all Address TLVs from this block.
322 */
323 void Clear();
324
325 /**
326 * \return The size (in bytes) needed to serialize this block.
327 */
329
330 /**
331 * \brief Serializes this block into the specified buffer.
332 * \param start a reference to the point in a buffer to begin serializing.
333 *
334 * Users should not need to call this. Blocks will be serialized by their
335 * containing packet.
336 */
337 void Serialize(Buffer::Iterator& start) const;
338
339 /**
340 * \brief Deserializes a block from the specified buffer.
341 * \param start a reference to the point in a buffer to begin deserializing.
342 *
343 * Users should not need to call this. Blocks will be deserialized by their
344 * containing packet.
345 */
346 void Deserialize(Buffer::Iterator& start);
347
348 /**
349 * \brief Pretty-prints the contents of this block.
350 * \param os a stream object to print to.
351 */
352 void Print(std::ostream& os) const;
353
354 /**
355 * \brief Pretty-prints the contents of this block, with specified indentation.
356 * \param os a stream object to print to.
357 * \param level level of indentation.
358 *
359 * This probably never needs to be called by users. This is used when
360 * recursively printing sub-objects.
361 */
362 void Print(std::ostream& os, int level) const;
363
364 /**
365 * \brief Equality operator for PbbAddressTlvBlock
366 * \param other PbbAddressTlvBlock to compare to this one
367 * \returns true if PbbAddressTlvBlock are equal
368 */
369 bool operator==(const PbbAddressTlvBlock& other) const;
370
371 /**
372 * \brief Inequality operator for PbbAddressTlvBlock
373 * \param other PbbAddressTlvBlock to compare to this one
374 * \returns true if PbbAddressTlvBlock are not equal
375 */
376 bool operator!=(const PbbAddressTlvBlock& other) const;
377
378 private:
379 std::list<Ptr<PbbAddressTlv>> m_tlvList; //!< PbbAddressTlv container
380};
381
382/**
383 * \brief Main PacketBB Packet object.
384 *
385 * A PacketBB packet is made up of zero or more packet TLVs (PbbTlv), and zero
386 * or more messages (PbbMessage).
387 *
388 * See: \RFC{5444} for details.
389 */
390class PbbPacket : public SimpleRefCount<PbbPacket, Header>
391{
392 public:
393 /// PbbTlv iterator for PbbPacket
394 typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
395 /// PbbTlv const iterator for PbbPacket
396 typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
397 /// PbbMessage Iterator for PbbPacket
398 typedef std::list<Ptr<PbbMessage>>::iterator MessageIterator;
399 /// PbbMessage Const Iterator for PbbPacket
400 typedef std::list<Ptr<PbbMessage>>::const_iterator ConstMessageIterator;
401
402 PbbPacket();
403 ~PbbPacket() override;
404
405 /**
406 * \return the version of PacketBB that constructed this packet.
407 *
408 * This will always return 0 for packets constructed using this API.
409 */
410 uint8_t GetVersion() const;
411
412 /**
413 * \brief Sets the sequence number of this packet.
414 * \param number the sequence number.
415 */
416 void SetSequenceNumber(uint16_t number);
417
418 /**
419 * \return the sequence number of this packet.
420 *
421 * Calling this while HasSequenceNumber is False is undefined. Make sure you
422 * check it first. This will be checked by an assert in debug builds.
423 */
424 uint16_t GetSequenceNumber() const;
425
426 /**
427 * \brief Tests whether or not this packet has a sequence number.
428 * \return true if this packet has a sequence number, false otherwise.
429 *
430 * This should be called before calling GetSequenceNumber to make sure there
431 * actually is one.
432 */
433 bool HasSequenceNumber() const;
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 */
492 void TlvPushFront(Ptr<PbbTlv> tlv);
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 */
503 void TlvPushBack(Ptr<PbbTlv> tlv);
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};
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:101
iterator in a Buffer instance
Definition: buffer.h:100
automatically resized byte buffer
Definition: buffer.h:94
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:1995
Address AddressFront() const
Definition: packetbb.cc:1866
std::list< uint8_t >::iterator PrefixIterator
Prefix iterator.
Definition: packetbb.h:1192
int TlvSize() const
Definition: packetbb.cc:2075
void AddressPopFront()
Removes an address from the front of this block.
Definition: packetbb.cc:1887
uint8_t GetPrefixFlags() const
Get the prefix flags.
Definition: packetbb.cc:2429
void PrefixPushFront(uint8_t prefix)
Prepends a prefix to the front of this block.
Definition: packetbb.cc:1988
void Print(std::ostream &os) const
Pretty-prints the contents of this address block.
Definition: packetbb.cc:2348
PrefixIterator PrefixEnd()
Definition: packetbb.cc:1946
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:2038
uint32_t GetSerializedSize() const
Definition: packetbb.cc:2166
bool operator!=(const PbbAddressBlock &other) const
Inequality operator for PbbAddressBlock.
Definition: packetbb.cc:2423
void Serialize(Buffer::Iterator &start) const
Serializes this address block into the specified buffer.
Definition: packetbb.cc:2214
PbbAddressTlvBlock::Iterator TlvIterator
tlvblock iterator
Definition: packetbb.h:1197
bool PrefixEmpty() const
Definition: packetbb.cc:1967
Ptr< PbbAddressTlv > TlvBack()
Definition: packetbb.cc:2103
virtual void PrintAddress(std::ostream &os, ConstAddressIterator iter) const =0
Print one or more addresses.
Ptr< PbbAddressTlv > TlvFront()
Definition: packetbb.cc:2089
void GetHeadTail(uint8_t *head, uint8_t &headlen, uint8_t *tail, uint8_t &taillen) const
Get head and tail.
Definition: packetbb.cc:2447
void TlvPopBack()
Removes an address TLV from the back of this message.
Definition: packetbb.cc:2138
TlvIterator TlvBegin()
Definition: packetbb.cc:2047
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:2082
int PrefixSize() const
Definition: packetbb.cc:1960
void TlvPushBack(Ptr< PbbAddressTlv > address)
Appends an address TLV to the back of this message.
Definition: packetbb.cc:2131
Address AddressBack() const
Definition: packetbb.cc:1873
void AddressClear()
Removes all addresses from this block.
Definition: packetbb.cc:1923
void AddressPushBack(Address address)
Appends an address to the back of this block.
Definition: packetbb.cc:1894
AddressIterator AddressErase(AddressIterator position)
Removes the address at the specified position.
Definition: packetbb.cc:1908
bool HasZeroTail(const uint8_t *tail, uint8_t taillen) const
Check if the tail is empty.
Definition: packetbb.cc:2508
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:2002
void PrefixPopBack()
Removes a prefix from the back of this block.
Definition: packetbb.cc:2009
uint8_t PrefixFront() const
Definition: packetbb.cc:1974
PrefixIterator PrefixBegin()
Definition: packetbb.cc:1932
void AddressPopBack()
Removes an address from the back of this block.
Definition: packetbb.cc:1901
PrefixIterator PrefixErase(PrefixIterator position)
Removes the prefix at the specified position.
Definition: packetbb.cc:2023
virtual Address DeserializeAddress(uint8_t *buffer) const =0
Deserialize one address.
uint8_t PrefixBack() const
Definition: packetbb.cc:1981
void TlvClear()
Removes all address TLVs from this block.
Definition: packetbb.cc:2159
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:2016
void TlvPushFront(Ptr< PbbAddressTlv > address)
Prepends an address TLV to the front of this message.
Definition: packetbb.cc:2117
void TlvPopFront()
Removes an address TLV from the front of this message.
Definition: packetbb.cc:2124
virtual ~PbbAddressBlock()
Definition: packetbb.cc:1816
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:2294
AddressIterator AddressBegin()
Definition: packetbb.cc:1824
TlvIterator TlvErase(TlvIterator position)
Removes the address TLV at the specified position.
Definition: packetbb.cc:2145
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:1880
std::list< Address >::iterator AddressIterator
Address iterator.
Definition: packetbb.h:1187
AddressIterator AddressEnd()
Definition: packetbb.cc:1838
bool AddressEmpty() const
Definition: packetbb.cc:1859
bool operator==(const PbbAddressBlock &other) const
Equality operator for PbbAddressBlock.
Definition: packetbb.cc:2383
TlvIterator TlvEnd()
Definition: packetbb.cc:2061
PbbAddressTlvBlock m_addressTlvList
PbbAddressTlv container.
Definition: packetbb.h:1606
int AddressSize() const
Definition: packetbb.cc:1852
Concrete IPv4 specific PbbAddressBlock.
Definition: packetbb.h:1615
uint8_t GetAddressLength() const override
Returns address length.
Definition: packetbb.cc:2535
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition: packetbb.cc:2556
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition: packetbb.cc:2542
~PbbAddressBlockIpv4() override
Definition: packetbb.cc:2529
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition: packetbb.cc:2549
Concrete IPv6 specific PbbAddressBlock.
Definition: packetbb.h:1637
~PbbAddressBlockIpv6() override
Definition: packetbb.cc:2569
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition: packetbb.cc:2582
uint8_t GetAddressLength() const override
Returns address length.
Definition: packetbb.cc:2575
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition: packetbb.cc:2596
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition: packetbb.cc:2589
A block of Address TLVs (PbbAddressTlv).
Definition: packetbb.h:221
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition: packetbb.cc:445
void PushBack(Ptr< PbbAddressTlv > tlv)
Appends an Address TLV to the back of this block.
Definition: packetbb.cc:386
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:486
Iterator Erase(Iterator position)
Removes the Address TLV at the specified position.
Definition: packetbb.cc:407
std::list< Ptr< PbbAddressTlv > > m_tlvList
PbbAddressTlv container.
Definition: packetbb.h:379
void PopFront()
Removes an AddressTLV from the front of this block.
Definition: packetbb.cc:379
bool operator!=(const PbbAddressTlvBlock &other) const
Inequality operator for PbbAddressTlvBlock.
Definition: packetbb.cc:536
std::list< Ptr< PbbAddressTlv > >::const_iterator ConstIterator
PbbAddressTlv const iterator for PbbAddressTlvBlock.
Definition: packetbb.h:226
void Clear()
Removes all Address TLVs from this block.
Definition: packetbb.cc:421
std::list< Ptr< PbbAddressTlv > >::iterator Iterator
PbbAddressTlv iterator for PbbAddressTlvBlock.
Definition: packetbb.h:224
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition: packetbb.cc:468
bool Empty() const
Definition: packetbb.cc:351
uint32_t GetSerializedSize() const
Definition: packetbb.cc:432
Ptr< PbbAddressTlv > Front() const
Definition: packetbb.cc:358
Ptr< PbbAddressTlv > Back() const
Definition: packetbb.cc:365
Iterator Insert(Iterator position, const Ptr< PbbAddressTlv > tlv)
Inserts an Address TLV at the specified position in this block.
Definition: packetbb.cc:400
void PushFront(Ptr< PbbAddressTlv > tlv)
Prepends an Address TLV to the front of this block.
Definition: packetbb.cc:372
void PopBack()
Removes an Address TLV from the back of this block.
Definition: packetbb.cc:393
bool operator==(const PbbAddressTlvBlock &other) const
Equality operator for PbbAddressTlvBlock.
Definition: packetbb.cc:516
An Address TLV.
Definition: packetbb.h:1853
bool HasIndexStart() const
Tests whether or not this address TLV has a start index.
Definition: packetbb.cc:3002
bool IsMultivalue() const
Tests whether or not this address TLV is "multivalue".
Definition: packetbb.cc:3037
void SetMultivalue(bool isMultivalue)
Sets whether or not this address TLV is "multivalue".
Definition: packetbb.cc:3030
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:2988
bool HasIndexStop() const
Tests whether or not this address TLV has a stop index.
Definition: packetbb.cc:3023
uint8_t GetIndexStop() const
Definition: packetbb.cc:3016
uint8_t GetIndexStart() const
Definition: packetbb.cc:2995
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:3009
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:1340
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:1048
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:1071
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:1226
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a message TLV to the front of this message.
Definition: packetbb.cc:1219
Address m_originatorAddress
originator address
Definition: packetbb.h:1109
uint8_t GetType() const
Definition: packetbb.cc:1041
bool HasHopLimit() const
Tests whether or not this message has a hop limit.
Definition: packetbb.cc:1094
bool operator!=(const PbbMessage &other) const
Inequality operator for PbbMessage.
Definition: packetbb.cc:1702
int AddressBlockSize() const
Definition: packetbb.cc:1298
AddressBlockIterator AddressBlockBegin()
Definition: packetbb.cc:1270
void Deserialize(Buffer::Iterator &start)
Deserializes a message from the specified buffer.
Definition: packetbb.cc:1518
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator.
Definition: packetbb.h:701
AddressBlockIterator AddressBlockEnd()
Definition: packetbb.cc:1284
void SetType(uint8_t type)
Sets the type for this message.
Definition: packetbb.cc:1034
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:1431
Ptr< PbbTlv > TlvFront()
Definition: packetbb.cc:1191
TlvIterator TlvErase(TlvIterator position)
Removes the message TLV at the specified position.
Definition: packetbb.cc:1247
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:1055
void SetHopLimit(uint8_t hoplimit)
Sets the maximum number of hops this message should travel.
Definition: packetbb.cc:1078
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:1486
Address GetOriginatorAddress() const
Definition: packetbb.cc:1063
void TlvClear()
Removes all message TLVs from this block.
Definition: packetbb.cc:1261
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:1354
TlvIterator TlvBegin()
Definition: packetbb.cc:1149
void TlvPopBack()
Removes a message TLV from the back of this message.
Definition: packetbb.cc:1240
uint16_t GetSequenceNumber() const
Definition: packetbb.cc:1132
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:1140
uint8_t GetHopLimit() const
Definition: packetbb.cc:1086
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:1101
void Print(std::ostream &os) const
Pretty-prints the contents of this message.
Definition: packetbb.cc:1560
void SetSequenceNumber(uint16_t seqnum)
Sets the sequence number of this message.
Definition: packetbb.cc:1124
int TlvSize() const
Definition: packetbb.cc:1177
bool m_hasHopCount
Hop count present.
Definition: packetbb.h:1114
void AddressBlockClear()
Removes all address blocks from this message.
Definition: packetbb.cc:1383
virtual ~PbbMessage()
Definition: packetbb.cc:1027
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:1233
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:1368
Ptr< PbbAddressBlock > AddressBlockBack()
Definition: packetbb.cc:1326
uint8_t GetHopCount() const
Definition: packetbb.cc:1109
void AddressBlockPopFront()
Removes an address block from the front of this message.
Definition: packetbb.cc:1347
bool operator==(const PbbMessage &other) const
Equality operator for PbbMessage.
Definition: packetbb.cc:1613
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:1394
TlvIterator TlvEnd()
Definition: packetbb.cc:1163
Ptr< PbbAddressBlock > AddressBlockFront()
Definition: packetbb.cc:1312
bool AddressBlockEmpty() const
Definition: packetbb.cc:1305
bool TlvEmpty() const
Definition: packetbb.cc:1184
bool HasHopCount() const
Tests whether or not this message has a hop count.
Definition: packetbb.cc:1117
Ptr< PbbTlv > TlvBack()
Definition: packetbb.cc:1205
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:1361
Concrete IPv4 specific PbbMessage.
Definition: packetbb.h:1127
void PrintOriginatorAddress(std::ostream &os) const override
Print the originator address.
Definition: packetbb.cc:1743
void SerializeOriginatorAddress(Buffer::Iterator &start) const override
Serialize the originator address.
Definition: packetbb.cc:1722
PbbAddressLength GetAddressLength() const override
Returns address length (IPV4 3 or IPV6 15)
Definition: packetbb.cc:1715
Address DeserializeOriginatorAddress(Buffer::Iterator &start) const override
Deserialize the originator address.
Definition: packetbb.cc:1732
Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const override
Deserialize an address block.
Definition: packetbb.cc:1750
Concrete IPv6 specific PbbMessage class.
Definition: packetbb.h:1155
Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const override
Deserialize an address block.
Definition: packetbb.cc:1801
void PrintOriginatorAddress(std::ostream &os) const override
Print the originator address.
Definition: packetbb.cc:1794
void SerializeOriginatorAddress(Buffer::Iterator &start) const override
Serialize the originator address.
Definition: packetbb.cc:1773
PbbAddressLength GetAddressLength() const override
Returns address length (IPV4 3 or IPV6 15)
Definition: packetbb.cc:1766
Address DeserializeOriginatorAddress(Buffer::Iterator &start) const override
Deserialize the originator address.
Definition: packetbb.cc:1783
Main PacketBB Packet object.
Definition: packetbb.h:391
std::list< Ptr< PbbMessage > >::iterator MessageIterator
PbbMessage Iterator for PbbPacket.
Definition: packetbb.h:398
~PbbPacket() override
Definition: packetbb.cc:550
uint8_t m_version
version
Definition: packetbb.h:682
TlvIterator TlvBegin()
Definition: packetbb.cc:589
std::list< Ptr< PbbMessage > >::const_iterator ConstMessageIterator
PbbMessage Const Iterator for PbbPacket.
Definition: packetbb.h:400
MessageIterator MessageEnd()
Definition: packetbb.cc:724
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:673
bool TlvEmpty() const
Definition: packetbb.cc:624
void TlvClear()
Removes all packet TLVs from this packet.
Definition: packetbb.cc:701
static TypeId GetTypeId()
Get the type ID.
Definition: packetbb.cc:833
void TlvPopBack()
Removes a packet TLV from the back of this block.
Definition: packetbb.cc:680
void TlvPopFront()
Removes a packet TLV from the front of this packet.
Definition: packetbb.cc:666
void MessagePushBack(Ptr< PbbMessage > message)
Appends a message to the back of this packet.
Definition: packetbb.cc:794
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator for PbbPacket.
Definition: packetbb.h:394
Ptr< PbbTlv > TlvFront()
Definition: packetbb.cc:631
TlvIterator TlvEnd()
Definition: packetbb.cc:603
void MessageClear()
Removes all messages from this packet.
Definition: packetbb.cc:822
Ptr< PbbMessage > MessageFront()
Definition: packetbb.cc:752
void SetSequenceNumber(uint16_t number)
Sets the sequence number of this packet.
Definition: packetbb.cc:564
void MessagePopFront()
Removes a message from the front of this packet.
Definition: packetbb.cc:787
uint32_t GetSerializedSize() const override
Definition: packetbb.cc:849
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a packet TLV to the front of this packet.
Definition: packetbb.cc:659
bool MessageEmpty() const
Definition: packetbb.cc:745
uint16_t GetSequenceNumber() const
Definition: packetbb.cc:572
void MessagePopBack()
Removes a message from the back of this packet.
Definition: packetbb.cc:801
bool HasSequenceNumber() const
Tests whether or not this packet has a sequence number.
Definition: packetbb.cc:580
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: packetbb.cc:843
Ptr< PbbTlv > TlvBack()
Definition: packetbb.cc:645
MessageIterator MessageBegin()
Definition: packetbb.cc:710
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:687
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:780
int TlvSize() const
Definition: packetbb.cc:617
void Serialize(Buffer::Iterator start) const override
Serializes this packet into the specified buffer.
Definition: packetbb.cc:874
Ptr< PbbMessage > MessageBack()
Definition: packetbb.cc:766
void Print(std::ostream &os) const override
Pretty-prints the contents of this block.
Definition: packetbb.cc:941
bool operator!=(const PbbPacket &other) const
Inequality operator for PbbPacket.
Definition: packetbb.cc:1009
uint16_t m_seqnum
Sequence number.
Definition: packetbb.h:685
uint8_t GetVersion() const
Definition: packetbb.cc:557
uint32_t Deserialize(Buffer::Iterator start) override
Deserializes a packet from the specified buffer.
Definition: packetbb.cc:907
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator for PbbPacket.
Definition: packetbb.h:396
int MessageSize() const
Definition: packetbb.cc:738
PbbTlvBlock m_tlvList
PbbTlv container.
Definition: packetbb.h:679
bool operator==(const PbbPacket &other) const
Equality operator for PbbPacket.
Definition: packetbb.cc:964
A block of packet or message TLVs (PbbTlv).
Definition: packetbb.h:57
Iterator Erase(Iterator position)
Removes the TLV at the specified position.
Definition: packetbb.cc:168
void PushBack(Ptr< PbbTlv > tlv)
Appends a TLV to the back of this block.
Definition: packetbb.cc:147
bool operator==(const PbbTlvBlock &other) const
Equality operator for PbbTlvBlock.
Definition: packetbb.cc:277
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition: packetbb.cc:206
Iterator End()
Definition: packetbb.cc:91
Ptr< PbbTlv > Front() const
Definition: packetbb.cc:119
void PushFront(Ptr< PbbTlv > tlv)
Prepends a TLV to the front of this block.
Definition: packetbb.cc:133
std::list< Ptr< PbbTlv > >::iterator Iterator
PbbTlv container iterator.
Definition: packetbb.h:60
Iterator Begin()
Definition: packetbb.cc:77
Ptr< PbbTlv > Back() const
Definition: packetbb.cc:126
void Clear()
Removes all TLVs from this block.
Definition: packetbb.cc:182
Iterator Insert(Iterator position, const Ptr< PbbTlv > tlv)
Inserts a TLV at the specified position in this block.
Definition: packetbb.cc:161
void PopFront()
Removes a TLV from the front of this block.
Definition: packetbb.cc:140
std::list< Ptr< PbbTlv > >::const_iterator ConstIterator
PbbTlv container const iterator.
Definition: packetbb.h:62
uint32_t GetSerializedSize() const
Definition: packetbb.cc:193
bool Empty() const
Definition: packetbb.cc:112
int Size() const
Definition: packetbb.cc:105
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition: packetbb.cc:229
std::list< Ptr< PbbTlv > > m_tlvList
PbbTlv container.
Definition: packetbb.h:212
void PopBack()
Removes a TLV from the back of this block.
Definition: packetbb.cc:154
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:247
bool operator!=(const PbbTlvBlock &other) const
Inequality operator for PbbTlvBlock.
Definition: packetbb.cc:297
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:2718
uint8_t GetIndexStop() const
Get the stop point index.
Definition: packetbb.cc:2689
bool operator!=(const PbbTlv &other) const
Inequality operator for PbbTlv.
Definition: packetbb.cc:2980
bool HasTypeExt() const
Tests whether or not this TLV has a type extension.
Definition: packetbb.cc:2651
uint8_t GetIndexStart() const
Get the starting point index.
Definition: packetbb.cc:2666
bool HasValue() const
Tests whether or not this TLV has a value.
Definition: packetbb.cc:2743
bool HasIndexStart() const
Checks if there is a starting index.
Definition: packetbb.cc:2674
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:2935
void Serialize(Buffer::Iterator &start) const
Serializes this TLV into the specified buffer.
Definition: packetbb.cc:2788
bool IsMultivalue() const
Check the multivalue parameter.
Definition: packetbb.cc:2711
void SetType(uint8_t type)
Sets the type of this TLV.
Definition: packetbb.cc:2621
bool m_hasIndexStop
Stop index present.
Definition: packetbb.h:1841
uint8_t GetTypeExt() const
Definition: packetbb.cc:2643
void SetIndexStop(uint8_t index)
Set an index as stop point.
Definition: packetbb.cc:2681
bool HasIndexStop() const
Checks if there is a stop index.
Definition: packetbb.cc:2697
void SetMultivalue(bool isMultivalue)
Set the multivalue parameter.
Definition: packetbb.cc:2704
void Print(std::ostream &os) const
Pretty-prints the contents of this TLV.
Definition: packetbb.cc:2890
virtual ~PbbTlv()
Definition: packetbb.cc:2614
void SetIndexStart(uint8_t index)
Set an index as starting point.
Definition: packetbb.cc:2658
Buffer GetValue() const
Definition: packetbb.cc:2735
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:2628
uint32_t GetSerializedSize() const
Definition: packetbb.cc:2750
void SetTypeExt(uint8_t type)
Sets the type extension of this TLV.
Definition: packetbb.cc:2635
void Deserialize(Buffer::Iterator &start)
Deserializes a TLV from the specified buffer.
Definition: packetbb.cc:2845
bool m_hasValue
Has value.
Definition: packetbb.h:1845
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:59
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:46
@ IPV6
Definition: packetbb.h:48
@ IPV4
Definition: packetbb.h:47