diff options
| author | 2022-09-26 13:17:04 -0400 | |
|---|---|---|
| committer | 2022-09-26 13:17:04 -0400 | |
| commit | a31884d44375d99c1ac47e27150b3b05d42871ef (patch) | |
| tree | 9a26a9aebc1ccf8a33085f34d5c3b00c7d4e4347 /common/msg.h | |
start unfinished code
Diffstat (limited to 'common/msg.h')
| -rw-r--r-- | common/msg.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/common/msg.h b/common/msg.h new file mode 100644 index 0000000..c68f699 --- /dev/null +++ b/common/msg.h @@ -0,0 +1,72 @@ +#include "sds.h" + +#ifdef WINDOWS +# include <windows.h> +#else +# include <sys/socket.h> +# include <unistd.h> +typedef int SOCKET; +#endif + +union msg { + struct { + uint16_t bus; + uint8_t node; + uint64_t addr; + uint8_t tcode; + uint8_t tlabel; + uint8_t extcode; + uint16_t len; + char *buf; + } send_async; + + struct { + uint8_t ch; + uint8_t tag; + uint8_t synch; + uint16_t len; + char *buf; + } iso; + + struct { + uint64_t start; + uint64_t length; + } allocate; +}; + +enum { + MSG_SEND_INVALID = -1, + MSG_NOOP = 0, + MSG_SEND_ASYNC = 1, + MSG_SEND_ISO = 2, + MSG_ALLOCATE = 3, + MSG_TYPES_LEN +}; + +enum parsestate { + PARSE_VERSION_MESSAGE, + PARSE_SEND_ASYNC, + PARSE_SEND_ISO, + PARSE_ALLOCATE +} + +typedef void (*msg_exec)(int, union msg *); + +struct msg_state { + char *buf; + enum msgtype type; + + int msgtype; + union msg msg; + + enum parsestate state; + + msg_exec on_read[MSG_TYPES_LEN]; +}; + +/* Message Header: + [2 : version][6 : message] + + * noop [0] + * (none) + */ |
