blob: eed1714e39a11b6f6d586bf46cc9b9de494fd64e (
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
33
|
#pragma once
#include <stdint.h>
#define IP_HEADER_SIZE 40
#define MIN_MTU 576
#define MAX_IP_PACKET_SIZE 65535
#define MAX_DATAGRAM_SIZE (MAX_IP_PACKET_SIZE - IP_HEADER_SIZE)
#define ICMP_PAYLOAD_OFFSET 8
struct __attribute__((packed)) icmp_echo {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint16_t id;
uint16_t seqnum;
uint8_t payload[MAX_DATAGRAM_SIZE - ICMP_PAYLOAD_OFFSET];
};
#define ICMP_MAX_PAYLOAD_LENGTH (MAX_DATAGRAM_SIZE - ICMP_PAYLOAD_OFFSET)
#define ICMP_SAFE_PAYLOAD_LENGTH (MIN_MTU - IP_HEADER_SIZE - ICMP_PAYLOAD_OFFSET)
struct icmp_incoming {
const uint8_t *data; // points to internal buffer
size_t length; // length of 'data'
int id, seqnum;
uint32_t source_addr;
};
|