- Added function StopDBWriter() to ensure flushing SQL query queue on shutdown
[public/netxms.git] / include / nxclapi.h
CommitLineData
80ffed5a
VK
1/*
2** NetXMS - Network Management System
3** Client Library API
4** Copyright (C) 2004 Victor Kirhenshtein
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19**
20** $module: nxclapi.h
21**
22**/
23
24#ifndef _nxclapi_h_
25#define _nxclapi_h_
26
27#include <nms_common.h>
28
29
0c8bf759
VK
30//
31// Some constants
32//
33
34#define MAX_OBJECT_NAME 64
35#define MAX_COMMUNITY_LENGTH 32
36#define MAX_OID_LENGTH 1024
a1dc75b0 37#define MAX_EVENT_MSG_LENGTH 256
0c8bf759
VK
38
39
71c18491
VK
40//
41// Authentication methods
42//
43
44#define AUTH_NONE 0
45#define AUTH_PLAINTEXT 1
46#define AUTH_MD5_HASH 2
47#define AUTH_SHA1_HASH 3
48
49
50//
51// Object types
52//
53
54#define OBJECT_GENERIC 0
55#define OBJECT_SUBNET 1
56#define OBJECT_NODE 2
57#define OBJECT_INTERFACE 3
58#define OBJECT_NETWORK 4
59
60
5fad5c32
VK
61//
62// Events
63//
64
65#define NXC_EVENT_STATE_CHANGED 1
71f8d3d7 66#define NXC_EVENT_ERROR 2
c7f4f5a9 67#define NXC_EVENT_LOGIN_RESULT 3
a1dc75b0 68#define NXC_EVENT_NEW_ELOG_RECORD 4
71f8d3d7
VK
69
70
71//
72// Errors
73//
74
75#define NXC_ERR_INTERNAL 1
5fad5c32
VK
76
77
54481027
VK
78//
79// States
80//
81
82#define STATE_DISCONNECTED 0
83#define STATE_CONNECTING 1
84#define STATE_IDLE 2
7e986059
VK
85#define STATE_SYNC_OBJECTS 3
86#define STATE_SYNC_EVENTS 4
87
88
89//
90// Operations
91//
92
93#define NXC_OP_SYNC_OBJECTS 1
0c8bf759 94#define NXC_OP_SYNC_EVENTS 2
54481027
VK
95
96
97//
0c8bf759 98// Callbacks data types
54481027
VK
99//
100
101typedef void (* NXC_EVENT_HANDLER)(DWORD dwEvent, DWORD dwCode, void *pArg);
5d63b3c1 102typedef void (* NXC_DEBUG_CALLBACK)(char *pMsg);
54481027
VK
103
104
a1dc75b0
VK
105//
106// Event log record structure
107//
108
109typedef struct
110{
111 DWORD dwTimeStamp;
112 DWORD dwEventId;
113 DWORD dwSourceId;
114 DWORD dwSeverity;
115 char szMessage[MAX_EVENT_MSG_LENGTH];
116} NXC_EVENT;
117
118
0c8bf759
VK
119//
120// Network object structure
121//
122
123typedef struct
124{
125 DWORD dwId; // Unique object's identifier
126 int iClass; // Object's class
127 int iStatus; // Object's status
128 DWORD dwIpAddr; // IP address
129 char szName[MAX_OBJECT_NAME];
130 DWORD dwNumParents;
131 DWORD *pdwParentList;
132 DWORD dwNumChilds;
133 DWORD *pdwChildList;
134 union
135 {
136 struct
137 {
138 DWORD dwIpNetMask; // Ip netmask.
139 DWORD dwIfIndex; // Interface index.
140 DWORD dwIfType; // Interface type
141 } iface;
142 struct
143 {
144 DWORD dwFlags;
145 DWORD dwDiscoveryFlags;
146 char szSharedSecret[MAX_SECRET_LENGTH];
147 char szCommunityString[MAX_COMMUNITY_LENGTH];
148 char szObjectId[MAX_OID_LENGTH];
149 WORD wAgentPort; // Listening TCP port for native agent
150 WORD wAuthMethod; // Native agent's authentication method
151 } node;
152 struct
153 {
154 DWORD dwIpNetMask;
155 } subnet;
156 };
157} NXC_OBJECT;
158
159
80ffed5a
VK
160//
161// Functions
162//
163
164#ifdef __cplusplus
165extern "C" {
166#endif
167
54481027
VK
168DWORD EXPORTABLE NXCGetVersion(void);
169BOOL EXPORTABLE NXCInitialize(void);
71f8d3d7 170BOOL EXPORTABLE NXCConnect(char *szServer, char *szLogin, char *szPassword);
54481027
VK
171void EXPORTABLE NXCDisconnect(void);
172void EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler);
5d63b3c1 173void EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc);
54481027 174int EXPORTABLE NXCRequest(DWORD dwOperation, ...);
80ffed5a 175
8b3d61c1
VK
176NXC_OBJECT EXPORTABLE *NXCFindObjectById(DWORD dwId);
177void EXPORTABLE NXCEnumerateObjects(BOOL (* pHandler)(NXC_OBJECT *));
04a534d5 178NXC_OBJECT EXPORTABLE *NXCGetRootObject(void);
8b3d61c1 179
80ffed5a
VK
180#ifdef __cplusplus
181}
182#endif
183
184
7e986059
VK
185//
186// Macros
187//
188
189#define NXCSyncObjects() NXCRequest(NXC_OP_SYNC_OBJECTS)
a1dc75b0 190#define NXCSyncEvents() NXCRequest(NXC_OP_SYNC_EVENTS)
7e986059
VK
191
192
80ffed5a 193#endif /* _nxclapi_h_ */