summaryrefslogtreecommitdiff
path: root/protm.h
blob: 4939df250f4c3c8f896e289555486412615f3f46 (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
34
35
36
37
38
39
40
41
42
#pragma once

#include <stdlib.h>
#include <stdint.h>


#define PROTM_MAX_SIZE 65536

#define PROTM_TYPE_ESTAB 1
#define PROTM_TYPE_TERM 2
#define PROTM_TYPE_DATA 3
#define PROTM_TYPE_RR 4
#define PROTM_TYPE_RR_POLL 5

struct __attribute__((packed)) protm {
	uint8_t type;
	union {
		struct {
			uint8_t ack;
		} estab;
		struct {
			uint8_t ack;
		} term;
		struct {
			uint8_t seqnum, rr;
			uint32_t size;
			// An IPv4 packet is at most 65536 bytes, so the data portion
			// left after allowing for the IPv4 and ICMP headers as well
			// as those for this protocol, is surely at most 65536 bytes.
			uint8_t data[65536];
		} data;
		struct {
			uint8_t rr, nrej;
			uint8_t rej[256];
		} rr;
		struct {
			// empty
		} rr_poll;
	};
};

size_t protm_size(const struct protm *pm);