|
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); |
|
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 |
|
|
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); |
|
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); |
|
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); |
|
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); |
|
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); |
|
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); |
|
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 |
|
|
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); |