libgd compiles under VS2005; more components added to 64bit build
[public/netxms.git] / include / nms_agent.h
CommitLineData
cbcaf8c8 1/*
7ac71e60 2** NetXMS - Network Management System
e2d68ddd 3** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
cbcaf8c8
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**
456d5d1c 19** File: nms_agent.h
cbcaf8c8
VK
20**
21**/
22
23#ifndef _nms_agent_h_
24#define _nms_agent_h_
25
adc00755 26#include <nms_common.h>
64584976 27#include <nms_util.h>
6827d635
VK
28
29
b5138dfb
VK
30//
31// Initialization function declaration macro
32//
33
a0a945fb 34#if defined(_STATIC_AGENT) || defined(_NETWARE)
f0be41a4 35#define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL NxSubAgentRegister_##name(NETXMS_SUBAGENT_INFO **ppInfo, TCHAR *pszConfigFile)
a0a945fb 36#else
b5138dfb 37#ifdef _WIN32
a0a945fb 38#define DECLSPEC_EXPORT __declspec(dllexport) __cdecl
b5138dfb
VK
39#else
40#define DECLSPEC_EXPORT
41#endif
f0be41a4 42#define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL DECLSPEC_EXPORT NxSubAgentRegister(NETXMS_SUBAGENT_INFO **ppInfo, TCHAR *pszConfigFile)
b5138dfb
VK
43#endif
44
45
cbcaf8c8
VK
46//
47// Some constants
48//
49
50#define AGENT_LISTEN_PORT 4700
deaa4491 51#define AGENT_PROTOCOL_VERSION 2
cbcaf8c8 52#define MAX_RESULT_LENGTH 256
e22f1644
VK
53#define MAX_CMD_LEN 256
54#define COMMAND_TIMEOUT 60
47e0446b 55#define MAX_SUBAGENT_NAME 64
cbcaf8c8
VK
56
57
58//
59// Error codes
60//
61
deaa4491
VK
62#define ERR_SUCCESS ((DWORD)0)
63#define ERR_UNKNOWN_COMMAND ((DWORD)400)
64#define ERR_AUTH_REQUIRED ((DWORD)401)
d096bcdd 65#define ERR_ACCESS_DENIED ((DWORD)403)
deaa4491
VK
66#define ERR_UNKNOWN_PARAMETER ((DWORD)404)
67#define ERR_REQUEST_TIMEOUT ((DWORD)408)
68#define ERR_AUTH_FAILED ((DWORD)440)
69#define ERR_ALREADY_AUTHENTICATED ((DWORD)441)
70#define ERR_AUTH_NOT_REQUIRED ((DWORD)442)
71#define ERR_INTERNAL_ERROR ((DWORD)500)
72#define ERR_NOT_IMPLEMENTED ((DWORD)501)
73#define ERR_OUT_OF_RESOURCES ((DWORD)503)
74#define ERR_NOT_CONNECTED ((DWORD)900)
75#define ERR_CONNECTION_BROKEN ((DWORD)901)
1a17feb0 76#define ERR_BAD_RESPONSE ((DWORD)902)
d096bcdd
VK
77#define ERR_IO_FAILURE ((DWORD)903)
78#define ERR_RESOURCE_BUSY ((DWORD)904)
e925a5fc 79#define ERR_EXEC_FAILED ((DWORD)905)
e44ac467
VK
80#define ERR_ENCRYPTION_REQUIRED ((DWORD)906)
81#define ERR_NO_CIPHERS ((DWORD)907)
82#define ERR_INVALID_PUBLIC_KEY ((DWORD)908)
83#define ERR_INVALID_SESSION_KEY ((DWORD)909)
1ba3c17a 84#define ERR_CONNECT_FAILED ((DWORD)910)
bff234b8 85#define ERR_MAILFORMED_COMMAND ((DWORD)911)
f1448d17 86#define ERR_SOCKET_ERROR ((DWORD)912)
dbca7ed1 87#define ERR_BAD_ARGUMENTS ((DWORD)913)
5405ce0b 88#define ERR_SUBAGENT_LOAD_FAILED ((DWORD)914)
deb10d32
VK
89#define ERR_FILE_OPEN_ERROR ((DWORD)915)
90#define ERR_FILE_STAT_FAILED ((DWORD)916)
91#define ERR_MEM_ALLOC_FAILED ((DWORD)917)
92#define ERR_FILE_DELETE_FAILED ((DWORD)918)
cbcaf8c8
VK
93
94
95//
96// Parameter handler return codes
97//
98
99#define SYSINFO_RC_SUCCESS 0
100#define SYSINFO_RC_UNSUPPORTED 1
101#define SYSINFO_RC_ERROR 2
102
103
30c68fa1
AK
104//
105// Descriptions for common parameters
106//
107
108#define DCIDESC_DISK_AVAIL "Available disk space on {instance}"
109#define DCIDESC_DISK_AVAILPERC "Percentage of available disk space on {instance}"
110#define DCIDESC_DISK_FREE "Free disk space on {instance}"
111#define DCIDESC_DISK_FREEPERC "Percentage of free disk space on {instance}"
112#define DCIDESC_DISK_TOTAL "Total disk space on {instance}"
113#define DCIDESC_DISK_USED "Used disk space on {instance}"
114#define DCIDESC_DISK_USEDPERC "Percentage of used disk space on {instance}"
115#define DCIDESC_NET_INTERFACE_ADMINSTATUS "Administrative status of interface {instance}"
116#define DCIDESC_NET_INTERFACE_BYTESIN "Number of input bytes on interface {instance}"
117#define DCIDESC_NET_INTERFACE_BYTESOUT "Number of output bytes on interface {instance}"
e7e5ef1c 118#define DCIDESC_NET_INTERFACE_DESCRIPTION "Description of interface {instance}"
30c68fa1
AK
119#define DCIDESC_NET_INTERFACE_INERRORS "Number of input errors on interface {instance}"
120#define DCIDESC_NET_INTERFACE_LINK "Link status for interface {instance}"
121#define DCIDESC_NET_INTERFACE_OUTERRORS "Number of output errors on interface {instance}"
122#define DCIDESC_NET_INTERFACE_PACKETSIN "Number of input packets on interface {instance}"
123#define DCIDESC_NET_INTERFACE_PACKETSOUT "Number of output packets on interface {instance}"
124#define DCIDESC_NET_INTERFACE_SPEED "Speed of interface {instance}"
125#define DCIDESC_NET_IP_FORWARDING "IP forwarding status"
126#define DCIDESC_NET_IP6_FORWARDING "IPv6 forwarding status"
127#define DCIDESC_PHYSICALDISK_FIRMWARE "Firmware version of hard disk {instance}"
128#define DCIDESC_PHYSICALDISK_MODEL "Model of hard disk {instance}"
129#define DCIDESC_PHYSICALDISK_SERIALNUMBER "Serial number of hard disk {instance}"
130#define DCIDESC_PHYSICALDISK_SMARTATTR ""
131#define DCIDESC_PHYSICALDISK_SMARTSTATUS "Status of hard disk {instance} reported by SMART"
132#define DCIDESC_PHYSICALDISK_TEMPERATURE "Temperature of hard disk {instance}"
133#define DCIDESC_SYSTEM_CPU_COUNT "Number of CPU in the system"
134#define DCIDESC_SYSTEM_HOSTNAME "Host name"
135#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE "Free physical memory"
8a78d30d 136#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE_PCT "Percentage of free physical memory"
30c68fa1
AK
137#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_TOTAL "Total amount of physical memory"
138#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED "Used physical memory"
8a78d30d 139#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED_PCT "Percentage of used physical memory"
30c68fa1 140#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE "Free virtual memory"
8a78d30d 141#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE_PCT "Percentage of free virtual memory"
30c68fa1
AK
142#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_TOTAL "Total amount of virtual memory"
143#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED "Used virtual memory"
8a78d30d 144#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED_PCT "Percentage of used virtual memory"
30c68fa1 145#define DCIDESC_SYSTEM_MEMORY_SWAP_FREE "Free swap space"
8a78d30d 146#define DCIDESC_SYSTEM_MEMORY_SWAP_FREE_PCT "Percentage of free swap space"
30c68fa1
AK
147#define DCIDESC_SYSTEM_MEMORY_SWAP_TOTAL "Total amount of swap space"
148#define DCIDESC_SYSTEM_MEMORY_SWAP_USED "Used swap space"
8a78d30d 149#define DCIDESC_SYSTEM_MEMORY_SWAP_USED_PCT "Percentage of used swap space"
30c68fa1
AK
150#define DCIDESC_SYSTEM_UNAME "System uname"
151#define DCIDESC_AGENT_ACCEPTEDCONNECTIONS "Number of connections accepted by agent"
152#define DCIDESC_AGENT_ACCEPTERRORS "Number of accept() call errors"
153#define DCIDESC_AGENT_ACTIVECONNECTIONS "Number of active connections to agent"
154#define DCIDESC_AGENT_AUTHENTICATIONFAILURES "Number of authentication failures"
522f6f07 155#define DCIDESC_AGENT_CONFIG_SERVER "Configuration server address set on agent startup"
30c68fa1
AK
156#define DCIDESC_AGENT_FAILEDREQUESTS "Number of failed requests to agent"
157#define DCIDESC_AGENT_PROCESSEDREQUESTS "Number of requests processed by agent"
522f6f07 158#define DCIDESC_AGENT_REGISTRAR "Registrar server address set on agent startup"
30c68fa1
AK
159#define DCIDESC_AGENT_REJECTEDCONNECTIONS "Number of connections rejected by agent"
160#define DCIDESC_AGENT_SOURCEPACKAGESUPPORT ""
161#define DCIDESC_AGENT_SUPPORTEDCIPHERS "List of ciphers supported by agent"
162#define DCIDESC_AGENT_TIMEDOUTREQUESTS "Number of timed out requests to agent"
163#define DCIDESC_AGENT_UNSUPPORTEDREQUESTS "Number of requests for unsupported parameters"
164#define DCIDESC_AGENT_UPTIME "Agent's uptime"
165#define DCIDESC_AGENT_VERSION "Agent's version"
166#define DCIDESC_FILE_COUNT "Number of files {instance}"
167#define DCIDESC_FILE_HASH_CRC32 "CRC32 checksum of {instance}"
168#define DCIDESC_FILE_HASH_MD5 "MD5 hash of {instance}"
169#define DCIDESC_FILE_HASH_SHA1 "SHA1 hash of {instance}"
170#define DCIDESC_FILE_SIZE "Size of file {instance}"
171#define DCIDESC_FILE_TIME_ACCESS "Time of last access to file {instance}"
172#define DCIDESC_FILE_TIME_CHANGE "Time of last status change of file {instance}"
173#define DCIDESC_FILE_TIME_MODIFY "Time of last modification of file {instance}"
174#define DCIDESC_SYSTEM_PLATFORMNAME "Platform name"
175#define DCIDESC_PROCESS_COUNT "Number of {instance} processes"
176#define DCIDESC_PROCESS_COUNTEX "Number of {instance} processes (extended)"
a765d97c 177#define DCIDESC_PROCESS_GDIOBJ "GDI objects used by process {instance}"
30c68fa1
AK
178#define DCIDESC_PROCESS_IO_OTHERB ""
179#define DCIDESC_PROCESS_IO_OTHEROP ""
180#define DCIDESC_PROCESS_IO_READB ""
181#define DCIDESC_PROCESS_IO_READOP ""
182#define DCIDESC_PROCESS_IO_WRITEB ""
183#define DCIDESC_PROCESS_IO_WRITEOP ""
761d297e 184#define DCIDESC_PROCESS_KERNELTIME "Total execution time in kernel mode for process {instance}"
a765d97c 185#define DCIDESC_PROCESS_PAGEFAULTS "Page faults for process {instance}"
761d297e 186#define DCIDESC_PROCESS_THREADS "Number of threads in process {instance}"
a765d97c 187#define DCIDESC_PROCESS_USEROBJ "USER objects used by process {instance}"
761d297e 188#define DCIDESC_PROCESS_USERTIME "Total execution time in user mode for process {instance}"
a765d97c
VK
189#define DCIDESC_PROCESS_VMSIZE "Virtual memory used by process {instance}"
190#define DCIDESC_PROCESS_WKSET "Physical memory used by process {instance}"
30c68fa1
AK
191#define DCIDESC_SYSTEM_CONNECTEDUSERS "Number of logged in users"
192#define DCIDESC_SYSTEM_PROCESSCOUNT "Total number of processes"
193#define DCIDESC_SYSTEM_SERVICESTATE "State of {instance} service"
194#define DCIDESC_SYSTEM_PROCESSCOUNT "Total number of processes"
195#define DCIDESC_SYSTEM_THREADCOUNT "Total number of threads"
a765d97c 196#define DCIDESC_PDH_COUNTERVALUE "Value of PDH counter {instance}"
30c68fa1 197#define DCIDESC_PDH_VERSION "Version of PDH.DLL"
30c68fa1
AK
198#define DCIDESC_SYSTEM_UPTIME "System uptime"
199#define DCIDESC_SYSTEM_CPU_LOADAVG "Average CPU load for last minute"
200#define DCIDESC_SYSTEM_CPU_LOADAVG5 "Average CPU load for last 5 minutes"
201#define DCIDESC_SYSTEM_CPU_LOADAVG15 "Average CPU load for last 15 minutes"
ea242c94
AK
202
203
e7e5ef1c
VK
204#define DCIDESC_SYSTEM_CPU_USAGE_EX "Average CPU {instance} utilization for last minute"
205#define DCIDESC_SYSTEM_CPU_USAGE5_EX "Average CPU {instance} utilization for last 5 minutes"
206#define DCIDESC_SYSTEM_CPU_USAGE15_EX "Average CPU {instance} utilization for last 15 minutes"
30c68fa1
AK
207#define DCIDESC_SYSTEM_CPU_USAGE "Average CPU utilization for last minute"
208#define DCIDESC_SYSTEM_CPU_USAGE5 "Average CPU utilization for last 5 minutes"
209#define DCIDESC_SYSTEM_CPU_USAGE15 "Average CPU utilization for last 15 minutes"
ea242c94
AK
210
211#define DCIDESC_SYSTEM_CPU_USAGE_USER_EX "Average CPU {instance} utilization (user) for last minute"
212#define DCIDESC_SYSTEM_CPU_USAGE5_USER_EX "Average CPU {instance} utilization (user) for last 5 minutes"
213#define DCIDESC_SYSTEM_CPU_USAGE15_USER_EX "Average CPU {instance} utilization (user) for last 15 minutes"
214#define DCIDESC_SYSTEM_CPU_USAGE_USER "Average CPU utilization (user) for last minute"
215#define DCIDESC_SYSTEM_CPU_USAGE5_USER "Average CPU utilization (user) for last 5 minutes"
216#define DCIDESC_SYSTEM_CPU_USAGE15_USER "Average CPU utilization (user) for last 15 minutes"
217
218#define DCIDESC_SYSTEM_CPU_USAGE_NICE_EX "Average CPU {instance} utilization (nice) for last minute"
219#define DCIDESC_SYSTEM_CPU_USAGE5_NICE_EX "Average CPU {instance} utilization (nice) for last 5 minutes"
220#define DCIDESC_SYSTEM_CPU_USAGE15_NICE_EX "Average CPU {instance} utilization (nice) for last 15 minutes"
221#define DCIDESC_SYSTEM_CPU_USAGE_NICE "Average CPU utilization (nice) for last minute"
222#define DCIDESC_SYSTEM_CPU_USAGE5_NICE "Average CPU utilization (nice) for last 5 minutes"
223#define DCIDESC_SYSTEM_CPU_USAGE15_NICE "Average CPU utilization (nice) for last 15 minutes"
224
225#define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM_EX "Average CPU {instance} utilization (system) for last minute"
226#define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM_EX "Average CPU {instance} utilization (system) for last 5 minutes"
227#define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM_EX "Average CPU {instance} utilization (system) for last 15 minutes"
228#define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM "Average CPU utilization (system) for last minute"
229#define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM "Average CPU utilization (system) for last 5 minutes"
230#define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM "Average CPU utilization (system) for last 15 minutes"
231
232#define DCIDESC_SYSTEM_CPU_USAGE_IDLE_EX "Average CPU {instance} utilization (idle) for last minute"
233#define DCIDESC_SYSTEM_CPU_USAGE5_IDLE_EX "Average CPU {instance} utilization (idle) for last 5 minutes"
234#define DCIDESC_SYSTEM_CPU_USAGE15_IDLE_EX "Average CPU {instance} utilization (idle) for last 15 minutes"
235#define DCIDESC_SYSTEM_CPU_USAGE_IDLE "Average CPU utilization (idle) for last minute"
236#define DCIDESC_SYSTEM_CPU_USAGE5_IDLE "Average CPU utilization (idle) for last 5 minutes"
237#define DCIDESC_SYSTEM_CPU_USAGE15_IDLE "Average CPU utilization (idle) for last 15 minutes"
238
239#define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last minute"
240#define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last 5 minutes"
241#define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last 15 minutes"
242#define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT "Average CPU utilization (iowait) for last minute"
243#define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT "Average CPU utilization (iowait) for last 5 minutes"
244#define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT "Average CPU utilization (iowait) for last 15 minutes"
245
246#define DCIDESC_SYSTEM_CPU_USAGE_IRQ_EX "Average CPU {instance} utilization (irq) for last minute"
247#define DCIDESC_SYSTEM_CPU_USAGE5_IRQ_EX "Average CPU {instance} utilization (irq) for last 5 minutes"
248#define DCIDESC_SYSTEM_CPU_USAGE15_IRQ_EX "Average CPU {instance} utilization (irq) for last 15 minutes"
249#define DCIDESC_SYSTEM_CPU_USAGE_IRQ "Average CPU utilization (irq) for last minute"
250#define DCIDESC_SYSTEM_CPU_USAGE5_IRQ "Average CPU utilization (irq) for last 5 minutes"
251#define DCIDESC_SYSTEM_CPU_USAGE15_IRQ "Average CPU utilization (irq) for last 15 minutes"
252
253#define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last minute"
254#define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last 5 minutes"
255#define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last 15 minutes"
256#define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ "Average CPU utilization (softirq) for last minute"
257#define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ "Average CPU utilization (softirq) for last 5 minutes"
258#define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ "Average CPU utilization (softirq) for last 15 minutes"
259
260#define DCIDESC_SYSTEM_CPU_USAGE_STEAL_EX "Average CPU {instance} utilization (steal) for last minute"
261#define DCIDESC_SYSTEM_CPU_USAGE5_STEAL_EX "Average CPU {instance} utilization (steal) for last 5 minutes"
262#define DCIDESC_SYSTEM_CPU_USAGE15_STEAL_EX "Average CPU {instance} utilization (steal) for last 15 minutes"
263#define DCIDESC_SYSTEM_CPU_USAGE_STEAL "Average CPU utilization (steal) for last minute"
264#define DCIDESC_SYSTEM_CPU_USAGE5_STEAL "Average CPU utilization (steal) for last 5 minutes"
265#define DCIDESC_SYSTEM_CPU_USAGE15_STEAL "Average CPU utilization (steal) for last 15 minutes"
266
267
30c68fa1 268#define DCIDESC_SYSTEM_IO_DISKQUEUE "Average disk queue length for last minute"
30c68fa1
AK
269
270
b9b4ec17
VK
271//
272// Connection handle
273//
274
275typedef void *HCONN;
276
277
901c96c7
VK
278//
279// Structure for holding enumeration results
280//
281
282typedef struct
283{
284 DWORD dwNumStrings;
018fda4d 285 TCHAR **ppStringList;
901c96c7
VK
286} NETXMS_VALUES_LIST;
287
288
3b376ea0 289//
6827d635 290// Subagent's parameter information
3b376ea0
VK
291//
292
6827d635
VK
293typedef struct
294{
018fda4d 295 TCHAR szName[MAX_PARAM_NAME];
e2d68ddd 296 LONG (* fpHandler)(const TCHAR *, const TCHAR *, TCHAR *);
a765d97c 297 const TCHAR *pArg;
a72a1fb1
VK
298 int iDataType;
299 TCHAR szDescription[MAX_DB_STRING];
6827d635
VK
300} NETXMS_SUBAGENT_PARAM;
301
302
901c96c7
VK
303//
304// Subagent's enum information
305//
306
307typedef struct
308{
018fda4d 309 TCHAR szName[MAX_PARAM_NAME];
e2d68ddd 310 LONG (* fpHandler)(const TCHAR *, const TCHAR *, NETXMS_VALUES_LIST *);
a765d97c 311 const TCHAR *pArg;
901c96c7
VK
312} NETXMS_SUBAGENT_ENUM;
313
314
37778a1d
VK
315//
316// Subagent's action information
317//
318
319typedef struct
320{
321 TCHAR szName[MAX_PARAM_NAME];
a765d97c
VK
322 LONG (* fpHandler)(const TCHAR *, NETXMS_VALUES_LIST *, const TCHAR *);
323 const TCHAR *pArg;
37778a1d
VK
324 TCHAR szDescription[MAX_DB_STRING];
325} NETXMS_SUBAGENT_ACTION;
326
327
6827d635
VK
328//
329// Subagent initialization structure
330//
3b376ea0 331
f7139bdc 332#define NETXMS_SUBAGENT_INFO_MAGIC ((DWORD)0x20080722)
ded831ac
VK
333
334class CSCPMessage;
d618c3ae 335
6827d635
VK
336typedef struct
337{
d618c3ae 338 DWORD dwMagic; // Magic number to check if subagent uses correct version of this structure
018fda4d 339 TCHAR szName[MAX_SUBAGENT_NAME];
43caa61e 340 TCHAR szVersion[32];
f0be41a4
VK
341 BOOL (* pInit)(TCHAR *); // Called to initialize subagent. Can be NULL.
342 void (* pShutdown)(void); // Called at subagent unload. Can be NULL.
2e5d6a1e 343 BOOL (* pCommandHandler)(DWORD dwCommand, CSCPMessage *pRequest,
f7139bdc
VK
344 CSCPMessage *pResponse, SOCKET sock,
345 CSCP_ENCRYPTION_CONTEXT *ctx);
6827d635
VK
346 DWORD dwNumParameters;
347 NETXMS_SUBAGENT_PARAM *pParamList;
901c96c7
VK
348 DWORD dwNumEnums;
349 NETXMS_SUBAGENT_ENUM *pEnumList;
37778a1d
VK
350 DWORD dwNumActions;
351 NETXMS_SUBAGENT_ACTION *pActionList;
6827d635 352} NETXMS_SUBAGENT_INFO;
3b376ea0
VK
353
354
cbcaf8c8
VK
355//
356// Inline functions for returning parameters
357//
358
359#ifdef __cplusplus
64584976 360#ifndef LIBNETXMS_INLINE
cbcaf8c8 361
ded831ac
VK
362#include <nms_agent.h>
363
a765d97c 364inline void ret_string(TCHAR *rbuf, const TCHAR *value)
cbcaf8c8 365{
c81979bc
VK
366 _tcsncpy(rbuf, value, MAX_RESULT_LENGTH - 1);
367 rbuf[MAX_RESULT_LENGTH - 1] = 0;
cbcaf8c8
VK
368}
369
0212dc5a 370inline void ret_int(TCHAR *rbuf, LONG value)
cbcaf8c8 371{
8b86c5dc 372 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%d"), value);
cbcaf8c8
VK
373}
374
0212dc5a 375inline void ret_uint(TCHAR *rbuf, DWORD value)
cbcaf8c8 376{
8b86c5dc 377 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%u"), value);
cbcaf8c8
VK
378}
379
018fda4d 380inline void ret_double(TCHAR *rbuf, double value)
cbcaf8c8 381{
8b86c5dc 382 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%f"), value);
cbcaf8c8
VK
383}
384
018fda4d 385inline void ret_int64(TCHAR *rbuf, INT64 value)
cbcaf8c8
VK
386{
387#ifdef _WIN32
8b86c5dc 388 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%I64d"), value);
cbcaf8c8 389#else /* _WIN32 */
8b86c5dc 390 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%lld"), value);
cbcaf8c8
VK
391#endif /* _WIN32 */
392}
393
018fda4d 394inline void ret_uint64(TCHAR *rbuf, QWORD value)
cbcaf8c8
VK
395{
396#ifdef _WIN32
8b86c5dc 397 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%I64u"), value);
cbcaf8c8 398#else /* _WIN32 */
8b86c5dc 399 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%llu"), value);
cbcaf8c8
VK
400#endif /* _WIN32 */
401}
402
901c96c7 403#endif /* LIBNETXMS_INLINE */
6827d635
VK
404#else /* __cplusplus */
405
a765d97c 406void LIBNETXMS_EXPORTABLE ret_string(TCHAR *rbuf, const TCHAR *value);
b50f1100
VK
407void LIBNETXMS_EXPORTABLE ret_int(TCHAR *rbuf, long value);
408void LIBNETXMS_EXPORTABLE ret_uint(TCHAR *rbuf, unsigned long value);
409void LIBNETXMS_EXPORTABLE ret_double(TCHAR *rbuf, double value);
410void LIBNETXMS_EXPORTABLE ret_int64(TCHAR *rbuf, INT64 value);
411void LIBNETXMS_EXPORTABLE ret_uint64(TCHAR *rbuf, QWORD value);
6827d635 412
cbcaf8c8
VK
413#endif /* __cplusplus */
414
6827d635
VK
415
416//
64584976 417// Functions from libnetxms
6827d635
VK
418//
419
420#ifdef __cplusplus
421extern "C" {
422#endif
423
a765d97c
VK
424BOOL LIBNETXMS_EXPORTABLE NxGetParameterArg(const TCHAR *param, int index, TCHAR *arg, int maxSize);
425void LIBNETXMS_EXPORTABLE NxAddResultString(NETXMS_VALUES_LIST *pList, const TCHAR *pszString);
ea1acec2 426void LIBNETXMS_EXPORTABLE NxDestroyValuesList(NETXMS_VALUES_LIST *pList);
a765d97c 427void LIBNETXMS_EXPORTABLE NxWriteAgentLog(int iLevel, const TCHAR *pszFormat, ...);
37809558 428void LIBNETXMS_EXPORTABLE NxWriteAgentLog2(int iLevel, const TCHAR *pszFormat, va_list args);
a765d97c 429void LIBNETXMS_EXPORTABLE NxSendTrap(DWORD dwEvent, const char *pszFormat, ...);
15c8cf46 430void LIBNETXMS_EXPORTABLE NxSendTrap2(DWORD dwEvent, int nCount, TCHAR **ppszArgList);
6827d635
VK
431
432#ifdef __cplusplus
433}
434#endif
435
cbcaf8c8 436#endif /* _nms_agent_h_ */