summaryrefslogtreecommitdiff
path: root/protm.h
diff options
context:
space:
mode:
Diffstat (limited to 'protm.h')
-rw-r--r--protm.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/protm.h b/protm.h
new file mode 100644
index 0000000..4939df2
--- /dev/null
+++ b/protm.h
@@ -0,0 +1,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);