dns/dnsresolver.cpp
dns/hostaddress.cpp
dns/timetolive.cpp
- host/hoststatusanalyzer.cpp
+ host/hoststatus.cpp
host/messagepayload.cpp
host/networkinterfacelist.cpp
host/pinger.cpp
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/hoststatusanalyzer.h"
+#include "host/hoststatus.h"
#include <iostream>
using boost::shared_ptr;
//-----------------------------------------------------------------------------
-// HostStatusAnalyzer
+// HostStatus
//-----------------------------------------------------------------------------
/**
- * @param host_address the address of the host it has to analyze.
- * @param ping_fail_percentage_limit the percentage threshold of pings that can
+ * @param host_address The address of the host it has to analyze.
+ * @param ping_fail_percentage_limit The percentage threshold of pings that can
* fail.
- * @param link_analyzer the object used to notify the status of the host.
+ * @param link_analyzer The object used to notify the status of the host.
*/
-HostStatusAnalyzer::HostStatusAnalyzer(
+HostStatus::HostStatus(
const string &host_address,
const int ping_fail_limit_percentage,
const shared_ptr<LinkStatusAnalyzer> link_analyzer
BOOST_ASSERT( ( 0 <= PingFailLimitPercentage ) && ( PingFailLimitPercentage <= 100 ) );
}
-HostStatusAnalyzer::~HostStatusAnalyzer()
+HostStatus::~HostStatus()
{
}
/**
- * @param resolved_ip_count the number of IPs resolved for the host.
+ * @param resolved_ip_count The number of IPs resolved for the host.
*/
-void HostStatusAnalyzer::set_resolved_ip_count( const int resolved_ip_count )
+void HostStatus::set_resolved_ip_count( const int resolved_ip_count )
{
BOOST_ASSERT( 1 <= resolved_ip_count );
* @return true if the amount of failed pings given to the host exceeded the
* limit.
*/
-bool HostStatusAnalyzer::exceeded_ping_failed_limit() const
+bool HostStatus::exceeded_ping_failed_limit() const
{
return ExceededPingFailedLimit;
}
* Adds a ping status (success or failure).
* @param ping_success
*/
-void HostStatusAnalyzer::update_ping_statistics( bool ping_success )
+void HostStatus::update_ping_statistics( bool ping_success )
{
BOOST_ASSERT( 1 <= ResolvedIpCount );
BOOST_ASSERT( 0 <= PingsPerformedCount );
BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount );
}
-bool HostStatusAnalyzer::tried_all_resolved_ip() const
+bool HostStatus::tried_all_resolved_ip() const
{
BOOST_ASSERT( ( 0 < PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) );
return ( PingsPerformedCount == ResolvedIpCount );
}
-void HostStatusAnalyzer::analyze_ping_statistics()
+void HostStatus::analyze_ping_statistics()
{
BOOST_ASSERT( !HostAddress.empty() );
BOOST_ASSERT( PingsPerformedCount == ResolvedIpCount );
}
-void HostStatusAnalyzer::reset_ping_counters()
+void HostStatus::reset_ping_counters()
{
PingsPerformedCount = 0;
PingsFailedCount = 0;
}
-void HostStatusAnalyzer::increase_ping_performed_count()
+void HostStatus::increase_ping_performed_count()
{
++PingsPerformedCount;
BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) );
}
-void HostStatusAnalyzer::increase_ping_failed_count()
+void HostStatus::increase_ping_failed_count()
{
++PingsFailedCount;
BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) );
}
-void HostStatusAnalyzer::analyze_ping_failed_count()
+void HostStatus::analyze_ping_failed_count()
{
BOOST_ASSERT( ( 0 <= PingFailLimitPercentage ) && ( PingFailLimitPercentage <= 100 ) );
BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) );
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 HOST_STATUS_ANALYZER_H
-#define HOST_STATUS_ANALYZER_H
+#ifndef HOST_STATUS_H
+#define HOST_STATUS_H
#include <string>
#include "link/linkstatusanalyzer.h"
//-----------------------------------------------------------------------------
-// HostStatusAnalyzer
+// HostStatus
//-----------------------------------------------------------------------------
/**
* responses (success or failure). And notifies its status.
* Scope: one object per host.
*/
-class HostStatusAnalyzer
+class HostStatus
{
public:
- HostStatusAnalyzer(
+ HostStatus(
const std::string &host_address,
const int ping_fail_limit_percentage,
const boost::shared_ptr<LinkStatusAnalyzer> link_analyzer
);
- ~HostStatusAnalyzer();
+ ~HostStatus();
void set_resolved_ip_count( const int resolved_ip_count );
bool exceeded_ping_failed_limit() const;
};
-#endif // HOST_STATUS_ANALYZER_H
+#endif // HOST_STATUS_H
#include "dns/dnsresolver.h"
#include "link/linkstatusanalyzer.h"
-#include "host/hoststatusanalyzer.h"
+#include "host/hoststatus.h"
#include "host/pinger.h"
#include "host/pingerfactory.h"
#include "host/pinginterval.h"
/// The port to ping at destination host
int DestinationPort;
/// Object responsible to evaluate the status of the host
- HostStatusAnalyzer HostAnalyzer;
+ HostStatus HostAnalyzer;
/// Internal boost pinger object
boost::shared_ptr<Pinger> Ping;
/// Thread object
--- /dev/null
+# compiler: creates the binaries
+add_executable(test_hoststatus
+ test_hoststatus.cpp
+ ${CMAKE_SOURCE_DIR}/src/host/hoststatus.cpp
+)
+
+# linker: link the program against the libraries
+target_link_libraries(
+ test_hoststatus
+ ${I2NCOMMON_LIBRARIES}
+ ${Boost_LIBRARIES}
+)
+
+# cmake: invocation via "make test"
+add_test(test_hoststatus test_hoststatus)
+++ /dev/null
-# compiler: creates the binaries
-add_executable(test_hoststatusanalyzer
- test_hoststatusanalyzer.cpp
- ${CMAKE_SOURCE_DIR}/src/host/hoststatusanalyzer.cpp
-)
-
-# linker: link the program against the libraries
-target_link_libraries(
- test_hoststatusanalyzer
- ${I2NCOMMON_LIBRARIES}
- ${Boost_LIBRARIES}
-)
-
-# cmake: invocation via "make test"
-add_test(test_hoststatusanalyzer test_hoststatusanalyzer)
# cmake: inclusion of each test case cmake file
include(CMakeLists.test_messagepayload.txt)
-include(CMakeLists.test_hoststatusanalyzer.txt)
+include(CMakeLists.test_hoststatus.txt)
include(CMakeLists.test_ipv4header.txt)
include(CMakeLists.test_ipv6header.txt)
include(CMakeLists.test_icmpv4header.txt)
# cmake: add a custom "make check" target which automatically builds the binary
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS
test_messagepayload
- test_hoststatusanalyzer
+ test_hoststatus
test_ipv4header
test_ipv6header
test_icmpv4header
#include "mock_linkstatusanalyzer.h"
-#include "host/hoststatusanalyzer.h"
+#include "host/hoststatus.h"
-BOOST_AUTO_TEST_SUITE( TestHostStatusAnalyzer )
+BOOST_AUTO_TEST_SUITE( TestHostStatus )
BOOST_AUTO_TEST_CASE( fail_percentage_10 )
{
int resolved_ip_count = 10;
LinkStatusAnalyzerItem link_status( new LinkStatusAnalyzer );
- HostStatusAnalyzer host_status( "localhost", ping_fail_percentage_limit, link_status );
+ HostStatus host_status( "localhost", ping_fail_percentage_limit, link_status );
host_status.set_resolved_ip_count( resolved_ip_count );
host_status.update_ping_statistics( true );
int resolved_ip_count = 10;
LinkStatusAnalyzerItem link_status( new LinkStatusAnalyzer );
- HostStatusAnalyzer host_status( "localhost", ping_fail_percentage_limit, link_status );
+ HostStatus host_status( "localhost", ping_fail_percentage_limit, link_status );
host_status.set_resolved_ip_count( resolved_ip_count );
host_status.update_ping_statistics( true );
int resolved_ip_count = 10;
LinkStatusAnalyzerItem link_status( new LinkStatusAnalyzer );
- HostStatusAnalyzer host_status( "localhost", ping_fail_percentage_limit, link_status );
+ HostStatus host_status( "localhost", ping_fail_percentage_limit, link_status );
host_status.set_resolved_ip_count( resolved_ip_count );
host_status.update_ping_statistics( false );