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-2019 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 1.9.6
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
128 extern "C" {
129 #endif
130 
131 
132 /**
133  * @brief SNMP version identifiers
134  **/
135 
136 typedef enum
137 {
141 } SnmpVersion;
142 
143 
144 /**
145  * @brief SNMP PDU types
146  **/
147 
148 typedef enum
149 {
159 } SnmpPduType;
160 
161 
162 /**
163  * @brief SNMP generic trap types
164  **/
165 
166 typedef enum
167 {
176 
177 
178 /**
179  * @brief SNMP error status
180  **/
181 
182 typedef enum
183 {
204 
205 
206 /**
207  * @brief SNMP exceptions
208  **/
209 
210 typedef enum
211 {
215 } SnmpException;
216 
217 
218 /**
219  * @brief SNMP engine ID format
220  **/
221 
222 typedef enum
223 {
230 
231 
232 //C++ guard
233 #ifdef __cplusplus
234 }
235 #endif
236 
237 #endif
SnmpGenericTrapType
SNMP generic trap types.
Definition: snmp_common.h:166
SnmpException
SNMP exceptions.
Definition: snmp_common.h:210
SnmpVersion
SNMP version identifiers.
Definition: snmp_common.h:136
SnmpPduType
SNMP PDU types.
Definition: snmp_common.h:148
SnmpEngineIdFormat
SNMP engine ID format.
Definition: snmp_common.h:222
SnmpErrorStatus
SNMP error status.
Definition: snmp_common.h:182
TCP/IP stack core.