convert UdpSocket and Udp to Ptr<Node>
parent
ad8424e6d1
commit
96e58ed708
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
|
|
||||||
UdpSocket::UdpSocket (Node *node, Udp *udp)
|
UdpSocket::UdpSocket (Ptr<Node> node, Udp *udp)
|
||||||
: m_endPoint (0),
|
: m_endPoint (0),
|
||||||
m_node (node),
|
m_node (node),
|
||||||
m_udp (udp),
|
m_udp (udp),
|
||||||
|
@ -36,15 +36,10 @@ UdpSocket::UdpSocket (Node *node, Udp *udp)
|
||||||
m_connected (false)
|
m_connected (false)
|
||||||
{
|
{
|
||||||
m_udp->Ref ();
|
m_udp->Ref ();
|
||||||
m_node->Ref ();
|
|
||||||
}
|
}
|
||||||
UdpSocket::~UdpSocket ()
|
UdpSocket::~UdpSocket ()
|
||||||
{
|
{
|
||||||
if (m_node != 0)
|
m_node = 0;
|
||||||
{
|
|
||||||
m_node->Unref ();
|
|
||||||
m_node = 0;
|
|
||||||
}
|
|
||||||
if (m_endPoint != 0)
|
if (m_endPoint != 0)
|
||||||
{
|
{
|
||||||
NS_ASSERT (m_udp != 0);
|
NS_ASSERT (m_udp != 0);
|
||||||
|
@ -67,8 +62,8 @@ UdpSocket::~UdpSocket ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *
|
Ptr<Node>
|
||||||
UdpSocket::PeekNode (void) const
|
UdpSocket::GetNode (void) const
|
||||||
{
|
{
|
||||||
return m_node;
|
return m_node;
|
||||||
}
|
}
|
||||||
|
@ -76,11 +71,7 @@ UdpSocket::PeekNode (void) const
|
||||||
void
|
void
|
||||||
UdpSocket::Destroy (void)
|
UdpSocket::Destroy (void)
|
||||||
{
|
{
|
||||||
if (m_node != 0)
|
m_node = 0;
|
||||||
{
|
|
||||||
m_node->Unref ();
|
|
||||||
m_node = 0;
|
|
||||||
}
|
|
||||||
m_endPoint = 0;
|
m_endPoint = 0;
|
||||||
if (m_udp != 0)
|
if (m_udp != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "ns3/callback.h"
|
#include "ns3/callback.h"
|
||||||
#include "ns3/socket.h"
|
#include "ns3/socket.h"
|
||||||
|
#include "ns3/ptr.h"
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
|
|
||||||
|
@ -38,11 +39,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Create an unbound udp socket.
|
* Create an unbound udp socket.
|
||||||
*/
|
*/
|
||||||
UdpSocket (Node *node, Udp *udp);
|
UdpSocket (Ptr<Node> node, Udp *udp);
|
||||||
virtual ~UdpSocket ();
|
virtual ~UdpSocket ();
|
||||||
|
|
||||||
virtual enum SocketErrno GetErrno (void) const;
|
virtual enum SocketErrno GetErrno (void) const;
|
||||||
virtual Node *PeekNode (void) const;
|
virtual Ptr<Node> GetNode (void) const;
|
||||||
virtual int Bind (void);
|
virtual int Bind (void);
|
||||||
virtual int Bind (Ipv4Address address);
|
virtual int Bind (Ipv4Address address);
|
||||||
virtual int Bind (uint16_t port);
|
virtual int Bind (uint16_t port);
|
||||||
|
@ -81,7 +82,7 @@ private:
|
||||||
ns3::Callback<void, Socket*, uint32_t> dataSent);
|
ns3::Callback<void, Socket*, uint32_t> dataSent);
|
||||||
|
|
||||||
Ipv4EndPoint *m_endPoint;
|
Ipv4EndPoint *m_endPoint;
|
||||||
Node *m_node;
|
Ptr<Node> m_node;
|
||||||
Udp *m_udp;
|
Udp *m_udp;
|
||||||
Ipv4Address m_defaultAddress;
|
Ipv4Address m_defaultAddress;
|
||||||
uint16_t m_defaultPort;
|
uint16_t m_defaultPort;
|
||||||
|
|
|
@ -38,13 +38,11 @@ namespace ns3 {
|
||||||
/* see http://www.iana.org/assignments/protocol-numbers */
|
/* see http://www.iana.org/assignments/protocol-numbers */
|
||||||
const uint8_t Udp::PROT_NUMBER = 17;
|
const uint8_t Udp::PROT_NUMBER = 17;
|
||||||
|
|
||||||
Udp::Udp (Node *node)
|
Udp::Udp (Ptr<Node> node)
|
||||||
: Ipv4L4Protocol (PROT_NUMBER, 2),
|
: Ipv4L4Protocol (PROT_NUMBER, 2),
|
||||||
m_node (node),
|
m_node (node),
|
||||||
m_endPoints (new Ipv4EndPointDemux ())
|
m_endPoints (new Ipv4EndPointDemux ())
|
||||||
{
|
{}
|
||||||
m_node->Ref ();
|
|
||||||
}
|
|
||||||
|
|
||||||
Udp::~Udp ()
|
Udp::~Udp ()
|
||||||
{}
|
{}
|
||||||
|
@ -63,11 +61,7 @@ Udp::DoDispose (void)
|
||||||
delete m_endPoints;
|
delete m_endPoints;
|
||||||
m_endPoints = 0;
|
m_endPoints = 0;
|
||||||
}
|
}
|
||||||
if (m_node != 0)
|
m_node = 0;
|
||||||
{
|
|
||||||
m_node->Unref ();
|
|
||||||
m_node = 0;
|
|
||||||
}
|
|
||||||
Ipv4L4Protocol::DoDispose ();
|
Ipv4L4Protocol::DoDispose ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "ns3/packet.h"
|
#include "ns3/packet.h"
|
||||||
#include "ns3/ipv4-address.h"
|
#include "ns3/ipv4-address.h"
|
||||||
|
#include "ns3/ptr.h"
|
||||||
#include "ipv4-end-point-demux.h"
|
#include "ipv4-end-point-demux.h"
|
||||||
#include "ipv4-l4-protocol.h"
|
#include "ipv4-l4-protocol.h"
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ class Udp : public Ipv4L4Protocol {
|
||||||
public:
|
public:
|
||||||
static const uint8_t PROT_NUMBER;
|
static const uint8_t PROT_NUMBER;
|
||||||
|
|
||||||
Udp (Node *node);
|
Udp (Ptr<Node> node);
|
||||||
virtual ~Udp ();
|
virtual ~Udp ();
|
||||||
|
|
||||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||||
|
@ -67,7 +68,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDispose (void);
|
virtual void DoDispose (void);
|
||||||
private:
|
private:
|
||||||
Node *m_node;
|
Ptr<Node> m_node;
|
||||||
Ipv4EndPointDemux *m_endPoints;
|
Ipv4EndPointDemux *m_endPoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#define __SOCKET_H__
|
#define __SOCKET_H__
|
||||||
|
|
||||||
#include "ns3/callback.h"
|
#include "ns3/callback.h"
|
||||||
|
#include "ns3/ptr.h"
|
||||||
#include "ipv4-address.h"
|
#include "ipv4-address.h"
|
||||||
#include "ns3/object.h"
|
#include "ns3/object.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -65,7 +66,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* \returns the node this socket is associated with.
|
* \returns the node this socket is associated with.
|
||||||
*/
|
*/
|
||||||
virtual Node *PeekNode (void) const = 0;
|
virtual Ptr<Node> GetNode (void) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a free port number and
|
* Allocate a free port number and
|
||||||
|
|
Loading…
Reference in New Issue