Start changing code to add threshold manipulation
[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
4d597931
VK
91//
92// Node flags
93//
94
95#define NF_IS_SNMP 0x0001
96#define NF_IS_NATIVE_AGENT 0x0002
97#define NF_IS_BRIDGE 0x0004
98#define NF_IS_ROUTER 0x0008
99#define NF_IS_LOCAL_MGMT 0x0010
100
101
5fad5c32
VK
102//
103// Events
104//
105
878c92bc
VK
106#define NXC_EVENT_STATE_CHANGED 1
107#define NXC_EVENT_ERROR 2
108#define NXC_EVENT_LOGIN_RESULT 3
109#define NXC_EVENT_NEW_ELOG_RECORD 4
f75b99fd 110#define NXC_EVENT_USER_DB_CHANGED 5
4d597931 111#define NXC_EVENT_OBJECT_CHANGED 6
71f8d3d7
VK
112
113
114//
115// Errors
116//
117
118#define NXC_ERR_INTERNAL 1
5fad5c32
VK
119
120
54481027
VK
121//
122// States
123//
124
125#define STATE_DISCONNECTED 0
126#define STATE_CONNECTING 1
127#define STATE_IDLE 2
7e986059
VK
128#define STATE_SYNC_OBJECTS 3
129#define STATE_SYNC_EVENTS 4
878c92bc
VK
130#define STATE_LOAD_EVENT_DB 5
131#define STATE_LOAD_EPP 6
5ac3236b 132#define STATE_LOAD_USER_DB 7
7ec6cca8 133#define STATE_LOAD_DCI 8
7e986059
VK
134
135
b601b1fa
VK
136//
137// Notification codes
138//
139
878c92bc
VK
140#define NX_NOTIFY_SHUTDOWN 1
141
142
143//
144// Request completion codes
145//
146
147#define RCC_SUCCESS ((DWORD)0)
148#define RCC_COMPONENT_LOCKED ((DWORD)1)
149#define RCC_ACCESS_DENIED ((DWORD)2)
150#define RCC_INVALID_REQUEST ((DWORD)3)
151#define RCC_TIMEOUT ((DWORD)4)
605d2931
VK
152#define RCC_OUT_OF_STATE_REQUEST ((DWORD)5)
153#define RCC_DB_FAILURE ((DWORD)6)
effb51ab 154#define RCC_INVALID_OBJECT_ID ((DWORD)7)
34d95c13 155#define RCC_ALREADY_EXIST ((DWORD)8)
2e29457d 156#define RCC_COMM_FAILURE ((DWORD)9)
0d9c1b96 157#define RCC_SYSTEM_FAILURE ((DWORD)10)
62f3f072 158#define RCC_INVALID_USER_ID ((DWORD)11)
7ec6cca8 159#define RCC_INVALID_ARGUMENT ((DWORD)12)
9ed4eaff
VK
160#define RCC_DUPLICATE_DCI ((DWORD)13)
161#define RCC_INVALID_DCI_ID ((DWORD)14)
878c92bc
VK
162
163
d9152256
VK
164//
165// Mask bits for NXCModifyEventTemplate()
166//
167
168#define EM_SEVERITY ((DWORD)0x01)
169#define EM_FLAGS ((DWORD)0x02)
170#define EM_NAME ((DWORD)0x04)
171#define EM_MESSAGE ((DWORD)0x08)
172#define EM_DESCRIPTION ((DWORD)0x10)
173#define EM_ALL ((DWORD)0x1F)
174
175
effb51ab
VK
176//
177// Mask bits (flags) for NXCModifyObject()
178//
179
180#define OBJ_UPDATE_NAME ((DWORD)0x01)
181#define OBJ_UPDATE_AGENT_PORT ((DWORD)0x02)
182#define OBJ_UPDATE_AGENT_AUTH ((DWORD)0x04)
183#define OBJ_UPDATE_AGENT_SECRET ((DWORD)0x08)
184#define OBJ_UPDATE_SNMP_VERSION ((DWORD)0x10)
185#define OBJ_UPDATE_SNMP_COMMUNITY ((DWORD)0x20)
186#define OBJ_UPDATE_ACL ((DWORD)0x40)
187#define OBJ_UPDATE_ALL ((DWORD)0x7F)
188
189
5ac3236b
VK
190//
191// Global user rights
192//
193
194#define SYSTEM_ACCESS_MANAGE_USERS 0x0001
195#define SYSTEM_ACCESS_VIEW_CONFIG 0x0002
196#define SYSTEM_ACCESS_EDIT_CONFIG 0x0004
197#define SYSTEM_ACCESS_DROP_CONNECTIONS 0x0008
198#define SYSTEM_ACCESS_VIEW_EVENT_DB 0x0010
199#define SYSTEM_ACCESS_EDIT_EVENT_DB 0x0020
200
911dbb64
VK
201#define SYSTEM_ACCESS_FULL 0x003F
202
5ac3236b
VK
203
204//
205// Object access rights
206//
207
208#define OBJECT_ACCESS_READ 0x00000001
209#define OBJECT_ACCESS_MODIFY 0x00000002
210#define OBJECT_ACCESS_CREATE 0x00000004
211#define OBJECT_ACCESS_DELETE 0x00000008
212#define OBJECT_ACCESS_MOVE 0x00000010
34d95c13 213#define OBJECT_ACCESS_CONTROL 0x00000020
5ac3236b
VK
214
215
216//
217// User/group flags
218//
219
220#define UF_MODIFIED 0x0001
221#define UF_DELETED 0x0002
222#define UF_DISABLED 0x0004
223#define UF_CHANGE_PASSWORD 0x0008
8c18110a 224#define UF_CANNOT_CHANGE_PASSWORD 0x0010
5ac3236b
VK
225
226
984542f8
VK
227//
228// User database change notification types
229//
230
231#define USER_DB_CREATE 0
232#define USER_DB_DELETE 1
233#define USER_DB_MODIFY 2
234
235
878c92bc 236//
7ec6cca8 237// Data types
878c92bc
VK
238//
239
7ec6cca8
VK
240#define DTYPE_INTEGER 0
241#define DTYPE_INT64 1
242#define DTYPE_STRING 2
243#define DTYPE_FLOAT 3
b601b1fa
VK
244
245
54481027 246//
7ec6cca8 247// Data sources
54481027
VK
248//
249
7ec6cca8
VK
250#define DS_INTERNAL 0
251#define DS_NATIVE_AGENT 1
252#define DS_SNMP_AGENT 2
54481027
VK
253
254
878c92bc 255//
7ec6cca8 256// Item status
878c92bc
VK
257//
258
7ec6cca8
VK
259#define ITEM_STATUS_ACTIVE 0
260#define ITEM_STATUS_DISABLED 1
261#define ITEM_STATUS_NOT_SUPPORTED 2
878c92bc
VK
262
263
a1dc75b0
VK
264//
265// Event log record structure
266//
267
268typedef struct
269{
270 DWORD dwTimeStamp;
271 DWORD dwEventId;
272 DWORD dwSourceId;
273 DWORD dwSeverity;
274 char szMessage[MAX_EVENT_MSG_LENGTH];
275} NXC_EVENT;
276
277
7ec6cca8
VK
278/********************************************************************
279 * Following part of this file shouldn't be included by server code *
280 ********************************************************************/
281
282#ifndef LIBNXCL_NO_DECLARATIONS
283
284
285//
286// Callbacks data types
287//
288
289typedef void (* NXC_EVENT_HANDLER)(DWORD dwEvent, DWORD dwCode, void *pArg);
290typedef void (* NXC_DEBUG_CALLBACK)(char *pMsg);
291
292
293//
294// Event configuration structure
295//
296
297typedef struct
298{
299 DWORD dwCode;
300 DWORD dwSeverity;
301 DWORD dwFlags;
302 char szName[MAX_EVENT_NAME];
303 char *pszMessage;
304 char *pszDescription;
305} NXC_EVENT_TEMPLATE;
306
307
effb51ab
VK
308//
309// Entry in object's ACL
310//
311
312typedef struct
313{
314 DWORD dwUserId;
315 DWORD dwAccessRights;
316} NXC_ACL_ENTRY;
317
318
0c8bf759
VK
319//
320// Network object structure
321//
322
323typedef struct
324{
325 DWORD dwId; // Unique object's identifier
326 int iClass; // Object's class
327 int iStatus; // Object's status
328 DWORD dwIpAddr; // IP address
329 char szName[MAX_OBJECT_NAME];
330 DWORD dwNumParents;
331 DWORD *pdwParentList;
332 DWORD dwNumChilds;
333 DWORD *pdwChildList;
4d597931 334 BOOL bIsDeleted; // TRUE for deleted objects
effb51ab
VK
335 BOOL bInheritRights;
336 DWORD dwAclSize;
337 NXC_ACL_ENTRY *pAccessList;
0c8bf759
VK
338 union
339 {
340 struct
341 {
342 DWORD dwIpNetMask; // Ip netmask.
343 DWORD dwIfIndex; // Interface index.
344 DWORD dwIfType; // Interface type
345 } iface;
346 struct
347 {
348 DWORD dwFlags;
349 DWORD dwDiscoveryFlags;
350 char szSharedSecret[MAX_SECRET_LENGTH];
351 char szCommunityString[MAX_COMMUNITY_LENGTH];
352 char szObjectId[MAX_OID_LENGTH];
353 WORD wAgentPort; // Listening TCP port for native agent
354 WORD wAuthMethod; // Native agent's authentication method
355 } node;
356 struct
357 {
358 DWORD dwIpNetMask;
359 } subnet;
360 };
361} NXC_OBJECT;
362
363
effb51ab
VK
364//
365// Structure with data for NXCModifyObject
366//
367
368typedef struct
369{
370 DWORD dwObjectId;
371 DWORD dwFlags;
372 char *pszName;
373 int iAgentPort;
374 int iAuthType;
375 char *pszSecret;
376 int iSnmpVersion;
377 char *pszCommunity;
378 BOOL bInheritRights;
379 DWORD dwAclSize;
380 NXC_ACL_ENTRY *pAccessList;
381} NXC_OBJECT_UPDATE;
382
383
5ac3236b
VK
384//
385// NetXMS user information structure
386//
387
388typedef struct
389{
390 char szName[MAX_USER_NAME];
391 DWORD dwId;
392 WORD wFlags;
393 WORD wSystemRights;
394 DWORD dwNumMembers; // Only for groups
395 DWORD *pdwMemberList; // Only for groups
54abbe0e
VK
396 char szFullName[MAX_USER_FULLNAME]; // Only for users
397 char szDescription[MAX_USER_DESCR];
5ac3236b
VK
398} NXC_USER;
399
400
7ec6cca8
VK
401//
402// Data collection item structure
403//
404
405typedef struct
406{
407 DWORD dwId;
408 char szName[MAX_ITEM_NAME];
409 int iPollingInterval;
410 int iRetentionTime;
411 BYTE iSource;
412 BYTE iDataType;
413 BYTE iStatus;
414} NXC_DCI;
415
416
417//
418// Node's data collection list information
419//
420
421typedef struct
422{
423 DWORD dwNodeId;
424 DWORD dwNumItems;
425 NXC_DCI *pItems;
426} NXC_DCI_LIST;
427
428
b9b4ec17
VK
429//
430// Row structure
431//
432
9f20696e
VK
433#pragma pack(1)
434
b9b4ec17
VK
435typedef struct
436{
437 DWORD dwTimeStamp;
438 union
439 {
440 DWORD dwInt32;
cb17745c 441 INT64 qwInt64;
b9b4ec17
VK
442 double dFloat;
443 char szString[MAX_STRING_VALUE];
444 } value;
445} NXC_DCI_ROW;
446
9f20696e
VK
447#pragma pack()
448
b9b4ec17
VK
449
450//
451// DCI's collected data
452//
453
454typedef struct
455{
456 DWORD dwNodeId; // Owner's node id
457 DWORD dwItemId; // Item id
458 DWORD dwNumRows; // Number of rows in set
459 WORD wDataType; // Data type (integer, string, etc.)
460 WORD wRowSize; // Size of single row in bytes
461 NXC_DCI_ROW *pRows; // Array of rows
462} NXC_DCI_DATA;
463
464
80ffed5a
VK
465//
466// Functions
467//
468
469#ifdef __cplusplus
470extern "C" {
471#endif
472
8aeffdee 473DWORD LIBNXCL_EXPORTABLE NXCGetVersion(void);
effb51ab
VK
474const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError);
475
8aeffdee 476BOOL LIBNXCL_EXPORTABLE NXCInitialize(void);
1df4b30b 477DWORD LIBNXCL_EXPORTABLE NXCConnect(char *szServer, char *szLogin, char *szPassword);
8aeffdee
VK
478void LIBNXCL_EXPORTABLE NXCDisconnect(void);
479void LIBNXCL_EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler);
480void LIBNXCL_EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc);
481HREQUEST LIBNXCL_EXPORTABLE NXCRequest(DWORD dwOperation, ...);
80ffed5a 482
2e29457d 483DWORD LIBNXCL_EXPORTABLE NXCSyncObjects(void);
8aeffdee 484NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectById(DWORD dwId);
a98e6d5f 485NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectByName(char *pszName);
8aeffdee
VK
486void LIBNXCL_EXPORTABLE NXCEnumerateObjects(BOOL (* pHandler)(NXC_OBJECT *));
487NXC_OBJECT LIBNXCL_EXPORTABLE *NXCGetRootObject(void);
8e80aeb6
VK
488void LIBNXCL_EXPORTABLE *NXCGetObjectIndex(DWORD *pdwNumObjects);
489void LIBNXCL_EXPORTABLE NXCLockObjectIndex(void);
490void LIBNXCL_EXPORTABLE NXCUnlockObjectIndex(void);
2e29457d 491DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_OBJECT_UPDATE *pData);
c1c39152 492DWORD LIBNXCL_EXPORTABLE NXCSetObjectMgmtStatus(DWORD dwObjectId, BOOL bIsManaged);
8b3d61c1 493
2e29457d
VK
494DWORD LIBNXCL_EXPORTABLE NXCSyncEvents(void);
495DWORD LIBNXCL_EXPORTABLE NXCOpenEventDB(void);
496DWORD LIBNXCL_EXPORTABLE NXCCloseEventDB(BOOL bSaveChanges);
8aeffdee
VK
497BOOL LIBNXCL_EXPORTABLE NXCGetEventDB(NXC_EVENT_TEMPLATE ***pppTemplateList, DWORD *pdwNumRecords);
498void LIBNXCL_EXPORTABLE NXCModifyEventTemplate(NXC_EVENT_TEMPLATE *pEvent, DWORD dwMask,
d9152256
VK
499 DWORD dwSeverity, DWORD dwFlags, const char *pszName,
500 const char *pszMessage, const char *pszDescription);
878c92bc 501
2e29457d 502DWORD LIBNXCL_EXPORTABLE NXCLoadUserDB(void);
5ac3236b 503NXC_USER LIBNXCL_EXPORTABLE *NXCFindUserById(DWORD dwId);
440716ce 504BOOL LIBNXCL_EXPORTABLE NXCGetUserDB(NXC_USER **ppUserList, DWORD *pdwNumUsers);
0d9c1b96
VK
505DWORD LIBNXCL_EXPORTABLE NXCLockUserDB(void);
506DWORD LIBNXCL_EXPORTABLE NXCUnlockUserDB(void);
f75b99fd
VK
507DWORD LIBNXCL_EXPORTABLE NXCCreateUser(char *pszName, BOOL bIsGroup, DWORD *pdwNewId);
508DWORD LIBNXCL_EXPORTABLE NXCDeleteUser(DWORD dwId);
911dbb64 509DWORD LIBNXCL_EXPORTABLE NXCModifyUser(NXC_USER *pUserInfo);
8c18110a 510DWORD LIBNXCL_EXPORTABLE NXCSetPassword(DWORD dwUserId, char *pszNewPassword);
5ac3236b 511
7ec6cca8
VK
512DWORD LIBNXCL_EXPORTABLE NXCOpenNodeDCIList(DWORD dwNodeId, NXC_DCI_LIST **ppItemList);
513DWORD LIBNXCL_EXPORTABLE NXCCloseNodeDCIList(NXC_DCI_LIST *pItemList);
7ac0c0a8
VK
514DWORD LIBNXCL_EXPORTABLE NXCCreateNewDCI(NXC_DCI_LIST *pItemList, DWORD *pdwItemId);
515DWORD LIBNXCL_EXPORTABLE NXCUpdateDCI(DWORD dwNodeId, NXC_DCI *pItem);
516DWORD LIBNXCL_EXPORTABLE NXCDeleteDCI(NXC_DCI_LIST *pItemList, DWORD dwItemId);
517DWORD LIBNXCL_EXPORTABLE NXCItemIndex(NXC_DCI_LIST *pItemList, DWORD dwItemId);
b9b4ec17
VK
518DWORD LIBNXCL_EXPORTABLE NXCGetDCIData(DWORD dwNodeId, DWORD dwItemId, DWORD dwMaxRows,
519 DWORD dwTimeFrom, DWORD dwTimeTo, NXC_DCI_DATA **ppData);
4c20673b
VK
520void LIBNXCL_EXPORTABLE NXCDestroyDCIData(NXC_DCI_DATA *pData);
521NXC_DCI_ROW LIBNXCL_EXPORTABLE *NXCGetRowPtr(NXC_DCI_DATA *pData, DWORD dwRow);
7ec6cca8 522
80ffed5a
VK
523#ifdef __cplusplus
524}
525#endif
526
7ec6cca8
VK
527#endif /* LIBNXCL_NO_DECLARATIONS */
528
80ffed5a 529#endif /* _nxclapi_h_ */