Ping_Socket.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Ping_Socket.h
00006  *
00007  *  Ping_Socket.h,v 1.7 2005/10/28 16:14:54 ossama Exp
00008  *
00009  *  @author Robert S. Iakobashvili <coroberti@gmail.com> <coroberti@walla.co.il>
00010  *  @author Gonzalo A. Diethelm <gonzalo.diethelm@aditiva.com>
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 /* ACE_LACKS_PRAGMA_ONCE */
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  * @class ACE_Ping_Socket
00035  *
00036  * @brief This class is useful to perform ICMP echo checks (pinging)
00037  * on the party of your interest.  It may be used as well to check
00038  * LAN-adapters against 3rd parties.
00039  */
00040 class ACE_Export ACE_Ping_Socket : public ACE_ICMP_Socket
00041 {
00042   typedef ACE_ICMP_Socket inherited;
00043 
00044 public:
00045 
00046   // = Initialization and termination methods.
00047 
00048   /// Default constructor.
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   /// Destructor.
00056   ~ACE_Ping_Socket (void);
00057 
00058   /// Wrapper around the BSD-style @c socket system call (no QoS).
00059   int open (ACE_Addr const & local = ACE_Addr::sap_any,
00060             int protocol = IPPROTO_ICMP,
00061             int reuse_addr = 0);
00062 
00063   /// @a toConnect = 1 - makes connect to remote address
00064   int send_echo_check (ACE_INET_Addr & remote_addr,
00065                        int to_connect = 0);
00066 
00067   /// To receive @c ICMP_ECHOREPLY. To be called after successfully
00068   /// sending @c ICMP_ECHO.
00069   int process_incoming_dgram (char * ptr, ssize_t len);
00070 
00071   /// @a toConnect = 1 - makes connect to remote address
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   /// Dump the state of an object.
00079   void dump (void) const;
00080 
00081   /// Declare the dynamic allocation hooks.
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   /// Do not allow this function to percolate up to this interface.
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 /* __ACE_INLINE__ */
00114 
00115 #endif  /* ACE_HAS_ICMP_SUPPORT == 1 */
00116 
00117 #include /**/ "ace/post.h"
00118 
00119 #endif /* ACE_PING_SOCKET_H */

Generated on Thu Nov 9 09:41:59 2006 for ACE by doxygen 1.3.6