make Ipv4L4Demux an NsUnknown object.
parent
0e11e9f7f4
commit
69ffe8defb
|
@ -40,17 +40,21 @@ InternetNode::InternetNode()
|
|||
// Instantiate the capabilities
|
||||
m_applicationList = new ApplicationList(this);
|
||||
L3Demux *l3Demux = new L3Demux(this);
|
||||
Ipv4L4Demux *ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
|
||||
NsUnknown::AddInterface (l3Demux);
|
||||
m_ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
NsUnknown::AddInterface (ipv4L4Demux);
|
||||
|
||||
Ipv4 *ipv4 = new Ipv4 (this);
|
||||
Arp *arp = new Arp (this);
|
||||
Udp *udp = new Udp (this);
|
||||
|
||||
l3Demux->Insert (ipv4);
|
||||
l3Demux->Insert (arp);
|
||||
m_ipv4L4Demux->Insert (udp);
|
||||
ipv4L4Demux->Insert (udp);
|
||||
|
||||
l3Demux->Unref ();
|
||||
ipv4L4Demux->Unref ();
|
||||
ipv4->Unref ();
|
||||
arp->Unref ();
|
||||
udp->Unref ();
|
||||
|
@ -93,13 +97,6 @@ InternetNode::CreateTraceResolver (TraceContext const &context)
|
|||
void
|
||||
InternetNode::DoDispose()
|
||||
{
|
||||
if (m_ipv4L4Demux != 0)
|
||||
{
|
||||
m_ipv4L4Demux->Dispose ();
|
||||
m_ipv4L4Demux->Unref ();
|
||||
m_ipv4L4Demux = 0;
|
||||
}
|
||||
|
||||
if (m_applicationList != 0)
|
||||
{
|
||||
m_applicationList->Dispose ();
|
||||
|
@ -117,12 +114,6 @@ InternetNode::GetApplicationList() const
|
|||
return m_applicationList;
|
||||
}
|
||||
|
||||
Ipv4L4Demux*
|
||||
InternetNode::GetIpv4L4Demux() const
|
||||
{
|
||||
m_ipv4L4Demux->Ref ();
|
||||
return m_ipv4L4Demux;
|
||||
}
|
||||
|
||||
Ipv4 *
|
||||
InternetNode::GetIpv4 (void) const
|
||||
|
@ -136,7 +127,9 @@ InternetNode::GetIpv4 (void) const
|
|||
Udp *
|
||||
InternetNode::GetUdp (void) const
|
||||
{
|
||||
Udp *udp = static_cast<Udp*> (m_ipv4L4Demux->PeekProtocol (Udp::PROT_NUMBER));
|
||||
Ipv4L4Demux *demux = QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid);
|
||||
Udp *udp = static_cast<Udp*> (demux->PeekProtocol (Udp::PROT_NUMBER));
|
||||
demux->Unref ();
|
||||
udp->Ref ();
|
||||
return udp;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ public:
|
|||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
// Capability access
|
||||
virtual ApplicationList* GetApplicationList() const;
|
||||
virtual Ipv4L4Demux* GetIpv4L4Demux() const;
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
virtual Udp * GetUdp (void) const;
|
||||
virtual Arp * GetArp (void) const;
|
||||
|
@ -59,7 +58,6 @@ private:
|
|||
bool ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const;
|
||||
// Capabilities
|
||||
ApplicationList* m_applicationList;
|
||||
Ipv4L4Demux* m_ipv4L4Demux;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,24 +24,27 @@
|
|||
|
||||
#include <sstream>
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
#include "ns3/iid-manager.h"
|
||||
#include "ipv4-l4-demux.h"
|
||||
#include "ipv4-l4-protocol.h"
|
||||
#include "node.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
const uint32_t Ipv4L4Demux::iid = IidManager::Allocate ("Ipv4L4Demux");
|
||||
|
||||
Ipv4L4Demux::Ipv4L4Demux (Node *node)
|
||||
: m_node (node)
|
||||
: NsUnknown (Ipv4L4Demux::iid),
|
||||
m_node (node)
|
||||
{
|
||||
m_node->Ref ();
|
||||
}
|
||||
|
||||
Ipv4L4Demux::~Ipv4L4Demux()
|
||||
{
|
||||
Dispose ();
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
Ipv4L4Demux::Dispose (void)
|
||||
Ipv4L4Demux::DoDispose (void)
|
||||
{
|
||||
for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
|
||||
{
|
||||
|
@ -54,6 +57,7 @@ Ipv4L4Demux::Dispose (void)
|
|||
m_node->Unref ();
|
||||
m_node = 0;
|
||||
}
|
||||
NsUnknown::DoDispose ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#define IPV4_L4_DEMUX_H
|
||||
|
||||
#include <list>
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ns-unknown.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
@ -38,15 +38,14 @@ class TraceContext;
|
|||
/**
|
||||
* \brief L4 Ipv4 Demux
|
||||
*/
|
||||
class Ipv4L4Demux : public Object
|
||||
class Ipv4L4Demux : public NsUnknown
|
||||
{
|
||||
public:
|
||||
static const uint32_t iid;
|
||||
typedef int Ipv4L4ProtocolTraceType;
|
||||
Ipv4L4Demux (Node *node);
|
||||
virtual ~Ipv4L4Demux();
|
||||
|
||||
void Dispose (void);
|
||||
|
||||
/**
|
||||
* \param context the trace context to use to construct the
|
||||
* TraceResolver to return
|
||||
|
@ -84,6 +83,7 @@ public:
|
|||
*/
|
||||
void Erase(Ipv4L4Protocol*protocol);
|
||||
private:
|
||||
virtual void DoDispose (void);
|
||||
typedef std::list<Ipv4L4Protocol*> L4List_t;
|
||||
L4List_t m_protocols;
|
||||
Node *m_node;
|
||||
|
|
|
@ -512,7 +512,7 @@ Ipv4::Forwarding (Packet const &packet, Ipv4Header &ipHeader, NetDevice *device)
|
|||
void
|
||||
Ipv4::ForwardUp (Packet p, Ipv4Header const&ip)
|
||||
{
|
||||
Ipv4L4Demux *demux = m_node->GetIpv4L4Demux ();
|
||||
Ipv4L4Demux *demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid);
|
||||
Ipv4L4Protocol *protocol = demux->PeekProtocol (ip.GetProtocol ());
|
||||
demux->Unref ();
|
||||
protocol->Receive (p, ip.GetSource (), ip.GetDestination ());
|
||||
|
|
|
@ -103,12 +103,6 @@ void Node::DoDispose()
|
|||
NsUnknown::DoDispose ();
|
||||
}
|
||||
|
||||
Ipv4L4Demux*
|
||||
Node::GetIpv4L4Demux() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ApplicationList* Node::GetApplicationList() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
namespace ns3 {
|
||||
|
||||
class ApplicationList;
|
||||
class Ipv4L4Demux;
|
||||
class Ipv4;
|
||||
class Udp;
|
||||
class Arp;
|
||||
|
@ -73,7 +72,6 @@ public:
|
|||
// Each of these has a default behavior of returning a null capability
|
||||
// of the correct type if one exists, or the nil pointer if no
|
||||
// null capability exists.
|
||||
virtual Ipv4L4Demux* GetIpv4L4Demux() const;
|
||||
virtual ApplicationList* GetApplicationList() const;
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
virtual Udp * GetUdp (void) const;
|
||||
|
|
Loading…
Reference in New Issue