--- a/src/internet-stack/udp-l4-protocol.cc Thu Aug 05 15:32:06 2010 +0200
+++ b/src/internet-stack/udp-l4-protocol.cc Thu Aug 05 11:22:11 2010 -0400
@@ -23,6 +23,7 @@
#include "ns3/packet.h"
#include "ns3/node.h"
#include "ns3/boolean.h"
+#include "ns3/object-vector.h"
#include "ns3/ipv4-route.h"
#include "udp-l4-protocol.h"
@@ -48,6 +49,10 @@
static TypeId tid = TypeId ("ns3::UdpL4Protocol")
.SetParent<Ipv4L4Protocol> ()
.AddConstructor<UdpL4Protocol> ()
+ .AddAttribute ("SocketList", "The list of sockets associated to this protocol.",
+ ObjectVectorValue (),
+ MakeObjectVectorAccessor (&UdpL4Protocol::m_sockets),
+ MakeObjectVectorChecker<UdpSocketImpl> ())
;
return tid;
}
@@ -107,6 +112,12 @@
UdpL4Protocol::DoDispose (void)
{
NS_LOG_FUNCTION_NOARGS ();
+ for (std::vector<Ptr<UdpSocketImpl> >::iterator i = m_sockets.begin (); i != m_sockets.end (); i++)
+ {
+ *i = 0;
+ }
+ m_sockets.clear ();
+
if (m_endPoints != 0)
{
delete m_endPoints;
@@ -123,6 +134,7 @@
Ptr<UdpSocketImpl> socket = CreateObject<UdpSocketImpl> ();
socket->SetNode (m_node);
socket->SetUdp (this);
+ m_sockets.push_back (socket);
return socket;
}
--- a/src/internet-stack/udp-l4-protocol.h Thu Aug 05 15:32:06 2010 +0200
+++ b/src/internet-stack/udp-l4-protocol.h Thu Aug 05 11:22:11 2010 -0400
@@ -35,6 +35,8 @@
class Ipv4Route;
class Ipv4EndPointDemux;
class Ipv4EndPoint;
+class UdpSocketImpl;
+
/**
* \ingroup udp
* \brief Implementation of the UDP protocol
@@ -117,6 +119,9 @@
private:
Ptr<Node> m_node;
Ipv4EndPointDemux *m_endPoints;
+ UdpL4Protocol (const UdpL4Protocol &o);
+ UdpL4Protocol &operator = (const UdpL4Protocol &o);
+ std::vector<Ptr<UdpSocketImpl> > m_sockets;
};
}; // namespace ns3