debug prints to make validation easier
This commit is contained in:
1 parent
a82fc38dbb
commit
09b235eaec
6 files changed
+240
-17
No files matched your search
@@ -18,6 +18,8 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/inet-socket-address.h"
|
||||
#include "udp-socket.h"
|
||||
@@ -25,6 +27,8 @@
|
||||
#include "ipv4-end-point.h"
|
||||
#include "ipv4-l4-demux.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("UdpSocket");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
UdpSocket::UdpSocket (Ptr<Node> node, Ptr<UdpL4Protocol> udp)
|
||||
@@ -35,9 +39,14 @@ UdpSocket::UdpSocket (Ptr<Node> node, Ptr<UdpL4Protocol> udp)
|
||||
m_shutdownSend (false),
|
||||
m_shutdownRecv (false),
|
||||
m_connected (false)
|
||||
{}
|
||||
{
|
||||
NS_DEBUG("UdpSocket::UdpSocket ()");
|
||||
}
|
||||
|
||||
UdpSocket::~UdpSocket ()
|
||||
{
|
||||
NS_DEBUG("UdpSocket::~UdpSocket ()");
|
||||
|
||||
m_node = 0;
|
||||
if (m_endPoint != 0)
|
||||
{
|
||||
@@ -60,25 +69,32 @@ UdpSocket::~UdpSocket ()
|
||||
enum Socket::SocketErrno
|
||||
UdpSocket::GetErrno (void) const
|
||||
{
|
||||
NS_DEBUG("UdpSocket::GetErrno ()");
|
||||
|
||||
return m_errno;
|
||||
}
|
||||
|
||||
Ptr<Node>
|
||||
UdpSocket::GetNode (void) const
|
||||
{
|
||||
NS_DEBUG("UdpSocket::GetNode ()");
|
||||
return m_node;
|
||||
}
|
||||
|
||||
void
|
||||
UdpSocket::Destroy (void)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Destroy ()");
|
||||
m_node = 0;
|
||||
m_endPoint = 0;
|
||||
m_udp = 0;
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::FinishBind (void)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::FinishBind ()");
|
||||
|
||||
if (m_endPoint == 0)
|
||||
{
|
||||
return -1;
|
||||
@@ -91,14 +107,20 @@ UdpSocket::FinishBind (void)
|
||||
int
|
||||
UdpSocket::Bind (void)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Bind ()");
|
||||
|
||||
m_endPoint = m_udp->Allocate ();
|
||||
return FinishBind ();
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::Bind (const Address &address)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Bind (" << address << ")");
|
||||
|
||||
if (!InetSocketAddress::IsMatchingType (address))
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Bind (): Not IsMatchingType");
|
||||
return ERROR_INVAL;
|
||||
}
|
||||
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
|
||||
@@ -127,12 +149,15 @@ UdpSocket::Bind (const Address &address)
|
||||
int
|
||||
UdpSocket::ShutdownSend (void)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::ShutDownSend ()");
|
||||
m_shutdownSend = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::ShutdownRecv (void)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::ShutDownRecv ()");
|
||||
m_shutdownRecv = false;
|
||||
return 0;
|
||||
}
|
||||
@@ -140,6 +165,7 @@ UdpSocket::ShutdownRecv (void)
|
||||
int
|
||||
UdpSocket::Close(void)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Close ()");
|
||||
NotifyCloseCompleted ();
|
||||
return 0;
|
||||
}
|
||||
@@ -147,6 +173,8 @@ UdpSocket::Close(void)
|
||||
int
|
||||
UdpSocket::Connect(const Address & address)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Connect (" << address << ")");
|
||||
|
||||
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
|
||||
m_defaultAddress = transport.GetIpv4 ();
|
||||
m_defaultPort = transport.GetPort ();
|
||||
@@ -154,9 +182,12 @@ UdpSocket::Connect(const Address & address)
|
||||
m_connected = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::Send (const Packet &p)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::Send (" << &p << ")");
|
||||
|
||||
if (!m_connected)
|
||||
{
|
||||
m_errno = ERROR_NOTCONN;
|
||||
@@ -164,17 +195,23 @@ UdpSocket::Send (const Packet &p)
|
||||
}
|
||||
return DoSendTo (p, m_defaultAddress, m_defaultPort);
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::DoSendTo (const Packet &p, const Address &address)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::DoSendTo (" << &p << ", " << address << ")");
|
||||
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
|
||||
Ipv4Address ipv4 = transport.GetIpv4 ();
|
||||
uint16_t port = transport.GetPort ();
|
||||
return DoSendTo (p, ipv4, port);
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::DoSendTo (const Packet &p, Ipv4Address ipv4, uint16_t port)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::DoSendTo (" << &p << ", " << ipv4 << ", " <<
|
||||
port << ")");
|
||||
|
||||
if (m_endPoint == 0)
|
||||
{
|
||||
if (Bind () == -1)
|
||||
@@ -189,14 +226,18 @@ UdpSocket::DoSendTo (const Packet &p, Ipv4Address ipv4, uint16_t port)
|
||||
m_errno = ERROR_SHUTDOWN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_DEBUG("UdpSocket::DoSendTo (): Send to UDP");
|
||||
m_udp->Send (p, m_endPoint->GetLocalAddress (), ipv4,
|
||||
m_endPoint->GetLocalPort (), port);
|
||||
NotifyDataSent (p.GetSize ());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::SendTo(const Address &address, const Packet &p)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::SendTo (" << address << ", " << &p << ")");
|
||||
if (m_connected)
|
||||
{
|
||||
m_errno = ERROR_ISCONN;
|
||||
@@ -211,6 +252,9 @@ UdpSocket::SendTo(const Address &address, const Packet &p)
|
||||
void
|
||||
UdpSocket::ForwardUp (const Packet &packet, Ipv4Address ipv4, uint16_t port)
|
||||
{
|
||||
NS_DEBUG("UdpSocket::ForwardUp (" << &packet << ", " << ipv4 << ", " <<
|
||||
port << ")");
|
||||
|
||||
if (m_shutdownRecv)
|
||||
{
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user