00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __LWIP_SNMP_STRUCTS_H__
00038 #define __LWIP_SNMP_STRUCTS_H__
00039
00040 #include "lwip/opt.h"
00041
00042 #if LWIP_SNMP
00043
00044 #include "lwip/snmp.h"
00045
00046 #if SNMP_PRIVATE_MIB
00047 #include "private_mib.h"
00048 #endif
00049
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053
00054
00055 #define MIB_OBJECT_NONE 0
00056 #define MIB_OBJECT_SCALAR 1
00057 #define MIB_OBJECT_TAB 2
00058
00059
00060 #define MIB_OBJECT_READ_ONLY 0
00061 #define MIB_OBJECT_READ_WRITE 1
00062 #define MIB_OBJECT_WRITE_ONLY 2
00063 #define MIB_OBJECT_NOT_ACCESSIBLE 3
00064
00065
00066 struct obj_def
00067 {
00068
00069 u8_t instance;
00070
00071 u8_t access;
00072
00073 u8_t asn_type;
00074
00075 u16_t v_len;
00076
00077 u8_t id_inst_len;
00078
00079 s32_t *id_inst_ptr;
00080 };
00081
00082 struct snmp_name_ptr
00083 {
00084 u8_t ident_len;
00085 s32_t *ident;
00086 };
00087
00088
00089 #define MIB_NODE_SC 0x01
00090
00091 #define MIB_NODE_AR 0x02
00092
00093 #define MIB_NODE_RA 0x03
00094
00095 #define MIB_NODE_LR 0x04
00096
00097 #define MIB_NODE_EX 0x05
00098
00099
00100 struct mib_node
00101 {
00102
00103 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00104
00105
00106 void (*get_value)(struct obj_def *od, u16_t len, void *value);
00107
00108 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00109
00110 void (*set_value)(struct obj_def *od, u16_t len, void *value);
00111
00112 const u8_t node_type;
00113
00114 const u16_t maxlength;
00115 };
00116
00117
00118 typedef struct mib_node mib_scalar_node;
00119
00120
00121
00122 struct mib_array_node
00123 {
00124
00125 void (* const get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00126 void (* const get_value)(struct obj_def *od, u16_t len, void *value);
00127 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00128 void (*set_value)(struct obj_def *od, u16_t len, void *value);
00129
00130 const u8_t node_type;
00131 const u16_t maxlength;
00132
00133
00134 const s32_t *objid;
00135 struct mib_node* const *nptr;
00136 };
00137
00138
00139
00140 struct mib_ram_array_node
00141 {
00142
00143 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00144 void (*get_value)(struct obj_def *od, u16_t len, void *value);
00145 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00146 void (*set_value)(struct obj_def *od, u16_t len, void *value);
00147
00148 u8_t node_type;
00149 u16_t maxlength;
00150
00151
00152 s32_t *objid;
00153 struct mib_node **nptr;
00154 };
00155
00156 struct mib_list_node
00157 {
00158 struct mib_list_node *prev;
00159 struct mib_list_node *next;
00160 s32_t objid;
00161 struct mib_node *nptr;
00162 };
00163
00164
00165
00166 struct mib_list_rootnode
00167 {
00168
00169 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00170 void (*get_value)(struct obj_def *od, u16_t len, void *value);
00171 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00172 void (*set_value)(struct obj_def *od, u16_t len, void *value);
00173
00174 u8_t node_type;
00175 u16_t maxlength;
00176
00177
00178 struct mib_list_node *head;
00179 struct mib_list_node *tail;
00180
00181 u16_t count;
00182 };
00183
00184
00185
00186 struct mib_external_node
00187 {
00188
00189 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00190 void (*get_value)(struct obj_def *od, u16_t len, void *value);
00191 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00192 void (*set_value)(struct obj_def *od, u16_t len, void *value);
00193
00194 u8_t node_type;
00195 u16_t maxlength;
00196
00197
00198
00199
00200 void* addr_inf;
00201
00202 u8_t tree_levels;
00203
00204 u16_t (*level_length)(void* addr_inf, u8_t level);
00205
00206
00207 s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id);
00208 void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id);
00209
00210
00211 void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident);
00212 void (*get_value_q)(u8_t rid, struct obj_def *od);
00213 void (*set_test_q)(u8_t rid, struct obj_def *od);
00214 void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value);
00215
00216 void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od);
00217 void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
00218 u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
00219 void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
00220
00221
00222 void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident);
00223 void (*get_value_pc)(u8_t rid, struct obj_def *od);
00224 void (*set_test_pc)(u8_t rid, struct obj_def *od);
00225 void (*set_value_pc)(u8_t rid, struct obj_def *od);
00226 };
00227
00228
00229 extern const struct mib_array_node internet;
00230
00231
00232 void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
00233 void noleafs_get_value(struct obj_def *od, u16_t len, void *value);
00234 u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value);
00235 void noleafs_set_value(struct obj_def *od, u16_t len, void *value);
00236
00237 void snmp_oidtoip(s32_t *ident, struct ip_addr *ip);
00238 void snmp_iptooid(struct ip_addr *ip, s32_t *ident);
00239 void snmp_ifindextonetif(s32_t ifindex, struct netif **netif);
00240 void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx);
00241
00242 struct mib_list_node* snmp_mib_ln_alloc(s32_t id);
00243 void snmp_mib_ln_free(struct mib_list_node *ln);
00244 struct mib_list_rootnode* snmp_mib_lrn_alloc(void);
00245 void snmp_mib_lrn_free(struct mib_list_rootnode *lrn);
00246
00247 s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn);
00248 s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn);
00249 struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n);
00250
00251 struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np);
00252 struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
00253 u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
00254 u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
00255
00256 #ifdef __cplusplus
00257 }
00258 #endif
00259
00260 #endif
00261
00262 #endif