]> git.stg.codes - stg.git/blob - include/stg/ia_packets.h
Better handling of errors from server. Refactoring.
[stg.git] / include / stg / ia_packets.h
1 #ifndef PACKETH
2 #define PACKETH
3
4 #include "os_int.h"
5
6 #define CONN_SYN_N          0
7 #define CONN_SYN_ACK_N      1
8 #define CONN_ACK_N          2
9 #define ALIVE_SYN_N         3
10 #define ALIVE_ACK_N         4
11 #define DISCONN_SYN_N       5
12 #define DISCONN_SYN_ACK_N   6
13 #define DISCONN_ACK_N       7
14 #define FIN_N               8
15 #define ERROR_N             9
16 #define INFO_N              10
17 #define INFO_7_N            11
18 #define INFO_8_N            12
19 #define UPDATE_N            13
20
21 #define DIR_NUM             (10)
22
23 #define IA_FREEMB_LEN       (16)
24 #define IA_LOGIN_LEN        (32)
25 #define IA_PASSWD_LEN       (32)
26 #define IA_MAX_TYPE_LEN     (16)
27 #define IA_MAX_MSG_LEN      (235)
28 #define IA_MAX_MSG_LEN_8    (1030)
29 #define IA_DIR_NAME_LEN     (16)
30 #define IA_MAGIC_LEN        (6)
31 #define IA_PROTO_VER_LEN    (2)
32
33 #define ST_NOT_INETABLE     (0)
34 #define ST_INETABLE         (1)
35
36 #define IA_ID "00100"
37
38 typedef int8_t string16[IA_DIR_NAME_LEN];
39 //-----------------------------------------------------------------------------
40 struct HDR_8
41 {
42 int8_t          magic[IA_MAGIC_LEN];
43 int8_t          protoVer[IA_PROTO_VER_LEN];
44 //uint32_t        ip;
45 //int8_t          padding[4];
46 };
47 //-----------------------------------------------------------------------------
48 struct CONN_SYN_6
49 {
50 int8_t          magic[IA_MAGIC_LEN];
51 int8_t          protoVer[IA_PROTO_VER_LEN];
52 int8_t          loginS[IA_LOGIN_LEN];
53 int32_t         len;    // Byte-order dependent
54 int8_t          type[IA_MAX_TYPE_LEN];
55 int8_t          login[IA_LOGIN_LEN];
56 int8_t          padding[2];
57 };
58 //-----------------------------------------------------------------------------
59 struct CONN_SYN_8
60 {
61 HDR_8           hdr;
62 int8_t          loginS[IA_LOGIN_LEN];
63 int32_t         len;    // Byte-order dependent
64 int8_t          type[IA_MAX_TYPE_LEN];
65 int8_t          login[IA_LOGIN_LEN];
66 uint32_t        dirs;   // Byte-order dependent
67 };
68 //-----------------------------------------------------------------------------
69 struct CONN_SYN_ACK_6
70 {
71 int32_t         len;    // Byte-order dependent
72 int8_t          type[IA_MAX_TYPE_LEN];
73 uint32_t        rnd;    // Byte-order dependent
74 int32_t         userTimeOut;    // Byte-order dependent
75 int32_t         aliveDelay;     // Byte-order dependent
76 string16        dirName[DIR_NUM];
77 };
78 //-----------------------------------------------------------------------------
79 struct CONN_SYN_ACK_8
80 {
81 HDR_8           hdr;
82 int32_t         len;    // Byte-order dependent
83 int8_t          type[IA_MAX_TYPE_LEN];
84 uint32_t        rnd;    // Byte-order dependent
85 int32_t         userTimeOut;    // Byte-order dependent
86 int32_t         aliveDelay;     // Byte-order dependent
87 string16        dirName[DIR_NUM];
88 };
89 //-----------------------------------------------------------------------------
90 struct CONN_ACK_6
91 {
92 int8_t          magic[IA_MAGIC_LEN];
93 int8_t          protoVer[IA_PROTO_VER_LEN];
94 int8_t          loginS[IA_LOGIN_LEN];
95 int32_t         len;    // Byte-order dependent
96 int8_t          type[IA_MAX_TYPE_LEN];
97 uint32_t        rnd;    // Byte-order dependent
98 };
99 //-----------------------------------------------------------------------------
100 struct CONN_ACK_8
101 {
102 HDR_8           hdr;
103 int8_t          loginS[IA_LOGIN_LEN];
104 int32_t         len;    // Byte-order dependent
105 int8_t          type[IA_MAX_TYPE_LEN];
106 uint32_t        rnd;    // Byte-order dependent
107 };
108 //-----------------------------------------------------------------------------
109 struct ALIVE_SYN_6
110 {
111 int32_t         len;    // Byte-order dependent
112 int8_t          type[IA_MAX_TYPE_LEN];
113 uint32_t        rnd;    // Byte-order dependent
114
115 int64_t         mu[DIR_NUM];    // Byte-order dependent
116 int64_t         md[DIR_NUM];    // Byte-order dependent
117
118 int64_t         su[DIR_NUM];    // Byte-order dependent
119 int64_t         sd[DIR_NUM];    // Byte-order dependent
120
121 int64_t         cash;           // Byte-order dependent
122
123 int8_t          freeMb[IA_FREEMB_LEN];
124 };
125 //-----------------------------------------------------------------------------
126 struct ALIVE_SYN_8
127 {
128 HDR_8           hdr;
129 int32_t         len;    // Byte-order dependent
130 int8_t          type[IA_MAX_TYPE_LEN];
131 uint32_t        rnd;    // Byte-order dependent
132
133 int64_t         mu[DIR_NUM];    // Byte-order dependent
134 int64_t         md[DIR_NUM];    // Byte-order dependent
135
136 int64_t         su[DIR_NUM];    // Byte-order dependent
137 int64_t         sd[DIR_NUM];    // Byte-order dependent
138
139 int64_t         cash; // Äåíüãè óìíîæåííûå íà 1000 - Byte-order dependent
140 int8_t          freeMb[IA_FREEMB_LEN];
141
142 uint32_t        status; // Byte-order dependent
143 int8_t          padding[4];
144 };
145 //-----------------------------------------------------------------------------
146 struct ALIVE_ACK_6
147 {
148 int8_t          magic[IA_MAGIC_LEN];
149 int8_t          protoVer[IA_PROTO_VER_LEN];
150 int8_t          loginS[IA_LOGIN_LEN];
151 int32_t         len;    // Byte-order dependent
152 int8_t          type[IA_MAX_TYPE_LEN];
153 uint32_t        rnd;    // Byte-order dependent
154 };
155 //-----------------------------------------------------------------------------
156 struct ALIVE_ACK_8
157 {
158 HDR_8           hdr;
159 int8_t          loginS[IA_LOGIN_LEN];
160 int32_t         len;    // Byte-order dependent
161 int8_t          type[IA_MAX_TYPE_LEN];
162 uint32_t        rnd;    // Byte-order dependent
163 };
164 //-----------------------------------------------------------------------------
165 struct DISCONN_SYN_6
166 {
167 int8_t          magic[IA_MAGIC_LEN];
168 int8_t          protoVer[IA_PROTO_VER_LEN];
169 int8_t          loginS[IA_LOGIN_LEN];
170 int32_t         len;    // Byte-order dependent
171 int8_t          type[IA_MAX_TYPE_LEN];
172 int8_t          login[IA_LOGIN_LEN];
173 int8_t          padding[2];
174 };
175 //-----------------------------------------------------------------------------
176 struct DISCONN_SYN_8
177 {
178 HDR_8           hdr;
179 int8_t          loginS[IA_LOGIN_LEN];
180 int32_t         len;    // Byte-order dependent
181 int8_t          type[IA_MAX_TYPE_LEN];
182 int8_t          login[IA_LOGIN_LEN];
183 int8_t          padding[4];
184 };
185 //-----------------------------------------------------------------------------
186 struct DISCONN_SYN_ACK_6
187 {
188 int32_t         len;    // Byte-order dependent
189 int8_t          type[IA_MAX_TYPE_LEN];
190 uint32_t        rnd;    // Byte-order dependent
191 };
192 //-----------------------------------------------------------------------------
193 struct DISCONN_SYN_ACK_8
194 {
195 HDR_8           hdr;
196 int32_t         len;    // Byte-order dependent
197 int8_t          type[IA_MAX_TYPE_LEN];
198 uint32_t        rnd;    // Byte-order dependent
199 };
200 //-----------------------------------------------------------------------------
201 struct DISCONN_ACK_6
202 {
203 int8_t          magic[IA_MAGIC_LEN];
204 int8_t          protoVer[IA_PROTO_VER_LEN];
205 int8_t          loginS[IA_LOGIN_LEN];
206 int32_t         len;    // Byte-order dependent
207 int8_t          type[IA_MAX_TYPE_LEN];
208 uint32_t        rnd;    // Byte-order dependent
209 };
210 //-----------------------------------------------------------------------------
211 struct DISCONN_ACK_8
212 {
213 HDR_8           hdr;
214 int8_t          loginS[IA_LOGIN_LEN];
215 int32_t         len;    // Byte-order dependent
216 int8_t          type[IA_MAX_TYPE_LEN];
217 uint32_t        rnd;    // Byte-order dependent
218 };
219 //-----------------------------------------------------------------------------
220 struct FIN_6
221 {
222 int32_t         len;    // Byte-order dependent
223 int8_t          type[IA_MAX_TYPE_LEN];
224 int8_t          ok[3];
225 int8_t          padding[1];
226 };
227 //-----------------------------------------------------------------------------
228 struct FIN_8
229 {
230 HDR_8           hdr;
231 int32_t         len;    // Byte-order dependent
232 int8_t          type[IA_MAX_TYPE_LEN];
233 int8_t          ok[3];
234 int8_t          padding[1];
235 };
236 //-----------------------------------------------------------------------------
237 struct ERR
238 {
239 int32_t         len;    // Byte-order dependent
240 int8_t          type[IA_MAX_TYPE_LEN];
241 int8_t          text[236];
242 };
243 //-----------------------------------------------------------------------------
244 struct ERR_8
245 {
246 HDR_8           hdr;
247 int32_t         len;    // Byte-order dependent
248 int8_t          type[IA_MAX_TYPE_LEN];
249 int8_t          text[236];
250 };
251 //-----------------------------------------------------------------------------
252 struct INFO_6
253 {
254 int32_t         len;    // Byte-order dependent
255 int8_t          type[IA_MAX_TYPE_LEN];
256 int8_t          infoType;
257 int8_t          text[IA_MAX_MSG_LEN];
258 };
259 //-----------------------------------------------------------------------------
260 struct INFO_7
261 {
262 int32_t         len;    // Byte-order dependent
263 int8_t          type[IA_MAX_TYPE_LEN];
264 int8_t          infoType;
265 uint32_t        sendTime;   // Byte-order dependent
266 int8_t          showTime;
267 int8_t          text[IA_MAX_MSG_LEN];
268 int8_t          padding[5];
269 };
270 //-----------------------------------------------------------------------------
271 struct INFO_8
272 {
273 HDR_8           hdr;
274 int32_t         len;    // Byte-order dependent
275 int8_t          type[IA_MAX_TYPE_LEN];
276 int8_t          infoType;
277 uint32_t        sendTime;   // Byte-order dependent
278 int8_t          showTime;
279 int8_t          text[IA_MAX_MSG_LEN_8];
280 };
281 //-----------------------------------------------------------------------------
282 struct LOADSTAT
283 {
284 int64_t         mu[DIR_NUM];    // Byte-order dependent
285 int64_t         md[DIR_NUM];    // Byte-order dependent
286
287 int64_t         su[DIR_NUM];    // Byte-order dependent
288 int64_t         sd[DIR_NUM];    // Byte-order dependent
289
290 int64_t         cash;   // Äåíüãè óìíîæåííûå íà 1000 - Byte-order dependent
291 int8_t          freeMb[IA_FREEMB_LEN];
292 int32_t         status; // Byte-order dependent
293 };
294 //-----------------------------------------------------------------------------
295 #define CONN_SYN_7          CONN_SYN_6
296 #define CONN_SYN_ACK_7      CONN_SYN_ACK_6
297 #define CONN_ACK_7          CONN_ACK_6
298 #define ALIVE_SYN_7         ALIVE_SYN_6
299 #define ALIVE_ACK_7         ALIVE_ACK_6
300 #define DISCONN_SYN_7       DISCONN_SYN_6
301 #define DISCONN_SYN_ACK_7   DISCONN_SYN_ACK_6
302 #define DISCONN_ACK_7       DISCONN_ACK_6
303 #define FIN_7               FIN_6
304
305 #endif