diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-07-23 21:44:07 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-07-25 18:07:49 +0200 |
commit | 9f2fccfdc2eae83efbde1e3ae94a2cc220537983 (patch) | |
tree | 16a19a1877d7cfdd39767de0cfaf312adc398d1b /icmp_client.h | |
parent | b582cce69853d0a562dd0171914426887e854966 (diff) |
Better ICMP code encapsulation
Diffstat (limited to 'icmp_client.h')
-rw-r--r-- | icmp_client.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/icmp_client.h b/icmp_client.h new file mode 100644 index 0000000..78cfe7a --- /dev/null +++ b/icmp_client.h @@ -0,0 +1,23 @@ +#pragma once + +#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); + +// 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, + const void *data, size_t length); |