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>
32 //-----------------------------------------------------------------------------
53 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
74 //-----------------------------------------------------------------------------
76 #define PING_DATA_LEN (64)
77 //-----------------------------------------------------------------------------
81 char msg[PING_DATA_LEN];
83 //-----------------------------------------------------------------------------
87 STG_PINGER(time_t delay = 15);
92 void AddIP(uint32_t ip);
93 void DelIP(uint32_t ip);
94 int GetPingIPNum() const;
96 int GetIPTime(uint32_t ip, time_t * t) const;
97 void SetDelayTime(time_t d) { delay = d; }
98 time_t GetDelayTime() const { return delay; }
99 const std::string & GetStrError() const { return errorStr; }
102 uint16_t PingCheckSum(void * data, int len);
103 int SendPing(uint32_t ip);
108 static void * RunSendPing(void * d);
109 static void * RunRecvPing(void * d);
113 bool isRunningRecver;
114 bool isRunningSender;
117 pthread_t sendThread;
118 pthread_t recvThread;
123 std::string errorStr;
125 std::multimap<uint32_t, time_t> pingIP;
126 std::list<uint32_t> ipToAdd;
127 std::list<uint32_t> ipToDel;
129 mutable pthread_mutex_t mutex;
131 //-----------------------------------------------------------------------------