remove ipv4 interface from public API
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "udp.h"
|
||||
#include "ipv4.h"
|
||||
#include "arp.h"
|
||||
#include "ipv4-loopback-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -52,7 +51,6 @@ InternetNode::InternetNode()
|
||||
m_l3Demux->Insert (Ipv4 (this));
|
||||
m_l3Demux->Insert (Arp (this));
|
||||
m_ipv4L4Demux->Insert (Udp (this));
|
||||
SetupLoopback ();
|
||||
}
|
||||
|
||||
InternetNode::InternetNode (InternetNode const &o)
|
||||
@@ -61,7 +59,6 @@ InternetNode::InternetNode (InternetNode const &o)
|
||||
m_applicationList = new ApplicationList();
|
||||
m_l3Demux = o.m_l3Demux->Copy (this);
|
||||
m_ipv4L4Demux = o.m_ipv4L4Demux->Copy (this);
|
||||
SetupLoopback ();
|
||||
}
|
||||
InternetNode const &
|
||||
InternetNode::operator = (InternetNode const &o)
|
||||
@@ -73,7 +70,6 @@ InternetNode::operator = (InternetNode const &o)
|
||||
m_netDevices = new NetDeviceList ();
|
||||
m_l3Demux = o.m_l3Demux->Copy (this);
|
||||
m_ipv4L4Demux = o.m_ipv4L4Demux->Copy (this);
|
||||
SetupLoopback ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -91,17 +87,6 @@ InternetNode::SetName (std::string name)
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void
|
||||
InternetNode::SetupLoopback (void)
|
||||
{
|
||||
Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (this);
|
||||
interface->SetAddress (Ipv4Address::GetLoopback ());
|
||||
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
|
||||
uint32_t index = GetIpv4 ()->AddInterface (interface);
|
||||
GetIpv4 ()->AddHostRouteTo (Ipv4Address::GetLoopback (), index);
|
||||
interface->SetUp ();
|
||||
}
|
||||
|
||||
// Copy this node
|
||||
InternetNode*
|
||||
InternetNode::Copy() const
|
||||
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
|
||||
void SetName(std::string name);
|
||||
private:
|
||||
void SetupLoopback (void);
|
||||
// Capabilities
|
||||
NetDeviceList* m_netDevices;
|
||||
ApplicationList* m_applicationList;
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "ipv4-header.h"
|
||||
#include "ipv4-interface.h"
|
||||
#include "ipv4-route.h"
|
||||
#include "ipv4-loopback-interface.h"
|
||||
#include "arp-ipv4-interface.h"
|
||||
// the two following headers are needed for Ipv4::ForwardUp
|
||||
#include "node.h"
|
||||
#include "ipv4-l4-demux.h"
|
||||
@@ -48,10 +50,11 @@ Ipv4::Ipv4(Node *node)
|
||||
m_identification (0),
|
||||
m_defaultRoute (0),
|
||||
m_node (node)
|
||||
{}
|
||||
{
|
||||
SetupLoopback ();
|
||||
}
|
||||
Ipv4::~Ipv4 ()
|
||||
{
|
||||
// XXX I am not sure we are really allowed to do this here.
|
||||
for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
|
||||
{
|
||||
delete (*i);
|
||||
@@ -71,6 +74,17 @@ Ipv4::~Ipv4 ()
|
||||
delete m_defaultRoute;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4::SetupLoopback (void)
|
||||
{
|
||||
Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (m_node);
|
||||
interface->SetAddress (Ipv4Address::GetLoopback ());
|
||||
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
|
||||
uint32_t index = AddIpv4Interface (interface);
|
||||
AddHostRouteTo (Ipv4Address::GetLoopback (), index);
|
||||
interface->SetUp ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
@@ -85,7 +99,7 @@ Ipv4::CreateTraceResolver (TraceContext const &context)
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4::InterfacesCreateTraceResolver (TraceContext const &context)
|
||||
Ipv4::InterfacesCreateTraceResolver (TraceContext const &context) const
|
||||
{
|
||||
ArrayTraceResolver<Ipv4Interface> *resolver =
|
||||
new ArrayTraceResolver<Ipv4Interface>
|
||||
@@ -286,7 +300,13 @@ Ipv4::RemoveRoute (uint32_t index)
|
||||
|
||||
|
||||
uint32_t
|
||||
Ipv4::AddInterface (Ipv4Interface *interface)
|
||||
Ipv4::AddInterface (NetDevice *device)
|
||||
{
|
||||
Ipv4Interface *interface = new ArpIpv4Interface (m_node, device);
|
||||
return AddIpv4Interface (interface);
|
||||
}
|
||||
uint32_t
|
||||
Ipv4::AddIpv4Interface (Ipv4Interface *interface)
|
||||
{
|
||||
uint32_t index = m_nInterfaces;
|
||||
m_interfaces.push_back (interface);
|
||||
@@ -294,7 +314,7 @@ Ipv4::AddInterface (Ipv4Interface *interface)
|
||||
return index;
|
||||
}
|
||||
Ipv4Interface *
|
||||
Ipv4::GetInterface (uint32_t index)
|
||||
Ipv4::GetInterface (uint32_t index) const
|
||||
{
|
||||
uint32_t tmp = 0;
|
||||
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
|
||||
@@ -308,7 +328,7 @@ Ipv4::GetInterface (uint32_t index)
|
||||
return 0;
|
||||
}
|
||||
uint32_t
|
||||
Ipv4::GetNInterfaces (void)
|
||||
Ipv4::GetNInterfaces (void) const
|
||||
{
|
||||
return m_nInterfaces;
|
||||
}
|
||||
@@ -477,4 +497,54 @@ Ipv4::ForwardUp (Packet p, Ipv4Header const&ip)
|
||||
protocol->Receive (p, ip.GetSource (), ip.GetDestination ());
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4::SetAddress (uint32_t i, Ipv4Address address)
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
interface->SetAddress (address);
|
||||
}
|
||||
void
|
||||
Ipv4::SetNetworkMask (uint32_t i, Ipv4Mask mask)
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
interface->SetNetworkMask (mask);
|
||||
}
|
||||
Ipv4Mask
|
||||
Ipv4::GetNetworkMask (uint32_t i) const
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
return interface->GetNetworkMask ();
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4::GetAddress (uint32_t i) const
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
return interface->GetAddress ();
|
||||
}
|
||||
uint16_t
|
||||
Ipv4::GetMtu (uint32_t i) const
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
return interface->GetMtu ();
|
||||
}
|
||||
bool
|
||||
Ipv4::IsUp (uint32_t i) const
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
return interface->IsUp ();
|
||||
}
|
||||
void
|
||||
Ipv4::SetUp (uint32_t i)
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
interface->SetUp ();
|
||||
}
|
||||
void
|
||||
Ipv4::SetDown (uint32_t i)
|
||||
{
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
interface->SetDown ();
|
||||
}
|
||||
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -164,16 +164,16 @@ public:
|
||||
* to disable it, you can invoke Ipv4Interface::SetDown which will
|
||||
* make sure that it is never used during packet forwarding.
|
||||
*/
|
||||
uint32_t AddInterface (Ipv4Interface *interface);
|
||||
uint32_t AddInterface (NetDevice *device);
|
||||
/**
|
||||
* \param i index of interface to return
|
||||
* \returns the requested interface
|
||||
*/
|
||||
Ipv4Interface * GetInterface (uint32_t i);
|
||||
Ipv4Interface * GetInterface (uint32_t i) const;
|
||||
/**
|
||||
* \returns the number of interfaces added by the user.
|
||||
*/
|
||||
uint32_t GetNInterfaces (void);
|
||||
uint32_t GetNInterfaces (void) const;
|
||||
/**
|
||||
* \param device the device to match
|
||||
* \returns the matching interface, zero if not found.
|
||||
@@ -207,11 +207,23 @@ public:
|
||||
void Send (Packet const &packet, Ipv4Address source,
|
||||
Ipv4Address destination, uint8_t protocol);
|
||||
|
||||
void SetAddress (uint32_t i, Ipv4Address address);
|
||||
void SetNetworkMask (uint32_t i, Ipv4Mask mask);
|
||||
Ipv4Mask GetNetworkMask (uint32_t t) const;
|
||||
Ipv4Address GetAddress (uint32_t i) const;
|
||||
uint16_t GetMtu (uint32_t i) const;
|
||||
bool IsUp (uint32_t i) const;
|
||||
void SetUp (uint32_t i);
|
||||
void SetDown (uint32_t i);
|
||||
|
||||
|
||||
private:
|
||||
void SendRealOut (Packet const &packet, Ipv4Header const &ip, Ipv4Route const &route);
|
||||
bool Forwarding (Packet const &packet, Ipv4Header &ipHeader, NetDevice &device);
|
||||
void ForwardUp (Packet p, Ipv4Header const&ip);
|
||||
TraceResolver *InterfacesCreateTraceResolver (TraceContext const &context);
|
||||
uint32_t AddIpv4Interface (Ipv4Interface *interface);
|
||||
void SetupLoopback (void);
|
||||
TraceResolver *InterfacesCreateTraceResolver (TraceContext const &context) const;
|
||||
|
||||
typedef std::list<Ipv4Interface*> Ipv4InterfaceList;
|
||||
typedef std::list<Ipv4Route *> HostRoutes;
|
||||
|
||||
@@ -41,15 +41,15 @@ L3Demux::~L3Demux()
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
L3Demux::CreateTraceResolver (TraceContext const &context)
|
||||
L3Demux::CreateTraceResolver (TraceContext const &context) const
|
||||
{
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
for (L3Map_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
|
||||
{
|
||||
std::string protValue;
|
||||
std::ostringstream oss (protValue);
|
||||
oss << (i->second)->GetProtocolNumber ();
|
||||
ProtocolTraceType context = (i->second)->GetProtocolNumber ();
|
||||
oss << i->second->GetProtocolNumber ();
|
||||
ProtocolTraceType context = i->second->GetProtocolNumber ();
|
||||
resolver->Add (protValue,
|
||||
MakeCallback (&L3Protocol::CreateTraceResolver, i->second),
|
||||
context);
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* performed in this object. The caller must
|
||||
* delete the returned object.
|
||||
*/
|
||||
TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
TraceResolver *CreateTraceResolver (TraceContext const &context) const;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user