Implemented file upload to agents
[public/netxms.git] / include / nms_cscp.h
1 /*
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** $module: nms_cscp.h
20 **
21 **/
22
23 #ifndef _nms_cscp_h_
24 #define _nms_cscp_h_
25
26
27 //
28 // Constants
29 //
30
31 #define SERVER_LISTEN_PORT 4701
32 #define MAX_DCI_STRING_VALUE 256
33 #define CSCP_HEADER_SIZE 16
34
35
36 //
37 // Data field structure
38 //
39
40 #pragma pack(1)
41
42 typedef struct
43 {
44 DWORD dwVarId; // Variable identifier
45 BYTE bType; // Data type
46 BYTE bReserved; // Padding
47 union
48 {
49 struct
50 {
51 WORD wReserved1;
52 DWORD dwLen;
53 WORD szValue[1];
54 } string;
55 struct
56 {
57 WORD wReserved2;
58 DWORD dwInteger;
59 } integer;
60 struct
61 {
62 WORD wReserverd3;
63 QWORD qwInt64;
64 } int64;
65 struct
66 {
67 WORD wReserverd4;
68 double dFloat;
69 } fp;
70 WORD wInt16;
71 } data;
72 } CSCP_DF;
73
74
75 //
76 // Message structure
77 //
78
79 typedef struct
80 {
81 WORD wCode; // Message (command) code
82 WORD wFlags; // Message flags
83 DWORD dwSize; // Message size (including header) in bytes
84 DWORD dwId; // Unique message identifier
85 DWORD dwNumVars; // Number of variables in message
86 CSCP_DF df[1]; // Data fields
87 } CSCP_MESSAGE;
88
89
90 //
91 // DCI data header structure
92 //
93
94 typedef struct
95 {
96 DWORD dwItemId;
97 DWORD dwNumRows;
98 DWORD dwDataType;
99 } DCI_DATA_HEADER;
100
101
102 //
103 // DCI data row structure
104 //
105
106 typedef struct
107 {
108 DWORD dwTimeStamp;
109 union
110 {
111 DWORD dwInteger;
112 QWORD qwInt64;
113 double dFloat;
114 TCHAR szString[MAX_DCI_STRING_VALUE];
115 } value;
116 } DCI_DATA_ROW;
117
118
119 //
120 // DCI threshold structure
121 //
122
123 typedef struct
124 {
125 DWORD dwId;
126 DWORD dwEvent;
127 DWORD dwArg1;
128 DWORD dwArg2;
129 union
130 {
131 DWORD dwInt32;
132 INT64 qwInt64;
133 double dFloat;
134 TCHAR szString[MAX_DCI_STRING_VALUE];
135 } value;
136 WORD wFunction;
137 WORD wOperation;
138 } DCI_THRESHOLD;
139
140 #pragma pack()
141
142
143 //
144 // Data types
145 //
146
147 #define CSCP_DT_INTEGER 0
148 #define CSCP_DT_STRING 1
149 #define CSCP_DT_INT64 2
150 #define CSCP_DT_INT16 3
151 #define CSCP_DT_BINARY 4
152 #define CSCP_DT_FLOAT 5
153
154
155 //
156 // Message flags
157 //
158
159 #define MF_BINARY 0x0001
160 #define MF_EOF 0x0002
161
162
163 //
164 // Message (command) codes
165 //
166
167 #define CMD_LOGIN 0x0001
168 #define CMD_LOGIN_RESP 0x0002
169 #define CMD_KEEPALIVE 0x0003
170 #define CMD_EVENT 0x0004
171 #define CMD_GET_OBJECTS 0x0005
172 #define CMD_OBJECT 0x0006
173 #define CMD_DELETE_OBJECT 0x0007
174 #define CMD_MODIFY_OBJECT 0x0008
175 #define CMD_OBJECT_LIST_END 0x0009
176 #define CMD_OBJECT_UPDATE 0x000A
177 #define CMD_GET_EVENTS 0x000B
178 #define CMD_EVENT_LIST_END 0x000C
179 #define CMD_GET_CONFIG_VARLIST 0x000D
180 #define CMD_SET_CONFIG_VARIABLE 0x000E
181 #define CMD_CONFIG_VARIABLE 0x000F
182 #define CMD_CONFIG_VARLIST_END 0x0010
183 #define CMD_DELETE_CONFIG_VARIABLE 0x0011
184 #define CMD_NOTIFY 0x0012
185 #define CMD_TRAP 0x0013
186 #define CMD_OPEN_EPP 0x0014
187 #define CMD_CLOSE_EPP 0x0015
188 #define CMD_SAVE_EPP 0x0016
189 #define CMD_EPP_RECORD 0x0017
190 #define CMD_LOCK_EVENT_DB 0x0018
191 #define CMD_UNLOCK_EVENT_DB 0x0019
192 #define CMD_SET_EVENT_INFO 0x001A
193 #define CMD_EVENT_DB_RECORD 0x001B
194 #define CMD_LOAD_EVENT_DB 0x001C
195 #define CMD_REQUEST_COMPLETED 0x001D
196 #define CMD_LOAD_USER_DB 0x001E
197 #define CMD_USER_DATA 0x001F
198 #define CMD_GROUP_DATA 0x0020
199 #define CMD_USER_DB_EOF 0x0021
200 #define CMD_UPDATE_USER 0x0022
201 #define CMD_DELETE_USER 0x0023
202 #define CMD_CREATE_USER 0x0024
203 #define CMD_LOCK_USER_DB 0x0025
204 #define CMD_UNLOCK_USER_DB 0x0026
205 #define CMD_USER_DB_UPDATE 0x0027
206 #define CMD_SET_PASSWORD 0x0028
207 #define CMD_GET_NODE_DCI_LIST 0x0029
208 #define CMD_NODE_DCI 0x002A
209 #define CMD_NODE_DCI_LIST_END 0x002B
210 #define CMD_DELETE_NODE_DCI 0x002C
211 #define CMD_MODIFY_NODE_DCI 0x002D
212 #define CMD_UNLOCK_NODE_DCI_LIST 0x002E
213 #define CMD_SET_OBJECT_MGMT_STATUS 0x002F
214 #define CMD_CREATE_NEW_DCI 0x0030
215 #define CMD_GET_DCI_DATA 0x0031
216 #define CMD_DCI_DATA 0x0032
217 #define CMD_GET_MIB_LIST 0x0033
218 #define CMD_GET_MIB 0x0034
219 #define CMD_MIB_LIST 0x0035
220 #define CMD_MIB 0x0036
221 #define CMD_CREATE_OBJECT 0x0037
222 #define CMD_GET_EVENT_NAMES 0x0038
223 #define CMD_EVENT_NAME_LIST 0x0039
224 #define CMD_BIND_OBJECT 0x003A
225 #define CMD_UNBIND_OBJECT 0x003B
226 #define CMD_GET_IMAGE_LIST 0x003C
227 #define CMD_LOAD_IMAGE_FILE 0x003D
228 #define CMD_IMAGE_LIST 0x003E
229 #define CMD_IMAGE_FILE 0x003F
230 #define CMD_AUTHENTICATE 0x0040
231 #define CMD_GET_PARAMETER 0x0041
232 #define CMD_GET_LIST 0x0042
233 #define CMD_ACTION 0x0043
234 #define CMD_GET_DEFAULT_IMAGE_LIST 0x0044
235 #define CMD_DEFAULT_IMAGE_LIST 0x0045
236 #define CMD_GET_ALL_ALARMS 0x0046
237 #define CMD_GET_ALARM 0x0047
238 #define CMD_ACK_ALARM 0x0048
239 #define CMD_ALARM_UPDATE 0x0049
240 #define CMD_ALARM_DATA 0x004A
241 #define CMD_DELETE_ALARM 0x004B
242 #define CMD_LOCK_ACTION_DB 0x004C
243 #define CMD_UNLOCK_ACTION_DB 0x004D
244 #define CMD_LOAD_ACTIONS 0x004E
245 #define CMD_ACTION_DB_UPDATE 0x004F
246 #define CMD_MODIFY_ACTION 0x0050
247 #define CMD_CREATE_ACTION 0x0051
248 #define CMD_DELETE_ACTION 0x0052
249 #define CMD_ACTION_DATA 0x0053
250 #define CMD_GET_CONTAINER_CAT_LIST 0x0054
251 #define CMD_CONTAINER_CAT_DATA 0x0055
252 #define CMD_DELETE_CONTAINER_CAT 0x0056
253 #define CMD_CREATE_CONTAINER_CAT 0x0057
254 #define CMD_MODIFY_CONTAINER_CAT 0x0058
255 #define CMD_POLL_NODE 0x0059
256 #define CMD_POLLING_INFO 0x005A
257 #define CMD_COPY_DCI 0x005B
258 #define CMD_WAKEUP_NODE 0x005C
259 #define CMD_DELETE_EVENT_TEMPLATE 0x005D
260 #define CMD_GENERATE_EVENT_CODE 0x005E
261 #define CMD_LOCK_TRAP_CFG 0x005F
262 #define CMD_UNLOCK_TRAP_CFG 0x0060
263 #define CMD_CREATE_TRAP 0x0061
264 #define CMD_MODIFY_TRAP 0x0062
265 #define CMD_DELETE_TRAP 0x0063
266 #define CMD_LOAD_TRAP_CFG 0x0064
267 #define CMD_TRAP_CFG_RECORD 0x0065
268 #define CMD_QUERY_PARAMETER 0x0066
269 #define CMD_GET_SERVER_INFO 0x0067
270 #define CMD_SET_DCI_STATUS 0x0068
271 #define CMD_FILE_DATA 0x0069
272 #define CMD_TRANSFER_FILE 0x006A
273
274
275 //
276 // Variable identifiers
277 //
278
279 #define VID_LOGIN_NAME ((DWORD)1)
280 #define VID_PASSWORD ((DWORD)2)
281 #define VID_OBJECT_ID ((DWORD)3)
282 #define VID_OBJECT_NAME ((DWORD)4)
283 #define VID_OBJECT_CLASS ((DWORD)5)
284 #define VID_SNMP_VERSION ((DWORD)6)
285 #define VID_PARENT_CNT ((DWORD)7)
286 #define VID_IP_ADDRESS ((DWORD)8)
287 #define VID_IP_NETMASK ((DWORD)9)
288 #define VID_OBJECT_STATUS ((DWORD)10)
289 #define VID_IF_INDEX ((DWORD)11)
290 #define VID_IF_TYPE ((DWORD)12)
291 #define VID_FLAGS ((DWORD)13)
292 #define VID_DISCOVERY_FLAGS ((DWORD)14)
293 #define VID_AGENT_PORT ((DWORD)15)
294 #define VID_AUTH_METHOD ((DWORD)16)
295 #define VID_SHARED_SECRET ((DWORD)17)
296 #define VID_COMMUNITY_STRING ((DWORD)18)
297 #define VID_SNMP_OID ((DWORD)19)
298 #define VID_NAME ((DWORD)20)
299 #define VID_VALUE ((DWORD)21)
300 #define VID_ERROR ((DWORD)22)
301 #define VID_NOTIFICATION_CODE ((DWORD)23)
302 #define VID_EVENT_CODE ((DWORD)24)
303 #define VID_SEVERITY ((DWORD)25)
304 #define VID_MESSAGE ((DWORD)26)
305 #define VID_DESCRIPTION ((DWORD)27)
306 #define VID_RCC ((DWORD)28) /* RCC == Request Completion Code */
307 #define VID_LOCKED_BY ((DWORD)29)
308 #define VID_IS_DELETED ((DWORD)30)
309 #define VID_CHILD_CNT ((DWORD)31)
310 #define VID_ACL_SIZE ((DWORD)32)
311 #define VID_INHERIT_RIGHTS ((DWORD)33)
312 #define VID_USER_NAME ((DWORD)34)
313 #define VID_USER_ID ((DWORD)35)
314 #define VID_USER_SYS_RIGHTS ((DWORD)36)
315 #define VID_USER_FLAGS ((DWORD)37)
316 #define VID_NUM_MEMBERS ((DWORD)38) /* Number of members in users group */
317 #define VID_IS_GROUP ((DWORD)39)
318 #define VID_USER_FULL_NAME ((DWORD)40)
319 #define VID_USER_DESCRIPTION ((DWORD)41)
320 #define VID_UPDATE_TYPE ((DWORD)42)
321 #define VID_DCI_ID ((DWORD)43)
322 #define VID_POLLING_INTERVAL ((DWORD)44)
323 #define VID_RETENTION_TIME ((DWORD)45)
324 #define VID_DCI_SOURCE_TYPE ((DWORD)46)
325 #define VID_DCI_DATA_TYPE ((DWORD)47)
326 #define VID_DCI_STATUS ((DWORD)48)
327 #define VID_MGMT_STATUS ((DWORD)49)
328 #define VID_MAX_ROWS ((DWORD)50)
329 #define VID_TIME_FROM ((DWORD)51)
330 #define VID_TIME_TO ((DWORD)52)
331 #define VID_DCI_DATA ((DWORD)53)
332 #define VID_NUM_THRESHOLDS ((DWORD)54)
333 #define VID_DCI_NUM_MAPS ((DWORD)55)
334 #define VID_DCI_MAP_IDS ((DWORD)56)
335 #define VID_DCI_MAP_INDEXES ((DWORD)57)
336 #define VID_NUM_MIBS ((DWORD)58)
337 #define VID_MIB_NAME ((DWORD)59)
338 #define VID_MIB_FILE_SIZE ((DWORD)60)
339 #define VID_MIB_FILE ((DWORD)61)
340 #define VID_COMMENT ((DWORD)62)
341 #define VID_ALARM_SEVERITY ((DWORD)63)
342 #define VID_ALARM_KEY ((DWORD)64)
343 #define VID_ALARM_ACK_KEY ((DWORD)65)
344 #define VID_ALARM_MESSAGE ((DWORD)66)
345 #define VID_RULE_ID ((DWORD)67)
346 #define VID_NUM_SOURCES ((DWORD)68)
347 #define VID_NUM_EVENTS ((DWORD)69)
348 #define VID_NUM_ACTIONS ((DWORD)70)
349 #define VID_RULE_SOURCES ((DWORD)71)
350 #define VID_RULE_EVENTS ((DWORD)72)
351 #define VID_RULE_ACTIONS ((DWORD)73)
352 #define VID_NUM_RULES ((DWORD)74)
353 #define VID_CATEGORY ((DWORD)75)
354 #define VID_UPDATED_CHILD_LIST ((DWORD)76)
355 #define VID_EVENT_NAME_TABLE ((DWORD)77)
356 #define VID_PARENT_ID ((DWORD)78)
357 #define VID_CHILD_ID ((DWORD)79)
358 #define VID_IMAGE_ID ((DWORD)80)
359 #define VID_NUM_IMAGES ((DWORD)81)
360 #define VID_IMAGE_LIST ((DWORD)82)
361 #define VID_IMAGE_FILE_SIZE ((DWORD)83)
362 #define VID_IMAGE_FILE ((DWORD)84)
363 #define VID_PARAMETER ((DWORD)85)
364 #define VID_NUM_STRINGS ((DWORD)86)
365 #define VID_ACTION_NAME ((DWORD)87)
366 #define VID_NUM_ARGS ((DWORD)88)
367 #define VID_IMAGE_ID_LIST ((DWORD)89)
368 #define VID_CLASS_ID_LIST ((DWORD)90)
369 #define VID_IMAGE_FORMAT ((DWORD)91)
370 #define VID_NOTIFICATION_DATA ((DWORD)92)
371 #define VID_ALARM_ID ((DWORD)93)
372 #define VID_TIMESTAMP ((DWORD)94)
373 #define VID_ACK_BY_USER ((DWORD)95)
374 #define VID_IS_ACK ((DWORD)96)
375 #define VID_ACTION_ID ((DWORD)97)
376 #define VID_IS_DISABLED ((DWORD)98)
377 #define VID_ACTION_TYPE ((DWORD)99)
378 #define VID_ACTION_DATA ((DWORD)100)
379 #define VID_EMAIL_SUBJECT ((DWORD)101)
380 #define VID_RCPT_ADDR ((DWORD)102)
381 #define VID_CATEGORY_NAME ((DWORD)103)
382 #define VID_CATEGORY_ID ((DWORD)104)
383 #define VID_DCI_DELTA_CALCULATION ((DWORD)105)
384 #define VID_DCI_FORMULA ((DWORD)106)
385 #define VID_POLL_TYPE ((DWORD)107)
386 #define VID_POLLER_MESSAGE ((DWORD)108)
387 #define VID_SOURCE_OBJECT_ID ((DWORD)109)
388 #define VID_DESTINATION_OBJECT_ID ((DWORD)110)
389 #define VID_NUM_ITEMS ((DWORD)111)
390 #define VID_ITEM_LIST ((DWORD)112)
391 #define VID_MAC_ADDR ((DWORD)113)
392 #define VID_TEMPLATE_VERSION ((DWORD)114)
393 #define VID_NODE_TYPE ((DWORD)115)
394 #define VID_INSTANCE ((DWORD)116)
395 #define VID_TRAP_ID ((DWORD)117)
396 #define VID_TRAP_OID ((DWORD)118)
397 #define VID_TRAP_OID_LEN ((DWORD)119)
398 #define VID_TRAP_NUM_MAPS ((DWORD)120)
399 #define VID_SERVER_VERSION ((DWORD)121)
400 #define VID_SUPPORTED_ENCRYPTION ((DWORD)122)
401 #define VID_EVENT_ID ((DWORD)123)
402 #define VID_AGENT_VERSION ((DWORD)124)
403 #define VID_FILE_NAME ((DWORD)125)
404
405 // Variable ranges for object's ACL
406 #define VID_ACL_USER_BASE ((DWORD)0x00001000)
407 #define VID_ACL_USER_LAST ((DWORD)0x00001FFF)
408 #define VID_ACL_RIGHTS_BASE ((DWORD)0x00002000)
409 #define VID_ACL_RIGHTS_LAST ((DWORD)0x00002FFF)
410
411 // Variable range for user group members
412 #define VID_GROUP_MEMBER_BASE ((DWORD)0x00004000)
413 #define VID_GROUP_MEMBER_LAST ((DWORD)0x00004FFF)
414
415 // Variable range for data collection thresholds
416 #define VID_DCI_THRESHOLD_BASE ((DWORD)0x00005000)
417 #define VID_DCI_THRESHOLD_LAST ((DWORD)0x00005FFF)
418
419 // Variable range for MIB list
420 #define VID_MIB_NAME_BASE ((DWORD)0x00006000)
421 #define VID_MIB_NAME_LAST ((DWORD)0x00006FFF)
422 #define VID_MIB_HASH_BASE ((DWORD)0x00007000)
423 #define VID_MIB_HASH_LAST ((DWORD)0x00007FFF)
424
425 // Variable range for event argument list
426 #define VID_EVENT_ARG_BASE ((DWORD)0x00008000)
427 #define VID_EVENT_ARG_LAST ((DWORD)0x00008FFF)
428
429 // Variable range for trap parameter list
430 #define VID_TRAP_PLEN_BASE ((DWORD)0x00009000)
431 #define VID_TRAP_PLEN_LAST ((DWORD)0x000093FF)
432 #define VID_TRAP_PNAME_BASE ((DWORD)0x00009400)
433 #define VID_TRAP_PNAME_LAST ((DWORD)0x000097FF)
434 #define VID_TRAP_PDESCR_BASE ((DWORD)0x00009800)
435 #define VID_TRAP_PDESCR_LAST ((DWORD)0x00009BFF)
436
437 // Object information can contain variable number of parent and child objects' ids.
438 // Because each variable in message have to have unique identifier,
439 // we reserver a two range ids for this variables.
440 #define VID_PARENT_ID_BASE ((DWORD)0x00003000)
441 #define VID_PARENT_ID_LAST ((DWORD)0x00003FFF)
442
443 // Reservation of 0x7FFFFFFF ids for child object's list
444 #define VID_CHILD_ID_BASE ((DWORD)0x80000000)
445 #define VID_CHILD_ID_LAST ((DWORD)0xFFFFFFFE)
446
447 // Base value for agent's enum values
448 #define VID_ENUM_VALUE_BASE ((DWORD)0x10000000)
449
450 // Base value for agent's action arguments
451 #define VID_ACTION_ARG_BASE ((DWORD)0x10000000)
452
453
454 //
455 // Inline functions
456 //
457
458 #ifdef __cplusplus
459
460 inline BOOL IsBinaryMsg(CSCP_MESSAGE *pMsg)
461 {
462 return ntohs(pMsg->wFlags) & MF_BINARY;
463 }
464
465 #endif
466
467
468 #endif /* _nms_cscp_h_ */