Initial version of skeleton subagent
[public/netxms.git] / include / nms_agent.h
CommitLineData
cbcaf8c8 1/*
7ac71e60 2** NetXMS - Network Management System
cbcaf8c8
VK
3** Copyright (C) 2003 Victor Kirhenshtein
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_agent.h
20**
21**/
22
23#ifndef _nms_agent_h_
24#define _nms_agent_h_
25
26#include <stdio.h>
27
28//
29// Some constants
30//
31
32#define AGENT_LISTEN_PORT 4700
33#define AGENT_PROTOCOL_VERSION 1
cbcaf8c8
VK
34#define MAX_PARAM_NAME 256
35#define MAX_RESULT_LENGTH 256
36
37
38//
39// Error codes
40//
41
42#define ERR_SUCCESS 0
43#define ERR_UNKNOWN_COMMAND 400
44#define ERR_AUTH_REQUIRED 401
45#define ERR_UNKNOWN_PARAMETER 404
46#define ERR_REQUEST_TIMEOUT 408
47#define ERR_AUTH_FAILED 440
48#define ERR_ALREADY_AUTHENTICATED 441
49#define ERR_AUTH_NOT_REQUIRED 442
50#define ERR_INTERNAL_ERROR 500
51#define ERR_NOT_IMPLEMENTED 501
52#define ERR_OUT_OF_RESOURCES 503
5811233f
VK
53#define ERR_NOT_CONNECTED 900
54#define ERR_CONNECTION_BROKEN 901
55#define ERR_BAD_RESPONCE 902
cbcaf8c8
VK
56
57
58//
59// Parameter handler return codes
60//
61
62#define SYSINFO_RC_SUCCESS 0
63#define SYSINFO_RC_UNSUPPORTED 1
64#define SYSINFO_RC_ERROR 2
65
66
3b376ea0
VK
67//
68// Subagent initialization structure
69//
70
71
72
73
cbcaf8c8
VK
74//
75// Inline functions for returning parameters
76//
77
78#ifdef __cplusplus
79
80inline void ret_string(char *rbuf, char *value)
81{
82 memset(rbuf, 0, MAX_RESULT_LENGTH);
83 strncpy(rbuf, value, MAX_RESULT_LENGTH - 3);
84 strcat(rbuf, "\r\n");
85}
86
87inline void ret_int(char *rbuf, long value)
88{
89 sprintf(rbuf, "%ld\r\n", value);
90}
91
92inline void ret_uint(char *rbuf, unsigned long value)
93{
94 sprintf(rbuf, "%lu\r\n", value);
95}
96
97inline void ret_double(char *rbuf, double value)
98{
99 sprintf(rbuf, "%f\r\n", value);
100}
101
102inline void ret_int64(char *rbuf, __int64 value)
103{
104#ifdef _WIN32
105 sprintf(rbuf, "%I64d\r\n", value);
106#else /* _WIN32 */
107 sprintf(rbuf, "%lld\r\n", value);
108#endif /* _WIN32 */
109}
110
111inline void ret_uint64(char *rbuf, unsigned __int64 value)
112{
113#ifdef _WIN32
114 sprintf(rbuf, "%I64u\r\n", value);
115#else /* _WIN32 */
116 sprintf(rbuf, "%llu\r\n", value);
117#endif /* _WIN32 */
118}
119
120#endif /* __cplusplus */
121
122#endif /* _nms_agent_h_ */