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