Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Ping_Socket.h
blob59faff255b5e10f82c971c05a7471a41eb47fba5
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Ping_Socket.h
7 * @author Robert S. Iakobashvili <coroberti@gmail.com> <coroberti@walla.co.il>
8 * @author Gonzalo A. Diethelm <gonzalo.diethelm@aditiva.com>
9 */
10 //=============================================================================
12 #ifndef ACE_PING_SOCKET_H
13 #define ACE_PING_SOCKET_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)
25 #include "ace/ICMP_Socket.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 class ACE_INET_Addr;
31 /**
32 * @class ACE_Ping_Socket
34 * @brief This class is useful to perform ICMP echo checks (pinging)
35 * on the party of your interest. It may be used as well to check
36 * LAN-adapters against 3rd parties.
38 class ACE_Export ACE_Ping_Socket : public ACE_ICMP_Socket
40 typedef ACE_ICMP_Socket inherited;
41 public:
42 /// Default constructor.
43 ACE_Ping_Socket ();
45 ACE_Ping_Socket (ACE_Addr const & local,
46 int protocol = IPPROTO_ICMP,
47 int reuse_addr = 0);
49 /// Destructor.
50 ~ACE_Ping_Socket ();
52 /// Wrapper around the BSD-style @c socket system call (no QoS).
53 int open (ACE_Addr const & local = ACE_Addr::sap_any,
54 int protocol = IPPROTO_ICMP,
55 int reuse_addr = 0);
57 /// @a to_connect = true - makes connect to remote address
58 int send_echo_check (ACE_INET_Addr & remote_addr,
59 bool to_connect = false);
61 /// To receive @c ICMP_ECHOREPLY. To be called after successfully
62 /// sending @c ICMP_ECHO.
63 int process_incoming_dgram (char * ptr, ssize_t len);
65 /// @a to_connect = true - makes connect to remote address
66 int make_echo_check (ACE_INET_Addr & remote_addr,
67 bool to_connect = false,
68 ACE_Time_Value const * timeout = &time_default_);
70 char * icmp_recv_buff ();
72 /// Dump the state of an object.
73 void dump () const;
75 /// Declare the dynamic allocation hooks.
76 ACE_ALLOC_HOOK_DECLARE;
78 public:
79 enum
81 PING_BUFFER_SIZE = (1024 * 2)
84 static ACE_Time_Value const time_default_;
86 private:
87 int receive_echo_reply (ACE_Time_Value const * timeout);
89 /// Do not allow this function to percolate up to this interface.
90 int get_remote_addr (ACE_INET_Addr &addr) const;
92 char icmp_send_buff_[PING_BUFFER_SIZE];
93 char icmp_recv_buff_[PING_BUFFER_SIZE];
95 ACE_UINT16 sequence_number_;
97 bool connected_socket_;
100 ACE_END_VERSIONED_NAMESPACE_DECL
102 #if defined (__ACE_INLINE__)
103 # include "ace/Ping_Socket.inl"
104 #endif /* __ACE_INLINE__ */
106 #endif /* ACE_HAS_ICMP_SUPPORT == 1 */
108 #include /**/ "ace/post.h"
110 #endif /* ACE_PING_SOCKET_H */