summaryrefslogtreecommitdiff
path: root/icmp_client.h
diff options
context:
space:
mode:
Diffstat (limited to 'icmp_client.h')
-rw-r--r--icmp_client.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/icmp_client.h b/icmp_client.h
index 78cfe7a..3474f5d 100644
--- a/icmp_client.h
+++ b/icmp_client.h
@@ -3,21 +3,24 @@
#include "icmp.h"
-struct icmp_client_incoming {
- const uint8_t *data; // points to internal buffer
- size_t length; // length of 'data'
-
- int id, seqnum;
-};
-
// Returns -1 on error with errno.
int icmp_client_open_socket(void);
+// Returns {.data=NULL} on error with errno.
+// Receives only ECHOREPLY.
+struct icmp_incoming icmp_client_receive(int sock);
+
+// Only actual IPv4 addresses allowed. Sends data in 'data' with length 'length'.
+int icmp_client_send(
+ int sock, uint32_t addr,
+ int seqnum,
+ const void *data, size_t length);
+
// Only actual IPv4 addresses allowed. Sends data in 'data' with length 'length', and
// returns pointer to internal buffer with reply data. Buffer is invalidated on next
// call to the function.
// Returns {.data=NULL} on error with errno.
-struct icmp_client_incoming icmp_client_communicate(
- int sock, const char *ip_address,
- int id, int seqnum,
+struct icmp_incoming icmp_client_communicate(
+ int sock, uint32_t addr,
+ int seqnum,
const void *data, size_t length);