#pragma once #include #include #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);