Lorcan Smith
/
Enet_SPI
SNMP agent attached to SPI slave
lwip/core/snmp/private_mib.h@2:25e12a7fe0aa, 2012-09-06 (annotated)
- Committer:
- lorcansmith
- Date:
- Thu Sep 06 12:52:48 2012 +0000
- Revision:
- 2:25e12a7fe0aa
- Parent:
- 0:2a53a4c3238c
Open source version 1.a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lorcansmith | 0:2a53a4c3238c | 1 | /***************************************************************************** |
lorcansmith | 2:25e12a7fe0aa | 2 | * Copyright SEEC Ltd |
lorcansmith | 0:2a53a4c3238c | 3 | * File: private_mib.H |
lorcansmith | 2:25e12a7fe0aa | 4 | * Reference: A3600-HDR-private_mib |
lorcansmith | 0:2a53a4c3238c | 5 | * Content: Header file for private MIB tree structures |
lorcansmith | 2:25e12a7fe0aa | 6 | * Version: 0.5 |
lorcansmith | 0:2a53a4c3238c | 7 | * System: mbed gnu compiler |
lorcansmith | 0:2a53a4c3238c | 8 | * Target Hardware: mbed LPC1768 |
lorcansmith | 0:2a53a4c3238c | 9 | * Amendment Record: |
lorcansmith | 0:2a53a4c3238c | 10 | * Author: L. Smith for all versions unless otherwise specified |
lorcansmith | 0:2a53a4c3238c | 11 | * Initial release |
lorcansmith | 0:2a53a4c3238c | 12 | * 0.1 21/11/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 13 | Derived from snmp_structs.h by Christiaan Simons <christiaan.simons@axon.tv> |
lorcansmith | 0:2a53a4c3238c | 14 | * 0.2 28/11/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 15 | Use SNMP_ENTERPRISE_ID for private mib |
lorcansmith | 0:2a53a4c3238c | 16 | * 0.3 30/11/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 17 | Increase ID range for private MIB scalars from 6 to MAX_PRIVATE_ID |
lorcansmith | 0:2a53a4c3238c | 18 | * 0.4 01/12/11: L. Smith |
lorcansmith | 2:25e12a7fe0aa | 19 | Replace lwIP SNMP_ENTERPRISE_ID |
lorcansmith | 0:2a53a4c3238c | 20 | * 0.5 19/06/12: L. Smith |
lorcansmith | 0:2a53a4c3238c | 21 | Define snmp_obj_id snmptrap_id for use in msg_out.c |
lorcansmith | 0:2a53a4c3238c | 22 | *******************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 23 | |
lorcansmith | 0:2a53a4c3238c | 24 | #ifndef __PRIVATE_MIB_H__ |
lorcansmith | 0:2a53a4c3238c | 25 | #define __PRIVATE_MIB_H__ |
lorcansmith | 0:2a53a4c3238c | 26 | |
lorcansmith | 0:2a53a4c3238c | 27 | #include "lwip/opt.h" |
lorcansmith | 0:2a53a4c3238c | 28 | |
lorcansmith | 0:2a53a4c3238c | 29 | #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ |
lorcansmith | 0:2a53a4c3238c | 30 | |
lorcansmith | 0:2a53a4c3238c | 31 | #include "lwip/snmp.h" |
lorcansmith | 0:2a53a4c3238c | 32 | #include "lwip/snmp_structs.h" |
lorcansmith | 0:2a53a4c3238c | 33 | #include "IO_file.h" |
lorcansmith | 0:2a53a4c3238c | 34 | |
lorcansmith | 0:2a53a4c3238c | 35 | |
lorcansmith | 0:2a53a4c3238c | 36 | #ifdef __cplusplus |
lorcansmith | 0:2a53a4c3238c | 37 | extern "C" { |
lorcansmith | 0:2a53a4c3238c | 38 | #endif |
lorcansmith | 0:2a53a4c3238c | 39 | |
lorcansmith | 2:25e12a7fe0aa | 40 | #define SNMP_ENTERPRISE_ID 26381 // v0.4: replaces lwIP PEN from mib2.c |
lorcansmith | 0:2a53a4c3238c | 41 | #define MAX_PRIVATE_ID 9 // v0.5: max number of scalars in private MIB |
lorcansmith | 0:2a53a4c3238c | 42 | #define MAX_IO_TABLE 32 // v0.3: max number of I/O to be shown in table |
lorcansmith | 0:2a53a4c3238c | 43 | |
lorcansmith | 2:25e12a7fe0aa | 44 | /** v0.5: enterprise ID for enterprise specific TRAPs */ |
lorcansmith | 0:2a53a4c3238c | 45 | static struct snmp_obj_id snmptrap_id = {7,{1,3,6,1,4,1,SNMP_ENTERPRISE_ID}}; |
lorcansmith | 2:25e12a7fe0aa | 46 | |
lorcansmith | 0:2a53a4c3238c | 47 | /* MIB object instance from snmp_structs.h |
lorcansmith | 0:2a53a4c3238c | 48 | #define MIB_OBJECT_NONE 0 |
lorcansmith | 0:2a53a4c3238c | 49 | #define MIB_OBJECT_SCALAR 1 |
lorcansmith | 0:2a53a4c3238c | 50 | #define MIB_OBJECT_TAB 2 |
lorcansmith | 0:2a53a4c3238c | 51 | |
lorcansmith | 0:2a53a4c3238c | 52 | MIB access types |
lorcansmith | 0:2a53a4c3238c | 53 | #define MIB_ACCESS_READ 1 |
lorcansmith | 0:2a53a4c3238c | 54 | #define MIB_ACCESS_WRITE 2 |
lorcansmith | 0:2a53a4c3238c | 55 | |
lorcansmith | 0:2a53a4c3238c | 56 | MIB object access |
lorcansmith | 0:2a53a4c3238c | 57 | #define MIB_OBJECT_READ_ONLY MIB_ACCESS_READ |
lorcansmith | 0:2a53a4c3238c | 58 | #define MIB_OBJECT_READ_WRITE (MIB_ACCESS_READ | MIB_ACCESS_WRITE) |
lorcansmith | 0:2a53a4c3238c | 59 | #define MIB_OBJECT_WRITE_ONLY MIB_ACCESS_WRITE |
lorcansmith | 0:2a53a4c3238c | 60 | #define MIB_OBJECT_NOT_ACCESSIBLE 0 |
lorcansmith | 0:2a53a4c3238c | 61 | */ |
lorcansmith | 0:2a53a4c3238c | 62 | /** object definition returned by (get_object_def)() |
lorcansmith | 0:2a53a4c3238c | 63 | struct obj_def |
lorcansmith | 0:2a53a4c3238c | 64 | { |
lorcansmith | 0:2a53a4c3238c | 65 | MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) |
lorcansmith | 0:2a53a4c3238c | 66 | u8_t instance; |
lorcansmith | 0:2a53a4c3238c | 67 | 0 read-only, 1 read-write, 2 write-only, 3 not-accessible |
lorcansmith | 0:2a53a4c3238c | 68 | u8_t access; |
lorcansmith | 0:2a53a4c3238c | 69 | ASN type for this object |
lorcansmith | 0:2a53a4c3238c | 70 | u8_t asn_type; |
lorcansmith | 0:2a53a4c3238c | 71 | value length (host length) |
lorcansmith | 0:2a53a4c3238c | 72 | u16_t v_len; |
lorcansmith | 0:2a53a4c3238c | 73 | length of instance part of supplied object identifier |
lorcansmith | 0:2a53a4c3238c | 74 | u8_t id_inst_len; |
lorcansmith | 0:2a53a4c3238c | 75 | instance part of supplied object identifier |
lorcansmith | 0:2a53a4c3238c | 76 | s32_t *id_inst_ptr; |
lorcansmith | 0:2a53a4c3238c | 77 | }; |
lorcansmith | 0:2a53a4c3238c | 78 | |
lorcansmith | 0:2a53a4c3238c | 79 | struct snmp_name_ptr |
lorcansmith | 0:2a53a4c3238c | 80 | { |
lorcansmith | 0:2a53a4c3238c | 81 | u8_t ident_len; |
lorcansmith | 0:2a53a4c3238c | 82 | s32_t *ident; |
lorcansmith | 0:2a53a4c3238c | 83 | }; |
lorcansmith | 0:2a53a4c3238c | 84 | */ |
lorcansmith | 0:2a53a4c3238c | 85 | /** MIB const scalar (.0) node |
lorcansmith | 0:2a53a4c3238c | 86 | #define MIB_NODE_SC 0x01 |
lorcansmith | 0:2a53a4c3238c | 87 | * MIB const array node |
lorcansmith | 0:2a53a4c3238c | 88 | #define MIB_NODE_AR 0x02 |
lorcansmith | 0:2a53a4c3238c | 89 | * MIB array node (mem_malloced from RAM) |
lorcansmith | 0:2a53a4c3238c | 90 | #define MIB_NODE_RA 0x03 |
lorcansmith | 0:2a53a4c3238c | 91 | * MIB list root node (mem_malloced from RAM) |
lorcansmith | 0:2a53a4c3238c | 92 | #define MIB_NODE_LR 0x04 |
lorcansmith | 0:2a53a4c3238c | 93 | * MIB node for external objects |
lorcansmith | 0:2a53a4c3238c | 94 | #define MIB_NODE_EX 0x05 |
lorcansmith | 0:2a53a4c3238c | 95 | */ |
lorcansmith | 0:2a53a4c3238c | 96 | /** node "base class" layout, the mandatory fields for a node |
lorcansmith | 0:2a53a4c3238c | 97 | struct mib_node |
lorcansmith | 0:2a53a4c3238c | 98 | { |
lorcansmith | 0:2a53a4c3238c | 99 | * returns struct obj_def for the given object identifier |
lorcansmith | 0:2a53a4c3238c | 100 | void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); |
lorcansmith | 0:2a53a4c3238c | 101 | * returns object value for the given object identifier, |
lorcansmith | 0:2a53a4c3238c | 102 | @note the caller must allocate at least len bytes for the value |
lorcansmith | 0:2a53a4c3238c | 103 | void (*get_value)(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 104 | * tests length and/or range BEFORE setting |
lorcansmith | 0:2a53a4c3238c | 105 | u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 106 | * sets object value, only to be called when set_test() |
lorcansmith | 0:2a53a4c3238c | 107 | void (*set_value)(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 108 | * One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX |
lorcansmith | 0:2a53a4c3238c | 109 | u8_t node_type; |
lorcansmith | 0:2a53a4c3238c | 110 | array or max list length |
lorcansmith | 0:2a53a4c3238c | 111 | u16_t maxlength; |
lorcansmith | 0:2a53a4c3238c | 112 | }; |
lorcansmith | 0:2a53a4c3238c | 113 | |
lorcansmith | 0:2a53a4c3238c | 114 | * derived node for scalars .0 index |
lorcansmith | 0:2a53a4c3238c | 115 | typedef struct mib_node mib_scalar_node; |
lorcansmith | 0:2a53a4c3238c | 116 | */ |
lorcansmith | 0:2a53a4c3238c | 117 | /* derived node, points to a fixed size const array |
lorcansmith | 0:2a53a4c3238c | 118 | of sub-identifiers plus a 'child' pointer |
lorcansmith | 0:2a53a4c3238c | 119 | struct mib_array_node |
lorcansmith | 0:2a53a4c3238c | 120 | { |
lorcansmith | 0:2a53a4c3238c | 121 | inherited "base class" members |
lorcansmith | 0:2a53a4c3238c | 122 | void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); |
lorcansmith | 0:2a53a4c3238c | 123 | void (*get_value)(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 124 | u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 125 | void (*set_value)(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 126 | |
lorcansmith | 0:2a53a4c3238c | 127 | u8_t node_type; |
lorcansmith | 0:2a53a4c3238c | 128 | u16_t maxlength; |
lorcansmith | 0:2a53a4c3238c | 129 | |
lorcansmith | 0:2a53a4c3238c | 130 | additional struct members |
lorcansmith | 0:2a53a4c3238c | 131 | const s32_t *objid; |
lorcansmith | 0:2a53a4c3238c | 132 | struct mib_node* const *nptr; |
lorcansmith | 0:2a53a4c3238c | 133 | }; |
lorcansmith | 0:2a53a4c3238c | 134 | |
lorcansmith | 0:2a53a4c3238c | 135 | from snmp_structs.h */ |
lorcansmith | 0:2a53a4c3238c | 136 | |
lorcansmith | 0:2a53a4c3238c | 137 | |
lorcansmith | 0:2a53a4c3238c | 138 | extern const struct mib_array_node mib_f3k; // in private_mib.c |
lorcansmith | 0:2a53a4c3238c | 139 | /* v0.2: SNMP_ENTERPRISE_ID .1.3.6.1.4.1 */ |
lorcansmith | 0:2a53a4c3238c | 140 | const s32_t private_ids[1] = { SNMP_ENTERPRISE_ID }; |
lorcansmith | 0:2a53a4c3238c | 141 | struct mib_node* const private_nodes[1] = { (struct mib_node*)&mib_f3k }; |
lorcansmith | 0:2a53a4c3238c | 142 | const struct mib_array_node mib_enterprise = { |
lorcansmith | 0:2a53a4c3238c | 143 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 144 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 145 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 146 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 147 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 148 | 1, |
lorcansmith | 0:2a53a4c3238c | 149 | private_ids, |
lorcansmith | 0:2a53a4c3238c | 150 | private_nodes |
lorcansmith | 0:2a53a4c3238c | 151 | }; |
lorcansmith | 0:2a53a4c3238c | 152 | |
lorcansmith | 0:2a53a4c3238c | 153 | /* link from enterprises node to SNMP system calls via mib_private */ |
lorcansmith | 0:2a53a4c3238c | 154 | /* enterprises .1.3.6.1.4 */ |
lorcansmith | 0:2a53a4c3238c | 155 | const s32_t ent_ids[1] = { 1 }; |
lorcansmith | 0:2a53a4c3238c | 156 | struct mib_node* const ent_nodes[1] = { (struct mib_node*)&mib_enterprise }; |
lorcansmith | 0:2a53a4c3238c | 157 | const struct mib_array_node mib_private = { |
lorcansmith | 0:2a53a4c3238c | 158 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 159 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 160 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 161 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 162 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 163 | 1, |
lorcansmith | 0:2a53a4c3238c | 164 | ent_ids, |
lorcansmith | 0:2a53a4c3238c | 165 | ent_nodes |
lorcansmith | 0:2a53a4c3238c | 166 | }; |
lorcansmith | 0:2a53a4c3238c | 167 | |
lorcansmith | 0:2a53a4c3238c | 168 | |
lorcansmith | 0:2a53a4c3238c | 169 | |
lorcansmith | 0:2a53a4c3238c | 170 | #ifdef __cplusplus |
lorcansmith | 0:2a53a4c3238c | 171 | } |
lorcansmith | 0:2a53a4c3238c | 172 | #endif |
lorcansmith | 0:2a53a4c3238c | 173 | |
lorcansmith | 0:2a53a4c3238c | 174 | #endif /* LWIP_SNMP */ |
lorcansmith | 0:2a53a4c3238c | 175 | |
lorcansmith | 0:2a53a4c3238c | 176 | #endif /* __PRIVATE_MIB_H__ */ |