Added sending node's DCIs to client
[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
8c18110a
VK
60#define GROUP_FLAG ((DWORD)0x80000000)
61#define GROUP_EVERYONE ((DWORD)0x80000000)
62#define INVALID_UID ((DWORD)0xFFFFFFFF)
0c8bf759
VK
63
64
71c18491
VK
65//
66// Authentication methods
67//
68
69#define AUTH_NONE 0
70#define AUTH_PLAINTEXT 1
71#define AUTH_MD5_HASH 2
72#define AUTH_SHA1_HASH 3
73
74
75//
76// Object types
77//
78
79#define OBJECT_GENERIC 0
80#define OBJECT_SUBNET 1
81#define OBJECT_NODE 2
82#define OBJECT_INTERFACE 3
83#define OBJECT_NETWORK 4
372b525a
VK
84#define OBJECT_LOCATION 5
85#define OBJECT_ZONE 6
71c18491
VK
86
87
4d597931
VK
88//
89// Node flags
90//
91
92#define NF_IS_SNMP 0x0001
93#define NF_IS_NATIVE_AGENT 0x0002
94#define NF_IS_BRIDGE 0x0004
95#define NF_IS_ROUTER 0x0008
96#define NF_IS_LOCAL_MGMT 0x0010
97
98
5fad5c32
VK
99//
100// Events
101//
102
878c92bc
VK
103#define NXC_EVENT_STATE_CHANGED 1
104#define NXC_EVENT_ERROR 2
105#define NXC_EVENT_LOGIN_RESULT 3
106#define NXC_EVENT_NEW_ELOG_RECORD 4
f75b99fd 107#define NXC_EVENT_USER_DB_CHANGED 5
4d597931 108#define NXC_EVENT_OBJECT_CHANGED 6
71f8d3d7
VK
109
110
111//
112// Errors
113//
114
115#define NXC_ERR_INTERNAL 1
5fad5c32
VK
116
117
54481027
VK
118//
119// States
120//
121
122#define STATE_DISCONNECTED 0
123#define STATE_CONNECTING 1
124#define STATE_IDLE 2
7e986059
VK
125#define STATE_SYNC_OBJECTS 3
126#define STATE_SYNC_EVENTS 4
878c92bc
VK
127#define STATE_LOAD_EVENT_DB 5
128#define STATE_LOAD_EPP 6
5ac3236b 129#define STATE_LOAD_USER_DB 7
7e986059
VK
130
131
b601b1fa
VK
132//
133// Notification codes
134//
135
878c92bc
VK
136#define NX_NOTIFY_SHUTDOWN 1
137
138
139//
140// Request completion codes
141//
142
143#define RCC_SUCCESS ((DWORD)0)
144#define RCC_COMPONENT_LOCKED ((DWORD)1)
145#define RCC_ACCESS_DENIED ((DWORD)2)
146#define RCC_INVALID_REQUEST ((DWORD)3)
147#define RCC_TIMEOUT ((DWORD)4)
605d2931
VK
148#define RCC_OUT_OF_STATE_REQUEST ((DWORD)5)
149#define RCC_DB_FAILURE ((DWORD)6)
effb51ab 150#define RCC_INVALID_OBJECT_ID ((DWORD)7)
34d95c13 151#define RCC_ALREADY_EXIST ((DWORD)8)
2e29457d 152#define RCC_COMM_FAILURE ((DWORD)9)
0d9c1b96 153#define RCC_SYSTEM_FAILURE ((DWORD)10)
62f3f072 154#define RCC_INVALID_USER_ID ((DWORD)11)
878c92bc
VK
155
156
d9152256
VK
157//
158// Mask bits for NXCModifyEventTemplate()
159//
160
161#define EM_SEVERITY ((DWORD)0x01)
162#define EM_FLAGS ((DWORD)0x02)
163#define EM_NAME ((DWORD)0x04)
164#define EM_MESSAGE ((DWORD)0x08)
165#define EM_DESCRIPTION ((DWORD)0x10)
166#define EM_ALL ((DWORD)0x1F)
167
168
effb51ab
VK
169//
170// Mask bits (flags) for NXCModifyObject()
171//
172
173#define OBJ_UPDATE_NAME ((DWORD)0x01)
174#define OBJ_UPDATE_AGENT_PORT ((DWORD)0x02)
175#define OBJ_UPDATE_AGENT_AUTH ((DWORD)0x04)
176#define OBJ_UPDATE_AGENT_SECRET ((DWORD)0x08)
177#define OBJ_UPDATE_SNMP_VERSION ((DWORD)0x10)
178#define OBJ_UPDATE_SNMP_COMMUNITY ((DWORD)0x20)
179#define OBJ_UPDATE_ACL ((DWORD)0x40)
180#define OBJ_UPDATE_ALL ((DWORD)0x7F)
181
182
5ac3236b
VK
183//
184// Global user rights
185//
186
187#define SYSTEM_ACCESS_MANAGE_USERS 0x0001
188#define SYSTEM_ACCESS_VIEW_CONFIG 0x0002
189#define SYSTEM_ACCESS_EDIT_CONFIG 0x0004
190#define SYSTEM_ACCESS_DROP_CONNECTIONS 0x0008
191#define SYSTEM_ACCESS_VIEW_EVENT_DB 0x0010
192#define SYSTEM_ACCESS_EDIT_EVENT_DB 0x0020
193
911dbb64
VK
194#define SYSTEM_ACCESS_FULL 0x003F
195
5ac3236b
VK
196
197//
198// Object access rights
199//
200
201#define OBJECT_ACCESS_READ 0x00000001
202#define OBJECT_ACCESS_MODIFY 0x00000002
203#define OBJECT_ACCESS_CREATE 0x00000004
204#define OBJECT_ACCESS_DELETE 0x00000008
205#define OBJECT_ACCESS_MOVE 0x00000010
34d95c13 206#define OBJECT_ACCESS_CONTROL 0x00000020
5ac3236b
VK
207
208
209//
210// User/group flags
211//
212
213#define UF_MODIFIED 0x0001
214#define UF_DELETED 0x0002
215#define UF_DISABLED 0x0004
216#define UF_CHANGE_PASSWORD 0x0008
8c18110a 217#define UF_CANNOT_CHANGE_PASSWORD 0x0010
5ac3236b
VK
218
219
984542f8
VK
220//
221// User database change notification types
222//
223
224#define USER_DB_CREATE 0
225#define USER_DB_DELETE 1
226#define USER_DB_MODIFY 2
227
228
878c92bc
VK
229//
230// Custom data types
231//
232
233typedef unsigned long HREQUEST;
b601b1fa
VK
234
235
54481027 236//
0c8bf759 237// Callbacks data types
54481027
VK
238//
239
240typedef void (* NXC_EVENT_HANDLER)(DWORD dwEvent, DWORD dwCode, void *pArg);
5d63b3c1 241typedef void (* NXC_DEBUG_CALLBACK)(char *pMsg);
54481027
VK
242
243
878c92bc
VK
244//
245// Event configuration structure
246//
247
248typedef struct
249{
250 DWORD dwCode;
251 DWORD dwSeverity;
252 DWORD dwFlags;
253 char szName[MAX_EVENT_NAME];
254 char *pszMessage;
255 char *pszDescription;
256} NXC_EVENT_TEMPLATE;
257
258
a1dc75b0
VK
259//
260// Event log record structure
261//
262
263typedef struct
264{
265 DWORD dwTimeStamp;
266 DWORD dwEventId;
267 DWORD dwSourceId;
268 DWORD dwSeverity;
269 char szMessage[MAX_EVENT_MSG_LENGTH];
270} NXC_EVENT;
271
272
effb51ab
VK
273//
274// Entry in object's ACL
275//
276
277typedef struct
278{
279 DWORD dwUserId;
280 DWORD dwAccessRights;
281} NXC_ACL_ENTRY;
282
283
0c8bf759
VK
284//
285// Network object structure
286//
287
288typedef struct
289{
290 DWORD dwId; // Unique object's identifier
291 int iClass; // Object's class
292 int iStatus; // Object's status
293 DWORD dwIpAddr; // IP address
294 char szName[MAX_OBJECT_NAME];
295 DWORD dwNumParents;
296 DWORD *pdwParentList;
297 DWORD dwNumChilds;
298 DWORD *pdwChildList;
4d597931 299 BOOL bIsDeleted; // TRUE for deleted objects
effb51ab
VK
300 BOOL bInheritRights;
301 DWORD dwAclSize;
302 NXC_ACL_ENTRY *pAccessList;
0c8bf759
VK
303 union
304 {
305 struct
306 {
307 DWORD dwIpNetMask; // Ip netmask.
308 DWORD dwIfIndex; // Interface index.
309 DWORD dwIfType; // Interface type
310 } iface;
311 struct
312 {
313 DWORD dwFlags;
314 DWORD dwDiscoveryFlags;
315 char szSharedSecret[MAX_SECRET_LENGTH];
316 char szCommunityString[MAX_COMMUNITY_LENGTH];
317 char szObjectId[MAX_OID_LENGTH];
318 WORD wAgentPort; // Listening TCP port for native agent
319 WORD wAuthMethod; // Native agent's authentication method
320 } node;
321 struct
322 {
323 DWORD dwIpNetMask;
324 } subnet;
325 };
326} NXC_OBJECT;
327
328
effb51ab
VK
329//
330// Structure with data for NXCModifyObject
331//
332
333typedef struct
334{
335 DWORD dwObjectId;
336 DWORD dwFlags;
337 char *pszName;
338 int iAgentPort;
339 int iAuthType;
340 char *pszSecret;
341 int iSnmpVersion;
342 char *pszCommunity;
343 BOOL bInheritRights;
344 DWORD dwAclSize;
345 NXC_ACL_ENTRY *pAccessList;
346} NXC_OBJECT_UPDATE;
347
348
5ac3236b
VK
349//
350// NetXMS user information structure
351//
352
353typedef struct
354{
355 char szName[MAX_USER_NAME];
356 DWORD dwId;
357 WORD wFlags;
358 WORD wSystemRights;
359 DWORD dwNumMembers; // Only for groups
360 DWORD *pdwMemberList; // Only for groups
54abbe0e
VK
361 char szFullName[MAX_USER_FULLNAME]; // Only for users
362 char szDescription[MAX_USER_DESCR];
5ac3236b
VK
363} NXC_USER;
364
365
80ffed5a
VK
366//
367// Functions
368//
369
370#ifdef __cplusplus
371extern "C" {
372#endif
373
8aeffdee 374DWORD LIBNXCL_EXPORTABLE NXCGetVersion(void);
effb51ab
VK
375const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError);
376
8aeffdee 377BOOL LIBNXCL_EXPORTABLE NXCInitialize(void);
1df4b30b 378DWORD LIBNXCL_EXPORTABLE NXCConnect(char *szServer, char *szLogin, char *szPassword);
8aeffdee
VK
379void LIBNXCL_EXPORTABLE NXCDisconnect(void);
380void LIBNXCL_EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler);
381void LIBNXCL_EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc);
382HREQUEST LIBNXCL_EXPORTABLE NXCRequest(DWORD dwOperation, ...);
80ffed5a 383
2e29457d 384DWORD LIBNXCL_EXPORTABLE NXCSyncObjects(void);
8aeffdee 385NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectById(DWORD dwId);
a98e6d5f 386NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectByName(char *pszName);
8aeffdee
VK
387void LIBNXCL_EXPORTABLE NXCEnumerateObjects(BOOL (* pHandler)(NXC_OBJECT *));
388NXC_OBJECT LIBNXCL_EXPORTABLE *NXCGetRootObject(void);
8e80aeb6
VK
389void LIBNXCL_EXPORTABLE *NXCGetObjectIndex(DWORD *pdwNumObjects);
390void LIBNXCL_EXPORTABLE NXCLockObjectIndex(void);
391void LIBNXCL_EXPORTABLE NXCUnlockObjectIndex(void);
2e29457d 392DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_OBJECT_UPDATE *pData);
8b3d61c1 393
2e29457d
VK
394DWORD LIBNXCL_EXPORTABLE NXCSyncEvents(void);
395DWORD LIBNXCL_EXPORTABLE NXCOpenEventDB(void);
396DWORD LIBNXCL_EXPORTABLE NXCCloseEventDB(BOOL bSaveChanges);
8aeffdee
VK
397BOOL LIBNXCL_EXPORTABLE NXCGetEventDB(NXC_EVENT_TEMPLATE ***pppTemplateList, DWORD *pdwNumRecords);
398void LIBNXCL_EXPORTABLE NXCModifyEventTemplate(NXC_EVENT_TEMPLATE *pEvent, DWORD dwMask,
d9152256
VK
399 DWORD dwSeverity, DWORD dwFlags, const char *pszName,
400 const char *pszMessage, const char *pszDescription);
878c92bc 401
2e29457d 402DWORD LIBNXCL_EXPORTABLE NXCLoadUserDB(void);
5ac3236b 403NXC_USER LIBNXCL_EXPORTABLE *NXCFindUserById(DWORD dwId);
440716ce 404BOOL LIBNXCL_EXPORTABLE NXCGetUserDB(NXC_USER **ppUserList, DWORD *pdwNumUsers);
0d9c1b96
VK
405DWORD LIBNXCL_EXPORTABLE NXCLockUserDB(void);
406DWORD LIBNXCL_EXPORTABLE NXCUnlockUserDB(void);
f75b99fd
VK
407DWORD LIBNXCL_EXPORTABLE NXCCreateUser(char *pszName, BOOL bIsGroup, DWORD *pdwNewId);
408DWORD LIBNXCL_EXPORTABLE NXCDeleteUser(DWORD dwId);
911dbb64 409DWORD LIBNXCL_EXPORTABLE NXCModifyUser(NXC_USER *pUserInfo);
8c18110a 410DWORD LIBNXCL_EXPORTABLE NXCSetPassword(DWORD dwUserId, char *pszNewPassword);
5ac3236b 411
80ffed5a
VK
412#ifdef __cplusplus
413}
414#endif
415
80ffed5a 416#endif /* _nxclapi_h_ */