00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ACE_PING_SOCKET_H
00015 #define ACE_PING_SOCKET_H
00016
00017 #include "ace/pre.h"
00018
00019 #include "ace/ACE_export.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif
00024
00025 #if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)
00026
00027 #include "ace/ICMP_Socket.h"
00028
00029 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00030
00031 class ACE_INET_Addr;
00032
00033
00034
00035
00036
00037
00038
00039
00040 class ACE_Export ACE_Ping_Socket : public ACE_ICMP_Socket
00041 {
00042 typedef ACE_ICMP_Socket inherited;
00043
00044 public:
00045
00046
00047
00048
00049 ACE_Ping_Socket (void);
00050
00051 ACE_Ping_Socket (ACE_Addr const & local,
00052 int protocol = IPPROTO_ICMP,
00053 int reuse_addr = 0);
00054
00055
00056 ~ACE_Ping_Socket (void);
00057
00058
00059 int open (ACE_Addr const & local = ACE_Addr::sap_any,
00060 int protocol = IPPROTO_ICMP,
00061 int reuse_addr = 0);
00062
00063
00064 int send_echo_check (ACE_INET_Addr & remote_addr,
00065 int to_connect = 0);
00066
00067
00068
00069 int process_incoming_dgram (char * ptr, ssize_t len);
00070
00071
00072 int make_echo_check (ACE_INET_Addr & remote_addr,
00073 int to_connect = 0,
00074 ACE_Time_Value const * timeout = &time_default_);
00075
00076 char * icmp_recv_buff (void);
00077
00078
00079 void dump (void) const;
00080
00081
00082 ACE_ALLOC_HOOK_DECLARE;
00083
00084 public:
00085
00086 enum
00087 {
00088 PING_BUFFER_SIZE = (1024 * 2)
00089 };
00090
00091 static ACE_Time_Value const time_default_;
00092
00093 private:
00094
00095 int receive_echo_reply (ACE_Time_Value const * timeout);
00096
00097
00098 int get_remote_addr (ACE_INET_Addr &addr) const;
00099
00100 char icmp_send_buff_[PING_BUFFER_SIZE];
00101 char icmp_recv_buff_[PING_BUFFER_SIZE];
00102
00103 ACE_UINT16 sequence_number_;
00104
00105 int connected_socket_;
00106
00107 };
00108
00109 ACE_END_VERSIONED_NAMESPACE_DECL
00110
00111 #if defined (__ACE_INLINE__)
00112 # include "ace/Ping_Socket.inl"
00113 #endif
00114
00115 #endif
00116
00117 #include "ace/post.h"
00118
00119 #endif