+ sockets reuse (*nix only)
[public/netxms.git] / src / server / include / nms_core.h
CommitLineData
9a19737f 1/*
b54b2b11
VK
2** NetXMS - Network Management System
3** Copyright (C) 2003, 2004 Victor Kirhenshtein
9a19737f
VK
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** $module: nms_core.h
20**
21**/
22
23#ifndef _nms_core_h_
24#define _nms_core_h_
25
a551fe4d
VK
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
3c55b85d
VK
37#define LIBNXCL_NO_DECLARATIONS 1
38
e31784c0 39#include <nms_common.h>
0ee0c807 40
e31784c0 41#ifndef _WIN32
0ee0c807 42
c9ccd685
AK
43#if HAVE_SYS_TYPES_H
44# include <sys/types.h>
45#endif
46
e31784c0 47#if HAVE_DLFCN_H
3a2f672c 48#include <dlfcn.h>
e31784c0 49#endif
0ee0c807 50
5af4c41b 51#define WSAGetLastError() (errno)
0ee0c807 52
9a19737f
VK
53#endif /* _WIN32 */
54
4385fa12
VK
55#include <time.h>
56#include <stdio.h>
57#include <string.h>
f9b7e653 58#include <stdarg.h>
469b937c 59
e31784c0 60#ifdef _WIN32
66c04cc7 61#define _GETOPT_H_ 1 /* Prevent including getopt.h from net-snmp */
53512272 62#define HAVE_SOCKLEN_T /* Prevent defining socklen_t in net-snmp */
e31784c0 63#endif /* _WIN32 */
66c04cc7 64
3d1cb7d6
VK
65//#include <net-snmp/net-snmp-config.h>
66//#include <net-snmp/net-snmp-includes.h>
469b937c 67
9a19737f 68#include <nms_threads.h>
3a2f672c 69#include <dbdrv.h>
5af4c41b 70#include <nms_cscp.h>
4a4afbd0 71#include <nms_util.h>
f11f4edc 72#include <nxsrvapi.h>
b02279eb 73#include <nxcscpapi.h>
e641b7d0 74#include <nximage.h>
77312b6f 75#include <nxqueue.h>
3d1cb7d6 76#include <nxsnmp.h>
d21a14fc 77#include <nxmodule.h>
1275c750 78#include "nms_dcoll.h"
23a32988 79#include "nms_users.h"
3ea35b38 80#include "nms_objects.h"
3a2f672c 81#include "messages.h"
b54b2b11 82#include "nms_locks.h"
257defd7 83#include "nms_pkg.h"
9a19737f
VK
84
85
86//
d2a1dd18 87// Common constants and macros
9a19737f
VK
88//
89
9a19737f 90#ifdef _WIN32
06e7be2f 91
4d5a05a0 92#define DEFAULT_SHELL "cmd.exe"
1275c750 93#define DEFAULT_LOG_FILE "C:\\NetXMS.log"
06e7be2f
VK
94#define DEFAULT_DATA_DIR "C:\\NetXMS\\var"
95
96#define DDIR_MIBS "\\mibs"
e641b7d0 97#define DDIR_IMAGES "\\images"
1c8b8363 98#define DDIR_PACKAGES "\\packages"
06e7be2f 99
9a19737f 100#else /* _WIN32 */
06e7be2f 101
4d5a05a0 102#define DEFAULT_SHELL "/bin/sh"
9e9d381c 103#define DEFAULT_LOG_FILE "/var/log/netxmsd.log"
06e7be2f
VK
104#define DEFAULT_DATA_DIR "/var/netxms"
105
106#define DDIR_MIBS "/mibs"
e641b7d0 107#define DDIR_IMAGES "/images"
acd3bc53 108#define DDIR_PACKAGES "/packages"
06e7be2f 109
9a19737f
VK
110#endif /* _WIN32 */
111
64584976 112#define MAX_LINE_SIZE 4096
3a2f672c 113
4d5a05a0 114#define GROUP_FLAG_BIT ((DWORD)0x80000000)
c7ca9142 115
f92869c9
VK
116typedef void * HSNMPSESSION;
117
b7271ccb
VK
118
119//
3ea35b38
VK
120// Unique identifier group codes
121//
122
123#define IDG_NETWORK_OBJECT 0
ef44d5ea 124#define IDG_CONTAINER_CAT 1
3ea35b38
VK
125#define IDG_EVENT 2
126#define IDG_ITEM 3
840eb902 127#define IDG_SNMP_TRAP 4
a60d4f27 128#define IDG_IMAGE 5
3ea35b38
VK
129#define IDG_ACTION 6
130#define IDG_EVENT_GROUP 7
131#define IDG_THRESHOLD 8
de78f964
VK
132#define IDG_USER 9
133#define IDG_USER_GROUP 10
06e7be2f
VK
134#define IDG_ALARM 11
135#define IDG_ALARM_NOTE 12
257defd7 136#define IDG_PACKAGE 13
3ea35b38
VK
137
138
139//
4385fa12 140// Application flags
9a19737f
VK
141//
142
3e4e127f
VK
143#define AF_STANDALONE 0x00000001
144#define AF_USE_EVENT_LOG 0x00000002
145#define AF_ENABLE_ACCESS_CONTROL 0x00000004
146#define AF_ENABLE_EVENTS_ACCESS_CONTROL 0x00000008
78bf9c68 147#define AF_LOG_SQL_ERRORS 0x00000010
3ea35b38 148#define AF_DELETE_EMPTY_SUBNETS 0x00000020
5add75d8 149#define AF_ENABLE_SNMP_TRAPD 0x00000040
3e4e127f
VK
150#define AF_DEBUG_EVENTS 0x00000100
151#define AF_DEBUG_CSCP 0x00000200
152#define AF_DEBUG_DISCOVERY 0x00000400
153#define AF_DEBUG_DC 0x00000800
83f0529c 154#define AF_DEBUG_HOUSEKEEPER 0x00001000
b54b2b11 155#define AF_DEBUG_LOCKS 0x00002000
4d5a05a0 156#define AF_DEBUG_ACTIONS 0x00004000
0c598d0e 157#define AF_DEBUG_MISC 0x00008000
b1dd534d 158#define AF_DEBUG_SQL 0x00010000
3aeed82c
VK
159#define AF_DEBUG_SNMP 0x00020000
160#define AF_DEBUG_ALL 0x0002FF00
2260ffe5 161#define AF_DB_LOCKED 0x01000000
3e4e127f 162#define AF_SHUTDOWN 0x80000000
a68e217b 163
1a26164f 164#define IsStandalone() (g_dwFlags & AF_STANDALONE)
a68e217b 165#define ShutdownInProgress() (g_dwFlags & AF_SHUTDOWN)
9a19737f
VK
166
167
168//
b54b2b11 169// Client session flags
62f5857f
VK
170//
171
b8bad201
VK
172#define CSF_EVENT_DB_LOCKED ((DWORD)0x0001)
173#define CSF_EPP_LOCKED ((DWORD)0x0002)
174#define CSF_EVENT_DB_MODIFIED ((DWORD)0x0004)
ff550544 175#define CSF_USER_DB_LOCKED ((DWORD)0x0008)
8f7e2482 176#define CSF_EPP_UPLOAD ((DWORD)0x0010)
c9363772 177#define CSF_ACTION_DB_LOCKED ((DWORD)0x0020)
840eb902 178#define CSF_TRAP_CFG_LOCKED ((DWORD)0x0040)
cb7ec554 179#define CSF_AUTHENTICATED ((DWORD)0x0080)
5be45ff2 180#define CSF_PACKAGE_DB_LOCKED ((DWORD)0x0100)
cb7ec554
VK
181
182
183//
184// Client session states
185//
186
187#define SESSION_STATE_INIT 0
188#define SESSION_STATE_IDLE 1
189#define SESSION_STATE_PROCESSING 2
62f5857f
VK
190
191
192//
b54b2b11 193// Information categories for UPDATE_INFO structure
c7ca9142
VK
194//
195
53512272
VK
196#define INFO_CAT_EVENT 1
197#define INFO_CAT_OBJECT_CHANGE 2
03482383 198#define INFO_CAT_ALARM 3
c9363772 199#define INFO_CAT_ACTION 4
c7ca9142
VK
200
201
202//
f9b7e653
VK
203// Event handling subsystem definitions
204//
205
206#include "nms_events.h"
7e495d97 207#include "nms_actions.h"
2260ffe5 208#include "nms_alarm.h"
f9b7e653
VK
209
210
211//
62f5857f
VK
212// Data update structure for client sessions
213//
214
215typedef struct
216{
217 DWORD dwCategory; // Data category - event, network object, etc.
c9363772 218 DWORD dwCode; // Data-specific update code
62f5857f
VK
219 void *pData; // Pointer to data block
220} UPDATE_INFO;
221
222
223//
5af4c41b
VK
224// Client session
225//
226
227class ClientSession
228{
229private:
230 SOCKET m_hSocket;
231 Queue *m_pSendQueue;
4a4afbd0 232 Queue *m_pMessageQueue;
62f5857f 233 Queue *m_pUpdateQueue;
da54bd8d
VK
234 DWORD m_dwIndex;
235 int m_iState;
cb7ec554 236 WORD m_wCurrentCmd;
da54bd8d 237 DWORD m_dwUserId;
4b8ef715 238 DWORD m_dwSystemAccess; // User's system access rights
b54b2b11 239 DWORD m_dwFlags; // Session flags
3664c5ba 240 CSCP_BUFFER *m_pMsgBuffer;
ccdbbb52
VK
241 THREAD m_hWriteThread;
242 THREAD m_hProcessingThread;
243 THREAD m_hUpdateThread;
03482383
VK
244 MUTEX m_mutexSendEvents;
245 MUTEX m_mutexSendObjects;
246 MUTEX m_mutexSendAlarms;
c9363772 247 MUTEX m_mutexSendActions;
d966d18a 248 MUTEX m_mutexPollerInit;
b54b2b11 249 DWORD m_dwHostAddr; // IP address of connected host (network byte order)
257defd7 250 TCHAR m_szUserName[256]; // String in form login_name@host
338493a0
VK
251 DWORD m_dwOpenDCIListSize; // Number of open DCI lists
252 DWORD *m_pOpenDCIList; // List of nodes with DCI lists open
8f7e2482
VK
253 DWORD m_dwNumRecordsToUpload; // Number of records to be uploaded
254 DWORD m_dwRecordsUploaded;
255 EPRule **m_ppEPPRuleList; // List of loaded EPP rules
257defd7
VK
256 int m_hCurrFile;
257 DWORD m_dwFileRqId;
258 DWORD m_dwUploadCommand;
259 DWORD m_dwUploadData;
260 TCHAR m_szCurrFileName[MAX_PATH];
da54bd8d 261
ccdbbb52
VK
262 static THREAD_RESULT THREAD_CALL ReadThreadStarter(void *);
263 static THREAD_RESULT THREAD_CALL WriteThreadStarter(void *);
264 static THREAD_RESULT THREAD_CALL ProcessingThreadStarter(void *);
265 static THREAD_RESULT THREAD_CALL UpdateThreadStarter(void *);
d966d18a 266 static THREAD_RESULT THREAD_CALL PollerThreadStarter(void *);
ccdbbb52
VK
267
268 void ReadThread(void);
269 void WriteThread(void);
270 void ProcessingThread(void);
271 void UpdateThread(void);
d966d18a 272 void PollerThread(Node *pNode, int iPollType, DWORD dwRqId);
ccdbbb52 273
605d2931
VK
274 BOOL CheckSysAccessRights(DWORD dwRequiredAccess)
275 {
276 return m_dwUserId == 0 ? TRUE :
277 ((dwRequiredAccess & m_dwSystemAccess) ? TRUE : FALSE);
278 }
279
257defd7 280 void OnFileUpload(BOOL bSuccess);
da54bd8d 281 void DebugPrintf(char *szFormat, ...);
693119d6 282 void SendServerInfo(DWORD dwRqId);
7257eb7d 283 void Login(CSCPMessage *pRequest);
e100f091 284 void SendAllObjects(DWORD dwRqId);
74a5aa17 285 void SendAllEvents(DWORD dwRqId);
4b8ef715 286 void SendAllConfigVars(void);
23a32988 287 void SendUserDB(DWORD dwRqId);
03482383 288 void SendAllAlarms(DWORD dwRqId, BOOL bIncludeAck);
7257eb7d
VK
289 void CreateUser(CSCPMessage *pRequest);
290 void UpdateUser(CSCPMessage *pRequest);
291 void DeleteUser(CSCPMessage *pRequest);
017e1e13 292 void SetPassword(CSCPMessage *pRequest);
ff550544 293 void LockUserDB(DWORD dwRqId, BOOL bLock);
7257eb7d 294 void SetConfigVariable(CSCPMessage *pRequest);
b54b2b11 295 void SendEventDB(DWORD dwRqId);
37c4d6aa
VK
296 void LockEventDB(DWORD dwRqId);
297 void UnlockEventDB(DWORD dwRqId);
7257eb7d 298 void SetEventInfo(CSCPMessage *pRequest);
37c4d6aa 299 void DeleteEventTemplate(CSCPMessage *pRequest);
c19b2871 300 void GenerateEventCode(DWORD dwRqId);
7257eb7d 301 void ModifyObject(CSCPMessage *pRequest);
c1c39152 302 void ChangeObjectMgmtStatus(CSCPMessage *pRequest);
7257eb7d
VK
303 void OpenNodeDCIList(CSCPMessage *pRequest);
304 void CloseNodeDCIList(CSCPMessage *pRequest);
9ed4eaff 305 void ModifyNodeDCI(CSCPMessage *pRequest);
933aee5c 306 void CopyDCI(CSCPMessage *pRequest);
ebebc8ea 307 void GetCollectedData(CSCPMessage *pRequest);
5b9a1c7b 308 void ChangeDCIStatus(CSCPMessage *pRequest);
06e7be2f
VK
309 void OpenEPP(DWORD dwRqId);
310 void CloseEPP(DWORD dwRqId);
311 void SaveEPP(CSCPMessage *pRequest);
8f7e2482 312 void ProcessEPPRecord(CSCPMessage *pRequest);
06e7be2f
VK
313 void SendMIBList(DWORD dwRqId);
314 void SendMIB(CSCPMessage *pRequest);
e6b958c4
VK
315 void CreateObject(CSCPMessage *pRequest);
316 void ChangeObjectBinding(CSCPMessage *pRequest, BOOL bBind);
88039e6c 317 void DeleteObject(CSCPMessage *pRequest);
ee20e615 318 void AcknowlegeAlarm(CSCPMessage *pRequest);
1dac1073 319 void DeleteAlarm(CSCPMessage *pRequest);
c9363772
VK
320 void CreateAction(CSCPMessage *pRequest);
321 void UpdateAction(CSCPMessage *pRequest);
322 void DeleteAction(CSCPMessage *pRequest);
323 void LockActionDB(DWORD dwRqId, BOOL bLock);
e91cb822 324 void SendAllActions(DWORD dwRqId);
6849d9be 325 void SendContainerCategories(DWORD dwRqId);
0b89f5fb 326 void ForcedNodePoll(CSCPMessage *pRequest);
b562fca8 327 void OnTrap(CSCPMessage *pRequest);
ed1140dc 328 void OnWakeUpNode(CSCPMessage *pRequest);
80de4676 329 void QueryParameter(CSCPMessage *pRequest);
693119d6 330 void EditTrap(int iOperation, CSCPMessage *pRequest);
b4895bbe
VK
331 void LockTrapCfg(DWORD dwRqId, BOOL bLock);
332 void SendAllTraps(DWORD dwRqId);
5be45ff2 333 void LockPackageDB(DWORD dwRqId, BOOL bLock);
1c8b8363 334 void SendAllPackages(DWORD dwRqId);
257defd7 335 void InstallPackage(CSCPMessage *pRequest);
f6aa542e 336 void RemovePackage(CSCPMessage *pRequest);
5af4c41b
VK
337
338public:
b54b2b11 339 ClientSession(SOCKET hSocket, DWORD dwHostAddr);
5af4c41b
VK
340 ~ClientSession();
341
ccdbbb52 342 void Run(void);
da54bd8d 343
3c55b85d 344 void SendMessage(CSCPMessage *pMsg) { m_pSendQueue->Put(pMsg->CreateMessage()); }
d966d18a 345 void SendPollerMsg(DWORD dwRqId, TCHAR *pszMsg);
3c55b85d 346
da54bd8d
VK
347 DWORD GetIndex(void) { return m_dwIndex; }
348 void SetIndex(DWORD dwIndex) { if (m_dwIndex == INVALID_INDEX) m_dwIndex = dwIndex; }
62f5857f 349 int GetState(void) { return m_iState; }
c868331f 350 const char *GetUserName(void) { return m_szUserName; }
03482383 351 DWORD GetUserId(void) { return m_dwUserId; }
cb7ec554
VK
352 BOOL IsAuthenticated(void) { return (m_dwFlags & CSF_AUTHENTICATED) ? TRUE : FALSE; }
353 WORD GetCurrentCmd(void) { return m_wCurrentCmd; }
20177e8e
VK
354
355 void Kill(void);
4de204a3 356 void Notify(DWORD dwCode, DWORD dwData = 0);
62f5857f
VK
357
358 void OnNewEvent(Event *pEvent);
53512272 359 void OnObjectChange(NetObj *pObject);
984542f8 360 void OnUserDBUpdate(int iCode, DWORD dwUserId, NMS_USER *pUser, NMS_USER_GROUP *pGroup);
03482383 361 void OnAlarmUpdate(DWORD dwCode, NXC_ALARM *pAlarm);
c9363772 362 void OnActionDBUpdate(DWORD dwCode, NXC_ACTION *pAction);
5af4c41b
VK
363};
364
365
366//
9a19737f
VK
367// Functions
368//
369
a551fe4d
VK
370BOOL NXCORE_EXPORTABLE ConfigReadStr(char *szVar, char *szBuffer, int iBufSize, const char *szDefault);
371int NXCORE_EXPORTABLE ConfigReadInt(char *szVar, int iDefault);
372DWORD NXCORE_EXPORTABLE ConfigReadULong(char *szVar, DWORD dwDefault);
373BOOL NXCORE_EXPORTABLE ConfigWriteStr(char *szVar, char *szValue, BOOL bCreate);
374BOOL NXCORE_EXPORTABLE ConfigWriteInt(char *szVar, int iValue, BOOL bCreate);
375BOOL NXCORE_EXPORTABLE ConfigWriteULong(char *szVar, DWORD dwValue, BOOL bCreate);
7084ac81 376
a551fe4d 377BOOL NXCORE_EXPORTABLE LoadConfig(void);
9a19737f 378
a551fe4d
VK
379void NXCORE_EXPORTABLE Shutdown(void);
380BOOL NXCORE_EXPORTABLE Initialize(void);
381void NXCORE_EXPORTABLE Main(void);
382void NXCORE_EXPORTABLE ShutdownDB(void);
9a19737f 383
a551fe4d 384BOOL NXCORE_EXPORTABLE SleepAndCheckForShutdown(int iSeconds);
d627ae40 385
d627ae40
VK
386void SaveObjects(void);
387
067f2689 388void QueueSQLRequest(char *szQuery);
ccdbbb52 389void StartDBWriter(void);
83f0529c 390void StopDBWriter(void);
067f2689 391
be0a5a53 392void SnmpInit(void);
80de4676
VK
393DWORD SnmpGet(DWORD dwVersion, DWORD dwAddr, const char *szCommunity, const char *szOidStr,
394 const DWORD *oidBinary, DWORD dwOidLen, void *pValue,
395 DWORD dwBufferSize, BOOL bVerbose, BOOL bStringResult);
396DWORD SnmpEnumerate(DWORD dwVersion, DWORD dwAddr, const char *szCommunity, const char *szRootOid,
397 void (* pHandler)(DWORD, DWORD, const char *, SNMP_Variable *, void *),
398 void *pUserArg, BOOL bVerbose);
b50f1100 399void StrToMac(char *pszStr, BYTE *pBuffer);
18e26ff8 400DWORD OidToType(TCHAR *pszOid, DWORD *pdwFlags);
d7d76e50 401
b688074e
VK
402void InitLocalNetInfo(void);
403
910ca685 404ARP_CACHE *GetLocalArpCache(void);
37c4d6aa 405ARP_CACHE *SnmpGetArpCache(DWORD dwVersion, DWORD dwAddr, const char *szCommunity);
910ca685 406
37c4d6aa 407INTERFACE_LIST *SnmpGetInterfaceList(DWORD dwVersion, DWORD dwAddr, const char *szCommunity, DWORD dwNodeType);
910ca685 408INTERFACE_LIST *GetLocalInterfaceList(void);
48b1c0ac 409void CleanInterfaceList(INTERFACE_LIST *pIfList);
80de4676 410int SnmpGetInterfaceStatus(DWORD dwNodeAddr, DWORD dwVersion, char *pszCommunity, DWORD dwIfIndex);
a0495b6e 411
f91fa4c2 412void WatchdogInit(void);
a97797f8 413DWORD WatchdogAddThread(char *szName, time_t tNotifyInterval);
f91fa4c2
VK
414void WatchdogNotify(DWORD dwId);
415void WatchdogPrintStatus(void);
416
3e4e127f 417void CheckForMgmtNode(void);
b900a78b 418NetObj *PollNewNode(DWORD dwIpAddr, DWORD dwNetMask, DWORD dwFlags, TCHAR *pszName);
3e4e127f 419
62f5857f 420void EnumerateClientSessions(void (*pHandler)(ClientSession *, void *), void *pArg);
3421c063 421void NotifyClient(ClientSession *pSession, void *pArg);
62f5857f 422
c7ca9142
VK
423void GetSysInfoStr(char *pszBuffer);
424DWORD GetLocalIpAddr(void);
425
4d5a05a0 426BOOL ExecCommand(char *pszCommand);
ed1140dc 427BOOL SendMagicPacket(DWORD dwIpAddr, BYTE *pbMacAddr, int iNumPackets);
4d5a05a0 428
3ea35b38
VK
429BOOL InitIdTable(void);
430DWORD CreateUniqueId(int iGroup);
0c6014e4 431QWORD CreateUniqueEventId(void);
3ea35b38 432
06e7be2f
VK
433BYTE *LoadFile(char *pszFileName, DWORD *pdwFileSize);
434
e641b7d0 435void UpdateImageHashes(void);
aa3743b2
VK
436void SendImageCatalogue(ClientSession *pSession, DWORD dwRqId, WORD wFormat);
437void SendImageFile(ClientSession *pSession, DWORD dwRqId, DWORD dwImageId, WORD wFormat);
8bff53f6 438void SendDefaultImageList(ClientSession *pSession, DWORD dwRqId);
e641b7d0 439
a551fe4d
VK
440char NXCORE_EXPORTABLE *EncodeSQLString(const char *pszIn);
441void NXCORE_EXPORTABLE DecodeSQLString(char *pszStr);
8f7e2482 442
b86ba1c0
VK
443void InitMailer(void);
444void ShutdownMailer(void);
a551fe4d 445void NXCORE_EXPORTABLE PostMail(char *pszRcpt, char *pszSubject, char *pszText);
b86ba1c0 446
37c4d6aa 447void GetAccelarVLANIfList(DWORD dwVersion, DWORD dwIpAddr, const TCHAR *pszCommunity, INTERFACE_LIST *pIfList);
18e26ff8 448
106e7ae3 449void InitTraps(void);
840eb902 450void SendTrapsToClient(ClientSession *pSession, DWORD dwRqId);
693119d6
VK
451DWORD CreateNewTrap(DWORD *pdwTrapId);
452DWORD UpdateTrapFromMsg(CSCPMessage *pMsg);
106e7ae3 453DWORD DeleteTrap(DWORD dwId);
840eb902 454
9a19737f
VK
455#ifdef _WIN32
456
a551fe4d 457char NXCORE_EXPORTABLE *GetSystemErrorText(DWORD error);
9f881a19
AK
458#define SetSocketReuseFlag(sd)
459}
a551fe4d
VK
460
461#else
9a19737f 462
a551fe4d 463void NXCORE_EXPORTABLE OnSignal(int iSignal);
9a19737f 464
9f881a19
AK
465#define SetSocketReuseFlag(sd) { \
466 int nVal = 1; \
467 setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *)&nVal, \
468 (socklen_t)sizeof(nVal)); \
469}
470
9a19737f
VK
471#endif /* _WIN32 */
472
dbe67493
VK
473void DbgTestMutex(MUTEX hMutex, TCHAR *szName);
474void DbgTestRWLock(RWLOCK hLock, TCHAR *szName);
475void DbgPrintf(DWORD dwFlags, TCHAR *szFormat, ...);
c868331f 476void DumpSessions(void);
be0a5a53 477
9a19737f
VK
478
479//
480// Global variables
481//
482
a551fe4d
VK
483extern DWORD NXCORE_EXPORTABLE g_dwFlags;
484extern char NXCORE_EXPORTABLE g_szConfigFile[];
485extern char NXCORE_EXPORTABLE g_szLogFile[];
9e9d381c 486#ifndef _WIN32
a551fe4d 487extern char NXCORE_EXPORTABLE g_szPIDFile[];
9e9d381c 488#endif
06e7be2f 489extern char g_szDataDir[];
3a2f672c 490
3a2f672c 491extern DB_HANDLE g_hCoreDB;
067f2689 492extern Queue *g_pLazyRequestQueue;
9a19737f 493
eb8b1960
VK
494extern char *g_pszStatusName[];
495
9a19737f 496#endif /* _nms_core_h_ */