Fixed bug in serialization of PbbAddressBlock.
authorTom Wambold <tom5760@gmail.com>
Tue, 29 Dec 2009 13:09:26 -0500
changeset 5885 d6ee673adda4
parent 5884 46614fa27eae
child 5890 9c48446a0946
Fixed bug in serialization of PbbAddressBlock. PbbAddressBlock would not set its flags correctly when there was only a single address in the address block.
src/node/packetbb.cc
--- a/src/node/packetbb.cc	Tue Dec 29 09:39:52 2009 -0800
+++ b/src/node/packetbb.cc	Tue Dec 29 13:09:26 2009 -0500
@@ -2014,11 +2014,12 @@
 PbbAddressBlock::Serialize (Buffer::Iterator &start) const
 {
   start.WriteU8 (AddressSize ());
+  Buffer::Iterator bufref = start;
+  uint8_t flags = 0;
+  start.Next ();
 
   if (AddressSize () == 1)
     {
-      start.WriteU8 (0);
-
       uint8_t buf[GetAddressLength ()];
       SerializeAddress (buf, AddressBegin ());
       start.Write (buf, GetAddressLength ());
@@ -2026,14 +2027,12 @@
       if (PrefixSize () == 1)
         {
           start.WriteU8 (PrefixFront ());
+          flags |= AHAS_SINGLE_PRE_LEN;
         }
+      bufref.WriteU8 (flags);
     }
   else if (AddressSize () > 0)
     {
-      Buffer::Iterator bufref = start;
-      uint8_t flags = 0;
-      start.Next ();
-
       uint8_t head[GetAddressLength ()];
       uint8_t tail[GetAddressLength ()];
       uint8_t headlen = 0;