-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathprotocol.h
76 lines (56 loc) · 2.16 KB
/
protocol.h
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
73
74
75
76
#ifdef __GCC_IEC_559
#pragma message("GCC ICE 559 defined...")
#else
#error *** do not use this platform
#endif
#include <stdint.h>
/*
Used in both directions; if
server->client,type should be set to 1,
client->server type = 2.
*/
struct __attribute__((__packed__)) calcProtocol{
uint16_t type; // What message is this, 1 = server to client, 2 client to server, 3... reserved , conversion needed
uint16_t major_version; // 1, conversion needed
uint16_t minor_version; // 0, conversion needed
uint32_t id; // Server side identification with operation. Client must return the same ID as it got from Server., conversion needed
uint32_t arith; // What operation to perform, see mapping below.
int32_t inValue1; // integer value 1, conversion needed
int32_t inValue2; // integer value 2, conversion needed
int32_t inResult; // integer result, conversion needed
double flValue1; // float value 1,NO NEED TO do host to Network or Network to Host conversion here, we are using equivalent platforms
double flValue2; // float value 2,NO NEED TO do host to Network or Network to Host conversion here, we are using equivalent platforms
double flResult; // float result,NO NEED TO do host to Network or Network to Host conversion here, we are using equivalent platforms
};
struct __attribute__((__packed__)) calcMessage {
uint16_t type; // See below, conversion needed
uint32_t message; // See below, conversion needed
// Protocol, UDP = 17, TCP = 6, other values are reserved.
uint16_t protocol; // conversion needed
uint16_t major_version; // 1, conversion needed
uint16_t minor_version; // 0 , conversion needed
};
/* arith mapping in calcProtocol
1 - add
2 - sub
3 - mul
4 - div
5 - fadd
6 - fsub
7 - fmul
8 - fdiv
other numbers are reserved
*/
/*
calcMessage.type
1 - server-to-client, text protocol
2 - server-to-client, binary protocol
3 - server-to-client, N/A
21 - client-to-server, text protocol
22 - client-to-server, binary protocol
23 - client-to-serve, N/A
calcMessage.message
0 = Not applicable/availible (N/A or NA)
1 = OK // Accept
2 = NOT OK // Reject
*/