I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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