Advertisement
abagrintsev

PingProcess.h

Sep 3rd, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. #ifndef PINGPROCESS_H
  2. #define PINGPROCESS_H
  3.  
  4. #include <string>
  5. #include <boost/asio.hpp>
  6. #include <boost/bind.hpp>
  7. #include <boost/asio/time_traits.hpp>
  8. #include <boost/date_time/posix_time/posix_time.hpp>
  9. #include <boost/asio/signal_set.hpp>
  10. #include <Logging_Controller.h>
  11. #include "Icmp_header.hpp"
  12. #include "Ipv4_header.hpp"
  13.  
  14. class Ping;
  15.  
  16. class PingProcess : public boost::noncopyable
  17. {
  18. friend Ping;
  19.  
  20. public:
  21.     const int timeout_to_fail = 5,
  22.         timeout_to_send_request = 60,
  23.         timeout_to_read_reply = 5;
  24.    
  25. private:
  26.    
  27.     Ping *parent;
  28.    
  29.     boost::asio::ip::icmp::endpoint m_destination;
  30.     unsigned short m_sequence_number;
  31.     boost::asio::ip::icmp::resolver *m_resolver;
  32.     boost::posix_time::ptime m_time_sent;
  33.     boost::asio::deadline_timer *m_timer;
  34.     boost::asio::streambuf *m_reply_buffer;
  35.     std::size_t m_num_replies;
  36.     boost::asio::ip::icmp::socket *m_socket;
  37.     bool m_camera_availability;
  38.    
  39.     void HandleTimeout();
  40.     void HandleReceive ( std::size_t length );
  41.    
  42.     std::string UUID;
  43.     int m_ping_process_id;
  44.     int m_num_timeout;
  45.    
  46.     void StartSend();
  47.     void StartReceive();
  48.     bool Init();
  49.     bool Query ( std::string destination );
  50.    
  51. public:
  52.     PingProcess ( Ping *parent );
  53.     ~PingProcess();
  54.    
  55.     /*
  56.     PingProcess& operator=(const PingProcess& other);
  57.     PingProcess(const PingProcess& other);
  58.     bool operator==(const PingProcess& other) const;*/
  59.     //short unsigned int GetIdentidier();
  60.    
  61.     /**
  62.     * Установить ID для камеры или объекта
  63.     * @param uuid - идентификатор камеры
  64.     */
  65.     void SetUUID ( std::string uuid );
  66.     /**
  67.     * Пометить камеру как недоступную
  68.     * @param uuid - идентификатор камеры
  69.     */
  70.     void SetCameraUnavailable ( std::string uuid );
  71.     /**
  72.     * Пометить камеру как доступную
  73.     * @param uuid - идентификатор камеры
  74.     */
  75.     void SetCameraAvailable ( std::string uuid );
  76.     /**
  77.      * Идентификатор процесса пингера. Нужен, чтобы отличать пришедшие пакеты между процессами.
  78.     * @param ID - уникальное число
  79.     */
  80.     void SetPingProcessID ( int ID );
  81. };
  82. #endif // PINGPROCESS_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement