sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
snmp_table.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 * OF SUCH DAMAGE.
32 *
33 * This file is part of the lwIP TCP/IP stack.
34 *
35 * Author: Martin Hentschel <info@cl-soft.de>
36 *
37 */
38
39#ifndef LWIP_HDR_APPS_SNMP_TABLE_H
40#define LWIP_HDR_APPS_SNMP_TABLE_H
41
42#include "lwip/apps/snmp_opts.h"
43#include "lwip/apps/snmp_core.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
50
52struct snmp_table_col_def
53{
54 u32_t index;
55 u8_t asn1_type;
56 snmp_access_t access;
57};
58
60struct snmp_table_node
61{
63 struct snmp_leaf_node node;
64 u16_t column_count;
65 const struct snmp_table_col_def* columns;
66 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);
67 snmp_err_t (*get_next_cell_instance)(const u32_t* column, struct snmp_obj_id* row_oid, struct snmp_node_instance* cell_instance);
69 node_instance_get_value_method get_value;
71 node_instance_set_test_method set_test;
73 node_instance_set_value_method set_value;
74};
75
76snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
77snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
78
79#define SNMP_TABLE_CREATE(oid, columns, get_cell_instance_method, get_next_cell_instance_method, get_value_method, set_test_method, set_value_method) \
80 {{{ SNMP_NODE_TABLE, (oid) }, \
81 snmp_table_get_instance, \
82 snmp_table_get_next_instance }, \
83 (u16_t)LWIP_ARRAYSIZE(columns), (columns), \
84 (get_cell_instance_method), (get_next_cell_instance_method), \
85 (get_value_method), (set_test_method), (set_value_method)}
86
87#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 */
88
89
91typedef enum {
92 SNMP_VARIANT_VALUE_TYPE_U32,
93 SNMP_VARIANT_VALUE_TYPE_S32,
94 SNMP_VARIANT_VALUE_TYPE_PTR,
95 SNMP_VARIANT_VALUE_TYPE_CONST_PTR
96} snmp_table_column_data_type_t;
97
98struct snmp_table_simple_col_def
99{
100 u32_t index;
101 u8_t asn1_type;
102 snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/
103};
104
106struct snmp_table_simple_node
107{
108 /* inherited "base class" members */
109 struct snmp_leaf_node node;
110 u16_t column_count;
111 const struct snmp_table_simple_col_def* columns;
112 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);
113 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);
114};
115
116snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
117snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
118
119#define SNMP_TABLE_CREATE_SIMPLE(oid, columns, get_cell_value_method, get_next_cell_instance_and_value_method) \
120 {{{ SNMP_NODE_TABLE, (oid) }, \
121 snmp_table_simple_get_instance, \
122 snmp_table_simple_get_next_instance }, \
123 (u16_t)LWIP_ARRAYSIZE(columns), (columns), (get_cell_value_method), (get_next_cell_instance_and_value_method) }
124
125s16_t snmp_table_extract_value_from_s32ref(struct snmp_node_instance* instance, void* value);
126s16_t snmp_table_extract_value_from_u32ref(struct snmp_node_instance* instance, void* value);
127s16_t snmp_table_extract_value_from_refconstptr(struct snmp_node_instance* instance, void* value);
128
129#endif /* LWIP_SNMP */
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* LWIP_HDR_APPS_SNMP_TABLE_H */