snmp_scalar.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * @file
  3. * SNMP server MIB API to implement scalar nodes
  4. */
  5. /*
  6. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
  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: Martin Hentschel <info@cl-soft.de>
  34. *
  35. */
  36. #ifndef LWIP_HDR_APPS_SNMP_SCALAR_H
  37. #define LWIP_HDR_APPS_SNMP_SCALAR_H
  38. #include "lwip/apps/snmp_opts.h"
  39. #include "lwip/apps/snmp_core.h"
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
  44. /** basic scalar node */
  45. struct snmp_scalar_node
  46. {
  47. /** inherited "base class" members */
  48. struct snmp_leaf_node node;
  49. u8_t asn1_type;
  50. snmp_access_t access;
  51. node_instance_get_value_method get_value;
  52. node_instance_set_test_method set_test;
  53. node_instance_set_value_method set_value;
  54. };
  55. snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
  56. snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
  57. #define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \
  58. {{{ SNMP_NODE_SCALAR, (oid) }, \
  59. snmp_scalar_get_instance, \
  60. snmp_scalar_get_next_instance }, \
  61. (asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) }
  62. #define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL)
  63. /** scalar array node - a tree node which contains scalars only as children */
  64. struct snmp_scalar_array_node_def
  65. {
  66. u32_t oid;
  67. u8_t asn1_type;
  68. snmp_access_t access;
  69. };
  70. typedef s16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*);
  71. typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
  72. typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
  73. /** basic scalar array node */
  74. struct snmp_scalar_array_node
  75. {
  76. /** inherited "base class" members */
  77. struct snmp_leaf_node node;
  78. u16_t array_node_count;
  79. const struct snmp_scalar_array_node_def* array_nodes;
  80. snmp_scalar_array_get_value_method get_value;
  81. snmp_scalar_array_set_test_method set_test;
  82. snmp_scalar_array_set_value_method set_value;
  83. };
  84. snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
  85. snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
  86. #define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \
  87. {{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \
  88. snmp_scalar_array_get_instance, \
  89. snmp_scalar_array_get_next_instance }, \
  90. (u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) }
  91. #endif /* LWIP_SNMP */
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */