Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 36 additions & 30 deletions ACE/ace/Ping_Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)

#include "ace/ACE.h"
#include "ace/INET_Addr.h"
#include "ace/Log_Category.h"
#include "ace/OS_NS_string.h"
Expand Down Expand Up @@ -110,9 +111,10 @@ ACE_Ping_Socket::ACE_Ping_Socket (ACE_Addr const & local,

if (this->open (local, protocol, reuse_addr) == -1)
{
ACELIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("ACE_Ping_Socket::ACE_Ping_Socket: %p\n"),
ACE_TEXT ("open")));
if (ACE::debug())
ACELIB_DEBUG ((LM_DEBUG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use {} around ACE_LIB_DEBUG, all places here

ACE_TEXT ("ACE_Ping_Socket::ACE_Ping_Socket: %p\n"),
ACE_TEXT ("open")));
return;
}

Expand Down Expand Up @@ -222,11 +224,12 @@ ACE_Ping_Socket::process_incoming_dgram (char * ptr, ssize_t len)

if ((icmplen = len - hlen1) < ICMP_MIN)
{
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram")
ACE_TEXT (" - ICMP length is %b < 8.\n"),
icmplen));
if (ACE::debug())
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram")
ACE_TEXT (" - ICMP length is %b < 8.\n"),
icmplen));
ACELIB_ERROR_RETURN
((LM_ERROR,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram - ")
Expand All @@ -236,10 +239,11 @@ ACE_Ping_Socket::process_incoming_dgram (char * ptr, ssize_t len)

if (icmp->icmp_type == ICMP_ECHOREPLY)
{
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram")
ACE_TEXT (" - ICMP_ECHOREPLY received.\n")));
if (ACE::debug())
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram")
ACE_TEXT (" - ICMP_ECHOREPLY received.\n")));

if (icmp->icmp_id != (ACE_OS::getpid () & 0xFFFF))
{
Expand All @@ -263,21 +267,23 @@ ACE_Ping_Socket::process_incoming_dgram (char * ptr, ssize_t len)
-1);
}

ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE::Ping_Socket::process_incoming_dgram - ")
ACE_TEXT ("received ")
ACE_TEXT ("ICMP datagram with length of %b bytes (not counting ")
ACE_TEXT ("IP-header): seq=%u, ttl=%d.\n"),
icmplen, icmp->icmp_seq, ip->ip_ttl));
if (ACE::debug())
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram - ")
ACE_TEXT ("received ")
ACE_TEXT ("ICMP datagram with length of %b bytes (not counting ")
ACE_TEXT ("IP-header): seq=%u, ttl=%d.\n"),
icmplen, icmp->icmp_seq, ip->ip_ttl));

return 0; //= success
}

ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE::Ping_Socket::process_incoming_dgram - ")
ACE_TEXT ("received datagram that is not ICMP_ECHOREPLY.\n")));
if (ACE::debug())
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::process_incoming_dgram - ")
ACE_TEXT ("received datagram that is not ICMP_ECHOREPLY.\n")));

return -1;
}
Expand Down Expand Up @@ -352,16 +358,16 @@ ACE_Ping_Socket::make_echo_check (ACE_INET_Addr & remote_addr,
bool to_connect,
ACE_Time_Value const * timeout)
{
int rval_send = -1;
const int rval_send = this->send_echo_check (remote_addr, to_connect);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use right side const normally


if ((rval_send = this->send_echo_check (remote_addr,
to_connect)) == -1)
if (rval_send == -1)
return -1;

ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::make_echo_check - sent %d.\n"),
rval_send));
if (ACE::debug())
ACELIB_DEBUG
((LM_DEBUG,
ACE_TEXT ("(%P|%t) ACE_Ping_Socket::make_echo_check - sent %d bytes.\n"),
rval_send));

return this->receive_echo_reply (timeout);
}
Expand Down
Loading