remove Node::GetArp
This commit is contained in:
@@ -223,6 +223,7 @@ node.add_sources ([
|
||||
'ipv4-end-point-demux.cc',
|
||||
'i-udp.cc',
|
||||
'i-udp-impl.cc',
|
||||
'i-arp-private.cc',
|
||||
])
|
||||
node.add_headers ([
|
||||
'ipv4-header.h',
|
||||
@@ -243,6 +244,7 @@ node.add_headers ([
|
||||
'udp-socket.h',
|
||||
'i-udp-impl.h',
|
||||
'udp.h',
|
||||
'i-arp-private.h',
|
||||
])
|
||||
node.add_inst_headers ([
|
||||
'node.h',
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
|
||||
#include "arp-ipv4-interface.h"
|
||||
#include "arp.h"
|
||||
#include "i-arp-private.h"
|
||||
#include "node.h"
|
||||
#include "net-device.h"
|
||||
#include "ipv4.h"
|
||||
@@ -62,7 +62,7 @@ ArpIpv4Interface::SendTo (Packet p, Ipv4Address dest)
|
||||
NS_ASSERT (PeekDevice () != 0);
|
||||
if (PeekDevice ()->NeedsArp ())
|
||||
{
|
||||
Arp * arp = m_node->GetArp ();
|
||||
IArpPrivate * arp = m_node->QueryInterface<IArpPrivate> (IArpPrivate::iid);
|
||||
MacAddress hardwareDestination;
|
||||
bool found = arp->Lookup (p, dest, PeekDevice (), &hardwareDestination);
|
||||
if (found)
|
||||
|
||||
58
src/node/i-arp-private.cc
Normal file
58
src/node/i-arp-private.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "i-arp-private.h"
|
||||
#include "ns3/iid-manager.h"
|
||||
#include "arp.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
const uint32_t IArpPrivate::iid = IidManager::Allocate ("IArpPrivate");
|
||||
|
||||
IArpPrivate::IArpPrivate (Arp *arp)
|
||||
: NsUnknown (IArpPrivate::iid),
|
||||
m_arp (arp)
|
||||
{
|
||||
m_arp->Ref ();
|
||||
}
|
||||
IArpPrivate::~IArpPrivate ()
|
||||
{
|
||||
NS_ASSERT (m_arp == 0);
|
||||
}
|
||||
|
||||
bool
|
||||
IArpPrivate::Lookup (Packet &p, Ipv4Address destination,
|
||||
NetDevice *device,
|
||||
MacAddress *hardwareDestination)
|
||||
{
|
||||
return m_arp->Lookup (p, destination, device, hardwareDestination);
|
||||
}
|
||||
|
||||
void
|
||||
IArpPrivate::DoDispose (void)
|
||||
{
|
||||
m_arp->Unref ();
|
||||
m_arp = 0;
|
||||
NsUnknown::DoDispose ();
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
51
src/node/i-arp-private.h
Normal file
51
src/node/i-arp-private.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef I_ARP_PRIVATE_H
|
||||
#define I_ARP_PRIVATE_H
|
||||
|
||||
#include "ns3/ns-unknown.h"
|
||||
#include "ipv4-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NetDevice;
|
||||
class MacAddress;
|
||||
class Packet;
|
||||
class Arp;
|
||||
|
||||
class IArpPrivate : public NsUnknown
|
||||
{
|
||||
public:
|
||||
static const uint32_t iid;
|
||||
IArpPrivate (Arp *arp);
|
||||
virtual ~IArpPrivate ();
|
||||
bool Lookup (Packet &p, Ipv4Address destination,
|
||||
NetDevice *device,
|
||||
MacAddress *hardwareDestination);
|
||||
protected:
|
||||
virtual void DoDispose (void);
|
||||
private:
|
||||
Arp *m_arp;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* I_ARP_PRIVATE_H */
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "arp.h"
|
||||
#include "net-device.h"
|
||||
#include "i-udp-impl.h"
|
||||
#include "i-arp-private.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -42,8 +43,6 @@ InternetNode::InternetNode()
|
||||
Arp *arp = new Arp (this);
|
||||
Udp *udp = new Udp (this);
|
||||
|
||||
|
||||
// Instantiate the capabilities
|
||||
ApplicationList *applicationList = new ApplicationList(this);
|
||||
L3Demux *l3Demux = new L3Demux(this);
|
||||
Ipv4L4Demux *ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
@@ -53,7 +52,9 @@ InternetNode::InternetNode()
|
||||
ipv4L4Demux->Insert (udp);
|
||||
|
||||
IUdpImpl *udpImpl = new IUdpImpl (udp);
|
||||
IArpPrivate *arpPrivate = new IArpPrivate (arp);
|
||||
|
||||
NsUnknown::AddInterface (arpPrivate);
|
||||
NsUnknown::AddInterface (udpImpl);
|
||||
NsUnknown::AddInterface (applicationList);
|
||||
NsUnknown::AddInterface (l3Demux);
|
||||
@@ -67,6 +68,7 @@ InternetNode::InternetNode()
|
||||
arp->Unref ();
|
||||
udp->Unref ();
|
||||
udpImpl->Unref ();
|
||||
arpPrivate->Unref ();
|
||||
}
|
||||
|
||||
InternetNode::~InternetNode ()
|
||||
@@ -88,11 +90,6 @@ InternetNode::CreateTraceResolver (TraceContext const &context)
|
||||
InternetNode::IPV4);
|
||||
ipv4->Unref ();
|
||||
|
||||
Arp *arp = GetArp ();
|
||||
resolver->Add ("arp",
|
||||
MakeCallback (&Arp::CreateTraceResolver, arp),
|
||||
InternetNode::ARP);
|
||||
arp->Unref ();
|
||||
|
||||
return resolver;
|
||||
}
|
||||
@@ -113,16 +110,6 @@ InternetNode::GetIpv4 (void) const
|
||||
return ipv4;
|
||||
}
|
||||
|
||||
Arp *
|
||||
InternetNode::GetArp (void) const
|
||||
{
|
||||
L3Demux *l3Demux = QueryInterface<L3Demux> (L3Demux::iid);
|
||||
Arp *arp = static_cast<Arp*> (l3Demux->PeekProtocol (Arp::PROT_NUMBER));
|
||||
l3Demux->Unref ();
|
||||
arp->Ref ();
|
||||
return arp;
|
||||
}
|
||||
|
||||
void
|
||||
InternetNode::DoAddDevice (NetDevice *device) const
|
||||
{
|
||||
|
||||
@@ -38,14 +38,12 @@ class InternetNode : public Node
|
||||
public:
|
||||
enum TraceType {
|
||||
IPV4,
|
||||
ARP,
|
||||
};
|
||||
InternetNode();
|
||||
virtual ~InternetNode ();
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
// Capability access
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
virtual Arp * GetArp (void) const;
|
||||
|
||||
void SetName(std::string name);
|
||||
protected:
|
||||
|
||||
@@ -108,10 +108,4 @@ Node::GetIpv4 (void) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Arp *
|
||||
Node::GetArp (void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv4;
|
||||
class Arp;
|
||||
|
||||
class TraceContext;
|
||||
class TraceResolver;
|
||||
@@ -71,7 +70,6 @@ public:
|
||||
// of the correct type if one exists, or the nil pointer if no
|
||||
// null capability exists.
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
virtual Arp * GetArp (void) const;
|
||||
|
||||
private:
|
||||
uint32_t m_id; // Node id for this node
|
||||
|
||||
Reference in New Issue
Block a user