blob: c68f69913e8f3e5f773e0f06da750bf709784e06 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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)
*/
|