[457] | 1 | /**
|
---|
| 2 | * @file
|
---|
| 3 | * SNMP server options list
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
| 7 | * Copyright (c) 2015 Dirk Ziegelmeier
|
---|
| 8 | * All rights reserved.
|
---|
| 9 | *
|
---|
| 10 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
| 11 | * are permitted provided that the following conditions are met:
|
---|
| 12 | *
|
---|
| 13 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
| 14 | * this list of conditions and the following disclaimer.
|
---|
| 15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
| 16 | * this list of conditions and the following disclaimer in the documentation
|
---|
| 17 | * and/or other materials provided with the distribution.
|
---|
| 18 | * 3. The name of the author may not be used to endorse or promote products
|
---|
| 19 | * derived from this software without specific prior written permission.
|
---|
| 20 | *
|
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
---|
| 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
| 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
---|
| 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
| 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
---|
| 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
| 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
---|
| 30 | * OF SUCH DAMAGE.
|
---|
| 31 | *
|
---|
| 32 | * This file is part of the lwIP TCP/IP stack.
|
---|
| 33 | *
|
---|
| 34 | * Author: Dirk Ziegelmeier
|
---|
| 35 | *
|
---|
| 36 | */
|
---|
| 37 | #ifndef LWIP_HDR_SNMP_OPTS_H
|
---|
| 38 | #define LWIP_HDR_SNMP_OPTS_H
|
---|
| 39 |
|
---|
| 40 | #include "lwip/opt.h"
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | * @defgroup snmp_opts Options
|
---|
| 44 | * @ingroup snmp
|
---|
| 45 | * @{
|
---|
| 46 | */
|
---|
| 47 |
|
---|
| 48 | /**
|
---|
| 49 | * LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available
|
---|
| 50 | * for SNMP transport.
|
---|
| 51 | * If you want to use your own SNMP agent, leave this disabled.
|
---|
| 52 | * To integrate MIB2 of an external agent, you need to enable
|
---|
| 53 | * LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks
|
---|
| 54 | * and statistics counters you need to get MIB2 working.
|
---|
| 55 | */
|
---|
| 56 | #if !defined LWIP_SNMP || defined __DOXYGEN__
|
---|
| 57 | #define LWIP_SNMP 0
|
---|
| 58 | #endif
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * SNMP_USE_NETCONN: Use netconn API instead of raw API.
|
---|
| 62 | * Makes SNMP agent run in a worker thread, so blocking operations
|
---|
| 63 | * can be done in MIB calls.
|
---|
| 64 | */
|
---|
| 65 | #if !defined SNMP_USE_NETCONN || defined __DOXYGEN__
|
---|
| 66 | #define SNMP_USE_NETCONN 0
|
---|
| 67 | #endif
|
---|
| 68 |
|
---|
| 69 | /**
|
---|
| 70 | * SNMP_USE_RAW: Use raw API.
|
---|
| 71 | * SNMP agent does not run in a worker thread, so blocking operations
|
---|
| 72 | * should not be done in MIB calls.
|
---|
| 73 | */
|
---|
| 74 | #if !defined SNMP_USE_RAW || defined __DOXYGEN__
|
---|
| 75 | #define SNMP_USE_RAW 1
|
---|
| 76 | #endif
|
---|
| 77 |
|
---|
| 78 | #if SNMP_USE_NETCONN && SNMP_USE_RAW
|
---|
| 79 | #error SNMP stack can use only one of the APIs {raw, netconn}
|
---|
| 80 | #endif
|
---|
| 81 |
|
---|
| 82 | #if LWIP_SNMP && !SNMP_USE_NETCONN && !SNMP_USE_RAW
|
---|
| 83 | #error SNMP stack needs a receive API and UDP {raw, netconn}
|
---|
| 84 | #endif
|
---|
| 85 |
|
---|
| 86 | #if SNMP_USE_NETCONN
|
---|
| 87 | /**
|
---|
| 88 | * SNMP_STACK_SIZE: Stack size of SNMP netconn worker thread
|
---|
| 89 | */
|
---|
| 90 | #if !defined SNMP_STACK_SIZE || defined __DOXYGEN__
|
---|
| 91 | #define SNMP_STACK_SIZE DEFAULT_THREAD_STACKSIZE
|
---|
| 92 | #endif
|
---|
| 93 |
|
---|
| 94 | /**
|
---|
| 95 | * SNMP_THREAD_PRIO: SNMP netconn worker thread priority
|
---|
| 96 | */
|
---|
| 97 | #if !defined SNMP_THREAD_PRIO || defined __DOXYGEN__
|
---|
| 98 | #define SNMP_THREAD_PRIO DEFAULT_THREAD_PRIO
|
---|
| 99 | #endif
|
---|
| 100 | #endif /* SNMP_USE_NETCONN */
|
---|
| 101 |
|
---|
| 102 | /**
|
---|
| 103 | * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
|
---|
| 104 | * destination is required
|
---|
| 105 | */
|
---|
| 106 | #if !defined SNMP_TRAP_DESTINATIONS || defined __DOXYGEN__
|
---|
| 107 | #define SNMP_TRAP_DESTINATIONS 1
|
---|
| 108 | #endif
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | * Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not
|
---|
| 112 | * a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
|
---|
| 113 | * Unsafe requests are disabled by default!
|
---|
| 114 | */
|
---|
| 115 | #if !defined SNMP_SAFE_REQUESTS || defined __DOXYGEN__
|
---|
| 116 | #define SNMP_SAFE_REQUESTS 1
|
---|
| 117 | #endif
|
---|
| 118 |
|
---|
| 119 | /**
|
---|
| 120 | * The maximum length of strings used.
|
---|
| 121 | */
|
---|
| 122 | #if !defined SNMP_MAX_OCTET_STRING_LEN || defined __DOXYGEN__
|
---|
| 123 | #define SNMP_MAX_OCTET_STRING_LEN 127
|
---|
| 124 | #endif
|
---|
| 125 |
|
---|
| 126 | /**
|
---|
| 127 | * The maximum number of Sub ID's inside an object identifier.
|
---|
| 128 | * Indirectly this also limits the maximum depth of SNMP tree.
|
---|
| 129 | */
|
---|
| 130 | #if !defined SNMP_MAX_OBJ_ID_LEN || defined __DOXYGEN__
|
---|
| 131 | #define SNMP_MAX_OBJ_ID_LEN 50
|
---|
| 132 | #endif
|
---|
| 133 |
|
---|
| 134 | #if !defined SNMP_MAX_VALUE_SIZE || defined __DOXYGEN__
|
---|
| 135 | /**
|
---|
| 136 | * The minimum size of a value.
|
---|
| 137 | */
|
---|
| 138 | #define SNMP_MIN_VALUE_SIZE (2 * sizeof(u32_t*)) /* size required to store the basic types (8 bytes for counter64) */
|
---|
| 139 | /**
|
---|
| 140 | * The maximum size of a value.
|
---|
| 141 | */
|
---|
| 142 | #define SNMP_MAX_VALUE_SIZE LWIP_MAX(LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN), sizeof(u32_t)*(SNMP_MAX_OBJ_ID_LEN)), SNMP_MIN_VALUE_SIZE)
|
---|
| 143 | #endif
|
---|
| 144 |
|
---|
| 145 | /**
|
---|
| 146 | * The snmp read-access community. Used for write-access and traps, too
|
---|
| 147 | * unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively.
|
---|
| 148 | */
|
---|
| 149 | #if !defined SNMP_COMMUNITY || defined __DOXYGEN__
|
---|
| 150 | #define SNMP_COMMUNITY "public"
|
---|
| 151 | #endif
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
| 154 | * The snmp write-access community.
|
---|
| 155 | * Set this community to "" in order to disallow any write access.
|
---|
| 156 | */
|
---|
| 157 | #if !defined SNMP_COMMUNITY_WRITE || defined __DOXYGEN__
|
---|
| 158 | #define SNMP_COMMUNITY_WRITE "private"
|
---|
| 159 | #endif
|
---|
| 160 |
|
---|
| 161 | /**
|
---|
| 162 | * The snmp community used for sending traps.
|
---|
| 163 | */
|
---|
| 164 | #if !defined SNMP_COMMUNITY_TRAP || defined __DOXYGEN__
|
---|
| 165 | #define SNMP_COMMUNITY_TRAP "public"
|
---|
| 166 | #endif
|
---|
| 167 |
|
---|
| 168 | /**
|
---|
| 169 | * The maximum length of community string.
|
---|
| 170 | * If community names shall be adjusted at runtime via snmp_set_community() calls,
|
---|
| 171 | * enter here the possible maximum length (+1 for terminating null character).
|
---|
| 172 | */
|
---|
| 173 | #if !defined SNMP_MAX_COMMUNITY_STR_LEN || defined __DOXYGEN__
|
---|
| 174 | #define SNMP_MAX_COMMUNITY_STR_LEN LWIP_MAX(LWIP_MAX(sizeof(SNMP_COMMUNITY), sizeof(SNMP_COMMUNITY_WRITE)), sizeof(SNMP_COMMUNITY_TRAP))
|
---|
| 175 | #endif
|
---|
| 176 |
|
---|
| 177 | /**
|
---|
| 178 | * The OID identifiying the device. This may be the enterprise OID itself or any OID located below it in tree.
|
---|
| 179 | */
|
---|
| 180 | #if !defined SNMP_DEVICE_ENTERPRISE_OID || defined __DOXYGEN__
|
---|
| 181 | #define SNMP_LWIP_ENTERPRISE_OID 26381
|
---|
| 182 | /**
|
---|
| 183 | * IANA assigned enterprise ID for lwIP is 26381
|
---|
| 184 | * @see http://www.iana.org/assignments/enterprise-numbers
|
---|
| 185 | *
|
---|
| 186 | * @note this enterprise ID is assigned to the lwIP project,
|
---|
| 187 | * all object identifiers living under this ID are assigned
|
---|
| 188 | * by the lwIP maintainers!
|
---|
| 189 | * @note don't change this define, use snmp_set_device_enterprise_oid()
|
---|
| 190 | *
|
---|
| 191 | * If you need to create your own private MIB you'll need
|
---|
| 192 | * to apply for your own enterprise ID with IANA:
|
---|
| 193 | * http://www.iana.org/numbers.html
|
---|
| 194 | */
|
---|
| 195 | #define SNMP_DEVICE_ENTERPRISE_OID {1, 3, 6, 1, 4, 1, SNMP_LWIP_ENTERPRISE_OID}
|
---|
| 196 | /**
|
---|
| 197 | * Length of SNMP_DEVICE_ENTERPRISE_OID
|
---|
| 198 | */
|
---|
| 199 | #define SNMP_DEVICE_ENTERPRISE_OID_LEN 7
|
---|
| 200 | #endif
|
---|
| 201 |
|
---|
| 202 | /**
|
---|
| 203 | * SNMP_DEBUG: Enable debugging for SNMP messages.
|
---|
| 204 | */
|
---|
| 205 | #if !defined SNMP_DEBUG || defined __DOXYGEN__
|
---|
| 206 | #define SNMP_DEBUG LWIP_DBG_OFF
|
---|
| 207 | #endif
|
---|
| 208 |
|
---|
| 209 | /**
|
---|
| 210 | * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs.
|
---|
| 211 | */
|
---|
| 212 | #if !defined SNMP_MIB_DEBUG || defined __DOXYGEN__
|
---|
| 213 | #define SNMP_MIB_DEBUG LWIP_DBG_OFF
|
---|
| 214 | #endif
|
---|
| 215 |
|
---|
| 216 | /**
|
---|
| 217 | * Indicates if the MIB2 implementation of LWIP SNMP stack is used.
|
---|
| 218 | */
|
---|
| 219 | #if !defined SNMP_LWIP_MIB2 || defined __DOXYGEN__
|
---|
| 220 | #define SNMP_LWIP_MIB2 LWIP_SNMP
|
---|
| 221 | #endif
|
---|
| 222 |
|
---|
| 223 | /**
|
---|
| 224 | * Value return for sysDesc field of MIB2.
|
---|
| 225 | */
|
---|
| 226 | #if !defined SNMP_LWIP_MIB2_SYSDESC || defined __DOXYGEN__
|
---|
| 227 | #define SNMP_LWIP_MIB2_SYSDESC "lwIP"
|
---|
| 228 | #endif
|
---|
| 229 |
|
---|
| 230 | /**
|
---|
| 231 | * Value return for sysName field of MIB2.
|
---|
| 232 | * To make sysName field settable, call snmp_mib2_set_sysname() to provide the necessary buffers.
|
---|
| 233 | */
|
---|
| 234 | #if !defined SNMP_LWIP_MIB2_SYSNAME || defined __DOXYGEN__
|
---|
| 235 | #define SNMP_LWIP_MIB2_SYSNAME "FQDN-unk"
|
---|
| 236 | #endif
|
---|
| 237 |
|
---|
| 238 | /**
|
---|
| 239 | * Value return for sysContact field of MIB2.
|
---|
| 240 | * To make sysContact field settable, call snmp_mib2_set_syscontact() to provide the necessary buffers.
|
---|
| 241 | */
|
---|
| 242 | #if !defined SNMP_LWIP_MIB2_SYSCONTACT || defined __DOXYGEN__
|
---|
| 243 | #define SNMP_LWIP_MIB2_SYSCONTACT ""
|
---|
| 244 | #endif
|
---|
| 245 |
|
---|
| 246 | /**
|
---|
| 247 | * Value return for sysLocation field of MIB2.
|
---|
| 248 | * To make sysLocation field settable, call snmp_mib2_set_syslocation() to provide the necessary buffers.
|
---|
| 249 | */
|
---|
| 250 | #if !defined SNMP_LWIP_MIB2_SYSLOCATION || defined __DOXYGEN__
|
---|
| 251 | #define SNMP_LWIP_MIB2_SYSLOCATION ""
|
---|
| 252 | #endif
|
---|
| 253 |
|
---|
| 254 | /**
|
---|
| 255 | * This value is used to limit the repetitions processed in GetBulk requests (value == 0 means no limitation).
|
---|
| 256 | * This may be useful to limit the load for a single request.
|
---|
| 257 | * According to SNMP RFC 1905 it is allowed to not return all requested variables from a GetBulk request if system load would be too high.
|
---|
| 258 | * so the effect is that the client will do more requests to gather all data.
|
---|
| 259 | * For the stack this could be useful in case that SNMP processing is done in TCP/IP thread. In this situation a request with many
|
---|
| 260 | * repetitions could block the thread for a longer time. Setting limit here will keep the stack more responsive.
|
---|
| 261 | */
|
---|
| 262 | #if !defined SNMP_LWIP_GETBULK_MAX_REPETITIONS || defined __DOXYGEN__
|
---|
| 263 | #define SNMP_LWIP_GETBULK_MAX_REPETITIONS 0
|
---|
| 264 | #endif
|
---|
| 265 |
|
---|
| 266 | /**
|
---|
| 267 | * @}
|
---|
| 268 | */
|
---|
| 269 |
|
---|
| 270 | /*
|
---|
| 271 | ------------------------------------
|
---|
| 272 | ---------- SNMPv3 options ----------
|
---|
| 273 | ------------------------------------
|
---|
| 274 | */
|
---|
| 275 |
|
---|
| 276 | /**
|
---|
| 277 | * LWIP_SNMP_V3==1: This enables EXPERIMENTAL SNMPv3 support. LWIP_SNMP must
|
---|
| 278 | * also be enabled.
|
---|
| 279 | * THIS IS UNDER DEVELOPMENT AND SHOULD NOT BE ENABLED IN PRODUCTS.
|
---|
| 280 | */
|
---|
| 281 | #ifndef LWIP_SNMP_V3
|
---|
| 282 | #define LWIP_SNMP_V3 0
|
---|
| 283 | #endif
|
---|
| 284 |
|
---|
| 285 | #ifndef LWIP_SNMP_V3_MBEDTLS
|
---|
| 286 | #define LWIP_SNMP_V3_MBEDTLS LWIP_SNMP_V3
|
---|
| 287 | #endif
|
---|
| 288 |
|
---|
| 289 | #ifndef LWIP_SNMP_V3_CRYPTO
|
---|
| 290 | #define LWIP_SNMP_V3_CRYPTO LWIP_SNMP_V3_MBEDTLS
|
---|
| 291 | #endif
|
---|
| 292 |
|
---|
| 293 | #ifndef LWIP_SNMP_CONFIGURE_VERSIONS
|
---|
| 294 | #define LWIP_SNMP_CONFIGURE_VERSIONS 0
|
---|
| 295 | #endif
|
---|
| 296 |
|
---|
| 297 | #endif /* LWIP_HDR_SNMP_OPTS_H */
|
---|