STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
snmp_scalar.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Martin Hentschel <info@cl-soft.de>
30  *
31  */
32 
33 #ifndef LWIP_HDR_APPS_SNMP_SCALAR_H
34 #define LWIP_HDR_APPS_SNMP_SCALAR_H
35 
36 #include "lwip/apps/snmp_opts.h"
37 #include "lwip/apps/snmp_core.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
44 
45 /* basic scalar node */
46 
47 struct snmp_scalar_node
48 {
49  /* inherited "base class" members */
50  struct snmp_leaf_node node;
51  u8_t asn1_type;
52  snmp_access_t access;
53  node_instance_get_value_method get_value;
54  node_instance_set_test_method set_test;
55  node_instance_set_value_method set_value;
56 };
57 
58 
59 snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
60 snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
61 
62 #define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \
63  {{{ SNMP_NODE_SCALAR, (oid) }, \
64  snmp_scalar_get_instance, \
65  snmp_scalar_get_next_instance }, \
66  (asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) }
67 
68 #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)
69 
70 /* scalar array node - a tree node which contains scalars only as children */
71 struct snmp_scalar_array_node_def
72 {
73  u32_t oid;
74  u8_t asn1_type;
75  snmp_access_t access;
76 };
77 
78 typedef u16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*);
79 typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
80 typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
81 
82 struct snmp_scalar_array_node
83 {
84  /* inherited "base class" members */
85  struct snmp_leaf_node node;
86  u16_t array_node_count;
87  const struct snmp_scalar_array_node_def* array_nodes;
88  snmp_scalar_array_get_value_method get_value;
89  snmp_scalar_array_set_test_method set_test;
90  snmp_scalar_array_set_value_method set_value;
91 };
92 
93 snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
94 snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
95 
96 #define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \
97  {{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \
98  snmp_scalar_array_get_instance, \
99  snmp_scalar_array_get_next_instance }, \
100  (u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) }
101 
102 #endif /* LWIP_SNMP */
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */
unsigned long u32_t
Definition: cc.h:42
unsigned char u8_t
Definition: cc.h:38
unsigned short u16_t
Definition: cc.h:40