PacketBB: Moved from src/contrib to src/node.
authorTom Wambold <tom5760@gmail.com>
Fri Sep 11 11:52:47 2009 -0400 (5 months ago)
changeset 4785d1c0b9c89160
parent 4784 2d87b22311dd
child 4786 48c1400fbed1
PacketBB: Moved from src/contrib to src/node.
src/contrib/packetbb.cc
src/contrib/packetbb.h
src/contrib/test-packetbb.cc
src/node/packetbb.cc
src/node/packetbb.h
src/node/test-packetbb.cc
     1.1 --- a/src/contrib/packetbb.cc	Fri Sep 11 00:52:23 2009 -0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,2783 +0,0 @@
     1.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     1.5 -/* vim: set ts=2 sw=2 sta expandtab ai si cin: */
     1.6 -/* 
     1.7 - * Copyright (c) 2009 Drexel University
     1.8 - * 
     1.9 - * This program is free software; you can redistribute it and/or modify
    1.10 - * it under the terms of the GNU General Public License version 2 as
    1.11 - * published by the Free Software Foundation;
    1.12 - *
    1.13 - * This program is distributed in the hope that it will be useful,
    1.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 - * GNU General Public License for more details.
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License
    1.19 - * along with this program; if not, write to the Free Software
    1.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 - * 
    1.22 - * Author: Tom Wambold <tom5760@gmail.com>
    1.23 - */
    1.24 -/* TODO:
    1.25 - * - Check style
    1.26 - * - Check copy constructors
    1.27 - */
    1.28 -
    1.29 -#include "ns3/ipv4-address.h"
    1.30 -#include "ns3/ipv6-address.h"
    1.31 -#include "ns3/assert.h"
    1.32 -
    1.33 -#include "packetbb.h"
    1.34 -
    1.35 -static const uint8_t VERSION = 0;
    1.36 -/* Packet flags */
    1.37 -static const uint8_t PHAS_SEQ_NUM = 0x8;
    1.38 -static const uint8_t PHAS_TLV = 0x4;
    1.39 -
    1.40 -/* PbbMessage flags */
    1.41 -static const uint8_t MHAS_ORIG = 0x80;
    1.42 -static const uint8_t MHAS_HOP_LIMIT = 0x40;
    1.43 -static const uint8_t MHAS_HOP_COUNT = 0x20;
    1.44 -static const uint8_t MHAS_SEQ_NUM = 0x10;
    1.45 -
    1.46 -/* Address block flags */
    1.47 -static const uint8_t AHAS_HEAD = 0x80;
    1.48 -static const uint8_t AHAS_FULL_TAIL = 0x40;
    1.49 -static const uint8_t AHAS_ZERO_TAIL = 0x20;
    1.50 -static const uint8_t AHAS_SINGLE_PRE_LEN = 0x10;
    1.51 -static const uint8_t AHAS_MULTI_PRE_LEN = 0x08;
    1.52 -
    1.53 -/* TLV Flags */
    1.54 -static const uint8_t THAS_TYPE_EXT = 0x80;
    1.55 -static const uint8_t THAS_SINGLE_INDEX = 0x40;
    1.56 -static const uint8_t THAS_MULTI_INDEX = 0x20;
    1.57 -static const uint8_t THAS_VALUE = 0x10;
    1.58 -static const uint8_t THAS_EXT_LEN = 0x08;
    1.59 -static const uint8_t TIS_MULTIVALUE = 0x04;
    1.60 -
    1.61 -namespace ns3 {
    1.62 -
    1.63 -NS_OBJECT_ENSURE_REGISTERED (PbbPacket);
    1.64 -
    1.65 -PbbTlvBlock::Iterator
    1.66 -PbbTlvBlock::Begin (void)
    1.67 -{
    1.68 -  return m_tlvList.begin ();
    1.69 -}
    1.70 -
    1.71 -PbbTlvBlock::ConstIterator
    1.72 -PbbTlvBlock::Begin (void) const
    1.73 -{
    1.74 -  return m_tlvList.begin ();
    1.75 -}
    1.76 -
    1.77 -PbbTlvBlock::Iterator
    1.78 -PbbTlvBlock::End (void)
    1.79 -{
    1.80 -  return m_tlvList.end ();
    1.81 -}
    1.82 -
    1.83 -PbbTlvBlock::ConstIterator
    1.84 -PbbTlvBlock::End (void) const
    1.85 -{
    1.86 -  return m_tlvList.end ();
    1.87 -}
    1.88 -
    1.89 -int
    1.90 -PbbTlvBlock::Size (void) const
    1.91 -{
    1.92 -  return m_tlvList.size ();
    1.93 -}
    1.94 -
    1.95 -bool
    1.96 -PbbTlvBlock::Empty (void) const
    1.97 -{
    1.98 -  return m_tlvList.empty ();
    1.99 -}
   1.100 -
   1.101 -Ptr<PbbTlv>
   1.102 -PbbTlvBlock::Front (void) const
   1.103 -{
   1.104 -  return m_tlvList.front ();
   1.105 -}
   1.106 -
   1.107 -Ptr<PbbTlv>
   1.108 -PbbTlvBlock::Back (void) const
   1.109 -{
   1.110 -  return m_tlvList.back ();
   1.111 -}
   1.112 -
   1.113 -void
   1.114 -PbbTlvBlock::PushFront (Ptr<PbbTlv> tlv)
   1.115 -{
   1.116 -  m_tlvList.push_front (tlv);
   1.117 -}
   1.118 -
   1.119 -void
   1.120 -PbbTlvBlock::PopFront (void)
   1.121 -{
   1.122 -  m_tlvList.pop_front ();
   1.123 -}
   1.124 -
   1.125 -void
   1.126 -PbbTlvBlock::PushBack (Ptr<PbbTlv> tlv)
   1.127 -{
   1.128 -  m_tlvList.push_back (tlv);
   1.129 -}
   1.130 -
   1.131 -void
   1.132 -PbbTlvBlock::PopBack (void)
   1.133 -{
   1.134 -  m_tlvList.pop_back ();
   1.135 -}
   1.136 -
   1.137 -PbbTlvBlock::Iterator
   1.138 -PbbTlvBlock::Insert (PbbTlvBlock::Iterator position, const Ptr<PbbTlv> tlv)
   1.139 -{
   1.140 -  return m_tlvList.insert (position, tlv);
   1.141 -}
   1.142 -
   1.143 -PbbTlvBlock::Iterator
   1.144 -PbbTlvBlock::Erase (PbbTlvBlock::Iterator position)
   1.145 -{
   1.146 -  return m_tlvList.erase (position);
   1.147 -}
   1.148 -
   1.149 -PbbTlvBlock::Iterator
   1.150 -PbbTlvBlock::Erase (PbbTlvBlock::Iterator first, PbbTlvBlock::Iterator last)
   1.151 -{
   1.152 -  return m_tlvList.erase (first, last);
   1.153 -}
   1.154 -
   1.155 -void
   1.156 -PbbTlvBlock::Clear (void)
   1.157 -{
   1.158 -  m_tlvList.clear ();
   1.159 -}
   1.160 -
   1.161 -uint32_t
   1.162 -PbbTlvBlock::GetSerializedSize (void) const
   1.163 -{
   1.164 -  /* tlv size */
   1.165 -  uint32_t size = 2;
   1.166 -  for (ConstIterator iter = Begin (); iter != End (); iter++)
   1.167 -    {
   1.168 -      size += (*iter)->GetSerializedSize ();
   1.169 -    }
   1.170 -  return size;
   1.171 -}
   1.172 -
   1.173 -void
   1.174 -PbbTlvBlock::Serialize (Buffer::Iterator &start) const
   1.175 -{
   1.176 -  if (Empty ())
   1.177 -    {
   1.178 -      start.WriteHtonU16 (0);
   1.179 -      return;
   1.180 -    }
   1.181 -
   1.182 -  /* We need to write the size of the TLV block in front, so save its
   1.183 -   * position. */
   1.184 -  Buffer::Iterator tlvsize = start;
   1.185 -  start.Next (2);
   1.186 -  for (ConstIterator iter = Begin (); iter != End (); iter++)
   1.187 -    {
   1.188 -      (*iter)->Serialize (start);
   1.189 -    }
   1.190 -  /* - 2 to not include the size field */
   1.191 -  uint16_t size = start.GetDistanceFrom (tlvsize) - 2;
   1.192 -  tlvsize.WriteHtonU16 (size);
   1.193 -}
   1.194 -
   1.195 -void
   1.196 -PbbTlvBlock::Deserialize (Buffer::Iterator &start)
   1.197 -{
   1.198 -  uint16_t size = start.ReadNtohU16 ();
   1.199 -
   1.200 -  Buffer::Iterator tlvstart = start;
   1.201 -  if (size > 0)
   1.202 -    {
   1.203 -      while (start.GetDistanceFrom (tlvstart) < size)
   1.204 -        {
   1.205 -          Ptr<PbbTlv> newtlv = Create<PbbTlv> ();
   1.206 -          newtlv->Deserialize (start);
   1.207 -          PushBack (newtlv);
   1.208 -        }
   1.209 -    }
   1.210 -}
   1.211 -
   1.212 -void
   1.213 -PbbTlvBlock::Print (std::ostream &os) const
   1.214 -{
   1.215 -  Print (os, 0);
   1.216 -}
   1.217 -
   1.218 -void
   1.219 -PbbTlvBlock::Print (std::ostream &os, int level) const
   1.220 -{
   1.221 -  std::string prefix = "";
   1.222 -  for (int i = 0; i < level; i++)
   1.223 -    {
   1.224 -      prefix.append("\t");
   1.225 -    }
   1.226 -
   1.227 -  os << prefix << "TLV Block {" << std::endl;
   1.228 -  os << prefix << "\tsize = " << Size () << std::endl;
   1.229 -  os << prefix << "\tmembers [" << std::endl;
   1.230 -
   1.231 -  for (ConstIterator iter = Begin (); iter != End (); iter++)
   1.232 -    {
   1.233 -      (*iter)->Print (os, level+2);
   1.234 -    }
   1.235 -
   1.236 -  os << prefix << "\t]" << std::endl;
   1.237 -  os << prefix << "}" << std::endl;
   1.238 -}
   1.239 -
   1.240 -bool
   1.241 -PbbTlvBlock::operator== (const PbbTlvBlock &other) const
   1.242 -{
   1.243 -  if (Size () != other.Size ())
   1.244 -    {
   1.245 -      return false;
   1.246 -    }
   1.247 -
   1.248 -  ConstIterator ti, oi;
   1.249 -  for (ti = Begin (), oi = other.Begin ();
   1.250 -      ti != End () && oi != other.End ();
   1.251 -      ti++, oi++)
   1.252 -    {
   1.253 -      if (**ti != **oi)
   1.254 -        {
   1.255 -          return false;
   1.256 -        }
   1.257 -    }
   1.258 -  return true;
   1.259 -}
   1.260 -
   1.261 -bool
   1.262 -PbbTlvBlock::operator!= (const PbbTlvBlock &other) const
   1.263 -{
   1.264 -  return !(*this == other);
   1.265 -}
   1.266 -
   1.267 -/* End PbbTlvBlock class */
   1.268 -
   1.269 -PbbAddressTlvBlock::Iterator
   1.270 -PbbAddressTlvBlock::Begin (void)
   1.271 -{
   1.272 -  return m_tlvList.begin ();
   1.273 -}
   1.274 -
   1.275 -PbbAddressTlvBlock::ConstIterator
   1.276 -PbbAddressTlvBlock::Begin (void) const
   1.277 -{
   1.278 -  return m_tlvList.begin ();
   1.279 -}
   1.280 -
   1.281 -PbbAddressTlvBlock::Iterator
   1.282 -PbbAddressTlvBlock::End (void)
   1.283 -{
   1.284 -  return m_tlvList.end ();
   1.285 -}
   1.286 -
   1.287 -PbbAddressTlvBlock::ConstIterator
   1.288 -PbbAddressTlvBlock::End (void) const
   1.289 -{
   1.290 -  return m_tlvList.end ();
   1.291 -}
   1.292 -
   1.293 -int
   1.294 -PbbAddressTlvBlock::Size (void) const
   1.295 -{
   1.296 -  return m_tlvList.size ();
   1.297 -}
   1.298 -
   1.299 -bool
   1.300 -PbbAddressTlvBlock::Empty (void) const
   1.301 -{
   1.302 -  return m_tlvList.empty ();
   1.303 -}
   1.304 -
   1.305 -Ptr<PbbAddressTlv>
   1.306 -PbbAddressTlvBlock::Front (void) const
   1.307 -{
   1.308 -  return m_tlvList.front ();
   1.309 -}
   1.310 -
   1.311 -Ptr<PbbAddressTlv>
   1.312 -PbbAddressTlvBlock::Back (void) const
   1.313 -{
   1.314 -  return m_tlvList.back ();
   1.315 -}
   1.316 -
   1.317 -void
   1.318 -PbbAddressTlvBlock::PushFront (Ptr<PbbAddressTlv> tlv)
   1.319 -{
   1.320 -  m_tlvList.push_front (tlv);
   1.321 -}
   1.322 -
   1.323 -void
   1.324 -PbbAddressTlvBlock::PopFront (void)
   1.325 -{
   1.326 -  m_tlvList.pop_front ();
   1.327 -}
   1.328 -
   1.329 -void
   1.330 -PbbAddressTlvBlock::PushBack (Ptr<PbbAddressTlv> tlv)
   1.331 -{
   1.332 -  m_tlvList.push_back (tlv);
   1.333 -}
   1.334 -
   1.335 -void
   1.336 -PbbAddressTlvBlock::PopBack (void)
   1.337 -{
   1.338 -  m_tlvList.pop_back ();
   1.339 -}
   1.340 -
   1.341 -PbbAddressTlvBlock::Iterator
   1.342 -PbbAddressTlvBlock::Insert (PbbAddressTlvBlock::Iterator position, const Ptr<PbbAddressTlv> tlv)
   1.343 -{
   1.344 -  return m_tlvList.insert (position, tlv);
   1.345 -}
   1.346 -
   1.347 -PbbAddressTlvBlock::Iterator
   1.348 -PbbAddressTlvBlock::Erase (PbbAddressTlvBlock::Iterator position)
   1.349 -{
   1.350 -  return m_tlvList.erase (position);
   1.351 -}
   1.352 -
   1.353 -PbbAddressTlvBlock::Iterator
   1.354 -PbbAddressTlvBlock::Erase (PbbAddressTlvBlock::Iterator first, PbbAddressTlvBlock::Iterator last)
   1.355 -{
   1.356 -  return m_tlvList.erase (first, last);
   1.357 -}
   1.358 -
   1.359 -void
   1.360 -PbbAddressTlvBlock::Clear (void)
   1.361 -{
   1.362 -  m_tlvList.clear ();
   1.363 -}
   1.364 -
   1.365 -uint32_t
   1.366 -PbbAddressTlvBlock::GetSerializedSize (void) const
   1.367 -{
   1.368 -  /* tlv size */
   1.369 -  uint32_t size = 2;
   1.370 -  for (ConstIterator iter = Begin (); iter != End (); iter++)
   1.371 -    {
   1.372 -      size += (*iter)->GetSerializedSize ();
   1.373 -    }
   1.374 -  return size;
   1.375 -}
   1.376 -
   1.377 -void
   1.378 -PbbAddressTlvBlock::Serialize (Buffer::Iterator &start) const
   1.379 -{
   1.380 -  if (Empty ())
   1.381 -    {
   1.382 -      start.WriteHtonU16 (0);
   1.383 -      return;
   1.384 -    }
   1.385 -
   1.386 -  /* We need to write the size of the TLV block in front, so save its
   1.387 -   * position. */
   1.388 -  Buffer::Iterator tlvsize = start;
   1.389 -  start.Next (2);
   1.390 -  for (ConstIterator iter = Begin (); iter != End (); iter++)
   1.391 -    {
   1.392 -      (*iter)->Serialize (start);
   1.393 -    }
   1.394 -  /* - 2 to not include the size field */
   1.395 -  uint16_t size = start.GetDistanceFrom (tlvsize) - 2;
   1.396 -  tlvsize.WriteHtonU16 (size);
   1.397 -}
   1.398 -
   1.399 -void
   1.400 -PbbAddressTlvBlock::Deserialize (Buffer::Iterator &start)
   1.401 -{
   1.402 -  uint16_t size = start.ReadNtohU16 ();
   1.403 -
   1.404 -  Buffer::Iterator tlvstart = start;
   1.405 -  if (size > 0)
   1.406 -    {
   1.407 -      while (start.GetDistanceFrom (tlvstart) < size)
   1.408 -      {
   1.409 -        Ptr<PbbAddressTlv> newtlv = Create<PbbAddressTlv> ();
   1.410 -        newtlv->Deserialize (start);
   1.411 -        PushBack (newtlv);
   1.412 -      }
   1.413 -    }
   1.414 -}
   1.415 -
   1.416 -void
   1.417 -PbbAddressTlvBlock::Print (std::ostream &os) const
   1.418 -{
   1.419 -  Print (os, 0);
   1.420 -}
   1.421 -
   1.422 -void
   1.423 -PbbAddressTlvBlock::Print (std::ostream &os, int level) const
   1.424 -{
   1.425 -  std::string prefix = "";
   1.426 -  for (int i = 0; i < level; i++)
   1.427 -    {
   1.428 -      prefix.append("\t");
   1.429 -    }
   1.430 -
   1.431 -  os << prefix << "TLV Block {" << std::endl;
   1.432 -  os << prefix << "\tsize = " << Size () << std::endl;
   1.433 -  os << prefix << "\tmembers [" << std::endl;
   1.434 -
   1.435 -  for (ConstIterator iter = Begin (); iter != End (); iter++)
   1.436 -    {
   1.437 -      (*iter)->Print (os, level+2);
   1.438 -    }
   1.439 -
   1.440 -  os << prefix << "\t]" << std::endl;
   1.441 -  os << prefix << "}" << std::endl;
   1.442 -}
   1.443 -
   1.444 -bool
   1.445 -PbbAddressTlvBlock::operator== (const PbbAddressTlvBlock &other) const
   1.446 -{
   1.447 -  if (Size () != other.Size ())
   1.448 -    {
   1.449 -      return false;
   1.450 -    }
   1.451 -
   1.452 -  ConstIterator it, ot;
   1.453 -  for (it = Begin (), ot = other.Begin ();
   1.454 -      it != End () && ot != other.End ();
   1.455 -      it++, ot++)
   1.456 -    {
   1.457 -      if (**it != **ot)
   1.458 -        {
   1.459 -          return false;
   1.460 -        }
   1.461 -    }
   1.462 -  return true;
   1.463 -}
   1.464 -
   1.465 -bool
   1.466 -PbbAddressTlvBlock::operator!= (const PbbAddressTlvBlock &other) const
   1.467 -{
   1.468 -  return !(*this == other);
   1.469 -}
   1.470 -
   1.471 -
   1.472 -/* End PbbAddressTlvBlock Class */
   1.473 -
   1.474 -PbbPacket::PbbPacket (void)
   1.475 -{
   1.476 -  m_refCount = 1;
   1.477 -  m_version = VERSION;
   1.478 -  m_hasseqnum = false;
   1.479 -}
   1.480 -
   1.481 -uint8_t
   1.482 -PbbPacket::GetVersion (void) const
   1.483 -{
   1.484 -  return m_version;
   1.485 -}
   1.486 -
   1.487 -void
   1.488 -PbbPacket::SetSequenceNumber (uint16_t number)
   1.489 -{
   1.490 -  m_seqnum = number;
   1.491 -  m_hasseqnum = true;
   1.492 -}
   1.493 -
   1.494 -uint16_t
   1.495 -PbbPacket::GetSequenceNumber (void) const
   1.496 -{
   1.497 -  NS_ASSERT (HasSequenceNumber ());
   1.498 -  return m_seqnum;
   1.499 -}
   1.500 -
   1.501 -bool
   1.502 -PbbPacket::HasSequenceNumber (void) const
   1.503 -{
   1.504 -  return m_hasseqnum;
   1.505 -}
   1.506 -
   1.507 -/* Manipulating Packet TLVs */
   1.508 -
   1.509 -PbbPacket::TlvIterator
   1.510 -PbbPacket::TlvBegin (void)
   1.511 -{
   1.512 -  return m_tlvList.Begin ();
   1.513 -}
   1.514 -
   1.515 -PbbPacket::ConstTlvIterator
   1.516 -PbbPacket::TlvBegin (void) const
   1.517 -{
   1.518 -  return m_tlvList.Begin ();
   1.519 -}
   1.520 -
   1.521 -PbbPacket::TlvIterator
   1.522 -PbbPacket::TlvEnd (void)
   1.523 -{
   1.524 -  return m_tlvList.End ();
   1.525 -}
   1.526 -
   1.527 -PbbPacket::ConstTlvIterator
   1.528 -PbbPacket::TlvEnd (void) const
   1.529 -{
   1.530 -  return m_tlvList.End ();
   1.531 -}
   1.532 -
   1.533 -int
   1.534 -PbbPacket::TlvSize (void) const
   1.535 -{
   1.536 -  return m_tlvList.Size ();
   1.537 -}
   1.538 -
   1.539 -bool
   1.540 -PbbPacket::TlvEmpty (void) const
   1.541 -{
   1.542 -  return m_tlvList.Empty ();
   1.543 -}
   1.544 -
   1.545 -Ptr<PbbTlv>
   1.546 -PbbPacket::TlvFront (void)
   1.547 -{
   1.548 -  return m_tlvList.Front ();
   1.549 -}
   1.550 -
   1.551 -const Ptr<PbbTlv>
   1.552 -PbbPacket::TlvFront (void) const
   1.553 -{
   1.554 -  return m_tlvList.Front ();
   1.555 -}
   1.556 -
   1.557 -Ptr<PbbTlv>
   1.558 -PbbPacket::TlvBack (void)
   1.559 -{
   1.560 -  return m_tlvList.Back ();
   1.561 -}
   1.562 -
   1.563 -const Ptr<PbbTlv>
   1.564 -PbbPacket::TlvBack (void) const
   1.565 -{
   1.566 -  return m_tlvList.Back ();
   1.567 -}
   1.568 -
   1.569 -void
   1.570 -PbbPacket::TlvPushFront (Ptr<PbbTlv> tlv)
   1.571 -{
   1.572 -  m_tlvList.PushFront (tlv);
   1.573 -}
   1.574 -
   1.575 -void
   1.576 -PbbPacket::TlvPopFront (void)
   1.577 -{
   1.578 -  m_tlvList.PopFront ();
   1.579 -}
   1.580 -
   1.581 -void
   1.582 -PbbPacket::TlvPushBack (Ptr<PbbTlv> tlv)
   1.583 -{
   1.584 -  m_tlvList.PushBack (tlv);
   1.585 -}
   1.586 -
   1.587 -void
   1.588 -PbbPacket::TlvPopBack (void)
   1.589 -{
   1.590 -  m_tlvList.PopBack ();
   1.591 -}
   1.592 -
   1.593 -PbbPacket::TlvIterator
   1.594 -PbbPacket::Erase (PbbPacket::TlvIterator position)
   1.595 -{
   1.596 -  return m_tlvList.Erase (position);
   1.597 -}
   1.598 -
   1.599 -PbbPacket::TlvIterator
   1.600 -PbbPacket::Erase (PbbPacket::TlvIterator first, PbbPacket::TlvIterator last)
   1.601 -{
   1.602 -  return m_tlvList.Erase (first, last);
   1.603 -}
   1.604 -
   1.605 -void
   1.606 -PbbPacket::TlvClear (void)
   1.607 -{
   1.608 -  m_tlvList.Clear ();
   1.609 -}
   1.610 -
   1.611 -/* Manipulating Packet Messages */
   1.612 -
   1.613 -PbbPacket::MessageIterator
   1.614 -PbbPacket::MessageBegin (void)
   1.615 -{
   1.616 -  return m_messageList.begin ();
   1.617 -}
   1.618 -
   1.619 -PbbPacket::ConstMessageIterator
   1.620 -PbbPacket::MessageBegin (void) const
   1.621 -{
   1.622 -  return m_messageList.begin ();
   1.623 -}
   1.624 -
   1.625 -PbbPacket::MessageIterator
   1.626 -PbbPacket::MessageEnd (void)
   1.627 -{
   1.628 -  return m_messageList.end ();
   1.629 -}
   1.630 -
   1.631 -PbbPacket::ConstMessageIterator
   1.632 -PbbPacket::MessageEnd (void) const
   1.633 -{
   1.634 -  return m_messageList.end ();
   1.635 -}
   1.636 -
   1.637 -int
   1.638 -PbbPacket::MessageSize (void) const
   1.639 -{
   1.640 -  return m_messageList.size ();
   1.641 -}
   1.642 -
   1.643 -bool
   1.644 -PbbPacket::MessageEmpty (void) const
   1.645 -{
   1.646 -  return m_messageList.empty ();
   1.647 -}
   1.648 -
   1.649 -Ptr<PbbMessage>
   1.650 -PbbPacket::MessageFront (void)
   1.651 -{
   1.652 -  return m_messageList.front ();
   1.653 -}
   1.654 -
   1.655 -const Ptr<PbbMessage>
   1.656 -PbbPacket::MessageFront (void) const
   1.657 -{
   1.658 -  return m_messageList.front ();
   1.659 -}
   1.660 -
   1.661 -Ptr<PbbMessage>
   1.662 -PbbPacket::MessageBack (void)
   1.663 -{
   1.664 -  return m_messageList.back ();
   1.665 -}
   1.666 -
   1.667 -const Ptr<PbbMessage>
   1.668 -PbbPacket::MessageBack (void) const
   1.669 -{
   1.670 -  return m_messageList.back ();
   1.671 -}
   1.672 -
   1.673 -void
   1.674 -PbbPacket::MessagePushFront (Ptr<PbbMessage> tlv)
   1.675 -{
   1.676 -  m_messageList.push_front (tlv);
   1.677 -}
   1.678 -
   1.679 -void
   1.680 -PbbPacket::MessagePopFront (void)
   1.681 -{
   1.682 -  m_messageList.pop_front ();
   1.683 -}
   1.684 -
   1.685 -void
   1.686 -PbbPacket::MessagePushBack (Ptr<PbbMessage> tlv)
   1.687 -{
   1.688 -  m_messageList.push_back (tlv);
   1.689 -}
   1.690 -
   1.691 -void
   1.692 -PbbPacket::MessagePopBack (void)
   1.693 -{
   1.694 -  m_messageList.pop_back ();
   1.695 -}
   1.696 -
   1.697 -PbbPacket::MessageIterator
   1.698 -PbbPacket::Erase (PbbPacket::MessageIterator position)
   1.699 -{
   1.700 -  return m_messageList.erase (position);
   1.701 -}
   1.702 -
   1.703 -PbbPacket::MessageIterator
   1.704 -PbbPacket::Erase (PbbPacket::MessageIterator first,
   1.705 -    PbbPacket::MessageIterator last)
   1.706 -{
   1.707 -  return m_messageList.erase (first, last);
   1.708 -}
   1.709 -
   1.710 -void
   1.711 -PbbPacket::MessageClear (void)
   1.712 -{
   1.713 -  m_messageList.clear ();
   1.714 -}
   1.715 -
   1.716 -void
   1.717 -PbbPacket::Ref (void) const
   1.718 -{
   1.719 -  m_refCount++;
   1.720 -}
   1.721 -
   1.722 -void
   1.723 -PbbPacket::Unref (void) const
   1.724 -{
   1.725 -  m_refCount--;
   1.726 -  if (m_refCount == 0)
   1.727 -    {
   1.728 -      delete this;
   1.729 -    }
   1.730 -}
   1.731 -
   1.732 -TypeId
   1.733 -PbbPacket::GetTypeId (void)
   1.734 -{
   1.735 -  static TypeId tid = TypeId ("PbbPacket")
   1.736 -    .SetParent<Header> ()
   1.737 -    .AddConstructor<PbbPacket> ()
   1.738 -  ;
   1.739 -  return tid;
   1.740 -}
   1.741 -
   1.742 -TypeId
   1.743 -PbbPacket::GetInstanceTypeId (void) const
   1.744 -{
   1.745 -  return GetTypeId ();
   1.746 -}
   1.747 -
   1.748 -uint32_t
   1.749 -PbbPacket::GetSerializedSize (void) const
   1.750 -{
   1.751 -  /* Version number + flags */
   1.752 -  uint32_t size = 1;
   1.753 -
   1.754 -  if (HasSequenceNumber())
   1.755 -    {
   1.756 -      size += 2;
   1.757 -    }
   1.758 -
   1.759 -  if (!TlvEmpty ())
   1.760 -    {
   1.761 -      size += m_tlvList.GetSerializedSize ();
   1.762 -    }
   1.763 -
   1.764 -  for (ConstMessageIterator iter = MessageBegin ();
   1.765 -      iter != MessageEnd ();
   1.766 -      iter++)
   1.767 -    {
   1.768 -      size += (*iter)->GetSerializedSize ();
   1.769 -    }
   1.770 -
   1.771 -  return size;
   1.772 -}
   1.773 -
   1.774 -void
   1.775 -PbbPacket::Serialize (Buffer::Iterator start) const
   1.776 -{
   1.777 -  /* We remember the start, so we can write the flags after we check for a
   1.778 -   * sequence number and TLV. */
   1.779 -  Buffer::Iterator bufref = start;
   1.780 -  start.Next ();
   1.781 -
   1.782 -  uint8_t flags = VERSION;
   1.783 -  /* Make room for 4 bit flags */
   1.784 -  flags <<= 4;
   1.785 -
   1.786 -  if (HasSequenceNumber ())
   1.787 -    {
   1.788 -      flags |= PHAS_SEQ_NUM;
   1.789 -      start.WriteHtonU16 (GetSequenceNumber ());
   1.790 -    }
   1.791 -
   1.792 -  if (!TlvEmpty ())
   1.793 -    {
   1.794 -      flags |= PHAS_TLV;
   1.795 -      m_tlvList.Serialize (start);
   1.796 -    }
   1.797 -
   1.798 -  bufref.WriteU8(flags);
   1.799 -
   1.800 -  for (ConstMessageIterator iter = MessageBegin ();
   1.801 -      iter != MessageEnd ();
   1.802 -      iter++)
   1.803 -    {
   1.804 -      (*iter)->Serialize (start);
   1.805 -    }
   1.806 -}
   1.807 -
   1.808 -uint32_t
   1.809 -PbbPacket::Deserialize (Buffer::Iterator start)
   1.810 -{
   1.811 -  Buffer::Iterator begin = start;
   1.812 -
   1.813 -  uint8_t flags = start.ReadU8 ();
   1.814 -
   1.815 -  if (flags & PHAS_SEQ_NUM)
   1.816 -    {
   1.817 -      SetSequenceNumber (start.ReadNtohU16 ());
   1.818 -    }
   1.819 -
   1.820 -  if (flags & PHAS_TLV)
   1.821 -    {
   1.822 -      m_tlvList.Deserialize (start);
   1.823 -    }
   1.824 -
   1.825 -  while (!start.IsEnd())
   1.826 -    {
   1.827 -      Ptr<PbbMessage> newmsg = PbbMessage::DeserializeMessage (start);
   1.828 -      if (newmsg == 0)
   1.829 -        {
   1.830 -          return start.GetDistanceFrom (begin);
   1.831 -        }
   1.832 -      MessagePushBack (newmsg);
   1.833 -    }
   1.834 -
   1.835 -  flags >>= 4;
   1.836 -  m_version = flags;
   1.837 -
   1.838 -  return start.GetDistanceFrom (begin);
   1.839 -}
   1.840 -
   1.841 -void
   1.842 -PbbPacket::Print (std::ostream &os) const
   1.843 -{
   1.844 -  os << "PbbPacket {" << std::endl;
   1.845 -
   1.846 -  if (HasSequenceNumber ())
   1.847 -    {
   1.848 -      os << "\tsequence number = " << GetSequenceNumber ();
   1.849 -    }
   1.850 -
   1.851 -  os << std::endl;
   1.852 -
   1.853 -  m_tlvList.Print (os, 1);
   1.854 -
   1.855 -  for (ConstMessageIterator iter = MessageBegin ();
   1.856 -      iter != MessageEnd ();
   1.857 -      iter++)
   1.858 -    {
   1.859 -      (*iter)->Print (os, 1);
   1.860 -    }
   1.861 -
   1.862 -  os << "}" << std::endl;
   1.863 -}
   1.864 -
   1.865 -bool
   1.866 -PbbPacket::operator== (const PbbPacket &other) const
   1.867 -{
   1.868 -  if (GetVersion () != other.GetVersion ())
   1.869 -    {
   1.870 -      return false;
   1.871 -    }
   1.872 -
   1.873 -  if (HasSequenceNumber () != other.HasSequenceNumber ())
   1.874 -    {
   1.875 -      return false;
   1.876 -    }
   1.877 -
   1.878 -  if (HasSequenceNumber ())
   1.879 -    {
   1.880 -      if (GetSequenceNumber () != other.GetSequenceNumber ())
   1.881 -        return false;
   1.882 -    }
   1.883 -
   1.884 -  if (m_tlvList != other.m_tlvList)
   1.885 -    {
   1.886 -      return false;
   1.887 -    }
   1.888 -
   1.889 -  if (MessageSize () != other.MessageSize ())
   1.890 -    {
   1.891 -        return false;
   1.892 -    }
   1.893 -
   1.894 -  ConstMessageIterator tmi, omi;
   1.895 -  for (tmi = MessageBegin (), omi = other.MessageBegin ();
   1.896 -    tmi != MessageEnd () && omi != other.MessageEnd ();
   1.897 -    tmi++, omi++)
   1.898 -    {
   1.899 -      if (**tmi != **omi)
   1.900 -        {
   1.901 -          return false;
   1.902 -        }
   1.903 -    }
   1.904 -  return true;
   1.905 -}
   1.906 -
   1.907 -bool
   1.908 -PbbPacket::operator!= (const PbbPacket &other) const
   1.909 -{
   1.910 -  return !(*this == other);
   1.911 -}
   1.912 -
   1.913 -/* End PbbPacket class */
   1.914 -
   1.915 -PbbMessage::PbbMessage (void)
   1.916 -{
   1.917 -  m_refCount = 1;
   1.918 -  /* Default to IPv4 */
   1.919 -  m_addrSize = IPV4;
   1.920 -  m_hasOriginatorAddress = false;
   1.921 -  m_hasHopLimit = false;
   1.922 -  m_hasHopCount = false;
   1.923 -  m_hasSequenceNumber = false;
   1.924 -}
   1.925 -
   1.926 -void
   1.927 -PbbMessage::SetType (uint8_t type)
   1.928 -{
   1.929 -  m_type = type;
   1.930 -}
   1.931 -
   1.932 -uint8_t
   1.933 -PbbMessage::GetType (void) const
   1.934 -{
   1.935 -  return m_type;
   1.936 -}
   1.937 -
   1.938 -PbbAddressLength
   1.939 -PbbMessage::GetAddressLength (void) const
   1.940 -{
   1.941 -  return m_addrSize;
   1.942 -}
   1.943 -
   1.944 -void
   1.945 -PbbMessage::SetOriginatorAddress (Address address)
   1.946 -{
   1.947 -  m_originatorAddress = address;
   1.948 -  m_hasOriginatorAddress = true;
   1.949 -}
   1.950 -
   1.951 -Address
   1.952 -PbbMessage::GetOriginatorAddress (void) const
   1.953 -{
   1.954 -  NS_ASSERT (HasOriginatorAddress ());
   1.955 -  return m_originatorAddress;
   1.956 -}
   1.957 -
   1.958 -bool
   1.959 -PbbMessage::HasOriginatorAddress (void) const
   1.960 -{
   1.961 -  return m_hasOriginatorAddress;
   1.962 -}
   1.963 -
   1.964 -void
   1.965 -PbbMessage::SetHopLimit (uint8_t hopLimit)
   1.966 -{
   1.967 -  m_hopLimit = hopLimit;
   1.968 -  m_hasHopLimit = true;
   1.969 -}
   1.970 -
   1.971 -uint8_t
   1.972 -PbbMessage::GetHopLimit (void) const
   1.973 -{
   1.974 -  NS_ASSERT (HasHopLimit ());
   1.975 -  return m_hopLimit;
   1.976 -}
   1.977 -
   1.978 -bool
   1.979 -PbbMessage::HasHopLimit (void) const
   1.980 -{
   1.981 -  return m_hasHopLimit;
   1.982 -}
   1.983 -
   1.984 -void
   1.985 -PbbMessage::SetHopCount (uint8_t hopCount)
   1.986 -{
   1.987 -  m_hopCount = hopCount;
   1.988 -  m_hasHopCount = true;
   1.989 -}
   1.990 -
   1.991 -uint8_t
   1.992 -PbbMessage::GetHopCount (void) const
   1.993 -{
   1.994 -  NS_ASSERT (HasHopCount ());
   1.995 -  return m_hopCount;
   1.996 -}
   1.997 -
   1.998 -bool
   1.999 -PbbMessage::HasHopCount (void) const
  1.1000 -{
  1.1001 -  return m_hasHopCount;
  1.1002 -}
  1.1003 -
  1.1004 -void
  1.1005 -PbbMessage::SetSequenceNumber (uint16_t sequenceNumber)
  1.1006 -{
  1.1007 -  m_sequenceNumber = sequenceNumber;
  1.1008 -  m_hasSequenceNumber = true;
  1.1009 -}
  1.1010 -
  1.1011 -uint16_t
  1.1012 -PbbMessage::GetSequenceNumber (void) const
  1.1013 -{
  1.1014 -  NS_ASSERT (HasSequenceNumber ());
  1.1015 -  return m_sequenceNumber;
  1.1016 -}
  1.1017 -
  1.1018 -bool
  1.1019 -PbbMessage::HasSequenceNumber (void) const
  1.1020 -{
  1.1021 -  return m_hasSequenceNumber;
  1.1022 -}
  1.1023 -
  1.1024 -/* Manipulating PbbMessage TLVs */
  1.1025 -
  1.1026 -PbbMessage::TlvIterator
  1.1027 -PbbMessage::TlvBegin (void)
  1.1028 -{
  1.1029 -  return m_tlvList.Begin();
  1.1030 -}
  1.1031 -
  1.1032 -PbbMessage::ConstTlvIterator
  1.1033 -PbbMessage::TlvBegin (void) const
  1.1034 -{
  1.1035 -  return m_tlvList.Begin();
  1.1036 -}
  1.1037 -
  1.1038 -PbbMessage::TlvIterator
  1.1039 -PbbMessage::TlvEnd (void)
  1.1040 -{
  1.1041 -  return m_tlvList.End();
  1.1042 -}
  1.1043 -
  1.1044 -PbbMessage::ConstTlvIterator
  1.1045 -PbbMessage::TlvEnd (void) const
  1.1046 -{
  1.1047 -  return m_tlvList.End();
  1.1048 -}
  1.1049 -
  1.1050 -int
  1.1051 -PbbMessage::TlvSize (void) const
  1.1052 -{
  1.1053 -  return m_tlvList.Size();
  1.1054 -}
  1.1055 -
  1.1056 -bool
  1.1057 -PbbMessage::TlvEmpty (void) const
  1.1058 -{
  1.1059 -  return m_tlvList.Empty();
  1.1060 -}
  1.1061 -
  1.1062 -Ptr<PbbTlv>
  1.1063 -PbbMessage::TlvFront (void)
  1.1064 -{
  1.1065 -  return m_tlvList.Front();
  1.1066 -}
  1.1067 -
  1.1068 -const Ptr<PbbTlv>
  1.1069 -PbbMessage::TlvFront (void) const
  1.1070 -{
  1.1071 -  return m_tlvList.Front();
  1.1072 -}
  1.1073 -
  1.1074 -Ptr<PbbTlv>
  1.1075 -PbbMessage::TlvBack (void)
  1.1076 -{
  1.1077 -  return m_tlvList.Back();
  1.1078 -}
  1.1079 -
  1.1080 -const Ptr<PbbTlv>
  1.1081 -PbbMessage::TlvBack (void) const
  1.1082 -{
  1.1083 -  return m_tlvList.Back();
  1.1084 -}
  1.1085 -
  1.1086 -void
  1.1087 -PbbMessage::TlvPushFront (Ptr<PbbTlv> tlv)
  1.1088 -{
  1.1089 -  m_tlvList.PushFront(tlv);
  1.1090 -}
  1.1091 -
  1.1092 -void
  1.1093 -PbbMessage::TlvPopFront (void)
  1.1094 -{
  1.1095 -  m_tlvList.PopFront();
  1.1096 -}
  1.1097 -
  1.1098 -void
  1.1099 -PbbMessage::TlvPushBack (Ptr<PbbTlv> tlv)
  1.1100 -{
  1.1101 -  m_tlvList.PushBack(tlv);
  1.1102 -}
  1.1103 -
  1.1104 -void
  1.1105 -PbbMessage::TlvPopBack (void)
  1.1106 -{
  1.1107 -  m_tlvList.PopBack();
  1.1108 -}
  1.1109 -
  1.1110 -PbbMessage::TlvIterator
  1.1111 -PbbMessage::TlvErase (PbbMessage::TlvIterator position)
  1.1112 -{
  1.1113 -  return m_tlvList.Erase(position);
  1.1114 -}
  1.1115 -
  1.1116 -PbbMessage::TlvIterator
  1.1117 -PbbMessage::TlvErase (PbbMessage::TlvIterator first, PbbMessage::TlvIterator last)
  1.1118 -{
  1.1119 -  return m_tlvList.Erase(first, last);
  1.1120 -}
  1.1121 -
  1.1122 -void
  1.1123 -PbbMessage::TlvClear (void)
  1.1124 -{
  1.1125 -  return m_tlvList.Clear();
  1.1126 -}
  1.1127 -
  1.1128 -/* Manipulating Address Block and Address TLV pairs */
  1.1129 -
  1.1130 -PbbMessage::AddressBlockIterator
  1.1131 -PbbMessage::AddressBlockBegin (void)
  1.1132 -{
  1.1133 -  return m_addressBlockList.begin();
  1.1134 -}
  1.1135 -
  1.1136 -PbbMessage::ConstAddressBlockIterator
  1.1137 -PbbMessage::AddressBlockBegin (void) const
  1.1138 -{
  1.1139 -  return m_addressBlockList.begin();
  1.1140 -}
  1.1141 -
  1.1142 -PbbMessage::AddressBlockIterator
  1.1143 -PbbMessage::AddressBlockEnd (void)
  1.1144 -{
  1.1145 -  return m_addressBlockList.end();
  1.1146 -}
  1.1147 -
  1.1148 -PbbMessage::ConstAddressBlockIterator
  1.1149 -PbbMessage::AddressBlockEnd (void) const
  1.1150 -{
  1.1151 -  return m_addressBlockList.end();
  1.1152 -}
  1.1153 -
  1.1154 -int
  1.1155 -PbbMessage::AddressBlockSize (void) const
  1.1156 -{
  1.1157 -  return m_addressBlockList.size();
  1.1158 -}
  1.1159 -
  1.1160 -bool
  1.1161 -PbbMessage::AddressBlockEmpty (void) const
  1.1162 -{
  1.1163 -  return m_addressBlockList.empty();
  1.1164 -}
  1.1165 -
  1.1166 -Ptr<PbbAddressBlock>
  1.1167 -PbbMessage::AddressBlockFront (void)
  1.1168 -{
  1.1169 -  return m_addressBlockList.front();
  1.1170 -}
  1.1171 -
  1.1172 -const Ptr<PbbAddressBlock>
  1.1173 -PbbMessage::AddressBlockFront (void) const
  1.1174 -{
  1.1175 -  return m_addressBlockList.front();
  1.1176 -}
  1.1177 -
  1.1178 -Ptr<PbbAddressBlock>
  1.1179 -PbbMessage::AddressBlockBack (void)
  1.1180 -{
  1.1181 -  return m_addressBlockList.back();
  1.1182 -}
  1.1183 -
  1.1184 -const Ptr<PbbAddressBlock>
  1.1185 -PbbMessage::AddressBlockBack (void) const
  1.1186 -{
  1.1187 -  return m_addressBlockList.back();
  1.1188 -}
  1.1189 -
  1.1190 -void
  1.1191 -PbbMessage::AddressBlockPushFront (Ptr<PbbAddressBlock> tlv)
  1.1192 -{
  1.1193 -  m_addressBlockList.push_front(tlv);
  1.1194 -}
  1.1195 -
  1.1196 -void
  1.1197 -PbbMessage::AddressBlockPopFront (void)
  1.1198 -{
  1.1199 -  m_addressBlockList.pop_front();
  1.1200 -}
  1.1201 -
  1.1202 -void
  1.1203 -PbbMessage::AddressBlockPushBack (Ptr<PbbAddressBlock> tlv)
  1.1204 -{
  1.1205 -  m_addressBlockList.push_back(tlv);
  1.1206 -}
  1.1207 -
  1.1208 -void
  1.1209 -PbbMessage::AddressBlockPopBack (void)
  1.1210 -{
  1.1211 -  m_addressBlockList.pop_back();
  1.1212 -}
  1.1213 -
  1.1214 -PbbMessage::AddressBlockIterator
  1.1215 -PbbMessage::AddressBlockErase (PbbMessage::AddressBlockIterator position)
  1.1216 -{
  1.1217 -  return m_addressBlockList.erase(position);
  1.1218 -}
  1.1219 -
  1.1220 -PbbMessage::AddressBlockIterator
  1.1221 -PbbMessage::AddressBlockErase (PbbMessage::AddressBlockIterator first,
  1.1222 -    PbbMessage::AddressBlockIterator last)
  1.1223 -{
  1.1224 -  return m_addressBlockList.erase(first, last);
  1.1225 -}
  1.1226 -
  1.1227 -void
  1.1228 -PbbMessage::AddressBlockClear (void)
  1.1229 -{
  1.1230 -  return m_addressBlockList.clear();
  1.1231 -}
  1.1232 -
  1.1233 -void
  1.1234 -PbbMessage::Ref (void) const
  1.1235 -{
  1.1236 -  m_refCount++;
  1.1237 -}
  1.1238 -
  1.1239 -void
  1.1240 -PbbMessage::Unref (void) const
  1.1241 -{
  1.1242 -  m_refCount--;
  1.1243 -  if (m_refCount == 0)
  1.1244 -    {
  1.1245 -      delete this;
  1.1246 -    }
  1.1247 -}
  1.1248 -
  1.1249 -uint32_t
  1.1250 -PbbMessage::GetSerializedSize (void) const
  1.1251 -{
  1.1252 -  /* msg-type + (msg-flags + msg-addr-length) + 2msg-size */
  1.1253 -  uint32_t size = 4;
  1.1254 -
  1.1255 -  if (HasOriginatorAddress())
  1.1256 -    {
  1.1257 -      size += GetAddressLength() + 1;
  1.1258 -    }
  1.1259 -
  1.1260 -  if (HasHopLimit())
  1.1261 -    {
  1.1262 -      size++;
  1.1263 -    }
  1.1264 -
  1.1265 -  if (HasHopCount())
  1.1266 -    {
  1.1267 -      size++;
  1.1268 -    }
  1.1269 -
  1.1270 -  if (HasSequenceNumber())
  1.1271 -    {
  1.1272 -      size += 2;
  1.1273 -    }
  1.1274 -
  1.1275 -  size += m_tlvList.GetSerializedSize ();
  1.1276 -
  1.1277 -  for (ConstAddressBlockIterator iter = AddressBlockBegin ();
  1.1278 -      iter != AddressBlockEnd ();
  1.1279 -      iter++)
  1.1280 -    {
  1.1281 -      size += (*iter)->GetSerializedSize ();
  1.1282 -    }
  1.1283 -
  1.1284 -  return size;
  1.1285 -}
  1.1286 -
  1.1287 -void
  1.1288 -PbbMessage::Serialize (Buffer::Iterator &start) const
  1.1289 -{
  1.1290 -  Buffer::Iterator front = start;
  1.1291 -
  1.1292 -  start.WriteU8 (GetType());
  1.1293 -
  1.1294 -  /* Save a reference to the spot where we will later write the flags */
  1.1295 -  Buffer::Iterator bufref = start;
  1.1296 -  start.Next (1);
  1.1297 -
  1.1298 -  uint8_t flags = 0;
  1.1299 -
  1.1300 -  flags = GetAddressLength ();
  1.1301 -
  1.1302 -  Buffer::Iterator sizeref = start;
  1.1303 -  start.Next (2);
  1.1304 -
  1.1305 -  if (HasOriginatorAddress ())
  1.1306 -    {
  1.1307 -      flags |= MHAS_ORIG;
  1.1308 -      SerializeOriginatorAddress (start);
  1.1309 -    }
  1.1310 -
  1.1311 -  if (HasHopLimit ())
  1.1312 -    {
  1.1313 -      flags |= MHAS_HOP_LIMIT;
  1.1314 -      start.WriteU8 (GetHopLimit ());
  1.1315 -    }
  1.1316 -
  1.1317 -  if (HasHopCount ())
  1.1318 -    {
  1.1319 -      flags |= MHAS_HOP_COUNT;
  1.1320 -      start.WriteU8 (GetHopCount ());
  1.1321 -    }
  1.1322 -
  1.1323 -  if (HasSequenceNumber ())
  1.1324 -    {
  1.1325 -      flags |= MHAS_SEQ_NUM;
  1.1326 -      start.WriteHtonU16 (GetSequenceNumber ());
  1.1327 -    }
  1.1328 -
  1.1329 -  bufref.WriteU8(flags);
  1.1330 -
  1.1331 -  m_tlvList.Serialize (start);
  1.1332 -
  1.1333 -  for (ConstAddressBlockIterator iter = AddressBlockBegin ();
  1.1334 -      iter != AddressBlockEnd ();
  1.1335 -      iter++)
  1.1336 -    {
  1.1337 -      (*iter)->Serialize (start);
  1.1338 -    }
  1.1339 -
  1.1340 -  sizeref.WriteHtonU16 (front.GetDistanceFrom (start));
  1.1341 -}
  1.1342 -
  1.1343 -Ptr<PbbMessage>
  1.1344 -PbbMessage::DeserializeMessage (Buffer::Iterator &start)
  1.1345 -{
  1.1346 -  /* We need to read the msg-addr-len field to determine what kind of object to
  1.1347 -   * construct. */
  1.1348 -  start.Next ();
  1.1349 -  uint8_t addrlen = start.ReadU8 ();
  1.1350 -  start.Prev (2); /* Go back to the start */
  1.1351 -
  1.1352 -  /* The first four bytes of the flag is the address length.  Set the last four
  1.1353 -   * bytes to 0 to read it. */
  1.1354 -  addrlen = (addrlen & 0xf);
  1.1355 -
  1.1356 -  Ptr<PbbMessage> newmsg;
  1.1357 -
  1.1358 -  switch (addrlen)
  1.1359 -    {
  1.1360 -      case 0:
  1.1361 -      case IPV4:
  1.1362 -        newmsg = Create<PbbMessageIpv4> ();
  1.1363 -        break;
  1.1364 -      case IPV6:
  1.1365 -        newmsg = Create<PbbMessageIpv6> ();
  1.1366 -        break;
  1.1367 -      default:
  1.1368 -        return 0;
  1.1369 -        break;
  1.1370 -    }
  1.1371 -  newmsg->Deserialize (start);
  1.1372 -  return newmsg;
  1.1373 -}
  1.1374 -
  1.1375 -void
  1.1376 -PbbMessage::Deserialize (Buffer::Iterator &start)
  1.1377 -{
  1.1378 -  Buffer::Iterator front = start;
  1.1379 -  SetType (start.ReadU8 ());
  1.1380 -  uint8_t flags = start.ReadU8 ();
  1.1381 -
  1.1382 -  uint16_t size = start.ReadNtohU16 ();
  1.1383 -
  1.1384 -  if (flags & MHAS_ORIG)
  1.1385 -    {
  1.1386 -      SetOriginatorAddress (DeserializeOriginatorAddress (start));
  1.1387 -    }
  1.1388 -
  1.1389 -  if (flags & MHAS_HOP_LIMIT)
  1.1390 -    {
  1.1391 -      SetHopLimit (start.ReadU8 ());
  1.1392 -    }
  1.1393 -
  1.1394 -  if (flags & MHAS_HOP_COUNT)
  1.1395 -    {
  1.1396 -      SetHopCount (start.ReadU8 ());
  1.1397 -    }
  1.1398 -
  1.1399 -  if (flags & MHAS_SEQ_NUM)
  1.1400 -    {
  1.1401 -      SetSequenceNumber (start.ReadNtohU16 ());
  1.1402 -    }
  1.1403 -
  1.1404 -  m_tlvList.Deserialize (start);
  1.1405 -
  1.1406 -  if (size > 0)
  1.1407 -    {
  1.1408 -      while (start.GetDistanceFrom(front) < size)
  1.1409 -        {
  1.1410 -          Ptr<PbbAddressBlock> newab = AddressBlockDeserialize (start);
  1.1411 -          AddressBlockPushBack (newab);
  1.1412 -        }
  1.1413 -    }
  1.1414 -}
  1.1415 -
  1.1416 -void
  1.1417 -PbbMessage::Print (std::ostream &os) const
  1.1418 -{
  1.1419 -  Print (os, 0);
  1.1420 -}
  1.1421 -
  1.1422 -void
  1.1423 -PbbMessage::Print (std::ostream &os, int level) const
  1.1424 -{
  1.1425 -  std::string prefix = "";
  1.1426 -  for (int i = 0; i < level; i++)
  1.1427 -    {
  1.1428 -      prefix.append ("\t");
  1.1429 -    }
  1.1430 -
  1.1431 -  os << prefix << "PbbMessage {" << std::endl;
  1.1432 -
  1.1433 -  os << prefix << "\tmessage type = " << (int)GetType () << std::endl;
  1.1434 -  os << prefix << "\taddress size = " << GetAddressLength () << std::endl;
  1.1435 -
  1.1436 -  if (HasOriginatorAddress ())
  1.1437 -    {
  1.1438 -      os << prefix << "\toriginator address = ";
  1.1439 -      PrintOriginatorAddress (os);
  1.1440 -      os << std::endl;
  1.1441 -    }
  1.1442 -
  1.1443 -  if (HasHopLimit ())
  1.1444 -    {
  1.1445 -      os << prefix << "\thop limit = " << (int)GetHopLimit () << std::endl;
  1.1446 -    }
  1.1447 -
  1.1448 -  if (HasHopCount ())
  1.1449 -    {
  1.1450 -      os << prefix << "\thop count = " << (int)GetHopCount () << std::endl;
  1.1451 -    }
  1.1452 -
  1.1453 -  if (HasSequenceNumber ())
  1.1454 -    {
  1.1455 -      os << prefix << "\tseqnum = " << GetSequenceNumber () << std::endl;
  1.1456 -    }
  1.1457 -
  1.1458 -  m_tlvList.Print (os, level+1);
  1.1459 -
  1.1460 -  for (ConstAddressBlockIterator iter = AddressBlockBegin ();
  1.1461 -      iter != AddressBlockEnd ();
  1.1462 -      iter++)
  1.1463 -    {
  1.1464 -      (*iter)->Print (os, level+1);
  1.1465 -    }
  1.1466 -  os << prefix << "}" << std::endl;
  1.1467 -}
  1.1468 -
  1.1469 -bool
  1.1470 -PbbMessage::operator== (const PbbMessage &other) const
  1.1471 -{
  1.1472 -  if (GetAddressLength () != other.GetAddressLength ())
  1.1473 -    {
  1.1474 -      return false;
  1.1475 -    }
  1.1476 -
  1.1477 -  if (GetType () != other.GetType ())
  1.1478 -    {
  1.1479 -      return false;
  1.1480 -    }
  1.1481 -
  1.1482 -  if (HasOriginatorAddress () != other.HasOriginatorAddress ())
  1.1483 -    {
  1.1484 -      return false;
  1.1485 -    }
  1.1486 -
  1.1487 -  if (HasOriginatorAddress ())
  1.1488 -    {
  1.1489 -      if (GetOriginatorAddress () != other.GetOriginatorAddress ())
  1.1490 -        {
  1.1491 -          return false;
  1.1492 -        }
  1.1493 -    }
  1.1494 -
  1.1495 -  if (HasHopLimit () != other.HasHopLimit ())
  1.1496 -    {
  1.1497 -      return false;
  1.1498 -    }
  1.1499 -
  1.1500 -  if (HasHopLimit ())
  1.1501 -    {
  1.1502 -      if (GetHopLimit () != other.GetHopLimit ())
  1.1503 -        {
  1.1504 -          return false;
  1.1505 -        }
  1.1506 -    }
  1.1507 -
  1.1508 -  if (HasHopCount () != other.HasHopCount ())
  1.1509 -    {
  1.1510 -      return false;
  1.1511 -    }
  1.1512 -
  1.1513 -  if (HasHopCount ())
  1.1514 -    {
  1.1515 -      if (GetHopCount () != other.GetHopCount ())
  1.1516 -        {
  1.1517 -          return false;
  1.1518 -        }
  1.1519 -    }
  1.1520 -
  1.1521 -  if (HasSequenceNumber () != other.HasSequenceNumber ())
  1.1522 -    {
  1.1523 -      return false;
  1.1524 -    }
  1.1525 -
  1.1526 -  if (HasSequenceNumber ())
  1.1527 -    {
  1.1528 -      if (GetSequenceNumber () != other.GetSequenceNumber ())
  1.1529 -        {
  1.1530 -          return false;
  1.1531 -        }
  1.1532 -    }
  1.1533 -
  1.1534 -  if (m_tlvList != other.m_tlvList)
  1.1535 -    {
  1.1536 -      return false;
  1.1537 -    }
  1.1538 -
  1.1539 -  if (AddressBlockSize () != other.AddressBlockSize ())
  1.1540 -    {
  1.1541 -      return false;
  1.1542 -    }
  1.1543 -
  1.1544 -  ConstAddressBlockIterator tai, oai;
  1.1545 -  for (tai = AddressBlockBegin (), oai = other.AddressBlockBegin ();
  1.1546 -      tai != AddressBlockEnd () && oai != other.AddressBlockEnd ();
  1.1547 -      tai++, oai++)
  1.1548 -    {
  1.1549 -      if (**tai != **oai)
  1.1550 -        {
  1.1551 -          return false;
  1.1552 -        }
  1.1553 -    }
  1.1554 -  return true;
  1.1555 -}
  1.1556 -
  1.1557 -bool
  1.1558 -PbbMessage::operator!= (const PbbMessage &other) const
  1.1559 -{
  1.1560 -  return !(*this == other);
  1.1561 -}
  1.1562 -
  1.1563 -/* End PbbMessage Class */
  1.1564 -
  1.1565 -PbbAddressLength
  1.1566 -PbbMessageIpv4::GetAddressLength (void) const
  1.1567 -{
  1.1568 -  return IPV4;
  1.1569 -}
  1.1570 -
  1.1571 -void
  1.1572 -PbbMessageIpv4::SerializeOriginatorAddress (Buffer::Iterator &start) const
  1.1573 -{
  1.1574 -  uint8_t buffer[GetAddressLength () + 1];
  1.1575 -  Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
  1.1576 -  start.Write (buffer, GetAddressLength () + 1);
  1.1577 -}
  1.1578 -
  1.1579 -Address
  1.1580 -PbbMessageIpv4::DeserializeOriginatorAddress (Buffer::Iterator &start) const
  1.1581 -{
  1.1582 -  uint8_t buffer[GetAddressLength () + 1];
  1.1583 -  start.Read(buffer, GetAddressLength () + 1);
  1.1584 -  return Ipv4Address::Deserialize (buffer);
  1.1585 -}
  1.1586 -
  1.1587 -void
  1.1588 -PbbMessageIpv4::PrintOriginatorAddress (std::ostream &os) const
  1.1589 -{
  1.1590 -  Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Print (os);
  1.1591 -}
  1.1592 -
  1.1593 -Ptr<PbbAddressBlock>
  1.1594 -PbbMessageIpv4::AddressBlockDeserialize (Buffer::Iterator &start) const
  1.1595 -{
  1.1596 -  Ptr<PbbAddressBlock> newab = Create<PbbAddressBlockIpv4> ();
  1.1597 -  newab->Deserialize (start);
  1.1598 -  return newab;
  1.1599 -}
  1.1600 -
  1.1601 -/* End PbbMessageIpv4 Class */
  1.1602 -
  1.1603 -PbbAddressLength
  1.1604 -PbbMessageIpv6::GetAddressLength (void) const
  1.1605 -{
  1.1606 -  return IPV6;
  1.1607 -}
  1.1608 -
  1.1609 -void
  1.1610 -PbbMessageIpv6::SerializeOriginatorAddress (Buffer::Iterator &start) const
  1.1611 -{
  1.1612 -  uint8_t buffer[GetAddressLength () + 1];
  1.1613 -  Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
  1.1614 -  start.Write (buffer, GetAddressLength () + 1);
  1.1615 -}
  1.1616 -
  1.1617 -Address
  1.1618 -PbbMessageIpv6::DeserializeOriginatorAddress (Buffer::Iterator &start) const
  1.1619 -{
  1.1620 -  uint8_t buffer[GetAddressLength () + 1];
  1.1621 -  start.Read(buffer, GetAddressLength () + 1);
  1.1622 -  return Ipv6Address::Deserialize (buffer);
  1.1623 -}
  1.1624 -
  1.1625 -void
  1.1626 -PbbMessageIpv6::PrintOriginatorAddress (std::ostream &os) const
  1.1627 -{
  1.1628 -  Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Print (os);
  1.1629 -}
  1.1630 -
  1.1631 -Ptr<PbbAddressBlock>
  1.1632 -PbbMessageIpv6::AddressBlockDeserialize (Buffer::Iterator &start) const
  1.1633 -{
  1.1634 -  Ptr<PbbAddressBlock> newab = Create<PbbAddressBlockIpv6> ();
  1.1635 -  newab->Deserialize (start);
  1.1636 -  return newab;
  1.1637 -}
  1.1638 -
  1.1639 -/* End PbbMessageIpv6 Class */
  1.1640 -
  1.1641 -PbbAddressBlock::PbbAddressBlock ()
  1.1642 -{
  1.1643 -  m_refCount = 1;
  1.1644 -}
  1.1645 -
  1.1646 -/* Manipulating the address block */
  1.1647 -
  1.1648 -PbbAddressBlock::AddressIterator
  1.1649 -PbbAddressBlock::AddressBegin (void)
  1.1650 -{
  1.1651 -  return m_addressList.begin();
  1.1652 -}
  1.1653 -
  1.1654 -PbbAddressBlock::ConstAddressIterator
  1.1655 -PbbAddressBlock::AddressBegin (void) const
  1.1656 -{
  1.1657 -  return m_addressList.begin();
  1.1658 -}
  1.1659 -
  1.1660 -PbbAddressBlock::AddressIterator
  1.1661 -PbbAddressBlock::AddressEnd (void)
  1.1662 -{
  1.1663 -  return m_addressList.end();
  1.1664 -}
  1.1665 -
  1.1666 -PbbAddressBlock::ConstAddressIterator
  1.1667 -PbbAddressBlock::AddressEnd (void) const
  1.1668 -{
  1.1669 -  return m_addressList.end();
  1.1670 -}
  1.1671 -
  1.1672 -int
  1.1673 -PbbAddressBlock::AddressSize (void) const
  1.1674 -{
  1.1675 -  return m_addressList.size();
  1.1676 -}
  1.1677 -
  1.1678 -bool
  1.1679 -PbbAddressBlock::AddressEmpty (void) const
  1.1680 -{
  1.1681 -  return m_addressList.empty();
  1.1682 -}
  1.1683 -
  1.1684 -Address
  1.1685 -PbbAddressBlock::AddressFront (void) const
  1.1686 -{
  1.1687 -  return m_addressList.front();
  1.1688 -}
  1.1689 -
  1.1690 -Address
  1.1691 -PbbAddressBlock::AddressBack (void) const
  1.1692 -{
  1.1693 -  return m_addressList.back();
  1.1694 -}
  1.1695 -
  1.1696 -void
  1.1697 -PbbAddressBlock::AddressPushFront (Address tlv)
  1.1698 -{
  1.1699 -  m_addressList.push_front(tlv);
  1.1700 -}
  1.1701 -
  1.1702 -void
  1.1703 -PbbAddressBlock::AddressPopFront (void)
  1.1704 -{
  1.1705 -  m_addressList.pop_front();
  1.1706 -}
  1.1707 -
  1.1708 -void
  1.1709 -PbbAddressBlock::AddressPushBack (Address tlv)
  1.1710 -{
  1.1711 -  m_addressList.push_back(tlv);
  1.1712 -}
  1.1713 -
  1.1714 -void
  1.1715 -PbbAddressBlock::AddressPopBack (void)
  1.1716 -{
  1.1717 -  m_addressList.pop_back();
  1.1718 -}
  1.1719 -
  1.1720 -PbbAddressBlock::AddressIterator
  1.1721 -PbbAddressBlock::AddressErase (PbbAddressBlock::AddressIterator position)
  1.1722 -{
  1.1723 -  return m_addressList.erase(position);
  1.1724 -}
  1.1725 -
  1.1726 -PbbAddressBlock::AddressIterator
  1.1727 -PbbAddressBlock::AddressErase (PbbAddressBlock::AddressIterator first,
  1.1728 -    PbbAddressBlock::AddressIterator last)
  1.1729 -{
  1.1730 -  return m_addressList.erase(first, last);
  1.1731 -}
  1.1732 -
  1.1733 -  void
  1.1734 -PbbAddressBlock::AddressClear (void)
  1.1735 -{
  1.1736 -  return m_addressList.clear();
  1.1737 -}
  1.1738 -
  1.1739 -/* Manipulating the prefix list */
  1.1740 -
  1.1741 -PbbAddressBlock::PrefixIterator
  1.1742 -PbbAddressBlock::PrefixBegin (void)
  1.1743 -{
  1.1744 -  return m_prefixList.begin ();
  1.1745 -}
  1.1746 -
  1.1747 -PbbAddressBlock::ConstPrefixIterator
  1.1748 -PbbAddressBlock::PrefixBegin (void) const
  1.1749 -{
  1.1750 -  return m_prefixList.begin ();
  1.1751 -}
  1.1752 -
  1.1753 -PbbAddressBlock::PrefixIterator
  1.1754 -PbbAddressBlock::PrefixEnd (void)
  1.1755 -{
  1.1756 -  return m_prefixList.end ();
  1.1757 -}
  1.1758 -
  1.1759 -PbbAddressBlock::ConstPrefixIterator
  1.1760 -PbbAddressBlock::PrefixEnd (void) const
  1.1761 -{
  1.1762 -  return m_prefixList.end ();
  1.1763 -}
  1.1764 -
  1.1765 -int
  1.1766 -PbbAddressBlock::PrefixSize (void) const
  1.1767 -{
  1.1768 -  return m_prefixList.size ();
  1.1769 -}
  1.1770 -
  1.1771 -bool
  1.1772 -PbbAddressBlock::PrefixEmpty (void) const
  1.1773 -{
  1.1774 -  return m_prefixList.empty ();
  1.1775 -}
  1.1776 -
  1.1777 -uint8_t
  1.1778 -PbbAddressBlock::PrefixFront (void) const
  1.1779 -{
  1.1780 -  return m_prefixList.front ();
  1.1781 -}
  1.1782 -
  1.1783 -uint8_t
  1.1784 -PbbAddressBlock::PrefixBack (void) const
  1.1785 -{
  1.1786 -  return m_prefixList.back ();
  1.1787 -}
  1.1788 -
  1.1789 -void
  1.1790 -PbbAddressBlock::PrefixPushFront (uint8_t prefix)
  1.1791 -{
  1.1792 -  m_prefixList.push_front (prefix);
  1.1793 -}
  1.1794 -
  1.1795 -void
  1.1796 -PbbAddressBlock::PrefixPopFront (void)
  1.1797 -{
  1.1798 -  m_prefixList.pop_front ();
  1.1799 -}
  1.1800 -
  1.1801 -void
  1.1802 -PbbAddressBlock::PrefixPushBack (uint8_t prefix)
  1.1803 -{
  1.1804 -  m_prefixList.push_back (prefix);
  1.1805 -}
  1.1806 -
  1.1807 -void
  1.1808 -PbbAddressBlock::PrefixPopBack (void)
  1.1809 -{
  1.1810 -  m_prefixList.pop_back ();
  1.1811 -}
  1.1812 -
  1.1813 -PbbAddressBlock::PrefixIterator
  1.1814 -PbbAddressBlock::PrefixInsert (PbbAddressBlock::PrefixIterator position, const uint8_t value)
  1.1815 -{
  1.1816 -  return m_prefixList.insert (position, value);
  1.1817 -}
  1.1818 -
  1.1819 -PbbAddressBlock::PrefixIterator
  1.1820 -PbbAddressBlock::PrefixErase (PbbAddressBlock::PrefixIterator position)
  1.1821 -{
  1.1822 -  return m_prefixList.erase (position);
  1.1823 -}
  1.1824 -
  1.1825 -PbbAddressBlock::PrefixIterator
  1.1826 -PbbAddressBlock::PrefixErase (PbbAddressBlock::PrefixIterator first, PbbAddressBlock::PrefixIterator last)
  1.1827 -{
  1.1828 -  return m_prefixList.erase (first, last);
  1.1829 -}
  1.1830 -
  1.1831 -void
  1.1832 -PbbAddressBlock::PrefixClear (void)
  1.1833 -{
  1.1834 -  m_prefixList.clear ();
  1.1835 -}
  1.1836 -
  1.1837 -/* Manipulating the TLV block */
  1.1838 -
  1.1839 -PbbAddressBlock::TlvIterator
  1.1840 -PbbAddressBlock::TlvBegin (void)
  1.1841 -{
  1.1842 -  return m_addressTlvList.Begin();
  1.1843 -}
  1.1844 -
  1.1845 -PbbAddressBlock::ConstTlvIterator
  1.1846 -PbbAddressBlock::TlvBegin (void) const
  1.1847 -{
  1.1848 -  return m_addressTlvList.Begin();
  1.1849 -}
  1.1850 -
  1.1851 -PbbAddressBlock::TlvIterator
  1.1852 -PbbAddressBlock::TlvEnd (void)
  1.1853 -{
  1.1854 -  return m_addressTlvList.End();
  1.1855 -}
  1.1856 -
  1.1857 -PbbAddressBlock::ConstTlvIterator
  1.1858 -PbbAddressBlock::TlvEnd (void) const
  1.1859 -{
  1.1860 -  return m_addressTlvList.End();
  1.1861 -}
  1.1862 -
  1.1863 -int
  1.1864 -PbbAddressBlock::TlvSize (void) const
  1.1865 -{
  1.1866 -  return m_addressTlvList.Size();
  1.1867 -}
  1.1868 -
  1.1869 -bool
  1.1870 -PbbAddressBlock::TlvEmpty (void) const
  1.1871 -{
  1.1872 -  return m_addressTlvList.Empty();
  1.1873 -}
  1.1874 -
  1.1875 -Ptr<PbbAddressTlv>
  1.1876 -PbbAddressBlock::TlvFront (void)
  1.1877 -{
  1.1878 -  return m_addressTlvList.Front();
  1.1879 -}
  1.1880 -
  1.1881 -const Ptr<PbbAddressTlv>
  1.1882 -PbbAddressBlock::TlvFront (void) const
  1.1883 -{
  1.1884 -  return m_addressTlvList.Front();
  1.1885 -}
  1.1886 -
  1.1887 -Ptr<PbbAddressTlv>
  1.1888 -PbbAddressBlock::TlvBack (void)
  1.1889 -{
  1.1890 -  return m_addressTlvList.Back();
  1.1891 -}
  1.1892 -
  1.1893 -const Ptr<PbbAddressTlv>
  1.1894 -PbbAddressBlock::TlvBack (void) const
  1.1895 -{
  1.1896 -  return m_addressTlvList.Back();
  1.1897 -}
  1.1898 -
  1.1899 -void
  1.1900 -PbbAddressBlock::TlvPushFront (Ptr<PbbAddressTlv> tlv)
  1.1901 -{
  1.1902 -  m_addressTlvList.PushFront(tlv);
  1.1903 -}
  1.1904 -
  1.1905 -void
  1.1906 -PbbAddressBlock::TlvPopFront (void)
  1.1907 -{
  1.1908 -  m_addressTlvList.PopFront();
  1.1909 -}
  1.1910 -
  1.1911 -void
  1.1912 -PbbAddressBlock::TlvPushBack (Ptr<PbbAddressTlv> tlv)
  1.1913 -{
  1.1914 -  m_addressTlvList.PushBack(tlv);
  1.1915 -}
  1.1916 -
  1.1917 -void
  1.1918 -PbbAddressBlock::TlvPopBack (void)
  1.1919 -{
  1.1920 -  m_addressTlvList.PopBack();
  1.1921 -}
  1.1922 -
  1.1923 -PbbAddressBlock::TlvIterator
  1.1924 -PbbAddressBlock::TlvErase (PbbAddressBlock::TlvIterator position)
  1.1925 -{
  1.1926 -  return m_addressTlvList.Erase(position);
  1.1927 -}
  1.1928 -
  1.1929 -PbbAddressBlock::TlvIterator
  1.1930 -PbbAddressBlock::TlvErase (PbbAddressBlock::TlvIterator first,
  1.1931 -    PbbAddressBlock::TlvIterator last)
  1.1932 -{
  1.1933 -  return m_addressTlvList.Erase(first, last);
  1.1934 -}
  1.1935 -
  1.1936 -void
  1.1937 -PbbAddressBlock::TlvClear (void)
  1.1938 -{
  1.1939 -  return m_addressTlvList.Clear();
  1.1940 -}
  1.1941 -
  1.1942 -void
  1.1943 -PbbAddressBlock::Ref (void) const
  1.1944 -{
  1.1945 -  m_refCount++;
  1.1946 -}
  1.1947 -
  1.1948 -void
  1.1949 -PbbAddressBlock::Unref (void) const
  1.1950 -{
  1.1951 -  m_refCount--;
  1.1952 -  if (m_refCount == 0)
  1.1953 -    {
  1.1954 -      delete this;
  1.1955 -    }
  1.1956 -}
  1.1957 -
  1.1958 -uint32_t
  1.1959 -PbbAddressBlock::GetSerializedSize (void) const
  1.1960 -{
  1.1961 -  /* num-addr + flags */
  1.1962 -  uint32_t size = 2;
  1.1963 -
  1.1964 -  if (AddressSize () == 1)
  1.1965 -    {
  1.1966 -      size += GetAddressLength () + PrefixSize();
  1.1967 -    }
  1.1968 -  else if (AddressSize () > 0)
  1.1969 -    {
  1.1970 -      uint8_t head[GetAddressLength ()];
  1.1971 -      uint8_t headlen = 0;
  1.1972 -      uint8_t tail[GetAddressLength ()];
  1.1973 -      uint8_t taillen = 0;
  1.1974 -
  1.1975 -      GetHeadTail (head, headlen, tail, taillen);
  1.1976 -
  1.1977 -      if (headlen > 0)
  1.1978 -        {
  1.1979 -          size += 1 + headlen;
  1.1980 -        }
  1.1981 -
  1.1982 -      if (taillen > 0)
  1.1983 -        {
  1.1984 -          size++;
  1.1985 -          if (!HasZeroTail (tail, taillen))
  1.1986 -            {
  1.1987 -              size += taillen;
  1.1988 -            }
  1.1989 -        }
  1.1990 -
  1.1991 -      /* mid size */
  1.1992 -      size += (GetAddressLength () - headlen - taillen) * AddressSize ();
  1.1993 -
  1.1994 -      size += PrefixSize ();
  1.1995 -    }
  1.1996 -
  1.1997 -  size += m_addressTlvList.GetSerializedSize ();
  1.1998 -
  1.1999 -  return size;
  1.2000 -}
  1.2001 -
  1.2002 -void
  1.2003 -PbbAddressBlock::Serialize (Buffer::Iterator &start) const
  1.2004 -{
  1.2005 -  start.WriteU8 (AddressSize ());
  1.2006 -
  1.2007 -  if (AddressSize () == 1)
  1.2008 -    {
  1.2009 -      start.WriteU8 (0);
  1.2010 -
  1.2011 -      uint8_t buf[GetAddressLength ()];
  1.2012 -      SerializeAddress (buf, AddressBegin ());
  1.2013 -      start.Write (buf, GetAddressLength ());
  1.2014 -
  1.2015 -      if (PrefixSize () == 1)
  1.2016 -        {
  1.2017 -          start.WriteU8 (PrefixFront ());
  1.2018 -        }
  1.2019 -    }
  1.2020 -  else if (AddressSize () > 0)
  1.2021 -    {
  1.2022 -      Buffer::Iterator bufref = start;
  1.2023 -      uint8_t flags = 0;
  1.2024 -      start.Next ();
  1.2025 -
  1.2026 -      uint8_t head[GetAddressLength ()];
  1.2027 -      uint8_t tail[GetAddressLength ()];
  1.2028 -      uint8_t headlen = 0;
  1.2029 -      uint8_t taillen = 0;
  1.2030 -
  1.2031 -      GetHeadTail (head, headlen, tail, taillen);
  1.2032 -
  1.2033 -      if (headlen > 0)
  1.2034 -        {
  1.2035 -          flags |= AHAS_HEAD;
  1.2036 -          start.WriteU8 (headlen);
  1.2037 -          start.Write (head, headlen);
  1.2038 -        }
  1.2039 -
  1.2040 -      if (taillen > 0)
  1.2041 -        {
  1.2042 -          start.WriteU8 (taillen);
  1.2043 -
  1.2044 -          if (HasZeroTail (tail, taillen))
  1.2045 -            {
  1.2046 -              flags |= AHAS_ZERO_TAIL;
  1.2047 -            }
  1.2048 -          else
  1.2049 -            {
  1.2050 -              flags |= AHAS_FULL_TAIL;
  1.2051 -              start.Write (tail, taillen);
  1.2052 -            }
  1.2053 -        }
  1.2054 -
  1.2055 -      if (headlen + taillen < GetAddressLength ())
  1.2056 -        {
  1.2057 -          uint8_t mid[GetAddressLength ()];
  1.2058 -          for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin ();
  1.2059 -              iter != AddressEnd ();
  1.2060 -              iter++)
  1.2061 -            {
  1.2062 -              SerializeAddress (mid, iter);
  1.2063 -              start.Write (mid + headlen, GetAddressLength () - headlen - taillen);
  1.2064 -            }
  1.2065 -        }
  1.2066 -
  1.2067 -      flags |= GetPrefixFlags ();
  1.2068 -      bufref.WriteU8 (flags);
  1.2069 -
  1.2070 -      for (ConstPrefixIterator iter = PrefixBegin ();
  1.2071 -          iter != PrefixEnd ();
  1.2072 -          iter++)
  1.2073 -        {
  1.2074 -          start.WriteU8 (*iter);
  1.2075 -        }
  1.2076 -    }
  1.2077 -  
  1.2078 -  m_addressTlvList.Serialize (start);
  1.2079 -}
  1.2080 -
  1.2081 -void
  1.2082 -PbbAddressBlock::Deserialize (Buffer::Iterator &start)
  1.2083 -{
  1.2084 -  uint8_t numaddr = start.ReadU8 ();
  1.2085 -  uint8_t flags = start.ReadU8 ();
  1.2086 -
  1.2087 -  if (numaddr > 0)
  1.2088 -    {
  1.2089 -      uint8_t headlen = 0;
  1.2090 -      uint8_t taillen = 0;
  1.2091 -      uint8_t addrtmp[GetAddressLength ()];
  1.2092 -      memset(addrtmp, 0, GetAddressLength ());
  1.2093 -
  1.2094 -      if (flags & AHAS_HEAD)
  1.2095 -        {
  1.2096 -          headlen = start.ReadU8 ();
  1.2097 -          start.Read (addrtmp, headlen);
  1.2098 -        }
  1.2099 -
  1.2100 -      if ((flags & AHAS_FULL_TAIL) ^ (flags & AHAS_ZERO_TAIL))
  1.2101 -        {
  1.2102 -          taillen = start.ReadU8 ();
  1.2103 -          
  1.2104 -          if (flags & AHAS_FULL_TAIL)
  1.2105 -            {
  1.2106 -              start.Read (addrtmp + GetAddressLength () - taillen, taillen);
  1.2107 -            }
  1.2108 -        }
  1.2109 -
  1.2110 -      for (int i = 0; i < numaddr; i++)
  1.2111 -        {
  1.2112 -          start.Read (addrtmp + headlen, GetAddressLength () - headlen - taillen);
  1.2113 -          AddressPushBack (DeserializeAddress (addrtmp));
  1.2114 -        }
  1.2115 -
  1.2116 -      if (flags & AHAS_SINGLE_PRE_LEN)
  1.2117 -        {
  1.2118 -          PrefixPushBack (start.ReadU8 ());
  1.2119 -        }
  1.2120 -      else if (flags & AHAS_MULTI_PRE_LEN)
  1.2121 -        {
  1.2122 -          for (int i = 0; i < numaddr; i++)
  1.2123 -            {
  1.2124 -              PrefixPushBack (start.ReadU8 ());
  1.2125 -            }
  1.2126 -        }
  1.2127 -    }
  1.2128 -
  1.2129 -  m_addressTlvList.Deserialize (start);
  1.2130 -}
  1.2131 -
  1.2132 -void
  1.2133 -PbbAddressBlock::Print (std::ostream &os) const
  1.2134 -{
  1.2135 -  Print (os, 0);
  1.2136 -}
  1.2137 -
  1.2138 -void
  1.2139 -PbbAddressBlock::Print (std::ostream &os, int level) const
  1.2140 -{
  1.2141 -  std::string prefix = "";
  1.2142 -  for (int i = 0; i < level; i++)
  1.2143 -    {
  1.2144 -      prefix.append ("\t");
  1.2145 -    }
  1.2146 -
  1.2147 -  os << prefix << "PbbAddressBlock {" << std::endl;
  1.2148 -  os << prefix << "\taddresses = " << std::endl;
  1.2149 -  for (ConstAddressIterator iter = AddressBegin ();
  1.2150 -      iter != AddressEnd ();
  1.2151 -      iter++)
  1.2152 -    {
  1.2153 -      os << prefix << "\t\t";
  1.2154 -      PrintAddress(os, iter);
  1.2155 -      os << std::endl;
  1.2156 -    }
  1.2157 -
  1.2158 -  os << prefix << "\tprefixes = " << std::endl;
  1.2159 -  for (ConstPrefixIterator iter = PrefixBegin ();
  1.2160 -      iter != PrefixEnd ();
  1.2161 -      iter++)
  1.2162 -    {
  1.2163 -      os << prefix << "\t\t" << (int)(*iter) << std::endl;
  1.2164 -    }
  1.2165 -
  1.2166 -  m_addressTlvList.Print (os, level+1);
  1.2167 -}
  1.2168 -
  1.2169 -bool
  1.2170 -PbbAddressBlock::operator== (const PbbAddressBlock &other) const
  1.2171 -{
  1.2172 -  if (AddressSize () != other.AddressSize ())
  1.2173 -    {
  1.2174 -      return false;
  1.2175 -    }
  1.2176 -
  1.2177 -  ConstAddressIterator tai, oai;
  1.2178 -  for (tai = AddressBegin (), oai = other.AddressBegin ();
  1.2179 -      tai != AddressEnd () && oai != other.AddressEnd ();
  1.2180 -      tai++, oai++)
  1.2181 -    {
  1.2182 -      if (*tai != *oai)
  1.2183 -        {
  1.2184 -          return false;
  1.2185 -        }
  1.2186 -    }
  1.2187 -
  1.2188 -  if (PrefixSize () != other.PrefixSize ())
  1.2189 -    {
  1.2190 -      return false;
  1.2191 -    }
  1.2192 -
  1.2193 -  ConstPrefixIterator tpi, opi;
  1.2194 -  for (tpi = PrefixBegin (), opi = other.PrefixBegin ();
  1.2195 -      tpi != PrefixEnd () && opi != other.PrefixEnd ();
  1.2196 -      tpi++, opi++)
  1.2197 -    {
  1.2198 -      if (*tpi != *opi)
  1.2199 -        {
  1.2200 -          return false;
  1.2201 -        }
  1.2202 -    }
  1.2203 -
  1.2204 -  if (m_addressTlvList != other.m_addressTlvList)
  1.2205 -    {
  1.2206 -      return false;
  1.2207 -    }
  1.2208 -
  1.2209 -  return true;
  1.2210 -}
  1.2211 -
  1.2212 -bool
  1.2213 -PbbAddressBlock::operator!= (const PbbAddressBlock &other) const
  1.2214 -{
  1.2215 -  return !(*this == other);
  1.2216 -}
  1.2217 -
  1.2218 -uint8_t
  1.2219 -PbbAddressBlock::GetPrefixFlags (void) const
  1.2220 -{
  1.2221 -  switch (PrefixSize ())
  1.2222 -    {
  1.2223 -      case 0:
  1.2224 -        return 0;
  1.2225 -        break;
  1.2226 -      case 1:
  1.2227 -        return AHAS_SINGLE_PRE_LEN;
  1.2228 -        break;
  1.2229 -      default:
  1.2230 -        return AHAS_MULTI_PRE_LEN;
  1.2231 -        break;
  1.2232 -    }
  1.2233 -}
  1.2234 -
  1.2235 -void
  1.2236 -PbbAddressBlock::GetHeadTail (uint8_t *head, uint8_t &headlen,
  1.2237 -    uint8_t *tail, uint8_t &taillen) const
  1.2238 -{
  1.2239 -  headlen = GetAddressLength ();
  1.2240 -  taillen = headlen;
  1.2241 -
  1.2242 -  /* Temporary automatic buffers to store serialized addresses */
  1.2243 -  uint8_t * buflast = new uint8_t[GetAddressLength ()];
  1.2244 -  uint8_t * bufcur = new uint8_t[GetAddressLength ()];
  1.2245 -  uint8_t * tmp;
  1.2246 -
  1.2247 -  SerializeAddress (buflast, AddressBegin ());
  1.2248 -
  1.2249 -  /* Skip the first item */
  1.2250 -  for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin ()++;
  1.2251 -      iter != AddressEnd ();
  1.2252 -      iter++)
  1.2253 -    {
  1.2254 -      SerializeAddress (bufcur, iter);
  1.2255 -
  1.2256 -      int i;
  1.2257 -      for (i = 0; i < headlen; i++)
  1.2258 -        {
  1.2259 -          if (buflast[i] != bufcur[i])
  1.2260 -            {
  1.2261 -              headlen = i;
  1.2262 -              break;
  1.2263 -            }
  1.2264 -        }
  1.2265 -
  1.2266 -      /* If headlen == fulllen - 1, then tail is 0 */
  1.2267 -      if (headlen <= GetAddressLength () - 1)
  1.2268 -        {
  1.2269 -          for (i = GetAddressLength () - 1;
  1.2270 -              GetAddressLength () - 1 - i <= taillen && i > headlen;
  1.2271 -              i--)
  1.2272 -            {
  1.2273 -              if (buflast[i] != bufcur[i])
  1.2274 -                {
  1.2275 -                  break;
  1.2276 -                }
  1.2277 -            }
  1.2278 -          taillen = GetAddressLength () - 1 - i;
  1.2279 -        }
  1.2280 -      else if (headlen == 0)
  1.2281 -        {
  1.2282 -          taillen = 0;
  1.2283 -          break;
  1.2284 -        }
  1.2285 -
  1.2286 -      tmp = buflast;
  1.2287 -      buflast = bufcur;
  1.2288 -      bufcur = tmp;
  1.2289 -    }
  1.2290 -
  1.2291 -  memcpy(head, bufcur, headlen);
  1.2292 -  memcpy(tail, bufcur + (GetAddressLength () - taillen), taillen);
  1.2293 -
  1.2294 -  delete[] buflast;
  1.2295 -  delete[] bufcur;
  1.2296 -}
  1.2297 -
  1.2298 -bool
  1.2299 -PbbAddressBlock::HasZeroTail (const uint8_t *tail, uint8_t taillen) const
  1.2300 -{
  1.2301 -  int i;
  1.2302 -  for (i = 0; i < taillen; i++)
  1.2303 -    {
  1.2304 -      if (tail[i] != 0)
  1.2305 -        {
  1.2306 -          break;
  1.2307 -        }
  1.2308 -    }
  1.2309 -  return i == taillen;
  1.2310 -}
  1.2311 -
  1.2312 -/* End PbbAddressBlock Class */
  1.2313 -
  1.2314 -uint8_t
  1.2315 -PbbAddressBlockIpv4::GetAddressLength (void) const
  1.2316 -{
  1.2317 -  return 4;
  1.2318 -}
  1.2319 -
  1.2320 -void
  1.2321 -PbbAddressBlockIpv4::SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const
  1.2322 -{
  1.2323 -  Ipv4Address::ConvertFrom (*iter).Serialize (buffer);
  1.2324 -}
  1.2325 -
  1.2326 -Address
  1.2327 -PbbAddressBlockIpv4::DeserializeAddress (uint8_t *buffer) const
  1.2328 -{
  1.2329 -  return Ipv4Address::Deserialize (buffer);
  1.2330 -}
  1.2331 -
  1.2332 -void
  1.2333 -PbbAddressBlockIpv4::PrintAddress (std::ostream &os, ConstAddressIterator iter) const
  1.2334 -{
  1.2335 -  Ipv4Address::ConvertFrom (*iter).Print (os);
  1.2336 -}
  1.2337 -
  1.2338 -/* End PbbAddressBlockIpv4 Class */
  1.2339 -
  1.2340 -uint8_t
  1.2341 -PbbAddressBlockIpv6::GetAddressLength (void) const
  1.2342 -{
  1.2343 -  return 16;
  1.2344 -}
  1.2345 -
  1.2346 -void
  1.2347 -PbbAddressBlockIpv6::SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const
  1.2348 -{
  1.2349 -  Ipv6Address::ConvertFrom (*iter).Serialize (buffer);
  1.2350 -}
  1.2351 -
  1.2352 -Address
  1.2353 -PbbAddressBlockIpv6::DeserializeAddress (uint8_t *buffer) const
  1.2354 -{
  1.2355 -  return Ipv6Address::Deserialize (buffer);
  1.2356 -}
  1.2357 -
  1.2358 -void
  1.2359 -PbbAddressBlockIpv6::PrintAddress (std::ostream &os, ConstAddressIterator iter) const
  1.2360 -{
  1.2361 -  Ipv6Address::ConvertFrom (*iter).Print (os);
  1.2362 -}
  1.2363 -
  1.2364 -/* End PbbAddressBlockIpv6 Class */
  1.2365 -
  1.2366 -PbbTlv::PbbTlv (void)
  1.2367 -{
  1.2368 -  m_refCount = 1;
  1.2369 -  m_hasTypeExt = false;
  1.2370 -  m_hasIndexStart = false;
  1.2371 -  m_hasIndexStop = false;
  1.2372 -  m_isMultivalue = false;
  1.2373 -  m_hasValue = false;
  1.2374 -}
  1.2375 -
  1.2376 -void
  1.2377 -PbbTlv::SetType (uint8_t type)
  1.2378 -{
  1.2379 -  m_type = type;
  1.2380 -}
  1.2381 -
  1.2382 -uint8_t
  1.2383 -PbbTlv::GetType (void) const
  1.2384 -{
  1.2385 -  return m_type;
  1.2386 -}
  1.2387 -
  1.2388 -void
  1.2389 -PbbTlv::SetTypeExt (uint8_t typeExt)
  1.2390 -{
  1.2391 -  m_typeExt = typeExt;
  1.2392 -  m_hasTypeExt = true;
  1.2393 -}
  1.2394 -
  1.2395 -uint8_t
  1.2396 -PbbTlv::GetTypeExt (void) const
  1.2397 -{
  1.2398 -  NS_ASSERT (HasTypeExt ());
  1.2399 -  return m_typeExt;
  1.2400 -}
  1.2401 -
  1.2402 -bool
  1.2403 -PbbTlv::HasTypeExt (void) const
  1.2404 -{
  1.2405 -  return m_hasTypeExt;
  1.2406 -}
  1.2407 -
  1.2408 -void
  1.2409 -PbbTlv::SetIndexStart (uint8_t index)
  1.2410 -{
  1.2411 -  m_indexStart = index;
  1.2412 -  m_hasIndexStart = true;
  1.2413 -}
  1.2414 -
  1.2415 -uint8_t
  1.2416 -PbbTlv::GetIndexStart (void) const
  1.2417 -{
  1.2418 -  NS_ASSERT (HasIndexStart ());
  1.2419 -  return m_indexStart;
  1.2420 -}
  1.2421 -
  1.2422 -bool
  1.2423 -PbbTlv::HasIndexStart (void) const
  1.2424 -{
  1.2425 -  return m_hasIndexStart;
  1.2426 -}
  1.2427 -
  1.2428 -void
  1.2429 -PbbTlv::SetIndexStop (uint8_t index)
  1.2430 -{
  1.2431 -  m_indexStop = index;
  1.2432 -  m_hasIndexStop = true;
  1.2433 -}
  1.2434 -
  1.2435 -uint8_t
  1.2436 -PbbTlv::GetIndexStop (void) const
  1.2437 -{
  1.2438 -  NS_ASSERT (HasIndexStop ());
  1.2439 -  return m_indexStop;
  1.2440 -}
  1.2441 -
  1.2442 -bool
  1.2443 -PbbTlv::HasIndexStop (void) const
  1.2444 -{
  1.2445 -  return m_hasIndexStop;
  1.2446 -}
  1.2447 -
  1.2448 -void
  1.2449 -PbbTlv::SetMultivalue (bool isMultivalue)
  1.2450 -{
  1.2451 -  m_isMultivalue = isMultivalue;
  1.2452 -}
  1.2453 -
  1.2454 -bool
  1.2455 -PbbTlv::IsMultivalue (void) const
  1.2456 -{
  1.2457 -  return m_isMultivalue;
  1.2458 -}
  1.2459 -
  1.2460 -void
  1.2461 -PbbTlv::SetValue (Buffer start)
  1.2462 -{
  1.2463 -  m_hasValue = true;
  1.2464 -  m_value = start;
  1.2465 -}
  1.2466 -
  1.2467 -void
  1.2468 -PbbTlv::SetValue (const uint8_t * buffer, uint32_t size)
  1.2469 -{
  1.2470 -  Buffer value;
  1.2471 -  value.AddAtStart (size);
  1.2472 -  value.Begin ().Write (buffer, size);
  1.2473 -  SetValue (value);
  1.2474 -}
  1.2475 -
  1.2476 -Buffer
  1.2477 -PbbTlv::GetValue (void) const
  1.2478 -{
  1.2479 -  NS_ASSERT (HasValue ());
  1.2480 -  return m_value;
  1.2481 -}
  1.2482 -
  1.2483 -bool
  1.2484 -PbbTlv::HasValue (void) const
  1.2485 -{
  1.2486 -  return m_hasValue;
  1.2487 -}
  1.2488 -
  1.2489 -void
  1.2490 -PbbTlv::Ref (void) const
  1.2491 -{
  1.2492 -  m_refCount++;
  1.2493 -}
  1.2494 -
  1.2495 -void
  1.2496 -PbbTlv::Unref (void) const
  1.2497 -{
  1.2498 -  m_refCount--;
  1.2499 -  if (m_refCount == 0)
  1.2500 -    {
  1.2501 -      delete this;
  1.2502 -    }
  1.2503 -}
  1.2504 -
  1.2505 -uint32_t
  1.2506 -PbbTlv::GetSerializedSize (void) const
  1.2507 -{
  1.2508 -  /* type + flags */
  1.2509 -  uint32_t size = 2;
  1.2510 -
  1.2511 -  if (HasTypeExt ())
  1.2512 -    {
  1.2513 -      size++;
  1.2514 -    }
  1.2515 -
  1.2516 -  if (HasIndexStart ())
  1.2517 -    {
  1.2518 -      size++;
  1.2519 -    }
  1.2520 -
  1.2521 -  if (HasIndexStop ())
  1.2522 -    {
  1.2523 -      size++;
  1.2524 -    }
  1.2525 -
  1.2526 -  if (HasValue ())
  1.2527 -    {
  1.2528 -      if (GetValue ().GetSize () > 255)
  1.2529 -        {
  1.2530 -          size += 2;
  1.2531 -        } 
  1.2532 -      else 
  1.2533 -        {
  1.2534 -          size++;
  1.2535 -        }
  1.2536 -      size += GetValue ().GetSize ();
  1.2537 -    }
  1.2538 -
  1.2539 -  return size;
  1.2540 -}
  1.2541 -
  1.2542 -void
  1.2543 -PbbTlv::Serialize (Buffer::Iterator &start) const
  1.2544 -{
  1.2545 -  start.WriteU8 (GetType ());
  1.2546 -
  1.2547 -  Buffer::Iterator bufref = start;
  1.2548 -  uint8_t flags = 0;
  1.2549 -  start.Next();
  1.2550 -
  1.2551 -  if (HasTypeExt())
  1.2552 -    {
  1.2553 -      flags |= THAS_TYPE_EXT;
  1.2554 -      start.WriteU8 (GetTypeExt ());
  1.2555 -    }
  1.2556 -
  1.2557 -  if (HasIndexStart ())
  1.2558 -    {
  1.2559 -      start.WriteU8 (GetIndexStart ());
  1.2560 -
  1.2561 -      if (HasIndexStop ())
  1.2562 -        {
  1.2563 -          flags |= THAS_MULTI_INDEX;
  1.2564 -          start.WriteU8 (GetIndexStop ());
  1.2565 -        } 
  1.2566 -      else
  1.2567 -        {
  1.2568 -          flags |= THAS_SINGLE_INDEX;
  1.2569 -        }
  1.2570 -    }
  1.2571 -
  1.2572 -  if (HasValue ()) 
  1.2573 -    {
  1.2574 -      flags |= THAS_VALUE;
  1.2575 -
  1.2576 -      uint32_t size = GetValue ().GetSize ();
  1.2577 -      if (size > 255)
  1.2578 -        {
  1.2579 -          flags |= THAS_EXT_LEN;
  1.2580 -          start.WriteHtonU16 (size);
  1.2581 -        }
  1.2582 -      else
  1.2583 -        {
  1.2584 -          start.WriteU8 (size);
  1.2585 -        }
  1.2586 -
  1.2587 -      if (IsMultivalue ())
  1.2588 -        {
  1.2589 -          flags |= TIS_MULTIVALUE;
  1.2590 -        }
  1.2591 -
  1.2592 -      start.Write(GetValue ().Begin (), GetValue ().End ());
  1.2593 -    }
  1.2594 -
  1.2595 -  bufref.WriteU8 (flags);
  1.2596 -}
  1.2597 -
  1.2598 -void
  1.2599 -PbbTlv::Deserialize (Buffer::Iterator &start)
  1.2600 -{
  1.2601 -  SetType (start.ReadU8 ());
  1.2602 -
  1.2603 -  uint8_t flags = start.ReadU8 ();
  1.2604 -
  1.2605 -  if (flags & THAS_TYPE_EXT)
  1.2606 -    {
  1.2607 -      SetTypeExt (start.ReadU8 ());
  1.2608 -    }
  1.2609 -
  1.2610 -  if (flags & THAS_MULTI_INDEX)
  1.2611 -    {
  1.2612 -      SetIndexStart (start.ReadU8 ());
  1.2613 -      SetIndexStop (start.ReadU8 ());
  1.2614 -    }
  1.2615 -  else if (flags & THAS_SINGLE_INDEX)
  1.2616 -    {
  1.2617 -      SetIndexStart (start.ReadU8 ());
  1.2618 -    }
  1.2619 -
  1.2620 -  if (flags & THAS_VALUE)
  1.2621 -    {
  1.2622 -      uint16_t len = 0;
  1.2623 -
  1.2624 -      if (flags & THAS_EXT_LEN)
  1.2625 -        {
  1.2626 -          len = start.ReadNtohU16 ();
  1.2627 -        }
  1.2628 -      else
  1.2629 -        {
  1.2630 -          len = start.ReadU8 ();
  1.2631 -        }
  1.2632 -
  1.2633 -      m_value.AddAtStart (len);
  1.2634 -
  1.2635 -      Buffer::Iterator valueStart = start;
  1.2636 -      start.Next (len);
  1.2637 -      m_value.Begin ().Write (valueStart, start);
  1.2638 -      m_hasValue = true;
  1.2639 -    }
  1.2640 -}
  1.2641 -
  1.2642 -void
  1.2643 -PbbTlv::Print (std::ostream &os) const
  1.2644 -{
  1.2645 -  Print (os, 0);
  1.2646 -}
  1.2647 -
  1.2648 -void
  1.2649 -PbbTlv::Print (std::ostream &os, int level) const
  1.2650 -{
  1.2651 -  std::string prefix = "";
  1.2652 -  for (int i = 0; i < level; i++)
  1.2653 -    {
  1.2654 -      prefix.append ("\t");
  1.2655 -    }
  1.2656 -
  1.2657 -  os << prefix << "PbbTlv {" << std::endl;
  1.2658 -  os << prefix << "\ttype = " << (int)GetType () << std::endl;
  1.2659 -
  1.2660 -  if (HasTypeExt ())
  1.2661 -    {
  1.2662 -      os << prefix << "\ttypeext = " << (int)GetTypeExt () << std::endl;
  1.2663 -    }
  1.2664 -
  1.2665 -  if (HasIndexStart ())
  1.2666 -    {
  1.2667 -      os << prefix << "\tindexStart = " << (int)GetIndexStart () << std::endl;
  1.2668 -    }
  1.2669 -
  1.2670 -  if (HasIndexStop ())
  1.2671 -    {
  1.2672 -      os << prefix << "\tindexStop = " << (int)GetIndexStop () << std::endl;
  1.2673 -    }
  1.2674 -
  1.2675 -  os << prefix << "\tisMultivalue = " << IsMultivalue () << std::endl;
  1.2676 -
  1.2677 -  if (HasValue ())
  1.2678 -    {
  1.2679 -      os << prefix << "\thas value; size = " << GetValue (). GetSize () << std::endl;
  1.2680 -    }
  1.2681 -
  1.2682 -  os << prefix << "}" << std::endl;
  1.2683 -}
  1.2684 -
  1.2685 -bool
  1.2686 -PbbTlv::operator== (const PbbTlv &other) const
  1.2687 -{
  1.2688 -  if (GetType () != other.GetType ())
  1.2689 -    {
  1.2690 -      return false;
  1.2691 -    }
  1.2692 -
  1.2693 -  if (HasTypeExt () != other.HasTypeExt ())
  1.2694 -    {
  1.2695 -      return false;
  1.2696 -    }
  1.2697 -
  1.2698 -  if (HasTypeExt ())
  1.2699 -    {
  1.2700 -      if (GetTypeExt () != other.GetTypeExt ())
  1.2701 -        {
  1.2702 -          return false;
  1.2703 -        }
  1.2704 -    }
  1.2705 -
  1.2706 -  if (HasValue () != other.HasValue ())
  1.2707 -    {
  1.2708 -      return false;
  1.2709 -    }
  1.2710 -
  1.2711 -  if (HasValue ())
  1.2712 -    {
  1.2713 -      Buffer tv = GetValue ();
  1.2714 -      Buffer ov = other.GetValue ();
  1.2715 -      if (tv.GetSize () != ov.GetSize ())
  1.2716 -        {
  1.2717 -          return false;
  1.2718 -        }
  1.2719 -
  1.2720 -      /* The docs say I probably shouldn't use Buffer::PeekData, but I think it
  1.2721 -       * is justified in this case. */
  1.2722 -      if (memcmp (tv.PeekData (), ov.PeekData (), tv.GetSize ()) != 0)
  1.2723 -        {
  1.2724 -          return false;
  1.2725 -        }
  1.2726 -    }
  1.2727 -  return true;
  1.2728 -}
  1.2729 -
  1.2730 -bool
  1.2731 -PbbTlv::operator!= (const PbbTlv &other) const
  1.2732 -{
  1.2733 -  return !(*this == other);
  1.2734 -}
  1.2735 -
  1.2736 -/* End PbbTlv Class */
  1.2737 -
  1.2738 -void 
  1.2739 -PbbAddressTlv::SetIndexStart (uint8_t index)
  1.2740 -{
  1.2741 -  PbbTlv::SetIndexStart (index);
  1.2742 -}
  1.2743 -
  1.2744 -uint8_t
  1.2745 -PbbAddressTlv::GetIndexStart (void) const
  1.2746 -{
  1.2747 -  return PbbTlv::GetIndexStart ();
  1.2748 -}
  1.2749 -
  1.2750 -bool
  1.2751 -PbbAddressTlv::HasIndexStart (void) const
  1.2752 -{
  1.2753 -  return PbbTlv::HasIndexStart ();
  1.2754 -}
  1.2755 -
  1.2756 -void 
  1.2757 -PbbAddressTlv::SetIndexStop (uint8_t index)
  1.2758 -{
  1.2759 -  PbbTlv::SetIndexStop (index);
  1.2760 -}
  1.2761 -
  1.2762 -uint8_t
  1.2763 -PbbAddressTlv::GetIndexStop (void) const
  1.2764 -{
  1.2765 -  return PbbTlv::GetIndexStop ();
  1.2766 -}
  1.2767 -
  1.2768 -bool
  1.2769 -PbbAddressTlv::HasIndexStop (void) const
  1.2770 -{
  1.2771 -  return PbbTlv::HasIndexStop ();
  1.2772 -}
  1.2773 -
  1.2774 -void
  1.2775 -PbbAddressTlv::SetMultivalue (bool isMultivalue)
  1.2776 -{
  1.2777 -  PbbTlv::SetMultivalue (isMultivalue);
  1.2778 -}
  1.2779 -
  1.2780 -bool
  1.2781 -PbbAddressTlv::IsMultivalue (void) const
  1.2782 -{
  1.2783 -  return PbbTlv::IsMultivalue ();
  1.2784 -}
  1.2785 -
  1.2786 -} /* namespace ns3 */
     2.1 --- a/src/contrib/packetbb.h	Fri Sep 11 00:52:23 2009 -0400
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,1727 +0,0 @@
     2.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2.5 -/* vim: set ts=2 sw=2 sta expandtab ai si cin: */
     2.6 -/* 
     2.7 - * Copyright (c) 2009 Drexel University
     2.8 - * 
     2.9 - * This program is free software; you can redistribute it and/or modify
    2.10 - * it under the terms of the GNU General Public License version 2 as
    2.11 - * published by the Free Software Foundation;
    2.12 - *
    2.13 - * This program is distributed in the hope that it will be useful,
    2.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.16 - * GNU General Public License for more details.
    2.17 - *
    2.18 - * You should have received a copy of the GNU General Public License
    2.19 - * along with this program; if not, write to the Free Software
    2.20 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.21 - * 
    2.22 - * Author: Tom Wambold <tom5760@gmail.com>
    2.23 - */
    2.24 -/* These classes implement RFC 5444 - The Generalized Mobile Ad Hoc Network
    2.25 - * (MANET) Packet/PbbMessage Format
    2.26 - * See: http://tools.ietf.org/html/rfc5444 for details */
    2.27 -
    2.28 -#ifndef PACKETBB_H
    2.29 -#define PACKETBB_H
    2.30 -
    2.31 -#include <list>
    2.32 -
    2.33 -#include "ns3/ptr.h"
    2.34 -#include "ns3/address.h"
    2.35 -#include "ns3/header.h"
    2.36 -#include "ns3/buffer.h"
    2.37 -
    2.38 -namespace ns3 {
    2.39 -
    2.40 -/* Forward declare objects */
    2.41 -class PbbPacket;
    2.42 -class PbbMessage;
    2.43 -class PbbAddressBlock;
    2.44 -class PbbTlvBlock;
    2.45 -class PbbAddressTlvBlock;
    2.46 -class PbbTlv;
    2.47 -class PbbAddressTlv;
    2.48 -
    2.49 -/** Used in Messages to determine whether it contains IPv4 or IPv6 addresses */
    2.50 -enum PbbAddressLength {
    2.51 -  IPV4 = 3,
    2.52 -  IPV6 = 15,
    2.53 -};
    2.54 -
    2.55 -/**
    2.56 - * \brief A block of Packet or PbbMessage TLVs.
    2.57 - *
    2.58 - * Acts similar to a C++ STL container.  Should not be used for Address TLVs.
    2.59 - */
    2.60 -class PbbTlvBlock
    2.61 -{
    2.62 -public:
    2.63 -  typedef std::list< Ptr<PbbTlv> >::iterator Iterator;
    2.64 -  typedef std::list< Ptr<PbbTlv> >::const_iterator ConstIterator;
    2.65 -
    2.66 -  /**
    2.67 -   * \return an iterator to the first TLV in this block.
    2.68 -   */
    2.69 -  Iterator Begin (void);
    2.70 -
    2.71 -  /**
    2.72 -   * \return a const iterator to the first TLV in this block.
    2.73 -   */
    2.74 -  ConstIterator Begin (void) const;
    2.75 -
    2.76 -  /**
    2.77 -   * \return an iterator to the past-the-end element in this block.
    2.78 -   */
    2.79 -  Iterator End (void);
    2.80 -
    2.81 -  /**
    2.82 -   * \return a const iterator to the past-the-end element in this block.
    2.83 -   */
    2.84 -  ConstIterator End (void) const;
    2.85 -
    2.86 -  /**
    2.87 -   * \return the number of TLVs in this block.
    2.88 -   */
    2.89 -  int Size (void) const;
    2.90 -
    2.91 -  /**
    2.92 -   * \return true if there are no TLVs in this block, false otherwise.
    2.93 -   */
    2.94 -  bool Empty (void) const;
    2.95 -
    2.96 -  /**
    2.97 -   * \return a smart pointer to the first TLV in this block.
    2.98 -   */
    2.99 -  Ptr<PbbTlv> Front (void) const;
   2.100 -
   2.101 -  /**
   2.102 -   * \return a smart pointer to the last TLV in this block.
   2.103 -   */
   2.104 -  Ptr<PbbTlv> Back (void) const;
   2.105 -
   2.106 -  /**
   2.107 -   * \brief Prepends a TLV to the front of this block.
   2.108 -   * \param tlv a smart pointer to the TLV to prepend.
   2.109 -   */
   2.110 -  void PushFront (Ptr<PbbTlv> tlv);
   2.111 -
   2.112 -  /**
   2.113 -   * \brief Removes a TLV from the front of this block.
   2.114 -   */
   2.115 -  void PopFront (void);
   2.116 -
   2.117 -  /**
   2.118 -   * \brief Appends a TLV to the back of this block.
   2.119 -   * \param tlv a smart pointer to the TLV to append.
   2.120 -   */
   2.121 -  void PushBack (Ptr<PbbTlv> tlv);
   2.122 -
   2.123 -  /**
   2.124 -   * \brief Removes a TLV from the back of this block.
   2.125 -   */
   2.126 -  void PopBack (void);
   2.127 -
   2.128 -  /**
   2.129 -   * \brief Inserts a TLV at the specified position in this block.
   2.130 -   * \param position an Iterator pointing to the position in this block to
   2.131 -   *        insert the TLV.
   2.132 -   * \param tlv a smart pointer to the TLV to insert.
   2.133 -   * \return An iterator pointing to the newly inserted TLV.
   2.134 -   */
   2.135 -  Iterator Insert (Iterator position, const Ptr<PbbTlv> tlv);
   2.136 -
   2.137 -  /**
   2.138 -   * \brief Removes the TLV at the specified position.
   2.139 -   * \param position an Iterator pointing to the TLV to erase.
   2.140 -   * \return an iterator pointing to the next TLV in the block.
   2.141 -   */
   2.142 -  Iterator Erase (Iterator position);
   2.143 -
   2.144 -  /**
   2.145 -   * \brief Removes all TLVs from [first, last) (includes first, not includes
   2.146 -   *        last).
   2.147 -   * \param first an Iterator pointing to the first TLV to erase (inclusive).
   2.148 -   * \param last an Iterator pointing to the element past the last TLV to erase.
   2.149 -   * \return an iterator pointing to the next TLV in the block.
   2.150 -   */
   2.151 -  Iterator Erase (Iterator first, Iterator last);
   2.152 -
   2.153 -  /**
   2.154 -   * \brief Removes all TLVs from this block.
   2.155 -   */
   2.156 -  void Clear (void);
   2.157 -
   2.158 -  /**
   2.159 -   * \return The size (in bytes) needed to serialize this block.
   2.160 -   */
   2.161 -  uint32_t GetSerializedSize (void) const;
   2.162 -
   2.163 -  /**
   2.164 -   * \brief Serializes this block into the specified buffer.
   2.165 -   * \param start a reference to the point in a buffer to begin serializing.
   2.166 -   *
   2.167 -   * Users should not need to call this.  Blocks will be serialized by their
   2.168 -   * containing packet.
   2.169 -   */
   2.170 -  void Serialize (Buffer::Iterator &start) const;
   2.171 -
   2.172 -  /**
   2.173 -   * \brief Deserializes a block from the specified buffer.
   2.174 -   * \param start a reference to the point in a buffer to begin deserializing.
   2.175 -   *
   2.176 -   * Users should not need to call this.  Blocks will be deserialized by their
   2.177 -   * containing packet.
   2.178 -   */
   2.179 -  void Deserialize (Buffer::Iterator &start);
   2.180 -
   2.181 -  /**
   2.182 -   * \brief Pretty-prints the contents of this block.
   2.183 -   * \param os a stream object to print to.
   2.184 -   */
   2.185 -  void Print (std::ostream &os) const;
   2.186 -
   2.187 -  /**
   2.188 -   * \brief Pretty-prints the contents of this block, with specified indentation.
   2.189 -   * \param os a stream object to print to.
   2.190 -   * \param level level of indentation.
   2.191 -   *
   2.192 -   * This probably never needs to be called by users.  This is used when
   2.193 -   * recursively printing sub-objects.
   2.194 -   */
   2.195 -  void Print (std::ostream &os, int level) const;
   2.196 -
   2.197 -  bool operator== (const PbbTlvBlock &other) const;
   2.198 -  bool operator!= (const PbbTlvBlock &other) const;
   2.199 -
   2.200 -private:
   2.201 -  std::list< Ptr<PbbTlv> > m_tlvList;
   2.202 -};
   2.203 -
   2.204 -/**
   2.205 - * \brief A block of Address TLVs.
   2.206 - *
   2.207 - * Acts similar to a C++ STL container.
   2.208 - */
   2.209 -class PbbAddressTlvBlock
   2.210 -{
   2.211 -public:
   2.212 -  typedef std::list< Ptr<PbbAddressTlv> >::iterator Iterator;
   2.213 -  typedef std::list< Ptr<PbbAddressTlv> >::const_iterator ConstIterator;
   2.214 -
   2.215 -  /**
   2.216 -   * \return an iterator to the first Address TLV in this block.
   2.217 -   */
   2.218 -  Iterator Begin (void);
   2.219 -
   2.220 -  /**
   2.221 -   * \return a const iterator to the first Address TLV in this block.
   2.222 -   */
   2.223 -  ConstIterator Begin (void) const;
   2.224 -
   2.225 -  /**
   2.226 -   * \return an iterator to the past-the-end element in this block.
   2.227 -   */
   2.228 -  Iterator End (void);
   2.229 -
   2.230 -  /**
   2.231 -   * \return a const iterator to the past-the-end element in this block.
   2.232 -   */
   2.233 -  ConstIterator End (void) const;
   2.234 -
   2.235 -  /**
   2.236 -   * \return the number of Address TLVs in this block.
   2.237 -   */
   2.238 -  int Size (void) const;
   2.239 -
   2.240 -  /**
   2.241 -   * \return true if there are no Address TLVs in this block, false otherwise.
   2.242 -   */
   2.243 -  bool Empty (void) const;
   2.244 -
   2.245 -  /**
   2.246 -   * \return the first Address TLV in this block.
   2.247 -   */
   2.248 -  Ptr<PbbAddressTlv> Front (void) const;
   2.249 -
   2.250 -  /**
   2.251 -   * \return the last AddressTLV in this block.
   2.252 -   */
   2.253 -  Ptr<PbbAddressTlv> Back (void) const;
   2.254 -
   2.255 -  /**
   2.256 -   * \brief Prepends an Address TLV to the front of this block.
   2.257 -   * \param tlv a smart pointer to the Address TLV to prepend.
   2.258 -   */
   2.259 -  void PushFront (Ptr<PbbAddressTlv> tlv);
   2.260 -
   2.261 -  /**
   2.262 -   * \brief Removes an AddressTLV from the front of this block.
   2.263 -   */
   2.264 -  void PopFront (void);
   2.265 -
   2.266 -  /**
   2.267 -   * \brief Appends an Address TLV to the back of this block.
   2.268 -   * \param tlv a smart pointer to the Address TLV to append.
   2.269 -   */
   2.270 -  void PushBack (Ptr<PbbAddressTlv> tlv);
   2.271 -
   2.272 -  /**
   2.273 -   * \brief Removes an Address TLV from the back of this block.
   2.274 -   */
   2.275 -  void PopBack (void);
   2.276 -
   2.277 -  /**
   2.278 -   * \brief Inserts an Address TLV at the specified position in this block.
   2.279 -   * \param position an Iterator pointing to the position in this block to
   2.280 -   *        insert the Address TLV.
   2.281 -   * \param tlv a smart pointer to the Address TLV to insert.
   2.282 -   * \return An iterator pointing to the newly inserted Address TLV.
   2.283 -   */
   2.284 -  Iterator Insert (Iterator position, const Ptr<PbbAddressTlv> tlv);
   2.285 -
   2.286 -  /**
   2.287 -   * \brief Removes the Address TLV at the specified position.
   2.288 -   * \param position an Iterator pointing to the Address TLV to erase.
   2.289 -   * \return an iterator pointing to the next Address TLV in the block.
   2.290 -   */
   2.291 -  Iterator Erase (Iterator position);
   2.292 -
   2.293 -  /**
   2.294 -   * \brief Removes all Address TLVs from [first, last) (includes first, not
   2.295 -   *        includes last).
   2.296 -   * \param first an Iterator pointing to the first Address TLV to erase
   2.297 -   *        (inclusive).
   2.298 -   * \param last an Iterator pointing to the element past the last Address TLV
   2.299 -   *        to erase.
   2.300 -   * \return an iterator pointing to the next Address TLV in the block.
   2.301 -   */
   2.302 -  Iterator Erase (Iterator first, Iterator last);
   2.303 -
   2.304 -  /**
   2.305 -   * \brief Removes all Address TLVs from this block.
   2.306 -   */
   2.307 -  void Clear (void);
   2.308 -
   2.309 -  /**
   2.310 -   * \return The size (in bytes) needed to serialize this block.
   2.311 -   */
   2.312 -  uint32_t GetSerializedSize (void) const;
   2.313 -
   2.314 -  /**
   2.315 -   * \brief Serializes this block into the specified buffer.
   2.316 -   * \param start a reference to the point in a buffer to begin serializing.
   2.317 -   *
   2.318 -   * Users should not need to call this.  Blocks will be serialized by their
   2.319 -   * containing packet.
   2.320 -   */
   2.321 -  void Serialize (Buffer::Iterator &start) const;
   2.322 -
   2.323 -  /**
   2.324 -   * \brief Deserializes a block from the specified buffer.
   2.325 -   * \param start a reference to the point in a buffer to begin deserializing.
   2.326 -   *
   2.327 -   * Users should not need to call this.  Blocks will be deserialized by their
   2.328 -   * containing packet.
   2.329 -   */
   2.330 -  void Deserialize (Buffer::Iterator &start);
   2.331 -
   2.332 -  /**
   2.333 -   * \brief Pretty-prints the contents of this block.
   2.334 -   * \param os a stream object to print to.
   2.335 -   */
   2.336 -  void Print (std::ostream &os) const;
   2.337 -
   2.338 -  /**
   2.339 -   * \brief Pretty-prints the contents of this block, with specified indentation.
   2.340 -   * \param os a stream object to print to.
   2.341 -   * \param level level of indentation.
   2.342 -   *
   2.343 -   * This probably never needs to be called by users.  This is used when
   2.344 -   * recursively printing sub-objects.
   2.345 -   */
   2.346 -  void Print (std::ostream &os, int level) const;
   2.347 -
   2.348 -  bool operator== (const PbbAddressTlvBlock &other) const;
   2.349 -  bool operator!= (const PbbAddressTlvBlock &other) const;
   2.350 -
   2.351 -private:
   2.352 -  std::list< Ptr<PbbAddressTlv> > m_tlvList;
   2.353 -};
   2.354 -
   2.355 -/**
   2.356 - * \brief Main PacketBB Packet object.
   2.357 - *
   2.358 - * See: http://tools.ietf.org/html/rfc5444 for details.
   2.359 - */
   2.360 -class PbbPacket : public Header
   2.361 -{
   2.362 -public:
   2.363 -  typedef std::list< Ptr<PbbTlv> >::iterator TlvIterator;
   2.364 -  typedef std::list< Ptr<PbbTlv> >::const_iterator ConstTlvIterator;
   2.365 -  typedef std::list< Ptr<PbbMessage> >::iterator MessageIterator;
   2.366 -  typedef std::list< Ptr<PbbMessage> >::const_iterator ConstMessageIterator;
   2.367 -
   2.368 -  PbbPacket (void);
   2.369 -
   2.370 -  /**
   2.371 -   * \return the version of PacketBB that constructed this packet.
   2.372 -   *
   2.373 -   * This will always return 0 for packets constructed using this API.
   2.374 -   */
   2.375 -  uint8_t GetVersion (void) const;
   2.376 -
   2.377 -  /**
   2.378 -   * \brief Sets the sequence number of this packet.
   2.379 -   * \param number the sequence number.
   2.380 -   */
   2.381 -  void SetSequenceNumber (uint16_t number);
   2.382 -
   2.383 -  /**
   2.384 -   * \return the sequence number of this packet.
   2.385 -   *
   2.386 -   * Calling this while HasSequenceNumber is False is undefined.  Make sure you
   2.387 -   * check it first.  This will be checked by an assert in debug builds.
   2.388 -   */
   2.389 -  uint16_t GetSequenceNumber (void) const;
   2.390 -
   2.391 -  /**
   2.392 -   * \brief Tests whether or not this packet has a sequence number.
   2.393 -   * \return true if this packet has a sequence number, false otherwise.
   2.394 -   *
   2.395 -   * This should be called before calling GetSequenceNumber to make sure there
   2.396 -   * actually is one.
   2.397 -   */
   2.398 -  bool HasSequenceNumber (void) const;
   2.399 -
   2.400 -  /* Manipulating Packet TLVs */
   2.401 -
   2.402 -  /**
   2.403 -   * \return an iterator to the first Packet TLV in this packet.
   2.404 -   */
   2.405 -  TlvIterator TlvBegin (void);
   2.406 -
   2.407 -  /**
   2.408 -   * \return a const iterator to the first Packet TLV in this packet.
   2.409 -   */
   2.410 -  ConstTlvIterator TlvBegin (void) const;
   2.411 -
   2.412 -  /**
   2.413 -   * \return an iterator to the past-the-end element in this packet TLV block.
   2.414 -   */
   2.415 -  TlvIterator TlvEnd (void);
   2.416 -
   2.417 -  /**
   2.418 -   * \return a const iterator to the past-the-end element in this packet TLV
   2.419 -   *         block.
   2.420 -   */
   2.421 -  ConstTlvIterator TlvEnd (void) const;
   2.422 -
   2.423 -  /**
   2.424 -   * \return the number of packet TLVs in this packet.
   2.425 -   */
   2.426 -  int TlvSize (void) const;
   2.427 -
   2.428 -  /**
   2.429 -   * \return true if there are no packet TLVs in this packet, false otherwise.
   2.430 -   */
   2.431 -  bool TlvEmpty (void) const;
   2.432 -
   2.433 -  /**
   2.434 -   * \return a smart pointer to the first packet TLV in this packet.
   2.435 -   */
   2.436 -  Ptr<PbbTlv> TlvFront (void);
   2.437 -
   2.438 -  /**
   2.439 -   * \return a const smart pointer to the first packet TLV in this packet.
   2.440 -   */
   2.441 -  const Ptr<PbbTlv> TlvFront (void) const;
   2.442 -
   2.443 -  /**
   2.444 -   * \return a smart pointer to the last packet TLV in this packet.
   2.445 -   */
   2.446 -  Ptr<PbbTlv> TlvBack (void);
   2.447 -
   2.448 -  /**
   2.449 -   * \return a const smart pointer to the last packet TLV in this packet.
   2.450 -   */
   2.451 -  const Ptr<PbbTlv> TlvBack (void) const;
   2.452 -
   2.453 -  /**
   2.454 -   * \brief Prepends a packet TLV to the front of this packet.
   2.455 -   * \param tlv a smart pointer to the packet TLV to prepend.
   2.456 -   */
   2.457 -  void TlvPushFront (Ptr<PbbTlv> tlv);
   2.458 -
   2.459 -  /**
   2.460 -   * \brief Removes a packet TLV from the front of this packet.
   2.461 -   */
   2.462 -  void TlvPopFront (void);
   2.463 -
   2.464 -  /**
   2.465 -   * \brief Appends a packet TLV to the back of this packet.
   2.466 -   * \param tlv a smart pointer to the packet TLV to append.
   2.467 -   */
   2.468 -  void TlvPushBack (Ptr<PbbTlv> tlv);
   2.469 -
   2.470 -  /**
   2.471 -   * \brief Removes a packet TLV from the back of this block.
   2.472 -   */
   2.473 -  void TlvPopBack (void);
   2.474 -
   2.475 -  /**
   2.476 -   * \brief Removes the packet TLV at the specified position.
   2.477 -   * \param position an Iterator pointing to the packet TLV to erase.
   2.478 -   * \return an iterator pointing to the next packet TLV in the block.
   2.479 -   */
   2.480 -  TlvIterator Erase (TlvIterator position);
   2.481 -
   2.482 -  /**
   2.483 -   * \brief Removes all packet TLVs from [first, last) (includes first, not
   2.484 -   *        includes last).
   2.485 -   * \param first an Iterator pointing to the first packet TLV to erase
   2.486 -   *        (inclusive).
   2.487 -   * \param last an Iterator pointing to the element past the last packet TLV
   2.488 -   *        to erase.
   2.489 -   * \return an iterator pointing to the next packet TLV in the block.
   2.490 -   */
   2.491 -  TlvIterator Erase (TlvIterator first, TlvIterator last);
   2.492 -
   2.493 -  /**
   2.494 -   * \brief Removes all packet TLVs from this packet.
   2.495 -   */
   2.496 -  void TlvClear (void);
   2.497 -
   2.498 -  /* Manipulating Packet Messages */
   2.499 -
   2.500 -  /**
   2.501 -   * \return an iterator to the first message in this packet.
   2.502 -   */
   2.503 -  MessageIterator MessageBegin (void);
   2.504 -
   2.505 -  /**
   2.506 -   * \return a const iterator to the first message in this packet.
   2.507 -   */
   2.508 -  ConstMessageIterator MessageBegin (void) const;
   2.509 -
   2.510 -  /**
   2.511 -   * \return an iterator to the past-the-end element in this message block.
   2.512 -   */
   2.513 -  MessageIterator MessageEnd (void);
   2.514 -
   2.515 -  /**
   2.516 -   * \return a const iterator to the past-the-end element in this message
   2.517 -   *         block.
   2.518 -   */
   2.519 -  ConstMessageIterator MessageEnd (void) const;
   2.520 -
   2.521 -  /**
   2.522 -   * \return the number of messages in this packet.
   2.523 -   */
   2.524 -  int MessageSize (void) const;
   2.525 -
   2.526 -  /**
   2.527 -   * \return true if there are no messages in this packet, false otherwise.
   2.528 -   */
   2.529 -  bool MessageEmpty (void) const;
   2.530 -
   2.531 -  /**
   2.532 -   * \return a smart pointer to the first message in this packet.
   2.533 -   */
   2.534 -  Ptr<PbbMessage> MessageFront (void);
   2.535 -
   2.536 -  /**
   2.537 -   * \return a cosnt smart pointer to the first message in this packet.
   2.538 -   */
   2.539 -  const Ptr<PbbMessage> MessageFront (void) const;
   2.540 -
   2.541 -  /**
   2.542 -   * \return a smart pointer to the last message in this packet.
   2.543 -   */
   2.544 -  Ptr<PbbMessage> MessageBack (void);
   2.545 -
   2.546 -  /**
   2.547 -   * \return a cosnt smart pointer to the last message in this packet.
   2.548 -   */
   2.549 -  const Ptr<PbbMessage> MessageBack (void) const;
   2.550 -
   2.551 -  /**
   2.552 -   * \brief Prepends a message to the front of this packet.
   2.553 -   * \param message a smart pointer to the message to prepend.
   2.554 -   */
   2.555 -  void MessagePushFront (Ptr<PbbMessage> message);
   2.556 -
   2.557 -  /**
   2.558 -   * \brief Removes a message from the front of this packet.
   2.559 -   */
   2.560 -  void MessagePopFront (void);
   2.561 -
   2.562 -  /**
   2.563 -   * \brief Appends a message to the back of this packet.
   2.564 -   * \param message a smart pointer to the message to append.
   2.565 -   */
   2.566 -  void MessagePushBack (Ptr<PbbMessage> message);
   2.567 -
   2.568 -  /**
   2.569 -   * \brief Removes a message from the back of this packet.
   2.570 -   */
   2.571 -  void MessagePopBack (void);
   2.572 -
   2.573 -  /**
   2.574 -   * \brief Removes the message at the specified position.
   2.575 -   * \param position an Iterator pointing to the message to erase.
   2.576 -   * \return an iterator pointing to the next message in the packet.
   2.577 -   */
   2.578 -  MessageIterator Erase (MessageIterator position);
   2.579 -
   2.580 -  /**
   2.581 -   * \brief Removes all messages from [first, last) (includes first, not
   2.582 -   *        includes last).
   2.583 -   * \param first an Iterator pointing to the first message to erase (inclusive).
   2.584 -   * \param last an Iterator pointing to the element past the last message to erase.
   2.585 -   * \return an iterator pointing to the next message in the block.
   2.586 -   */
   2.587 -  MessageIterator Erase (MessageIterator first, MessageIterator last);
   2.588 -
   2.589 -  /**
   2.590 -   * \brief Removes all messages from this packet.
   2.591 -   */
   2.592 -  void MessageClear (void);
   2.593 -
   2.594 -  /* Smart pointer methods */
   2.595 -  void Ref (void) const;
   2.596 -  void Unref (void) const;
   2.597 -
   2.598 -  /* Methods implemented by all headers */
   2.599 -  static TypeId GetTypeId (void);
   2.600 -  virtual TypeId GetInstanceTypeId (void) const;
   2.601 -
   2.602 -  /**
   2.603 -   * \return The size (in bytes) needed to serialize this packet.
   2.604 -   */
   2.605 -  virtual uint32_t GetSerializedSize (void) const;
   2.606 -
   2.607 -  /**
   2.608 -   * \brief Serializes this packet into the specified buffer.
   2.609 -   * \param start a reference to the point in a buffer to begin serializing.
   2.610 -   */
   2.611 -  virtual void Serialize (Buffer::Iterator start) const;
   2.612 -
   2.613 -  /**
   2.614 -   * \brief Deserializes a packet from the specified buffer.
   2.615 -   * \return the number of bytes deserialized
   2.616 -   *
   2.617 -   * If this returns a number smaller than the total number of bytes in the
   2.618 -   * buffer, there was an error.
   2.619 -   */
   2.620 -  virtual uint32_t Deserialize (Buffer::Iterator start);
   2.621 -
   2.622 -  /**
   2.623 -   * \brief Pretty-prints the contents of this block.
   2.624 -   * \param os a stream object to print to.
   2.625 -   */
   2.626 -  virtual void Print (std::ostream &os) const;
   2.627 -
   2.628 -  bool operator== (const PbbPacket &other) const;
   2.629 -  bool operator!= (const PbbPacket &other) const;
   2.630 -
   2.631 -protected:
   2.632 -  void SerializePacketTlv (Buffer::Iterator &start) const;
   2.633 -
   2.634 -private:
   2.635 -  PbbTlvBlock m_tlvList;
   2.636 -  std::list< Ptr<PbbMessage> > m_messageList;
   2.637 -
   2.638 -  uint8_t m_version;
   2.639 -
   2.640 -  bool m_hasseqnum;
   2.641 -  uint16_t m_seqnum;
   2.642 -
   2.643 -  mutable uint32_t m_refCount;
   2.644 -};
   2.645 -
   2.646 -/**
   2.647 - * \brief A message within a PbbPacket packet.
   2.648 - *
   2.649 - * There may be any number of messages in one PbbPacket packet.
   2.650 - * This is a pure virutal base class, you should instantiate either PbbMessageIpv4
   2.651 - * or PbbMessageIpv6.
   2.652 - */
   2.653 -class PbbMessage
   2.654 -{
   2.655 -public:
   2.656 -  typedef std::list< Ptr<PbbTlv> >::iterator TlvIterator;
   2.657 -  typedef std::list< Ptr<PbbTlv> >::const_iterator ConstTlvIterator;
   2.658 -  typedef std::list< Ptr<PbbAddressBlock> >::iterator AddressBlockIterator;
   2.659 -  typedef std::list< Ptr<PbbAddressBlock> >::const_iterator ConstAddressBlockIterator;
   2.660 -
   2.661 -  PbbMessage (void);
   2.662 -
   2.663 -  /**
   2.664 -   * \brief Sets the type for this message.
   2.665 -   * \param type the type to set.
   2.666 -   */
   2.667 -  void SetType (uint8_t type);
   2.668 -
   2.669 -  /**
   2.670 -   * \return the type assigned to this packet
   2.671 -   */
   2.672 -  uint8_t GetType (void) const;
   2.673 -
   2.674 -  /**
   2.675 -   * \brief Sets the address for the node that created this packet.
   2.676 -   * \param address the originator address.
   2.677 -   */
   2.678 -  void SetOriginatorAddress (Address address);
   2.679 -
   2.680 -  /**
   2.681 -   * \return the address of the node that created this packet.
   2.682 -   *
   2.683 -   * Calling this while HasOriginatorAddress is False is undefined.  Make sure
   2.684 -   * you check it first.  This will be checked by an assert in debug builds.
   2.685 -   */
   2.686 -  Address GetOriginatorAddress (void) const;
   2.687 -
   2.688 -  /**
   2.689 -   * \brief Tests whether or not this message has an originator address.
   2.690 -   * \return true if this message has an originator address, false otherwise.
   2.691 -   */
   2.692 -  bool HasOriginatorAddress (void) const;
   2.693 -
   2.694 -  /**
   2.695 -   * \brief Sets the maximum number of hops this message should travel
   2.696 -   * \param hoplimit the limit to set
   2.697 -   */
   2.698 -  void SetHopLimit (uint8_t hoplimit);
   2.699 -
   2.700 -  /**
   2.701 -   * \return the maximum number of hops this message should travel.
   2.702 -   *
   2.703 -   * Calling this while HasHopLimit is False is undefined.  Make sure you check
   2.704 -   * it first.  This will be checked by an assert in debug builds.
   2.705 -   */
   2.706 -  uint8_t GetHopLimit (void) const;
   2.707 -
   2.708 -  /**
   2.709 -   * \brief Tests whether or not this message has a hop limit.
   2.710 -   * \return true if this message has a hop limit, false otherwise.
   2.711 -   *
   2.712 -   * If this is set, messages should not hop further than this limit.
   2.713 -   */
   2.714 -  bool HasHopLimit (void) const;
   2.715 -
   2.716 -  /**
   2.717 -   * \brief Sets the current number of hops this message has traveled.
   2.718 -   * \param hopcount the current number of hops
   2.719 -   */
   2.720 -  void SetHopCount (uint8_t hopcount);
   2.721 -
   2.722 -  /**
   2.723 -   * \return the current number of hops this message has traveled.
   2.724 -   *
   2.725 -   * Calling this while HasHopCount is False is undefined.  Make sure you check
   2.726 -   * it first.  This will be checked by an assert in debug builds.
   2.727 -   */
   2.728 -  uint8_t GetHopCount (void) const;
   2.729 -
   2.730 -  /**
   2.731 -   * \brief Tests whether or not this message has a hop count.
   2.732 -   * \return true if this message has a hop limit, false otherwise.
   2.733 -   */
   2.734 -  bool HasHopCount (void) const;
   2.735 -
   2.736 -  /**
   2.737 -   * \brief Sets the sequence number of this message.
   2.738 -   * \param seqnum the sequence number to set.
   2.739 -   */
   2.740 -  void SetSequenceNumber (uint16_t seqnum);
   2.741 -
   2.742 -  /**
   2.743 -   * \return the sequence number of this message.
   2.744 -   *
   2.745 -   * Calling this while HasSequenceNumber is False is undefined.  Make sure you
   2.746 -   * check it first.  This will be checked by an assert in debug builds.
   2.747 -   */
   2.748 -  uint16_t GetSequenceNumber (void) const;
   2.749 -
   2.750 -  /**
   2.751 -   * \brief Tests whether or not this message has a sequence number.
   2.752 -   * \return true if this message has a sequence number, false otherwise.
   2.753 -   */
   2.754 -  bool HasSequenceNumber (void) const;
   2.755 -
   2.756 -  /* Manipulating PbbMessage TLVs */
   2.757 -
   2.758 -  /**
   2.759 -   * \return an iterator to the first message TLV in this message.
   2.760 -   */
   2.761 -  TlvIterator TlvBegin ();
   2.762 -
   2.763 -  /**
   2.764 -   * \return a const iterator to the first message TLV in this message.
   2.765 -   */
   2.766 -  ConstTlvIterator TlvBegin () const;
   2.767 -
   2.768 -  /**
   2.769 -   * \return an iterator to the past-the-end message TLV element in this
   2.770 -   *         message.
   2.771 -   */
   2.772 -  TlvIterator TlvEnd ();
   2.773 -
   2.774 -  /**
   2.775 -   * \return a const iterator to the past-the-end message TLV element in this
   2.776 -   *         message.
   2.777 -   */
   2.778 -  ConstTlvIterator TlvEnd () const;
   2.779 -
   2.780 -  /**
   2.781 -   * \return the number of message TLVs in this message.
   2.782 -   */
   2.783 -  int TlvSize (void) const;
   2.784 -
   2.785 -  /**
   2.786 -   * \return true if there are no message TLVs in this message, false otherwise.
   2.787 -   */
   2.788 -  bool TlvEmpty (void) const;
   2.789 -
   2.790 -  /**
   2.791 -   * \return a smart pointer to the first message TLV in this message.
   2.792 -   */
   2.793 -  Ptr<PbbTlv> TlvFront (void);
   2.794 -
   2.795 -  /**
   2.796 -   * \return a const smart pointer to the first message TLV in this message.
   2.797 -   */
   2.798 -  const Ptr<PbbTlv> TlvFront (void) const;
   2.799 -
   2.800 -  /**
   2.801 -   * \return a smart pointer to the last message TLV in this message.
   2.802 -   */
   2.803 -  Ptr<PbbTlv> TlvBack (void);
   2.804 -
   2.805 -  /**
   2.806 -   * \return a const smart pointer to the last message TLV in this message.
   2.807 -   */
   2.808 -  const Ptr<PbbTlv> TlvBack (void) const;
   2.809 -
   2.810 -  /**
   2.811 -   * \brief Prepends a message TLV to the front of this message.
   2.812 -   * \param tlv a smart pointer to the message TLV to prepend.
   2.813 -   */
   2.814 -  void TlvPushFront (Ptr<PbbTlv> tlv);
   2.815 -
   2.816 -  /**
   2.817 -   * \brief Removes a message TLV from the front of this message.
   2.818 -   */
   2.819 -  void TlvPopFront (void);
   2.820 -
   2.821 -  /**
   2.822 -   * \brief Appends a message TLV to the back of this message.
   2.823 -   * \param tlv a smart pointer to the message TLV to append.
   2.824 -   */
   2.825 -  void TlvPushBack (Ptr<PbbTlv> tlv);
   2.826 -
   2.827 -  /**
   2.828 -   * \brief Removes a message TLV from the back of this message.
   2.829 -   */
   2.830 -  void TlvPopBack (void);
   2.831 -
   2.832 -  /**
   2.833 -   * \brief Removes the message TLV at the specified position.
   2.834 -   * \param position an Iterator pointing to the message TLV to erase.
   2.835 -   * \return an iterator pointing to the next TLV in the block.
   2.836 -   */
   2.837 -  TlvIterator TlvErase (TlvIterator position);
   2.838 -
   2.839 -  /**
   2.840 -   * \brief Removes all message TLVs from [first, last) (includes first, not
   2.841 -   *        includes last).
   2.842 -   * \param first an Iterator pointing to the first message TLV to erase
   2.843 -   *        (inclusive).
   2.844 -   * \param last an Iterator pointing to the element past the last message TLV
   2.845 -   *        to erase.
   2.846 -   * \return an iterator pointing to the next message TLV in the message.
   2.847 -   */
   2.848 -  TlvIterator TlvErase (TlvIterator first, TlvIterator last);
   2.849 -
   2.850 -  /**
   2.851 -   * \brief Removes all message TLVs from this block.
   2.852 -   */
   2.853 -  void TlvClear (void);
   2.854 -
   2.855 -  /* Manipulating Address Block and Address TLV pairs */
   2.856 -
   2.857 -  /**
   2.858 -   * \return an iterator to the first address block in this message.
   2.859 -   */
   2.860 -  AddressBlockIterator AddressBlockBegin ();
   2.861 -
   2.862 -  /**
   2.863 -   * \return a const iterator to the first address block in this message.
   2.864 -   */
   2.865 -  ConstAddressBlockIterator AddressBlockBegin () const;
   2.866 -
   2.867 -  /**
   2.868 -   * \return an iterator to the past-the-end address block element in this
   2.869 -   *         message.
   2.870 -   */
   2.871 -  AddressBlockIterator AddressBlockEnd ();
   2.872 -
   2.873 -  /**
   2.874 -   * \return a const iterator to the past-the-end address block element in this
   2.875 -   *         message.
   2.876 -   */
   2.877 -  ConstAddressBlockIterator AddressBlockEnd () const;
   2.878 -
   2.879 -  /**
   2.880 -   * \return the number of address blocks in this message.
   2.881 -   */
   2.882 -  int AddressBlockSize (void) const;
   2.883 -
   2.884 -  /**
   2.885 -   * \return true if there are no address blocks in this message, false
   2.886 -   *         otherwise.
   2.887 -   */
   2.888 -  bool AddressBlockEmpty (void) const;
   2.889 -
   2.890 -  /**
   2.891 -   * \return a smart pointer to the first address block in this message.
   2.892 -   */
   2.893 -  Ptr<PbbAddressBlock> AddressBlockFront (void);
   2.894 -
   2.895 -  /**
   2.896 -   * \return a const smart pointer to the first address block in this message.
   2.897 -   */
   2.898 -  const Ptr<PbbAddressBlock> AddressBlockFront (void) const;
   2.899 -
   2.900 -  /**
   2.901 -   * \return a smart pointer to the last address block in this message.
   2.902 -   */
   2.903 -  Ptr<PbbAddressBlock> AddressBlockBack (void);
   2.904 -
   2.905 -  /**
   2.906 -   * \return a const smart pointer to the last address block in this message.
   2.907 -   */
   2.908 -  const Ptr<PbbAddressBlock> AddressBlockBack (void) const;
   2.909 -
   2.910 -  /**
   2.911 -   * \brief Prepends an address block to the front of this message.
   2.912 -   * \param block a smart pointer to the address block to prepend.
   2.913 -   */
   2.914 -  void AddressBlockPushFront (Ptr<PbbAddressBlock> block);
   2.915 -
   2.916 -  /**
   2.917 -   * \brief Removes an address block from the front of this message.
   2.918 -   */
   2.919 -  void AddressBlockPopFront (void);
   2.920 -
   2.921 -  /**
   2.922 -   * \brief Appends an address block to the front of this message.
   2.923 -   * \param block a smart pointer to the address block to append.
   2.924 -   */
   2.925 -  void AddressBlockPushBack (Ptr<PbbAddressBlock> block);
   2.926 -
   2.927 -  /**
   2.928 -   * \brief Removes an address block from the back of this message.
   2.929 -   */
   2.930 -  void AddressBlockPopBack (void);
   2.931 -
   2.932 -  /**
   2.933 -   * \brief Removes the address block at the specified position.
   2.934 -   * \param position an Iterator pointing to the address block to erase.
   2.935 -   * \return an iterator pointing to the next address block in the message.
   2.936 -   */
   2.937 -  AddressBlockIterator AddressBlockErase (AddressBlockIterator position);
   2.938 -
   2.939 -  /**
   2.940 -   * \brief Removes all address blocks from [first, last) (includes first, not
   2.941 -   *        includes last).
   2.942 -   * \param first an Iterator pointing to the first address block to erase
   2.943 -   *        (inclusive).
   2.944 -   * \param last an Iterator pointing to the element past the last address
   2.945 -   *        block to erase.
   2.946 -   * \return an iterator pointing to the next address block in the message.
   2.947 -   */
   2.948 -  AddressBlockIterator AddressBlockErase (AddressBlockIterator first,
   2.949 -      AddressBlockIterator last);
   2.950 -
   2.951 -  /**
   2.952 -   * \brief Removes all address blocks from this message.
   2.953 -   */
   2.954 -  void AddressBlockClear (void);
   2.955 -
   2.956 -  /* Smart pointer methods */
   2.957 -  void Ref (void) const;
   2.958 -  void Unref (void) const;
   2.959 -
   2.960 -  /**
   2.961 -   * \brief Deserializes a message, returning the correct object depending on
   2.962 -   *        whether it is an IPv4 message or an IPv6 message.
   2.963 -   * \param start a reference to the point in a buffer to begin deserializing.
   2.964 -   * \return A pointer to the deserialized message, or 0 on error.
   2.965 -   *
   2.966 -   * Users should not need to call this.  Blocks will be deserialized by their
   2.967 -   * containing packet.
   2.968 -   */
   2.969 -  static Ptr<PbbMessage> DeserializeMessage (Buffer::Iterator &start);
   2.970 -
   2.971 -  /**
   2.972 -   * \return The size (in bytes) needed to serialize this message.
   2.973 -   */
   2.974 -  uint32_t GetSerializedSize (void) const;
   2.975 -
   2.976 -  /**
   2.977 -   * \brief Serializes this message into the specified buffer.
   2.978 -   * \param start a reference to the point in a buffer to begin serializing.
   2.979 -   *
   2.980 -   * Users should not need to call this.  Blocks will be deserialized by their
   2.981 -   * containing packet.
   2.982 -   */
   2.983 -  void Serialize (Buffer::Iterator &start) const;
   2.984 -
   2.985 -  /**
   2.986 -   * \brief Deserializes a message from the specified buffer.
   2.987 -   * \param start a reference to the point in a buffer to begin deserializing.
   2.988 -   *
   2.989 -   * Users should not need to call this.  Blocks will be deserialized by their
   2.990 -   * containing packet.
   2.991 -   */
   2.992 -  void Deserialize (Buffer::Iterator &start);
   2.993 -
   2.994 -  /**
   2.995 -   * \brief Pretty-prints the contents of this message.
   2.996 -   * \param os a stream object to print to.
   2.997 -   */
   2.998 -  void Print (std::ostream &os) const;
   2.999 -
  2.1000 -  /**
  2.1001 -   * \brief Pretty-prints the contents of this message, with specified
  2.1002 -   *        indentation.
  2.1003 -   * \param os a stream object to print to.
  2.1004 -   * \param level level of indentation.
  2.1005 -   *
  2.1006 -   * This probably never needs to be called by users.  This is used when
  2.1007 -   * recursively printing sub-objects.
  2.1008 -   */
  2.1009 -  void Print (std::ostream &os, int level) const;
  2.1010 -
  2.1011 -  bool operator== (const PbbMessage &other) const;
  2.1012 -  bool operator!= (const PbbMessage &other) const;
  2.1013 -
  2.1014 -protected:
  2.1015 -  /* PbbMessage size in bytes - 1.
  2.1016 -   *
  2.1017 -   * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
  2.1018 -   */
  2.1019 -  virtual PbbAddressLength GetAddressLength (void) const = 0;
  2.1020 -
  2.1021 -  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const = 0;
  2.1022 -  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const = 0;
  2.1023 -  virtual void PrintOriginatorAddress (std::ostream &os) const = 0;
  2.1024 -
  2.1025 -  virtual Ptr<PbbAddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const = 0;
  2.1026 -
  2.1027 -private:
  2.1028 -  PbbTlvBlock m_tlvList;
  2.1029 -  std::list< Ptr<PbbAddressBlock> > m_addressBlockList;
  2.1030 -
  2.1031 -  uint8_t m_type;
  2.1032 -  PbbAddressLength m_addrSize;
  2.1033 -
  2.1034 -  bool m_hasOriginatorAddress;
  2.1035 -  Address m_originatorAddress;
  2.1036 -
  2.1037 -  bool m_hasHopLimit;
  2.1038 -  uint8_t m_hopLimit;
  2.1039 -
  2.1040 -  bool m_hasHopCount;
  2.1041 -  uint8_t m_hopCount;
  2.1042 -
  2.1043 -  bool m_hasSequenceNumber;
  2.1044 -  uint16_t m_sequenceNumber;
  2.1045 -
  2.1046 -  mutable uint32_t m_refCount;
  2.1047 -};
  2.1048 -
  2.1049 -/**
  2.1050 - * \brief Concrete IPv4 specific PbbMessage.
  2.1051 - *
  2.1052 - * This message will only contain IPv4 addresses.
  2.1053 - */
  2.1054 -class PbbMessageIpv4 : public PbbMessage {
  2.1055 -protected:
  2.1056 -  virtual PbbAddressLength GetAddressLength (void) const;
  2.1057 -
  2.1058 -  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const;
  2.1059 -  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const;
  2.1060 -  virtual void PrintOriginatorAddress (std::ostream &os) const;
  2.1061 -
  2.1062 -  virtual Ptr<PbbAddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const;
  2.1063 -};
  2.1064 -
  2.1065 -/**
  2.1066 - * \brief Concrete IPv6 specific PbbMessage class.
  2.1067 - *
  2.1068 - * This message will only contain IPv6 addresses.
  2.1069 - */
  2.1070 -class PbbMessageIpv6 : public PbbMessage {
  2.1071 -protected:
  2.1072 -  virtual PbbAddressLength GetAddressLength (void) const;
  2.1073 -
  2.1074 -  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const;
  2.1075 -  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const;
  2.1076 -  virtual void PrintOriginatorAddress (std::ostream &os) const;
  2.1077 -
  2.1078 -  virtual Ptr<PbbAddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const;
  2.1079 -};
  2.1080 -
  2.1081 -/**
  2.1082 - * \brief An Address Block and its associated Address TLV Blocks.
  2.1083 - *
  2.1084 - * This is a pure virtual base class, you should instantiate either
  2.1085 - * PbbAddressBlockIpv4 or PbbAddressBlockIpv6.
  2.1086 - */
  2.1087 -class PbbAddressBlock
  2.1088 -{
  2.1089 -public:
  2.1090 -  typedef std::list< Address >::iterator AddressIterator;
  2.1091 -  typedef std::list< Address >::const_iterator ConstAddressIterator;
  2.1092 -
  2.1093 -  typedef std::list<uint8_t>::iterator PrefixIterator;
  2.1094 -  typedef std::list<uint8_t>::const_iterator ConstPrefixIterator;
  2.1095 -
  2.1096 -  typedef PbbAddressTlvBlock::Iterator TlvIterator;
  2.1097 -  typedef PbbAddressTlvBlock::ConstIterator ConstTlvIterator;
  2.1098 -
  2.1099 -  PbbAddressBlock (void);
  2.1100 -
  2.1101 -  /* Manipulating the address block */
  2.1102 -
  2.1103 -  /**
  2.1104 -   * \return an iterator to the first address in this block.
  2.1105 -   */
  2.1106 -  AddressIterator AddressBegin (void);
  2.1107 -
  2.1108 -  /**
  2.1109 -   * \return a const iterator to the first address in this block.
  2.1110 -   */
  2.1111 -  ConstAddressIterator AddressBegin (void) const;
  2.1112 -
  2.1113 -  /**
  2.1114 -   * \return an iterator to the last address in this block.
  2.1115 -   */
  2.1116 -  AddressIterator AddressEnd (void);
  2.1117 -
  2.1118 -  /**
  2.1119 -   * \return a const iterator to the last address in this block.
  2.1120 -   */
  2.1121 -  ConstAddressIterator AddressEnd (void) const;
  2.1122 -
  2.1123 -  /**
  2.1124 -   * \return the number of addresses in this block.
  2.1125 -   */
  2.1126 -  int AddressSize (void) const;
  2.1127 -
  2.1128 -  /**
  2.1129 -   * \return true if there are no addresses in this block, false otherwise.
  2.1130 -   */
  2.1131 -  bool AddressEmpty (void) const;
  2.1132 -
  2.1133 -  /**
  2.1134 -   * \return the first address in this block.
  2.1135 -   */
  2.1136 -  Address AddressFront (void) const;
  2.1137 -
  2.1138 -  /**
  2.1139 -   * \return the last address in this block.
  2.1140 -   */
  2.1141 -  Address AddressBack (void) const;
  2.1142 -
  2.1143 -  /**
  2.1144 -   * \brief Prepends an address to the front of this block.
  2.1145 -   * \param address the address to prepend.
  2.1146 -   */
  2.1147 -  void AddressPushFront (Address address);
  2.1148 -
  2.1149 -  /**
  2.1150 -   * \brief Removes an address from the front of this block.
  2.1151 -   */
  2.1152 -  void AddressPopFront (void);
  2.1153 -
  2.1154 -  /**
  2.1155 -   * \brief Appends an address to the back of this block.
  2.1156 -   * \param address the address to append.
  2.1157 -   */
  2.1158 -  void AddressPushBack (Address address);
  2.1159 -
  2.1160 -  /**
  2.1161 -   * \brief Removes an address from the back of this block.
  2.1162 -   */
  2.1163 -  void AddressPopBack (void);
  2.1164 -
  2.1165 -  /**
  2.1166 -   * \brief Inserts an address at the specified position in this block.
  2.1167 -   * \param position an Iterator pointing to the position in this block to
  2.1168 -   *        insert the address.
  2.1169 -   * \param value the address to insert.
  2.1170 -   * \return An iterator pointing to the newly inserted address.
  2.1171 -   */
  2.1172 -  AddressIterator AddressInsert (AddressIterator position,
  2.1173 -      const Address value);
  2.1174 -
  2.1175 -  /**
  2.1176 -   * \brief Removes the address at the specified position.
  2.1177 -   * \param position an Iterator pointing to the address to erase.
  2.1178 -   * \return an iterator pointing to the next address in the block.
  2.1179 -   */
  2.1180 -  AddressIterator AddressErase (AddressIterator position);
  2.1181 -
  2.1182 -  /**
  2.1183 -   * \brief Removes all addresses from [first, last) (includes first, not
  2.1184 -   *        includes last).
  2.1185 -   * \param first an Iterator pointing to the first address to erase
  2.1186 -   *        (inclusive).
  2.1187 -   * \param last an Iterator pointing to the element past the last address to
  2.1188 -   *        erase.
  2.1189 -   * \return an iterator pointing to the next address in the block.
  2.1190 -   */
  2.1191 -  AddressIterator AddressErase (AddressIterator first, AddressIterator last);
  2.1192 -
  2.1193 -  /**
  2.1194 -   * \brief Removes all addresses from this block.
  2.1195 -   */
  2.1196 -  void AddressClear (void);
  2.1197 -
  2.1198 -  /* Prefix methods */
  2.1199 -
  2.1200 -  /**
  2.1201 -   * \return an iterator to the first prefix in this block.
  2.1202 -   */
  2.1203 -  PrefixIterator PrefixBegin (void);
  2.1204 -
  2.1205 -  /**
  2.1206 -   * \return a const iterator to the first prefix in this block.
  2.1207 -   */
  2.1208 -  ConstPrefixIterator PrefixBegin (void) const;
  2.1209 -
  2.1210 -  /**
  2.1211 -   * \return an iterator to the last prefix in this block.
  2.1212 -   */
  2.1213 -  PrefixIterator PrefixEnd (void);
  2.1214 -
  2.1215 -  /**
  2.1216 -   * \return a const iterator to the last prefix in this block.
  2.1217 -   */
  2.1218 -  ConstPrefixIterator PrefixEnd (void) const;
  2.1219 -
  2.1220 -  /**
  2.1221 -   * \return the number of prefixes in this block.
  2.1222 -   */
  2.1223 -  int PrefixSize (void) const;
  2.1224 -
  2.1225 -  /**
  2.1226 -   * \return true if there are no prefixes in this block, false otherwise.
  2.1227 -   */
  2.1228 -  bool PrefixEmpty (void) const;
  2.1229 -
  2.1230 -  /**
  2.1231 -   * \return the first prefix in this block.
  2.1232 -   */
  2.1233 -  uint8_t PrefixFront (void) const;
  2.1234 -
  2.1235 -  /**
  2.1236 -   * \return the last prefix in this block.
  2.1237 -   */
  2.1238 -  uint8_t PrefixBack (void) const;
  2.1239 -
  2.1240 -  /**
  2.1241 -   * \brief Prepends a prefix to the front of this block.
  2.1242 -   * \param prefix the prefix to prepend.
  2.1243 -   */
  2.1244 -  void PrefixPushFront (uint8_t prefix);
  2.1245 -
  2.1246 -  /**
  2.1247 -   * \brief Removes a prefix from the front of this block.
  2.1248 -   */
  2.1249 -  void PrefixPopFront (void);
  2.1250 -
  2.1251 -  /**
  2.1252 -   * \brief Appends a prefix to the back of this block.
  2.1253 -   * \param prefix the prefix to append.
  2.1254 -   */
  2.1255 -  void PrefixPushBack (uint8_t prefix);
  2.1256 -
  2.1257 -  /**
  2.1258 -   * \brief Removes a prefix from the back of this block.
  2.1259 -   */
  2.1260 -  void PrefixPopBack (void);
  2.1261 -
  2.1262 -  /**
  2.1263 -   * \brief Inserts a prefix at the specified position in this block.
  2.1264 -   * \param position an Iterator pointing to the position in this block to
  2.1265 -   *        insert the prefix.
  2.1266 -   * \param value the prefix to insert.
  2.1267 -   * \return An iterator pointing to the newly inserted prefix.
  2.1268 -   */
  2.1269 -  PrefixIterator PrefixInsert (PrefixIterator position, const uint8_t value);
  2.1270 -
  2.1271 -  /**
  2.1272 -   * \brief Removes the prefix at the specified position.
  2.1273 -   * \param position an Iterator pointing to the prefix to erase.
  2.1274 -   * \return an iterator pointing to the next prefix in the block.
  2.1275 -   */
  2.1276 -  PrefixIterator PrefixErase (PrefixIterator position);
  2.1277 -
  2.1278 -  /**
  2.1279 -   * \brief Removes all prefixes from [first, last) (includes first, not
  2.1280 -   *        includes last).
  2.1281 -   * \param first an Iterator pointing to the first prefix to erase
  2.1282 -   *        (inclusive).
  2.1283 -   * \param last an Iterator pointing to the element past the last prefix to
  2.1284 -   *        erase.
  2.1285 -   * \return an iterator pointing to the next prefix in the block.
  2.1286 -   */
  2.1287 -  PrefixIterator PrefixErase (PrefixIterator first, PrefixIterator last);
  2.1288 -
  2.1289 -  /**
  2.1290 -   * \brief Removes all prefixes from this block.
  2.1291 -   */
  2.1292 -  void PrefixClear (void);
  2.1293 -
  2.1294 -  /* Manipulating the TLV block */
  2.1295 -
  2.1296 -  /**
  2.1297 -   * \return an iterator to the first address TLV in this block.
  2.1298 -   */
  2.1299 -  TlvIterator TlvBegin (void);
  2.1300 -
  2.1301 -  /**
  2.1302 -   * \return a const iterator to the first address TLV in this block.
  2.1303 -   */
  2.1304 -  ConstTlvIterator TlvBegin (void) const;
  2.1305 -
  2.1306 -  /**
  2.1307 -   * \return an iterator to the last address TLV in this block.
  2.1308 -   */
  2.1309 -  TlvIterator TlvEnd (void);
  2.1310 -
  2.1311 -  /**
  2.1312 -   * \return a const iterator to the last address TLV in this block.
  2.1313 -   */
  2.1314 -  ConstTlvIterator TlvEnd (void) const;
  2.1315 -
  2.1316 -  /**
  2.1317 -   * \return the number of address TLVs in this block.
  2.1318 -   */
  2.1319 -  int TlvSize (void) const;
  2.1320 -
  2.1321 -  /**
  2.1322 -   * \return true if there are no address TLVs in this block, false otherwise.
  2.1323 -   */
  2.1324 -  bool TlvEmpty (void) const;
  2.1325 -
  2.1326 -  /**
  2.1327 -   * \return a smart pointer to the first address TLV in this block.
  2.1328 -   */
  2.1329 -  Ptr<PbbAddressTlv> TlvFront (void);
  2.1330 -
  2.1331 -  /**
  2.1332 -   * \return a const smart pointer to the first address TLV in this message.
  2.1333 -   */
  2.1334 -  const Ptr<PbbAddressTlv> TlvFront (void) const;
  2.1335 -
  2.1336 -  /**
  2.1337 -   * \return a smart pointer to the last address TLV in this message.
  2.1338 -   */
  2.1339 -  Ptr<PbbAddressTlv> TlvBack (void);
  2.1340 -
  2.1341 -  /**
  2.1342 -   * \return a const smart pointer to the last address TLV in this message.
  2.1343 -   */
  2.1344 -  const Ptr<PbbAddressTlv> TlvBack (void) const;
  2.1345 -
  2.1346 -  /**
  2.1347 -   * \brief Prepends an address TLV to the front of this message.
  2.1348 -   * \param address a smart pointer to the address TLV to prepend.
  2.1349 -   */
  2.1350 -  void TlvPushFront (Ptr<PbbAddressTlv> address);
  2.1351 -
  2.1352 -  /**
  2.1353 -   * \brief Removes an address TLV from the front of this message.
  2.1354 -   */
  2.1355 -  void TlvPopFront (void);
  2.1356 -
  2.1357 -  /**
  2.1358 -   * \brief Appends an address TLV to the back of this message.
  2.1359 -   * \param address a smart pointer to the address TLV to append.
  2.1360 -   */
  2.1361 -  void TlvPushBack (Ptr<PbbAddressTlv> address);
  2.1362 -
  2.1363 -  /**
  2.1364 -   * \brief Removes an address TLV from the back of this message.
  2.1365 -   */
  2.1366 -  void TlvPopBack (void);
  2.1367 -
  2.1368 -  /**
  2.1369 -   * \brief Inserts an address TLV at the specified position in this block.
  2.1370 -   * \param position an Iterator pointing to the position in this block to
  2.1371 -   *        insert the address TLV.
  2.1372 -   * \param value the prefix to insert.
  2.1373 -   * \return An iterator pointing to the newly inserted address TLV.
  2.1374 -   */
  2.1375 -  TlvIterator TlvInsert (TlvIterator position, const Ptr<PbbTlv> value);
  2.1376 -
  2.1377 -  /**
  2.1378 -   * \brief Removes the address TLV at the specified position.
  2.1379 -   * \param position an Iterator pointing to the address TLV to erase.
  2.1380 -   * \return an iterator pointing to the next address TLV in the block.
  2.1381 -   */
  2.1382 -  TlvIterator TlvErase (TlvIterator position);
  2.1383 -
  2.1384 -  /**
  2.1385 -   * \brief Removes all address TLVs from [first, last) (includes first, not
  2.1386 -   *        includes last).
  2.1387 -   * \param first an Iterator pointing to the first address TLV to erase
  2.1388 -   *        (inclusive).
  2.1389 -   * \param last an Iterator pointing to the element past the last address TLV
  2.1390 -   *        to erase.
  2.1391 -   * \return an iterator pointing to the next address TLV in the message.
  2.1392 -   */
  2.1393 -  TlvIterator TlvErase (TlvIterator first, TlvIterator last);
  2.1394 -
  2.1395 -  /**
  2.1396 -   * \brief Removes all address TLVs from this block.
  2.1397 -   */
  2.1398 -  void TlvClear (void);
  2.1399 -
  2.1400 -  /* Smart pointer methods */
  2.1401 -  void Ref (void) const;
  2.1402 -  void Unref (void) const;
  2.1403 -
  2.1404 -  /**
  2.1405 -   * \return The size (in bytes) needed to serialize this address block.
  2.1406 -   */
  2.1407 -  uint32_t GetSerializedSize (void) const;
  2.1408 -
  2.1409 -  /**
  2.1410 -   * \brief Serializes this address block into the specified buffer.
  2.1411 -   * \param start a reference to the point in a buffer to begin serializing.
  2.1412 -   *
  2.1413 -   * Users should not need to call this.  Blocks will be deserialized by their
  2.1414 -   * containing packet.
  2.1415 -   */
  2.1416 -  void Serialize (Buffer::Iterator &start) const;
  2.1417 -
  2.1418 -  /**
  2.1419 -   * \brief Deserializes an address block from the specified buffer.
  2.1420 -   * \param start a reference to the point in a buffer to begin deserializing.
  2.1421 -   *
  2.1422 -   * Users should not need to call this.  Blocks will be deserialized by their
  2.1423 -   * containing packet.
  2.1424 -   */
  2.1425 -  void Deserialize (Buffer::Iterator &start);
  2.1426 -
  2.1427 -  /**
  2.1428 -   * \brief Pretty-prints the contents of this address block.
  2.1429 -   * \param os a stream object to print to.
  2.1430 -   */
  2.1431 -  void Print (std::ostream &os) const;
  2.1432 -
  2.1433 -  /**
  2.1434 -   * \brief Pretty-prints the contents of this address block, with specified
  2.1435 -   *        indentation.
  2.1436 -   * \param os a stream object to print to.
  2.1437 -   * \param level level of indentation.
  2.1438 -   *
  2.1439 -   * This probably never needs to be called by users.  This is used when
  2.1440 -   * recursively printing sub-objects.
  2.1441 -   */
  2.1442 -  void Print (std::ostream &os, int level) const;
  2.1443 -
  2.1444 -  bool operator== (const PbbAddressBlock &other) const;
  2.1445 -  bool operator!= (const PbbAddressBlock &other) const;
  2.1446 -
  2.1447 -protected:
  2.1448 -  virtual uint8_t GetAddressLength (void) const = 0;
  2.1449 -
  2.1450 -  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const = 0;
  2.1451 -  virtual Address DeserializeAddress (uint8_t *buffer) const = 0;
  2.1452 -  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const = 0;
  2.1453 -
  2.1454 -private:
  2.1455 -  uint8_t GetPrefixFlags (void) const;
  2.1456 -  void GetHeadTail (uint8_t *head, uint8_t &headlen,
  2.1457 -      uint8_t *tail, uint8_t &taillen) const;
  2.1458 -  bool HasZeroTail (const uint8_t *tail, uint8_t taillen) const;
  2.1459 -
  2.1460 -  std::list<Address> m_addressList;
  2.1461 -  std::list<uint8_t> m_prefixList;
  2.1462 -  PbbAddressTlvBlock m_addressTlvList;
  2.1463 -
  2.1464 -  mutable uint32_t m_refCount;
  2.1465 -};
  2.1466 -
  2.1467 -/**
  2.1468 - * \brief Concrete IPv4 specific PbbAddressBlock.
  2.1469 - *
  2.1470 - * This address block will only contain IPv4 addresses.
  2.1471 - */
  2.1472 -class PbbAddressBlockIpv4 : public PbbAddressBlock
  2.1473 -{
  2.1474 -protected:
  2.1475 -  virtual uint8_t GetAddressLength (void) const;
  2.1476 -
  2.1477 -  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const;
  2.1478 -  virtual Address DeserializeAddress (uint8_t *buffer) const;
  2.1479 -  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const;
  2.1480 -};
  2.1481 -
  2.1482 -/**
  2.1483 - * \brief Concrete IPv6 specific PbbAddressBlock.
  2.1484 - *
  2.1485 - * This address block will only contain IPv6 addresses.
  2.1486 - */
  2.1487 -class PbbAddressBlockIpv6 : public PbbAddressBlock
  2.1488 -{
  2.1489 -protected:
  2.1490 -  virtual uint8_t GetAddressLength (void) const;
  2.1491 -
  2.1492 -  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const;
  2.1493 -  virtual Address DeserializeAddress (uint8_t *buffer) const;
  2.1494 -  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const;
  2.1495 -};
  2.1496 -
  2.1497 -/**
  2.1498 - * \brief A packet or message TLV
  2.1499 - */
  2.1500 -class PbbTlv
  2.1501 -{
  2.1502 -public:
  2.1503 -  PbbTlv (void);
  2.1504 -
  2.1505 -  /**
  2.1506 -   * \brief Sets the type of this TLV.
  2.1507 -   * \param type the type value to set.
  2.1508 -   */
  2.1509 -  void SetType (uint8_t type);
  2.1510 -
  2.1511 -  /**
  2.1512 -   * \return the type of this TLV.
  2.1513 -   */
  2.1514 -  uint8_t GetType (void) const;
  2.1515 -
  2.1516 -  /**
  2.1517 -   * \brief Sets the type extension of this TLV.
  2.1518 -   * \param type the type extension value to set.
  2.1519 -   *
  2.1520 -   * The type extension is like a sub-type used to further distinguish between
  2.1521 -   * TLVs of the same type.
  2.1522 -   */
  2.1523 -  void SetTypeExt (uint8_t type);
  2.1524 -
  2.1525 -  /**
  2.1526 -   * \return the type extension for this TLV.
  2.1527 -   *
  2.1528 -   * Calling this while HasTypeExt is False is undefined.  Make sure you check
  2.1529 -   * it first.  This will be checked by an assert in debug builds.
  2.1530 -   */
  2.1531 -  uint8_t GetTypeExt (void) const;
  2.1532 -
  2.1533 -  /**
  2.1534 -   * \brief Tests whether or not this TLV has a type extension.
  2.1535 -   * \return true if this TLV has a type extension, false otherwise.
  2.1536 -   *
  2.1537 -   * This should be called before calling GetTypeExt to make sure there
  2.1538 -   * actually is one.
  2.1539 -   */
  2.1540 -  bool HasTypeExt (void) const;
  2.1541 -
  2.1542 -  /**
  2.1543 -   * \brief Sets the value of this message to the specified buffer.
  2.1544 -   * \param start a buffer instance.
  2.1545 -   *
  2.1546 -   * The buffer is _not_ copied until this TLV is serialized.  You should not
  2.1547 -   * change the contents of the buffer you pass in to this function.
  2.1548 -   */
  2.1549 -  void SetValue (Buffer start);
  2.1550 -
  2.1551 -  /**
  2.1552 -   * \brief Sets the value of this message to a buffer with the specified data.
  2.1553 -   * \param buffer a pointer to data to put in the TLVs buffer.
  2.1554 -   * \param size the size of the buffer.
  2.1555 -   *
  2.1556 -   * The buffer *is copied* into a *new buffer instance*.  You can free the
  2.1557 -   * data in the buffer provided anytime you wish.
  2.1558 -   */
  2.1559 -  void SetValue (const uint8_t * buffer, uint32_t size);
  2.1560 -
  2.1561 -  /**
  2.1562 -   * \return a Buffer pointing to the value of this TLV.
  2.1563 -   *
  2.1564 -   * Calling this while HasValue is False is undefined.  Make sure you check it
  2.1565 -   * first.  This will be checked by an assert in debug builds.
  2.1566 -   */
  2.1567 -  Buffer GetValue (void) const;
  2.1568 -
  2.1569 -  /**
  2.1570 -   * \brief Tests whether or not this TLV has a value.
  2.1571 -   * \return true if this tlv has a TLV, false otherwise.
  2.1572 -   *
  2.1573 -   * This should be called before calling GetTypeExt to make sure there
  2.1574 -   * actually is one.
  2.1575 -   */
  2.1576 -  bool HasValue (void) const;
  2.1577 -
  2.1578 -  /* Smart pointer methods */
  2.1579 -  void Ref (void) const;
  2.1580 -  void Unref (void) const;
  2.1581 -
  2.1582 -  /**
  2.1583 -   * \return The size (in bytes) needed to serialize this TLV.
  2.1584 -   */
  2.1585 -  uint32_t GetSerializedSize (void) const;
  2.1586 -
  2.1587 -  /**
  2.1588 -   * \brief Serializes this TLV into the specified buffer.
  2.1589 -   * \param start a reference to the point in a buffer to begin serializing.
  2.1590 -   *
  2.1591 -   * Users should not need to call this.  TLVs will be serialized by their