- Object browser improved
[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
57#define INVALID_REQUEST_HANDLE ((HREQUEST)0xFFFFFFFF)
0c8bf759
VK
58
59
71c18491
VK
60//
61// Authentication methods
62//
63
64#define AUTH_NONE 0
65#define AUTH_PLAINTEXT 1
66#define AUTH_MD5_HASH 2
67#define AUTH_SHA1_HASH 3
68
69
70//
71// Object types
72//
73
74#define OBJECT_GENERIC 0
75#define OBJECT_SUBNET 1
76#define OBJECT_NODE 2
77#define OBJECT_INTERFACE 3
78#define OBJECT_NETWORK 4
372b525a
VK
79#define OBJECT_LOCATION 5
80#define OBJECT_ZONE 6
71c18491
VK
81
82
5fad5c32
VK
83//
84// Events
85//
86
878c92bc
VK
87#define NXC_EVENT_STATE_CHANGED 1
88#define NXC_EVENT_ERROR 2
89#define NXC_EVENT_LOGIN_RESULT 3
90#define NXC_EVENT_NEW_ELOG_RECORD 4
91#define NXC_EVENT_REQUEST_COMPLETED 5
71f8d3d7
VK
92
93
94//
95// Errors
96//
97
98#define NXC_ERR_INTERNAL 1
5fad5c32
VK
99
100
54481027
VK
101//
102// States
103//
104
105#define STATE_DISCONNECTED 0
106#define STATE_CONNECTING 1
107#define STATE_IDLE 2
7e986059
VK
108#define STATE_SYNC_OBJECTS 3
109#define STATE_SYNC_EVENTS 4
878c92bc
VK
110#define STATE_LOAD_EVENT_DB 5
111#define STATE_LOAD_EPP 6
7e986059
VK
112
113
114//
115// Operations
116//
117
878c92bc
VK
118#define NXC_OP_SYNC_OBJECTS 1
119#define NXC_OP_SYNC_EVENTS 2
120#define NXC_OP_OPEN_EVENT_DB 3
121#define NXC_OP_CLOSE_EVENT_DB 4
31521248 122#define NXC_OP_SET_EVENT_INFO 5
54481027
VK
123
124
b601b1fa
VK
125//
126// Notification codes
127//
128
878c92bc
VK
129#define NX_NOTIFY_SHUTDOWN 1
130
131
132//
133// Request completion codes
134//
135
136#define RCC_SUCCESS ((DWORD)0)
137#define RCC_COMPONENT_LOCKED ((DWORD)1)
138#define RCC_ACCESS_DENIED ((DWORD)2)
139#define RCC_INVALID_REQUEST ((DWORD)3)
140#define RCC_TIMEOUT ((DWORD)4)
605d2931
VK
141#define RCC_OUT_OF_STATE_REQUEST ((DWORD)5)
142#define RCC_DB_FAILURE ((DWORD)6)
878c92bc
VK
143
144
d9152256
VK
145//
146// Mask bits for NXCModifyEventTemplate()
147//
148
149#define EM_SEVERITY ((DWORD)0x01)
150#define EM_FLAGS ((DWORD)0x02)
151#define EM_NAME ((DWORD)0x04)
152#define EM_MESSAGE ((DWORD)0x08)
153#define EM_DESCRIPTION ((DWORD)0x10)
154#define EM_ALL ((DWORD)0x1F)
155
156
878c92bc
VK
157//
158// Custom data types
159//
160
161typedef unsigned long HREQUEST;
b601b1fa
VK
162
163
54481027 164//
0c8bf759 165// Callbacks data types
54481027
VK
166//
167
168typedef void (* NXC_EVENT_HANDLER)(DWORD dwEvent, DWORD dwCode, void *pArg);
5d63b3c1 169typedef void (* NXC_DEBUG_CALLBACK)(char *pMsg);
54481027
VK
170
171
878c92bc
VK
172//
173// Event configuration structure
174//
175
176typedef struct
177{
178 DWORD dwCode;
179 DWORD dwSeverity;
180 DWORD dwFlags;
181 char szName[MAX_EVENT_NAME];
182 char *pszMessage;
183 char *pszDescription;
184} NXC_EVENT_TEMPLATE;
185
186
a1dc75b0
VK
187//
188// Event log record structure
189//
190
191typedef struct
192{
193 DWORD dwTimeStamp;
194 DWORD dwEventId;
195 DWORD dwSourceId;
196 DWORD dwSeverity;
197 char szMessage[MAX_EVENT_MSG_LENGTH];
198} NXC_EVENT;
199
200
0c8bf759
VK
201//
202// Network object structure
203//
204
205typedef struct
206{
207 DWORD dwId; // Unique object's identifier
208 int iClass; // Object's class
209 int iStatus; // Object's status
210 DWORD dwIpAddr; // IP address
211 char szName[MAX_OBJECT_NAME];
212 DWORD dwNumParents;
213 DWORD *pdwParentList;
214 DWORD dwNumChilds;
215 DWORD *pdwChildList;
216 union
217 {
218 struct
219 {
220 DWORD dwIpNetMask; // Ip netmask.
221 DWORD dwIfIndex; // Interface index.
222 DWORD dwIfType; // Interface type
223 } iface;
224 struct
225 {
226 DWORD dwFlags;
227 DWORD dwDiscoveryFlags;
228 char szSharedSecret[MAX_SECRET_LENGTH];
229 char szCommunityString[MAX_COMMUNITY_LENGTH];
230 char szObjectId[MAX_OID_LENGTH];
231 WORD wAgentPort; // Listening TCP port for native agent
232 WORD wAuthMethod; // Native agent's authentication method
233 } node;
234 struct
235 {
236 DWORD dwIpNetMask;
237 } subnet;
238 };
239} NXC_OBJECT;
240
241
80ffed5a
VK
242//
243// Functions
244//
245
246#ifdef __cplusplus
247extern "C" {
248#endif
249
8aeffdee
VK
250DWORD LIBNXCL_EXPORTABLE NXCGetVersion(void);
251BOOL LIBNXCL_EXPORTABLE NXCInitialize(void);
252BOOL LIBNXCL_EXPORTABLE NXCConnect(char *szServer, char *szLogin, char *szPassword);
253void LIBNXCL_EXPORTABLE NXCDisconnect(void);
254void LIBNXCL_EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler);
255void LIBNXCL_EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc);
256HREQUEST LIBNXCL_EXPORTABLE NXCRequest(DWORD dwOperation, ...);
80ffed5a 257
8aeffdee
VK
258NXC_OBJECT LIBNXCL_EXPORTABLE *NXCFindObjectById(DWORD dwId);
259void LIBNXCL_EXPORTABLE NXCEnumerateObjects(BOOL (* pHandler)(NXC_OBJECT *));
260NXC_OBJECT LIBNXCL_EXPORTABLE *NXCGetRootObject(void);
8b3d61c1 261
8aeffdee
VK
262BOOL LIBNXCL_EXPORTABLE NXCGetEventDB(NXC_EVENT_TEMPLATE ***pppTemplateList, DWORD *pdwNumRecords);
263void LIBNXCL_EXPORTABLE NXCModifyEventTemplate(NXC_EVENT_TEMPLATE *pEvent, DWORD dwMask,
d9152256
VK
264 DWORD dwSeverity, DWORD dwFlags, const char *pszName,
265 const char *pszMessage, const char *pszDescription);
878c92bc 266
80ffed5a
VK
267#ifdef __cplusplus
268}
269#endif
270
271
7e986059 272//
bc97ab99 273// Inline functions
7e986059
VK
274//
275
bc97ab99
VK
276#ifdef __cplusplus
277
278#ifndef __libnxcl_inline_c__
279inline DWORD NXCSyncObjects(void) { return NXCRequest(NXC_OP_SYNC_OBJECTS); }
280inline DWORD NXCSyncEvents(void) { return NXCRequest(NXC_OP_SYNC_EVENTS); }
281inline DWORD NXCOpenEventDB(void) { return NXCRequest(NXC_OP_OPEN_EVENT_DB); }
282inline DWORD NXCCloseEventDB(BOOL bSaveChanges) { return NXCRequest(NXC_OP_CLOSE_EVENT_DB, bSaveChanges); }
283#endif /* __libnxcl_inline_c__ */
284
285#else /* __cplusplus */
286
8aeffdee
VK
287DWORD LIBNXCL_EXPORTABLE NXCSyncObjects(void);
288DWORD LIBNXCL_EXPORTABLE NXCSyncEvents(void);
289DWORD LIBNXCL_EXPORTABLE NXCOpenEventDB(void);
290DWORD LIBNXCL_EXPORTABLE NXCCloseEventDB(BOOL bSaveChanges);
7e986059 291
bc97ab99 292#endif /* __cplusplus */
7e986059 293
80ffed5a 294#endif /* _nxclapi_h_ */