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