Merge branch 'master' of 10.3.0.4:public/netxms
[public/netxms.git] / src / server / include / nms_core.h
CommitLineData
88f2990c 1/*
5039dede 2** NetXMS - Network Management System
6adc4a1a 3** Copyright (C) 2003-2012 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
50#define WSAGetLastError() (errno)
51
52#endif /* _WIN32 */
53
54#include <time.h>
55#include <stdio.h>
56#include <string.h>
57#include <stdarg.h>
58
958a9397
VK
59#ifdef _WITH_ENCRYPTION
60#include <openssl/ssl.h>
61#endif
62
5039dede
AK
63#define SHOW_FLAG_VALUE(x) _T(" %-32s = %d\n"), _T(#x), (g_dwFlags & x) ? 1 : 0
64
65
66//
67// Common includes
68//
69
70#include <nms_util.h>
71#include <dbdrv.h>
72#include <nms_cscp.h>
73#include <uuid.h>
74#include <nxsrvapi.h>
5039dede
AK
75#include <nxqueue.h>
76#include <nxsnmp.h>
77#include <nxmodule.h>
78#include <nxsl.h>
9d88cdc9 79#include <nxdbapi.h>
9796ce45 80#include <nddrv.h>
d41edbd3 81#include <nxcore_smclp.h>
5039dede 82
46ee6286
VK
83/**
84 * Console context
85 */
5039dede
AK
86struct __console_ctx
87{
88 SOCKET hSocket;
d3a7cf4c 89 MUTEX socketMutex;
5039dede 90 CSCPMessage *pMsg;
200d662d 91 ClientSession *session;
244c65ef 92 String *output;
5039dede
AK
93};
94
95typedef __console_ctx * CONSOLE_CTX;
96
2bac37f9
VK
97/**
98 * Server includes
99 */
5039dede
AK
100#include "nms_dcoll.h"
101#include "nms_users.h"
46ee6286 102#include "nxcore_winperf.h"
5039dede 103#include "nms_objects.h"
5039dede
AK
104#include "nms_locks.h"
105#include "nms_pkg.h"
106#include "nms_topo.h"
107#include "nms_script.h"
5039dede 108#include "nxcore_situations.h"
ab621f39 109#include "nxcore_jobs.h"
e05b1945 110#include "nxcore_logs.h"
5039dede 111
2bac37f9
VK
112/**
113 * Common constants and macros
114 */
73869331 115#define MAX_LINE_SIZE 4096
967893bb 116#define GROUP_FLAG_BIT ((UINT32)0x80000000)
73869331
VK
117#define CHECKPOINT_SNMP_PORT 260
118#define DEFAULT_AFFINITY_MASK 0xFFFFFFFF
5039dede
AK
119
120typedef void * HSNMPSESSION;
121
0f506caa
VK
122/**
123 * Prefixes for poller messages
124 */
df8a4ca2
VK
125#define POLLER_ERROR _T("\x7F") _T("e")
126#define POLLER_WARNING _T("\x7Fw")
127#define POLLER_INFO _T("\x7Fi")
128
0f506caa
VK
129/**
130 * Unique identifier group codes
131 */
5039dede
AK
132#define IDG_NETWORK_OBJECT 0
133#define IDG_CONTAINER_CAT 1
134#define IDG_EVENT 2
135#define IDG_ITEM 3
136#define IDG_SNMP_TRAP 4
24dc5346 137#define IDG_JOB 5
5039dede
AK
138#define IDG_ACTION 6
139#define IDG_EVENT_GROUP 7
140#define IDG_THRESHOLD 8
141#define IDG_USER 9
142#define IDG_USER_GROUP 10
143#define IDG_ALARM 11
144#define IDG_ALARM_NOTE 12
145#define IDG_PACKAGE 13
636e0c72 146#define IDG_SLM_TICKET 14
5039dede
AK
147#define IDG_OBJECT_TOOL 15
148#define IDG_SCRIPT 16
149#define IDG_AGENT_CONFIG 17
150#define IDG_GRAPH 18
151#define IDG_CERTIFICATE 19
152#define IDG_SITUATION 20
ba89fed2 153#define IDG_DCT_COLUMN 21
0f506caa 154#define IDG_MAPPING_TABLE 22
b4c2a628 155#define IDG_DCI_SUMMARY_TABLE 23
5039dede 156
0f506caa
VK
157/**
158 * Exit codes for console commands
159 */
5039dede
AK
160#define CMD_EXIT_CONTINUE 0
161#define CMD_EXIT_CLOSE_SESSION 1
162#define CMD_EXIT_SHUTDOWN 2
163
0f506caa
VK
164/**
165 * Network discovery mode
166 */
5039dede
AK
167#define DISCOVERY_DISABLED 0
168#define DISCOVERY_PASSIVE_ONLY 1
169#define DISCOVERY_ACTIVE 2
170
0f506caa
VK
171/**
172 * Client session flags
173 */
967893bb
VK
174#define CSF_EPP_LOCKED ((UINT32)0x0002)
175#define CSF_PACKAGE_DB_LOCKED ((UINT32)0x0004)
176#define CSF_USER_DB_LOCKED ((UINT32)0x0008)
177#define CSF_EPP_UPLOAD ((UINT32)0x0010)
178#define CSF_CONSOLE_OPEN ((UINT32)0x0020)
179#define CSF_AUTHENTICATED ((UINT32)0x0080)
180#define CSF_RECEIVING_MAP_DATA ((UINT32)0x0200)
181#define CSF_SYNC_OBJECT_COMMENTS ((UINT32)0x0400)
5039dede 182
0f506caa
VK
183/**
184 * Client session states
185 */
5039dede
AK
186#define SESSION_STATE_INIT 0
187#define SESSION_STATE_IDLE 1
188#define SESSION_STATE_PROCESSING 2
189
0f506caa
VK
190/**
191 * Information categories for UPDATE_INFO structure
192 */
5039dede
AK
193#define INFO_CAT_EVENT 1
194#define INFO_CAT_OBJECT_CHANGE 2
195#define INFO_CAT_ALARM 3
196#define INFO_CAT_ACTION 4
197#define INFO_CAT_SYSLOG_MSG 5
198#define INFO_CAT_SNMP_TRAP 6
199#define INFO_CAT_AUDIT_RECORD 7
200#define INFO_CAT_SITUATION 8
624f1165 201#define INFO_CAT_LIBRARY_IMAGE 9
5039dede 202
0f506caa
VK
203/**
204 * Certificate types
205 */
5039dede
AK
206#define CERT_TYPE_TRUSTED_CA 0
207#define CERT_TYPE_USER 1
208
0f506caa
VK
209/**
210 * Audit subsystems
211 */
5039dede
AK
212#define AUDIT_SECURITY _T("SECURITY")
213#define AUDIT_OBJECTS _T("OBJECTS")
214#define AUDIT_SYSCFG _T("SYSCFG")
215#define AUDIT_CONSOLE _T("CONSOLE")
216
0f506caa
VK
217/**
218 * Event handling subsystem definitions
219 */
5039dede
AK
220#include "nms_events.h"
221#include "nms_actions.h"
222#include "nms_alarm.h"
223
0f506caa
VK
224/**
225 * New node information
226 */
5039dede
AK
227typedef struct
228{
967893bb
VK
229 UINT32 dwIpAddr;
230 UINT32 dwNetMask;
231 UINT32 zoneId;
5039dede 232 BOOL ignoreFilter;
baa5324c 233 BYTE bMacAddr[MAC_ADDR_LENGTH];
5039dede
AK
234} NEW_NODE;
235
0f506caa
VK
236/**
237 * New node flags
238 */
5039dede
AK
239#define NNF_IS_SNMP 0x0001
240#define NNF_IS_AGENT 0x0002
241#define NNF_IS_ROUTER 0x0004
242#define NNF_IS_BRIDGE 0x0008
243#define NNF_IS_PRINTER 0x0010
244#define NNF_IS_CDP 0x0020
245#define NNF_IS_SONMP 0x0040
246#define NNF_IS_LLDP 0x0080
247
0f506caa
VK
248/**
249 * Node information for autodiscovery filter
250 */
5039dede
AK
251typedef struct
252{
967893bb
VK
253 UINT32 dwIpAddr;
254 UINT32 dwNetMask;
255 UINT32 dwSubnetAddr;
256 UINT32 dwFlags;
5039dede 257 int nSNMPVersion;
35f836fe
VK
258 TCHAR szObjectId[MAX_OID_LEN * 4]; // SNMP OID
259 TCHAR szAgentVersion[MAX_AGENT_VERSION_LEN];
260 TCHAR szPlatform[MAX_PLATFORM_NAME_LEN];
5039dede
AK
261} DISCOVERY_FILTER_DATA;
262
0f506caa
VK
263/**
264 * Data update structure for client sessions
265 */
5039dede
AK
266typedef struct
267{
967893bb
VK
268 UINT32 dwCategory; // Data category - event, network object, etc.
269 UINT32 dwCode; // Data-specific update code
5039dede
AK
270 void *pData; // Pointer to data block
271} UPDATE_INFO;
272
72f6ece2 273
534e1b83
VK
274/**
275 * Extended agent connection
276 */
5039dede
AK
277class AgentConnectionEx : public AgentConnection
278{
279protected:
967893bb 280 UINT32 m_nodeId;
d1c1c522 281
af21affe 282 virtual void printMsg(const TCHAR *format, ...);
f480bdd4
VK
283 virtual void onTrap(CSCPMessage *msg);
284 virtual void onDataPush(CSCPMessage *msg);
5039dede
AK
285
286public:
69c6604d
VK
287 AgentConnectionEx(UINT32 nodeId, UINT32 ipAddr, WORD port = AGENT_LISTEN_PORT, int authMethod = AUTH_NONE, const TCHAR *secret = NULL) :
288 AgentConnection(ipAddr, port, authMethod, secret) { m_nodeId = nodeId; }
5039dede 289 virtual ~AgentConnectionEx();
45d84f8a 290
967893bb
VK
291 UINT32 deployPolicy(AgentPolicy *policy);
292 UINT32 uninstallPolicy(AgentPolicy *policy);
5039dede
AK
293};
294
534e1b83
VK
295/**
296 * Mobile device session
297 */
298class NXCORE_EXPORTABLE MobileDeviceSession
299{
300private:
301 SOCKET m_hSocket;
302 Queue *m_pSendQueue;
303 Queue *m_pMessageQueue;
967893bb 304 UINT32 m_dwIndex;
534e1b83
VK
305 int m_iState;
306 WORD m_wCurrentCmd;
967893bb
VK
307 UINT32 m_dwUserId;
308 UINT32 m_deviceObjectId;
534e1b83
VK
309 CSCP_BUFFER *m_pMsgBuffer;
310 NXCPEncryptionContext *m_pCtx;
311 BYTE m_challenge[CLIENT_CHALLENGE_SIZE];
312 THREAD m_hWriteThread;
313 THREAD m_hProcessingThread;
314 MUTEX m_mutexSocketWrite;
315 struct sockaddr *m_clientAddr;
316 TCHAR m_szHostName[256]; // IP address of name of conneced host in textual form
317 TCHAR m_szUserName[MAX_SESSION_NAME]; // String in form login_name@host
318 TCHAR m_szClientInfo[96]; // Client app info string
967893bb
VK
319 UINT32 m_dwEncryptionRqId;
320 UINT32 m_dwEncryptionResult;
534e1b83 321 CONDITION m_condEncryptionSetup;
967893bb 322 UINT32 m_dwRefCount;
534e1b83
VK
323 bool m_isAuthenticated;
324
325 static THREAD_RESULT THREAD_CALL readThreadStarter(void *);
326 static THREAD_RESULT THREAD_CALL writeThreadStarter(void *);
327 static THREAD_RESULT THREAD_CALL processingThreadStarter(void *);
5039dede 328
534e1b83
VK
329 void readThread();
330 void writeThread();
331 void processingThread();
332
333 void setupEncryption(CSCPMessage *request);
967893bb 334 void respondToKeepalive(UINT32 dwRqId);
534e1b83 335 void debugPrintf(int level, const TCHAR *format, ...);
967893bb 336 void sendServerInfo(UINT32 dwRqId);
534e1b83
VK
337 void login(CSCPMessage *pRequest);
338 void updateDeviceInfo(CSCPMessage *pRequest);
339 void updateDeviceStatus(CSCPMessage *pRequest);
340
341public:
342 MobileDeviceSession(SOCKET hSocket, struct sockaddr *addr);
343 ~MobileDeviceSession();
344
345 void incRefCount() { m_dwRefCount++; }
346 void decRefCount() { if (m_dwRefCount > 0) m_dwRefCount--; }
347
348 void run();
349
350 void postMessage(CSCPMessage *pMsg) { m_pSendQueue->Put(pMsg->CreateMessage()); }
351 void sendMessage(CSCPMessage *pMsg);
5039dede 352
967893bb
VK
353 UINT32 getIndex() { return m_dwIndex; }
354 void setIndex(UINT32 dwIndex) { if (m_dwIndex == INVALID_INDEX) m_dwIndex = dwIndex; }
534e1b83
VK
355 int getState() { return m_iState; }
356 const TCHAR *getUserName() { return m_szUserName; }
357 const TCHAR *getClientInfo() { return m_szClientInfo; }
358 const TCHAR *getHostName() { return m_szHostName; }
967893bb 359 UINT32 getUserId() { return m_dwUserId; }
534e1b83
VK
360 bool isAuthenticated() { return m_isAuthenticated; }
361 WORD getCurrentCmd() { return m_wCurrentCmd; }
362 int getCipher() { return (m_pCtx == NULL) ? -1 : m_pCtx->getCipher(); }
363};
364
365/**
366 * Client (user) session
367 */
5039dede
AK
368#define DECLARE_THREAD_STARTER(func) static THREAD_RESULT THREAD_CALL ThreadStarter_##func(void *);
369
a0e3917e 370class NXCORE_EXPORTABLE ClientSession
5039dede
AK
371{
372private:
373 SOCKET m_hSocket;
374 Queue *m_pSendQueue;
375 Queue *m_pMessageQueue;
376 Queue *m_pUpdateQueue;
967893bb 377 UINT32 m_dwIndex;
5039dede
AK
378 int m_iState;
379 WORD m_wCurrentCmd;
967893bb
VK
380 UINT32 m_dwUserId;
381 UINT32 m_dwSystemAccess; // User's system access rights
382 UINT32 m_dwFlags; // Session flags
f8c6f10f 383 int m_clientType; // Client system type - desktop, web, mobile, etc.
5039dede 384 CSCP_BUFFER *m_pMsgBuffer;
98abc9f1 385 NXCPEncryptionContext *m_pCtx;
5039dede
AK
386 BYTE m_challenge[CLIENT_CHALLENGE_SIZE];
387 THREAD m_hWriteThread;
388 THREAD m_hProcessingThread;
389 THREAD m_hUpdateThread;
d3a7cf4c 390 MUTEX m_mutexSocketWrite;
5039dede
AK
391 MUTEX m_mutexSendEvents;
392 MUTEX m_mutexSendSyslog;
393 MUTEX m_mutexSendTrapLog;
394 MUTEX m_mutexSendObjects;
395 MUTEX m_mutexSendAlarms;
396 MUTEX m_mutexSendActions;
397 MUTEX m_mutexSendAuditLog;
398 MUTEX m_mutexSendSituations;
399 MUTEX m_mutexPollerInit;
60557d06 400 struct sockaddr *m_clientAddr;
91f6b72c
VK
401 TCHAR m_workstation[256]; // IP address or name of connected host in textual form
402 TCHAR m_webServerAddress[256]; // IP address or name of web server for web sessions
5039dede
AK
403 TCHAR m_szUserName[MAX_SESSION_NAME]; // String in form login_name@host
404 TCHAR m_szClientInfo[96]; // Client app info string
a51628e2 405 time_t m_loginTime;
967893bb
VK
406 UINT32 m_dwOpenDCIListSize; // Number of open DCI lists
407 UINT32 *m_pOpenDCIList; // List of nodes with DCI lists open
408 UINT32 m_dwNumRecordsToUpload; // Number of records to be uploaded
409 UINT32 m_dwRecordsUploaded;
5039dede
AK
410 EPRule **m_ppEPPRuleList; // List of loaded EPP rules
411 int m_hCurrFile;
967893bb
VK
412 UINT32 m_dwFileRqId;
413 UINT32 m_dwUploadCommand;
414 UINT32 m_dwUploadData;
e928a6db 415 uuid_t m_uploadImageGuid;
5039dede 416 TCHAR m_szCurrFileName[MAX_PATH];
967893bb
VK
417 UINT32 m_dwRefCount;
418 UINT32 m_dwEncryptionRqId;
419 UINT32 m_dwEncryptionResult;
5039dede 420 CONDITION m_condEncryptionSetup;
967893bb 421 UINT32 m_dwActiveChannels; // Active data channels
200d662d 422 CONSOLE_CTX m_console; // Server console context
5039dede 423
534e1b83
VK
424 static THREAD_RESULT THREAD_CALL readThreadStarter(void *);
425 static THREAD_RESULT THREAD_CALL writeThreadStarter(void *);
426 static THREAD_RESULT THREAD_CALL processingThreadStarter(void *);
427 static THREAD_RESULT THREAD_CALL updateThreadStarter(void *);
428 static THREAD_RESULT THREAD_CALL pollerThreadStarter(void *);
5039dede 429
92c51b1d
VK
430 DECLARE_THREAD_STARTER(getCollectedData)
431 DECLARE_THREAD_STARTER(getTableCollectedData)
432 DECLARE_THREAD_STARTER(clearDCIData)
adac28be
VK
433 DECLARE_THREAD_STARTER(queryParameter)
434 DECLARE_THREAD_STARTER(queryAgentTable)
84880c89 435 DECLARE_THREAD_STARTER(queryL2Topology)
b1e9b6b3
VK
436 DECLARE_THREAD_STARTER(sendEventLog)
437 DECLARE_THREAD_STARTER(sendSyslog)
1da08bc6
VK
438 DECLARE_THREAD_STARTER(createObject)
439 DECLARE_THREAD_STARTER(getServerFile)
6f16f12d 440 DECLARE_THREAD_STARTER(getAgentFile)
e05b1945
VK
441 DECLARE_THREAD_STARTER(queryServerLog)
442 DECLARE_THREAD_STARTER(getServerLogQueryData)
e31c8e60 443 DECLARE_THREAD_STARTER(executeAction)
630e15d6 444 DECLARE_THREAD_STARTER(findNodeConnection)
06a93345 445 DECLARE_THREAD_STARTER(findMacAddress)
80e0db05 446 DECLARE_THREAD_STARTER(findIpAddress)
200d662d 447 DECLARE_THREAD_STARTER(processConsoleCommand)
b08d31f4 448 DECLARE_THREAD_STARTER(sendMib)
e12e1422 449 DECLARE_THREAD_STARTER(getReportResults)
3932fde6 450 DECLARE_THREAD_STARTER(deleteReportResults)
e12e1422 451 DECLARE_THREAD_STARTER(renderReport)
6d069676 452 DECLARE_THREAD_STARTER(getNetworkPath)
2bac37f9 453 DECLARE_THREAD_STARTER(getAlarmEvents)
d75003e1 454 DECLARE_THREAD_STARTER(forwardToReportingServer)
5039dede 455
62768df3
VK
456 void readThread();
457 void writeThread();
458 void processingThread();
459 void updateThread();
967893bb 460 void pollerThread(Node *pNode, int iPollType, UINT32 dwRqId);
5039dede 461
9e9d631e 462 void setupEncryption(CSCPMessage *request);
967893bb 463 void respondToKeepalive(UINT32 dwRqId);
e05b1945 464 void onFileUpload(BOOL bSuccess);
534e1b83 465 void debugPrintf(int level, const TCHAR *format, ...);
967893bb 466 void sendServerInfo(UINT32 dwRqId);
711e5e9a 467 void login(CSCPMessage *pRequest);
62768df3
VK
468 void sendAllObjects(CSCPMessage *pRequest);
469 void sendSelectedObjects(CSCPMessage *pRequest);
b1e9b6b3 470 void sendEventLog(CSCPMessage *pRequest);
967893bb 471 void sendAllConfigVars(UINT32 dwRqId);
b1e9b6b3
VK
472 void setConfigVariable(CSCPMessage *pRequest);
473 void deleteConfigVariable(CSCPMessage *pRequest);
967893bb
VK
474 void sendUserDB(UINT32 dwRqId);
475 void sendAllAlarms(UINT32 dwRqId);
b1e9b6b3
VK
476 void createUser(CSCPMessage *pRequest);
477 void updateUser(CSCPMessage *pRequest);
478 void deleteUser(CSCPMessage *pRequest);
479 void setPassword(CSCPMessage *pRequest);
967893bb
VK
480 void lockUserDB(UINT32 dwRqId, BOOL bLock);
481 void sendEventDB(UINT32 dwRqId);
8eb2d92b
VK
482 void modifyEventTemplate(CSCPMessage *pRequest);
483 void deleteEventTemplate(CSCPMessage *pRequest);
967893bb 484 void generateEventCode(UINT32 dwRqId);
92c51b1d 485 void modifyObject(CSCPMessage *pRequest);
1da08bc6 486 void changeObjectMgmtStatus(CSCPMessage *pRequest);
92c51b1d
VK
487 void openNodeDCIList(CSCPMessage *pRequest);
488 void closeNodeDCIList(CSCPMessage *pRequest);
489 void modifyNodeDCI(CSCPMessage *pRequest);
490 void copyDCI(CSCPMessage *pRequest);
491 void applyTemplate(CSCPMessage *pRequest);
492 void getCollectedData(CSCPMessage *pRequest);
493 void getTableCollectedData(CSCPMessage *pRequest);
6fd6de0a 494 bool getCollectedDataFromDB(CSCPMessage *request, CSCPMessage *response, DataCollectionTarget *object, int dciType);
92c51b1d
VK
495 void clearDCIData(CSCPMessage *pRequest);
496 void changeDCIStatus(CSCPMessage *pRequest);
b9a8e081
VK
497 void getLastValues(CSCPMessage *pRequest);
498 void getTableLastValues(CSCPMessage *pRequest);
711e5e9a 499 void getThresholdSummary(CSCPMessage *request);
c9630390 500 void openEPP(CSCPMessage *request);
967893bb 501 void closeEPP(UINT32 dwRqId);
92c51b1d
VK
502 void saveEPP(CSCPMessage *pRequest);
503 void processEPPRecord(CSCPMessage *pRequest);
967893bb 504 void sendMIBTimestamp(UINT32 dwRqId);
b08d31f4 505 void sendMib(CSCPMessage *request);
b1e9b6b3
VK
506 void createObject(CSCPMessage *request);
507 void changeObjectBinding(CSCPMessage *request, BOOL bBind);
508 void deleteObject(CSCPMessage *request);
509 void getAlarm(CSCPMessage *request);
510 void getAlarmEvents(CSCPMessage *request);
511 void acknowledgeAlarm(CSCPMessage *request);
512 void resolveAlarm(CSCPMessage *request, bool terminate);
513 void deleteAlarm(CSCPMessage *request);
1b94acbf
VK
514 void getAlarmNotes(CSCPMessage *pRequest);
515 void updateAlarmNote(CSCPMessage *pRequest);
516 void createAction(CSCPMessage *pRequest);
517 void updateAction(CSCPMessage *pRequest);
518 void deleteAction(CSCPMessage *pRequest);
967893bb
VK
519 void sendAllActions(UINT32 dwRqId);
520 void SendContainerCategories(UINT32 dwRqId);
92c51b1d 521 void forcedNodePoll(CSCPMessage *pRequest);
b1e9b6b3
VK
522 void onTrap(CSCPMessage *pRequest);
523 void onWakeUpNode(CSCPMessage *pRequest);
adac28be
VK
524 void queryParameter(CSCPMessage *pRequest);
525 void queryAgentTable(CSCPMessage *pRequest);
fdbee7f8 526 void editTrap(int iOperation, CSCPMessage *pRequest);
967893bb
VK
527 void LockTrapCfg(UINT32 dwRqId, BOOL bLock);
528 void sendAllTraps(UINT32 dwRqId);
529 void sendAllTraps2(UINT32 dwRqId);
530 void LockPackageDB(UINT32 dwRqId, BOOL bLock);
531 void SendAllPackages(UINT32 dwRqId);
5039dede
AK
532 void InstallPackage(CSCPMessage *pRequest);
533 void RemovePackage(CSCPMessage *pRequest);
534 void DeployPackage(CSCPMessage *pRequest);
074498ac 535 void getParametersList(CSCPMessage *pRequest);
fdbee7f8
VK
536 void getUserVariable(CSCPMessage *pRequest);
537 void setUserVariable(CSCPMessage *pRequest);
538 void copyUserVariable(CSCPMessage *pRequest);
539 void enumUserVariables(CSCPMessage *pRequest);
540 void deleteUserVariable(CSCPMessage *pRequest);
4c789f9e 541 void changeObjectZone(CSCPMessage *pRequest);
92c51b1d
VK
542 void getAgentConfig(CSCPMessage *pRequest);
543 void updateAgentConfig(CSCPMessage *pRequest);
e31c8e60 544 void executeAction(CSCPMessage *pRequest);
967893bb 545 void sendObjectTools(UINT32 dwRqId);
0e950f45
VK
546 void sendObjectToolDetails(CSCPMessage *pRequest);
547 void updateObjectTool(CSCPMessage *pRequest);
548 void deleteObjectTool(CSCPMessage *pRequest);
967893bb 549 void generateObjectToolId(UINT32 dwRqId);
0e950f45 550 void execTableTool(CSCPMessage *pRequest);
b1e9b6b3
VK
551 void changeSubscription(CSCPMessage *pRequest);
552 void sendSyslog(CSCPMessage *pRequest);
967893bb
VK
553 void sendServerStats(UINT32 dwRqId);
554 void sendScriptList(UINT32 dwRqId);
0c7aca90
VK
555 void sendScript(CSCPMessage *pRequest);
556 void updateScript(CSCPMessage *pRequest);
557 void renameScript(CSCPMessage *pRequest);
558 void deleteScript(CSCPMessage *pRequest);
967893bb 559 void SendSessionList(UINT32 dwRqId);
5039dede
AK
560 void KillSession(CSCPMessage *pRequest);
561 void SendTrapLog(CSCPMessage *pRequest);
562 void StartSnmpWalk(CSCPMessage *pRequest);
241c2740 563 void resolveDCINames(CSCPMessage *pRequest);
967893bb 564 UINT32 resolveDCIName(UINT32 dwNode, UINT32 dwItem, TCHAR **ppszName);
5039dede 565 void SendConfigForAgent(CSCPMessage *pRequest);
967893bb 566 void sendAgentCfgList(UINT32 dwRqId);
5039dede
AK
567 void OpenAgentConfig(CSCPMessage *pRequest);
568 void SaveAgentConfig(CSCPMessage *pRequest);
569 void DeleteAgentConfig(CSCPMessage *pRequest);
570 void SwapAgentConfigs(CSCPMessage *pRequest);
571 void SendObjectComments(CSCPMessage *pRequest);
6fd6de0a
VK
572 void updateObjectComments(CSCPMessage *pRequest);
573 void pushDCIData(CSCPMessage *pRequest);
574 void getAddrList(CSCPMessage *pRequest);
575 void setAddrList(CSCPMessage *pRequest);
92c51b1d 576 void resetComponent(CSCPMessage *pRequest);
7a46028e 577 void sendDCIEventList(CSCPMessage *request);
5039dede 578 void SendDCIInfo(CSCPMessage *pRequest);
74526d25 579 void sendPerfTabDCIList(CSCPMessage *pRequest);
a7ff20a5
VK
580 void exportConfiguration(CSCPMessage *pRequest);
581 void importConfiguration(CSCPMessage *pRequest);
967893bb 582 void SendGraphList(UINT32 dwRqId);
7a4c94ee 583 void SaveGraph(CSCPMessage *pRequest);
5039dede
AK
584 void DeleteGraph(CSCPMessage *pRequest);
585 void AddCACertificate(CSCPMessage *pRequest);
586 void DeleteCertificate(CSCPMessage *pRequest);
587 void UpdateCertificateComments(CSCPMessage *pRequest);
967893bb 588 void getCertificateList(UINT32 dwRqId);
84880c89 589 void queryL2Topology(CSCPMessage *pRequest);
b1e9b6b3 590 void sendSMS(CSCPMessage *pRequest);
967893bb 591 void SendCommunityList(UINT32 dwRqId);
5039dede 592 void UpdateCommunityList(CSCPMessage *pRequest);
a882b714
VK
593 void getSituationList(UINT32 dwRqId);
594 void createSituation(CSCPMessage *pRequest);
595 void updateSituation(CSCPMessage *pRequest);
596 void deleteSituation(CSCPMessage *pRequest);
597 void deleteSituationInstance(CSCPMessage *pRequest);
1da08bc6
VK
598 void setConfigCLOB(CSCPMessage *pRequest);
599 void getConfigCLOB(CSCPMessage *pRequest);
1da08bc6
VK
600 void registerAgent(CSCPMessage *pRequest);
601 void getServerFile(CSCPMessage *pRequest);
6f16f12d 602 void getAgentFile(CSCPMessage *pRequest);
1da08bc6 603 void testDCITransformation(CSCPMessage *pRequest);
967893bb 604 void sendJobList(UINT32 dwRqId);
45d84f8a 605 void cancelJob(CSCPMessage *pRequest);
8d9f7450
VK
606 void holdJob(CSCPMessage *pRequest);
607 void unholdJob(CSCPMessage *pRequest);
93599cfd 608 void deployAgentPolicy(CSCPMessage *pRequest, bool uninstallFlag);
d83dc1f0
VK
609 void getUserCustomAttribute(CSCPMessage *request);
610 void setUserCustomAttribute(CSCPMessage *request);
e05b1945
VK
611 void openServerLog(CSCPMessage *request);
612 void closeServerLog(CSCPMessage *request);
613 void queryServerLog(CSCPMessage *request);
614 void getServerLogQueryData(CSCPMessage *request);
967893bb 615 void sendUsmCredentials(UINT32 dwRqId);
df8a4ca2 616 void updateUsmCredentials(CSCPMessage *pRequest);
071fd171 617 void sendDCIThresholds(CSCPMessage *request);
1da08bc6 618 void addClusterNode(CSCPMessage *request);
630e15d6 619 void findNodeConnection(CSCPMessage *request);
06a93345 620 void findMacAddress(CSCPMessage *request);
80e0db05 621 void findIpAddress(CSCPMessage *request);
e6b9439a
AK
622 void sendLibraryImage(CSCPMessage *request);
623 void updateLibraryImage(CSCPMessage *request);
624 void listLibraryImages(CSCPMessage *request);
625 void deleteLibraryImage(CSCPMessage *request);
f69c6203 626 void executeServerCommand(CSCPMessage *request);
619e5c9b 627 void uploadFileToAgent(CSCPMessage *request);
1a5e0c22 628 void listServerFileStore(CSCPMessage *request);
200d662d 629 void processConsoleCommand(CSCPMessage *msg);
967893bb
VK
630 void openConsole(UINT32 rqId);
631 void closeConsole(UINT32 rqId);
7f632dfe 632 void getVlans(CSCPMessage *msg);
68f898c9
VK
633 void receiveFile(CSCPMessage *request);
634 void deleteFile(CSCPMessage *request);
8c5b6ed3
VK
635 void executeReport(CSCPMessage *msg);
636 void getReportResults(CSCPMessage *msg);
3932fde6 637 void deleteReportResults(CSCPMessage *msg);
e12e1422 638 void renderReport(CSCPMessage *request);
6d069676 639 void getNetworkPath(CSCPMessage *request);
8836184f 640 void getNodeComponents(CSCPMessage *request);
caa04e26 641 void getNodeSoftware(CSCPMessage *request);
46ee6286 642 void getWinPerfObjects(CSCPMessage *request);
fdbee7f8
VK
643 void listMappingTables(CSCPMessage *request);
644 void getMappingTable(CSCPMessage *request);
645 void updateMappingTable(CSCPMessage *request);
646 void deleteMappingTable(CSCPMessage *request);
d5de1d1d 647 void getWirelessStations(CSCPMessage *request);
967893bb 648 void getSummaryTables(UINT32 rqId);
b4c2a628
VK
649 void getSummaryTableDetails(CSCPMessage *request);
650 void modifySummaryTable(CSCPMessage *request);
651 void deleteSummaryTable(CSCPMessage *request);
652 void querySummaryTable(CSCPMessage *request);
d75003e1 653 void forwardToReportingServer(CSCPMessage *request);
ceb0fc8d 654 void getSubnetAddressMap(CSCPMessage *request);
5039dede
AK
655
656public:
60557d06 657 ClientSession(SOCKET hSocket, struct sockaddr *addr);
5039dede
AK
658 ~ClientSession();
659
e05b1945
VK
660 void incRefCount() { m_dwRefCount++; }
661 void decRefCount() { if (m_dwRefCount > 0) m_dwRefCount--; }
662
663 void run();
664
d3a7cf4c
VK
665 void postMessage(CSCPMessage *pMsg) { m_pSendQueue->Put(pMsg->CreateMessage()); }
666 void sendMessage(CSCPMessage *pMsg);
92c51b1d 667 void sendRawMessage(CSCP_MESSAGE *pMsg);
967893bb
VK
668 void sendPollerMsg(UINT32 dwRqId, const TCHAR *pszMsg);
669 BOOL sendFile(const TCHAR *file, UINT32 dwRqId);
e05b1945 670
967893bb
VK
671 UINT32 getIndex() { return m_dwIndex; }
672 void setIndex(UINT32 dwIndex) { if (m_dwIndex == INVALID_INDEX) m_dwIndex = dwIndex; }
f669df41 673 int getState() { return m_iState; }
889d7ff7
VK
674 const TCHAR *getUserName() { return m_szUserName; }
675 const TCHAR *getClientInfo() { return m_szClientInfo; }
91f6b72c
VK
676 const TCHAR *getWorkstation() { return m_workstation; }
677 const TCHAR *getWebServerAddress() { return m_webServerAddress; }
967893bb
VK
678 UINT32 getUserId() { return m_dwUserId; }
679 UINT32 getSystemRights() { return m_dwSystemAccess; }
f669df41
VK
680 bool isAuthenticated() { return (m_dwFlags & CSF_AUTHENTICATED) ? true : false; }
681 bool isConsoleOpen() { return (m_dwFlags & CSF_CONSOLE_OPEN) ? true : false; }
967893bb 682 bool isSubscribed(UINT32 dwChannel) { return (m_dwActiveChannels & dwChannel) ? true : false; }
f669df41 683 WORD getCurrentCmd() { return m_wCurrentCmd; }
98abc9f1 684 int getCipher() { return (m_pCtx == NULL) ? -1 : m_pCtx->getCipher(); }
f8c6f10f 685 int getClientType() { return m_clientType; }
a51628e2 686 time_t getLoginTime() { return m_loginTime; }
e05b1945 687
88f2990c 688 bool checkSysAccessRights(UINT32 requiredAccess)
689 {
690 return (m_dwUserId == 0) ? true :
badf9a95 691 ((requiredAccess & m_dwSystemAccess) == requiredAccess);
e05b1945
VK
692 }
693
f669df41 694 void kill();
967893bb 695 void notify(UINT32 dwCode, UINT32 dwData = 0);
e05b1945
VK
696
697 void queueUpdate(UPDATE_INFO *pUpdate) { m_pUpdateQueue->Put(pUpdate); }
698 void onNewEvent(Event *pEvent);
e0f99bf0 699 void onSyslogMessage(NX_SYSLOG_RECORD *pRec);
e05b1945
VK
700 void onNewSNMPTrap(CSCPMessage *pMsg);
701 void onObjectChange(NetObj *pObject);
967893bb
VK
702 void onUserDBUpdate(int code, UINT32 id, UserDatabaseObject *user);
703 void onAlarmUpdate(UINT32 dwCode, NXC_ALARM *pAlarm);
704 void onActionDBUpdate(UINT32 dwCode, NXC_ACTION *pAction);
72f6ece2
AK
705 void onSituationChange(CSCPMessage *msg);
706 void onLibraryImageChange(uuid_t *guid, bool removed = false);
5039dede
AK
707};
708
2bac37f9
VK
709/**
710 * Delayed SQL request
711 */
7dad92fb
VK
712typedef struct
713{
714 TCHAR *query;
715 int bindCount;
716 BYTE *sqlTypes;
717 TCHAR *bindings[1]; /* actual size determined by bindCount field */
718} DELAYED_SQL_REQUEST;
719
2bac37f9
VK
720/**
721 * Delayed request for idata_ INSERT
722 */
f68d9eac
VK
723typedef struct
724{
725 time_t timestamp;
967893bb
VK
726 UINT32 nodeId;
727 UINT32 dciId;
f68d9eac
VK
728 TCHAR value[MAX_RESULT_LENGTH];
729} DELAYED_IDATA_INSERT;
730
7a4c94ee 731/**
732 * Graph ACL entry
733 */
734struct GRAPH_ACL_ENTRY
735{
736 UINT32 dwGraphId;
737 UINT32 dwUserId;
738 UINT32 dwAccess;
739};
740
741/**
742 * Information about graph with name existence and it's ID.
743 */
744struct GRAPH_ACL_AND_ID
745{
88f2990c 746 UINT32 graphId;
7a4c94ee 747 UINT32 status;
748};
749
2bac37f9
VK
750/**
751 * Functions
752 */
35f836fe
VK
753BOOL NXCORE_EXPORTABLE ConfigReadStr(const TCHAR *szVar, TCHAR *szBuffer, int iBufSize, const TCHAR *szDefault);
754#ifdef UNICODE
755BOOL NXCORE_EXPORTABLE ConfigReadStrA(const WCHAR *szVar, char *szBuffer, int iBufSize, const char *szDefault);
756#else
757#define ConfigReadStrA ConfigReadStr
758#endif
5039dede 759int NXCORE_EXPORTABLE ConfigReadInt(const TCHAR *szVar, int iDefault);
967893bb 760UINT32 NXCORE_EXPORTABLE ConfigReadULong(const TCHAR *szVar, UINT32 dwDefault);
5039dede
AK
761BOOL NXCORE_EXPORTABLE ConfigReadByteArray(const TCHAR *pszVar, int *pnArray,
762 int nSize, int nDefault);
763BOOL NXCORE_EXPORTABLE ConfigWriteStr(const TCHAR *szVar, const TCHAR *szValue, BOOL bCreate,
764 BOOL isVisible = TRUE, BOOL needRestart = FALSE);
765BOOL NXCORE_EXPORTABLE ConfigWriteInt(const TCHAR *szVar, int iValue, BOOL bCreate,
766 BOOL isVisible = TRUE, BOOL needRestart = FALSE);
967893bb 767BOOL NXCORE_EXPORTABLE ConfigWriteULong(const TCHAR *szVar, UINT32 dwValue, BOOL bCreate,
5039dede
AK
768 BOOL isVisible = TRUE, BOOL needRestart = FALSE);
769BOOL NXCORE_EXPORTABLE ConfigWriteByteArray(const TCHAR *pszVar, int *pnArray,
770 int nSize, BOOL bCreate,
771 BOOL isVisible = TRUE, BOOL needRestart = FALSE);
772TCHAR NXCORE_EXPORTABLE *ConfigReadCLOB(const TCHAR *var, const TCHAR *defValue);
773BOOL NXCORE_EXPORTABLE ConfigWriteCLOB(const TCHAR *var, const TCHAR *value, BOOL bCreate);
774
28f5b9a4
VK
775BOOL NXCORE_EXPORTABLE MetaDataReadStr(const TCHAR *szVar, TCHAR *szBuffer, int iBufSize, const TCHAR *szDefault);
776
35f836fe 777BOOL NXCORE_EXPORTABLE LoadConfig();
5039dede 778
35f836fe
VK
779void NXCORE_EXPORTABLE Shutdown();
780void NXCORE_EXPORTABLE FastShutdown();
781BOOL NXCORE_EXPORTABLE Initialize();
5039dede 782THREAD_RESULT NXCORE_EXPORTABLE THREAD_CALL Main(void *);
35f836fe
VK
783void NXCORE_EXPORTABLE ShutdownDB();
784void InitiateShutdown();
5039dede
AK
785
786BOOL NXCORE_EXPORTABLE SleepAndCheckForShutdown(int iSeconds);
787
35f836fe
VK
788void ConsolePrintf(CONSOLE_CTX pCtx, const TCHAR *pszFormat, ...);
789int ProcessConsoleCommand(const TCHAR *pszCmdLine, CONSOLE_CTX pCtx);
5039dede
AK
790
791void SaveObjects(DB_HANDLE hdb);
ff6d2c5d
VK
792void NXCORE_EXPORTABLE ObjectTransactionStart();
793void NXCORE_EXPORTABLE ObjectTransactionEnd();
5039dede 794
ce7565e7 795void NXCORE_EXPORTABLE QueueSQLRequest(const TCHAR *query);
7dad92fb 796void NXCORE_EXPORTABLE QueueSQLRequest(const TCHAR *query, int bindCount, int *sqlTypes, const TCHAR **values);
967893bb 797void QueueIDataInsert(time_t timestamp, UINT32 nodeId, UINT32 dciId, const TCHAR *value);
ce7565e7
VK
798void StartDBWriter();
799void StopDBWriter();
5039dede 800
967893bb 801bool NXCORE_EXPORTABLE IsDatabaseRecordExist(DB_HANDLE hdb, const TCHAR *table, const TCHAR *idColumn, UINT32 id);
ba89fed2 802
967893bb 803void DecodeSQLStringAndSetVariable(CSCPMessage *pMsg, UINT32 dwVarId, TCHAR *pszStr);
5039dede 804
1f4c37ee 805SNMP_SecurityContext *SnmpCheckCommSettings(SNMP_Transport *pTransport, int *version, SNMP_SecurityContext *originalContext, StringList *customTestOids);
35f836fe 806void StrToMac(const TCHAR *pszStr, BYTE *pBuffer);
5039dede 807
f42b8099 808void InitLocalNetInfo();
5039dede 809
f42b8099 810ARP_CACHE *GetLocalArpCache();
967893bb 811ARP_CACHE *SnmpGetArpCache(UINT32 dwVersion, SNMP_Transport *pTransport);
5039dede 812
98762401 813InterfaceList *GetLocalInterfaceList();
967893bb 814void SnmpGetInterfaceStatus(UINT32 dwVersion, SNMP_Transport *pTransport, UINT32 dwIfIndex, int *adminState, int *operState);
5039dede 815
967893bb 816ROUTING_TABLE *SnmpGetRoutingTable(UINT32 dwVersion, SNMP_Transport *pTransport);
5039dede 817
9796ce45 818void LoadNetworkDeviceDrivers();
21254a93 819NetworkDeviceDriver *FindDriverForNode(Node *node, SNMP_Transport *pTransport);
28e1575f 820NetworkDeviceDriver *FindDriverByName(const TCHAR *name);
1f4c37ee 821void AddDriverSpecificOids(StringList *list);
9796ce45 822
5ad2167d 823void WatchdogInit();
967893bb
VK
824UINT32 WatchdogAddThread(const TCHAR *szName, time_t tNotifyInterval);
825void WatchdogNotify(UINT32 dwId);
5039dede
AK
826void WatchdogPrintStatus(CONSOLE_CTX pCtx);
827
5ad2167d 828void CheckForMgmtNode();
967893bb 829Node *PollNewNode(UINT32 dwIpAddr, UINT32 dwNetMask, UINT32 dwCreationFlags, WORD agentPort,
88f2990c 830 WORD snmpPort, const TCHAR *pszName, UINT32 dwProxyNode, UINT32 dwSNMPProxy, Cluster *pCluster,
967893bb 831 UINT32 zoneId, bool doConfPoll, bool discoveredNode);
5039dede 832
b1e9b6b3 833void NXCORE_EXPORTABLE EnumerateClientSessions(void (*pHandler)(ClientSession *, void *), void *pArg);
967893bb 834void NXCORE_EXPORTABLE NotifyClientSessions(UINT32 dwCode, UINT32 dwData);
e1ebbfc2 835int GetSessionCount(bool withRoot = true);
967893bb 836bool IsLoggedIn(UINT32 dwUserId);
5039dede 837
35f836fe 838void GetSysInfoStr(TCHAR *pszBuffer, int nMaxSize);
967893bb 839UINT32 GetLocalIpAddr();
f7694811 840TCHAR *GetLocalHostName(TCHAR *buffer, size_t bufSize);
5039dede 841
35f836fe 842BOOL ExecCommand(TCHAR *pszCommand);
967893bb 843BOOL SendMagicPacket(UINT32 dwIpAddr, BYTE *pbMacAddr, int iNumPackets);
5039dede 844
35f836fe 845BOOL InitIdTable();
967893bb 846UINT32 CreateUniqueId(int iGroup);
35f836fe 847QWORD CreateUniqueEventId();
69bb7f47 848void SaveCurrentFreeId();
5039dede 849
35f836fe
VK
850void InitMailer();
851void ShutdownMailer();
852void NXCORE_EXPORTABLE PostMail(const TCHAR *pszRcpt, const TCHAR *pszSubject, const TCHAR *pszText);
5039dede 853
35f836fe
VK
854void InitSMSSender();
855void ShutdownSMSSender();
856void NXCORE_EXPORTABLE PostSMS(const TCHAR *pszRcpt, const TCHAR *pszText);
5039dede 857
35f836fe 858void InitTraps();
967893bb 859void SendTrapsToClient(ClientSession *pSession, UINT32 dwRqId);
5039dede 860void CreateTrapCfgMessage(CSCPMessage &msg);
967893bb
VK
861UINT32 CreateNewTrap(UINT32 *pdwTrapId);
862UINT32 CreateNewTrap(NXC_TRAP_CFG_ENTRY *pTrap);
863UINT32 UpdateTrapFromMsg(CSCPMessage *pMsg);
864UINT32 DeleteTrap(UINT32 dwId);
865void CreateNXMPTrapRecord(String &str, UINT32 dwId);
866
867BOOL IsTableTool(UINT32 dwToolId);
868BOOL CheckObjectToolAccess(UINT32 dwToolId, UINT32 dwUserId);
869UINT32 ExecuteTableTool(UINT32 dwToolId, Node *pNode, UINT32 dwRqId, ClientSession *pSession);
870UINT32 DeleteObjectToolFromDB(UINT32 dwToolId);
871UINT32 UpdateObjectToolFromMessage(CSCPMessage *pMsg);
872
873UINT32 ModifySummaryTable(CSCPMessage *msg, LONG *newId);
874UINT32 DeleteSummaryTable(LONG tableId);
875Table *QuerySummaryTable(LONG tableId, UINT32 baseObjectId, UINT32 userId, UINT32 *rcc);
b4c2a628 876
e0f99bf0 877void CreateMessageFromSyslogMsg(CSCPMessage *pMsg, NX_SYSLOG_RECORD *pRec);
4262c0dc 878void ReinitializeSyslogParser();
5039dede
AK
879
880void EscapeString(String &str);
881
ce7565e7 882void InitAuditLog();
967893bb
VK
883void NXCORE_EXPORTABLE WriteAuditLog(const TCHAR *subsys, BOOL isSuccess, UINT32 userId,
884 const TCHAR *workstation, UINT32 objectId,
ce7565e7 885 const TCHAR *format, ...);
88f2990c 886
967893bb
VK
887bool ValidateConfig(Config *config, UINT32 flags, TCHAR *errorText, int errorTextLen);
888UINT32 ImportConfig(Config *config, UINT32 flags);
5039dede
AK
889
890#ifdef _WITH_ENCRYPTION
891X509 *CertificateFromLoginMessage(CSCPMessage *pMsg);
a50eaebe 892BOOL ValidateUserCertificate(X509 *pCert, const TCHAR *pszLogin, BYTE *pChallenge,
967893bb 893 BYTE *pSignature, UINT32 dwSigLen, int nMappingMethod,
a50eaebe 894 const TCHAR *pszMappingData);
9796ce45 895void ReloadCertificates();
5039dede
AK
896#endif
897
898#ifndef _WIN32
899THREAD_RESULT NXCORE_EXPORTABLE THREAD_CALL SignalHandler(void *);
900#endif /* not _WIN32 */
901
5039dede 902void DbgTestRWLock(RWLOCK hLock, const TCHAR *szName, CONSOLE_CTX pCtx);
534e1b83
VK
903void DumpClientSessions(CONSOLE_CTX pCtx);
904void DumpMobileDeviceSessions(CONSOLE_CTX pCtx);
5039dede 905void ShowPollerState(CONSOLE_CTX pCtx);
35f836fe 906void SetPollerInfo(int nIdx, const TCHAR *pszMsg);
5039dede 907void ShowServerStats(CONSOLE_CTX pCtx);
35f836fe 908void ShowQueueStats(CONSOLE_CTX pCtx, Queue *pQueue, const TCHAR *pszName);
5039dede
AK
909void DumpProcess(CONSOLE_CTX pCtx);
910
88f2990c 911GRAPH_ACL_ENTRY *LoadGraphACL(UINT32 graphId, int *pnACLSize);
9ad921e5
VK
912BOOL CheckGraphAccess(GRAPH_ACL_ENTRY *pACL, int nACLSize, UINT32 graphId, UINT32 graphUserId, UINT32 graphDesiredAccess);
913int GetGraphAccessCheckResult(UINT32 graphId, UINT32 graphUserId);
914GRAPH_ACL_AND_ID IsGraphNameExists(const TCHAR *graphName);
7a4c94ee 915
d00ad4c6 916#if XMPP_SUPPORTED
244c65ef 917bool SendXMPPMessage(const TCHAR *rcpt, const TCHAR *message);
d00ad4c6 918#endif
244c65ef 919
534e1b83
VK
920/**
921 * Global variables
922 */
5039dede
AK
923extern TCHAR NXCORE_EXPORTABLE g_szConfigFile[];
924extern TCHAR NXCORE_EXPORTABLE g_szLogFile[];
967893bb
VK
925extern UINT32 g_dwLogRotationMode;
926extern UINT32 g_dwMaxLogSize;
927extern UINT32 g_dwLogHistorySize;
4f8998ca 928extern TCHAR g_szDailyLogFileSuffix[64];
5039dede
AK
929extern TCHAR NXCORE_EXPORTABLE g_szDumpDir[];
930extern TCHAR NXCORE_EXPORTABLE g_szListenAddress[];
931#ifndef _WIN32
932extern TCHAR NXCORE_EXPORTABLE g_szPIDFile[];
933#endif
934extern TCHAR g_szDataDir[];
9796ce45 935extern TCHAR g_szLibDir[];
712dd47d 936extern TCHAR g_szJavaLibDir[];
967893bb 937extern UINT32 NXCORE_EXPORTABLE g_processAffinityMask;
5039dede
AK
938extern QWORD g_qwServerId;
939extern RSA *g_pServerKey;
c59466d2
VK
940extern UINT32 g_icmpPingSize;
941extern UINT32 g_icmpPingTimeout;
942extern UINT32 g_auditFlags;
943extern time_t g_serverStartTime;
944extern UINT32 g_lockTimeout;
945extern UINT32 g_agentCommandTimeout;
946extern UINT32 g_thresholdRepeatInterval;
947extern int g_requiredPolls;
948extern UINT32 g_slmPollingInterval;
5039dede 949
b8c1ec69
VK
950extern TCHAR g_szDbDriver[];
951extern TCHAR g_szDbDrvParams[];
952extern TCHAR g_szDbServer[];
953extern TCHAR g_szDbLogin[];
954extern TCHAR g_szDbPassword[];
955extern TCHAR g_szDbName[];
f3c30cf5 956extern TCHAR g_szDbSchema[];
712dd47d 957extern TCHAR NXCORE_EXPORTABLE g_szJavaPath[];
b8c1ec69 958extern DB_DRIVER g_dbDriver;
5039dede
AK
959extern DB_HANDLE NXCORE_EXPORTABLE g_hCoreDB;
960extern Queue *g_pLazyRequestQueue;
c9a9601c 961extern Queue *g_pIDataInsertQueue;
5039dede 962
28f5b9a4 963extern int NXCORE_EXPORTABLE g_nDBSyntax;
5039dede
AK
964
965#endif /* _nms_core_h_ */