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