From 59b21be36b2f4cd74aa0cea53492e3023b59770b Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Fri, 14 Dec 2007 13:40:31 -0800 Subject: initial check wan lb Signed-off-by: Michael Larson --- src/hosttool.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/hosttool.h (limited to 'src/hosttool.h') diff --git a/src/hosttool.h b/src/hosttool.h new file mode 100644 index 0000000..06d03a0 --- /dev/null +++ b/src/hosttool.h @@ -0,0 +1,86 @@ +/** + * Module: HostsTool + * Description: Collects lists of hosts on the network responding to broadcast icmp. + * This list of hosts are then dispatched for processing of results + * + * Author: Michael Larson + * email: mike(at)lrlart.com + * Date: August 2004 + **/ +#ifndef HOSTSTOOL_HPP_ +#define HOSTSTOOL_HPP_ + +//forward decls +class HostsResult; + +//header includes +#include +#include "Task.hpp" +#include "Test.hpp" +#include "ToolBase.hpp" + +/********************************************* + ** HostsToolKonstants ** + *********************************************/ +class HostsToolKonstants +{ + public: + static const int packet_data_len_; + static const int recv_timeout_; + static const int ip_offset_; +}; + +/********************************************* + ** HostsTool ** + *********************************************/ +class HostsTool : public ToolBase +{ + public: + /* + * Constructor and Destructor + */ + HostsTool(Task *pCompleteTask, unsigned long local_ip, unsigned long bc_addr_); + ~HostsTool(); + + /* + * compute test result + */ + void + compute(); + + /* + * finished tests + */ + void + finish(); + + /* + * send a new test + */ + void + send(unsigned long target_addr, unsigned short packet_id); + + /* + * receive results + */ + HostsResult* + receive(); + + private: + /* + * checksum for icmp packets + */ + unsigned short + in_checksum(const unsigned short *addr, int len) const; + + private: + unsigned long local_ip_; + int send_sock_; + int recv_sock_; + unsigned long bc_addr_; + int packet_id_; + bool test_in_progress_; + PERF_MUTEX mutex_; +}; + +#endif //HOSTSTOOL_HPP_ -- cgit v1.2.3