Lorcan Smith
/
Enet_SPI
SNMP agent attached to SPI slave
lwip/core/snmp/private_mib.c@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.c |
lorcansmith | 2:25e12a7fe0aa | 4 | * Reference: A3600-SRC-private_mib |
lorcansmith | 0:2a53a4c3238c | 5 | * Content: Header file for private MIB tree structures |
lorcansmith | 2:25e12a7fe0aa | 6 | * Version: 1.4 |
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 23/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 | Add f3k_cpu_version & f3k_mbed_version to scalar values |
lorcansmith | 0:2a53a4c3238c | 16 | * 0.3 01/12/11: L. Smith |
lorcansmith | 2:25e12a7fe0aa | 17 | Replace lwIP SNMP_ENTERPRISE_ID - see http://www.iana.org/assignments/enterprise-numbers |
lorcansmith | 0:2a53a4c3238c | 18 | * 0.4 13/12/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 19 | Increase function calls for number of I/O nodes to 32 |
lorcansmith | 0:2a53a4c3238c | 20 | * 0.5 21/12/11: L. Smith |
lorcansmith | 2:25e12a7fe0aa | 21 | Increase f3k_system nodes from 3 to 7 |
lorcansmith | 0:2a53a4c3238c | 22 | * 0.6 22/12/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 23 | Add f3k_comms_set_value() and f3k_comms_set_test() to enable UID change |
lorcansmith | 0:2a53a4c3238c | 24 | * 0.7 27/12/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 25 | Add f3k_sys_set_value() and f3k_sys_set_test() to enable UID change |
lorcansmith | 0:2a53a4c3238c | 26 | * 0.8 29/12/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 27 | Update f3k_sys_set_value() and f3k_sys_set_test() to enable net address change |
lorcansmith | 0:2a53a4c3238c | 28 | * 0.9 30/12/11: L. Smith |
lorcansmith | 0:2a53a4c3238c | 29 | Read least sig. (alternate) bytes from I/O channels in snmp_get_f3k_IO_value() |
lorcansmith | 0:2a53a4c3238c | 30 | * 1.0 11/01/12: L. Smith |
lorcansmith | 0:2a53a4c3238c | 31 | Add breaks in case statement to fix f3k_speed reporting error |
lorcansmith | 0:2a53a4c3238c | 32 | * 1.1 30/01/12: L. Smith |
lorcansmith | 0:2a53a4c3238c | 33 | Add f3k_SPI_count as f3k_sys_object 5 before f3k_run_scan |
lorcansmith | 0:2a53a4c3238c | 34 | * 1.2 02/05/12: L. Smith |
lorcansmith | 0:2a53a4c3238c | 35 | Change pointers for RTU unit ID from s32_t to u16_t |
lorcansmith | 0:2a53a4c3238c | 36 | * 1.3 19/06/12: L. Smith |
lorcansmith | 0:2a53a4c3238c | 37 | Add f3k_IO_mask as R/W f3k_sys_object 7 - hex formatted string |
lorcansmith | 0:2a53a4c3238c | 38 | * 1.4 20/06/12: L. Smith |
lorcansmith | 2:25e12a7fe0aa | 39 | Add snmp_trh_addrs[4] as R/W f3k_comms 8 - trap host |
lorcansmith | 0:2a53a4c3238c | 40 | *******************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 41 | |
lorcansmith | 0:2a53a4c3238c | 42 | #include "lwip/opt.h" |
lorcansmith | 0:2a53a4c3238c | 43 | |
lorcansmith | 0:2a53a4c3238c | 44 | #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ |
lorcansmith | 0:2a53a4c3238c | 45 | |
lorcansmith | 0:2a53a4c3238c | 46 | #include <stdlib.h> |
lorcansmith | 0:2a53a4c3238c | 47 | #include <string.h> |
lorcansmith | 0:2a53a4c3238c | 48 | |
lorcansmith | 0:2a53a4c3238c | 49 | #include "lwip/snmp.h" |
lorcansmith | 0:2a53a4c3238c | 50 | #include "lwip/udp.h" |
lorcansmith | 0:2a53a4c3238c | 51 | #include "lwip/snmp_asn1.h" |
lorcansmith | 0:2a53a4c3238c | 52 | #include "lwip/snmp_structs.h" |
lorcansmith | 0:2a53a4c3238c | 53 | #include "lwip/snmp_msg.h" |
lorcansmith | 0:2a53a4c3238c | 54 | #include "IO_file.h" |
lorcansmith | 0:2a53a4c3238c | 55 | #include "private_mib.h" |
lorcansmith | 0:2a53a4c3238c | 56 | |
lorcansmith | 0:2a53a4c3238c | 57 | /* mib_f3k integers derived from 3000 CPU */ |
lorcansmith | 0:2a53a4c3238c | 58 | static u16_t f3k_error = 0, |
lorcansmith | 0:2a53a4c3238c | 59 | f3k_num_cards = 0, |
lorcansmith | 0:2a53a4c3238c | 60 | f3k_SPI_count = 0, |
lorcansmith | 0:2a53a4c3238c | 61 | f3k_run_scan = 0, |
lorcansmith | 0:2a53a4c3238c | 62 | f3k_uid = 0, |
lorcansmith | 0:2a53a4c3238c | 63 | f3k_protocol = 0; |
lorcansmith | 0:2a53a4c3238c | 64 | static u32_t f3k_speed = 0; |
lorcansmith | 0:2a53a4c3238c | 65 | static char f3k_fw_version[ 4 ] = {0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 66 | /* v1.3: I/O mask is read/written in SNMP protocol as 8 byte hex string */ |
lorcansmith | 0:2a53a4c3238c | 67 | static char f3k_IO_mask[ 8 ] = {0,0,0,0,0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 68 | |
lorcansmith | 0:2a53a4c3238c | 69 | /* lengths of ethernet address strings */ |
lorcansmith | 0:2a53a4c3238c | 70 | static u16_t snmp_ip_len = 0, |
lorcansmith | 0:2a53a4c3238c | 71 | snmp_net_len = 0, |
lorcansmith | 0:2a53a4c3238c | 72 | snmp_gwy_len = 0, |
lorcansmith | 0:2a53a4c3238c | 73 | snmp_trh_len = 0, |
lorcansmith | 0:2a53a4c3238c | 74 | snmp_dns_len = 0; |
lorcansmith | 0:2a53a4c3238c | 75 | /* ethernet address strings */ |
lorcansmith | 0:2a53a4c3238c | 76 | static char snmp_ip_addrs[ 16 ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 77 | static char snmp_net_mask[ 16 ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 78 | static char snmp_gwy_addrs[ 16 ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 79 | static char snmp_dns_addrs[ 16 ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 80 | static char snmp_trh_addrs[ 16 ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
lorcansmith | 0:2a53a4c3238c | 81 | //static char snmp_trh_addrs[ 4 ] = {0,0,0,0}; // v1.4: Trap host address |
lorcansmith | 0:2a53a4c3238c | 82 | |
lorcansmith | 0:2a53a4c3238c | 83 | |
lorcansmith | 0:2a53a4c3238c | 84 | static void f3k_IO_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); |
lorcansmith | 0:2a53a4c3238c | 85 | static void f3k_IO_get_value(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 86 | static void f3k_comms_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); |
lorcansmith | 0:2a53a4c3238c | 87 | static void f3k_comms_get_value(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 88 | static u8_t f3k_comms_set_test(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 89 | static void f3k_comms_set_value(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 90 | static void f3k_sys_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); |
lorcansmith | 0:2a53a4c3238c | 91 | static void f3k_sys_get_value(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 92 | static u8_t f3k_sys_set_test(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 93 | static void f3k_sys_set_value(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 94 | void snmp_get_f3k_data( void ); |
lorcansmith | 0:2a53a4c3238c | 95 | u32_t snmp_get_f3k_IO_value( u8_t index ); |
lorcansmith | 0:2a53a4c3238c | 96 | void snmp_update_net_addrs( void ); |
lorcansmith | 0:2a53a4c3238c | 97 | int update_addrs_from_string( char * adrs_str, unsigned char * num_array ); |
lorcansmith | 0:2a53a4c3238c | 98 | |
lorcansmith | 0:2a53a4c3238c | 99 | /* the following routines are not used as no tables are used for F3000 |
lorcansmith | 0:2a53a4c3238c | 100 | static void f3kentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); |
lorcansmith | 0:2a53a4c3238c | 101 | static void f3kentry_get_value(struct obj_def *od, u16_t len, void *value); |
lorcansmith | 0:2a53a4c3238c | 102 | |
lorcansmith | 0:2a53a4c3238c | 103 | // mib_f3k .1.3.6.1.4.1.SNMP_ENTERPRISE_ID |
lorcansmith | 0:2a53a4c3238c | 104 | // index root node for f3kTable |
lorcansmith | 0:2a53a4c3238c | 105 | struct mib_list_rootnode f3k_root = { |
lorcansmith | 0:2a53a4c3238c | 106 | &f3kentry_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 107 | &f3kentry_get_value, |
lorcansmith | 0:2a53a4c3238c | 108 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 109 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 110 | MIB_NODE_LR, |
lorcansmith | 0:2a53a4c3238c | 111 | 0, |
lorcansmith | 0:2a53a4c3238c | 112 | NULL, |
lorcansmith | 0:2a53a4c3238c | 113 | NULL, |
lorcansmith | 0:2a53a4c3238c | 114 | 0 |
lorcansmith | 0:2a53a4c3238c | 115 | }; |
lorcansmith | 0:2a53a4c3238c | 116 | |
lorcansmith | 0:2a53a4c3238c | 117 | const s32_t f3kentry_ids[2] = { 1, 2 }; |
lorcansmith | 0:2a53a4c3238c | 118 | struct mib_node* const f3kentry_nodes[2] = { |
lorcansmith | 0:2a53a4c3238c | 119 | (struct mib_node*)&f3k_root, (struct mib_node*)&f3k_root, |
lorcansmith | 0:2a53a4c3238c | 120 | }; |
lorcansmith | 0:2a53a4c3238c | 121 | const struct mib_array_node f3kentry = { |
lorcansmith | 0:2a53a4c3238c | 122 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 123 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 124 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 125 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 126 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 127 | 2, |
lorcansmith | 0:2a53a4c3238c | 128 | f3kentry_ids, |
lorcansmith | 0:2a53a4c3238c | 129 | f3kentry_nodes |
lorcansmith | 0:2a53a4c3238c | 130 | }; |
lorcansmith | 0:2a53a4c3238c | 131 | |
lorcansmith | 0:2a53a4c3238c | 132 | s32_t f3ktable_id = 1; |
lorcansmith | 0:2a53a4c3238c | 133 | struct mib_node* f3ktable_node = (struct mib_node*)&f3kentry; |
lorcansmith | 0:2a53a4c3238c | 134 | struct mib_ram_array_node f3ktable = { |
lorcansmith | 0:2a53a4c3238c | 135 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 136 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 137 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 138 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 139 | MIB_NODE_RA, |
lorcansmith | 0:2a53a4c3238c | 140 | 0, |
lorcansmith | 0:2a53a4c3238c | 141 | &f3ktable_id, |
lorcansmith | 0:2a53a4c3238c | 142 | &f3ktable_node |
lorcansmith | 0:2a53a4c3238c | 143 | }; |
lorcansmith | 0:2a53a4c3238c | 144 | */ |
lorcansmith | 0:2a53a4c3238c | 145 | |
lorcansmith | 0:2a53a4c3238c | 146 | /* f3k_IO nodes */ |
lorcansmith | 0:2a53a4c3238c | 147 | const mib_scalar_node f3k_IO_scalar = { |
lorcansmith | 0:2a53a4c3238c | 148 | &f3k_IO_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 149 | &f3k_IO_get_value, |
lorcansmith | 0:2a53a4c3238c | 150 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 151 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 152 | MIB_NODE_SC, |
lorcansmith | 0:2a53a4c3238c | 153 | 0 |
lorcansmith | 0:2a53a4c3238c | 154 | }; |
lorcansmith | 0:2a53a4c3238c | 155 | |
lorcansmith | 0:2a53a4c3238c | 156 | const s32_t f3k_IO_ids[32] = { 1, 2, 3, 4, 5, 6, 7, 8, |
lorcansmith | 0:2a53a4c3238c | 157 | 9, 10, 11, 12, 13, 14, 15, 16, |
lorcansmith | 0:2a53a4c3238c | 158 | 17, 18, 19, 20, 21, 22, 23, 24, |
lorcansmith | 0:2a53a4c3238c | 159 | 25, 26, 27, 28, 29, 30, 31, 32 }; |
lorcansmith | 0:2a53a4c3238c | 160 | struct mib_node* const f3k_IO_nodes[32] = { |
lorcansmith | 0:2a53a4c3238c | 161 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 162 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 163 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 164 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 165 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 166 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 167 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 168 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 169 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 170 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 171 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 172 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 173 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 174 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 175 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar, |
lorcansmith | 0:2a53a4c3238c | 176 | (struct mib_node*)&f3k_IO_scalar, (struct mib_node*)&f3k_IO_scalar |
lorcansmith | 0:2a53a4c3238c | 177 | }; |
lorcansmith | 0:2a53a4c3238c | 178 | /* v0.3: f3k_IO .1.3.6.1.4.1.SNMP_ENTERPRISE_ID.mib_f3k */ |
lorcansmith | 0:2a53a4c3238c | 179 | const struct mib_array_node f3k_IO = { |
lorcansmith | 0:2a53a4c3238c | 180 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 181 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 182 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 183 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 184 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 185 | 32, |
lorcansmith | 0:2a53a4c3238c | 186 | f3k_IO_ids, |
lorcansmith | 0:2a53a4c3238c | 187 | f3k_IO_nodes |
lorcansmith | 0:2a53a4c3238c | 188 | }; |
lorcansmith | 0:2a53a4c3238c | 189 | |
lorcansmith | 0:2a53a4c3238c | 190 | |
lorcansmith | 0:2a53a4c3238c | 191 | /* f3k_comms nodes */ |
lorcansmith | 0:2a53a4c3238c | 192 | const mib_scalar_node f3k_comms_scalar = { |
lorcansmith | 0:2a53a4c3238c | 193 | &f3k_comms_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 194 | &f3k_comms_get_value, |
lorcansmith | 0:2a53a4c3238c | 195 | &f3k_comms_set_test, |
lorcansmith | 0:2a53a4c3238c | 196 | &f3k_comms_set_value, |
lorcansmith | 0:2a53a4c3238c | 197 | MIB_NODE_SC, |
lorcansmith | 0:2a53a4c3238c | 198 | 0 |
lorcansmith | 0:2a53a4c3238c | 199 | }; |
lorcansmith | 0:2a53a4c3238c | 200 | |
lorcansmith | 2:25e12a7fe0aa | 201 | const s32_t f3k_comms_ids[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
lorcansmith | 2:25e12a7fe0aa | 202 | struct mib_node* const f3k_comms_nodes[8] = { |
lorcansmith | 0:2a53a4c3238c | 203 | (struct mib_node*)&f3k_comms_scalar, (struct mib_node*)&f3k_comms_scalar, |
lorcansmith | 0:2a53a4c3238c | 204 | (struct mib_node*)&f3k_comms_scalar, (struct mib_node*)&f3k_comms_scalar, |
lorcansmith | 0:2a53a4c3238c | 205 | (struct mib_node*)&f3k_comms_scalar, (struct mib_node*)&f3k_comms_scalar, |
lorcansmith | 2:25e12a7fe0aa | 206 | (struct mib_node*)&f3k_comms_scalar, (struct mib_node*)&f3k_comms_scalar |
lorcansmith | 0:2a53a4c3238c | 207 | }; |
lorcansmith | 0:2a53a4c3238c | 208 | /* v0.3: f3k_comms .1.3.6.1.4.1.SNMP_ENTERPRISE_ID.mib_f3k */ |
lorcansmith | 0:2a53a4c3238c | 209 | const struct mib_array_node f3k_comms = { |
lorcansmith | 0:2a53a4c3238c | 210 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 211 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 212 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 213 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 214 | MIB_NODE_AR, |
lorcansmith | 2:25e12a7fe0aa | 215 | 8, |
lorcansmith | 0:2a53a4c3238c | 216 | f3k_comms_ids, |
lorcansmith | 0:2a53a4c3238c | 217 | f3k_comms_nodes |
lorcansmith | 0:2a53a4c3238c | 218 | }; |
lorcansmith | 0:2a53a4c3238c | 219 | |
lorcansmith | 0:2a53a4c3238c | 220 | |
lorcansmith | 0:2a53a4c3238c | 221 | /* f3k_system nodes */ |
lorcansmith | 0:2a53a4c3238c | 222 | const mib_scalar_node f3k_sys_scalar = { |
lorcansmith | 0:2a53a4c3238c | 223 | &f3k_sys_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 224 | &f3k_sys_get_value, |
lorcansmith | 0:2a53a4c3238c | 225 | &f3k_sys_set_test, |
lorcansmith | 0:2a53a4c3238c | 226 | &f3k_sys_set_value, |
lorcansmith | 0:2a53a4c3238c | 227 | MIB_NODE_SC, |
lorcansmith | 0:2a53a4c3238c | 228 | 0 |
lorcansmith | 0:2a53a4c3238c | 229 | }; |
lorcansmith | 0:2a53a4c3238c | 230 | |
lorcansmith | 0:2a53a4c3238c | 231 | const s32_t f3k_sys_ids[7] = { 1, 2, 3, 4, 5, 6, 7 }; |
lorcansmith | 0:2a53a4c3238c | 232 | struct mib_node* const f3k_sys_nodes[7] = { |
lorcansmith | 0:2a53a4c3238c | 233 | (struct mib_node*)&f3k_sys_scalar, (struct mib_node*)&f3k_sys_scalar, |
lorcansmith | 0:2a53a4c3238c | 234 | (struct mib_node*)&f3k_sys_scalar, (struct mib_node*)&f3k_sys_scalar, |
lorcansmith | 0:2a53a4c3238c | 235 | (struct mib_node*)&f3k_sys_scalar, (struct mib_node*)&f3k_sys_scalar, |
lorcansmith | 0:2a53a4c3238c | 236 | (struct mib_node*)&f3k_sys_scalar |
lorcansmith | 0:2a53a4c3238c | 237 | /*, (struct mib_node*)&f3ktable */ |
lorcansmith | 0:2a53a4c3238c | 238 | }; |
lorcansmith | 0:2a53a4c3238c | 239 | /* v0.3: f3k_system .1.3.6.1.4.1.SNMP_ENTERPRISE_ID.mib_f3k */ |
lorcansmith | 0:2a53a4c3238c | 240 | const struct mib_array_node f3k_system = { |
lorcansmith | 0:2a53a4c3238c | 241 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 242 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 243 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 244 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 245 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 246 | 7, |
lorcansmith | 0:2a53a4c3238c | 247 | f3k_sys_ids, |
lorcansmith | 0:2a53a4c3238c | 248 | f3k_sys_nodes |
lorcansmith | 0:2a53a4c3238c | 249 | }; |
lorcansmith | 0:2a53a4c3238c | 250 | |
lorcansmith | 2:25e12a7fe0aa | 251 | const s32_t f3k_ids[5] = { 1, 2, 3 }; |
lorcansmith | 2:25e12a7fe0aa | 252 | struct mib_node* const f3k_nodes[3] = { |
lorcansmith | 0:2a53a4c3238c | 253 | (struct mib_node*)&f3k_system, |
lorcansmith | 0:2a53a4c3238c | 254 | (struct mib_node*)&f3k_comms, |
lorcansmith | 2:25e12a7fe0aa | 255 | (struct mib_node*)&f3k_IO |
lorcansmith | 0:2a53a4c3238c | 256 | }; |
lorcansmith | 0:2a53a4c3238c | 257 | /* v0.3: mib_f3k .1.3.6.1.4.1.SNMP_ENTERPRISE_ID */ |
lorcansmith | 0:2a53a4c3238c | 258 | /* f3k private node called from mib_array_node mib_link */ |
lorcansmith | 0:2a53a4c3238c | 259 | const struct mib_array_node mib_f3k = { |
lorcansmith | 0:2a53a4c3238c | 260 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 261 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 262 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 263 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 264 | MIB_NODE_AR, |
lorcansmith | 2:25e12a7fe0aa | 265 | 3, |
lorcansmith | 0:2a53a4c3238c | 266 | f3k_ids, |
lorcansmith | 0:2a53a4c3238c | 267 | f3k_nodes |
lorcansmith | 0:2a53a4c3238c | 268 | }; |
lorcansmith | 0:2a53a4c3238c | 269 | |
lorcansmith | 0:2a53a4c3238c | 270 | |
lorcansmith | 0:2a53a4c3238c | 271 | /* link from enterprises node to SNMP system calls via mib_private */ |
lorcansmith | 0:2a53a4c3238c | 272 | /* v0.2: SNMP_ENTERPRISE_ID .1.3.6.1.4.1 |
lorcansmith | 0:2a53a4c3238c | 273 | const s32_t private_ids[1] = { SNMP_ENTERPRISE_ID }; |
lorcansmith | 0:2a53a4c3238c | 274 | struct mib_node* const private_nodes[1] = { (struct mib_node*)&mib_f3k }; |
lorcansmith | 0:2a53a4c3238c | 275 | const struct mib_array_node mib_enterprise = { |
lorcansmith | 0:2a53a4c3238c | 276 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 277 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 278 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 279 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 280 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 281 | 1, |
lorcansmith | 0:2a53a4c3238c | 282 | private_ids, |
lorcansmith | 0:2a53a4c3238c | 283 | private_nodes |
lorcansmith | 0:2a53a4c3238c | 284 | }; |
lorcansmith | 0:2a53a4c3238c | 285 | */ |
lorcansmith | 0:2a53a4c3238c | 286 | |
lorcansmith | 0:2a53a4c3238c | 287 | /* internet .1.3.6.1 */ |
lorcansmith | 0:2a53a4c3238c | 288 | /* When using a private MIB, you have to create a file 'private_mib.h' that contains |
lorcansmith | 0:2a53a4c3238c | 289 | * a 'struct mib_array_node mib_private' which contains your MIB. |
lorcansmith | 0:2a53a4c3238c | 290 | s32_t internet_ids[2] = { 2, 4 }; |
lorcansmith | 0:2a53a4c3238c | 291 | struct mib_node* const internet_nodes[2] = { (struct mib_node*)&mgmt, (struct mib_node*)&mib_private }; |
lorcansmith | 0:2a53a4c3238c | 292 | const struct mib_array_node internet = { |
lorcansmith | 0:2a53a4c3238c | 293 | &noleafs_get_object_def, |
lorcansmith | 0:2a53a4c3238c | 294 | &noleafs_get_value, |
lorcansmith | 0:2a53a4c3238c | 295 | &noleafs_set_test, |
lorcansmith | 0:2a53a4c3238c | 296 | &noleafs_set_value, |
lorcansmith | 0:2a53a4c3238c | 297 | MIB_NODE_AR, |
lorcansmith | 0:2a53a4c3238c | 298 | 2, |
lorcansmith | 0:2a53a4c3238c | 299 | internet_ids, |
lorcansmith | 0:2a53a4c3238c | 300 | internet_nodes |
lorcansmith | 0:2a53a4c3238c | 301 | }; |
lorcansmith | 0:2a53a4c3238c | 302 | */ |
lorcansmith | 0:2a53a4c3238c | 303 | |
lorcansmith | 0:2a53a4c3238c | 304 | |
lorcansmith | 0:2a53a4c3238c | 305 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 306 | /* snmp_get_f3k_data: |
lorcansmith | 0:2a53a4c3238c | 307 | * Description: Updates SNMP data from data array written by F3000 SPI |
lorcansmith | 0:2a53a4c3238c | 308 | * Called by f3k_sys_get_value() |
lorcansmith | 0:2a53a4c3238c | 309 | * Parameters: NONE |
lorcansmith | 0:2a53a4c3238c | 310 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 311 | */ |
lorcansmith | 0:2a53a4c3238c | 312 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 313 | void snmp_get_f3k_data(void) |
lorcansmith | 0:2a53a4c3238c | 314 | { |
lorcansmith | 0:2a53a4c3238c | 315 | u8_t comm_cfg; |
lorcansmith | 0:2a53a4c3238c | 316 | u8_t f3k_version; |
lorcansmith | 0:2a53a4c3238c | 317 | |
lorcansmith | 0:2a53a4c3238c | 318 | f3k_error = fsvr.get_error(); |
lorcansmith | 0:2a53a4c3238c | 319 | f3k_num_cards = (u16_t)fsvr.get_byte( NUM_CARD_IDX ); |
lorcansmith | 0:2a53a4c3238c | 320 | f3k_SPI_count = fsvr.get_SPI_count(); |
lorcansmith | 0:2a53a4c3238c | 321 | f3k_run_scan = (u16_t)fsvr.get_byte( RUN_SCAN_IDX ); |
lorcansmith | 2:25e12a7fe0aa | 322 | strncpy( f3k_IO_mask, get_hex_mask(), 8 ); // v1.3: copy mask4_IO_registers as hex |
lorcansmith | 0:2a53a4c3238c | 323 | f3k_uid = (u16_t)fsvr.get_byte( UNIT_ID_IDX ); |
lorcansmith | 0:2a53a4c3238c | 324 | comm_cfg = (u8_t)fsvr.get_byte( COMMS_IDX ); |
lorcansmith | 0:2a53a4c3238c | 325 | f3k_protocol = (u16_t)(comm_cfg / 16); |
lorcansmith | 0:2a53a4c3238c | 326 | switch (comm_cfg & 0x0f) |
lorcansmith | 0:2a53a4c3238c | 327 | { |
lorcansmith | 0:2a53a4c3238c | 328 | case 2 : |
lorcansmith | 0:2a53a4c3238c | 329 | f3k_speed = 600; |
lorcansmith | 0:2a53a4c3238c | 330 | break; |
lorcansmith | 0:2a53a4c3238c | 331 | case 3 : |
lorcansmith | 0:2a53a4c3238c | 332 | f3k_speed = 1200; |
lorcansmith | 0:2a53a4c3238c | 333 | break; |
lorcansmith | 0:2a53a4c3238c | 334 | case 4 : |
lorcansmith | 0:2a53a4c3238c | 335 | f3k_speed = 2400; |
lorcansmith | 0:2a53a4c3238c | 336 | break; |
lorcansmith | 0:2a53a4c3238c | 337 | case 5 : |
lorcansmith | 0:2a53a4c3238c | 338 | f3k_speed = 4800; |
lorcansmith | 0:2a53a4c3238c | 339 | break; |
lorcansmith | 0:2a53a4c3238c | 340 | case 6 : |
lorcansmith | 0:2a53a4c3238c | 341 | f3k_speed = 9600; |
lorcansmith | 0:2a53a4c3238c | 342 | break; |
lorcansmith | 0:2a53a4c3238c | 343 | case 7 : |
lorcansmith | 0:2a53a4c3238c | 344 | f3k_speed = 19200; |
lorcansmith | 0:2a53a4c3238c | 345 | break; |
lorcansmith | 0:2a53a4c3238c | 346 | case 8 : |
lorcansmith | 0:2a53a4c3238c | 347 | f3k_speed = 38400; |
lorcansmith | 0:2a53a4c3238c | 348 | break; |
lorcansmith | 0:2a53a4c3238c | 349 | case 9 : |
lorcansmith | 0:2a53a4c3238c | 350 | f3k_speed = 76800; |
lorcansmith | 0:2a53a4c3238c | 351 | break; |
lorcansmith | 0:2a53a4c3238c | 352 | default : |
lorcansmith | 0:2a53a4c3238c | 353 | f3k_speed = 9600; |
lorcansmith | 0:2a53a4c3238c | 354 | break; |
lorcansmith | 0:2a53a4c3238c | 355 | } |
lorcansmith | 0:2a53a4c3238c | 356 | f3k_version = (u8_t)fsvr.get_byte( VERSION_IDX ); |
lorcansmith | 0:2a53a4c3238c | 357 | f3k_fw_version[0] = (f3k_version / 16) + '0'; |
lorcansmith | 0:2a53a4c3238c | 358 | f3k_fw_version[1] = '.'; |
lorcansmith | 0:2a53a4c3238c | 359 | if ( (f3k_version & 0xf) < 0xa ) |
lorcansmith | 0:2a53a4c3238c | 360 | { |
lorcansmith | 0:2a53a4c3238c | 361 | f3k_fw_version[2] = (f3k_version & 0xf) + '0'; |
lorcansmith | 0:2a53a4c3238c | 362 | } |
lorcansmith | 0:2a53a4c3238c | 363 | else |
lorcansmith | 0:2a53a4c3238c | 364 | { |
lorcansmith | 0:2a53a4c3238c | 365 | f3k_fw_version[2] = (f3k_version & 0xf) - 0xa + 'A'; |
lorcansmith | 0:2a53a4c3238c | 366 | } |
lorcansmith | 0:2a53a4c3238c | 367 | } |
lorcansmith | 0:2a53a4c3238c | 368 | |
lorcansmith | 0:2a53a4c3238c | 369 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 370 | /* snmp_get_f3k_IO_value: |
lorcansmith | 0:2a53a4c3238c | 371 | * Description: Updates SNMP data from I/O data in array written by F3000 SPI |
lorcansmith | 0:2a53a4c3238c | 372 | * Called by f3kentry_get_value() |
lorcansmith | 0:2a53a4c3238c | 373 | * Parameters: IN: u8_t 1-based index into 0-based Field SPI server array |
lorcansmith | 0:2a53a4c3238c | 374 | * Returns: u32_t io_value from Field SPI server array |
lorcansmith | 0:2a53a4c3238c | 375 | */ |
lorcansmith | 0:2a53a4c3238c | 376 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 377 | u32_t snmp_get_f3k_IO_value( u8_t index ) |
lorcansmith | 0:2a53a4c3238c | 378 | { |
lorcansmith | 0:2a53a4c3238c | 379 | unsigned short io_value; |
lorcansmith | 0:2a53a4c3238c | 380 | |
lorcansmith | 0:2a53a4c3238c | 381 | index = index > 0 ? 2 * (index - 1) : index; // index range is 1 to 32 |
lorcansmith | 0:2a53a4c3238c | 382 | io_value = 256 * fsvr.get_byte( index ); // v0.9: read ms byte from I/O |
lorcansmith | 0:2a53a4c3238c | 383 | io_value += fsvr.get_byte( index + 1 ); // v0.9: add ls byte from I/O |
lorcansmith | 0:2a53a4c3238c | 384 | return (u32_t)io_value; |
lorcansmith | 0:2a53a4c3238c | 385 | } |
lorcansmith | 0:2a53a4c3238c | 386 | |
lorcansmith | 0:2a53a4c3238c | 387 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 388 | /* snmp_update_net_addrs: |
lorcansmith | 0:2a53a4c3238c | 389 | * Description: Updates SNMP address strings from ethernet addresses |
lorcansmith | 0:2a53a4c3238c | 390 | * v1.4: Add trap host address conversion |
lorcansmith | 0:2a53a4c3238c | 391 | * Called by f3k_comms_get_object_def() |
lorcansmith | 0:2a53a4c3238c | 392 | * Parameters: NONE |
lorcansmith | 0:2a53a4c3238c | 393 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 394 | */ |
lorcansmith | 0:2a53a4c3238c | 395 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 396 | void snmp_update_net_addrs( void ) |
lorcansmith | 0:2a53a4c3238c | 397 | { |
lorcansmith | 0:2a53a4c3238c | 398 | char i; |
lorcansmith | 0:2a53a4c3238c | 399 | |
lorcansmith | 0:2a53a4c3238c | 400 | for ( i = 0; i < 16; i++ ) |
lorcansmith | 0:2a53a4c3238c | 401 | { // ensure string terminated by 0 |
lorcansmith | 0:2a53a4c3238c | 402 | snmp_ip_addrs[ i ] = 0; |
lorcansmith | 0:2a53a4c3238c | 403 | snmp_net_mask[ i ] = 0; |
lorcansmith | 0:2a53a4c3238c | 404 | snmp_gwy_addrs[ i ] = 0; |
lorcansmith | 0:2a53a4c3238c | 405 | snmp_dns_addrs[ i ] = 0; |
lorcansmith | 0:2a53a4c3238c | 406 | snmp_trh_addrs[ i ] = 0; |
lorcansmith | 0:2a53a4c3238c | 407 | } |
lorcansmith | 0:2a53a4c3238c | 408 | sprintf( snmp_ip_addrs, "%d.%d.%d.%d", ip_ad[0], ip_ad[1], ip_ad[2], ip_ad[3] ); |
lorcansmith | 0:2a53a4c3238c | 409 | snmp_ip_len = strlen( snmp_ip_addrs ); |
lorcansmith | 0:2a53a4c3238c | 410 | sprintf( snmp_net_mask, "%d.%d.%d.%d", msk_ad[0], msk_ad[1], msk_ad[2], msk_ad[3] ); |
lorcansmith | 0:2a53a4c3238c | 411 | snmp_net_len = strlen( snmp_net_mask ); |
lorcansmith | 0:2a53a4c3238c | 412 | sprintf( snmp_gwy_addrs, "%d.%d.%d.%d", gwy_ad[0], gwy_ad[1], gwy_ad[2], gwy_ad[3] ); |
lorcansmith | 0:2a53a4c3238c | 413 | snmp_gwy_len = strlen( snmp_gwy_addrs ); |
lorcansmith | 0:2a53a4c3238c | 414 | sprintf( snmp_dns_addrs, "%d.%d.%d.%d", dns_ad[0], dns_ad[1], dns_ad[2], dns_ad[3] ); |
lorcansmith | 0:2a53a4c3238c | 415 | snmp_dns_len = strlen( snmp_dns_addrs ); |
lorcansmith | 0:2a53a4c3238c | 416 | sprintf( snmp_trh_addrs, "%d.%d.%d.%d", th_ad[0], th_ad[1], th_ad[2], th_ad[3] ); |
lorcansmith | 0:2a53a4c3238c | 417 | snmp_trh_len = strlen( snmp_trh_addrs ); |
lorcansmith | 0:2a53a4c3238c | 418 | /* for ( i = 0; i < 4; i++ ) |
lorcansmith | 0:2a53a4c3238c | 419 | { // copy IP addresses to string |
lorcansmith | 0:2a53a4c3238c | 420 | snmp_trh_addrs[ i ] = th_ad[ i ]; |
lorcansmith | 0:2a53a4c3238c | 421 | } */ |
lorcansmith | 0:2a53a4c3238c | 422 | } |
lorcansmith | 0:2a53a4c3238c | 423 | |
lorcansmith | 0:2a53a4c3238c | 424 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 425 | /* update_addrs_from_string: |
lorcansmith | 0:2a53a4c3238c | 426 | * Description: Reads data from adrs_str into num_array |
lorcansmith | 0:2a53a4c3238c | 427 | * Globals used: NONE |
lorcansmith | 0:2a53a4c3238c | 428 | * Parameters: IN: char * adrs_str |
lorcansmith | 0:2a53a4c3238c | 429 | * OUT: unsigned char * num_array |
lorcansmith | 0:2a53a4c3238c | 430 | * Returns: Returns set_ok = 1 if able to set value, 0 otherwise |
lorcansmith | 0:2a53a4c3238c | 431 | */ |
lorcansmith | 0:2a53a4c3238c | 432 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 433 | int update_addrs_from_string( char * adrs_str, unsigned char * num_array ) |
lorcansmith | 0:2a53a4c3238c | 434 | { |
lorcansmith | 0:2a53a4c3238c | 435 | unsigned char c, i, j, digit_found, number_completed; |
lorcansmith | 0:2a53a4c3238c | 436 | int set_ok, new_num; |
lorcansmith | 0:2a53a4c3238c | 437 | |
lorcansmith | 0:2a53a4c3238c | 438 | set_ok = 1; // default is good value |
lorcansmith | 0:2a53a4c3238c | 439 | new_num = 0; |
lorcansmith | 0:2a53a4c3238c | 440 | i = j = 0; |
lorcansmith | 0:2a53a4c3238c | 441 | number_completed = digit_found = false; |
lorcansmith | 0:2a53a4c3238c | 442 | while ( ((c = adrs_str[ i ]) != 0) && (i++ < 16) ) |
lorcansmith | 0:2a53a4c3238c | 443 | { |
lorcansmith | 0:2a53a4c3238c | 444 | num_array[ j ] = 0; |
lorcansmith | 0:2a53a4c3238c | 445 | if ( c < '0' || c > '9' ) |
lorcansmith | 0:2a53a4c3238c | 446 | { // not a numeric character |
lorcansmith | 0:2a53a4c3238c | 447 | if ( digit_found ) |
lorcansmith | 0:2a53a4c3238c | 448 | { |
lorcansmith | 0:2a53a4c3238c | 449 | number_completed = true; |
lorcansmith | 0:2a53a4c3238c | 450 | } |
lorcansmith | 0:2a53a4c3238c | 451 | } |
lorcansmith | 0:2a53a4c3238c | 452 | else // numeric character |
lorcansmith | 0:2a53a4c3238c | 453 | { |
lorcansmith | 0:2a53a4c3238c | 454 | digit_found = true; |
lorcansmith | 0:2a53a4c3238c | 455 | if ( number_completed ) |
lorcansmith | 0:2a53a4c3238c | 456 | { // test for valid data |
lorcansmith | 0:2a53a4c3238c | 457 | if ( (new_num <= 255) && (j < 4) ) |
lorcansmith | 0:2a53a4c3238c | 458 | { // save number into array |
lorcansmith | 0:2a53a4c3238c | 459 | num_array[ j++ ] = new_num; |
lorcansmith | 0:2a53a4c3238c | 460 | } |
lorcansmith | 0:2a53a4c3238c | 461 | else |
lorcansmith | 0:2a53a4c3238c | 462 | { |
lorcansmith | 0:2a53a4c3238c | 463 | set_ok = 0; |
lorcansmith | 0:2a53a4c3238c | 464 | break; |
lorcansmith | 0:2a53a4c3238c | 465 | } |
lorcansmith | 0:2a53a4c3238c | 466 | new_num = 0; |
lorcansmith | 0:2a53a4c3238c | 467 | } |
lorcansmith | 0:2a53a4c3238c | 468 | new_num = 10*new_num + c - '0'; |
lorcansmith | 0:2a53a4c3238c | 469 | number_completed = false; |
lorcansmith | 0:2a53a4c3238c | 470 | } // else numeric character |
lorcansmith | 0:2a53a4c3238c | 471 | } // end while |
lorcansmith | 0:2a53a4c3238c | 472 | if ( number_completed || (c == 0) ) |
lorcansmith | 0:2a53a4c3238c | 473 | { // test for valid data |
lorcansmith | 0:2a53a4c3238c | 474 | if ( (new_num <= 255) && (j < 4) && (i <= 16) ) |
lorcansmith | 0:2a53a4c3238c | 475 | { // save last number into array |
lorcansmith | 0:2a53a4c3238c | 476 | num_array[ j ] = new_num; |
lorcansmith | 0:2a53a4c3238c | 477 | } |
lorcansmith | 0:2a53a4c3238c | 478 | else |
lorcansmith | 0:2a53a4c3238c | 479 | { |
lorcansmith | 0:2a53a4c3238c | 480 | set_ok = 0; |
lorcansmith | 0:2a53a4c3238c | 481 | } |
lorcansmith | 0:2a53a4c3238c | 482 | } |
lorcansmith | 0:2a53a4c3238c | 483 | return set_ok; |
lorcansmith | 0:2a53a4c3238c | 484 | } |
lorcansmith | 0:2a53a4c3238c | 485 | |
lorcansmith | 0:2a53a4c3238c | 486 | |
lorcansmith | 0:2a53a4c3238c | 487 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 488 | /* f3k_sys_get_object_def: |
lorcansmith | 0:2a53a4c3238c | 489 | * Description: get definition for F3000 scalar objects |
lorcansmith | 0:2a53a4c3238c | 490 | * Called via mib_scalar_node f3k_sys_scalar |
lorcansmith | 0:2a53a4c3238c | 491 | * Parameters: IN: u8_t ident_len - length of ID in... |
lorcansmith | 0:2a53a4c3238c | 492 | * IN: s32_t *ident - array holding ID |
lorcansmith | 0:2a53a4c3238c | 493 | * OUT: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 494 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 495 | */ |
lorcansmith | 0:2a53a4c3238c | 496 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 497 | static void |
lorcansmith | 0:2a53a4c3238c | 498 | f3k_sys_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) |
lorcansmith | 0:2a53a4c3238c | 499 | { |
lorcansmith | 0:2a53a4c3238c | 500 | u8_t id; |
lorcansmith | 0:2a53a4c3238c | 501 | |
lorcansmith | 0:2a53a4c3238c | 502 | /* return to object name, adding index depth (1) */ |
lorcansmith | 0:2a53a4c3238c | 503 | ident_len += 1; |
lorcansmith | 0:2a53a4c3238c | 504 | ident -= 1; |
lorcansmith | 0:2a53a4c3238c | 505 | LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 7)); |
lorcansmith | 0:2a53a4c3238c | 506 | if ((ident_len == 2) && |
lorcansmith | 2:25e12a7fe0aa | 507 | (ident[0] > 0) && (ident[0] < MAX_PRIVATE_ID)) |
lorcansmith | 0:2a53a4c3238c | 508 | { |
lorcansmith | 0:2a53a4c3238c | 509 | od->id_inst_len = ident_len; |
lorcansmith | 0:2a53a4c3238c | 510 | od->id_inst_ptr = ident; |
lorcansmith | 0:2a53a4c3238c | 511 | |
lorcansmith | 0:2a53a4c3238c | 512 | id = (u8_t)ident[0]; |
lorcansmith | 2:25e12a7fe0aa | 513 | printf("\r\nf3k_sys_get_object_def: ident_len %d, id %d\r\n", ident_len, id); |
lorcansmith | 0:2a53a4c3238c | 514 | switch (id) |
lorcansmith | 0:2a53a4c3238c | 515 | { |
lorcansmith | 0:2a53a4c3238c | 516 | case 1: /* f3k_fw_version */ |
lorcansmith | 0:2a53a4c3238c | 517 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 518 | od->access = MIB_OBJECT_READ_ONLY; |
lorcansmith | 0:2a53a4c3238c | 519 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 520 | od->v_len = 3; |
lorcansmith | 0:2a53a4c3238c | 521 | break; |
lorcansmith | 0:2a53a4c3238c | 522 | case 2: /* snmp_fw_version */ |
lorcansmith | 0:2a53a4c3238c | 523 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 524 | od->access = MIB_OBJECT_READ_ONLY; |
lorcansmith | 0:2a53a4c3238c | 525 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 526 | od->v_len = 4; |
lorcansmith | 0:2a53a4c3238c | 527 | break; |
lorcansmith | 0:2a53a4c3238c | 528 | case 3: /* f3k_error */ |
lorcansmith | 0:2a53a4c3238c | 529 | case 4: /* f3k_num_cards */ |
lorcansmith | 0:2a53a4c3238c | 530 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 531 | od->access = MIB_OBJECT_READ_ONLY; |
lorcansmith | 0:2a53a4c3238c | 532 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); |
lorcansmith | 0:2a53a4c3238c | 533 | od->v_len = sizeof(u32_t); |
lorcansmith | 0:2a53a4c3238c | 534 | break; |
lorcansmith | 0:2a53a4c3238c | 535 | case 5: /* f3k_SPI_count */ |
lorcansmith | 0:2a53a4c3238c | 536 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 537 | od->access = MIB_OBJECT_READ_ONLY; |
lorcansmith | 0:2a53a4c3238c | 538 | od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE); |
lorcansmith | 0:2a53a4c3238c | 539 | od->v_len = sizeof(u32_t); |
lorcansmith | 0:2a53a4c3238c | 540 | break; |
lorcansmith | 0:2a53a4c3238c | 541 | case 6: /* f3k_run_scan */ |
lorcansmith | 0:2a53a4c3238c | 542 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 543 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 544 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); |
lorcansmith | 0:2a53a4c3238c | 545 | od->v_len = sizeof(u32_t); |
lorcansmith | 0:2a53a4c3238c | 546 | break; |
lorcansmith | 0:2a53a4c3238c | 547 | case 7: /* v1.3: f3k_IO_mask */ |
lorcansmith | 0:2a53a4c3238c | 548 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 549 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 550 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 551 | od->v_len = 8; |
lorcansmith | 0:2a53a4c3238c | 552 | break; |
lorcansmith | 0:2a53a4c3238c | 553 | } // end switch |
lorcansmith | 0:2a53a4c3238c | 554 | } |
lorcansmith | 0:2a53a4c3238c | 555 | else |
lorcansmith | 0:2a53a4c3238c | 556 | { |
lorcansmith | 0:2a53a4c3238c | 557 | LWIP_DEBUGF(SNMP_MIB_DEBUG,("f3k_sys_get_object_def: no scalar\n")); |
lorcansmith | 0:2a53a4c3238c | 558 | od->instance = MIB_OBJECT_NONE; |
lorcansmith | 0:2a53a4c3238c | 559 | } |
lorcansmith | 0:2a53a4c3238c | 560 | } |
lorcansmith | 0:2a53a4c3238c | 561 | |
lorcansmith | 0:2a53a4c3238c | 562 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 563 | /* f3k_sys_get_value: |
lorcansmith | 0:2a53a4c3238c | 564 | * Description: Returns f3k scalar object value |
lorcansmith | 0:2a53a4c3238c | 565 | * @param ident points to objectname.0 (object id trailer) |
lorcansmith | 0:2a53a4c3238c | 566 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 567 | * IN: u16_t len - return value space (in bytes) |
lorcansmith | 0:2a53a4c3238c | 568 | * OUT: void *value - points to (varbind) space to copy value into |
lorcansmith | 0:2a53a4c3238c | 569 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 570 | */ |
lorcansmith | 0:2a53a4c3238c | 571 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 572 | static void |
lorcansmith | 0:2a53a4c3238c | 573 | f3k_sys_get_value(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 574 | { |
lorcansmith | 0:2a53a4c3238c | 575 | u32_t *uint_ptr = (u32_t*)value; |
lorcansmith | 0:2a53a4c3238c | 576 | u8_t *uchr_ptr = (u8_t*)value; |
lorcansmith | 0:2a53a4c3238c | 577 | u8_t id; |
lorcansmith | 0:2a53a4c3238c | 578 | u8_t i = 0; // character pointer for copying unterminated strings |
lorcansmith | 0:2a53a4c3238c | 579 | |
lorcansmith | 0:2a53a4c3238c | 580 | LWIP_UNUSED_ARG(len); |
lorcansmith | 0:2a53a4c3238c | 581 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= MAX_PRIVATE_ID)); |
lorcansmith | 0:2a53a4c3238c | 582 | snmp_get_f3k_data(); // read the data from the SPI array |
lorcansmith | 0:2a53a4c3238c | 583 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 2:25e12a7fe0aa | 584 | printf("\r\nf3k_sys_set_test: id %d, len %d\r\n", id, len); |
lorcansmith | 2:25e12a7fe0aa | 585 | switch (id) |
lorcansmith | 0:2a53a4c3238c | 586 | { |
lorcansmith | 0:2a53a4c3238c | 587 | case 1: /* f3k_fw_version */ |
lorcansmith | 0:2a53a4c3238c | 588 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 589 | *(uchr_ptr++) = f3k_fw_version[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 590 | } |
lorcansmith | 0:2a53a4c3238c | 591 | break; |
lorcansmith | 0:2a53a4c3238c | 592 | case 2: /* snmp_fw_version */ |
lorcansmith | 0:2a53a4c3238c | 593 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 594 | *(uchr_ptr++) = snmp_fw_version[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 595 | } |
lorcansmith | 0:2a53a4c3238c | 596 | break; |
lorcansmith | 0:2a53a4c3238c | 597 | case 3: /* f3k_error */ |
lorcansmith | 0:2a53a4c3238c | 598 | *uint_ptr = f3k_error; |
lorcansmith | 0:2a53a4c3238c | 599 | break; |
lorcansmith | 0:2a53a4c3238c | 600 | case 4: /* f3k_num_cards */ |
lorcansmith | 0:2a53a4c3238c | 601 | *uint_ptr = f3k_num_cards; |
lorcansmith | 0:2a53a4c3238c | 602 | break; |
lorcansmith | 0:2a53a4c3238c | 603 | case 5: /* f3k_SPI_count */ |
lorcansmith | 0:2a53a4c3238c | 604 | *uint_ptr = f3k_SPI_count; |
lorcansmith | 0:2a53a4c3238c | 605 | break; |
lorcansmith | 0:2a53a4c3238c | 606 | case 6: /* f3k_run_scan */ |
lorcansmith | 0:2a53a4c3238c | 607 | *uint_ptr = f3k_run_scan; |
lorcansmith | 0:2a53a4c3238c | 608 | break; |
lorcansmith | 0:2a53a4c3238c | 609 | case 7: /* v1.3: f3k_IO_mask */ |
lorcansmith | 0:2a53a4c3238c | 610 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 611 | *(uchr_ptr++) = f3k_IO_mask[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 612 | } |
lorcansmith | 0:2a53a4c3238c | 613 | break; |
lorcansmith | 0:2a53a4c3238c | 614 | } |
lorcansmith | 0:2a53a4c3238c | 615 | } |
lorcansmith | 0:2a53a4c3238c | 616 | |
lorcansmith | 0:2a53a4c3238c | 617 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 618 | /* f3k_sys_set_test: |
lorcansmith | 0:2a53a4c3238c | 619 | * Description: Test f3k_ object value before setting |
lorcansmith | 0:2a53a4c3238c | 620 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 621 | * IN: u16_t len - return value space (in bytes) - NOT USED |
lorcansmith | 0:2a53a4c3238c | 622 | * OUT: void *value - points to (varbind) space to copy value from |
lorcansmith | 0:2a53a4c3238c | 623 | * Returns: Returns set_ok = 1 if able to set value, 0 otherwise |
lorcansmith | 0:2a53a4c3238c | 624 | */ |
lorcansmith | 0:2a53a4c3238c | 625 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 626 | static u8_t |
lorcansmith | 0:2a53a4c3238c | 627 | f3k_sys_set_test(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 628 | { |
lorcansmith | 0:2a53a4c3238c | 629 | u8_t id, set_ok; |
lorcansmith | 0:2a53a4c3238c | 630 | u8_t i = 0; |
lorcansmith | 0:2a53a4c3238c | 631 | u8_t * uc_ptr = (u8_t*)value; // char pointer to first byte in value |
lorcansmith | 0:2a53a4c3238c | 632 | |
lorcansmith | 0:2a53a4c3238c | 633 | LWIP_UNUSED_ARG(len); |
lorcansmith | 0:2a53a4c3238c | 634 | set_ok = 0; |
lorcansmith | 0:2a53a4c3238c | 635 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 7)); |
lorcansmith | 0:2a53a4c3238c | 636 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 2:25e12a7fe0aa | 637 | printf("\r\nf3k_sys_set_test: id %d\r\n", id); |
lorcansmith | 0:2a53a4c3238c | 638 | if ( id == 6 ) |
lorcansmith | 0:2a53a4c3238c | 639 | { /* f3k_run_scan */ |
lorcansmith | 0:2a53a4c3238c | 640 | s32_t *sint_ptr = (s32_t*)value; |
lorcansmith | 0:2a53a4c3238c | 641 | |
lorcansmith | 0:2a53a4c3238c | 642 | if ( (*sint_ptr == 0) || (*sint_ptr == 1) ) |
lorcansmith | 0:2a53a4c3238c | 643 | { |
lorcansmith | 0:2a53a4c3238c | 644 | set_ok = 1; |
lorcansmith | 0:2a53a4c3238c | 645 | } |
lorcansmith | 0:2a53a4c3238c | 646 | } |
lorcansmith | 0:2a53a4c3238c | 647 | else if ( id == 7 ) |
lorcansmith | 0:2a53a4c3238c | 648 | { /* v1.3: f3k_IO_mask */ |
lorcansmith | 0:2a53a4c3238c | 649 | if ( len <= 8 ) |
lorcansmith | 0:2a53a4c3238c | 650 | { // ensure all digits are hexadecimal |
lorcansmith | 0:2a53a4c3238c | 651 | set_ok = 1; |
lorcansmith | 0:2a53a4c3238c | 652 | for ( i = 0; i < len; i++ ) |
lorcansmith | 0:2a53a4c3238c | 653 | { |
lorcansmith | 0:2a53a4c3238c | 654 | if ( !isxdigit( *(uc_ptr++) ) ) |
lorcansmith | 0:2a53a4c3238c | 655 | { |
lorcansmith | 0:2a53a4c3238c | 656 | set_ok = 0; // invalid hexadecimal digit |
lorcansmith | 0:2a53a4c3238c | 657 | break; // so quit |
lorcansmith | 0:2a53a4c3238c | 658 | } |
lorcansmith | 0:2a53a4c3238c | 659 | } |
lorcansmith | 0:2a53a4c3238c | 660 | } |
lorcansmith | 0:2a53a4c3238c | 661 | } |
lorcansmith | 0:2a53a4c3238c | 662 | return set_ok; |
lorcansmith | 0:2a53a4c3238c | 663 | } |
lorcansmith | 0:2a53a4c3238c | 664 | |
lorcansmith | 0:2a53a4c3238c | 665 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 666 | /* f3k_sys_set_value: |
lorcansmith | 0:2a53a4c3238c | 667 | * Description: Returns f3k scalar object value |
lorcansmith | 0:2a53a4c3238c | 668 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 669 | * IN: u16_t len - return value space (in bytes) - NOT USED |
lorcansmith | 0:2a53a4c3238c | 670 | * OUT: void *value - points to (varbind) space to copy value from |
lorcansmith | 0:2a53a4c3238c | 671 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 672 | */ |
lorcansmith | 0:2a53a4c3238c | 673 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 674 | static void |
lorcansmith | 0:2a53a4c3238c | 675 | f3k_sys_set_value(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 676 | { |
lorcansmith | 0:2a53a4c3238c | 677 | u8_t id; |
lorcansmith | 2:25e12a7fe0aa | 678 | u8_t i = 0; |
lorcansmith | 0:2a53a4c3238c | 679 | u8_t * uc_ptr = (u8_t*)value; // char pointer to first byte in value |
lorcansmith | 0:2a53a4c3238c | 680 | |
lorcansmith | 0:2a53a4c3238c | 681 | // LWIP_UNUSED_ARG(len); |
lorcansmith | 0:2a53a4c3238c | 682 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 7)); |
lorcansmith | 0:2a53a4c3238c | 683 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 0:2a53a4c3238c | 684 | if ( id == 6 ) |
lorcansmith | 0:2a53a4c3238c | 685 | { /* f3k_run_scan */ |
lorcansmith | 0:2a53a4c3238c | 686 | cmd_buf[ RUN_SCAN_CMD ] = *uc_ptr; |
lorcansmith | 0:2a53a4c3238c | 687 | cmd_buf[ 0 ] = cmd_buf[ RUN_SCAN_CMD ]; // tell the 3000 cpu data available |
lorcansmith | 0:2a53a4c3238c | 688 | new_cmd_idx = RUN_SCAN_CMD; |
lorcansmith | 0:2a53a4c3238c | 689 | fsvr.put_byte( RUN_SCAN_IDX, cmd_buf[ RUN_SCAN_CMD ] ); |
lorcansmith | 0:2a53a4c3238c | 690 | } |
lorcansmith | 0:2a53a4c3238c | 691 | else if ( id == 7 ) |
lorcansmith | 0:2a53a4c3238c | 692 | { /* v1.3: f3k_IO_mask */ |
lorcansmith | 2:25e12a7fe0aa | 693 | convert2decimal( uc_ptr, len ); |
lorcansmith | 0:2a53a4c3238c | 694 | net_addrs_set = true; // save mask to file system |
lorcansmith | 0:2a53a4c3238c | 695 | } |
lorcansmith | 0:2a53a4c3238c | 696 | } |
lorcansmith | 0:2a53a4c3238c | 697 | |
lorcansmith | 0:2a53a4c3238c | 698 | |
lorcansmith | 0:2a53a4c3238c | 699 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 700 | /* f3k_comms_get_object_def: |
lorcansmith | 0:2a53a4c3238c | 701 | * Description: get definition for F3000 scalar objects |
lorcansmith | 0:2a53a4c3238c | 702 | * Called via mib_scalar_node f3k_comms_scalar |
lorcansmith | 0:2a53a4c3238c | 703 | * Parameters: IN: u8_t ident_len - length of ID in... |
lorcansmith | 0:2a53a4c3238c | 704 | * IN: s32_t *ident - array holding ID |
lorcansmith | 0:2a53a4c3238c | 705 | * OUT: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 706 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 707 | */ |
lorcansmith | 0:2a53a4c3238c | 708 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 709 | static void |
lorcansmith | 0:2a53a4c3238c | 710 | f3k_comms_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) |
lorcansmith | 0:2a53a4c3238c | 711 | { |
lorcansmith | 0:2a53a4c3238c | 712 | u8_t id; |
lorcansmith | 0:2a53a4c3238c | 713 | /* return to object name, adding index depth (1) */ |
lorcansmith | 0:2a53a4c3238c | 714 | ident_len += 1; |
lorcansmith | 0:2a53a4c3238c | 715 | ident -= 1; |
lorcansmith | 0:2a53a4c3238c | 716 | LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); |
lorcansmith | 0:2a53a4c3238c | 717 | if ((ident_len == 2) && |
lorcansmith | 2:25e12a7fe0aa | 718 | (ident[0] > 0) && (ident[0] < MAX_PRIVATE_ID)) |
lorcansmith | 0:2a53a4c3238c | 719 | { |
lorcansmith | 0:2a53a4c3238c | 720 | od->id_inst_len = ident_len; |
lorcansmith | 0:2a53a4c3238c | 721 | od->id_inst_ptr = ident; |
lorcansmith | 0:2a53a4c3238c | 722 | id = (u8_t)ident[0]; |
lorcansmith | 2:25e12a7fe0aa | 723 | printf("\r\nf3k_comms_get_object_def: ident_len %d, id %d\r\n", ident_len, id); |
lorcansmith | 0:2a53a4c3238c | 724 | snmp_update_net_addrs(); |
lorcansmith | 0:2a53a4c3238c | 725 | switch (id) |
lorcansmith | 0:2a53a4c3238c | 726 | { |
lorcansmith | 0:2a53a4c3238c | 727 | case 1: /* RTU unit ID */ |
lorcansmith | 0:2a53a4c3238c | 728 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 729 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 730 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); |
lorcansmith | 0:2a53a4c3238c | 731 | od->v_len = sizeof(u16_t); // v1.2: changed from u32_t |
lorcansmith | 0:2a53a4c3238c | 732 | break; |
lorcansmith | 0:2a53a4c3238c | 733 | case 2: /* RTU baud rate */ |
lorcansmith | 0:2a53a4c3238c | 734 | case 3: /* RTU protocol */ |
lorcansmith | 0:2a53a4c3238c | 735 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 736 | od->access = MIB_OBJECT_READ_ONLY; |
lorcansmith | 0:2a53a4c3238c | 737 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG); |
lorcansmith | 0:2a53a4c3238c | 738 | od->v_len = sizeof(u16_t); // v1.2: changed from u32_t |
lorcansmith | 0:2a53a4c3238c | 739 | break; |
lorcansmith | 0:2a53a4c3238c | 740 | case 4: /* IP address */ |
lorcansmith | 0:2a53a4c3238c | 741 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 742 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 743 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 744 | od->v_len = snmp_ip_len; |
lorcansmith | 0:2a53a4c3238c | 745 | break; |
lorcansmith | 0:2a53a4c3238c | 746 | case 5: /* net mask */ |
lorcansmith | 0:2a53a4c3238c | 747 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 748 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 749 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 750 | od->v_len = snmp_net_len; |
lorcansmith | 0:2a53a4c3238c | 751 | break; |
lorcansmith | 0:2a53a4c3238c | 752 | case 6: /* Gateway address */ |
lorcansmith | 0:2a53a4c3238c | 753 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 754 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 755 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 756 | od->v_len = snmp_gwy_len; |
lorcansmith | 0:2a53a4c3238c | 757 | break; |
lorcansmith | 0:2a53a4c3238c | 758 | case 7: /* DNS address */ |
lorcansmith | 0:2a53a4c3238c | 759 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 760 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 0:2a53a4c3238c | 761 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 762 | od->v_len = snmp_dns_len; |
lorcansmith | 0:2a53a4c3238c | 763 | break; |
lorcansmith | 0:2a53a4c3238c | 764 | case 8: /* v1.4: Trap host address */ |
lorcansmith | 0:2a53a4c3238c | 765 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 766 | od->access = MIB_OBJECT_READ_WRITE; |
lorcansmith | 2:25e12a7fe0aa | 767 | // od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR); |
lorcansmith | 2:25e12a7fe0aa | 768 | // od->v_len = 4; |
lorcansmith | 0:2a53a4c3238c | 769 | od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR); |
lorcansmith | 0:2a53a4c3238c | 770 | od->v_len = snmp_trh_len; |
lorcansmith | 0:2a53a4c3238c | 771 | break; |
lorcansmith | 2:25e12a7fe0aa | 772 | } // end switch |
lorcansmith | 0:2a53a4c3238c | 773 | } |
lorcansmith | 0:2a53a4c3238c | 774 | else |
lorcansmith | 0:2a53a4c3238c | 775 | { |
lorcansmith | 0:2a53a4c3238c | 776 | LWIP_DEBUGF(SNMP_MIB_DEBUG,("f3k_comms_get_object_def: no scalar\n")); |
lorcansmith | 0:2a53a4c3238c | 777 | od->instance = MIB_OBJECT_NONE; |
lorcansmith | 0:2a53a4c3238c | 778 | } |
lorcansmith | 0:2a53a4c3238c | 779 | } |
lorcansmith | 0:2a53a4c3238c | 780 | |
lorcansmith | 0:2a53a4c3238c | 781 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 782 | /* f3k_comms_get_value: |
lorcansmith | 0:2a53a4c3238c | 783 | * Description: Returns f3k scalar object value |
lorcansmith | 0:2a53a4c3238c | 784 | * @param ident points to objectname.0 (object id trailer) |
lorcansmith | 0:2a53a4c3238c | 785 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 786 | * IN: u16_t len - return value space (in bytes) |
lorcansmith | 0:2a53a4c3238c | 787 | * OUT: void *value - points to (varbind) space to copy value into |
lorcansmith | 0:2a53a4c3238c | 788 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 789 | */ |
lorcansmith | 0:2a53a4c3238c | 790 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 791 | static void |
lorcansmith | 0:2a53a4c3238c | 792 | f3k_comms_get_value(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 793 | { |
lorcansmith | 0:2a53a4c3238c | 794 | u32_t *uint_ptr = (u32_t*)value; |
lorcansmith | 0:2a53a4c3238c | 795 | u8_t * uchr_ptr = (u8_t*)value; |
lorcansmith | 0:2a53a4c3238c | 796 | u8_t id; |
lorcansmith | 0:2a53a4c3238c | 797 | u8_t i = 0; |
lorcansmith | 0:2a53a4c3238c | 798 | |
lorcansmith | 2:25e12a7fe0aa | 799 | // LWIP_UNUSED_ARG(len); |
lorcansmith | 2:25e12a7fe0aa | 800 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= MAX_PRIVATE_ID)); |
lorcansmith | 0:2a53a4c3238c | 801 | snmp_get_f3k_data(); // read the data from the SPI array |
lorcansmith | 0:2a53a4c3238c | 802 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 0:2a53a4c3238c | 803 | switch (id) |
lorcansmith | 0:2a53a4c3238c | 804 | { |
lorcansmith | 0:2a53a4c3238c | 805 | case 1: /* RTU unit ID */ |
lorcansmith | 0:2a53a4c3238c | 806 | *uint_ptr = f3k_uid; |
lorcansmith | 0:2a53a4c3238c | 807 | break; |
lorcansmith | 0:2a53a4c3238c | 808 | case 2: /* RTU baud rate */ |
lorcansmith | 0:2a53a4c3238c | 809 | *uint_ptr = f3k_speed; |
lorcansmith | 0:2a53a4c3238c | 810 | break; |
lorcansmith | 0:2a53a4c3238c | 811 | case 3: /* RTU protocol */ |
lorcansmith | 0:2a53a4c3238c | 812 | *uint_ptr = f3k_protocol; |
lorcansmith | 0:2a53a4c3238c | 813 | break; |
lorcansmith | 0:2a53a4c3238c | 814 | case 4: /* IP address */ |
lorcansmith | 0:2a53a4c3238c | 815 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 816 | *(uchr_ptr++) = snmp_ip_addrs[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 817 | } |
lorcansmith | 0:2a53a4c3238c | 818 | break; |
lorcansmith | 0:2a53a4c3238c | 819 | case 5: /* net mask */ |
lorcansmith | 0:2a53a4c3238c | 820 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 821 | *(uchr_ptr++) = snmp_net_mask[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 822 | } |
lorcansmith | 0:2a53a4c3238c | 823 | break; |
lorcansmith | 0:2a53a4c3238c | 824 | case 6: /* Gateway address */ |
lorcansmith | 0:2a53a4c3238c | 825 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 826 | *(uchr_ptr++) = snmp_gwy_addrs[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 827 | } |
lorcansmith | 0:2a53a4c3238c | 828 | break; |
lorcansmith | 0:2a53a4c3238c | 829 | case 7: /* DNS address */ |
lorcansmith | 0:2a53a4c3238c | 830 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 831 | *(uchr_ptr++) = snmp_dns_addrs[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 832 | } |
lorcansmith | 0:2a53a4c3238c | 833 | break; |
lorcansmith | 0:2a53a4c3238c | 834 | case 8: /* v1.4: Trap host address */ |
lorcansmith | 0:2a53a4c3238c | 835 | while (i < len) { |
lorcansmith | 0:2a53a4c3238c | 836 | *(uchr_ptr++) = snmp_trh_addrs[ i++ ]; |
lorcansmith | 0:2a53a4c3238c | 837 | } |
lorcansmith | 0:2a53a4c3238c | 838 | break; |
lorcansmith | 0:2a53a4c3238c | 839 | } |
lorcansmith | 0:2a53a4c3238c | 840 | } |
lorcansmith | 0:2a53a4c3238c | 841 | |
lorcansmith | 0:2a53a4c3238c | 842 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 843 | /* f3k_comms_set_test: |
lorcansmith | 0:2a53a4c3238c | 844 | * Description: Test f3k_comms object value before setting |
lorcansmith | 0:2a53a4c3238c | 845 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 846 | * IN: u16_t len - return value space (in bytes) - NOT USED |
lorcansmith | 0:2a53a4c3238c | 847 | * OUT: void *value - points to (varbind) space to copy value from |
lorcansmith | 0:2a53a4c3238c | 848 | * Returns: Returns set_ok = 1 if able to set value, 0 otherwise |
lorcansmith | 0:2a53a4c3238c | 849 | */ |
lorcansmith | 0:2a53a4c3238c | 850 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 851 | static u8_t |
lorcansmith | 0:2a53a4c3238c | 852 | f3k_comms_set_test(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 853 | { |
lorcansmith | 0:2a53a4c3238c | 854 | u8_t id, set_ok, i; |
lorcansmith | 0:2a53a4c3238c | 855 | u8_t * uc_ptr; |
lorcansmith | 0:2a53a4c3238c | 856 | char test_addrs[16]; |
lorcansmith | 0:2a53a4c3238c | 857 | unsigned char test_ad[4]; |
lorcansmith | 0:2a53a4c3238c | 858 | |
lorcansmith | 0:2a53a4c3238c | 859 | set_ok = i = 0; |
lorcansmith | 2:25e12a7fe0aa | 860 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= MAX_PRIVATE_ID)); |
lorcansmith | 0:2a53a4c3238c | 861 | uc_ptr = (u8_t*)value; // char pointer to first byte in value |
lorcansmith | 0:2a53a4c3238c | 862 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 2:25e12a7fe0aa | 863 | printf("\r\nf3k_comms_set_test: id %d, len %d\r\n", id, len); |
lorcansmith | 0:2a53a4c3238c | 864 | switch ( id ) |
lorcansmith | 0:2a53a4c3238c | 865 | { |
lorcansmith | 0:2a53a4c3238c | 866 | case 1: /* RTU unit ID */ |
lorcansmith | 2:25e12a7fe0aa | 867 | u16_t *uint_ptr = (u16_t*)value; // v1.2: changed from s32_t |
lorcansmith | 0:2a53a4c3238c | 868 | if ( *uint_ptr < 255 ) |
lorcansmith | 0:2a53a4c3238c | 869 | { |
lorcansmith | 0:2a53a4c3238c | 870 | set_ok = 1; |
lorcansmith | 0:2a53a4c3238c | 871 | } |
lorcansmith | 2:25e12a7fe0aa | 872 | //printf("f3k_comms_set_test: value u16 %d, u8 %d, set_ok %d\r\n", *uint_ptr, *uc_ptr, set_ok); |
lorcansmith | 0:2a53a4c3238c | 873 | break; |
lorcansmith | 0:2a53a4c3238c | 874 | case 4: /* IP address */ |
lorcansmith | 0:2a53a4c3238c | 875 | case 5: /* net mask */ |
lorcansmith | 0:2a53a4c3238c | 876 | case 6: /* Gateway address */ |
lorcansmith | 0:2a53a4c3238c | 877 | case 7: /* DNS address */ |
lorcansmith | 0:2a53a4c3238c | 878 | case 8: /* v1.4: Trap host address */ |
lorcansmith | 0:2a53a4c3238c | 879 | if ( len <= 16 ) |
lorcansmith | 0:2a53a4c3238c | 880 | { |
lorcansmith | 0:2a53a4c3238c | 881 | while ( i < 16 ) |
lorcansmith | 0:2a53a4c3238c | 882 | { |
lorcansmith | 0:2a53a4c3238c | 883 | test_addrs[ i++ ] = i < len ? *(uc_ptr++) : 0; |
lorcansmith | 0:2a53a4c3238c | 884 | } |
lorcansmith | 0:2a53a4c3238c | 885 | set_ok = update_addrs_from_string( test_addrs, test_ad ); |
lorcansmith | 0:2a53a4c3238c | 886 | } |
lorcansmith | 0:2a53a4c3238c | 887 | break; |
lorcansmith | 0:2a53a4c3238c | 888 | } // end switch |
lorcansmith | 0:2a53a4c3238c | 889 | return set_ok; |
lorcansmith | 0:2a53a4c3238c | 890 | } |
lorcansmith | 0:2a53a4c3238c | 891 | |
lorcansmith | 0:2a53a4c3238c | 892 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 893 | /* f3k_comms_set_value: |
lorcansmith | 0:2a53a4c3238c | 894 | * Description: Returns f3k scalar object value |
lorcansmith | 0:2a53a4c3238c | 895 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 896 | * IN: u16_t len - return value space (in bytes) - NOT USED |
lorcansmith | 0:2a53a4c3238c | 897 | * OUT: void *value - points to (varbind) space to copy value from |
lorcansmith | 0:2a53a4c3238c | 898 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 899 | */ |
lorcansmith | 0:2a53a4c3238c | 900 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 901 | static void |
lorcansmith | 0:2a53a4c3238c | 902 | f3k_comms_set_value(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 903 | { |
lorcansmith | 0:2a53a4c3238c | 904 | u8_t id, i; |
lorcansmith | 0:2a53a4c3238c | 905 | u8_t * uc_ptr; |
lorcansmith | 0:2a53a4c3238c | 906 | |
lorcansmith | 0:2a53a4c3238c | 907 | i = 0; |
lorcansmith | 2:25e12a7fe0aa | 908 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= MAX_PRIVATE_ID)); |
lorcansmith | 0:2a53a4c3238c | 909 | uc_ptr = (u8_t*)value; // char pointer to first byte in value |
lorcansmith | 0:2a53a4c3238c | 910 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 0:2a53a4c3238c | 911 | switch (id) |
lorcansmith | 0:2a53a4c3238c | 912 | { |
lorcansmith | 0:2a53a4c3238c | 913 | case 1: /* RTU unit ID */ |
lorcansmith | 0:2a53a4c3238c | 914 | cmd_buf[ UNIT_ID_CMD ] = *uc_ptr; |
lorcansmith | 0:2a53a4c3238c | 915 | cmd_buf[ 0 ] = cmd_buf[ UNIT_ID_CMD ]; // tell the 3000 cpu data available |
lorcansmith | 0:2a53a4c3238c | 916 | new_cmd_idx = UNIT_ID_CMD; |
lorcansmith | 0:2a53a4c3238c | 917 | fsvr.put_byte( UNIT_ID_IDX, cmd_buf[ UNIT_ID_CMD ] ); |
lorcansmith | 0:2a53a4c3238c | 918 | break; |
lorcansmith | 0:2a53a4c3238c | 919 | case 4: /* IP address */ |
lorcansmith | 0:2a53a4c3238c | 920 | while ( i < 16 ) { |
lorcansmith | 0:2a53a4c3238c | 921 | snmp_ip_addrs[ i++ ] = ( i < len ) ? *(uc_ptr++) : 0; |
lorcansmith | 0:2a53a4c3238c | 922 | } |
lorcansmith | 0:2a53a4c3238c | 923 | update_addrs_from_string( snmp_ip_addrs, ip_ad ); |
lorcansmith | 0:2a53a4c3238c | 924 | net_addrs_set = true; |
lorcansmith | 0:2a53a4c3238c | 925 | break; |
lorcansmith | 0:2a53a4c3238c | 926 | case 5: /* net mask */ |
lorcansmith | 0:2a53a4c3238c | 927 | while ( i < 16 ) { |
lorcansmith | 0:2a53a4c3238c | 928 | snmp_net_mask[ i++ ] = ( i < len ) ? *(uc_ptr++) : 0; |
lorcansmith | 0:2a53a4c3238c | 929 | } |
lorcansmith | 0:2a53a4c3238c | 930 | update_addrs_from_string( snmp_net_mask, msk_ad ); |
lorcansmith | 0:2a53a4c3238c | 931 | net_addrs_set = true; |
lorcansmith | 0:2a53a4c3238c | 932 | break; |
lorcansmith | 0:2a53a4c3238c | 933 | case 6: /* Gateway address */ |
lorcansmith | 0:2a53a4c3238c | 934 | while ( i < 16 ) { |
lorcansmith | 0:2a53a4c3238c | 935 | snmp_gwy_addrs[ i++ ] = ( i < len ) ? *(uc_ptr++) : 0; |
lorcansmith | 0:2a53a4c3238c | 936 | } |
lorcansmith | 0:2a53a4c3238c | 937 | update_addrs_from_string( snmp_gwy_addrs, gwy_ad ); |
lorcansmith | 0:2a53a4c3238c | 938 | net_addrs_set = true; |
lorcansmith | 0:2a53a4c3238c | 939 | break; |
lorcansmith | 0:2a53a4c3238c | 940 | case 7: /* DNS address */ |
lorcansmith | 0:2a53a4c3238c | 941 | while ( i < 16 ) { |
lorcansmith | 0:2a53a4c3238c | 942 | snmp_dns_addrs[ i++ ] = ( i < len ) ? *(uc_ptr++) : 0; |
lorcansmith | 0:2a53a4c3238c | 943 | } |
lorcansmith | 0:2a53a4c3238c | 944 | update_addrs_from_string( snmp_dns_addrs, dns_ad ); |
lorcansmith | 0:2a53a4c3238c | 945 | net_addrs_set = true; |
lorcansmith | 0:2a53a4c3238c | 946 | break; |
lorcansmith | 0:2a53a4c3238c | 947 | case 8: /* v1.4: Trap host address */ |
lorcansmith | 0:2a53a4c3238c | 948 | while ( i < 16 ) { |
lorcansmith | 0:2a53a4c3238c | 949 | snmp_trh_addrs[ i++ ] = ( i < len ) ? *(uc_ptr++) : 0; |
lorcansmith | 0:2a53a4c3238c | 950 | } |
lorcansmith | 0:2a53a4c3238c | 951 | update_addrs_from_string( snmp_trh_addrs, th_ad ); |
lorcansmith | 0:2a53a4c3238c | 952 | net_addrs_set = true; |
lorcansmith | 0:2a53a4c3238c | 953 | break; |
lorcansmith | 0:2a53a4c3238c | 954 | } |
lorcansmith | 0:2a53a4c3238c | 955 | } |
lorcansmith | 0:2a53a4c3238c | 956 | |
lorcansmith | 0:2a53a4c3238c | 957 | |
lorcansmith | 0:2a53a4c3238c | 958 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 959 | /* f3k_IO_get_object_def: |
lorcansmith | 0:2a53a4c3238c | 960 | * Description: get definition for F3000 scalar objects |
lorcansmith | 0:2a53a4c3238c | 961 | * Called via mib_scalar_node f3k_IO_scalar |
lorcansmith | 0:2a53a4c3238c | 962 | * Parameters: IN: u8_t ident_len - length of ID in... |
lorcansmith | 0:2a53a4c3238c | 963 | * IN: s32_t *ident - array holding ID |
lorcansmith | 0:2a53a4c3238c | 964 | * OUT: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 965 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 966 | */ |
lorcansmith | 0:2a53a4c3238c | 967 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 968 | static void |
lorcansmith | 0:2a53a4c3238c | 969 | f3k_IO_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) |
lorcansmith | 0:2a53a4c3238c | 970 | { |
lorcansmith | 0:2a53a4c3238c | 971 | u8_t id; |
lorcansmith | 0:2a53a4c3238c | 972 | |
lorcansmith | 0:2a53a4c3238c | 973 | /* return to object name, adding index depth (1) */ |
lorcansmith | 0:2a53a4c3238c | 974 | ident_len += 1; |
lorcansmith | 0:2a53a4c3238c | 975 | ident -= 1; |
lorcansmith | 0:2a53a4c3238c | 976 | LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff)); |
lorcansmith | 0:2a53a4c3238c | 977 | if ((ident_len == 2) && |
lorcansmith | 0:2a53a4c3238c | 978 | (ident[0] > 0) && (ident[0] <= MAX_IO_TABLE)) |
lorcansmith | 0:2a53a4c3238c | 979 | { |
lorcansmith | 0:2a53a4c3238c | 980 | od->id_inst_len = ident_len; |
lorcansmith | 0:2a53a4c3238c | 981 | od->id_inst_ptr = ident; |
lorcansmith | 0:2a53a4c3238c | 982 | |
lorcansmith | 0:2a53a4c3238c | 983 | id = (u8_t)ident[0]; |
lorcansmith | 0:2a53a4c3238c | 984 | printf("\r\nf3k_IO_get_object_def: ident_len %d, id %d\r\n", ident_len, id); |
lorcansmith | 0:2a53a4c3238c | 985 | |
lorcansmith | 0:2a53a4c3238c | 986 | od->instance = MIB_OBJECT_SCALAR; |
lorcansmith | 0:2a53a4c3238c | 987 | od->access = MIB_OBJECT_READ_ONLY; |
lorcansmith | 0:2a53a4c3238c | 988 | od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE); |
lorcansmith | 0:2a53a4c3238c | 989 | od->v_len = sizeof(u32_t); |
lorcansmith | 0:2a53a4c3238c | 990 | } |
lorcansmith | 0:2a53a4c3238c | 991 | else |
lorcansmith | 0:2a53a4c3238c | 992 | { |
lorcansmith | 0:2a53a4c3238c | 993 | LWIP_DEBUGF(SNMP_MIB_DEBUG,("f3k_IO_get_object_def: no scalar\n")); |
lorcansmith | 0:2a53a4c3238c | 994 | od->instance = MIB_OBJECT_NONE; |
lorcansmith | 0:2a53a4c3238c | 995 | } |
lorcansmith | 0:2a53a4c3238c | 996 | } |
lorcansmith | 0:2a53a4c3238c | 997 | |
lorcansmith | 0:2a53a4c3238c | 998 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 999 | /* f3k_IO_get_value: |
lorcansmith | 0:2a53a4c3238c | 1000 | * Description: Returns f3k scalar object value |
lorcansmith | 0:2a53a4c3238c | 1001 | * @param ident points to objectname.0 (object id trailer) |
lorcansmith | 0:2a53a4c3238c | 1002 | * Parameters: IN: struct obj_def *od - object definition found |
lorcansmith | 0:2a53a4c3238c | 1003 | * IN: u16_t len - return value space (in bytes) |
lorcansmith | 0:2a53a4c3238c | 1004 | * OUT: void *value - points to (varbind) space to copy value into |
lorcansmith | 0:2a53a4c3238c | 1005 | * Returns: NONE |
lorcansmith | 0:2a53a4c3238c | 1006 | */ |
lorcansmith | 0:2a53a4c3238c | 1007 | /****************************************************************************/ |
lorcansmith | 0:2a53a4c3238c | 1008 | static void |
lorcansmith | 0:2a53a4c3238c | 1009 | f3k_IO_get_value(struct obj_def *od, u16_t len, void *value) |
lorcansmith | 0:2a53a4c3238c | 1010 | { |
lorcansmith | 0:2a53a4c3238c | 1011 | u32_t *uint_ptr = (u32_t*)value; |
lorcansmith | 0:2a53a4c3238c | 1012 | u8_t id; |
lorcansmith | 0:2a53a4c3238c | 1013 | |
lorcansmith | 0:2a53a4c3238c | 1014 | LWIP_UNUSED_ARG(len); |
lorcansmith | 0:2a53a4c3238c | 1015 | LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff)); |
lorcansmith | 0:2a53a4c3238c | 1016 | id = (u8_t)od->id_inst_ptr[0]; |
lorcansmith | 0:2a53a4c3238c | 1017 | *uint_ptr = snmp_get_f3k_IO_value( id ); |
lorcansmith | 0:2a53a4c3238c | 1018 | } |
lorcansmith | 0:2a53a4c3238c | 1019 | |
lorcansmith | 0:2a53a4c3238c | 1020 | |
lorcansmith | 0:2a53a4c3238c | 1021 | #endif /* LWIP_SNMP */ |