SNMP agent attached to SPI slave

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers private_mib.h Source File

private_mib.h

00001 /*****************************************************************************
00002 *                     Copyright SEEC Ltd
00003 * File:             private_mib.H
00004 * Reference:        A3600-HDR-private_mib
00005 * Content:          Header file for private MIB tree structures
00006 * Version:          0.5
00007 * System:           mbed gnu compiler
00008 * Target Hardware:  mbed LPC1768                                  
00009 * Amendment Record:    
00010 * Author:      L. Smith for all versions unless otherwise specified 
00011 * Initial release
00012 * 0.1         21/11/11: L. Smith
00013   Derived from snmp_structs.h by Christiaan Simons <christiaan.simons@axon.tv>
00014 * 0.2         28/11/11: L. Smith
00015   Use SNMP_ENTERPRISE_ID for private mib
00016 * 0.3         30/11/11: L. Smith
00017   Increase ID range for private MIB scalars from 6 to MAX_PRIVATE_ID
00018 * 0.4         01/12/11: L. Smith
00019   Replace lwIP SNMP_ENTERPRISE_ID
00020 * 0.5         19/06/12: L. Smith
00021   Define snmp_obj_id snmptrap_id for use in msg_out.c
00022 *******************************************************************************/
00023 
00024 #ifndef __PRIVATE_MIB_H__
00025 #define __PRIVATE_MIB_H__
00026 
00027 #include "lwip/opt.h"
00028 
00029 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
00030 
00031 #include "lwip/snmp.h"
00032 #include "lwip/snmp_structs.h"
00033 #include "IO_file.h"
00034 
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #define SNMP_ENTERPRISE_ID  26381       // v0.4: replaces lwIP PEN from mib2.c
00041 #define MAX_PRIVATE_ID      9           // v0.5: max number of scalars in private MIB
00042 #define MAX_IO_TABLE        32          // v0.3: max number of I/O to be shown in table
00043 
00044 /** v0.5: enterprise ID for enterprise specific TRAPs */
00045 static struct snmp_obj_id snmptrap_id = {7,{1,3,6,1,4,1,SNMP_ENTERPRISE_ID}};
00046 
00047 /* MIB object instance      from snmp_structs.h
00048 #define MIB_OBJECT_NONE 0 
00049 #define MIB_OBJECT_SCALAR 1
00050 #define MIB_OBJECT_TAB 2
00051 
00052  MIB access types 
00053 #define MIB_ACCESS_READ   1
00054 #define MIB_ACCESS_WRITE  2
00055 
00056  MIB object access 
00057 #define MIB_OBJECT_READ_ONLY      MIB_ACCESS_READ
00058 #define MIB_OBJECT_READ_WRITE     (MIB_ACCESS_READ | MIB_ACCESS_WRITE)
00059 #define MIB_OBJECT_WRITE_ONLY     MIB_ACCESS_WRITE
00060 #define MIB_OBJECT_NOT_ACCESSIBLE 0
00061 */
00062 /** object definition returned by (get_object_def)() 
00063 struct obj_def
00064 {
00065    MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) 
00066   u8_t instance;
00067    0 read-only, 1 read-write, 2 write-only, 3 not-accessible 
00068   u8_t access;
00069    ASN type for this object 
00070   u8_t asn_type;
00071    value length (host length) 
00072   u16_t v_len;
00073    length of instance part of supplied object identifier 
00074   u8_t  id_inst_len;
00075    instance part of supplied object identifier 
00076   s32_t *id_inst_ptr;
00077 };
00078 
00079 struct snmp_name_ptr
00080 {
00081   u8_t ident_len;
00082   s32_t *ident;
00083 };
00084 */
00085 /** MIB const scalar (.0) node 
00086 #define MIB_NODE_SC 0x01
00087 * MIB const array node 
00088 #define MIB_NODE_AR 0x02
00089 * MIB array node (mem_malloced from RAM) 
00090 #define MIB_NODE_RA 0x03
00091 * MIB list root node (mem_malloced from RAM) 
00092 #define MIB_NODE_LR 0x04
00093 * MIB node for external objects 
00094 #define MIB_NODE_EX 0x05
00095 */
00096 /** node "base class" layout, the mandatory fields for a node  
00097 struct mib_node
00098 {
00099   * returns struct obj_def for the given object identifier 
00100   void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00101   * returns object value for the given object identifier,
00102      @note the caller must allocate at least len bytes for the value 
00103   void (*get_value)(struct obj_def *od, u16_t len, void *value);
00104   * tests length and/or range BEFORE setting 
00105   u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00106   * sets object value, only to be called when set_test()  
00107   void (*set_value)(struct obj_def *od, u16_t len, void *value);  
00108   * One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX 
00109   u8_t node_type;
00110    array or max list length 
00111   u16_t maxlength;
00112 };
00113 
00114 * derived node for scalars .0 index 
00115 typedef struct mib_node mib_scalar_node;
00116 */
00117 /* derived node, points to a fixed size const array
00118     of sub-identifiers plus a 'child' pointer 
00119 struct mib_array_node
00120 {
00121    inherited "base class" members 
00122   void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
00123   void (*get_value)(struct obj_def *od, u16_t len, void *value);
00124   u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
00125   void (*set_value)(struct obj_def *od, u16_t len, void *value);
00126 
00127   u8_t node_type;
00128   u16_t maxlength;
00129 
00130    additional struct members 
00131   const s32_t *objid;
00132   struct mib_node* const *nptr;
00133 };
00134 
00135 from snmp_structs.h */
00136 
00137 
00138 extern const struct mib_array_node mib_f3k;     // in private_mib.c
00139 /* v0.2: SNMP_ENTERPRISE_ID .1.3.6.1.4.1 */
00140 const s32_t private_ids[1] = { SNMP_ENTERPRISE_ID };
00141 struct mib_node* const private_nodes[1] = { (struct mib_node*)&mib_f3k };
00142 const struct mib_array_node mib_enterprise = {
00143   &noleafs_get_object_def,
00144   &noleafs_get_value,
00145   &noleafs_set_test,
00146   &noleafs_set_value,
00147   MIB_NODE_AR,
00148   1,
00149   private_ids,
00150   private_nodes
00151 };
00152 
00153 /* link from enterprises node to SNMP system calls via mib_private */
00154 /* enterprises .1.3.6.1.4 */
00155 const s32_t ent_ids[1] = { 1 };
00156 struct mib_node* const ent_nodes[1] = { (struct mib_node*)&mib_enterprise };
00157 const struct mib_array_node mib_private = {
00158   &noleafs_get_object_def,
00159   &noleafs_get_value,
00160   &noleafs_set_test,
00161   &noleafs_set_value,
00162   MIB_NODE_AR,
00163   1,
00164   ent_ids,
00165   ent_nodes
00166 };
00167 
00168 
00169 
00170 #ifdef __cplusplus
00171 }
00172 #endif
00173 
00174 #endif /* LWIP_SNMP */
00175 
00176 #endif /* __PRIVATE_MIB_H__ */