- All component locks moved to memory
[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 TCHAR 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
161
162 //
163 // Message (command) codes
164 //
165
166 #define CMD_LOGIN 0x0001
167 #define CMD_LOGIN_RESP 0x0002
168 #define CMD_KEEPALIVE 0x0003
169 #define CMD_EVENT 0x0004
170 #define CMD_GET_OBJECTS 0x0005
171 #define CMD_OBJECT 0x0006
172 #define CMD_DELETE_OBJECT 0x0007
173 #define CMD_MODIFY_OBJECT 0x0008
174 #define CMD_OBJECT_LIST_END 0x0009
175 #define CMD_OBJECT_UPDATE 0x000A
176 #define CMD_GET_EVENTS 0x000B
177 #define CMD_EVENT_LIST_END 0x000C
178 #define CMD_GET_CONFIG_VARLIST 0x000D
179 #define CMD_SET_CONFIG_VARIABLE 0x000E
180 #define CMD_CONFIG_VARIABLE 0x000F
181 #define CMD_CONFIG_VARLIST_END 0x0010
182 #define CMD_DELETE_CONFIG_VARIABLE 0x0011
183 #define CMD_NOTIFY 0x0012
184 #define CMD_TRAP 0x0013
185 #define CMD_OPEN_EPP 0x0014
186 #define CMD_CLOSE_EPP 0x0015
187 #define CMD_SAVE_EPP 0x0016
188 #define CMD_EPP_RECORD 0x0017
189 #define CMD_LOCK_EVENT_DB 0x0018
190 #define CMD_UNLOCK_EVENT_DB 0x0019
191 #define CMD_SET_EVENT_INFO 0x001A
192 #define CMD_EVENT_DB_RECORD 0x001B
193 #define CMD_LOAD_EVENT_DB 0x001C
194 #define CMD_REQUEST_COMPLETED 0x001D
195 #define CMD_LOAD_USER_DB 0x001E
196 #define CMD_USER_DATA 0x001F
197 #define CMD_GROUP_DATA 0x0020
198 #define CMD_USER_DB_EOF 0x0021
199 #define CMD_UPDATE_USER 0x0022
200 #define CMD_DELETE_USER 0x0023
201 #define CMD_CREATE_USER 0x0024
202 #define CMD_LOCK_USER_DB 0x0025
203 #define CMD_UNLOCK_USER_DB 0x0026
204 #define CMD_USER_DB_UPDATE 0x0027
205 #define CMD_SET_PASSWORD 0x0028
206 #define CMD_GET_NODE_DCI_LIST 0x0029
207 #define CMD_NODE_DCI 0x002A
208 #define CMD_NODE_DCI_LIST_END 0x002B
209 #define CMD_DELETE_NODE_DCI 0x002C
210 #define CMD_MODIFY_NODE_DCI 0x002D
211 #define CMD_UNLOCK_NODE_DCI_LIST 0x002E
212 #define CMD_SET_OBJECT_MGMT_STATUS 0x002F
213 #define CMD_CREATE_NEW_DCI 0x0030
214 #define CMD_GET_DCI_DATA 0x0031
215 #define CMD_DCI_DATA 0x0032
216 #define CMD_GET_MIB_LIST 0x0033
217 #define CMD_GET_MIB 0x0034
218 #define CMD_MIB_LIST 0x0035
219 #define CMD_MIB 0x0036
220 #define CMD_CREATE_OBJECT 0x0037
221 #define CMD_GET_EVENT_NAMES 0x0038
222 #define CMD_EVENT_NAME_LIST 0x0039
223 #define CMD_BIND_OBJECT 0x003A
224 #define CMD_UNBIND_OBJECT 0x003B
225 #define CMD_GET_IMAGE_LIST 0x003C
226 #define CMD_LOAD_IMAGE_FILE 0x003D
227 #define CMD_IMAGE_LIST 0x003E
228 #define CMD_IMAGE_FILE 0x003F
229 #define CMD_AUTHENTICATE 0x0040
230 #define CMD_GET_PARAMETER 0x0041
231 #define CMD_GET_LIST 0x0042
232 #define CMD_ACTION 0x0043
233 #define CMD_GET_DEFAULT_IMAGE_LIST 0x0044
234 #define CMD_DEFAULT_IMAGE_LIST 0x0045
235 #define CMD_GET_ALL_ALARMS 0x0046
236 #define CMD_GET_ALARM 0x0047
237 #define CMD_ACK_ALARM 0x0048
238 #define CMD_ALARM_UPDATE 0x0049
239 #define CMD_ALARM_DATA 0x004A
240 #define CMD_DELETE_ALARM 0x004B
241 #define CMD_LOCK_ACTION_DB 0x004C
242 #define CMD_UNLOCK_ACTION_DB 0x004D
243 #define CMD_LOAD_ACTIONS 0x004E
244 #define CMD_ACTION_DB_UPDATE 0x004F
245 #define CMD_MODIFY_ACTION 0x0050
246 #define CMD_CREATE_ACTION 0x0051
247 #define CMD_DELETE_ACTION 0x0052
248 #define CMD_ACTION_DATA 0x0053
249 #define CMD_GET_CONTAINER_CAT_LIST 0x0054
250 #define CMD_CONTAINER_CAT_DATA 0x0055
251 #define CMD_DELETE_CONTAINER_CAT 0x0056
252 #define CMD_CREATE_CONTAINER_CAT 0x0057
253 #define CMD_MODIFY_CONTAINER_CAT 0x0058
254 #define CMD_POLL_NODE 0x0059
255 #define CMD_POLLING_INFO 0x005A
256 #define CMD_COPY_DCI 0x005B
257 #define CMD_WAKEUP_NODE 0x005C
258 #define CMD_DELETE_EVENT_TEMPLATE 0x005D
259 #define CMD_GENERATE_EVENT_ID 0x005E
260 #define CMD_LOCK_TRAP_CFG 0x005F
261 #define CMD_UNLOCK_TRAP_CFG 0x0060
262 #define CMD_CREATE_TRAP 0x0061
263 #define CMD_MODIFY_TRAP 0x0062
264 #define CMD_DELETE_TRAP 0x0063
265 #define CMD_LOAD_TRAP_LIST 0x0064
266
267
268 //
269 // Variable identifiers
270 //
271
272 #define VID_LOGIN_NAME ((DWORD)1)
273 #define VID_PASSWORD ((DWORD)2)
274 #define VID_OBJECT_ID ((DWORD)3)
275 #define VID_OBJECT_NAME ((DWORD)4)
276 #define VID_OBJECT_CLASS ((DWORD)5)
277 #define VID_SNMP_VERSION ((DWORD)6)
278 #define VID_PARENT_CNT ((DWORD)7)
279 #define VID_IP_ADDRESS ((DWORD)8)
280 #define VID_IP_NETMASK ((DWORD)9)
281 #define VID_OBJECT_STATUS ((DWORD)10)
282 #define VID_IF_INDEX ((DWORD)11)
283 #define VID_IF_TYPE ((DWORD)12)
284 #define VID_FLAGS ((DWORD)13)
285 #define VID_DISCOVERY_FLAGS ((DWORD)14)
286 #define VID_AGENT_PORT ((DWORD)15)
287 #define VID_AUTH_METHOD ((DWORD)16)
288 #define VID_SHARED_SECRET ((DWORD)17)
289 #define VID_COMMUNITY_STRING ((DWORD)18)
290 #define VID_SNMP_OID ((DWORD)19)
291 #define VID_NAME ((DWORD)20)
292 #define VID_VALUE ((DWORD)21)
293 #define VID_ERROR ((DWORD)22)
294 #define VID_NOTIFICATION_CODE ((DWORD)23)
295 #define VID_EVENT_ID ((DWORD)24)
296 #define VID_SEVERITY ((DWORD)25)
297 #define VID_MESSAGE ((DWORD)26)
298 #define VID_DESCRIPTION ((DWORD)27)
299 #define VID_RCC ((DWORD)28) /* RCC == Request Completion Code */
300 #define VID_LOCKED_BY ((DWORD)29)
301 #define VID_IS_DELETED ((DWORD)30)
302 #define VID_CHILD_CNT ((DWORD)31)
303 #define VID_ACL_SIZE ((DWORD)32)
304 #define VID_INHERIT_RIGHTS ((DWORD)33)
305 #define VID_USER_NAME ((DWORD)34)
306 #define VID_USER_ID ((DWORD)35)
307 #define VID_USER_SYS_RIGHTS ((DWORD)36)
308 #define VID_USER_FLAGS ((DWORD)37)
309 #define VID_NUM_MEMBERS ((DWORD)38) /* Number of members in users group */
310 #define VID_IS_GROUP ((DWORD)39)
311 #define VID_USER_FULL_NAME ((DWORD)40)
312 #define VID_USER_DESCRIPTION ((DWORD)41)
313 #define VID_UPDATE_TYPE ((DWORD)42)
314 #define VID_DCI_ID ((DWORD)43)
315 #define VID_POLLING_INTERVAL ((DWORD)44)
316 #define VID_RETENTION_TIME ((DWORD)45)
317 #define VID_DCI_SOURCE_TYPE ((DWORD)46)
318 #define VID_DCI_DATA_TYPE ((DWORD)47)
319 #define VID_DCI_STATUS ((DWORD)48)
320 #define VID_MGMT_STATUS ((DWORD)49)
321 #define VID_MAX_ROWS ((DWORD)50)
322 #define VID_TIME_FROM ((DWORD)51)
323 #define VID_TIME_TO ((DWORD)52)
324 #define VID_DCI_DATA ((DWORD)53)
325 #define VID_NUM_THRESHOLDS ((DWORD)54)
326 #define VID_DCI_NUM_MAPS ((DWORD)55)
327 #define VID_DCI_MAP_IDS ((DWORD)56)
328 #define VID_DCI_MAP_INDEXES ((DWORD)57)
329 #define VID_NUM_MIBS ((DWORD)58)
330 #define VID_MIB_NAME ((DWORD)59)
331 #define VID_MIB_FILE_SIZE ((DWORD)60)
332 #define VID_MIB_FILE ((DWORD)61)
333 #define VID_COMMENT ((DWORD)62)
334 #define VID_ALARM_SEVERITY ((DWORD)63)
335 #define VID_ALARM_KEY ((DWORD)64)
336 #define VID_ALARM_ACK_KEY ((DWORD)65)
337 #define VID_ALARM_MESSAGE ((DWORD)66)
338 #define VID_RULE_ID ((DWORD)67)
339 #define VID_NUM_SOURCES ((DWORD)68)
340 #define VID_NUM_EVENTS ((DWORD)69)
341 #define VID_NUM_ACTIONS ((DWORD)70)
342 #define VID_RULE_SOURCES ((DWORD)71)
343 #define VID_RULE_EVENTS ((DWORD)72)
344 #define VID_RULE_ACTIONS ((DWORD)73)
345 #define VID_NUM_RULES ((DWORD)74)
346 #define VID_CATEGORY ((DWORD)75)
347 #define VID_UPDATED_CHILD_LIST ((DWORD)76)
348 #define VID_EVENT_NAME_TABLE ((DWORD)77)
349 #define VID_PARENT_ID ((DWORD)78)
350 #define VID_CHILD_ID ((DWORD)79)
351 #define VID_IMAGE_ID ((DWORD)80)
352 #define VID_NUM_IMAGES ((DWORD)81)
353 #define VID_IMAGE_LIST ((DWORD)82)
354 #define VID_IMAGE_FILE_SIZE ((DWORD)83)
355 #define VID_IMAGE_FILE ((DWORD)84)
356 #define VID_PARAMETER ((DWORD)85)
357 #define VID_NUM_STRINGS ((DWORD)86)
358 #define VID_ACTION_NAME ((DWORD)87)
359 #define VID_NUM_ARGS ((DWORD)88)
360 #define VID_IMAGE_ID_LIST ((DWORD)89)
361 #define VID_CLASS_ID_LIST ((DWORD)90)
362 #define VID_IMAGE_FORMAT ((DWORD)91)
363 #define VID_NOTIFICATION_DATA ((DWORD)92)
364 #define VID_ALARM_ID ((DWORD)93)
365 #define VID_TIMESTAMP ((DWORD)94)
366 #define VID_ACK_BY_USER ((DWORD)95)
367 #define VID_IS_ACK ((DWORD)96)
368 #define VID_ACTION_ID ((DWORD)97)
369 #define VID_IS_DISABLED ((DWORD)98)
370 #define VID_ACTION_TYPE ((DWORD)99)
371 #define VID_ACTION_DATA ((DWORD)100)
372 #define VID_EMAIL_SUBJECT ((DWORD)101)
373 #define VID_RCPT_ADDR ((DWORD)102)
374 #define VID_CATEGORY_NAME ((DWORD)103)
375 #define VID_CATEGORY_ID ((DWORD)104)
376 #define VID_DCI_DELTA_CALCULATION ((DWORD)105)
377 #define VID_DCI_FORMULA ((DWORD)106)
378 #define VID_POLL_TYPE ((DWORD)107)
379 #define VID_POLLER_MESSAGE ((DWORD)108)
380 #define VID_SOURCE_OBJECT_ID ((DWORD)109)
381 #define VID_DESTINATION_OBJECT_ID ((DWORD)110)
382 #define VID_NUM_ITEMS ((DWORD)111)
383 #define VID_ITEM_LIST ((DWORD)112)
384 #define VID_MAC_ADDR ((DWORD)113)
385 #define VID_TEMPLATE_VERSION ((DWORD)114)
386 #define VID_NODE_TYPE ((DWORD)115)
387 #define VID_INSTANCE ((DWORD)116)
388
389 // Variable ranges for object's ACL
390 #define VID_ACL_USER_BASE ((DWORD)0x00001000)
391 #define VID_ACL_USER_LAST ((DWORD)0x00001FFF)
392 #define VID_ACL_RIGHTS_BASE ((DWORD)0x00002000)
393 #define VID_ACL_RIGHTS_LAST ((DWORD)0x00002FFF)
394
395 // Variable range for user group members
396 #define VID_GROUP_MEMBER_BASE ((DWORD)0x00004000)
397 #define VID_GROUP_MEMBER_LAST ((DWORD)0x00004FFF)
398
399 // Variable range for data collection thresholds
400 #define VID_DCI_THRESHOLD_BASE ((DWORD)0x00005000)
401 #define VID_DCI_THRESHOLD_LAST ((DWORD)0x00005FFF)
402
403 // Variable range for MIB list
404 #define VID_MIB_NAME_BASE ((DWORD)0x00006000)
405 #define VID_MIB_NAME_LAST ((DWORD)0x00006FFF)
406 #define VID_MIB_HASH_BASE ((DWORD)0x00007000)
407 #define VID_MIB_HASH_LAST ((DWORD)0x00007FFF)
408
409 // Variable range for event argument list
410 #define VID_EVENT_ARG_BASE ((DWORD)0x00008000)
411 #define VID_EVENT_ARG_LAST ((DWORD)0x00008FFF)
412
413 // Object information can contain variable number of parent and child objects' ids.
414 // Because each variable in message have to have unique identifier,
415 // we reserver a two range ids for this variables.
416 #define VID_PARENT_ID_BASE ((DWORD)0x00003000)
417 #define VID_PARENT_ID_LAST ((DWORD)0x00003FFF)
418
419 // Reservation of 0x7FFFFFFF ids for child object's list
420 #define VID_CHILD_ID_BASE ((DWORD)0x80000000)
421 #define VID_CHILD_ID_LAST ((DWORD)0xFFFFFFFE)
422
423 // Base value for agent's enum values
424 #define VID_ENUM_VALUE_BASE ((DWORD)0x10000000)
425
426 // Base value for agent's action arguments
427 #define VID_ACTION_ARG_BASE ((DWORD)0x10000000)
428
429
430 //
431 // Inline functions
432 //
433
434 #ifdef __cplusplus
435
436 inline BOOL IsBinaryMsg(CSCP_MESSAGE *pMsg)
437 {
438 return ntohs(pMsg->wFlags) & MF_BINARY;
439 }
440
441 #endif
442
443
444 #endif /* _nms_cscp_h_ */