概述
## ping_dev.h
#ifndef PING_DEV_H
#define PING_DEV_H
#include "typedef.h"
INT32 get_device_status(PCHAR pDevIp);
INT32 ping_fun(PCHAR pDevIp);
int ping_dev_by_icmp(PCHAR pDevIp);
int ping_dev_by_icmp_result();
UINT16 ping_dev_by_icmp_cksum(UINT16 *addr, UINT32 len);
int ping_dev_by_icmp_size(UINT32 pack_no);
VOID ping_dev_by_icmp_send();
VOID ping_dev_by_icmp_recv();
int ping_dev_by_icmp_upack(PCHAR buf, UINT32 len);
VOID ping_dev_by_icmp_timeval(struct timeval *out,struct timeval *in);
#endif
## ping_dev.cpp
#include "ping_dev.h"
#include "log.h"
#include <stdio.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netdb.h>
#include <time.h>
//check static device status
#define PACET_SIZE
4096
#define MAX_WAIT_TIME 3
#define MAX_NO_PACKETS 3
pid_t pid;
int sockfd = -1 ,datalen = 56;
int nsend = 0,nreceived = 0;
static INT32 gDevPingFlag = -1;
//-1:no device is pinging now, 0:some device is pinging now
char sendpacket[PACET_SIZE] = {'