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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
/*
* This file provides a system independant interface to send and
* receive ICMP messages.
*/
#ifndef _mod_icmp_h_
#define _mod_icmp_h_
#if defined(__STDC__) || defined(__cplusplus)
#define PROTO(a,b) a b
#else
#define PROTO(a,b) a()
#endif
#ifdef __cplusplus
#define API "C"
#else
#define API
#endif
typedef void* icmp_handle;
/* initialize the ICMP module, return a pointer to it. */
extern icmp_handle PROTO(
icmp_open,
(
void
));
/* set a socket option. Returns >= 0 if successful, -1 otherwise */
extern int PROTO(
icmp_set_option,
(
icmp_handle handle, /* module handle */
int level,
int optname, /* option to be set */
void *optval, /* option value */
int optlen /* length of option value */
));
/* set the timeout for receives */
extern void PROTO(
icmp_set_timeout,
(
icmp_handle handle,
unsigned long timeout /* timeout in microseconds */
));
/* get the ID used in packets */
extern unsigned short PROTO(
icmp_get_id,
(
icmp_handle handle
));
/* send an ICMP message. Returns >= 0 if successful, -1 otherwise */
extern int PROTO(
icmp_send,
(
icmp_handle handle, /* module handle */
void *msg, /* ICMP message contents */
int msg_size, /* size */
struct sockaddr *to_addr, /* who to send to */
int to_addr_size /* sockaddr size */
));
/*
* Wait for an ICMP message.
* Returns:
* >0: successful, return value is the packet size
* 0: timeout
* -1: interrupted, should be called again
*/
extern int PROTO(
icmp_recv,
(
icmp_handle handle, /* module handle */
char *buffer, /* buffer pointer */
int buffer_size, /* buffer size */
struct sockaddr *from_addr,
int *from_addr_size,
double *elapsed /* elapsed microseconds since last icmp_send */
));
/* close the ICMP module. Returns >= 0 if successful, -1 otherwise */
extern int PROTO(
icmp_close,
(
icmp_handle handle
));
#endif /* End of File */
|