From de3b9c78f3c695861b9b5f8916dc522e60914923 Mon Sep 17 00:00:00 2001 From: Raj Bhattacharjea Date: Wed, 9 May 2007 14:50:14 -0400 Subject: [PATCH 1/4] Removed manual ref/unref calls for Ptr --- examples/simple-p2p.cc | 10 +++++----- src/applications/application.cc | 11 ----------- src/node/net-device.cc | 2 -- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/examples/simple-p2p.cc b/examples/simple-p2p.cc index 2ec17cf80..43dfb5303 100644 --- a/examples/simple-p2p.cc +++ b/examples/simple-p2p.cc @@ -184,11 +184,11 @@ int main (int argc, char *argv[]) ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); ipv4->Unref (); - n0->Unref (); - n1->Unref (); - n2->Unref (); - n3->Unref (); - + n0 = 0; + n1 = 0; + n2 = 0; + n3 = 0; + // Configure tracing of all enqueue, dequeue, and NetDevice receive events // Trace output will be sent to the simple-p2p.tr file AsciiTrace asciitrace ("simple-p2p.tr"); diff --git a/src/applications/application.cc b/src/applications/application.cc index 9379c87e4..6c62fe5ba 100644 --- a/src/applications/application.cc +++ b/src/applications/application.cc @@ -39,7 +39,6 @@ Application::Application(Ptr n) m_startVar(0), m_stopVar(0), m_start(false), m_stop(false) { - m_node->Ref (); } Application::Application(const Application& o) @@ -47,7 +46,6 @@ Application::Application(const Application& o) m_start(false), m_stop(false) { // Copy constructor m_node = o.m_node; - m_node->Ref (); // Copy the start and stop random variables if they exist if (o.m_startVar) m_startVar = o.m_startVar->Copy(); if (o.m_stopVar) m_stopVar = o.m_stopVar->Copy(); @@ -65,7 +63,6 @@ Application::DoDispose (void) { if (m_node != 0) { - m_node->Unref (); m_node = 0; } if (m_start) @@ -87,10 +84,7 @@ Application::DoDispose (void) Application& Application::operator=(const Application& rhs) { if (this == &rhs) return *this; // Self assignment - m_node->Unref (); - m_node = 0; m_node = rhs.m_node; - m_node->Ref (); delete m_startVar; m_startVar = 0; @@ -149,12 +143,7 @@ void Application::Stop(const RandomVariable& stopVar) // an application to a node. void Application::SetNode(Ptr n) { - if (m_node != 0) - { - m_node->Unref (); - } m_node = n; - m_node->Ref (); } Ptr Application::PeekNode() const diff --git a/src/node/net-device.cc b/src/node/net-device.cc index 401fb2a52..1f626d0f5 100644 --- a/src/node/net-device.cc +++ b/src/node/net-device.cc @@ -40,12 +40,10 @@ NetDevice::NetDevice(Ptr node, const MacAddress& addr) : m_isMulticast (false), m_isPointToPoint (false) { - m_node->Ref (); } NetDevice::~NetDevice () { - m_node->Unref (); m_node = 0; } From bd73c92bb562e3e80a84d2d98b7dd83bacac3c7c Mon Sep 17 00:00:00 2001 From: Raj Bhattacharjea Date: Wed, 9 May 2007 16:56:33 -0400 Subject: [PATCH 2/4] Hacked arraytraceresolver to compile, but segfaults upon running simple-p2p --- src/common/array-trace-resolver.h | 15 ++++++++++++++- src/node/node-list.cc | 22 +++++++++++----------- src/node/node-list.h | 7 ++++--- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/common/array-trace-resolver.h b/src/common/array-trace-resolver.h index af4e231bd..4374df6ce 100644 --- a/src/common/array-trace-resolver.h +++ b/src/common/array-trace-resolver.h @@ -24,6 +24,7 @@ #include #include #include "ns3/callback.h" +#include "ns3/ptr.h" #include "trace-resolver.h" namespace ns3 { @@ -82,12 +83,15 @@ public: ArrayTraceResolver (TraceContext const &context, Callback getSize, Callback get); + ArrayTraceResolver (TraceContext const &context, + Callback getSize, + Callback, uint32_t> get); private: virtual TraceResolverList DoLookup (std::string id) const; Callback m_getSize; Callback m_get; + Callback, uint32_t> m_get2; }; - }//namespace ns3 namespace ns3 { @@ -115,6 +119,14 @@ ArrayTraceResolver::ArrayTraceResolver (TraceContext const &context, m_get (get) {} template +ArrayTraceResolver::ArrayTraceResolver (TraceContext const &context, + Callback getSize, + Callback, uint32_t> get) + : TraceResolver (context), + m_getSize (getSize), + m_get2 (get) +{} +template TraceResolver::TraceResolverList ArrayTraceResolver::DoLookup (std::string id) const { @@ -127,6 +139,7 @@ ArrayTraceResolver::DoLookup (std::string id) const typename ArrayTraceResolver::Index index = typename ArrayTraceResolver::Index (i); context.Add (index); list.push_back (m_get (i)->CreateTraceResolver (context)); + } } return list; diff --git a/src/node/node-list.cc b/src/node/node-list.cc index 5ea7d3a8b..889117ea3 100644 --- a/src/node/node-list.cc +++ b/src/node/node-list.cc @@ -49,37 +49,37 @@ public: NodeListPriv (); ~NodeListPriv (); - uint32_t Add (Node *node); + uint32_t Add (Ptr node); NodeList::Iterator Begin (void); NodeList::Iterator End (void); TraceResolver *CreateTraceResolver (TraceContext const &context); - Node *PeekNode (uint32_t n); + Ptr PeekNode (uint32_t n); uint32_t GetNNodes (void); private: - std::vector m_nodes; + std::vector > m_nodes; }; NodeListPriv::NodeListPriv () {} NodeListPriv::~NodeListPriv () { - for (std::vector::iterator i = m_nodes.begin (); + for (std::vector >::iterator i = m_nodes.begin (); i != m_nodes.end (); i++) { - Node *node = *i; + Ptr node = *i; node->Dispose (); - node->Unref (); + //node->Unref (); } m_nodes.erase (m_nodes.begin (), m_nodes.end ()); } uint32_t -NodeListPriv::Add (Node *node) +NodeListPriv::Add (Ptr node) { uint32_t index = m_nodes.size (); - node->Ref (); + //node->Ref (); m_nodes.push_back (node); return index; @@ -99,7 +99,7 @@ NodeListPriv::GetNNodes (void) { return m_nodes.size (); } -Node * +Ptr NodeListPriv::PeekNode (uint32_t n) { return m_nodes[n]; @@ -126,7 +126,7 @@ NodeListPriv::CreateTraceResolver (TraceContext const &context) namespace ns3 { uint32_t -NodeList::Add (Node *node) +NodeList::Add (Ptr node) { return SimulationSingleton::Get ()->Add (node); } @@ -145,7 +145,7 @@ NodeList::CreateTraceResolver (TraceContext const &context) { return SimulationSingleton::Get ()->CreateTraceResolver (context); } -Node * +Ptr NodeList::PeekNode (uint32_t n) { return SimulationSingleton::Get ()->PeekNode (n); diff --git a/src/node/node-list.h b/src/node/node-list.h index 57d8bf663..cbc19f250 100644 --- a/src/node/node-list.h +++ b/src/node/node-list.h @@ -24,6 +24,7 @@ #include #include "ns3/array-trace-resolver.h" +#include "ns3/ptr.h" namespace ns3 { @@ -35,14 +36,14 @@ class NodeList { public: typedef ArrayTraceResolver::Index NodeIndex; - typedef std::vector::iterator Iterator; + typedef std::vector< Ptr >::iterator Iterator; - static uint32_t Add (Node *node); + static uint32_t Add (Ptr node); static Iterator Begin (void); static Iterator End (void); static TraceResolver *CreateTraceResolver (TraceContext const &context); - static Node *PeekNode (uint32_t n); + static Ptr PeekNode (uint32_t n); }; }//namespace ns3 From 80854a2c39e81cbab26a473e2c67081a41403eea Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 9 May 2007 19:48:33 +0200 Subject: [PATCH 3/4] remove ptr::Remove, make ptr::Peek share the same signature as ptr::Get --- samples/main-ptr.cc | 3 ++- src/core/ptr.cc | 13 ++++++----- src/core/ptr.h | 53 ++++++++++++++++----------------------------- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/samples/main-ptr.cc b/samples/main-ptr.cc index 3dc2fb246..fc6f97551 100644 --- a/samples/main-ptr.cc +++ b/samples/main-ptr.cc @@ -67,7 +67,8 @@ int main (int argc, char *argv[]) // remove the raw pointer from its smart pointer. // we can do this because the refcount is exactly one // here - A *raw = prev.Remove (); + A *raw = prev.Get (); + prev = 0; raw->Method (); delete raw; } diff --git a/src/core/ptr.cc b/src/core/ptr.cc index a0d37633c..610f535b2 100644 --- a/src/core/ptr.cc +++ b/src/core/ptr.cc @@ -241,7 +241,8 @@ PtrTest::RunTests (void) { Ptr p1 = p; } - raw = p.Remove (); + raw = p.Get (); + p = 0; } if (m_nDestroyed != 0) { @@ -254,12 +255,12 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p = new NoCount (cb); - NoCount const&v1 = p.Peek(); - NoCount v2 = p.Peek(); - v1.Nothing (); - v2.Nothing (); + const NoCount *v1 = p.Peek(); + NoCount *v2 = p.Peek(); + v1->Nothing (); + v2->Nothing (); } - if (m_nDestroyed != 2) + if (m_nDestroyed != 1) { ok = false; } diff --git a/src/core/ptr.h b/src/core/ptr.h index 7af3440bd..7ebe43af6 100644 --- a/src/core/ptr.h +++ b/src/core/ptr.h @@ -72,7 +72,23 @@ public: Ptr (Ptr const &o); ~Ptr () ; Ptr &operator = (Ptr const& o); - T const& Peek () const; + + /** + * \return the pointer managed by this smart pointer. + * + * The underlying refcount is not incremented prior + * to returning to the caller so the caller is not + * responsible for calling Unref himself. + */ + T * Peek () const; + + /** + * \return the pointer managed by this smart pointer. + * + * The underlying refcount is incremented prior + * to returning to the caller so the caller is + * responsible for calling Unref himself. + */ T * Get () const; T *operator -> () const; T *operator -> (); @@ -97,20 +113,6 @@ public: inline friend Ptr const_pointer_cast (Ptr const&p); - /** - * \returns raw pointer - * - * It is a programming error to invoke this method when - * the reference count of the smart pointer is not one. - * If you try to do it anyway, an assert will be triggered. - * If asserts are disabled, bad things will happen. - * Once you have successfully called Ptr::Remove on - * a smart pointer, the smart pointer will forget - * about the raw pointer and will stop managing it. As such, - * you, as the caller, become responsible for invoking - * operator delete on the returned raw pointer. - */ - T *Remove (void); }; template @@ -172,10 +174,10 @@ Ptr::operator = (Ptr const& o) } template -T const& +T * Ptr::Peek () const { - return *m_ptr; + return m_ptr; } template @@ -218,23 +220,6 @@ Ptr::operator Tester * () const return &test; } -template -T * -Ptr::Remove (void) -{ - if (m_ptr == 0) - { - return (T *) 0; - } - else - { - //NS_ASSERT (m_ptr->IsSingle()); - T *retval = m_ptr; - m_ptr = 0; - return retval; - } -} - // non-member friend functions. template bool From a70e279787ade042c763589426a76fcddaadb598 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 9 May 2007 23:23:05 -0400 Subject: [PATCH 4/4] some Ipv4Interface* -> Ptr, and unhack arraytraceresolver, still segfaults --- src/common/array-trace-resolver.h | 25 ++++++------------------ src/internet-node/arp-cache.cc | 4 ++-- src/internet-node/arp-cache.h | 9 +++++---- src/internet-node/arp.cc | 6 +++--- src/internet-node/arp.h | 5 +++-- src/internet-node/i-ipv4-private.cc | 2 +- src/internet-node/i-ipv4-private.h | 3 ++- src/internet-node/ipv4-interface.h | 3 ++- src/internet-node/ipv4.cc | 30 ++++++++++++++--------------- src/internet-node/ipv4.h | 11 ++++++----- 10 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/common/array-trace-resolver.h b/src/common/array-trace-resolver.h index 4374df6ce..5a3a44c05 100644 --- a/src/common/array-trace-resolver.h +++ b/src/common/array-trace-resolver.h @@ -80,17 +80,13 @@ public: * a pointer to a TraceResolver. i.e. the signature is: * TraceResolver * (*) (TraceContext const &) */ - ArrayTraceResolver (TraceContext const &context, - Callback getSize, - Callback get); ArrayTraceResolver (TraceContext const &context, Callback getSize, Callback, uint32_t> get); private: virtual TraceResolverList DoLookup (std::string id) const; Callback m_getSize; - Callback m_get; - Callback, uint32_t> m_get2; + Callback, uint32_t> m_get; }; }//namespace ns3 @@ -110,21 +106,13 @@ ArrayTraceResolver::Index::operator uint32_t () return m_index; } -template -ArrayTraceResolver::ArrayTraceResolver (TraceContext const &context, - Callback getSize, - Callback get) - : TraceResolver (context), - m_getSize (getSize), - m_get (get) -{} template ArrayTraceResolver::ArrayTraceResolver (TraceContext const &context, Callback getSize, Callback, uint32_t> get) : TraceResolver (context), m_getSize (getSize), - m_get2 (get) + m_get (get) {} template TraceResolver::TraceResolverList @@ -132,16 +120,15 @@ ArrayTraceResolver::DoLookup (std::string id) const { TraceResolverList list; if (id == "*") + { + for (uint32_t i = 0; i < m_getSize (); i++) { - for (uint32_t i = 0; i < m_getSize (); i++) - { TraceContext context = GetContext (); - typename ArrayTraceResolver::Index index = typename ArrayTraceResolver::Index (i); + typename ArrayTraceResolver::Index index = typename ArrayTraceResolver::Index (i); context.Add (index); list.push_back (m_get (i)->CreateTraceResolver (context)); - - } } + } return list; } diff --git a/src/internet-node/arp-cache.cc b/src/internet-node/arp-cache.cc index 6a6f71bc9..ff886f430 100644 --- a/src/internet-node/arp-cache.cc +++ b/src/internet-node/arp-cache.cc @@ -28,7 +28,7 @@ namespace ns3 { -ArpCache::ArpCache (NetDevice *device, Ipv4Interface *interface) +ArpCache::ArpCache (NetDevice *device, Ptr interface) : m_device (device), m_interface (interface), m_aliveTimeout (Seconds (120)), @@ -50,7 +50,7 @@ ArpCache::PeekDevice (void) const return m_device; } -Ipv4Interface * +Ptr ArpCache::GetInterface (void) const { return m_interface; diff --git a/src/internet-node/arp-cache.h b/src/internet-node/arp-cache.h index 5923d2ca9..70c094154 100644 --- a/src/internet-node/arp-cache.h +++ b/src/internet-node/arp-cache.h @@ -28,21 +28,22 @@ #include "ns3/ipv4-address.h" #include "ns3/mac-address.h" #include "sgi-hashmap.h" +#include "ns3/ptr.h" +#include "ipv4-interface.h" namespace ns3 { class NetDevice; -class Ipv4Interface; class ArpCache { public: class Entry; - ArpCache (NetDevice *device, Ipv4Interface *interface); + ArpCache (NetDevice *device, Ptr interface); ~ArpCache (); NetDevice *PeekDevice (void) const; - Ipv4Interface *GetInterface (void) const; + Ptr GetInterface (void) const; void SetAliveTimeout (Time aliveTimeout); void SetDeadTimeout (Time deadTimeout); @@ -92,7 +93,7 @@ private: typedef sgi::hash_map::iterator CacheI; NetDevice *m_device; - Ipv4Interface *m_interface; + Ptr m_interface; Time m_aliveTimeout; Time m_deadTimeout; Time m_waitReplyTimeout; diff --git a/src/internet-node/arp.cc b/src/internet-node/arp.cc index 8c702adf4..5fdd5d96b 100644 --- a/src/internet-node/arp.cc +++ b/src/internet-node/arp.cc @@ -23,6 +23,7 @@ #include "ns3/empty-trace-resolver.h" #include "ns3/node.h" #include "ns3/net-device.h" +#include "ns3/ptr.h" #include "arp.h" #include "arp-header.h" @@ -36,11 +37,10 @@ namespace ns3 { const uint16_t Arp::PROT_NUMBER = 0x0806; -Arp::Arp (Node *node) + Arp::Arp (Ptr node) : L3Protocol (PROT_NUMBER, 0/* XXX: correct version number ? */ ), m_node (node) { - m_node->Ref (); } Arp::~Arp () @@ -81,7 +81,7 @@ Arp::FindCache (NetDevice *device) } } IIpv4Private *ipv4 = m_node->QueryInterface (IIpv4Private::iid); - Ipv4Interface *interface = ipv4->FindInterfaceForDevice (device); + Ptr interface = ipv4->FindInterfaceForDevice (device); ipv4->Unref (); ArpCache * cache = new ArpCache (device, interface); NS_ASSERT (device->IsBroadcast ()); diff --git a/src/internet-node/arp.h b/src/internet-node/arp.h index ef909b2c8..67d61dce1 100644 --- a/src/internet-node/arp.h +++ b/src/internet-node/arp.h @@ -25,6 +25,7 @@ #include "ns3/ipv4-address.h" #include "ns3/mac-address.h" #include "l3-protocol.h" +#include "ns3/ptr.h" namespace ns3 { @@ -40,7 +41,7 @@ class Arp : public L3Protocol public: static const uint16_t PROT_NUMBER; - Arp (Node *node); + Arp (Ptr node); ~Arp (); virtual TraceResolver *CreateTraceResolver (TraceContext const &context); @@ -57,7 +58,7 @@ private: void SendArpRequest (ArpCache const *cache, Ipv4Address to); void SendArpReply (ArpCache const *cache, Ipv4Address toIp, MacAddress toMac); CacheList m_cacheList; - Node *m_node; + Ptr m_node; }; }//namespace ns3 diff --git a/src/internet-node/i-ipv4-private.cc b/src/internet-node/i-ipv4-private.cc index 2921d5262..7bc2ec609 100644 --- a/src/internet-node/i-ipv4-private.cc +++ b/src/internet-node/i-ipv4-private.cc @@ -47,7 +47,7 @@ IIpv4Private::Send (Packet const &packet, Ipv4Address source, { m_ipv4->Send (packet, source, destination, protocol); } -Ipv4Interface * +Ptr IIpv4Private::FindInterfaceForDevice (NetDevice const*device) { return m_ipv4->FindInterfaceForDevice (device); diff --git a/src/internet-node/i-ipv4-private.h b/src/internet-node/i-ipv4-private.h index a300f725f..e595f2f42 100644 --- a/src/internet-node/i-ipv4-private.h +++ b/src/internet-node/i-ipv4-private.h @@ -23,6 +23,7 @@ #include "ns3/ns-unknown.h" #include "ns3/ipv4-address.h" +#include "ns3/ptr.h" #include namespace ns3 { @@ -44,7 +45,7 @@ public: TraceResolver *CreateTraceResolver (TraceContext const &context); void Send (Packet const &packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol); - Ipv4Interface *FindInterfaceForDevice (NetDevice const*device); + Ptr FindInterfaceForDevice (NetDevice const*device); void Receive(Packet& p, NetDevice *device); protected: virtual void DoDispose (void); diff --git a/src/internet-node/ipv4-interface.h b/src/internet-node/ipv4-interface.h index ef2b56408..ffee9f001 100644 --- a/src/internet-node/ipv4-interface.h +++ b/src/internet-node/ipv4-interface.h @@ -25,6 +25,7 @@ #include #include "ns3/ipv4-address.h" +#include "ns3/object.h" namespace ns3 { @@ -61,7 +62,7 @@ class TraceContext; * - Ipv4Interface::SendTo * - Ipv4Interface::DoCreateTraceResolver */ -class Ipv4Interface +class Ipv4Interface : public Object { public: /** diff --git a/src/internet-node/ipv4.cc b/src/internet-node/ipv4.cc index d049edcd7..c0567742c 100644 --- a/src/internet-node/ipv4.cc +++ b/src/internet-node/ipv4.cc @@ -63,7 +63,7 @@ Ipv4::DoDispose (void) { for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) { - delete (*i); + ::delete (*i); } m_interfaces.clear (); for (HostRoutesI i = m_hostRoutes.begin (); @@ -319,18 +319,18 @@ Ipv4::RemoveRoute (uint32_t index) uint32_t Ipv4::AddInterface (NetDevice *device) { - Ipv4Interface *interface = new ArpIpv4Interface (m_node, device); + Ptr interface = new ArpIpv4Interface (m_node, device); return AddIpv4Interface (interface); } uint32_t -Ipv4::AddIpv4Interface (Ipv4Interface *interface) +Ipv4::AddIpv4Interface (Ptr interface) { uint32_t index = m_nInterfaces; m_interfaces.push_back (interface); m_nInterfaces++; return index; } -Ipv4Interface * +Ptr Ipv4::GetInterface (uint32_t index) const { uint32_t tmp = 0; @@ -350,7 +350,7 @@ Ipv4::GetNInterfaces (void) const return m_nInterfaces; } -Ipv4Interface * +Ptr Ipv4::FindInterfaceForDevice (NetDevice const*device) { for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) @@ -434,7 +434,7 @@ Ipv4::SendRealOut (Packet const &p, Ipv4Header const &ip, Ipv4Route const &route { Packet packet = p; packet.AddHeader (ip); - Ipv4Interface *outInterface = GetInterface (route.GetInterface ()); + Ptr outInterface = GetInterface (route.GetInterface ()); NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ()); m_txTrace (packet, route.GetInterface ()); if (route.IsGateway ()) @@ -464,7 +464,7 @@ Ipv4::Forwarding (Packet const &packet, Ipv4Header &ipHeader, NetDevice *device) for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) { - Ipv4Interface *interface = *i; + Ptr interface = *i; if (interface->PeekDevice () == device) { if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) @@ -520,49 +520,49 @@ Ipv4::ForwardUp (Packet p, Ipv4Header const&ip) void Ipv4::SetAddress (uint32_t i, Ipv4Address address) { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); interface->SetAddress (address); } void Ipv4::SetNetworkMask (uint32_t i, Ipv4Mask mask) { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); interface->SetNetworkMask (mask); } Ipv4Mask Ipv4::GetNetworkMask (uint32_t i) const { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); return interface->GetNetworkMask (); } Ipv4Address Ipv4::GetAddress (uint32_t i) const { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); return interface->GetAddress (); } uint16_t Ipv4::GetMtu (uint32_t i) const { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); return interface->GetMtu (); } bool Ipv4::IsUp (uint32_t i) const { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); return interface->IsUp (); } void Ipv4::SetUp (uint32_t i) { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); interface->SetUp (); } void Ipv4::SetDown (uint32_t i) { - Ipv4Interface *interface = GetInterface (i); + Ptr interface = GetInterface (i); interface->SetDown (); } diff --git a/src/internet-node/ipv4.h b/src/internet-node/ipv4.h index 84b63bf95..b84d9005f 100644 --- a/src/internet-node/ipv4.h +++ b/src/internet-node/ipv4.h @@ -28,12 +28,13 @@ #include "ns3/array-trace-resolver.h" #include "ns3/ipv4-address.h" #include "l3-protocol.h" +#include "ns3/ptr.h" +#include "ipv4-interface.h" namespace ns3 { class Packet; class NetDevice; -class Ipv4Interface; class Ipv4Address; class Ipv4Header; class Ipv4Route; @@ -169,7 +170,7 @@ public: * \param i index of interface to return * \returns the requested interface */ - Ipv4Interface * GetInterface (uint32_t i) const; + Ptr GetInterface (uint32_t i) const; /** * \returns the number of interfaces added by the user. */ @@ -181,7 +182,7 @@ public: * Try to find an Ipv4Interface whose NetDevice is equal to * the input NetDevice. */ - Ipv4Interface *FindInterfaceForDevice (NetDevice const*device); + Ptr FindInterfaceForDevice (NetDevice const*device); /** @@ -221,11 +222,11 @@ 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); - uint32_t AddIpv4Interface (Ipv4Interface *interface); + uint32_t AddIpv4Interface (Ptr interface); void SetupLoopback (void); TraceResolver *InterfacesCreateTraceResolver (TraceContext const &context) const; - typedef std::list Ipv4InterfaceList; + typedef std::list > Ipv4InterfaceList; typedef std::list HostRoutes; typedef std::list::const_iterator HostRoutesCI; typedef std::list::iterator HostRoutesI;