src/contrib/packetbb.h
author Tom Wambold <tom5760@gmail.com>
Thu, 13 Aug 2009 23:30:03 -0400
changeset 4775 5b3efd4b3884
child 4776 6ef853626f2a
permissions -rw-r--r--
Adding PacketBB (RFC 5444) library, along with test.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4775
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     2
/* vim: set ts=2 sw=2 expandtab: */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     3
/* 
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     4
 * Copyright (c) 2009 Drexel University
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     5
 * 
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
     9
 *
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    13
 * GNU General Public License for more details.
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    14
 *
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    18
 * 
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    19
 * Author: Tom Wambold <tom5760@gmail.com>
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    20
 */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    21
/* These classes implement RFC 5444 - The Generalized Mobile Ad Hoc Network
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    22
 * (MANET) Packet/Message Format
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    23
 * See: http://tools.ietf.org/html/rfc5444 for details */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    24
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    25
#ifndef PACKETBB_H
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    26
#define PACKETBB_H
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    27
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    28
#include <stdexcept>
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    29
#include <list>
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    30
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    31
#include "ns3/ptr.h"
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    32
#include "ns3/address.h"
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    33
#include "ns3/header.h"
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    34
#include "ns3/buffer.h"
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    35
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    36
namespace ns3 {
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    37
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    38
namespace pbb {
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    39
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    40
/* Forward declare objects */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    41
class PacketBB;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    42
class Message;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    43
class AddressBlock;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    44
class TlvBlock;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    45
class AddressTlvBlock;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    46
class Tlv;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    47
class AddressTlv;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    48
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    49
enum AddressLength {
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    50
  IPV4 = 3,
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    51
  IPV6 = 15,
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    52
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    53
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    54
class PacketBBError : public std::runtime_error {
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    55
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    56
  PacketBBError(const std::string &arg) : std::runtime_error(arg) {}
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    57
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    58
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    59
class TlvBlock
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    60
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    61
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    62
  typedef std::list< Ptr<Tlv> >::iterator Iterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    63
  typedef std::list< Ptr<Tlv> >::const_iterator ConstIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    64
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    65
  Iterator Begin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    66
  ConstIterator Begin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    67
  Iterator End (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    68
  ConstIterator End (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    69
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    70
  int Size (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    71
  bool Empty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    72
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    73
  Ptr<Tlv> Front (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    74
  Ptr<Tlv> Back (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    75
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    76
  void PushFront (Ptr<Tlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    77
  void PopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    78
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    79
  void PushBack (Ptr<Tlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    80
  void PopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    81
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    82
  Iterator Insert (Iterator position, const Ptr<Tlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    83
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    84
  Iterator Erase (Iterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    85
  Iterator Erase (Iterator first, Iterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    86
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    87
  void Clear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    88
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    89
  uint32_t GetSerializedSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    90
  void Serialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    91
  void Deserialize (Buffer::Iterator &start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    92
  void Print (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    93
  void Print (std::ostream &os, int level) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    94
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    95
  bool operator== (const TlvBlock &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    96
  bool operator!= (const TlvBlock &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    97
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    98
private:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
    99
  std::list< Ptr<Tlv> > m_tlvList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   100
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   101
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   102
class AddressTlvBlock
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   103
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   104
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   105
  typedef std::list< Ptr<AddressTlv> >::iterator Iterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   106
  typedef std::list< Ptr<AddressTlv> >::const_iterator ConstIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   107
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   108
  Iterator Begin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   109
  ConstIterator Begin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   110
  Iterator End (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   111
  ConstIterator End (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   112
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   113
  int Size (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   114
  bool Empty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   115
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   116
  Ptr<AddressTlv> Front (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   117
  Ptr<AddressTlv> Back (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   118
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   119
  void PushFront (Ptr<AddressTlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   120
  void PopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   121
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   122
  void PushBack (Ptr<AddressTlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   123
  void PopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   124
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   125
  Iterator Insert (Iterator position, const Ptr<AddressTlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   126
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   127
  Iterator Erase (Iterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   128
  Iterator Erase (Iterator first, Iterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   129
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   130
  void Clear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   131
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   132
  uint32_t GetSerializedSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   133
  void Serialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   134
  void Deserialize (Buffer::Iterator &start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   135
  void Print (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   136
  void Print (std::ostream &os, int level) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   137
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   138
  bool operator== (const AddressTlvBlock &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   139
  bool operator!= (const AddressTlvBlock &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   140
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   141
private:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   142
  std::list< Ptr<AddressTlv> > m_tlvList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   143
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   144
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   145
/** Top level PacketBB packet object */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   146
class PacketBB : public Header
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   147
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   148
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   149
  typedef std::list< Ptr<Tlv> >::iterator TlvIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   150
  typedef std::list< Ptr<Tlv> >::const_iterator ConstTlvIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   151
  typedef std::list< Ptr<Message> >::iterator MessageIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   152
  typedef std::list< Ptr<Message> >::const_iterator ConstMessageIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   153
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   154
  PacketBB (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   155
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   156
  uint8_t GetVersion (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   157
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   158
  void SetSequenceNumber (uint16_t number);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   159
  uint16_t GetSequenceNumber (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   160
  bool HasSequenceNumber (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   161
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   162
  /* Manipulating Packet TLVs */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   163
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   164
  TlvIterator TlvBegin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   165
  ConstTlvIterator TlvBegin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   166
  TlvIterator TlvEnd (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   167
  ConstTlvIterator TlvEnd (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   168
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   169
  int TlvSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   170
  bool TlvEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   171
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   172
  Ptr<Tlv> TlvFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   173
  const Ptr<Tlv> TlvFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   174
  Ptr<Tlv> TlvBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   175
  const Ptr<Tlv> TlvBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   176
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   177
  void TlvPushFront (Ptr<Tlv>);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   178
  void TlvPopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   179
  void TlvPushBack (Ptr<Tlv>);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   180
  void TlvPopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   181
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   182
  TlvIterator Erase (TlvIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   183
  TlvIterator Erase (TlvIterator first, TlvIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   184
  void TlvClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   185
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   186
  /* Manipulating Packet Messages */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   187
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   188
  MessageIterator MessageBegin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   189
  ConstMessageIterator MessageBegin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   190
  MessageIterator MessageEnd (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   191
  ConstMessageIterator MessageEnd (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   192
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   193
  int MessageSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   194
  bool MessageEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   195
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   196
  Ptr<Message> MessageFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   197
  const Ptr<Message> MessageFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   198
  Ptr<Message> MessageBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   199
  const Ptr<Message> MessageBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   200
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   201
  void MessagePushFront (Ptr<Message> message);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   202
  void MessagePopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   203
  void MessagePushBack (Ptr<Message> message);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   204
  void MessagePopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   205
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   206
  MessageIterator Erase (MessageIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   207
  MessageIterator Erase (MessageIterator first, MessageIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   208
  void MessageClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   209
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   210
  /* Smart pointer methods */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   211
  void Ref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   212
  void Unref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   213
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   214
  /* Methods implemented by all headers */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   215
  static TypeId GetTypeId (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   216
  virtual TypeId GetInstanceTypeId (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   217
  virtual uint32_t GetSerializedSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   218
  virtual void Serialize (Buffer::Iterator start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   219
  virtual uint32_t Deserialize (Buffer::Iterator start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   220
  virtual void Print (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   221
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   222
  bool operator== (const PacketBB &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   223
  bool operator!= (const PacketBB &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   224
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   225
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   226
  void SerializePacketTlv (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   227
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   228
private:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   229
  TlvBlock m_tlvList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   230
  std::list< Ptr<Message> > m_messageList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   231
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   232
  uint8_t m_version;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   233
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   234
  bool m_hasseqnum;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   235
  uint16_t m_seqnum;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   236
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   237
  mutable uint32_t m_refCount;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   238
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   239
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   240
class Message
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   241
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   242
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   243
  typedef std::list< Ptr<Tlv> >::iterator TlvIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   244
  typedef std::list< Ptr<Tlv> >::const_iterator ConstTlvIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   245
  typedef std::list< Ptr<AddressBlock> >::iterator AddressBlockIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   246
  typedef std::list< Ptr<AddressBlock> >::const_iterator ConstAddressBlockIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   247
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   248
  Message (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   249
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   250
  void SetType (uint8_t type);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   251
  uint8_t GetType (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   252
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   253
  void SetOriginatorAddress (Address address);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   254
  Address GetOriginatorAddress (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   255
  bool HasOriginatorAddress (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   256
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   257
  void SetHopLimit (uint8_t hoplimit);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   258
  uint8_t GetHopLimit (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   259
  bool HasHopLimit (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   260
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   261
  void SetHopCount (uint8_t hopcount);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   262
  uint8_t GetHopCount (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   263
  bool HasHopCount (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   264
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   265
  void SetSequenceNumber (uint16_t seqnum);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   266
  uint16_t GetSequenceNumber (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   267
  bool HasSequenceNumber (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   268
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   269
  /* Manipulating Message TLVs */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   270
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   271
  TlvIterator TlvBegin ();
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   272
  ConstTlvIterator TlvBegin () const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   273
  TlvIterator TlvEnd ();
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   274
  ConstTlvIterator TlvEnd () const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   275
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   276
  int TlvSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   277
  bool TlvEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   278
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   279
  Ptr<Tlv> TlvFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   280
  const Ptr<Tlv> TlvFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   281
  Ptr<Tlv> TlvBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   282
  const Ptr<Tlv> TlvBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   283
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   284
  void TlvPushFront (Ptr<Tlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   285
  void TlvPopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   286
  void TlvPushBack (Ptr<Tlv> tlv);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   287
  void TlvPopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   288
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   289
  TlvIterator TlvErase (TlvIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   290
  TlvIterator TlvErase (TlvIterator first, TlvIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   291
  void TlvClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   292
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   293
  /* Manipulating Address Block and Address TLV pairs */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   294
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   295
  AddressBlockIterator AddressBlockBegin ();
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   296
  ConstAddressBlockIterator AddressBlockBegin () const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   297
  AddressBlockIterator AddressBlockEnd ();
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   298
  ConstAddressBlockIterator AddressBlockEnd () const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   299
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   300
  int AddressBlockSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   301
  bool AddressBlockEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   302
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   303
  Ptr<AddressBlock> AddressBlockFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   304
  const Ptr<AddressBlock> AddressBlockFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   305
  Ptr<AddressBlock> AddressBlockBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   306
  const Ptr<AddressBlock> AddressBlockBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   307
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   308
  void AddressBlockPushFront (Ptr<AddressBlock> block);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   309
  void AddressBlockPopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   310
  void AddressBlockPushBack (Ptr<AddressBlock> block);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   311
  void AddressBlockPopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   312
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   313
  AddressBlockIterator AddressBlockErase (AddressBlockIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   314
  AddressBlockIterator AddressBlockErase (AddressBlockIterator first,
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   315
      AddressBlockIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   316
  void AddressBlockClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   317
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   318
  /* Smart pointer methods */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   319
  void Ref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   320
  void Unref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   321
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   322
  static Ptr<Message> DeserializeMessage (Buffer::Iterator &start) throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   323
  uint32_t GetSerializedSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   324
  void Serialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   325
  void Deserialize (Buffer::Iterator &start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   326
  void Print (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   327
  void Print (std::ostream &os, int level) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   328
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   329
  bool operator== (const Message &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   330
  bool operator!= (const Message &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   331
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   332
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   333
  /* Message size in bytes - 1.
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   334
   *
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   335
   * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   336
   */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   337
  virtual AddressLength GetAddressLength (void) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   338
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   339
  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   340
  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   341
  virtual void PrintOriginatorAddress (std::ostream &os) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   342
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   343
  virtual Ptr<AddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   344
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   345
private:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   346
  TlvBlock m_tlvList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   347
  std::list< Ptr<AddressBlock> > m_addressBlockList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   348
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   349
  uint8_t m_type;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   350
  AddressLength m_addrSize;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   351
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   352
  bool m_hasOriginatorAddress;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   353
  Address m_originatorAddress;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   354
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   355
  bool m_hasHopLimit;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   356
  uint8_t m_hopLimit;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   357
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   358
  bool m_hasHopCount;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   359
  uint8_t m_hopCount;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   360
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   361
  bool m_hasSequenceNumber;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   362
  uint16_t m_sequenceNumber;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   363
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   364
  mutable uint32_t m_refCount;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   365
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   366
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   367
class MessageIpv4 : public Message {
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   368
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   369
  virtual AddressLength GetAddressLength (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   370
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   371
  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   372
  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   373
  virtual void PrintOriginatorAddress (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   374
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   375
  virtual Ptr<AddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   376
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   377
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   378
class MessageIpv6 : public Message {
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   379
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   380
  virtual AddressLength GetAddressLength (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   381
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   382
  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   383
  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   384
  virtual void PrintOriginatorAddress (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   385
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   386
  virtual Ptr<AddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   387
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   388
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   389
/** This combines address blocks with their associated TLVs */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   390
class AddressBlock
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   391
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   392
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   393
  typedef std::list< Address >::iterator AddressIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   394
  typedef std::list< Address >::const_iterator ConstAddressIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   395
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   396
  typedef std::list<uint8_t>::iterator PrefixIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   397
  typedef std::list<uint8_t>::const_iterator ConstPrefixIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   398
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   399
  typedef AddressTlvBlock::Iterator TlvIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   400
  typedef AddressTlvBlock::ConstIterator ConstTlvIterator;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   401
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   402
  AddressBlock ();
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   403
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   404
  /* Manipulating the address block */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   405
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   406
  AddressIterator AddressBegin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   407
  ConstAddressIterator AddressBegin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   408
  AddressIterator AddressEnd (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   409
  ConstAddressIterator AddressEnd (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   410
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   411
  int AddressSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   412
  bool AddressEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   413
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   414
  Address AddressFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   415
  Address AddressBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   416
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   417
  void AddressPushFront (Address address);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   418
  void AddressPopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   419
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   420
  void AddressPushBack (Address address);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   421
  void AddressPopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   422
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   423
  AddressIterator AddressInsert (AddressIterator position,
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   424
      const Address value);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   425
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   426
  AddressIterator AddressErase (AddressIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   427
  AddressIterator AddressErase (AddressIterator first, AddressIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   428
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   429
  void AddressClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   430
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   431
  /* Prefix methods */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   432
  PrefixIterator PrefixBegin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   433
  ConstPrefixIterator PrefixBegin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   434
  PrefixIterator PrefixEnd (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   435
  ConstPrefixIterator PrefixEnd (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   436
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   437
  int PrefixSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   438
  bool PrefixEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   439
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   440
  uint8_t PrefixFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   441
  uint8_t PrefixBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   442
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   443
  void PrefixPushFront (uint8_t prefix);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   444
  void PrefixPopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   445
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   446
  void PrefixPushBack (uint8_t prefix);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   447
  void PrefixPopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   448
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   449
  PrefixIterator PrefixInsert (PrefixIterator position, const uint8_t value);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   450
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   451
  PrefixIterator PrefixErase (PrefixIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   452
  PrefixIterator PrefixErase (PrefixIterator first, PrefixIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   453
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   454
  void PrefixClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   455
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   456
  /* Manipulating the TLV block */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   457
  TlvIterator TlvBegin (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   458
  ConstTlvIterator TlvBegin (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   459
  TlvIterator TlvEnd (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   460
  ConstTlvIterator TlvEnd (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   461
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   462
  int TlvSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   463
  bool TlvEmpty (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   464
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   465
  Ptr<AddressTlv> TlvFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   466
  const Ptr<AddressTlv> TlvFront (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   467
  Ptr<AddressTlv> TlvBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   468
  const Ptr<AddressTlv> TlvBack (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   469
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   470
  void TlvPushFront (Ptr<AddressTlv> address);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   471
  void TlvPopFront (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   472
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   473
  void TlvPushBack (Ptr<AddressTlv> address);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   474
  void TlvPopBack (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   475
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   476
  TlvIterator TlvInsert (TlvIterator position, const Ptr<Tlv> value);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   477
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   478
  TlvIterator TlvErase (TlvIterator position);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   479
  TlvIterator TlvErase (TlvIterator first, TlvIterator last);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   480
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   481
  void TlvClear (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   482
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   483
  /* Smart pointer methods */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   484
  void Ref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   485
  void Unref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   486
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   487
  uint32_t GetSerializedSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   488
  void Serialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   489
  void Deserialize (Buffer::Iterator &start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   490
  void Print (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   491
  void Print (std::ostream &os, int level) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   492
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   493
  bool operator== (const AddressBlock &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   494
  bool operator!= (const AddressBlock &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   495
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   496
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   497
  virtual uint8_t GetAddressLength (void) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   498
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   499
  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   500
  virtual Address DeserializeAddress (uint8_t *buffer) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   501
  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const = 0;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   502
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   503
private:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   504
  uint8_t GetPrefixFlags (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   505
  void GetHeadTail (uint8_t *head, uint8_t &headlen,
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   506
      uint8_t *tail, uint8_t &taillen) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   507
  bool HasZeroTail (const uint8_t *tail, uint8_t taillen) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   508
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   509
  std::list<Address> m_addressList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   510
  std::list<uint8_t> m_prefixList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   511
  AddressTlvBlock m_addressTlvList;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   512
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   513
  mutable uint32_t m_refCount;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   514
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   515
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   516
class AddressBlockIpv4 : public AddressBlock
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   517
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   518
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   519
  virtual uint8_t GetAddressLength (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   520
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   521
  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   522
  virtual Address DeserializeAddress (uint8_t *buffer) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   523
  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   524
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   525
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   526
class AddressBlockIpv6 : public AddressBlock
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   527
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   528
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   529
  virtual uint8_t GetAddressLength (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   530
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   531
  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   532
  virtual Address DeserializeAddress (uint8_t *buffer) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   533
  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   534
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   535
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   536
/** A packet or message TLV */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   537
class Tlv
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   538
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   539
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   540
  Tlv (void);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   541
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   542
  void SetType (uint8_t type);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   543
  uint8_t GetType (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   544
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   545
  void SetTypeExt (uint8_t type);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   546
  uint8_t GetTypeExt (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   547
  bool HasTypeExt (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   548
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   549
  void SetValue (Buffer start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   550
  void SetValue (const uint8_t * buffer, uint32_t size);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   551
  Buffer GetValue (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   552
  bool HasValue (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   553
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   554
  /* Smart pointer methods */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   555
  void Ref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   556
  void Unref (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   557
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   558
  uint32_t GetSerializedSize (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   559
  void Serialize (Buffer::Iterator &start) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   560
  void Deserialize (Buffer::Iterator &start);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   561
  void Print (std::ostream &os) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   562
  void Print (std::ostream &os, int level) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   563
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   564
  bool operator== (const Tlv &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   565
  bool operator!= (const Tlv &other) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   566
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   567
protected:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   568
  void SetIndexStart (uint8_t index);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   569
  uint8_t GetIndexStart (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   570
  bool HasIndexStart (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   571
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   572
  void SetIndexStop (uint8_t index);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   573
  uint8_t GetIndexStop (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   574
  bool HasIndexStop (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   575
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   576
  void SetMultivalue (bool isMultivalue);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   577
  bool IsMultivalue (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   578
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   579
private:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   580
  uint8_t m_type;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   581
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   582
  bool m_hasTypeExt;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   583
  uint8_t m_typeExt;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   584
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   585
  bool m_hasIndexStart;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   586
  uint8_t m_indexStart;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   587
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   588
  bool m_hasIndexStop;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   589
  uint8_t m_indexStop;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   590
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   591
  bool m_isMultivalue;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   592
  bool m_hasValue;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   593
  Buffer m_value;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   594
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   595
  mutable uint32_t m_refCount;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   596
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   597
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   598
class AddressTlv : public Tlv
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   599
{
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   600
public:
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   601
  void SetIndexStart (uint8_t index);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   602
  uint8_t GetIndexStart (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   603
  bool HasIndexStart (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   604
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   605
  void SetIndexStop (uint8_t index);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   606
  uint8_t GetIndexStop (void) const throw (PacketBBError);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   607
  bool HasIndexStop (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   608
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   609
  void SetMultivalue (bool isMultivalue);
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   610
  bool IsMultivalue (void) const;
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   611
};
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   612
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   613
} /* namespace pbb */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   614
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   615
} /* namespace ns3 */
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   616
5b3efd4b3884 Adding PacketBB (RFC 5444) library, along with test.
Tom Wambold <tom5760@gmail.com>
parents:
diff changeset
   617
#endif /* PACKETBB_H */