PacketBB: Doxygen documentation. Still have some more I want to write.
authorTom Wambold <tom5760@gmail.com>
Fri Sep 11 00:52:23 2009 -0400 (5 months ago)
changeset 47842d87b22311dd
parent 4783 6648a2c450e5
child 4785 d1c0b9c89160
PacketBB: Doxygen documentation. Still have some more I want to write.
src/contrib/packetbb.h
     1.1 --- a/src/contrib/packetbb.h	Thu Sep 10 15:35:16 2009 -0400
     1.2 +++ b/src/contrib/packetbb.h	Fri Sep 11 00:52:23 2009 -0400
     1.3 @@ -43,6 +43,7 @@
     1.4  class PbbTlv;
     1.5  class PbbAddressTlv;
     1.6  
     1.7 +/** Used in Messages to determine whether it contains IPv4 or IPv6 addresses */
     1.8  enum PbbAddressLength {
     1.9    IPV4 = 3,
    1.10    IPV6 = 15,
    1.11 @@ -59,34 +60,135 @@
    1.12    typedef std::list< Ptr<PbbTlv> >::iterator Iterator;
    1.13    typedef std::list< Ptr<PbbTlv> >::const_iterator ConstIterator;
    1.14  
    1.15 +  /**
    1.16 +   * \return an iterator to the first TLV in this block.
    1.17 +   */
    1.18    Iterator Begin (void);
    1.19 +
    1.20 +  /**
    1.21 +   * \return a const iterator to the first TLV in this block.
    1.22 +   */
    1.23    ConstIterator Begin (void) const;
    1.24 +
    1.25 +  /**
    1.26 +   * \return an iterator to the past-the-end element in this block.
    1.27 +   */
    1.28    Iterator End (void);
    1.29 +
    1.30 +  /**
    1.31 +   * \return a const iterator to the past-the-end element in this block.
    1.32 +   */
    1.33    ConstIterator End (void) const;
    1.34  
    1.35 +  /**
    1.36 +   * \return the number of TLVs in this block.
    1.37 +   */
    1.38    int Size (void) const;
    1.39 +
    1.40 +  /**
    1.41 +   * \return true if there are no TLVs in this block, false otherwise.
    1.42 +   */
    1.43    bool Empty (void) const;
    1.44  
    1.45 +  /**
    1.46 +   * \return a smart pointer to the first TLV in this block.
    1.47 +   */
    1.48    Ptr<PbbTlv> Front (void) const;
    1.49 +
    1.50 +  /**
    1.51 +   * \return a smart pointer to the last TLV in this block.
    1.52 +   */
    1.53    Ptr<PbbTlv> Back (void) const;
    1.54  
    1.55 +  /**
    1.56 +   * \brief Prepends a TLV to the front of this block.
    1.57 +   * \param tlv a smart pointer to the TLV to prepend.
    1.58 +   */
    1.59    void PushFront (Ptr<PbbTlv> tlv);
    1.60 +
    1.61 +  /**
    1.62 +   * \brief Removes a TLV from the front of this block.
    1.63 +   */
    1.64    void PopFront (void);
    1.65  
    1.66 +  /**
    1.67 +   * \brief Appends a TLV to the back of this block.
    1.68 +   * \param tlv a smart pointer to the TLV to append.
    1.69 +   */
    1.70    void PushBack (Ptr<PbbTlv> tlv);
    1.71 +
    1.72 +  /**
    1.73 +   * \brief Removes a TLV from the back of this block.
    1.74 +   */
    1.75    void PopBack (void);
    1.76  
    1.77 +  /**
    1.78 +   * \brief Inserts a TLV at the specified position in this block.
    1.79 +   * \param position an Iterator pointing to the position in this block to
    1.80 +   *        insert the TLV.
    1.81 +   * \param tlv a smart pointer to the TLV to insert.
    1.82 +   * \return An iterator pointing to the newly inserted TLV.
    1.83 +   */
    1.84    Iterator Insert (Iterator position, const Ptr<PbbTlv> tlv);
    1.85  
    1.86 +  /**
    1.87 +   * \brief Removes the TLV at the specified position.
    1.88 +   * \param position an Iterator pointing to the TLV to erase.
    1.89 +   * \return an iterator pointing to the next TLV in the block.
    1.90 +   */
    1.91    Iterator Erase (Iterator position);
    1.92 +
    1.93 +  /**
    1.94 +   * \brief Removes all TLVs from [first, last) (includes first, not includes
    1.95 +   *        last).
    1.96 +   * \param first an Iterator pointing to the first TLV to erase (inclusive).
    1.97 +   * \param last an Iterator pointing to the element past the last TLV to erase.
    1.98 +   * \return an iterator pointing to the next TLV in the block.
    1.99 +   */
   1.100    Iterator Erase (Iterator first, Iterator last);
   1.101  
   1.102 +  /**
   1.103 +   * \brief Removes all TLVs from this block.
   1.104 +   */
   1.105    void Clear (void);
   1.106  
   1.107 +  /**
   1.108 +   * \return The size (in bytes) needed to serialize this block.
   1.109 +   */
   1.110    uint32_t GetSerializedSize (void) const;
   1.111 +
   1.112 +  /**
   1.113 +   * \brief Serializes this block into the specified buffer.
   1.114 +   * \param start a reference to the point in a buffer to begin serializing.
   1.115 +   *
   1.116 +   * Users should not need to call this.  Blocks will be serialized by their
   1.117 +   * containing packet.
   1.118 +   */
   1.119    void Serialize (Buffer::Iterator &start) const;
   1.120 +
   1.121 +  /**
   1.122 +   * \brief Deserializes a block from the specified buffer.
   1.123 +   * \param start a reference to the point in a buffer to begin deserializing.
   1.124 +   *
   1.125 +   * Users should not need to call this.  Blocks will be deserialized by their
   1.126 +   * containing packet.
   1.127 +   */
   1.128    void Deserialize (Buffer::Iterator &start);
   1.129 +
   1.130 +  /**
   1.131 +   * \brief Pretty-prints the contents of this block.
   1.132 +   * \param os a stream object to print to.
   1.133 +   */
   1.134    void Print (std::ostream &os) const;
   1.135 +
   1.136 +  /**
   1.137 +   * \brief Pretty-prints the contents of this block, with specified indentation.
   1.138 +   * \param os a stream object to print to.
   1.139 +   * \param level level of indentation.
   1.140 +   *
   1.141 +   * This probably never needs to be called by users.  This is used when
   1.142 +   * recursively printing sub-objects.
   1.143 +   */
   1.144    void Print (std::ostream &os, int level) const;
   1.145  
   1.146    bool operator== (const PbbTlvBlock &other) const;
   1.147 @@ -107,34 +209,137 @@
   1.148    typedef std::list< Ptr<PbbAddressTlv> >::iterator Iterator;
   1.149    typedef std::list< Ptr<PbbAddressTlv> >::const_iterator ConstIterator;
   1.150  
   1.151 +  /**
   1.152 +   * \return an iterator to the first Address TLV in this block.
   1.153 +   */
   1.154    Iterator Begin (void);
   1.155 +
   1.156 +  /**
   1.157 +   * \return a const iterator to the first Address TLV in this block.
   1.158 +   */
   1.159    ConstIterator Begin (void) const;
   1.160 +
   1.161 +  /**
   1.162 +   * \return an iterator to the past-the-end element in this block.
   1.163 +   */
   1.164    Iterator End (void);
   1.165 +
   1.166 +  /**
   1.167 +   * \return a const iterator to the past-the-end element in this block.
   1.168 +   */
   1.169    ConstIterator End (void) const;
   1.170  
   1.171 +  /**
   1.172 +   * \return the number of Address TLVs in this block.
   1.173 +   */
   1.174    int Size (void) const;
   1.175 +
   1.176 +  /**
   1.177 +   * \return true if there are no Address TLVs in this block, false otherwise.
   1.178 +   */
   1.179    bool Empty (void) const;
   1.180  
   1.181 +  /**
   1.182 +   * \return the first Address TLV in this block.
   1.183 +   */
   1.184    Ptr<PbbAddressTlv> Front (void) const;
   1.185 +
   1.186 +  /**
   1.187 +   * \return the last AddressTLV in this block.
   1.188 +   */
   1.189    Ptr<PbbAddressTlv> Back (void) const;
   1.190  
   1.191 +  /**
   1.192 +   * \brief Prepends an Address TLV to the front of this block.
   1.193 +   * \param tlv a smart pointer to the Address TLV to prepend.
   1.194 +   */
   1.195    void PushFront (Ptr<PbbAddressTlv> tlv);
   1.196 +
   1.197 +  /**
   1.198 +   * \brief Removes an AddressTLV from the front of this block.
   1.199 +   */
   1.200    void PopFront (void);
   1.201  
   1.202 +  /**
   1.203 +   * \brief Appends an Address TLV to the back of this block.
   1.204 +   * \param tlv a smart pointer to the Address TLV to append.
   1.205 +   */
   1.206    void PushBack (Ptr<PbbAddressTlv> tlv);
   1.207 +
   1.208 +  /**
   1.209 +   * \brief Removes an Address TLV from the back of this block.
   1.210 +   */
   1.211    void PopBack (void);
   1.212  
   1.213 +  /**
   1.214 +   * \brief Inserts an Address TLV at the specified position in this block.
   1.215 +   * \param position an Iterator pointing to the position in this block to
   1.216 +   *        insert the Address TLV.
   1.217 +   * \param tlv a smart pointer to the Address TLV to insert.
   1.218 +   * \return An iterator pointing to the newly inserted Address TLV.
   1.219 +   */
   1.220    Iterator Insert (Iterator position, const Ptr<PbbAddressTlv> tlv);
   1.221  
   1.222 +  /**
   1.223 +   * \brief Removes the Address TLV at the specified position.
   1.224 +   * \param position an Iterator pointing to the Address TLV to erase.
   1.225 +   * \return an iterator pointing to the next Address TLV in the block.
   1.226 +   */
   1.227    Iterator Erase (Iterator position);
   1.228 +
   1.229 +  /**
   1.230 +   * \brief Removes all Address TLVs from [first, last) (includes first, not
   1.231 +   *        includes last).
   1.232 +   * \param first an Iterator pointing to the first Address TLV to erase
   1.233 +   *        (inclusive).
   1.234 +   * \param last an Iterator pointing to the element past the last Address TLV
   1.235 +   *        to erase.
   1.236 +   * \return an iterator pointing to the next Address TLV in the block.
   1.237 +   */
   1.238    Iterator Erase (Iterator first, Iterator last);
   1.239  
   1.240 +  /**
   1.241 +   * \brief Removes all Address TLVs from this block.
   1.242 +   */
   1.243    void Clear (void);
   1.244  
   1.245 +  /**
   1.246 +   * \return The size (in bytes) needed to serialize this block.
   1.247 +   */
   1.248    uint32_t GetSerializedSize (void) const;
   1.249 +
   1.250 +  /**
   1.251 +   * \brief Serializes this block into the specified buffer.
   1.252 +   * \param start a reference to the point in a buffer to begin serializing.
   1.253 +   *
   1.254 +   * Users should not need to call this.  Blocks will be serialized by their
   1.255 +   * containing packet.
   1.256 +   */
   1.257    void Serialize (Buffer::Iterator &start) const;
   1.258 +
   1.259 +  /**
   1.260 +   * \brief Deserializes a block from the specified buffer.
   1.261 +   * \param start a reference to the point in a buffer to begin deserializing.
   1.262 +   *
   1.263 +   * Users should not need to call this.  Blocks will be deserialized by their
   1.264 +   * containing packet.
   1.265 +   */
   1.266    void Deserialize (Buffer::Iterator &start);
   1.267 +
   1.268 +  /**
   1.269 +   * \brief Pretty-prints the contents of this block.
   1.270 +   * \param os a stream object to print to.
   1.271 +   */
   1.272    void Print (std::ostream &os) const;
   1.273 +
   1.274 +  /**
   1.275 +   * \brief Pretty-prints the contents of this block, with specified indentation.
   1.276 +   * \param os a stream object to print to.
   1.277 +   * \param level level of indentation.
   1.278 +   *
   1.279 +   * This probably never needs to be called by users.  This is used when
   1.280 +   * recursively printing sub-objects.
   1.281 +   */
   1.282    void Print (std::ostream &os, int level) const;
   1.283  
   1.284    bool operator== (const PbbAddressTlvBlock &other) const;
   1.285 @@ -145,7 +350,9 @@
   1.286  };
   1.287  
   1.288  /**
   1.289 - * \brief Main PbbPacket Packet object.
   1.290 + * \brief Main PacketBB Packet object.
   1.291 + *
   1.292 + * See: http://tools.ietf.org/html/rfc5444 for details.
   1.293   */
   1.294  class PbbPacket : public Header
   1.295  {
   1.296 @@ -157,64 +364,228 @@
   1.297  
   1.298    PbbPacket (void);
   1.299  
   1.300 +  /**
   1.301 +   * \return the version of PacketBB that constructed this packet.
   1.302 +   *
   1.303 +   * This will always return 0 for packets constructed using this API.
   1.304 +   */
   1.305    uint8_t GetVersion (void) const;
   1.306  
   1.307 +  /**
   1.308 +   * \brief Sets the sequence number of this packet.
   1.309 +   * \param number the sequence number.
   1.310 +   */
   1.311    void SetSequenceNumber (uint16_t number);
   1.312 +
   1.313    /**
   1.314 -   * \returns the sequence number of this packet.
   1.315 +   * \return the sequence number of this packet.
   1.316     *
   1.317     * Calling this while HasSequenceNumber is False is undefined.  Make sure you
   1.318     * check it first.  This will be checked by an assert in debug builds.
   1.319     */
   1.320    uint16_t GetSequenceNumber (void) const;
   1.321 +
   1.322 +  /**
   1.323 +   * \brief Tests whether or not this packet has a sequence number.
   1.324 +   * \return true if this packet has a sequence number, false otherwise.
   1.325 +   *
   1.326 +   * This should be called before calling GetSequenceNumber to make sure there
   1.327 +   * actually is one.
   1.328 +   */
   1.329    bool HasSequenceNumber (void) const;
   1.330  
   1.331    /* Manipulating Packet TLVs */
   1.332  
   1.333 +  /**
   1.334 +   * \return an iterator to the first Packet TLV in this packet.
   1.335 +   */
   1.336    TlvIterator TlvBegin (void);
   1.337 +
   1.338 +  /**
   1.339 +   * \return a const iterator to the first Packet TLV in this packet.
   1.340 +   */
   1.341    ConstTlvIterator TlvBegin (void) const;
   1.342 +
   1.343 +  /**
   1.344 +   * \return an iterator to the past-the-end element in this packet TLV block.
   1.345 +   */
   1.346    TlvIterator TlvEnd (void);
   1.347 +
   1.348 +  /**
   1.349 +   * \return a const iterator to the past-the-end element in this packet TLV
   1.350 +   *         block.
   1.351 +   */
   1.352    ConstTlvIterator TlvEnd (void) const;
   1.353  
   1.354 +  /**
   1.355 +   * \return the number of packet TLVs in this packet.
   1.356 +   */
   1.357    int TlvSize (void) const;
   1.358 +
   1.359 +  /**
   1.360 +   * \return true if there are no packet TLVs in this packet, false otherwise.
   1.361 +   */
   1.362    bool TlvEmpty (void) const;
   1.363  
   1.364 +  /**
   1.365 +   * \return a smart pointer to the first packet TLV in this packet.
   1.366 +   */
   1.367    Ptr<PbbTlv> TlvFront (void);
   1.368 +
   1.369 +  /**
   1.370 +   * \return a const smart pointer to the first packet TLV in this packet.
   1.371 +   */
   1.372    const Ptr<PbbTlv> TlvFront (void) const;
   1.373 +
   1.374 +  /**
   1.375 +   * \return a smart pointer to the last packet TLV in this packet.
   1.376 +   */
   1.377    Ptr<PbbTlv> TlvBack (void);
   1.378 +
   1.379 +  /**
   1.380 +   * \return a const smart pointer to the last packet TLV in this packet.
   1.381 +   */
   1.382    const Ptr<PbbTlv> TlvBack (void) const;
   1.383  
   1.384 -  void TlvPushFront (Ptr<PbbTlv>);
   1.385 +  /**
   1.386 +   * \brief Prepends a packet TLV to the front of this packet.
   1.387 +   * \param tlv a smart pointer to the packet TLV to prepend.
   1.388 +   */
   1.389 +  void TlvPushFront (Ptr<PbbTlv> tlv);
   1.390 +
   1.391 +  /**
   1.392 +   * \brief Removes a packet TLV from the front of this packet.
   1.393 +   */
   1.394    void TlvPopFront (void);
   1.395 -  void TlvPushBack (Ptr<PbbTlv>);
   1.396 +
   1.397 +  /**
   1.398 +   * \brief Appends a packet TLV to the back of this packet.
   1.399 +   * \param tlv a smart pointer to the packet TLV to append.
   1.400 +   */
   1.401 +  void TlvPushBack (Ptr<PbbTlv> tlv);
   1.402 +
   1.403 +  /**
   1.404 +   * \brief Removes a packet TLV from the back of this block.
   1.405 +   */
   1.406    void TlvPopBack (void);
   1.407  
   1.408 +  /**
   1.409 +   * \brief Removes the packet TLV at the specified position.
   1.410 +   * \param position an Iterator pointing to the packet TLV to erase.
   1.411 +   * \return an iterator pointing to the next packet TLV in the block.
   1.412 +   */
   1.413    TlvIterator Erase (TlvIterator position);
   1.414 +
   1.415 +  /**
   1.416 +   * \brief Removes all packet TLVs from [first, last) (includes first, not
   1.417 +   *        includes last).
   1.418 +   * \param first an Iterator pointing to the first packet TLV to erase
   1.419 +   *        (inclusive).
   1.420 +   * \param last an Iterator pointing to the element past the last packet TLV
   1.421 +   *        to erase.
   1.422 +   * \return an iterator pointing to the next packet TLV in the block.
   1.423 +   */
   1.424    TlvIterator Erase (TlvIterator first, TlvIterator last);
   1.425 +
   1.426 +  /**
   1.427 +   * \brief Removes all packet TLVs from this packet.
   1.428 +   */
   1.429    void TlvClear (void);
   1.430  
   1.431    /* Manipulating Packet Messages */
   1.432  
   1.433 +  /**
   1.434 +   * \return an iterator to the first message in this packet.
   1.435 +   */
   1.436    MessageIterator MessageBegin (void);
   1.437 +
   1.438 +  /**
   1.439 +   * \return a const iterator to the first message in this packet.
   1.440 +   */
   1.441    ConstMessageIterator MessageBegin (void) const;
   1.442 +
   1.443 +  /**
   1.444 +   * \return an iterator to the past-the-end element in this message block.
   1.445 +   */
   1.446    MessageIterator MessageEnd (void);
   1.447 +
   1.448 +  /**
   1.449 +   * \return a const iterator to the past-the-end element in this message
   1.450 +   *         block.
   1.451 +   */
   1.452    ConstMessageIterator MessageEnd (void) const;
   1.453  
   1.454 +  /**
   1.455 +   * \return the number of messages in this packet.
   1.456 +   */
   1.457    int MessageSize (void) const;
   1.458 +
   1.459 +  /**
   1.460 +   * \return true if there are no messages in this packet, false otherwise.
   1.461 +   */
   1.462    bool MessageEmpty (void) const;
   1.463  
   1.464 +  /**
   1.465 +   * \return a smart pointer to the first message in this packet.
   1.466 +   */
   1.467    Ptr<PbbMessage> MessageFront (void);
   1.468 +
   1.469 +  /**
   1.470 +   * \return a cosnt smart pointer to the first message in this packet.
   1.471 +   */
   1.472    const Ptr<PbbMessage> MessageFront (void) const;
   1.473 +
   1.474 +  /**
   1.475 +   * \return a smart pointer to the last message in this packet.
   1.476 +   */
   1.477    Ptr<PbbMessage> MessageBack (void);
   1.478 +
   1.479 +  /**
   1.480 +   * \return a cosnt smart pointer to the last message in this packet.
   1.481 +   */
   1.482    const Ptr<PbbMessage> MessageBack (void) const;
   1.483  
   1.484 +  /**
   1.485 +   * \brief Prepends a message to the front of this packet.
   1.486 +   * \param message a smart pointer to the message to prepend.
   1.487 +   */
   1.488    void MessagePushFront (Ptr<PbbMessage> message);
   1.489 +
   1.490 +  /**
   1.491 +   * \brief Removes a message from the front of this packet.
   1.492 +   */
   1.493    void MessagePopFront (void);
   1.494 +
   1.495 +  /**
   1.496 +   * \brief Appends a message to the back of this packet.
   1.497 +   * \param message a smart pointer to the message to append.
   1.498 +   */
   1.499    void MessagePushBack (Ptr<PbbMessage> message);
   1.500 +
   1.501 +  /**
   1.502 +   * \brief Removes a message from the back of this packet.
   1.503 +   */
   1.504    void MessagePopBack (void);
   1.505  
   1.506 +  /**
   1.507 +   * \brief Removes the message at the specified position.
   1.508 +   * \param position an Iterator pointing to the message to erase.
   1.509 +   * \return an iterator pointing to the next message in the packet.
   1.510 +   */
   1.511    MessageIterator Erase (MessageIterator position);
   1.512 +
   1.513 +  /**
   1.514 +   * \brief Removes all messages from [first, last) (includes first, not
   1.515 +   *        includes last).
   1.516 +   * \param first an Iterator pointing to the first message to erase (inclusive).
   1.517 +   * \param last an Iterator pointing to the element past the last message to erase.
   1.518 +   * \return an iterator pointing to the next message in the block.
   1.519 +   */
   1.520    MessageIterator Erase (MessageIterator first, MessageIterator last);
   1.521 +
   1.522 +  /**
   1.523 +   * \brief Removes all messages from this packet.
   1.524 +   */
   1.525    void MessageClear (void);
   1.526  
   1.527    /* Smart pointer methods */
   1.528 @@ -224,15 +595,31 @@
   1.529    /* Methods implemented by all headers */
   1.530    static TypeId GetTypeId (void);
   1.531    virtual TypeId GetInstanceTypeId (void) const;
   1.532 +
   1.533 +  /**
   1.534 +   * \return The size (in bytes) needed to serialize this packet.
   1.535 +   */
   1.536    virtual uint32_t GetSerializedSize (void) const;
   1.537 +
   1.538 +  /**
   1.539 +   * \brief Serializes this packet into the specified buffer.
   1.540 +   * \param start a reference to the point in a buffer to begin serializing.
   1.541 +   */
   1.542    virtual void Serialize (Buffer::Iterator start) const;
   1.543 +
   1.544    /**
   1.545 -   * \returns the number of bytes deserialized
   1.546 +   * \brief Deserializes a packet from the specified buffer.
   1.547 +   * \return the number of bytes deserialized
   1.548     *
   1.549     * If this returns a number smaller than the total number of bytes in the
   1.550     * buffer, there was an error.
   1.551     */
   1.552    virtual uint32_t Deserialize (Buffer::Iterator start);
   1.553 +
   1.554 +  /**
   1.555 +   * \brief Pretty-prints the contents of this block.
   1.556 +   * \param os a stream object to print to.
   1.557 +   */
   1.558    virtual void Print (std::ostream &os) const;
   1.559  
   1.560    bool operator== (const PbbPacket &other) const;
   1.561 @@ -270,108 +657,352 @@
   1.562  
   1.563    PbbMessage (void);
   1.564  
   1.565 +  /**
   1.566 +   * \brief Sets the type for this message.
   1.567 +   * \param type the type to set.
   1.568 +   */
   1.569    void SetType (uint8_t type);
   1.570 +
   1.571 +  /**
   1.572 +   * \return the type assigned to this packet
   1.573 +   */
   1.574    uint8_t GetType (void) const;
   1.575  
   1.576 +  /**
   1.577 +   * \brief Sets the address for the node that created this packet.
   1.578 +   * \param address the originator address.
   1.579 +   */
   1.580    void SetOriginatorAddress (Address address);
   1.581 +
   1.582    /**
   1.583 -   * \returns the address of the node that created this packet.
   1.584 +   * \return the address of the node that created this packet.
   1.585     *
   1.586     * Calling this while HasOriginatorAddress is False is undefined.  Make sure
   1.587     * you check it first.  This will be checked by an assert in debug builds.
   1.588     */
   1.589    Address GetOriginatorAddress (void) const;
   1.590 +
   1.591 +  /**
   1.592 +   * \brief Tests whether or not this message has an originator address.
   1.593 +   * \return true if this message has an originator address, false otherwise.
   1.594 +   */
   1.595    bool HasOriginatorAddress (void) const;
   1.596  
   1.597 +  /**
   1.598 +   * \brief Sets the maximum number of hops this message should travel
   1.599 +   * \param hoplimit the limit to set
   1.600 +   */
   1.601    void SetHopLimit (uint8_t hoplimit);
   1.602 +
   1.603    /**
   1.604 -   * \returns the maximum number of hops this message should travel.
   1.605 +   * \return the maximum number of hops this message should travel.
   1.606     *
   1.607     * Calling this while HasHopLimit is False is undefined.  Make sure you check
   1.608     * it first.  This will be checked by an assert in debug builds.
   1.609     */
   1.610    uint8_t GetHopLimit (void) const;
   1.611 +
   1.612 +  /**
   1.613 +   * \brief Tests whether or not this message has a hop limit.
   1.614 +   * \return true if this message has a hop limit, false otherwise.
   1.615 +   *
   1.616 +   * If this is set, messages should not hop further than this limit.
   1.617 +   */
   1.618    bool HasHopLimit (void) const;
   1.619  
   1.620 +  /**
   1.621 +   * \brief Sets the current number of hops this message has traveled.
   1.622 +   * \param hopcount the current number of hops
   1.623 +   */
   1.624    void SetHopCount (uint8_t hopcount);
   1.625 +
   1.626    /**
   1.627 -   * \returns the current number of hops this message has traveled.
   1.628 +   * \return the current number of hops this message has traveled.
   1.629     *
   1.630     * Calling this while HasHopCount is False is undefined.  Make sure you check
   1.631     * it first.  This will be checked by an assert in debug builds.
   1.632     */
   1.633    uint8_t GetHopCount (void) const;
   1.634 +
   1.635 +  /**
   1.636 +   * \brief Tests whether or not this message has a hop count.
   1.637 +   * \return true if this message has a hop limit, false otherwise.
   1.638 +   */
   1.639    bool HasHopCount (void) const;
   1.640  
   1.641 +  /**
   1.642 +   * \brief Sets the sequence number of this message.
   1.643 +   * \param seqnum the sequence number to set.
   1.644 +   */
   1.645    void SetSequenceNumber (uint16_t seqnum);
   1.646 +
   1.647    /**
   1.648 -   * \returns the sequence number of this message.
   1.649 +   * \return the sequence number of this message.
   1.650     *
   1.651     * Calling this while HasSequenceNumber is False is undefined.  Make sure you
   1.652     * check it first.  This will be checked by an assert in debug builds.
   1.653     */
   1.654    uint16_t GetSequenceNumber (void) const;
   1.655 +
   1.656 +  /**
   1.657 +   * \brief Tests whether or not this message has a sequence number.
   1.658 +   * \return true if this message has a sequence number, false otherwise.
   1.659 +   */
   1.660    bool HasSequenceNumber (void) const;
   1.661  
   1.662    /* Manipulating PbbMessage TLVs */
   1.663  
   1.664 +  /**
   1.665 +   * \return an iterator to the first message TLV in this message.
   1.666 +   */
   1.667    TlvIterator TlvBegin ();
   1.668 +
   1.669 +  /**
   1.670 +   * \return a const iterator to the first message TLV in this message.
   1.671 +   */
   1.672    ConstTlvIterator TlvBegin () const;
   1.673 +
   1.674 +  /**
   1.675 +   * \return an iterator to the past-the-end message TLV element in this
   1.676 +   *         message.
   1.677 +   */
   1.678    TlvIterator TlvEnd ();
   1.679 +
   1.680 +  /**
   1.681 +   * \return a const iterator to the past-the-end message TLV element in this
   1.682 +   *         message.
   1.683 +   */
   1.684    ConstTlvIterator TlvEnd () const;
   1.685  
   1.686 +  /**
   1.687 +   * \return the number of message TLVs in this message.
   1.688 +   */
   1.689    int TlvSize (void) const;
   1.690 +
   1.691 +  /**
   1.692 +   * \return true if there are no message TLVs in this message, false otherwise.
   1.693 +   */
   1.694    bool TlvEmpty (void) const;
   1.695  
   1.696 +  /**
   1.697 +   * \return a smart pointer to the first message TLV in this message.
   1.698 +   */
   1.699    Ptr<PbbTlv> TlvFront (void);
   1.700 +
   1.701 +  /**
   1.702 +   * \return a const smart pointer to the first message TLV in this message.
   1.703 +   */
   1.704    const Ptr<PbbTlv> TlvFront (void) const;
   1.705 +
   1.706 +  /**
   1.707 +   * \return a smart pointer to the last message TLV in this message.
   1.708 +   */
   1.709    Ptr<PbbTlv> TlvBack (void);
   1.710 +
   1.711 +  /**
   1.712 +   * \return a const smart pointer to the last message TLV in this message.
   1.713 +   */
   1.714    const Ptr<PbbTlv> TlvBack (void) const;
   1.715  
   1.716 +  /**
   1.717 +   * \brief Prepends a message TLV to the front of this message.
   1.718 +   * \param tlv a smart pointer to the message TLV to prepend.
   1.719 +   */
   1.720    void TlvPushFront (Ptr<PbbTlv> tlv);
   1.721 +
   1.722 +  /**
   1.723 +   * \brief Removes a message TLV from the front of this message.
   1.724 +   */
   1.725    void TlvPopFront (void);
   1.726 +
   1.727 +  /**
   1.728 +   * \brief Appends a message TLV to the back of this message.
   1.729 +   * \param tlv a smart pointer to the message TLV to append.
   1.730 +   */
   1.731    void TlvPushBack (Ptr<PbbTlv> tlv);
   1.732 +
   1.733 +  /**
   1.734 +   * \brief Removes a message TLV from the back of this message.
   1.735 +   */
   1.736    void TlvPopBack (void);
   1.737  
   1.738 +  /**
   1.739 +   * \brief Removes the message TLV at the specified position.
   1.740 +   * \param position an Iterator pointing to the message TLV to erase.
   1.741 +   * \return an iterator pointing to the next TLV in the block.
   1.742 +   */
   1.743    TlvIterator TlvErase (TlvIterator position);
   1.744 +
   1.745 +  /**
   1.746 +   * \brief Removes all message TLVs from [first, last) (includes first, not
   1.747 +   *        includes last).
   1.748 +   * \param first an Iterator pointing to the first message TLV to erase
   1.749 +   *        (inclusive).
   1.750 +   * \param last an Iterator pointing to the element past the last message TLV
   1.751 +   *        to erase.
   1.752 +   * \return an iterator pointing to the next message TLV in the message.
   1.753 +   */
   1.754    TlvIterator TlvErase (TlvIterator first, TlvIterator last);
   1.755 +
   1.756 +  /**
   1.757 +   * \brief Removes all message TLVs from this block.
   1.758 +   */
   1.759    void TlvClear (void);
   1.760  
   1.761    /* Manipulating Address Block and Address TLV pairs */
   1.762  
   1.763 +  /**
   1.764 +   * \return an iterator to the first address block in this message.
   1.765 +   */
   1.766    AddressBlockIterator AddressBlockBegin ();
   1.767 +
   1.768 +  /**
   1.769 +   * \return a const iterator to the first address block in this message.
   1.770 +   */
   1.771    ConstAddressBlockIterator AddressBlockBegin () const;
   1.772 +
   1.773 +  /**
   1.774 +   * \return an iterator to the past-the-end address block element in this
   1.775 +   *         message.
   1.776 +   */
   1.777    AddressBlockIterator AddressBlockEnd ();
   1.778 +
   1.779 +  /**
   1.780 +   * \return a const iterator to the past-the-end address block element in this
   1.781 +   *         message.
   1.782 +   */
   1.783    ConstAddressBlockIterator AddressBlockEnd () const;
   1.784  
   1.785 +  /**
   1.786 +   * \return the number of address blocks in this message.
   1.787 +   */
   1.788    int AddressBlockSize (void) const;
   1.789 +
   1.790 +  /**
   1.791 +   * \return true if there are no address blocks in this message, false
   1.792 +   *         otherwise.
   1.793 +   */
   1.794    bool AddressBlockEmpty (void) const;
   1.795  
   1.796 +  /**
   1.797 +   * \return a smart pointer to the first address block in this message.
   1.798 +   */
   1.799    Ptr<PbbAddressBlock> AddressBlockFront (void);
   1.800 +
   1.801 +  /**
   1.802 +   * \return a const smart pointer to the first address block in this message.
   1.803 +   */
   1.804    const Ptr<PbbAddressBlock> AddressBlockFront (void) const;
   1.805 +
   1.806 +  /**
   1.807 +   * \return a smart pointer to the last address block in this message.
   1.808 +   */
   1.809    Ptr<PbbAddressBlock> AddressBlockBack (void);
   1.810 +
   1.811 +  /**
   1.812 +   * \return a const smart pointer to the last address block in this message.
   1.813 +   */
   1.814    const Ptr<PbbAddressBlock> AddressBlockBack (void) const;
   1.815  
   1.816 +  /**
   1.817 +   * \brief Prepends an address block to the front of this message.
   1.818 +   * \param block a smart pointer to the address block to prepend.
   1.819 +   */
   1.820    void AddressBlockPushFront (Ptr<PbbAddressBlock> block);
   1.821 +
   1.822 +  /**
   1.823 +   * \brief Removes an address block from the front of this message.
   1.824 +   */
   1.825    void AddressBlockPopFront (void);
   1.826 +
   1.827 +  /**
   1.828 +   * \brief Appends an address block to the front of this message.
   1.829 +   * \param block a smart pointer to the address block to append.
   1.830 +   */
   1.831    void AddressBlockPushBack (Ptr<PbbAddressBlock> block);
   1.832 +
   1.833 +  /**
   1.834 +   * \brief Removes an address block from the back of this message.
   1.835 +   */
   1.836    void AddressBlockPopBack (void);
   1.837  
   1.838 +  /**
   1.839 +   * \brief Removes the address block at the specified position.
   1.840 +   * \param position an Iterator pointing to the address block to erase.
   1.841 +   * \return an iterator pointing to the next address block in the message.
   1.842 +   */
   1.843    AddressBlockIterator AddressBlockErase (AddressBlockIterator position);
   1.844 +
   1.845 +  /**
   1.846 +   * \brief Removes all address blocks from [first, last) (includes first, not
   1.847 +   *        includes last).
   1.848 +   * \param first an Iterator pointing to the first address block to erase
   1.849 +   *        (inclusive).
   1.850 +   * \param last an Iterator pointing to the element past the last address
   1.851 +   *        block to erase.
   1.852 +   * \return an iterator pointing to the next address block in the message.
   1.853 +   */
   1.854    AddressBlockIterator AddressBlockErase (AddressBlockIterator first,
   1.855        AddressBlockIterator last);
   1.856 +
   1.857 +  /**
   1.858 +   * \brief Removes all address blocks from this message.
   1.859 +   */
   1.860    void AddressBlockClear (void);
   1.861  
   1.862    /* Smart pointer methods */
   1.863    void Ref (void) const;
   1.864    void Unref (void) const;
   1.865  
   1.866 -  /* Returns 0 on error */
   1.867 +  /**
   1.868 +   * \brief Deserializes a message, returning the correct object depending on
   1.869 +   *        whether it is an IPv4 message or an IPv6 message.
   1.870 +   * \param start a reference to the point in a buffer to begin deserializing.
   1.871 +   * \return A pointer to the deserialized message, or 0 on error.
   1.872 +   *
   1.873 +   * Users should not need to call this.  Blocks will be deserialized by their
   1.874 +   * containing packet.
   1.875 +   */
   1.876    static Ptr<PbbMessage> DeserializeMessage (Buffer::Iterator &start);
   1.877 +
   1.878 +  /**
   1.879 +   * \return The size (in bytes) needed to serialize this message.
   1.880 +   */
   1.881    uint32_t GetSerializedSize (void) const;
   1.882 +
   1.883 +  /**
   1.884 +   * \brief Serializes this message into the specified buffer.
   1.885 +   * \param start a reference to the point in a buffer to begin serializing.
   1.886 +   *
   1.887 +   * Users should not need to call this.  Blocks will be deserialized by their
   1.888 +   * containing packet.
   1.889 +   */
   1.890    void Serialize (Buffer::Iterator &start) const;
   1.891 +
   1.892 +  /**
   1.893 +   * \brief Deserializes a message from the specified buffer.
   1.894 +   * \param start a reference to the point in a buffer to begin deserializing.
   1.895 +   *
   1.896 +   * Users should not need to call this.  Blocks will be deserialized by their
   1.897 +   * containing packet.
   1.898 +   */
   1.899    void Deserialize (Buffer::Iterator &start);
   1.900 +
   1.901 +  /**
   1.902 +   * \brief Pretty-prints the contents of this message.
   1.903 +   * \param os a stream object to print to.
   1.904 +   */
   1.905    void Print (std::ostream &os) const;
   1.906 +
   1.907 +  /**
   1.908 +   * \brief Pretty-prints the contents of this message, with specified
   1.909 +   *        indentation.
   1.910 +   * \param os a stream object to print to.
   1.911 +   * \param level level of indentation.
   1.912 +   *
   1.913 +   * This probably never needs to be called by users.  This is used when
   1.914 +   * recursively printing sub-objects.
   1.915 +   */
   1.916    void Print (std::ostream &os, int level) const;
   1.917  
   1.918    bool operator== (const PbbMessage &other) const;
   1.919 @@ -462,95 +1093,349 @@
   1.920    typedef PbbAddressTlvBlock::Iterator TlvIterator;
   1.921    typedef PbbAddressTlvBlock::ConstIterator ConstTlvIterator;
   1.922  
   1.923 -  PbbAddressBlock ();
   1.924 +  PbbAddressBlock (void);
   1.925  
   1.926    /* Manipulating the address block */
   1.927  
   1.928 +  /**
   1.929 +   * \return an iterator to the first address in this block.
   1.930 +   */
   1.931    AddressIterator AddressBegin (void);
   1.932 +
   1.933 +  /**
   1.934 +   * \return a const iterator to the first address in this block.
   1.935 +   */
   1.936    ConstAddressIterator AddressBegin (void) const;
   1.937 +
   1.938 +  /**
   1.939 +   * \return an iterator to the last address in this block.
   1.940 +   */
   1.941    AddressIterator AddressEnd (void);
   1.942 +
   1.943 +  /**
   1.944 +   * \return a const iterator to the last address in this block.
   1.945 +   */
   1.946    ConstAddressIterator AddressEnd (void) const;
   1.947  
   1.948 +  /**
   1.949 +   * \return the number of addresses in this block.
   1.950 +   */
   1.951    int AddressSize (void) const;
   1.952 +
   1.953 +  /**
   1.954 +   * \return true if there are no addresses in this block, false otherwise.
   1.955 +   */
   1.956    bool AddressEmpty (void) const;
   1.957  
   1.958 +  /**
   1.959 +   * \return the first address in this block.
   1.960 +   */
   1.961    Address AddressFront (void) const;
   1.962 +
   1.963 +  /**
   1.964 +   * \return the last address in this block.
   1.965 +   */
   1.966    Address AddressBack (void) const;
   1.967  
   1.968 +  /**
   1.969 +   * \brief Prepends an address to the front of this block.
   1.970 +   * \param address the address to prepend.
   1.971 +   */
   1.972    void AddressPushFront (Address address);
   1.973 +
   1.974 +  /**
   1.975 +   * \brief Removes an address from the front of this block.
   1.976 +   */
   1.977    void AddressPopFront (void);
   1.978  
   1.979 +  /**
   1.980 +   * \brief Appends an address to the back of this block.
   1.981 +   * \param address the address to append.
   1.982 +   */
   1.983    void AddressPushBack (Address address);
   1.984 +
   1.985 +  /**
   1.986 +   * \brief Removes an address from the back of this block.
   1.987 +   */
   1.988    void AddressPopBack (void);
   1.989  
   1.990 +  /**
   1.991 +   * \brief Inserts an address at the specified position in this block.
   1.992 +   * \param position an Iterator pointing to the position in this block to
   1.993 +   *        insert the address.
   1.994 +   * \param value the address to insert.
   1.995 +   * \return An iterator pointing to the newly inserted address.
   1.996 +   */
   1.997    AddressIterator AddressInsert (AddressIterator position,
   1.998        const Address value);
   1.999  
  1.1000 +  /**
  1.1001 +   * \brief Removes the address at the specified position.
  1.1002 +   * \param position an Iterator pointing to the address to erase.
  1.1003 +   * \return an iterator pointing to the next address in the block.
  1.1004 +   */
  1.1005    AddressIterator AddressErase (AddressIterator position);
  1.1006 +
  1.1007 +  /**
  1.1008 +   * \brief Removes all addresses from [first, last) (includes first, not
  1.1009 +   *        includes last).
  1.1010 +   * \param first an Iterator pointing to the first address to erase
  1.1011 +   *        (inclusive).
  1.1012 +   * \param last an Iterator pointing to the element past the last address to
  1.1013 +   *        erase.
  1.1014 +   * \return an iterator pointing to the next address in the block.
  1.1015 +   */
  1.1016    AddressIterator AddressErase (AddressIterator first, AddressIterator last);
  1.1017  
  1.1018 +  /**
  1.1019 +   * \brief Removes all addresses from this block.
  1.1020 +   */
  1.1021    void AddressClear (void);
  1.1022  
  1.1023    /* Prefix methods */
  1.1024 +
  1.1025 +  /**
  1.1026 +   * \return an iterator to the first prefix in this block.
  1.1027 +   */
  1.1028    PrefixIterator PrefixBegin (void);
  1.1029 +
  1.1030 +  /**
  1.1031 +   * \return a const iterator to the first prefix in this block.
  1.1032 +   */
  1.1033    ConstPrefixIterator PrefixBegin (void) const;
  1.1034 +
  1.1035 +  /**
  1.1036 +   * \return an iterator to the last prefix in this block.
  1.1037 +   */
  1.1038    PrefixIterator PrefixEnd (void);
  1.1039 +
  1.1040 +  /**
  1.1041 +   * \return a const iterator to the last prefix in this block.
  1.1042 +   */
  1.1043    ConstPrefixIterator PrefixEnd (void) const;
  1.1044  
  1.1045 +  /**
  1.1046 +   * \return the number of prefixes in this block.
  1.1047 +   */
  1.1048    int PrefixSize (void) const;
  1.1049 +
  1.1050 +  /**
  1.1051 +   * \return true if there are no prefixes in this block, false otherwise.
  1.1052 +   */
  1.1053    bool PrefixEmpty (void) const;
  1.1054  
  1.1055 +  /**
  1.1056 +   * \return the first prefix in this block.
  1.1057 +   */
  1.1058    uint8_t PrefixFront (void) const;
  1.1059 +
  1.1060 +  /**
  1.1061 +   * \return the last prefix in this block.
  1.1062 +   */
  1.1063    uint8_t PrefixBack (void) const;
  1.1064  
  1.1065 +  /**
  1.1066 +   * \brief Prepends a prefix to the front of this block.
  1.1067 +   * \param prefix the prefix to prepend.
  1.1068 +   */
  1.1069    void PrefixPushFront (uint8_t prefix);
  1.1070 +
  1.1071 +  /**
  1.1072 +   * \brief Removes a prefix from the front of this block.
  1.1073 +   */
  1.1074    void PrefixPopFront (void);
  1.1075  
  1.1076 +  /**
  1.1077 +   * \brief Appends a prefix to the back of this block.
  1.1078 +   * \param prefix the prefix to append.
  1.1079 +   */
  1.1080    void PrefixPushBack (uint8_t prefix);
  1.1081 +
  1.1082 +  /**
  1.1083 +   * \brief Removes a prefix from the back of this block.
  1.1084 +   */
  1.1085    void PrefixPopBack (void);
  1.1086  
  1.1087 +  /**
  1.1088 +   * \brief Inserts a prefix at the specified position in this block.
  1.1089 +   * \param position an Iterator pointing to the position in this block to
  1.1090 +   *        insert the prefix.
  1.1091 +   * \param value the prefix to insert.
  1.1092 +   * \return An iterator pointing to the newly inserted prefix.
  1.1093 +   */
  1.1094    PrefixIterator PrefixInsert (PrefixIterator position, const uint8_t value);
  1.1095  
  1.1096 +  /**
  1.1097 +   * \brief Removes the prefix at the specified position.
  1.1098 +   * \param position an Iterator pointing to the prefix to erase.
  1.1099 +   * \return an iterator pointing to the next prefix in the block.
  1.1100 +   */
  1.1101    PrefixIterator PrefixErase (PrefixIterator position);
  1.1102 +
  1.1103 +  /**
  1.1104 +   * \brief Removes all prefixes from [first, last) (includes first, not
  1.1105 +   *        includes last).
  1.1106 +   * \param first an Iterator pointing to the first prefix to erase
  1.1107 +   *        (inclusive).
  1.1108 +   * \param last an Iterator pointing to the element past the last prefix to
  1.1109 +   *        erase.
  1.1110 +   * \return an iterator pointing to the next prefix in the block.
  1.1111 +   */
  1.1112    PrefixIterator PrefixErase (PrefixIterator first, PrefixIterator last);
  1.1113  
  1.1114 +  /**
  1.1115 +   * \brief Removes all prefixes from this block.
  1.1116 +   */
  1.1117    void PrefixClear (void);
  1.1118  
  1.1119    /* Manipulating the TLV block */
  1.1120 +
  1.1121 +  /**
  1.1122 +   * \return an iterator to the first address TLV in this block.
  1.1123 +   */
  1.1124    TlvIterator TlvBegin (void);
  1.1125 +
  1.1126 +  /**
  1.1127 +   * \return a const iterator to the first address TLV in this block.
  1.1128 +   */
  1.1129    ConstTlvIterator TlvBegin (void) const;
  1.1130 +
  1.1131 +  /**
  1.1132 +   * \return an iterator to the last address TLV in this block.
  1.1133 +   */
  1.1134    TlvIterator TlvEnd (void);
  1.1135 +
  1.1136 +  /**
  1.1137 +   * \return a const iterator to the last address TLV in this block.
  1.1138 +   */
  1.1139    ConstTlvIterator TlvEnd (void) const;
  1.1140  
  1.1141 +  /**
  1.1142 +   * \return the number of address TLVs in this block.
  1.1143 +   */
  1.1144    int TlvSize (void) const;
  1.1145 +
  1.1146 +  /**
  1.1147 +   * \return true if there are no address TLVs in this block, false otherwise.
  1.1148 +   */
  1.1149    bool TlvEmpty (void) const;
  1.1150  
  1.1151 +  /**
  1.1152 +   * \return a smart pointer to the first address TLV in this block.
  1.1153 +   */
  1.1154    Ptr<PbbAddressTlv> TlvFront (void);
  1.1155 +
  1.1156 +  /**
  1.1157 +   * \return a const smart pointer to the first address TLV in this message.
  1.1158 +   */
  1.1159    const Ptr<PbbAddressTlv> TlvFront (void) const;
  1.1160 +
  1.1161 +  /**
  1.1162 +   * \return a smart pointer to the last address TLV in this message.
  1.1163 +   */
  1.1164    Ptr<PbbAddressTlv> TlvBack (void);
  1.1165 +
  1.1166 +  /**
  1.1167 +   * \return a const smart pointer to the last address TLV in this message.
  1.1168 +   */
  1.1169    const Ptr<PbbAddressTlv> TlvBack (void) const;
  1.1170  
  1.1171 +  /**
  1.1172 +   * \brief Prepends an address TLV to the front of this message.
  1.1173 +   * \param address a smart pointer to the address TLV to prepend.
  1.1174 +   */
  1.1175    void TlvPushFront (Ptr<PbbAddressTlv> address);
  1.1176 +
  1.1177 +  /**
  1.1178 +   * \brief Removes an address TLV from the front of this message.
  1.1179 +   */
  1.1180    void TlvPopFront (void);
  1.1181  
  1.1182 +  /**
  1.1183 +   * \brief Appends an address TLV to the back of this message.
  1.1184 +   * \param address a smart pointer to the address TLV to append.
  1.1185 +   */
  1.1186    void TlvPushBack (Ptr<PbbAddressTlv> address);
  1.1187 +
  1.1188 +  /**
  1.1189 +   * \brief Removes an address TLV from the back of this message.
  1.1190 +   */
  1.1191    void TlvPopBack (void);
  1.1192  
  1.1193 +  /**
  1.1194 +   * \brief Inserts an address TLV at the specified position in this block.
  1.1195 +   * \param position an Iterator pointing to the position in this block to
  1.1196 +   *        insert the address TLV.
  1.1197 +   * \param value the prefix to insert.
  1.1198 +   * \return An iterator pointing to the newly inserted address TLV.
  1.1199 +   */
  1.1200    TlvIterator TlvInsert (TlvIterator position, const Ptr<PbbTlv> value);
  1.1201  
  1.1202 +  /**
  1.1203 +   * \brief Removes the address TLV at the specified position.
  1.1204 +   * \param position an Iterator pointing to the address TLV to erase.
  1.1205 +   * \return an iterator pointing to the next address TLV in the block.
  1.1206 +   */
  1.1207    TlvIterator TlvErase (TlvIterator position);
  1.1208 +
  1.1209 +  /**
  1.1210 +   * \brief Removes all address TLVs from [first, last) (includes first, not
  1.1211 +   *        includes last).
  1.1212 +   * \param first an Iterator pointing to the first address TLV to erase
  1.1213 +   *        (inclusive).
  1.1214 +   * \param last an Iterator pointing to the element past the last address TLV
  1.1215 +   *        to erase.
  1.1216 +   * \return an iterator pointing to the next address TLV in the message.
  1.1217 +   */
  1.1218    TlvIterator TlvErase (TlvIterator first, TlvIterator last);
  1.1219  
  1.1220 +  /**
  1.1221 +   * \brief Removes all address TLVs from this block.
  1.1222 +   */
  1.1223    void TlvClear (void);
  1.1224  
  1.1225    /* Smart pointer methods */
  1.1226    void Ref (void) const;
  1.1227    void Unref (void) const;
  1.1228  
  1.1229 +  /**
  1.1230 +   * \return The size (in bytes) needed to serialize this address block.
  1.1231 +   */
  1.1232    uint32_t GetSerializedSize (void) const;
  1.1233 +
  1.1234 +  /**
  1.1235 +   * \brief Serializes this address block into the specified buffer.
  1.1236 +   * \param start a reference to the point in a buffer to begin serializing.
  1.1237 +   *
  1.1238 +   * Users should not need to call this.  Blocks will be deserialized by their
  1.1239 +   * containing packet.
  1.1240 +   */
  1.1241    void Serialize (Buffer::Iterator &start) const;
  1.1242 +
  1.1243 +  /**
  1.1244 +   * \brief Deserializes an address block from the specified buffer.
  1.1245 +   * \param start a reference to the point in a buffer to begin deserializing.
  1.1246 +   *
  1.1247 +   * Users should not need to call this.  Blocks will be deserialized by their
  1.1248 +   * containing packet.
  1.1249 +   */
  1.1250    void Deserialize (Buffer::Iterator &start);
  1.1251 +
  1.1252 +  /**
  1.1253 +   * \brief Pretty-prints the contents of this address block.
  1.1254 +   * \param os a stream object to print to.
  1.1255 +   */
  1.1256    void Print (std::ostream &os) const;
  1.1257 +
  1.1258 +  /**
  1.1259 +   * \brief Pretty-prints the contents of this address block, with specified
  1.1260 +   *        indentation.
  1.1261 +   * \param os a stream object to print to.
  1.1262 +   * \param level level of indentation.
  1.1263 +   *
  1.1264 +   * This probably never needs to be called by users.  This is used when
  1.1265 +   * recursively printing sub-objects.
  1.1266 +   */
  1.1267    void Print (std::ostream &os, int level) const;
  1.1268  
  1.1269    bool operator== (const PbbAddressBlock &other) const;
  1.1270 @@ -614,38 +1499,120 @@
  1.1271  public:
  1.1272    PbbTlv (void);
  1.1273  
  1.1274 +  /**
  1.1275 +   * \brief Sets the type of this TLV.
  1.1276 +   * \param type the type value to set.
  1.1277 +   */
  1.1278    void SetType (uint8_t type);
  1.1279 +
  1.1280 +  /**
  1.1281 +   * \return the type of this TLV.
  1.1282 +   */
  1.1283    uint8_t GetType (void) const;
  1.1284  
  1.1285 +  /**
  1.1286 +   * \brief Sets the type extension of this TLV.
  1.1287 +   * \param type the type extension value to set.
  1.1288 +   *
  1.1289 +   * The type extension is like a sub-type used to further distinguish between
  1.1290 +   * TLVs of the same type.
  1.1291 +   */
  1.1292    void SetTypeExt (uint8_t type);
  1.1293 +
  1.1294    /**
  1.1295 -   * \returns the type extension for this TLV.
  1.1296 +   * \return the type extension for this TLV.
  1.1297     *
  1.1298     * Calling this while HasTypeExt is False is undefined.  Make sure you check
  1.1299     * it first.  This will be checked by an assert in debug builds.
  1.1300     */
  1.1301    uint8_t GetTypeExt (void) const;
  1.1302 +
  1.1303 +  /**
  1.1304 +   * \brief Tests whether or not this TLV has a type extension.
  1.1305 +   * \return true if this TLV has a type extension, false otherwise.
  1.1306 +   *
  1.1307 +   * This should be called before calling GetTypeExt to make sure there
  1.1308 +   * actually is one.
  1.1309 +   */
  1.1310    bool HasTypeExt (void) const;
  1.1311  
  1.1312 +  /**
  1.1313 +   * \brief Sets the value of this message to the specified buffer.
  1.1314 +   * \param start a buffer instance.
  1.1315 +   *
  1.1316 +   * The buffer is _not_ copied until this TLV is serialized.  You should not
  1.1317 +   * change the contents of the buffer you pass in to this function.
  1.1318 +   */
  1.1319    void SetValue (Buffer start);
  1.1320 +
  1.1321 +  /**
  1.1322 +   * \brief Sets the value of this message to a buffer with the specified data.
  1.1323 +   * \param buffer a pointer to data to put in the TLVs buffer.
  1.1324 +   * \param size the size of the buffer.
  1.1325 +   *
  1.1326 +   * The buffer *is copied* into a *new buffer instance*.  You can free the
  1.1327 +   * data in the buffer provided anytime you wish.
  1.1328 +   */
  1.1329    void SetValue (const uint8_t * buffer, uint32_t size);
  1.1330 +
  1.1331    /**
  1.1332 -   * \returns a Buffer pointing to the value of this TLV.
  1.1333 +   * \return a Buffer pointing to the value of this TLV.
  1.1334     *
  1.1335     * Calling this while HasValue is False is undefined.  Make sure you check it
  1.1336     * first.  This will be checked by an assert in debug builds.
  1.1337     */
  1.1338    Buffer GetValue (void) const;
  1.1339 +
  1.1340 +  /**
  1.1341 +   * \brief Tests whether or not this TLV has a value.
  1.1342 +   * \return true if this tlv has a TLV, false otherwise.
  1.1343 +   *
  1.1344 +   * This should be called before calling GetTypeExt to make sure there
  1.1345 +   * actually is one.
  1.1346 +   */
  1.1347    bool HasValue (void) const;
  1.1348  
  1.1349    /* Smart pointer methods */
  1.1350    void Ref (void) const;
  1.1351    void Unref (void) const;
  1.1352  
  1.1353 +  /**
  1.1354 +   * \return The size (in bytes) needed to serialize this TLV.
  1.1355 +   */
  1.1356    uint32_t GetSerializedSize (void) const;
  1.1357 +
  1.1358 +  /**
  1.1359 +   * \brief Serializes this TLV into the specified buffer.
  1.1360 +   * \param start a reference to the point in a buffer to begin serializing.
  1.1361 +   *
  1.1362 +   * Users should not need to call this.  TLVs will be serialized by their
  1.1363 +   * containing blocks.
  1.1364 +   */
  1.1365    void Serialize (Buffer::Iterator &start) const;
  1.1366 +
  1.1367 +  /**
  1.1368 +   * \brief Deserializes a TLV from the specified buffer.
  1.1369 +   * \param start a reference to the point in a buffer to begin deserializing.
  1.1370 +   *
  1.1371 +   * Users should not need to call this.  TLVs will be deserialized by their
  1.1372 +   * containing blocks.
  1.1373 +   */
  1.1374    void Deserialize (Buffer::Iterator &start);
  1.1375 +
  1.1376 +  /**
  1.1377 +   * \brief Pretty-prints the contents of this TLV.
  1.1378 +   * \param os a stream object to print to.
  1.1379 +   */
  1.1380    void Print (std::ostream &os) const;
  1.1381 +
  1.1382 +  /**
  1.1383 +   * \brief Pretty-prints the contents of this TLV, with specified indentation.
  1.1384 +   * \param os a stream object to print to.
  1.1385 +   * \param level level of indentation.
  1.1386 +   *
  1.1387 +   * This probably never needs to be called by users.  This is used when
  1.1388 +   * recursively printing sub-objects.
  1.1389 +   */
  1.1390    void Print (std::ostream &os, int level) const;
  1.1391  
  1.1392    bool operator== (const PbbTlv &other) const;
  1.1393 @@ -688,29 +1655,70 @@
  1.1394  class PbbAddressTlv : public PbbTlv
  1.1395  {
  1.1396  public:
  1.1397 +  /**
  1.1398 +   * \brief Sets the index of the first address in the associated address block
  1.1399 +   * that this address TLV applies to.
  1.1400 +   * \param index the index of the first address.
  1.1401 +   */
  1.1402    void SetIndexStart (uint8_t index);
  1.1403 +
  1.1404    /**
  1.1405 -   * \returns the first (inclusive) index of the address in the corresponding
  1.1406 -   * PbbAddressBlock that this TLV applies to.
  1.1407 +   * \return the first (inclusive) index of the address in the corresponding
  1.1408 +   * address block that this TLV applies to.
  1.1409     *
  1.1410     * Calling this while HasIndexStart is False is undefined.  Make sure you
  1.1411     * check it first.  This will be checked by an assert in debug builds.
  1.1412     */
  1.1413    uint8_t GetIndexStart (void) const;
  1.1414 +
  1.1415 +  /**
  1.1416 +   * \brief Tests whether or not this address TLV has a start index.
  1.1417 +   * \return true if this address TLV has a start index, false otherwise.
  1.1418 +   *
  1.1419 +   * This should be called before calling GetIndexStart to make sure there
  1.1420 +   * actually is one.
  1.1421 +   */
  1.1422    bool HasIndexStart (void) const;
  1.1423  
  1.1424 +  /**
  1.1425 +   * \brief Sets the index of the last address in the associated address block
  1.1426 +   * that this address TLV applies to.
  1.1427 +   * \param index the index of the last address.
  1.1428 +   */
  1.1429    void SetIndexStop (uint8_t index);
  1.1430 +
  1.1431    /**
  1.1432 -   * \returns the last (inclusive) index of the address in the corresponding
  1.1433 +   * \return the last (inclusive) index of the address in the corresponding
  1.1434     * PbbAddressBlock that this TLV applies to.
  1.1435     *
  1.1436     * Calling this while HasIndexStop is False is undefined.  Make sure you
  1.1437     * check it first.  This will be checked by an assert in debug builds.
  1.1438     */
  1.1439    uint8_t GetIndexStop (void) const;
  1.1440 +
  1.1441 +  /**
  1.1442 +   * \brief Tests whether or not this address TLV has a stop index.
  1.1443 +   * \return true if this address TLV has a stop index, false otherwise.
  1.1444 +   *
  1.1445 +   * This should be called before calling GetIndexStop to make sure there
  1.1446 +   * actually is one.
  1.1447 +   */
  1.1448    bool HasIndexStop (void) const;
  1.1449  
  1.1450 +  /**
  1.1451 +   * \brief Sets whether or not this address TLV is "multivalue"
  1.1452 +   * \param isMultivalue whether or not this address TLV should be multivalue.
  1.1453 +   *
  1.1454 +   * If true, this means the value associated with this TLV should be divided
  1.1455 +   * evenly into (GetIndexStop() - GetIndexStart() + 1) values.  Otherwise, the
  1.1456 +   * value is one single value that applies to each address in the range.
  1.1457 +   */
  1.1458    void SetMultivalue (bool isMultivalue);
  1.1459 +
  1.1460 +  /**
  1.1461 +   * \brief Tests whether or not this address TLV is "multivalue"
  1.1462 +   * \return whether this address TLV is multivalue or not.
  1.1463 +   */
  1.1464    bool IsMultivalue (void) const;
  1.1465  };
  1.1466