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
77
78
79
80
81
82
83
84
85
86
87
88
89
| #ifndef _EV_PROTO_H_
| #define _EV_PROTO_H_
|
| #include <stddef.h>
| #include <stdint.h>
| #include <limits.h>
|
| #pragma pack(1)
|
| struct EVPProto
| {
| enum EVPP
| {
| EVPP__FIRST,
| EVPP_RAW_BIN = 1,
| EVPP_RAW_TEXT,
| EVPP_PROTOBUF,
| EVPP_HTTP,
| EVPP__LAST
| };
| };
|
| struct EVPCommand
| {
| enum EVPC
| {
| EVPC__FIRST,
| EVPC_STATUS = 1,
| EVPC_USER_DEFINE = 128,
| EVPC__LAST = USHRT_MAX
| };
| };
|
| struct EVPStatus
| {
| enum EVPS
| {
| EVPS__FIRST,
| EVPS_OK = 1,
| EVPS_ERROR = 128,
| EVPS_INTERNAL_ERROR,
| EVPS_PROTO_ERROR,
| EVPS_COMMAND_ERROR,
| EVPS_PARAMETER_ERROR,
| EVPS__LAST
| };
| };
|
| struct EVPHeader
| {
| private:
| uint8_t _padding1;
|
| public:
| uint8_t proto; // EVPProto::EVPP
| int16_t cmd; // EVPCommand::EVPC
| uint32_t size; // sizeof(EVPHeader)+sizeof(subcmd)
|
| void hton();
| void ntoh();
|
| EVPHeader() : _padding1(0), proto(EVPProto::EVPP__FIRST), cmd(EVPCommand::EVPC__FIRST), size(8)
| {}
| };
|
| struct EVP_Status
| {
| int16_t status;
|
| void hton();
| void ntoh();
| };
|
| struct EVP_VariableBuffer
| {
| int16_t type;
| uint8_t buff[0];
|
| void hton();
| void ntoh();
| };
|
| //#todo
| template<typename TPacket>
| void endian_convert(TPacket& packet);
|
| #pragma pack()
|
| #endif
|
|