Added NXCModifyEventTemplate() function
[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
133//
134// Custom data types
135//
136
137typedef unsigned long HREQUEST;
b601b1fa
VK
138
139
54481027 140//
0c8bf759 141// Callbacks data types
54481027
VK
142//
143
144typedef void (* NXC_EVENT_HANDLER)(DWORD dwEvent, DWORD dwCode, void *pArg);
5d63b3c1 145typedef void (* NXC_DEBUG_CALLBACK)(char *pMsg);
54481027
VK
146
147
878c92bc
VK
148//
149// Event configuration structure
150//
151
152typedef struct
153{
154 DWORD dwCode;
155 DWORD dwSeverity;
156 DWORD dwFlags;
157 char szName[MAX_EVENT_NAME];
158 char *pszMessage;
159 char *pszDescription;
160} NXC_EVENT_TEMPLATE;
161
162
a1dc75b0
VK
163//
164// Event log record structure
165//
166
167typedef struct
168{
169 DWORD dwTimeStamp;
170 DWORD dwEventId;
171 DWORD dwSourceId;
172 DWORD dwSeverity;
173 char szMessage[MAX_EVENT_MSG_LENGTH];
174} NXC_EVENT;
175
176
0c8bf759
VK
177//
178// Network object structure
179//
180
181typedef struct
182{
183 DWORD dwId; // Unique object's identifier
184 int iClass; // Object's class
185 int iStatus; // Object's status
186 DWORD dwIpAddr; // IP address
187 char szName[MAX_OBJECT_NAME];
188 DWORD dwNumParents;
189 DWORD *pdwParentList;
190 DWORD dwNumChilds;
191 DWORD *pdwChildList;
192 union
193 {
194 struct
195 {
196 DWORD dwIpNetMask; // Ip netmask.
197 DWORD dwIfIndex; // Interface index.
198 DWORD dwIfType; // Interface type
199 } iface;
200 struct
201 {
202 DWORD dwFlags;
203 DWORD dwDiscoveryFlags;
204 char szSharedSecret[MAX_SECRET_LENGTH];
205 char szCommunityString[MAX_COMMUNITY_LENGTH];
206 char szObjectId[MAX_OID_LENGTH];
207 WORD wAgentPort; // Listening TCP port for native agent
208 WORD wAuthMethod; // Native agent's authentication method
209 } node;
210 struct
211 {
212 DWORD dwIpNetMask;
213 } subnet;
214 };
215} NXC_OBJECT;
216
217
80ffed5a
VK
218//
219// Functions
220//
221
222#ifdef __cplusplus
223extern "C" {
224#endif
225
54481027
VK
226DWORD EXPORTABLE NXCGetVersion(void);
227BOOL EXPORTABLE NXCInitialize(void);
71f8d3d7 228BOOL EXPORTABLE NXCConnect(char *szServer, char *szLogin, char *szPassword);
54481027
VK
229void EXPORTABLE NXCDisconnect(void);
230void EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler);
5d63b3c1 231void EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc);
878c92bc 232HREQUEST EXPORTABLE NXCRequest(DWORD dwOperation, ...);
80ffed5a 233
8b3d61c1
VK
234NXC_OBJECT EXPORTABLE *NXCFindObjectById(DWORD dwId);
235void EXPORTABLE NXCEnumerateObjects(BOOL (* pHandler)(NXC_OBJECT *));
04a534d5 236NXC_OBJECT EXPORTABLE *NXCGetRootObject(void);
8b3d61c1 237
878c92bc
VK
238BOOL EXPORTABLE NXCGetEventDB(NXC_EVENT_TEMPLATE ***pppTemplateList, DWORD *pdwNumRecords);
239
80ffed5a
VK
240#ifdef __cplusplus
241}
242#endif
243
244
7e986059 245//
bc97ab99 246// Inline functions
7e986059
VK
247//
248
bc97ab99
VK
249#ifdef __cplusplus
250
251#ifndef __libnxcl_inline_c__
252inline DWORD NXCSyncObjects(void) { return NXCRequest(NXC_OP_SYNC_OBJECTS); }
253inline DWORD NXCSyncEvents(void) { return NXCRequest(NXC_OP_SYNC_EVENTS); }
254inline DWORD NXCOpenEventDB(void) { return NXCRequest(NXC_OP_OPEN_EVENT_DB); }
255inline DWORD NXCCloseEventDB(BOOL bSaveChanges) { return NXCRequest(NXC_OP_CLOSE_EVENT_DB, bSaveChanges); }
256#endif /* __libnxcl_inline_c__ */
257
258#else /* __cplusplus */
259
260DWORD EXPORTABLE NXCSyncObjects(void);
261DWORD EXPORTABLE NXCSyncEvents(void);
262DWORD EXPORTABLE NXCOpenEventDB(void);
263DWORD EXPORTABLE NXCCloseEventDB(BOOL bSaveChanges);
7e986059 264
bc97ab99 265#endif /* __cplusplus */
7e986059 266
80ffed5a 267#endif /* _nxclapi_h_ */