use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
--- a/src/devices/csma-cd/csma-cd-net-device.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/devices/csma-cd/csma-cd-net-device.cc Sun Aug 12 16:28:29 2007 +0200
@@ -450,19 +450,18 @@
}
Ptr<TraceResolver>
-CsmaCdNetDevice::DoCreateTraceResolver (void)
+CsmaCdNetDevice::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
- resolver->Add ("queue",
- MakeCallback (&Queue::CreateTraceResolver,
- PeekPointer (m_queue)));
+ resolver->AddChild ("queue", m_queue);
resolver->Add ("rx",
m_rxTrace,
CsmaCdTraceType (CsmaCdTraceType::RX));
resolver->Add ("drop",
m_dropTrace,
CsmaCdTraceType (CsmaCdTraceType::DROP));
- return resolver;
+ resolver->SetParent (NetDevice::GetTraceResolver ());
+ return resolver;
}
bool
--- a/src/devices/csma-cd/csma-cd-net-device.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/devices/csma-cd/csma-cd-net-device.h Sun Aug 12 16:28:29 2007 +0200
@@ -192,6 +192,13 @@
virtual bool DoNeedsArp (void) const;
virtual void DoDispose (void);
/**
+ * Create a Trace Resolver for events in the net device.
+ * (NOT TESTED)
+ * @see class TraceResolver
+ */
+ virtual Ptr<TraceResolver> GetTraceResolver (void);
+
+ /**
* Get a copy of the attached Queue.
*
* This method is provided for any derived class that may need to get
@@ -306,12 +313,6 @@
* @see TransmitStart ()
*/
void TransmitReadyEvent (void);
- /**
- * Create a Trace Resolver for events in the net device.
- * (NOT TESTED)
- * @see class TraceResolver
- */
- virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
/**
* Aborts the transmission of the current packet
--- a/src/devices/point-to-point/point-to-point-net-device.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.cc Sun Aug 12 16:28:29 2007 +0200
@@ -189,14 +189,14 @@
}
Ptr<TraceResolver>
-PointToPointNetDevice::DoCreateTraceResolver (void)
+PointToPointNetDevice::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
- resolver->Add ("queue",
- MakeCallback (&Queue::CreateTraceResolver, PeekPointer (m_queue)));
+ resolver->AddChild ("queue", m_queue);
resolver->Add ("rx",
m_rxTrace,
PointToPointTraceType ());
+ resolver->SetParent (NetDevice::GetTraceResolver ());
return resolver;
}
--- a/src/devices/point-to-point/point-to-point-net-device.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.h Sun Aug 12 16:28:29 2007 +0200
@@ -152,6 +152,12 @@
*/
void Receive (Packet& p);
protected:
+ /**
+ * Create a Trace Resolver for events in the net device.
+ *
+ * @see class TraceResolver
+ */
+ virtual Ptr<TraceResolver> GetTraceResolver (void);
virtual void DoDispose (void);
/**
* Get a copy of the attached Queue.
@@ -238,12 +244,6 @@
*
*/
void TransmitComplete(void);
- /**
- * Create a Trace Resolver for events in the net device.
- *
- * @see class TraceResolver
- */
- virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
virtual bool DoNeedsArp (void) const;
/**
* Enumeration of the states of the transmit machine of the net device.
--- a/src/internet-node/arp-cache.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/arp-cache.cc Sun Aug 12 16:28:29 2007 +0200
@@ -19,16 +19,16 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "ns3/assert.h"
-
#include "ns3/packet.h"
#include "ns3/simulator.h"
#include "arp-cache.h"
#include "arp-header.h"
+#include "ipv4-interface.h"
namespace ns3 {
-ArpCache::ArpCache (Ptr<NetDevice> device, Ipv4Interface *interface)
+ArpCache::ArpCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface)
: m_device (device),
m_interface (interface),
m_aliveTimeout (Seconds (120)),
@@ -47,7 +47,7 @@
return m_device;
}
-Ipv4Interface *
+Ptr<Ipv4Interface>
ArpCache::GetInterface (void) const
{
return m_interface;
--- a/src/internet-node/arp-cache.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/arp-cache.h Sun Aug 12 16:28:29 2007 +0200
@@ -48,7 +48,7 @@
* \param device The hardware NetDevice associated with this ARP chache
* \param interface the Ipv4Interface associated with this ARP chache
*/
- ArpCache (Ptr<NetDevice> device, Ipv4Interface *interface);
+ ArpCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
~ArpCache ();
/**
* \return The NetDevice that this ARP cache is associated with
@@ -57,7 +57,7 @@
/**
* \return the Ipv4Interface that this ARP cache is associated with
*/
- Ipv4Interface *GetInterface (void) const;
+ Ptr<Ipv4Interface> GetInterface (void) const;
void SetAliveTimeout (Time aliveTimeout);
void SetDeadTimeout (Time deadTimeout);
@@ -152,7 +152,7 @@
typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator CacheI;
Ptr<NetDevice> m_device;
- Ipv4Interface *m_interface;
+ Ptr<Ipv4Interface> m_interface;
Time m_aliveTimeout;
Time m_deadTimeout;
Time m_waitReplyTimeout;
--- a/src/internet-node/arp-ipv4-interface.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/arp-ipv4-interface.cc Sun Aug 12 16:28:29 2007 +0200
@@ -41,15 +41,14 @@
{}
Ptr<TraceResolver>
-ArpIpv4Interface::DoCreateTraceResolver (void)
+ArpIpv4Interface::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
if (GetDevice () != 0)
{
- resolver->Add ("netdevice",
- MakeCallback (&NetDevice::CreateTraceResolver, PeekPointer (GetDevice ())));
+ resolver->AddChild ("netdevice", GetDevice ());
}
-
+ resolver->SetParent (Ipv4Interface::GetTraceResolver ());
return resolver;
}
--- a/src/internet-node/arp-ipv4-interface.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/arp-ipv4-interface.h Sun Aug 12 16:28:29 2007 +0200
@@ -42,9 +42,10 @@
ArpIpv4Interface (Ptr<Node> node, Ptr<NetDevice> device);
virtual ~ArpIpv4Interface ();
- private:
+protected:
+ virtual Ptr<TraceResolver> GetTraceResolver (void);
+private:
virtual void SendTo (Packet p, Ipv4Address dest);
- virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
Ptr<Node> m_node;
};
--- a/src/internet-node/arp-l3-protocol.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/arp-l3-protocol.cc Sun Aug 12 16:28:29 2007 +0200
@@ -58,12 +58,6 @@
Object::DoDispose ();
}
-Ptr<TraceResolver>
-ArpL3Protocol::CreateTraceResolver (void)
-{
- return Create<EmptyTraceResolver> ();
-}
-
ArpCache *
ArpL3Protocol::FindCache (Ptr<NetDevice> device)
{
@@ -75,7 +69,7 @@
}
}
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
- Ipv4Interface *interface = ipv4->FindInterfaceForDevice (device);
+ Ptr<Ipv4Interface> interface = ipv4->FindInterfaceForDevice (device);
ArpCache * cache = new ArpCache (device, interface);
NS_ASSERT (device->IsBroadcast ());
device->SetLinkChangeCallback (MakeCallback (&ArpCache::Flush, cache));
--- a/src/internet-node/arp-l3-protocol.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/arp-l3-protocol.h Sun Aug 12 16:28:29 2007 +0200
@@ -48,8 +48,6 @@
*/
ArpL3Protocol (Ptr<Node> node);
virtual ~ArpL3Protocol ();
-
- virtual Ptr<TraceResolver> CreateTraceResolver (void);
/**
* \brief Recieve a packet
*/
--- a/src/internet-node/internet-node.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/internet-node.cc Sun Aug 12 16:28:29 2007 +0200
@@ -74,13 +74,14 @@
Object::AddInterface (ipv4L4Demux);
}
-void
-InternetNode::DoFillTraceResolver (CompositeTraceResolver &resolver)
+Ptr<TraceResolver>
+InternetNode::GetTraceResolver ()
{
- Node::DoFillTraceResolver (resolver);
+ Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
Ptr<Ipv4L3Protocol> ipv4 = QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
- resolver.Add ("ipv4",
- MakeCallback (&Ipv4L3Protocol::CreateTraceResolver, PeekPointer (ipv4)));
+ resolver->AddChild ("ipv4", ipv4);
+ resolver->SetParent (Node::GetTraceResolver ());
+ return resolver;
}
void
--- a/src/internet-node/internet-node.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/internet-node.h Sun Aug 12 16:28:29 2007 +0200
@@ -42,8 +42,8 @@
protected:
virtual void DoDispose(void);
+ virtual Ptr<TraceResolver> GetTraceResolver (void);
private:
- virtual void DoFillTraceResolver (CompositeTraceResolver &resolver);
bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const;
void Construct (void);
};
--- a/src/internet-node/ipv4-interface.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-interface.cc Sun Aug 12 16:28:29 2007 +0200
@@ -40,18 +40,19 @@
Ipv4Interface::~Ipv4Interface ()
{}
+void
+Ipv4Interface::DoDispose (void)
+{
+ m_netdevice = 0;
+ Object::DoDispose ();
+}
+
Ptr<NetDevice>
Ipv4Interface::GetDevice (void) const
{
return m_netdevice;
}
-Ptr<TraceResolver>
-Ipv4Interface::CreateTraceResolver (void)
-{
- return DoCreateTraceResolver ();
-}
-
void
Ipv4Interface::SetAddress (Ipv4Address a)
{
--- a/src/internet-node/ipv4-interface.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-interface.h Sun Aug 12 16:28:29 2007 +0200
@@ -26,6 +26,7 @@
#include <list>
#include "ns3/ipv4-address.h"
#include "ns3/ptr.h"
+#include "ns3/object.h"
namespace ns3 {
@@ -60,9 +61,8 @@
*
* Subclasses must implement the two methods:
* - Ipv4Interface::SendTo
- * - Ipv4Interface::DoCreateTraceResolver
*/
-class Ipv4Interface
+class Ipv4Interface : public Object
{
public:
/**
@@ -74,17 +74,6 @@
virtual ~Ipv4Interface();
/**
- * \param context the trace context to use to construct the
- * TraceResolver to return
- * \returns a TraceResolver which can resolve all traces
- * performed in this object. The caller must
- * delete the returned object.
- *
- * This method will delegate the work to the private DoCreateTraceResolver
- * method which is supposed to be implemented by subclasses.
- */
- Ptr<TraceResolver> CreateTraceResolver (void);
- /**
* \returns the underlying NetDevice. This method can return
* zero if this interface has no associated NetDevice.
*/
@@ -150,10 +139,10 @@
*/
void Send(Packet p, Ipv4Address dest);
-
- private:
+protected:
+ virtual void DoDispose (void);
+private:
virtual void SendTo (Packet p, Ipv4Address dest) = 0;
- virtual Ptr<TraceResolver> DoCreateTraceResolver (void) = 0;
Ptr<NetDevice> m_netdevice;
bool m_ifup;
Ipv4Address m_address;
--- a/src/internet-node/ipv4-l3-protocol.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.cc Sun Aug 12 16:28:29 2007 +0200
@@ -22,7 +22,6 @@
#include "ns3/packet.h"
#include "ns3/debug.h"
#include "ns3/composite-trace-resolver.h"
-#include "ns3/array-trace-resolver.h"
#include "ns3/callback.h"
#include "ns3/ipv4-address.h"
#include "ns3/ipv4-route.h"
@@ -90,26 +89,26 @@
}
-Ipv4l3ProtocolInterfaceIndex::Ipv4l3ProtocolInterfaceIndex ()
+Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex ()
: m_index (0)
{}
-Ipv4l3ProtocolInterfaceIndex::Ipv4l3ProtocolInterfaceIndex (uint32_t index)
+Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex (uint32_t index)
: m_index (index)
{}
uint32_t
-Ipv4l3ProtocolInterfaceIndex::Get (void) const
+Ipv4L3ProtocolInterfaceIndex::Get (void) const
{
return m_index;
}
void
-Ipv4l3ProtocolInterfaceIndex::Print (std::ostream &os) const
+Ipv4L3ProtocolInterfaceIndex::Print (std::ostream &os) const
{
os << "ipv4-interface=" << m_index;
}
uint16_t
-Ipv4l3ProtocolInterfaceIndex::GetUid (void)
+Ipv4L3ProtocolInterfaceIndex::GetUid (void)
{
- static uint16_t uid = AllocateUid<Ipv4l3ProtocolInterfaceIndex> ("Ipv4l3ProtocolInterfaceIndex");
+ static uint16_t uid = AllocateUid<Ipv4L3ProtocolInterfaceIndex> ("Ipv4L3ProtocolInterfaceIndex");
return uid;
}
@@ -131,10 +130,6 @@
void
Ipv4L3Protocol::DoDispose (void)
{
- for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
- {
- delete (*i);
- }
m_interfaces.clear ();
m_node = 0;
m_staticRouting->Dispose ();
@@ -145,7 +140,7 @@
void
Ipv4L3Protocol::SetupLoopback (void)
{
- Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (m_node);
+ Ptr<Ipv4LoopbackInterface> interface = Create<Ipv4LoopbackInterface> (m_node);
interface->SetAddress (Ipv4Address::GetLoopback ());
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
uint32_t index = AddIpv4Interface (interface);
@@ -154,24 +149,15 @@
}
Ptr<TraceResolver>
-Ipv4L3Protocol::CreateTraceResolver (void)
+Ipv4L3Protocol::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
resolver->Add ("tx", m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX));
resolver->Add ("rx", m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX));
resolver->Add ("drop", m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP));
- resolver->Add ("interfaces",
- MakeCallback (&Ipv4L3Protocol::InterfacesCreateTraceResolver, this));
- return resolver;
-}
-
-Ptr<TraceResolver>
-Ipv4L3Protocol::InterfacesCreateTraceResolver (void) const
-{
- Ptr<ArrayTraceResolver<Ipv4Interface *, Ipv4l3ProtocolInterfaceIndex> >resolver =
- Create<ArrayTraceResolver<Ipv4Interface *,Ipv4l3ProtocolInterfaceIndex> >
- (MakeCallback (&Ipv4L3Protocol::GetNInterfaces, this),
- MakeCallback (&Ipv4L3Protocol::GetInterface, this));
+ resolver->AddArray ("interfaces",
+ m_interfaces.begin (), m_interfaces.end (),
+ Ipv4L3ProtocolInterfaceIndex ());
return resolver;
}
@@ -264,18 +250,18 @@
uint32_t
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
{
- Ipv4Interface *interface = new ArpIpv4Interface (m_node, device);
+ Ptr<Ipv4Interface> interface = Create<ArpIpv4Interface> (m_node, device);
return AddIpv4Interface (interface);
}
uint32_t
-Ipv4L3Protocol::AddIpv4Interface (Ipv4Interface *interface)
+Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface)
{
uint32_t index = m_nInterfaces;
m_interfaces.push_back (interface);
m_nInterfaces++;
return index;
}
-Ipv4Interface *
+Ptr<Ipv4Interface>
Ipv4L3Protocol::GetInterface (uint32_t index) const
{
uint32_t tmp = 0;
@@ -295,7 +281,7 @@
return m_nInterfaces;
}
-Ipv4Interface *
+Ptr<Ipv4Interface>
Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
{
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
@@ -363,7 +349,7 @@
for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
{
- Ipv4Interface *outInterface = *ifaceIter;
+ Ptr<Ipv4Interface> outInterface = *ifaceIter;
Packet packetCopy = packet;
NS_ASSERT (packetCopy.GetSize () <= outInterface->GetMtu ());
@@ -400,7 +386,7 @@
return;
}
packet.AddHeader (ipHeader);
- Ipv4Interface *outInterface = GetInterface (route.GetInterface ());
+ Ptr<Ipv4Interface> outInterface = GetInterface (route.GetInterface ());
NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ());
m_txTrace (packet, route.GetInterface ());
if (route.IsGateway ())
@@ -430,7 +416,7 @@
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
i != m_interfaces.end (); i++)
{
- Ipv4Interface *interface = *i;
+ Ptr<Ipv4Interface> interface = *i;
if (interface->GetDevice () == device)
{
if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ()))
@@ -480,43 +466,43 @@
void
Ipv4L3Protocol::SetAddress (uint32_t i, Ipv4Address address)
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
interface->SetAddress (address);
}
void
Ipv4L3Protocol::SetNetworkMask (uint32_t i, Ipv4Mask mask)
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
interface->SetNetworkMask (mask);
}
Ipv4Mask
Ipv4L3Protocol::GetNetworkMask (uint32_t i) const
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->GetNetworkMask ();
}
Ipv4Address
Ipv4L3Protocol::GetAddress (uint32_t i) const
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->GetAddress ();
}
uint16_t
Ipv4L3Protocol::GetMtu (uint32_t i) const
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->GetMtu ();
}
bool
Ipv4L3Protocol::IsUp (uint32_t i) const
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
return interface->IsUp ();
}
void
Ipv4L3Protocol::SetUp (uint32_t i)
{
- Ipv4Interface *interface = GetInterface (i);
+ Ptr<Ipv4Interface> interface = GetInterface (i);
interface->SetUp ();
// If interface address and network mask have been set, add a route
@@ -532,7 +518,7 @@
void
Ipv4L3Protocol::SetDown (uint32_t ifaceIndex)
{
- Ipv4Interface *interface = GetInterface (ifaceIndex);
+ Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex);
interface->SetDown ();
// Remove all routes that are going through this interface
--- a/src/internet-node/ipv4-l3-protocol.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.h Sun Aug 12 16:28:29 2007 +0200
@@ -63,11 +63,11 @@
enum Type m_type;
};
-class Ipv4l3ProtocolInterfaceIndex : public TraceContextElement
+class Ipv4L3ProtocolInterfaceIndex : public TraceContextElement
{
public:
- Ipv4l3ProtocolInterfaceIndex ();
- Ipv4l3ProtocolInterfaceIndex (uint32_t index);
+ Ipv4L3ProtocolInterfaceIndex ();
+ Ipv4L3ProtocolInterfaceIndex (uint32_t index);
uint32_t Get (void) const;
void Print (std::ostream &os) const;
static uint16_t GetUid (void);
@@ -86,15 +86,6 @@
virtual ~Ipv4L3Protocol ();
/**
- * \param context the trace context to use to construct the
- * TraceResolver to return
- * \returns a TraceResolver which can resolve all traces
- * performed in this object. The caller must
- * delete the returned object.
- */
- virtual Ptr<TraceResolver> CreateTraceResolver (void);
-
- /**
* \param ttl default ttl to use
*
* When we need to send an ipv4 packet, we use this default
@@ -109,7 +100,7 @@
* Try to find an Ipv4Interface whose NetDevice is equal to
* the input NetDevice.
*/
- Ipv4Interface *FindInterfaceForDevice (Ptr<const NetDevice> device);
+ Ptr<Ipv4Interface> FindInterfaceForDevice (Ptr<const NetDevice> device);
/**
* Lower layer calls this method after calling L3Demux::Lookup
@@ -159,7 +150,7 @@
void RemoveRoute (uint32_t i);
uint32_t AddInterface (Ptr<NetDevice> device);
- Ipv4Interface * GetInterface (uint32_t i) const;
+ Ptr<Ipv4Interface> GetInterface (uint32_t i) const;
uint32_t GetNInterfaces (void) const;
@@ -178,6 +169,7 @@
protected:
virtual void DoDispose (void);
+ virtual Ptr<TraceResolver> GetTraceResolver (void);
private:
@@ -187,11 +179,10 @@
Ipv4Header const &ipHeader);
bool Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetDevice> device);
void ForwardUp (Packet p, Ipv4Header const&ip);
- uint32_t AddIpv4Interface (Ipv4Interface *interface);
+ uint32_t AddIpv4Interface (Ptr<Ipv4Interface> interface);
void SetupLoopback (void);
- Ptr<TraceResolver> InterfacesCreateTraceResolver (void) const;
- typedef std::list<Ipv4Interface*> Ipv4InterfaceList;
+ typedef std::list<Ptr<Ipv4Interface> > Ipv4InterfaceList;
typedef std::list< std::pair< int, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList;
Ipv4InterfaceList m_interfaces;
--- a/src/internet-node/ipv4-l4-demux.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.cc Sun Aug 12 16:28:29 2007 +0200
@@ -79,7 +79,7 @@
}
Ptr<TraceResolver>
-Ipv4L4Demux::CreateTraceResolver (void)
+Ipv4L4Demux::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
@@ -89,10 +89,9 @@
std::ostringstream oss (protValue);
oss << (*i)->GetProtocolNumber ();
Ipv4L4ProtocolTraceContextElement protocolNumber = (*i)->GetProtocolNumber ();
- resolver->Add (protValue,
- MakeCallback (&Ipv4L4Protocol::CreateTraceResolver, PeekPointer (protocol)),
- protocolNumber);
+ resolver->AddChild (protValue, protocol, protocolNumber);
}
+ resolver->SetParent (Object::GetTraceResolver ());
return resolver;
}
void
--- a/src/internet-node/ipv4-l4-demux.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.h Sun Aug 12 16:28:29 2007 +0200
@@ -60,14 +60,6 @@
virtual ~Ipv4L4Demux();
/**
- * \param context the trace context to use to construct the
- * TraceResolver to return
- * \returns a TraceResolver which can resolve all traces
- * performed in this object. The caller must
- * delete the returned object.
- */
- Ptr<TraceResolver> CreateTraceResolver (void);
- /**
* \param protocol a template for the protocol to add to this L4 Demux.
* \returns the L4Protocol effectively added.
*
@@ -95,8 +87,10 @@
* returned from the Ipv4L4Protocol::Insert method.
*/
void Remove (Ptr<Ipv4L4Protocol> protocol);
+protected:
+ Ptr<TraceResolver> GetTraceResolver (void);
+ virtual void DoDispose (void);
private:
- virtual void DoDispose (void);
typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t;
L4List_t m_protocols;
Ptr<Node> m_node;
--- a/src/internet-node/ipv4-l4-protocol.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-l4-protocol.h Sun Aug 12 16:28:29 2007 +0200
@@ -37,10 +37,6 @@
/**
* \brief L4 Protocol base class
*
- * All subclasses must implement:
- * - Ipv4L4Protocol::Copy
- * - Ipv4L4Protocol::CreateTraceResolver
- *
* If you want to implement a new L4 protocol, all you have to do is
* implement a subclass of this base class and add it to an L4Demux.
*/
@@ -59,8 +55,6 @@
*/
int GetVersion() const;
- virtual Ptr<TraceResolver> CreateTraceResolver () = 0;
-
/**
* \param p packet to forward up
* \param source source address of packet received
--- a/src/internet-node/ipv4-loopback-interface.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-loopback-interface.cc Sun Aug 12 16:28:29 2007 +0200
@@ -33,13 +33,6 @@
{}
Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
{}
-
-Ptr<TraceResolver>
-Ipv4LoopbackInterface::DoCreateTraceResolver (void)
-{
- return Create<EmptyTraceResolver> ();
-}
-
void
Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
{
--- a/src/internet-node/ipv4-loopback-interface.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/ipv4-loopback-interface.h Sun Aug 12 16:28:29 2007 +0200
@@ -43,7 +43,6 @@
private:
virtual void SendTo (Packet p, Ipv4Address dest);
- virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
Ptr<Node> m_node;
};
--- a/src/internet-node/udp-l4-protocol.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/udp-l4-protocol.cc Sun Aug 12 16:28:29 2007 +0200
@@ -45,12 +45,6 @@
UdpL4Protocol::~UdpL4Protocol ()
{}
-Ptr<TraceResolver>
-UdpL4Protocol::CreateTraceResolver (void)
-{
- return Create<EmptyTraceResolver> ();
-}
-
void
UdpL4Protocol::DoDispose (void)
{
--- a/src/internet-node/udp-l4-protocol.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/internet-node/udp-l4-protocol.h Sun Aug 12 16:28:29 2007 +0200
@@ -49,7 +49,6 @@
UdpL4Protocol (Ptr<Node> node);
virtual ~UdpL4Protocol ();
- virtual Ptr<TraceResolver> CreateTraceResolver (void);
/**
* \return A smart Socket pointer to a UdpSocket, allocated by this instance
* of the UDP protocol
--- a/src/node/net-device.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/net-device.cc Sun Aug 12 16:28:29 2007 +0200
@@ -184,12 +184,6 @@
}
}
-Ptr<TraceResolver>
-NetDevice::CreateTraceResolver (void)
-{
- return DoCreateTraceResolver ();
-}
-
Ptr<Channel>
NetDevice::GetChannel (void) const
{
--- a/src/node/net-device.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/net-device.h Sun Aug 12 16:28:29 2007 +0200
@@ -62,14 +62,6 @@
static const InterfaceId iid;
virtual ~NetDevice();
- /**
- * \param context the trace context to use to construct the
- * TraceResolver to return
- * \returns a TraceResolver which can resolve all traces
- * performed in this object. The caller must
- * delete the returned object.
- */
- Ptr<TraceResolver> CreateTraceResolver (void);
/**
* \return the channel this NetDevice is connected to. The value
@@ -283,15 +275,6 @@
*/
virtual bool DoNeedsArp (void) const = 0;
/**
- * \param context the trace context to associated to the
- * trace resolver.
- * \returns a trace resolver associated to the input context.
- * the caller takes ownership of the pointer returned.
- *
- * Subclasses must implement this method.
- */
- virtual Ptr<TraceResolver> DoCreateTraceResolver (void) = 0;
- /**
* \returns the channel associated to this NetDevice.
*
* Subclasses must implement this method.
--- a/src/node/node-list.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/node-list.cc Sun Aug 12 16:28:29 2007 +0200
@@ -33,7 +33,7 @@
public:
Initialization ()
{
- ns3::TraceRoot::Register ("nodes", ns3::MakeCallback (&ns3::NodeList::CreateTraceResolver));
+ ns3::TraceRoot::Register ("nodes", ns3::MakeCallback (&ns3::NodeList::GetTraceResolver));
}
} g_initialization;
}
@@ -76,7 +76,7 @@
uint32_t Add (Ptr<Node> node);
NodeList::Iterator Begin (void);
NodeList::Iterator End (void);
- Ptr<TraceResolver> CreateTraceResolver (void);
+ Ptr<TraceResolver> GetTraceResolver (void);
Ptr<Node> GetNode (uint32_t n);
uint32_t GetNNodes (void);
@@ -131,12 +131,11 @@
Ptr<TraceResolver>
-NodeListPriv::CreateTraceResolver (void)
+NodeListPriv::GetTraceResolver (void)
{
- Ptr<ArrayTraceResolver<Ptr<Node>, NodeListIndex> >resolver =
- Create<ArrayTraceResolver<Ptr<Node>, NodeListIndex> >
- (MakeCallback (&NodeListPriv::GetNNodes, this),
- MakeCallback (&NodeListPriv::GetNode, this));
+ Ptr<ArrayTraceResolver<NodeListIndex> >resolver =
+ Create<ArrayTraceResolver<NodeListIndex> > ();
+ resolver->SetIterators (Begin (), End ());
return resolver;
}
@@ -165,9 +164,9 @@
return SimulationSingleton<NodeListPriv>::Get ()->End ();
}
Ptr<TraceResolver>
-NodeList::CreateTraceResolver (void)
+NodeList::GetTraceResolver (void)
{
- return SimulationSingleton<NodeListPriv>::Get ()->CreateTraceResolver ();
+ return SimulationSingleton<NodeListPriv>::Get ()->GetTraceResolver ();
}
Ptr<Node>
NodeList::GetNode (uint32_t n)
--- a/src/node/node-list.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/node-list.h Sun Aug 12 16:28:29 2007 +0200
@@ -79,7 +79,7 @@
* \returns the requested trace resolver. The caller
* takes ownership of the returned pointer.
*/
- static Ptr<TraceResolver> CreateTraceResolver (void);
+ static Ptr<TraceResolver> GetTraceResolver (void);
/**
* \param n index of requested node.
--- a/src/node/node.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/node.cc Sun Aug 12 16:28:29 2007 +0200
@@ -25,7 +25,6 @@
#include "packet-socket-factory.h"
#include "ns3/simulator.h"
#include "ns3/composite-trace-resolver.h"
-#include "ns3/array-trace-resolver.h"
namespace ns3{
@@ -83,10 +82,11 @@
{}
Ptr<TraceResolver>
-Node::CreateTraceResolver (void)
+Node::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
- DoFillTraceResolver (*PeekPointer (resolver));
+ resolver->AddArray ("devices", m_devices.begin (), m_devices.end (), NodeNetDeviceIndex ());
+ resolver->SetParent (Object::GetTraceResolver ());
return resolver;
}
@@ -141,24 +141,6 @@
return m_applications.size ();
}
-Ptr<TraceResolver>
-Node::CreateDevicesTraceResolver (void)
-{
- Ptr<ArrayTraceResolver<Ptr<NetDevice>,NodeNetDeviceIndex> >resolver =
- Create<ArrayTraceResolver<Ptr<NetDevice>,NodeNetDeviceIndex> >
- (MakeCallback (&Node::GetNDevices, this),
- MakeCallback (&Node::GetDevice, this));
-
- return resolver;
-}
-
-void
-Node::DoFillTraceResolver (CompositeTraceResolver &resolver)
-{
- resolver.Add ("devices",
- MakeCallback (&Node::CreateDevicesTraceResolver, this));
-}
-
void
Node::DoDispose()
{
--- a/src/node/node.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/node.h Sun Aug 12 16:28:29 2007 +0200
@@ -85,16 +85,6 @@
virtual ~Node();
/**
- * \returns a newly-created TraceResolver. The caller takes
- * ownership of the returned pointer.
- *
- * Request the Node to create a trace resolver. This method
- * could be used directly by a user who needs access to very low-level
- * trace configuration.
- */
- Ptr<TraceResolver> CreateTraceResolver (void);
-
- /**
* \returns the unique id of this node.
*
* This unique id happens to be also the index of the Node into
@@ -182,23 +172,15 @@
void UnregisterProtocolHandler (ProtocolHandler handler);
protected:
+ virtual Ptr<TraceResolver> GetTraceResolver (void);
/**
* The dispose method. Subclasses must override this method
* and must chain up to it by calling Node::DoDispose at the
* end of their own DoDispose method.
*/
virtual void DoDispose (void);
- /**
- * \param resolver the resolver to store trace sources in.
- *
- * If a subclass wants to add new traces to a Node, it needs
- * to override this method and record the new trace sources
- * in the input resolver. Subclasses also _must_ chain up to
- * their parent's DoFillTraceResolver method prior
- * to recording they own trace sources.
- */
- virtual void DoFillTraceResolver (CompositeTraceResolver &resolver);
private:
+
/**
* \param device the device added to this Node.
*
@@ -212,7 +194,6 @@
bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet,
uint16_t protocol, const Address &from);
void Construct (void);
- Ptr<TraceResolver> CreateDevicesTraceResolver (void);
struct ProtocolHandlerEntry {
ProtocolHandler handler;
--- a/src/node/queue.cc Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/queue.cc Sun Aug 12 16:28:29 2007 +0200
@@ -95,12 +95,13 @@
}
Ptr<TraceResolver>
-Queue::CreateTraceResolver (void)
+Queue::GetTraceResolver (void)
{
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
resolver->Add ("enqueue", m_traceEnqueue, QueueTraceType (QueueTraceType::ENQUEUE));
resolver->Add ("dequeue", m_traceDequeue, QueueTraceType (QueueTraceType::DEQUEUE));
resolver->Add ("drop", m_traceDrop, QueueTraceType (QueueTraceType::DROP));
+ resolver->SetParent (Object::GetTraceResolver ());
return resolver;
}
--- a/src/node/queue.h Sun Aug 12 16:27:42 2007 +0200
+++ b/src/node/queue.h Sun Aug 12 16:28:29 2007 +0200
@@ -69,8 +69,6 @@
Queue ();
virtual ~Queue ();
-
- Ptr<TraceResolver> CreateTraceResolver (void);
/**
* \return true if the queue is empty; false otherwise
@@ -167,6 +165,7 @@
virtual bool DoPeek (Packet &p) = 0;
protected:
+ Ptr<TraceResolver> GetTraceResolver (void);
// called by subclasses to notify parent of packet drops.
void Drop (const Packet& p);