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