merge with trunk
This commit is contained in:
@@ -99,6 +99,11 @@ Ipv4Mask::SetHostOrder (uint32_t value)
|
||||
{
|
||||
m_mask = value;
|
||||
}
|
||||
uint32_t
|
||||
Ipv4Mask::GetInverse (void) const
|
||||
{
|
||||
return ~m_mask;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Mask::Print (std::ostream &os) const
|
||||
@@ -162,6 +167,18 @@ Ipv4Address::CombineMask (Ipv4Mask const &mask) const
|
||||
return Ipv4Address (GetHostOrder () & mask.GetHostOrder ());
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4Address::GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const
|
||||
{
|
||||
return Ipv4Address (GetHostOrder () | mask.GetInverse ());
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4Address::IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const
|
||||
{
|
||||
return ( (GetHostOrder () | mask.GetInverse ()) == GetHostOrder () );
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4Address::IsBroadcast (void) const
|
||||
{
|
||||
|
||||
@@ -119,6 +119,16 @@ public:
|
||||
* \param mask a network mask
|
||||
*/
|
||||
Ipv4Address CombineMask (Ipv4Mask const &mask) const;
|
||||
/**
|
||||
* \brief Generate subnet-directed broadcast address corresponding to mask
|
||||
*
|
||||
* The subnet-directed broadcast address has the host bits set to all
|
||||
* ones.
|
||||
*
|
||||
* \param mask a network mask
|
||||
*/
|
||||
Ipv4Address GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const;
|
||||
bool IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const;
|
||||
|
||||
static bool IsMatchingType (const Address &address);
|
||||
operator Address ();
|
||||
@@ -151,6 +161,10 @@ public:
|
||||
*/
|
||||
uint32_t GetHostOrder (void) const;
|
||||
void SetHostOrder (uint32_t value);
|
||||
/**
|
||||
* \brief Return the inverse mask in host order.
|
||||
*/
|
||||
uint32_t GetInverse (void) const;
|
||||
|
||||
void Print (std::ostream &os) const;
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ipv4.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -32,4 +35,53 @@ Ipv4::Ipv4 ()
|
||||
Ipv4::~Ipv4 ()
|
||||
{}
|
||||
|
||||
uint32_t
|
||||
GetIfIndexByIpv4Address (Ptr<Node> node, Ipv4Address a, Ipv4Mask amask)
|
||||
{
|
||||
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG (ipv4, "GetIfIndexByIpv4Address: No Ipv4 interface");
|
||||
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++)
|
||||
{
|
||||
if (ipv4->GetAddress (i).CombineMask(amask) == a.CombineMask(amask) )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// Mapping not found
|
||||
NS_ASSERT_MSG (false, "GetIfIndexByIpv4Address failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
GetIpv4RouteToDestination (Ptr<Node> node, Ipv4Route& route,
|
||||
Ipv4Address a, Ipv4Mask amask)
|
||||
{
|
||||
Ipv4Route tempRoute;
|
||||
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG (ipv4, "GetIpv4RouteToDestination: No Ipv4 interface");
|
||||
for (uint32_t i = 0; i < ipv4->GetNRoutes (); i++)
|
||||
{
|
||||
tempRoute = ipv4->GetRoute (i);
|
||||
// Host route found
|
||||
if ( tempRoute.IsNetwork () == false && tempRoute.GetDest () == a )
|
||||
{
|
||||
route = tempRoute;
|
||||
return true;
|
||||
}
|
||||
else if ( tempRoute.IsNetwork () &&
|
||||
tempRoute.GetDestNetwork () == a.CombineMask(amask) )
|
||||
{
|
||||
route = tempRoute;
|
||||
return true;
|
||||
}
|
||||
else if ( tempRoute.IsDefault () )
|
||||
{
|
||||
route = tempRoute;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
class NetDevice;
|
||||
class Packet;
|
||||
class Ipv4Route;
|
||||
@@ -425,6 +426,19 @@ public:
|
||||
virtual void SetDown (uint32_t i) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience functions (Doxygen still needed)
|
||||
*
|
||||
* Return the ifIndex corresponding to the Ipv4Address provided.
|
||||
*/
|
||||
uint32_t GetIfIndexByIpv4Address (Ptr<Node> node,
|
||||
Ipv4Address a,
|
||||
Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
|
||||
|
||||
bool GetIpv4RouteToDestination (Ptr<Node> node, Ipv4Route& route,
|
||||
Ipv4Address a,
|
||||
Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* IPV4_H */
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
#include "packet-socket-factory.h"
|
||||
#include "node.h"
|
||||
#include "packet-socket.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define PACKET_SOCKET_FACTORY_H
|
||||
|
||||
#include "socket-factory.h"
|
||||
#include "packet-socket.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
ERROR_AFNOSUPPORT,
|
||||
ERROR_INVAL,
|
||||
ERROR_BADF,
|
||||
ERROR_NOROUTETOHOST,
|
||||
SOCKET_ERRNO_LAST
|
||||
};
|
||||
|
||||
|
||||
1
src/node/waf
vendored
Executable file
1
src/node/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
Reference in New Issue
Block a user