internet: refactor how headers are built during fragmentation
This commit is contained in:
@@ -513,11 +513,16 @@ Ipv6ExtensionFragment::GetFragments(Ptr<Packet> packet,
|
||||
}
|
||||
else if (nextHeader == Ipv6Header::IPV6_EXT_ROUTING)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
Ptr<Ipv6ExtensionRoutingDemux> ipv6ExtensionRoutingDemux =
|
||||
GetNode()->GetObject<Ipv6ExtensionRoutingDemux>();
|
||||
|
||||
uint8_t buf[4];
|
||||
p->CopyData(buf, sizeof(buf));
|
||||
uint8_t numberAddress = buf[1] / 2;
|
||||
Ipv6ExtensionLooseRoutingHeader* routingHeader = new Ipv6ExtensionLooseRoutingHeader();
|
||||
routingHeader->SetNumberAddress(numberAddress);
|
||||
uint8_t routingType = buf[2];
|
||||
|
||||
Ipv6ExtensionRoutingHeader* routingHeader =
|
||||
ipv6ExtensionRoutingDemux->GetExtensionRoutingHeaderPtr(routingType);
|
||||
|
||||
p->RemoveHeader(*routingHeader);
|
||||
|
||||
nextHeader = routingHeader->GetNextHeader();
|
||||
@@ -885,6 +890,12 @@ Ipv6ExtensionRouting::GetTypeRouting() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ipv6ExtensionRoutingHeader*
|
||||
Ipv6ExtensionRouting::GetExtensionRoutingHeaderPtr()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Ipv6ExtensionRouting::Process(Ptr<Packet>& packet,
|
||||
uint8_t offset,
|
||||
@@ -1014,15 +1025,30 @@ Ipv6ExtensionRoutingDemux::Insert(Ptr<Ipv6ExtensionRouting> extensionRouting)
|
||||
Ptr<Ipv6ExtensionRouting>
|
||||
Ipv6ExtensionRoutingDemux::GetExtensionRouting(uint8_t typeRouting)
|
||||
{
|
||||
for (Ipv6ExtensionRoutingList_t::iterator i = m_extensionsRouting.begin();
|
||||
i != m_extensionsRouting.end();
|
||||
i++)
|
||||
for (const auto& extRouting : m_extensionsRouting)
|
||||
{
|
||||
if ((*i)->GetTypeRouting() == typeRouting)
|
||||
if (extRouting->GetTypeRouting() == typeRouting)
|
||||
{
|
||||
return *i;
|
||||
return extRouting;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ipv6ExtensionRoutingHeader*
|
||||
Ipv6ExtensionRoutingDemux::GetExtensionRoutingHeaderPtr(uint8_t typeRouting)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << typeRouting);
|
||||
|
||||
for (const auto& extRouting : m_extensionsRouting)
|
||||
{
|
||||
if (extRouting->GetTypeRouting() == typeRouting)
|
||||
{
|
||||
return extRouting->GetExtensionRoutingHeaderPtr();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1059,6 +1085,12 @@ Ipv6ExtensionLooseRouting::GetTypeRouting() const
|
||||
return TYPE_ROUTING;
|
||||
}
|
||||
|
||||
Ipv6ExtensionRoutingHeader*
|
||||
Ipv6ExtensionLooseRouting::GetExtensionRoutingHeaderPtr()
|
||||
{
|
||||
return new Ipv6ExtensionLooseRoutingHeader();
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Ipv6ExtensionLooseRouting::Process(Ptr<Packet>& packet,
|
||||
uint8_t offset,
|
||||
@@ -1089,9 +1121,7 @@ Ipv6ExtensionLooseRouting::Process(Ptr<Packet>& packet,
|
||||
// Get the number of routers' address field
|
||||
uint8_t buf[2];
|
||||
p->CopyData(buf, sizeof(buf));
|
||||
uint8_t numberAddress = buf[1] / 2;
|
||||
Ipv6ExtensionLooseRoutingHeader routingHeader;
|
||||
routingHeader.SetNumberAddress(numberAddress);
|
||||
p->RemoveHeader(routingHeader);
|
||||
|
||||
if (nextHeader)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef IPV6_EXTENSION_H
|
||||
#define IPV6_EXTENSION_H
|
||||
|
||||
#include "ipv6-extension-header.h"
|
||||
#include "ipv6-interface.h"
|
||||
|
||||
#include "ns3/buffer.h"
|
||||
@@ -515,6 +516,13 @@ class Ipv6ExtensionRouting : public Ipv6Extension
|
||||
*/
|
||||
virtual uint8_t GetTypeRouting() const;
|
||||
|
||||
/**
|
||||
* \brief Get a pointer to a new routing extension header.
|
||||
* The ownership is transferred to the caller.
|
||||
* \return a pointer to a new routing extension header.
|
||||
*/
|
||||
virtual Ipv6ExtensionRoutingHeader* GetExtensionRoutingHeaderPtr();
|
||||
|
||||
uint8_t Process(Ptr<Packet>& packet,
|
||||
uint8_t offset,
|
||||
const Ipv6Header& ipv6Header,
|
||||
@@ -568,6 +576,14 @@ class Ipv6ExtensionRoutingDemux : public Object
|
||||
*/
|
||||
Ptr<Ipv6ExtensionRouting> GetExtensionRouting(uint8_t typeRouting);
|
||||
|
||||
/**
|
||||
* \brief Get a pointer to a new routing extension header corresponding
|
||||
* to typeRouting. The ownership is transferred to the caller.
|
||||
* \param typeRouting the number of the routing extension to retrieve
|
||||
* \return a pointer to a new routing extension header matching IPv6 routing extension
|
||||
*/
|
||||
Ipv6ExtensionRoutingHeader* GetExtensionRoutingHeaderPtr(uint8_t typeRouting);
|
||||
|
||||
/**
|
||||
* \brief Remove a routing extension from this demux.
|
||||
* \param extensionRouting pointer on the extension to remove
|
||||
@@ -632,6 +648,8 @@ class Ipv6ExtensionLooseRouting : public Ipv6ExtensionRouting
|
||||
*/
|
||||
uint8_t GetTypeRouting() const override;
|
||||
|
||||
Ipv6ExtensionRoutingHeader* GetExtensionRoutingHeaderPtr() override;
|
||||
|
||||
uint8_t Process(Ptr<Packet>& packet,
|
||||
uint8_t offset,
|
||||
const Ipv6Header& ipv6Header,
|
||||
|
||||
Reference in New Issue
Block a user