blob: fbf4158340e9d8d541f4ae425caec310b65ebe2c (
plain)
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
|
#pragma once
#include "icmp.h"
#ifndef ICMP_ECHO
#define ICMP_ECHO 8
#endif
#ifndef ICMP_ECHOREPLY
#define ICMP_ECHOREPLY 0
#endif
struct icmp_server_incoming {
const uint8_t *data; // points to internal buffer
size_t length; // length of 'data'
int type; // ICMP_ECHO or ICMP_ECHOREPLY
int id, seqnum;
uint32_t source_addr;
};
// Returns -1 on error with errno.
int icmp_server_open_socket(void);
// Returns {.data=NULL} on error with errno.
struct icmp_server_incoming icmp_server_receive(int sock);
// Returns -1 on error with errno.
int icmp_server_send_reply(
int sock, uint32_t addr,
int id, int seqnum,
const void *data, size_t length);
|