This commit was generated by cvs2svn to compensate for changes in r2,
[public/netxms.git] / include / nms_agent.h
CommitLineData
cbcaf8c8
VK
1/*
2** Project X - Network Management System
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
34#define MAX_SECRET_LENGTH 64
35#define MAX_PARAM_NAME 256
36#define MAX_RESULT_LENGTH 256
37
38
39//
40// Error codes
41//
42
43#define ERR_SUCCESS 0
44#define ERR_UNKNOWN_COMMAND 400
45#define ERR_AUTH_REQUIRED 401
46#define ERR_UNKNOWN_PARAMETER 404
47#define ERR_REQUEST_TIMEOUT 408
48#define ERR_AUTH_FAILED 440
49#define ERR_ALREADY_AUTHENTICATED 441
50#define ERR_AUTH_NOT_REQUIRED 442
51#define ERR_INTERNAL_ERROR 500
52#define ERR_NOT_IMPLEMENTED 501
53#define ERR_OUT_OF_RESOURCES 503
54
55
56//
57// Parameter handler return codes
58//
59
60#define SYSINFO_RC_SUCCESS 0
61#define SYSINFO_RC_UNSUPPORTED 1
62#define SYSINFO_RC_ERROR 2
63
64
65//
66// Inline functions for returning parameters
67//
68
69#ifdef __cplusplus
70
71inline void ret_string(char *rbuf, char *value)
72{
73 memset(rbuf, 0, MAX_RESULT_LENGTH);
74 strncpy(rbuf, value, MAX_RESULT_LENGTH - 3);
75 strcat(rbuf, "\r\n");
76}
77
78inline void ret_int(char *rbuf, long value)
79{
80 sprintf(rbuf, "%ld\r\n", value);
81}
82
83inline void ret_uint(char *rbuf, unsigned long value)
84{
85 sprintf(rbuf, "%lu\r\n", value);
86}
87
88inline void ret_double(char *rbuf, double value)
89{
90 sprintf(rbuf, "%f\r\n", value);
91}
92
93inline void ret_int64(char *rbuf, __int64 value)
94{
95#ifdef _WIN32
96 sprintf(rbuf, "%I64d\r\n", value);
97#else /* _WIN32 */
98 sprintf(rbuf, "%lld\r\n", value);
99#endif /* _WIN32 */
100}
101
102inline void ret_uint64(char *rbuf, unsigned __int64 value)
103{
104#ifdef _WIN32
105 sprintf(rbuf, "%I64u\r\n", value);
106#else /* _WIN32 */
107 sprintf(rbuf, "%llu\r\n", value);
108#endif /* _WIN32 */
109}
110
111#endif /* __cplusplus */
112
113#endif /* _nms_agent_h_ */