From 4b0fdca8673c76cb2305db301a3b36e9e3822e02 Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 25 Dec 2023 01:45:05 +0200 Subject: init --- include/rctp.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 include/rctp.h (limited to 'include/rctp.h') diff --git a/include/rctp.h b/include/rctp.h new file mode 100644 index 0000000..71aa812 --- /dev/null +++ b/include/rctp.h @@ -0,0 +1,50 @@ +#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 -- cgit v1.2.3