A Discrete-Event Network Simulator
API
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 
35 namespace ns3
36 {
37 
38 /* Forward declare objects */
39 class PbbMessage;
40 class PbbAddressBlock;
41 class PbbTlv;
42 class PbbAddressTlv;
43 
46 {
47  IPV4 = 3,
48  IPV6 = 15,
49 };
50 
57 {
58  public:
60  typedef std::list<Ptr<PbbTlv>>::iterator Iterator;
62  typedef std::list<Ptr<PbbTlv>>::const_iterator ConstIterator;
63 
64  PbbTlvBlock();
65  ~PbbTlvBlock();
66 
70  Iterator Begin();
71 
75  ConstIterator Begin() const;
76 
80  Iterator End();
81 
85  ConstIterator End() const;
86 
90  int Size() const;
91 
95  bool Empty() const;
96 
100  Ptr<PbbTlv> Front() const;
101 
105  Ptr<PbbTlv> Back() const;
106 
111  void PushFront(Ptr<PbbTlv> tlv);
112 
116  void PopFront();
117 
122  void PushBack(Ptr<PbbTlv> tlv);
123 
127  void PopBack();
128 
136  Iterator Insert(Iterator position, const Ptr<PbbTlv> tlv);
137 
143  Iterator Erase(Iterator position);
144 
153 
157  void Clear();
158 
162  uint32_t GetSerializedSize() const;
163 
171  void Serialize(Buffer::Iterator& start) const;
172 
181 
186  void Print(std::ostream& os) const;
187 
196  void Print(std::ostream& os, int level) const;
197 
203  bool operator==(const PbbTlvBlock& other) const;
209  bool operator!=(const PbbTlvBlock& other) const;
210 
211  private:
212  std::list<Ptr<PbbTlv>> m_tlvList;
213 };
214 
221 {
222  public:
224  typedef std::list<Ptr<PbbAddressTlv>>::iterator Iterator;
226  typedef std::list<Ptr<PbbAddressTlv>>::const_iterator ConstIterator;
227 
230 
234  Iterator Begin();
235 
239  ConstIterator Begin() const;
240 
244  Iterator End();
245 
249  ConstIterator End() const;
250 
254  int Size() const;
255 
259  bool Empty() const;
260 
264  Ptr<PbbAddressTlv> Front() const;
265 
269  Ptr<PbbAddressTlv> Back() const;
270 
275  void PushFront(Ptr<PbbAddressTlv> tlv);
276 
280  void PopFront();
281 
286  void PushBack(Ptr<PbbAddressTlv> tlv);
287 
291  void PopBack();
292 
300  Iterator Insert(Iterator position, const Ptr<PbbAddressTlv> tlv);
301 
307  Iterator Erase(Iterator position);
308 
319 
323  void Clear();
324 
328  uint32_t GetSerializedSize() const;
329 
337  void Serialize(Buffer::Iterator& start) const;
338 
347 
352  void Print(std::ostream& os) const;
353 
362  void Print(std::ostream& os, int level) const;
363 
369  bool operator==(const PbbAddressTlvBlock& other) const;
370 
376  bool operator!=(const PbbAddressTlvBlock& other) const;
377 
378  private:
379  std::list<Ptr<PbbAddressTlv>> m_tlvList;
380 };
381 
390 class PbbPacket : public SimpleRefCount<PbbPacket, Header>
391 {
392  public:
394  typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
396  typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
398  typedef std::list<Ptr<PbbMessage>>::iterator MessageIterator;
400  typedef std::list<Ptr<PbbMessage>>::const_iterator ConstMessageIterator;
401 
402  PbbPacket();
403  ~PbbPacket() override;
404 
410  uint8_t GetVersion() const;
411 
416  void SetSequenceNumber(uint16_t number);
417 
424  uint16_t GetSequenceNumber() const;
425 
433  bool HasSequenceNumber() const;
434 
435  /* Manipulating Packet TLVs */
436 
441 
445  ConstTlvIterator TlvBegin() const;
446 
451 
456  ConstTlvIterator TlvEnd() const;
457 
461  int TlvSize() const;
462 
466  bool TlvEmpty() const;
467 
472 
476  const Ptr<PbbTlv> TlvFront() const;
477 
482 
486  const Ptr<PbbTlv> TlvBack() const;
487 
492  void TlvPushFront(Ptr<PbbTlv> tlv);
493 
497  void TlvPopFront();
498 
503  void TlvPushBack(Ptr<PbbTlv> tlv);
504 
508  void TlvPopBack();
509 
515  TlvIterator Erase(TlvIterator position);
516 
527 
531  void TlvClear();
532 
533  /* Manipulating Packet Messages */
534 
539 
544 
549 
555 
559  int MessageSize() const;
560 
564  bool MessageEmpty() const;
565 
570 
574  const Ptr<PbbMessage> MessageFront() const;
575 
580 
584  const Ptr<PbbMessage> MessageBack() const;
585 
590  void MessagePushFront(Ptr<PbbMessage> message);
591 
595  void MessagePopFront();
596 
601  void MessagePushBack(Ptr<PbbMessage> message);
602 
606  void MessagePopBack();
607 
614 
623 
627  void MessageClear();
628 
633  static TypeId GetTypeId();
634  TypeId GetInstanceTypeId() const override;
635 
639  uint32_t GetSerializedSize() const override;
640 
645  void Serialize(Buffer::Iterator start) const override;
646 
655  uint32_t Deserialize(Buffer::Iterator start) override;
656 
661  void Print(std::ostream& os) const override;
662 
668  bool operator==(const PbbPacket& other) const;
669 
675  bool operator!=(const PbbPacket& other) const;
676 
677  protected:
678  private:
680  std::list<Ptr<PbbMessage>> m_messageList;
681 
682  uint8_t m_version;
683 
684  bool m_hasseqnum;
685  uint16_t m_seqnum;
686 };
687 
695 class PbbMessage : public SimpleRefCount<PbbMessage>
696 {
697  public:
699  typedef std::list<Ptr<PbbTlv>>::iterator TlvIterator;
701  typedef std::list<Ptr<PbbTlv>>::const_iterator ConstTlvIterator;
703  typedef std::list<Ptr<PbbAddressBlock>>::iterator AddressBlockIterator;
705  typedef std::list<Ptr<PbbAddressBlock>>::const_iterator ConstAddressBlockIterator;
706 
707  PbbMessage();
708  virtual ~PbbMessage();
709 
714  void SetType(uint8_t type);
715 
719  uint8_t GetType() const;
720 
726 
734 
739  bool HasOriginatorAddress() const;
740 
745  void SetHopLimit(uint8_t hoplimit);
746 
753  uint8_t GetHopLimit() const;
754 
761  bool HasHopLimit() const;
762 
767  void SetHopCount(uint8_t hopcount);
768 
775  uint8_t GetHopCount() const;
776 
781  bool HasHopCount() const;
782 
787  void SetSequenceNumber(uint16_t seqnum);
788 
795  uint16_t GetSequenceNumber() const;
796 
801  bool HasSequenceNumber() const;
802 
803  /* Manipulating PbbMessage TLVs */
804 
809 
813  ConstTlvIterator TlvBegin() const;
814 
820 
825  ConstTlvIterator TlvEnd() const;
826 
830  int TlvSize() const;
831 
835  bool TlvEmpty() const;
836 
841 
845  const Ptr<PbbTlv> TlvFront() const;
846 
851 
855  const Ptr<PbbTlv> TlvBack() const;
856 
861  void TlvPushFront(Ptr<PbbTlv> tlv);
862 
866  void TlvPopFront();
867 
872  void TlvPushBack(Ptr<PbbTlv> tlv);
873 
877  void TlvPopBack();
878 
884  TlvIterator TlvErase(TlvIterator position);
885 
896 
900  void TlvClear();
901 
902  /* Manipulating Address Block and Address TLV pairs */
903 
908 
913 
919 
925 
929  int AddressBlockSize() const;
930 
935  bool AddressBlockEmpty() const;
936 
941 
946 
951 
956 
962 
966  void AddressBlockPopFront();
967 
973 
977  void AddressBlockPopBack();
978 
985 
996 
1000  void AddressBlockClear();
1001 
1012 
1016  uint32_t GetSerializedSize() const;
1017 
1025  void Serialize(Buffer::Iterator& start) const;
1026 
1035 
1040  void Print(std::ostream& os) const;
1041 
1051  void Print(std::ostream& os, int level) const;
1052 
1058  bool operator==(const PbbMessage& other) const;
1064  bool operator!=(const PbbMessage& other) const;
1065 
1066  protected:
1075  virtual PbbAddressLength GetAddressLength() const = 0;
1076 
1092  virtual void PrintOriginatorAddress(std::ostream& os) const = 0;
1093 
1100 
1101  private:
1103  std::list<Ptr<PbbAddressBlock>> m_addressBlockList;
1104 
1105  uint8_t m_type;
1107 
1110 
1112  uint8_t m_hopLimit;
1113 
1115  uint8_t m_hopCount;
1116 
1118  uint16_t m_sequenceNumber;
1119 };
1120 
1127 {
1128  public:
1129  PbbMessageIpv4();
1130 
1131  protected:
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 
1155 {
1156  public:
1157  PbbMessageIpv6();
1158 
1159  protected:
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 
1183 class PbbAddressBlock : public SimpleRefCount<PbbAddressBlock>
1184 {
1185  public:
1187  typedef std::list<Address>::iterator AddressIterator;
1189  typedef std::list<Address>::const_iterator ConstAddressIterator;
1190 
1192  typedef std::list<uint8_t>::iterator PrefixIterator;
1194  typedef std::list<uint8_t>::const_iterator ConstPrefixIterator;
1195 
1200 
1201  PbbAddressBlock();
1202  virtual ~PbbAddressBlock();
1203 
1204  /* Manipulating the address block */
1205 
1210 
1215 
1220 
1225 
1229  int AddressSize() const;
1230 
1234  bool AddressEmpty() const;
1235 
1239  Address AddressFront() const;
1240 
1244  Address AddressBack() const;
1245 
1251 
1255  void AddressPopFront();
1256 
1262 
1266  void AddressPopBack();
1267 
1276 
1283 
1294 
1298  void AddressClear();
1299 
1300  /* Prefix methods */
1301 
1306 
1311 
1316 
1321 
1325  int PrefixSize() const;
1326 
1330  bool PrefixEmpty() const;
1331 
1335  uint8_t PrefixFront() const;
1336 
1340  uint8_t PrefixBack() const;
1341 
1346  void PrefixPushFront(uint8_t prefix);
1347 
1351  void PrefixPopFront();
1352 
1357  void PrefixPushBack(uint8_t prefix);
1358 
1362  void PrefixPopBack();
1363 
1371  PrefixIterator PrefixInsert(PrefixIterator position, const uint8_t value);
1372 
1379 
1390 
1394  void PrefixClear();
1395 
1396  /* Manipulating the TLV block */
1397 
1402 
1406  ConstTlvIterator TlvBegin() const;
1407 
1411  TlvIterator TlvEnd();
1412 
1416  ConstTlvIterator TlvEnd() const;
1417 
1421  int TlvSize() const;
1422 
1426  bool TlvEmpty() const;
1427 
1432 
1436  const Ptr<PbbAddressTlv> TlvFront() const;
1437 
1442 
1446  const Ptr<PbbAddressTlv> TlvBack() const;
1447 
1453 
1457  void TlvPopFront();
1458 
1464 
1468  void TlvPopBack();
1469 
1478 
1484  TlvIterator TlvErase(TlvIterator position);
1485 
1496 
1500  void TlvClear();
1501 
1505  uint32_t GetSerializedSize() const;
1506 
1514  void Serialize(Buffer::Iterator& start) const;
1515 
1524 
1529  void Print(std::ostream& os) const;
1530 
1540  void Print(std::ostream& os, int level) const;
1541 
1547  bool operator==(const PbbAddressBlock& other) const;
1548 
1554  bool operator!=(const PbbAddressBlock& other) const;
1555 
1556  protected:
1561  virtual uint8_t GetAddressLength() const = 0;
1567  virtual void SerializeAddress(uint8_t* buffer, ConstAddressIterator iter) const = 0;
1573  virtual Address DeserializeAddress(uint8_t* buffer) const = 0;
1579  virtual void PrintAddress(std::ostream& os, ConstAddressIterator iter) const = 0;
1580 
1581  private:
1586  uint8_t GetPrefixFlags() const;
1594  void GetHeadTail(uint8_t* head, uint8_t& headlen, uint8_t* tail, uint8_t& taillen) const;
1595 
1602  bool HasZeroTail(const uint8_t* tail, uint8_t taillen) const;
1603 
1604  std::list<Address> m_addressList;
1605  std::list<uint8_t> m_prefixList;
1607 };
1608 
1615 {
1616  public:
1618  ~PbbAddressBlockIpv4() override;
1619 
1620  protected:
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 
1637 {
1638  public:
1640  ~PbbAddressBlockIpv6() override;
1641 
1642  protected:
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 
1656 class PbbTlv : public SimpleRefCount<PbbTlv>
1657 {
1658  public:
1659  PbbTlv();
1660  virtual ~PbbTlv();
1661 
1666  void SetType(uint8_t type);
1667 
1671  uint8_t GetType() const;
1672 
1680  void SetTypeExt(uint8_t type);
1681 
1688  uint8_t GetTypeExt() const;
1689 
1697  bool HasTypeExt() const;
1698 
1706  void SetValue(Buffer start);
1707 
1716  void SetValue(const uint8_t* buffer, uint32_t size);
1717 
1724  Buffer GetValue() const;
1725 
1733  bool HasValue() const;
1734 
1738  uint32_t GetSerializedSize() const;
1739 
1747  void Serialize(Buffer::Iterator& start) const;
1748 
1757 
1762  void Print(std::ostream& os) const;
1763 
1772  void Print(std::ostream& os, int level) const;
1773 
1779  bool operator==(const PbbTlv& other) const;
1780 
1786  bool operator!=(const PbbTlv& other) const;
1787 
1788  protected:
1793  void SetIndexStart(uint8_t index);
1798  uint8_t GetIndexStart() const;
1803  bool HasIndexStart() const;
1804 
1809  void SetIndexStop(uint8_t index);
1814  uint8_t GetIndexStop() const;
1819  bool HasIndexStop() const;
1820 
1825  void SetMultivalue(bool isMultivalue);
1830  bool IsMultivalue() const;
1831 
1832  private:
1833  uint8_t m_type;
1834 
1836  uint8_t m_typeExt;
1837 
1839  uint8_t m_indexStart;
1840 
1842  uint8_t m_indexStop;
1843 
1845  bool m_hasValue;
1847 };
1848 
1852 class PbbAddressTlv : public PbbTlv
1853 {
1854  public:
1860  void SetIndexStart(uint8_t index);
1861 
1869  uint8_t GetIndexStart() const;
1870 
1878  bool HasIndexStart() const;
1879 
1885  void SetIndexStop(uint8_t index);
1886 
1894  uint8_t GetIndexStop() const;
1895 
1903  bool HasIndexStop() const;
1904 
1913  void SetMultivalue(bool isMultivalue);
1914 
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
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
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
void Clear()
Removes all Address TLVs from this block.
Definition: packetbb.cc:421
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
std::list< Ptr< PbbAddressTlv > >::const_iterator ConstIterator
PbbAddressTlv const iterator for PbbAddressTlvBlock.
Definition: packetbb.h:226
std::list< Ptr< PbbAddressTlv > >::iterator Iterator
PbbAddressTlv iterator for PbbAddressTlvBlock.
Definition: packetbb.h:224
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< PbbAddressBlock > >::const_iterator ConstAddressBlockIterator
PbbAddressBlock const iterator.
Definition: packetbb.h:705
AddressBlockIterator AddressBlockEnd()
Definition: packetbb.cc:1284
void SetType(uint8_t type)
Sets the type for this message.
Definition: packetbb.cc:1034
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
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator.
Definition: packetbb.h:701
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
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
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
virtual Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const =0
Deserialize an address block.
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
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator.
Definition: packetbb.h:699
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
~PbbPacket() override
Definition: packetbb.cc:550
uint8_t m_version
version
Definition: packetbb.h:682
TlvIterator TlvBegin()
Definition: packetbb.cc:589
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
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
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator for PbbPacket.
Definition: packetbb.h:396
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
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator for PbbPacket.
Definition: packetbb.h:394
uint16_t m_seqnum
Sequence number.
Definition: packetbb.h:685
std::list< Ptr< PbbMessage > >::iterator MessageIterator
PbbMessage Iterator for PbbPacket.
Definition: packetbb.h:398
uint8_t GetVersion() const
Definition: packetbb.cc:557
std::list< Ptr< PbbMessage > >::const_iterator ConstMessageIterator
PbbMessage Const Iterator for PbbPacket.
Definition: packetbb.h:400
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
Iterator Begin()
Definition: packetbb.cc:77
Ptr< PbbTlv > Back() const
Definition: packetbb.cc:126
std::list< Ptr< PbbTlv > >::const_iterator ConstIterator
PbbTlv container const iterator.
Definition: packetbb.h:62
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
uint32_t GetSerializedSize() const
Definition: packetbb.cc:193
bool Empty() const
Definition: packetbb.cc:112
std::list< Ptr< PbbTlv > >::iterator Iterator
PbbTlv container iterator.
Definition: packetbb.h:60
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
address
Definition: first.py:47
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