additional debug
[public/netxms.git] / src / server / include / nms_core.h
CommitLineData
88f2990c 1/*
5039dede 2** NetXMS - Network Management System
d727efe6 3** Copyright (C) 2003-2016 Victor Kirhenshtein
5039dede
AK
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** File: nms_core.h
20**
21**/
22
23#ifndef _nms_core_h_
24#define _nms_core_h_
25
26#ifdef _WIN32
27#ifdef NXCORE_EXPORTS
28#define NXCORE_EXPORTABLE __declspec(dllexport)
29#else
30#define NXCORE_EXPORTABLE __declspec(dllimport)
31#endif
32#else /* _WIN32 */
33#define NXCORE_EXPORTABLE
34#endif
35
36#define LIBNXCL_NO_DECLARATIONS 1
37
38#include <nms_common.h>
39
40#ifndef _WIN32
41
42#if HAVE_SYS_TYPES_H
43# include <sys/types.h>
44#endif
45
46#if HAVE_DLFCN_H
47#include <dlfcn.h>
48#endif
49
d9177dd1 50
5039dede
AK
51#define WSAGetLastError() (errno)
52
53#endif /* _WIN32 */
54
55#include <time.h>
56#include <stdio.h>
57#include <string.h>
58#include <stdarg.h>
59
958a9397
VK
60#ifdef _WITH_ENCRYPTION
61#include <openssl/ssl.h>
62#endif
63
5039dede
AK
64//
65// Common includes
66//
67
68#include <nms_util.h>
69#include <dbdrv.h>
70#include <nms_cscp.h>
71#include <uuid.h>
72#include <nxsrvapi.h>
5039dede
AK
73#include <nxqueue.h>
74#include <nxsnmp.h>
75#include <nxmodule.h>
76#include <nxsl.h>
9d88cdc9 77#include <nxdbapi.h>
9796ce45 78#include <nddrv.h>
288a0046 79#include <npe.h>
d41edbd3 80#include <nxcore_smclp.h>
5039dede 81
46ee6286
VK
82/**
83 * Console context
84 */
5039dede
AK
85struct __console_ctx
86{
87 SOCKET hSocket;
d3a7cf4c 88 MUTEX socketMutex;
b368969c 89 NXCPMessage *pMsg;
200d662d 90 ClientSession *session;
244c65ef 91 String *output;
5039dede
AK
92};
93
94typedef __console_ctx * CONSOLE_CTX;
95
2bac37f9
VK
96/**
97 * Server includes
98 */
5039dede
AK
99#include "nms_dcoll.h"
100#include "nms_users.h"
46ee6286 101#include "nxcore_winperf.h"
5039dede 102#include "nms_objects.h"
5039dede
AK
103#include "nms_locks.h"
104#include "nms_pkg.h"
105#include "nms_topo.h"
106#include "nms_script.h"
00420032 107#include "nxcore_ps.h"
ab621f39 108#include "nxcore_jobs.h"
e05b1945 109#include "nxcore_logs.h"
fd72d846 110#include "nxcore_schedule.h"
4ef60905
AK
111#ifdef WITH_ZMQ
112#include "zeromq.h"
113#endif
5039dede 114
2bac37f9
VK
115/**
116 * Common constants and macros
117 */
73869331 118#define MAX_LINE_SIZE 4096
967893bb 119#define GROUP_FLAG_BIT ((UINT32)0x80000000)
73869331
VK
120#define CHECKPOINT_SNMP_PORT 260
121#define DEFAULT_AFFINITY_MASK 0xFFFFFFFF
5039dede 122
2a964810
VK
123#define MAX_CLIENT_SESSIONS 128
124#define MAX_DEVICE_SESSIONS 256
125
ebb2dc70
VK
126#define PING_TIME_TIMEOUT 10000
127
5039dede
AK
128typedef void * HSNMPSESSION;
129
0f506caa
VK
130/**
131 * Prefixes for poller messages
132 */
df8a4ca2
VK
133#define POLLER_ERROR _T("\x7F") _T("e")
134#define POLLER_WARNING _T("\x7Fw")
135#define POLLER_INFO _T("\x7Fi")
136
0f506caa
VK
137/**
138 * Unique identifier group codes
139 */
5039dede 140#define IDG_NETWORK_OBJECT 0
23464115
VK
141#define IDG_EVENT 1
142#define IDG_ITEM 2
143#define IDG_SNMP_TRAP 3
144#define IDG_JOB 4
145#define IDG_ACTION 5
146#define IDG_EVENT_GROUP 6
147#define IDG_THRESHOLD 7
148#define IDG_USER 8
149#define IDG_USER_GROUP 9
150#define IDG_ALARM 10
151#define IDG_ALARM_NOTE 11
152#define IDG_PACKAGE 12
153#define IDG_SLM_TICKET 13
154#define IDG_OBJECT_TOOL 14
155#define IDG_SCRIPT 15
156#define IDG_AGENT_CONFIG 16
157#define IDG_GRAPH 17
158#define IDG_CERTIFICATE 18
00420032 159#define IDG_DCT_COLUMN 19
160#define IDG_MAPPING_TABLE 20
161#define IDG_DCI_SUMMARY_TABLE 21
162#define IDG_SCHEDULED_TASK 22
163#define IDG_ALARM_CATEGORY 23
5039dede 164
0f506caa
VK
165/**
166 * Exit codes for console commands
167 */
5039dede
AK
168#define CMD_EXIT_CONTINUE 0
169#define CMD_EXIT_CLOSE_SESSION 1
170#define CMD_EXIT_SHUTDOWN 2
171
0f506caa
VK
172/**
173 * Network discovery mode
174 */
5039dede
AK
175#define DISCOVERY_DISABLED 0
176#define DISCOVERY_PASSIVE_ONLY 1
177#define DISCOVERY_ACTIVE 2
178
0f506caa
VK
179/**
180 * Client session flags
181 */
134c3d00 182#define CSF_TERMINATED ((UINT32)0x00000001)
850ce3ed
VK
183#define CSF_EPP_LOCKED ((UINT32)0x00000002)
184#define CSF_PACKAGE_DB_LOCKED ((UINT32)0x00000004)
185#define CSF_USER_DB_LOCKED ((UINT32)0x00000008)
186#define CSF_EPP_UPLOAD ((UINT32)0x00000010)
187#define CSF_CONSOLE_OPEN ((UINT32)0x00000020)
188#define CSF_AUTHENTICATED ((UINT32)0x00000080)
4970ef34 189#define CSF_COMPRESSION_ENABLED ((UINT32)0x00000100)
850ce3ed
VK
190#define CSF_RECEIVING_MAP_DATA ((UINT32)0x00000200)
191#define CSF_SYNC_OBJECT_COMMENTS ((UINT32)0x00000400)
678fe569
VK
192#define CSF_CUSTOM_LOCK_1 ((UINT32)0x01000000)
193#define CSF_CUSTOM_LOCK_2 ((UINT32)0x02000000)
194#define CSF_CUSTOM_LOCK_3 ((UINT32)0x04000000)
195#define CSF_CUSTOM_LOCK_4 ((UINT32)0x08000000)
196#define CSF_CUSTOM_LOCK_5 ((UINT32)0x10000000)
197#define CSF_CUSTOM_LOCK_6 ((UINT32)0x20000000)
198#define CSF_CUSTOM_LOCK_7 ((UINT32)0x40000000)
199#define CSF_CUSTOM_LOCK_8 ((UINT32)0x80000000)
5039dede 200
0f506caa
VK
201/**
202 * Client session states
203 */
5039dede
AK
204#define SESSION_STATE_INIT 0
205#define SESSION_STATE_IDLE 1
206#define SESSION_STATE_PROCESSING 2
207
0f506caa
VK
208/**
209 * Certificate types
210 */
cce82c3a
VK
211enum CertificateType
212{
213 CERT_TYPE_TRUSTED_CA = 0,
214 CERT_TYPE_USER = 1,
215 CERT_TYPE_AGENT = 2,
216 CERT_TYPE_SERVER = 3
217};
5039dede 218
0f506caa
VK
219/**
220 * Audit subsystems
221 */
5039dede
AK
222#define AUDIT_SECURITY _T("SECURITY")
223#define AUDIT_OBJECTS _T("OBJECTS")
224#define AUDIT_SYSCFG _T("SYSCFG")
225#define AUDIT_CONSOLE _T("CONSOLE")
226
2a964810
VK
227#define AUDIT_SYSTEM_SID (-1)
228
0f506caa
VK
229/**
230 * Event handling subsystem definitions
231 */
5039dede
AK
232#include "nms_events.h"
233#include "nms_actions.h"
234#include "nms_alarm.h"
235
0f506caa
VK
236/**
237 * New node information
238 */
5039dede
AK
239typedef struct
240{
c75e9ee4 241 InetAddress ipAddr;
a191c634 242 UINT32 zoneUIN;
5039dede 243 BOOL ignoreFilter;
baa5324c 244 BYTE bMacAddr[MAC_ADDR_LENGTH];
5039dede
AK
245} NEW_NODE;
246
0f506caa
VK
247/**
248 * New node flags
249 */
5039dede
AK
250#define NNF_IS_SNMP 0x0001
251#define NNF_IS_AGENT 0x0002
252#define NNF_IS_ROUTER 0x0004
253#define NNF_IS_BRIDGE 0x0008
254#define NNF_IS_PRINTER 0x0010
255#define NNF_IS_CDP 0x0020
256#define NNF_IS_SONMP 0x0040
257#define NNF_IS_LLDP 0x0080
258
ba889094
VK
259/**
260 * Address list element types
261 */
262#define InetAddressListElement_SUBNET 0
263#define InetAddressListElement_RANGE 1
264
265/**
266 * IP address list element
267 */
268class NXCORE_EXPORTABLE InetAddressListElement
269{
270private:
271 int m_type;
272 InetAddress m_baseAddress;
273 InetAddress m_endAddress;
274
275public:
276 InetAddressListElement(NXCPMessage *msg, UINT32 baseId);
277 InetAddressListElement(const InetAddress& baseAddr, const InetAddress& endAddr);
278 InetAddressListElement(const InetAddress& baseAddr, int maskBits);
279 InetAddressListElement(DB_RESULT hResult, int row);
280
281 void fillMessage(NXCPMessage *msg, UINT32 baseId) const;
282
283 bool contains(const InetAddress& addr) const;
284
285 int getType() const { return m_type; }
286 const InetAddress& getBaseAddress() const { return m_baseAddress; }
287 const InetAddress& getEndAddress() const { return m_endAddress; }
288
289 String toString() const;
290};
291
0f506caa
VK
292/**
293 * Node information for autodiscovery filter
294 */
5039dede
AK
295typedef struct
296{
c75e9ee4 297 InetAddress ipAddr;
967893bb 298 UINT32 dwFlags;
5039dede 299 int nSNMPVersion;
35f836fe
VK
300 TCHAR szObjectId[MAX_OID_LEN * 4]; // SNMP OID
301 TCHAR szAgentVersion[MAX_AGENT_VERSION_LEN];
302 TCHAR szPlatform[MAX_PLATFORM_NAME_LEN];
5039dede
AK
303} DISCOVERY_FILTER_DATA;
304
0f506caa
VK
305/**
306 * Data update structure for client sessions
307 */
5039dede
AK
308typedef struct
309{
967893bb
VK
310 UINT32 dwCategory; // Data category - event, network object, etc.
311 UINT32 dwCode; // Data-specific update code
5039dede
AK
312 void *pData; // Pointer to data block
313} UPDATE_INFO;
314
534e1b83
VK
315/**
316 * Mobile device session
317 */
318class NXCORE_EXPORTABLE MobileDeviceSession
319{
320private:
321 SOCKET m_hSocket;
322 Queue *m_pSendQueue;
323 Queue *m_pMessageQueue;
2a964810
VK
324 int m_id;
325 int m_state;
534e1b83 326 WORD m_wCurrentCmd;
967893bb
VK
327 UINT32 m_dwUserId;
328 UINT32 m_deviceObjectId;
b368969c 329 NXCP_BUFFER *m_pMsgBuffer;
534e1b83
VK
330 NXCPEncryptionContext *m_pCtx;
331 BYTE m_challenge[CLIENT_CHALLENGE_SIZE];
332 THREAD m_hWriteThread;
333 THREAD m_hProcessingThread;
334 MUTEX m_mutexSocketWrite;
f0718805 335 InetAddress m_clientAddr;
534e1b83
VK
336 TCHAR m_szHostName[256]; // IP address of name of conneced host in textual form
337 TCHAR m_szUserName[MAX_SESSION_NAME]; // String in form login_name@host
338 TCHAR m_szClientInfo[96]; // Client app info string
967893bb
VK
339 UINT32 m_dwEncryptionRqId;
340 UINT32 m_dwEncryptionResult;
534e1b83 341 CONDITION m_condEncryptionSetup;
967893bb 342 UINT32 m_dwRefCount;
534e1b83
VK
343 bool m_isAuthenticated;
344
345 static THREAD_RESULT THREAD_CALL readThreadStarter(void *);
346 static THREAD_RESULT THREAD_CALL writeThreadStarter(void *);
347 static THREAD_RESULT THREAD_CALL processingThreadStarter(void *);
5039dede 348
534e1b83
VK
349 void readThread();
350 void writeThread();
351 void processingThread();
352
b368969c 353 void setupEncryption(NXCPMessage *request);
967893bb 354 void respondToKeepalive(UINT32 dwRqId);
534e1b83 355 void debugPrintf(int level, const TCHAR *format, ...);
967893bb 356 void sendServerInfo(UINT32 dwRqId);
b368969c
VK
357 void login(NXCPMessage *pRequest);
358 void updateDeviceInfo(NXCPMessage *pRequest);
359 void updateDeviceStatus(NXCPMessage *pRequest);
360 void pushData(NXCPMessage *request);
534e1b83
VK
361
362public:
f0718805 363 MobileDeviceSession(SOCKET hSocket, const InetAddress& addr);
534e1b83
VK
364 ~MobileDeviceSession();
365
534e1b83
VK
366 void run();
367
198745dd 368 void postMessage(NXCPMessage *pMsg) { m_pSendQueue->put(pMsg->serialize()); }
b368969c 369 void sendMessage(NXCPMessage *pMsg);
5039dede 370
2a964810
VK
371 int getId() { return m_id; }
372 void setId(int id) { if (m_id == -1) m_id = id; }
373 int getState() { return m_state; }
534e1b83
VK
374 const TCHAR *getUserName() { return m_szUserName; }
375 const TCHAR *getClientInfo() { return m_szClientInfo; }
376 const TCHAR *getHostName() { return m_szHostName; }
967893bb 377 UINT32 getUserId() { return m_dwUserId; }
534e1b83
VK
378 bool isAuthenticated() { return m_isAuthenticated; }
379 WORD getCurrentCmd() { return m_wCurrentCmd; }
380 int getCipher() { return (m_pCtx == NULL) ? -1 : m_pCtx->getCipher(); }
381};
382
383/**
84ea7692 384 * Processing thread starter declaration for client session
534e1b83 385 */
134c3d00 386#define DECLARE_THREAD_STARTER(func) static void ThreadStarter_##func(void *);
5039dede 387
7b45b90d 388/**
389 * Class that stores information about file that will be received
390 */
b8b6cd2f 391class ServerDownloadFileInfo : public DownloadFileInfo
7b45b90d 392{
b8b6cd2f 393protected:
7b45b90d 394 UINT32 m_uploadCommand;
395 UINT32 m_uploadData;
b8b6cd2f 396 uuid m_uploadImageGuid;
7b45b90d 397
398public:
b8b6cd2f
VK
399 ServerDownloadFileInfo(const TCHAR *name, UINT32 uploadCommand, time_t lastModTime = 0);
400 virtual ~ServerDownloadFileInfo();
401
402 virtual void close(bool success);
403
404 void setUploadData(UINT32 data) { m_uploadData = data; }
405 void setImageGuid(const uuid& guid) { m_uploadImageGuid = guid; }
7b45b90d 406 void updateAgentPkgDBInfo(const TCHAR *description, const TCHAR *pkgName, const TCHAR *pkgVersion, const TCHAR *platform, const TCHAR *cleanFileName);
7b45b90d 407};
408
84ea7692
VK
409/**
410 * Client (user) session
411 */
a0e3917e 412class NXCORE_EXPORTABLE ClientSession
5039dede
AK
413{
414private:
415 SOCKET m_hSocket;
b784f8ac
VK
416 Queue *m_sendQueue;
417 Queue *m_requestQueue;
2a964810
VK
418 int m_id;
419 int m_state;
5039dede 420 WORD m_wCurrentCmd;
967893bb 421 UINT32 m_dwUserId;
f4d8fe18 422 UINT64 m_dwSystemAccess; // User's system access rights
967893bb 423 UINT32 m_dwFlags; // Session flags
f8c6f10f 424 int m_clientType; // Client system type - desktop, web, mobile, etc.
98abc9f1 425 NXCPEncryptionContext *m_pCtx;
5039dede
AK
426 BYTE m_challenge[CLIENT_CHALLENGE_SIZE];
427 THREAD m_hWriteThread;
428 THREAD m_hProcessingThread;
d3a7cf4c 429 MUTEX m_mutexSocketWrite;
5039dede
AK
430 MUTEX m_mutexSendObjects;
431 MUTEX m_mutexSendAlarms;
432 MUTEX m_mutexSendActions;
433 MUTEX m_mutexSendAuditLog;
5039dede 434 MUTEX m_mutexPollerInit;
f0718805 435 InetAddress m_clientAddr;
91f6b72c
VK
436 TCHAR m_workstation[256]; // IP address or name of connected host in textual form
437 TCHAR m_webServerAddress[256]; // IP address or name of web server for web sessions
77a08c86
VK
438 TCHAR m_loginName[MAX_USER_NAME];
439 TCHAR m_sessionName[MAX_SESSION_NAME]; // String in form login_name@host
440 TCHAR m_clientInfo[96]; // Client app info string
2a964810 441 TCHAR m_language[8]; // Client's desired language
a51628e2 442 time_t m_loginTime;
967893bb
VK
443 UINT32 m_dwOpenDCIListSize; // Number of open DCI lists
444 UINT32 *m_pOpenDCIList; // List of nodes with DCI lists open
445 UINT32 m_dwNumRecordsToUpload; // Number of records to be uploaded
446 UINT32 m_dwRecordsUploaded;
5039dede 447 EPRule **m_ppEPPRuleList; // List of loaded EPP rules
b8b6cd2f 448 HashMap<UINT32, ServerDownloadFileInfo> *m_downloadFileMap;
c044d4f3 449 VolatileCounter m_refCount;
967893bb
VK
450 UINT32 m_dwEncryptionRqId;
451 UINT32 m_dwEncryptionResult;
5039dede 452 CONDITION m_condEncryptionSetup;
200d662d 453 CONSOLE_CTX m_console; // Server console context
810bd8c4 454 StringList m_musicTypeList;
7cf549ad 455 ObjectIndex m_agentConn;
84ea7692 456 StringObjectMap<UINT32> *m_subscriptions;
c044d4f3 457 MUTEX m_subscriptionLock;
45ac5dd0 458 HashMap<UINT32, CommandExec> *m_serverCommands;
5039dede 459
534e1b83
VK
460 static THREAD_RESULT THREAD_CALL readThreadStarter(void *);
461 static THREAD_RESULT THREAD_CALL writeThreadStarter(void *);
462 static THREAD_RESULT THREAD_CALL processingThreadStarter(void *);
134c3d00 463 static void pollerThreadStarter(void *);
5039dede 464
78ccd7b4
VK
465 DECLARE_THREAD_STARTER(cancelFileMonitoring)
466 DECLARE_THREAD_STARTER(clearDCIData)
467 DECLARE_THREAD_STARTER(createObject)
468 DECLARE_THREAD_STARTER(executeAction)
469 DECLARE_THREAD_STARTER(executeScript)
e9bf9011 470 DECLARE_THREAD_STARTER(executeLibraryScript)
74d0b136 471 DECLARE_THREAD_STARTER(fileManagerControl)
78ccd7b4
VK
472 DECLARE_THREAD_STARTER(findIpAddress)
473 DECLARE_THREAD_STARTER(findMacAddress)
f1984eb9 474 DECLARE_THREAD_STARTER(findHostname)
78ccd7b4
VK
475 DECLARE_THREAD_STARTER(findNodeConnection)
476 DECLARE_THREAD_STARTER(forceDCIPoll)
477 DECLARE_THREAD_STARTER(forwardToReportingServer)
478 DECLARE_THREAD_STARTER(getAgentFile)
479 DECLARE_THREAD_STARTER(getAlarmEvents)
3ddc492b 480 DECLARE_THREAD_STARTER(getAlarms)
78ccd7b4 481 DECLARE_THREAD_STARTER(getCollectedData)
0cf6fcbd 482 DECLARE_THREAD_STARTER(getPredictedData)
4899db4d 483 DECLARE_THREAD_STARTER(getLocationHistory)
78ccd7b4
VK
484 DECLARE_THREAD_STARTER(getNetworkPath)
485 DECLARE_THREAD_STARTER(getRoutingTable)
486 DECLARE_THREAD_STARTER(getServerFile)
487 DECLARE_THREAD_STARTER(getServerLogQueryData)
488 DECLARE_THREAD_STARTER(getSwitchForwardingDatabase)
489 DECLARE_THREAD_STARTER(getTableCollectedData)
490 DECLARE_THREAD_STARTER(importConfiguration)
491 DECLARE_THREAD_STARTER(openHelpdeskIssue)
492 DECLARE_THREAD_STARTER(processConsoleCommand)
493 DECLARE_THREAD_STARTER(queryAgentTable)
494 DECLARE_THREAD_STARTER(queryL2Topology)
495 DECLARE_THREAD_STARTER(queryParameter)
496 DECLARE_THREAD_STARTER(queryServerLog)
78ccd7b4 497 DECLARE_THREAD_STARTER(sendMib)
78ccd7b4 498 DECLARE_THREAD_STARTER(uploadUserFileToAgent)
badd6e08
VK
499 DECLARE_THREAD_STARTER(getRepositories)
500 DECLARE_THREAD_STARTER(addRepository)
501 DECLARE_THREAD_STARTER(modifyRepository)
502 DECLARE_THREAD_STARTER(deleteRepository)
5039dede 503
62768df3
VK
504 void readThread();
505 void writeThread();
506 void processingThread();
91b3cba9 507 void pollerThread(DataCollectionTarget *pNode, int iPollType, UINT32 dwRqId);
5039dede 508
badd6e08
VK
509 void debugPrintf(int level, const TCHAR *format, ...);
510
b368969c 511 void setupEncryption(NXCPMessage *request);
967893bb 512 void respondToKeepalive(UINT32 dwRqId);
e05b1945 513 void onFileUpload(BOOL bSuccess);
967893bb 514 void sendServerInfo(UINT32 dwRqId);
b368969c
VK
515 void login(NXCPMessage *pRequest);
516 void sendAllObjects(NXCPMessage *pRequest);
517 void sendSelectedObjects(NXCPMessage *pRequest);
c85c8ef2
VK
518 void getConfigurationVariables(UINT32 dwRqId);
519 void getPublicConfigurationVariable(NXCPMessage *request);
c7aa788e 520 void setDefaultConfigurationVariableValues(NXCPMessage *pRequest);
c85c8ef2
VK
521 void setConfigurationVariable(NXCPMessage *pRequest);
522 void deleteConfigurationVariable(NXCPMessage *pRequest);
967893bb 523 void sendUserDB(UINT32 dwRqId);
b368969c
VK
524 void createUser(NXCPMessage *pRequest);
525 void updateUser(NXCPMessage *pRequest);
2d8d8ea2 526 void detachLdapUser(NXCPMessage *pRequest);
b368969c 527 void deleteUser(NXCPMessage *pRequest);
77a08c86
VK
528 void setPassword(NXCPMessage *request);
529 void validatePassword(NXCPMessage *request);
967893bb 530 void lockUserDB(UINT32 dwRqId, BOOL bLock);
a881eafa 531 void getAlarmCategories(UINT32 requestId);
6a6b96c0 532 void modifyAlarmCategory(NXCPMessage *pRequest);
a881eafa 533 void deleteAlarmCategory(NXCPMessage *pRequest);
1b281c3e 534 void sendEventDB(NXCPMessage *pRequest);
b368969c
VK
535 void modifyEventTemplate(NXCPMessage *pRequest);
536 void deleteEventTemplate(NXCPMessage *pRequest);
967893bb 537 void generateEventCode(UINT32 dwRqId);
b368969c
VK
538 void modifyObject(NXCPMessage *pRequest);
539 void changeObjectMgmtStatus(NXCPMessage *pRequest);
7e18667a
VK
540 void enterMaintenanceMode(NXCPMessage *request);
541 void leaveMaintenanceMode(NXCPMessage *request);
b368969c
VK
542 void openNodeDCIList(NXCPMessage *pRequest);
543 void closeNodeDCIList(NXCPMessage *pRequest);
544 void modifyNodeDCI(NXCPMessage *pRequest);
545 void copyDCI(NXCPMessage *pRequest);
546 void applyTemplate(NXCPMessage *pRequest);
547 void getCollectedData(NXCPMessage *pRequest);
548 void getTableCollectedData(NXCPMessage *pRequest);
549 bool getCollectedDataFromDB(NXCPMessage *request, NXCPMessage *response, DataCollectionTarget *object, int dciType);
550 void clearDCIData(NXCPMessage *pRequest);
79633a65 551 void forceDCIPoll(NXCPMessage *pRequest);
b368969c
VK
552 void changeDCIStatus(NXCPMessage *pRequest);
553 void getLastValues(NXCPMessage *pRequest);
554 void getLastValuesByDciId(NXCPMessage *pRequest);
555 void getTableLastValues(NXCPMessage *pRequest);
556 void getThresholdSummary(NXCPMessage *request);
557 void openEPP(NXCPMessage *request);
967893bb 558 void closeEPP(UINT32 dwRqId);
b368969c
VK
559 void saveEPP(NXCPMessage *pRequest);
560 void processEPPRecord(NXCPMessage *pRequest);
967893bb 561 void sendMIBTimestamp(UINT32 dwRqId);
b368969c
VK
562 void sendMib(NXCPMessage *request);
563 void createObject(NXCPMessage *request);
564 void changeObjectBinding(NXCPMessage *request, BOOL bBind);
565 void deleteObject(NXCPMessage *request);
3ddc492b 566 void getAlarms(NXCPMessage *request);
b368969c
VK
567 void getAlarm(NXCPMessage *request);
568 void getAlarmEvents(NXCPMessage *request);
569 void acknowledgeAlarm(NXCPMessage *request);
570 void resolveAlarm(NXCPMessage *request, bool terminate);
a881eafa 571 void bulkResolveAlarms(NXCPMessage *pRequest, bool terminate);
b368969c
VK
572 void deleteAlarm(NXCPMessage *request);
573 void openHelpdeskIssue(NXCPMessage *request);
574 void getHelpdeskUrl(NXCPMessage *request);
575 void unlinkHelpdeskIssue(NXCPMessage *request);
576 void getAlarmComments(NXCPMessage *pRequest);
577 void updateAlarmComment(NXCPMessage *pRequest);
578 void deleteAlarmComment(NXCPMessage *request);
579 void updateAlarmStatusFlow(NXCPMessage *request);
580 void createAction(NXCPMessage *pRequest);
581 void updateAction(NXCPMessage *pRequest);
582 void deleteAction(NXCPMessage *pRequest);
967893bb 583 void sendAllActions(UINT32 dwRqId);
b368969c
VK
584 void forcedNodePoll(NXCPMessage *pRequest);
585 void onTrap(NXCPMessage *pRequest);
586 void onWakeUpNode(NXCPMessage *pRequest);
587 void queryParameter(NXCPMessage *pRequest);
588 void queryAgentTable(NXCPMessage *pRequest);
589 void editTrap(int iOperation, NXCPMessage *pRequest);
967893bb
VK
590 void LockTrapCfg(UINT32 dwRqId, BOOL bLock);
591 void sendAllTraps(UINT32 dwRqId);
592 void sendAllTraps2(UINT32 dwRqId);
593 void LockPackageDB(UINT32 dwRqId, BOOL bLock);
594 void SendAllPackages(UINT32 dwRqId);
b368969c
VK
595 void InstallPackage(NXCPMessage *pRequest);
596 void RemovePackage(NXCPMessage *pRequest);
597 void DeployPackage(NXCPMessage *pRequest);
598 void getParametersList(NXCPMessage *pRequest);
599 void getUserVariable(NXCPMessage *pRequest);
600 void setUserVariable(NXCPMessage *pRequest);
601 void copyUserVariable(NXCPMessage *pRequest);
602 void enumUserVariables(NXCPMessage *pRequest);
603 void deleteUserVariable(NXCPMessage *pRequest);
604 void changeObjectZone(NXCPMessage *pRequest);
605 void getAgentConfig(NXCPMessage *pRequest);
606 void updateAgentConfig(NXCPMessage *pRequest);
607 void executeAction(NXCPMessage *pRequest);
b576249a
VK
608 void getObjectTools(UINT32 requestId);
609 void getObjectToolDetails(NXCPMessage *request);
b368969c
VK
610 void updateObjectTool(NXCPMessage *pRequest);
611 void deleteObjectTool(NXCPMessage *pRequest);
612 void changeObjectToolStatus(NXCPMessage *pRequest);
967893bb 613 void generateObjectToolId(UINT32 dwRqId);
b368969c
VK
614 void execTableTool(NXCPMessage *pRequest);
615 void changeSubscription(NXCPMessage *pRequest);
967893bb
VK
616 void sendServerStats(UINT32 dwRqId);
617 void sendScriptList(UINT32 dwRqId);
b368969c
VK
618 void sendScript(NXCPMessage *pRequest);
619 void updateScript(NXCPMessage *pRequest);
620 void renameScript(NXCPMessage *pRequest);
621 void deleteScript(NXCPMessage *pRequest);
967893bb 622 void SendSessionList(UINT32 dwRqId);
b368969c 623 void KillSession(NXCPMessage *pRequest);
b368969c
VK
624 void StartSnmpWalk(NXCPMessage *pRequest);
625 void resolveDCINames(NXCPMessage *pRequest);
55a918b7 626 UINT32 resolveDCIName(UINT32 dwNode, UINT32 dwItem, TCHAR *ppszName);
b368969c 627 void sendConfigForAgent(NXCPMessage *pRequest);
967893bb 628 void sendAgentCfgList(UINT32 dwRqId);
b368969c
VK
629 void OpenAgentConfig(NXCPMessage *pRequest);
630 void SaveAgentConfig(NXCPMessage *pRequest);
631 void DeleteAgentConfig(NXCPMessage *pRequest);
632 void SwapAgentConfigs(NXCPMessage *pRequest);
633 void SendObjectComments(NXCPMessage *pRequest);
634 void updateObjectComments(NXCPMessage *pRequest);
635 void pushDCIData(NXCPMessage *pRequest);
ba889094
VK
636 void getAddrList(NXCPMessage *request);
637 void setAddrList(NXCPMessage *request);
b368969c 638 void resetComponent(NXCPMessage *pRequest);
25a1e9d0
VK
639 void getDCIEventList(NXCPMessage *request);
640 void getDCIScriptList(NXCPMessage *request);
b368969c
VK
641 void SendDCIInfo(NXCPMessage *pRequest);
642 void sendPerfTabDCIList(NXCPMessage *pRequest);
643 void exportConfiguration(NXCPMessage *pRequest);
644 void importConfiguration(NXCPMessage *pRequest);
aed41472 645 void sendGraphList(NXCPMessage *request);
b368969c
VK
646 void saveGraph(NXCPMessage *pRequest);
647 void deleteGraph(NXCPMessage *pRequest);
493beadc
VK
648 void addCACertificate(NXCPMessage *pRequest);
649 void deleteCertificate(NXCPMessage *pRequest);
650 void updateCertificateComments(NXCPMessage *pRequest);
967893bb 651 void getCertificateList(UINT32 dwRqId);
b368969c
VK
652 void queryL2Topology(NXCPMessage *pRequest);
653 void sendSMS(NXCPMessage *pRequest);
967893bb 654 void SendCommunityList(UINT32 dwRqId);
b368969c 655 void UpdateCommunityList(NXCPMessage *pRequest);
00420032 656 void getPersistantStorage(UINT32 dwRqId);
657 void setPstorageValue(NXCPMessage *pRequest);
658 void deletePstorageValue(NXCPMessage *pRequest);
b368969c
VK
659 void setConfigCLOB(NXCPMessage *pRequest);
660 void getConfigCLOB(NXCPMessage *pRequest);
661 void registerAgent(NXCPMessage *pRequest);
662 void getServerFile(NXCPMessage *pRequest);
663 void cancelFileMonitoring(NXCPMessage *request);
664 void getAgentFile(NXCPMessage *pRequest);
665 void testDCITransformation(NXCPMessage *pRequest);
967893bb 666 void sendJobList(UINT32 dwRqId);
b368969c
VK
667 void cancelJob(NXCPMessage *pRequest);
668 void holdJob(NXCPMessage *pRequest);
669 void unholdJob(NXCPMessage *pRequest);
670 void deployAgentPolicy(NXCPMessage *pRequest, bool uninstallFlag);
671 void getUserCustomAttribute(NXCPMessage *request);
672 void setUserCustomAttribute(NXCPMessage *request);
673 void openServerLog(NXCPMessage *request);
674 void closeServerLog(NXCPMessage *request);
675 void queryServerLog(NXCPMessage *request);
676 void getServerLogQueryData(NXCPMessage *request);
967893bb 677 void sendUsmCredentials(UINT32 dwRqId);
b368969c
VK
678 void updateUsmCredentials(NXCPMessage *pRequest);
679 void sendDCIThresholds(NXCPMessage *request);
680 void addClusterNode(NXCPMessage *request);
681 void findNodeConnection(NXCPMessage *request);
682 void findMacAddress(NXCPMessage *request);
683 void findIpAddress(NXCPMessage *request);
f1984eb9 684 void findHostname(NXCPMessage *request);
b368969c
VK
685 void sendLibraryImage(NXCPMessage *request);
686 void updateLibraryImage(NXCPMessage *request);
687 void listLibraryImages(NXCPMessage *request);
688 void deleteLibraryImage(NXCPMessage *request);
689 void executeServerCommand(NXCPMessage *request);
45ac5dd0 690 void stopServerCommand(NXCPMessage *request);
b368969c
VK
691 void uploadFileToAgent(NXCPMessage *request);
692 void listServerFileStore(NXCPMessage *request);
693 void processConsoleCommand(NXCPMessage *msg);
967893bb
VK
694 void openConsole(UINT32 rqId);
695 void closeConsole(UINT32 rqId);
b368969c
VK
696 void getVlans(NXCPMessage *msg);
697 void receiveFile(NXCPMessage *request);
698 void deleteFile(NXCPMessage *request);
699 void getNetworkPath(NXCPMessage *request);
700 void getNodeComponents(NXCPMessage *request);
701 void getNodeSoftware(NXCPMessage *request);
702 void getWinPerfObjects(NXCPMessage *request);
703 void listMappingTables(NXCPMessage *request);
704 void getMappingTable(NXCPMessage *request);
705 void updateMappingTable(NXCPMessage *request);
706 void deleteMappingTable(NXCPMessage *request);
707 void getWirelessStations(NXCPMessage *request);
967893bb 708 void getSummaryTables(UINT32 rqId);
b368969c
VK
709 void getSummaryTableDetails(NXCPMessage *request);
710 void modifySummaryTable(NXCPMessage *request);
711 void deleteSummaryTable(NXCPMessage *request);
712 void querySummaryTable(NXCPMessage *request);
713 void queryAdHocSummaryTable(NXCPMessage *request);
714 void forwardToReportingServer(NXCPMessage *request);
715 void getSubnetAddressMap(NXCPMessage *request);
716 void getEffectiveRights(NXCPMessage *request);
717 void fileManagerControl(NXCPMessage *request);
718 void uploadUserFileToAgent(NXCPMessage *request);
719 void getSwitchForwardingDatabase(NXCPMessage *request);
720 void getRoutingTable(NXCPMessage *request);
721 void getLocationHistory(NXCPMessage *request);
722 void getScreenshot(NXCPMessage *request);
723 void executeScript(NXCPMessage *request);
e9bf9011 724 void executeLibraryScript(NXCPMessage *request);
5f573844 725 void compileScript(NXCPMessage *request);
4b535d78 726 void resyncAgentDciConfiguration(NXCPMessage *request);
727 void cleanAgentDciConfiguration(NXCPMessage *request);
ec13a467
VK
728 void getSchedulerTaskHandlers(NXCPMessage *request);
729 void getScheduledTasks(NXCPMessage *request);
730 void addScheduledTask(NXCPMessage *request);
731 void updateScheduledTask(NXCPMessage *request);
732 void removeScheduledTask(NXCPMessage *request);
badd6e08
VK
733 void getRepositories(NXCPMessage *request);
734 void addRepository(NXCPMessage *request);
735 void modifyRepository(NXCPMessage *request);
736 void deleteRepository(NXCPMessage *request);
3c463101 737 void getAgentTunnels(NXCPMessage *request);
3b89a4c1 738 void bindAgentTunnel(NXCPMessage *request);
c733fcc4 739 void unbindAgentTunnel(NXCPMessage *request);
0cf6fcbd
VK
740 void getPredictionEngines(NXCPMessage *request);
741 void getPredictedData(NXCPMessage *request);
2649d20b 742 void expandMacros(NXCPMessage *request);
4ef60905
AK
743#ifdef WITH_ZMQ
744 void zmqManageSubscription(NXCPMessage *request, zmq::SubscriptionType type, bool subscribe);
745 void zmqListSubscriptions(NXCPMessage *request, zmq::SubscriptionType type);
746#endif
45ac5dd0 747 void registerServerCommand(CommandExec *command) { m_serverCommands->set(command->getStreamId(), command); }
5039dede 748
8586c088 749 void alarmUpdateWorker(Alarm *alarm);
9f21d472 750 void sendActionDBUpdateMessage(NXCP_MESSAGE *msg);
b784f8ac 751 void sendObjectUpdate(NetObj *object);
8586c088 752
5039dede 753public:
f0718805 754 ClientSession(SOCKET hSocket, const InetAddress& addr);
5039dede
AK
755 ~ClientSession();
756
c044d4f3
VK
757 void incRefCount() { InterlockedIncrement(&m_refCount); }
758 void decRefCount() { InterlockedDecrement(&m_refCount); }
e05b1945
VK
759
760 void run();
761
198745dd 762 void postMessage(NXCPMessage *pMsg) { if (!isTerminated()) m_sendQueue->put(pMsg->serialize((m_dwFlags & CSF_COMPRESSION_ENABLED) != 0)); }
a07511b5 763 bool sendMessage(NXCPMessage *pMsg);
b368969c 764 void sendRawMessage(NXCP_MESSAGE *pMsg);
967893bb 765 void sendPollerMsg(UINT32 dwRqId, const TCHAR *pszMsg);
cc022855 766 BOOL sendFile(const TCHAR *file, UINT32 dwRqId, long offset);
e05b1945 767
9515e7b1 768 void writeAuditLog(const TCHAR *subsys, bool success, UINT32 objectId, const TCHAR *format, ...);
dbb49f94 769 void writeAuditLogWithValues(const TCHAR *subsys, bool success, UINT32 objectId, const TCHAR *oldValue, const TCHAR *newValue, const TCHAR *format, ...);
0d402aa8 770 void writeAuditLogWithValues(const TCHAR *subsys, bool success, UINT32 objectId, json_t *oldValue, json_t *newValue, const TCHAR *format, ...);
9515e7b1 771
c044d4f3 772 int getId() const { return m_id; }
2a964810 773 void setId(int id) { if (m_id == -1) m_id = id; }
e05b1945 774
c044d4f3
VK
775 int getState() const { return m_state; }
776 const TCHAR *getLoginName() const { return m_loginName; }
777 const TCHAR *getSessionName() const { return m_sessionName; }
778 const TCHAR *getClientInfo() const { return m_clientInfo; }
779 const TCHAR *getWorkstation() const { return m_workstation; }
780 const TCHAR *getWebServerAddress() const { return m_webServerAddress; }
781 UINT32 getUserId() const { return m_dwUserId; }
782 UINT64 getSystemRights() const { return m_dwSystemAccess; }
783 UINT32 getFlags() const { return m_dwFlags; }
784 bool isAuthenticated() const { return (m_dwFlags & CSF_AUTHENTICATED) ? true : false; }
785 bool isTerminated() const { return (m_dwFlags & CSF_TERMINATED) ? true : false; }
786 bool isConsoleOpen() const { return (m_dwFlags & CSF_CONSOLE_OPEN) ? true : false; }
d3a20572
VK
787 bool isCompressionEnabled() const { return (m_dwFlags & CSF_COMPRESSION_ENABLED) ? true : false; }
788 UINT16 getCurrentCmd() const { return m_wCurrentCmd; }
c044d4f3
VK
789 int getCipher() const { return (m_pCtx == NULL) ? -1 : m_pCtx->getCipher(); }
790 int getClientType() const { return m_clientType; }
791 time_t getLoginTime() const { return m_loginTime; }
792 bool isSubscribedTo(const TCHAR *channel) const;
793
794 bool checkSysAccessRights(UINT64 requiredAccess) const
88f2990c 795 {
796 return (m_dwUserId == 0) ? true :
badf9a95 797 ((requiredAccess & m_dwSystemAccess) == requiredAccess);
e05b1945
VK
798 }
799
87f56b19
VK
800 void setCustomLock(UINT32 bit, bool value)
801 {
802 if (value)
803 m_dwFlags |= (bit & 0xFF000000);
804 else
805 m_dwFlags &= ~(bit & 0xFF000000);
806 }
807
f669df41 808 void kill();
967893bb 809 void notify(UINT32 dwCode, UINT32 dwData = 0);
e05b1945 810
e05b1945 811 void onNewEvent(Event *pEvent);
e0f99bf0 812 void onSyslogMessage(NX_SYSLOG_RECORD *pRec);
b368969c 813 void onNewSNMPTrap(NXCPMessage *pMsg);
e05b1945 814 void onObjectChange(NetObj *pObject);
d727efe6 815 void onAlarmUpdate(UINT32 dwCode, const Alarm *alarm);
967893bb 816 void onActionDBUpdate(UINT32 dwCode, NXC_ACTION *pAction);
b8b6cd2f 817 void onLibraryImageChange(const uuid& guid, bool removed = false);
5039dede
AK
818};
819
2bac37f9
VK
820/**
821 * Delayed SQL request
822 */
7dad92fb
VK
823typedef struct
824{
825 TCHAR *query;
826 int bindCount;
827 BYTE *sqlTypes;
828 TCHAR *bindings[1]; /* actual size determined by bindCount field */
829} DELAYED_SQL_REQUEST;
830
2bac37f9
VK
831/**
832 * Delayed request for idata_ INSERT
833 */
f68d9eac
VK
834typedef struct
835{
836 time_t timestamp;
967893bb
VK
837 UINT32 nodeId;
838 UINT32 dciId;
f68d9eac
VK
839 TCHAR value[MAX_RESULT_LENGTH];
840} DELAYED_IDATA_INSERT;
841
76fcb995
VK
842/**
843 * Delayed request for raw_dci_values UPDATE
844 */
845typedef struct
846{
847 time_t timestamp;
848 UINT32 dciId;
849 TCHAR rawValue[MAX_RESULT_LENGTH];
850 TCHAR transformedValue[MAX_RESULT_LENGTH];
851} DELAYED_RAW_DATA_UPDATE;
852
7a4c94ee 853/**
854 * Graph ACL entry
855 */
856struct GRAPH_ACL_ENTRY
857{
858 UINT32 dwGraphId;
859 UINT32 dwUserId;
860 UINT32 dwAccess;
861};
862
863/**
864 * Information about graph with name existence and it's ID.
865 */
866struct GRAPH_ACL_AND_ID
867{
88f2990c 868 UINT32 graphId;
7a4c94ee 869 UINT32 status;
870};
871
9f3db00f
VK
872/**
873 * Thread pool stats
874 */
875enum ThreadPoolStat
876{
877 THREAD_POOL_CURR_SIZE,
878 THREAD_POOL_MIN_SIZE,
879 THREAD_POOL_MAX_SIZE,
880 THREAD_POOL_REQUESTS,
881 THREAD_POOL_LOAD,
882 THREAD_POOL_USAGE,
883 THREAD_POOL_LOADAVG_1,
884 THREAD_POOL_LOADAVG_5,
885 THREAD_POOL_LOADAVG_15
886};
887
234079c4
VK
888/**
889 * Server command execution data
890 */
45ac5dd0 891class ServerCommandExec : public CommandExec
234079c4
VK
892{
893private:
234079c4
VK
894 UINT32 m_requestId;
895 ClientSession *m_session;
896
45ac5dd0
EJ
897 virtual void onOutput(const char *text);
898 virtual void endOfOutput();
234079c4 899
45ac5dd0
EJ
900public:
901 ServerCommandExec(NXCPMessage *msg, ClientSession *session);
902 ~ServerCommandExec();
234079c4
VK
903};
904
0207b7dd
EJ
905/**
906 * SNMP Trap parameter map object
907 */
6f1137b7 908class SNMPTrapParameterMapping
0207b7dd
EJ
909{
910private:
911 SNMP_ObjectId *m_objectId; // Trap OID
912 UINT32 m_position; // Trap position
913 UINT32 m_flags;
914 TCHAR m_description[MAX_DB_STRING];
915
916public:
6f1137b7
VK
917 SNMPTrapParameterMapping();
918 SNMPTrapParameterMapping(DB_RESULT mapResult, int row);
919 SNMPTrapParameterMapping(ConfigEntry *entry);
920 SNMPTrapParameterMapping(SNMP_ObjectId *oid, UINT32 flags, TCHAR *description);
921 SNMPTrapParameterMapping(NXCPMessage *msg, UINT32 base);
922 ~SNMPTrapParameterMapping();
0207b7dd 923
ed4d6982 924 void fillMessage(NXCPMessage *msg, UINT32 base) const;
0207b7dd 925
ed4d6982 926 SNMP_ObjectId *getOid() const { return m_objectId; }
6f1137b7
VK
927 int getPosition() const { return m_position; }
928 bool isPositional() const { return m_objectId == NULL; }
0207b7dd 929
ed4d6982 930 UINT32 getFlags() const { return m_flags; }
0207b7dd 931
ed4d6982 932 const TCHAR *getDescription() const { return m_description; }
0207b7dd
EJ
933};
934
935/**
936 * SNMP Trap configuration object
937 */
6f1137b7 938class SNMPTrapConfiguration
0207b7dd
EJ
939{
940private:
941 uuid m_guid; // Trap guid
942 UINT32 m_id; // Entry ID
6f1137b7 943 SNMP_ObjectId m_objectId; // Trap OID
0207b7dd 944 UINT32 m_eventCode; // Event code
6f1137b7 945 ObjectArray<SNMPTrapParameterMapping> m_mappings;
0207b7dd
EJ
946 TCHAR m_description[MAX_DB_STRING];
947 TCHAR m_userTag[MAX_USERTAG_LENGTH];
948
949public:
6f1137b7
VK
950 SNMPTrapConfiguration();
951 SNMPTrapConfiguration(DB_RESULT trapResult, DB_STATEMENT stmt, int row);
952 SNMPTrapConfiguration(ConfigEntry *entry, const uuid& guid, UINT32 id, UINT32 eventCode);
953 SNMPTrapConfiguration(NXCPMessage *msg);
954 ~SNMPTrapConfiguration();
0207b7dd 955
ed4d6982
VK
956 void fillMessage(NXCPMessage *msg) const;
957 void fillMessage(NXCPMessage *msg, UINT32 base) const;
0207b7dd
EJ
958 bool saveParameterMapping(DB_HANDLE hdb);
959 void notifyOnTrapCfgChange(UINT32 code);
960
ed4d6982 961 UINT32 getId() const { return m_id; }
6f1137b7
VK
962 const uuid& getGuid() const { return m_guid; }
963 const SNMP_ObjectId& getOid() const { return m_objectId; }
964 const SNMPTrapParameterMapping *getParameterMapping(int index) const { return m_mappings.get(index); }
965 int getParameterMappingCount() const { return m_mappings.size(); }
ed4d6982 966 UINT32 getEventCode() const { return m_eventCode; }
ed4d6982
VK
967 const TCHAR *getDescription() const { return m_description; }
968 const TCHAR *getUserTag() const { return m_userTag; }
0207b7dd
EJ
969};
970
83b1c107
VK
971/**
972 * Watchdog thread state codes
973 */
974enum WatchdogState
975{
976 WATCHDOG_UNKNOWN = -1,
977 WATCHDOG_RUNNING = 0,
978 WATCHDOG_SLEEPING = 1,
979 WATCHDOG_NOT_RESPONDING = 2
980};
981
2bac37f9
VK
982/**
983 * Functions
984 */
35959841 985bool NXCORE_EXPORTABLE ConfigReadStr(const TCHAR *szVar, TCHAR *szBuffer, int iBufSize, const TCHAR *szDefault);
9bd1bace 986bool NXCORE_EXPORTABLE ConfigReadStrEx(DB_HANDLE hdb, const TCHAR *szVar, TCHAR *szBuffer, int iBufSize, const TCHAR *szDefault);
35f836fe 987#ifdef UNICODE
35959841 988bool NXCORE_EXPORTABLE ConfigReadStrA(const WCHAR *szVar, char *szBuffer, int iBufSize, const char *szDefault);
35f836fe
VK
989#else
990#define ConfigReadStrA ConfigReadStr
991#endif
43526096 992bool NXCORE_EXPORTABLE ConfigReadStrUTF8(const TCHAR *szVar, char *szBuffer, int iBufSize, const char *szDefault);
5039dede 993int NXCORE_EXPORTABLE ConfigReadInt(const TCHAR *szVar, int iDefault);
9bd1bace 994int NXCORE_EXPORTABLE ConfigReadIntEx(DB_HANDLE hdb, const TCHAR *szVar, int iDefault);
967893bb 995UINT32 NXCORE_EXPORTABLE ConfigReadULong(const TCHAR *szVar, UINT32 dwDefault);
35959841
VK
996bool NXCORE_EXPORTABLE ConfigReadByteArray(const TCHAR *pszVar, int *pnArray, int nSize, int nDefault);
997bool NXCORE_EXPORTABLE ConfigWriteStr(const TCHAR *szVar, const TCHAR *szValue, bool bCreate, bool isVisible = true, bool needRestart = false);
998bool NXCORE_EXPORTABLE ConfigWriteInt(const TCHAR *szVar, int iValue, bool bCreate, bool isVisible = true, bool needRestart = false);
999bool NXCORE_EXPORTABLE ConfigWriteULong(const TCHAR *szVar, UINT32 dwValue, bool bCreate, bool isVisible = true, bool needRestart = false);
1000bool NXCORE_EXPORTABLE ConfigWriteByteArray(const TCHAR *pszVar, int *pnArray, int nSize, bool bCreate, bool isVisible = true, bool needRestart = false);
5039dede 1001TCHAR NXCORE_EXPORTABLE *ConfigReadCLOB(const TCHAR *var, const TCHAR *defValue);
35959841
VK
1002bool NXCORE_EXPORTABLE ConfigWriteCLOB(const TCHAR *var, const TCHAR *value, bool bCreate);
1003bool NXCORE_EXPORTABLE ConfigDelete(const TCHAR *name);
5039dede 1004
0fdb37c6 1005void MetaDataPreLoad();
35959841 1006bool NXCORE_EXPORTABLE MetaDataReadStr(const TCHAR *szVar, TCHAR *szBuffer, int iBufSize, const TCHAR *szDefault);
dba9c498 1007INT32 NXCORE_EXPORTABLE MetaDataReadInt32(const TCHAR *var, INT32 defaultValue);
e9902466 1008bool NXCORE_EXPORTABLE MetaDataWriteStr(const TCHAR *varName, const TCHAR *value);
dba9c498 1009bool NXCORE_EXPORTABLE MetaDataWriteInt32(const TCHAR *name, INT32 value);
28f5b9a4 1010
2df047f4 1011bool NXCORE_EXPORTABLE LoadConfig(int *debugLevel);
5039dede 1012
35f836fe
VK
1013void NXCORE_EXPORTABLE Shutdown();
1014void NXCORE_EXPORTABLE FastShutdown();
1015BOOL NXCORE_EXPORTABLE Initialize();
5039dede 1016THREAD_RESULT NXCORE_EXPORTABLE THREAD_CALL Main(void *);
35f836fe
VK
1017void NXCORE_EXPORTABLE ShutdownDB();
1018void InitiateShutdown();
5039dede 1019
400e55c4 1020bool NXCORE_EXPORTABLE SleepAndCheckForShutdown(int iSeconds);
5039dede 1021
6e383343
VK
1022void ConsolePrintf(CONSOLE_CTX pCtx, const TCHAR *pszFormat, ...)
1023#if !defined(UNICODE) && (defined(__GNUC__) || defined(__clang__))
1024 __attribute__ ((format(printf, 2, 3)))
1025#endif
1026;
532990d2 1027void ConsoleWrite(CONSOLE_CTX pCtx, const TCHAR *text);
35f836fe 1028int ProcessConsoleCommand(const TCHAR *pszCmdLine, CONSOLE_CTX pCtx);
5039dede 1029
b4277312 1030void SaveObjects(DB_HANDLE hdb, UINT32 watchdogId, bool saveRuntimeData);
ff6d2c5d
VK
1031void NXCORE_EXPORTABLE ObjectTransactionStart();
1032void NXCORE_EXPORTABLE ObjectTransactionEnd();
5039dede 1033
ce7565e7 1034void NXCORE_EXPORTABLE QueueSQLRequest(const TCHAR *query);
7dad92fb 1035void NXCORE_EXPORTABLE QueueSQLRequest(const TCHAR *query, int bindCount, int *sqlTypes, const TCHAR **values);
967893bb 1036void QueueIDataInsert(time_t timestamp, UINT32 nodeId, UINT32 dciId, const TCHAR *value);
76fcb995 1037void QueueRawDciDataUpdate(time_t timestamp, UINT32 dciId, const TCHAR *rawValue, const TCHAR *transformedValue);
ce7565e7
VK
1038void StartDBWriter();
1039void StopDBWriter();
5039dede 1040
ea50bc33
VK
1041void PerfDataStorageRequest(DCItem *dci, time_t timestamp, const TCHAR *value);
1042void PerfDataStorageRequest(DCTable *dci, time_t timestamp, Table *value);
1043
b368969c 1044void DecodeSQLStringAndSetVariable(NXCPMessage *pMsg, UINT32 dwVarId, TCHAR *pszStr);
5039dede 1045
d0a2ada6 1046SNMP_Transport *SnmpCheckCommSettings(UINT32 snmpProxy, const InetAddress& ipAddr, INT16 *version, UINT16 originalPort, SNMP_SecurityContext *originalContext, StringList *customTestOids);
35f836fe 1047void StrToMac(const TCHAR *pszStr, BYTE *pBuffer);
5039dede 1048
f42b8099 1049void InitLocalNetInfo();
5039dede 1050
f42b8099 1051ARP_CACHE *GetLocalArpCache();
967893bb 1052ARP_CACHE *SnmpGetArpCache(UINT32 dwVersion, SNMP_Transport *pTransport);
5039dede 1053
98762401 1054InterfaceList *GetLocalInterfaceList();
5039dede 1055
967893bb 1056ROUTING_TABLE *SnmpGetRoutingTable(UINT32 dwVersion, SNMP_Transport *pTransport);
5039dede 1057
9796ce45 1058void LoadNetworkDeviceDrivers();
21254a93 1059NetworkDeviceDriver *FindDriverForNode(Node *node, SNMP_Transport *pTransport);
28e1575f 1060NetworkDeviceDriver *FindDriverByName(const TCHAR *name);
1f4c37ee 1061void AddDriverSpecificOids(StringList *list);
9796ce45 1062
fa9c1a51
VK
1063bool LookupDevicePortLayout(const SNMP_ObjectId& objectId, NDD_MODULE_LAYOUT *layout);
1064
5ad2167d 1065void CheckForMgmtNode();
a191c634 1066void CheckPotentialNode(const InetAddress& ipAddr, UINT32 zoneUIN);
de4c3060
VK
1067Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 creationFlags, UINT16 agentPort,
1068 UINT16 snmpPort, const TCHAR *name, UINT32 agentProxyId, UINT32 snmpProxyId,
1069 UINT32 icmpProxyId, UINT32 sshProxyId, const TCHAR *sshLogin, const TCHAR *sshPassword,
a191c634 1070 Cluster *cluster, UINT32 zoneUIN, bool doConfPoll, bool discoveredNode);
5039dede 1071
b1e9b6b3 1072void NXCORE_EXPORTABLE EnumerateClientSessions(void (*pHandler)(ClientSession *, void *), void *pArg);
967893bb 1073void NXCORE_EXPORTABLE NotifyClientSessions(UINT32 dwCode, UINT32 dwData);
6da535d9 1074void NXCORE_EXPORTABLE NotifyClientSession(UINT32 sessionId, UINT32 dwCode, UINT32 dwData);
32f372a5 1075void NXCORE_EXPORTABLE NotifyClientGraphUpdate(NXCPMessage *update, UINT32 graphId);
64909a13 1076int GetSessionCount(bool includeSystemAccount);
967893bb 1077bool IsLoggedIn(UINT32 dwUserId);
5d9a9c84 1078bool NXCORE_EXPORTABLE KillClientSession(int id);
27858eaa 1079void CloseOtherSessions(UINT32 userId, UINT32 thisSession);
5039dede 1080
35f836fe 1081void GetSysInfoStr(TCHAR *pszBuffer, int nMaxSize);
c30c0c0f 1082InetAddress GetLocalIpAddr();
f7694811 1083TCHAR *GetLocalHostName(TCHAR *buffer, size_t bufSize);
5039dede 1084
a191c634 1085InetAddress NXCORE_EXPORTABLE ResolveHostName(UINT32 zoneUIN, const TCHAR *hostname);
b4cf3199 1086
35f836fe 1087BOOL ExecCommand(TCHAR *pszCommand);
967893bb 1088BOOL SendMagicPacket(UINT32 dwIpAddr, BYTE *pbMacAddr, int iNumPackets);
5039dede 1089
35f836fe 1090BOOL InitIdTable();
967893bb 1091UINT32 CreateUniqueId(int iGroup);
35f836fe 1092QWORD CreateUniqueEventId();
69bb7f47 1093void SaveCurrentFreeId();
5039dede 1094
35f836fe
VK
1095void InitMailer();
1096void ShutdownMailer();
f14e669f 1097void NXCORE_EXPORTABLE PostMail(const TCHAR *pszRcpt, const TCHAR *pszSubject, const TCHAR *pszText, bool isHtml = false);
5039dede 1098
35f836fe
VK
1099void InitSMSSender();
1100void ShutdownSMSSender();
1101void NXCORE_EXPORTABLE PostSMS(const TCHAR *pszRcpt, const TCHAR *pszText);
5039dede 1102
35f836fe 1103void InitTraps();
967893bb 1104void SendTrapsToClient(ClientSession *pSession, UINT32 dwRqId);
0207b7dd 1105void CreateTrapCfgMessage(NXCPMessage *msg);
967893bb 1106UINT32 CreateNewTrap(UINT32 *pdwTrapId);
b368969c 1107UINT32 UpdateTrapFromMsg(NXCPMessage *pMsg);
967893bb 1108UINT32 DeleteTrap(UINT32 dwId);
25a1e9d0 1109void CreateTrapExportRecord(String &xml, UINT32 id);
0207b7dd 1110UINT32 ResolveTrapGuid(const uuid& guid);
6f1137b7 1111void AddTrapCfgToList(SNMPTrapConfiguration *trapCfg);
967893bb
VK
1112
1113BOOL IsTableTool(UINT32 dwToolId);
1114BOOL CheckObjectToolAccess(UINT32 dwToolId, UINT32 dwUserId);
1115UINT32 ExecuteTableTool(UINT32 dwToolId, Node *pNode, UINT32 dwRqId, ClientSession *pSession);
1116UINT32 DeleteObjectToolFromDB(UINT32 dwToolId);
6f8e39e5 1117UINT32 ChangeObjectToolStatus(UINT32 toolId, bool enabled);
b368969c 1118UINT32 UpdateObjectToolFromMessage(NXCPMessage *pMsg);
4c3cc965 1119void CreateObjectToolExportRecord(String &xml, UINT32 id);
271e3971 1120bool ImportObjectTool(ConfigEntry *config);
b576249a
VK
1121UINT32 GetObjectToolsIntoMessage(NXCPMessage *msg, UINT32 userId, bool fullAccess);
1122UINT32 GetObjectToolDetailsIntoMessage(UINT32 toolId, NXCPMessage *msg);
967893bb 1123
b368969c 1124UINT32 ModifySummaryTable(NXCPMessage *msg, LONG *newId);
967893bb 1125UINT32 DeleteSummaryTable(LONG tableId);
5389f7b0 1126Table *QuerySummaryTable(LONG tableId, SummaryTable *adHocDefinition, UINT32 baseObjectId, UINT32 userId, UINT32 *rcc);
2096c8f0 1127bool CreateSummaryTableExportRecord(INT32 id, String &xml);
c7a9d87c 1128bool ImportSummaryTable(ConfigEntry *config);
b4c2a628 1129
b368969c 1130void CreateMessageFromSyslogMsg(NXCPMessage *pMsg, NX_SYSLOG_RECORD *pRec);
4262c0dc 1131void ReinitializeSyslogParser();
b8c8a8a7 1132void OnSyslogConfigurationChange(const TCHAR *name, const TCHAR *value);
5039dede
AK
1133
1134void EscapeString(String &str);
1135
ce7565e7 1136void InitAuditLog();
badd6e08 1137void NXCORE_EXPORTABLE WriteAuditLog(const TCHAR *subsys, bool isSuccess, UINT32 userId,
2a964810 1138 const TCHAR *workstation, int sessionId, UINT32 objectId,
ce7565e7 1139 const TCHAR *format, ...);
badd6e08
VK
1140void NXCORE_EXPORTABLE WriteAuditLog2(const TCHAR *subsys, bool isSuccess, UINT32 userId,
1141 const TCHAR *workstation, int sessionId, UINT32 objectId,
1142 const TCHAR *format, va_list args);
dbb49f94
VK
1143void NXCORE_EXPORTABLE WriteAuditLogWithValues(const TCHAR *subsys, bool isSuccess, UINT32 userId,
1144 const TCHAR *workstation, int sessionId, UINT32 objectId,
1145 const TCHAR *oldValue, const TCHAR *newValue,
1146 const TCHAR *format, ...);
0d402aa8
VK
1147void NXCORE_EXPORTABLE WriteAuditLogWithJsonValues(const TCHAR *subsys, bool isSuccess, UINT32 userId,
1148 const TCHAR *workstation, int sessionId, UINT32 objectId,
1149 json_t *oldValue, json_t *newValue,
1150 const TCHAR *format, ...);
dbb49f94
VK
1151void NXCORE_EXPORTABLE WriteAuditLogWithValues2(const TCHAR *subsys, bool isSuccess, UINT32 userId,
1152 const TCHAR *workstation, int sessionId, UINT32 objectId,
1153 const TCHAR *oldValue, const TCHAR *newValue,
1154 const TCHAR *format, va_list args);
0d402aa8
VK
1155void NXCORE_EXPORTABLE WriteAuditLogWithJsonValues2(const TCHAR *subsys, bool isSuccess, UINT32 userId,
1156 const TCHAR *workstation, int sessionId, UINT32 objectId,
1157 json_t *oldValue, json_t *newValue,
1158 const TCHAR *format, va_list args);
88f2990c 1159
967893bb
VK
1160bool ValidateConfig(Config *config, UINT32 flags, TCHAR *errorText, int errorTextLen);
1161UINT32 ImportConfig(Config *config, UINT32 flags);
5039dede
AK
1162
1163#ifdef _WITH_ENCRYPTION
b368969c 1164X509 *CertificateFromLoginMessage(NXCPMessage *pMsg);
b95f153a
VK
1165bool ValidateUserCertificate(X509 *cert, const TCHAR *login, const BYTE *challenge,
1166 const BYTE *signature, size_t sigLen, int mappingMethod,
1167 const TCHAR *mappingData);
cce82c3a 1168bool ValidateAgentCertificate(X509 *cert);
9796ce45 1169void ReloadCertificates();
c48843a5 1170bool GetCertificateSubjectField(X509 *cert, int nid, TCHAR *buffer, size_t size);
cce82c3a 1171bool GetCertificateCN(X509 *cert, TCHAR *buffer, size_t size);
c48843a5 1172bool GetCertificateOU(X509 *cert, TCHAR *buffer, size_t size);
8e78c21a 1173String GetCertificateSubjectString(X509 *cert);
c48843a5
VK
1174bool GetServerCertificateCountry(TCHAR *buffer, size_t size);
1175bool GetServerCertificateOrganization(TCHAR *buffer, size_t size);
1176X509 *IssueCertificate(X509_REQ *request, const char *ou, const char *cn, int days);
5039dede
AK
1177#endif
1178
1179#ifndef _WIN32
1180THREAD_RESULT NXCORE_EXPORTABLE THREAD_CALL SignalHandler(void *);
1181#endif /* not _WIN32 */
1182
5d3459af
VK
1183void DbgTestRWLock(RWLOCK hLock, const TCHAR *szName, CONSOLE_CTX console);
1184void DumpClientSessions(CONSOLE_CTX console);
1185void DumpMobileDeviceSessions(CONSOLE_CTX console);
5d3459af
VK
1186void ShowServerStats(CONSOLE_CTX console);
1187void ShowQueueStats(CONSOLE_CTX console, Queue *pQueue, const TCHAR *pszName);
b239e165 1188void ShowThreadPoolPendingQueue(CONSOLE_CTX console, ThreadPool *p, const TCHAR *pszName);
5d3459af 1189void ShowThreadPool(CONSOLE_CTX console, ThreadPool *p);
9f3db00f 1190LONG GetThreadPoolStat(ThreadPoolStat stat, const TCHAR *param, TCHAR *value);
5d3459af 1191void DumpProcess(CONSOLE_CTX console);
5039dede 1192
aed41472 1193#define GRAPH_FLAG_TEMPLATE 1
1194
bd360fd5 1195GRAPH_ACL_ENTRY *LoadGraphACL(DB_HANDLE hdb, UINT32 graphId, int *pnACLSize);
48abffaa 1196GRAPH_ACL_ENTRY *LoadAllGraphACL(DB_HANDLE hdb, int *pnACLSize);
9ad921e5 1197BOOL CheckGraphAccess(GRAPH_ACL_ENTRY *pACL, int nACLSize, UINT32 graphId, UINT32 graphUserId, UINT32 graphDesiredAccess);
fff23fae 1198UINT32 GetGraphAccessCheckResult(UINT32 graphId, UINT32 graphUserId);
9ad921e5 1199GRAPH_ACL_AND_ID IsGraphNameExists(const TCHAR *graphName);
aed41472 1200void FillGraphListMsg(NXCPMessage *msg, UINT32 userId, bool templageGraphs);
1201void SaveGraph(NXCPMessage *pRequest, UINT32 userId, NXCPMessage *msg);
1202UINT32 DeleteGraph(UINT32 graphId, UINT32 userId);
7a4c94ee 1203
d00ad4c6 1204#if XMPP_SUPPORTED
098ef635 1205void SendXMPPMessage(const TCHAR *rcpt, const TCHAR *text);
d00ad4c6 1206#endif
244c65ef 1207
0de31ec3
VK
1208const TCHAR NXCORE_EXPORTABLE *CountryAlphaCode(const TCHAR *code);
1209const TCHAR NXCORE_EXPORTABLE *CountryName(const TCHAR *code);
1210const TCHAR NXCORE_EXPORTABLE *CurrencyAlphaCode(const TCHAR *numericCode);
1211int NXCORE_EXPORTABLE CurrencyExponent(const TCHAR *code);
1212const TCHAR NXCORE_EXPORTABLE *CurrencyName(const TCHAR *code);
1213
4fd0b7ca
VK
1214void NXCORE_EXPORTABLE RegisterComponent(const TCHAR *id);
1215bool NXCORE_EXPORTABLE IsComponentRegistered(const TCHAR *id);
1216
83b1c107
VK
1217/**
1218 * Watchdog API
1219 */
1220void WatchdogInit();
1221void WatchdogShutdown();
1222UINT32 WatchdogAddThread(const TCHAR *name, time_t notifyInterval);
1223void WatchdogNotify(UINT32 id);
1224void WatchdogStartSleep(UINT32 id);
1225void WatchdogPrintStatus(CONSOLE_CTX console);
1226WatchdogState WatchdogGetState(const TCHAR *name);
1227void WatchdogGetThreads(StringList *out);
1228
01090206
VK
1229/**
1230 * Housekeeper control
1231 */
1232void StartHouseKeeper();
1233void StopHouseKeeper();
1234void RunHouseKeeper();
1235
a881eafa
VK
1236/**
1237 * Alarm category functions
1238 */
1239void GetAlarmCategories(NXCPMessage *msg);
f5050daf 1240UINT32 UpdateAlarmCategory(const NXCPMessage *request, UINT32 *returnId);
a881eafa 1241UINT32 DeleteAlarmCategory(UINT32 id);
e30c2442
VK
1242bool CheckAlarmCategoryAccess(UINT32 userId, UINT32 categoryId);
1243void LoadAlarmCategories();
a881eafa 1244
f14e669f
EJ
1245/**
1246 * Alarm summary emails
1247 */
1248void SendAlarmSummaryEmail(const ScheduledTaskParameters *params);
1249void EnableAlarmSummaryEmails();
1250
0207b7dd
EJ
1251/**
1252 * NXSL script functions
1253 */
1254UINT32 UpdateScript(const NXCPMessage *request, UINT32 *scriptId);
1255UINT32 RenameScript(const NXCPMessage *request);
1256UINT32 DeleteScript(const NXCPMessage *request);
1257
9fa031cd 1258/**
1259 * File monitoring
1260 */
1261struct MONITORED_FILE
1262{
1263 TCHAR fileName[MAX_PATH];
1264 ClientSession *session;
1265 UINT32 nodeID;
1266};
1267
1268class FileMonitoringList
1269{
1270private:
1271 MUTEX m_mutex;
1272 ObjectArray<MONITORED_FILE> m_monitoredFiles;
9fa031cd 1273
1274public:
1275 FileMonitoringList();
1276 ~FileMonitoringList();
e13420c1 1277 void addMonitoringFile(MONITORED_FILE *fileForAdd, Node *obj, AgentConnection *conn);
e2338033 1278 bool checkDuplicate(MONITORED_FILE *fileForAdd);
1279 ObjectArray<ClientSession>* findClientByFNameAndNodeID(const TCHAR *fileName, UINT32 nodeID);
9fa031cd 1280 bool removeMonitoringFile(MONITORED_FILE *fileForRemove);
f9f79a93 1281 void removeDisconnectedNode(UINT32 nodeId);
9fa031cd 1282
1283private:
1284 void lock();
1285 void unlock();
1286};
1287
379f8228 1288/**********************
1289 * Distance calculation
1290 **********************/
1291
1292/**
1293 * Class stores object and distance to it from provided node
1294 */
1295class ObjectsDistance
1296{
1297public:
1298 NetObj *m_obj;
1299 int m_distance;
1300
1301 ObjectsDistance(NetObj *obj, int distance) { m_obj = obj; m_distance = distance; }
1302 ~ObjectsDistance() { m_obj->decRefCount(); }
1303};
1304
1305/**
1306 * Calculate nearest objects from current one
1307 * Object ref count will be automatically decreased on array delete
1308 */
1309ObjectArray<ObjectsDistance> *FindNearestObjects(UINT32 currObjectId, int maxDistance, bool (* filter)(NetObj *object, void *data), void *sortData, int (* calculateRealDistance)(GeoLocation &loc1, GeoLocation &loc2));
1310
534e1b83
VK
1311/**
1312 * Global variables
1313 */
5039dede
AK
1314extern TCHAR NXCORE_EXPORTABLE g_szConfigFile[];
1315extern TCHAR NXCORE_EXPORTABLE g_szLogFile[];
458b5d2b
VK
1316extern UINT32 g_logRotationMode;
1317extern UINT64 g_maxLogSize;
1318extern UINT32 g_logHistorySize;
4f8998ca 1319extern TCHAR g_szDailyLogFileSuffix[64];
5039dede
AK
1320extern TCHAR NXCORE_EXPORTABLE g_szDumpDir[];
1321extern TCHAR NXCORE_EXPORTABLE g_szListenAddress[];
1322#ifndef _WIN32
1323extern TCHAR NXCORE_EXPORTABLE g_szPIDFile[];
1324#endif
db6a6b45
VK
1325extern TCHAR NXCORE_EXPORTABLE g_netxmsdDataDir[];
1326extern TCHAR NXCORE_EXPORTABLE g_netxmsdLibDir[];
967893bb 1327extern UINT32 NXCORE_EXPORTABLE g_processAffinityMask;
e9902466 1328extern UINT64 g_serverId;
5039dede 1329extern RSA *g_pServerKey;
c59466d2
VK
1330extern UINT32 g_icmpPingSize;
1331extern UINT32 g_icmpPingTimeout;
1332extern UINT32 g_auditFlags;
1333extern time_t g_serverStartTime;
1334extern UINT32 g_lockTimeout;
1335extern UINT32 g_agentCommandTimeout;
1336extern UINT32 g_thresholdRepeatInterval;
1337extern int g_requiredPolls;
1338extern UINT32 g_slmPollingInterval;
f6456d80 1339extern UINT32 g_offlineDataRelevanceTime;
5039dede 1340
b8c1ec69
VK
1341extern TCHAR g_szDbDriver[];
1342extern TCHAR g_szDbDrvParams[];
1343extern TCHAR g_szDbServer[];
1344extern TCHAR g_szDbLogin[];
1345extern TCHAR g_szDbPassword[];
1346extern TCHAR g_szDbName[];
f3c30cf5 1347extern TCHAR g_szDbSchema[];
b8c1ec69 1348extern DB_DRIVER g_dbDriver;
76fcb995
VK
1349extern Queue *g_dbWriterQueue;
1350extern Queue *g_dciDataWriterQueue;
1351extern Queue *g_dciRawDataWriterQueue;
6547a540
VK
1352extern UINT64 g_idataWriteRequests;
1353extern UINT64 g_rawDataWriteRequests;
1354extern UINT64 g_otherWriteRequests;
5039dede 1355
2a964810 1356extern int NXCORE_EXPORTABLE g_dbSyntax;
9fa031cd 1357extern FileMonitoringList g_monitoringList;
5039dede 1358
1ef6170e 1359extern ThreadPool NXCORE_EXPORTABLE *g_mainThreadPool;
5d3459af 1360
5039dede 1361#endif /* _nms_core_h_ */