Files
TCPlayerbotCore/dep/ACE_wrappers/ace/Ping_Socket.h
T

120 lines
2.9 KiB
C++
Raw Normal View History

// -*- C++ -*-
2009-10-17 15:51:44 -07:00
//=============================================================================
/**
* @file Ping_Socket.h
*
* $Id: Ping_Socket.h 81737 2008-05-20 09:46:39Z johnnyw $
*
* @author Robert S. Iakobashvili <[email protected]> <[email protected]>
* @author Gonzalo A. Diethelm <[email protected]>
*/
//=============================================================================
2009-10-17 15:51:44 -07:00
#ifndef ACE_PING_SOCKET_H
#define ACE_PING_SOCKET_H
2009-10-17 15:51:44 -07:00
#include /**/ "ace/pre.h"
2009-10-17 15:51:44 -07:00
#include /**/ "ace/ACE_export.h"
2009-10-17 15:51:44 -07:00
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
2009-10-17 15:51:44 -07:00
#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)
2009-10-17 15:51:44 -07:00
#include "ace/ICMP_Socket.h"
2009-10-17 15:51:44 -07:00
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
2009-10-17 15:51:44 -07:00
class ACE_INET_Addr;
2009-10-17 15:51:44 -07:00
/**
* @class ACE_Ping_Socket
*
* @brief This class is useful to perform ICMP echo checks (pinging)
* on the party of your interest. It may be used as well to check
* LAN-adapters against 3rd parties.
*/
class ACE_Export ACE_Ping_Socket : public ACE_ICMP_Socket
{
typedef ACE_ICMP_Socket inherited;
2009-10-17 15:51:44 -07:00
public:
2009-10-17 15:51:44 -07:00
// = Initialization and termination methods.
2009-10-17 15:51:44 -07:00
/// Default constructor.
ACE_Ping_Socket (void);
2009-10-17 15:51:44 -07:00
ACE_Ping_Socket (ACE_Addr const & local,
int protocol = IPPROTO_ICMP,
int reuse_addr = 0);
2009-10-17 15:51:44 -07:00
/// Destructor.
~ACE_Ping_Socket (void);
2009-10-17 15:51:44 -07:00
/// Wrapper around the BSD-style @c socket system call (no QoS).
int open (ACE_Addr const & local = ACE_Addr::sap_any,
int protocol = IPPROTO_ICMP,
int reuse_addr = 0);
2009-10-17 15:51:44 -07:00
/// @a toConnect = 1 - makes connect to remote address
int send_echo_check (ACE_INET_Addr & remote_addr,
bool to_connect = false);
2009-10-17 15:51:44 -07:00
/// To receive @c ICMP_ECHOREPLY. To be called after successfully
/// sending @c ICMP_ECHO.
int process_incoming_dgram (char * ptr, ssize_t len);
2009-10-17 15:51:44 -07:00
/// @a toConnect = 1 - makes connect to remote address
int make_echo_check (ACE_INET_Addr & remote_addr,
bool to_connect = false,
ACE_Time_Value const * timeout = &time_default_);
2009-10-17 15:51:44 -07:00
char * icmp_recv_buff (void);
2009-10-17 15:51:44 -07:00
/// Dump the state of an object.
void dump (void) const;
2009-10-17 15:51:44 -07:00
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
2009-10-17 15:51:44 -07:00
public:
2009-10-17 15:51:44 -07:00
enum
{
PING_BUFFER_SIZE = (1024 * 2)
};
2009-10-17 15:51:44 -07:00
static ACE_Time_Value const time_default_;
2009-10-17 15:51:44 -07:00
private:
2009-10-17 15:51:44 -07:00
int receive_echo_reply (ACE_Time_Value const * timeout);
2009-10-17 15:51:44 -07:00
/// Do not allow this function to percolate up to this interface.
int get_remote_addr (ACE_INET_Addr &addr) const;
2009-10-17 15:51:44 -07:00
char icmp_send_buff_[PING_BUFFER_SIZE];
char icmp_recv_buff_[PING_BUFFER_SIZE];
2009-10-17 15:51:44 -07:00
ACE_UINT16 sequence_number_;
2009-10-17 15:51:44 -07:00
bool connected_socket_;
};
2009-10-17 15:51:44 -07:00
ACE_END_VERSIONED_NAMESPACE_DECL
2009-10-17 15:51:44 -07:00
#if defined (__ACE_INLINE__)
# include "ace/Ping_Socket.inl"
#endif /* __ACE_INLINE__ */
2009-10-17 15:51:44 -07:00
#endif /* ACE_HAS_ICMP_SUPPORT == 1 */
2009-10-17 15:51:44 -07:00
#include /**/ "ace/post.h"
2009-10-17 15:51:44 -07:00
#endif /* ACE_PING_SOCKET_H */
2009-02-17 20:07:49 -06:00