diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-08-13 18:01:05 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-08-13 18:01:05 +0200 |
commit | cf6fbbec9e2a04217a135924fd2bf209be488223 (patch) | |
tree | 567e44cb20b3e0e305bf66b49299258ad0ec0bc5 /protm.h | |
parent | f5054cc7ee058cff2226994036949e77725ae454 (diff) |
Protocol implementation WIP
Diffstat (limited to 'protm.h')
-rw-r--r-- | protm.h | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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); |