3 $Date: 2008/05/10 11:59:53 $
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netinet/ip_icmp.h>
21 #if defined (FREE_BSD) || defined (FREE_BSD5)
22 #include <netinet/in.h>
23 #include <netinet/in_systm.h>
24 #include <netinet/ip.h>
25 #include <netinet/ip_icmp.h>
26 #include <netinet/ip_var.h>
27 #include <arpa/inet.h>
30 #include "stg/os_int.h"
32 //-----------------------------------------------------------------------------
53 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
74 //-----------------------------------------------------------------------------
76 #define PING_DATA_LEN (64)
77 //-----------------------------------------------------------------------------
81 char msg[PING_DATA_LEN];
83 //-----------------------------------------------------------------------------
87 typedef std::multimap<uint32_t, time_t> PingIPs;
88 typedef PingIPs::size_type SizeType;
90 STG_PINGER(time_t delay = 15);
95 void AddIP(uint32_t ip);
96 void DelIP(uint32_t ip);
97 SizeType GetPingIPNum() const { return pingIP.size(); }
99 int GetIPTime(uint32_t ip, time_t * t) const;
100 void SetDelayTime(time_t d) { delay = d; }
101 time_t GetDelayTime() const { return delay; }
102 const std::string & GetStrError() const { return errorStr; }
105 uint16_t PingCheckSum(void * data, int len);
106 int SendPing(uint32_t ip);
111 static void * RunSendPing(void * d);
112 static void * RunRecvPing(void * d);
116 bool isRunningRecver;
117 bool isRunningSender;
120 pthread_t sendThread;
121 pthread_t recvThread;
126 std::string errorStr;
128 std::multimap<uint32_t, time_t> pingIP;
129 std::list<uint32_t> ipToAdd;
130 std::list<uint32_t> ipToDel;
132 mutable pthread_mutex_t mutex;
134 //-----------------------------------------------------------------------------