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