snmp_opts.h 9.4 KB

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