-
Notifications
You must be signed in to change notification settings - Fork 35
/
ping.h
35 lines (25 loc) · 969 Bytes
/
ping.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef _PING_H
#define _PING_H
#include <stdint.h>
#ifdef WIN32
typedef int socklen_t;
struct sockaddr;
#else
#include <sys/socket.h>
#endif
unsigned short checksum(const unsigned char *b, uint16_t len);
//Callback (when received)
void display(uint8_t *buf, int bytes);
//Callback (before sending)
//return value = # of bytes to send in ping message.
int load_ping_packet( uint8_t * buffer, int buffersize );
void listener();
void ping(struct sockaddr *addr, socklen_t addr_len );
void do_pinger( );
void singleping(struct sockaddr *addr, socklen_t addr_len ); // If using this, must call ping_setup( 0, 0); to begin.
//If pingperiodseconds = -1, run ping/do_pinger once and exit.
extern float pingperiodseconds;
extern int precise_ping; //if 0, use minimal CPU, but ping send-outs are only approximate, if 1, spinlock until precise time for ping is hit.
extern int ping_failed_to_send;
void ping_setup(const char * strhost, const char * device);
#endif