#ifndef RCTP_H #define RCTP_H typedef unsigned char rctp_byte; typedef struct request rctp_req_t; typedef struct response rctp_res_t; typedef enum { RCTP_OK = 0, RCTP_ERROR, // unknown error RCTP_UNKNOWN_METHOD, RCTP_UNKNOWN_STATUS, RCTP_INVALID_STRING, } RCTP_STAT; #define RCTP_METHODS(X) \ X(PING) \ #define RCTP_STATUSES(X) \ X(PONG) \ #define TO_ENUM(s) s, #define TO_STR(s) #s, enum rctp_method { RCTP_METHODS(TO_ENUM) } __attribute__((packed)); enum rctp_status { RCTP_STATUSES(TO_ENUM) } __attribute__((packed)); struct request { enum rctp_req method; union { /* ... */ }; } __attribute__((packed)); struct response { enum rctp_res status; union { /* ... */ }; } __attribute__((packed)); #endif