all pollers converted to single thread pool
[public/netxms.git] / src / server / include / nxmodule.h
CommitLineData
c0a48696 1/*
5039dede 2** NetXMS - Network Management System
46ee6286 3** Copyright (C) 2003-2013 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: nxmodule.h
20**
21**/
22
23#ifndef _nxmodule_h_
24#define _nxmodule_h_
25
50546cb7 26#include <nxdbapi.h>
208d7427 27
534e1b83
VK
28/**
29 * Forward declaration of server classes
30 */
5039dede 31class ClientSession;
534e1b83 32class MobileDeviceSession;
5039dede
AK
33class Node;
34class Event;
496390c2 35class NetObj;
208d7427 36class PollerInfo;
c0a48696 37class NXSL_Environment;
0cdf79a3 38struct NXCORE_LOG;
5039dede 39
534e1b83
VK
40/**
41 * Command handler return codes
42 */
5039dede
AK
43#define NXMOD_COMMAND_IGNORED -1
44#define NXMOD_COMMAND_PROCESSED 0
45#define NXMOD_COMMAND_ACCEPTED_ASYNC 1
46
4f5d216b
VK
47/**
48 * Module-specific object data
49 */
50class NXCORE_EXPORTABLE ModuleData
51{
52public:
53 ModuleData();
54 virtual ~ModuleData();
2e590d1a 55
b368969c 56 virtual void fillMessage(NXCPMessage *msg, UINT32 baseId);
dcc8b1bc
VK
57 virtual bool saveToDatabase(DB_HANDLE hdb, UINT32 objectId);
58 virtual bool deleteFromDatabase(DB_HANDLE hdb, UINT32 objectId);
4f5d216b
VK
59};
60
534e1b83
VK
61/**
62 * Module registration structure
63 */
5039dede
AK
64typedef struct
65{
967893bb 66 UINT32 dwSize; // Size of structure in bytes
5039dede 67 TCHAR szName[MAX_OBJECT_NAME];
53d2de79 68 void (* pfServerStarted)();
496390c2
VK
69 void (* pfShutdown)();
70 void (* pfLoadObjects)();
71 void (* pfLinkObjects)();
b368969c
VK
72 int (* pfClientCommandHandler)(UINT32 dwCommand, NXCPMessage *pMsg, ClientSession *pSession);
73 int (* pfMobileDeviceCommandHandler)(UINT32 dwCommand, NXCPMessage *pMsg, MobileDeviceSession *pSession);
5039dede
AK
74 BOOL (* pfTrapHandler)(SNMP_PDU *pdu, Node *pNode);
75 BOOL (* pfEventHandler)(Event *event);
967893bb 76 void (* pfAlarmChangeHook)(UINT32 changeCode, NXC_ALARM *alarm);
208d7427
VK
77 void (* pfStatusPollHook)(Node *node, ClientSession *session, UINT32 rqId, PollerInfo *poller);
78 bool (* pfConfPollHook)(Node *node, ClientSession *session, UINT32 rqId, PollerInfo *poller);
79 void (* pfTopologyPollHook)(Node *node, ClientSession *session, UINT32 rqId, PollerInfo *poller);
f84f22b5 80 int (* pfCalculateObjectStatus)(NetObj *object);
496390c2
VK
81 BOOL (* pfNetObjInsert)(NetObj *object);
82 BOOL (* pfNetObjDelete)(NetObj *object);
95171c4b 83 void (* pfPostObjectCreate)(NetObj *object);
3ef332c7 84 void (* pfPostObjectLoad)(NetObj *object);
95171c4b 85 void (* pfPreObjectDelete)(NetObj *object);
b368969c 86 NetObj *(* pfCreateObject)(int objectClass, const TCHAR *name, NetObj *parent, NXCPMessage *msg);
496390c2 87 BOOL (* pfIsValidParentClass)(int childClass, int parentClass);
c75e9ee4
VK
88 BOOL (* pfAcceptNewNode)(const InetAddress& addr, UINT32 zoneId, BYTE *macAddr);
89 UINT32 (* pfValidateObjectCreation)(int objectClass, const TCHAR *name, const InetAddress& ipAddr, UINT32 zoneId, NXCPMessage *request);
b368969c 90 UINT32 (* pfAdditionalLoginCheck)(UINT32 userId, NXCPMessage *request);
a77272b7 91 void (* pfClientSessionClose)(ClientSession *session);
e9902466
VK
92 void (* pfNXSLServerEnvConfig)(NXSL_Environment *env);
93 void (* pfOnConnectToAgent)(Node *node, AgentConnection *conn);
94 BOOL (* pfOnAgentMessage)(NXCPMessage *msg, UINT32 nodeId);
0cdf79a3 95 NXCORE_LOG *logs;
5039dede
AK
96 HMODULE hModule;
97} NXMODULE;
98
a0efa7b5
VK
99/**
100 * Enumerate all modules where given entry point available
101 */
c8076b19 102#define ENUMERATE_MODULES(e) if (!(g_flags & AF_SHUTDOWN)) \
a0efa7b5
VK
103 for(UINT32 __i = 0; __i < g_dwNumModules; __i++) \
104 if (g_pModuleList[__i]. e != NULL)
105
106/**
107 * Call module entry point for all loaded modules
108 */
c8076b19 109#define CALL_ALL_MODULES(e, p) if (!(g_flags & AF_SHUTDOWN)) { \
a0efa7b5
VK
110 for(UINT32 __i = 0; __i < g_dwNumModules; __i++) { \
111 if (g_pModuleList[__i]. e != NULL) { g_pModuleList[__i]. e p; } \
112 } \
113}
114
534e1b83
VK
115/**
116 * Functions
117 */
890478d8 118bool LoadNetXMSModules();
5039dede 119
534e1b83
VK
120/**
121 * Global variables
122 */
967893bb 123extern UINT32 g_dwNumModules;
5039dede
AK
124extern NXMODULE *g_pModuleList;
125
5039dede 126#endif /* _nxmodule_h_ */