host/hoststatusanalyzer.cpp
host/pinger.cpp
host/pinginterval.cpp
+ host/pingprotocol.cpp
host/pingscheduler.cpp
icmp/icmpdestinationunreachablemessage.cpp
icmp/icmpechoreplymessage.cpp
#ifndef PINGERFACTORY_H
#define PINGERFACTORY_H
+#include "host/pingprotocol.h"
+
//-----------------------------------------------------------------------------
// PingerFactory
//-----------------------------------------------------------------------------
class PingerFactory
{
public:
- enum PingProtocol
- {
- PingProtocol_ICMP,
- PingProtocol_TCP
- };
-
-public:
PingerFactory();
virtual ~PingerFactory();
--- /dev/null
+/*
+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/pingprotocol.h"
+
+#include <map>
+
+#include <boost/assert.hpp>
+
+using namespace std;
+
+map<string, PingProtocol> protocol_string_map;
+
+PingProtocol get_ping_protocol_from_string( string protocol_string )
+{
+ BOOST_ASSERT( !protocol_string.empty() );
+
+ // TODO move to an init method
+ protocol_string_map[ "ICMP" ] = PingProtocol_ICMP;
+ protocol_string_map[ "TCP" ] = PingProtocol_TCP;
+
+ return protocol_string_map[ protocol_string ];
+}
--- /dev/null
+/*
+ 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 PINGPROTOCOL_H
+#define PINGPROTOCOL_H
+
+#include <string>
+
+enum PingProtocol
+{
+ PingProtocol_First = 0,
+ PingProtocol_ICMP = 0,
+ PingProtocol_TCP,
+ PingProtocol_Last = PingProtocol_TCP
+};
+
+PingProtocol get_ping_protocol_from_string( std::string protocol_string );
+
+#endif /* PINGPROTOCOL_H */
PingScheduler::PingScheduler(
const string &network_interface,
const string &destination_address,
- const PingerFactory::PingProtocol /*ping_protocol*/,
+ const PingProtocol /*ping_protocol*/,
const long ping_interval_in_sec,
const int ping_fail_percentage_limit,
const string &nameserver,
#include "host/pinger.h"
#include "host/pingerfactory.h"
#include "host/pinginterval.h"
+#include "host/pingprotocol.h"
#include "icmp/icmppinger.h"
//-----------------------------------------------------------------------------
PingScheduler(
const std::string &network_interface,
const std::string &destination_address,
- const PingerFactory::PingProtocol ping_protocol,
+ const PingProtocol ping_protocol,
const long ping_interval_in_sec,
const int ping_fail_percentage_limit,
const std::string &nameserver,
#include "config/host.h"
#include "link/linkstatusanalyzer.h"
#include "host/pingerfactory.h"
+#include "host/pingprotocol.h"
#include "host/pingscheduler.h"
using namespace std;
PingSchedulerList *scheduler_list
)
{
+ PingProtocol protocol = configuration->get_ping_protocol();
string local_interface = configuration->get_source_network_interface();
string nameserver = configuration->get_nameserver();
int ping_fail_limit = configuration->get_ping_fail_limit();
{
string destination_address = host->get_address();
int ping_interval_in_sec = host->get_interval_in_sec();
- PingerFactory::PingProtocol protocol = PingerFactory::PingProtocol_ICMP;
PingSchedulerItem scheduler(
new PingScheduler(
local_interface,