--- a/SConstruct Thu May 03 14:23:41 2007 +0200
+++ b/SConstruct Thu May 03 14:39:37 2007 +0200
@@ -223,6 +223,7 @@
'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 @@
'udp-socket.h',
'i-udp-impl.h',
'udp.h',
+ 'i-arp-private.h',
])
node.add_inst_headers ([
'node.h',
--- a/src/node/arp-ipv4-interface.cc Thu May 03 14:23:41 2007 +0200
+++ b/src/node/arp-ipv4-interface.cc Thu May 03 14:39:37 2007 +0200
@@ -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 @@
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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/node/i-arp-private.cc Thu May 03 14:39:37 2007 +0200
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/node/i-arp-private.h Thu May 03 14:39:37 2007 +0200
@@ -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 */
--- a/src/node/internet-node.cc Thu May 03 14:23:41 2007 +0200
+++ b/src/node/internet-node.cc Thu May 03 14:39:37 2007 +0200
@@ -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 @@
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 @@
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 @@
arp->Unref ();
udp->Unref ();
udpImpl->Unref ();
+ arpPrivate->Unref ();
}
InternetNode::~InternetNode ()
@@ -88,11 +90,6 @@
InternetNode::IPV4);
ipv4->Unref ();
- Arp *arp = GetArp ();
- resolver->Add ("arp",
- MakeCallback (&Arp::CreateTraceResolver, arp),
- InternetNode::ARP);
- arp->Unref ();
return resolver;
}
@@ -113,16 +110,6 @@
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
{
--- a/src/node/internet-node.h Thu May 03 14:23:41 2007 +0200
+++ b/src/node/internet-node.h Thu May 03 14:39:37 2007 +0200
@@ -38,14 +38,12 @@
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:
--- a/src/node/node.cc Thu May 03 14:23:41 2007 +0200
+++ b/src/node/node.cc Thu May 03 14:39:37 2007 +0200
@@ -108,10 +108,4 @@
return 0;
}
-Arp *
-Node::GetArp (void) const
-{
- return 0;
-}
-
}//namespace ns3
--- a/src/node/node.h Thu May 03 14:23:41 2007 +0200
+++ b/src/node/node.h Thu May 03 14:39:37 2007 +0200
@@ -32,7 +32,6 @@
namespace ns3 {
class Ipv4;
-class Arp;
class TraceContext;
class TraceResolver;
@@ -71,7 +70,6 @@
// 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