fixed MacAddress::parse declaration
[public/netxms.git] / include / nxcc.h
1 #ifndef _nxcc_h_
2 #define _nxcc_h_
3
4 #ifdef _WIN32
5 #ifdef LIBNXCC_EXPORTS
6 #define LIBNXCC_EXPORTABLE __declspec(dllexport)
7 #else
8 #define LIBNXCC_EXPORTABLE __declspec(dllimport)
9 #endif
10 #else /* _WIN32 */
11 #define LIBNXCC_EXPORTABLE
12 #endif
13
14 #include <nms_common.h>
15 #include <nms_util.h>
16 #include <nms_threads.h>
17 #include <nxcpapi.h>
18 #include <nxconfig.h>
19
20 /**
21 * Cluster error codes
22 */
23 #define NXCC_RCC_SUCCESS 0
24 #define NXCC_RCC_INVALID_NODE 1
25 #define NXCC_RCC_TIMEOUT 2
26 #define NXCC_RCC_COMM_FAILURE 3
27 #define NXCC_RCC_NOT_MASTER 4
28 #define NXCC_RCC_INVALID_REQUEST 5
29
30 /**
31 * Base value for custom notifications
32 */
33 #define NXCC_CUSTOM_NOTIFICATION_BASE 1000
34
35 /**
36 * Cluster node states
37 */
38 enum ClusterNodeState
39 {
40 CLUSTER_NODE_DOWN = 0,
41 CLUSTER_NODE_CONNECTED = 1,
42 CLUSTER_NODE_SYNC = 2,
43 CLUSTER_NODE_UP = 3
44 };
45
46 /**
47 * Cluster message processing result
48 */
49 enum ClusterMessageProcessingResult
50 {
51 CLUSTER_MSG_IGNORED = 0,
52 CLUSTER_MSG_PROCESSED = 1,
53 CLUSTER_MSG_QUEUED = 2
54 };
55
56 /**
57 * Cluster node event handler
58 */
59 class LIBNXCC_EXPORTABLE ClusterEventHandler
60 {
61 public:
62 ClusterEventHandler();
63 virtual ~ClusterEventHandler();
64
65 virtual void onNodeJoin(UINT32 nodeId);
66 virtual void onNodeUp(UINT32 nodeId);
67 virtual void onNodeDisconnect(UINT32 nodeId);
68 virtual void onShutdown();
69 virtual void onSplitBrain();
70
71 virtual ClusterMessageProcessingResult onMessage(NXCPMessage *msg, UINT32 sourceNodeId);
72 virtual void onNotification(int code, UINT32 sourceNodeId);
73 };
74
75 /**
76 * API functions
77 */
78 bool LIBNXCC_EXPORTABLE ClusterInit(Config *config, const TCHAR *section, ClusterEventHandler *eventHandler);
79 bool LIBNXCC_EXPORTABLE ClusterJoin();
80 void LIBNXCC_EXPORTABLE ClusterSetRunning();
81 void LIBNXCC_EXPORTABLE ClusterShutdown();
82
83 UINT32 LIBNXCC_EXPORTABLE ClusterGetLocalNodeId();
84 UINT32 LIBNXCC_EXPORTABLE ClusterGetMasterNodeId();
85 bool LIBNXCC_EXPORTABLE ClusterIsMasterNode();
86 bool LIBNXCC_EXPORTABLE ClusterIsSyncNeeded();
87 bool LIBNXCC_EXPORTABLE ClusterAllNodesConnected();
88
89 void LIBNXCC_EXPORTABLE ClusterNotify(NXCPMessage *msg);
90 void LIBNXCC_EXPORTABLE ClusterNotify(INT16 code);
91 void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, INT16 code);
92 void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, NXCPMessage *msg);
93 int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg);
94 UINT32 LIBNXCC_EXPORTABLE ClusterSendDirectCommand(UINT32 nodeId, NXCPMessage *msg);
95 NXCPMessage LIBNXCC_EXPORTABLE *ClusterSendDirectCommandEx(UINT32 nodeId, NXCPMessage *msg);
96 void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UINT32 rcc);
97 void LIBNXCC_EXPORTABLE ClusterSendResponseEx(UINT32 nodeId, UINT32 requestId, NXCPMessage *msg);
98
99 #endif