dsr: Simplify code with STL alternatives and avoid pointer arithmetic
This commit is contained in:
@@ -58,6 +58,7 @@
|
||||
#include "ns3/udp-header.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
#include <map>
|
||||
@@ -164,14 +165,10 @@ bool
|
||||
DsrOptions::ReverseRoutes(std::vector<Ipv4Address>& vec)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
std::vector<Ipv4Address> vec2(vec);
|
||||
vec.clear(); // To ensure vec is empty before start
|
||||
for (std::vector<Ipv4Address>::reverse_iterator ri = vec2.rbegin(); ri != vec2.rend(); ++ri)
|
||||
{
|
||||
vec.push_back(*ri);
|
||||
}
|
||||
|
||||
return (vec.size() == vec2.size()) && (vec.front() == vec2.back());
|
||||
std::reverse(vec.begin(), vec.end());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
|
||||
@@ -436,13 +436,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source)
|
||||
}
|
||||
route.push_back(source);
|
||||
// Reverse the route
|
||||
DsrRouteCacheEntry::IP_VECTOR reverseroute;
|
||||
for (DsrRouteCacheEntry::IP_VECTOR::reverse_iterator j = route.rbegin();
|
||||
j != route.rend();
|
||||
++j)
|
||||
{
|
||||
reverseroute.push_back(*j);
|
||||
}
|
||||
DsrRouteCacheEntry::IP_VECTOR reverseroute(route.rbegin(), route.rend());
|
||||
NS_LOG_LOGIC("Add newly calculated best routes");
|
||||
PrintVector(reverseroute);
|
||||
m_bestRoutesTable_link[i->first] = reverseroute;
|
||||
|
||||
@@ -3654,7 +3654,7 @@ DsrRouting::Receive(Ptr<Packet> p, const Ipv4Header& ip, Ptr<Ipv4Interface> inco
|
||||
optionLength =
|
||||
dsrOption
|
||||
->Process(p, packet, m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
|
||||
segmentsLeft = *(data + 3);
|
||||
segmentsLeft = data[3];
|
||||
if (optionLength == 0)
|
||||
{
|
||||
NS_LOG_INFO("Discard this packet");
|
||||
|
||||
Reference in New Issue
Block a user