From: Guilherme Maciel Ferreira Date: Sun, 29 May 2011 20:37:24 +0000 (-0300) Subject: Bring aboard TCP pinger class X-Git-Tag: v1.0~4 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=cd395966ebe2683fd9e9864713932ad9e021cc04;p=pingcheck Bring aboard TCP pinger class --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4366f83..96e656a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ set(SOURCES dns/hostaddress.cpp dns/timetolive.cpp host/hoststatusanalyzer.cpp + host/pinger.cpp host/pinginterval.cpp host/pingscheduler.cpp icmp/icmpdestinationunreachablemessage.cpp @@ -46,6 +47,7 @@ set(SOURCES icmp/ipv4header.cpp link/linkstatusanalyzer.cpp link/statusnotifiercommand.cpp + tcp/tcppinger.cpp main.cpp ) diff --git a/src/host/pinger.cpp b/src/host/pinger.cpp new file mode 100644 index 0000000..0d509fb --- /dev/null +++ b/src/host/pinger.cpp @@ -0,0 +1,33 @@ +/* + The software in this package is distributed under the GNU General + Public License version 2 (with a special exception described below). + + A copy of GNU General Public License (GPL) is included in this distribution, + in the file COPYING.GPL. + + As a special exception, if other files instantiate templates or use macros + or inline functions from this file, or you compile this file and link it + with other works to produce a work based on this file, this file + does not by itself cause the resulting work to be covered + by the GNU General Public License. + + However the source code for this file must still be made available + in accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work based + on this file might be covered by the GNU General Public License. + */ + +#include "host/pinger.h" + +//----------------------------------------------------------------------------- +// Pinger +//----------------------------------------------------------------------------- + +Pinger::Pinger() +{ +} + +Pinger::~Pinger() +{ +} diff --git a/src/host/pinger.h b/src/host/pinger.h new file mode 100644 index 0000000..859a5ae --- /dev/null +++ b/src/host/pinger.h @@ -0,0 +1,45 @@ +/* + The software in this package is distributed under the GNU General + Public License version 2 (with a special exception described below). + + A copy of GNU General Public License (GPL) is included in this distribution, + in the file COPYING.GPL. + + As a special exception, if other files instantiate templates or use macros + or inline functions from this file, or you compile this file and link it + with other works to produce a work based on this file, this file + does not by itself cause the resulting work to be covered + by the GNU General Public License. + + However the source code for this file must still be made available + in accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work based + on this file might be covered by the GNU General Public License. + */ + +#ifndef PINGER_H +#define PINGER_H + +#include + +#include + +//----------------------------------------------------------------------------- +// Pinger +//----------------------------------------------------------------------------- + +class Pinger +{ +public: + Pinger(); + virtual ~Pinger(); + + virtual void ping( + const std::string &destination_ip, + boost::function ping_done_callback + ) = 0; + +}; + +#endif /* PINGER_H */ diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index fa35713..019c726 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -31,6 +32,7 @@ using boost::asio::io_service; using boost::asio::ip::address; using boost::asio::ip::icmp; using boost::date_time::time_resolution_traits_adapted64_impl; +using boost::function; using boost::posix_time::microsec_clock; using boost::posix_time::ptime; using boost::posix_time::seconds; diff --git a/src/tcp/tcppinger.cpp b/src/tcp/tcppinger.cpp new file mode 100644 index 0000000..ced9c99 --- /dev/null +++ b/src/tcp/tcppinger.cpp @@ -0,0 +1,45 @@ +/* +The software in this package is distributed under the GNU General +Public License version 2 (with a special exception described below). + +A copy of GNU General Public License (GPL) is included in this distribution, +in the file COPYING.GPL. + +As a special exception, if other files instantiate templates or use macros +or inline functions from this file, or you compile this file and link it +with other works to produce a work based on this file, this file +does not by itself cause the resulting work to be covered +by the GNU General Public License. + +However the source code for this file must still be made available +in accordance with section (3) of the GNU General Public License. + +This exception does not invalidate any other reasons why a work based +on this file might be covered by the GNU General Public License. +*/ +#include "tcp/tcppinger.h" + +#include + +using namespace std; +using boost::function; + +//----------------------------------------------------------------------------- +// TcpPinger +//----------------------------------------------------------------------------- + +TcpPinger::TcpPinger() +{ +} + +TcpPinger::~TcpPinger() +{ +} + +void TcpPinger::ping( + const string &destination_ip, + function /*ping_done_callback*/ +) +{ + BOOST_ASSERT( !destination_ip.empty() ); +} diff --git a/src/tcp/tcppinger.h b/src/tcp/tcppinger.h new file mode 100644 index 0000000..9c20695 --- /dev/null +++ b/src/tcp/tcppinger.h @@ -0,0 +1,46 @@ +/* +The software in this package is distributed under the GNU General +Public License version 2 (with a special exception described below). + +A copy of GNU General Public License (GPL) is included in this distribution, +in the file COPYING.GPL. + +As a special exception, if other files instantiate templates or use macros +or inline functions from this file, or you compile this file and link it +with other works to produce a work based on this file, this file +does not by itself cause the resulting work to be covered +by the GNU General Public License. + +However the source code for this file must still be made available +in accordance with section (3) of the GNU General Public License. + +This exception does not invalidate any other reasons why a work based +on this file might be covered by the GNU General Public License. +*/ +#ifndef TCPPINGER_H +#define TCPPINGER_H + +#include + +#include + +#include "host/pinger.h" + +//----------------------------------------------------------------------------- +// TcpPinger +//----------------------------------------------------------------------------- + +class TcpPinger : public Pinger +{ +public: + TcpPinger(); + virtual ~TcpPinger(); + + void ping( + const std::string &destination_ip, + boost::function ping_done_callback + ); + +}; + +#endif /* TCPPINGER_H */