wip

Dependents:   EthernetInterface_vz

Fork of lwip by VZTECH

Committer:
mbed_official
Date:
Fri Jun 22 09:25:39 2012 +0000
Revision:
0:51ac1d130fd4
Initial import from lwip-1.4.0: http://download.savannah.gnu.org/releases/lwip/lwip-1.4.0.zip

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:51ac1d130fd4 1 /**
mbed_official 0:51ac1d130fd4 2 * @file
mbed_official 0:51ac1d130fd4 3 * Management Information Base II (RFC1213) objects and functions.
mbed_official 0:51ac1d130fd4 4 *
mbed_official 0:51ac1d130fd4 5 * @note the object identifiers for this MIB-2 and private MIB tree
mbed_official 0:51ac1d130fd4 6 * must be kept in sorted ascending order. This to ensure correct getnext operation.
mbed_official 0:51ac1d130fd4 7 */
mbed_official 0:51ac1d130fd4 8
mbed_official 0:51ac1d130fd4 9 /*
mbed_official 0:51ac1d130fd4 10 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
mbed_official 0:51ac1d130fd4 11 * All rights reserved.
mbed_official 0:51ac1d130fd4 12 *
mbed_official 0:51ac1d130fd4 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 0:51ac1d130fd4 14 * are permitted provided that the following conditions are met:
mbed_official 0:51ac1d130fd4 15 *
mbed_official 0:51ac1d130fd4 16 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 0:51ac1d130fd4 17 * this list of conditions and the following disclaimer.
mbed_official 0:51ac1d130fd4 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 0:51ac1d130fd4 19 * this list of conditions and the following disclaimer in the documentation
mbed_official 0:51ac1d130fd4 20 * and/or other materials provided with the distribution.
mbed_official 0:51ac1d130fd4 21 * 3. The name of the author may not be used to endorse or promote products
mbed_official 0:51ac1d130fd4 22 * derived from this software without specific prior written permission.
mbed_official 0:51ac1d130fd4 23 *
mbed_official 0:51ac1d130fd4 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
mbed_official 0:51ac1d130fd4 25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
mbed_official 0:51ac1d130fd4 26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
mbed_official 0:51ac1d130fd4 27 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
mbed_official 0:51ac1d130fd4 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
mbed_official 0:51ac1d130fd4 29 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
mbed_official 0:51ac1d130fd4 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
mbed_official 0:51ac1d130fd4 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
mbed_official 0:51ac1d130fd4 32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
mbed_official 0:51ac1d130fd4 33 * OF SUCH DAMAGE.
mbed_official 0:51ac1d130fd4 34 *
mbed_official 0:51ac1d130fd4 35 * Author: Christiaan Simons <christiaan.simons@axon.tv>
mbed_official 0:51ac1d130fd4 36 */
mbed_official 0:51ac1d130fd4 37
mbed_official 0:51ac1d130fd4 38 #include "lwip/opt.h"
mbed_official 0:51ac1d130fd4 39
mbed_official 0:51ac1d130fd4 40 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
mbed_official 0:51ac1d130fd4 41
mbed_official 0:51ac1d130fd4 42 #include "lwip/snmp.h"
mbed_official 0:51ac1d130fd4 43 #include "lwip/netif.h"
mbed_official 0:51ac1d130fd4 44 #include "lwip/ip.h"
mbed_official 0:51ac1d130fd4 45 #include "lwip/ip_frag.h"
mbed_official 0:51ac1d130fd4 46 #include "lwip/mem.h"
mbed_official 0:51ac1d130fd4 47 #include "lwip/tcp_impl.h"
mbed_official 0:51ac1d130fd4 48 #include "lwip/udp.h"
mbed_official 0:51ac1d130fd4 49 #include "lwip/snmp_asn1.h"
mbed_official 0:51ac1d130fd4 50 #include "lwip/snmp_structs.h"
mbed_official 0:51ac1d130fd4 51 #include "lwip/sys.h"
mbed_official 0:51ac1d130fd4 52 #include "netif/etharp.h"
mbed_official 0:51ac1d130fd4 53
mbed_official 0:51ac1d130fd4 54 /**
mbed_official 0:51ac1d130fd4 55 * IANA assigned enterprise ID for lwIP is 26381
mbed_official 0:51ac1d130fd4 56 * @see http://www.iana.org/assignments/enterprise-numbers
mbed_official 0:51ac1d130fd4 57 *
mbed_official 0:51ac1d130fd4 58 * @note this enterprise ID is assigned to the lwIP project,
mbed_official 0:51ac1d130fd4 59 * all object identifiers living under this ID are assigned
mbed_official 0:51ac1d130fd4 60 * by the lwIP maintainers (contact Christiaan Simons)!
mbed_official 0:51ac1d130fd4 61 * @note don't change this define, use snmp_set_sysobjid()
mbed_official 0:51ac1d130fd4 62 *
mbed_official 0:51ac1d130fd4 63 * If you need to create your own private MIB you'll need
mbed_official 0:51ac1d130fd4 64 * to apply for your own enterprise ID with IANA:
mbed_official 0:51ac1d130fd4 65 * http://www.iana.org/numbers.html
mbed_official 0:51ac1d130fd4 66 */
mbed_official 0:51ac1d130fd4 67 #define SNMP_ENTERPRISE_ID 26381
mbed_official 0:51ac1d130fd4 68 #define SNMP_SYSOBJID_LEN 7
mbed_official 0:51ac1d130fd4 69 #define SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, SNMP_ENTERPRISE_ID}
mbed_official 0:51ac1d130fd4 70
mbed_official 0:51ac1d130fd4 71 #ifndef SNMP_SYSSERVICES
mbed_official 0:51ac1d130fd4 72 #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
mbed_official 0:51ac1d130fd4 73 #endif
mbed_official 0:51ac1d130fd4 74
mbed_official 0:51ac1d130fd4 75 #ifndef SNMP_GET_SYSUPTIME
mbed_official 0:51ac1d130fd4 76 #define SNMP_GET_SYSUPTIME(sysuptime)
mbed_official 0:51ac1d130fd4 77 #endif
mbed_official 0:51ac1d130fd4 78
mbed_official 0:51ac1d130fd4 79 static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 80 static void system_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 81 static u8_t system_set_test(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 82 static void system_set_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 83 static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 84 static void interfaces_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 85 static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 86 static void ifentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 87 #if !SNMP_SAFE_REQUESTS
mbed_official 0:51ac1d130fd4 88 static u8_t ifentry_set_test (struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 89 static void ifentry_set_value (struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 90 #endif /* SNMP_SAFE_REQUESTS */
mbed_official 0:51ac1d130fd4 91 static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 92 static void atentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 93 static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 94 static void ip_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 95 static u8_t ip_set_test(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 96 static void ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 97 static void ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 98 static void ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 99 static void ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 100 static void ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 101 static void ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 102 static void icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 103 static void icmp_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 104 #if LWIP_TCP
mbed_official 0:51ac1d130fd4 105 static void tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 106 static void tcp_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 107 #ifdef THIS_SEEMS_UNUSED
mbed_official 0:51ac1d130fd4 108 static void tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 109 static void tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 110 #endif
mbed_official 0:51ac1d130fd4 111 #endif
mbed_official 0:51ac1d130fd4 112 static void udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 113 static void udp_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 114 static void udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 115 static void udpentry_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 116 static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
mbed_official 0:51ac1d130fd4 117 static void snmp_get_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 118 static u8_t snmp_set_test(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 119 static void snmp_set_value(struct obj_def *od, u16_t len, void *value);
mbed_official 0:51ac1d130fd4 120
mbed_official 0:51ac1d130fd4 121
mbed_official 0:51ac1d130fd4 122 /* snmp .1.3.6.1.2.1.11 */
mbed_official 0:51ac1d130fd4 123 const mib_scalar_node snmp_scalar = {
mbed_official 0:51ac1d130fd4 124 &snmp_get_object_def,
mbed_official 0:51ac1d130fd4 125 &snmp_get_value,
mbed_official 0:51ac1d130fd4 126 &snmp_set_test,
mbed_official 0:51ac1d130fd4 127 &snmp_set_value,
mbed_official 0:51ac1d130fd4 128 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 129 0
mbed_official 0:51ac1d130fd4 130 };
mbed_official 0:51ac1d130fd4 131 const s32_t snmp_ids[28] = {
mbed_official 0:51ac1d130fd4 132 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
mbed_official 0:51ac1d130fd4 133 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30
mbed_official 0:51ac1d130fd4 134 };
mbed_official 0:51ac1d130fd4 135 struct mib_node* const snmp_nodes[28] = {
mbed_official 0:51ac1d130fd4 136 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 137 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 138 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 139 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 140 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 141 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 142 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 143 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 144 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 145 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 146 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 147 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 148 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
mbed_official 0:51ac1d130fd4 149 (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar
mbed_official 0:51ac1d130fd4 150 };
mbed_official 0:51ac1d130fd4 151 const struct mib_array_node snmp = {
mbed_official 0:51ac1d130fd4 152 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 153 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 154 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 155 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 156 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 157 28,
mbed_official 0:51ac1d130fd4 158 snmp_ids,
mbed_official 0:51ac1d130fd4 159 snmp_nodes
mbed_official 0:51ac1d130fd4 160 };
mbed_official 0:51ac1d130fd4 161
mbed_official 0:51ac1d130fd4 162 /* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */
mbed_official 0:51ac1d130fd4 163 /* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */
mbed_official 0:51ac1d130fd4 164 /* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
mbed_official 0:51ac1d130fd4 165
mbed_official 0:51ac1d130fd4 166 /* udp .1.3.6.1.2.1.7 */
mbed_official 0:51ac1d130fd4 167 /** index root node for udpTable */
mbed_official 0:51ac1d130fd4 168 struct mib_list_rootnode udp_root = {
mbed_official 0:51ac1d130fd4 169 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 170 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 171 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 172 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 173 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 174 0,
mbed_official 0:51ac1d130fd4 175 NULL,
mbed_official 0:51ac1d130fd4 176 NULL,
mbed_official 0:51ac1d130fd4 177 0
mbed_official 0:51ac1d130fd4 178 };
mbed_official 0:51ac1d130fd4 179 const s32_t udpentry_ids[2] = { 1, 2 };
mbed_official 0:51ac1d130fd4 180 struct mib_node* const udpentry_nodes[2] = {
mbed_official 0:51ac1d130fd4 181 (struct mib_node*)&udp_root, (struct mib_node*)&udp_root,
mbed_official 0:51ac1d130fd4 182 };
mbed_official 0:51ac1d130fd4 183 const struct mib_array_node udpentry = {
mbed_official 0:51ac1d130fd4 184 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 185 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 186 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 187 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 188 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 189 2,
mbed_official 0:51ac1d130fd4 190 udpentry_ids,
mbed_official 0:51ac1d130fd4 191 udpentry_nodes
mbed_official 0:51ac1d130fd4 192 };
mbed_official 0:51ac1d130fd4 193
mbed_official 0:51ac1d130fd4 194 s32_t udptable_id = 1;
mbed_official 0:51ac1d130fd4 195 struct mib_node* udptable_node = (struct mib_node*)&udpentry;
mbed_official 0:51ac1d130fd4 196 struct mib_ram_array_node udptable = {
mbed_official 0:51ac1d130fd4 197 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 198 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 199 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 200 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 201 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 202 0,
mbed_official 0:51ac1d130fd4 203 &udptable_id,
mbed_official 0:51ac1d130fd4 204 &udptable_node
mbed_official 0:51ac1d130fd4 205 };
mbed_official 0:51ac1d130fd4 206
mbed_official 0:51ac1d130fd4 207 const mib_scalar_node udp_scalar = {
mbed_official 0:51ac1d130fd4 208 &udp_get_object_def,
mbed_official 0:51ac1d130fd4 209 &udp_get_value,
mbed_official 0:51ac1d130fd4 210 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 211 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 212 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 213 0
mbed_official 0:51ac1d130fd4 214 };
mbed_official 0:51ac1d130fd4 215 const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 };
mbed_official 0:51ac1d130fd4 216 struct mib_node* const udp_nodes[5] = {
mbed_official 0:51ac1d130fd4 217 (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar,
mbed_official 0:51ac1d130fd4 218 (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar,
mbed_official 0:51ac1d130fd4 219 (struct mib_node*)&udptable
mbed_official 0:51ac1d130fd4 220 };
mbed_official 0:51ac1d130fd4 221 const struct mib_array_node udp = {
mbed_official 0:51ac1d130fd4 222 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 223 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 224 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 225 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 226 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 227 5,
mbed_official 0:51ac1d130fd4 228 udp_ids,
mbed_official 0:51ac1d130fd4 229 udp_nodes
mbed_official 0:51ac1d130fd4 230 };
mbed_official 0:51ac1d130fd4 231
mbed_official 0:51ac1d130fd4 232 /* tcp .1.3.6.1.2.1.6 */
mbed_official 0:51ac1d130fd4 233 #if LWIP_TCP
mbed_official 0:51ac1d130fd4 234 /* only if the TCP protocol is available may implement this group */
mbed_official 0:51ac1d130fd4 235 /** index root node for tcpConnTable */
mbed_official 0:51ac1d130fd4 236 struct mib_list_rootnode tcpconntree_root = {
mbed_official 0:51ac1d130fd4 237 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 238 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 239 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 240 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 241 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 242 0,
mbed_official 0:51ac1d130fd4 243 NULL,
mbed_official 0:51ac1d130fd4 244 NULL,
mbed_official 0:51ac1d130fd4 245 0
mbed_official 0:51ac1d130fd4 246 };
mbed_official 0:51ac1d130fd4 247 const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
mbed_official 0:51ac1d130fd4 248 struct mib_node* const tcpconnentry_nodes[5] = {
mbed_official 0:51ac1d130fd4 249 (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root,
mbed_official 0:51ac1d130fd4 250 (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root,
mbed_official 0:51ac1d130fd4 251 (struct mib_node*)&tcpconntree_root
mbed_official 0:51ac1d130fd4 252 };
mbed_official 0:51ac1d130fd4 253 const struct mib_array_node tcpconnentry = {
mbed_official 0:51ac1d130fd4 254 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 255 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 256 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 257 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 258 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 259 5,
mbed_official 0:51ac1d130fd4 260 tcpconnentry_ids,
mbed_official 0:51ac1d130fd4 261 tcpconnentry_nodes
mbed_official 0:51ac1d130fd4 262 };
mbed_official 0:51ac1d130fd4 263
mbed_official 0:51ac1d130fd4 264 s32_t tcpconntable_id = 1;
mbed_official 0:51ac1d130fd4 265 struct mib_node* tcpconntable_node = (struct mib_node*)&tcpconnentry;
mbed_official 0:51ac1d130fd4 266 struct mib_ram_array_node tcpconntable = {
mbed_official 0:51ac1d130fd4 267 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 268 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 269 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 270 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 271 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 272 /** @todo update maxlength when inserting / deleting from table
mbed_official 0:51ac1d130fd4 273 0 when table is empty, 1 when more than one entry */
mbed_official 0:51ac1d130fd4 274 0,
mbed_official 0:51ac1d130fd4 275 &tcpconntable_id,
mbed_official 0:51ac1d130fd4 276 &tcpconntable_node
mbed_official 0:51ac1d130fd4 277 };
mbed_official 0:51ac1d130fd4 278
mbed_official 0:51ac1d130fd4 279 const mib_scalar_node tcp_scalar = {
mbed_official 0:51ac1d130fd4 280 &tcp_get_object_def,
mbed_official 0:51ac1d130fd4 281 &tcp_get_value,
mbed_official 0:51ac1d130fd4 282 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 283 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 284 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 285 0
mbed_official 0:51ac1d130fd4 286 };
mbed_official 0:51ac1d130fd4 287 const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
mbed_official 0:51ac1d130fd4 288 struct mib_node* const tcp_nodes[15] = {
mbed_official 0:51ac1d130fd4 289 (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 290 (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 291 (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 292 (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 293 (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 294 (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 295 (struct mib_node*)&tcpconntable, (struct mib_node*)&tcp_scalar,
mbed_official 0:51ac1d130fd4 296 (struct mib_node*)&tcp_scalar
mbed_official 0:51ac1d130fd4 297 };
mbed_official 0:51ac1d130fd4 298 const struct mib_array_node tcp = {
mbed_official 0:51ac1d130fd4 299 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 300 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 301 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 302 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 303 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 304 15,
mbed_official 0:51ac1d130fd4 305 tcp_ids,
mbed_official 0:51ac1d130fd4 306 tcp_nodes
mbed_official 0:51ac1d130fd4 307 };
mbed_official 0:51ac1d130fd4 308 #endif
mbed_official 0:51ac1d130fd4 309
mbed_official 0:51ac1d130fd4 310 /* icmp .1.3.6.1.2.1.5 */
mbed_official 0:51ac1d130fd4 311 const mib_scalar_node icmp_scalar = {
mbed_official 0:51ac1d130fd4 312 &icmp_get_object_def,
mbed_official 0:51ac1d130fd4 313 &icmp_get_value,
mbed_official 0:51ac1d130fd4 314 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 315 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 316 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 317 0
mbed_official 0:51ac1d130fd4 318 };
mbed_official 0:51ac1d130fd4 319 const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
mbed_official 0:51ac1d130fd4 320 struct mib_node* const icmp_nodes[26] = {
mbed_official 0:51ac1d130fd4 321 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 322 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 323 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 324 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 325 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 326 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 327 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 328 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 329 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 330 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 331 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 332 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
mbed_official 0:51ac1d130fd4 333 (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar
mbed_official 0:51ac1d130fd4 334 };
mbed_official 0:51ac1d130fd4 335 const struct mib_array_node icmp = {
mbed_official 0:51ac1d130fd4 336 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 337 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 338 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 339 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 340 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 341 26,
mbed_official 0:51ac1d130fd4 342 icmp_ids,
mbed_official 0:51ac1d130fd4 343 icmp_nodes
mbed_official 0:51ac1d130fd4 344 };
mbed_official 0:51ac1d130fd4 345
mbed_official 0:51ac1d130fd4 346 /** index root node for ipNetToMediaTable */
mbed_official 0:51ac1d130fd4 347 struct mib_list_rootnode ipntomtree_root = {
mbed_official 0:51ac1d130fd4 348 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 349 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 350 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 351 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 352 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 353 0,
mbed_official 0:51ac1d130fd4 354 NULL,
mbed_official 0:51ac1d130fd4 355 NULL,
mbed_official 0:51ac1d130fd4 356 0
mbed_official 0:51ac1d130fd4 357 };
mbed_official 0:51ac1d130fd4 358 const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 };
mbed_official 0:51ac1d130fd4 359 struct mib_node* const ipntomentry_nodes[4] = {
mbed_official 0:51ac1d130fd4 360 (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root,
mbed_official 0:51ac1d130fd4 361 (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root
mbed_official 0:51ac1d130fd4 362 };
mbed_official 0:51ac1d130fd4 363 const struct mib_array_node ipntomentry = {
mbed_official 0:51ac1d130fd4 364 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 365 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 366 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 367 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 368 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 369 4,
mbed_official 0:51ac1d130fd4 370 ipntomentry_ids,
mbed_official 0:51ac1d130fd4 371 ipntomentry_nodes
mbed_official 0:51ac1d130fd4 372 };
mbed_official 0:51ac1d130fd4 373
mbed_official 0:51ac1d130fd4 374 s32_t ipntomtable_id = 1;
mbed_official 0:51ac1d130fd4 375 struct mib_node* ipntomtable_node = (struct mib_node*)&ipntomentry;
mbed_official 0:51ac1d130fd4 376 struct mib_ram_array_node ipntomtable = {
mbed_official 0:51ac1d130fd4 377 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 378 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 379 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 380 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 381 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 382 0,
mbed_official 0:51ac1d130fd4 383 &ipntomtable_id,
mbed_official 0:51ac1d130fd4 384 &ipntomtable_node
mbed_official 0:51ac1d130fd4 385 };
mbed_official 0:51ac1d130fd4 386
mbed_official 0:51ac1d130fd4 387 /** index root node for ipRouteTable */
mbed_official 0:51ac1d130fd4 388 struct mib_list_rootnode iprtetree_root = {
mbed_official 0:51ac1d130fd4 389 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 390 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 391 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 392 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 393 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 394 0,
mbed_official 0:51ac1d130fd4 395 NULL,
mbed_official 0:51ac1d130fd4 396 NULL,
mbed_official 0:51ac1d130fd4 397 0
mbed_official 0:51ac1d130fd4 398 };
mbed_official 0:51ac1d130fd4 399 const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
mbed_official 0:51ac1d130fd4 400 struct mib_node* const iprteentry_nodes[13] = {
mbed_official 0:51ac1d130fd4 401 (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
mbed_official 0:51ac1d130fd4 402 (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
mbed_official 0:51ac1d130fd4 403 (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
mbed_official 0:51ac1d130fd4 404 (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
mbed_official 0:51ac1d130fd4 405 (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
mbed_official 0:51ac1d130fd4 406 (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
mbed_official 0:51ac1d130fd4 407 (struct mib_node*)&iprtetree_root
mbed_official 0:51ac1d130fd4 408 };
mbed_official 0:51ac1d130fd4 409 const struct mib_array_node iprteentry = {
mbed_official 0:51ac1d130fd4 410 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 411 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 412 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 413 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 414 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 415 13,
mbed_official 0:51ac1d130fd4 416 iprteentry_ids,
mbed_official 0:51ac1d130fd4 417 iprteentry_nodes
mbed_official 0:51ac1d130fd4 418 };
mbed_official 0:51ac1d130fd4 419
mbed_official 0:51ac1d130fd4 420 s32_t iprtetable_id = 1;
mbed_official 0:51ac1d130fd4 421 struct mib_node* iprtetable_node = (struct mib_node*)&iprteentry;
mbed_official 0:51ac1d130fd4 422 struct mib_ram_array_node iprtetable = {
mbed_official 0:51ac1d130fd4 423 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 424 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 425 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 426 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 427 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 428 0,
mbed_official 0:51ac1d130fd4 429 &iprtetable_id,
mbed_official 0:51ac1d130fd4 430 &iprtetable_node
mbed_official 0:51ac1d130fd4 431 };
mbed_official 0:51ac1d130fd4 432
mbed_official 0:51ac1d130fd4 433 /** index root node for ipAddrTable */
mbed_official 0:51ac1d130fd4 434 struct mib_list_rootnode ipaddrtree_root = {
mbed_official 0:51ac1d130fd4 435 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 436 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 437 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 438 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 439 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 440 0,
mbed_official 0:51ac1d130fd4 441 NULL,
mbed_official 0:51ac1d130fd4 442 NULL,
mbed_official 0:51ac1d130fd4 443 0
mbed_official 0:51ac1d130fd4 444 };
mbed_official 0:51ac1d130fd4 445 const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 };
mbed_official 0:51ac1d130fd4 446 struct mib_node* const ipaddrentry_nodes[5] = {
mbed_official 0:51ac1d130fd4 447 (struct mib_node*)&ipaddrtree_root,
mbed_official 0:51ac1d130fd4 448 (struct mib_node*)&ipaddrtree_root,
mbed_official 0:51ac1d130fd4 449 (struct mib_node*)&ipaddrtree_root,
mbed_official 0:51ac1d130fd4 450 (struct mib_node*)&ipaddrtree_root,
mbed_official 0:51ac1d130fd4 451 (struct mib_node*)&ipaddrtree_root
mbed_official 0:51ac1d130fd4 452 };
mbed_official 0:51ac1d130fd4 453 const struct mib_array_node ipaddrentry = {
mbed_official 0:51ac1d130fd4 454 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 455 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 456 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 457 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 458 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 459 5,
mbed_official 0:51ac1d130fd4 460 ipaddrentry_ids,
mbed_official 0:51ac1d130fd4 461 ipaddrentry_nodes
mbed_official 0:51ac1d130fd4 462 };
mbed_official 0:51ac1d130fd4 463
mbed_official 0:51ac1d130fd4 464 s32_t ipaddrtable_id = 1;
mbed_official 0:51ac1d130fd4 465 struct mib_node* ipaddrtable_node = (struct mib_node*)&ipaddrentry;
mbed_official 0:51ac1d130fd4 466 struct mib_ram_array_node ipaddrtable = {
mbed_official 0:51ac1d130fd4 467 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 468 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 469 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 470 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 471 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 472 0,
mbed_official 0:51ac1d130fd4 473 &ipaddrtable_id,
mbed_official 0:51ac1d130fd4 474 &ipaddrtable_node
mbed_official 0:51ac1d130fd4 475 };
mbed_official 0:51ac1d130fd4 476
mbed_official 0:51ac1d130fd4 477 /* ip .1.3.6.1.2.1.4 */
mbed_official 0:51ac1d130fd4 478 const mib_scalar_node ip_scalar = {
mbed_official 0:51ac1d130fd4 479 &ip_get_object_def,
mbed_official 0:51ac1d130fd4 480 &ip_get_value,
mbed_official 0:51ac1d130fd4 481 &ip_set_test,
mbed_official 0:51ac1d130fd4 482 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 483 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 484 0
mbed_official 0:51ac1d130fd4 485 };
mbed_official 0:51ac1d130fd4 486 const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
mbed_official 0:51ac1d130fd4 487 struct mib_node* const ip_nodes[23] = {
mbed_official 0:51ac1d130fd4 488 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 489 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 490 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 491 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 492 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 493 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 494 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 495 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 496 (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
mbed_official 0:51ac1d130fd4 497 (struct mib_node*)&ip_scalar, (struct mib_node*)&ipaddrtable,
mbed_official 0:51ac1d130fd4 498 (struct mib_node*)&iprtetable, (struct mib_node*)&ipntomtable,
mbed_official 0:51ac1d130fd4 499 (struct mib_node*)&ip_scalar
mbed_official 0:51ac1d130fd4 500 };
mbed_official 0:51ac1d130fd4 501 const struct mib_array_node mib2_ip = {
mbed_official 0:51ac1d130fd4 502 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 503 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 504 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 505 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 506 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 507 23,
mbed_official 0:51ac1d130fd4 508 ip_ids,
mbed_official 0:51ac1d130fd4 509 ip_nodes
mbed_official 0:51ac1d130fd4 510 };
mbed_official 0:51ac1d130fd4 511
mbed_official 0:51ac1d130fd4 512 /** index root node for atTable */
mbed_official 0:51ac1d130fd4 513 struct mib_list_rootnode arptree_root = {
mbed_official 0:51ac1d130fd4 514 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 515 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 516 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 517 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 518 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 519 0,
mbed_official 0:51ac1d130fd4 520 NULL,
mbed_official 0:51ac1d130fd4 521 NULL,
mbed_official 0:51ac1d130fd4 522 0
mbed_official 0:51ac1d130fd4 523 };
mbed_official 0:51ac1d130fd4 524 const s32_t atentry_ids[3] = { 1, 2, 3 };
mbed_official 0:51ac1d130fd4 525 struct mib_node* const atentry_nodes[3] = {
mbed_official 0:51ac1d130fd4 526 (struct mib_node*)&arptree_root,
mbed_official 0:51ac1d130fd4 527 (struct mib_node*)&arptree_root,
mbed_official 0:51ac1d130fd4 528 (struct mib_node*)&arptree_root
mbed_official 0:51ac1d130fd4 529 };
mbed_official 0:51ac1d130fd4 530 const struct mib_array_node atentry = {
mbed_official 0:51ac1d130fd4 531 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 532 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 533 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 534 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 535 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 536 3,
mbed_official 0:51ac1d130fd4 537 atentry_ids,
mbed_official 0:51ac1d130fd4 538 atentry_nodes
mbed_official 0:51ac1d130fd4 539 };
mbed_official 0:51ac1d130fd4 540
mbed_official 0:51ac1d130fd4 541 const s32_t attable_id = 1;
mbed_official 0:51ac1d130fd4 542 struct mib_node* const attable_node = (struct mib_node*)&atentry;
mbed_official 0:51ac1d130fd4 543 const struct mib_array_node attable = {
mbed_official 0:51ac1d130fd4 544 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 545 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 546 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 547 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 548 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 549 1,
mbed_official 0:51ac1d130fd4 550 &attable_id,
mbed_official 0:51ac1d130fd4 551 &attable_node
mbed_official 0:51ac1d130fd4 552 };
mbed_official 0:51ac1d130fd4 553
mbed_official 0:51ac1d130fd4 554 /* at .1.3.6.1.2.1.3 */
mbed_official 0:51ac1d130fd4 555 s32_t at_id = 1;
mbed_official 0:51ac1d130fd4 556 struct mib_node* mib2_at_node = (struct mib_node*)&attable;
mbed_official 0:51ac1d130fd4 557 struct mib_ram_array_node at = {
mbed_official 0:51ac1d130fd4 558 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 559 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 560 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 561 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 562 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 563 0,
mbed_official 0:51ac1d130fd4 564 &at_id,
mbed_official 0:51ac1d130fd4 565 &mib2_at_node
mbed_official 0:51ac1d130fd4 566 };
mbed_official 0:51ac1d130fd4 567
mbed_official 0:51ac1d130fd4 568 /** index root node for ifTable */
mbed_official 0:51ac1d130fd4 569 struct mib_list_rootnode iflist_root = {
mbed_official 0:51ac1d130fd4 570 &ifentry_get_object_def,
mbed_official 0:51ac1d130fd4 571 &ifentry_get_value,
mbed_official 0:51ac1d130fd4 572 #if SNMP_SAFE_REQUESTS
mbed_official 0:51ac1d130fd4 573 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 574 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 575 #else /* SNMP_SAFE_REQUESTS */
mbed_official 0:51ac1d130fd4 576 &ifentry_set_test,
mbed_official 0:51ac1d130fd4 577 &ifentry_set_value,
mbed_official 0:51ac1d130fd4 578 #endif /* SNMP_SAFE_REQUESTS */
mbed_official 0:51ac1d130fd4 579 MIB_NODE_LR,
mbed_official 0:51ac1d130fd4 580 0,
mbed_official 0:51ac1d130fd4 581 NULL,
mbed_official 0:51ac1d130fd4 582 NULL,
mbed_official 0:51ac1d130fd4 583 0
mbed_official 0:51ac1d130fd4 584 };
mbed_official 0:51ac1d130fd4 585 const s32_t ifentry_ids[22] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 };
mbed_official 0:51ac1d130fd4 586 struct mib_node* const ifentry_nodes[22] = {
mbed_official 0:51ac1d130fd4 587 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 588 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 589 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 590 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 591 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 592 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 593 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 594 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 595 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 596 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
mbed_official 0:51ac1d130fd4 597 (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root
mbed_official 0:51ac1d130fd4 598 };
mbed_official 0:51ac1d130fd4 599 const struct mib_array_node ifentry = {
mbed_official 0:51ac1d130fd4 600 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 601 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 602 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 603 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 604 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 605 22,
mbed_official 0:51ac1d130fd4 606 ifentry_ids,
mbed_official 0:51ac1d130fd4 607 ifentry_nodes
mbed_official 0:51ac1d130fd4 608 };
mbed_official 0:51ac1d130fd4 609
mbed_official 0:51ac1d130fd4 610 s32_t iftable_id = 1;
mbed_official 0:51ac1d130fd4 611 struct mib_node* iftable_node = (struct mib_node*)&ifentry;
mbed_official 0:51ac1d130fd4 612 struct mib_ram_array_node iftable = {
mbed_official 0:51ac1d130fd4 613 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 614 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 615 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 616 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 617 MIB_NODE_RA,
mbed_official 0:51ac1d130fd4 618 0,
mbed_official 0:51ac1d130fd4 619 &iftable_id,
mbed_official 0:51ac1d130fd4 620 &iftable_node
mbed_official 0:51ac1d130fd4 621 };
mbed_official 0:51ac1d130fd4 622
mbed_official 0:51ac1d130fd4 623 /* interfaces .1.3.6.1.2.1.2 */
mbed_official 0:51ac1d130fd4 624 const mib_scalar_node interfaces_scalar = {
mbed_official 0:51ac1d130fd4 625 &interfaces_get_object_def,
mbed_official 0:51ac1d130fd4 626 &interfaces_get_value,
mbed_official 0:51ac1d130fd4 627 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 628 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 629 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 630 0
mbed_official 0:51ac1d130fd4 631 };
mbed_official 0:51ac1d130fd4 632 const s32_t interfaces_ids[2] = { 1, 2 };
mbed_official 0:51ac1d130fd4 633 struct mib_node* const interfaces_nodes[2] = {
mbed_official 0:51ac1d130fd4 634 (struct mib_node*)&interfaces_scalar, (struct mib_node*)&iftable
mbed_official 0:51ac1d130fd4 635 };
mbed_official 0:51ac1d130fd4 636 const struct mib_array_node interfaces = {
mbed_official 0:51ac1d130fd4 637 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 638 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 639 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 640 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 641 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 642 2,
mbed_official 0:51ac1d130fd4 643 interfaces_ids,
mbed_official 0:51ac1d130fd4 644 interfaces_nodes
mbed_official 0:51ac1d130fd4 645 };
mbed_official 0:51ac1d130fd4 646
mbed_official 0:51ac1d130fd4 647
mbed_official 0:51ac1d130fd4 648 /* 0 1 2 3 4 5 6 */
mbed_official 0:51ac1d130fd4 649 /* system .1.3.6.1.2.1.1 */
mbed_official 0:51ac1d130fd4 650 const mib_scalar_node sys_tem_scalar = {
mbed_official 0:51ac1d130fd4 651 &system_get_object_def,
mbed_official 0:51ac1d130fd4 652 &system_get_value,
mbed_official 0:51ac1d130fd4 653 &system_set_test,
mbed_official 0:51ac1d130fd4 654 &system_set_value,
mbed_official 0:51ac1d130fd4 655 MIB_NODE_SC,
mbed_official 0:51ac1d130fd4 656 0
mbed_official 0:51ac1d130fd4 657 };
mbed_official 0:51ac1d130fd4 658 const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 };
mbed_official 0:51ac1d130fd4 659 struct mib_node* const sys_tem_nodes[7] = {
mbed_official 0:51ac1d130fd4 660 (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar,
mbed_official 0:51ac1d130fd4 661 (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar,
mbed_official 0:51ac1d130fd4 662 (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar,
mbed_official 0:51ac1d130fd4 663 (struct mib_node*)&sys_tem_scalar
mbed_official 0:51ac1d130fd4 664 };
mbed_official 0:51ac1d130fd4 665 /* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
mbed_official 0:51ac1d130fd4 666 const struct mib_array_node sys_tem = {
mbed_official 0:51ac1d130fd4 667 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 668 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 669 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 670 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 671 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 672 7,
mbed_official 0:51ac1d130fd4 673 sys_tem_ids,
mbed_official 0:51ac1d130fd4 674 sys_tem_nodes
mbed_official 0:51ac1d130fd4 675 };
mbed_official 0:51ac1d130fd4 676
mbed_official 0:51ac1d130fd4 677 /* mib-2 .1.3.6.1.2.1 */
mbed_official 0:51ac1d130fd4 678 #if LWIP_TCP
mbed_official 0:51ac1d130fd4 679 #define MIB2_GROUPS 8
mbed_official 0:51ac1d130fd4 680 #else
mbed_official 0:51ac1d130fd4 681 #define MIB2_GROUPS 7
mbed_official 0:51ac1d130fd4 682 #endif
mbed_official 0:51ac1d130fd4 683 const s32_t mib2_ids[MIB2_GROUPS] =
mbed_official 0:51ac1d130fd4 684 {
mbed_official 0:51ac1d130fd4 685 1,
mbed_official 0:51ac1d130fd4 686 2,
mbed_official 0:51ac1d130fd4 687 3,
mbed_official 0:51ac1d130fd4 688 4,
mbed_official 0:51ac1d130fd4 689 5,
mbed_official 0:51ac1d130fd4 690 #if LWIP_TCP
mbed_official 0:51ac1d130fd4 691 6,
mbed_official 0:51ac1d130fd4 692 #endif
mbed_official 0:51ac1d130fd4 693 7,
mbed_official 0:51ac1d130fd4 694 11
mbed_official 0:51ac1d130fd4 695 };
mbed_official 0:51ac1d130fd4 696 struct mib_node* const mib2_nodes[MIB2_GROUPS] = {
mbed_official 0:51ac1d130fd4 697 (struct mib_node*)&sys_tem,
mbed_official 0:51ac1d130fd4 698 (struct mib_node*)&interfaces,
mbed_official 0:51ac1d130fd4 699 (struct mib_node*)&at,
mbed_official 0:51ac1d130fd4 700 (struct mib_node*)&mib2_ip,
mbed_official 0:51ac1d130fd4 701 (struct mib_node*)&icmp,
mbed_official 0:51ac1d130fd4 702 #if LWIP_TCP
mbed_official 0:51ac1d130fd4 703 (struct mib_node*)&tcp,
mbed_official 0:51ac1d130fd4 704 #endif
mbed_official 0:51ac1d130fd4 705 (struct mib_node*)&udp,
mbed_official 0:51ac1d130fd4 706 (struct mib_node*)&snmp
mbed_official 0:51ac1d130fd4 707 };
mbed_official 0:51ac1d130fd4 708
mbed_official 0:51ac1d130fd4 709 const struct mib_array_node mib2 = {
mbed_official 0:51ac1d130fd4 710 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 711 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 712 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 713 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 714 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 715 MIB2_GROUPS,
mbed_official 0:51ac1d130fd4 716 mib2_ids,
mbed_official 0:51ac1d130fd4 717 mib2_nodes
mbed_official 0:51ac1d130fd4 718 };
mbed_official 0:51ac1d130fd4 719
mbed_official 0:51ac1d130fd4 720 /* mgmt .1.3.6.1.2 */
mbed_official 0:51ac1d130fd4 721 const s32_t mgmt_ids[1] = { 1 };
mbed_official 0:51ac1d130fd4 722 struct mib_node* const mgmt_nodes[1] = { (struct mib_node*)&mib2 };
mbed_official 0:51ac1d130fd4 723 const struct mib_array_node mgmt = {
mbed_official 0:51ac1d130fd4 724 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 725 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 726 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 727 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 728 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 729 1,
mbed_official 0:51ac1d130fd4 730 mgmt_ids,
mbed_official 0:51ac1d130fd4 731 mgmt_nodes
mbed_official 0:51ac1d130fd4 732 };
mbed_official 0:51ac1d130fd4 733
mbed_official 0:51ac1d130fd4 734 /* internet .1.3.6.1 */
mbed_official 0:51ac1d130fd4 735 #if SNMP_PRIVATE_MIB
mbed_official 0:51ac1d130fd4 736 /* When using a private MIB, you have to create a file 'private_mib.h' that contains
mbed_official 0:51ac1d130fd4 737 * a 'struct mib_array_node mib_private' which contains your MIB. */
mbed_official 0:51ac1d130fd4 738 s32_t internet_ids[2] = { 2, 4 };
mbed_official 0:51ac1d130fd4 739 struct mib_node* const internet_nodes[2] = { (struct mib_node*)&mgmt, (struct mib_node*)&mib_private };
mbed_official 0:51ac1d130fd4 740 const struct mib_array_node internet = {
mbed_official 0:51ac1d130fd4 741 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 742 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 743 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 744 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 745 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 746 2,
mbed_official 0:51ac1d130fd4 747 internet_ids,
mbed_official 0:51ac1d130fd4 748 internet_nodes
mbed_official 0:51ac1d130fd4 749 };
mbed_official 0:51ac1d130fd4 750 #else
mbed_official 0:51ac1d130fd4 751 const s32_t internet_ids[1] = { 2 };
mbed_official 0:51ac1d130fd4 752 struct mib_node* const internet_nodes[1] = { (struct mib_node*)&mgmt };
mbed_official 0:51ac1d130fd4 753 const struct mib_array_node internet = {
mbed_official 0:51ac1d130fd4 754 &noleafs_get_object_def,
mbed_official 0:51ac1d130fd4 755 &noleafs_get_value,
mbed_official 0:51ac1d130fd4 756 &noleafs_set_test,
mbed_official 0:51ac1d130fd4 757 &noleafs_set_value,
mbed_official 0:51ac1d130fd4 758 MIB_NODE_AR,
mbed_official 0:51ac1d130fd4 759 1,
mbed_official 0:51ac1d130fd4 760 internet_ids,
mbed_official 0:51ac1d130fd4 761 internet_nodes
mbed_official 0:51ac1d130fd4 762 };
mbed_official 0:51ac1d130fd4 763 #endif
mbed_official 0:51ac1d130fd4 764
mbed_official 0:51ac1d130fd4 765 /** mib-2.system.sysObjectID */
mbed_official 0:51ac1d130fd4 766 static struct snmp_obj_id sysobjid = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID};
mbed_official 0:51ac1d130fd4 767 /** enterprise ID for generic TRAPs, .iso.org.dod.internet.mgmt.mib-2.snmp */
mbed_official 0:51ac1d130fd4 768 static struct snmp_obj_id snmpgrp_id = {7,{1,3,6,1,2,1,11}};
mbed_official 0:51ac1d130fd4 769 /** mib-2.system.sysServices */
mbed_official 0:51ac1d130fd4 770 static const s32_t sysservices = SNMP_SYSSERVICES;
mbed_official 0:51ac1d130fd4 771
mbed_official 0:51ac1d130fd4 772 /** mib-2.system.sysDescr */
mbed_official 0:51ac1d130fd4 773 static const u8_t sysdescr_len_default = 4;
mbed_official 0:51ac1d130fd4 774 static const u8_t sysdescr_default[] = "lwIP";
mbed_official 0:51ac1d130fd4 775 static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default;
mbed_official 0:51ac1d130fd4 776 static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0];
mbed_official 0:51ac1d130fd4 777 /** mib-2.system.sysContact */
mbed_official 0:51ac1d130fd4 778 static const u8_t syscontact_len_default = 0;
mbed_official 0:51ac1d130fd4 779 static const u8_t syscontact_default[] = "";
mbed_official 0:51ac1d130fd4 780 static u8_t* syscontact_len_ptr = (u8_t*)&syscontact_len_default;
mbed_official 0:51ac1d130fd4 781 static u8_t* syscontact_ptr = (u8_t*)&syscontact_default[0];
mbed_official 0:51ac1d130fd4 782 /** mib-2.system.sysName */
mbed_official 0:51ac1d130fd4 783 static const u8_t sysname_len_default = 8;
mbed_official 0:51ac1d130fd4 784 static const u8_t sysname_default[] = "FQDN-unk";
mbed_official 0:51ac1d130fd4 785 static u8_t* sysname_len_ptr = (u8_t*)&sysname_len_default;
mbed_official 0:51ac1d130fd4 786 static u8_t* sysname_ptr = (u8_t*)&sysname_default[0];
mbed_official 0:51ac1d130fd4 787 /** mib-2.system.sysLocation */
mbed_official 0:51ac1d130fd4 788 static const u8_t syslocation_len_default = 0;
mbed_official 0:51ac1d130fd4 789 static const u8_t syslocation_default[] = "";
mbed_official 0:51ac1d130fd4 790 static u8_t* syslocation_len_ptr = (u8_t*)&syslocation_len_default;
mbed_official 0:51ac1d130fd4 791 static u8_t* syslocation_ptr = (u8_t*)&syslocation_default[0];
mbed_official 0:51ac1d130fd4 792 /** mib-2.snmp.snmpEnableAuthenTraps */
mbed_official 0:51ac1d130fd4 793 static const u8_t snmpenableauthentraps_default = 2; /* disabled */
mbed_official 0:51ac1d130fd4 794 static u8_t* snmpenableauthentraps_ptr = (u8_t*)&snmpenableauthentraps_default;
mbed_official 0:51ac1d130fd4 795
mbed_official 0:51ac1d130fd4 796 /** mib-2.interfaces.ifTable.ifEntry.ifSpecific (zeroDotZero) */
mbed_official 0:51ac1d130fd4 797 static const struct snmp_obj_id ifspecific = {2, {0, 0}};
mbed_official 0:51ac1d130fd4 798 /** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */
mbed_official 0:51ac1d130fd4 799 static const struct snmp_obj_id iprouteinfo = {2, {0, 0}};
mbed_official 0:51ac1d130fd4 800
mbed_official 0:51ac1d130fd4 801
mbed_official 0:51ac1d130fd4 802
mbed_official 0:51ac1d130fd4 803 /* mib-2.system counter(s) */
mbed_official 0:51ac1d130fd4 804 static u32_t sysuptime = 0;
mbed_official 0:51ac1d130fd4 805
mbed_official 0:51ac1d130fd4 806 /* mib-2.ip counter(s) */
mbed_official 0:51ac1d130fd4 807 static u32_t ipinreceives = 0,
mbed_official 0:51ac1d130fd4 808 ipinhdrerrors = 0,
mbed_official 0:51ac1d130fd4 809 ipinaddrerrors = 0,
mbed_official 0:51ac1d130fd4 810 ipforwdatagrams = 0,
mbed_official 0:51ac1d130fd4 811 ipinunknownprotos = 0,
mbed_official 0:51ac1d130fd4 812 ipindiscards = 0,
mbed_official 0:51ac1d130fd4 813 ipindelivers = 0,
mbed_official 0:51ac1d130fd4 814 ipoutrequests = 0,
mbed_official 0:51ac1d130fd4 815 ipoutdiscards = 0,
mbed_official 0:51ac1d130fd4 816 ipoutnoroutes = 0,
mbed_official 0:51ac1d130fd4 817 ipreasmreqds = 0,
mbed_official 0:51ac1d130fd4 818 ipreasmoks = 0,
mbed_official 0:51ac1d130fd4 819 ipreasmfails = 0,
mbed_official 0:51ac1d130fd4 820 ipfragoks = 0,
mbed_official 0:51ac1d130fd4 821 ipfragfails = 0,
mbed_official 0:51ac1d130fd4 822 ipfragcreates = 0,
mbed_official 0:51ac1d130fd4 823 iproutingdiscards = 0;
mbed_official 0:51ac1d130fd4 824 /* mib-2.icmp counter(s) */
mbed_official 0:51ac1d130fd4 825 static u32_t icmpinmsgs = 0,
mbed_official 0:51ac1d130fd4 826 icmpinerrors = 0,
mbed_official 0:51ac1d130fd4 827 icmpindestunreachs = 0,
mbed_official 0:51ac1d130fd4 828 icmpintimeexcds = 0,
mbed_official 0:51ac1d130fd4 829 icmpinparmprobs = 0,
mbed_official 0:51ac1d130fd4 830 icmpinsrcquenchs = 0,
mbed_official 0:51ac1d130fd4 831 icmpinredirects = 0,
mbed_official 0:51ac1d130fd4 832 icmpinechos = 0,
mbed_official 0:51ac1d130fd4 833 icmpinechoreps = 0,
mbed_official 0:51ac1d130fd4 834 icmpintimestamps = 0,
mbed_official 0:51ac1d130fd4 835 icmpintimestampreps = 0,
mbed_official 0:51ac1d130fd4 836 icmpinaddrmasks = 0,
mbed_official 0:51ac1d130fd4 837 icmpinaddrmaskreps = 0,
mbed_official 0:51ac1d130fd4 838 icmpoutmsgs = 0,
mbed_official 0:51ac1d130fd4 839 icmpouterrors = 0,
mbed_official 0:51ac1d130fd4 840 icmpoutdestunreachs = 0,
mbed_official 0:51ac1d130fd4 841 icmpouttimeexcds = 0,
mbed_official 0:51ac1d130fd4 842 icmpoutparmprobs = 0,
mbed_official 0:51ac1d130fd4 843 icmpoutsrcquenchs = 0,
mbed_official 0:51ac1d130fd4 844 icmpoutredirects = 0,
mbed_official 0:51ac1d130fd4 845 icmpoutechos = 0,
mbed_official 0:51ac1d130fd4 846 icmpoutechoreps = 0,
mbed_official 0:51ac1d130fd4 847 icmpouttimestamps = 0,
mbed_official 0:51ac1d130fd4 848 icmpouttimestampreps = 0,
mbed_official 0:51ac1d130fd4 849 icmpoutaddrmasks = 0,
mbed_official 0:51ac1d130fd4 850 icmpoutaddrmaskreps = 0;
mbed_official 0:51ac1d130fd4 851 /* mib-2.tcp counter(s) */
mbed_official 0:51ac1d130fd4 852 static u32_t tcpactiveopens = 0,
mbed_official 0:51ac1d130fd4 853 tcppassiveopens = 0,
mbed_official 0:51ac1d130fd4 854 tcpattemptfails = 0,
mbed_official 0:51ac1d130fd4 855 tcpestabresets = 0,
mbed_official 0:51ac1d130fd4 856 tcpinsegs = 0,
mbed_official 0:51ac1d130fd4 857 tcpoutsegs = 0,
mbed_official 0:51ac1d130fd4 858 tcpretranssegs = 0,
mbed_official 0:51ac1d130fd4 859 tcpinerrs = 0,
mbed_official 0:51ac1d130fd4 860 tcpoutrsts = 0;
mbed_official 0:51ac1d130fd4 861 /* mib-2.udp counter(s) */
mbed_official 0:51ac1d130fd4 862 static u32_t udpindatagrams = 0,
mbed_official 0:51ac1d130fd4 863 udpnoports = 0,
mbed_official 0:51ac1d130fd4 864 udpinerrors = 0,
mbed_official 0:51ac1d130fd4 865 udpoutdatagrams = 0;
mbed_official 0:51ac1d130fd4 866 /* mib-2.snmp counter(s) */
mbed_official 0:51ac1d130fd4 867 static u32_t snmpinpkts = 0,
mbed_official 0:51ac1d130fd4 868 snmpoutpkts = 0,
mbed_official 0:51ac1d130fd4 869 snmpinbadversions = 0,
mbed_official 0:51ac1d130fd4 870 snmpinbadcommunitynames = 0,
mbed_official 0:51ac1d130fd4 871 snmpinbadcommunityuses = 0,
mbed_official 0:51ac1d130fd4 872 snmpinasnparseerrs = 0,
mbed_official 0:51ac1d130fd4 873 snmpintoobigs = 0,
mbed_official 0:51ac1d130fd4 874 snmpinnosuchnames = 0,
mbed_official 0:51ac1d130fd4 875 snmpinbadvalues = 0,
mbed_official 0:51ac1d130fd4 876 snmpinreadonlys = 0,
mbed_official 0:51ac1d130fd4 877 snmpingenerrs = 0,
mbed_official 0:51ac1d130fd4 878 snmpintotalreqvars = 0,
mbed_official 0:51ac1d130fd4 879 snmpintotalsetvars = 0,
mbed_official 0:51ac1d130fd4 880 snmpingetrequests = 0,
mbed_official 0:51ac1d130fd4 881 snmpingetnexts = 0,
mbed_official 0:51ac1d130fd4 882 snmpinsetrequests = 0,
mbed_official 0:51ac1d130fd4 883 snmpingetresponses = 0,
mbed_official 0:51ac1d130fd4 884 snmpintraps = 0,
mbed_official 0:51ac1d130fd4 885 snmpouttoobigs = 0,
mbed_official 0:51ac1d130fd4 886 snmpoutnosuchnames = 0,
mbed_official 0:51ac1d130fd4 887 snmpoutbadvalues = 0,
mbed_official 0:51ac1d130fd4 888 snmpoutgenerrs = 0,
mbed_official 0:51ac1d130fd4 889 snmpoutgetrequests = 0,
mbed_official 0:51ac1d130fd4 890 snmpoutgetnexts = 0,
mbed_official 0:51ac1d130fd4 891 snmpoutsetrequests = 0,
mbed_official 0:51ac1d130fd4 892 snmpoutgetresponses = 0,
mbed_official 0:51ac1d130fd4 893 snmpouttraps = 0;
mbed_official 0:51ac1d130fd4 894
mbed_official 0:51ac1d130fd4 895
mbed_official 0:51ac1d130fd4 896
mbed_official 0:51ac1d130fd4 897 /* prototypes of the following functions are in lwip/src/include/lwip/snmp.h */
mbed_official 0:51ac1d130fd4 898 /**
mbed_official 0:51ac1d130fd4 899 * Copy octet string.
mbed_official 0:51ac1d130fd4 900 *
mbed_official 0:51ac1d130fd4 901 * @param dst points to destination
mbed_official 0:51ac1d130fd4 902 * @param src points to source
mbed_official 0:51ac1d130fd4 903 * @param n number of octets to copy.
mbed_official 0:51ac1d130fd4 904 */
mbed_official 0:51ac1d130fd4 905 static void ocstrncpy(u8_t *dst, u8_t *src, u16_t n)
mbed_official 0:51ac1d130fd4 906 {
mbed_official 0:51ac1d130fd4 907 u16_t i = n;
mbed_official 0:51ac1d130fd4 908 while (i > 0) {
mbed_official 0:51ac1d130fd4 909 i--;
mbed_official 0:51ac1d130fd4 910 *dst++ = *src++;
mbed_official 0:51ac1d130fd4 911 }
mbed_official 0:51ac1d130fd4 912 }
mbed_official 0:51ac1d130fd4 913
mbed_official 0:51ac1d130fd4 914 /**
mbed_official 0:51ac1d130fd4 915 * Copy object identifier (s32_t) array.
mbed_official 0:51ac1d130fd4 916 *
mbed_official 0:51ac1d130fd4 917 * @param dst points to destination
mbed_official 0:51ac1d130fd4 918 * @param src points to source
mbed_official 0:51ac1d130fd4 919 * @param n number of sub identifiers to copy.
mbed_official 0:51ac1d130fd4 920 */
mbed_official 0:51ac1d130fd4 921 void objectidncpy(s32_t *dst, s32_t *src, u8_t n)
mbed_official 0:51ac1d130fd4 922 {
mbed_official 0:51ac1d130fd4 923 u8_t i = n;
mbed_official 0:51ac1d130fd4 924 while(i > 0) {
mbed_official 0:51ac1d130fd4 925 i--;
mbed_official 0:51ac1d130fd4 926 *dst++ = *src++;
mbed_official 0:51ac1d130fd4 927 }
mbed_official 0:51ac1d130fd4 928 }
mbed_official 0:51ac1d130fd4 929
mbed_official 0:51ac1d130fd4 930 /**
mbed_official 0:51ac1d130fd4 931 * Initializes sysDescr pointers.
mbed_official 0:51ac1d130fd4 932 *
mbed_official 0:51ac1d130fd4 933 * @param str if non-NULL then copy str pointer
mbed_official 0:51ac1d130fd4 934 * @param len points to string length, excluding zero terminator
mbed_official 0:51ac1d130fd4 935 */
mbed_official 0:51ac1d130fd4 936 void snmp_set_sysdesr(u8_t *str, u8_t *len)
mbed_official 0:51ac1d130fd4 937 {
mbed_official 0:51ac1d130fd4 938 if (str != NULL)
mbed_official 0:51ac1d130fd4 939 {
mbed_official 0:51ac1d130fd4 940 sysdescr_ptr = str;
mbed_official 0:51ac1d130fd4 941 sysdescr_len_ptr = len;
mbed_official 0:51ac1d130fd4 942 }
mbed_official 0:51ac1d130fd4 943 }
mbed_official 0:51ac1d130fd4 944
mbed_official 0:51ac1d130fd4 945 void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid)
mbed_official 0:51ac1d130fd4 946 {
mbed_official 0:51ac1d130fd4 947 *oid = &sysobjid;
mbed_official 0:51ac1d130fd4 948 }
mbed_official 0:51ac1d130fd4 949
mbed_official 0:51ac1d130fd4 950 /**
mbed_official 0:51ac1d130fd4 951 * Initializes sysObjectID value.
mbed_official 0:51ac1d130fd4 952 *
mbed_official 0:51ac1d130fd4 953 * @param oid points to stuct snmp_obj_id to copy
mbed_official 0:51ac1d130fd4 954 */
mbed_official 0:51ac1d130fd4 955 void snmp_set_sysobjid(struct snmp_obj_id *oid)
mbed_official 0:51ac1d130fd4 956 {
mbed_official 0:51ac1d130fd4 957 sysobjid = *oid;
mbed_official 0:51ac1d130fd4 958 }
mbed_official 0:51ac1d130fd4 959
mbed_official 0:51ac1d130fd4 960 /**
mbed_official 0:51ac1d130fd4 961 * Must be called at regular 10 msec interval from a timer interrupt
mbed_official 0:51ac1d130fd4 962 * or signal handler depending on your runtime environment.
mbed_official 0:51ac1d130fd4 963 */
mbed_official 0:51ac1d130fd4 964 void snmp_inc_sysuptime(void)
mbed_official 0:51ac1d130fd4 965 {
mbed_official 0:51ac1d130fd4 966 sysuptime++;
mbed_official 0:51ac1d130fd4 967 }
mbed_official 0:51ac1d130fd4 968
mbed_official 0:51ac1d130fd4 969 void snmp_add_sysuptime(u32_t value)
mbed_official 0:51ac1d130fd4 970 {
mbed_official 0:51ac1d130fd4 971 sysuptime+=value;
mbed_official 0:51ac1d130fd4 972 }
mbed_official 0:51ac1d130fd4 973
mbed_official 0:51ac1d130fd4 974 void snmp_get_sysuptime(u32_t *value)
mbed_official 0:51ac1d130fd4 975 {
mbed_official 0:51ac1d130fd4 976 SNMP_GET_SYSUPTIME(sysuptime);
mbed_official 0:51ac1d130fd4 977 *value = sysuptime;
mbed_official 0:51ac1d130fd4 978 }
mbed_official 0:51ac1d130fd4 979
mbed_official 0:51ac1d130fd4 980 /**
mbed_official 0:51ac1d130fd4 981 * Initializes sysContact pointers,
mbed_official 0:51ac1d130fd4 982 * e.g. ptrs to non-volatile memory external to lwIP.
mbed_official 0:51ac1d130fd4 983 *
mbed_official 0:51ac1d130fd4 984 * @param ocstr if non-NULL then copy str pointer
mbed_official 0:51ac1d130fd4 985 * @param ocstrlen points to string length, excluding zero terminator
mbed_official 0:51ac1d130fd4 986 */
mbed_official 0:51ac1d130fd4 987 void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen)
mbed_official 0:51ac1d130fd4 988 {
mbed_official 0:51ac1d130fd4 989 if (ocstr != NULL)
mbed_official 0:51ac1d130fd4 990 {
mbed_official 0:51ac1d130fd4 991 syscontact_ptr = ocstr;
mbed_official 0:51ac1d130fd4 992 syscontact_len_ptr = ocstrlen;
mbed_official 0:51ac1d130fd4 993 }
mbed_official 0:51ac1d130fd4 994 }
mbed_official 0:51ac1d130fd4 995
mbed_official 0:51ac1d130fd4 996 /**
mbed_official 0:51ac1d130fd4 997 * Initializes sysName pointers,
mbed_official 0:51ac1d130fd4 998 * e.g. ptrs to non-volatile memory external to lwIP.
mbed_official 0:51ac1d130fd4 999 *
mbed_official 0:51ac1d130fd4 1000 * @param ocstr if non-NULL then copy str pointer
mbed_official 0:51ac1d130fd4 1001 * @param ocstrlen points to string length, excluding zero terminator
mbed_official 0:51ac1d130fd4 1002 */
mbed_official 0:51ac1d130fd4 1003 void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen)
mbed_official 0:51ac1d130fd4 1004 {
mbed_official 0:51ac1d130fd4 1005 if (ocstr != NULL)
mbed_official 0:51ac1d130fd4 1006 {
mbed_official 0:51ac1d130fd4 1007 sysname_ptr = ocstr;
mbed_official 0:51ac1d130fd4 1008 sysname_len_ptr = ocstrlen;
mbed_official 0:51ac1d130fd4 1009 }
mbed_official 0:51ac1d130fd4 1010 }
mbed_official 0:51ac1d130fd4 1011
mbed_official 0:51ac1d130fd4 1012 /**
mbed_official 0:51ac1d130fd4 1013 * Initializes sysLocation pointers,
mbed_official 0:51ac1d130fd4 1014 * e.g. ptrs to non-volatile memory external to lwIP.
mbed_official 0:51ac1d130fd4 1015 *
mbed_official 0:51ac1d130fd4 1016 * @param ocstr if non-NULL then copy str pointer
mbed_official 0:51ac1d130fd4 1017 * @param ocstrlen points to string length, excluding zero terminator
mbed_official 0:51ac1d130fd4 1018 */
mbed_official 0:51ac1d130fd4 1019 void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen)
mbed_official 0:51ac1d130fd4 1020 {
mbed_official 0:51ac1d130fd4 1021 if (ocstr != NULL)
mbed_official 0:51ac1d130fd4 1022 {
mbed_official 0:51ac1d130fd4 1023 syslocation_ptr = ocstr;
mbed_official 0:51ac1d130fd4 1024 syslocation_len_ptr = ocstrlen;
mbed_official 0:51ac1d130fd4 1025 }
mbed_official 0:51ac1d130fd4 1026 }
mbed_official 0:51ac1d130fd4 1027
mbed_official 0:51ac1d130fd4 1028
mbed_official 0:51ac1d130fd4 1029 void snmp_add_ifinoctets(struct netif *ni, u32_t value)
mbed_official 0:51ac1d130fd4 1030 {
mbed_official 0:51ac1d130fd4 1031 ni->ifinoctets += value;
mbed_official 0:51ac1d130fd4 1032 }
mbed_official 0:51ac1d130fd4 1033
mbed_official 0:51ac1d130fd4 1034 void snmp_inc_ifinucastpkts(struct netif *ni)
mbed_official 0:51ac1d130fd4 1035 {
mbed_official 0:51ac1d130fd4 1036 (ni->ifinucastpkts)++;
mbed_official 0:51ac1d130fd4 1037 }
mbed_official 0:51ac1d130fd4 1038
mbed_official 0:51ac1d130fd4 1039 void snmp_inc_ifinnucastpkts(struct netif *ni)
mbed_official 0:51ac1d130fd4 1040 {
mbed_official 0:51ac1d130fd4 1041 (ni->ifinnucastpkts)++;
mbed_official 0:51ac1d130fd4 1042 }
mbed_official 0:51ac1d130fd4 1043
mbed_official 0:51ac1d130fd4 1044 void snmp_inc_ifindiscards(struct netif *ni)
mbed_official 0:51ac1d130fd4 1045 {
mbed_official 0:51ac1d130fd4 1046 (ni->ifindiscards)++;
mbed_official 0:51ac1d130fd4 1047 }
mbed_official 0:51ac1d130fd4 1048
mbed_official 0:51ac1d130fd4 1049 void snmp_add_ifoutoctets(struct netif *ni, u32_t value)
mbed_official 0:51ac1d130fd4 1050 {
mbed_official 0:51ac1d130fd4 1051 ni->ifoutoctets += value;
mbed_official 0:51ac1d130fd4 1052 }
mbed_official 0:51ac1d130fd4 1053
mbed_official 0:51ac1d130fd4 1054 void snmp_inc_ifoutucastpkts(struct netif *ni)
mbed_official 0:51ac1d130fd4 1055 {
mbed_official 0:51ac1d130fd4 1056 (ni->ifoutucastpkts)++;
mbed_official 0:51ac1d130fd4 1057 }
mbed_official 0:51ac1d130fd4 1058
mbed_official 0:51ac1d130fd4 1059 void snmp_inc_ifoutnucastpkts(struct netif *ni)
mbed_official 0:51ac1d130fd4 1060 {
mbed_official 0:51ac1d130fd4 1061 (ni->ifoutnucastpkts)++;
mbed_official 0:51ac1d130fd4 1062 }
mbed_official 0:51ac1d130fd4 1063
mbed_official 0:51ac1d130fd4 1064 void snmp_inc_ifoutdiscards(struct netif *ni)
mbed_official 0:51ac1d130fd4 1065 {
mbed_official 0:51ac1d130fd4 1066 (ni->ifoutdiscards)++;
mbed_official 0:51ac1d130fd4 1067 }
mbed_official 0:51ac1d130fd4 1068
mbed_official 0:51ac1d130fd4 1069 void snmp_inc_iflist(void)
mbed_official 0:51ac1d130fd4 1070 {
mbed_official 0:51ac1d130fd4 1071 struct mib_list_node *if_node = NULL;
mbed_official 0:51ac1d130fd4 1072
mbed_official 0:51ac1d130fd4 1073 snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
mbed_official 0:51ac1d130fd4 1074 /* enable getnext traversal on filled table */
mbed_official 0:51ac1d130fd4 1075 iftable.maxlength = 1;
mbed_official 0:51ac1d130fd4 1076 }
mbed_official 0:51ac1d130fd4 1077
mbed_official 0:51ac1d130fd4 1078 void snmp_dec_iflist(void)
mbed_official 0:51ac1d130fd4 1079 {
mbed_official 0:51ac1d130fd4 1080 snmp_mib_node_delete(&iflist_root, iflist_root.tail);
mbed_official 0:51ac1d130fd4 1081 /* disable getnext traversal on empty table */
mbed_official 0:51ac1d130fd4 1082 if(iflist_root.count == 0) iftable.maxlength = 0;
mbed_official 0:51ac1d130fd4 1083 }
mbed_official 0:51ac1d130fd4 1084
mbed_official 0:51ac1d130fd4 1085 /**
mbed_official 0:51ac1d130fd4 1086 * Inserts ARP table indexes (.xIfIndex.xNetAddress)
mbed_official 0:51ac1d130fd4 1087 * into arp table index trees (both atTable and ipNetToMediaTable).
mbed_official 0:51ac1d130fd4 1088 */
mbed_official 0:51ac1d130fd4 1089 void snmp_insert_arpidx_tree(struct netif *ni, ip_addr_t *ip)
mbed_official 0:51ac1d130fd4 1090 {
mbed_official 0:51ac1d130fd4 1091 struct mib_list_rootnode *at_rn;
mbed_official 0:51ac1d130fd4 1092 struct mib_list_node *at_node;
mbed_official 0:51ac1d130fd4 1093 s32_t arpidx[5];
mbed_official 0:51ac1d130fd4 1094 u8_t level, tree;
mbed_official 0:51ac1d130fd4 1095
mbed_official 0:51ac1d130fd4 1096 LWIP_ASSERT("ni != NULL", ni != NULL);
mbed_official 0:51ac1d130fd4 1097 snmp_netiftoifindex(ni, &arpidx[0]);
mbed_official 0:51ac1d130fd4 1098 snmp_iptooid(ip, &arpidx[1]);
mbed_official 0:51ac1d130fd4 1099
mbed_official 0:51ac1d130fd4 1100 for (tree = 0; tree < 2; tree++)
mbed_official 0:51ac1d130fd4 1101 {
mbed_official 0:51ac1d130fd4 1102 if (tree == 0)
mbed_official 0:51ac1d130fd4 1103 {
mbed_official 0:51ac1d130fd4 1104 at_rn = &arptree_root;
mbed_official 0:51ac1d130fd4 1105 }
mbed_official 0:51ac1d130fd4 1106 else
mbed_official 0:51ac1d130fd4 1107 {
mbed_official 0:51ac1d130fd4 1108 at_rn = &ipntomtree_root;
mbed_official 0:51ac1d130fd4 1109 }
mbed_official 0:51ac1d130fd4 1110 for (level = 0; level < 5; level++)
mbed_official 0:51ac1d130fd4 1111 {
mbed_official 0:51ac1d130fd4 1112 at_node = NULL;
mbed_official 0:51ac1d130fd4 1113 snmp_mib_node_insert(at_rn, arpidx[level], &at_node);
mbed_official 0:51ac1d130fd4 1114 if ((level != 4) && (at_node != NULL))
mbed_official 0:51ac1d130fd4 1115 {
mbed_official 0:51ac1d130fd4 1116 if (at_node->nptr == NULL)
mbed_official 0:51ac1d130fd4 1117 {
mbed_official 0:51ac1d130fd4 1118 at_rn = snmp_mib_lrn_alloc();
mbed_official 0:51ac1d130fd4 1119 at_node->nptr = (struct mib_node*)at_rn;
mbed_official 0:51ac1d130fd4 1120 if (at_rn != NULL)
mbed_official 0:51ac1d130fd4 1121 {
mbed_official 0:51ac1d130fd4 1122 if (level == 3)
mbed_official 0:51ac1d130fd4 1123 {
mbed_official 0:51ac1d130fd4 1124 if (tree == 0)
mbed_official 0:51ac1d130fd4 1125 {
mbed_official 0:51ac1d130fd4 1126 at_rn->get_object_def = atentry_get_object_def;
mbed_official 0:51ac1d130fd4 1127 at_rn->get_value = atentry_get_value;
mbed_official 0:51ac1d130fd4 1128 }
mbed_official 0:51ac1d130fd4 1129 else
mbed_official 0:51ac1d130fd4 1130 {
mbed_official 0:51ac1d130fd4 1131 at_rn->get_object_def = ip_ntomentry_get_object_def;
mbed_official 0:51ac1d130fd4 1132 at_rn->get_value = ip_ntomentry_get_value;
mbed_official 0:51ac1d130fd4 1133 }
mbed_official 0:51ac1d130fd4 1134 at_rn->set_test = noleafs_set_test;
mbed_official 0:51ac1d130fd4 1135 at_rn->set_value = noleafs_set_value;
mbed_official 0:51ac1d130fd4 1136 }
mbed_official 0:51ac1d130fd4 1137 }
mbed_official 0:51ac1d130fd4 1138 else
mbed_official 0:51ac1d130fd4 1139 {
mbed_official 0:51ac1d130fd4 1140 /* at_rn == NULL, malloc failure */
mbed_official 0:51ac1d130fd4 1141 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_arpidx_tree() insert failed, mem full"));
mbed_official 0:51ac1d130fd4 1142 break;
mbed_official 0:51ac1d130fd4 1143 }
mbed_official 0:51ac1d130fd4 1144 }
mbed_official 0:51ac1d130fd4 1145 else
mbed_official 0:51ac1d130fd4 1146 {
mbed_official 0:51ac1d130fd4 1147 at_rn = (struct mib_list_rootnode*)at_node->nptr;
mbed_official 0:51ac1d130fd4 1148 }
mbed_official 0:51ac1d130fd4 1149 }
mbed_official 0:51ac1d130fd4 1150 }
mbed_official 0:51ac1d130fd4 1151 }
mbed_official 0:51ac1d130fd4 1152 /* enable getnext traversal on filled tables */
mbed_official 0:51ac1d130fd4 1153 at.maxlength = 1;
mbed_official 0:51ac1d130fd4 1154 ipntomtable.maxlength = 1;
mbed_official 0:51ac1d130fd4 1155 }
mbed_official 0:51ac1d130fd4 1156
mbed_official 0:51ac1d130fd4 1157 /**
mbed_official 0:51ac1d130fd4 1158 * Removes ARP table indexes (.xIfIndex.xNetAddress)
mbed_official 0:51ac1d130fd4 1159 * from arp table index trees.
mbed_official 0:51ac1d130fd4 1160 */
mbed_official 0:51ac1d130fd4 1161 void snmp_delete_arpidx_tree(struct netif *ni, ip_addr_t *ip)
mbed_official 0:51ac1d130fd4 1162 {
mbed_official 0:51ac1d130fd4 1163 struct mib_list_rootnode *at_rn, *next, *del_rn[5];
mbed_official 0:51ac1d130fd4 1164 struct mib_list_node *at_n, *del_n[5];
mbed_official 0:51ac1d130fd4 1165 s32_t arpidx[5];
mbed_official 0:51ac1d130fd4 1166 u8_t fc, tree, level, del_cnt;
mbed_official 0:51ac1d130fd4 1167
mbed_official 0:51ac1d130fd4 1168 snmp_netiftoifindex(ni, &arpidx[0]);
mbed_official 0:51ac1d130fd4 1169 snmp_iptooid(ip, &arpidx[1]);
mbed_official 0:51ac1d130fd4 1170
mbed_official 0:51ac1d130fd4 1171 for (tree = 0; tree < 2; tree++)
mbed_official 0:51ac1d130fd4 1172 {
mbed_official 0:51ac1d130fd4 1173 /* mark nodes for deletion */
mbed_official 0:51ac1d130fd4 1174 if (tree == 0)
mbed_official 0:51ac1d130fd4 1175 {
mbed_official 0:51ac1d130fd4 1176 at_rn = &arptree_root;
mbed_official 0:51ac1d130fd4 1177 }
mbed_official 0:51ac1d130fd4 1178 else
mbed_official 0:51ac1d130fd4 1179 {
mbed_official 0:51ac1d130fd4 1180 at_rn = &ipntomtree_root;
mbed_official 0:51ac1d130fd4 1181 }
mbed_official 0:51ac1d130fd4 1182 level = 0;
mbed_official 0:51ac1d130fd4 1183 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1184 while ((level < 5) && (at_rn != NULL))
mbed_official 0:51ac1d130fd4 1185 {
mbed_official 0:51ac1d130fd4 1186 fc = snmp_mib_node_find(at_rn, arpidx[level], &at_n);
mbed_official 0:51ac1d130fd4 1187 if (fc == 0)
mbed_official 0:51ac1d130fd4 1188 {
mbed_official 0:51ac1d130fd4 1189 /* arpidx[level] does not exist */
mbed_official 0:51ac1d130fd4 1190 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1191 at_rn = NULL;
mbed_official 0:51ac1d130fd4 1192 }
mbed_official 0:51ac1d130fd4 1193 else if (fc == 1)
mbed_official 0:51ac1d130fd4 1194 {
mbed_official 0:51ac1d130fd4 1195 del_rn[del_cnt] = at_rn;
mbed_official 0:51ac1d130fd4 1196 del_n[del_cnt] = at_n;
mbed_official 0:51ac1d130fd4 1197 del_cnt++;
mbed_official 0:51ac1d130fd4 1198 at_rn = (struct mib_list_rootnode*)(at_n->nptr);
mbed_official 0:51ac1d130fd4 1199 }
mbed_official 0:51ac1d130fd4 1200 else if (fc == 2)
mbed_official 0:51ac1d130fd4 1201 {
mbed_official 0:51ac1d130fd4 1202 /* reset delete (2 or more childs) */
mbed_official 0:51ac1d130fd4 1203 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1204 at_rn = (struct mib_list_rootnode*)(at_n->nptr);
mbed_official 0:51ac1d130fd4 1205 }
mbed_official 0:51ac1d130fd4 1206 level++;
mbed_official 0:51ac1d130fd4 1207 }
mbed_official 0:51ac1d130fd4 1208 /* delete marked index nodes */
mbed_official 0:51ac1d130fd4 1209 while (del_cnt > 0)
mbed_official 0:51ac1d130fd4 1210 {
mbed_official 0:51ac1d130fd4 1211 del_cnt--;
mbed_official 0:51ac1d130fd4 1212
mbed_official 0:51ac1d130fd4 1213 at_rn = del_rn[del_cnt];
mbed_official 0:51ac1d130fd4 1214 at_n = del_n[del_cnt];
mbed_official 0:51ac1d130fd4 1215
mbed_official 0:51ac1d130fd4 1216 next = snmp_mib_node_delete(at_rn, at_n);
mbed_official 0:51ac1d130fd4 1217 if (next != NULL)
mbed_official 0:51ac1d130fd4 1218 {
mbed_official 0:51ac1d130fd4 1219 LWIP_ASSERT("next_count == 0",next->count == 0);
mbed_official 0:51ac1d130fd4 1220 snmp_mib_lrn_free(next);
mbed_official 0:51ac1d130fd4 1221 }
mbed_official 0:51ac1d130fd4 1222 }
mbed_official 0:51ac1d130fd4 1223 }
mbed_official 0:51ac1d130fd4 1224 /* disable getnext traversal on empty tables */
mbed_official 0:51ac1d130fd4 1225 if(arptree_root.count == 0) at.maxlength = 0;
mbed_official 0:51ac1d130fd4 1226 if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0;
mbed_official 0:51ac1d130fd4 1227 }
mbed_official 0:51ac1d130fd4 1228
mbed_official 0:51ac1d130fd4 1229 void snmp_inc_ipinreceives(void)
mbed_official 0:51ac1d130fd4 1230 {
mbed_official 0:51ac1d130fd4 1231 ipinreceives++;
mbed_official 0:51ac1d130fd4 1232 }
mbed_official 0:51ac1d130fd4 1233
mbed_official 0:51ac1d130fd4 1234 void snmp_inc_ipinhdrerrors(void)
mbed_official 0:51ac1d130fd4 1235 {
mbed_official 0:51ac1d130fd4 1236 ipinhdrerrors++;
mbed_official 0:51ac1d130fd4 1237 }
mbed_official 0:51ac1d130fd4 1238
mbed_official 0:51ac1d130fd4 1239 void snmp_inc_ipinaddrerrors(void)
mbed_official 0:51ac1d130fd4 1240 {
mbed_official 0:51ac1d130fd4 1241 ipinaddrerrors++;
mbed_official 0:51ac1d130fd4 1242 }
mbed_official 0:51ac1d130fd4 1243
mbed_official 0:51ac1d130fd4 1244 void snmp_inc_ipforwdatagrams(void)
mbed_official 0:51ac1d130fd4 1245 {
mbed_official 0:51ac1d130fd4 1246 ipforwdatagrams++;
mbed_official 0:51ac1d130fd4 1247 }
mbed_official 0:51ac1d130fd4 1248
mbed_official 0:51ac1d130fd4 1249 void snmp_inc_ipinunknownprotos(void)
mbed_official 0:51ac1d130fd4 1250 {
mbed_official 0:51ac1d130fd4 1251 ipinunknownprotos++;
mbed_official 0:51ac1d130fd4 1252 }
mbed_official 0:51ac1d130fd4 1253
mbed_official 0:51ac1d130fd4 1254 void snmp_inc_ipindiscards(void)
mbed_official 0:51ac1d130fd4 1255 {
mbed_official 0:51ac1d130fd4 1256 ipindiscards++;
mbed_official 0:51ac1d130fd4 1257 }
mbed_official 0:51ac1d130fd4 1258
mbed_official 0:51ac1d130fd4 1259 void snmp_inc_ipindelivers(void)
mbed_official 0:51ac1d130fd4 1260 {
mbed_official 0:51ac1d130fd4 1261 ipindelivers++;
mbed_official 0:51ac1d130fd4 1262 }
mbed_official 0:51ac1d130fd4 1263
mbed_official 0:51ac1d130fd4 1264 void snmp_inc_ipoutrequests(void)
mbed_official 0:51ac1d130fd4 1265 {
mbed_official 0:51ac1d130fd4 1266 ipoutrequests++;
mbed_official 0:51ac1d130fd4 1267 }
mbed_official 0:51ac1d130fd4 1268
mbed_official 0:51ac1d130fd4 1269 void snmp_inc_ipoutdiscards(void)
mbed_official 0:51ac1d130fd4 1270 {
mbed_official 0:51ac1d130fd4 1271 ipoutdiscards++;
mbed_official 0:51ac1d130fd4 1272 }
mbed_official 0:51ac1d130fd4 1273
mbed_official 0:51ac1d130fd4 1274 void snmp_inc_ipoutnoroutes(void)
mbed_official 0:51ac1d130fd4 1275 {
mbed_official 0:51ac1d130fd4 1276 ipoutnoroutes++;
mbed_official 0:51ac1d130fd4 1277 }
mbed_official 0:51ac1d130fd4 1278
mbed_official 0:51ac1d130fd4 1279 void snmp_inc_ipreasmreqds(void)
mbed_official 0:51ac1d130fd4 1280 {
mbed_official 0:51ac1d130fd4 1281 ipreasmreqds++;
mbed_official 0:51ac1d130fd4 1282 }
mbed_official 0:51ac1d130fd4 1283
mbed_official 0:51ac1d130fd4 1284 void snmp_inc_ipreasmoks(void)
mbed_official 0:51ac1d130fd4 1285 {
mbed_official 0:51ac1d130fd4 1286 ipreasmoks++;
mbed_official 0:51ac1d130fd4 1287 }
mbed_official 0:51ac1d130fd4 1288
mbed_official 0:51ac1d130fd4 1289 void snmp_inc_ipreasmfails(void)
mbed_official 0:51ac1d130fd4 1290 {
mbed_official 0:51ac1d130fd4 1291 ipreasmfails++;
mbed_official 0:51ac1d130fd4 1292 }
mbed_official 0:51ac1d130fd4 1293
mbed_official 0:51ac1d130fd4 1294 void snmp_inc_ipfragoks(void)
mbed_official 0:51ac1d130fd4 1295 {
mbed_official 0:51ac1d130fd4 1296 ipfragoks++;
mbed_official 0:51ac1d130fd4 1297 }
mbed_official 0:51ac1d130fd4 1298
mbed_official 0:51ac1d130fd4 1299 void snmp_inc_ipfragfails(void)
mbed_official 0:51ac1d130fd4 1300 {
mbed_official 0:51ac1d130fd4 1301 ipfragfails++;
mbed_official 0:51ac1d130fd4 1302 }
mbed_official 0:51ac1d130fd4 1303
mbed_official 0:51ac1d130fd4 1304 void snmp_inc_ipfragcreates(void)
mbed_official 0:51ac1d130fd4 1305 {
mbed_official 0:51ac1d130fd4 1306 ipfragcreates++;
mbed_official 0:51ac1d130fd4 1307 }
mbed_official 0:51ac1d130fd4 1308
mbed_official 0:51ac1d130fd4 1309 void snmp_inc_iproutingdiscards(void)
mbed_official 0:51ac1d130fd4 1310 {
mbed_official 0:51ac1d130fd4 1311 iproutingdiscards++;
mbed_official 0:51ac1d130fd4 1312 }
mbed_official 0:51ac1d130fd4 1313
mbed_official 0:51ac1d130fd4 1314 /**
mbed_official 0:51ac1d130fd4 1315 * Inserts ipAddrTable indexes (.ipAdEntAddr)
mbed_official 0:51ac1d130fd4 1316 * into index tree.
mbed_official 0:51ac1d130fd4 1317 */
mbed_official 0:51ac1d130fd4 1318 void snmp_insert_ipaddridx_tree(struct netif *ni)
mbed_official 0:51ac1d130fd4 1319 {
mbed_official 0:51ac1d130fd4 1320 struct mib_list_rootnode *ipa_rn;
mbed_official 0:51ac1d130fd4 1321 struct mib_list_node *ipa_node;
mbed_official 0:51ac1d130fd4 1322 s32_t ipaddridx[4];
mbed_official 0:51ac1d130fd4 1323 u8_t level;
mbed_official 0:51ac1d130fd4 1324
mbed_official 0:51ac1d130fd4 1325 LWIP_ASSERT("ni != NULL", ni != NULL);
mbed_official 0:51ac1d130fd4 1326 snmp_iptooid(&ni->ip_addr, &ipaddridx[0]);
mbed_official 0:51ac1d130fd4 1327
mbed_official 0:51ac1d130fd4 1328 level = 0;
mbed_official 0:51ac1d130fd4 1329 ipa_rn = &ipaddrtree_root;
mbed_official 0:51ac1d130fd4 1330 while (level < 4)
mbed_official 0:51ac1d130fd4 1331 {
mbed_official 0:51ac1d130fd4 1332 ipa_node = NULL;
mbed_official 0:51ac1d130fd4 1333 snmp_mib_node_insert(ipa_rn, ipaddridx[level], &ipa_node);
mbed_official 0:51ac1d130fd4 1334 if ((level != 3) && (ipa_node != NULL))
mbed_official 0:51ac1d130fd4 1335 {
mbed_official 0:51ac1d130fd4 1336 if (ipa_node->nptr == NULL)
mbed_official 0:51ac1d130fd4 1337 {
mbed_official 0:51ac1d130fd4 1338 ipa_rn = snmp_mib_lrn_alloc();
mbed_official 0:51ac1d130fd4 1339 ipa_node->nptr = (struct mib_node*)ipa_rn;
mbed_official 0:51ac1d130fd4 1340 if (ipa_rn != NULL)
mbed_official 0:51ac1d130fd4 1341 {
mbed_official 0:51ac1d130fd4 1342 if (level == 2)
mbed_official 0:51ac1d130fd4 1343 {
mbed_official 0:51ac1d130fd4 1344 ipa_rn->get_object_def = ip_addrentry_get_object_def;
mbed_official 0:51ac1d130fd4 1345 ipa_rn->get_value = ip_addrentry_get_value;
mbed_official 0:51ac1d130fd4 1346 ipa_rn->set_test = noleafs_set_test;
mbed_official 0:51ac1d130fd4 1347 ipa_rn->set_value = noleafs_set_value;
mbed_official 0:51ac1d130fd4 1348 }
mbed_official 0:51ac1d130fd4 1349 }
mbed_official 0:51ac1d130fd4 1350 else
mbed_official 0:51ac1d130fd4 1351 {
mbed_official 0:51ac1d130fd4 1352 /* ipa_rn == NULL, malloc failure */
mbed_official 0:51ac1d130fd4 1353 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_ipaddridx_tree() insert failed, mem full"));
mbed_official 0:51ac1d130fd4 1354 break;
mbed_official 0:51ac1d130fd4 1355 }
mbed_official 0:51ac1d130fd4 1356 }
mbed_official 0:51ac1d130fd4 1357 else
mbed_official 0:51ac1d130fd4 1358 {
mbed_official 0:51ac1d130fd4 1359 ipa_rn = (struct mib_list_rootnode*)ipa_node->nptr;
mbed_official 0:51ac1d130fd4 1360 }
mbed_official 0:51ac1d130fd4 1361 }
mbed_official 0:51ac1d130fd4 1362 level++;
mbed_official 0:51ac1d130fd4 1363 }
mbed_official 0:51ac1d130fd4 1364 /* enable getnext traversal on filled table */
mbed_official 0:51ac1d130fd4 1365 ipaddrtable.maxlength = 1;
mbed_official 0:51ac1d130fd4 1366 }
mbed_official 0:51ac1d130fd4 1367
mbed_official 0:51ac1d130fd4 1368 /**
mbed_official 0:51ac1d130fd4 1369 * Removes ipAddrTable indexes (.ipAdEntAddr)
mbed_official 0:51ac1d130fd4 1370 * from index tree.
mbed_official 0:51ac1d130fd4 1371 */
mbed_official 0:51ac1d130fd4 1372 void snmp_delete_ipaddridx_tree(struct netif *ni)
mbed_official 0:51ac1d130fd4 1373 {
mbed_official 0:51ac1d130fd4 1374 struct mib_list_rootnode *ipa_rn, *next, *del_rn[4];
mbed_official 0:51ac1d130fd4 1375 struct mib_list_node *ipa_n, *del_n[4];
mbed_official 0:51ac1d130fd4 1376 s32_t ipaddridx[4];
mbed_official 0:51ac1d130fd4 1377 u8_t fc, level, del_cnt;
mbed_official 0:51ac1d130fd4 1378
mbed_official 0:51ac1d130fd4 1379 LWIP_ASSERT("ni != NULL", ni != NULL);
mbed_official 0:51ac1d130fd4 1380 snmp_iptooid(&ni->ip_addr, &ipaddridx[0]);
mbed_official 0:51ac1d130fd4 1381
mbed_official 0:51ac1d130fd4 1382 /* mark nodes for deletion */
mbed_official 0:51ac1d130fd4 1383 level = 0;
mbed_official 0:51ac1d130fd4 1384 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1385 ipa_rn = &ipaddrtree_root;
mbed_official 0:51ac1d130fd4 1386 while ((level < 4) && (ipa_rn != NULL))
mbed_official 0:51ac1d130fd4 1387 {
mbed_official 0:51ac1d130fd4 1388 fc = snmp_mib_node_find(ipa_rn, ipaddridx[level], &ipa_n);
mbed_official 0:51ac1d130fd4 1389 if (fc == 0)
mbed_official 0:51ac1d130fd4 1390 {
mbed_official 0:51ac1d130fd4 1391 /* ipaddridx[level] does not exist */
mbed_official 0:51ac1d130fd4 1392 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1393 ipa_rn = NULL;
mbed_official 0:51ac1d130fd4 1394 }
mbed_official 0:51ac1d130fd4 1395 else if (fc == 1)
mbed_official 0:51ac1d130fd4 1396 {
mbed_official 0:51ac1d130fd4 1397 del_rn[del_cnt] = ipa_rn;
mbed_official 0:51ac1d130fd4 1398 del_n[del_cnt] = ipa_n;
mbed_official 0:51ac1d130fd4 1399 del_cnt++;
mbed_official 0:51ac1d130fd4 1400 ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
mbed_official 0:51ac1d130fd4 1401 }
mbed_official 0:51ac1d130fd4 1402 else if (fc == 2)
mbed_official 0:51ac1d130fd4 1403 {
mbed_official 0:51ac1d130fd4 1404 /* reset delete (2 or more childs) */
mbed_official 0:51ac1d130fd4 1405 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1406 ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
mbed_official 0:51ac1d130fd4 1407 }
mbed_official 0:51ac1d130fd4 1408 level++;
mbed_official 0:51ac1d130fd4 1409 }
mbed_official 0:51ac1d130fd4 1410 /* delete marked index nodes */
mbed_official 0:51ac1d130fd4 1411 while (del_cnt > 0)
mbed_official 0:51ac1d130fd4 1412 {
mbed_official 0:51ac1d130fd4 1413 del_cnt--;
mbed_official 0:51ac1d130fd4 1414
mbed_official 0:51ac1d130fd4 1415 ipa_rn = del_rn[del_cnt];
mbed_official 0:51ac1d130fd4 1416 ipa_n = del_n[del_cnt];
mbed_official 0:51ac1d130fd4 1417
mbed_official 0:51ac1d130fd4 1418 next = snmp_mib_node_delete(ipa_rn, ipa_n);
mbed_official 0:51ac1d130fd4 1419 if (next != NULL)
mbed_official 0:51ac1d130fd4 1420 {
mbed_official 0:51ac1d130fd4 1421 LWIP_ASSERT("next_count == 0",next->count == 0);
mbed_official 0:51ac1d130fd4 1422 snmp_mib_lrn_free(next);
mbed_official 0:51ac1d130fd4 1423 }
mbed_official 0:51ac1d130fd4 1424 }
mbed_official 0:51ac1d130fd4 1425 /* disable getnext traversal on empty table */
mbed_official 0:51ac1d130fd4 1426 if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0;
mbed_official 0:51ac1d130fd4 1427 }
mbed_official 0:51ac1d130fd4 1428
mbed_official 0:51ac1d130fd4 1429 /**
mbed_official 0:51ac1d130fd4 1430 * Inserts ipRouteTable indexes (.ipRouteDest)
mbed_official 0:51ac1d130fd4 1431 * into index tree.
mbed_official 0:51ac1d130fd4 1432 *
mbed_official 0:51ac1d130fd4 1433 * @param dflt non-zero for the default rte, zero for network rte
mbed_official 0:51ac1d130fd4 1434 * @param ni points to network interface for this rte
mbed_official 0:51ac1d130fd4 1435 *
mbed_official 0:51ac1d130fd4 1436 * @todo record sysuptime for _this_ route when it is installed
mbed_official 0:51ac1d130fd4 1437 * (needed for ipRouteAge) in the netif.
mbed_official 0:51ac1d130fd4 1438 */
mbed_official 0:51ac1d130fd4 1439 void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
mbed_official 0:51ac1d130fd4 1440 {
mbed_official 0:51ac1d130fd4 1441 u8_t insert = 0;
mbed_official 0:51ac1d130fd4 1442 ip_addr_t dst;
mbed_official 0:51ac1d130fd4 1443
mbed_official 0:51ac1d130fd4 1444 if (dflt != 0)
mbed_official 0:51ac1d130fd4 1445 {
mbed_official 0:51ac1d130fd4 1446 /* the default route 0.0.0.0 */
mbed_official 0:51ac1d130fd4 1447 ip_addr_set_any(&dst);
mbed_official 0:51ac1d130fd4 1448 insert = 1;
mbed_official 0:51ac1d130fd4 1449 }
mbed_official 0:51ac1d130fd4 1450 else
mbed_official 0:51ac1d130fd4 1451 {
mbed_official 0:51ac1d130fd4 1452 /* route to the network address */
mbed_official 0:51ac1d130fd4 1453 ip_addr_get_network(&dst, &ni->ip_addr, &ni->netmask);
mbed_official 0:51ac1d130fd4 1454 /* exclude 0.0.0.0 network (reserved for default rte) */
mbed_official 0:51ac1d130fd4 1455 if (!ip_addr_isany(&dst)) {
mbed_official 0:51ac1d130fd4 1456 insert = 1;
mbed_official 0:51ac1d130fd4 1457 }
mbed_official 0:51ac1d130fd4 1458 }
mbed_official 0:51ac1d130fd4 1459 if (insert)
mbed_official 0:51ac1d130fd4 1460 {
mbed_official 0:51ac1d130fd4 1461 struct mib_list_rootnode *iprte_rn;
mbed_official 0:51ac1d130fd4 1462 struct mib_list_node *iprte_node;
mbed_official 0:51ac1d130fd4 1463 s32_t iprteidx[4];
mbed_official 0:51ac1d130fd4 1464 u8_t level;
mbed_official 0:51ac1d130fd4 1465
mbed_official 0:51ac1d130fd4 1466 snmp_iptooid(&dst, &iprteidx[0]);
mbed_official 0:51ac1d130fd4 1467 level = 0;
mbed_official 0:51ac1d130fd4 1468 iprte_rn = &iprtetree_root;
mbed_official 0:51ac1d130fd4 1469 while (level < 4)
mbed_official 0:51ac1d130fd4 1470 {
mbed_official 0:51ac1d130fd4 1471 iprte_node = NULL;
mbed_official 0:51ac1d130fd4 1472 snmp_mib_node_insert(iprte_rn, iprteidx[level], &iprte_node);
mbed_official 0:51ac1d130fd4 1473 if ((level != 3) && (iprte_node != NULL))
mbed_official 0:51ac1d130fd4 1474 {
mbed_official 0:51ac1d130fd4 1475 if (iprte_node->nptr == NULL)
mbed_official 0:51ac1d130fd4 1476 {
mbed_official 0:51ac1d130fd4 1477 iprte_rn = snmp_mib_lrn_alloc();
mbed_official 0:51ac1d130fd4 1478 iprte_node->nptr = (struct mib_node*)iprte_rn;
mbed_official 0:51ac1d130fd4 1479 if (iprte_rn != NULL)
mbed_official 0:51ac1d130fd4 1480 {
mbed_official 0:51ac1d130fd4 1481 if (level == 2)
mbed_official 0:51ac1d130fd4 1482 {
mbed_official 0:51ac1d130fd4 1483 iprte_rn->get_object_def = ip_rteentry_get_object_def;
mbed_official 0:51ac1d130fd4 1484 iprte_rn->get_value = ip_rteentry_get_value;
mbed_official 0:51ac1d130fd4 1485 iprte_rn->set_test = noleafs_set_test;
mbed_official 0:51ac1d130fd4 1486 iprte_rn->set_value = noleafs_set_value;
mbed_official 0:51ac1d130fd4 1487 }
mbed_official 0:51ac1d130fd4 1488 }
mbed_official 0:51ac1d130fd4 1489 else
mbed_official 0:51ac1d130fd4 1490 {
mbed_official 0:51ac1d130fd4 1491 /* iprte_rn == NULL, malloc failure */
mbed_official 0:51ac1d130fd4 1492 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_iprteidx_tree() insert failed, mem full"));
mbed_official 0:51ac1d130fd4 1493 break;
mbed_official 0:51ac1d130fd4 1494 }
mbed_official 0:51ac1d130fd4 1495 }
mbed_official 0:51ac1d130fd4 1496 else
mbed_official 0:51ac1d130fd4 1497 {
mbed_official 0:51ac1d130fd4 1498 iprte_rn = (struct mib_list_rootnode*)iprte_node->nptr;
mbed_official 0:51ac1d130fd4 1499 }
mbed_official 0:51ac1d130fd4 1500 }
mbed_official 0:51ac1d130fd4 1501 level++;
mbed_official 0:51ac1d130fd4 1502 }
mbed_official 0:51ac1d130fd4 1503 }
mbed_official 0:51ac1d130fd4 1504 /* enable getnext traversal on filled table */
mbed_official 0:51ac1d130fd4 1505 iprtetable.maxlength = 1;
mbed_official 0:51ac1d130fd4 1506 }
mbed_official 0:51ac1d130fd4 1507
mbed_official 0:51ac1d130fd4 1508 /**
mbed_official 0:51ac1d130fd4 1509 * Removes ipRouteTable indexes (.ipRouteDest)
mbed_official 0:51ac1d130fd4 1510 * from index tree.
mbed_official 0:51ac1d130fd4 1511 *
mbed_official 0:51ac1d130fd4 1512 * @param dflt non-zero for the default rte, zero for network rte
mbed_official 0:51ac1d130fd4 1513 * @param ni points to network interface for this rte or NULL
mbed_official 0:51ac1d130fd4 1514 * for default route to be removed.
mbed_official 0:51ac1d130fd4 1515 */
mbed_official 0:51ac1d130fd4 1516 void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
mbed_official 0:51ac1d130fd4 1517 {
mbed_official 0:51ac1d130fd4 1518 u8_t del = 0;
mbed_official 0:51ac1d130fd4 1519 ip_addr_t dst;
mbed_official 0:51ac1d130fd4 1520
mbed_official 0:51ac1d130fd4 1521 if (dflt != 0)
mbed_official 0:51ac1d130fd4 1522 {
mbed_official 0:51ac1d130fd4 1523 /* the default route 0.0.0.0 */
mbed_official 0:51ac1d130fd4 1524 ip_addr_set_any(&dst);
mbed_official 0:51ac1d130fd4 1525 del = 1;
mbed_official 0:51ac1d130fd4 1526 }
mbed_official 0:51ac1d130fd4 1527 else
mbed_official 0:51ac1d130fd4 1528 {
mbed_official 0:51ac1d130fd4 1529 /* route to the network address */
mbed_official 0:51ac1d130fd4 1530 ip_addr_get_network(&dst, &ni->ip_addr, &ni->netmask);
mbed_official 0:51ac1d130fd4 1531 /* exclude 0.0.0.0 network (reserved for default rte) */
mbed_official 0:51ac1d130fd4 1532 if (!ip_addr_isany(&dst)) {
mbed_official 0:51ac1d130fd4 1533 del = 1;
mbed_official 0:51ac1d130fd4 1534 }
mbed_official 0:51ac1d130fd4 1535 }
mbed_official 0:51ac1d130fd4 1536 if (del)
mbed_official 0:51ac1d130fd4 1537 {
mbed_official 0:51ac1d130fd4 1538 struct mib_list_rootnode *iprte_rn, *next, *del_rn[4];
mbed_official 0:51ac1d130fd4 1539 struct mib_list_node *iprte_n, *del_n[4];
mbed_official 0:51ac1d130fd4 1540 s32_t iprteidx[4];
mbed_official 0:51ac1d130fd4 1541 u8_t fc, level, del_cnt;
mbed_official 0:51ac1d130fd4 1542
mbed_official 0:51ac1d130fd4 1543 snmp_iptooid(&dst, &iprteidx[0]);
mbed_official 0:51ac1d130fd4 1544 /* mark nodes for deletion */
mbed_official 0:51ac1d130fd4 1545 level = 0;
mbed_official 0:51ac1d130fd4 1546 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1547 iprte_rn = &iprtetree_root;
mbed_official 0:51ac1d130fd4 1548 while ((level < 4) && (iprte_rn != NULL))
mbed_official 0:51ac1d130fd4 1549 {
mbed_official 0:51ac1d130fd4 1550 fc = snmp_mib_node_find(iprte_rn, iprteidx[level], &iprte_n);
mbed_official 0:51ac1d130fd4 1551 if (fc == 0)
mbed_official 0:51ac1d130fd4 1552 {
mbed_official 0:51ac1d130fd4 1553 /* iprteidx[level] does not exist */
mbed_official 0:51ac1d130fd4 1554 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1555 iprte_rn = NULL;
mbed_official 0:51ac1d130fd4 1556 }
mbed_official 0:51ac1d130fd4 1557 else if (fc == 1)
mbed_official 0:51ac1d130fd4 1558 {
mbed_official 0:51ac1d130fd4 1559 del_rn[del_cnt] = iprte_rn;
mbed_official 0:51ac1d130fd4 1560 del_n[del_cnt] = iprte_n;
mbed_official 0:51ac1d130fd4 1561 del_cnt++;
mbed_official 0:51ac1d130fd4 1562 iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
mbed_official 0:51ac1d130fd4 1563 }
mbed_official 0:51ac1d130fd4 1564 else if (fc == 2)
mbed_official 0:51ac1d130fd4 1565 {
mbed_official 0:51ac1d130fd4 1566 /* reset delete (2 or more childs) */
mbed_official 0:51ac1d130fd4 1567 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1568 iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
mbed_official 0:51ac1d130fd4 1569 }
mbed_official 0:51ac1d130fd4 1570 level++;
mbed_official 0:51ac1d130fd4 1571 }
mbed_official 0:51ac1d130fd4 1572 /* delete marked index nodes */
mbed_official 0:51ac1d130fd4 1573 while (del_cnt > 0)
mbed_official 0:51ac1d130fd4 1574 {
mbed_official 0:51ac1d130fd4 1575 del_cnt--;
mbed_official 0:51ac1d130fd4 1576
mbed_official 0:51ac1d130fd4 1577 iprte_rn = del_rn[del_cnt];
mbed_official 0:51ac1d130fd4 1578 iprte_n = del_n[del_cnt];
mbed_official 0:51ac1d130fd4 1579
mbed_official 0:51ac1d130fd4 1580 next = snmp_mib_node_delete(iprte_rn, iprte_n);
mbed_official 0:51ac1d130fd4 1581 if (next != NULL)
mbed_official 0:51ac1d130fd4 1582 {
mbed_official 0:51ac1d130fd4 1583 LWIP_ASSERT("next_count == 0",next->count == 0);
mbed_official 0:51ac1d130fd4 1584 snmp_mib_lrn_free(next);
mbed_official 0:51ac1d130fd4 1585 }
mbed_official 0:51ac1d130fd4 1586 }
mbed_official 0:51ac1d130fd4 1587 }
mbed_official 0:51ac1d130fd4 1588 /* disable getnext traversal on empty table */
mbed_official 0:51ac1d130fd4 1589 if (iprtetree_root.count == 0) iprtetable.maxlength = 0;
mbed_official 0:51ac1d130fd4 1590 }
mbed_official 0:51ac1d130fd4 1591
mbed_official 0:51ac1d130fd4 1592
mbed_official 0:51ac1d130fd4 1593 void snmp_inc_icmpinmsgs(void)
mbed_official 0:51ac1d130fd4 1594 {
mbed_official 0:51ac1d130fd4 1595 icmpinmsgs++;
mbed_official 0:51ac1d130fd4 1596 }
mbed_official 0:51ac1d130fd4 1597
mbed_official 0:51ac1d130fd4 1598 void snmp_inc_icmpinerrors(void)
mbed_official 0:51ac1d130fd4 1599 {
mbed_official 0:51ac1d130fd4 1600 icmpinerrors++;
mbed_official 0:51ac1d130fd4 1601 }
mbed_official 0:51ac1d130fd4 1602
mbed_official 0:51ac1d130fd4 1603 void snmp_inc_icmpindestunreachs(void)
mbed_official 0:51ac1d130fd4 1604 {
mbed_official 0:51ac1d130fd4 1605 icmpindestunreachs++;
mbed_official 0:51ac1d130fd4 1606 }
mbed_official 0:51ac1d130fd4 1607
mbed_official 0:51ac1d130fd4 1608 void snmp_inc_icmpintimeexcds(void)
mbed_official 0:51ac1d130fd4 1609 {
mbed_official 0:51ac1d130fd4 1610 icmpintimeexcds++;
mbed_official 0:51ac1d130fd4 1611 }
mbed_official 0:51ac1d130fd4 1612
mbed_official 0:51ac1d130fd4 1613 void snmp_inc_icmpinparmprobs(void)
mbed_official 0:51ac1d130fd4 1614 {
mbed_official 0:51ac1d130fd4 1615 icmpinparmprobs++;
mbed_official 0:51ac1d130fd4 1616 }
mbed_official 0:51ac1d130fd4 1617
mbed_official 0:51ac1d130fd4 1618 void snmp_inc_icmpinsrcquenchs(void)
mbed_official 0:51ac1d130fd4 1619 {
mbed_official 0:51ac1d130fd4 1620 icmpinsrcquenchs++;
mbed_official 0:51ac1d130fd4 1621 }
mbed_official 0:51ac1d130fd4 1622
mbed_official 0:51ac1d130fd4 1623 void snmp_inc_icmpinredirects(void)
mbed_official 0:51ac1d130fd4 1624 {
mbed_official 0:51ac1d130fd4 1625 icmpinredirects++;
mbed_official 0:51ac1d130fd4 1626 }
mbed_official 0:51ac1d130fd4 1627
mbed_official 0:51ac1d130fd4 1628 void snmp_inc_icmpinechos(void)
mbed_official 0:51ac1d130fd4 1629 {
mbed_official 0:51ac1d130fd4 1630 icmpinechos++;
mbed_official 0:51ac1d130fd4 1631 }
mbed_official 0:51ac1d130fd4 1632
mbed_official 0:51ac1d130fd4 1633 void snmp_inc_icmpinechoreps(void)
mbed_official 0:51ac1d130fd4 1634 {
mbed_official 0:51ac1d130fd4 1635 icmpinechoreps++;
mbed_official 0:51ac1d130fd4 1636 }
mbed_official 0:51ac1d130fd4 1637
mbed_official 0:51ac1d130fd4 1638 void snmp_inc_icmpintimestamps(void)
mbed_official 0:51ac1d130fd4 1639 {
mbed_official 0:51ac1d130fd4 1640 icmpintimestamps++;
mbed_official 0:51ac1d130fd4 1641 }
mbed_official 0:51ac1d130fd4 1642
mbed_official 0:51ac1d130fd4 1643 void snmp_inc_icmpintimestampreps(void)
mbed_official 0:51ac1d130fd4 1644 {
mbed_official 0:51ac1d130fd4 1645 icmpintimestampreps++;
mbed_official 0:51ac1d130fd4 1646 }
mbed_official 0:51ac1d130fd4 1647
mbed_official 0:51ac1d130fd4 1648 void snmp_inc_icmpinaddrmasks(void)
mbed_official 0:51ac1d130fd4 1649 {
mbed_official 0:51ac1d130fd4 1650 icmpinaddrmasks++;
mbed_official 0:51ac1d130fd4 1651 }
mbed_official 0:51ac1d130fd4 1652
mbed_official 0:51ac1d130fd4 1653 void snmp_inc_icmpinaddrmaskreps(void)
mbed_official 0:51ac1d130fd4 1654 {
mbed_official 0:51ac1d130fd4 1655 icmpinaddrmaskreps++;
mbed_official 0:51ac1d130fd4 1656 }
mbed_official 0:51ac1d130fd4 1657
mbed_official 0:51ac1d130fd4 1658 void snmp_inc_icmpoutmsgs(void)
mbed_official 0:51ac1d130fd4 1659 {
mbed_official 0:51ac1d130fd4 1660 icmpoutmsgs++;
mbed_official 0:51ac1d130fd4 1661 }
mbed_official 0:51ac1d130fd4 1662
mbed_official 0:51ac1d130fd4 1663 void snmp_inc_icmpouterrors(void)
mbed_official 0:51ac1d130fd4 1664 {
mbed_official 0:51ac1d130fd4 1665 icmpouterrors++;
mbed_official 0:51ac1d130fd4 1666 }
mbed_official 0:51ac1d130fd4 1667
mbed_official 0:51ac1d130fd4 1668 void snmp_inc_icmpoutdestunreachs(void)
mbed_official 0:51ac1d130fd4 1669 {
mbed_official 0:51ac1d130fd4 1670 icmpoutdestunreachs++;
mbed_official 0:51ac1d130fd4 1671 }
mbed_official 0:51ac1d130fd4 1672
mbed_official 0:51ac1d130fd4 1673 void snmp_inc_icmpouttimeexcds(void)
mbed_official 0:51ac1d130fd4 1674 {
mbed_official 0:51ac1d130fd4 1675 icmpouttimeexcds++;
mbed_official 0:51ac1d130fd4 1676 }
mbed_official 0:51ac1d130fd4 1677
mbed_official 0:51ac1d130fd4 1678 void snmp_inc_icmpoutparmprobs(void)
mbed_official 0:51ac1d130fd4 1679 {
mbed_official 0:51ac1d130fd4 1680 icmpoutparmprobs++;
mbed_official 0:51ac1d130fd4 1681 }
mbed_official 0:51ac1d130fd4 1682
mbed_official 0:51ac1d130fd4 1683 void snmp_inc_icmpoutsrcquenchs(void)
mbed_official 0:51ac1d130fd4 1684 {
mbed_official 0:51ac1d130fd4 1685 icmpoutsrcquenchs++;
mbed_official 0:51ac1d130fd4 1686 }
mbed_official 0:51ac1d130fd4 1687
mbed_official 0:51ac1d130fd4 1688 void snmp_inc_icmpoutredirects(void)
mbed_official 0:51ac1d130fd4 1689 {
mbed_official 0:51ac1d130fd4 1690 icmpoutredirects++;
mbed_official 0:51ac1d130fd4 1691 }
mbed_official 0:51ac1d130fd4 1692
mbed_official 0:51ac1d130fd4 1693 void snmp_inc_icmpoutechos(void)
mbed_official 0:51ac1d130fd4 1694 {
mbed_official 0:51ac1d130fd4 1695 icmpoutechos++;
mbed_official 0:51ac1d130fd4 1696 }
mbed_official 0:51ac1d130fd4 1697
mbed_official 0:51ac1d130fd4 1698 void snmp_inc_icmpoutechoreps(void)
mbed_official 0:51ac1d130fd4 1699 {
mbed_official 0:51ac1d130fd4 1700 icmpoutechoreps++;
mbed_official 0:51ac1d130fd4 1701 }
mbed_official 0:51ac1d130fd4 1702
mbed_official 0:51ac1d130fd4 1703 void snmp_inc_icmpouttimestamps(void)
mbed_official 0:51ac1d130fd4 1704 {
mbed_official 0:51ac1d130fd4 1705 icmpouttimestamps++;
mbed_official 0:51ac1d130fd4 1706 }
mbed_official 0:51ac1d130fd4 1707
mbed_official 0:51ac1d130fd4 1708 void snmp_inc_icmpouttimestampreps(void)
mbed_official 0:51ac1d130fd4 1709 {
mbed_official 0:51ac1d130fd4 1710 icmpouttimestampreps++;
mbed_official 0:51ac1d130fd4 1711 }
mbed_official 0:51ac1d130fd4 1712
mbed_official 0:51ac1d130fd4 1713 void snmp_inc_icmpoutaddrmasks(void)
mbed_official 0:51ac1d130fd4 1714 {
mbed_official 0:51ac1d130fd4 1715 icmpoutaddrmasks++;
mbed_official 0:51ac1d130fd4 1716 }
mbed_official 0:51ac1d130fd4 1717
mbed_official 0:51ac1d130fd4 1718 void snmp_inc_icmpoutaddrmaskreps(void)
mbed_official 0:51ac1d130fd4 1719 {
mbed_official 0:51ac1d130fd4 1720 icmpoutaddrmaskreps++;
mbed_official 0:51ac1d130fd4 1721 }
mbed_official 0:51ac1d130fd4 1722
mbed_official 0:51ac1d130fd4 1723 void snmp_inc_tcpactiveopens(void)
mbed_official 0:51ac1d130fd4 1724 {
mbed_official 0:51ac1d130fd4 1725 tcpactiveopens++;
mbed_official 0:51ac1d130fd4 1726 }
mbed_official 0:51ac1d130fd4 1727
mbed_official 0:51ac1d130fd4 1728 void snmp_inc_tcppassiveopens(void)
mbed_official 0:51ac1d130fd4 1729 {
mbed_official 0:51ac1d130fd4 1730 tcppassiveopens++;
mbed_official 0:51ac1d130fd4 1731 }
mbed_official 0:51ac1d130fd4 1732
mbed_official 0:51ac1d130fd4 1733 void snmp_inc_tcpattemptfails(void)
mbed_official 0:51ac1d130fd4 1734 {
mbed_official 0:51ac1d130fd4 1735 tcpattemptfails++;
mbed_official 0:51ac1d130fd4 1736 }
mbed_official 0:51ac1d130fd4 1737
mbed_official 0:51ac1d130fd4 1738 void snmp_inc_tcpestabresets(void)
mbed_official 0:51ac1d130fd4 1739 {
mbed_official 0:51ac1d130fd4 1740 tcpestabresets++;
mbed_official 0:51ac1d130fd4 1741 }
mbed_official 0:51ac1d130fd4 1742
mbed_official 0:51ac1d130fd4 1743 void snmp_inc_tcpinsegs(void)
mbed_official 0:51ac1d130fd4 1744 {
mbed_official 0:51ac1d130fd4 1745 tcpinsegs++;
mbed_official 0:51ac1d130fd4 1746 }
mbed_official 0:51ac1d130fd4 1747
mbed_official 0:51ac1d130fd4 1748 void snmp_inc_tcpoutsegs(void)
mbed_official 0:51ac1d130fd4 1749 {
mbed_official 0:51ac1d130fd4 1750 tcpoutsegs++;
mbed_official 0:51ac1d130fd4 1751 }
mbed_official 0:51ac1d130fd4 1752
mbed_official 0:51ac1d130fd4 1753 void snmp_inc_tcpretranssegs(void)
mbed_official 0:51ac1d130fd4 1754 {
mbed_official 0:51ac1d130fd4 1755 tcpretranssegs++;
mbed_official 0:51ac1d130fd4 1756 }
mbed_official 0:51ac1d130fd4 1757
mbed_official 0:51ac1d130fd4 1758 void snmp_inc_tcpinerrs(void)
mbed_official 0:51ac1d130fd4 1759 {
mbed_official 0:51ac1d130fd4 1760 tcpinerrs++;
mbed_official 0:51ac1d130fd4 1761 }
mbed_official 0:51ac1d130fd4 1762
mbed_official 0:51ac1d130fd4 1763 void snmp_inc_tcpoutrsts(void)
mbed_official 0:51ac1d130fd4 1764 {
mbed_official 0:51ac1d130fd4 1765 tcpoutrsts++;
mbed_official 0:51ac1d130fd4 1766 }
mbed_official 0:51ac1d130fd4 1767
mbed_official 0:51ac1d130fd4 1768 void snmp_inc_udpindatagrams(void)
mbed_official 0:51ac1d130fd4 1769 {
mbed_official 0:51ac1d130fd4 1770 udpindatagrams++;
mbed_official 0:51ac1d130fd4 1771 }
mbed_official 0:51ac1d130fd4 1772
mbed_official 0:51ac1d130fd4 1773 void snmp_inc_udpnoports(void)
mbed_official 0:51ac1d130fd4 1774 {
mbed_official 0:51ac1d130fd4 1775 udpnoports++;
mbed_official 0:51ac1d130fd4 1776 }
mbed_official 0:51ac1d130fd4 1777
mbed_official 0:51ac1d130fd4 1778 void snmp_inc_udpinerrors(void)
mbed_official 0:51ac1d130fd4 1779 {
mbed_official 0:51ac1d130fd4 1780 udpinerrors++;
mbed_official 0:51ac1d130fd4 1781 }
mbed_official 0:51ac1d130fd4 1782
mbed_official 0:51ac1d130fd4 1783 void snmp_inc_udpoutdatagrams(void)
mbed_official 0:51ac1d130fd4 1784 {
mbed_official 0:51ac1d130fd4 1785 udpoutdatagrams++;
mbed_official 0:51ac1d130fd4 1786 }
mbed_official 0:51ac1d130fd4 1787
mbed_official 0:51ac1d130fd4 1788 /**
mbed_official 0:51ac1d130fd4 1789 * Inserts udpTable indexes (.udpLocalAddress.udpLocalPort)
mbed_official 0:51ac1d130fd4 1790 * into index tree.
mbed_official 0:51ac1d130fd4 1791 */
mbed_official 0:51ac1d130fd4 1792 void snmp_insert_udpidx_tree(struct udp_pcb *pcb)
mbed_official 0:51ac1d130fd4 1793 {
mbed_official 0:51ac1d130fd4 1794 struct mib_list_rootnode *udp_rn;
mbed_official 0:51ac1d130fd4 1795 struct mib_list_node *udp_node;
mbed_official 0:51ac1d130fd4 1796 s32_t udpidx[5];
mbed_official 0:51ac1d130fd4 1797 u8_t level;
mbed_official 0:51ac1d130fd4 1798
mbed_official 0:51ac1d130fd4 1799 LWIP_ASSERT("pcb != NULL", pcb != NULL);
mbed_official 0:51ac1d130fd4 1800 snmp_iptooid(&pcb->local_ip, &udpidx[0]);
mbed_official 0:51ac1d130fd4 1801 udpidx[4] = pcb->local_port;
mbed_official 0:51ac1d130fd4 1802
mbed_official 0:51ac1d130fd4 1803 udp_rn = &udp_root;
mbed_official 0:51ac1d130fd4 1804 for (level = 0; level < 5; level++)
mbed_official 0:51ac1d130fd4 1805 {
mbed_official 0:51ac1d130fd4 1806 udp_node = NULL;
mbed_official 0:51ac1d130fd4 1807 snmp_mib_node_insert(udp_rn, udpidx[level], &udp_node);
mbed_official 0:51ac1d130fd4 1808 if ((level != 4) && (udp_node != NULL))
mbed_official 0:51ac1d130fd4 1809 {
mbed_official 0:51ac1d130fd4 1810 if (udp_node->nptr == NULL)
mbed_official 0:51ac1d130fd4 1811 {
mbed_official 0:51ac1d130fd4 1812 udp_rn = snmp_mib_lrn_alloc();
mbed_official 0:51ac1d130fd4 1813 udp_node->nptr = (struct mib_node*)udp_rn;
mbed_official 0:51ac1d130fd4 1814 if (udp_rn != NULL)
mbed_official 0:51ac1d130fd4 1815 {
mbed_official 0:51ac1d130fd4 1816 if (level == 3)
mbed_official 0:51ac1d130fd4 1817 {
mbed_official 0:51ac1d130fd4 1818 udp_rn->get_object_def = udpentry_get_object_def;
mbed_official 0:51ac1d130fd4 1819 udp_rn->get_value = udpentry_get_value;
mbed_official 0:51ac1d130fd4 1820 udp_rn->set_test = noleafs_set_test;
mbed_official 0:51ac1d130fd4 1821 udp_rn->set_value = noleafs_set_value;
mbed_official 0:51ac1d130fd4 1822 }
mbed_official 0:51ac1d130fd4 1823 }
mbed_official 0:51ac1d130fd4 1824 else
mbed_official 0:51ac1d130fd4 1825 {
mbed_official 0:51ac1d130fd4 1826 /* udp_rn == NULL, malloc failure */
mbed_official 0:51ac1d130fd4 1827 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_udpidx_tree() insert failed, mem full"));
mbed_official 0:51ac1d130fd4 1828 break;
mbed_official 0:51ac1d130fd4 1829 }
mbed_official 0:51ac1d130fd4 1830 }
mbed_official 0:51ac1d130fd4 1831 else
mbed_official 0:51ac1d130fd4 1832 {
mbed_official 0:51ac1d130fd4 1833 udp_rn = (struct mib_list_rootnode*)udp_node->nptr;
mbed_official 0:51ac1d130fd4 1834 }
mbed_official 0:51ac1d130fd4 1835 }
mbed_official 0:51ac1d130fd4 1836 }
mbed_official 0:51ac1d130fd4 1837 udptable.maxlength = 1;
mbed_official 0:51ac1d130fd4 1838 }
mbed_official 0:51ac1d130fd4 1839
mbed_official 0:51ac1d130fd4 1840 /**
mbed_official 0:51ac1d130fd4 1841 * Removes udpTable indexes (.udpLocalAddress.udpLocalPort)
mbed_official 0:51ac1d130fd4 1842 * from index tree.
mbed_official 0:51ac1d130fd4 1843 */
mbed_official 0:51ac1d130fd4 1844 void snmp_delete_udpidx_tree(struct udp_pcb *pcb)
mbed_official 0:51ac1d130fd4 1845 {
mbed_official 0:51ac1d130fd4 1846 struct udp_pcb *npcb;
mbed_official 0:51ac1d130fd4 1847 struct mib_list_rootnode *udp_rn, *next, *del_rn[5];
mbed_official 0:51ac1d130fd4 1848 struct mib_list_node *udp_n, *del_n[5];
mbed_official 0:51ac1d130fd4 1849 s32_t udpidx[5];
mbed_official 0:51ac1d130fd4 1850 u8_t bindings, fc, level, del_cnt;
mbed_official 0:51ac1d130fd4 1851
mbed_official 0:51ac1d130fd4 1852 LWIP_ASSERT("pcb != NULL", pcb != NULL);
mbed_official 0:51ac1d130fd4 1853 snmp_iptooid(&pcb->local_ip, &udpidx[0]);
mbed_official 0:51ac1d130fd4 1854 udpidx[4] = pcb->local_port;
mbed_official 0:51ac1d130fd4 1855
mbed_official 0:51ac1d130fd4 1856 /* count PCBs for a given binding
mbed_official 0:51ac1d130fd4 1857 (e.g. when reusing ports or for temp output PCBs) */
mbed_official 0:51ac1d130fd4 1858 bindings = 0;
mbed_official 0:51ac1d130fd4 1859 npcb = udp_pcbs;
mbed_official 0:51ac1d130fd4 1860 while ((npcb != NULL))
mbed_official 0:51ac1d130fd4 1861 {
mbed_official 0:51ac1d130fd4 1862 if (ip_addr_cmp(&npcb->local_ip, &pcb->local_ip) &&
mbed_official 0:51ac1d130fd4 1863 (npcb->local_port == udpidx[4]))
mbed_official 0:51ac1d130fd4 1864 {
mbed_official 0:51ac1d130fd4 1865 bindings++;
mbed_official 0:51ac1d130fd4 1866 }
mbed_official 0:51ac1d130fd4 1867 npcb = npcb->next;
mbed_official 0:51ac1d130fd4 1868 }
mbed_official 0:51ac1d130fd4 1869 if (bindings == 1)
mbed_official 0:51ac1d130fd4 1870 {
mbed_official 0:51ac1d130fd4 1871 /* selectively remove */
mbed_official 0:51ac1d130fd4 1872 /* mark nodes for deletion */
mbed_official 0:51ac1d130fd4 1873 level = 0;
mbed_official 0:51ac1d130fd4 1874 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1875 udp_rn = &udp_root;
mbed_official 0:51ac1d130fd4 1876 while ((level < 5) && (udp_rn != NULL))
mbed_official 0:51ac1d130fd4 1877 {
mbed_official 0:51ac1d130fd4 1878 fc = snmp_mib_node_find(udp_rn, udpidx[level], &udp_n);
mbed_official 0:51ac1d130fd4 1879 if (fc == 0)
mbed_official 0:51ac1d130fd4 1880 {
mbed_official 0:51ac1d130fd4 1881 /* udpidx[level] does not exist */
mbed_official 0:51ac1d130fd4 1882 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1883 udp_rn = NULL;
mbed_official 0:51ac1d130fd4 1884 }
mbed_official 0:51ac1d130fd4 1885 else if (fc == 1)
mbed_official 0:51ac1d130fd4 1886 {
mbed_official 0:51ac1d130fd4 1887 del_rn[del_cnt] = udp_rn;
mbed_official 0:51ac1d130fd4 1888 del_n[del_cnt] = udp_n;
mbed_official 0:51ac1d130fd4 1889 del_cnt++;
mbed_official 0:51ac1d130fd4 1890 udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
mbed_official 0:51ac1d130fd4 1891 }
mbed_official 0:51ac1d130fd4 1892 else if (fc == 2)
mbed_official 0:51ac1d130fd4 1893 {
mbed_official 0:51ac1d130fd4 1894 /* reset delete (2 or more childs) */
mbed_official 0:51ac1d130fd4 1895 del_cnt = 0;
mbed_official 0:51ac1d130fd4 1896 udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
mbed_official 0:51ac1d130fd4 1897 }
mbed_official 0:51ac1d130fd4 1898 level++;
mbed_official 0:51ac1d130fd4 1899 }
mbed_official 0:51ac1d130fd4 1900 /* delete marked index nodes */
mbed_official 0:51ac1d130fd4 1901 while (del_cnt > 0)
mbed_official 0:51ac1d130fd4 1902 {
mbed_official 0:51ac1d130fd4 1903 del_cnt--;
mbed_official 0:51ac1d130fd4 1904
mbed_official 0:51ac1d130fd4 1905 udp_rn = del_rn[del_cnt];
mbed_official 0:51ac1d130fd4 1906 udp_n = del_n[del_cnt];
mbed_official 0:51ac1d130fd4 1907
mbed_official 0:51ac1d130fd4 1908 next = snmp_mib_node_delete(udp_rn, udp_n);
mbed_official 0:51ac1d130fd4 1909 if (next != NULL)
mbed_official 0:51ac1d130fd4 1910 {
mbed_official 0:51ac1d130fd4 1911 LWIP_ASSERT("next_count == 0",next->count == 0);
mbed_official 0:51ac1d130fd4 1912 snmp_mib_lrn_free(next);
mbed_official 0:51ac1d130fd4 1913 }
mbed_official 0:51ac1d130fd4 1914 }
mbed_official 0:51ac1d130fd4 1915 }
mbed_official 0:51ac1d130fd4 1916 /* disable getnext traversal on empty table */
mbed_official 0:51ac1d130fd4 1917 if (udp_root.count == 0) udptable.maxlength = 0;
mbed_official 0:51ac1d130fd4 1918 }
mbed_official 0:51ac1d130fd4 1919
mbed_official 0:51ac1d130fd4 1920
mbed_official 0:51ac1d130fd4 1921 void snmp_inc_snmpinpkts(void)
mbed_official 0:51ac1d130fd4 1922 {
mbed_official 0:51ac1d130fd4 1923 snmpinpkts++;
mbed_official 0:51ac1d130fd4 1924 }
mbed_official 0:51ac1d130fd4 1925
mbed_official 0:51ac1d130fd4 1926 void snmp_inc_snmpoutpkts(void)
mbed_official 0:51ac1d130fd4 1927 {
mbed_official 0:51ac1d130fd4 1928 snmpoutpkts++;
mbed_official 0:51ac1d130fd4 1929 }
mbed_official 0:51ac1d130fd4 1930
mbed_official 0:51ac1d130fd4 1931 void snmp_inc_snmpinbadversions(void)
mbed_official 0:51ac1d130fd4 1932 {
mbed_official 0:51ac1d130fd4 1933 snmpinbadversions++;
mbed_official 0:51ac1d130fd4 1934 }
mbed_official 0:51ac1d130fd4 1935
mbed_official 0:51ac1d130fd4 1936 void snmp_inc_snmpinbadcommunitynames(void)
mbed_official 0:51ac1d130fd4 1937 {
mbed_official 0:51ac1d130fd4 1938 snmpinbadcommunitynames++;
mbed_official 0:51ac1d130fd4 1939 }
mbed_official 0:51ac1d130fd4 1940
mbed_official 0:51ac1d130fd4 1941 void snmp_inc_snmpinbadcommunityuses(void)
mbed_official 0:51ac1d130fd4 1942 {
mbed_official 0:51ac1d130fd4 1943 snmpinbadcommunityuses++;
mbed_official 0:51ac1d130fd4 1944 }
mbed_official 0:51ac1d130fd4 1945
mbed_official 0:51ac1d130fd4 1946 void snmp_inc_snmpinasnparseerrs(void)
mbed_official 0:51ac1d130fd4 1947 {
mbed_official 0:51ac1d130fd4 1948 snmpinasnparseerrs++;
mbed_official 0:51ac1d130fd4 1949 }
mbed_official 0:51ac1d130fd4 1950
mbed_official 0:51ac1d130fd4 1951 void snmp_inc_snmpintoobigs(void)
mbed_official 0:51ac1d130fd4 1952 {
mbed_official 0:51ac1d130fd4 1953 snmpintoobigs++;
mbed_official 0:51ac1d130fd4 1954 }
mbed_official 0:51ac1d130fd4 1955
mbed_official 0:51ac1d130fd4 1956 void snmp_inc_snmpinnosuchnames(void)
mbed_official 0:51ac1d130fd4 1957 {
mbed_official 0:51ac1d130fd4 1958 snmpinnosuchnames++;
mbed_official 0:51ac1d130fd4 1959 }
mbed_official 0:51ac1d130fd4 1960
mbed_official 0:51ac1d130fd4 1961 void snmp_inc_snmpinbadvalues(void)
mbed_official 0:51ac1d130fd4 1962 {
mbed_official 0:51ac1d130fd4 1963 snmpinbadvalues++;
mbed_official 0:51ac1d130fd4 1964 }
mbed_official 0:51ac1d130fd4 1965
mbed_official 0:51ac1d130fd4 1966 void snmp_inc_snmpinreadonlys(void)
mbed_official 0:51ac1d130fd4 1967 {
mbed_official 0:51ac1d130fd4 1968 snmpinreadonlys++;
mbed_official 0:51ac1d130fd4 1969 }
mbed_official 0:51ac1d130fd4 1970
mbed_official 0:51ac1d130fd4 1971 void snmp_inc_snmpingenerrs(void)
mbed_official 0:51ac1d130fd4 1972 {
mbed_official 0:51ac1d130fd4 1973 snmpingenerrs++;
mbed_official 0:51ac1d130fd4 1974 }
mbed_official 0:51ac1d130fd4 1975
mbed_official 0:51ac1d130fd4 1976 void snmp_add_snmpintotalreqvars(u8_t value)
mbed_official 0:51ac1d130fd4 1977 {
mbed_official 0:51ac1d130fd4 1978 snmpintotalreqvars += value;
mbed_official 0:51ac1d130fd4 1979 }
mbed_official 0:51ac1d130fd4 1980
mbed_official 0:51ac1d130fd4 1981 void snmp_add_snmpintotalsetvars(u8_t value)
mbed_official 0:51ac1d130fd4 1982 {
mbed_official 0:51ac1d130fd4 1983 snmpintotalsetvars += value;
mbed_official 0:51ac1d130fd4 1984 }
mbed_official 0:51ac1d130fd4 1985
mbed_official 0:51ac1d130fd4 1986 void snmp_inc_snmpingetrequests(void)
mbed_official 0:51ac1d130fd4 1987 {
mbed_official 0:51ac1d130fd4 1988 snmpingetrequests++;
mbed_official 0:51ac1d130fd4 1989 }
mbed_official 0:51ac1d130fd4 1990
mbed_official 0:51ac1d130fd4 1991 void snmp_inc_snmpingetnexts(void)
mbed_official 0:51ac1d130fd4 1992 {
mbed_official 0:51ac1d130fd4 1993 snmpingetnexts++;
mbed_official 0:51ac1d130fd4 1994 }
mbed_official 0:51ac1d130fd4 1995
mbed_official 0:51ac1d130fd4 1996 void snmp_inc_snmpinsetrequests(void)
mbed_official 0:51ac1d130fd4 1997 {
mbed_official 0:51ac1d130fd4 1998 snmpinsetrequests++;
mbed_official 0:51ac1d130fd4 1999 }
mbed_official 0:51ac1d130fd4 2000
mbed_official 0:51ac1d130fd4 2001 void snmp_inc_snmpingetresponses(void)
mbed_official 0:51ac1d130fd4 2002 {
mbed_official 0:51ac1d130fd4 2003 snmpingetresponses++;
mbed_official 0:51ac1d130fd4 2004 }
mbed_official 0:51ac1d130fd4 2005
mbed_official 0:51ac1d130fd4 2006 void snmp_inc_snmpintraps(void)
mbed_official 0:51ac1d130fd4 2007 {
mbed_official 0:51ac1d130fd4 2008 snmpintraps++;
mbed_official 0:51ac1d130fd4 2009 }
mbed_official 0:51ac1d130fd4 2010
mbed_official 0:51ac1d130fd4 2011 void snmp_inc_snmpouttoobigs(void)
mbed_official 0:51ac1d130fd4 2012 {
mbed_official 0:51ac1d130fd4 2013 snmpouttoobigs++;
mbed_official 0:51ac1d130fd4 2014 }
mbed_official 0:51ac1d130fd4 2015
mbed_official 0:51ac1d130fd4 2016 void snmp_inc_snmpoutnosuchnames(void)
mbed_official 0:51ac1d130fd4 2017 {
mbed_official 0:51ac1d130fd4 2018 snmpoutnosuchnames++;
mbed_official 0:51ac1d130fd4 2019 }
mbed_official 0:51ac1d130fd4 2020
mbed_official 0:51ac1d130fd4 2021 void snmp_inc_snmpoutbadvalues(void)
mbed_official 0:51ac1d130fd4 2022 {
mbed_official 0:51ac1d130fd4 2023 snmpoutbadvalues++;
mbed_official 0:51ac1d130fd4 2024 }
mbed_official 0:51ac1d130fd4 2025
mbed_official 0:51ac1d130fd4 2026 void snmp_inc_snmpoutgenerrs(void)
mbed_official 0:51ac1d130fd4 2027 {
mbed_official 0:51ac1d130fd4 2028 snmpoutgenerrs++;
mbed_official 0:51ac1d130fd4 2029 }
mbed_official 0:51ac1d130fd4 2030
mbed_official 0:51ac1d130fd4 2031 void snmp_inc_snmpoutgetrequests(void)
mbed_official 0:51ac1d130fd4 2032 {
mbed_official 0:51ac1d130fd4 2033 snmpoutgetrequests++;
mbed_official 0:51ac1d130fd4 2034 }
mbed_official 0:51ac1d130fd4 2035
mbed_official 0:51ac1d130fd4 2036 void snmp_inc_snmpoutgetnexts(void)
mbed_official 0:51ac1d130fd4 2037 {
mbed_official 0:51ac1d130fd4 2038 snmpoutgetnexts++;
mbed_official 0:51ac1d130fd4 2039 }
mbed_official 0:51ac1d130fd4 2040
mbed_official 0:51ac1d130fd4 2041 void snmp_inc_snmpoutsetrequests(void)
mbed_official 0:51ac1d130fd4 2042 {
mbed_official 0:51ac1d130fd4 2043 snmpoutsetrequests++;
mbed_official 0:51ac1d130fd4 2044 }
mbed_official 0:51ac1d130fd4 2045
mbed_official 0:51ac1d130fd4 2046 void snmp_inc_snmpoutgetresponses(void)
mbed_official 0:51ac1d130fd4 2047 {
mbed_official 0:51ac1d130fd4 2048 snmpoutgetresponses++;
mbed_official 0:51ac1d130fd4 2049 }
mbed_official 0:51ac1d130fd4 2050
mbed_official 0:51ac1d130fd4 2051 void snmp_inc_snmpouttraps(void)
mbed_official 0:51ac1d130fd4 2052 {
mbed_official 0:51ac1d130fd4 2053 snmpouttraps++;
mbed_official 0:51ac1d130fd4 2054 }
mbed_official 0:51ac1d130fd4 2055
mbed_official 0:51ac1d130fd4 2056 void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid)
mbed_official 0:51ac1d130fd4 2057 {
mbed_official 0:51ac1d130fd4 2058 *oid = &snmpgrp_id;
mbed_official 0:51ac1d130fd4 2059 }
mbed_official 0:51ac1d130fd4 2060
mbed_official 0:51ac1d130fd4 2061 void snmp_set_snmpenableauthentraps(u8_t *value)
mbed_official 0:51ac1d130fd4 2062 {
mbed_official 0:51ac1d130fd4 2063 if (value != NULL)
mbed_official 0:51ac1d130fd4 2064 {
mbed_official 0:51ac1d130fd4 2065 snmpenableauthentraps_ptr = value;
mbed_official 0:51ac1d130fd4 2066 }
mbed_official 0:51ac1d130fd4 2067 }
mbed_official 0:51ac1d130fd4 2068
mbed_official 0:51ac1d130fd4 2069 void snmp_get_snmpenableauthentraps(u8_t *value)
mbed_official 0:51ac1d130fd4 2070 {
mbed_official 0:51ac1d130fd4 2071 *value = *snmpenableauthentraps_ptr;
mbed_official 0:51ac1d130fd4 2072 }
mbed_official 0:51ac1d130fd4 2073
mbed_official 0:51ac1d130fd4 2074 void
mbed_official 0:51ac1d130fd4 2075 noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 2076 {
mbed_official 0:51ac1d130fd4 2077 LWIP_UNUSED_ARG(ident_len);
mbed_official 0:51ac1d130fd4 2078 LWIP_UNUSED_ARG(ident);
mbed_official 0:51ac1d130fd4 2079 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2080 }
mbed_official 0:51ac1d130fd4 2081
mbed_official 0:51ac1d130fd4 2082 void
mbed_official 0:51ac1d130fd4 2083 noleafs_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2084 {
mbed_official 0:51ac1d130fd4 2085 LWIP_UNUSED_ARG(od);
mbed_official 0:51ac1d130fd4 2086 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2087 LWIP_UNUSED_ARG(value);
mbed_official 0:51ac1d130fd4 2088 }
mbed_official 0:51ac1d130fd4 2089
mbed_official 0:51ac1d130fd4 2090 u8_t
mbed_official 0:51ac1d130fd4 2091 noleafs_set_test(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2092 {
mbed_official 0:51ac1d130fd4 2093 LWIP_UNUSED_ARG(od);
mbed_official 0:51ac1d130fd4 2094 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2095 LWIP_UNUSED_ARG(value);
mbed_official 0:51ac1d130fd4 2096 /* can't set */
mbed_official 0:51ac1d130fd4 2097 return 0;
mbed_official 0:51ac1d130fd4 2098 }
mbed_official 0:51ac1d130fd4 2099
mbed_official 0:51ac1d130fd4 2100 void
mbed_official 0:51ac1d130fd4 2101 noleafs_set_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2102 {
mbed_official 0:51ac1d130fd4 2103 LWIP_UNUSED_ARG(od);
mbed_official 0:51ac1d130fd4 2104 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2105 LWIP_UNUSED_ARG(value);
mbed_official 0:51ac1d130fd4 2106 }
mbed_official 0:51ac1d130fd4 2107
mbed_official 0:51ac1d130fd4 2108
mbed_official 0:51ac1d130fd4 2109 /**
mbed_official 0:51ac1d130fd4 2110 * Returns systems object definitions.
mbed_official 0:51ac1d130fd4 2111 *
mbed_official 0:51ac1d130fd4 2112 * @param ident_len the address length (2)
mbed_official 0:51ac1d130fd4 2113 * @param ident points to objectname.0 (object id trailer)
mbed_official 0:51ac1d130fd4 2114 * @param od points to object definition.
mbed_official 0:51ac1d130fd4 2115 */
mbed_official 0:51ac1d130fd4 2116 static void
mbed_official 0:51ac1d130fd4 2117 system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 2118 {
mbed_official 0:51ac1d130fd4 2119 u8_t id;
mbed_official 0:51ac1d130fd4 2120
mbed_official 0:51ac1d130fd4 2121 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 2122 ident_len += 1;
mbed_official 0:51ac1d130fd4 2123 ident -= 1;
mbed_official 0:51ac1d130fd4 2124 if (ident_len == 2)
mbed_official 0:51ac1d130fd4 2125 {
mbed_official 0:51ac1d130fd4 2126 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 2127 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 2128
mbed_official 0:51ac1d130fd4 2129 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2130 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 2131 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def system.%"U16_F".0\n",(u16_t)id));
mbed_official 0:51ac1d130fd4 2132 switch (id)
mbed_official 0:51ac1d130fd4 2133 {
mbed_official 0:51ac1d130fd4 2134 case 1: /* sysDescr */
mbed_official 0:51ac1d130fd4 2135 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2136 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2137 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2138 od->v_len = *sysdescr_len_ptr;
mbed_official 0:51ac1d130fd4 2139 break;
mbed_official 0:51ac1d130fd4 2140 case 2: /* sysObjectID */
mbed_official 0:51ac1d130fd4 2141 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2142 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2143 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
mbed_official 0:51ac1d130fd4 2144 od->v_len = sysobjid.len * sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2145 break;
mbed_official 0:51ac1d130fd4 2146 case 3: /* sysUpTime */
mbed_official 0:51ac1d130fd4 2147 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2148 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2149 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
mbed_official 0:51ac1d130fd4 2150 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 2151 break;
mbed_official 0:51ac1d130fd4 2152 case 4: /* sysContact */
mbed_official 0:51ac1d130fd4 2153 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2154 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2155 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2156 od->v_len = *syscontact_len_ptr;
mbed_official 0:51ac1d130fd4 2157 break;
mbed_official 0:51ac1d130fd4 2158 case 5: /* sysName */
mbed_official 0:51ac1d130fd4 2159 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2160 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2161 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2162 od->v_len = *sysname_len_ptr;
mbed_official 0:51ac1d130fd4 2163 break;
mbed_official 0:51ac1d130fd4 2164 case 6: /* sysLocation */
mbed_official 0:51ac1d130fd4 2165 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2166 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2167 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2168 od->v_len = *syslocation_len_ptr;
mbed_official 0:51ac1d130fd4 2169 break;
mbed_official 0:51ac1d130fd4 2170 case 7: /* sysServices */
mbed_official 0:51ac1d130fd4 2171 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2172 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2173 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2174 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2175 break;
mbed_official 0:51ac1d130fd4 2176 default:
mbed_official 0:51ac1d130fd4 2177 LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 2178 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2179 break;
mbed_official 0:51ac1d130fd4 2180 };
mbed_official 0:51ac1d130fd4 2181 }
mbed_official 0:51ac1d130fd4 2182 else
mbed_official 0:51ac1d130fd4 2183 {
mbed_official 0:51ac1d130fd4 2184 LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 2185 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2186 }
mbed_official 0:51ac1d130fd4 2187 }
mbed_official 0:51ac1d130fd4 2188
mbed_official 0:51ac1d130fd4 2189 /**
mbed_official 0:51ac1d130fd4 2190 * Returns system object value.
mbed_official 0:51ac1d130fd4 2191 *
mbed_official 0:51ac1d130fd4 2192 * @param ident_len the address length (2)
mbed_official 0:51ac1d130fd4 2193 * @param ident points to objectname.0 (object id trailer)
mbed_official 0:51ac1d130fd4 2194 * @param len return value space (in bytes)
mbed_official 0:51ac1d130fd4 2195 * @param value points to (varbind) space to copy value into.
mbed_official 0:51ac1d130fd4 2196 */
mbed_official 0:51ac1d130fd4 2197 static void
mbed_official 0:51ac1d130fd4 2198 system_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2199 {
mbed_official 0:51ac1d130fd4 2200 u8_t id;
mbed_official 0:51ac1d130fd4 2201
mbed_official 0:51ac1d130fd4 2202 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2203 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2204 switch (id)
mbed_official 0:51ac1d130fd4 2205 {
mbed_official 0:51ac1d130fd4 2206 case 1: /* sysDescr */
mbed_official 0:51ac1d130fd4 2207 ocstrncpy((u8_t*)value, sysdescr_ptr, len);
mbed_official 0:51ac1d130fd4 2208 break;
mbed_official 0:51ac1d130fd4 2209 case 2: /* sysObjectID */
mbed_official 0:51ac1d130fd4 2210 objectidncpy((s32_t*)value, (s32_t*)sysobjid.id, (u8_t)(len / sizeof(s32_t)));
mbed_official 0:51ac1d130fd4 2211 break;
mbed_official 0:51ac1d130fd4 2212 case 3: /* sysUpTime */
mbed_official 0:51ac1d130fd4 2213 {
mbed_official 0:51ac1d130fd4 2214 snmp_get_sysuptime((u32_t*)value);
mbed_official 0:51ac1d130fd4 2215 }
mbed_official 0:51ac1d130fd4 2216 break;
mbed_official 0:51ac1d130fd4 2217 case 4: /* sysContact */
mbed_official 0:51ac1d130fd4 2218 ocstrncpy((u8_t*)value, syscontact_ptr, len);
mbed_official 0:51ac1d130fd4 2219 break;
mbed_official 0:51ac1d130fd4 2220 case 5: /* sysName */
mbed_official 0:51ac1d130fd4 2221 ocstrncpy((u8_t*)value, sysname_ptr, len);
mbed_official 0:51ac1d130fd4 2222 break;
mbed_official 0:51ac1d130fd4 2223 case 6: /* sysLocation */
mbed_official 0:51ac1d130fd4 2224 ocstrncpy((u8_t*)value, syslocation_ptr, len);
mbed_official 0:51ac1d130fd4 2225 break;
mbed_official 0:51ac1d130fd4 2226 case 7: /* sysServices */
mbed_official 0:51ac1d130fd4 2227 {
mbed_official 0:51ac1d130fd4 2228 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2229 *sint_ptr = sysservices;
mbed_official 0:51ac1d130fd4 2230 }
mbed_official 0:51ac1d130fd4 2231 break;
mbed_official 0:51ac1d130fd4 2232 };
mbed_official 0:51ac1d130fd4 2233 }
mbed_official 0:51ac1d130fd4 2234
mbed_official 0:51ac1d130fd4 2235 static u8_t
mbed_official 0:51ac1d130fd4 2236 system_set_test(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2237 {
mbed_official 0:51ac1d130fd4 2238 u8_t id, set_ok;
mbed_official 0:51ac1d130fd4 2239
mbed_official 0:51ac1d130fd4 2240 LWIP_UNUSED_ARG(value);
mbed_official 0:51ac1d130fd4 2241 set_ok = 0;
mbed_official 0:51ac1d130fd4 2242 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2243 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2244 switch (id)
mbed_official 0:51ac1d130fd4 2245 {
mbed_official 0:51ac1d130fd4 2246 case 4: /* sysContact */
mbed_official 0:51ac1d130fd4 2247 if ((syscontact_ptr != syscontact_default) &&
mbed_official 0:51ac1d130fd4 2248 (len <= 255))
mbed_official 0:51ac1d130fd4 2249 {
mbed_official 0:51ac1d130fd4 2250 set_ok = 1;
mbed_official 0:51ac1d130fd4 2251 }
mbed_official 0:51ac1d130fd4 2252 break;
mbed_official 0:51ac1d130fd4 2253 case 5: /* sysName */
mbed_official 0:51ac1d130fd4 2254 if ((sysname_ptr != sysname_default) &&
mbed_official 0:51ac1d130fd4 2255 (len <= 255))
mbed_official 0:51ac1d130fd4 2256 {
mbed_official 0:51ac1d130fd4 2257 set_ok = 1;
mbed_official 0:51ac1d130fd4 2258 }
mbed_official 0:51ac1d130fd4 2259 break;
mbed_official 0:51ac1d130fd4 2260 case 6: /* sysLocation */
mbed_official 0:51ac1d130fd4 2261 if ((syslocation_ptr != syslocation_default) &&
mbed_official 0:51ac1d130fd4 2262 (len <= 255))
mbed_official 0:51ac1d130fd4 2263 {
mbed_official 0:51ac1d130fd4 2264 set_ok = 1;
mbed_official 0:51ac1d130fd4 2265 }
mbed_official 0:51ac1d130fd4 2266 break;
mbed_official 0:51ac1d130fd4 2267 };
mbed_official 0:51ac1d130fd4 2268 return set_ok;
mbed_official 0:51ac1d130fd4 2269 }
mbed_official 0:51ac1d130fd4 2270
mbed_official 0:51ac1d130fd4 2271 static void
mbed_official 0:51ac1d130fd4 2272 system_set_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2273 {
mbed_official 0:51ac1d130fd4 2274 u8_t id;
mbed_official 0:51ac1d130fd4 2275
mbed_official 0:51ac1d130fd4 2276 LWIP_ASSERT("invalid len", len <= 0xff);
mbed_official 0:51ac1d130fd4 2277 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2278 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2279 switch (id)
mbed_official 0:51ac1d130fd4 2280 {
mbed_official 0:51ac1d130fd4 2281 case 4: /* sysContact */
mbed_official 0:51ac1d130fd4 2282 ocstrncpy(syscontact_ptr, (u8_t*)value, len);
mbed_official 0:51ac1d130fd4 2283 *syscontact_len_ptr = (u8_t)len;
mbed_official 0:51ac1d130fd4 2284 break;
mbed_official 0:51ac1d130fd4 2285 case 5: /* sysName */
mbed_official 0:51ac1d130fd4 2286 ocstrncpy(sysname_ptr, (u8_t*)value, len);
mbed_official 0:51ac1d130fd4 2287 *sysname_len_ptr = (u8_t)len;
mbed_official 0:51ac1d130fd4 2288 break;
mbed_official 0:51ac1d130fd4 2289 case 6: /* sysLocation */
mbed_official 0:51ac1d130fd4 2290 ocstrncpy(syslocation_ptr, (u8_t*)value, len);
mbed_official 0:51ac1d130fd4 2291 *syslocation_len_ptr = (u8_t)len;
mbed_official 0:51ac1d130fd4 2292 break;
mbed_official 0:51ac1d130fd4 2293 };
mbed_official 0:51ac1d130fd4 2294 }
mbed_official 0:51ac1d130fd4 2295
mbed_official 0:51ac1d130fd4 2296 /**
mbed_official 0:51ac1d130fd4 2297 * Returns interfaces.ifnumber object definition.
mbed_official 0:51ac1d130fd4 2298 *
mbed_official 0:51ac1d130fd4 2299 * @param ident_len the address length (2)
mbed_official 0:51ac1d130fd4 2300 * @param ident points to objectname.index
mbed_official 0:51ac1d130fd4 2301 * @param od points to object definition.
mbed_official 0:51ac1d130fd4 2302 */
mbed_official 0:51ac1d130fd4 2303 static void
mbed_official 0:51ac1d130fd4 2304 interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 2305 {
mbed_official 0:51ac1d130fd4 2306 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 2307 ident_len += 1;
mbed_official 0:51ac1d130fd4 2308 ident -= 1;
mbed_official 0:51ac1d130fd4 2309 if (ident_len == 2)
mbed_official 0:51ac1d130fd4 2310 {
mbed_official 0:51ac1d130fd4 2311 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 2312 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 2313
mbed_official 0:51ac1d130fd4 2314 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2315 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2316 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2317 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2318 }
mbed_official 0:51ac1d130fd4 2319 else
mbed_official 0:51ac1d130fd4 2320 {
mbed_official 0:51ac1d130fd4 2321 LWIP_DEBUGF(SNMP_MIB_DEBUG,("interfaces_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 2322 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2323 }
mbed_official 0:51ac1d130fd4 2324 }
mbed_official 0:51ac1d130fd4 2325
mbed_official 0:51ac1d130fd4 2326 /**
mbed_official 0:51ac1d130fd4 2327 * Returns interfaces.ifnumber object value.
mbed_official 0:51ac1d130fd4 2328 *
mbed_official 0:51ac1d130fd4 2329 * @param ident_len the address length (2)
mbed_official 0:51ac1d130fd4 2330 * @param ident points to objectname.0 (object id trailer)
mbed_official 0:51ac1d130fd4 2331 * @param len return value space (in bytes)
mbed_official 0:51ac1d130fd4 2332 * @param value points to (varbind) space to copy value into.
mbed_official 0:51ac1d130fd4 2333 */
mbed_official 0:51ac1d130fd4 2334 static void
mbed_official 0:51ac1d130fd4 2335 interfaces_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2336 {
mbed_official 0:51ac1d130fd4 2337 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2338 if (od->id_inst_ptr[0] == 1)
mbed_official 0:51ac1d130fd4 2339 {
mbed_official 0:51ac1d130fd4 2340 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2341 *sint_ptr = iflist_root.count;
mbed_official 0:51ac1d130fd4 2342 }
mbed_official 0:51ac1d130fd4 2343 }
mbed_official 0:51ac1d130fd4 2344
mbed_official 0:51ac1d130fd4 2345 /**
mbed_official 0:51ac1d130fd4 2346 * Returns ifentry object definitions.
mbed_official 0:51ac1d130fd4 2347 *
mbed_official 0:51ac1d130fd4 2348 * @param ident_len the address length (2)
mbed_official 0:51ac1d130fd4 2349 * @param ident points to objectname.index
mbed_official 0:51ac1d130fd4 2350 * @param od points to object definition.
mbed_official 0:51ac1d130fd4 2351 */
mbed_official 0:51ac1d130fd4 2352 static void
mbed_official 0:51ac1d130fd4 2353 ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 2354 {
mbed_official 0:51ac1d130fd4 2355 u8_t id;
mbed_official 0:51ac1d130fd4 2356
mbed_official 0:51ac1d130fd4 2357 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 2358 ident_len += 1;
mbed_official 0:51ac1d130fd4 2359 ident -= 1;
mbed_official 0:51ac1d130fd4 2360 if (ident_len == 2)
mbed_official 0:51ac1d130fd4 2361 {
mbed_official 0:51ac1d130fd4 2362 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 2363 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 2364
mbed_official 0:51ac1d130fd4 2365 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2366 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 2367 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ifentry.%"U16_F"\n",(u16_t)id));
mbed_official 0:51ac1d130fd4 2368 switch (id)
mbed_official 0:51ac1d130fd4 2369 {
mbed_official 0:51ac1d130fd4 2370 case 1: /* ifIndex */
mbed_official 0:51ac1d130fd4 2371 case 3: /* ifType */
mbed_official 0:51ac1d130fd4 2372 case 4: /* ifMtu */
mbed_official 0:51ac1d130fd4 2373 case 8: /* ifOperStatus */
mbed_official 0:51ac1d130fd4 2374 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2375 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2376 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2377 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2378 break;
mbed_official 0:51ac1d130fd4 2379 case 2: /* ifDescr */
mbed_official 0:51ac1d130fd4 2380 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2381 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2382 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2383 /** @todo this should be some sort of sizeof(struct netif.name) */
mbed_official 0:51ac1d130fd4 2384 od->v_len = 2;
mbed_official 0:51ac1d130fd4 2385 break;
mbed_official 0:51ac1d130fd4 2386 case 5: /* ifSpeed */
mbed_official 0:51ac1d130fd4 2387 case 21: /* ifOutQLen */
mbed_official 0:51ac1d130fd4 2388 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2389 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2390 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
mbed_official 0:51ac1d130fd4 2391 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 2392 break;
mbed_official 0:51ac1d130fd4 2393 case 6: /* ifPhysAddress */
mbed_official 0:51ac1d130fd4 2394 {
mbed_official 0:51ac1d130fd4 2395 struct netif *netif;
mbed_official 0:51ac1d130fd4 2396
mbed_official 0:51ac1d130fd4 2397 snmp_ifindextonetif(ident[1], &netif);
mbed_official 0:51ac1d130fd4 2398 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2399 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2400 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2401 od->v_len = netif->hwaddr_len;
mbed_official 0:51ac1d130fd4 2402 }
mbed_official 0:51ac1d130fd4 2403 break;
mbed_official 0:51ac1d130fd4 2404 case 7: /* ifAdminStatus */
mbed_official 0:51ac1d130fd4 2405 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2406 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2407 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2408 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2409 break;
mbed_official 0:51ac1d130fd4 2410 case 9: /* ifLastChange */
mbed_official 0:51ac1d130fd4 2411 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2412 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2413 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
mbed_official 0:51ac1d130fd4 2414 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 2415 break;
mbed_official 0:51ac1d130fd4 2416 case 10: /* ifInOctets */
mbed_official 0:51ac1d130fd4 2417 case 11: /* ifInUcastPkts */
mbed_official 0:51ac1d130fd4 2418 case 12: /* ifInNUcastPkts */
mbed_official 0:51ac1d130fd4 2419 case 13: /* ifInDiscarts */
mbed_official 0:51ac1d130fd4 2420 case 14: /* ifInErrors */
mbed_official 0:51ac1d130fd4 2421 case 15: /* ifInUnkownProtos */
mbed_official 0:51ac1d130fd4 2422 case 16: /* ifOutOctets */
mbed_official 0:51ac1d130fd4 2423 case 17: /* ifOutUcastPkts */
mbed_official 0:51ac1d130fd4 2424 case 18: /* ifOutNUcastPkts */
mbed_official 0:51ac1d130fd4 2425 case 19: /* ifOutDiscarts */
mbed_official 0:51ac1d130fd4 2426 case 20: /* ifOutErrors */
mbed_official 0:51ac1d130fd4 2427 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2428 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2429 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
mbed_official 0:51ac1d130fd4 2430 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 2431 break;
mbed_official 0:51ac1d130fd4 2432 case 22: /* ifSpecific */
mbed_official 0:51ac1d130fd4 2433 /** @note returning zeroDotZero (0.0) no media specific MIB support */
mbed_official 0:51ac1d130fd4 2434 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2435 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2436 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
mbed_official 0:51ac1d130fd4 2437 od->v_len = ifspecific.len * sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2438 break;
mbed_official 0:51ac1d130fd4 2439 default:
mbed_official 0:51ac1d130fd4 2440 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 2441 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2442 break;
mbed_official 0:51ac1d130fd4 2443 };
mbed_official 0:51ac1d130fd4 2444 }
mbed_official 0:51ac1d130fd4 2445 else
mbed_official 0:51ac1d130fd4 2446 {
mbed_official 0:51ac1d130fd4 2447 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 2448 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2449 }
mbed_official 0:51ac1d130fd4 2450 }
mbed_official 0:51ac1d130fd4 2451
mbed_official 0:51ac1d130fd4 2452 /**
mbed_official 0:51ac1d130fd4 2453 * Returns ifentry object value.
mbed_official 0:51ac1d130fd4 2454 *
mbed_official 0:51ac1d130fd4 2455 * @param ident_len the address length (2)
mbed_official 0:51ac1d130fd4 2456 * @param ident points to objectname.0 (object id trailer)
mbed_official 0:51ac1d130fd4 2457 * @param len return value space (in bytes)
mbed_official 0:51ac1d130fd4 2458 * @param value points to (varbind) space to copy value into.
mbed_official 0:51ac1d130fd4 2459 */
mbed_official 0:51ac1d130fd4 2460 static void
mbed_official 0:51ac1d130fd4 2461 ifentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2462 {
mbed_official 0:51ac1d130fd4 2463 struct netif *netif;
mbed_official 0:51ac1d130fd4 2464 u8_t id;
mbed_official 0:51ac1d130fd4 2465
mbed_official 0:51ac1d130fd4 2466 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
mbed_official 0:51ac1d130fd4 2467 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2468 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2469 switch (id)
mbed_official 0:51ac1d130fd4 2470 {
mbed_official 0:51ac1d130fd4 2471 case 1: /* ifIndex */
mbed_official 0:51ac1d130fd4 2472 {
mbed_official 0:51ac1d130fd4 2473 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2474 *sint_ptr = od->id_inst_ptr[1];
mbed_official 0:51ac1d130fd4 2475 }
mbed_official 0:51ac1d130fd4 2476 break;
mbed_official 0:51ac1d130fd4 2477 case 2: /* ifDescr */
mbed_official 0:51ac1d130fd4 2478 ocstrncpy((u8_t*)value, (u8_t*)netif->name, len);
mbed_official 0:51ac1d130fd4 2479 break;
mbed_official 0:51ac1d130fd4 2480 case 3: /* ifType */
mbed_official 0:51ac1d130fd4 2481 {
mbed_official 0:51ac1d130fd4 2482 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2483 *sint_ptr = netif->link_type;
mbed_official 0:51ac1d130fd4 2484 }
mbed_official 0:51ac1d130fd4 2485 break;
mbed_official 0:51ac1d130fd4 2486 case 4: /* ifMtu */
mbed_official 0:51ac1d130fd4 2487 {
mbed_official 0:51ac1d130fd4 2488 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2489 *sint_ptr = netif->mtu;
mbed_official 0:51ac1d130fd4 2490 }
mbed_official 0:51ac1d130fd4 2491 break;
mbed_official 0:51ac1d130fd4 2492 case 5: /* ifSpeed */
mbed_official 0:51ac1d130fd4 2493 {
mbed_official 0:51ac1d130fd4 2494 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2495 *uint_ptr = netif->link_speed;
mbed_official 0:51ac1d130fd4 2496 }
mbed_official 0:51ac1d130fd4 2497 break;
mbed_official 0:51ac1d130fd4 2498 case 6: /* ifPhysAddress */
mbed_official 0:51ac1d130fd4 2499 ocstrncpy((u8_t*)value, netif->hwaddr, len);
mbed_official 0:51ac1d130fd4 2500 break;
mbed_official 0:51ac1d130fd4 2501 case 7: /* ifAdminStatus */
mbed_official 0:51ac1d130fd4 2502 {
mbed_official 0:51ac1d130fd4 2503 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2504 if (netif_is_up(netif))
mbed_official 0:51ac1d130fd4 2505 {
mbed_official 0:51ac1d130fd4 2506 if (netif_is_link_up(netif))
mbed_official 0:51ac1d130fd4 2507 {
mbed_official 0:51ac1d130fd4 2508 *sint_ptr = 1; /* up */
mbed_official 0:51ac1d130fd4 2509 }
mbed_official 0:51ac1d130fd4 2510 else
mbed_official 0:51ac1d130fd4 2511 {
mbed_official 0:51ac1d130fd4 2512 *sint_ptr = 7; /* lowerLayerDown */
mbed_official 0:51ac1d130fd4 2513 }
mbed_official 0:51ac1d130fd4 2514 }
mbed_official 0:51ac1d130fd4 2515 else
mbed_official 0:51ac1d130fd4 2516 {
mbed_official 0:51ac1d130fd4 2517 *sint_ptr = 2; /* down */
mbed_official 0:51ac1d130fd4 2518 }
mbed_official 0:51ac1d130fd4 2519 }
mbed_official 0:51ac1d130fd4 2520 break;
mbed_official 0:51ac1d130fd4 2521 case 8: /* ifOperStatus */
mbed_official 0:51ac1d130fd4 2522 {
mbed_official 0:51ac1d130fd4 2523 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2524 if (netif_is_up(netif))
mbed_official 0:51ac1d130fd4 2525 {
mbed_official 0:51ac1d130fd4 2526 *sint_ptr = 1;
mbed_official 0:51ac1d130fd4 2527 }
mbed_official 0:51ac1d130fd4 2528 else
mbed_official 0:51ac1d130fd4 2529 {
mbed_official 0:51ac1d130fd4 2530 *sint_ptr = 2;
mbed_official 0:51ac1d130fd4 2531 }
mbed_official 0:51ac1d130fd4 2532 }
mbed_official 0:51ac1d130fd4 2533 break;
mbed_official 0:51ac1d130fd4 2534 case 9: /* ifLastChange */
mbed_official 0:51ac1d130fd4 2535 {
mbed_official 0:51ac1d130fd4 2536 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2537 *uint_ptr = netif->ts;
mbed_official 0:51ac1d130fd4 2538 }
mbed_official 0:51ac1d130fd4 2539 break;
mbed_official 0:51ac1d130fd4 2540 case 10: /* ifInOctets */
mbed_official 0:51ac1d130fd4 2541 {
mbed_official 0:51ac1d130fd4 2542 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2543 *uint_ptr = netif->ifinoctets;
mbed_official 0:51ac1d130fd4 2544 }
mbed_official 0:51ac1d130fd4 2545 break;
mbed_official 0:51ac1d130fd4 2546 case 11: /* ifInUcastPkts */
mbed_official 0:51ac1d130fd4 2547 {
mbed_official 0:51ac1d130fd4 2548 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2549 *uint_ptr = netif->ifinucastpkts;
mbed_official 0:51ac1d130fd4 2550 }
mbed_official 0:51ac1d130fd4 2551 break;
mbed_official 0:51ac1d130fd4 2552 case 12: /* ifInNUcastPkts */
mbed_official 0:51ac1d130fd4 2553 {
mbed_official 0:51ac1d130fd4 2554 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2555 *uint_ptr = netif->ifinnucastpkts;
mbed_official 0:51ac1d130fd4 2556 }
mbed_official 0:51ac1d130fd4 2557 break;
mbed_official 0:51ac1d130fd4 2558 case 13: /* ifInDiscarts */
mbed_official 0:51ac1d130fd4 2559 {
mbed_official 0:51ac1d130fd4 2560 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2561 *uint_ptr = netif->ifindiscards;
mbed_official 0:51ac1d130fd4 2562 }
mbed_official 0:51ac1d130fd4 2563 break;
mbed_official 0:51ac1d130fd4 2564 case 14: /* ifInErrors */
mbed_official 0:51ac1d130fd4 2565 case 15: /* ifInUnkownProtos */
mbed_official 0:51ac1d130fd4 2566 /** @todo add these counters! */
mbed_official 0:51ac1d130fd4 2567 {
mbed_official 0:51ac1d130fd4 2568 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2569 *uint_ptr = 0;
mbed_official 0:51ac1d130fd4 2570 }
mbed_official 0:51ac1d130fd4 2571 break;
mbed_official 0:51ac1d130fd4 2572 case 16: /* ifOutOctets */
mbed_official 0:51ac1d130fd4 2573 {
mbed_official 0:51ac1d130fd4 2574 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2575 *uint_ptr = netif->ifoutoctets;
mbed_official 0:51ac1d130fd4 2576 }
mbed_official 0:51ac1d130fd4 2577 break;
mbed_official 0:51ac1d130fd4 2578 case 17: /* ifOutUcastPkts */
mbed_official 0:51ac1d130fd4 2579 {
mbed_official 0:51ac1d130fd4 2580 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2581 *uint_ptr = netif->ifoutucastpkts;
mbed_official 0:51ac1d130fd4 2582 }
mbed_official 0:51ac1d130fd4 2583 break;
mbed_official 0:51ac1d130fd4 2584 case 18: /* ifOutNUcastPkts */
mbed_official 0:51ac1d130fd4 2585 {
mbed_official 0:51ac1d130fd4 2586 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2587 *uint_ptr = netif->ifoutnucastpkts;
mbed_official 0:51ac1d130fd4 2588 }
mbed_official 0:51ac1d130fd4 2589 break;
mbed_official 0:51ac1d130fd4 2590 case 19: /* ifOutDiscarts */
mbed_official 0:51ac1d130fd4 2591 {
mbed_official 0:51ac1d130fd4 2592 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2593 *uint_ptr = netif->ifoutdiscards;
mbed_official 0:51ac1d130fd4 2594 }
mbed_official 0:51ac1d130fd4 2595 break;
mbed_official 0:51ac1d130fd4 2596 case 20: /* ifOutErrors */
mbed_official 0:51ac1d130fd4 2597 /** @todo add this counter! */
mbed_official 0:51ac1d130fd4 2598 {
mbed_official 0:51ac1d130fd4 2599 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2600 *uint_ptr = 0;
mbed_official 0:51ac1d130fd4 2601 }
mbed_official 0:51ac1d130fd4 2602 break;
mbed_official 0:51ac1d130fd4 2603 case 21: /* ifOutQLen */
mbed_official 0:51ac1d130fd4 2604 /** @todo figure out if this must be 0 (no queue) or 1? */
mbed_official 0:51ac1d130fd4 2605 {
mbed_official 0:51ac1d130fd4 2606 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2607 *uint_ptr = 0;
mbed_official 0:51ac1d130fd4 2608 }
mbed_official 0:51ac1d130fd4 2609 break;
mbed_official 0:51ac1d130fd4 2610 case 22: /* ifSpecific */
mbed_official 0:51ac1d130fd4 2611 objectidncpy((s32_t*)value, (s32_t*)ifspecific.id, (u8_t)(len / sizeof(s32_t)));
mbed_official 0:51ac1d130fd4 2612 break;
mbed_official 0:51ac1d130fd4 2613 };
mbed_official 0:51ac1d130fd4 2614 }
mbed_official 0:51ac1d130fd4 2615
mbed_official 0:51ac1d130fd4 2616 #if !SNMP_SAFE_REQUESTS
mbed_official 0:51ac1d130fd4 2617 static u8_t
mbed_official 0:51ac1d130fd4 2618 ifentry_set_test(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2619 {
mbed_official 0:51ac1d130fd4 2620 struct netif *netif;
mbed_official 0:51ac1d130fd4 2621 u8_t id, set_ok;
mbed_official 0:51ac1d130fd4 2622 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2623
mbed_official 0:51ac1d130fd4 2624 set_ok = 0;
mbed_official 0:51ac1d130fd4 2625 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
mbed_official 0:51ac1d130fd4 2626 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2627 switch (id)
mbed_official 0:51ac1d130fd4 2628 {
mbed_official 0:51ac1d130fd4 2629 case 7: /* ifAdminStatus */
mbed_official 0:51ac1d130fd4 2630 {
mbed_official 0:51ac1d130fd4 2631 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2632 if (*sint_ptr == 1 || *sint_ptr == 2)
mbed_official 0:51ac1d130fd4 2633 set_ok = 1;
mbed_official 0:51ac1d130fd4 2634 }
mbed_official 0:51ac1d130fd4 2635 break;
mbed_official 0:51ac1d130fd4 2636 }
mbed_official 0:51ac1d130fd4 2637 return set_ok;
mbed_official 0:51ac1d130fd4 2638 }
mbed_official 0:51ac1d130fd4 2639
mbed_official 0:51ac1d130fd4 2640 static void
mbed_official 0:51ac1d130fd4 2641 ifentry_set_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2642 {
mbed_official 0:51ac1d130fd4 2643 struct netif *netif;
mbed_official 0:51ac1d130fd4 2644 u8_t id;
mbed_official 0:51ac1d130fd4 2645 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2646
mbed_official 0:51ac1d130fd4 2647 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
mbed_official 0:51ac1d130fd4 2648 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2649 switch (id)
mbed_official 0:51ac1d130fd4 2650 {
mbed_official 0:51ac1d130fd4 2651 case 7: /* ifAdminStatus */
mbed_official 0:51ac1d130fd4 2652 {
mbed_official 0:51ac1d130fd4 2653 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2654 if (*sint_ptr == 1)
mbed_official 0:51ac1d130fd4 2655 {
mbed_official 0:51ac1d130fd4 2656 netif_set_up(netif);
mbed_official 0:51ac1d130fd4 2657 }
mbed_official 0:51ac1d130fd4 2658 else if (*sint_ptr == 2)
mbed_official 0:51ac1d130fd4 2659 {
mbed_official 0:51ac1d130fd4 2660 netif_set_down(netif);
mbed_official 0:51ac1d130fd4 2661 }
mbed_official 0:51ac1d130fd4 2662 }
mbed_official 0:51ac1d130fd4 2663 break;
mbed_official 0:51ac1d130fd4 2664 }
mbed_official 0:51ac1d130fd4 2665 }
mbed_official 0:51ac1d130fd4 2666 #endif /* SNMP_SAFE_REQUESTS */
mbed_official 0:51ac1d130fd4 2667
mbed_official 0:51ac1d130fd4 2668 /**
mbed_official 0:51ac1d130fd4 2669 * Returns atentry object definitions.
mbed_official 0:51ac1d130fd4 2670 *
mbed_official 0:51ac1d130fd4 2671 * @param ident_len the address length (6)
mbed_official 0:51ac1d130fd4 2672 * @param ident points to objectname.atifindex.atnetaddress
mbed_official 0:51ac1d130fd4 2673 * @param od points to object definition.
mbed_official 0:51ac1d130fd4 2674 */
mbed_official 0:51ac1d130fd4 2675 static void
mbed_official 0:51ac1d130fd4 2676 atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 2677 {
mbed_official 0:51ac1d130fd4 2678 /* return to object name, adding index depth (5) */
mbed_official 0:51ac1d130fd4 2679 ident_len += 5;
mbed_official 0:51ac1d130fd4 2680 ident -= 5;
mbed_official 0:51ac1d130fd4 2681
mbed_official 0:51ac1d130fd4 2682 if (ident_len == 6)
mbed_official 0:51ac1d130fd4 2683 {
mbed_official 0:51ac1d130fd4 2684 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 2685 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 2686
mbed_official 0:51ac1d130fd4 2687 switch (ident[0])
mbed_official 0:51ac1d130fd4 2688 {
mbed_official 0:51ac1d130fd4 2689 case 1: /* atIfIndex */
mbed_official 0:51ac1d130fd4 2690 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2691 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2692 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2693 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2694 break;
mbed_official 0:51ac1d130fd4 2695 case 2: /* atPhysAddress */
mbed_official 0:51ac1d130fd4 2696 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2697 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2698 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 2699 od->v_len = 6; /** @todo try to use netif::hwaddr_len */
mbed_official 0:51ac1d130fd4 2700 break;
mbed_official 0:51ac1d130fd4 2701 case 3: /* atNetAddress */
mbed_official 0:51ac1d130fd4 2702 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 2703 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2704 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
mbed_official 0:51ac1d130fd4 2705 od->v_len = 4;
mbed_official 0:51ac1d130fd4 2706 break;
mbed_official 0:51ac1d130fd4 2707 default:
mbed_official 0:51ac1d130fd4 2708 LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 2709 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2710 break;
mbed_official 0:51ac1d130fd4 2711 }
mbed_official 0:51ac1d130fd4 2712 }
mbed_official 0:51ac1d130fd4 2713 else
mbed_official 0:51ac1d130fd4 2714 {
mbed_official 0:51ac1d130fd4 2715 LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 2716 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2717 }
mbed_official 0:51ac1d130fd4 2718 }
mbed_official 0:51ac1d130fd4 2719
mbed_official 0:51ac1d130fd4 2720 static void
mbed_official 0:51ac1d130fd4 2721 atentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2722 {
mbed_official 0:51ac1d130fd4 2723 #if LWIP_ARP
mbed_official 0:51ac1d130fd4 2724 u8_t id;
mbed_official 0:51ac1d130fd4 2725 struct eth_addr* ethaddr_ret;
mbed_official 0:51ac1d130fd4 2726 ip_addr_t* ipaddr_ret;
mbed_official 0:51ac1d130fd4 2727 #endif /* LWIP_ARP */
mbed_official 0:51ac1d130fd4 2728 ip_addr_t ip;
mbed_official 0:51ac1d130fd4 2729 struct netif *netif;
mbed_official 0:51ac1d130fd4 2730
mbed_official 0:51ac1d130fd4 2731 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2732 LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */
mbed_official 0:51ac1d130fd4 2733
mbed_official 0:51ac1d130fd4 2734 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
mbed_official 0:51ac1d130fd4 2735 snmp_oidtoip(&od->id_inst_ptr[2], &ip);
mbed_official 0:51ac1d130fd4 2736
mbed_official 0:51ac1d130fd4 2737 #if LWIP_ARP /** @todo implement a netif_find_addr */
mbed_official 0:51ac1d130fd4 2738 if (etharp_find_addr(netif, &ip, &ethaddr_ret, &ipaddr_ret) > -1)
mbed_official 0:51ac1d130fd4 2739 {
mbed_official 0:51ac1d130fd4 2740 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2741 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2742 switch (id)
mbed_official 0:51ac1d130fd4 2743 {
mbed_official 0:51ac1d130fd4 2744 case 1: /* atIfIndex */
mbed_official 0:51ac1d130fd4 2745 {
mbed_official 0:51ac1d130fd4 2746 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2747 *sint_ptr = od->id_inst_ptr[1];
mbed_official 0:51ac1d130fd4 2748 }
mbed_official 0:51ac1d130fd4 2749 break;
mbed_official 0:51ac1d130fd4 2750 case 2: /* atPhysAddress */
mbed_official 0:51ac1d130fd4 2751 {
mbed_official 0:51ac1d130fd4 2752 struct eth_addr *dst = (struct eth_addr*)value;
mbed_official 0:51ac1d130fd4 2753
mbed_official 0:51ac1d130fd4 2754 *dst = *ethaddr_ret;
mbed_official 0:51ac1d130fd4 2755 }
mbed_official 0:51ac1d130fd4 2756 break;
mbed_official 0:51ac1d130fd4 2757 case 3: /* atNetAddress */
mbed_official 0:51ac1d130fd4 2758 {
mbed_official 0:51ac1d130fd4 2759 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 2760
mbed_official 0:51ac1d130fd4 2761 *dst = *ipaddr_ret;
mbed_official 0:51ac1d130fd4 2762 }
mbed_official 0:51ac1d130fd4 2763 break;
mbed_official 0:51ac1d130fd4 2764 }
mbed_official 0:51ac1d130fd4 2765 }
mbed_official 0:51ac1d130fd4 2766 #endif /* LWIP_ARP */
mbed_official 0:51ac1d130fd4 2767 }
mbed_official 0:51ac1d130fd4 2768
mbed_official 0:51ac1d130fd4 2769 static void
mbed_official 0:51ac1d130fd4 2770 ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 2771 {
mbed_official 0:51ac1d130fd4 2772 u8_t id;
mbed_official 0:51ac1d130fd4 2773
mbed_official 0:51ac1d130fd4 2774 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 2775 ident_len += 1;
mbed_official 0:51ac1d130fd4 2776 ident -= 1;
mbed_official 0:51ac1d130fd4 2777 if (ident_len == 2)
mbed_official 0:51ac1d130fd4 2778 {
mbed_official 0:51ac1d130fd4 2779 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 2780 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 2781
mbed_official 0:51ac1d130fd4 2782 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2783 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 2784 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ip.%"U16_F".0\n",(u16_t)id));
mbed_official 0:51ac1d130fd4 2785 switch (id)
mbed_official 0:51ac1d130fd4 2786 {
mbed_official 0:51ac1d130fd4 2787 case 1: /* ipForwarding */
mbed_official 0:51ac1d130fd4 2788 case 2: /* ipDefaultTTL */
mbed_official 0:51ac1d130fd4 2789 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2790 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 2791 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2792 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2793 break;
mbed_official 0:51ac1d130fd4 2794 case 3: /* ipInReceives */
mbed_official 0:51ac1d130fd4 2795 case 4: /* ipInHdrErrors */
mbed_official 0:51ac1d130fd4 2796 case 5: /* ipInAddrErrors */
mbed_official 0:51ac1d130fd4 2797 case 6: /* ipForwDatagrams */
mbed_official 0:51ac1d130fd4 2798 case 7: /* ipInUnknownProtos */
mbed_official 0:51ac1d130fd4 2799 case 8: /* ipInDiscards */
mbed_official 0:51ac1d130fd4 2800 case 9: /* ipInDelivers */
mbed_official 0:51ac1d130fd4 2801 case 10: /* ipOutRequests */
mbed_official 0:51ac1d130fd4 2802 case 11: /* ipOutDiscards */
mbed_official 0:51ac1d130fd4 2803 case 12: /* ipOutNoRoutes */
mbed_official 0:51ac1d130fd4 2804 case 14: /* ipReasmReqds */
mbed_official 0:51ac1d130fd4 2805 case 15: /* ipReasmOKs */
mbed_official 0:51ac1d130fd4 2806 case 16: /* ipReasmFails */
mbed_official 0:51ac1d130fd4 2807 case 17: /* ipFragOKs */
mbed_official 0:51ac1d130fd4 2808 case 18: /* ipFragFails */
mbed_official 0:51ac1d130fd4 2809 case 19: /* ipFragCreates */
mbed_official 0:51ac1d130fd4 2810 case 23: /* ipRoutingDiscards */
mbed_official 0:51ac1d130fd4 2811 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2812 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2813 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
mbed_official 0:51ac1d130fd4 2814 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 2815 break;
mbed_official 0:51ac1d130fd4 2816 case 13: /* ipReasmTimeout */
mbed_official 0:51ac1d130fd4 2817 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 2818 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 2819 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 2820 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 2821 break;
mbed_official 0:51ac1d130fd4 2822 default:
mbed_official 0:51ac1d130fd4 2823 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 2824 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2825 break;
mbed_official 0:51ac1d130fd4 2826 };
mbed_official 0:51ac1d130fd4 2827 }
mbed_official 0:51ac1d130fd4 2828 else
mbed_official 0:51ac1d130fd4 2829 {
mbed_official 0:51ac1d130fd4 2830 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 2831 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 2832 }
mbed_official 0:51ac1d130fd4 2833 }
mbed_official 0:51ac1d130fd4 2834
mbed_official 0:51ac1d130fd4 2835 static void
mbed_official 0:51ac1d130fd4 2836 ip_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2837 {
mbed_official 0:51ac1d130fd4 2838 u8_t id;
mbed_official 0:51ac1d130fd4 2839
mbed_official 0:51ac1d130fd4 2840 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2841 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2842 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2843 switch (id)
mbed_official 0:51ac1d130fd4 2844 {
mbed_official 0:51ac1d130fd4 2845 case 1: /* ipForwarding */
mbed_official 0:51ac1d130fd4 2846 {
mbed_official 0:51ac1d130fd4 2847 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2848 #if IP_FORWARD
mbed_official 0:51ac1d130fd4 2849 /* forwarding */
mbed_official 0:51ac1d130fd4 2850 *sint_ptr = 1;
mbed_official 0:51ac1d130fd4 2851 #else
mbed_official 0:51ac1d130fd4 2852 /* not-forwarding */
mbed_official 0:51ac1d130fd4 2853 *sint_ptr = 2;
mbed_official 0:51ac1d130fd4 2854 #endif
mbed_official 0:51ac1d130fd4 2855 }
mbed_official 0:51ac1d130fd4 2856 break;
mbed_official 0:51ac1d130fd4 2857 case 2: /* ipDefaultTTL */
mbed_official 0:51ac1d130fd4 2858 {
mbed_official 0:51ac1d130fd4 2859 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2860 *sint_ptr = IP_DEFAULT_TTL;
mbed_official 0:51ac1d130fd4 2861 }
mbed_official 0:51ac1d130fd4 2862 break;
mbed_official 0:51ac1d130fd4 2863 case 3: /* ipInReceives */
mbed_official 0:51ac1d130fd4 2864 {
mbed_official 0:51ac1d130fd4 2865 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2866 *uint_ptr = ipinreceives;
mbed_official 0:51ac1d130fd4 2867 }
mbed_official 0:51ac1d130fd4 2868 break;
mbed_official 0:51ac1d130fd4 2869 case 4: /* ipInHdrErrors */
mbed_official 0:51ac1d130fd4 2870 {
mbed_official 0:51ac1d130fd4 2871 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2872 *uint_ptr = ipinhdrerrors;
mbed_official 0:51ac1d130fd4 2873 }
mbed_official 0:51ac1d130fd4 2874 break;
mbed_official 0:51ac1d130fd4 2875 case 5: /* ipInAddrErrors */
mbed_official 0:51ac1d130fd4 2876 {
mbed_official 0:51ac1d130fd4 2877 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2878 *uint_ptr = ipinaddrerrors;
mbed_official 0:51ac1d130fd4 2879 }
mbed_official 0:51ac1d130fd4 2880 break;
mbed_official 0:51ac1d130fd4 2881 case 6: /* ipForwDatagrams */
mbed_official 0:51ac1d130fd4 2882 {
mbed_official 0:51ac1d130fd4 2883 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2884 *uint_ptr = ipforwdatagrams;
mbed_official 0:51ac1d130fd4 2885 }
mbed_official 0:51ac1d130fd4 2886 break;
mbed_official 0:51ac1d130fd4 2887 case 7: /* ipInUnknownProtos */
mbed_official 0:51ac1d130fd4 2888 {
mbed_official 0:51ac1d130fd4 2889 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2890 *uint_ptr = ipinunknownprotos;
mbed_official 0:51ac1d130fd4 2891 }
mbed_official 0:51ac1d130fd4 2892 break;
mbed_official 0:51ac1d130fd4 2893 case 8: /* ipInDiscards */
mbed_official 0:51ac1d130fd4 2894 {
mbed_official 0:51ac1d130fd4 2895 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2896 *uint_ptr = ipindiscards;
mbed_official 0:51ac1d130fd4 2897 }
mbed_official 0:51ac1d130fd4 2898 break;
mbed_official 0:51ac1d130fd4 2899 case 9: /* ipInDelivers */
mbed_official 0:51ac1d130fd4 2900 {
mbed_official 0:51ac1d130fd4 2901 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2902 *uint_ptr = ipindelivers;
mbed_official 0:51ac1d130fd4 2903 }
mbed_official 0:51ac1d130fd4 2904 break;
mbed_official 0:51ac1d130fd4 2905 case 10: /* ipOutRequests */
mbed_official 0:51ac1d130fd4 2906 {
mbed_official 0:51ac1d130fd4 2907 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2908 *uint_ptr = ipoutrequests;
mbed_official 0:51ac1d130fd4 2909 }
mbed_official 0:51ac1d130fd4 2910 break;
mbed_official 0:51ac1d130fd4 2911 case 11: /* ipOutDiscards */
mbed_official 0:51ac1d130fd4 2912 {
mbed_official 0:51ac1d130fd4 2913 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2914 *uint_ptr = ipoutdiscards;
mbed_official 0:51ac1d130fd4 2915 }
mbed_official 0:51ac1d130fd4 2916 break;
mbed_official 0:51ac1d130fd4 2917 case 12: /* ipOutNoRoutes */
mbed_official 0:51ac1d130fd4 2918 {
mbed_official 0:51ac1d130fd4 2919 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2920 *uint_ptr = ipoutnoroutes;
mbed_official 0:51ac1d130fd4 2921 }
mbed_official 0:51ac1d130fd4 2922 break;
mbed_official 0:51ac1d130fd4 2923 case 13: /* ipReasmTimeout */
mbed_official 0:51ac1d130fd4 2924 {
mbed_official 0:51ac1d130fd4 2925 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2926 #if IP_REASSEMBLY
mbed_official 0:51ac1d130fd4 2927 *sint_ptr = IP_REASS_MAXAGE;
mbed_official 0:51ac1d130fd4 2928 #else
mbed_official 0:51ac1d130fd4 2929 *sint_ptr = 0;
mbed_official 0:51ac1d130fd4 2930 #endif
mbed_official 0:51ac1d130fd4 2931 }
mbed_official 0:51ac1d130fd4 2932 break;
mbed_official 0:51ac1d130fd4 2933 case 14: /* ipReasmReqds */
mbed_official 0:51ac1d130fd4 2934 {
mbed_official 0:51ac1d130fd4 2935 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2936 *uint_ptr = ipreasmreqds;
mbed_official 0:51ac1d130fd4 2937 }
mbed_official 0:51ac1d130fd4 2938 break;
mbed_official 0:51ac1d130fd4 2939 case 15: /* ipReasmOKs */
mbed_official 0:51ac1d130fd4 2940 {
mbed_official 0:51ac1d130fd4 2941 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2942 *uint_ptr = ipreasmoks;
mbed_official 0:51ac1d130fd4 2943 }
mbed_official 0:51ac1d130fd4 2944 break;
mbed_official 0:51ac1d130fd4 2945 case 16: /* ipReasmFails */
mbed_official 0:51ac1d130fd4 2946 {
mbed_official 0:51ac1d130fd4 2947 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2948 *uint_ptr = ipreasmfails;
mbed_official 0:51ac1d130fd4 2949 }
mbed_official 0:51ac1d130fd4 2950 break;
mbed_official 0:51ac1d130fd4 2951 case 17: /* ipFragOKs */
mbed_official 0:51ac1d130fd4 2952 {
mbed_official 0:51ac1d130fd4 2953 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2954 *uint_ptr = ipfragoks;
mbed_official 0:51ac1d130fd4 2955 }
mbed_official 0:51ac1d130fd4 2956 break;
mbed_official 0:51ac1d130fd4 2957 case 18: /* ipFragFails */
mbed_official 0:51ac1d130fd4 2958 {
mbed_official 0:51ac1d130fd4 2959 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2960 *uint_ptr = ipfragfails;
mbed_official 0:51ac1d130fd4 2961 }
mbed_official 0:51ac1d130fd4 2962 break;
mbed_official 0:51ac1d130fd4 2963 case 19: /* ipFragCreates */
mbed_official 0:51ac1d130fd4 2964 {
mbed_official 0:51ac1d130fd4 2965 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2966 *uint_ptr = ipfragcreates;
mbed_official 0:51ac1d130fd4 2967 }
mbed_official 0:51ac1d130fd4 2968 break;
mbed_official 0:51ac1d130fd4 2969 case 23: /* ipRoutingDiscards */
mbed_official 0:51ac1d130fd4 2970 /** @todo can lwIP discard routes at all?? hardwire this to 0?? */
mbed_official 0:51ac1d130fd4 2971 {
mbed_official 0:51ac1d130fd4 2972 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 2973 *uint_ptr = iproutingdiscards;
mbed_official 0:51ac1d130fd4 2974 }
mbed_official 0:51ac1d130fd4 2975 break;
mbed_official 0:51ac1d130fd4 2976 };
mbed_official 0:51ac1d130fd4 2977 }
mbed_official 0:51ac1d130fd4 2978
mbed_official 0:51ac1d130fd4 2979 /**
mbed_official 0:51ac1d130fd4 2980 * Test ip object value before setting.
mbed_official 0:51ac1d130fd4 2981 *
mbed_official 0:51ac1d130fd4 2982 * @param od is the object definition
mbed_official 0:51ac1d130fd4 2983 * @param len return value space (in bytes)
mbed_official 0:51ac1d130fd4 2984 * @param value points to (varbind) space to copy value from.
mbed_official 0:51ac1d130fd4 2985 *
mbed_official 0:51ac1d130fd4 2986 * @note we allow set if the value matches the hardwired value,
mbed_official 0:51ac1d130fd4 2987 * otherwise return badvalue.
mbed_official 0:51ac1d130fd4 2988 */
mbed_official 0:51ac1d130fd4 2989 static u8_t
mbed_official 0:51ac1d130fd4 2990 ip_set_test(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 2991 {
mbed_official 0:51ac1d130fd4 2992 u8_t id, set_ok;
mbed_official 0:51ac1d130fd4 2993 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 2994
mbed_official 0:51ac1d130fd4 2995 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 2996 set_ok = 0;
mbed_official 0:51ac1d130fd4 2997 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 2998 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 2999 switch (id)
mbed_official 0:51ac1d130fd4 3000 {
mbed_official 0:51ac1d130fd4 3001 case 1: /* ipForwarding */
mbed_official 0:51ac1d130fd4 3002 #if IP_FORWARD
mbed_official 0:51ac1d130fd4 3003 /* forwarding */
mbed_official 0:51ac1d130fd4 3004 if (*sint_ptr == 1)
mbed_official 0:51ac1d130fd4 3005 #else
mbed_official 0:51ac1d130fd4 3006 /* not-forwarding */
mbed_official 0:51ac1d130fd4 3007 if (*sint_ptr == 2)
mbed_official 0:51ac1d130fd4 3008 #endif
mbed_official 0:51ac1d130fd4 3009 {
mbed_official 0:51ac1d130fd4 3010 set_ok = 1;
mbed_official 0:51ac1d130fd4 3011 }
mbed_official 0:51ac1d130fd4 3012 break;
mbed_official 0:51ac1d130fd4 3013 case 2: /* ipDefaultTTL */
mbed_official 0:51ac1d130fd4 3014 if (*sint_ptr == IP_DEFAULT_TTL)
mbed_official 0:51ac1d130fd4 3015 {
mbed_official 0:51ac1d130fd4 3016 set_ok = 1;
mbed_official 0:51ac1d130fd4 3017 }
mbed_official 0:51ac1d130fd4 3018 break;
mbed_official 0:51ac1d130fd4 3019 };
mbed_official 0:51ac1d130fd4 3020 return set_ok;
mbed_official 0:51ac1d130fd4 3021 }
mbed_official 0:51ac1d130fd4 3022
mbed_official 0:51ac1d130fd4 3023 static void
mbed_official 0:51ac1d130fd4 3024 ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3025 {
mbed_official 0:51ac1d130fd4 3026 /* return to object name, adding index depth (4) */
mbed_official 0:51ac1d130fd4 3027 ident_len += 4;
mbed_official 0:51ac1d130fd4 3028 ident -= 4;
mbed_official 0:51ac1d130fd4 3029
mbed_official 0:51ac1d130fd4 3030 if (ident_len == 5)
mbed_official 0:51ac1d130fd4 3031 {
mbed_official 0:51ac1d130fd4 3032 u8_t id;
mbed_official 0:51ac1d130fd4 3033
mbed_official 0:51ac1d130fd4 3034 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3035 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3036
mbed_official 0:51ac1d130fd4 3037 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3038 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 3039 switch (id)
mbed_official 0:51ac1d130fd4 3040 {
mbed_official 0:51ac1d130fd4 3041 case 1: /* ipAdEntAddr */
mbed_official 0:51ac1d130fd4 3042 case 3: /* ipAdEntNetMask */
mbed_official 0:51ac1d130fd4 3043 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3044 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3045 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
mbed_official 0:51ac1d130fd4 3046 od->v_len = 4;
mbed_official 0:51ac1d130fd4 3047 break;
mbed_official 0:51ac1d130fd4 3048 case 2: /* ipAdEntIfIndex */
mbed_official 0:51ac1d130fd4 3049 case 4: /* ipAdEntBcastAddr */
mbed_official 0:51ac1d130fd4 3050 case 5: /* ipAdEntReasmMaxSize */
mbed_official 0:51ac1d130fd4 3051 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3052 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3053 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3054 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3055 break;
mbed_official 0:51ac1d130fd4 3056 default:
mbed_official 0:51ac1d130fd4 3057 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3058 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3059 break;
mbed_official 0:51ac1d130fd4 3060 }
mbed_official 0:51ac1d130fd4 3061 }
mbed_official 0:51ac1d130fd4 3062 else
mbed_official 0:51ac1d130fd4 3063 {
mbed_official 0:51ac1d130fd4 3064 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3065 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3066 }
mbed_official 0:51ac1d130fd4 3067 }
mbed_official 0:51ac1d130fd4 3068
mbed_official 0:51ac1d130fd4 3069 static void
mbed_official 0:51ac1d130fd4 3070 ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3071 {
mbed_official 0:51ac1d130fd4 3072 u8_t id;
mbed_official 0:51ac1d130fd4 3073 u16_t ifidx;
mbed_official 0:51ac1d130fd4 3074 ip_addr_t ip;
mbed_official 0:51ac1d130fd4 3075 struct netif *netif = netif_list;
mbed_official 0:51ac1d130fd4 3076
mbed_official 0:51ac1d130fd4 3077 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3078 snmp_oidtoip(&od->id_inst_ptr[1], &ip);
mbed_official 0:51ac1d130fd4 3079 ifidx = 0;
mbed_official 0:51ac1d130fd4 3080 while ((netif != NULL) && !ip_addr_cmp(&ip, &netif->ip_addr))
mbed_official 0:51ac1d130fd4 3081 {
mbed_official 0:51ac1d130fd4 3082 netif = netif->next;
mbed_official 0:51ac1d130fd4 3083 ifidx++;
mbed_official 0:51ac1d130fd4 3084 }
mbed_official 0:51ac1d130fd4 3085
mbed_official 0:51ac1d130fd4 3086 if (netif != NULL)
mbed_official 0:51ac1d130fd4 3087 {
mbed_official 0:51ac1d130fd4 3088 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3089 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3090 switch (id)
mbed_official 0:51ac1d130fd4 3091 {
mbed_official 0:51ac1d130fd4 3092 case 1: /* ipAdEntAddr */
mbed_official 0:51ac1d130fd4 3093 {
mbed_official 0:51ac1d130fd4 3094 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3095 *dst = netif->ip_addr;
mbed_official 0:51ac1d130fd4 3096 }
mbed_official 0:51ac1d130fd4 3097 break;
mbed_official 0:51ac1d130fd4 3098 case 2: /* ipAdEntIfIndex */
mbed_official 0:51ac1d130fd4 3099 {
mbed_official 0:51ac1d130fd4 3100 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3101 *sint_ptr = ifidx + 1;
mbed_official 0:51ac1d130fd4 3102 }
mbed_official 0:51ac1d130fd4 3103 break;
mbed_official 0:51ac1d130fd4 3104 case 3: /* ipAdEntNetMask */
mbed_official 0:51ac1d130fd4 3105 {
mbed_official 0:51ac1d130fd4 3106 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3107 *dst = netif->netmask;
mbed_official 0:51ac1d130fd4 3108 }
mbed_official 0:51ac1d130fd4 3109 break;
mbed_official 0:51ac1d130fd4 3110 case 4: /* ipAdEntBcastAddr */
mbed_official 0:51ac1d130fd4 3111 {
mbed_official 0:51ac1d130fd4 3112 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3113
mbed_official 0:51ac1d130fd4 3114 /* lwIP oddity, there's no broadcast
mbed_official 0:51ac1d130fd4 3115 address in the netif we can rely on */
mbed_official 0:51ac1d130fd4 3116 *sint_ptr = IPADDR_BROADCAST & 1;
mbed_official 0:51ac1d130fd4 3117 }
mbed_official 0:51ac1d130fd4 3118 break;
mbed_official 0:51ac1d130fd4 3119 case 5: /* ipAdEntReasmMaxSize */
mbed_official 0:51ac1d130fd4 3120 {
mbed_official 0:51ac1d130fd4 3121 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3122 #if IP_REASSEMBLY
mbed_official 0:51ac1d130fd4 3123 /* @todo The theoretical maximum is IP_REASS_MAX_PBUFS * size of the pbufs,
mbed_official 0:51ac1d130fd4 3124 * but only if receiving one fragmented packet at a time.
mbed_official 0:51ac1d130fd4 3125 * The current solution is to calculate for 2 simultaneous packets...
mbed_official 0:51ac1d130fd4 3126 */
mbed_official 0:51ac1d130fd4 3127 *sint_ptr = (IP_HLEN + ((IP_REASS_MAX_PBUFS/2) *
mbed_official 0:51ac1d130fd4 3128 (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN - IP_HLEN)));
mbed_official 0:51ac1d130fd4 3129 #else
mbed_official 0:51ac1d130fd4 3130 /** @todo returning MTU would be a bad thing and
mbed_official 0:51ac1d130fd4 3131 returning a wild guess like '576' isn't good either */
mbed_official 0:51ac1d130fd4 3132 *sint_ptr = 0;
mbed_official 0:51ac1d130fd4 3133 #endif
mbed_official 0:51ac1d130fd4 3134 }
mbed_official 0:51ac1d130fd4 3135 break;
mbed_official 0:51ac1d130fd4 3136 }
mbed_official 0:51ac1d130fd4 3137 }
mbed_official 0:51ac1d130fd4 3138 }
mbed_official 0:51ac1d130fd4 3139
mbed_official 0:51ac1d130fd4 3140 /**
mbed_official 0:51ac1d130fd4 3141 * @note
mbed_official 0:51ac1d130fd4 3142 * lwIP IP routing is currently using the network addresses in netif_list.
mbed_official 0:51ac1d130fd4 3143 * if no suitable network IP is found in netif_list, the default_netif is used.
mbed_official 0:51ac1d130fd4 3144 */
mbed_official 0:51ac1d130fd4 3145 static void
mbed_official 0:51ac1d130fd4 3146 ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3147 {
mbed_official 0:51ac1d130fd4 3148 u8_t id;
mbed_official 0:51ac1d130fd4 3149
mbed_official 0:51ac1d130fd4 3150 /* return to object name, adding index depth (4) */
mbed_official 0:51ac1d130fd4 3151 ident_len += 4;
mbed_official 0:51ac1d130fd4 3152 ident -= 4;
mbed_official 0:51ac1d130fd4 3153
mbed_official 0:51ac1d130fd4 3154 if (ident_len == 5)
mbed_official 0:51ac1d130fd4 3155 {
mbed_official 0:51ac1d130fd4 3156 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3157 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3158
mbed_official 0:51ac1d130fd4 3159 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3160 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 3161 switch (id)
mbed_official 0:51ac1d130fd4 3162 {
mbed_official 0:51ac1d130fd4 3163 case 1: /* ipRouteDest */
mbed_official 0:51ac1d130fd4 3164 case 7: /* ipRouteNextHop */
mbed_official 0:51ac1d130fd4 3165 case 11: /* ipRouteMask */
mbed_official 0:51ac1d130fd4 3166 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3167 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3168 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
mbed_official 0:51ac1d130fd4 3169 od->v_len = 4;
mbed_official 0:51ac1d130fd4 3170 break;
mbed_official 0:51ac1d130fd4 3171 case 2: /* ipRouteIfIndex */
mbed_official 0:51ac1d130fd4 3172 case 3: /* ipRouteMetric1 */
mbed_official 0:51ac1d130fd4 3173 case 4: /* ipRouteMetric2 */
mbed_official 0:51ac1d130fd4 3174 case 5: /* ipRouteMetric3 */
mbed_official 0:51ac1d130fd4 3175 case 6: /* ipRouteMetric4 */
mbed_official 0:51ac1d130fd4 3176 case 8: /* ipRouteType */
mbed_official 0:51ac1d130fd4 3177 case 10: /* ipRouteAge */
mbed_official 0:51ac1d130fd4 3178 case 12: /* ipRouteMetric5 */
mbed_official 0:51ac1d130fd4 3179 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3180 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3181 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3182 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3183 break;
mbed_official 0:51ac1d130fd4 3184 case 9: /* ipRouteProto */
mbed_official 0:51ac1d130fd4 3185 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3186 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3187 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3188 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3189 break;
mbed_official 0:51ac1d130fd4 3190 case 13: /* ipRouteInfo */
mbed_official 0:51ac1d130fd4 3191 /** @note returning zeroDotZero (0.0) no routing protocol specific MIB */
mbed_official 0:51ac1d130fd4 3192 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3193 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3194 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
mbed_official 0:51ac1d130fd4 3195 od->v_len = iprouteinfo.len * sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3196 break;
mbed_official 0:51ac1d130fd4 3197 default:
mbed_official 0:51ac1d130fd4 3198 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3199 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3200 break;
mbed_official 0:51ac1d130fd4 3201 }
mbed_official 0:51ac1d130fd4 3202 }
mbed_official 0:51ac1d130fd4 3203 else
mbed_official 0:51ac1d130fd4 3204 {
mbed_official 0:51ac1d130fd4 3205 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3206 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3207 }
mbed_official 0:51ac1d130fd4 3208 }
mbed_official 0:51ac1d130fd4 3209
mbed_official 0:51ac1d130fd4 3210 static void
mbed_official 0:51ac1d130fd4 3211 ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3212 {
mbed_official 0:51ac1d130fd4 3213 struct netif *netif;
mbed_official 0:51ac1d130fd4 3214 ip_addr_t dest;
mbed_official 0:51ac1d130fd4 3215 s32_t *ident;
mbed_official 0:51ac1d130fd4 3216 u8_t id;
mbed_official 0:51ac1d130fd4 3217
mbed_official 0:51ac1d130fd4 3218 ident = od->id_inst_ptr;
mbed_official 0:51ac1d130fd4 3219 snmp_oidtoip(&ident[1], &dest);
mbed_official 0:51ac1d130fd4 3220
mbed_official 0:51ac1d130fd4 3221 if (ip_addr_isany(&dest))
mbed_official 0:51ac1d130fd4 3222 {
mbed_official 0:51ac1d130fd4 3223 /* ip_route() uses default netif for default route */
mbed_official 0:51ac1d130fd4 3224 netif = netif_default;
mbed_official 0:51ac1d130fd4 3225 }
mbed_official 0:51ac1d130fd4 3226 else
mbed_official 0:51ac1d130fd4 3227 {
mbed_official 0:51ac1d130fd4 3228 /* not using ip_route(), need exact match! */
mbed_official 0:51ac1d130fd4 3229 netif = netif_list;
mbed_official 0:51ac1d130fd4 3230 while ((netif != NULL) &&
mbed_official 0:51ac1d130fd4 3231 !ip_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) )
mbed_official 0:51ac1d130fd4 3232 {
mbed_official 0:51ac1d130fd4 3233 netif = netif->next;
mbed_official 0:51ac1d130fd4 3234 }
mbed_official 0:51ac1d130fd4 3235 }
mbed_official 0:51ac1d130fd4 3236 if (netif != NULL)
mbed_official 0:51ac1d130fd4 3237 {
mbed_official 0:51ac1d130fd4 3238 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3239 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 3240 switch (id)
mbed_official 0:51ac1d130fd4 3241 {
mbed_official 0:51ac1d130fd4 3242 case 1: /* ipRouteDest */
mbed_official 0:51ac1d130fd4 3243 {
mbed_official 0:51ac1d130fd4 3244 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3245
mbed_official 0:51ac1d130fd4 3246 if (ip_addr_isany(&dest))
mbed_official 0:51ac1d130fd4 3247 {
mbed_official 0:51ac1d130fd4 3248 /* default rte has 0.0.0.0 dest */
mbed_official 0:51ac1d130fd4 3249 ip_addr_set_zero(dst);
mbed_official 0:51ac1d130fd4 3250 }
mbed_official 0:51ac1d130fd4 3251 else
mbed_official 0:51ac1d130fd4 3252 {
mbed_official 0:51ac1d130fd4 3253 /* netifs have netaddress dest */
mbed_official 0:51ac1d130fd4 3254 ip_addr_get_network(dst, &netif->ip_addr, &netif->netmask);
mbed_official 0:51ac1d130fd4 3255 }
mbed_official 0:51ac1d130fd4 3256 }
mbed_official 0:51ac1d130fd4 3257 break;
mbed_official 0:51ac1d130fd4 3258 case 2: /* ipRouteIfIndex */
mbed_official 0:51ac1d130fd4 3259 {
mbed_official 0:51ac1d130fd4 3260 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3261
mbed_official 0:51ac1d130fd4 3262 snmp_netiftoifindex(netif, sint_ptr);
mbed_official 0:51ac1d130fd4 3263 }
mbed_official 0:51ac1d130fd4 3264 break;
mbed_official 0:51ac1d130fd4 3265 case 3: /* ipRouteMetric1 */
mbed_official 0:51ac1d130fd4 3266 {
mbed_official 0:51ac1d130fd4 3267 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3268
mbed_official 0:51ac1d130fd4 3269 if (ip_addr_isany(&dest))
mbed_official 0:51ac1d130fd4 3270 {
mbed_official 0:51ac1d130fd4 3271 /* default rte has metric 1 */
mbed_official 0:51ac1d130fd4 3272 *sint_ptr = 1;
mbed_official 0:51ac1d130fd4 3273 }
mbed_official 0:51ac1d130fd4 3274 else
mbed_official 0:51ac1d130fd4 3275 {
mbed_official 0:51ac1d130fd4 3276 /* other rtes have metric 0 */
mbed_official 0:51ac1d130fd4 3277 *sint_ptr = 0;
mbed_official 0:51ac1d130fd4 3278 }
mbed_official 0:51ac1d130fd4 3279 }
mbed_official 0:51ac1d130fd4 3280 break;
mbed_official 0:51ac1d130fd4 3281 case 4: /* ipRouteMetric2 */
mbed_official 0:51ac1d130fd4 3282 case 5: /* ipRouteMetric3 */
mbed_official 0:51ac1d130fd4 3283 case 6: /* ipRouteMetric4 */
mbed_official 0:51ac1d130fd4 3284 case 12: /* ipRouteMetric5 */
mbed_official 0:51ac1d130fd4 3285 {
mbed_official 0:51ac1d130fd4 3286 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3287 /* not used */
mbed_official 0:51ac1d130fd4 3288 *sint_ptr = -1;
mbed_official 0:51ac1d130fd4 3289 }
mbed_official 0:51ac1d130fd4 3290 break;
mbed_official 0:51ac1d130fd4 3291 case 7: /* ipRouteNextHop */
mbed_official 0:51ac1d130fd4 3292 {
mbed_official 0:51ac1d130fd4 3293 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3294
mbed_official 0:51ac1d130fd4 3295 if (ip_addr_isany(&dest))
mbed_official 0:51ac1d130fd4 3296 {
mbed_official 0:51ac1d130fd4 3297 /* default rte: gateway */
mbed_official 0:51ac1d130fd4 3298 *dst = netif->gw;
mbed_official 0:51ac1d130fd4 3299 }
mbed_official 0:51ac1d130fd4 3300 else
mbed_official 0:51ac1d130fd4 3301 {
mbed_official 0:51ac1d130fd4 3302 /* other rtes: netif ip_addr */
mbed_official 0:51ac1d130fd4 3303 *dst = netif->ip_addr;
mbed_official 0:51ac1d130fd4 3304 }
mbed_official 0:51ac1d130fd4 3305 }
mbed_official 0:51ac1d130fd4 3306 break;
mbed_official 0:51ac1d130fd4 3307 case 8: /* ipRouteType */
mbed_official 0:51ac1d130fd4 3308 {
mbed_official 0:51ac1d130fd4 3309 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3310
mbed_official 0:51ac1d130fd4 3311 if (ip_addr_isany(&dest))
mbed_official 0:51ac1d130fd4 3312 {
mbed_official 0:51ac1d130fd4 3313 /* default rte is indirect */
mbed_official 0:51ac1d130fd4 3314 *sint_ptr = 4;
mbed_official 0:51ac1d130fd4 3315 }
mbed_official 0:51ac1d130fd4 3316 else
mbed_official 0:51ac1d130fd4 3317 {
mbed_official 0:51ac1d130fd4 3318 /* other rtes are direct */
mbed_official 0:51ac1d130fd4 3319 *sint_ptr = 3;
mbed_official 0:51ac1d130fd4 3320 }
mbed_official 0:51ac1d130fd4 3321 }
mbed_official 0:51ac1d130fd4 3322 break;
mbed_official 0:51ac1d130fd4 3323 case 9: /* ipRouteProto */
mbed_official 0:51ac1d130fd4 3324 {
mbed_official 0:51ac1d130fd4 3325 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3326 /* locally defined routes */
mbed_official 0:51ac1d130fd4 3327 *sint_ptr = 2;
mbed_official 0:51ac1d130fd4 3328 }
mbed_official 0:51ac1d130fd4 3329 break;
mbed_official 0:51ac1d130fd4 3330 case 10: /* ipRouteAge */
mbed_official 0:51ac1d130fd4 3331 {
mbed_official 0:51ac1d130fd4 3332 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3333 /** @todo (sysuptime - timestamp last change) / 100
mbed_official 0:51ac1d130fd4 3334 @see snmp_insert_iprteidx_tree() */
mbed_official 0:51ac1d130fd4 3335 *sint_ptr = 0;
mbed_official 0:51ac1d130fd4 3336 }
mbed_official 0:51ac1d130fd4 3337 break;
mbed_official 0:51ac1d130fd4 3338 case 11: /* ipRouteMask */
mbed_official 0:51ac1d130fd4 3339 {
mbed_official 0:51ac1d130fd4 3340 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3341
mbed_official 0:51ac1d130fd4 3342 if (ip_addr_isany(&dest))
mbed_official 0:51ac1d130fd4 3343 {
mbed_official 0:51ac1d130fd4 3344 /* default rte use 0.0.0.0 mask */
mbed_official 0:51ac1d130fd4 3345 ip_addr_set_zero(dst);
mbed_official 0:51ac1d130fd4 3346 }
mbed_official 0:51ac1d130fd4 3347 else
mbed_official 0:51ac1d130fd4 3348 {
mbed_official 0:51ac1d130fd4 3349 /* other rtes use netmask */
mbed_official 0:51ac1d130fd4 3350 *dst = netif->netmask;
mbed_official 0:51ac1d130fd4 3351 }
mbed_official 0:51ac1d130fd4 3352 }
mbed_official 0:51ac1d130fd4 3353 break;
mbed_official 0:51ac1d130fd4 3354 case 13: /* ipRouteInfo */
mbed_official 0:51ac1d130fd4 3355 objectidncpy((s32_t*)value, (s32_t*)iprouteinfo.id, (u8_t)(len / sizeof(s32_t)));
mbed_official 0:51ac1d130fd4 3356 break;
mbed_official 0:51ac1d130fd4 3357 }
mbed_official 0:51ac1d130fd4 3358 }
mbed_official 0:51ac1d130fd4 3359 }
mbed_official 0:51ac1d130fd4 3360
mbed_official 0:51ac1d130fd4 3361 static void
mbed_official 0:51ac1d130fd4 3362 ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3363 {
mbed_official 0:51ac1d130fd4 3364 /* return to object name, adding index depth (5) */
mbed_official 0:51ac1d130fd4 3365 ident_len += 5;
mbed_official 0:51ac1d130fd4 3366 ident -= 5;
mbed_official 0:51ac1d130fd4 3367
mbed_official 0:51ac1d130fd4 3368 if (ident_len == 6)
mbed_official 0:51ac1d130fd4 3369 {
mbed_official 0:51ac1d130fd4 3370 u8_t id;
mbed_official 0:51ac1d130fd4 3371
mbed_official 0:51ac1d130fd4 3372 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3373 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3374
mbed_official 0:51ac1d130fd4 3375 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3376 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 3377 switch (id)
mbed_official 0:51ac1d130fd4 3378 {
mbed_official 0:51ac1d130fd4 3379 case 1: /* ipNetToMediaIfIndex */
mbed_official 0:51ac1d130fd4 3380 case 4: /* ipNetToMediaType */
mbed_official 0:51ac1d130fd4 3381 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3382 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3383 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3384 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3385 break;
mbed_official 0:51ac1d130fd4 3386 case 2: /* ipNetToMediaPhysAddress */
mbed_official 0:51ac1d130fd4 3387 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3388 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3389 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
mbed_official 0:51ac1d130fd4 3390 od->v_len = 6; /** @todo try to use netif::hwaddr_len */
mbed_official 0:51ac1d130fd4 3391 break;
mbed_official 0:51ac1d130fd4 3392 case 3: /* ipNetToMediaNetAddress */
mbed_official 0:51ac1d130fd4 3393 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3394 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3395 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
mbed_official 0:51ac1d130fd4 3396 od->v_len = 4;
mbed_official 0:51ac1d130fd4 3397 break;
mbed_official 0:51ac1d130fd4 3398 default:
mbed_official 0:51ac1d130fd4 3399 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3400 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3401 break;
mbed_official 0:51ac1d130fd4 3402 }
mbed_official 0:51ac1d130fd4 3403 }
mbed_official 0:51ac1d130fd4 3404 else
mbed_official 0:51ac1d130fd4 3405 {
mbed_official 0:51ac1d130fd4 3406 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3407 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3408 }
mbed_official 0:51ac1d130fd4 3409 }
mbed_official 0:51ac1d130fd4 3410
mbed_official 0:51ac1d130fd4 3411 static void
mbed_official 0:51ac1d130fd4 3412 ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3413 {
mbed_official 0:51ac1d130fd4 3414 #if LWIP_ARP
mbed_official 0:51ac1d130fd4 3415 u8_t id;
mbed_official 0:51ac1d130fd4 3416 struct eth_addr* ethaddr_ret;
mbed_official 0:51ac1d130fd4 3417 ip_addr_t* ipaddr_ret;
mbed_official 0:51ac1d130fd4 3418 #endif /* LWIP_ARP */
mbed_official 0:51ac1d130fd4 3419 ip_addr_t ip;
mbed_official 0:51ac1d130fd4 3420 struct netif *netif;
mbed_official 0:51ac1d130fd4 3421
mbed_official 0:51ac1d130fd4 3422 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3423 LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */
mbed_official 0:51ac1d130fd4 3424
mbed_official 0:51ac1d130fd4 3425 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
mbed_official 0:51ac1d130fd4 3426 snmp_oidtoip(&od->id_inst_ptr[2], &ip);
mbed_official 0:51ac1d130fd4 3427
mbed_official 0:51ac1d130fd4 3428 #if LWIP_ARP /** @todo implement a netif_find_addr */
mbed_official 0:51ac1d130fd4 3429 if (etharp_find_addr(netif, &ip, &ethaddr_ret, &ipaddr_ret) > -1)
mbed_official 0:51ac1d130fd4 3430 {
mbed_official 0:51ac1d130fd4 3431 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3432 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3433 switch (id)
mbed_official 0:51ac1d130fd4 3434 {
mbed_official 0:51ac1d130fd4 3435 case 1: /* ipNetToMediaIfIndex */
mbed_official 0:51ac1d130fd4 3436 {
mbed_official 0:51ac1d130fd4 3437 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3438 *sint_ptr = od->id_inst_ptr[1];
mbed_official 0:51ac1d130fd4 3439 }
mbed_official 0:51ac1d130fd4 3440 break;
mbed_official 0:51ac1d130fd4 3441 case 2: /* ipNetToMediaPhysAddress */
mbed_official 0:51ac1d130fd4 3442 {
mbed_official 0:51ac1d130fd4 3443 struct eth_addr *dst = (struct eth_addr*)value;
mbed_official 0:51ac1d130fd4 3444
mbed_official 0:51ac1d130fd4 3445 *dst = *ethaddr_ret;
mbed_official 0:51ac1d130fd4 3446 }
mbed_official 0:51ac1d130fd4 3447 break;
mbed_official 0:51ac1d130fd4 3448 case 3: /* ipNetToMediaNetAddress */
mbed_official 0:51ac1d130fd4 3449 {
mbed_official 0:51ac1d130fd4 3450 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3451
mbed_official 0:51ac1d130fd4 3452 *dst = *ipaddr_ret;
mbed_official 0:51ac1d130fd4 3453 }
mbed_official 0:51ac1d130fd4 3454 break;
mbed_official 0:51ac1d130fd4 3455 case 4: /* ipNetToMediaType */
mbed_official 0:51ac1d130fd4 3456 {
mbed_official 0:51ac1d130fd4 3457 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3458 /* dynamic (?) */
mbed_official 0:51ac1d130fd4 3459 *sint_ptr = 3;
mbed_official 0:51ac1d130fd4 3460 }
mbed_official 0:51ac1d130fd4 3461 break;
mbed_official 0:51ac1d130fd4 3462 }
mbed_official 0:51ac1d130fd4 3463 }
mbed_official 0:51ac1d130fd4 3464 #endif /* LWIP_ARP */
mbed_official 0:51ac1d130fd4 3465 }
mbed_official 0:51ac1d130fd4 3466
mbed_official 0:51ac1d130fd4 3467 static void
mbed_official 0:51ac1d130fd4 3468 icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3469 {
mbed_official 0:51ac1d130fd4 3470 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 3471 ident_len += 1;
mbed_official 0:51ac1d130fd4 3472 ident -= 1;
mbed_official 0:51ac1d130fd4 3473 if ((ident_len == 2) &&
mbed_official 0:51ac1d130fd4 3474 (ident[0] > 0) && (ident[0] < 27))
mbed_official 0:51ac1d130fd4 3475 {
mbed_official 0:51ac1d130fd4 3476 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3477 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3478
mbed_official 0:51ac1d130fd4 3479 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 3480 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3481 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
mbed_official 0:51ac1d130fd4 3482 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 3483 }
mbed_official 0:51ac1d130fd4 3484 else
mbed_official 0:51ac1d130fd4 3485 {
mbed_official 0:51ac1d130fd4 3486 LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3487 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3488 }
mbed_official 0:51ac1d130fd4 3489 }
mbed_official 0:51ac1d130fd4 3490
mbed_official 0:51ac1d130fd4 3491 static void
mbed_official 0:51ac1d130fd4 3492 icmp_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3493 {
mbed_official 0:51ac1d130fd4 3494 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 3495 u8_t id;
mbed_official 0:51ac1d130fd4 3496
mbed_official 0:51ac1d130fd4 3497 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3498 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3499 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3500 switch (id)
mbed_official 0:51ac1d130fd4 3501 {
mbed_official 0:51ac1d130fd4 3502 case 1: /* icmpInMsgs */
mbed_official 0:51ac1d130fd4 3503 *uint_ptr = icmpinmsgs;
mbed_official 0:51ac1d130fd4 3504 break;
mbed_official 0:51ac1d130fd4 3505 case 2: /* icmpInErrors */
mbed_official 0:51ac1d130fd4 3506 *uint_ptr = icmpinerrors;
mbed_official 0:51ac1d130fd4 3507 break;
mbed_official 0:51ac1d130fd4 3508 case 3: /* icmpInDestUnreachs */
mbed_official 0:51ac1d130fd4 3509 *uint_ptr = icmpindestunreachs;
mbed_official 0:51ac1d130fd4 3510 break;
mbed_official 0:51ac1d130fd4 3511 case 4: /* icmpInTimeExcds */
mbed_official 0:51ac1d130fd4 3512 *uint_ptr = icmpintimeexcds;
mbed_official 0:51ac1d130fd4 3513 break;
mbed_official 0:51ac1d130fd4 3514 case 5: /* icmpInParmProbs */
mbed_official 0:51ac1d130fd4 3515 *uint_ptr = icmpinparmprobs;
mbed_official 0:51ac1d130fd4 3516 break;
mbed_official 0:51ac1d130fd4 3517 case 6: /* icmpInSrcQuenchs */
mbed_official 0:51ac1d130fd4 3518 *uint_ptr = icmpinsrcquenchs;
mbed_official 0:51ac1d130fd4 3519 break;
mbed_official 0:51ac1d130fd4 3520 case 7: /* icmpInRedirects */
mbed_official 0:51ac1d130fd4 3521 *uint_ptr = icmpinredirects;
mbed_official 0:51ac1d130fd4 3522 break;
mbed_official 0:51ac1d130fd4 3523 case 8: /* icmpInEchos */
mbed_official 0:51ac1d130fd4 3524 *uint_ptr = icmpinechos;
mbed_official 0:51ac1d130fd4 3525 break;
mbed_official 0:51ac1d130fd4 3526 case 9: /* icmpInEchoReps */
mbed_official 0:51ac1d130fd4 3527 *uint_ptr = icmpinechoreps;
mbed_official 0:51ac1d130fd4 3528 break;
mbed_official 0:51ac1d130fd4 3529 case 10: /* icmpInTimestamps */
mbed_official 0:51ac1d130fd4 3530 *uint_ptr = icmpintimestamps;
mbed_official 0:51ac1d130fd4 3531 break;
mbed_official 0:51ac1d130fd4 3532 case 11: /* icmpInTimestampReps */
mbed_official 0:51ac1d130fd4 3533 *uint_ptr = icmpintimestampreps;
mbed_official 0:51ac1d130fd4 3534 break;
mbed_official 0:51ac1d130fd4 3535 case 12: /* icmpInAddrMasks */
mbed_official 0:51ac1d130fd4 3536 *uint_ptr = icmpinaddrmasks;
mbed_official 0:51ac1d130fd4 3537 break;
mbed_official 0:51ac1d130fd4 3538 case 13: /* icmpInAddrMaskReps */
mbed_official 0:51ac1d130fd4 3539 *uint_ptr = icmpinaddrmaskreps;
mbed_official 0:51ac1d130fd4 3540 break;
mbed_official 0:51ac1d130fd4 3541 case 14: /* icmpOutMsgs */
mbed_official 0:51ac1d130fd4 3542 *uint_ptr = icmpoutmsgs;
mbed_official 0:51ac1d130fd4 3543 break;
mbed_official 0:51ac1d130fd4 3544 case 15: /* icmpOutErrors */
mbed_official 0:51ac1d130fd4 3545 *uint_ptr = icmpouterrors;
mbed_official 0:51ac1d130fd4 3546 break;
mbed_official 0:51ac1d130fd4 3547 case 16: /* icmpOutDestUnreachs */
mbed_official 0:51ac1d130fd4 3548 *uint_ptr = icmpoutdestunreachs;
mbed_official 0:51ac1d130fd4 3549 break;
mbed_official 0:51ac1d130fd4 3550 case 17: /* icmpOutTimeExcds */
mbed_official 0:51ac1d130fd4 3551 *uint_ptr = icmpouttimeexcds;
mbed_official 0:51ac1d130fd4 3552 break;
mbed_official 0:51ac1d130fd4 3553 case 18: /* icmpOutParmProbs */
mbed_official 0:51ac1d130fd4 3554 *uint_ptr = icmpoutparmprobs;
mbed_official 0:51ac1d130fd4 3555 break;
mbed_official 0:51ac1d130fd4 3556 case 19: /* icmpOutSrcQuenchs */
mbed_official 0:51ac1d130fd4 3557 *uint_ptr = icmpoutsrcquenchs;
mbed_official 0:51ac1d130fd4 3558 break;
mbed_official 0:51ac1d130fd4 3559 case 20: /* icmpOutRedirects */
mbed_official 0:51ac1d130fd4 3560 *uint_ptr = icmpoutredirects;
mbed_official 0:51ac1d130fd4 3561 break;
mbed_official 0:51ac1d130fd4 3562 case 21: /* icmpOutEchos */
mbed_official 0:51ac1d130fd4 3563 *uint_ptr = icmpoutechos;
mbed_official 0:51ac1d130fd4 3564 break;
mbed_official 0:51ac1d130fd4 3565 case 22: /* icmpOutEchoReps */
mbed_official 0:51ac1d130fd4 3566 *uint_ptr = icmpoutechoreps;
mbed_official 0:51ac1d130fd4 3567 break;
mbed_official 0:51ac1d130fd4 3568 case 23: /* icmpOutTimestamps */
mbed_official 0:51ac1d130fd4 3569 *uint_ptr = icmpouttimestamps;
mbed_official 0:51ac1d130fd4 3570 break;
mbed_official 0:51ac1d130fd4 3571 case 24: /* icmpOutTimestampReps */
mbed_official 0:51ac1d130fd4 3572 *uint_ptr = icmpouttimestampreps;
mbed_official 0:51ac1d130fd4 3573 break;
mbed_official 0:51ac1d130fd4 3574 case 25: /* icmpOutAddrMasks */
mbed_official 0:51ac1d130fd4 3575 *uint_ptr = icmpoutaddrmasks;
mbed_official 0:51ac1d130fd4 3576 break;
mbed_official 0:51ac1d130fd4 3577 case 26: /* icmpOutAddrMaskReps */
mbed_official 0:51ac1d130fd4 3578 *uint_ptr = icmpoutaddrmaskreps;
mbed_official 0:51ac1d130fd4 3579 break;
mbed_official 0:51ac1d130fd4 3580 }
mbed_official 0:51ac1d130fd4 3581 }
mbed_official 0:51ac1d130fd4 3582
mbed_official 0:51ac1d130fd4 3583 #if LWIP_TCP
mbed_official 0:51ac1d130fd4 3584 /** @todo tcp grp */
mbed_official 0:51ac1d130fd4 3585 static void
mbed_official 0:51ac1d130fd4 3586 tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3587 {
mbed_official 0:51ac1d130fd4 3588 u8_t id;
mbed_official 0:51ac1d130fd4 3589
mbed_official 0:51ac1d130fd4 3590 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 3591 ident_len += 1;
mbed_official 0:51ac1d130fd4 3592 ident -= 1;
mbed_official 0:51ac1d130fd4 3593 if (ident_len == 2)
mbed_official 0:51ac1d130fd4 3594 {
mbed_official 0:51ac1d130fd4 3595 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3596 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3597
mbed_official 0:51ac1d130fd4 3598 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3599 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 3600 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id));
mbed_official 0:51ac1d130fd4 3601
mbed_official 0:51ac1d130fd4 3602 switch (id)
mbed_official 0:51ac1d130fd4 3603 {
mbed_official 0:51ac1d130fd4 3604 case 1: /* tcpRtoAlgorithm */
mbed_official 0:51ac1d130fd4 3605 case 2: /* tcpRtoMin */
mbed_official 0:51ac1d130fd4 3606 case 3: /* tcpRtoMax */
mbed_official 0:51ac1d130fd4 3607 case 4: /* tcpMaxConn */
mbed_official 0:51ac1d130fd4 3608 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 3609 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3610 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3611 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3612 break;
mbed_official 0:51ac1d130fd4 3613 case 5: /* tcpActiveOpens */
mbed_official 0:51ac1d130fd4 3614 case 6: /* tcpPassiveOpens */
mbed_official 0:51ac1d130fd4 3615 case 7: /* tcpAttemptFails */
mbed_official 0:51ac1d130fd4 3616 case 8: /* tcpEstabResets */
mbed_official 0:51ac1d130fd4 3617 case 10: /* tcpInSegs */
mbed_official 0:51ac1d130fd4 3618 case 11: /* tcpOutSegs */
mbed_official 0:51ac1d130fd4 3619 case 12: /* tcpRetransSegs */
mbed_official 0:51ac1d130fd4 3620 case 14: /* tcpInErrs */
mbed_official 0:51ac1d130fd4 3621 case 15: /* tcpOutRsts */
mbed_official 0:51ac1d130fd4 3622 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 3623 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3624 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
mbed_official 0:51ac1d130fd4 3625 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 3626 break;
mbed_official 0:51ac1d130fd4 3627 case 9: /* tcpCurrEstab */
mbed_official 0:51ac1d130fd4 3628 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3629 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3630 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
mbed_official 0:51ac1d130fd4 3631 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 3632 break;
mbed_official 0:51ac1d130fd4 3633 default:
mbed_official 0:51ac1d130fd4 3634 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3635 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3636 break;
mbed_official 0:51ac1d130fd4 3637 };
mbed_official 0:51ac1d130fd4 3638 }
mbed_official 0:51ac1d130fd4 3639 else
mbed_official 0:51ac1d130fd4 3640 {
mbed_official 0:51ac1d130fd4 3641 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3642 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3643 }
mbed_official 0:51ac1d130fd4 3644 }
mbed_official 0:51ac1d130fd4 3645
mbed_official 0:51ac1d130fd4 3646 static void
mbed_official 0:51ac1d130fd4 3647 tcp_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3648 {
mbed_official 0:51ac1d130fd4 3649 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 3650 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3651 u8_t id;
mbed_official 0:51ac1d130fd4 3652
mbed_official 0:51ac1d130fd4 3653 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3654 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3655 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3656 switch (id)
mbed_official 0:51ac1d130fd4 3657 {
mbed_official 0:51ac1d130fd4 3658 case 1: /* tcpRtoAlgorithm, vanj(4) */
mbed_official 0:51ac1d130fd4 3659 *sint_ptr = 4;
mbed_official 0:51ac1d130fd4 3660 break;
mbed_official 0:51ac1d130fd4 3661 case 2: /* tcpRtoMin */
mbed_official 0:51ac1d130fd4 3662 /* @todo not the actual value, a guess,
mbed_official 0:51ac1d130fd4 3663 needs to be calculated */
mbed_official 0:51ac1d130fd4 3664 *sint_ptr = 1000;
mbed_official 0:51ac1d130fd4 3665 break;
mbed_official 0:51ac1d130fd4 3666 case 3: /* tcpRtoMax */
mbed_official 0:51ac1d130fd4 3667 /* @todo not the actual value, a guess,
mbed_official 0:51ac1d130fd4 3668 needs to be calculated */
mbed_official 0:51ac1d130fd4 3669 *sint_ptr = 60000;
mbed_official 0:51ac1d130fd4 3670 break;
mbed_official 0:51ac1d130fd4 3671 case 4: /* tcpMaxConn */
mbed_official 0:51ac1d130fd4 3672 *sint_ptr = MEMP_NUM_TCP_PCB;
mbed_official 0:51ac1d130fd4 3673 break;
mbed_official 0:51ac1d130fd4 3674 case 5: /* tcpActiveOpens */
mbed_official 0:51ac1d130fd4 3675 *uint_ptr = tcpactiveopens;
mbed_official 0:51ac1d130fd4 3676 break;
mbed_official 0:51ac1d130fd4 3677 case 6: /* tcpPassiveOpens */
mbed_official 0:51ac1d130fd4 3678 *uint_ptr = tcppassiveopens;
mbed_official 0:51ac1d130fd4 3679 break;
mbed_official 0:51ac1d130fd4 3680 case 7: /* tcpAttemptFails */
mbed_official 0:51ac1d130fd4 3681 *uint_ptr = tcpattemptfails;
mbed_official 0:51ac1d130fd4 3682 break;
mbed_official 0:51ac1d130fd4 3683 case 8: /* tcpEstabResets */
mbed_official 0:51ac1d130fd4 3684 *uint_ptr = tcpestabresets;
mbed_official 0:51ac1d130fd4 3685 break;
mbed_official 0:51ac1d130fd4 3686 case 9: /* tcpCurrEstab */
mbed_official 0:51ac1d130fd4 3687 {
mbed_official 0:51ac1d130fd4 3688 u16_t tcpcurrestab = 0;
mbed_official 0:51ac1d130fd4 3689 struct tcp_pcb *pcb = tcp_active_pcbs;
mbed_official 0:51ac1d130fd4 3690 while (pcb != NULL)
mbed_official 0:51ac1d130fd4 3691 {
mbed_official 0:51ac1d130fd4 3692 if ((pcb->state == ESTABLISHED) ||
mbed_official 0:51ac1d130fd4 3693 (pcb->state == CLOSE_WAIT))
mbed_official 0:51ac1d130fd4 3694 {
mbed_official 0:51ac1d130fd4 3695 tcpcurrestab++;
mbed_official 0:51ac1d130fd4 3696 }
mbed_official 0:51ac1d130fd4 3697 pcb = pcb->next;
mbed_official 0:51ac1d130fd4 3698 }
mbed_official 0:51ac1d130fd4 3699 *uint_ptr = tcpcurrestab;
mbed_official 0:51ac1d130fd4 3700 }
mbed_official 0:51ac1d130fd4 3701 break;
mbed_official 0:51ac1d130fd4 3702 case 10: /* tcpInSegs */
mbed_official 0:51ac1d130fd4 3703 *uint_ptr = tcpinsegs;
mbed_official 0:51ac1d130fd4 3704 break;
mbed_official 0:51ac1d130fd4 3705 case 11: /* tcpOutSegs */
mbed_official 0:51ac1d130fd4 3706 *uint_ptr = tcpoutsegs;
mbed_official 0:51ac1d130fd4 3707 break;
mbed_official 0:51ac1d130fd4 3708 case 12: /* tcpRetransSegs */
mbed_official 0:51ac1d130fd4 3709 *uint_ptr = tcpretranssegs;
mbed_official 0:51ac1d130fd4 3710 break;
mbed_official 0:51ac1d130fd4 3711 case 14: /* tcpInErrs */
mbed_official 0:51ac1d130fd4 3712 *uint_ptr = tcpinerrs;
mbed_official 0:51ac1d130fd4 3713 break;
mbed_official 0:51ac1d130fd4 3714 case 15: /* tcpOutRsts */
mbed_official 0:51ac1d130fd4 3715 *uint_ptr = tcpoutrsts;
mbed_official 0:51ac1d130fd4 3716 break;
mbed_official 0:51ac1d130fd4 3717 }
mbed_official 0:51ac1d130fd4 3718 }
mbed_official 0:51ac1d130fd4 3719 #ifdef THIS_SEEMS_UNUSED
mbed_official 0:51ac1d130fd4 3720 static void
mbed_official 0:51ac1d130fd4 3721 tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3722 {
mbed_official 0:51ac1d130fd4 3723 /* return to object name, adding index depth (10) */
mbed_official 0:51ac1d130fd4 3724 ident_len += 10;
mbed_official 0:51ac1d130fd4 3725 ident -= 10;
mbed_official 0:51ac1d130fd4 3726
mbed_official 0:51ac1d130fd4 3727 if (ident_len == 11)
mbed_official 0:51ac1d130fd4 3728 {
mbed_official 0:51ac1d130fd4 3729 u8_t id;
mbed_official 0:51ac1d130fd4 3730
mbed_official 0:51ac1d130fd4 3731 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3732 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3733
mbed_official 0:51ac1d130fd4 3734 id = ident[0];
mbed_official 0:51ac1d130fd4 3735 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id));
mbed_official 0:51ac1d130fd4 3736
mbed_official 0:51ac1d130fd4 3737 switch (id)
mbed_official 0:51ac1d130fd4 3738 {
mbed_official 0:51ac1d130fd4 3739 case 1: /* tcpConnState */
mbed_official 0:51ac1d130fd4 3740 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3741 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3742 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3743 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3744 break;
mbed_official 0:51ac1d130fd4 3745 case 2: /* tcpConnLocalAddress */
mbed_official 0:51ac1d130fd4 3746 case 4: /* tcpConnRemAddress */
mbed_official 0:51ac1d130fd4 3747 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3748 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3749 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
mbed_official 0:51ac1d130fd4 3750 od->v_len = 4;
mbed_official 0:51ac1d130fd4 3751 break;
mbed_official 0:51ac1d130fd4 3752 case 3: /* tcpConnLocalPort */
mbed_official 0:51ac1d130fd4 3753 case 5: /* tcpConnRemPort */
mbed_official 0:51ac1d130fd4 3754 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3755 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3756 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3757 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3758 break;
mbed_official 0:51ac1d130fd4 3759 default:
mbed_official 0:51ac1d130fd4 3760 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3761 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3762 break;
mbed_official 0:51ac1d130fd4 3763 };
mbed_official 0:51ac1d130fd4 3764 }
mbed_official 0:51ac1d130fd4 3765 else
mbed_official 0:51ac1d130fd4 3766 {
mbed_official 0:51ac1d130fd4 3767 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3768 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3769 }
mbed_official 0:51ac1d130fd4 3770 }
mbed_official 0:51ac1d130fd4 3771
mbed_official 0:51ac1d130fd4 3772 static void
mbed_official 0:51ac1d130fd4 3773 tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3774 {
mbed_official 0:51ac1d130fd4 3775 ip_addr_t lip, rip;
mbed_official 0:51ac1d130fd4 3776 u16_t lport, rport;
mbed_official 0:51ac1d130fd4 3777 s32_t *ident;
mbed_official 0:51ac1d130fd4 3778
mbed_official 0:51ac1d130fd4 3779 ident = od->id_inst_ptr;
mbed_official 0:51ac1d130fd4 3780 snmp_oidtoip(&ident[1], &lip);
mbed_official 0:51ac1d130fd4 3781 lport = ident[5];
mbed_official 0:51ac1d130fd4 3782 snmp_oidtoip(&ident[6], &rip);
mbed_official 0:51ac1d130fd4 3783 rport = ident[10];
mbed_official 0:51ac1d130fd4 3784
mbed_official 0:51ac1d130fd4 3785 /** @todo find matching PCB */
mbed_official 0:51ac1d130fd4 3786 }
mbed_official 0:51ac1d130fd4 3787 #endif /* if 0 */
mbed_official 0:51ac1d130fd4 3788 #endif
mbed_official 0:51ac1d130fd4 3789
mbed_official 0:51ac1d130fd4 3790 static void
mbed_official 0:51ac1d130fd4 3791 udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3792 {
mbed_official 0:51ac1d130fd4 3793 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 3794 ident_len += 1;
mbed_official 0:51ac1d130fd4 3795 ident -= 1;
mbed_official 0:51ac1d130fd4 3796 if ((ident_len == 2) &&
mbed_official 0:51ac1d130fd4 3797 (ident[0] > 0) && (ident[0] < 6))
mbed_official 0:51ac1d130fd4 3798 {
mbed_official 0:51ac1d130fd4 3799 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3800 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3801
mbed_official 0:51ac1d130fd4 3802 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 3803 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3804 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
mbed_official 0:51ac1d130fd4 3805 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 3806 }
mbed_official 0:51ac1d130fd4 3807 else
mbed_official 0:51ac1d130fd4 3808 {
mbed_official 0:51ac1d130fd4 3809 LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3810 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3811 }
mbed_official 0:51ac1d130fd4 3812 }
mbed_official 0:51ac1d130fd4 3813
mbed_official 0:51ac1d130fd4 3814 static void
mbed_official 0:51ac1d130fd4 3815 udp_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3816 {
mbed_official 0:51ac1d130fd4 3817 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 3818 u8_t id;
mbed_official 0:51ac1d130fd4 3819
mbed_official 0:51ac1d130fd4 3820 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3821 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3822 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3823 switch (id)
mbed_official 0:51ac1d130fd4 3824 {
mbed_official 0:51ac1d130fd4 3825 case 1: /* udpInDatagrams */
mbed_official 0:51ac1d130fd4 3826 *uint_ptr = udpindatagrams;
mbed_official 0:51ac1d130fd4 3827 break;
mbed_official 0:51ac1d130fd4 3828 case 2: /* udpNoPorts */
mbed_official 0:51ac1d130fd4 3829 *uint_ptr = udpnoports;
mbed_official 0:51ac1d130fd4 3830 break;
mbed_official 0:51ac1d130fd4 3831 case 3: /* udpInErrors */
mbed_official 0:51ac1d130fd4 3832 *uint_ptr = udpinerrors;
mbed_official 0:51ac1d130fd4 3833 break;
mbed_official 0:51ac1d130fd4 3834 case 4: /* udpOutDatagrams */
mbed_official 0:51ac1d130fd4 3835 *uint_ptr = udpoutdatagrams;
mbed_official 0:51ac1d130fd4 3836 break;
mbed_official 0:51ac1d130fd4 3837 }
mbed_official 0:51ac1d130fd4 3838 }
mbed_official 0:51ac1d130fd4 3839
mbed_official 0:51ac1d130fd4 3840 static void
mbed_official 0:51ac1d130fd4 3841 udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3842 {
mbed_official 0:51ac1d130fd4 3843 /* return to object name, adding index depth (5) */
mbed_official 0:51ac1d130fd4 3844 ident_len += 5;
mbed_official 0:51ac1d130fd4 3845 ident -= 5;
mbed_official 0:51ac1d130fd4 3846
mbed_official 0:51ac1d130fd4 3847 if (ident_len == 6)
mbed_official 0:51ac1d130fd4 3848 {
mbed_official 0:51ac1d130fd4 3849 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3850 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3851
mbed_official 0:51ac1d130fd4 3852 switch (ident[0])
mbed_official 0:51ac1d130fd4 3853 {
mbed_official 0:51ac1d130fd4 3854 case 1: /* udpLocalAddress */
mbed_official 0:51ac1d130fd4 3855 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3856 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3857 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
mbed_official 0:51ac1d130fd4 3858 od->v_len = 4;
mbed_official 0:51ac1d130fd4 3859 break;
mbed_official 0:51ac1d130fd4 3860 case 2: /* udpLocalPort */
mbed_official 0:51ac1d130fd4 3861 od->instance = MIB_OBJECT_TAB;
mbed_official 0:51ac1d130fd4 3862 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3863 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3864 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3865 break;
mbed_official 0:51ac1d130fd4 3866 default:
mbed_official 0:51ac1d130fd4 3867 LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3868 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3869 break;
mbed_official 0:51ac1d130fd4 3870 }
mbed_official 0:51ac1d130fd4 3871 }
mbed_official 0:51ac1d130fd4 3872 else
mbed_official 0:51ac1d130fd4 3873 {
mbed_official 0:51ac1d130fd4 3874 LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3875 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3876 }
mbed_official 0:51ac1d130fd4 3877 }
mbed_official 0:51ac1d130fd4 3878
mbed_official 0:51ac1d130fd4 3879 static void
mbed_official 0:51ac1d130fd4 3880 udpentry_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3881 {
mbed_official 0:51ac1d130fd4 3882 u8_t id;
mbed_official 0:51ac1d130fd4 3883 struct udp_pcb *pcb;
mbed_official 0:51ac1d130fd4 3884 ip_addr_t ip;
mbed_official 0:51ac1d130fd4 3885 u16_t port;
mbed_official 0:51ac1d130fd4 3886
mbed_official 0:51ac1d130fd4 3887 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3888 snmp_oidtoip(&od->id_inst_ptr[1], &ip);
mbed_official 0:51ac1d130fd4 3889 LWIP_ASSERT("invalid port", (od->id_inst_ptr[5] >= 0) && (od->id_inst_ptr[5] <= 0xffff));
mbed_official 0:51ac1d130fd4 3890 port = (u16_t)od->id_inst_ptr[5];
mbed_official 0:51ac1d130fd4 3891
mbed_official 0:51ac1d130fd4 3892 pcb = udp_pcbs;
mbed_official 0:51ac1d130fd4 3893 while ((pcb != NULL) &&
mbed_official 0:51ac1d130fd4 3894 !(ip_addr_cmp(&pcb->local_ip, &ip) &&
mbed_official 0:51ac1d130fd4 3895 (pcb->local_port == port)))
mbed_official 0:51ac1d130fd4 3896 {
mbed_official 0:51ac1d130fd4 3897 pcb = pcb->next;
mbed_official 0:51ac1d130fd4 3898 }
mbed_official 0:51ac1d130fd4 3899
mbed_official 0:51ac1d130fd4 3900 if (pcb != NULL)
mbed_official 0:51ac1d130fd4 3901 {
mbed_official 0:51ac1d130fd4 3902 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3903 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3904 switch (id)
mbed_official 0:51ac1d130fd4 3905 {
mbed_official 0:51ac1d130fd4 3906 case 1: /* udpLocalAddress */
mbed_official 0:51ac1d130fd4 3907 {
mbed_official 0:51ac1d130fd4 3908 ip_addr_t *dst = (ip_addr_t*)value;
mbed_official 0:51ac1d130fd4 3909 *dst = pcb->local_ip;
mbed_official 0:51ac1d130fd4 3910 }
mbed_official 0:51ac1d130fd4 3911 break;
mbed_official 0:51ac1d130fd4 3912 case 2: /* udpLocalPort */
mbed_official 0:51ac1d130fd4 3913 {
mbed_official 0:51ac1d130fd4 3914 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 3915 *sint_ptr = pcb->local_port;
mbed_official 0:51ac1d130fd4 3916 }
mbed_official 0:51ac1d130fd4 3917 break;
mbed_official 0:51ac1d130fd4 3918 }
mbed_official 0:51ac1d130fd4 3919 }
mbed_official 0:51ac1d130fd4 3920 }
mbed_official 0:51ac1d130fd4 3921
mbed_official 0:51ac1d130fd4 3922 static void
mbed_official 0:51ac1d130fd4 3923 snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
mbed_official 0:51ac1d130fd4 3924 {
mbed_official 0:51ac1d130fd4 3925 /* return to object name, adding index depth (1) */
mbed_official 0:51ac1d130fd4 3926 ident_len += 1;
mbed_official 0:51ac1d130fd4 3927 ident -= 1;
mbed_official 0:51ac1d130fd4 3928 if (ident_len == 2)
mbed_official 0:51ac1d130fd4 3929 {
mbed_official 0:51ac1d130fd4 3930 u8_t id;
mbed_official 0:51ac1d130fd4 3931
mbed_official 0:51ac1d130fd4 3932 od->id_inst_len = ident_len;
mbed_official 0:51ac1d130fd4 3933 od->id_inst_ptr = ident;
mbed_official 0:51ac1d130fd4 3934
mbed_official 0:51ac1d130fd4 3935 LWIP_ASSERT("invalid id", (ident[0] >= 0) && (ident[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3936 id = (u8_t)ident[0];
mbed_official 0:51ac1d130fd4 3937 switch (id)
mbed_official 0:51ac1d130fd4 3938 {
mbed_official 0:51ac1d130fd4 3939 case 1: /* snmpInPkts */
mbed_official 0:51ac1d130fd4 3940 case 2: /* snmpOutPkts */
mbed_official 0:51ac1d130fd4 3941 case 3: /* snmpInBadVersions */
mbed_official 0:51ac1d130fd4 3942 case 4: /* snmpInBadCommunityNames */
mbed_official 0:51ac1d130fd4 3943 case 5: /* snmpInBadCommunityUses */
mbed_official 0:51ac1d130fd4 3944 case 6: /* snmpInASNParseErrs */
mbed_official 0:51ac1d130fd4 3945 case 8: /* snmpInTooBigs */
mbed_official 0:51ac1d130fd4 3946 case 9: /* snmpInNoSuchNames */
mbed_official 0:51ac1d130fd4 3947 case 10: /* snmpInBadValues */
mbed_official 0:51ac1d130fd4 3948 case 11: /* snmpInReadOnlys */
mbed_official 0:51ac1d130fd4 3949 case 12: /* snmpInGenErrs */
mbed_official 0:51ac1d130fd4 3950 case 13: /* snmpInTotalReqVars */
mbed_official 0:51ac1d130fd4 3951 case 14: /* snmpInTotalSetVars */
mbed_official 0:51ac1d130fd4 3952 case 15: /* snmpInGetRequests */
mbed_official 0:51ac1d130fd4 3953 case 16: /* snmpInGetNexts */
mbed_official 0:51ac1d130fd4 3954 case 17: /* snmpInSetRequests */
mbed_official 0:51ac1d130fd4 3955 case 18: /* snmpInGetResponses */
mbed_official 0:51ac1d130fd4 3956 case 19: /* snmpInTraps */
mbed_official 0:51ac1d130fd4 3957 case 20: /* snmpOutTooBigs */
mbed_official 0:51ac1d130fd4 3958 case 21: /* snmpOutNoSuchNames */
mbed_official 0:51ac1d130fd4 3959 case 22: /* snmpOutBadValues */
mbed_official 0:51ac1d130fd4 3960 case 24: /* snmpOutGenErrs */
mbed_official 0:51ac1d130fd4 3961 case 25: /* snmpOutGetRequests */
mbed_official 0:51ac1d130fd4 3962 case 26: /* snmpOutGetNexts */
mbed_official 0:51ac1d130fd4 3963 case 27: /* snmpOutSetRequests */
mbed_official 0:51ac1d130fd4 3964 case 28: /* snmpOutGetResponses */
mbed_official 0:51ac1d130fd4 3965 case 29: /* snmpOutTraps */
mbed_official 0:51ac1d130fd4 3966 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 3967 od->access = MIB_OBJECT_READ_ONLY;
mbed_official 0:51ac1d130fd4 3968 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
mbed_official 0:51ac1d130fd4 3969 od->v_len = sizeof(u32_t);
mbed_official 0:51ac1d130fd4 3970 break;
mbed_official 0:51ac1d130fd4 3971 case 30: /* snmpEnableAuthenTraps */
mbed_official 0:51ac1d130fd4 3972 od->instance = MIB_OBJECT_SCALAR;
mbed_official 0:51ac1d130fd4 3973 od->access = MIB_OBJECT_READ_WRITE;
mbed_official 0:51ac1d130fd4 3974 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
mbed_official 0:51ac1d130fd4 3975 od->v_len = sizeof(s32_t);
mbed_official 0:51ac1d130fd4 3976 break;
mbed_official 0:51ac1d130fd4 3977 default:
mbed_official 0:51ac1d130fd4 3978 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no such object\n"));
mbed_official 0:51ac1d130fd4 3979 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3980 break;
mbed_official 0:51ac1d130fd4 3981 };
mbed_official 0:51ac1d130fd4 3982 }
mbed_official 0:51ac1d130fd4 3983 else
mbed_official 0:51ac1d130fd4 3984 {
mbed_official 0:51ac1d130fd4 3985 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no scalar\n"));
mbed_official 0:51ac1d130fd4 3986 od->instance = MIB_OBJECT_NONE;
mbed_official 0:51ac1d130fd4 3987 }
mbed_official 0:51ac1d130fd4 3988 }
mbed_official 0:51ac1d130fd4 3989
mbed_official 0:51ac1d130fd4 3990 static void
mbed_official 0:51ac1d130fd4 3991 snmp_get_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 3992 {
mbed_official 0:51ac1d130fd4 3993 u32_t *uint_ptr = (u32_t*)value;
mbed_official 0:51ac1d130fd4 3994 u8_t id;
mbed_official 0:51ac1d130fd4 3995
mbed_official 0:51ac1d130fd4 3996 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 3997 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 3998 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 3999 switch (id)
mbed_official 0:51ac1d130fd4 4000 {
mbed_official 0:51ac1d130fd4 4001 case 1: /* snmpInPkts */
mbed_official 0:51ac1d130fd4 4002 *uint_ptr = snmpinpkts;
mbed_official 0:51ac1d130fd4 4003 break;
mbed_official 0:51ac1d130fd4 4004 case 2: /* snmpOutPkts */
mbed_official 0:51ac1d130fd4 4005 *uint_ptr = snmpoutpkts;
mbed_official 0:51ac1d130fd4 4006 break;
mbed_official 0:51ac1d130fd4 4007 case 3: /* snmpInBadVersions */
mbed_official 0:51ac1d130fd4 4008 *uint_ptr = snmpinbadversions;
mbed_official 0:51ac1d130fd4 4009 break;
mbed_official 0:51ac1d130fd4 4010 case 4: /* snmpInBadCommunityNames */
mbed_official 0:51ac1d130fd4 4011 *uint_ptr = snmpinbadcommunitynames;
mbed_official 0:51ac1d130fd4 4012 break;
mbed_official 0:51ac1d130fd4 4013 case 5: /* snmpInBadCommunityUses */
mbed_official 0:51ac1d130fd4 4014 *uint_ptr = snmpinbadcommunityuses;
mbed_official 0:51ac1d130fd4 4015 break;
mbed_official 0:51ac1d130fd4 4016 case 6: /* snmpInASNParseErrs */
mbed_official 0:51ac1d130fd4 4017 *uint_ptr = snmpinasnparseerrs;
mbed_official 0:51ac1d130fd4 4018 break;
mbed_official 0:51ac1d130fd4 4019 case 8: /* snmpInTooBigs */
mbed_official 0:51ac1d130fd4 4020 *uint_ptr = snmpintoobigs;
mbed_official 0:51ac1d130fd4 4021 break;
mbed_official 0:51ac1d130fd4 4022 case 9: /* snmpInNoSuchNames */
mbed_official 0:51ac1d130fd4 4023 *uint_ptr = snmpinnosuchnames;
mbed_official 0:51ac1d130fd4 4024 break;
mbed_official 0:51ac1d130fd4 4025 case 10: /* snmpInBadValues */
mbed_official 0:51ac1d130fd4 4026 *uint_ptr = snmpinbadvalues;
mbed_official 0:51ac1d130fd4 4027 break;
mbed_official 0:51ac1d130fd4 4028 case 11: /* snmpInReadOnlys */
mbed_official 0:51ac1d130fd4 4029 *uint_ptr = snmpinreadonlys;
mbed_official 0:51ac1d130fd4 4030 break;
mbed_official 0:51ac1d130fd4 4031 case 12: /* snmpInGenErrs */
mbed_official 0:51ac1d130fd4 4032 *uint_ptr = snmpingenerrs;
mbed_official 0:51ac1d130fd4 4033 break;
mbed_official 0:51ac1d130fd4 4034 case 13: /* snmpInTotalReqVars */
mbed_official 0:51ac1d130fd4 4035 *uint_ptr = snmpintotalreqvars;
mbed_official 0:51ac1d130fd4 4036 break;
mbed_official 0:51ac1d130fd4 4037 case 14: /* snmpInTotalSetVars */
mbed_official 0:51ac1d130fd4 4038 *uint_ptr = snmpintotalsetvars;
mbed_official 0:51ac1d130fd4 4039 break;
mbed_official 0:51ac1d130fd4 4040 case 15: /* snmpInGetRequests */
mbed_official 0:51ac1d130fd4 4041 *uint_ptr = snmpingetrequests;
mbed_official 0:51ac1d130fd4 4042 break;
mbed_official 0:51ac1d130fd4 4043 case 16: /* snmpInGetNexts */
mbed_official 0:51ac1d130fd4 4044 *uint_ptr = snmpingetnexts;
mbed_official 0:51ac1d130fd4 4045 break;
mbed_official 0:51ac1d130fd4 4046 case 17: /* snmpInSetRequests */
mbed_official 0:51ac1d130fd4 4047 *uint_ptr = snmpinsetrequests;
mbed_official 0:51ac1d130fd4 4048 break;
mbed_official 0:51ac1d130fd4 4049 case 18: /* snmpInGetResponses */
mbed_official 0:51ac1d130fd4 4050 *uint_ptr = snmpingetresponses;
mbed_official 0:51ac1d130fd4 4051 break;
mbed_official 0:51ac1d130fd4 4052 case 19: /* snmpInTraps */
mbed_official 0:51ac1d130fd4 4053 *uint_ptr = snmpintraps;
mbed_official 0:51ac1d130fd4 4054 break;
mbed_official 0:51ac1d130fd4 4055 case 20: /* snmpOutTooBigs */
mbed_official 0:51ac1d130fd4 4056 *uint_ptr = snmpouttoobigs;
mbed_official 0:51ac1d130fd4 4057 break;
mbed_official 0:51ac1d130fd4 4058 case 21: /* snmpOutNoSuchNames */
mbed_official 0:51ac1d130fd4 4059 *uint_ptr = snmpoutnosuchnames;
mbed_official 0:51ac1d130fd4 4060 break;
mbed_official 0:51ac1d130fd4 4061 case 22: /* snmpOutBadValues */
mbed_official 0:51ac1d130fd4 4062 *uint_ptr = snmpoutbadvalues;
mbed_official 0:51ac1d130fd4 4063 break;
mbed_official 0:51ac1d130fd4 4064 case 24: /* snmpOutGenErrs */
mbed_official 0:51ac1d130fd4 4065 *uint_ptr = snmpoutgenerrs;
mbed_official 0:51ac1d130fd4 4066 break;
mbed_official 0:51ac1d130fd4 4067 case 25: /* snmpOutGetRequests */
mbed_official 0:51ac1d130fd4 4068 *uint_ptr = snmpoutgetrequests;
mbed_official 0:51ac1d130fd4 4069 break;
mbed_official 0:51ac1d130fd4 4070 case 26: /* snmpOutGetNexts */
mbed_official 0:51ac1d130fd4 4071 *uint_ptr = snmpoutgetnexts;
mbed_official 0:51ac1d130fd4 4072 break;
mbed_official 0:51ac1d130fd4 4073 case 27: /* snmpOutSetRequests */
mbed_official 0:51ac1d130fd4 4074 *uint_ptr = snmpoutsetrequests;
mbed_official 0:51ac1d130fd4 4075 break;
mbed_official 0:51ac1d130fd4 4076 case 28: /* snmpOutGetResponses */
mbed_official 0:51ac1d130fd4 4077 *uint_ptr = snmpoutgetresponses;
mbed_official 0:51ac1d130fd4 4078 break;
mbed_official 0:51ac1d130fd4 4079 case 29: /* snmpOutTraps */
mbed_official 0:51ac1d130fd4 4080 *uint_ptr = snmpouttraps;
mbed_official 0:51ac1d130fd4 4081 break;
mbed_official 0:51ac1d130fd4 4082 case 30: /* snmpEnableAuthenTraps */
mbed_official 0:51ac1d130fd4 4083 *uint_ptr = *snmpenableauthentraps_ptr;
mbed_official 0:51ac1d130fd4 4084 break;
mbed_official 0:51ac1d130fd4 4085 };
mbed_official 0:51ac1d130fd4 4086 }
mbed_official 0:51ac1d130fd4 4087
mbed_official 0:51ac1d130fd4 4088 /**
mbed_official 0:51ac1d130fd4 4089 * Test snmp object value before setting.
mbed_official 0:51ac1d130fd4 4090 *
mbed_official 0:51ac1d130fd4 4091 * @param od is the object definition
mbed_official 0:51ac1d130fd4 4092 * @param len return value space (in bytes)
mbed_official 0:51ac1d130fd4 4093 * @param value points to (varbind) space to copy value from.
mbed_official 0:51ac1d130fd4 4094 */
mbed_official 0:51ac1d130fd4 4095 static u8_t
mbed_official 0:51ac1d130fd4 4096 snmp_set_test(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 4097 {
mbed_official 0:51ac1d130fd4 4098 u8_t id, set_ok;
mbed_official 0:51ac1d130fd4 4099
mbed_official 0:51ac1d130fd4 4100 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 4101 set_ok = 0;
mbed_official 0:51ac1d130fd4 4102 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 4103 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 4104 if (id == 30)
mbed_official 0:51ac1d130fd4 4105 {
mbed_official 0:51ac1d130fd4 4106 /* snmpEnableAuthenTraps */
mbed_official 0:51ac1d130fd4 4107 s32_t *sint_ptr = (s32_t*)value;
mbed_official 0:51ac1d130fd4 4108
mbed_official 0:51ac1d130fd4 4109 if (snmpenableauthentraps_ptr != &snmpenableauthentraps_default)
mbed_official 0:51ac1d130fd4 4110 {
mbed_official 0:51ac1d130fd4 4111 /* we should have writable non-volatile mem here */
mbed_official 0:51ac1d130fd4 4112 if ((*sint_ptr == 1) || (*sint_ptr == 2))
mbed_official 0:51ac1d130fd4 4113 {
mbed_official 0:51ac1d130fd4 4114 set_ok = 1;
mbed_official 0:51ac1d130fd4 4115 }
mbed_official 0:51ac1d130fd4 4116 }
mbed_official 0:51ac1d130fd4 4117 else
mbed_official 0:51ac1d130fd4 4118 {
mbed_official 0:51ac1d130fd4 4119 /* const or hardwired value */
mbed_official 0:51ac1d130fd4 4120 if (*sint_ptr == snmpenableauthentraps_default)
mbed_official 0:51ac1d130fd4 4121 {
mbed_official 0:51ac1d130fd4 4122 set_ok = 1;
mbed_official 0:51ac1d130fd4 4123 }
mbed_official 0:51ac1d130fd4 4124 }
mbed_official 0:51ac1d130fd4 4125 }
mbed_official 0:51ac1d130fd4 4126 return set_ok;
mbed_official 0:51ac1d130fd4 4127 }
mbed_official 0:51ac1d130fd4 4128
mbed_official 0:51ac1d130fd4 4129 static void
mbed_official 0:51ac1d130fd4 4130 snmp_set_value(struct obj_def *od, u16_t len, void *value)
mbed_official 0:51ac1d130fd4 4131 {
mbed_official 0:51ac1d130fd4 4132 u8_t id;
mbed_official 0:51ac1d130fd4 4133
mbed_official 0:51ac1d130fd4 4134 LWIP_UNUSED_ARG(len);
mbed_official 0:51ac1d130fd4 4135 LWIP_ASSERT("invalid id", (od->id_inst_ptr[0] >= 0) && (od->id_inst_ptr[0] <= 0xff));
mbed_official 0:51ac1d130fd4 4136 id = (u8_t)od->id_inst_ptr[0];
mbed_official 0:51ac1d130fd4 4137 if (id == 30)
mbed_official 0:51ac1d130fd4 4138 {
mbed_official 0:51ac1d130fd4 4139 /* snmpEnableAuthenTraps */
mbed_official 0:51ac1d130fd4 4140 /* @todo @fixme: which kind of pointer is 'value'? s32_t or u8_t??? */
mbed_official 0:51ac1d130fd4 4141 u8_t *ptr = (u8_t*)value;
mbed_official 0:51ac1d130fd4 4142 *snmpenableauthentraps_ptr = *ptr;
mbed_official 0:51ac1d130fd4 4143 }
mbed_official 0:51ac1d130fd4 4144 }
mbed_official 0:51ac1d130fd4 4145
mbed_official 0:51ac1d130fd4 4146 #endif /* LWIP_SNMP */