A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("PacketBB");
32 
33 static const uint8_t VERSION = 0;
34 /* Packet flags */
35 static const uint8_t PHAS_SEQ_NUM = 0x8;
36 static const uint8_t PHAS_TLV = 0x4;
37 
38 /* PbbMessage flags */
39 static const uint8_t MHAS_ORIG = 0x80;
40 static const uint8_t MHAS_HOP_LIMIT = 0x40;
41 static const uint8_t MHAS_HOP_COUNT = 0x20;
42 static const uint8_t MHAS_SEQ_NUM = 0x10;
43 
44 /* Address block flags */
45 static const uint8_t AHAS_HEAD = 0x80;
46 static const uint8_t AHAS_FULL_TAIL = 0x40;
47 static const uint8_t AHAS_ZERO_TAIL = 0x20;
48 static const uint8_t AHAS_SINGLE_PRE_LEN = 0x10;
49 static const uint8_t AHAS_MULTI_PRE_LEN = 0x08;
50 
51 /* TLV Flags */
52 static const uint8_t THAS_TYPE_EXT = 0x80;
53 static const uint8_t THAS_SINGLE_INDEX = 0x40;
54 static const uint8_t THAS_MULTI_INDEX = 0x20;
55 static const uint8_t THAS_VALUE = 0x10;
56 static const uint8_t THAS_EXT_LEN = 0x08;
57 static const uint8_t TIS_MULTIVALUE = 0x04;
58 
59 namespace ns3 {
60 
62  ;
63 
65 {
66  NS_LOG_FUNCTION (this);
67  return;
68 }
69 
71 {
72  NS_LOG_FUNCTION (this);
73  Clear ();
74 }
75 
78 {
79  NS_LOG_FUNCTION (this);
80  return m_tlvList.begin ();
81 }
82 
84 PbbTlvBlock::Begin (void) const
85 {
86  NS_LOG_FUNCTION (this);
87  return m_tlvList.begin ();
88 }
89 
92 {
93  NS_LOG_FUNCTION (this);
94  return m_tlvList.end ();
95 }
96 
98 PbbTlvBlock::End (void) const
99 {
100  NS_LOG_FUNCTION (this);
101  return m_tlvList.end ();
102 }
103 
104 int
105 PbbTlvBlock::Size (void) const
106 {
107  NS_LOG_FUNCTION (this);
108  return m_tlvList.size ();
109 }
110 
111 bool
112 PbbTlvBlock::Empty (void) const
113 {
114  NS_LOG_FUNCTION (this);
115  return m_tlvList.empty ();
116 }
117 
119 PbbTlvBlock::Front (void) const
120 {
121  NS_LOG_FUNCTION (this);
122  return m_tlvList.front ();
123 }
124 
126 PbbTlvBlock::Back (void) const
127 {
128  NS_LOG_FUNCTION (this);
129  return m_tlvList.back ();
130 }
131 
132 void
134 {
135  NS_LOG_FUNCTION (this << tlv);
136  m_tlvList.push_front (tlv);
137 }
138 
139 void
141 {
142  NS_LOG_FUNCTION (this);
143  m_tlvList.pop_front ();
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION (this << tlv);
150  m_tlvList.push_back (tlv);
151 }
152 
153 void
155 {
156  NS_LOG_FUNCTION (this);
157  m_tlvList.pop_back ();
158 }
159 
162 {
163  NS_LOG_FUNCTION (this << &position << tlv);
164  return m_tlvList.insert (position, tlv);
165 }
166 
169 {
170  NS_LOG_FUNCTION (this << &position);
171  return m_tlvList.erase (position);
172 }
173 
176 {
177  NS_LOG_FUNCTION (this << &first << &last);
178  return m_tlvList.erase (first, last);
179 }
180 
181 void
183 {
184  NS_LOG_FUNCTION (this);
185  for (Iterator iter = Begin (); iter != End (); iter++)
186  {
187  *iter = 0;
188  }
189  m_tlvList.clear ();
190 }
191 
192 uint32_t
194 {
195  NS_LOG_FUNCTION (this);
196  /* tlv size */
197  uint32_t size = 2;
198  for (ConstIterator iter = Begin (); iter != End (); iter++)
199  {
200  size += (*iter)->GetSerializedSize ();
201  }
202  return size;
203 }
204 
205 void
207 {
208  NS_LOG_FUNCTION (this << &start);
209  if (Empty ())
210  {
211  start.WriteHtonU16 (0);
212  return;
213  }
214 
215  /* We need to write the size of the TLV block in front, so save its
216  * position. */
217  Buffer::Iterator tlvsize = start;
218  start.Next (2);
219  for (ConstIterator iter = Begin (); iter != End (); iter++)
220  {
221  (*iter)->Serialize (start);
222  }
223  /* - 2 to not include the size field */
224  uint16_t size = start.GetDistanceFrom (tlvsize) - 2;
225  tlvsize.WriteHtonU16 (size);
226 }
227 
228 void
230 {
231  NS_LOG_FUNCTION (this << &start);
232  uint16_t size = start.ReadNtohU16 ();
233 
234  Buffer::Iterator tlvstart = start;
235  if (size > 0)
236  {
237  while (start.GetDistanceFrom (tlvstart) < size)
238  {
239  Ptr<PbbTlv> newtlv = Create<PbbTlv> ();
240  newtlv->Deserialize (start);
241  PushBack (newtlv);
242  }
243  }
244 }
245 
246 void
247 PbbTlvBlock::Print (std::ostream &os) const
248 {
249  NS_LOG_FUNCTION (this << &os);
250  Print (os, 0);
251 }
252 
253 void
254 PbbTlvBlock::Print (std::ostream &os, int level) const
255 {
256  NS_LOG_FUNCTION (this << &os << level);
257  std::string prefix = "";
258  for (int i = 0; i < level; i++)
259  {
260  prefix.append ("\t");
261  }
262 
263  os << prefix << "TLV Block {" << std::endl;
264  os << prefix << "\tsize = " << Size () << std::endl;
265  os << prefix << "\tmembers [" << std::endl;
266 
267  for (ConstIterator iter = Begin (); iter != End (); iter++)
268  {
269  (*iter)->Print (os, level+2);
270  }
271 
272  os << prefix << "\t]" << std::endl;
273  os << prefix << "}" << std::endl;
274 }
275 
276 bool
278 {
279  if (Size () != other.Size ())
280  {
281  return false;
282  }
283 
284  ConstIterator ti, oi;
285  for (ti = Begin (), oi = other.Begin ();
286  ti != End () && oi != other.End ();
287  ti++, oi++)
288  {
289  if (**ti != **oi)
290  {
291  return false;
292  }
293  }
294  return true;
295 }
296 
297 bool
299 {
300  return !(*this == other);
301 }
302 
303 /* End PbbTlvBlock class */
304 
306 {
307  NS_LOG_FUNCTION (this);
308  return;
309 }
310 
312 {
313  NS_LOG_FUNCTION (this);
314  Clear ();
315 }
316 
319 {
320  NS_LOG_FUNCTION (this);
321  return m_tlvList.begin ();
322 }
323 
326 {
327  NS_LOG_FUNCTION (this);
328  return m_tlvList.begin ();
329 }
330 
333 {
334  NS_LOG_FUNCTION (this);
335  return m_tlvList.end ();
336 }
337 
340 {
341  NS_LOG_FUNCTION (this);
342  return m_tlvList.end ();
343 }
344 
345 int
347 {
348  NS_LOG_FUNCTION (this);
349  return m_tlvList.size ();
350 }
351 
352 bool
354 {
355  NS_LOG_FUNCTION (this);
356  return m_tlvList.empty ();
357 }
358 
361 {
362  NS_LOG_FUNCTION (this);
363  return m_tlvList.front ();
364 }
365 
368 {
369  NS_LOG_FUNCTION (this);
370  return m_tlvList.back ();
371 }
372 
373 void
375 {
376  NS_LOG_FUNCTION (this << tlv);
377  m_tlvList.push_front (tlv);
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION (this);
384  m_tlvList.pop_front ();
385 }
386 
387 void
389 {
390  NS_LOG_FUNCTION (this << tlv);
391  m_tlvList.push_back (tlv);
392 }
393 
394 void
396 {
397  NS_LOG_FUNCTION (this);
398  m_tlvList.pop_back ();
399 }
400 
403 {
404  NS_LOG_FUNCTION (this << &position << tlv);
405  return m_tlvList.insert (position, tlv);
406 }
407 
410 {
411  NS_LOG_FUNCTION (this << &position);
412  return m_tlvList.erase (position);
413 }
414 
417 {
418  NS_LOG_FUNCTION (this << &first << &last);
419  return m_tlvList.erase (first, last);
420 }
421 
422 void
424 {
425  NS_LOG_FUNCTION (this);
426  for (Iterator iter = Begin (); iter != End (); iter++)
427  {
428  *iter = 0;
429  }
430  m_tlvList.clear ();
431 }
432 
433 uint32_t
435 {
436  NS_LOG_FUNCTION (this);
437  /* tlv size */
438  uint32_t size = 2;
439  for (ConstIterator iter = Begin (); iter != End (); iter++)
440  {
441  size += (*iter)->GetSerializedSize ();
442  }
443  return size;
444 }
445 
446 void
448 {
449  NS_LOG_FUNCTION (this << &start);
450  if (Empty ())
451  {
452  start.WriteHtonU16 (0);
453  return;
454  }
455 
456  /* We need to write the size of the TLV block in front, so save its
457  * position. */
458  Buffer::Iterator tlvsize = start;
459  start.Next (2);
460  for (ConstIterator iter = Begin (); iter != End (); iter++)
461  {
462  (*iter)->Serialize (start);
463  }
464  /* - 2 to not include the size field */
465  uint16_t size = start.GetDistanceFrom (tlvsize) - 2;
466  tlvsize.WriteHtonU16 (size);
467 }
468 
469 void
471 {
472  NS_LOG_FUNCTION (this << &start);
473  uint16_t size = start.ReadNtohU16 ();
474 
475  Buffer::Iterator tlvstart = start;
476  if (size > 0)
477  {
478  while (start.GetDistanceFrom (tlvstart) < size)
479  {
480  Ptr<PbbAddressTlv> newtlv = Create<PbbAddressTlv> ();
481  newtlv->Deserialize (start);
482  PushBack (newtlv);
483  }
484  }
485 }
486 
487 void
488 PbbAddressTlvBlock::Print (std::ostream &os) const
489 {
490  NS_LOG_FUNCTION (this << &os);
491  Print (os, 0);
492 }
493 
494 void
495 PbbAddressTlvBlock::Print (std::ostream &os, int level) const
496 {
497  NS_LOG_FUNCTION (this << &os << level);
498  std::string prefix = "";
499  for (int i = 0; i < level; i++)
500  {
501  prefix.append ("\t");
502  }
503 
504  os << prefix << "TLV Block {" << std::endl;
505  os << prefix << "\tsize = " << Size () << std::endl;
506  os << prefix << "\tmembers [" << std::endl;
507 
508  for (ConstIterator iter = Begin (); iter != End (); iter++)
509  {
510  (*iter)->Print (os, level+2);
511  }
512 
513  os << prefix << "\t]" << std::endl;
514  os << prefix << "}" << std::endl;
515 }
516 
517 bool
519 {
520  if (Size () != other.Size ())
521  {
522  return false;
523  }
524 
525  ConstIterator it, ot;
526  for (it = Begin (), ot = other.Begin ();
527  it != End () && ot != other.End ();
528  it++, ot++)
529  {
530  if (**it != **ot)
531  {
532  return false;
533  }
534  }
535  return true;
536 }
537 
538 bool
540 {
541  return !(*this == other);
542 }
543 
544 
545 /* End PbbAddressTlvBlock Class */
546 
548 {
549  NS_LOG_FUNCTION (this);
550  m_version = VERSION;
551  m_hasseqnum = false;
552 }
553 
555 {
556  NS_LOG_FUNCTION (this);
557  MessageClear ();
558 }
559 
560 uint8_t
562 {
563  NS_LOG_FUNCTION (this);
564  return m_version;
565 }
566 
567 void
569 {
570  NS_LOG_FUNCTION (this << number);
571  m_seqnum = number;
572  m_hasseqnum = true;
573 }
574 
575 uint16_t
577 {
578  NS_LOG_FUNCTION (this);
580  return m_seqnum;
581 }
582 
583 bool
585 {
586  NS_LOG_FUNCTION (this);
587  return m_hasseqnum;
588 }
589 
590 /* Manipulating Packet TLVs */
591 
594 {
595  NS_LOG_FUNCTION (this);
596  return m_tlvList.Begin ();
597 }
598 
601 {
602  NS_LOG_FUNCTION (this);
603  return m_tlvList.Begin ();
604 }
605 
608 {
609  NS_LOG_FUNCTION (this);
610  return m_tlvList.End ();
611 }
612 
614 PbbPacket::TlvEnd (void) const
615 {
616  NS_LOG_FUNCTION (this);
617  return m_tlvList.End ();
618 }
619 
620 int
621 PbbPacket::TlvSize (void) const
622 {
623  NS_LOG_FUNCTION (this);
624  return m_tlvList.Size ();
625 }
626 
627 bool
629 {
630  NS_LOG_FUNCTION (this);
631  return m_tlvList.Empty ();
632 }
633 
636 {
637  NS_LOG_FUNCTION (this);
638  return m_tlvList.Front ();
639 }
640 
641 const Ptr<PbbTlv>
643 {
644  NS_LOG_FUNCTION (this);
645  return m_tlvList.Front ();
646 }
647 
650 {
651  NS_LOG_FUNCTION (this);
652  return m_tlvList.Back ();
653 }
654 
655 const Ptr<PbbTlv>
656 PbbPacket::TlvBack (void) const
657 {
658  NS_LOG_FUNCTION (this);
659  return m_tlvList.Back ();
660 }
661 
662 void
664 {
665  NS_LOG_FUNCTION (this << tlv);
666  m_tlvList.PushFront (tlv);
667 }
668 
669 void
671 {
672  NS_LOG_FUNCTION (this);
673  m_tlvList.PopFront ();
674 }
675 
676 void
678 {
679  NS_LOG_FUNCTION (this << tlv);
680  m_tlvList.PushBack (tlv);
681 }
682 
683 void
685 {
686  NS_LOG_FUNCTION (this);
687  m_tlvList.PopBack ();
688 }
689 
692 {
693  NS_LOG_FUNCTION (this << &position);
694  return m_tlvList.Erase (position);
695 }
696 
699 {
700  NS_LOG_FUNCTION (this << &first << &last);
701  return m_tlvList.Erase (first, last);
702 }
703 
704 void
706 {
707  NS_LOG_FUNCTION (this);
708  m_tlvList.Clear ();
709 }
710 
711 /* Manipulating Packet Messages */
712 
715 {
716  NS_LOG_FUNCTION (this);
717  return m_messageList.begin ();
718 }
719 
722 {
723  NS_LOG_FUNCTION (this);
724  return m_messageList.begin ();
725 }
726 
729 {
730  NS_LOG_FUNCTION (this);
731  return m_messageList.end ();
732 }
733 
736 {
737  NS_LOG_FUNCTION (this);
738  return m_messageList.end ();
739 }
740 
741 int
743 {
744  NS_LOG_FUNCTION (this);
745  return m_messageList.size ();
746 }
747 
748 bool
750 {
751  NS_LOG_FUNCTION (this);
752  return m_messageList.empty ();
753 }
754 
757 {
758  NS_LOG_FUNCTION (this);
759  return m_messageList.front ();
760 }
761 
762 const Ptr<PbbMessage>
764 {
765  NS_LOG_FUNCTION (this);
766  return m_messageList.front ();
767 }
768 
771 {
772  NS_LOG_FUNCTION (this);
773  return m_messageList.back ();
774 }
775 
776 const Ptr<PbbMessage>
778 {
779  NS_LOG_FUNCTION (this);
780  return m_messageList.back ();
781 }
782 
783 void
785 {
786  NS_LOG_FUNCTION (this << tlv);
787  m_messageList.push_front (tlv);
788 }
789 
790 void
792 {
793  NS_LOG_FUNCTION (this);
794  m_messageList.pop_front ();
795 }
796 
797 void
799 {
800  NS_LOG_FUNCTION (this << tlv);
801  m_messageList.push_back (tlv);
802 }
803 
804 void
806 {
807  NS_LOG_FUNCTION (this);
808  m_messageList.pop_back ();
809 }
810 
813 {
814  NS_LOG_FUNCTION (this << &position);
815  return m_messageList.erase (position);
816 }
817 
821 {
822  NS_LOG_FUNCTION (this << &first << &last);
823  return m_messageList.erase (first, last);
824 }
825 
826 void
828 {
829  NS_LOG_FUNCTION (this);
830  for (MessageIterator iter = MessageBegin (); iter != MessageEnd (); iter++)
831  {
832  *iter = 0;
833  }
834  m_messageList.clear ();
835 }
836 
837 
838 TypeId
840 {
841  static TypeId tid = TypeId ("ns3::PbbPacket")
842  .SetParent<Header> ()
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;
903  m_tlvList.Serialize (start);
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  {
931  m_tlvList.Deserialize (start);
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 
1488  m_tlvList.Serialize (start);
1489 
1491  iter != AddressBlockEnd ();
1492  iter++)
1493  {
1494  (*iter)->Serialize (start);
1495  }
1496 
1497  sizeref.WriteHtonU16 (front.GetDistanceFrom (start));
1498 }
1499 
1502 {
1503  NS_LOG_FUNCTION (&start);
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 
1563  m_tlvList.Deserialize (start);
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 
2320  m_addressTlvList.Serialize (start);
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 
2374  m_addressTlvList.Deserialize (start);
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 (headlen <= GetAddressLength () - 1)
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 */
Protocol header serialization and deserialization.
Definition: header.h:42
bool m_hasOriginatorAddress
Definition: packetbb.h:1076
static const uint8_t THAS_MULTI_INDEX
Definition: packetbb.cc:54
PrefixIterator PrefixEnd(void)
Definition: packetbb.cc:1973
AddressBlockIterator AddressBlockEnd()
Definition: packetbb.cc:1293
bool m_hasHopCount
Definition: packetbb.h:1082
static Ipv4Address Deserialize(const uint8_t buf[4])
void Print(std::ostream &os) const
Pretty-prints the contents of this message.
Definition: packetbb.cc:1576
void TlvPushBack(Ptr< PbbTlv > tlv)
Appends a packet TLV to the back of this packet.
Definition: packetbb.cc:677
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:593
std::list< Ptr< PbbTlv > >::iterator Iterator
Definition: packetbb.h:58
bool m_hasIndexStart
Definition: packetbb.h:1737
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
void MessagePushFront(Ptr< PbbMessage > message)
Prepends a message to the front of this packet.
Definition: packetbb.cc:784
Ptr< PbbMessage > MessageBack(void)
Definition: packetbb.cc:770
A packet or message TLV.
Definition: packetbb.h:1587
std::list< Ptr< PbbMessage > >::const_iterator ConstMessageIterator
This is a PbbMessageIterator for PbbPacket.
Definition: packetbb.h:391
void PushFront(Ptr< PbbTlv > tlv)
Prepends a TLV to the front of this block.
Definition: packetbb.cc:133
uint16_t GetSequenceNumber(void) const
Definition: packetbb.cc:1141
void RemoveAtEnd(uint32_t end)
Definition: buffer.cc:497
static const uint8_t AHAS_HEAD
Definition: packetbb.cc:45
int Size(void) const
Definition: packetbb.cc:105
Main PacketBB Packet object.
Definition: packetbb.h:385
static const uint8_t THAS_TYPE_EXT
Definition: packetbb.cc:52
virtual Address DeserializeOriginatorAddress(Buffer::Iterator &start) const
Definition: packetbb.cc:1754
bool HasIndexStart(void) const
Definition: packetbb.cc:2718
void MessagePushBack(Ptr< PbbMessage > message)
Appends a message to the back of this packet.
Definition: packetbb.cc:798
void PopFront(void)
Removes an AddressTLV from the front of this block.
Definition: packetbb.cc:381
uint32_t GetSerializedSize(void) const
Definition: packetbb.cc:2794
virtual ~PbbMessageIpv6()
Definition: packetbb.cc:1787
bool IsMultivalue(void) const
Definition: packetbb.cc:2755
virtual ~PbbAddressBlockIpv6()
Definition: packetbb.cc:2613
void PushFront(Ptr< PbbAddressTlv > tlv)
Prepends an Address TLV to the front of this block.
Definition: packetbb.cc:374
void SetSequenceNumber(uint16_t number)
Sets the sequence number of this packet.
Definition: packetbb.cc:568
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
bool HasSequenceNumber(void) const
Tests whether or not this message has a sequence number.
Definition: packetbb.cc:1149
void SetIndexStop(uint8_t index)
Definition: packetbb.cc:2725
int TlvSize(void) const
Definition: packetbb.cc:2101
virtual Address DeserializeOriginatorAddress(Buffer::Iterator &start) const =0
automatically resized byte buffer
Definition: buffer.h:92
int PrefixSize(void) const
Definition: packetbb.cc:1987
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
static const uint8_t VERSION
Definition: packetbb.cc:33
TlvIterator TlvEnd()
Definition: packetbb.cc:1172
bool TlvEmpty(void) const
Definition: packetbb.cc:628
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a packet TLV to the front of this packet.
Definition: packetbb.cc:663
virtual void SerializeOriginatorAddress(Buffer::Iterator &start) const
Definition: packetbb.cc:1744
PbbAddressLength
Used in Messages to determine whether it contains IPv4 or IPv6 addresses.
Definition: packetbb.h:45
std::list< Address > m_addressList
Definition: packetbb.h:1535
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:48
bool HasTypeExt(void) const
Tests whether or not this TLV has a type extension.
Definition: packetbb.cc:2695
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:684
void MessageClear(void)
Removes all messages from this packet.
Definition: packetbb.cc:827
void PushBack(Ptr< PbbTlv > tlv)
Appends a TLV to the back of this block.
Definition: packetbb.cc:147
TlvIterator TlvBegin()
Definition: packetbb.cc:1158
std::list< Ptr< PbbTlv > >::const_iterator ConstIterator
this is an iterator
Definition: packetbb.h:59
Ptr< PbbAddressTlv > Back(void) const
Definition: packetbb.cc:367
NS_LOG_COMPONENT_DEFINE("PacketBB")
bool operator!=(const PbbAddressBlock &other) const
Inequality operator for PbbAddressBlock.
Definition: packetbb.cc:2460
static const uint8_t PHAS_SEQ_NUM
Definition: packetbb.cc:35
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:488
uint8_t m_type
Definition: packetbb.h:1732
bool HasIndexStart(void) const
Tests whether or not this address TLV has a start index.
Definition: packetbb.cc:3046
bool HasIndexStop(void) const
Tests whether or not this address TLV has a stop index.
Definition: packetbb.cc:3067
std::list< Ptr< PbbAddressBlock > >::const_iterator ConstAddressBlockIterator
This is a PbbAddressBlock iterator for PbbMessage.
Definition: packetbb.h:690
static const uint8_t MHAS_HOP_LIMIT
Definition: packetbb.cc:40
uint8_t GetIndexStart(void) const
Definition: packetbb.cc:2710
void SetMultivalue(bool isMultivalue)
Definition: packetbb.cc:2748
void MessagePopFront(void)
Removes a message from the front of this packet.
Definition: packetbb.cc:791
void SetSequenceNumber(uint16_t seqnum)
Sets the sequence number of this message.
Definition: packetbb.cc:1133
static const uint8_t AHAS_FULL_TAIL
Definition: packetbb.cc:46
void TlvPopBack(void)
Removes a message TLV from the back of this message.
Definition: packetbb.cc:1249
uint8_t GetIndexStart(void) const
Definition: packetbb.cc:3039
std::list< Ptr< PbbMessage > >::iterator MessageIterator
This is a const PbbTlv iterator for PbbPacket.
Definition: packetbb.h:390
Ptr< PbbAddressTlv > TlvFront(void)
Definition: packetbb.cc:2115
uint8_t m_type
Definition: packetbb.h:1073
std::list< uint8_t > m_prefixList
Definition: packetbb.h:1536
std::list< Ptr< PbbAddressBlock > >::iterator AddressBlockIterator
This is a const PbbTlv iterator for PbbMessage.
Definition: packetbb.h:689
bool IsMultivalue(void) const
Tests whether or not this address TLV is "multivalue".
Definition: packetbb.cc:3081
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:807
Ptr< PbbTlv > TlvBack(void)
Definition: packetbb.cc:649
iterator in a Buffer instance
Definition: buffer.h:98
a polymophic address class
Definition: address.h:86
PbbAddressTlvBlock(void)
This is a const PbbAddressTlv iterator for PbbAddressTlvBlock.
Definition: packetbb.cc:305
virtual void PrintAddress(std::ostream &os, ConstAddressIterator iter) const
Definition: packetbb.cc:2640
bool m_hasSequenceNumber
Definition: packetbb.h:1085
MessageIterator MessageEnd(void)
Definition: packetbb.cc:728
uint16_t m_sequenceNumber
Definition: packetbb.h:1086
AddressBlockIterator AddressBlockBegin()
Definition: packetbb.cc:1279
uint8_t m_version
Definition: packetbb.h:671
static const uint8_t TIS_MULTIVALUE
Definition: packetbb.cc:57
virtual ~PbbTlv(void)
Definition: packetbb.cc:2658
virtual Address DeserializeAddress(uint8_t *buffer) const =0
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:395
bool TlvEmpty(void) const
Definition: packetbb.cc:2108
static const uint8_t AHAS_ZERO_TAIL
Definition: packetbb.cc:47
bool AddressEmpty(void) const
Definition: packetbb.cc:1886
void AddressBlockClear(void)
Removes all address blocks from this message.
Definition: packetbb.cc:1392
bool IsEnd(void) const
Definition: buffer.cc:823
Address GetOriginatorAddress(void) const
Definition: packetbb.cc:1072
uint8_t GetTypeExt(void) const
Definition: packetbb.cc:2687
virtual PbbAddressLength GetAddressLength(void) const
Returns address length (IPV4 3 or IPV6 15)
Definition: packetbb.cc:1793
void TlvPushFront(Ptr< PbbAddressTlv > address)
Prepends an address TLV to the front of this message.
Definition: packetbb.cc:2143
std::list< Address >::const_iterator ConstAddressIterator
this is an address iterator for PbbAddressBlock
Definition: packetbb.h:1155
Iterator Erase(Iterator position)
Removes the Address TLV at the specified position.
Definition: packetbb.cc:409
virtual void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const
Definition: packetbb.cc:2586
bool operator!=(const PbbTlv &other) const
Inequality operator for PbbTlv.
Definition: packetbb.cc:3024
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)
this is a const iterator
Definition: packetbb.cc:64
std::list< Address >::iterator AddressIterator
Definition: packetbb.h:1154
TlvIterator Erase(TlvIterator position)
Removes the packet TLV at the specified position.
Definition: packetbb.cc:691
bool operator==(const PbbMessage &other) const
Equality operator for PbbMessage.
Definition: packetbb.cc:1631
virtual void PrintAddress(std::ostream &os, ConstAddressIterator iter) const
Definition: packetbb.cc:2600
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:56
bool operator!=(const PbbPacket &other) const
Inequality operator for PbbPacket.
Definition: packetbb.cc:1018
void Prev(void)
go backward by one byte
Definition: buffer.h:672
Ptr< PbbAddressTlv > TlvBack(void)
Definition: packetbb.cc:2129
static const uint8_t MHAS_ORIG
Definition: packetbb.cc:39
uint8_t GetVersion(void) const
Definition: packetbb.cc:561
virtual uint8_t GetAddressLength(void) const
Returns address length.
Definition: packetbb.cc:2579
bool m_hasHopLimit
Definition: packetbb.h:1079
bool m_isMultivalue
Definition: packetbb.h:1743
void PushBack(Ptr< PbbAddressTlv > tlv)
Appends an Address TLV to the back of this block.
Definition: packetbb.cc:388
void SetType(uint8_t type)
Sets the type for this message.
Definition: packetbb.cc:1043
std::list< Ptr< PbbTlv > >::iterator TlvIterator
Definition: packetbb.h:388
void Serialize(Buffer::Iterator &start) const
Serializes this message into the specified buffer.
Definition: packetbb.cc:1444
void TlvPopBack(void)
Removes an address TLV from the back of this message.
Definition: packetbb.cc:2164
uint8_t m_hopCount
Definition: packetbb.h:1083
virtual Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const
Definition: packetbb.cc:1828
uint16_t GetSequenceNumber(void) const
Definition: packetbb.cc:576
int MessageSize(void) const
Definition: packetbb.cc:742
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:726
Address AddressFront(void) const
Definition: packetbb.cc:1893
~PbbPacket(void)
Definition: packetbb.cc:554
void TlvClear(void)
Removes all message TLVs from this block.
Definition: packetbb.cc:1270
Ptr< PbbAddressBlock > AddressBlockFront(void)
Definition: packetbb.cc:1321
bool TlvEmpty(void) const
Definition: packetbb.cc:1193
TlvIterator TlvEnd(void)
Definition: packetbb.cc:2087
uint8_t const * PeekData(void) const
Definition: buffer.cc:729
uint8_t PrefixBack(void) const
Definition: packetbb.cc:2008
PbbAddressLength m_addrSize
Definition: packetbb.h:1074
Ptr< PbbTlv > Front(void) const
Definition: packetbb.cc:119
bool operator==(const PbbTlvBlock &other) const
Equality operator for PbbTlvBlock.
Definition: packetbb.cc:277
std::list< uint8_t >::const_iterator ConstPrefixIterator
this is a prefix iterator for PbbAddressBlock
Definition: packetbb.h:1158
bool HasHopCount(void) const
Tests whether or not this message has a hop count.
Definition: packetbb.cc:1126
bool m_hasValue
Definition: packetbb.h:1744
void Next(void)
go forward by one byte
Definition: buffer.h:666
virtual void PrintAddress(std::ostream &os, ConstAddressIterator iter) const =0
uint8_t GetType(void) const
Definition: packetbb.cc:2672
void Print(std::ostream &os) const
Print this address to the given output stream.
bool Empty(void) const
Definition: packetbb.cc:353
uint8_t m_typeExt
Definition: packetbb.h:1735
Ptr< PbbTlv > Back(void) const
Definition: packetbb.cc:126
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition: packetbb.cc:470
std::list< Ptr< PbbTlv > >::iterator TlvIterator
Definition: packetbb.h:687
uint32_t GetSerializedSize(void) const
Definition: packetbb.cc:193
void Print(std::ostream &os) const
Print this address to the given output stream.
int AddressBlockSize(void) const
Definition: packetbb.cc:1307
void Deserialize(Buffer::Iterator &start)
Deserializes a block from the specified buffer.
Definition: packetbb.cc:229
virtual Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const =0
static const uint8_t THAS_SINGLE_INDEX
Definition: packetbb.cc:53
virtual uint32_t GetSerializedSize(void) const
Definition: packetbb.cc:855
Buffer::Iterator Begin(void) const
Definition: buffer.h:875
virtual PbbAddressLength GetAddressLength(void) const
Returns address length (IPV4 3 or IPV6 15)
Definition: packetbb.cc:1737
~PbbTlvBlock(void)
Definition: packetbb.cc:70
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 HasValue(void) const
Tests whether or not this TLV has a value.
Definition: packetbb.cc:2787
virtual void SerializeOriginatorAddress(Buffer::Iterator &start) const
Definition: packetbb.cc:1800
virtual void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const =0
virtual ~PbbAddressBlock()
Definition: packetbb.cc:1843
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:684
void SetHopLimit(uint8_t hoplimit)
Sets the maximum number of hops this message should travel.
Definition: packetbb.cc:1087
bool HasOriginatorAddress(void) const
Tests whether or not this message has an originator address.
Definition: packetbb.cc:1080
uint8_t PrefixFront(void) const
Definition: packetbb.cc:2001
void PrefixPushFront(uint8_t prefix)
Prepends a prefix to the front of this block.
Definition: packetbb.cc:2015
std::list< Ptr< PbbAddressTlv > >::iterator Iterator
Definition: packetbb.h:220
Buffer m_value
Definition: packetbb.h:1745
PbbAddressTlvBlock::Iterator TlvIterator
this is a const prefix iterator for PbbAddressBlock
Definition: packetbb.h:1160
bool HasHopLimit(void) const
Tests whether or not this message has a hop limit.
Definition: packetbb.cc:1103
AddressBlockIterator AddressBlockErase(AddressBlockIterator position)
Removes the address block at the specified position.
Definition: packetbb.cc:1377
void Serialize(Buffer::Iterator &start) const
Serializes this address block into the specified buffer.
Definition: packetbb.cc:2240
void Print(std::ostream &os) const
Pretty-prints the contents of this TLV.
Definition: packetbb.cc:2934
int Size(void) const
Definition: packetbb.cc:346
virtual void PrintOriginatorAddress(std::ostream &os) const
Definition: packetbb.cc:1765
void Print(std::ostream &os) const
Pretty-prints the contents of this address block.
Definition: packetbb.cc:2378
static const uint8_t MHAS_SEQ_NUM
Definition: packetbb.cc:42
int TlvSize(void) const
Definition: packetbb.cc:621
PbbAddressTlvBlock m_addressTlvList
Definition: packetbb.h:1537
virtual ~PbbMessageIpv4()
Definition: packetbb.cc:1731
void TlvClear(void)
Removes all address TLVs from this block.
Definition: packetbb.cc:2186
bool operator==(const PbbPacket &other) const
Equality operator for PbbPacket.
Definition: packetbb.cc:976
uint32_t GetSerializedSize(void) const
Definition: packetbb.cc:434
void PrefixPushBack(uint8_t prefix)
Appends a prefix to the back of this block.
Definition: packetbb.cc:2029
bool m_hasIndexStop
Definition: packetbb.h:1740
void Read(uint8_t *buffer, uint32_t size)
Definition: buffer.cc:1148
PbbMessage()
This is a const PbbAddressBlock iterator for PbbMessage.
Definition: packetbb.cc:1025
std::list< Ptr< PbbAddressTlv > > m_tlvList
Definition: packetbb.h:374
PbbAddressBlock()
this is a const tlvblock iterator for PbbAddressBlock
Definition: packetbb.cc:1838
void AddressBlockPopFront(void)
Removes an address block from the front of this message.
Definition: packetbb.cc:1356
bool operator!=(const PbbTlvBlock &other) const
Inequality operator for PbbTlvBlock.
Definition: packetbb.cc:298
Address m_originatorAddress
Definition: packetbb.h:1077
A block of packet or message TLVs (PbbTlv).
Definition: packetbb.h:55
uint8_t m_indexStart
Definition: packetbb.h:1738
uint8_t GetType(void) const
Definition: packetbb.cc:1050
bool MessageEmpty(void) const
Definition: packetbb.cc:749
uint32_t GetSize(void) const
Definition: buffer.h:869
uint8_t GetIndexStop(void) const
Definition: packetbb.cc:3060
std::list< Ptr< PbbMessage > > m_messageList
Definition: packetbb.h:669
void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:247
void SetIndexStart(uint8_t index)
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
Definition: packetbb.h:209
PbbTlvBlock m_tlvList
Definition: packetbb.h:668
int AddressSize(void) const
Definition: packetbb.cc:1879
std::list< Ptr< PbbAddressBlock > > m_addressBlockList
Definition: packetbb.h:1071
bool Empty(void) const
Definition: packetbb.cc:112
virtual ~PbbMessage()
Definition: packetbb.cc:1036
bool m_hasTypeExt
Definition: packetbb.h:1734
Iterator End(void)
Definition: packetbb.cc:91
bool operator!=(const PbbAddressTlvBlock &other) const
Inequality operator for PbbAddressTlvBlock.
Definition: packetbb.cc:539
A block of Address TLVs (PbbAddressTlv).
Definition: packetbb.h:217
uint8_t GetHopCount(void) const
Definition: packetbb.cc:1118
bool HasSequenceNumber(void) const
Tests whether or not this packet has a sequence number.
Definition: packetbb.cc:584
void PopBack(void)
Removes a TLV from the back of this block.
Definition: packetbb.cc:154
void TlvPopFront(void)
Removes a packet TLV from the front of this packet.
Definition: packetbb.cc:670
bool operator==(const PbbTlv &other) const
Equality operator for PbbTlv.
Definition: packetbb.cc:2979
uint8_t GetHopLimit(void) const
Definition: packetbb.cc:1095
uint16_t m_seqnum
Definition: packetbb.h:674
PbbAddressTlvBlock::ConstIterator ConstTlvIterator
this is a tlvblock iterator for PbbAddressBlock
Definition: packetbb.h:1161
virtual ~PbbAddressBlockIpv4()
Definition: packetbb.cc:2573
virtual void PrintOriginatorAddress(std::ostream &os) const =0
void WriteU8(uint8_t data)
Definition: buffer.h:690
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
uint32_t GetSerializedSize(void) const
Definition: packetbb.cc:1405
void AddressBlockPushFront(Ptr< PbbAddressBlock > block)
Prepends an address block to the front of this message.
Definition: packetbb.cc:1349
static const uint8_t THAS_VALUE
Definition: packetbb.cc:55
void MessagePopBack(void)
Removes a message from the back of this packet.
Definition: packetbb.cc:805
Ptr< PbbTlv > TlvFront(void)
Definition: packetbb.cc:1200
virtual void SerializeAddress(uint8_t *buffer, ConstAddressIterator iter) const
Definition: packetbb.cc:2626
Iterator Insert(Iterator position, const Ptr< PbbAddressTlv > tlv)
Inserts an Address TLV at the specified position in this block.
Definition: packetbb.cc:402
TlvIterator TlvEnd(void)
Definition: packetbb.cc:607
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
AddressIterator AddressBegin(void)
Definition: packetbb.cc:1851
int TlvSize(void) const
Definition: packetbb.cc:1186
void AddressClear(void)
Removes all addresses from this block.
Definition: packetbb.cc:1950
virtual void SerializeOriginatorAddress(Buffer::Iterator &start) const =0
void SetHopCount(uint8_t hopcount)
Sets the current number of hops this message has traveled.
Definition: packetbb.cc:1110
virtual uint8_t GetAddressLength(void) const =0
Returns address length.
Ptr< PbbTlv > TlvFront(void)
Definition: packetbb.cc:635
bool operator!=(const PbbMessage &other) const
Inequality operator for PbbMessage.
Definition: packetbb.cc:1719
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:41
uint8_t ReadU8(void)
Definition: buffer.h:819
Address AddressBack(void) const
Definition: packetbb.cc:1900
void Write(uint8_t const *buffer, uint32_t size)
Definition: buffer.cc:978
PrefixIterator PrefixErase(PrefixIterator position)
Removes the prefix at the specified position.
Definition: packetbb.cc:2050
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition: packetbb.cc:206
Iterator Begin(void)
Definition: packetbb.cc:77
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
This is a PbbAddressTlv iterator for PbbAddressTlvBlock.
Definition: packetbb.h:221
uint8_t m_hopLimit
Definition: packetbb.h:1080
uint32_t GetSerializedSize(void) const
Definition: packetbb.cc:2192
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:161
void TlvPopFront(void)
Removes an address TLV from the front of this message.
Definition: packetbb.cc:2150
static const uint8_t AHAS_MULTI_PRE_LEN
Definition: packetbb.cc:49
virtual Address DeserializeOriginatorAddress(Buffer::Iterator &start) const
Definition: packetbb.cc:1810
uint8_t GetPrefixFlags(void) const
Definition: packetbb.cc:2466
bool HasZeroTail(const uint8_t *tail, uint8_t taillen) const
Definition: packetbb.cc:2552
static Ipv4Address ConvertFrom(const Address &address)
bool AddAtStart(uint32_t start)
Definition: buffer.cc:305
Buffer GetValue(void) const
Definition: packetbb.cc:2779
uint8_t GetIndexStop(void) const
Definition: packetbb.cc:2733
tuple address
Definition: first.py:37
void Clear(void)
Removes all Address TLVs from this block.
Definition: packetbb.cc:423
void SetValue(Buffer start)
Sets the value of this message to the specified buffer.
Definition: packetbb.cc:2762
Iterator Begin(void)
Definition: packetbb.cc:318
PrefixIterator PrefixBegin(void)
Definition: packetbb.cc:1959
virtual void Print(std::ostream &os) const
Pretty-prints the contents of this block.
Definition: packetbb.cc:951
bool m_hasseqnum
Definition: packetbb.h:673
Ptr< PbbMessage > MessageFront(void)
Definition: packetbb.cc:756
virtual Ptr< PbbAddressBlock > AddressBlockDeserialize(Buffer::Iterator &start) const
Definition: packetbb.cc:1772
void TlvPushFront(Ptr< PbbTlv > tlv)
Prepends a message TLV to the front of this message.
Definition: packetbb.cc:1228
PbbPacket(void)
This is a const PbbMessageIterator for PbbPacket.
Definition: packetbb.cc:547
MessageIterator MessageBegin(void)
Definition: packetbb.cc:714
uint16_t ReadNtohU16(void)
Definition: buffer.h:767
bool HasIndexStop(void) const
Definition: packetbb.cc:2741
void Clear(void)
Removes all TLVs from this block.
Definition: packetbb.cc:182
Iterator End(void)
Definition: packetbb.cc:332
std::list< uint8_t >::iterator PrefixIterator
this is an const address iterator for PbbAddressBlock
Definition: packetbb.h:1157
virtual Address DeserializeAddress(uint8_t *buffer) const
Definition: packetbb.cc:2593
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
PbbTlvBlock m_tlvList
Definition: packetbb.h:1070
uint8_t m_indexStop
Definition: packetbb.h:1741
void Serialize(Buffer::Iterator &start) const
Serializes this block into the specified buffer.
Definition: packetbb.cc:447
a unique identifier for an interface.
Definition: type-id.h:49
virtual void Serialize(Buffer::Iterator start) const
Serializes this packet into the specified buffer.
Definition: packetbb.cc:882
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
This is a PbbTlv iterator for PbbPacket.
Definition: packetbb.h:389
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
bool AddressBlockEmpty(void) const
Definition: packetbb.cc:1314
void GetHeadTail(uint8_t *head, uint8_t &headlen, uint8_t *tail, uint8_t &taillen) const
Definition: packetbb.cc:2487
An Address Block and its associated Address TLV Blocks.
Definition: packetbb.h:1151
virtual void PrintOriginatorAddress(std::ostream &os) const
Definition: packetbb.cc:1821
bool operator==(const PbbAddressTlvBlock &other) const
Equality operator for PbbAddressTlvBlock.
Definition: packetbb.cc:518
void Serialize(Buffer::Iterator &start) const
Serializes this TLV into the specified buffer.
Definition: packetbb.cc:2832
void TlvPushBack(Ptr< PbbTlv > tlv)
Appends a message TLV to the back of this message.
Definition: packetbb.cc:1242
virtual TypeId GetInstanceTypeId(void) const
Definition: packetbb.cc:849
bool operator==(const PbbAddressBlock &other) const
Equality operator for PbbAddressBlock.
Definition: packetbb.cc:2417
std::list< Ptr< PbbTlv > >::const_iterator ConstTlvIterator
This is a PbbTlv iterator for PbbMessage.
Definition: packetbb.h:688
virtual uint8_t GetAddressLength(void) const
Returns address length.
Definition: packetbb.cc:2619
static const uint8_t PHAS_TLV
Definition: packetbb.cc:36
static TypeId GetTypeId(void)
Definition: packetbb.cc:839
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
bool PrefixEmpty(void) const
Definition: packetbb.cc:1994
Ptr< PbbAddressTlv > Front(void) const
Definition: packetbb.cc:360
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:705
virtual Address DeserializeAddress(uint8_t *buffer) const
Definition: packetbb.cc:2633
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:168
void PopFront(void)
Removes a TLV from the front of this block.
Definition: packetbb.cc:140
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.