#include "sds.h" #ifdef WINDOWS # include #else # include # include 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) */