new NXSL functions: AgentReadParameter, ManageObject, UnmanageObject
[public/netxms.git] / src / server / include / nxsrvapi.h
CommitLineData
5039dede
AK
1/*
2** NetXMS - Network Management System
3** Server Library
619e5c9b 4** Copyright (C) 2003-2011 Victor Kirhenshtein
5039dede
AK
5**
6** This program is free software; you can redistribute it and/or modify
0702ed69
VK
7** it under the terms of the GNU Lesser General Public License as published by
8** the Free Software Foundation; either version 3 of the License, or
5039dede
AK
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**
0702ed69 16** You should have received a copy of the GNU Lesser General Public License
5039dede
AK
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19**
20** File: nxsrvapi.h
21**
22**/
23
24#ifndef _nxsrvapi_h_
25#define _nxsrvapi_h_
26
27#ifdef _WIN32
28#ifdef LIBNXSRV_EXPORTS
29#define LIBNXSRV_EXPORTABLE __declspec(dllexport)
30#else
31#define LIBNXSRV_EXPORTABLE __declspec(dllimport)
32#endif
33#else /* _WIN32 */
34#define LIBNXSRV_EXPORTABLE
35#endif
36
37#ifndef LIBNXCL_NO_DECLARATIONS
38#define LIBNXCL_NO_DECLARATIONS 1
39#endif
40#include <nxclapi.h>
41#include <nxcpapi.h>
42#include <nms_agent.h>
944016d6 43#include "../libnxsrv/messages.h"
5039dede
AK
44#include <nxsnmp.h>
45#include <netxms_isc.h>
46
f375019e
VK
47/**
48 * Default files
49 */
5039dede
AK
50#ifdef _WIN32
51
9796ce45
VK
52#define DEFAULT_CONFIG_FILE _T("C:\\netxmsd.conf")
53
54#define DEFAULT_SHELL _T("cmd.exe")
55#define DEFAULT_LOG_FILE _T("C:\\NetXMS.log")
56#define DEFAULT_DATA_DIR _T("C:\\NetXMS\\var")
57#define DEFAULT_LIBDIR _T("C:\\NetXMS\\lib")
712dd47d 58#define DEFAULT_JAVA_LIBDIR _T("C:\\NetXMS\\lib\\java")
9796ce45
VK
59#define DEFAULT_DUMP_DIR _T("C:\\")
60
61#define LDIR_NDD _T("\\ndd")
62
63#define DDIR_MIBS _T("\\mibs")
64#define DDIR_PACKAGES _T("\\packages")
65#define DDIR_BACKGROUNDS _T("\\backgrounds")
66#define DDIR_SHARED_FILES _T("\\shared")
67#define DFILE_KEYS _T("\\server_key")
68#define DFILE_COMPILED_MIB _T("\\mibs\\netxms.mib")
69#define DDIR_IMAGES _T("\\images")
70#define DDIR_FILES _T("\\files")
e77e56ca 71#define DDIR_REPORTS _T("\\reports")
5039dede
AK
72
73#else /* _WIN32 */
74
9796ce45 75#define DEFAULT_CONFIG_FILE _T("{search}")
5039dede 76
9796ce45 77#define DEFAULT_SHELL _T("/bin/sh")
5039dede 78
9796ce45
VK
79#ifndef DATADIR
80#define DATADIR _T("/var/netxms")
81#endif
5039dede 82
9796ce45
VK
83#ifndef LIBDIR
84#define LIBDIR _T("/usr/lib")
85#endif
5039dede 86
644f97f5
VK
87#ifndef PKGLIBDIR
88#define PKGLIBDIR _T("/usr/lib/netxms")
89#endif
90
9796ce45
VK
91#define DEFAULT_LOG_FILE DATADIR _T("/log/netxmsd.log")
92#define DEFAULT_DATA_DIR DATADIR
644f97f5 93#define DEFAULT_LIBDIR PKGLIBDIR
712dd47d 94#define DEFAULT_JAVA_LIBDIR PKGLIBDIR _T("/java")
9796ce45
VK
95#define DEFAULT_DUMP_DIR _T("/")
96
97#define LDIR_NDD _T("/ndd")
98
99#define DDIR_MIBS _T("/mibs")
100#define DDIR_PACKAGES _T("/packages")
101#define DDIR_BACKGROUNDS _T("/backgrounds")
102#define DDIR_SHARED_FILES _T("/shared")
103#define DFILE_KEYS _T("/.server_key")
104#define DFILE_COMPILED_MIB _T("/mibs/netxms.mib")
105#define DDIR_IMAGES _T("/images")
106#define DDIR_FILES _T("/files")
e77e56ca 107#define DDIR_REPORTS _T("/reports")
5039dede
AK
108
109#endif /* _WIN32 */
110
f375019e
VK
111/**
112 * Application flags
113 */
5039dede
AK
114#define AF_DAEMON 0x00000001
115#define AF_USE_SYSLOG 0x00000002
116#define AF_ENABLE_NETWORK_DISCOVERY 0x00000004
117#define AF_ACTIVE_NETWORK_DISCOVERY 0x00000008
118#define AF_LOG_SQL_ERRORS 0x00000010
119#define AF_DELETE_EMPTY_SUBNETS 0x00000020
120#define AF_ENABLE_SNMP_TRAPD 0x00000040
121#define AF_ENABLE_ZONING 0x00000080
122#define AF_SYNC_NODE_NAMES_WITH_DNS 0x00000100
123#define AF_CHECK_TRUSTED_NODES 0x00000200
3bbc7435 124#define AF_ENABLE_NXSL_CONTAINER_FUNCS 0x00000400
a203ea53 125#define AF_USE_FQDN_FOR_NODE_NAMES 0x00000800
dc4a1aec 126#define AF_APPLY_TO_DISABLED_DCI_FROM_TEMPLATE 0x00001000
cbc777ee 127#define AF_WRITE_FULL_DUMP 0x00080000
5039dede
AK
128#define AF_RESOLVE_NODE_NAMES 0x00100000
129#define AF_CATCH_EXCEPTIONS 0x00200000
130#define AF_INTERNAL_CA 0x00400000
131#define AF_DB_LOCKED 0x01000000
132#define AF_ENABLE_MULTIPLE_DB_CONN 0x02000000
133#define AF_DB_CONNECTION_LOST 0x04000000
134#define AF_NO_NETWORK_CONNECTIVITY 0x08000000
b98bccbd 135#define AF_EVENT_STORM_DETECTED 0x10000000
5039dede
AK
136#define AF_SERVER_INITIALIZED 0x40000000
137#define AF_SHUTDOWN 0x80000000
138
f375019e
VK
139/**
140 * Encryption usage policies
141 */
5039dede
AK
142#define ENCRYPTION_DISABLED 0
143#define ENCRYPTION_ALLOWED 1
144#define ENCRYPTION_PREFERRED 2
145#define ENCRYPTION_REQUIRED 3
146
f375019e
VK
147/**
148 * Flags for SnmpGet
149 */
5ad2167d
VK
150#define SG_VERBOSE 0x0001
151#define SG_STRING_RESULT 0x0002
152#define SG_RAW_RESULT 0x0004
153#define SG_HSTRING_RESULT 0x0008
4f131f2f 154#define SG_PSTRING_RESULT 0x0010
5ad2167d 155
f375019e
VK
156/**
157 * Win32 service and syslog constants
158 */
5039dede
AK
159#ifdef _WIN32
160
161#define CORE_SERVICE_NAME _T("NetXMSCore")
162#define CORE_EVENT_SOURCE _T("NetXMSCore")
163#define NETXMSD_SYSLOG_NAME CORE_EVENT_SOURCE
164
165#else
166
167#define NETXMSD_SYSLOG_NAME _T("netxmsd")
168
169#endif /* _WIN32 */
170
f375019e
VK
171/**
172 * Single ARP cache entry
173 */
5039dede
AK
174typedef struct
175{
176 DWORD dwIndex; // Interface index
177 DWORD dwIpAddr;
178 BYTE bMacAddr[MAC_ADDR_LENGTH];
179} ARP_ENTRY;
180
f375019e
VK
181/**
182 * ARP cache structure used by discovery functions and AgentConnection class
183 */
5039dede
AK
184typedef struct
185{
186 DWORD dwNumEntries;
187 ARP_ENTRY *pEntries;
188} ARP_CACHE;
189
f375019e
VK
190/**
191 * Interface information structure used by discovery functions and AgentConnection class
192 */
5039dede
AK
193typedef struct
194{
478d4ff4
VK
195 TCHAR szName[MAX_DB_STRING]; // Interface display name
196 TCHAR szDescription[MAX_DB_STRING]; // Value of ifDescr MIB variable for SNMP agents
5039dede
AK
197 DWORD dwIndex;
198 DWORD dwType;
eec253a8
VK
199 DWORD dwBridgePortNumber;
200 DWORD dwSlotNumber;
201 DWORD dwPortNumber;
5039dede
AK
202 DWORD dwIpAddr;
203 DWORD dwIpNetMask;
204 BYTE bMacAddr[MAC_ADDR_LENGTH];
205 int iNumSecondary; // Number of secondary IP's on this interface
4c16cdc7 206 bool isPhysicalPort;
36e44abe 207} NX_INTERFACE_INFO;
5039dede 208
f375019e
VK
209/**
210 * Interface list used by discovery functions and AgentConnection class
211 */
98762401 212class LIBNXSRV_EXPORTABLE InterfaceList
5039dede 213{
98762401
VK
214private:
215 int m_size; // Number of valid entries
216 int m_allocated; // Number of allocated entries
217 void *m_data; // Can be used by custom enumeration handlers
36e44abe 218 NX_INTERFACE_INFO *m_interfaces; // Interface entries
98762401
VK
219
220public:
221 InterfaceList(int initialAlloc = 8);
222 ~InterfaceList();
223
36e44abe 224 void add(NX_INTERFACE_INFO *iface);
98762401 225 void remove(int index);
98762401
VK
226
227 int getSize() { return m_size; }
36e44abe 228 NX_INTERFACE_INFO *get(int index) { return ((index >= 0) && (index < m_size)) ? &m_interfaces[index] : NULL; }
b1bd1fb2 229 NX_INTERFACE_INFO *findByIfIndex(DWORD ifIndex);
98762401
VK
230
231 void setData(void *data) { m_data = data; }
232 void *getData() { return m_data; }
233};
5039dede 234
f375019e
VK
235/**
236 * Vlan information
237 */
0208aa8c
VK
238#define VLAN_PRM_IFINDEX 0
239#define VLAN_PRM_SLOTPORT 1
5eb3a790 240#define VLAN_PRM_BPORT 2
0208aa8c 241
77c7801c
VK
242class LIBNXSRV_EXPORTABLE VlanInfo
243{
244private:
245 int m_vlanId;
246 TCHAR *m_name;
0208aa8c 247 int m_portRefMode; // Port reference mode - by ifIndex or by slot/port
77c7801c
VK
248 int m_allocated;
249 int m_numPorts; // Number of ports in VLAN
0208aa8c 250 DWORD *m_ports; // member ports (slot/port pairs or ifIndex)
b1bd1fb2
VK
251 DWORD *m_indexes; // ifIndexes for ports
252 DWORD *m_ids; // Interface object IDs for ports
77c7801c
VK
253
254public:
0208aa8c 255 VlanInfo(int vlanId, int prm);
77c7801c
VK
256 ~VlanInfo();
257
258 int getVlanId() { return m_vlanId; }
0208aa8c 259 int getPortReferenceMode() { return m_portRefMode; }
77c7801c
VK
260 const TCHAR *getName() { return CHECK_NULL_EX(m_name); }
261 int getNumPorts() { return m_numPorts; }
262 DWORD *getPorts() { return m_ports; }
b1bd1fb2
VK
263 DWORD *getIfIndexes() { return m_indexes; }
264 DWORD *getIfIds() { return m_ids; }
77c7801c
VK
265
266 void add(DWORD slot, DWORD port);
0208aa8c 267 void add(DWORD ifIndex);
77c7801c 268 void setName(const TCHAR *name);
b1bd1fb2
VK
269
270 void prepareForResolve();
271 void resolvePort(int index, DWORD sp, DWORD ifIndex, DWORD id);
77c7801c
VK
272};
273
a3050773
VK
274/**
275 * Vlan list
276 */
7f632dfe 277class LIBNXSRV_EXPORTABLE VlanList : public RefCountObject
77c7801c
VK
278{
279private:
280 int m_size; // Number of valid entries
281 int m_allocated; // Number of allocated entries
282 void *m_data; // Can be used by custom enumeration handlers
283 VlanInfo **m_vlans; // VLAN entries
284
285public:
286 VlanList(int initialAlloc = 8);
7f632dfe 287 virtual ~VlanList();
77c7801c
VK
288
289 void add(VlanInfo *vlan);
0208aa8c 290 void addMemberPort(int vlanId, DWORD portId);
77c7801c
VK
291
292 int getSize() { return m_size; }
293 VlanInfo *get(int index) { return ((index >= 0) && (index < m_size)) ? m_vlans[index] : NULL; }
0208aa8c 294 VlanInfo *findById(int id);
77c7801c
VK
295
296 void setData(void *data) { m_data = data; }
297 void *getData() { return m_data; }
7f632dfe
VK
298
299 void fillMessage(CSCPMessage *msg);
77c7801c
VK
300};
301
a3050773
VK
302/**
303 * Route information
304 */
5039dede
AK
305typedef struct
306{
307 DWORD dwDestAddr;
308 DWORD dwDestMask;
309 DWORD dwNextHop;
310 DWORD dwIfIndex;
311 DWORD dwRouteType;
312} ROUTE;
313
a3050773
VK
314/**
315 * Routing table
316 */
5039dede
AK
317typedef struct
318{
319 int iNumEntries; // Number of entries
320 ROUTE *pRoutes; // Route list
321} ROUTING_TABLE;
322
a3050773
VK
323/**
324 * Information about policies installed on agent
325 */
1f385e47
VK
326class LIBNXSRV_EXPORTABLE AgentPolicyInfo
327{
328private:
329 int m_size;
330 BYTE *m_guidList;
331 int *m_typeList;
332 TCHAR **m_serverList;
333
334public:
335 AgentPolicyInfo(CSCPMessage *msg);
336 ~AgentPolicyInfo();
337
338 int getSize() { return m_size; }
339 bool getGuid(int index, uuid_t guid);
340 int getType(int index) { return ((index >= 0) && (index < m_size)) ? m_typeList[index] : -1; }
341 const TCHAR *getServer(int index) { return ((index >= 0) && (index < m_size)) ? m_serverList[index] : NULL; }
342};
343
a3050773
VK
344/**
345 * Agent connection
346 */
5039dede
AK
347class LIBNXSRV_EXPORTABLE AgentConnection
348{
349private:
350 DWORD m_dwAddr;
351 int m_nProtocolVersion;
352 int m_iAuthMethod;
08b214c6 353 char m_szSecret[MAX_SECRET_LENGTH];
5039dede
AK
354 time_t m_tLastCommandTime;
355 SOCKET m_hSocket;
356 DWORD m_dwNumDataLines;
357 DWORD m_dwRequestId;
358 DWORD m_dwCommandTimeout;
7c521895 359 DWORD m_connectionTimeout;
5039dede
AK
360 DWORD m_dwRecvTimeout;
361 TCHAR **m_ppDataLines;
362 MsgWaitQueue *m_pMsgWaitQueue;
363 BOOL m_bIsConnected;
364 MUTEX m_mutexDataLock;
d3a7cf4c 365 MUTEX m_mutexSocketWrite;
5039dede 366 THREAD m_hReceiverThread;
98abc9f1 367 NXCPEncryptionContext *m_pCtx;
5039dede
AK
368 int m_iEncryptionPolicy;
369 BOOL m_bUseProxy;
370 DWORD m_dwProxyAddr;
371 WORD m_wPort;
372 WORD m_wProxyPort;
373 int m_iProxyAuth;
08b214c6 374 char m_szProxySecret[MAX_SECRET_LENGTH];
5039dede 375 int m_hCurrFile;
9f6d453a 376 TCHAR m_currentFileName[MAX_PATH];
bb85e341
VK
377 DWORD m_dwDownloadRequestId;
378 CONDITION m_condFileDownload;
379 BOOL m_fileDownloadSucceeded;
380 void (*m_downloadProgressCallback)(size_t, void *);
381 void *m_downloadProgressCallbackArg;
901a5a9b 382 bool m_deleteFileOnDownloadFailure;
4685a2ad 383 bool m_fileUploadInProgress;
5039dede 384
a3050773
VK
385 void receiverThread();
386 static THREAD_RESULT THREAD_CALL receiverThreadStarter(void *);
5039dede
AK
387
388protected:
7c521895
VK
389 void destroyResultData();
390 BOOL sendMessage(CSCPMessage *pMsg);
c17f6cbc 391 CSCPMessage *waitForMessage(WORD wCode, DWORD dwId, DWORD dwTimeOut) { return m_pMsgWaitQueue->waitForMessage(wCode, dwId, dwTimeOut); }
7c521895
VK
392 DWORD waitForRCC(DWORD dwRqId, DWORD dwTimeOut);
393 DWORD setupEncryption(RSA *pServerKey);
394 DWORD authenticate(BOOL bProxyData);
395 DWORD setupProxyConnection();
396 DWORD getIpAddr() { return ntohl(m_dwAddr); }
397 DWORD prepareFileDownload(const TCHAR *fileName, DWORD rqId, bool append, void (*downloadProgressCallback)(size_t, void *), void *cbArg);
5039dede 398
a3050773 399 virtual void printMsg(const TCHAR *pszFormat, ...);
f480bdd4
VK
400 virtual void onTrap(CSCPMessage *pMsg);
401 virtual void onDataPush(CSCPMessage *msg);
90284364 402 virtual bool processCustomMessage(CSCPMessage *pMsg);
f480bdd4 403 virtual void onFileDownload(BOOL success);
5039dede 404
a3050773
VK
405 void lock() { MutexLock(m_mutexDataLock); }
406 void unlock() { MutexUnlock(m_mutexDataLock); }
98abc9f1 407 NXCPEncryptionContext *acquireEncryptionContext();
5039dede
AK
408
409public:
5039dede
AK
410 AgentConnection(DWORD dwAddr, WORD wPort = AGENT_LISTEN_PORT,
411 int iAuthMethod = AUTH_NONE, const TCHAR *pszSecret = NULL);
412 virtual ~AgentConnection();
413
c3acd0f6 414 BOOL connect(RSA *pServerKey = NULL, BOOL bVerbose = FALSE, DWORD *pdwError = NULL, DWORD *pdwSocketError = NULL);
7c521895
VK
415 void disconnect();
416 BOOL isConnected() { return m_bIsConnected; }
417 int getProtocolVersion() { return m_nProtocolVersion; }
5039dede 418
45d84f8a 419 SOCKET getSocket() { return m_hSocket; }
5a9e58a3 420
4687826e 421 ARP_CACHE *getArpCache();
98762401 422 InterfaceList *getInterfaceList();
4687826e
VK
423 ROUTING_TABLE *getRoutingTable();
424 DWORD getParameter(const TCHAR *pszParam, DWORD dwBufSize, TCHAR *pszBuffer);
425 DWORD getList(const TCHAR *pszParam);
426 DWORD getTable(const TCHAR *pszParam, Table **table);
7c521895 427 DWORD nop();
4687826e 428 DWORD execAction(const TCHAR *pszAction, int argc, TCHAR **argv);
619e5c9b 429 DWORD uploadFile(const TCHAR *localFile, const TCHAR *destinationFile = NULL, void (* progressCallback)(INT64, void *) = NULL, void *cbArg = NULL);
4687826e
VK
430 DWORD startUpgrade(const TCHAR *pszPkgName);
431 DWORD checkNetworkService(DWORD *pdwStatus, DWORD dwIpAddr, int iServiceType, WORD wPort = 0,
5039dede 432 WORD wProto = 0, const TCHAR *pszRequest = NULL, const TCHAR *pszResponse = NULL);
cc8ce218 433 DWORD getSupportedParameters(StructArray<NXC_AGENT_PARAM> **paramList, StructArray<NXC_AGENT_TABLE> **tableList);
4687826e 434 DWORD getConfigFile(TCHAR **ppszConfig, DWORD *pdwSize);
45d84f8a 435 DWORD updateConfigFile(const TCHAR *pszConfig);
7c521895 436 DWORD enableTraps();
1f385e47
VK
437 DWORD getPolicyInventory(AgentPolicyInfo **info);
438 DWORD uninstallPolicy(uuid_t guid);
e58b5e54
VK
439
440 DWORD generateRequestId() { return m_dwRequestId++; }
45d84f8a 441 CSCPMessage *customRequest(CSCPMessage *pRequest, const TCHAR *recvFile = NULL, bool appendFile = false,
f2665675 442 void (*downloadProgressCallback)(size_t, void *) = NULL, void *cbArg = NULL);
5039dede 443
7c521895
VK
444 DWORD getNumDataLines() { return m_dwNumDataLines; }
445 const TCHAR *getDataLine(DWORD dwIndex) { return dwIndex < m_dwNumDataLines ? m_ppDataLines[dwIndex] : _T("(error)"); }
5039dede 446
7c521895
VK
447 void setConnectionTimeout(DWORD dwTimeout) { m_connectionTimeout = max(dwTimeout, 1000); }
448 DWORD getConnectionTimeout() { return m_connectionTimeout; }
45d84f8a
VK
449 void setCommandTimeout(DWORD dwTimeout) { m_dwCommandTimeout = max(dwTimeout, 500); }
450 DWORD getCommandTimeout() { return m_dwCommandTimeout; }
7c521895
VK
451 void setRecvTimeout(DWORD dwTimeout) { m_dwRecvTimeout = max(dwTimeout, 10000); }
452 void setEncryptionPolicy(int iPolicy) { m_iEncryptionPolicy = iPolicy; }
453 void setProxy(DWORD dwAddr, WORD wPort = AGENT_LISTEN_PORT,
5039dede 454 int iAuthMethod = AUTH_NONE, const TCHAR *pszSecret = NULL);
7c521895 455 void setPort(WORD wPort) { m_wPort = wPort; }
08b214c6 456 void setAuthData(int nMethod, const char *pszSecret) { m_iAuthMethod = nMethod; strncpy(m_szSecret, pszSecret, MAX_SECRET_LENGTH); m_szSecret[MAX_SECRET_LENGTH - 1] = 0; }
901a5a9b 457 void setDeleteFileOnDownloadFailure(bool flag) { m_deleteFileOnDownloadFailure = flag; }
5039dede
AK
458};
459
a3050773
VK
460/**
461 * Proxy SNMP transport
462 */
5039dede
AK
463class LIBNXSRV_EXPORTABLE SNMP_ProxyTransport : public SNMP_Transport
464{
465protected:
466 AgentConnection *m_pAgentConnection;
467 CSCPMessage *m_pResponse;
468 DWORD m_dwIpAddr;
469 WORD m_wPort;
470
471public:
472 SNMP_ProxyTransport(AgentConnection *pConn, DWORD dwIpAddr, WORD wPort);
473 virtual ~SNMP_ProxyTransport();
474
c4366266 475 virtual int readMessage(SNMP_PDU **ppData, DWORD dwTimeout = INFINITE,
cd9f247e
VK
476 struct sockaddr *pSender = NULL, socklen_t *piAddrSize = NULL,
477 SNMP_SecurityContext* (*contextFinder)(struct sockaddr *, socklen_t) = NULL);
c4366266 478 virtual int sendMessage(SNMP_PDU *pdu);
5039dede
AK
479};
480
481
482//
483// ISC flags
484//
485
486#define ISCF_IS_CONNECTED ((DWORD)0x00000001)
487#define ISCF_REQUIRE_ENCRYPTION ((DWORD)0x00000002)
488
489
490//
491// Inter-server connection (ISC)
492//
493
494class LIBNXSRV_EXPORTABLE ISC
495{
496private:
497 DWORD m_flags;
498 DWORD m_addr;
499 WORD m_port;
500 SOCKET m_socket;
501 int m_protocolVersion;
502 DWORD m_requestId;
503 DWORD m_recvTimeout;
504 MsgWaitQueue *m_msgWaitQueue;
505 MUTEX m_mutexDataLock;
7b8b337e 506 MUTEX m_socketLock;
5039dede 507 THREAD m_hReceiverThread;
98abc9f1 508 NXCPEncryptionContext *m_ctx;
5039dede
AK
509 DWORD m_commandTimeout;
510
c17f6cbc 511 void ReceiverThread();
5039dede
AK
512 static THREAD_RESULT THREAD_CALL ReceiverThreadStarter(void *);
513
514protected:
515 void DestroyResultData(void);
516 DWORD SetupEncryption(RSA *pServerKey);
517 DWORD ConnectToService(DWORD service);
518
c17f6cbc
VK
519 void Lock() { MutexLock(m_mutexDataLock); }
520 void Unlock() { MutexUnlock(m_mutexDataLock); }
5039dede
AK
521
522 virtual void PrintMsg(const TCHAR *format, ...);
523
524public:
525 ISC();
526 ISC(DWORD addr, WORD port = NETXMS_ISC_PORT);
527 virtual ~ISC();
528
529 DWORD Connect(DWORD service, RSA *serverKey = NULL, BOOL requireEncryption = FALSE);
530 void Disconnect();
531
532 BOOL SendMessage(CSCPMessage *msg);
c17f6cbc 533 CSCPMessage *WaitForMessage(WORD code, DWORD id, DWORD timeOut) { return m_msgWaitQueue->waitForMessage(code, id, timeOut); }
5039dede
AK
534 DWORD WaitForRCC(DWORD rqId, DWORD timeOut);
535
536 DWORD Nop(void);
537};
538
539
540//
541// Functions
542//
543
544void LIBNXSRV_EXPORTABLE DestroyArpCache(ARP_CACHE *pArpCache);
5039dede
AK
545void LIBNXSRV_EXPORTABLE DestroyRoutingTable(ROUTING_TABLE *pRT);
546void LIBNXSRV_EXPORTABLE SortRoutingTable(ROUTING_TABLE *pRT);
547const TCHAR LIBNXSRV_EXPORTABLE *AgentErrorCodeToText(int iError);
548
549void LIBNXSRV_EXPORTABLE WriteLogOther(WORD wType, const TCHAR *format, ...);
550void LIBNXSRV_EXPORTABLE DbgPrintf(int level, const TCHAR *format, ...);
9d88cdc9 551void LIBNXSRV_EXPORTABLE DbgPrintf2(int level, const TCHAR *format, va_list args);
c20b2798 552
5039dede
AK
553void LIBNXSRV_EXPORTABLE SetAgentDEP(int iPolicy);
554
555const TCHAR LIBNXSRV_EXPORTABLE *ISCErrorCodeToText(DWORD code);
556
5ad2167d
VK
557DWORD LIBNXSRV_EXPORTABLE SnmpNewRequestId();
558DWORD LIBNXSRV_EXPORTABLE SnmpGet(DWORD dwVersion, SNMP_Transport *pTransport,
559 const TCHAR *szOidStr, const DWORD *oidBinary, DWORD dwOidLen, void *pValue,
560 DWORD dwBufferSize, DWORD dwFlags);
561DWORD LIBNXSRV_EXPORTABLE SnmpEnumerate(DWORD dwVersion, SNMP_Transport *pTransport, const TCHAR *szRootOid,
562 DWORD (* pHandler)(DWORD, SNMP_Variable *, SNMP_Transport *, void *),
563 void *pUserArg, BOOL bVerbose);
564
5039dede
AK
565
566//
567// Variables
568//
569
570extern DWORD LIBNXSRV_EXPORTABLE g_dwFlags;
5ad2167d 571extern DWORD LIBNXSRV_EXPORTABLE g_dwSNMPTimeout;
5039dede 572extern int LIBNXSRV_EXPORTABLE g_nDebugLevel;
5039dede 573
89135050
VK
574
575//
576// Helper finctions for checking server flags
577//
578
579inline bool IsStandalone()
580{
581 return !(g_dwFlags & AF_DAEMON) ? true : false;
582}
583
584inline bool IsZoningEnabled()
585{
586 return (g_dwFlags & AF_ENABLE_ZONING) ? true : false;
587}
588
589inline bool IsShutdownInProgress()
590{
591 return (g_dwFlags & AF_SHUTDOWN) ? true : false;
592}
593
594
5039dede 595#endif /* _nxsrvapi_h_ */