Schema extended for alarms
[public/netxms.git] / include / nxclapi.h
CommitLineData
80ffed5a
VK
1/*
2** NetXMS - Network Management System
3** Client Library API
4** Copyright (C) 2004 Victor Kirhenshtein
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19**
20** $module: nxclapi.h
21**
22**/
23
24#ifndef _nxclapi_h_
25#define _nxclapi_h_
26
27#include <nms_common.h>
5ebea5e0 28#include <nxevent.h>
80ffed5a 29
8aeffdee
VK
30#ifdef _WIN32
31#ifdef LIBNXCL_EXPORTS
32#define LIBNXCL_EXPORTABLE __declspec(dllexport)
33#else
34#define LIBNXCL_EXPORTABLE __declspec(dllimport)
35#endif
36#else /* _WIN32 */
37#define LIBNXCL_EXPORTABLE
38#endif
39
80ffed5a 40
c6576857
VK
41//
42// Custom data types
43//
44
45typedef unsigned long HREQUEST;
46
47
0c8bf759
VK
48//
49// Some constants
50//
51
878c92bc
VK
52#define MAX_OBJECT_NAME 64
53#define MAX_COMMUNITY_LENGTH 32
54#define MAX_OID_LENGTH 1024
55#define MAX_EVENT_MSG_LENGTH 256
56#define MAX_EVENT_NAME 64
5ac3236b 57#define MAX_USER_NAME 64
54abbe0e
VK
58#define MAX_USER_FULLNAME 128
59#define MAX_USER_DESCR 256
7ec6cca8
VK
60#define MAX_ITEM_NAME 256
61#define MAX_STRING_VALUE 256
8c18110a
VK
62#define GROUP_FLAG ((DWORD)0x80000000)
63#define GROUP_EVERYONE ((DWORD)0x80000000)
64#define INVALID_UID ((DWORD)0xFFFFFFFF)
c0ae9ed5 65#define OBJECT_STATUS_COUNT 7
0c8bf759
VK
66
67
71c18491
VK
68//
69// Authentication methods
70//
71
72#define AUTH_NONE 0
73#define AUTH_PLAINTEXT 1
74#define AUTH_MD5_HASH 2
75#define AUTH_SHA1_HASH 3
76
77
78//
79// Object types
80//
81
82#define OBJECT_GENERIC 0
83#define OBJECT_SUBNET 1
84#define OBJECT_NODE 2
85#define OBJECT_INTERFACE 3
86#define OBJECT_NETWORK 4
372b525a
VK
87#define OBJECT_LOCATION 5
88#define OBJECT_ZONE 6
71c18491
VK
89
90
9eb7685c
VK
91//
92// Object's status
93//
94
95#define STATUS_NORMAL 0
96#define STATUS_WARNING 1
97#define STATUS_MINOR 2
98#define STATUS_MAJOR 3
99#define STATUS_CRITICAL 4
100#define STATUS_UNKNOWN 5
101#define STATUS_UNMANAGED 6
102#define STATUS_DISABLED 7
103#define STATUS_TESTING 8
104
105
4d597931
VK
106//
107// Node flags
108//
109
110#define NF_IS_SNMP 0x0001
111#define NF_IS_NATIVE_AGENT 0x0002
112#define NF_IS_BRIDGE 0x0004
113#define NF_IS_ROUTER 0x0008
114#define NF_IS_LOCAL_MGMT 0x0010
115
116
5fad5c32
VK
117//
118// Events
119//
120
878c92bc
VK
121#define NXC_EVENT_STATE_CHANGED 1
122#define NXC_EVENT_ERROR 2
123#define NXC_EVENT_LOGIN_RESULT 3
124#define NXC_EVENT_NEW_ELOG_RECORD 4
f75b99fd 125#define NXC_EVENT_USER_DB_CHANGED 5
4d597931 126#define NXC_EVENT_OBJECT_CHANGED 6
71f8d3d7
VK
127
128
129//
130// Errors
131//
132
133#define NXC_ERR_INTERNAL 1
5fad5c32
VK
134
135
54481027
VK
136//
137// States
138//
139
140#define STATE_DISCONNECTED 0
141#define STATE_CONNECTING 1
142#define STATE_IDLE 2
7e986059
VK
143#define STATE_SYNC_OBJECTS 3
144#define STATE_SYNC_EVENTS 4
878c92bc
VK
145#define STATE_LOAD_EVENT_DB 5
146#define STATE_LOAD_EPP 6
5ac3236b 147#define STATE_LOAD_USER_DB 7
7ec6cca8 148#define STATE_LOAD_DCI 8
7e986059
VK
149
150
b601b1fa
VK
151//
152// Notification codes
153//
154
878c92bc
VK
155#define NX_NOTIFY_SHUTDOWN 1
156
157
158//
159// Request completion codes
160//
161
162#define RCC_SUCCESS ((DWORD)0)
163#define RCC_COMPONENT_LOCKED ((DWORD)1)
164#define RCC_ACCESS_DENIED ((DWORD)2)
165#define RCC_INVALID_REQUEST ((DWORD)3)
166#define RCC_TIMEOUT ((DWORD)4)
605d2931
VK
167#define RCC_OUT_OF_STATE_REQUEST ((DWORD)5)
168#define RCC_DB_FAILURE ((DWORD)6)
effb51ab 169#define RCC_INVALID_OBJECT_ID ((DWORD)7)
34d95c13 170#define RCC_ALREADY_EXIST ((DWORD)8)
2e29457d 171#define RCC_COMM_FAILURE ((DWORD)9)
0d9c1b96 172#define RCC_SYSTEM_FAILURE ((DWORD)10)
62f3f072 173#define RCC_INVALID_USER_ID ((DWORD)11)
7ec6cca8 174#define RCC_INVALID_ARGUMENT ((DWORD)12)
9ed4eaff
VK
175#define RCC_DUPLICATE_DCI ((DWORD)13)
176#define RCC_INVALID_DCI_ID ((DWORD)14)
878c92bc
VK
177
178
d9152256
VK
179//
180// Mask bits for NXCModifyEventTemplate()
181//
182
183#define EM_SEVERITY ((DWORD)0x01)
184#define EM_FLAGS ((DWORD)0x02)
185#define EM_NAME ((DWORD)0x04)
186#define EM_MESSAGE ((DWORD)0x08)
187#define EM_DESCRIPTION ((DWORD)0x10)
188#define EM_ALL ((DWORD)0x1F)
189
190
effb51ab
VK
191//
192// Mask bits (flags) for NXCModifyObject()
193//
194
195#define OBJ_UPDATE_NAME ((DWORD)0x01)
196#define OBJ_UPDATE_AGENT_PORT ((DWORD)0x02)
197#define OBJ_UPDATE_AGENT_AUTH ((DWORD)0x04)
198#define OBJ_UPDATE_AGENT_SECRET ((DWORD)0x08)
199#define OBJ_UPDATE_SNMP_VERSION ((DWORD)0x10)
200#define OBJ_UPDATE_SNMP_COMMUNITY ((DWORD)0x20)
201#define OBJ_UPDATE_ACL ((DWORD)0x40)
202#define OBJ_UPDATE_ALL ((DWORD)0x7F)
203
204
5ac3236b
VK
205//
206// Global user rights
207//
208
209#define SYSTEM_ACCESS_MANAGE_USERS 0x0001
210#define SYSTEM_ACCESS_VIEW_CONFIG 0x0002
211#define SYSTEM_ACCESS_EDIT_CONFIG 0x0004
212#define SYSTEM_ACCESS_DROP_CONNECTIONS 0x0008
213#define SYSTEM_ACCESS_VIEW_EVENT_DB 0x0010
214#define SYSTEM_ACCESS_EDIT_EVENT_DB 0x0020
215
911dbb64
VK
216#define SYSTEM_ACCESS_FULL 0x003F
217
5ac3236b
VK
218
219//
220// Object access rights
221//
222
223#define OBJECT_ACCESS_READ 0x00000001
224#define OBJECT_ACCESS_MODIFY 0x00000002
225#define OBJECT_ACCESS_CREATE 0x00000004
226#define OBJECT_ACCESS_DELETE 0x00000008
227#define OBJECT_ACCESS_MOVE 0x00000010
34d95c13 228#define OBJECT_ACCESS_CONTROL 0x00000020
5ac3236b
VK
229
230
231//
232// User/group flags
233//
234
235#define UF_MODIFIED 0x0001
236#define UF_DELETED 0x0002
237#define UF_DISABLED 0x0004
238#define UF_CHANGE_PASSWORD 0x0008
8c18110a 239#define UF_CANNOT_CHANGE_PASSWORD 0x0010
5ac3236b
VK
240
241
984542f8
VK
242//
243// User database change notification types
244//
245
246#define USER_DB_CREATE 0
247#define USER_DB_DELETE 1
248#define USER_DB_MODIFY 2
249
250
878c92bc 251//
7ec6cca8 252// Data types
878c92bc
VK
253//
254
7ec6cca8
VK
255#define DTYPE_INTEGER 0
256#define DTYPE_INT64 1
257#define DTYPE_STRING 2
258#define DTYPE_FLOAT 3
b601b1fa
VK
259
260
54481027 261//
7ec6cca8 262// Data sources
54481027
VK
263//
264
7ec6cca8
VK
265#define DS_INTERNAL 0
266#define DS_NATIVE_AGENT 1
267#define DS_SNMP_AGENT 2
54481027
VK
268
269
878c92bc 270//
7ec6cca8 271// Item status
878c92bc
VK
272//
273
7ec6cca8
VK
274#define ITEM_STATUS_ACTIVE 0
275#define ITEM_STATUS_DISABLED 1
276#define ITEM_STATUS_NOT_SUPPORTED 2
878c92bc
VK
277
278
d0e94572
VK
279//
280// Threshold functions and operations
281//
282
283#define F_LAST 0
284#define F_AVERAGE 1
285#define F_DEVIATION 2
286
287#define OP_LE 0
288#define OP_LE_EQ 1
289#define OP_EQ 2
290#define OP_GT_EQ 3
291#define OP_GT 4
292#define OP_NE 5
293#define OP_LIKE 6
294#define OP_NOTLIKE 7
295
296
a1dc75b0
VK
297//
298// Event log record structure
299//
300
301typedef struct
302{
303 DWORD dwTimeStamp;
304 DWORD dwEventId;
305 DWORD dwSourceId;
306 DWORD dwSeverity;
307 char szMessage[MAX_EVENT_MSG_LENGTH];
308} NXC_EVENT;
309
310
7ec6cca8
VK
311/********************************************************************
312 * Following part of this file shouldn't be included by server code *
313 ********************************************************************/
314
315#ifndef LIBNXCL_NO_DECLARATIONS
316
317
318//
319// Callbacks data types
320//
321
322typedef void (* NXC_EVENT_HANDLER)(DWORD dwEvent, DWORD dwCode, void *pArg);
323typedef void (* NXC_DEBUG_CALLBACK)(char *pMsg);
324
325
326//
327// Event configuration structure
328//
329
330typedef struct
331{
332 DWORD dwCode;
333 DWORD dwSeverity;
334 DWORD dwFlags;
335 char szName[MAX_EVENT_NAME];
336 char *pszMessage;
337 char *pszDescription;
338} NXC_EVENT_TEMPLATE;
339
340
effb51ab
VK
341//
342// Entry in object's ACL
343//
344
345typedef struct
346{
347 DWORD dwUserId;
348 DWORD dwAccessRights;
349} NXC_ACL_ENTRY;
350
351
0c8bf759
VK
352//
353// Network object structure
354//
355
356typedef struct
357{
358 DWORD dwId; // Unique object's identifier
359 int iClass; // Object's class
360 int iStatus; // Object's status
361 DWORD dwIpAddr; // IP address
362 char szName[MAX_OBJECT_NAME];
363 DWORD dwNumParents;
364 DWORD *pdwParentList;
365 DWORD dwNumChilds;
366 DWORD *pdwChildList;
4d597931 367 BOOL bIsDeleted; // TRUE for deleted objects
effb51ab
VK
368 BOOL bInheritRights;
369 DWORD dwAclSize;
370 NXC_ACL_ENTRY *pAccessList;
0c8bf759
VK
371 union
372 {
373 struct
374 {
375 DWORD dwIpNetMask; // Ip netmask.
376 DWORD dwIfIndex; // Interface index.
377 DWORD dwIfType; // Interface type
378 } iface;
379 struct
380 {
381 DWORD dwFlags;
382 DWORD dwDiscoveryFlags;
383 char szSharedSecret[MAX_SECRET_LENGTH];
384 char szCommunityString[MAX_COMMUNITY_LENGTH];
385 char szObjectId[MAX_OID_LENGTH];
386 WORD wAgentPort; // Listening TCP port for native agent
387 WORD wAuthMethod; // Native agent's authentication method
388 } node;
389 struct
390 {
391 DWORD dwIpNetMask;
392 } subnet;
393 };
394} NXC_OBJECT;
395
396
effb51ab
VK
397//
398// Structure with data for NXCModifyObject
399//
400
401typedef struct
402{
403 DWORD dwObjectId;
404 DWORD dwFlags;
405 char *pszName;
406 int iAgentPort;
407 int iAuthType;
408 char *pszSecret;
409 int iSnmpVersion;
410 char *pszCommunity;
411 BOOL bInheritRights;
412 DWORD dwAclSize;
413 NXC_ACL_ENTRY *pAccessList;
414} NXC_OBJECT_UPDATE;
415
416
5ac3236b
VK
417//
418// NetXMS user information structure
419//
420
421typedef struct
422{
423 char szName[MAX_USER_NAME];
424 DWORD dwId;
425 WORD wFlags;
426 WORD wSystemRights;
427 DWORD dwNumMembers; // Only for groups
428 DWORD *pdwMemberList; // Only for groups
54abbe0e
VK
429 char szFullName[MAX_USER_FULLNAME]; // Only for users
430 char szDescription[MAX_USER_DESCR];
5ac3236b
VK
431} NXC_USER;
432
433
f86ffdd2
VK
434//
435// Data collection item threshold structure
436//
437
438typedef struct
439{
440 DWORD dwId;
441 DWORD dwEvent;
442 WORD wFunction;
443 WORD wOperation;
444 DWORD dwArg1;
445 DWORD dwArg2;
446 union
447 {
448 DWORD dwInt32;
449 INT64 qwInt64;
450 double dFloat;
451 char szString[MAX_STRING_VALUE];
452 } value;
453} NXC_DCI_THRESHOLD;
454
455
7ec6cca8
VK
456//
457// Data collection item structure
458//
459
460typedef struct
461{
462 DWORD dwId;
463 char szName[MAX_ITEM_NAME];
464 int iPollingInterval;
465 int iRetentionTime;
466 BYTE iSource;
467 BYTE iDataType;
468 BYTE iStatus;
f86ffdd2
VK
469 DWORD dwNumThresholds;
470 NXC_DCI_THRESHOLD *pThresholdList;
7ec6cca8
VK
471} NXC_DCI;
472
473
474//
475// Node's data collection list information
476//
477
478typedef struct
479{
480 DWORD dwNodeId;
481 DWORD dwNumItems;
482 NXC_DCI *pItems;
483} NXC_DCI_LIST;
484
485
b9b4ec17
VK
486//
487// Row structure
488//
489
9f20696e
VK
490#pragma pack(1)
491
b9b4ec17
VK
492typedef struct
493{
494 DWORD dwTimeStamp;
495 union
496 {
497 DWORD dwInt32;
cb17745c 498 INT64 qwInt64;
b9b4ec17
VK
499 double dFloat;
500 char szString[MAX_STRING_VALUE];
501 } value;
502} NXC_DCI_ROW;
503
9f20696e
VK
504#pragma pack()
505
b9b4ec17
VK
506
507//
508// DCI's collected data
509//
510
511typedef struct
512{
513 DWORD dwNodeId; // Owner's node id
514 DWORD dwItemId; // Item id
515 DWORD dwNumRows; // Number of rows in set
516 WORD wDataType; // Data type (integer, string, etc.)
517 WORD wRowSize; // Size of single row in bytes
518 NXC_DCI_ROW *pRows; // Array of rows
519} NXC_DCI_DATA;
520
521
80ffed5a
VK
522//
523// Functions
524//
525
526#ifdef __cplusplus
527extern "C" {
528#endif
529
8aeffdee 530DWORD LIBNXCL_EXPORTABLE NXCGetVersion(void);
effb51ab
VK
531const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError);
532
8aeffdee 533BOOL LIBNXCL_EXPORTABLE NXCInitialize(void);
1df4b30b 534DWORD LIBNXCL_EXPORTABLE NXCConnect(char *szServer, char *szLogin, char *szPassword);
8aeffdee
VK
535void LIBNXCL_EXPORTABLE NXCDisconnect(void);
536void LIBNXCL_EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler);
537void LIBNXCL_EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc);
538HREQUEST LIBNXCL_EXPORTABLE NXCRequest(DWORD dwOperation, ...);
80ffed5a 539
2e29457d 540DWORD LIBNXCL_EXPORTABLE NXCSyncObjects(void);
8aeffdee 541NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectById(DWORD dwId);
a98e6d5f 542NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectByName(char *pszName);
8aeffdee
VK
543void LIBNXCL_EXPORTABLE NXCEnumerateObjects(BOOL (* pHandler)(NXC_OBJECT *));
544NXC_OBJECT LIBNXCL_EXPORTABLE *NXCGetRootObject(void);
8e80aeb6
VK
545void LIBNXCL_EXPORTABLE *NXCGetObjectIndex(DWORD *pdwNumObjects);
546void LIBNXCL_EXPORTABLE NXCLockObjectIndex(void);
547void LIBNXCL_EXPORTABLE NXCUnlockObjectIndex(void);
2e29457d 548DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_OBJECT_UPDATE *pData);
c1c39152 549DWORD LIBNXCL_EXPORTABLE NXCSetObjectMgmtStatus(DWORD dwObjectId, BOOL bIsManaged);
8b3d61c1 550
2e29457d
VK
551DWORD LIBNXCL_EXPORTABLE NXCSyncEvents(void);
552DWORD LIBNXCL_EXPORTABLE NXCOpenEventDB(void);
553DWORD LIBNXCL_EXPORTABLE NXCCloseEventDB(BOOL bSaveChanges);
8aeffdee
VK
554BOOL LIBNXCL_EXPORTABLE NXCGetEventDB(NXC_EVENT_TEMPLATE ***pppTemplateList, DWORD *pdwNumRecords);
555void LIBNXCL_EXPORTABLE NXCModifyEventTemplate(NXC_EVENT_TEMPLATE *pEvent, DWORD dwMask,
d9152256
VK
556 DWORD dwSeverity, DWORD dwFlags, const char *pszName,
557 const char *pszMessage, const char *pszDescription);
878c92bc 558
2e29457d 559DWORD LIBNXCL_EXPORTABLE NXCLoadUserDB(void);
5ac3236b 560NXC_USER LIBNXCL_EXPORTABLE *NXCFindUserById(DWORD dwId);
440716ce 561BOOL LIBNXCL_EXPORTABLE NXCGetUserDB(NXC_USER **ppUserList, DWORD *pdwNumUsers);
0d9c1b96
VK
562DWORD LIBNXCL_EXPORTABLE NXCLockUserDB(void);
563DWORD LIBNXCL_EXPORTABLE NXCUnlockUserDB(void);
f75b99fd
VK
564DWORD LIBNXCL_EXPORTABLE NXCCreateUser(char *pszName, BOOL bIsGroup, DWORD *pdwNewId);
565DWORD LIBNXCL_EXPORTABLE NXCDeleteUser(DWORD dwId);
911dbb64 566DWORD LIBNXCL_EXPORTABLE NXCModifyUser(NXC_USER *pUserInfo);
8c18110a 567DWORD LIBNXCL_EXPORTABLE NXCSetPassword(DWORD dwUserId, char *pszNewPassword);
5ac3236b 568
7ec6cca8
VK
569DWORD LIBNXCL_EXPORTABLE NXCOpenNodeDCIList(DWORD dwNodeId, NXC_DCI_LIST **ppItemList);
570DWORD LIBNXCL_EXPORTABLE NXCCloseNodeDCIList(NXC_DCI_LIST *pItemList);
7ac0c0a8
VK
571DWORD LIBNXCL_EXPORTABLE NXCCreateNewDCI(NXC_DCI_LIST *pItemList, DWORD *pdwItemId);
572DWORD LIBNXCL_EXPORTABLE NXCUpdateDCI(DWORD dwNodeId, NXC_DCI *pItem);
573DWORD LIBNXCL_EXPORTABLE NXCDeleteDCI(NXC_DCI_LIST *pItemList, DWORD dwItemId);
574DWORD LIBNXCL_EXPORTABLE NXCItemIndex(NXC_DCI_LIST *pItemList, DWORD dwItemId);
b9b4ec17
VK
575DWORD LIBNXCL_EXPORTABLE NXCGetDCIData(DWORD dwNodeId, DWORD dwItemId, DWORD dwMaxRows,
576 DWORD dwTimeFrom, DWORD dwTimeTo, NXC_DCI_DATA **ppData);
4c20673b
VK
577void LIBNXCL_EXPORTABLE NXCDestroyDCIData(NXC_DCI_DATA *pData);
578NXC_DCI_ROW LIBNXCL_EXPORTABLE *NXCGetRowPtr(NXC_DCI_DATA *pData, DWORD dwRow);
899f2093
VK
579DWORD LIBNXCL_EXPORTABLE NXCAddThresholdToItem(NXC_DCI *pItem, NXC_DCI_THRESHOLD *pThreshold);
580BOOL LIBNXCL_EXPORTABLE NXCDeleteThresholdFromItem(NXC_DCI *pItem, DWORD dwIndex);
581BOOL LIBNXCL_EXPORTABLE NXCSwapThresholds(NXC_DCI *pItem, DWORD dwIndex1, DWORD dwIndex2);
7ec6cca8 582
80ffed5a
VK
583#ifdef __cplusplus
584}
585#endif
586
7ec6cca8
VK
587#endif /* LIBNXCL_NO_DECLARATIONS */
588
80ffed5a 589#endif /* _nxclapi_h_ */