snmp_common.h
Go to the documentation of this file.
1/**
2 * @file snmp_common.h
3 * @brief Definitions common to SNMP agent and SNMP manager
4 *
5 * @section License
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * Copyright (C) 2010-2021 Oryx Embedded SARL. All rights reserved.
10 *
11 * This file is part of CycloneTCP Open.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 *
27 * @author Oryx Embedded SARL (www.oryx-embedded.com)
28 * @version 2.1.2
29 **/
30
31#ifndef _SNMP_COMMON_H
32#define _SNMP_COMMON_H
33
34//Dependencies
35#include "core/net.h"
36
37//SNMPv1 support
38#ifndef SNMP_V1_SUPPORT
39 #define SNMP_V1_SUPPORT ENABLED
40#elif (SNMP_V1_SUPPORT != ENABLED && SNMP_V1_SUPPORT != DISABLED)
41 #error SNMP_V1_SUPPORT parameter is not valid
42#endif
43
44//SNMPv2c support
45#ifndef SNMP_V2C_SUPPORT
46 #define SNMP_V2C_SUPPORT ENABLED
47#elif (SNMP_V2C_SUPPORT != ENABLED && SNMP_V2C_SUPPORT != DISABLED)
48 #error SNMP_V2C_SUPPORT parameter is not valid
49#endif
50
51//SNMPv3 support
52#ifndef SNMP_V3_SUPPORT
53 #define SNMP_V3_SUPPORT DISABLED
54#elif (SNMP_V3_SUPPORT != ENABLED && SNMP_V3_SUPPORT != DISABLED)
55 #error SNMP_V3_SUPPORT parameter is not valid
56#endif
57
58//Maximum size of SNMP messages
59#ifndef SNMP_MAX_MSG_SIZE
60 #define SNMP_MAX_MSG_SIZE 1452
61#elif (SNMP_MAX_MSG_SIZE < 484 || SNMP_MAX_MSG_SIZE > 65535)
62 #error SNMP_MAX_MSG_SIZE parameter is not valid
63#endif
64
65//Maximum size for context engine identifier
66#ifndef SNMP_MAX_CONTEXT_ENGINE_SIZE
67 #define SNMP_MAX_CONTEXT_ENGINE_SIZE 32
68#elif (SNMP_MAX_CONTEXT_ENGINE_SIZE < 1)
69 #error SNMP_MAX_CONTEXT_ENGINE_SIZE parameter is not valid
70#endif
71
72//Maximum length for context name
73#ifndef SNMP_MAX_CONTEXT_NAME_LEN
74 #define SNMP_MAX_CONTEXT_NAME_LEN 32
75#elif (SNMP_MAX_CONTEXT_NAME_LEN < 1)
76 #error SNMP_MAX_CONTEXT_NAME_LEN parameter is not valid
77#endif
78
79//Maximum length for user names and community names
80#ifndef SNMP_MAX_USER_NAME_LEN
81 #define SNMP_MAX_USER_NAME_LEN 32
82#elif (SNMP_MAX_USER_NAME_LEN < 1)
83 #error SNMP_MAX_USER_NAME_LEN parameter is not valid
84#endif
85
86//Maximum size for user public values
87#ifndef SNMP_MAX_PUBLIC_VALUE_SIZE
88 #define SNMP_MAX_PUBLIC_VALUE_SIZE 32
89#elif (SNMP_MAX_PUBLIC_VALUE_SIZE < 1)
90 #error SNMP_MAX_PUBLIC_VALUE_SIZE parameter is not valid
91#endif
92
93//Maximum length for group names
94#ifndef SNMP_MAX_GROUP_NAME_LEN
95 #define SNMP_MAX_GROUP_NAME_LEN 32
96#elif (SNMP_MAX_GROUP_NAME_LEN < 1)
97 #error SNMP_MAX_GROUP_NAME_LEN parameter is not valid
98#endif
99
100//Maximum length for view names
101#ifndef SNMP_MAX_VIEW_NAME_LEN
102 #define SNMP_MAX_VIEW_NAME_LEN 32
103#elif (SNMP_MAX_VIEW_NAME_LEN < 1)
104 #error SNMP_MAX_VIEW_NAME_LEN parameter is not valid
105#endif
106
107//Maximum length for bit masks
108#ifndef SNMP_MAX_BIT_MASK_SIZE
109 #define SNMP_MAX_BIT_MASK_SIZE 16
110#elif (SNMP_MAX_BIT_MASK_SIZE < 1)
111 #error SNMP_MAX_MASK_SIZE parameter is not valid
112#endif
113
114//Maximum size for object identifiers
115#ifndef SNMP_MAX_OID_SIZE
116 #define SNMP_MAX_OID_SIZE 16
117#elif (SNMP_MAX_OID_SIZE < 1)
118 #error SNMP_MAX_OID_SIZE parameter is not valid
119#endif
120
121//SNMP port number
122#define SNMP_PORT 161
123//SNMP trap port number
124#define SNMP_TRAP_PORT 162
125
126//C++ guard
127#ifdef __cplusplus
128extern "C" {
129#endif
130
131
132/**
133 * @brief SNMP version identifiers
134 **/
135
136typedef enum
137{
142
143
144/**
145 * @brief SNMP PDU types
146 **/
147
148typedef enum
149{
160
161
162/**
163 * @brief SNMP generic trap types
164 **/
165
166typedef enum
167{
176
177
178/**
179 * @brief SNMP error status
180 **/
181
182typedef enum
183{
204
205
206/**
207 * @brief SNMP exceptions
208 **/
209
210typedef enum
211{
216
217
218/**
219 * @brief SNMP engine ID format
220 **/
221
222typedef enum
223{
230
231
232//C++ guard
233#ifdef __cplusplus
234}
235#endif
236
237#endif
TCP/IP stack core.
SnmpEngineIdFormat
SNMP engine ID format.
Definition: snmp_common.h:223
@ SNMP_ENGINE_ID_FORMAT_MAC
Definition: snmp_common.h:226
@ SNMP_ENGINE_ID_FORMAT_IPV6
Definition: snmp_common.h:225
@ SNMP_ENGINE_ID_FORMAT_TEXT
Definition: snmp_common.h:227
@ SNMP_ENGINE_ID_FORMAT_IPV4
Definition: snmp_common.h:224
@ SNMP_ENGINE_ID_FORMAT_OCTETS
Definition: snmp_common.h:228
SnmpPduType
SNMP PDU types.
Definition: snmp_common.h:149
@ SNMP_PDU_TRAP_V2
Definition: snmp_common.h:157
@ SNMP_PDU_GET_REQUEST
Definition: snmp_common.h:150
@ SNMP_PDU_GET_RESPONSE
Definition: snmp_common.h:152
@ SNMP_PDU_INFORM_REQUEST
Definition: snmp_common.h:156
@ SNMP_PDU_TRAP
Definition: snmp_common.h:154
@ SNMP_PDU_GET_NEXT_REQUEST
Definition: snmp_common.h:151
@ SNMP_PDU_REPORT
Definition: snmp_common.h:158
@ SNMP_PDU_GET_BULK_REQUEST
Definition: snmp_common.h:155
@ SNMP_PDU_SET_REQUEST
Definition: snmp_common.h:153
SnmpException
SNMP exceptions.
Definition: snmp_common.h:211
@ SNMP_EXCEPTION_NO_SUCH_OBJECT
Definition: snmp_common.h:212
@ SNMP_EXCEPTION_END_OF_MIB_VIEW
Definition: snmp_common.h:214
@ SNMP_EXCEPTION_NO_SUCH_INSTANCE
Definition: snmp_common.h:213
SnmpVersion
SNMP version identifiers.
Definition: snmp_common.h:137
@ SNMP_VERSION_1
Definition: snmp_common.h:138
@ SNMP_VERSION_3
Definition: snmp_common.h:140
@ SNMP_VERSION_2C
Definition: snmp_common.h:139
SnmpErrorStatus
SNMP error status.
Definition: snmp_common.h:183
@ SNMP_ERROR_INCONSISTENT_VALUE
Definition: snmp_common.h:196
@ SNMP_ERROR_TOO_BIG
Definition: snmp_common.h:185
@ SNMP_ERROR_RESOURCE_UNAVAILABLE
Definition: snmp_common.h:197
@ SNMP_ERROR_COMMIT_FAILED
Definition: snmp_common.h:198
@ SNMP_ERROR_GENERIC
Definition: snmp_common.h:189
@ SNMP_ERROR_WRONG_VALUE
Definition: snmp_common.h:194
@ SNMP_ERROR_WRONG_TYPE
Definition: snmp_common.h:191
@ SNMP_ERROR_NO_SUCH_NAME
Definition: snmp_common.h:186
@ SNMP_ERROR_WRONG_LENGTH
Definition: snmp_common.h:192
@ SNMP_ERROR_NOT_WRITABLE
Definition: snmp_common.h:201
@ SNMP_ERROR_WRONG_ENCODING
Definition: snmp_common.h:193
@ SNMP_ERROR_READ_ONLY
Definition: snmp_common.h:188
@ SNMP_ERROR_NO_ACCESS
Definition: snmp_common.h:190
@ SNMP_ERROR_NO_CREATION
Definition: snmp_common.h:195
@ SNMP_ERROR_INCONSISTENT_NAME
Definition: snmp_common.h:202
@ SNMP_ERROR_NONE
Definition: snmp_common.h:184
@ SNMP_ERROR_BAD_VALUE
Definition: snmp_common.h:187
@ SNMP_ERROR_UNDO_FAILED
Definition: snmp_common.h:199
@ SNMP_ERROR_AUTHORIZATION
Definition: snmp_common.h:200
SnmpGenericTrapType
SNMP generic trap types.
Definition: snmp_common.h:167
@ SNMP_TRAP_WARM_START
Definition: snmp_common.h:169
@ SNMP_TRAP_ENTERPRISE_SPECIFIC
Definition: snmp_common.h:174
@ SNMP_TRAP_LINK_UP
Definition: snmp_common.h:171
@ SNMP_TRAP_LINK_DOWN
Definition: snmp_common.h:170
@ SNMP_TRAP_AUTH_FAILURE
Definition: snmp_common.h:172
@ SNMP_TRAP_EGP_NEIGHBOR_LOSS
Definition: snmp_common.h:173
@ SNMP_TRAP_COLD_START
Definition: snmp_common.h:168