Bring aboard TCP pinger class
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sun, 29 May 2011 20:37:24 +0000 (17:37 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sun, 29 May 2011 20:45:30 +0000 (17:45 -0300)
src/CMakeLists.txt
src/host/pinger.cpp [new file with mode: 0644]
src/host/pinger.h [new file with mode: 0644]
src/icmp/icmppinger.cpp
src/tcp/tcppinger.cpp [new file with mode: 0644]
src/tcp/tcppinger.h [new file with mode: 0644]

index 4366f83..96e656a 100644 (file)
@@ -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 (file)
index 0000000..0d509fb
--- /dev/null
@@ -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 (file)
index 0000000..859a5ae
--- /dev/null
@@ -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 <string>
+
+#include <boost/function.hpp>
+
+//-----------------------------------------------------------------------------
+// Pinger
+//-----------------------------------------------------------------------------
+
+class Pinger
+{
+public:
+    Pinger();
+    virtual ~Pinger();
+
+    virtual void ping(
+            const std::string &destination_ip,
+            boost::function<void(bool)> ping_done_callback
+    ) = 0;
+
+};
+
+#endif /* PINGER_H */
index fa35713..019c726 100644 (file)
@@ -9,6 +9,7 @@
 #include <istream>
 #include <ostream>
 
+#include <boost/assert.hpp>
 #include <boost/bind.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
@@ -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 (file)
index 0000000..ced9c99
--- /dev/null
@@ -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 <boost/assert.hpp>
+
+using namespace std;
+using boost::function;
+
+//-----------------------------------------------------------------------------
+// TcpPinger
+//-----------------------------------------------------------------------------
+
+TcpPinger::TcpPinger()
+{
+}
+
+TcpPinger::~TcpPinger()
+{
+}
+
+void TcpPinger::ping(
+        const string &destination_ip,
+        function<void(bool)> /*ping_done_callback*/
+)
+{
+    BOOST_ASSERT( !destination_ip.empty() );
+}
diff --git a/src/tcp/tcppinger.h b/src/tcp/tcppinger.h
new file mode 100644 (file)
index 0000000..9c20695
--- /dev/null
@@ -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 <string>
+
+#include <boost/function.hpp>
+
+#include "host/pinger.h"
+
+//-----------------------------------------------------------------------------
+// TcpPinger
+//-----------------------------------------------------------------------------
+
+class TcpPinger : public Pinger
+{
+public:
+    TcpPinger();
+    virtual ~TcpPinger();
+
+    void ping(
+            const std::string &destination_ip,
+            boost::function<void(bool)> ping_done_callback
+    );
+
+};
+
+#endif /* TCPPINGER_H */