View | Details | Raw Unified | Return to bug 1050
Collapse All | Expand All

(-)a/src/network/utils/packetbb.cc (-13 / +29 lines)
 Lines 1590-1606    Link Here 
1590
void
1590
void
1591
PbbMessageIpv4::SerializeOriginatorAddress (Buffer::Iterator &start) const
1591
PbbMessageIpv4::SerializeOriginatorAddress (Buffer::Iterator &start) const
1592
{
1592
{
1593
  uint8_t buffer[GetAddressLength () + 1];
1593
  uint8_t* buffer = new uint8_t[GetAddressLength () + 1];
1594
  Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
1594
  Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
1595
  start.Write (buffer, GetAddressLength () + 1);
1595
  start.Write (buffer, GetAddressLength () + 1);
1596
  delete[] buffer;
1596
}
1597
}
1597
1598
1598
Address
1599
Address
1599
PbbMessageIpv4::DeserializeOriginatorAddress (Buffer::Iterator &start) const
1600
PbbMessageIpv4::DeserializeOriginatorAddress (Buffer::Iterator &start) const
1600
{
1601
{
1601
  uint8_t buffer[GetAddressLength () + 1];
1602
  uint8_t* buffer = new uint8_t[GetAddressLength () + 1];
1602
  start.Read(buffer, GetAddressLength () + 1);
1603
  start.Read(buffer, GetAddressLength () + 1);
1603
  return Ipv4Address::Deserialize (buffer);
1604
  Address res = Ipv4Address::Deserialize (buffer);
1605
  delete[] buffer;
1606
  return res;
1604
}
1607
}
1605
1608
1606
void
1609
void
 Lines 1636-1652    Link Here 
1636
void
1639
void
1637
PbbMessageIpv6::SerializeOriginatorAddress (Buffer::Iterator &start) const
1640
PbbMessageIpv6::SerializeOriginatorAddress (Buffer::Iterator &start) const
1638
{
1641
{
1639
  uint8_t buffer[GetAddressLength () + 1];
1642
  uint8_t* buffer = new uint8_t[GetAddressLength () + 1];
1640
  Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
1643
  Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
1641
  start.Write (buffer, GetAddressLength () + 1);
1644
  start.Write (buffer, GetAddressLength () + 1);
1645
  delete[] buffer;
1642
}
1646
}
1643
1647
1644
Address
1648
Address
1645
PbbMessageIpv6::DeserializeOriginatorAddress (Buffer::Iterator &start) const
1649
PbbMessageIpv6::DeserializeOriginatorAddress (Buffer::Iterator &start) const
1646
{
1650
{
1647
  uint8_t buffer[GetAddressLength () + 1];
1651
  uint8_t* buffer = new uint8_t[GetAddressLength () + 1];
1648
  start.Read(buffer, GetAddressLength () + 1);
1652
  start.Read(buffer, GetAddressLength () + 1);
1649
  return Ipv6Address::Deserialize (buffer);
1653
  Address res = Ipv6Address::Deserialize (buffer);
1654
  delete[] buffer;
1655
  return res;
1650
}
1656
}
1651
1657
1652
void
1658
void
 Lines 1978-1986    Link Here 
1978
    }
1984
    }
1979
  else if (AddressSize () > 0)
1985
  else if (AddressSize () > 0)
1980
    {
1986
    {
1981
      uint8_t head[GetAddressLength ()];
1987
      uint8_t* head = new uint8_t[GetAddressLength ()];
1982
      uint8_t headlen = 0;
1988
      uint8_t headlen = 0;
1983
      uint8_t tail[GetAddressLength ()];
1989
      uint8_t* tail = new uint8_t[GetAddressLength ()];
1984
      uint8_t taillen = 0;
1990
      uint8_t taillen = 0;
1985
1991
1986
      GetHeadTail (head, headlen, tail, taillen);
1992
      GetHeadTail (head, headlen, tail, taillen);
 Lines 2003-2008    Link Here 
2003
      size += (GetAddressLength () - headlen - taillen) * AddressSize ();
2009
      size += (GetAddressLength () - headlen - taillen) * AddressSize ();
2004
2010
2005
      size += PrefixSize ();
2011
      size += PrefixSize ();
2012
2013
      delete[] head;
2014
      delete[] tail;
2006
    }
2015
    }
2007
2016
2008
  size += m_addressTlvList.GetSerializedSize ();
2017
  size += m_addressTlvList.GetSerializedSize ();
 Lines 2020-2026    Link Here 
2020
2029
2021
  if (AddressSize () == 1)
2030
  if (AddressSize () == 1)
2022
    {
2031
    {
2023
      uint8_t buf[GetAddressLength ()];
2032
      uint8_t* buf = new uint8_t[GetAddressLength ()];
2024
      SerializeAddress (buf, AddressBegin ());
2033
      SerializeAddress (buf, AddressBegin ());
2025
      start.Write (buf, GetAddressLength ());
2034
      start.Write (buf, GetAddressLength ());
2026
2035
 Lines 2030-2040    Link Here 
2030
          flags |= AHAS_SINGLE_PRE_LEN;
2039
          flags |= AHAS_SINGLE_PRE_LEN;
2031
        }
2040
        }
2032
      bufref.WriteU8 (flags);
2041
      bufref.WriteU8 (flags);
2042
      delete[] buf;
2033
    }
2043
    }
2034
  else if (AddressSize () > 0)
2044
  else if (AddressSize () > 0)
2035
    {
2045
    {
2036
      uint8_t head[GetAddressLength ()];
2046
      uint8_t* head = new uint8_t[GetAddressLength ()];
2037
      uint8_t tail[GetAddressLength ()];
2047
      uint8_t* tail = new uint8_t[GetAddressLength ()];
2038
      uint8_t headlen = 0;
2048
      uint8_t headlen = 0;
2039
      uint8_t taillen = 0;
2049
      uint8_t taillen = 0;
2040
2050
 Lines 2064-2070    Link Here 
2064
2074
2065
      if (headlen + taillen < GetAddressLength ())
2075
      if (headlen + taillen < GetAddressLength ())
2066
        {
2076
        {
2067
          uint8_t mid[GetAddressLength ()];
2077
          uint8_t* mid = new uint8_t[GetAddressLength ()];
2068
          for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin ();
2078
          for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin ();
2069
              iter != AddressEnd ();
2079
              iter != AddressEnd ();
2070
              iter++)
2080
              iter++)
 Lines 2072-2077    Link Here 
2072
              SerializeAddress (mid, iter);
2082
              SerializeAddress (mid, iter);
2073
              start.Write (mid + headlen, GetAddressLength () - headlen - taillen);
2083
              start.Write (mid + headlen, GetAddressLength () - headlen - taillen);
2074
            }
2084
            }
2085
          delete mid;
2075
        }
2086
        }
2076
2087
2077
      flags |= GetPrefixFlags ();
2088
      flags |= GetPrefixFlags ();
 Lines 2083-2088    Link Here 
2083
        {
2094
        {
2084
          start.WriteU8 (*iter);
2095
          start.WriteU8 (*iter);
2085
        }
2096
        }
2097
2098
      delete[] head;
2099
      delete[] tail;
2086
    }
2100
    }
2087
  
2101
  
2088
  m_addressTlvList.Serialize (start);
2102
  m_addressTlvList.Serialize (start);
 Lines 2098-2104    Link Here 
2098
    {
2112
    {
2099
      uint8_t headlen = 0;
2113
      uint8_t headlen = 0;
2100
      uint8_t taillen = 0;
2114
      uint8_t taillen = 0;
2101
      uint8_t addrtmp[GetAddressLength ()];
2115
      uint8_t* addrtmp = new uint8_t[GetAddressLength ()];
2102
      memset(addrtmp, 0, GetAddressLength ());
2116
      memset(addrtmp, 0, GetAddressLength ());
2103
2117
2104
      if (flags & AHAS_HEAD)
2118
      if (flags & AHAS_HEAD)
 Lines 2134-2139    Link Here 
2134
              PrefixPushBack (start.ReadU8 ());
2148
              PrefixPushBack (start.ReadU8 ());
2135
            }
2149
            }
2136
        }
2150
        }
2151
2152
      delete[] addrtmp;
2137
    }
2153
    }
2138
2154
2139
  m_addressTlvList.Deserialize (start);
2155
  m_addressTlvList.Deserialize (start);

Return to bug 1050