3 * Management Information Base II (RFC1213) objects and functions.
5 * @note the object identifiers for this MIB-2 and private MIB tree
6 * must be kept in sorted ascending order. This to ensure correct getnext operation.
10 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
11 * All rights reserved.
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * 3. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 * Author: Christiaan Simons <christiaan.simons@axon.tv>
40 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
42 #include "lwip/snmp.h"
43 #include "lwip/netif.h"
45 #include "lwip/ip_frag.h"
48 #include "lwip/snmp_asn1.h"
49 #include "lwip/snmp_structs.h"
50 #include "netif/etharp.h"
53 * IANA assigned enterprise ID for lwIP is 26381
54 * @see http://www.iana.org/assignments/enterprise-numbers
56 * @note this enterprise ID is assigned to the lwIP project,
57 * all object identifiers living under this ID are assigned
58 * by the lwIP maintainers (contact Christiaan Simons)!
59 * @note don't change this define, use snmp_set_sysobjid()
61 * If you need to create your own private MIB you'll need
62 * to apply for your own enterprise ID with IANA:
63 * http://www.iana.org/numbers.html
65 #define SNMP_ENTERPRISE_ID 26381
66 #define SNMP_SYSOBJID_LEN 7
67 #define SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, SNMP_ENTERPRISE_ID}
69 #ifndef SNMP_SYSSERVICES
70 #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
73 #ifndef SNMP_GET_SYSUPTIME
74 #define SNMP_GET_SYSUPTIME(sysuptime)
77 static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
78 static void system_get_value(struct obj_def *od, u16_t len, void *value);
79 static u8_t system_set_test(struct obj_def *od, u16_t len, void *value);
80 static void system_set_value(struct obj_def *od, u16_t len, void *value);
81 static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
82 static void interfaces_get_value(struct obj_def *od, u16_t len, void *value);
83 static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
84 static void ifentry_get_value(struct obj_def *od, u16_t len, void *value);
85 #if !SNMP_SAFE_REQUESTS
86 static u8_t ifentry_set_test (struct obj_def *od, u16_t len, void *value);
87 static void ifentry_set_value (struct obj_def *od, u16_t len, void *value);
88 #endif /* SNMP_SAFE_REQUESTS */
89 static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
90 static void atentry_get_value(struct obj_def *od, u16_t len, void *value);
91 static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
92 static void ip_get_value(struct obj_def *od, u16_t len, void *value);
93 static u8_t ip_set_test(struct obj_def *od, u16_t len, void *value);
94 static void ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
95 static void ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value);
96 static void ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
97 static void ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value);
98 static void ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
99 static void ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value);
100 static void icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
101 static void icmp_get_value(struct obj_def *od, u16_t len, void *value);
103 static void tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
104 static void tcp_get_value(struct obj_def *od, u16_t len, void *value);
105 #ifdef THIS_SEEMS_UNUSED
106 static void tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
107 static void tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value);
110 static void udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
111 static void udp_get_value(struct obj_def *od, u16_t len, void *value);
112 static void udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
113 static void udpentry_get_value(struct obj_def *od, u16_t len, void *value);
114 static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
115 static void snmp_get_value(struct obj_def *od, u16_t len, void *value);
116 static u8_t snmp_set_test(struct obj_def *od, u16_t len, void *value);
117 static void snmp_set_value(struct obj_def *od, u16_t len, void *value);
120 /* snmp .1.3.6.1.2.1.11 */
121 const mib_scalar_node snmp_scalar = {
122 &snmp_get_object_def,
129 const s32_t snmp_ids[28] = {
130 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
131 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30
133 struct mib_node* const snmp_nodes[28] = {
134 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
135 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
136 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
137 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
138 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
139 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
140 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
141 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
142 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
143 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
144 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
145 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
146 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
147 (struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar
149 const struct mib_array_node snmp = {
150 &noleafs_get_object_def,
160 /* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */
161 /* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */
162 /* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
164 /* udp .1.3.6.1.2.1.7 */
165 /** index root node for udpTable */
166 struct mib_list_rootnode udp_root = {
167 &noleafs_get_object_def,
177 const s32_t udpentry_ids[2] = { 1, 2 };
178 struct mib_node* const udpentry_nodes[2] = {
179 (struct mib_node* const)&udp_root, (struct mib_node* const)&udp_root,
181 const struct mib_array_node udpentry = {
182 &noleafs_get_object_def,
192 s32_t udptable_id = 1;
193 struct mib_node* udptable_node = (struct mib_node* const)&udpentry;
194 struct mib_ram_array_node udptable = {
195 &noleafs_get_object_def,
205 const mib_scalar_node udp_scalar = {
213 const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 };
214 struct mib_node* const udp_nodes[5] = {
215 (struct mib_node* const)&udp_scalar, (struct mib_node* const)&udp_scalar,
216 (struct mib_node* const)&udp_scalar, (struct mib_node* const)&udp_scalar,
217 (struct mib_node* const)&udptable
219 const struct mib_array_node udp = {
220 &noleafs_get_object_def,
230 /* tcp .1.3.6.1.2.1.6 */
232 /* only if the TCP protocol is available may implement this group */
233 /** index root node for tcpConnTable */
234 struct mib_list_rootnode tcpconntree_root = {
235 &noleafs_get_object_def,
245 const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
246 struct mib_node* const tcpconnentry_nodes[5] = {
247 (struct mib_node* const)&tcpconntree_root, (struct mib_node* const)&tcpconntree_root,
248 (struct mib_node* const)&tcpconntree_root, (struct mib_node* const)&tcpconntree_root,
249 (struct mib_node* const)&tcpconntree_root
251 const struct mib_array_node tcpconnentry = {
252 &noleafs_get_object_def,
262 s32_t tcpconntable_id = 1;
263 struct mib_node* tcpconntable_node = (struct mib_node* const)&tcpconnentry;
264 struct mib_ram_array_node tcpconntable = {
265 &noleafs_get_object_def,
270 /** @todo update maxlength when inserting / deleting from table
271 0 when table is empty, 1 when more than one entry */
277 const mib_scalar_node tcp_scalar = {
285 const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
286 struct mib_node* const tcp_nodes[15] = {
287 (struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
288 (struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
289 (struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
290 (struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
291 (struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
292 (struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
293 (struct mib_node* const)&tcpconntable, (struct mib_node* const)&tcp_scalar,
294 (struct mib_node* const)&tcp_scalar
296 const struct mib_array_node tcp = {
297 &noleafs_get_object_def,
308 /* icmp .1.3.6.1.2.1.5 */
309 const mib_scalar_node icmp_scalar = {
310 &icmp_get_object_def,
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 };
318 struct mib_node* const icmp_nodes[26] = {
319 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
320 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
321 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
322 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
323 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
324 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
325 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
326 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
327 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
328 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
329 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
330 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
331 (struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar
333 const struct mib_array_node icmp = {
334 &noleafs_get_object_def,
344 /** index root node for ipNetToMediaTable */
345 struct mib_list_rootnode ipntomtree_root = {
346 &noleafs_get_object_def,
356 const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 };
357 struct mib_node* const ipntomentry_nodes[4] = {
358 (struct mib_node* const)&ipntomtree_root, (struct mib_node* const)&ipntomtree_root,
359 (struct mib_node* const)&ipntomtree_root, (struct mib_node* const)&ipntomtree_root
361 const struct mib_array_node ipntomentry = {
362 &noleafs_get_object_def,
372 s32_t ipntomtable_id = 1;
373 struct mib_node* ipntomtable_node = (struct mib_node* const)&ipntomentry;
374 struct mib_ram_array_node ipntomtable = {
375 &noleafs_get_object_def,
385 /** index root node for ipRouteTable */
386 struct mib_list_rootnode iprtetree_root = {
387 &noleafs_get_object_def,
397 const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
398 struct mib_node* const iprteentry_nodes[13] = {
399 (struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
400 (struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
401 (struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
402 (struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
403 (struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
404 (struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
405 (struct mib_node* const)&iprtetree_root
407 const struct mib_array_node iprteentry = {
408 &noleafs_get_object_def,
418 s32_t iprtetable_id = 1;
419 struct mib_node* iprtetable_node = (struct mib_node* const)&iprteentry;
420 struct mib_ram_array_node iprtetable = {
421 &noleafs_get_object_def,
431 /** index root node for ipAddrTable */
432 struct mib_list_rootnode ipaddrtree_root = {
433 &noleafs_get_object_def,
443 const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 };
444 struct mib_node* const ipaddrentry_nodes[5] = {
445 (struct mib_node* const)&ipaddrtree_root,
446 (struct mib_node* const)&ipaddrtree_root,
447 (struct mib_node* const)&ipaddrtree_root,
448 (struct mib_node* const)&ipaddrtree_root,
449 (struct mib_node* const)&ipaddrtree_root
451 const struct mib_array_node ipaddrentry = {
452 &noleafs_get_object_def,
462 s32_t ipaddrtable_id = 1;
463 struct mib_node* ipaddrtable_node = (struct mib_node* const)&ipaddrentry;
464 struct mib_ram_array_node ipaddrtable = {
465 &noleafs_get_object_def,
475 /* ip .1.3.6.1.2.1.4 */
476 const mib_scalar_node ip_scalar = {
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 };
485 struct mib_node* const ip_nodes[23] = {
486 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
487 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
488 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
489 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
490 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
491 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
492 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
493 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
494 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
495 (struct mib_node* const)&ip_scalar, (struct mib_node* const)&ipaddrtable,
496 (struct mib_node* const)&iprtetable, (struct mib_node* const)&ipntomtable,
497 (struct mib_node* const)&ip_scalar
499 const struct mib_array_node mib2_ip = {
500 &noleafs_get_object_def,
510 /** index root node for atTable */
511 struct mib_list_rootnode arptree_root = {
512 &noleafs_get_object_def,
522 const s32_t atentry_ids[3] = { 1, 2, 3 };
523 struct mib_node* const atentry_nodes[3] = {
524 (struct mib_node* const)&arptree_root,
525 (struct mib_node* const)&arptree_root,
526 (struct mib_node* const)&arptree_root
528 const struct mib_array_node atentry = {
529 &noleafs_get_object_def,
539 const s32_t attable_id = 1;
540 struct mib_node* const attable_node = (struct mib_node* const)&atentry;
541 const struct mib_array_node attable = {
542 &noleafs_get_object_def,
552 /* at .1.3.6.1.2.1.3 */
554 struct mib_node* mib2_at_node = (struct mib_node* const)&attable;
555 struct mib_ram_array_node at = {
556 &noleafs_get_object_def,
566 /** index root node for ifTable */
567 struct mib_list_rootnode iflist_root = {
568 &ifentry_get_object_def,
570 #if SNMP_SAFE_REQUESTS
573 #else /* SNMP_SAFE_REQUESTS */
576 #endif /* SNMP_SAFE_REQUESTS */
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 };
584 struct mib_node* const ifentry_nodes[22] = {
585 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
586 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
587 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
588 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
589 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
590 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
591 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
592 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
593 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
594 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
595 (struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root
597 const struct mib_array_node ifentry = {
598 &noleafs_get_object_def,
608 s32_t iftable_id = 1;
609 struct mib_node* iftable_node = (struct mib_node* const)&ifentry;
610 struct mib_ram_array_node iftable = {
611 &noleafs_get_object_def,
621 /* interfaces .1.3.6.1.2.1.2 */
622 const mib_scalar_node interfaces_scalar = {
623 &interfaces_get_object_def,
624 &interfaces_get_value,
630 const s32_t interfaces_ids[2] = { 1, 2 };
631 struct mib_node* const interfaces_nodes[2] = {
632 (struct mib_node* const)&interfaces_scalar, (struct mib_node* const)&iftable
634 const struct mib_array_node interfaces = {
635 &noleafs_get_object_def,
647 /* system .1.3.6.1.2.1.1 */
648 const mib_scalar_node sys_tem_scalar = {
649 &system_get_object_def,
656 const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 };
657 struct mib_node* const sys_tem_nodes[7] = {
658 (struct mib_node* const)&sys_tem_scalar, (struct mib_node* const)&sys_tem_scalar,
659 (struct mib_node* const)&sys_tem_scalar, (struct mib_node* const)&sys_tem_scalar,
660 (struct mib_node* const)&sys_tem_scalar, (struct mib_node* const)&sys_tem_scalar,
661 (struct mib_node* const)&sys_tem_scalar
663 /* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
664 const struct mib_array_node sys_tem = {
665 &noleafs_get_object_def,
675 /* mib-2 .1.3.6.1.2.1 */
677 #define MIB2_GROUPS 8
679 #define MIB2_GROUPS 7
681 const s32_t mib2_ids[MIB2_GROUPS] =
694 struct mib_node* const mib2_nodes[MIB2_GROUPS] = {
695 (struct mib_node* const)&sys_tem,
696 (struct mib_node* const)&interfaces,
697 (struct mib_node* const)&at,
698 (struct mib_node* const)&mib2_ip,
699 (struct mib_node* const)&icmp,
701 (struct mib_node* const)&tcp,
703 (struct mib_node* const)&udp,
704 (struct mib_node* const)&snmp
707 const struct mib_array_node mib2 = {
708 &noleafs_get_object_def,
718 /* mgmt .1.3.6.1.2 */
719 const s32_t mgmt_ids[1] = { 1 };
720 struct mib_node* const mgmt_nodes[1] = { (struct mib_node* const)&mib2 };
721 const struct mib_array_node mgmt = {
722 &noleafs_get_object_def,
732 /* internet .1.3.6.1 */
734 s32_t internet_ids[2] = { 2, 4 };
735 struct mib_node* const internet_nodes[2] = { (struct mib_node* const)&mgmt, (struct mib_node* const)&private };
736 const struct mib_array_node internet = {
737 &noleafs_get_object_def,
747 const s32_t internet_ids[1] = { 2 };
748 struct mib_node* const internet_nodes[1] = { (struct mib_node* const)&mgmt };
749 const struct mib_array_node internet = {
750 &noleafs_get_object_def,
761 /** mib-2.system.sysObjectID */
762 static struct snmp_obj_id sysobjid = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID};
763 /** enterprise ID for generic TRAPs, .iso.org.dod.internet.mgmt.mib-2.snmp */
764 static struct snmp_obj_id snmpgrp_id = {7,{1,3,6,1,2,1,11}};
765 /** mib-2.system.sysServices */
766 static const s32_t sysservices = SNMP_SYSSERVICES;
768 /** mib-2.system.sysDescr */
769 static const u8_t sysdescr_len_default = 4;
770 static const u8_t sysdescr_default[] = "lwIP";
771 static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default;
772 static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0];
773 /** mib-2.system.sysContact */
774 static const u8_t syscontact_len_default = 0;
775 static const u8_t syscontact_default[] = "";
776 static u8_t* syscontact_len_ptr = (u8_t*)&syscontact_len_default;
777 static u8_t* syscontact_ptr = (u8_t*)&syscontact_default[0];
778 /** mib-2.system.sysName */
779 static const u8_t sysname_len_default = 8;
780 static const u8_t sysname_default[] = "FQDN-unk";
781 static u8_t* sysname_len_ptr = (u8_t*)&sysname_len_default;
782 static u8_t* sysname_ptr = (u8_t*)&sysname_default[0];
783 /** mib-2.system.sysLocation */
784 static const u8_t syslocation_len_default = 0;
785 static const u8_t syslocation_default[] = "";
786 static u8_t* syslocation_len_ptr = (u8_t*)&syslocation_len_default;
787 static u8_t* syslocation_ptr = (u8_t*)&syslocation_default[0];
788 /** mib-2.snmp.snmpEnableAuthenTraps */
789 static const u8_t snmpenableauthentraps_default = 2; /* disabled */
790 static u8_t* snmpenableauthentraps_ptr = (u8_t*)&snmpenableauthentraps_default;
792 /** mib-2.interfaces.ifTable.ifEntry.ifSpecific (zeroDotZero) */
793 static const struct snmp_obj_id ifspecific = {2, {0, 0}};
794 /** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */
795 static const struct snmp_obj_id iprouteinfo = {2, {0, 0}};
799 /* mib-2.system counter(s) */
800 static u32_t sysuptime = 0;
802 /* mib-2.ip counter(s) */
803 static u32_t ipinreceives = 0,
807 ipinunknownprotos = 0,
819 iproutingdiscards = 0;
820 /* mib-2.icmp counter(s) */
821 static u32_t icmpinmsgs = 0,
823 icmpindestunreachs = 0,
826 icmpinsrcquenchs = 0,
830 icmpintimestamps = 0,
831 icmpintimestampreps = 0,
833 icmpinaddrmaskreps = 0,
836 icmpoutdestunreachs = 0,
837 icmpouttimeexcds = 0,
838 icmpoutparmprobs = 0,
839 icmpoutsrcquenchs = 0,
840 icmpoutredirects = 0,
843 icmpouttimestamps = 0,
844 icmpouttimestampreps = 0,
845 icmpoutaddrmasks = 0,
846 icmpoutaddrmaskreps = 0;
847 /* mib-2.tcp counter(s) */
848 static u32_t tcpactiveopens = 0,
857 /* mib-2.udp counter(s) */
858 static u32_t udpindatagrams = 0,
862 /* mib-2.snmp counter(s) */
863 static u32_t snmpinpkts = 0,
865 snmpinbadversions = 0,
866 snmpinbadcommunitynames = 0,
867 snmpinbadcommunityuses = 0,
868 snmpinasnparseerrs = 0,
870 snmpinnosuchnames = 0,
874 snmpintotalreqvars = 0,
875 snmpintotalsetvars = 0,
876 snmpingetrequests = 0,
878 snmpinsetrequests = 0,
879 snmpingetresponses = 0,
882 snmpoutnosuchnames = 0,
883 snmpoutbadvalues = 0,
885 snmpoutgetrequests = 0,
887 snmpoutsetrequests = 0,
888 snmpoutgetresponses = 0,
893 /* prototypes of the following functions are in lwip/src/include/lwip/snmp.h */
897 * @param dst points to destination
898 * @param src points to source
899 * @param n number of octets to copy.
901 void ocstrncpy(u8_t *dst, u8_t *src, u8_t n)
911 * Copy object identifier (s32_t) array.
913 * @param dst points to destination
914 * @param src points to source
915 * @param n number of sub identifiers to copy.
917 void objectidncpy(s32_t *dst, s32_t *src, u8_t n)
927 * Initializes sysDescr pointers.
929 * @param str if non-NULL then copy str pointer
930 * @param len points to string length, excluding zero terminator
932 void snmp_set_sysdesr(u8_t *str, u8_t *len)
937 sysdescr_len_ptr = len;
941 void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid)
947 * Initializes sysObjectID value.
949 * @param oid points to stuct snmp_obj_id to copy
951 void snmp_set_sysobjid(struct snmp_obj_id *oid)
957 * Must be called at regular 10 msec interval from a timer interrupt
958 * or signal handler depending on your runtime environment.
960 void snmp_inc_sysuptime(void)
965 void snmp_add_sysuptime(u32_t value)
970 void snmp_get_sysuptime(u32_t *value)
972 SNMP_GET_SYSUPTIME(sysuptime);
977 * Initializes sysContact pointers,
978 * e.g. ptrs to non-volatile memory external to lwIP.
980 * @param ocstr if non-NULL then copy str pointer
981 * @param ocstrlen points to string length, excluding zero terminator
983 void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen)
987 syscontact_ptr = ocstr;
988 syscontact_len_ptr = ocstrlen;
993 * Initializes sysName pointers,
994 * e.g. ptrs to non-volatile memory external to lwIP.
996 * @param ocstr if non-NULL then copy str pointer
997 * @param ocstrlen points to string length, excluding zero terminator
999 void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen)
1003 sysname_ptr = ocstr;
1004 sysname_len_ptr = ocstrlen;
1009 * Initializes sysLocation pointers,
1010 * e.g. ptrs to non-volatile memory external to lwIP.
1012 * @param ocstr if non-NULL then copy str pointer
1013 * @param ocstrlen points to string length, excluding zero terminator
1015 void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen)
1019 syslocation_ptr = ocstr;
1020 syslocation_len_ptr = ocstrlen;
1025 void snmp_add_ifinoctets(struct netif *ni, u32_t value)
1027 ni->ifinoctets += value;
1030 void snmp_inc_ifinucastpkts(struct netif *ni)
1032 (ni->ifinucastpkts)++;
1035 void snmp_inc_ifinnucastpkts(struct netif *ni)
1037 (ni->ifinnucastpkts)++;
1040 void snmp_inc_ifindiscards(struct netif *ni)
1042 (ni->ifindiscards)++;
1045 void snmp_add_ifoutoctets(struct netif *ni, u32_t value)
1047 ni->ifoutoctets += value;
1050 void snmp_inc_ifoutucastpkts(struct netif *ni)
1052 (ni->ifoutucastpkts)++;
1055 void snmp_inc_ifoutnucastpkts(struct netif *ni)
1057 (ni->ifoutnucastpkts)++;
1060 void snmp_inc_ifoutdiscards(struct netif *ni)
1062 (ni->ifoutdiscards)++;
1065 void snmp_inc_iflist(void)
1067 struct mib_list_node *if_node = NULL;
1069 snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
1070 /* enable getnext traversal on filled table */
1071 iftable.maxlength = 1;
1074 void snmp_dec_iflist(void)
1076 snmp_mib_node_delete(&iflist_root, iflist_root.tail);
1077 /* disable getnext traversal on empty table */
1078 if(iflist_root.count == 0) iftable.maxlength = 0;
1082 * Inserts ARP table indexes (.xIfIndex.xNetAddress)
1083 * into arp table index trees (both atTable and ipNetToMediaTable).
1085 void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip)
1087 struct mib_list_rootnode *at_rn;
1088 struct mib_list_node *at_node;
1093 LWIP_ASSERT("ni != NULL", ni != NULL);
1094 snmp_netiftoifindex(ni, &arpidx[0]);
1095 hip.addr = ntohl(ip->addr);
1096 snmp_iptooid(&hip, &arpidx[1]);
1098 for (tree = 0; tree < 2; tree++)
1102 at_rn = &arptree_root;
1106 at_rn = &ipntomtree_root;
1108 for (level = 0; level < 5; level++)
1111 snmp_mib_node_insert(at_rn, arpidx[level], &at_node);
1112 if ((level != 4) && (at_node != NULL))
1114 if (at_node->nptr == NULL)
1116 at_rn = snmp_mib_lrn_alloc();
1117 at_node->nptr = (struct mib_node*)at_rn;
1124 at_rn->get_object_def = atentry_get_object_def;
1125 at_rn->get_value = atentry_get_value;
1129 at_rn->get_object_def = ip_ntomentry_get_object_def;
1130 at_rn->get_value = ip_ntomentry_get_value;
1132 at_rn->set_test = noleafs_set_test;
1133 at_rn->set_value = noleafs_set_value;
1138 /* at_rn == NULL, malloc failure */
1139 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_arpidx_tree() insert failed, mem full"));
1145 at_rn = (struct mib_list_rootnode*)at_node->nptr;
1150 /* enable getnext traversal on filled tables */
1152 ipntomtable.maxlength = 1;
1156 * Removes ARP table indexes (.xIfIndex.xNetAddress)
1157 * from arp table index trees.
1159 void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip)
1161 struct mib_list_rootnode *at_rn, *next, *del_rn[5];
1162 struct mib_list_node *at_n, *del_n[5];
1165 u8_t fc, tree, level, del_cnt;
1167 snmp_netiftoifindex(ni, &arpidx[0]);
1168 hip.addr = ntohl(ip->addr);
1169 snmp_iptooid(&hip, &arpidx[1]);
1171 for (tree = 0; tree < 2; tree++)
1173 /* mark nodes for deletion */
1176 at_rn = &arptree_root;
1180 at_rn = &ipntomtree_root;
1184 while ((level < 5) && (at_rn != NULL))
1186 fc = snmp_mib_node_find(at_rn, arpidx[level], &at_n);
1189 /* arpidx[level] does not exist */
1195 del_rn[del_cnt] = at_rn;
1196 del_n[del_cnt] = at_n;
1198 at_rn = (struct mib_list_rootnode*)(at_n->nptr);
1202 /* reset delete (2 or more childs) */
1204 at_rn = (struct mib_list_rootnode*)(at_n->nptr);
1208 /* delete marked index nodes */
1213 at_rn = del_rn[del_cnt];
1214 at_n = del_n[del_cnt];
1216 next = snmp_mib_node_delete(at_rn, at_n);
1219 LWIP_ASSERT("next_count == 0",next->count == 0);
1220 snmp_mib_lrn_free(next);
1224 /* disable getnext traversal on empty tables */
1225 if(arptree_root.count == 0) at.maxlength = 0;
1226 if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0;
1229 void snmp_inc_ipinreceives(void)
1234 void snmp_inc_ipinhdrerrors(void)
1239 void snmp_inc_ipinaddrerrors(void)
1244 void snmp_inc_ipforwdatagrams(void)
1249 void snmp_inc_ipinunknownprotos(void)
1251 ipinunknownprotos++;
1254 void snmp_inc_ipindiscards(void)
1259 void snmp_inc_ipindelivers(void)
1264 void snmp_inc_ipoutrequests(void)
1269 void snmp_inc_ipoutdiscards(void)
1274 void snmp_inc_ipoutnoroutes(void)
1279 void snmp_inc_ipreasmreqds(void)
1284 void snmp_inc_ipreasmoks(void)
1289 void snmp_inc_ipreasmfails(void)
1294 void snmp_inc_ipfragoks(void)
1299 void snmp_inc_ipfragfails(void)
1304 void snmp_inc_ipfragcreates(void)
1309 void snmp_inc_iproutingdiscards(void)
1311 iproutingdiscards++;
1315 * Inserts ipAddrTable indexes (.ipAdEntAddr)
1318 void snmp_insert_ipaddridx_tree(struct netif *ni)
1320 struct mib_list_rootnode *ipa_rn;
1321 struct mib_list_node *ipa_node;
1326 LWIP_ASSERT("ni != NULL", ni != NULL);
1327 ip.addr = ntohl(ni->ip_addr.addr);
1328 snmp_iptooid(&ip, &ipaddridx[0]);
1331 ipa_rn = &ipaddrtree_root;
1335 snmp_mib_node_insert(ipa_rn, ipaddridx[level], &ipa_node);
1336 if ((level != 3) && (ipa_node != NULL))
1338 if (ipa_node->nptr == NULL)
1340 ipa_rn = snmp_mib_lrn_alloc();
1341 ipa_node->nptr = (struct mib_node*)ipa_rn;
1346 ipa_rn->get_object_def = ip_addrentry_get_object_def;
1347 ipa_rn->get_value = ip_addrentry_get_value;
1348 ipa_rn->set_test = noleafs_set_test;
1349 ipa_rn->set_value = noleafs_set_value;
1354 /* ipa_rn == NULL, malloc failure */
1355 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_ipaddridx_tree() insert failed, mem full"));
1361 ipa_rn = (struct mib_list_rootnode*)ipa_node->nptr;
1366 /* enable getnext traversal on filled table */
1367 ipaddrtable.maxlength = 1;
1371 * Removes ipAddrTable indexes (.ipAdEntAddr)
1374 void snmp_delete_ipaddridx_tree(struct netif *ni)
1376 struct mib_list_rootnode *ipa_rn, *next, *del_rn[4];
1377 struct mib_list_node *ipa_n, *del_n[4];
1380 u8_t fc, level, del_cnt;
1382 LWIP_ASSERT("ni != NULL", ni != NULL);
1383 ip.addr = ntohl(ni->ip_addr.addr);
1384 snmp_iptooid(&ip, &ipaddridx[0]);
1386 /* mark nodes for deletion */
1389 ipa_rn = &ipaddrtree_root;
1390 while ((level < 4) && (ipa_rn != NULL))
1392 fc = snmp_mib_node_find(ipa_rn, ipaddridx[level], &ipa_n);
1395 /* ipaddridx[level] does not exist */
1401 del_rn[del_cnt] = ipa_rn;
1402 del_n[del_cnt] = ipa_n;
1404 ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
1408 /* reset delete (2 or more childs) */
1410 ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
1414 /* delete marked index nodes */
1419 ipa_rn = del_rn[del_cnt];
1420 ipa_n = del_n[del_cnt];
1422 next = snmp_mib_node_delete(ipa_rn, ipa_n);
1425 LWIP_ASSERT("next_count == 0",next->count == 0);
1426 snmp_mib_lrn_free(next);
1429 /* disable getnext traversal on empty table */
1430 if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0;
1434 * Inserts ipRouteTable indexes (.ipRouteDest)
1437 * @param dflt non-zero for the default rte, zero for network rte
1438 * @param ni points to network interface for this rte
1440 * @todo record sysuptime for _this_ route when it is installed
1441 * (needed for ipRouteAge) in the netif.
1443 void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
1450 /* the default route 0.0.0.0 */
1456 /* route to the network address */
1457 dst.addr = ntohl(ni->ip_addr.addr & ni->netmask.addr);
1458 /* exclude 0.0.0.0 network (reserved for default rte) */
1459 if (dst.addr != 0) insert = 1;
1463 struct mib_list_rootnode *iprte_rn;
1464 struct mib_list_node *iprte_node;
1468 snmp_iptooid(&dst, &iprteidx[0]);
1470 iprte_rn = &iprtetree_root;
1474 snmp_mib_node_insert(iprte_rn, iprteidx[level], &iprte_node);
1475 if ((level != 3) && (iprte_node != NULL))
1477 if (iprte_node->nptr == NULL)
1479 iprte_rn = snmp_mib_lrn_alloc();
1480 iprte_node->nptr = (struct mib_node*)iprte_rn;
1481 if (iprte_rn != NULL)
1485 iprte_rn->get_object_def = ip_rteentry_get_object_def;
1486 iprte_rn->get_value = ip_rteentry_get_value;
1487 iprte_rn->set_test = noleafs_set_test;
1488 iprte_rn->set_value = noleafs_set_value;
1493 /* iprte_rn == NULL, malloc failure */
1494 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_iprteidx_tree() insert failed, mem full"));
1500 iprte_rn = (struct mib_list_rootnode*)iprte_node->nptr;
1506 /* enable getnext traversal on filled table */
1507 iprtetable.maxlength = 1;
1511 * Removes ipRouteTable indexes (.ipRouteDest)
1514 * @param dflt non-zero for the default rte, zero for network rte
1515 * @param ni points to network interface for this rte or NULL
1516 * for default route to be removed.
1518 void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
1525 /* the default route 0.0.0.0 */
1531 /* route to the network address */
1532 dst.addr = ntohl(ni->ip_addr.addr & ni->netmask.addr);
1533 /* exclude 0.0.0.0 network (reserved for default rte) */
1534 if (dst.addr != 0) delete = 1;
1538 struct mib_list_rootnode *iprte_rn, *next, *del_rn[4];
1539 struct mib_list_node *iprte_n, *del_n[4];
1541 u8_t fc, level, del_cnt;
1543 snmp_iptooid(&dst, &iprteidx[0]);
1544 /* mark nodes for deletion */
1547 iprte_rn = &iprtetree_root;
1548 while ((level < 4) && (iprte_rn != NULL))
1550 fc = snmp_mib_node_find(iprte_rn, iprteidx[level], &iprte_n);
1553 /* iprteidx[level] does not exist */
1559 del_rn[del_cnt] = iprte_rn;
1560 del_n[del_cnt] = iprte_n;
1562 iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
1566 /* reset delete (2 or more childs) */
1568 iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
1572 /* delete marked index nodes */
1577 iprte_rn = del_rn[del_cnt];
1578 iprte_n = del_n[del_cnt];
1580 next = snmp_mib_node_delete(iprte_rn, iprte_n);
1583 LWIP_ASSERT("next_count == 0",next->count == 0);
1584 snmp_mib_lrn_free(next);
1588 /* disable getnext traversal on empty table */
1589 if (iprtetree_root.count == 0) iprtetable.maxlength = 0;
1593 void snmp_inc_icmpinmsgs(void)
1598 void snmp_inc_icmpinerrors(void)
1603 void snmp_inc_icmpindestunreachs(void)
1605 icmpindestunreachs++;
1608 void snmp_inc_icmpintimeexcds(void)
1613 void snmp_inc_icmpinparmprobs(void)
1618 void snmp_inc_icmpinsrcquenchs(void)
1623 void snmp_inc_icmpinredirects(void)
1628 void snmp_inc_icmpinechos(void)
1633 void snmp_inc_icmpinechoreps(void)
1638 void snmp_inc_icmpintimestamps(void)
1643 void snmp_inc_icmpintimestampreps(void)
1645 icmpintimestampreps++;
1648 void snmp_inc_icmpinaddrmasks(void)
1653 void snmp_inc_icmpinaddrmaskreps(void)
1655 icmpinaddrmaskreps++;
1658 void snmp_inc_icmpoutmsgs(void)
1663 void snmp_inc_icmpouterrors(void)
1668 void snmp_inc_icmpoutdestunreachs(void)
1670 icmpoutdestunreachs++;
1673 void snmp_inc_icmpouttimeexcds(void)
1678 void snmp_inc_icmpoutparmprobs(void)
1683 void snmp_inc_icmpoutsrcquenchs(void)
1685 icmpoutsrcquenchs++;
1688 void snmp_inc_icmpoutredirects(void)
1693 void snmp_inc_icmpoutechos(void)
1698 void snmp_inc_icmpoutechoreps(void)
1703 void snmp_inc_icmpouttimestamps(void)
1705 icmpouttimestamps++;
1708 void snmp_inc_icmpouttimestampreps(void)
1710 icmpouttimestampreps++;
1713 void snmp_inc_icmpoutaddrmasks(void)
1718 void snmp_inc_icmpoutaddrmaskreps(void)
1720 icmpoutaddrmaskreps++;
1723 void snmp_inc_tcpactiveopens(void)
1728 void snmp_inc_tcppassiveopens(void)
1733 void snmp_inc_tcpattemptfails(void)
1738 void snmp_inc_tcpestabresets(void)
1743 void snmp_inc_tcpinsegs(void)
1748 void snmp_inc_tcpoutsegs(void)
1753 void snmp_inc_tcpretranssegs(void)
1758 void snmp_inc_tcpinerrs(void)
1763 void snmp_inc_tcpoutrsts(void)
1768 void snmp_inc_udpindatagrams(void)
1773 void snmp_inc_udpnoports(void)
1778 void snmp_inc_udpinerrors(void)
1783 void snmp_inc_udpoutdatagrams(void)
1789 * Inserts udpTable indexes (.udpLocalAddress.udpLocalPort)
1792 void snmp_insert_udpidx_tree(struct udp_pcb *pcb)
1794 struct mib_list_rootnode *udp_rn;
1795 struct mib_list_node *udp_node;
1800 LWIP_ASSERT("pcb != NULL", pcb != NULL);
1801 ip.addr = ntohl(pcb->local_ip.addr);
1802 snmp_iptooid(&ip, &udpidx[0]);
1803 udpidx[4] = pcb->local_port;
1806 for (level = 0; level < 5; level++)
1809 snmp_mib_node_insert(udp_rn, udpidx[level], &udp_node);
1810 if ((level != 4) && (udp_node != NULL))
1812 if (udp_node->nptr == NULL)
1814 udp_rn = snmp_mib_lrn_alloc();
1815 udp_node->nptr = (struct mib_node*)udp_rn;
1820 udp_rn->get_object_def = udpentry_get_object_def;
1821 udp_rn->get_value = udpentry_get_value;
1822 udp_rn->set_test = noleafs_set_test;
1823 udp_rn->set_value = noleafs_set_value;
1828 /* udp_rn == NULL, malloc failure */
1829 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_udpidx_tree() insert failed, mem full"));
1835 udp_rn = (struct mib_list_rootnode*)udp_node->nptr;
1839 udptable.maxlength = 1;
1843 * Removes udpTable indexes (.udpLocalAddress.udpLocalPort)
1846 void snmp_delete_udpidx_tree(struct udp_pcb *pcb)
1848 struct mib_list_rootnode *udp_rn, *next, *del_rn[5];
1849 struct mib_list_node *udp_n, *del_n[5];
1852 u8_t bindings, fc, level, del_cnt;
1854 LWIP_ASSERT("pcb != NULL", pcb != NULL);
1855 ip.addr = ntohl(pcb->local_ip.addr);
1856 snmp_iptooid(&ip, &udpidx[0]);
1857 udpidx[4] = pcb->local_port;
1859 /* count PCBs for a given binding
1860 (e.g. when reusing ports or for temp output PCBs) */
1863 while ((pcb != NULL))
1865 if ((pcb->local_ip.addr == ip.addr) &&
1866 (pcb->local_port == udpidx[4]))
1874 /* selectively remove */
1875 /* mark nodes for deletion */
1879 while ((level < 5) && (udp_rn != NULL))
1881 fc = snmp_mib_node_find(udp_rn, udpidx[level], &udp_n);
1884 /* udpidx[level] does not exist */
1890 del_rn[del_cnt] = udp_rn;
1891 del_n[del_cnt] = udp_n;
1893 udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
1897 /* reset delete (2 or more childs) */
1899 udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
1903 /* delete marked index nodes */
1908 udp_rn = del_rn[del_cnt];
1909 udp_n = del_n[del_cnt];
1911 next = snmp_mib_node_delete(udp_rn, udp_n);
1914 LWIP_ASSERT("next_count == 0",next->count == 0);
1915 snmp_mib_lrn_free(next);
1919 /* disable getnext traversal on empty table */
1920 if (udp_root.count == 0) udptable.maxlength = 0;
1924 void snmp_inc_snmpinpkts(void)
1929 void snmp_inc_snmpoutpkts(void)
1934 void snmp_inc_snmpinbadversions(void)
1936 snmpinbadversions++;
1939 void snmp_inc_snmpinbadcommunitynames(void)
1941 snmpinbadcommunitynames++;
1944 void snmp_inc_snmpinbadcommunityuses(void)
1946 snmpinbadcommunityuses++;
1949 void snmp_inc_snmpinasnparseerrs(void)
1951 snmpinasnparseerrs++;
1954 void snmp_inc_snmpintoobigs(void)
1959 void snmp_inc_snmpinnosuchnames(void)
1961 snmpinnosuchnames++;
1964 void snmp_inc_snmpinbadvalues(void)
1969 void snmp_inc_snmpinreadonlys(void)
1974 void snmp_inc_snmpingenerrs(void)
1979 void snmp_add_snmpintotalreqvars(u8_t value)
1981 snmpintotalreqvars += value;
1984 void snmp_add_snmpintotalsetvars(u8_t value)
1986 snmpintotalsetvars += value;
1989 void snmp_inc_snmpingetrequests(void)
1991 snmpingetrequests++;
1994 void snmp_inc_snmpingetnexts(void)
1999 void snmp_inc_snmpinsetrequests(void)
2001 snmpinsetrequests++;
2004 void snmp_inc_snmpingetresponses(void)
2006 snmpingetresponses++;
2009 void snmp_inc_snmpintraps(void)
2014 void snmp_inc_snmpouttoobigs(void)
2019 void snmp_inc_snmpoutnosuchnames(void)
2021 snmpoutnosuchnames++;
2024 void snmp_inc_snmpoutbadvalues(void)
2029 void snmp_inc_snmpoutgenerrs(void)
2034 void snmp_inc_snmpoutgetrequests(void)
2036 snmpoutgetrequests++;
2039 void snmp_inc_snmpoutgetnexts(void)
2044 void snmp_inc_snmpoutsetrequests(void)
2046 snmpoutsetrequests++;
2049 void snmp_inc_snmpoutgetresponses(void)
2051 snmpoutgetresponses++;
2054 void snmp_inc_snmpouttraps(void)
2059 void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid)
2064 void snmp_set_snmpenableauthentraps(u8_t *value)
2068 snmpenableauthentraps_ptr = value;
2072 void snmp_get_snmpenableauthentraps(u8_t *value)
2074 *value = *snmpenableauthentraps_ptr;
2078 noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2080 LWIP_UNUSED_ARG(ident_len);
2081 LWIP_UNUSED_ARG(ident);
2082 od->instance = MIB_OBJECT_NONE;
2086 noleafs_get_value(struct obj_def *od, u16_t len, void *value)
2088 LWIP_UNUSED_ARG(od);
2089 LWIP_UNUSED_ARG(len);
2090 LWIP_UNUSED_ARG(value);
2094 noleafs_set_test(struct obj_def *od, u16_t len, void *value)
2096 LWIP_UNUSED_ARG(od);
2097 LWIP_UNUSED_ARG(len);
2098 LWIP_UNUSED_ARG(value);
2104 noleafs_set_value(struct obj_def *od, u16_t len, void *value)
2106 LWIP_UNUSED_ARG(od);
2107 LWIP_UNUSED_ARG(len);
2108 LWIP_UNUSED_ARG(value);
2113 * Returns systems object definitions.
2115 * @param ident_len the address length (2)
2116 * @param ident points to objectname.0 (object id trailer)
2117 * @param od points to object definition.
2120 system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2124 /* return to object name, adding index depth (1) */
2129 od->id_inst_len = ident_len;
2130 od->id_inst_ptr = ident;
2133 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def system.%"U16_F".0\n",(u16_t)id));
2136 case 1: /* sysDescr */
2137 od->instance = MIB_OBJECT_SCALAR;
2138 od->access = MIB_OBJECT_READ_ONLY;
2139 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2140 od->v_len = *sysdescr_len_ptr;
2142 case 2: /* sysObjectID */
2143 od->instance = MIB_OBJECT_SCALAR;
2144 od->access = MIB_OBJECT_READ_ONLY;
2145 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
2146 od->v_len = sysobjid.len * sizeof(s32_t);
2148 case 3: /* sysUpTime */
2149 od->instance = MIB_OBJECT_SCALAR;
2150 od->access = MIB_OBJECT_READ_ONLY;
2151 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
2152 od->v_len = sizeof(u32_t);
2154 case 4: /* sysContact */
2155 od->instance = MIB_OBJECT_SCALAR;
2156 od->access = MIB_OBJECT_READ_WRITE;
2157 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2158 od->v_len = *syscontact_len_ptr;
2160 case 5: /* sysName */
2161 od->instance = MIB_OBJECT_SCALAR;
2162 od->access = MIB_OBJECT_READ_WRITE;
2163 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2164 od->v_len = *sysname_len_ptr;
2166 case 6: /* sysLocation */
2167 od->instance = MIB_OBJECT_SCALAR;
2168 od->access = MIB_OBJECT_READ_WRITE;
2169 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2170 od->v_len = *syslocation_len_ptr;
2172 case 7: /* sysServices */
2173 od->instance = MIB_OBJECT_SCALAR;
2174 od->access = MIB_OBJECT_READ_ONLY;
2175 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2176 od->v_len = sizeof(s32_t);
2179 LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no such object\n"));
2180 od->instance = MIB_OBJECT_NONE;
2186 LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no scalar\n"));
2187 od->instance = MIB_OBJECT_NONE;
2192 * Returns system object value.
2194 * @param ident_len the address length (2)
2195 * @param ident points to objectname.0 (object id trailer)
2196 * @param len return value space (in bytes)
2197 * @param value points to (varbind) space to copy value into.
2200 system_get_value(struct obj_def *od, u16_t len, void *value)
2204 id = od->id_inst_ptr[0];
2207 case 1: /* sysDescr */
2208 ocstrncpy(value,sysdescr_ptr, len);
2210 case 2: /* sysObjectID */
2211 objectidncpy((s32_t*)value, (s32_t*)sysobjid.id, (u8_t)(len / sizeof(s32_t)));
2213 case 3: /* sysUpTime */
2215 snmp_get_sysuptime(value);
2218 case 4: /* sysContact */
2219 ocstrncpy(value,syscontact_ptr,len);
2221 case 5: /* sysName */
2222 ocstrncpy(value,sysname_ptr,len);
2224 case 6: /* sysLocation */
2225 ocstrncpy(value,syslocation_ptr,len);
2227 case 7: /* sysServices */
2229 s32_t *sint_ptr = value;
2230 *sint_ptr = sysservices;
2237 system_set_test(struct obj_def *od, u16_t len, void *value)
2241 LWIP_UNUSED_ARG(value);
2243 id = od->id_inst_ptr[0];
2246 case 4: /* sysContact */
2247 if ((syscontact_ptr != syscontact_default) &&
2253 case 5: /* sysName */
2254 if ((sysname_ptr != sysname_default) &&
2260 case 6: /* sysLocation */
2261 if ((syslocation_ptr != syslocation_default) &&
2272 system_set_value(struct obj_def *od, u16_t len, void *value)
2276 id = od->id_inst_ptr[0];
2279 case 4: /* sysContact */
2280 ocstrncpy(syscontact_ptr,value,len);
2281 *syscontact_len_ptr = len;
2283 case 5: /* sysName */
2284 ocstrncpy(sysname_ptr,value,len);
2285 *sysname_len_ptr = len;
2287 case 6: /* sysLocation */
2288 ocstrncpy(syslocation_ptr,value,len);
2289 *syslocation_len_ptr = len;
2295 * Returns interfaces.ifnumber object definition.
2297 * @param ident_len the address length (2)
2298 * @param ident points to objectname.index
2299 * @param od points to object definition.
2302 interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2304 /* return to object name, adding index depth (1) */
2309 od->id_inst_len = ident_len;
2310 od->id_inst_ptr = ident;
2312 od->instance = MIB_OBJECT_SCALAR;
2313 od->access = MIB_OBJECT_READ_ONLY;
2314 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2315 od->v_len = sizeof(s32_t);
2319 LWIP_DEBUGF(SNMP_MIB_DEBUG,("interfaces_get_object_def: no scalar\n"));
2320 od->instance = MIB_OBJECT_NONE;
2325 * Returns interfaces.ifnumber object value.
2327 * @param ident_len the address length (2)
2328 * @param ident points to objectname.0 (object id trailer)
2329 * @param len return value space (in bytes)
2330 * @param value points to (varbind) space to copy value into.
2333 interfaces_get_value(struct obj_def *od, u16_t len, void *value)
2335 LWIP_UNUSED_ARG(len);
2336 if (od->id_inst_ptr[0] == 1)
2338 s32_t *sint_ptr = value;
2339 *sint_ptr = iflist_root.count;
2344 * Returns ifentry object definitions.
2346 * @param ident_len the address length (2)
2347 * @param ident points to objectname.index
2348 * @param od points to object definition.
2351 ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2355 /* return to object name, adding index depth (1) */
2360 od->id_inst_len = ident_len;
2361 od->id_inst_ptr = ident;
2364 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ifentry.%"U16_F"\n",(u16_t)id));
2367 case 1: /* ifIndex */
2368 case 3: /* ifType */
2370 case 8: /* ifOperStatus */
2371 od->instance = MIB_OBJECT_TAB;
2372 od->access = MIB_OBJECT_READ_ONLY;
2373 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2374 od->v_len = sizeof(s32_t);
2376 case 2: /* ifDescr */
2377 od->instance = MIB_OBJECT_TAB;
2378 od->access = MIB_OBJECT_READ_ONLY;
2379 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2380 /** @todo this should be some sort of sizeof(struct netif.name) */
2383 case 5: /* ifSpeed */
2384 case 21: /* ifOutQLen */
2385 od->instance = MIB_OBJECT_TAB;
2386 od->access = MIB_OBJECT_READ_ONLY;
2387 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
2388 od->v_len = sizeof(u32_t);
2390 case 6: /* ifPhysAddress */
2392 struct netif *netif;
2394 snmp_ifindextonetif(ident[1], &netif);
2395 od->instance = MIB_OBJECT_TAB;
2396 od->access = MIB_OBJECT_READ_ONLY;
2397 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2398 od->v_len = netif->hwaddr_len;
2401 case 7: /* ifAdminStatus */
2402 od->instance = MIB_OBJECT_TAB;
2403 od->access = MIB_OBJECT_READ_WRITE;
2404 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2405 od->v_len = sizeof(s32_t);
2407 case 9: /* ifLastChange */
2408 od->instance = MIB_OBJECT_TAB;
2409 od->access = MIB_OBJECT_READ_ONLY;
2410 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
2411 od->v_len = sizeof(u32_t);
2413 case 10: /* ifInOctets */
2414 case 11: /* ifInUcastPkts */
2415 case 12: /* ifInNUcastPkts */
2416 case 13: /* ifInDiscarts */
2417 case 14: /* ifInErrors */
2418 case 15: /* ifInUnkownProtos */
2419 case 16: /* ifOutOctets */
2420 case 17: /* ifOutUcastPkts */
2421 case 18: /* ifOutNUcastPkts */
2422 case 19: /* ifOutDiscarts */
2423 case 20: /* ifOutErrors */
2424 od->instance = MIB_OBJECT_TAB;
2425 od->access = MIB_OBJECT_READ_ONLY;
2426 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
2427 od->v_len = sizeof(u32_t);
2429 case 22: /* ifSpecific */
2430 /** @note returning zeroDotZero (0.0) no media specific MIB support */
2431 od->instance = MIB_OBJECT_TAB;
2432 od->access = MIB_OBJECT_READ_ONLY;
2433 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
2434 od->v_len = ifspecific.len * sizeof(s32_t);
2437 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no such object\n"));
2438 od->instance = MIB_OBJECT_NONE;
2444 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no scalar\n"));
2445 od->instance = MIB_OBJECT_NONE;
2450 * Returns ifentry object value.
2452 * @param ident_len the address length (2)
2453 * @param ident points to objectname.0 (object id trailer)
2454 * @param len return value space (in bytes)
2455 * @param value points to (varbind) space to copy value into.
2458 ifentry_get_value(struct obj_def *od, u16_t len, void *value)
2460 struct netif *netif;
2463 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
2464 id = od->id_inst_ptr[0];
2467 case 1: /* ifIndex */
2469 s32_t *sint_ptr = value;
2470 *sint_ptr = od->id_inst_ptr[1];
2473 case 2: /* ifDescr */
2474 ocstrncpy(value,(u8_t*)netif->name,len);
2476 case 3: /* ifType */
2478 s32_t *sint_ptr = value;
2479 *sint_ptr = netif->link_type;
2484 s32_t *sint_ptr = value;
2485 *sint_ptr = netif->mtu;
2488 case 5: /* ifSpeed */
2490 u32_t *uint_ptr = value;
2491 *uint_ptr = netif->link_speed;
2494 case 6: /* ifPhysAddress */
2495 ocstrncpy(value,netif->hwaddr,len);
2497 case 7: /* ifAdminStatus */
2498 #if LWIP_NETIF_LINK_CALLBACK
2500 s32_t *sint_ptr = value;
2501 if (netif_is_up(netif))
2503 if (netif_is_link_up(netif))
2505 *sint_ptr = 1; /* up */
2509 *sint_ptr = 7; /* lowerLayerDown */
2514 *sint_ptr = 2; /* down */
2519 case 8: /* ifOperStatus */
2521 s32_t *sint_ptr = value;
2522 if (netif_is_up(netif))
2532 case 9: /* ifLastChange */
2534 u32_t *uint_ptr = value;
2535 *uint_ptr = netif->ts;
2538 case 10: /* ifInOctets */
2540 u32_t *uint_ptr = value;
2541 *uint_ptr = netif->ifinoctets;
2544 case 11: /* ifInUcastPkts */
2546 u32_t *uint_ptr = value;
2547 *uint_ptr = netif->ifinucastpkts;
2550 case 12: /* ifInNUcastPkts */
2552 u32_t *uint_ptr = value;
2553 *uint_ptr = netif->ifinnucastpkts;
2556 case 13: /* ifInDiscarts */
2558 u32_t *uint_ptr = value;
2559 *uint_ptr = netif->ifindiscards;
2562 case 14: /* ifInErrors */
2563 case 15: /* ifInUnkownProtos */
2564 /** @todo add these counters! */
2566 u32_t *uint_ptr = value;
2570 case 16: /* ifOutOctets */
2572 u32_t *uint_ptr = value;
2573 *uint_ptr = netif->ifoutoctets;
2576 case 17: /* ifOutUcastPkts */
2578 u32_t *uint_ptr = value;
2579 *uint_ptr = netif->ifoutucastpkts;
2582 case 18: /* ifOutNUcastPkts */
2584 u32_t *uint_ptr = value;
2585 *uint_ptr = netif->ifoutnucastpkts;
2588 case 19: /* ifOutDiscarts */
2590 u32_t *uint_ptr = value;
2591 *uint_ptr = netif->ifoutdiscards;
2594 case 20: /* ifOutErrors */
2595 /** @todo add this counter! */
2597 u32_t *uint_ptr = value;
2601 case 21: /* ifOutQLen */
2602 /** @todo figure out if this must be 0 (no queue) or 1? */
2604 u32_t *uint_ptr = value;
2608 case 22: /* ifSpecific */
2609 objectidncpy((s32_t*)value, (s32_t*)ifspecific.id, (u8_t)(len / sizeof(s32_t)));
2614 #if !SNMP_SAFE_REQUESTS
2616 ifentry_set_test (struct obj_def *od, u16_t len, void *value)
2618 struct netif *netif;
2622 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
2623 id = od->id_inst_ptr[0];
2626 case 7: /* ifAdminStatus */
2628 s32_t *sint_ptr = value;
2629 if (*sint_ptr == 1 || *sint_ptr == 2)
2638 ifentry_set_value (struct obj_def *od, u16_t len, void *value)
2640 struct netif *netif;
2643 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
2644 id = od->id_inst_ptr[0];
2647 case 7: /* ifAdminStatus */
2649 s32_t *sint_ptr = value;
2652 netif_set_up(netif);
2654 else if (*sint_ptr == 2)
2656 netif_set_down(netif);
2662 #endif /* SNMP_SAFE_REQUESTS */
2665 * Returns atentry object definitions.
2667 * @param ident_len the address length (6)
2668 * @param ident points to objectname.atifindex.atnetaddress
2669 * @param od points to object definition.
2672 atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2674 /* return to object name, adding index depth (5) */
2680 od->id_inst_len = ident_len;
2681 od->id_inst_ptr = ident;
2685 case 1: /* atIfIndex */
2686 od->instance = MIB_OBJECT_TAB;
2687 od->access = MIB_OBJECT_READ_WRITE;
2688 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2689 od->v_len = sizeof(s32_t);
2691 case 2: /* atPhysAddress */
2692 od->instance = MIB_OBJECT_TAB;
2693 od->access = MIB_OBJECT_READ_WRITE;
2694 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2695 od->v_len = 6; /** @todo try to use netif::hwaddr_len */
2697 case 3: /* atNetAddress */
2698 od->instance = MIB_OBJECT_TAB;
2699 od->access = MIB_OBJECT_READ_WRITE;
2700 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
2704 LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no such object\n"));
2705 od->instance = MIB_OBJECT_NONE;
2711 LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar\n"));
2712 od->instance = MIB_OBJECT_NONE;
2717 atentry_get_value(struct obj_def *od, u16_t len, void *value)
2721 struct eth_addr* ethaddr_ret;
2722 struct ip_addr* ipaddr_ret;
2723 #endif /* LWIP_ARP */
2725 struct netif *netif;
2727 LWIP_UNUSED_ARG(len);
2728 LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */
2730 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
2731 snmp_oidtoip(&od->id_inst_ptr[2], &ip);
2732 ip.addr = htonl(ip.addr);
2734 #if LWIP_ARP /** @todo implement a netif_find_addr */
2735 if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1)
2737 id = od->id_inst_ptr[0];
2740 case 1: /* atIfIndex */
2742 s32_t *sint_ptr = value;
2743 *sint_ptr = od->id_inst_ptr[1];
2746 case 2: /* atPhysAddress */
2748 struct eth_addr *dst = value;
2750 *dst = *ethaddr_ret;
2753 case 3: /* atNetAddress */
2755 struct ip_addr *dst = value;
2762 #endif /* LWIP_ARP */
2766 ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2770 /* return to object name, adding index depth (1) */
2775 od->id_inst_len = ident_len;
2776 od->id_inst_ptr = ident;
2779 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ip.%"U16_F".0\n",(u16_t)id));
2782 case 1: /* ipForwarding */
2783 case 2: /* ipDefaultTTL */
2784 od->instance = MIB_OBJECT_SCALAR;
2785 od->access = MIB_OBJECT_READ_WRITE;
2786 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2787 od->v_len = sizeof(s32_t);
2789 case 3: /* ipInReceives */
2790 case 4: /* ipInHdrErrors */
2791 case 5: /* ipInAddrErrors */
2792 case 6: /* ipForwDatagrams */
2793 case 7: /* ipInUnknownProtos */
2794 case 8: /* ipInDiscards */
2795 case 9: /* ipInDelivers */
2796 case 10: /* ipOutRequests */
2797 case 11: /* ipOutDiscards */
2798 case 12: /* ipOutNoRoutes */
2799 case 14: /* ipReasmReqds */
2800 case 15: /* ipReasmOKs */
2801 case 16: /* ipReasmFails */
2802 case 17: /* ipFragOKs */
2803 case 18: /* ipFragFails */
2804 case 19: /* ipFragCreates */
2805 case 23: /* ipRoutingDiscards */
2806 od->instance = MIB_OBJECT_SCALAR;
2807 od->access = MIB_OBJECT_READ_ONLY;
2808 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
2809 od->v_len = sizeof(u32_t);
2811 case 13: /* ipReasmTimeout */
2812 od->instance = MIB_OBJECT_SCALAR;
2813 od->access = MIB_OBJECT_READ_ONLY;
2814 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2815 od->v_len = sizeof(s32_t);
2818 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no such object\n"));
2819 od->instance = MIB_OBJECT_NONE;
2825 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no scalar\n"));
2826 od->instance = MIB_OBJECT_NONE;
2831 ip_get_value(struct obj_def *od, u16_t len, void *value)
2835 LWIP_UNUSED_ARG(len);
2836 id = od->id_inst_ptr[0];
2839 case 1: /* ipForwarding */
2841 s32_t *sint_ptr = value;
2846 /* not-forwarding */
2851 case 2: /* ipDefaultTTL */
2853 s32_t *sint_ptr = value;
2854 *sint_ptr = IP_DEFAULT_TTL;
2857 case 3: /* ipInReceives */
2859 u32_t *uint_ptr = value;
2860 *uint_ptr = ipinreceives;
2863 case 4: /* ipInHdrErrors */
2865 u32_t *uint_ptr = value;
2866 *uint_ptr = ipinhdrerrors;
2869 case 5: /* ipInAddrErrors */
2871 u32_t *uint_ptr = value;
2872 *uint_ptr = ipinaddrerrors;
2875 case 6: /* ipForwDatagrams */
2877 u32_t *uint_ptr = value;
2878 *uint_ptr = ipforwdatagrams;
2881 case 7: /* ipInUnknownProtos */
2883 u32_t *uint_ptr = value;
2884 *uint_ptr = ipinunknownprotos;
2887 case 8: /* ipInDiscards */
2889 u32_t *uint_ptr = value;
2890 *uint_ptr = ipindiscards;
2893 case 9: /* ipInDelivers */
2895 u32_t *uint_ptr = value;
2896 *uint_ptr = ipindelivers;
2899 case 10: /* ipOutRequests */
2901 u32_t *uint_ptr = value;
2902 *uint_ptr = ipoutrequests;
2905 case 11: /* ipOutDiscards */
2907 u32_t *uint_ptr = value;
2908 *uint_ptr = ipoutdiscards;
2911 case 12: /* ipOutNoRoutes */
2913 u32_t *uint_ptr = value;
2914 *uint_ptr = ipoutnoroutes;
2917 case 13: /* ipReasmTimeout */
2919 s32_t *sint_ptr = value;
2921 *sint_ptr = IP_REASS_MAXAGE;
2927 case 14: /* ipReasmReqds */
2929 u32_t *uint_ptr = value;
2930 *uint_ptr = ipreasmreqds;
2933 case 15: /* ipReasmOKs */
2935 u32_t *uint_ptr = value;
2936 *uint_ptr = ipreasmoks;
2939 case 16: /* ipReasmFails */
2941 u32_t *uint_ptr = value;
2942 *uint_ptr = ipreasmfails;
2945 case 17: /* ipFragOKs */
2947 u32_t *uint_ptr = value;
2948 *uint_ptr = ipfragoks;
2951 case 18: /* ipFragFails */
2953 u32_t *uint_ptr = value;
2954 *uint_ptr = ipfragfails;
2957 case 19: /* ipFragCreates */
2959 u32_t *uint_ptr = value;
2960 *uint_ptr = ipfragcreates;
2963 case 23: /* ipRoutingDiscards */
2964 /** @todo can lwIP discard routes at all?? hardwire this to 0?? */
2966 u32_t *uint_ptr = value;
2967 *uint_ptr = iproutingdiscards;
2974 * Test ip object value before setting.
2976 * @param od is the object definition
2977 * @param len return value space (in bytes)
2978 * @param value points to (varbind) space to copy value from.
2980 * @note we allow set if the value matches the hardwired value,
2981 * otherwise return badvalue.
2984 ip_set_test(struct obj_def *od, u16_t len, void *value)
2987 s32_t *sint_ptr = value;
2989 LWIP_UNUSED_ARG(len);
2991 id = od->id_inst_ptr[0];
2994 case 1: /* ipForwarding */
2999 /* not-forwarding */
3006 case 2: /* ipDefaultTTL */
3007 if (*sint_ptr == IP_DEFAULT_TTL)
3017 ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3019 /* return to object name, adding index depth (4) */
3027 od->id_inst_len = ident_len;
3028 od->id_inst_ptr = ident;
3033 case 1: /* ipAdEntAddr */
3034 case 3: /* ipAdEntNetMask */
3035 od->instance = MIB_OBJECT_TAB;
3036 od->access = MIB_OBJECT_READ_ONLY;
3037 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
3040 case 2: /* ipAdEntIfIndex */
3041 case 4: /* ipAdEntBcastAddr */
3042 case 5: /* ipAdEntReasmMaxSize */
3043 od->instance = MIB_OBJECT_TAB;
3044 od->access = MIB_OBJECT_READ_ONLY;
3045 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3046 od->v_len = sizeof(s32_t);
3049 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no such object\n"));
3050 od->instance = MIB_OBJECT_NONE;
3056 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar\n"));
3057 od->instance = MIB_OBJECT_NONE;
3062 ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
3067 struct netif *netif = netif_list;
3069 LWIP_UNUSED_ARG(len);
3070 snmp_oidtoip(&od->id_inst_ptr[1], &ip);
3071 ip.addr = htonl(ip.addr);
3073 while ((netif != NULL) && !ip_addr_cmp(&ip, &netif->ip_addr))
3075 netif = netif->next;
3081 id = od->id_inst_ptr[0];
3084 case 1: /* ipAdEntAddr */
3086 struct ip_addr *dst = value;
3087 *dst = netif->ip_addr;
3090 case 2: /* ipAdEntIfIndex */
3092 s32_t *sint_ptr = value;
3093 *sint_ptr = ifidx + 1;
3096 case 3: /* ipAdEntNetMask */
3098 struct ip_addr *dst = value;
3099 *dst = netif->netmask;
3102 case 4: /* ipAdEntBcastAddr */
3104 s32_t *sint_ptr = value;
3106 /* lwIP oddity, there's no broadcast
3107 address in the netif we can rely on */
3108 *sint_ptr = ip_addr_broadcast.addr & 1;
3111 case 5: /* ipAdEntReasmMaxSize */
3113 s32_t *sint_ptr = value;
3115 /* @todo The theoretical maximum is IP_REASS_MAX_PBUFS * size of the pbufs,
3116 * but only if receiving one fragmented packet at a time.
3117 * The current solution is to calculate for 2 simultaneous packets...
3119 *sint_ptr = (IP_HLEN + ((IP_REASS_MAX_PBUFS/2) *
3120 (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN - IP_HLEN)));
3122 /** @todo returning MTU would be a bad thing and
3123 returning a wild guess like '576' isn't good either */
3134 * lwIP IP routing is currently using the network addresses in netif_list.
3135 * if no suitable network IP is found in netif_list, the default_netif is used.
3138 ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3142 /* return to object name, adding index depth (4) */
3148 od->id_inst_len = ident_len;
3149 od->id_inst_ptr = ident;
3154 case 1: /* ipRouteDest */
3155 case 7: /* ipRouteNextHop */
3156 case 11: /* ipRouteMask */
3157 od->instance = MIB_OBJECT_TAB;
3158 od->access = MIB_OBJECT_READ_WRITE;
3159 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
3162 case 2: /* ipRouteIfIndex */
3163 case 3: /* ipRouteMetric1 */
3164 case 4: /* ipRouteMetric2 */
3165 case 5: /* ipRouteMetric3 */
3166 case 6: /* ipRouteMetric4 */
3167 case 8: /* ipRouteType */
3168 case 10: /* ipRouteAge */
3169 case 12: /* ipRouteMetric5 */
3170 od->instance = MIB_OBJECT_TAB;
3171 od->access = MIB_OBJECT_READ_WRITE;
3172 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3173 od->v_len = sizeof(s32_t);
3175 case 9: /* ipRouteProto */
3176 od->instance = MIB_OBJECT_TAB;
3177 od->access = MIB_OBJECT_READ_ONLY;
3178 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3179 od->v_len = sizeof(s32_t);
3181 case 13: /* ipRouteInfo */
3182 /** @note returning zeroDotZero (0.0) no routing protocol specific MIB */
3183 od->instance = MIB_OBJECT_TAB;
3184 od->access = MIB_OBJECT_READ_ONLY;
3185 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
3186 od->v_len = iprouteinfo.len * sizeof(s32_t);
3189 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no such object\n"));
3190 od->instance = MIB_OBJECT_NONE;
3196 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar\n"));
3197 od->instance = MIB_OBJECT_NONE;
3202 ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
3204 struct netif *netif;
3205 struct ip_addr dest;
3209 ident = od->id_inst_ptr;
3210 snmp_oidtoip(&ident[1], &dest);
3211 dest.addr = htonl(dest.addr);
3215 /* ip_route() uses default netif for default route */
3216 netif = netif_default;
3220 /* not using ip_route(), need exact match! */
3222 while ((netif != NULL) &&
3223 !ip_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) )
3225 netif = netif->next;
3233 case 1: /* ipRouteDest */
3235 struct ip_addr *dst = value;
3239 /* default rte has 0.0.0.0 dest */
3244 /* netifs have netaddress dest */
3245 dst->addr = netif->ip_addr.addr & netif->netmask.addr;
3249 case 2: /* ipRouteIfIndex */
3251 s32_t *sint_ptr = value;
3253 snmp_netiftoifindex(netif, sint_ptr);
3256 case 3: /* ipRouteMetric1 */
3258 s32_t *sint_ptr = value;
3262 /* default rte has metric 1 */
3267 /* other rtes have metric 0 */
3272 case 4: /* ipRouteMetric2 */
3273 case 5: /* ipRouteMetric3 */
3274 case 6: /* ipRouteMetric4 */
3275 case 12: /* ipRouteMetric5 */
3277 s32_t *sint_ptr = value;
3282 case 7: /* ipRouteNextHop */
3284 struct ip_addr *dst = value;
3288 /* default rte: gateway */
3293 /* other rtes: netif ip_addr */
3294 *dst = netif->ip_addr;
3298 case 8: /* ipRouteType */
3300 s32_t *sint_ptr = value;
3304 /* default rte is indirect */
3309 /* other rtes are direct */
3314 case 9: /* ipRouteProto */
3316 s32_t *sint_ptr = value;
3317 /* locally defined routes */
3321 case 10: /* ipRouteAge */
3323 s32_t *sint_ptr = value;
3324 /** @todo (sysuptime - timestamp last change) / 100
3325 @see snmp_insert_iprteidx_tree() */
3329 case 11: /* ipRouteMask */
3331 struct ip_addr *dst = value;
3335 /* default rte use 0.0.0.0 mask */
3340 /* other rtes use netmask */
3341 *dst = netif->netmask;
3345 case 13: /* ipRouteInfo */
3346 objectidncpy((s32_t*)value, (s32_t*)iprouteinfo.id, (u8_t)(len / sizeof(s32_t)));
3353 ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3355 /* return to object name, adding index depth (5) */
3363 od->id_inst_len = ident_len;
3364 od->id_inst_ptr = ident;
3369 case 1: /* ipNetToMediaIfIndex */
3370 case 4: /* ipNetToMediaType */
3371 od->instance = MIB_OBJECT_TAB;
3372 od->access = MIB_OBJECT_READ_WRITE;
3373 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3374 od->v_len = sizeof(s32_t);
3376 case 2: /* ipNetToMediaPhysAddress */
3377 od->instance = MIB_OBJECT_TAB;
3378 od->access = MIB_OBJECT_READ_WRITE;
3379 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
3380 od->v_len = 6; /** @todo try to use netif::hwaddr_len */
3382 case 3: /* ipNetToMediaNetAddress */
3383 od->instance = MIB_OBJECT_TAB;
3384 od->access = MIB_OBJECT_READ_WRITE;
3385 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
3389 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no such object\n"));
3390 od->instance = MIB_OBJECT_NONE;
3396 LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar\n"));
3397 od->instance = MIB_OBJECT_NONE;
3402 ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value)
3406 struct eth_addr* ethaddr_ret;
3407 struct ip_addr* ipaddr_ret;
3408 #endif /* LWIP_ARP */
3410 struct netif *netif;
3412 LWIP_UNUSED_ARG(len);
3413 LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */
3415 snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
3416 snmp_oidtoip(&od->id_inst_ptr[2], &ip);
3417 ip.addr = htonl(ip.addr);
3419 #if LWIP_ARP /** @todo implement a netif_find_addr */
3420 if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1)
3422 id = od->id_inst_ptr[0];
3425 case 1: /* ipNetToMediaIfIndex */
3427 s32_t *sint_ptr = value;
3428 *sint_ptr = od->id_inst_ptr[1];
3431 case 2: /* ipNetToMediaPhysAddress */
3433 struct eth_addr *dst = value;
3435 *dst = *ethaddr_ret;
3438 case 3: /* ipNetToMediaNetAddress */
3440 struct ip_addr *dst = value;
3445 case 4: /* ipNetToMediaType */
3447 s32_t *sint_ptr = value;
3454 #endif /* LWIP_ARP */
3458 icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3460 /* return to object name, adding index depth (1) */
3463 if ((ident_len == 2) &&
3464 (ident[0] > 0) && (ident[0] < 27))
3466 od->id_inst_len = ident_len;
3467 od->id_inst_ptr = ident;
3469 od->instance = MIB_OBJECT_SCALAR;
3470 od->access = MIB_OBJECT_READ_ONLY;
3471 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
3472 od->v_len = sizeof(u32_t);
3476 LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_object_def: no scalar\n"));
3477 od->instance = MIB_OBJECT_NONE;
3482 icmp_get_value(struct obj_def *od, u16_t len, void *value)
3484 u32_t *uint_ptr = value;
3487 LWIP_UNUSED_ARG(len);
3488 id = od->id_inst_ptr[0];
3491 case 1: /* icmpInMsgs */
3492 *uint_ptr = icmpinmsgs;
3494 case 2: /* icmpInErrors */
3495 *uint_ptr = icmpinerrors;
3497 case 3: /* icmpInDestUnreachs */
3498 *uint_ptr = icmpindestunreachs;
3500 case 4: /* icmpInTimeExcds */
3501 *uint_ptr = icmpintimeexcds;
3503 case 5: /* icmpInParmProbs */
3504 *uint_ptr = icmpinparmprobs;
3506 case 6: /* icmpInSrcQuenchs */
3507 *uint_ptr = icmpinsrcquenchs;
3509 case 7: /* icmpInRedirects */
3510 *uint_ptr = icmpinredirects;
3512 case 8: /* icmpInEchos */
3513 *uint_ptr = icmpinechos;
3515 case 9: /* icmpInEchoReps */
3516 *uint_ptr = icmpinechoreps;
3518 case 10: /* icmpInTimestamps */
3519 *uint_ptr = icmpintimestamps;
3521 case 11: /* icmpInTimestampReps */
3522 *uint_ptr = icmpintimestampreps;
3524 case 12: /* icmpInAddrMasks */
3525 *uint_ptr = icmpinaddrmasks;
3527 case 13: /* icmpInAddrMaskReps */
3528 *uint_ptr = icmpinaddrmaskreps;
3530 case 14: /* icmpOutMsgs */
3531 *uint_ptr = icmpoutmsgs;
3533 case 15: /* icmpOutErrors */
3534 *uint_ptr = icmpouterrors;
3536 case 16: /* icmpOutDestUnreachs */
3537 *uint_ptr = icmpoutdestunreachs;
3539 case 17: /* icmpOutTimeExcds */
3540 *uint_ptr = icmpouttimeexcds;
3542 case 18: /* icmpOutParmProbs */
3543 *uint_ptr = icmpoutparmprobs;
3545 case 19: /* icmpOutSrcQuenchs */
3546 *uint_ptr = icmpoutsrcquenchs;
3548 case 20: /* icmpOutRedirects */
3549 *uint_ptr = icmpoutredirects;
3551 case 21: /* icmpOutEchos */
3552 *uint_ptr = icmpoutechos;
3554 case 22: /* icmpOutEchoReps */
3555 *uint_ptr = icmpoutechoreps;
3557 case 23: /* icmpOutTimestamps */
3558 *uint_ptr = icmpouttimestamps;
3560 case 24: /* icmpOutTimestampReps */
3561 *uint_ptr = icmpouttimestampreps;
3563 case 25: /* icmpOutAddrMasks */
3564 *uint_ptr = icmpoutaddrmasks;
3566 case 26: /* icmpOutAddrMaskReps */
3567 *uint_ptr = icmpoutaddrmaskreps;
3573 /** @todo tcp grp */
3575 tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3579 /* return to object name, adding index depth (1) */
3584 od->id_inst_len = ident_len;
3585 od->id_inst_ptr = ident;
3588 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id));
3592 case 1: /* tcpRtoAlgorithm */
3593 case 2: /* tcpRtoMin */
3594 case 3: /* tcpRtoMax */
3595 case 4: /* tcpMaxConn */
3596 od->instance = MIB_OBJECT_SCALAR;
3597 od->access = MIB_OBJECT_READ_ONLY;
3598 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3599 od->v_len = sizeof(s32_t);
3601 case 5: /* tcpActiveOpens */
3602 case 6: /* tcpPassiveOpens */
3603 case 7: /* tcpAttemptFails */
3604 case 8: /* tcpEstabResets */
3605 case 10: /* tcpInSegs */
3606 case 11: /* tcpOutSegs */
3607 case 12: /* tcpRetransSegs */
3608 case 14: /* tcpInErrs */
3609 case 15: /* tcpOutRsts */
3610 od->instance = MIB_OBJECT_SCALAR;
3611 od->access = MIB_OBJECT_READ_ONLY;
3612 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
3613 od->v_len = sizeof(u32_t);
3615 case 9: /* tcpCurrEstab */
3616 od->instance = MIB_OBJECT_TAB;
3617 od->access = MIB_OBJECT_READ_ONLY;
3618 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
3619 od->v_len = sizeof(u32_t);
3622 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no such object\n"));
3623 od->instance = MIB_OBJECT_NONE;
3629 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no scalar\n"));
3630 od->instance = MIB_OBJECT_NONE;
3635 tcp_get_value(struct obj_def *od, u16_t len, void *value)
3637 u32_t *uint_ptr = value;
3638 s32_t *sint_ptr = value;
3641 LWIP_UNUSED_ARG(len);
3642 id = od->id_inst_ptr[0];
3645 case 1: /* tcpRtoAlgorithm, vanj(4) */
3648 case 2: /* tcpRtoMin */
3649 /* @todo not the actual value, a guess,
3650 needs to be calculated */
3653 case 3: /* tcpRtoMax */
3654 /* @todo not the actual value, a guess,
3655 needs to be calculated */
3658 case 4: /* tcpMaxConn */
3659 *sint_ptr = MEMP_NUM_TCP_PCB;
3661 case 5: /* tcpActiveOpens */
3662 *uint_ptr = tcpactiveopens;
3664 case 6: /* tcpPassiveOpens */
3665 *uint_ptr = tcppassiveopens;
3667 case 7: /* tcpAttemptFails */
3668 *uint_ptr = tcpattemptfails;
3670 case 8: /* tcpEstabResets */
3671 *uint_ptr = tcpestabresets;
3673 case 9: /* tcpCurrEstab */
3675 u16_t tcpcurrestab = 0;
3676 struct tcp_pcb *pcb = tcp_active_pcbs;
3679 if ((pcb->state == ESTABLISHED) ||
3680 (pcb->state == CLOSE_WAIT))
3686 *uint_ptr = tcpcurrestab;
3689 case 10: /* tcpInSegs */
3690 *uint_ptr = tcpinsegs;
3692 case 11: /* tcpOutSegs */
3693 *uint_ptr = tcpoutsegs;
3695 case 12: /* tcpRetransSegs */
3696 *uint_ptr = tcpretranssegs;
3698 case 14: /* tcpInErrs */
3699 *uint_ptr = tcpinerrs;
3701 case 15: /* tcpOutRsts */
3702 *uint_ptr = tcpoutrsts;
3706 #ifdef THIS_SEEMS_UNUSED
3708 tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3710 /* return to object name, adding index depth (10) */
3714 if (ident_len == 11)
3718 od->id_inst_len = ident_len;
3719 od->id_inst_ptr = ident;
3722 LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id));
3726 case 1: /* tcpConnState */
3727 od->instance = MIB_OBJECT_TAB;
3728 od->access = MIB_OBJECT_READ_WRITE;
3729 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3730 od->v_len = sizeof(s32_t);
3732 case 2: /* tcpConnLocalAddress */
3733 case 4: /* tcpConnRemAddress */
3734 od->instance = MIB_OBJECT_TAB;
3735 od->access = MIB_OBJECT_READ_ONLY;
3736 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
3739 case 3: /* tcpConnLocalPort */
3740 case 5: /* tcpConnRemPort */
3741 od->instance = MIB_OBJECT_TAB;
3742 od->access = MIB_OBJECT_READ_ONLY;
3743 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3744 od->v_len = sizeof(s32_t);
3747 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n"));
3748 od->instance = MIB_OBJECT_NONE;
3754 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n"));
3755 od->instance = MIB_OBJECT_NONE;
3760 tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value)
3762 struct ip_addr lip, rip;
3766 ident = od->id_inst_ptr;
3767 snmp_oidtoip(&ident[1], &lip);
3768 lip.addr = htonl(lip.addr);
3770 snmp_oidtoip(&ident[6], &rip);
3771 rip.addr = htonl(rip.addr);
3774 /** @todo find matching PCB */
3780 udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3782 /* return to object name, adding index depth (1) */
3785 if ((ident_len == 2) &&
3786 (ident[0] > 0) && (ident[0] < 6))
3788 od->id_inst_len = ident_len;
3789 od->id_inst_ptr = ident;
3791 od->instance = MIB_OBJECT_SCALAR;
3792 od->access = MIB_OBJECT_READ_ONLY;
3793 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
3794 od->v_len = sizeof(u32_t);
3798 LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_object_def: no scalar\n"));
3799 od->instance = MIB_OBJECT_NONE;
3804 udp_get_value(struct obj_def *od, u16_t len, void *value)
3806 u32_t *uint_ptr = value;
3809 LWIP_UNUSED_ARG(len);
3810 id = od->id_inst_ptr[0];
3813 case 1: /* udpInDatagrams */
3814 *uint_ptr = udpindatagrams;
3816 case 2: /* udpNoPorts */
3817 *uint_ptr = udpnoports;
3819 case 3: /* udpInErrors */
3820 *uint_ptr = udpinerrors;
3822 case 4: /* udpOutDatagrams */
3823 *uint_ptr = udpoutdatagrams;
3829 udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3831 /* return to object name, adding index depth (5) */
3837 od->id_inst_len = ident_len;
3838 od->id_inst_ptr = ident;
3842 case 1: /* udpLocalAddress */
3843 od->instance = MIB_OBJECT_TAB;
3844 od->access = MIB_OBJECT_READ_ONLY;
3845 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
3848 case 2: /* udpLocalPort */
3849 od->instance = MIB_OBJECT_TAB;
3850 od->access = MIB_OBJECT_READ_ONLY;
3851 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3852 od->v_len = sizeof(s32_t);
3855 LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no such object\n"));
3856 od->instance = MIB_OBJECT_NONE;
3862 LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar\n"));
3863 od->instance = MIB_OBJECT_NONE;
3868 udpentry_get_value(struct obj_def *od, u16_t len, void *value)
3871 struct udp_pcb *pcb;
3875 LWIP_UNUSED_ARG(len);
3876 snmp_oidtoip(&od->id_inst_ptr[1], &ip);
3877 ip.addr = htonl(ip.addr);
3878 port = od->id_inst_ptr[5];
3881 while ((pcb != NULL) &&
3882 !((pcb->local_ip.addr == ip.addr) &&
3883 (pcb->local_port == port)))
3890 id = od->id_inst_ptr[0];
3893 case 1: /* udpLocalAddress */
3895 struct ip_addr *dst = value;
3896 *dst = pcb->local_ip;
3899 case 2: /* udpLocalPort */
3901 s32_t *sint_ptr = value;
3902 *sint_ptr = pcb->local_port;
3910 snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
3912 /* return to object name, adding index depth (1) */
3919 od->id_inst_len = ident_len;
3920 od->id_inst_ptr = ident;
3925 case 1: /* snmpInPkts */
3926 case 2: /* snmpOutPkts */
3927 case 3: /* snmpInBadVersions */
3928 case 4: /* snmpInBadCommunityNames */
3929 case 5: /* snmpInBadCommunityUses */
3930 case 6: /* snmpInASNParseErrs */
3931 case 8: /* snmpInTooBigs */
3932 case 9: /* snmpInNoSuchNames */
3933 case 10: /* snmpInBadValues */
3934 case 11: /* snmpInReadOnlys */
3935 case 12: /* snmpInGenErrs */
3936 case 13: /* snmpInTotalReqVars */
3937 case 14: /* snmpInTotalSetVars */
3938 case 15: /* snmpInGetRequests */
3939 case 16: /* snmpInGetNexts */
3940 case 17: /* snmpInSetRequests */
3941 case 18: /* snmpInGetResponses */
3942 case 19: /* snmpInTraps */
3943 case 20: /* snmpOutTooBigs */
3944 case 21: /* snmpOutNoSuchNames */
3945 case 22: /* snmpOutBadValues */
3946 case 24: /* snmpOutGenErrs */
3947 case 25: /* snmpOutGetRequests */
3948 case 26: /* snmpOutGetNexts */
3949 case 27: /* snmpOutSetRequests */
3950 case 28: /* snmpOutGetResponses */
3951 case 29: /* snmpOutTraps */
3952 od->instance = MIB_OBJECT_SCALAR;
3953 od->access = MIB_OBJECT_READ_ONLY;
3954 od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
3955 od->v_len = sizeof(u32_t);
3957 case 30: /* snmpEnableAuthenTraps */
3958 od->instance = MIB_OBJECT_SCALAR;
3959 od->access = MIB_OBJECT_READ_WRITE;
3960 od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
3961 od->v_len = sizeof(s32_t);
3964 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no such object\n"));
3965 od->instance = MIB_OBJECT_NONE;
3971 LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no scalar\n"));
3972 od->instance = MIB_OBJECT_NONE;
3977 snmp_get_value(struct obj_def *od, u16_t len, void *value)
3979 u32_t *uint_ptr = value;
3982 LWIP_UNUSED_ARG(len);
3983 id = od->id_inst_ptr[0];
3986 case 1: /* snmpInPkts */
3987 *uint_ptr = snmpinpkts;
3989 case 2: /* snmpOutPkts */
3990 *uint_ptr = snmpoutpkts;
3992 case 3: /* snmpInBadVersions */
3993 *uint_ptr = snmpinbadversions;
3995 case 4: /* snmpInBadCommunityNames */
3996 *uint_ptr = snmpinbadcommunitynames;
3998 case 5: /* snmpInBadCommunityUses */
3999 *uint_ptr = snmpinbadcommunityuses;
4001 case 6: /* snmpInASNParseErrs */
4002 *uint_ptr = snmpinasnparseerrs;
4004 case 8: /* snmpInTooBigs */
4005 *uint_ptr = snmpintoobigs;
4007 case 9: /* snmpInNoSuchNames */
4008 *uint_ptr = snmpinnosuchnames;
4010 case 10: /* snmpInBadValues */
4011 *uint_ptr = snmpinbadvalues;
4013 case 11: /* snmpInReadOnlys */
4014 *uint_ptr = snmpinreadonlys;
4016 case 12: /* snmpInGenErrs */
4017 *uint_ptr = snmpingenerrs;
4019 case 13: /* snmpInTotalReqVars */
4020 *uint_ptr = snmpintotalreqvars;
4022 case 14: /* snmpInTotalSetVars */
4023 *uint_ptr = snmpintotalsetvars;
4025 case 15: /* snmpInGetRequests */
4026 *uint_ptr = snmpingetrequests;
4028 case 16: /* snmpInGetNexts */
4029 *uint_ptr = snmpingetnexts;
4031 case 17: /* snmpInSetRequests */
4032 *uint_ptr = snmpinsetrequests;
4034 case 18: /* snmpInGetResponses */
4035 *uint_ptr = snmpingetresponses;
4037 case 19: /* snmpInTraps */
4038 *uint_ptr = snmpintraps;
4040 case 20: /* snmpOutTooBigs */
4041 *uint_ptr = snmpouttoobigs;
4043 case 21: /* snmpOutNoSuchNames */
4044 *uint_ptr = snmpoutnosuchnames;
4046 case 22: /* snmpOutBadValues */
4047 *uint_ptr = snmpoutbadvalues;
4049 case 24: /* snmpOutGenErrs */
4050 *uint_ptr = snmpoutgenerrs;
4052 case 25: /* snmpOutGetRequests */
4053 *uint_ptr = snmpoutgetrequests;
4055 case 26: /* snmpOutGetNexts */
4056 *uint_ptr = snmpoutgetnexts;
4058 case 27: /* snmpOutSetRequests */
4059 *uint_ptr = snmpoutsetrequests;
4061 case 28: /* snmpOutGetResponses */
4062 *uint_ptr = snmpoutgetresponses;
4064 case 29: /* snmpOutTraps */
4065 *uint_ptr = snmpouttraps;
4067 case 30: /* snmpEnableAuthenTraps */
4068 *uint_ptr = *snmpenableauthentraps_ptr;
4074 * Test snmp object value before setting.
4076 * @param od is the object definition
4077 * @param len return value space (in bytes)
4078 * @param value points to (varbind) space to copy value from.
4081 snmp_set_test(struct obj_def *od, u16_t len, void *value)
4085 LWIP_UNUSED_ARG(len);
4087 id = od->id_inst_ptr[0];
4090 /* snmpEnableAuthenTraps */
4091 s32_t *sint_ptr = value;
4093 if (snmpenableauthentraps_ptr != &snmpenableauthentraps_default)
4095 /* we should have writable non-volatile mem here */
4096 if ((*sint_ptr == 1) || (*sint_ptr == 2))
4103 /* const or hardwired value */
4104 if (*sint_ptr == snmpenableauthentraps_default)
4114 snmp_set_value(struct obj_def *od, u16_t len, void *value)
4118 LWIP_UNUSED_ARG(len);
4119 id = od->id_inst_ptr[0];
4122 /* snmpEnableAuthenTraps */
4123 s32_t *sint_ptr = value;
4124 *snmpenableauthentraps_ptr = *sint_ptr;
4128 #endif /* LWIP_SNMP */