A Discrete-Event Network Simulator
API
packetbb.cc
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 #include "packetbb.h"
25 
26 #include "ns3/assert.h"
27 #include "ns3/ipv4-address.h"
28 #include "ns3/ipv6-address.h"
29 #include "ns3/log.h"
30 
31 static const uint8_t VERSION = 0;
32 /* Packet flags */
33 static const uint8_t PHAS_SEQ_NUM = 0x8;
34 static const uint8_t PHAS_TLV = 0x4;
35 
36 /* PbbMessage flags */
37 static const uint8_t MHAS_ORIG = 0x80;
38 static const uint8_t MHAS_HOP_LIMIT = 0x40;
39 static const uint8_t MHAS_HOP_COUNT = 0x20;
40 static const uint8_t MHAS_SEQ_NUM = 0x10;
41 
42 /* Address block flags */
43 static const uint8_t AHAS_HEAD = 0x80;
44 static const uint8_t AHAS_FULL_TAIL = 0x40;
45 static const uint8_t AHAS_ZERO_TAIL = 0x20;
46 static const uint8_t AHAS_SINGLE_PRE_LEN = 0x10;
47 static const uint8_t AHAS_MULTI_PRE_LEN = 0x08;
48 
49 /* TLV Flags */
50 static const uint8_t THAS_TYPE_EXT = 0x80;
51 static const uint8_t THAS_SINGLE_INDEX = 0x40;
52 static const uint8_t THAS_MULTI_INDEX = 0x20;
53 static const uint8_t THAS_VALUE = 0x10;
54 static const uint8_t THAS_EXT_LEN = 0x08;
55 static const uint8_t TIS_MULTIVALUE = 0x04;
56 
57 namespace ns3
58 {
59 
60 NS_LOG_COMPONENT_DEFINE("PacketBB");
61 
63 
65 {
66  NS_LOG_FUNCTION(this);
67 }
68 
70 {
71  NS_LOG_FUNCTION(this);
72  Clear();
73 }
74 
77 {
78  NS_LOG_FUNCTION(this);
79  return m_tlvList.begin();
80 }
81 
84 {
85  NS_LOG_FUNCTION(this);
86  return m_tlvList.begin();
87 }
88 
91 {
92  NS_LOG_FUNCTION(this);
93  return m_tlvList.end();
94 }
95 
98 {
99  NS_LOG_FUNCTION(this);
100  return m_tlvList.end();
101 }
102 
103 int
105 {
106  NS_LOG_FUNCTION(this);
107  return m_tlvList.size();
108 }
109 
110 bool
112 {
113  NS_LOG_FUNCTION(this);
114  return m_tlvList.empty();
115 }
116 
119 {
120  NS_LOG_FUNCTION(this);
121  return m_tlvList.front();
122 }
123 
126 {
127  NS_LOG_FUNCTION(this);
128  return m_tlvList.back();
129 }
130 
131 void
133 {
134  NS_LOG_FUNCTION(this << tlv);
135  m_tlvList.push_front(tlv);
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION(this);
142  m_tlvList.pop_front();
143 }
144 
145 void
147 {
148  NS_LOG_FUNCTION(this << tlv);
149  m_tlvList.push_back(tlv);
150 }
151 
152 void
154 {
155  NS_LOG_FUNCTION(this);
156  m_tlvList.pop_back();
157 }
158 
161 {
162  NS_LOG_FUNCTION(this << &position << tlv);
163  return m_tlvList.insert(position, tlv);
164 }
165 
168 {
169  NS_LOG_FUNCTION(this << &position);
170  return m_tlvList.erase(position);
171 }
172 
175 {
176  NS_LOG_FUNCTION(this << &first << &last);
177  return m_tlvList.erase(first, last);
178 }
179 
180 void
182 {
183  NS_LOG_FUNCTION(this);
184  for (Iterator iter = Begin(); iter != End(); iter++)
185  {
186  *iter = nullptr;
187  }
188  m_tlvList.clear();
189 }
190 
191 uint32_t
193 {
194  NS_LOG_FUNCTION(this);
195  /* tlv size */
196  uint32_t size = 2;
197  for (ConstIterator iter = Begin(); iter != End(); iter++)
198  {
199  size += (*iter)->GetSerializedSize();
200  }
201  return size;
202 }
203 
204 void
206 {
207  NS_LOG_FUNCTION(this << &start);
208  if (Empty())
209  {
210  start.WriteHtonU16(0);
211  return;
212  }
213 
214  /* We need to write the size of the TLV block in front, so save its
215  * position. */
216  Buffer::Iterator tlvsize = start;
217  start.Next(2);
218  for (ConstIterator iter = Begin(); iter != End(); iter++)
219  {
220  (*iter)->Serialize(start);
221  }
222  /* - 2 to not include the size field */
223  uint16_t size = start.GetDistanceFrom(tlvsize) - 2;
224  tlvsize.WriteHtonU16(size);
225 }
226 
227 void
229 {
230  NS_LOG_FUNCTION(this << &start);
231  uint16_t size = start.ReadNtohU16();
232 
233  Buffer::Iterator tlvstart = start;
234  if (size > 0)
235  {
236  while (start.GetDistanceFrom(tlvstart) < size)
237  {
238  Ptr<PbbTlv> newtlv = Create<PbbTlv>();
239  newtlv->Deserialize(start);
240  PushBack(newtlv);
241  }
242  }
243 }
244 
245 void
246 PbbTlvBlock::Print(std::ostream& os) const
247 {
248  NS_LOG_FUNCTION(this << &os);
249  Print(os, 0);
250 }
251 
252 void
253 PbbTlvBlock::Print(std::ostream& os, int level) const
254 {
255  NS_LOG_FUNCTION(this << &os << level);
256  std::string prefix = "";
257  for (int i = 0; i < level; i++)
258  {
259  prefix.append("\t");
260  }
261 
262  os << prefix << "TLV Block {" << std::endl;
263  os << prefix << "\tsize = " << Size() << std::endl;
264  os << prefix << "\tmembers [" << std::endl;
265 
266  for (ConstIterator iter = Begin(); iter != End(); iter++)
267  {
268  (*iter)->Print(os, level + 2);
269  }
270 
271  os << prefix << "\t]" << std::endl;
272  os << prefix << "}" << std::endl;
273 }
274 
275 bool
277 {
278  if (Size() != other.Size())
279  {
280  return false;
281  }
282 
283  ConstIterator ti;
284  ConstIterator oi;
285  for (ti = Begin(), oi = other.Begin(); ti != End() && oi != other.End(); ti++, oi++)
286  {
287  if (**ti != **oi)
288  {
289  return false;
290  }
291  }
292  return true;
293 }
294 
295 bool
297 {
298  return !(*this == other);
299 }
300 
301 /* End PbbTlvBlock class */
302 
304 {
305  NS_LOG_FUNCTION(this);
306 }
307 
309 {
310  NS_LOG_FUNCTION(this);
311  Clear();
312 }
313 
316 {
317  NS_LOG_FUNCTION(this);
318  return m_tlvList.begin();
319 }
320 
323 {
324  NS_LOG_FUNCTION(this);
325  return m_tlvList.begin();
326 }
327 
330 {
331  NS_LOG_FUNCTION(this);
332  return m_tlvList.end();
333 }
334 
337 {
338  NS_LOG_FUNCTION(this);
339  return m_tlvList.end();
340 }
341 
342 int
344 {
345  NS_LOG_FUNCTION(this);
346  return m_tlvList.size();
347 }
348 
349 bool
351 {
352  NS_LOG_FUNCTION(this);
353  return m_tlvList.empty();
354 }
355 
358 {
359  NS_LOG_FUNCTION(this);
360  return m_tlvList.front();
361 }
362 
365 {
366  NS_LOG_FUNCTION(this);
367  return m_tlvList.back();
368 }
369 
370 void
372 {
373  NS_LOG_FUNCTION(this << tlv);
374  m_tlvList.push_front(tlv);
375 }
376 
377 void
379 {
380  NS_LOG_FUNCTION(this);
381  m_tlvList.pop_front();
382 }
383 
384 void
386 {
387  NS_LOG_FUNCTION(this << tlv);
388  m_tlvList.push_back(tlv);
389 }
390 
391 void
393 {
394  NS_LOG_FUNCTION(this);
395  m_tlvList.pop_back();
396 }
397 
400 {
401  NS_LOG_FUNCTION(this << &position << tlv);
402  return m_tlvList.insert(position, tlv);
403 }
404 
407 {
408  NS_LOG_FUNCTION(this << &position);
409  return m_tlvList.erase(position);
410 }
411 
414 {
415  NS_LOG_FUNCTION(this << &first << &last);
416  return m_tlvList.erase(first, last);
417 }
418 
419 void
421 {
422  NS_LOG_FUNCTION(this);
423  for (Iterator iter = Begin(); iter != End(); iter++)
424  {
425  *iter = nullptr;
426  }
427  m_tlvList.clear();
428 }
429 
430 uint32_t
432 {
433  NS_LOG_FUNCTION(this);
434  /* tlv size */
435  uint32_t size = 2;
436  for (ConstIterator iter = Begin(); iter != End(); iter++)
437  {
438  size += (*iter)->GetSerializedSize();
439  }
440  return size;
441 }
442 
443 void
445 {
446  NS_LOG_FUNCTION(this << &start);
447  if (Empty())
448  {
449  start.WriteHtonU16(0);
450  return;
451  }
452 
453  /* We need to write the size of the TLV block in front, so save its
454  * position. */
455  Buffer::Iterator tlvsize = start;
456  start.Next(2);
457  for (ConstIterator iter = Begin(); iter != End(); iter++)
458  {
459  (*iter)->Serialize(start);
460  }
461  /* - 2 to not include the size field */
462  uint16_t size = start.GetDistanceFrom(tlvsize) - 2;
463  tlvsize.WriteHtonU16(size);
464 }
465 
466 void
468 {
469  NS_LOG_FUNCTION(this << &start);
470  uint16_t size = start.ReadNtohU16();
471 
472  Buffer::Iterator tlvstart = start;
473  if (size > 0)
474  {
475  while (start.GetDistanceFrom(tlvstart) < size)
476  {
477  Ptr<PbbAddressTlv> newtlv = Create<PbbAddressTlv>();
478  newtlv->Deserialize(start);
479  PushBack(newtlv);
480  }
481  }
482 }
483 
484 void
485 PbbAddressTlvBlock::Print(std::ostream& os) const
486 {
487  NS_LOG_FUNCTION(this << &os);
488  Print(os, 0);
489 }
490 
491 void
492 PbbAddressTlvBlock::Print(std::ostream& os, int level) const
493 {
494  NS_LOG_FUNCTION(this << &os << level);
495  std::string prefix = "";
496  for (int i = 0; i < level; i++)
497  {
498  prefix.append("\t");
499  }
500 
501  os << prefix << "TLV Block {" << std::endl;
502  os << prefix << "\tsize = " << Size() << std::endl;
503  os << prefix << "\tmembers [" << std::endl;
504 
505  for (ConstIterator iter = Begin(); iter != End(); iter++)
506  {
507  (*iter)->Print(os, level + 2);
508  }
509 
510  os << prefix << "\t]" << std::endl;
511  os << prefix << "}" << std::endl;
512 }
513 
514 bool
516 {
517  if (Size() != other.Size())
518  {
519  return false;
520  }
521 
522  ConstIterator it;
523  ConstIterator ot;
524  for (it = Begin(), ot = other.Begin(); it != End() && ot != other.End(); it++, ot++)
525  {
526  if (**it != **ot)
527  {
528  return false;
529  }
530  }
531  return true;
532 }
533 
534 bool
536 {
537  return !(*this == other);
538 }
539 
540 /* End PbbAddressTlvBlock Class */
541 
543 {
544  NS_LOG_FUNCTION(this);
545  m_version = VERSION;
546  m_hasseqnum = false;
547 }
548 
550 {
551  NS_LOG_FUNCTION(this);
552  MessageClear();
553 }
554 
555 uint8_t
557 {
558  NS_LOG_FUNCTION(this);
559  return m_version;
560 }
561 
562 void
564 {
565  NS_LOG_FUNCTION(this << number);
566  m_seqnum = number;
567  m_hasseqnum = true;
568 }
569 
570 uint16_t
572 {
573  NS_LOG_FUNCTION(this);
575  return m_seqnum;
576 }
577 
578 bool
580 {
581  NS_LOG_FUNCTION(this);
582  return m_hasseqnum;
583 }
584 
585 /* Manipulating Packet TLVs */
586 
589 {
590  NS_LOG_FUNCTION(this);
591  return m_tlvList.Begin();
592 }
593 
596 {
597  NS_LOG_FUNCTION(this);
598  return m_tlvList.Begin();
599 }
600 
603 {
604  NS_LOG_FUNCTION(this);
605  return m_tlvList.End();
606 }
607 
610 {
611  NS_LOG_FUNCTION(this);
612  return m_tlvList.End();
613 }
614 
615 int
617 {
618  NS_LOG_FUNCTION(this);
619  return m_tlvList.Size();
620 }
621 
622 bool
624 {
625  NS_LOG_FUNCTION(this);
626  return m_tlvList.Empty();
627 }
628 
631 {
632  NS_LOG_FUNCTION(this);
633  return m_tlvList.Front();
634 }
635 
636 const Ptr<PbbTlv>
638 {
639  NS_LOG_FUNCTION(this);
640  return m_tlvList.Front();
641 }
642 
645 {
646  NS_LOG_FUNCTION(this);
647  return m_tlvList.Back();
648 }
649 
650 const Ptr<PbbTlv>
652 {
653  NS_LOG_FUNCTION(this);
654  return m_tlvList.Back();
655 }
656 
657 void
659 {
660  NS_LOG_FUNCTION(this << tlv);
661  m_tlvList.PushFront(tlv);
662 }
663 
664 void
666 {
667  NS_LOG_FUNCTION(this);
669 }
670 
671 void
673 {
674  NS_LOG_FUNCTION(this << tlv);
675  m_tlvList.PushBack(tlv);
676 }
677 
678 void
680 {
681  NS_LOG_FUNCTION(this);
682  m_tlvList.PopBack();
683 }
684 
687 {
688  NS_LOG_FUNCTION(this << &position);
689  return m_tlvList.Erase(position);
690 }
691 
694 {
695  NS_LOG_FUNCTION(this << &first << &last);
696  return m_tlvList.Erase(first, last);
697 }
698 
699 void
701 {
702  NS_LOG_FUNCTION(this);
703  m_tlvList.Clear();
704 }
705 
706 /* Manipulating Packet Messages */
707 
710 {
711  NS_LOG_FUNCTION(this);
712  return m_messageList.begin();
713 }
714 
717 {
718  NS_LOG_FUNCTION(this);
719  return m_messageList.begin();
720 }
721 
724 {
725  NS_LOG_FUNCTION(this);
726  return m_messageList.end();
727 }
728 
731 {
732  NS_LOG_FUNCTION(this);
733  return m_messageList.end();
734 }
735 
736 int
738 {
739  NS_LOG_FUNCTION(this);
740  return m_messageList.size();
741 }
742 
743 bool
745 {
746  NS_LOG_FUNCTION(this);
747  return m_messageList.empty();
748 }
749 
752 {
753  NS_LOG_FUNCTION(this);
754  return m_messageList.front();
755 }
756 
757 const Ptr<PbbMessage>
759 {
760  NS_LOG_FUNCTION(this);
761  return m_messageList.front();
762 }
763 
766 {
767  NS_LOG_FUNCTION(this);
768  return m_messageList.back();
769 }
770 
771 const Ptr<PbbMessage>
773 {
774  NS_LOG_FUNCTION(this);
775  return m_messageList.back();
776 }
777 
778 void
780 {
781  NS_LOG_FUNCTION(this << tlv);
782  m_messageList.push_front(tlv);
783 }
784 
785 void
787 {
788  NS_LOG_FUNCTION(this);
789  m_messageList.pop_front();
790 }
791 
792 void
794 {
795  NS_LOG_FUNCTION(this << tlv);
796  m_messageList.push_back(tlv);
797 }
798 
799 void
801 {
802  NS_LOG_FUNCTION(this);
803  m_messageList.pop_back();
804 }
805 
808 {
809  NS_LOG_FUNCTION(this << &position);
810  return m_messageList.erase(position);
811 }
812 
815 {
816  NS_LOG_FUNCTION(this << &first << &last);
817  return m_messageList.erase(first, last);
818 }
819 
820 void
822 {
823  NS_LOG_FUNCTION(this);
824  for (MessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++)
825  {
826  *iter = nullptr;
827  }
828  m_messageList.clear();
829 }
830 
831 TypeId
833 {
834  static TypeId tid = TypeId("ns3::PbbPacket")
835  .SetParent<Header>()
836  .SetGroupName("Network")
837  .AddConstructor<PbbPacket>();
838  return tid;
839 }
840 
841 TypeId
843 {
844  return GetTypeId();
845 }
846 
847 uint32_t
849 {
850  NS_LOG_FUNCTION(this);
851  /* Version number + flags */
852  uint32_t size = 1;
853 
854  if (HasSequenceNumber())
855  {
856  size += 2;
857  }
858 
859  if (!TlvEmpty())
860  {
861  size += m_tlvList.GetSerializedSize();
862  }
863 
864  for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++)
865  {
866  size += (*iter)->GetSerializedSize();
867  }
868 
869  return size;
870 }
871 
872 void
874 {
875  NS_LOG_FUNCTION(this << &start);
876  /* We remember the start, so we can write the flags after we check for a
877  * sequence number and TLV. */
878  Buffer::Iterator bufref = start;
879  start.Next();
880 
881  uint8_t flags = VERSION;
882  /* Make room for 4 bit flags */
883  flags <<= 4;
884 
885  if (HasSequenceNumber())
886  {
887  flags |= PHAS_SEQ_NUM;
888  start.WriteHtonU16(GetSequenceNumber());
889  }
890 
891  if (!TlvEmpty())
892  {
893  flags |= PHAS_TLV;
895  }
896 
897  bufref.WriteU8(flags);
898 
899  for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++)
900  {
901  (*iter)->Serialize(start);
902  }
903 }
904 
905 uint32_t
907 {
908  NS_LOG_FUNCTION(this << &start);
909  Buffer::Iterator begin = start;
910 
911  uint8_t flags = start.ReadU8();
912 
913  if (flags & PHAS_SEQ_NUM)
914  {
915  SetSequenceNumber(start.ReadNtohU16());
916  }
917 
918  if (flags & PHAS_TLV)
919  {
921  }
922 
923  while (!start.IsEnd())
924  {
926  if (!newmsg)
927  {
928  return start.GetDistanceFrom(begin);
929  }
930  MessagePushBack(newmsg);
931  }
932 
933  flags >>= 4;
934  m_version = flags;
935 
936  return start.GetDistanceFrom(begin);
937 }
938 
939 void
940 PbbPacket::Print(std::ostream& os) const
941 {
942  NS_LOG_FUNCTION(this << &os);
943  os << "PbbPacket {" << std::endl;
944 
945  if (HasSequenceNumber())
946  {
947  os << "\tsequence number = " << GetSequenceNumber();
948  }
949 
950  os << std::endl;
951 
952  m_tlvList.Print(os, 1);
953 
954  for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++)
955  {
956  (*iter)->Print(os, 1);
957  }
958 
959  os << "}" << std::endl;
960 }
961 
962 bool
963 PbbPacket::operator==(const PbbPacket& other) const
964 {
965  if (GetVersion() != other.GetVersion())
966  {
967  return false;
968  }
969 
970  if (HasSequenceNumber() != other.HasSequenceNumber())
971  {
972  return false;
973  }
974 
975  if (HasSequenceNumber())
976  {
977  if (GetSequenceNumber() != other.GetSequenceNumber())
978  {
979  return false;
980  }
981  }
982 
983  if (m_tlvList != other.m_tlvList)
984  {
985  return false;
986  }
987 
988  if (MessageSize() != other.MessageSize())
989  {
990  return false;
991  }
992 
995  for (tmi = MessageBegin(), omi = other.MessageBegin();
996  tmi != MessageEnd() && omi != other.MessageEnd();
997  tmi++, omi++)
998  {
999  if (**tmi != **omi)
1000  {
1001  return false;
1002  }
1003  }
1004  return true;
1005 }
1006 
1007 bool
1009 {
1010  return !(*this == other);
1011 }
1012 
1013 /* End PbbPacket class */
1014 
1016 {
1017  NS_LOG_FUNCTION(this);
1018  /* Default to IPv4 */
1019  m_addrSize = IPV4;
1020  m_hasOriginatorAddress = false;
1021  m_hasHopLimit = false;
1022  m_hasHopCount = false;
1023  m_hasSequenceNumber = false;
1024 }
1025 
1027 {
1028  NS_LOG_FUNCTION(this);
1030 }
1031 
1032 void
1034 {
1035  NS_LOG_FUNCTION(this << static_cast<uint32_t>(type));
1036  m_type = type;
1037 }
1038 
1039 uint8_t
1041 {
1042  NS_LOG_FUNCTION(this);
1043  return m_type;
1044 }
1045 
1048 {
1049  NS_LOG_FUNCTION(this);
1050  return m_addrSize;
1051 }
1052 
1053 void
1055 {
1056  NS_LOG_FUNCTION(this << address);
1058  m_hasOriginatorAddress = true;
1059 }
1060 
1061 Address
1063 {
1064  NS_LOG_FUNCTION(this);
1066  return m_originatorAddress;
1067 }
1068 
1069 bool
1071 {
1072  NS_LOG_FUNCTION(this);
1073  return m_hasOriginatorAddress;
1074 }
1075 
1076 void
1077 PbbMessage::SetHopLimit(uint8_t hopLimit)
1078 {
1079  NS_LOG_FUNCTION(this << static_cast<uint32_t>(hopLimit));
1080  m_hopLimit = hopLimit;
1081  m_hasHopLimit = true;
1082 }
1083 
1084 uint8_t
1086 {
1087  NS_LOG_FUNCTION(this);
1089  return m_hopLimit;
1090 }
1091 
1092 bool
1094 {
1095  NS_LOG_FUNCTION(this);
1096  return m_hasHopLimit;
1097 }
1098 
1099 void
1100 PbbMessage::SetHopCount(uint8_t hopCount)
1101 {
1102  NS_LOG_FUNCTION(this << static_cast<uint32_t>(hopCount));
1103  m_hopCount = hopCount;
1104  m_hasHopCount = true;
1105 }
1106 
1107 uint8_t
1109 {
1110  NS_LOG_FUNCTION(this);
1112  return m_hopCount;
1113 }
1114 
1115 bool
1117 {
1118  NS_LOG_FUNCTION(this);
1119  return m_hasHopCount;
1120 }
1121 
1122 void
1123 PbbMessage::SetSequenceNumber(uint16_t sequenceNumber)
1124 {
1125  NS_LOG_FUNCTION(this << sequenceNumber);
1126  m_sequenceNumber = sequenceNumber;
1127  m_hasSequenceNumber = true;
1128 }
1129 
1130 uint16_t
1132 {
1133  NS_LOG_FUNCTION(this);
1135  return m_sequenceNumber;
1136 }
1137 
1138 bool
1140 {
1141  NS_LOG_FUNCTION(this);
1142  return m_hasSequenceNumber;
1143 }
1144 
1145 /* Manipulating PbbMessage TLVs */
1146 
1149 {
1150  NS_LOG_FUNCTION(this);
1151  return m_tlvList.Begin();
1152 }
1153 
1156 {
1157  NS_LOG_FUNCTION(this);
1158  return m_tlvList.Begin();
1159 }
1160 
1163 {
1164  NS_LOG_FUNCTION(this);
1165  return m_tlvList.End();
1166 }
1167 
1170 {
1171  NS_LOG_FUNCTION(this);
1172  return m_tlvList.End();
1173 }
1174 
1175 int
1177 {
1178  NS_LOG_FUNCTION(this);
1179  return m_tlvList.Size();
1180 }
1181 
1182 bool
1184 {
1185  NS_LOG_FUNCTION(this);
1186  return m_tlvList.Empty();
1187 }
1188 
1191 {
1192  NS_LOG_FUNCTION(this);
1193  return m_tlvList.Front();
1194 }
1195 
1196 const Ptr<PbbTlv>
1198 {
1199  NS_LOG_FUNCTION(this);
1200  return m_tlvList.Front();
1201 }
1202 
1205 {
1206  NS_LOG_FUNCTION(this);
1207  return m_tlvList.Back();
1208 }
1209 
1210 const Ptr<PbbTlv>
1212 {
1213  NS_LOG_FUNCTION(this);
1214  return m_tlvList.Back();
1215 }
1216 
1217 void
1219 {
1220  NS_LOG_FUNCTION(this << tlv);
1221  m_tlvList.PushFront(tlv);
1222 }
1223 
1224 void
1226 {
1227  NS_LOG_FUNCTION(this);
1228  m_tlvList.PopFront();
1229 }
1230 
1231 void
1233 {
1234  NS_LOG_FUNCTION(this << tlv);
1235  m_tlvList.PushBack(tlv);
1236 }
1237 
1238 void
1240 {
1241  NS_LOG_FUNCTION(this);
1242  m_tlvList.PopBack();
1243 }
1244 
1247 {
1248  NS_LOG_FUNCTION(this << &position);
1249  return m_tlvList.Erase(position);
1250 }
1251 
1254 {
1255  NS_LOG_FUNCTION(this << &first << &last);
1256  return m_tlvList.Erase(first, last);
1257 }
1258 
1259 void
1261 {
1262  NS_LOG_FUNCTION(this);
1263  m_tlvList.Clear();
1264 }
1265 
1266 /* Manipulating Address Block and Address TLV pairs */
1267 
1270 {
1271  NS_LOG_FUNCTION(this);
1272  return m_addressBlockList.begin();
1273 }
1274 
1277 {
1278  NS_LOG_FUNCTION(this);
1279  return m_addressBlockList.begin();
1280 }
1281 
1284 {
1285  NS_LOG_FUNCTION(this);
1286  return m_addressBlockList.end();
1287 }
1288 
1291 {
1292  NS_LOG_FUNCTION(this);
1293  return m_addressBlockList.end();
1294 }
1295 
1296 int
1298 {
1299  NS_LOG_FUNCTION(this);
1300  return m_addressBlockList.size();
1301 }
1302 
1303 bool
1305 {
1306  NS_LOG_FUNCTION(this);
1307  return m_addressBlockList.empty();
1308 }
1309 
1312 {
1313  NS_LOG_FUNCTION(this);
1314  return m_addressBlockList.front();
1315 }
1316 
1319 {
1320  NS_LOG_FUNCTION(this);
1321  return m_addressBlockList.front();
1322 }
1323 
1326 {
1327  NS_LOG_FUNCTION(this);
1328  return m_addressBlockList.back();
1329 }
1330 
1333 {
1334  NS_LOG_FUNCTION(this);
1335  return m_addressBlockList.back();
1336 }
1337 
1338 void
1340 {
1341  NS_LOG_FUNCTION(this << tlv);
1342  m_addressBlockList.push_front(tlv);
1343 }
1344 
1345 void
1347 {
1348  NS_LOG_FUNCTION(this);
1349  m_addressBlockList.pop_front();
1350 }
1351 
1352 void
1354 {
1355  NS_LOG_FUNCTION(this << tlv);
1356  m_addressBlockList.push_back(tlv);
1357 }
1358 
1359 void
1361 {
1362  NS_LOG_FUNCTION(this);
1363  m_addressBlockList.pop_back();
1364 }
1365 
1368 {
1369  NS_LOG_FUNCTION(this << &position);
1370  return m_addressBlockList.erase(position);
1371 }
1372 
1376 {
1377  NS_LOG_FUNCTION(this << &first << &last);
1378  return m_addressBlockList.erase(first, last);
1379 }
1380 
1381 void
1383 {
1384  NS_LOG_FUNCTION(this);
1385  for (AddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++)
1386  {
1387  *iter = nullptr;
1388  }
1389  return m_addressBlockList.clear();
1390 }
1391 
1392 uint32_t
1394 {
1395  NS_LOG_FUNCTION(this);
1396  /* msg-type + (msg-flags + msg-addr-length) + 2msg-size */
1397  uint32_t size = 4;
1398 
1399  if (HasOriginatorAddress())
1400  {
1401  size += GetAddressLength() + 1;
1402  }
1403 
1404  if (HasHopLimit())
1405  {
1406  size++;
1407  }
1408 
1409  if (HasHopCount())
1410  {
1411  size++;
1412  }
1413 
1414  if (HasSequenceNumber())
1415  {
1416  size += 2;
1417  }
1418 
1419  size += m_tlvList.GetSerializedSize();
1420 
1421  for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++)
1422  {
1423  size += (*iter)->GetSerializedSize();
1424  }
1425 
1426  return size;
1427 }
1428 
1429 void
1431 {
1432  NS_LOG_FUNCTION(this << &start);
1433  Buffer::Iterator front = start;
1434 
1435  start.WriteU8(GetType());
1436 
1437  /* Save a reference to the spot where we will later write the flags */
1438  Buffer::Iterator bufref = start;
1439  start.Next(1);
1440 
1441  uint8_t flags = 0;
1442 
1443  flags = GetAddressLength();
1444 
1445  Buffer::Iterator sizeref = start;
1446  start.Next(2);
1447 
1448  if (HasOriginatorAddress())
1449  {
1450  flags |= MHAS_ORIG;
1452  }
1453 
1454  if (HasHopLimit())
1455  {
1456  flags |= MHAS_HOP_LIMIT;
1457  start.WriteU8(GetHopLimit());
1458  }
1459 
1460  if (HasHopCount())
1461  {
1462  flags |= MHAS_HOP_COUNT;
1463  start.WriteU8(GetHopCount());
1464  }
1465 
1466  if (HasSequenceNumber())
1467  {
1468  flags |= MHAS_SEQ_NUM;
1469  start.WriteHtonU16(GetSequenceNumber());
1470  }
1471 
1472  bufref.WriteU8(flags);
1473 
1475 
1476  for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++)
1477  {
1478  (*iter)->Serialize(start);
1479  }
1480 
1481  sizeref.WriteHtonU16(front.GetDistanceFrom(start));
1482 }
1483 
1486 {
1488  /* We need to read the msg-addr-len field to determine what kind of object to
1489  * construct. */
1490  start.Next();
1491  uint8_t addrlen = start.ReadU8();
1492  start.Prev(2); /* Go back to the start */
1493 
1494  /* The first four bytes of the flag is the address length. Set the last four
1495  * bytes to 0 to read it. */
1496  addrlen = (addrlen & 0xf);
1497 
1498  Ptr<PbbMessage> newmsg;
1499 
1500  switch (addrlen)
1501  {
1502  case 0:
1503  case IPV4:
1504  newmsg = Create<PbbMessageIpv4>();
1505  break;
1506  case IPV6:
1507  newmsg = Create<PbbMessageIpv6>();
1508  break;
1509  default:
1510  return nullptr;
1511  break;
1512  }
1513  newmsg->Deserialize(start);
1514  return newmsg;
1515 }
1516 
1517 void
1519 {
1520  NS_LOG_FUNCTION(this << &start);
1521  Buffer::Iterator front = start;
1522  SetType(start.ReadU8());
1523  uint8_t flags = start.ReadU8();
1524 
1525  uint16_t size = start.ReadNtohU16();
1526 
1527  if (flags & MHAS_ORIG)
1528  {
1530  }
1531 
1532  if (flags & MHAS_HOP_LIMIT)
1533  {
1534  SetHopLimit(start.ReadU8());
1535  }
1536 
1537  if (flags & MHAS_HOP_COUNT)
1538  {
1539  SetHopCount(start.ReadU8());
1540  }
1541 
1542  if (flags & MHAS_SEQ_NUM)
1543  {
1544  SetSequenceNumber(start.ReadNtohU16());
1545  }
1546 
1548 
1549  if (size > 0)
1550  {
1551  while (start.GetDistanceFrom(front) < size)
1552  {
1554  AddressBlockPushBack(newab);
1555  }
1556  }
1557 }
1558 
1559 void
1560 PbbMessage::Print(std::ostream& os) const
1561 {
1562  NS_LOG_FUNCTION(this << &os);
1563  Print(os, 0);
1564 }
1565 
1566 void
1567 PbbMessage::Print(std::ostream& os, int level) const
1568 {
1569  NS_LOG_FUNCTION(this << &os << level);
1570  std::string prefix = "";
1571  for (int i = 0; i < level; i++)
1572  {
1573  prefix.append("\t");
1574  }
1575 
1576  os << prefix << "PbbMessage {" << std::endl;
1577 
1578  os << prefix << "\tmessage type = " << (int)GetType() << std::endl;
1579  os << prefix << "\taddress size = " << GetAddressLength() << std::endl;
1580 
1581  if (HasOriginatorAddress())
1582  {
1583  os << prefix << "\toriginator address = ";
1585  os << std::endl;
1586  }
1587 
1588  if (HasHopLimit())
1589  {
1590  os << prefix << "\thop limit = " << (int)GetHopLimit() << std::endl;
1591  }
1592 
1593  if (HasHopCount())
1594  {
1595  os << prefix << "\thop count = " << (int)GetHopCount() << std::endl;
1596  }
1597 
1598  if (HasSequenceNumber())
1599  {
1600  os << prefix << "\tseqnum = " << GetSequenceNumber() << std::endl;
1601  }
1602 
1603  m_tlvList.Print(os, level + 1);
1604 
1605  for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++)
1606  {
1607  (*iter)->Print(os, level + 1);
1608  }
1609  os << prefix << "}" << std::endl;
1610 }
1611 
1612 bool
1614 {
1615  if (GetAddressLength() != other.GetAddressLength())
1616  {
1617  return false;
1618  }
1619 
1620  if (GetType() != other.GetType())
1621  {
1622  return false;
1623  }
1624 
1625  if (HasOriginatorAddress() != other.HasOriginatorAddress())
1626  {
1627  return false;
1628  }
1629 
1630  if (HasOriginatorAddress())
1631  {
1632  if (GetOriginatorAddress() != other.GetOriginatorAddress())
1633  {
1634  return false;
1635  }
1636  }
1637 
1638  if (HasHopLimit() != other.HasHopLimit())
1639  {
1640  return false;
1641  }
1642 
1643  if (HasHopLimit())
1644  {
1645  if (GetHopLimit() != other.GetHopLimit())
1646  {
1647  return false;
1648  }
1649  }
1650 
1651  if (HasHopCount() != other.HasHopCount())
1652  {
1653  return false;
1654  }
1655 
1656  if (HasHopCount())
1657  {
1658  if (GetHopCount() != other.GetHopCount())
1659  {
1660  return false;
1661  }
1662  }
1663 
1664  if (HasSequenceNumber() != other.HasSequenceNumber())
1665  {
1666  return false;
1667  }
1668 
1669  if (HasSequenceNumber())
1670  {
1671  if (GetSequenceNumber() != other.GetSequenceNumber())
1672  {
1673  return false;
1674  }
1675  }
1676 
1677  if (m_tlvList != other.m_tlvList)
1678  {
1679  return false;
1680  }
1681 
1682  if (AddressBlockSize() != other.AddressBlockSize())
1683  {
1684  return false;
1685  }
1686 
1689  for (tai = AddressBlockBegin(), oai = other.AddressBlockBegin();
1690  tai != AddressBlockEnd() && oai != other.AddressBlockEnd();
1691  tai++, oai++)
1692  {
1693  if (**tai != **oai)
1694  {
1695  return false;
1696  }
1697  }
1698  return true;
1699 }
1700 
1701 bool
1703 {
1704  return !(*this == other);
1705 }
1706 
1707 /* End PbbMessage Class */
1708 
1710 {
1711  NS_LOG_FUNCTION(this);
1712 }
1713 
1716 {
1717  NS_LOG_FUNCTION(this);
1718  return IPV4;
1719 }
1720 
1721 void
1723 {
1724  NS_LOG_FUNCTION(this << &start);
1725  uint8_t* buffer = new uint8_t[GetAddressLength() + 1];
1727  start.Write(buffer, GetAddressLength() + 1);
1728  delete[] buffer;
1729 }
1730 
1731 Address
1733 {
1734  NS_LOG_FUNCTION(this << &start);
1735  uint8_t* buffer = new uint8_t[GetAddressLength() + 1];
1736  start.Read(buffer, GetAddressLength() + 1);
1737  Address result = Ipv4Address::Deserialize(buffer);
1738  delete[] buffer;
1739  return result;
1740 }
1741 
1742 void
1744 {
1745  NS_LOG_FUNCTION(this << &os);
1747 }
1748 
1751 {
1752  NS_LOG_FUNCTION(this << &start);
1753  Ptr<PbbAddressBlock> newab = Create<PbbAddressBlockIpv4>();
1754  newab->Deserialize(start);
1755  return newab;
1756 }
1757 
1758 /* End PbbMessageIpv4 Class */
1759 
1761 {
1762  NS_LOG_FUNCTION(this);
1763 }
1764 
1767 {
1768  NS_LOG_FUNCTION(this);
1769  return IPV6;
1770 }
1771 
1772 void
1774 {
1775  NS_LOG_FUNCTION(this << &start);
1776  uint8_t* buffer = new uint8_t[GetAddressLength() + 1];
1778  start.Write(buffer, GetAddressLength() + 1);
1779  delete[] buffer;
1780 }
1781 
1782 Address
1784 {
1785  NS_LOG_FUNCTION(this << &start);
1786  uint8_t* buffer = new uint8_t[GetAddressLength() + 1];
1787  start.Read(buffer, GetAddressLength() + 1);
1789  delete[] buffer;
1790  return res;
1791 }
1792 
1793 void
1795 {
1796  NS_LOG_FUNCTION(this << &os);
1798 }
1799 
1802 {
1803  NS_LOG_FUNCTION(this << &start);
1804  Ptr<PbbAddressBlock> newab = Create<PbbAddressBlockIpv6>();
1805  newab->Deserialize(start);
1806  return newab;
1807 }
1808 
1809 /* End PbbMessageIpv6 Class */
1810 
1812 {
1813  NS_LOG_FUNCTION(this);
1814 }
1815 
1817 {
1818  NS_LOG_FUNCTION(this);
1819 }
1820 
1821 /* Manipulating the address block */
1822 
1825 {
1826  NS_LOG_FUNCTION(this);
1827  return m_addressList.begin();
1828 }
1829 
1832 {
1833  NS_LOG_FUNCTION(this);
1834  return m_addressList.begin();
1835 }
1836 
1839 {
1840  NS_LOG_FUNCTION(this);
1841  return m_addressList.end();
1842 }
1843 
1846 {
1847  NS_LOG_FUNCTION(this);
1848  return m_addressList.end();
1849 }
1850 
1851 int
1853 {
1854  NS_LOG_FUNCTION(this);
1855  return m_addressList.size();
1856 }
1857 
1858 bool
1860 {
1861  NS_LOG_FUNCTION(this);
1862  return m_addressList.empty();
1863 }
1864 
1865 Address
1867 {
1868  NS_LOG_FUNCTION(this);
1869  return m_addressList.front();
1870 }
1871 
1872 Address
1874 {
1875  NS_LOG_FUNCTION(this);
1876  return m_addressList.back();
1877 }
1878 
1879 void
1881 {
1882  NS_LOG_FUNCTION(this << tlv);
1883  m_addressList.push_front(tlv);
1884 }
1885 
1886 void
1888 {
1889  NS_LOG_FUNCTION(this);
1890  m_addressList.pop_front();
1891 }
1892 
1893 void
1895 {
1896  NS_LOG_FUNCTION(this << tlv);
1897  m_addressList.push_back(tlv);
1898 }
1899 
1900 void
1902 {
1903  NS_LOG_FUNCTION(this);
1904  m_addressList.pop_back();
1905 }
1906 
1909 {
1910  NS_LOG_FUNCTION(this << &position);
1911  return m_addressList.erase(position);
1912 }
1913 
1917 {
1918  NS_LOG_FUNCTION(this << &first << &last);
1919  return m_addressList.erase(first, last);
1920 }
1921 
1922 void
1924 {
1925  NS_LOG_FUNCTION(this);
1926  return m_addressList.clear();
1927 }
1928 
1929 /* Manipulating the prefix list */
1930 
1933 {
1934  NS_LOG_FUNCTION(this);
1935  return m_prefixList.begin();
1936 }
1937 
1940 {
1941  NS_LOG_FUNCTION(this);
1942  return m_prefixList.begin();
1943 }
1944 
1947 {
1948  NS_LOG_FUNCTION(this);
1949  return m_prefixList.end();
1950 }
1951 
1954 {
1955  NS_LOG_FUNCTION(this);
1956  return m_prefixList.end();
1957 }
1958 
1959 int
1961 {
1962  NS_LOG_FUNCTION(this);
1963  return m_prefixList.size();
1964 }
1965 
1966 bool
1968 {
1969  NS_LOG_FUNCTION(this);
1970  return m_prefixList.empty();
1971 }
1972 
1973 uint8_t
1975 {
1976  NS_LOG_FUNCTION(this);
1977  return m_prefixList.front();
1978 }
1979 
1980 uint8_t
1982 {
1983  NS_LOG_FUNCTION(this);
1984  return m_prefixList.back();
1985 }
1986 
1987 void
1989 {
1990  NS_LOG_FUNCTION(this << static_cast<uint32_t>(prefix));
1991  m_prefixList.push_front(prefix);
1992 }
1993 
1994 void
1996 {
1997  NS_LOG_FUNCTION(this);
1998  m_prefixList.pop_front();
1999 }
2000 
2001 void
2003 {
2004  NS_LOG_FUNCTION(this << static_cast<uint32_t>(prefix));
2005  m_prefixList.push_back(prefix);
2006 }
2007 
2008 void
2010 {
2011  NS_LOG_FUNCTION(this);
2012  m_prefixList.pop_back();
2013 }
2014 
2017 {
2018  NS_LOG_FUNCTION(this << &position << static_cast<uint32_t>(value));
2019  return m_prefixList.insert(position, value);
2020 }
2021 
2024 {
2025  NS_LOG_FUNCTION(this << &position);
2026  return m_prefixList.erase(position);
2027 }
2028 
2032 {
2033  NS_LOG_FUNCTION(this << &first << &last);
2034  return m_prefixList.erase(first, last);
2035 }
2036 
2037 void
2039 {
2040  NS_LOG_FUNCTION(this);
2041  m_prefixList.clear();
2042 }
2043 
2044 /* Manipulating the TLV block */
2045 
2048 {
2049  NS_LOG_FUNCTION(this);
2050  return m_addressTlvList.Begin();
2051 }
2052 
2055 {
2056  NS_LOG_FUNCTION(this);
2057  return m_addressTlvList.Begin();
2058 }
2059 
2062 {
2063  NS_LOG_FUNCTION(this);
2064  return m_addressTlvList.End();
2065 }
2066 
2069 {
2070  NS_LOG_FUNCTION(this);
2071  return m_addressTlvList.End();
2072 }
2073 
2074 int
2076 {
2077  NS_LOG_FUNCTION(this);
2078  return m_addressTlvList.Size();
2079 }
2080 
2081 bool
2083 {
2084  NS_LOG_FUNCTION(this);
2085  return m_addressTlvList.Empty();
2086 }
2087 
2090 {
2091  NS_LOG_FUNCTION(this);
2092  return m_addressTlvList.Front();
2093 }
2094 
2095 const Ptr<PbbAddressTlv>
2097 {
2098  NS_LOG_FUNCTION(this);
2099  return m_addressTlvList.Front();
2100 }
2101 
2104 {
2105  NS_LOG_FUNCTION(this);
2106  return m_addressTlvList.Back();
2107 }
2108 
2109 const Ptr<PbbAddressTlv>
2111 {
2112  NS_LOG_FUNCTION(this);
2113  return m_addressTlvList.Back();
2114 }
2115 
2116 void
2118 {
2119  NS_LOG_FUNCTION(this << tlv);
2121 }
2122 
2123 void
2125 {
2126  NS_LOG_FUNCTION(this);
2128 }
2129 
2130 void
2132 {
2133  NS_LOG_FUNCTION(this << tlv);
2135 }
2136 
2137 void
2139 {
2140  NS_LOG_FUNCTION(this);
2142 }
2143 
2146 {
2147  NS_LOG_FUNCTION(this << &position);
2148  return m_addressTlvList.Erase(position);
2149 }
2150 
2153 {
2154  NS_LOG_FUNCTION(this << &first << &last);
2155  return m_addressTlvList.Erase(first, last);
2156 }
2157 
2158 void
2160 {
2161  NS_LOG_FUNCTION(this);
2163 }
2164 
2165 uint32_t
2167 {
2168  NS_LOG_FUNCTION(this);
2169  /* num-addr + flags */
2170  uint32_t size = 2;
2171 
2172  if (AddressSize() == 1)
2173  {
2174  size += GetAddressLength() + PrefixSize();
2175  }
2176  else if (AddressSize() > 0)
2177  {
2178  uint8_t* head = new uint8_t[GetAddressLength()];
2179  uint8_t headlen = 0;
2180  uint8_t* tail = new uint8_t[GetAddressLength()];
2181  uint8_t taillen = 0;
2182 
2183  GetHeadTail(head, headlen, tail, taillen);
2184 
2185  if (headlen > 0)
2186  {
2187  size += 1 + headlen;
2188  }
2189 
2190  if (taillen > 0)
2191  {
2192  size++;
2193  if (!HasZeroTail(tail, taillen))
2194  {
2195  size += taillen;
2196  }
2197  }
2198 
2199  /* mid size */
2200  size += (GetAddressLength() - headlen - taillen) * AddressSize();
2201 
2202  size += PrefixSize();
2203 
2204  delete[] head;
2205  delete[] tail;
2206  }
2207 
2209 
2210  return size;
2211 }
2212 
2213 void
2215 {
2216  NS_LOG_FUNCTION(this << &start);
2217  start.WriteU8(AddressSize());
2218  Buffer::Iterator bufref = start;
2219  uint8_t flags = 0;
2220  start.Next();
2221 
2222  if (AddressSize() == 1)
2223  {
2224  uint8_t* buf = new uint8_t[GetAddressLength()];
2226  start.Write(buf, GetAddressLength());
2227 
2228  if (PrefixSize() == 1)
2229  {
2230  start.WriteU8(PrefixFront());
2231  flags |= AHAS_SINGLE_PRE_LEN;
2232  }
2233  bufref.WriteU8(flags);
2234  delete[] buf;
2235  }
2236  else if (AddressSize() > 0)
2237  {
2238  uint8_t* head = new uint8_t[GetAddressLength()];
2239  uint8_t* tail = new uint8_t[GetAddressLength()];
2240  uint8_t headlen = 0;
2241  uint8_t taillen = 0;
2242 
2243  GetHeadTail(head, headlen, tail, taillen);
2244 
2245  if (headlen > 0)
2246  {
2247  flags |= AHAS_HEAD;
2248  start.WriteU8(headlen);
2249  start.Write(head, headlen);
2250  }
2251 
2252  if (taillen > 0)
2253  {
2254  start.WriteU8(taillen);
2255 
2256  if (HasZeroTail(tail, taillen))
2257  {
2258  flags |= AHAS_ZERO_TAIL;
2259  }
2260  else
2261  {
2262  flags |= AHAS_FULL_TAIL;
2263  start.Write(tail, taillen);
2264  }
2265  }
2266 
2267  if (headlen + taillen < GetAddressLength())
2268  {
2269  uint8_t* mid = new uint8_t[GetAddressLength()];
2271  iter++)
2272  {
2273  SerializeAddress(mid, iter);
2274  start.Write(mid + headlen, GetAddressLength() - headlen - taillen);
2275  }
2276  delete[] mid;
2277  }
2278 
2279  flags |= GetPrefixFlags();
2280  bufref.WriteU8(flags);
2281 
2282  for (ConstPrefixIterator iter = PrefixBegin(); iter != PrefixEnd(); iter++)
2283  {
2284  start.WriteU8(*iter);
2285  }
2286 
2287  delete[] head;
2288  delete[] tail;
2289  }
2290 
2292 }
2293 
2294 void
2296 {
2297  NS_LOG_FUNCTION(this << &start);
2298  uint8_t numaddr = start.ReadU8();
2299  uint8_t flags = start.ReadU8();
2300 
2301  if (numaddr > 0)
2302  {
2303  uint8_t headlen = 0;
2304  uint8_t taillen = 0;
2305  uint8_t* addrtmp = new uint8_t[GetAddressLength()];
2306  memset(addrtmp, 0, GetAddressLength());
2307 
2308  if (flags & AHAS_HEAD)
2309  {
2310  headlen = start.ReadU8();
2311  start.Read(addrtmp, headlen);
2312  }
2313 
2314  if ((flags & AHAS_FULL_TAIL) ^ (flags & AHAS_ZERO_TAIL))
2315  {
2316  taillen = start.ReadU8();
2317 
2318  if (flags & AHAS_FULL_TAIL)
2319  {
2320  start.Read(addrtmp + GetAddressLength() - taillen, taillen);
2321  }
2322  }
2323 
2324  for (int i = 0; i < numaddr; i++)
2325  {
2326  start.Read(addrtmp + headlen, GetAddressLength() - headlen - taillen);
2328  }
2329 
2330  if (flags & AHAS_SINGLE_PRE_LEN)
2331  {
2332  PrefixPushBack(start.ReadU8());
2333  }
2334  else if (flags & AHAS_MULTI_PRE_LEN)
2335  {
2336  for (int i = 0; i < numaddr; i++)
2337  {
2338  PrefixPushBack(start.ReadU8());
2339  }
2340  }
2341 
2342  delete[] addrtmp;
2343  }
2344 
2346 }
2347 
2348 void
2349 PbbAddressBlock::Print(std::ostream& os) const
2350 {
2351  NS_LOG_FUNCTION(this << &os);
2352  Print(os, 0);
2353 }
2354 
2355 void
2356 PbbAddressBlock::Print(std::ostream& os, int level) const
2357 {
2358  NS_LOG_FUNCTION(this << &os << level);
2359  std::string prefix = "";
2360  for (int i = 0; i < level; i++)
2361  {
2362  prefix.append("\t");
2363  }
2364 
2365  os << prefix << "PbbAddressBlock {" << std::endl;
2366  os << prefix << "\taddresses = " << std::endl;
2367  for (ConstAddressIterator iter = AddressBegin(); iter != AddressEnd(); iter++)
2368  {
2369  os << prefix << "\t\t";
2370  PrintAddress(os, iter);
2371  os << std::endl;
2372  }
2373 
2374  os << prefix << "\tprefixes = " << std::endl;
2375  for (ConstPrefixIterator iter = PrefixBegin(); iter != PrefixEnd(); iter++)
2376  {
2377  os << prefix << "\t\t" << (int)(*iter) << std::endl;
2378  }
2379 
2380  m_addressTlvList.Print(os, level + 1);
2381 }
2382 
2383 bool
2385 {
2386  if (AddressSize() != other.AddressSize())
2387  {
2388  return false;
2389  }
2390 
2393  for (tai = AddressBegin(), oai = other.AddressBegin();
2394  tai != AddressEnd() && oai != other.AddressEnd();
2395  tai++, oai++)
2396  {
2397  if (*tai != *oai)
2398  {
2399  return false;
2400  }
2401  }
2402 
2403  if (PrefixSize() != other.PrefixSize())
2404  {
2405  return false;
2406  }
2407 
2408  ConstPrefixIterator tpi;
2409  ConstPrefixIterator opi;
2410  for (tpi = PrefixBegin(), opi = other.PrefixBegin();
2411  tpi != PrefixEnd() && opi != other.PrefixEnd();
2412  tpi++, opi++)
2413  {
2414  if (*tpi != *opi)
2415  {
2416  return false;
2417  }
2418  }
2419 
2420  if (m_addressTlvList != other.m_addressTlvList)
2421  {
2422  return false;
2423  }
2424 
2425  return true;
2426 }
2427 
2428 bool
2430 {
2431  return !(*this == other);
2432 }
2433 
2434 uint8_t
2436 {
2437  NS_LOG_FUNCTION(this);
2438  switch (PrefixSize())
2439  {
2440  case 0:
2441  return 0;
2442  break;
2443  case 1:
2444  return AHAS_SINGLE_PRE_LEN;
2445  break;
2446  default:
2447  return AHAS_MULTI_PRE_LEN;
2448  break;
2449  }
2450 
2451  /* Quiet compiler */
2452  return 0;
2453 }
2454 
2455 void
2456 PbbAddressBlock::GetHeadTail(uint8_t* head, uint8_t& headlen, uint8_t* tail, uint8_t& taillen) const
2457 {
2458  NS_LOG_FUNCTION(this << &head << static_cast<uint32_t>(headlen) << &tail
2459  << static_cast<uint32_t>(taillen));
2460  headlen = GetAddressLength();
2461  taillen = headlen;
2462 
2463  /* Temporary automatic buffers to store serialized addresses */
2464  uint8_t* buflast = new uint8_t[GetAddressLength()];
2465  uint8_t* bufcur = new uint8_t[GetAddressLength()];
2466  uint8_t* tmp;
2467 
2468  SerializeAddress(buflast, AddressBegin());
2469 
2470  /* Skip the first item */
2472  iter++)
2473  {
2474  SerializeAddress(bufcur, iter);
2475 
2476  int i;
2477  for (i = 0; i < headlen; i++)
2478  {
2479  if (buflast[i] != bufcur[i])
2480  {
2481  headlen = i;
2482  break;
2483  }
2484  }
2485 
2486  /* If headlen == fulllen - 1, then tail is 0 */
2487  if (GetAddressLength() - headlen > 0)
2488  {
2489  for (i = GetAddressLength() - 1; GetAddressLength() - 1 - i <= taillen && i > headlen;
2490  i--)
2491  {
2492  if (buflast[i] != bufcur[i])
2493  {
2494  break;
2495  }
2496  }
2497  taillen = GetAddressLength() - 1 - i;
2498  }
2499  else if (headlen == 0)
2500  {
2501  taillen = 0;
2502  break;
2503  }
2504 
2505  tmp = buflast;
2506  buflast = bufcur;
2507  bufcur = tmp;
2508  }
2509 
2510  memcpy(head, bufcur, headlen);
2511  memcpy(tail, bufcur + (GetAddressLength() - taillen), taillen);
2512 
2513  delete[] buflast;
2514  delete[] bufcur;
2515 }
2516 
2517 bool
2518 PbbAddressBlock::HasZeroTail(const uint8_t* tail, uint8_t taillen) const
2519 {
2520  NS_LOG_FUNCTION(this << &tail << static_cast<uint32_t>(taillen));
2521  int i;
2522  for (i = 0; i < taillen; i++)
2523  {
2524  if (tail[i] != 0)
2525  {
2526  break;
2527  }
2528  }
2529  return i == taillen;
2530 }
2531 
2532 /* End PbbAddressBlock Class */
2533 
2535 {
2536  NS_LOG_FUNCTION(this);
2537 }
2538 
2540 {
2541  NS_LOG_FUNCTION(this);
2542 }
2543 
2544 uint8_t
2546 {
2547  NS_LOG_FUNCTION(this);
2548  return 4;
2549 }
2550 
2551 void
2553 {
2554  NS_LOG_FUNCTION(this << &buffer << &iter);
2555  Ipv4Address::ConvertFrom(*iter).Serialize(buffer);
2556 }
2557 
2558 Address
2560 {
2561  NS_LOG_FUNCTION(this << &buffer);
2562  return Ipv4Address::Deserialize(buffer);
2563 }
2564 
2565 void
2567 {
2568  NS_LOG_FUNCTION(this << &os << &iter);
2569  Ipv4Address::ConvertFrom(*iter).Print(os);
2570 }
2571 
2572 /* End PbbAddressBlockIpv4 Class */
2573 
2575 {
2576  NS_LOG_FUNCTION(this);
2577 }
2578 
2580 {
2581  NS_LOG_FUNCTION(this);
2582 }
2583 
2584 uint8_t
2586 {
2587  NS_LOG_FUNCTION(this);
2588  return 16;
2589 }
2590 
2591 void
2593 {
2594  NS_LOG_FUNCTION(this << &buffer << &iter);
2595  Ipv6Address::ConvertFrom(*iter).Serialize(buffer);
2596 }
2597 
2598 Address
2600 {
2601  NS_LOG_FUNCTION(this << &buffer);
2602  return Ipv6Address::Deserialize(buffer);
2603 }
2604 
2605 void
2607 {
2608  NS_LOG_FUNCTION(this << &os << &iter);
2609  Ipv6Address::ConvertFrom(*iter).Print(os);
2610 }
2611 
2612 /* End PbbAddressBlockIpv6 Class */
2613 
2615 {
2616  NS_LOG_FUNCTION(this);
2617  m_hasTypeExt = false;
2618  m_hasIndexStart = false;
2619  m_hasIndexStop = false;
2620  m_isMultivalue = false;
2621  m_hasValue = false;
2622 }
2623 
2625 {
2626  NS_LOG_FUNCTION(this);
2628 }
2629 
2630 void
2632 {
2633  NS_LOG_FUNCTION(this << static_cast<uint32_t>(type));
2634  m_type = type;
2635 }
2636 
2637 uint8_t
2639 {
2640  NS_LOG_FUNCTION(this);
2641  return m_type;
2642 }
2643 
2644 void
2645 PbbTlv::SetTypeExt(uint8_t typeExt)
2646 {
2647  NS_LOG_FUNCTION(this << static_cast<uint32_t>(typeExt));
2648  m_typeExt = typeExt;
2649  m_hasTypeExt = true;
2650 }
2651 
2652 uint8_t
2654 {
2655  NS_LOG_FUNCTION(this);
2656  NS_ASSERT(HasTypeExt());
2657  return m_typeExt;
2658 }
2659 
2660 bool
2662 {
2663  NS_LOG_FUNCTION(this);
2664  return m_hasTypeExt;
2665 }
2666 
2667 void
2669 {
2670  NS_LOG_FUNCTION(this << static_cast<uint32_t>(index));
2671  m_indexStart = index;
2672  m_hasIndexStart = true;
2673 }
2674 
2675 uint8_t
2677 {
2678  NS_LOG_FUNCTION(this);
2680  return m_indexStart;
2681 }
2682 
2683 bool
2685 {
2686  NS_LOG_FUNCTION(this);
2687  return m_hasIndexStart;
2688 }
2689 
2690 void
2691 PbbTlv::SetIndexStop(uint8_t index)
2692 {
2693  NS_LOG_FUNCTION(this << static_cast<uint32_t>(index));
2694  m_indexStop = index;
2695  m_hasIndexStop = true;
2696 }
2697 
2698 uint8_t
2700 {
2701  NS_LOG_FUNCTION(this);
2703  return m_indexStop;
2704 }
2705 
2706 bool
2708 {
2709  NS_LOG_FUNCTION(this);
2710  return m_hasIndexStop;
2711 }
2712 
2713 void
2714 PbbTlv::SetMultivalue(bool isMultivalue)
2715 {
2716  NS_LOG_FUNCTION(this << isMultivalue);
2717  m_isMultivalue = isMultivalue;
2718 }
2719 
2720 bool
2722 {
2723  NS_LOG_FUNCTION(this);
2724  return m_isMultivalue;
2725 }
2726 
2727 void
2729 {
2730  NS_LOG_FUNCTION(this << &start);
2731  m_hasValue = true;
2732  m_value = start;
2733 }
2734 
2735 void
2736 PbbTlv::SetValue(const uint8_t* buffer, uint32_t size)
2737 {
2738  NS_LOG_FUNCTION(this << &buffer << size);
2739  m_hasValue = true;
2740  m_value.AddAtStart(size);
2741  m_value.Begin().Write(buffer, size);
2742 }
2743 
2744 Buffer
2746 {
2747  NS_LOG_FUNCTION(this);
2748  NS_ASSERT(HasValue());
2749  return m_value;
2750 }
2751 
2752 bool
2754 {
2755  NS_LOG_FUNCTION(this);
2756  return m_hasValue;
2757 }
2758 
2759 uint32_t
2761 {
2762  NS_LOG_FUNCTION(this);
2763  /* type + flags */
2764  uint32_t size = 2;
2765 
2766  if (HasTypeExt())
2767  {
2768  size++;
2769  }
2770 
2771  if (HasIndexStart())
2772  {
2773  size++;
2774  }
2775 
2776  if (HasIndexStop())
2777  {
2778  size++;
2779  }
2780 
2781  if (HasValue())
2782  {
2783  if (GetValue().GetSize() > 255)
2784  {
2785  size += 2;
2786  }
2787  else
2788  {
2789  size++;
2790  }
2791  size += GetValue().GetSize();
2792  }
2793 
2794  return size;
2795 }
2796 
2797 void
2799 {
2800  NS_LOG_FUNCTION(this << &start);
2801  start.WriteU8(GetType());
2802 
2803  Buffer::Iterator bufref = start;
2804  uint8_t flags = 0;
2805  start.Next();
2806 
2807  if (HasTypeExt())
2808  {
2809  flags |= THAS_TYPE_EXT;
2810  start.WriteU8(GetTypeExt());
2811  }
2812 
2813  if (HasIndexStart())
2814  {
2815  start.WriteU8(GetIndexStart());
2816 
2817  if (HasIndexStop())
2818  {
2819  flags |= THAS_MULTI_INDEX;
2820  start.WriteU8(GetIndexStop());
2821  }
2822  else
2823  {
2824  flags |= THAS_SINGLE_INDEX;
2825  }
2826  }
2827 
2828  if (HasValue())
2829  {
2830  flags |= THAS_VALUE;
2831 
2832  uint32_t size = GetValue().GetSize();
2833  if (size > 255)
2834  {
2835  flags |= THAS_EXT_LEN;
2836  start.WriteHtonU16(size);
2837  }
2838  else
2839  {
2840  start.WriteU8(size);
2841  }
2842 
2843  if (IsMultivalue())
2844  {
2845  flags |= TIS_MULTIVALUE;
2846  }
2847 
2848  start.Write(GetValue().Begin(), GetValue().End());
2849  }
2850 
2851  bufref.WriteU8(flags);
2852 }
2853 
2854 void
2856 {
2857  NS_LOG_FUNCTION(this << &start);
2858  SetType(start.ReadU8());
2859 
2860  uint8_t flags = start.ReadU8();
2861 
2862  if (flags & THAS_TYPE_EXT)
2863  {
2864  SetTypeExt(start.ReadU8());
2865  }
2866 
2867  if (flags & THAS_MULTI_INDEX)
2868  {
2869  SetIndexStart(start.ReadU8());
2870  SetIndexStop(start.ReadU8());
2871  }
2872  else if (flags & THAS_SINGLE_INDEX)
2873  {
2874  SetIndexStart(start.ReadU8());
2875  }
2876 
2877  if (flags & THAS_VALUE)
2878  {
2879  uint16_t len = 0;
2880 
2881  if (flags & THAS_EXT_LEN)
2882  {
2883  len = start.ReadNtohU16();
2884  }
2885  else
2886  {
2887  len = start.ReadU8();
2888  }
2889 
2890  m_value.AddAtStart(len);
2891 
2892  Buffer::Iterator valueStart = start;
2893  start.Next(len);
2894  m_value.Begin().Write(valueStart, start);
2895  m_hasValue = true;
2896  }
2897 }
2898 
2899 void
2900 PbbTlv::Print(std::ostream& os) const
2901 {
2902  NS_LOG_FUNCTION(this << &os);
2903  Print(os, 0);
2904 }
2905 
2906 void
2907 PbbTlv::Print(std::ostream& os, int level) const
2908 {
2909  NS_LOG_FUNCTION(this << &os << level);
2910  std::string prefix = "";
2911  for (int i = 0; i < level; i++)
2912  {
2913  prefix.append("\t");
2914  }
2915 
2916  os << prefix << "PbbTlv {" << std::endl;
2917  os << prefix << "\ttype = " << (int)GetType() << std::endl;
2918 
2919  if (HasTypeExt())
2920  {
2921  os << prefix << "\ttypeext = " << (int)GetTypeExt() << std::endl;
2922  }
2923 
2924  if (HasIndexStart())
2925  {
2926  os << prefix << "\tindexStart = " << (int)GetIndexStart() << std::endl;
2927  }
2928 
2929  if (HasIndexStop())
2930  {
2931  os << prefix << "\tindexStop = " << (int)GetIndexStop() << std::endl;
2932  }
2933 
2934  os << prefix << "\tisMultivalue = " << IsMultivalue() << std::endl;
2935 
2936  if (HasValue())
2937  {
2938  os << prefix << "\thas value; size = " << GetValue().GetSize() << std::endl;
2939  }
2940 
2941  os << prefix << "}" << std::endl;
2942 }
2943 
2944 bool
2945 PbbTlv::operator==(const PbbTlv& other) const
2946 {
2947  if (GetType() != other.GetType())
2948  {
2949  return false;
2950  }
2951 
2952  if (HasTypeExt() != other.HasTypeExt())
2953  {
2954  return false;
2955  }
2956 
2957  if (HasTypeExt())
2958  {
2959  if (GetTypeExt() != other.GetTypeExt())
2960  {
2961  return false;
2962  }
2963  }
2964 
2965  if (HasValue() != other.HasValue())
2966  {
2967  return false;
2968  }
2969 
2970  if (HasValue())
2971  {
2972  Buffer tv = GetValue();
2973  Buffer ov = other.GetValue();
2974  if (tv.GetSize() != ov.GetSize())
2975  {
2976  return false;
2977  }
2978 
2979  /* The docs say I probably shouldn't use Buffer::PeekData, but I think it
2980  * is justified in this case. */
2981  if (memcmp(tv.PeekData(), ov.PeekData(), tv.GetSize()) != 0)
2982  {
2983  return false;
2984  }
2985  }
2986  return true;
2987 }
2988 
2989 bool
2990 PbbTlv::operator!=(const PbbTlv& other) const
2991 {
2992  return !(*this == other);
2993 }
2994 
2995 /* End PbbTlv Class */
2996 
2997 void
2999 {
3000  NS_LOG_FUNCTION(this << static_cast<uint32_t>(index));
3001  PbbTlv::SetIndexStart(index);
3002 }
3003 
3004 uint8_t
3006 {
3007  NS_LOG_FUNCTION(this);
3008  return PbbTlv::GetIndexStart();
3009 }
3010 
3011 bool
3013 {
3014  NS_LOG_FUNCTION(this);
3015  return PbbTlv::HasIndexStart();
3016 }
3017 
3018 void
3020 {
3021  NS_LOG_FUNCTION(this << static_cast<uint32_t>(index));
3022  PbbTlv::SetIndexStop(index);
3023 }
3024 
3025 uint8_t
3027 {
3028  NS_LOG_FUNCTION(this);
3029  return PbbTlv::GetIndexStop();
3030 }
3031 
3032 bool
3034 {
3035  NS_LOG_FUNCTION(this);
3036  return PbbTlv::HasIndexStop();
3037 }
3038 
3039 void
3041 {
3042  NS_LOG_FUNCTION(this << isMultivalue);
3043  PbbTlv::SetMultivalue(isMultivalue);
3044 }
3045 
3046 bool
3048 {
3049  NS_LOG_FUNCTION(this);
3050  return PbbTlv::IsMultivalue();
3051 }
3052 
3053 } /* namespace ns3 */
a polymophic address class
Definition: address.h:100
iterator in a Buffer instance
Definition: buffer.h:100
void WriteU8(uint8_t data)
Definition: buffer.h:881
void Write(const uint8_t *buffer, uint32_t size)
Definition: buffer.cc:951
void WriteHtonU16(uint16_t data)
Definition: buffer.h:915
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:783
automatically resized byte buffer
Definition: buffer.h:94
void RemoveAtEnd(uint32_t end)
Definition: buffer.cc:490
uint32_t GetSize() const
Definition: buffer.h:1068
void AddAtStart(uint32_t start)
Definition: buffer.cc:311
Buffer::Iterator Begin() const
Definition: buffer.h:1074
const uint8_t * PeekData() const
Definition: buffer.cc:706
Protocol header serialization and deserialization.
Definition: header.h:44
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
void Print(std::ostream &os) const
Print this address to the given output stream.
static Ipv4Address ConvertFrom(const Address &address)
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
static Ipv4Address Deserialize(const uint8_t buf[4])
void Print(std::ostream &os) const
Print this address to the given output stream.
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
static Ipv6Address ConvertFrom(const Address &address)
Convert the Address object into an Ipv6Address ones.
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:2435
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:2349
PrefixIterator PrefixEnd()
Definition: packetbb.cc:1946
std::list< Address > m_addressList
Addresses container.
Definition: packetbb.h:1604
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:2429
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:2456
void TlvPopBack()
Removes an address TLV from the back of this message.
Definition: packetbb.cc:2138
TlvIterator TlvBegin()
Definition: packetbb.cc:2047
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:2518
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:2295
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:2384
TlvIterator TlvEnd()
Definition: packetbb.cc:2061
PbbAddressTlvBlock m_addressTlvList
PbbAddressTlv container.
Definition: packetbb.h:1606
int AddressSize() const
Definition: packetbb.cc:1852
uint8_t GetAddressLength() const override
Returns address length.
Definition: packetbb.cc:2545
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition: packetbb.cc:2566
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition: packetbb.cc:2552
~PbbAddressBlockIpv4() override
Definition: packetbb.cc:2539
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition: packetbb.cc:2559
~PbbAddressBlockIpv6() override
Definition: packetbb.cc:2579
void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const override
Serialize one or more addresses.
Definition: packetbb.cc:2592
uint8_t GetAddressLength() const override
Returns address length.
Definition: packetbb.cc:2585
void PrintAddress(std::ostream &os, ConstAddressIterator iter) const override
Print one or more addresses.
Definition: packetbb.cc:2606
Address DeserializeAddress(uint8_t *buffer) const override
Deserialize one address.
Definition: packetbb.cc:2599
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:444
void PushBack(Ptr< PbbAddressTlv > tlv)
Appends an Address TLV to the back of this block.
Definition: packetbb.cc:385
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:485
Iterator Erase(Iterator position)
Removes the Address TLV at the specified position.
Definition: packetbb.cc:406
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:378
bool operator!=(const PbbAddressTlvBlock &other) const
Inequality operator for PbbAddressTlvBlock.
Definition: packetbb.cc:535
void Clear()
Removes all Address TLVs from this block.
Definition: packetbb.cc:420
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition: packetbb.cc:467
bool Empty() const
Definition: packetbb.cc:350
uint32_t GetSerializedSize() const
Definition: packetbb.cc:431
Ptr< PbbAddressTlv > Front() const
Definition: packetbb.cc:357
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:364
Iterator Insert(Iterator position, const Ptr< PbbAddressTlv > tlv)
Inserts an Address TLV at the specified position in this block.
Definition: packetbb.cc:399
void PushFront(Ptr< PbbAddressTlv > tlv)
Prepends an Address TLV to the front of this block.
Definition: packetbb.cc:371
void PopBack()
Removes an Address TLV from the back of this block.
Definition: packetbb.cc:392
bool operator==(const PbbAddressTlvBlock &other) const
Equality operator for PbbAddressTlvBlock.
Definition: packetbb.cc:515
bool HasIndexStart() const
Tests whether or not this address TLV has a start index.
Definition: packetbb.cc:3012
bool IsMultivalue() const
Tests whether or not this address TLV is "multivalue".
Definition: packetbb.cc:3047
void SetMultivalue(bool isMultivalue)
Sets whether or not this address TLV is "multivalue".
Definition: packetbb.cc:3040
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:2998
bool HasIndexStop() const
Tests whether or not this address TLV has a stop index.
Definition: packetbb.cc:3033
uint8_t GetIndexStop() const
Definition: packetbb.cc:3026
uint8_t GetIndexStart() const
Definition: packetbb.cc:3005
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:3019
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:1339
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:1047
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:1070
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:1225
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a message TLV to the front of this message.
Definition: packetbb.cc:1218
Address m_originatorAddress
originator address
Definition: packetbb.h:1109
uint8_t GetType() const
Definition: packetbb.cc:1040
bool HasHopLimit() const
Tests whether or not this message has a hop limit.
Definition: packetbb.cc:1093
bool operator!=(const PbbMessage &other) const
Inequality operator for PbbMessage.
Definition: packetbb.cc:1702
int AddressBlockSize() const
Definition: packetbb.cc:1297
AddressBlockIterator AddressBlockBegin()
Definition: packetbb.cc:1269
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:1283
void SetType(uint8_t type)
Sets the type for this message.
Definition: packetbb.cc:1033
void Serialize(Buffer::Iterator &start) const
Serializes this message into the specified buffer.
Definition: packetbb.cc:1430
Ptr< PbbTlv > TlvFront()
Definition: packetbb.cc:1190
TlvIterator TlvErase(TlvIterator position)
Removes the message TLV at the specified position.
Definition: packetbb.cc:1246
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:1054
void SetHopLimit(uint8_t hoplimit)
Sets the maximum number of hops this message should travel.
Definition: packetbb.cc:1077
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:1485
Address GetOriginatorAddress() const
Definition: packetbb.cc:1062
void TlvClear()
Removes all message TLVs from this block.
Definition: packetbb.cc:1260
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:1353
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
PbbTlv const iterator.
Definition: packetbb.h:701
TlvIterator TlvBegin()
Definition: packetbb.cc:1148
void TlvPopBack()
Removes a message TLV from the back of this message.
Definition: packetbb.cc:1239
uint16_t GetSequenceNumber() const
Definition: packetbb.cc:1131
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:1139
uint8_t GetHopLimit() const
Definition: packetbb.cc:1085
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:1100
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:1123
int TlvSize() const
Definition: packetbb.cc:1176
bool m_hasHopCount
Hop count present.
Definition: packetbb.h:1114
void AddressBlockClear()
Removes all address blocks from this message.
Definition: packetbb.cc:1382
virtual ~PbbMessage()
Definition: packetbb.cc:1026
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:1232
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:1367
Ptr< PbbAddressBlock > AddressBlockBack()
Definition: packetbb.cc:1325
uint8_t GetHopCount() const
Definition: packetbb.cc:1108
void AddressBlockPopFront()
Removes an address block from the front of this message.
Definition: packetbb.cc:1346
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:1393
std::list< Ptr< PbbTlv > >::iterator TlvIterator
PbbTlv iterator.
Definition: packetbb.h:699
TlvIterator TlvEnd()
Definition: packetbb.cc:1162
Ptr< PbbAddressBlock > AddressBlockFront()
Definition: packetbb.cc:1311
bool AddressBlockEmpty() const
Definition: packetbb.cc:1304
bool TlvEmpty() const
Definition: packetbb.cc:1183
bool HasHopCount() const
Tests whether or not this message has a hop count.
Definition: packetbb.cc:1116
Ptr< PbbTlv > TlvBack()
Definition: packetbb.cc:1204
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:1360
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
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:549
uint8_t m_version
version
Definition: packetbb.h:682
TlvIterator TlvBegin()
Definition: packetbb.cc:588
MessageIterator MessageEnd()
Definition: packetbb.cc:723
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:672
bool TlvEmpty() const
Definition: packetbb.cc:623
void TlvClear()
Removes all packet TLVs from this packet.
Definition: packetbb.cc:700
static TypeId GetTypeId()
Get the type ID.
Definition: packetbb.cc:832
void TlvPopBack()
Removes a packet TLV from the back of this block.
Definition: packetbb.cc:679
void TlvPopFront()
Removes a packet TLV from the front of this packet.
Definition: packetbb.cc:665
void MessagePushBack(Ptr< PbbMessage > message)
Appends a message to the back of this packet.
Definition: packetbb.cc:793
Ptr< PbbTlv > TlvFront()
Definition: packetbb.cc:630
TlvIterator TlvEnd()
Definition: packetbb.cc:602
void MessageClear()
Removes all messages from this packet.
Definition: packetbb.cc:821
Ptr< PbbMessage > MessageFront()
Definition: packetbb.cc:751
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:563
void MessagePopFront()
Removes a message from the front of this packet.
Definition: packetbb.cc:786
uint32_t GetSerializedSize() const override
Definition: packetbb.cc:848
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a packet TLV to the front of this packet.
Definition: packetbb.cc:658
bool MessageEmpty() const
Definition: packetbb.cc:744
uint16_t GetSequenceNumber() const
Definition: packetbb.cc:571
void MessagePopBack()
Removes a message from the back of this packet.
Definition: packetbb.cc:800
bool HasSequenceNumber() const
Tests whether or not this packet has a sequence number.
Definition: packetbb.cc:579
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: packetbb.cc:842
Ptr< PbbTlv > TlvBack()
Definition: packetbb.cc:644
MessageIterator MessageBegin()
Definition: packetbb.cc:709
TlvIterator Erase(TlvIterator position)
Removes the packet TLV at the specified position.
Definition: packetbb.cc:686
void MessagePushFront(Ptr< PbbMessage > message)
Prepends a message to the front of this packet.
Definition: packetbb.cc:779
int TlvSize() const
Definition: packetbb.cc:616
void Serialize(Buffer::Iterator start) const override
Serializes this packet into the specified buffer.
Definition: packetbb.cc:873
Ptr< PbbMessage > MessageBack()
Definition: packetbb.cc:765
void Print(std::ostream &os) const override
Pretty-prints the contents of this block.
Definition: packetbb.cc:940
bool operator!=(const PbbPacket &other) const
Inequality operator for PbbPacket.
Definition: packetbb.cc:1008
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:556
std::list< Ptr< PbbMessage > >::const_iterator ConstMessageIterator
PbbMessage Const Iterator for PbbPacket.
Definition: packetbb.h:400
int MessageSize() const
Definition: packetbb.cc:737
PbbTlvBlock m_tlvList
PbbTlv container.
Definition: packetbb.h:679
bool operator==(const PbbPacket &other) const
Equality operator for PbbPacket.
Definition: packetbb.cc:963
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:167
void PushBack(Ptr< PbbTlv > tlv)
Appends a TLV to the back of this block.
Definition: packetbb.cc:146
bool operator==(const PbbTlvBlock &other) const
Equality operator for PbbTlvBlock.
Definition: packetbb.cc:276
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition: packetbb.cc:205
Iterator End()
Definition: packetbb.cc:90
Ptr< PbbTlv > Front() const
Definition: packetbb.cc:118
void PushFront(Ptr< PbbTlv > tlv)
Prepends a TLV to the front of this block.
Definition: packetbb.cc:132
Iterator Begin()
Definition: packetbb.cc:76
Ptr< PbbTlv > Back() const
Definition: packetbb.cc:125
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:181
Iterator Insert(Iterator position, const Ptr< PbbTlv > tlv)
Inserts a TLV at the specified position in this block.
Definition: packetbb.cc:160
void PopFront()
Removes a TLV from the front of this block.
Definition: packetbb.cc:139
uint32_t GetSerializedSize() const
Definition: packetbb.cc:192
bool Empty() const
Definition: packetbb.cc:111
std::list< Ptr< PbbTlv > >::iterator Iterator
PbbTlv container iterator.
Definition: packetbb.h:60
int Size() const
Definition: packetbb.cc:104
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition: packetbb.cc:228
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:153
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:246
bool operator!=(const PbbTlvBlock &other) const
Inequality operator for PbbTlvBlock.
Definition: packetbb.cc:296
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:2728
uint8_t GetIndexStop() const
Get the stop point index.
Definition: packetbb.cc:2699
bool operator!=(const PbbTlv &other) const
Inequality operator for PbbTlv.
Definition: packetbb.cc:2990
bool HasTypeExt() const
Tests whether or not this TLV has a type extension.
Definition: packetbb.cc:2661
uint8_t GetIndexStart() const
Get the starting point index.
Definition: packetbb.cc:2676
bool HasValue() const
Tests whether or not this TLV has a value.
Definition: packetbb.cc:2753
bool HasIndexStart() const
Checks if there is a starting index.
Definition: packetbb.cc:2684
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:2945
void Serialize(Buffer::Iterator &start) const
Serializes this TLV into the specified buffer.
Definition: packetbb.cc:2798
bool IsMultivalue() const
Check the multivalue parameter.
Definition: packetbb.cc:2721
void SetType(uint8_t type)
Sets the type of this TLV.
Definition: packetbb.cc:2631
bool m_hasIndexStop
Stop index present.
Definition: packetbb.h:1841
uint8_t GetTypeExt() const
Definition: packetbb.cc:2653
void SetIndexStop(uint8_t index)
Set an index as stop point.
Definition: packetbb.cc:2691
bool HasIndexStop() const
Checks if there is a stop index.
Definition: packetbb.cc:2707
void SetMultivalue(bool isMultivalue)
Set the multivalue parameter.
Definition: packetbb.cc:2714
void Print(std::ostream &os) const
Pretty-prints the contents of this TLV.
Definition: packetbb.cc:2900
virtual ~PbbTlv()
Definition: packetbb.cc:2624
void SetIndexStart(uint8_t index)
Set an index as starting point.
Definition: packetbb.cc:2668
Buffer GetValue() const
Definition: packetbb.cc:2745
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:2638
uint32_t GetSerializedSize() const
Definition: packetbb.cc:2760
void SetTypeExt(uint8_t type)
Sets the type extension of this TLV.
Definition: packetbb.cc:2645
void Deserialize(Buffer::Iterator &start)
Deserializes a TLV from the specified buffer.
Definition: packetbb.cc:2855
bool m_hasValue
Has value.
Definition: packetbb.h:1845
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Definition: first.py:1
address
Definition: first.py:40
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
static const uint8_t VERSION
GTPv2-C protocol version number.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
Definition: wifi-utils.cc:132
value
Definition: second.py:41
static const uint8_t AHAS_ZERO_TAIL
Definition: packetbb.cc:45
static const uint8_t TIS_MULTIVALUE
Definition: packetbb.cc:55
static const uint8_t AHAS_MULTI_PRE_LEN
Definition: packetbb.cc:47
static const uint8_t THAS_SINGLE_INDEX
Definition: packetbb.cc:51
static const uint8_t MHAS_HOP_LIMIT
Definition: packetbb.cc:38
static const uint8_t PHAS_SEQ_NUM
Definition: packetbb.cc:33
static const uint8_t MHAS_HOP_COUNT
Definition: packetbb.cc:39
static const uint8_t MHAS_SEQ_NUM
Definition: packetbb.cc:40
static const uint8_t THAS_MULTI_INDEX
Definition: packetbb.cc:52
static const uint8_t AHAS_HEAD
Definition: packetbb.cc:43
static const uint8_t THAS_TYPE_EXT
Definition: packetbb.cc:50
static const uint8_t VERSION
Definition: packetbb.cc:31
static const uint8_t AHAS_FULL_TAIL
Definition: packetbb.cc:44
static const uint8_t PHAS_TLV
Definition: packetbb.cc:34
static const uint8_t THAS_EXT_LEN
Definition: packetbb.cc:54
static const uint8_t MHAS_ORIG
Definition: packetbb.cc:37
static const uint8_t AHAS_SINGLE_PRE_LEN
Definition: packetbb.cc:46
static const uint8_t THAS_VALUE
Definition: packetbb.cc:53