STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
snmp_table.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_TABLE_H
34 #define LWIP_HDR_APPS_SNMP_TABLE_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 /* default (customizable) read/write table */
46 
47 struct snmp_table_col_def
48 {
49  u32_t index;
50  u8_t asn1_type;
51  snmp_access_t access;
52 };
53 
54 struct snmp_table_node
55 {
56  /* inherited "base class" members */
57  struct snmp_leaf_node node;
58  u16_t column_count;
59  const struct snmp_table_col_def* columns;
60  snmp_err_t (*get_cell_instance)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, struct snmp_node_instance* cell_instance);
61  snmp_err_t (*get_next_cell_instance)(const u32_t* column, struct snmp_obj_id* row_oid, struct snmp_node_instance* cell_instance);
63  node_instance_get_value_method get_value;
65  node_instance_set_test_method set_test;
67  node_instance_set_value_method set_value;
68 };
69 
70 snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
71 snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
72 
73 #define SNMP_TABLE_CREATE(oid, columns, get_cell_instance_method, get_next_cell_instance_method, get_value_method, set_test_method, set_value_method) \
74  {{{ SNMP_NODE_TABLE, (oid) }, \
75  snmp_table_get_instance, \
76  snmp_table_get_next_instance }, \
77  (u16_t)LWIP_ARRAYSIZE(columns), (columns), \
78  (get_cell_instance_method), (get_next_cell_instance_method), \
79  (get_value_method), (set_test_method), (set_value_method)}
80 
81 #define SNMP_TABLE_GET_COLUMN_FROM_OID(oid) ((oid)[1]) /* first array value is (fixed) row entry (fixed to 1) and 2nd value is column, follow3ed by instance */
82 
83 
84 /* simple read-only table */
85 
86 typedef enum {
87  SNMP_VARIANT_VALUE_TYPE_U32,
88  SNMP_VARIANT_VALUE_TYPE_S32,
89  SNMP_VARIANT_VALUE_TYPE_PTR,
90  SNMP_VARIANT_VALUE_TYPE_CONST_PTR
91 } snmp_table_column_data_type_t;
92 
93 struct snmp_table_simple_col_def
94 {
95  u32_t index;
96  u8_t asn1_type;
97  snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/
98 };
99 
100 struct snmp_table_simple_node
101 {
102  /* inherited "base class" members */
103  struct snmp_leaf_node node;
104  u16_t column_count;
105  const struct snmp_table_simple_col_def* columns;
106  snmp_err_t (*get_cell_value)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len);
107  snmp_err_t (*get_next_cell_instance_and_value)(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len);
108 };
109 
110 snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
111 snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
112 
113 #define SNMP_TABLE_CREATE_SIMPLE(oid, columns, get_cell_value_method, get_next_cell_instance_and_value_method) \
114  {{{ SNMP_NODE_TABLE, (oid) }, \
115  snmp_table_simple_get_instance, \
116  snmp_table_simple_get_next_instance }, \
117  (u16_t)LWIP_ARRAYSIZE(columns), (columns), (get_cell_value_method), (get_next_cell_instance_and_value_method) }
118 
119 u16_t snmp_table_extract_value_from_s32ref(struct snmp_node_instance* instance, void* value);
120 u16_t snmp_table_extract_value_from_u32ref(struct snmp_node_instance* instance, void* value);
121 u16_t snmp_table_extract_value_from_refconstptr(struct snmp_node_instance* instance, void* value);
122 
123 #endif /* LWIP_SNMP */
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* LWIP_HDR_APPS_SNMP_TABLE_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