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

(-)a/src/internet-stack/icmpv6-header.cc (-5 / +25 lines)
 Lines 983-992    Link Here 
983
983
984
void Icmpv6DestinationUnreachable::Serialize (Buffer::Iterator start) const
984
void Icmpv6DestinationUnreachable::Serialize (Buffer::Iterator start) const
985
{
985
{
986
  const uint8_t *packet = m_packet->PeekData ();
986
  uint8_t *packet = new uint8_t[m_packet->GetSize ()];
987
  uint16_t checksum = 0;
987
  uint16_t checksum = 0;
988
  Buffer::Iterator i = start;
988
  Buffer::Iterator i = start;
989
989
990
  m_packet->CopyData (packet, m_packet->GetSize ());
991
990
  i.WriteU8 (GetType ());
992
  i.WriteU8 (GetType ());
991
  i.WriteU8 (GetCode ());
993
  i.WriteU8 (GetCode ());
992
  i.WriteHtonU16 (0);
994
  i.WriteHtonU16 (0);
 Lines 1000-1005    Link Here 
1000
  i = start;
1002
  i = start;
1001
  i.Next (2);
1003
  i.Next (2);
1002
  i.WriteU16 (checksum);
1004
  i.WriteU16 (checksum);
1005
1006
  delete[] packet;
1003
}
1007
}
1004
1008
1005
uint32_t Icmpv6DestinationUnreachable::Deserialize (Buffer::Iterator start)
1009
uint32_t Icmpv6DestinationUnreachable::Deserialize (Buffer::Iterator start)
 Lines 1078-1087    Link Here 
1078
1082
1079
void Icmpv6TooBig::Serialize (Buffer::Iterator start) const
1083
void Icmpv6TooBig::Serialize (Buffer::Iterator start) const
1080
{
1084
{
1081
  const uint8_t *packet = m_packet->PeekData ();
1085
  uint8_t *packet = new uint8_t[m_packet->GetSize ()];
1082
  uint16_t checksum = 0;
1086
  uint16_t checksum = 0;
1083
  Buffer::Iterator i = start;
1087
  Buffer::Iterator i = start;
1084
1088
1089
  m_packet->CopyData (packet, m_packet->GetSize ());
1090
1085
  i.WriteU8 (GetType ());
1091
  i.WriteU8 (GetType ());
1086
  i.WriteU8 (GetCode ());
1092
  i.WriteU8 (GetCode ());
1087
  i.WriteHtonU16 (0);
1093
  i.WriteHtonU16 (0);
 Lines 1095-1100    Link Here 
1095
  i = start;
1101
  i = start;
1096
  i.Next (2);
1102
  i.Next (2);
1097
  i.WriteU16 (checksum);
1103
  i.WriteU16 (checksum);
1104
1105
  delete[] packet;
1098
}
1106
}
1099
1107
1100
uint32_t Icmpv6TooBig::Deserialize (Buffer::Iterator start) 
1108
uint32_t Icmpv6TooBig::Deserialize (Buffer::Iterator start) 
 Lines 1162-1171    Link Here 
1162
1170
1163
void Icmpv6TimeExceeded::Serialize (Buffer::Iterator start) const
1171
void Icmpv6TimeExceeded::Serialize (Buffer::Iterator start) const
1164
{
1172
{
1165
  const uint8_t *packet = m_packet->PeekData ();
1173
  uint8_t *packet = new uint8_t[m_packet->GetSize ()];
1166
  uint16_t checksum = 0;
1174
  uint16_t checksum = 0;
1167
  Buffer::Iterator i = start;
1175
  Buffer::Iterator i = start;
1168
1176
1177
  m_packet->CopyData (packet, m_packet->GetSize ());
1178
1169
  i.WriteU8 (GetType ());
1179
  i.WriteU8 (GetType ());
1170
  i.WriteU8 (GetCode ());
1180
  i.WriteU8 (GetCode ());
1171
  i.WriteHtonU16 (0);
1181
  i.WriteHtonU16 (0);
 Lines 1179-1184    Link Here 
1179
  i = start;
1189
  i = start;
1180
  i.Next (2);
1190
  i.Next (2);
1181
  i.WriteU16 (checksum);
1191
  i.WriteU16 (checksum);
1192
1193
  delete[] packet;
1182
}
1194
}
1183
1195
1184
uint32_t Icmpv6TimeExceeded::Deserialize (Buffer::Iterator start)
1196
uint32_t Icmpv6TimeExceeded::Deserialize (Buffer::Iterator start)
 Lines 1257-1266    Link Here 
1257
1269
1258
void Icmpv6ParameterError::Serialize (Buffer::Iterator start) const 
1270
void Icmpv6ParameterError::Serialize (Buffer::Iterator start) const 
1259
{
1271
{
1260
  const uint8_t *packet = m_packet->PeekData ();
1272
  uint8_t *packet = new uint8_t[m_packet->GetSize ()];
1261
  uint16_t checksum = 0;
1273
  uint16_t checksum = 0;
1262
  Buffer::Iterator i = start;
1274
  Buffer::Iterator i = start;
1263
1275
1276
  m_packet->CopyData (packet, m_packet->GetSize ());
1277
1264
  i.WriteU8 (GetType ());
1278
  i.WriteU8 (GetType ());
1265
  i.WriteU8 (GetCode ());
1279
  i.WriteU8 (GetCode ());
1266
  i.WriteHtonU16 (0);
1280
  i.WriteHtonU16 (0);
 Lines 1274-1279    Link Here 
1274
  i = start;
1288
  i = start;
1275
  i.Next (2);
1289
  i.Next (2);
1276
  i.WriteU16 (checksum);
1290
  i.WriteU16 (checksum);
1291
1292
  delete[] packet;
1277
}
1293
}
1278
1294
1279
uint32_t Icmpv6ParameterError::Deserialize (Buffer::Iterator start) 
1295
uint32_t Icmpv6ParameterError::Deserialize (Buffer::Iterator start) 
 Lines 1749-1755    Link Here 
1749
  i.WriteU16 (0);
1765
  i.WriteU16 (0);
1750
  i.WriteU32 (0);
1766
  i.WriteU32 (0);
1751
1767
1752
  i.Write (m_packet->PeekData (), m_packet->GetSize ());
1768
  uint32_t size = m_packet->GetSize ();
1769
  uint8_t *packet = new uint8_t[size];
1770
  m_packet->CopyData (packet, size);
1771
  i.Write (packet, size);
1772
  delete[] packet;
1753
}
1773
}
1754
1774
1755
uint32_t Icmpv6OptionRedirected::Deserialize (Buffer::Iterator start)
1775
uint32_t Icmpv6OptionRedirected::Deserialize (Buffer::Iterator start)
(-)a/src/internet-stack/ipv6-extension.cc (-9 / +46 lines)
 Lines 97-106    Link Here 
97
  Ptr<Ipv6Option> ipv6Option;
97
  Ptr<Ipv6Option> ipv6Option;
98
98
99
  uint8_t processedSize = 0;
99
  uint8_t processedSize = 0;
100
  const uint8_t *data = p->PeekData ();
100
  uint8_t *data = new uint8_t[p->GetSize ()];
101
  uint8_t optionType = 0;
101
  uint8_t optionType = 0;
102
  uint8_t optionLength = 0;
102
  uint8_t optionLength = 0;
103
103
104
  p->CopyData (data, p->GetSize ());
105
104
  while (length > processedSize && !isDropped)
106
  while (length > processedSize && !isDropped)
105
    {
107
    {
106
      optionType = *(data + processedSize);
108
      optionType = *(data + processedSize);
 Lines 161-166    Link Here 
161
      p->RemoveAtStart (optionLength);
163
      p->RemoveAtStart (optionLength);
162
    }
164
    }
163
165
166
  delete[] data;
167
164
  return processedSize;
168
  return processedSize;
165
}
169
}
166
170
 Lines 377-386    Link Here 
377
381
378
  uint8_t nextHeader = ipv6Header.GetNextHeader ();
382
  uint8_t nextHeader = ipv6Header.GetNextHeader ();
379
  uint8_t ipv6HeaderSize = ipv6Header.GetSerializedSize ();
383
  uint8_t ipv6HeaderSize = ipv6Header.GetSerializedSize ();
384
  uint8_t firstOctet = 0x0;
385
  p->CopyData (&firstOctet, 1);
380
386
381
  bool moreHeader = true;
387
  bool moreHeader = true;
382
  if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING
388
  if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING
383
        || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && *p->PeekData () == Ipv6Header::IPV6_EXT_ROUTING)))
389
        || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && firstOctet == Ipv6Header::IPV6_EXT_ROUTING)))
384
    {
390
    {
385
      moreHeader = false;
391
      moreHeader = false;
386
      ipv6Header.SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
392
      ipv6Header.SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
 Lines 403-410    Link Here 
403
          nextHeader = hopbyhopHeader->GetNextHeader ();
409
          nextHeader = hopbyhopHeader->GetNextHeader ();
404
          extensionHeaderLength = hopbyhopHeader->GetLength ();
410
          extensionHeaderLength = hopbyhopHeader->GetLength ();
405
411
412
          // XXX: could the value of *p->PeekData() have changed since the last CopyData()?
413
          // I'm doing another CopyData just in case.
414
          p->CopyData (&firstOctet, 1);
415
406
          if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING
416
          if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING
407
                || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && *p->PeekData () == Ipv6Header::IPV6_EXT_ROUTING)))
417
                || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && firstOctet  == Ipv6Header::IPV6_EXT_ROUTING)))
408
            {
418
            {
409
              moreHeader = false;
419
              moreHeader = false;
410
              hopbyhopHeader->SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
420
              hopbyhopHeader->SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
 Lines 415-421    Link Here 
415
        }
425
        }
416
      else if (nextHeader == Ipv6Header::IPV6_EXT_ROUTING) 
426
      else if (nextHeader == Ipv6Header::IPV6_EXT_ROUTING) 
417
        {
427
        {
418
          uint8_t numberAddress = (*(p->PeekData () + 1)) / 2;
428
///          uint8_t numberAddress = (*(p->PeekData () + 1)) / 2;
429
          uint8_t numberAddress = 0;
430
          {
431
            uint8_t firstTwo[2];
432
            p->CopyData (firstTwo, 2);
433
            numberAddress = firstTwo[1] / 2;
434
          }
435
419
          Ipv6ExtensionLooseRoutingHeader *routingHeader = new Ipv6ExtensionLooseRoutingHeader ();
436
          Ipv6ExtensionLooseRoutingHeader *routingHeader = new Ipv6ExtensionLooseRoutingHeader ();
420
          routingHeader->SetNumberAddress (numberAddress);
437
          routingHeader->SetNumberAddress (numberAddress);
421
          p->RemoveHeader (*routingHeader);
438
          p->RemoveHeader (*routingHeader);
 Lines 423-430    Link Here 
423
          nextHeader = routingHeader->GetNextHeader ();
440
          nextHeader = routingHeader->GetNextHeader ();
424
          extensionHeaderLength = routingHeader->GetLength ();
441
          extensionHeaderLength = routingHeader->GetLength ();
425
442
443
          // XXX: could the value of *p->PeekData() have changed since the first CopyData()?
444
          // I'm doing another CopyData just in case.
445
          p->CopyData (&firstOctet, 1);
446
426
          if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING
447
          if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING
427
                || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && *p->PeekData () == Ipv6Header::IPV6_EXT_ROUTING)))
448
                || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && firstOctet == Ipv6Header::IPV6_EXT_ROUTING)))
428
            {
449
            {
429
              moreHeader = false;
450
              moreHeader = false;
430
              routingHeader->SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
451
              routingHeader->SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
 Lines 441-448    Link Here 
441
          nextHeader = destinationHeader->GetNextHeader ();
462
          nextHeader = destinationHeader->GetNextHeader ();
442
          extensionHeaderLength = destinationHeader->GetLength ();
463
          extensionHeaderLength = destinationHeader->GetLength ();
443
464
465
          // XXX: could the value of *p->PeekData() have changed since the first CopyData()?
466
          // I'm doing another CopyData just in case.
467
          p->CopyData (&firstOctet, 1);
468
444
          if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING 
469
          if (!(nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP || nextHeader == Ipv6Header::IPV6_EXT_ROUTING 
445
                || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && *p->PeekData () == Ipv6Header::IPV6_EXT_ROUTING)))
470
                || (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION && firstOctet == Ipv6Header::IPV6_EXT_ROUTING)))
446
            {
471
            {
447
              moreHeader = false;
472
              moreHeader = false;
448
              destinationHeader->SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
473
              destinationHeader->SetNextHeader (Ipv6Header::IPV6_EXT_FRAGMENTATION);
 Lines 637-643    Link Here 
637
  Ptr<Packet> p = packet->Copy ();
662
  Ptr<Packet> p = packet->Copy ();
638
  p->RemoveAtStart (offset);
663
  p->RemoveAtStart (offset);
639
664
640
  const uint8_t *buff = packet->PeekData ();
665
  uint8_t *buff = new uint8_t[packet->GetSize ()];
666
  packet->CopyData (buff, packet->GetSize ());
641
667
642
  uint8_t routingNextHeader = *buff;
668
  uint8_t routingNextHeader = *buff;
643
  uint8_t routingLength = *(buff + 1);
669
  uint8_t routingLength = *(buff + 1);
 Lines 669-678    Link Here 
669
          isDropped = true;
695
          isDropped = true;
670
        }
696
        }
671
697
698
      delete[] buff;
672
      return routingLength;
699
      return routingLength;
673
    }
700
    }
674
701
675
  return ipv6ExtensionRouting->Process (packet, offset, ipv6Header, dst, (uint8_t *)0, isDropped);
702
  uint8_t res = ipv6ExtensionRouting->Process (packet, offset, ipv6Header, dst, (uint8_t *)0, isDropped);
703
  delete[] buff;
704
705
  return res;
676
}
706
}
677
707
678
708
 Lines 786-792    Link Here 
786
  ipv6header.Deserialize (it);
816
  ipv6header.Deserialize (it);
787
817
788
  // Get the number of routers' address field
818
  // Get the number of routers' address field
789
  uint8_t numberAddress = (*(p->PeekData () + 1)) / 2;
819
///  uint8_t numberAddress = (*(p->PeekData () + 1)) / 2;
820
  uint8_t numberAddress = 0;
821
  {
822
    uint8_t firstTwo[2];
823
    p->CopyData (firstTwo, 2);
824
    numberAddress = firstTwo[1] / 2;
825
  }
826
790
  Ipv6ExtensionLooseRoutingHeader routingHeader;
827
  Ipv6ExtensionLooseRoutingHeader routingHeader;
791
  routingHeader.SetNumberAddress (numberAddress);
828
  routingHeader.SetNumberAddress (numberAddress);
792
  p->RemoveHeader (routingHeader);
829
  p->RemoveHeader (routingHeader);
(-)a/src/internet-stack/ipv6-l3-protocol.cc (-1 / +3 lines)
 Lines 954-963    Link Here 
954
  /* process hop-by-hop extension first if exists */
954
  /* process hop-by-hop extension first if exists */
955
  if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP)
955
  if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP)
956
    {
956
    {
957
      const uint8_t *buff = p->PeekData ();
957
      uint8_t *buff = new uint8_t[p->GetSize ()];
958
      p->CopyData (buff, p->GetSize ());
958
959
959
      nextHeader = *buff;
960
      nextHeader = *buff;
960
      nextHeaderPosition = *(buff + 1);
961
      nextHeaderPosition = *(buff + 1);
962
      delete[] buff;
961
    }
963
    }
962
964
963
  /* process all the extensions found and the layer 4 protocol */
965
  /* process all the extensions found and the layer 4 protocol */
(-)a/src/internet-stack/ipv6-raw-socket-impl.cc (-1 / +3 lines)
 Lines 222-228    Link Here 
222
              /* calculate checksum here for ICMPv6 echo request (sent by ping6) 
222
              /* calculate checksum here for ICMPv6 echo request (sent by ping6) 
223
               * as we cannot determine source IPv6 address at application level 
223
               * as we cannot determine source IPv6 address at application level 
224
               */
224
               */
225
              if (*p->PeekData () == Icmpv6Header::ICMPV6_ECHO_REQUEST)
225
              uint8_t firstOctet = 0x0;
226
              p->CopyData (&firstOctet, 1);
227
              if (firstOctet == Icmpv6Header::ICMPV6_ECHO_REQUEST)
226
                {
228
                {
227
                  Icmpv6Echo hdr (1);
229
                  Icmpv6Echo hdr (1);
228
                  p->RemoveHeader (hdr);
230
                  p->RemoveHeader (hdr);

Return to bug 925