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