1 /**
2  * @file
3  * Management Information Base II (RFC1213) objects and functions.
4  */
5 
6 /*
7  * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  *    this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  *    this list of conditions and the following disclaimer in the documentation
17  *    and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30  * OF SUCH DAMAGE.
31  *
32  * Author: Dirk Ziegelmeier <dziegel@gmx.de>
33  *         Christiaan Simons <christiaan.simons@axon.tv>
34  */
35 
36 /**
37  * @defgroup snmp_mib2 MIB2
38  * @ingroup snmp
39  */
40 
41 #include "lwip/apps/snmp_opts.h"
42 
43 #if LWIP_SNMP && SNMP_LWIP_MIB2 /* don't build if not configured for use in lwipopts.h */
44 
45 #if !LWIP_STATS
46 #error LWIP_SNMP MIB2 needs LWIP_STATS (for MIB2)
47 #endif
48 #if !MIB2_STATS
49 #error LWIP_SNMP MIB2 needs MIB2_STATS (for MIB2)
50 #endif
51 
52 #include "lwip/snmp.h"
53 #include "lwip/apps/snmp.h"
54 #include "lwip/apps/snmp_core.h"
55 #include "lwip/apps/snmp_mib2.h"
56 #include "lwip/apps/snmp_scalar.h"
57 
58 #if SNMP_USE_NETCONN
59 #include "lwip/tcpip.h"
60 #include "lwip/priv/tcpip_priv.h"
61 void
62 snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg)
63 {
64 #if LWIP_TCPIP_CORE_LOCKING
65   LOCK_TCPIP_CORE();
66   fn(arg);
67   UNLOCK_TCPIP_CORE();
68 #else
69   tcpip_callback(fn, arg);
70 #endif
71 }
72 
73 struct snmp_threadsync_instance snmp_mib2_lwip_locks;
74 #endif
75 
76 /* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */
77 /* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */
78 /* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
79 
80 /* --- mib-2 .1.3.6.1.2.1 ----------------------------------------------------- */
81 extern const struct snmp_scalar_array_node snmp_mib2_snmp_root;
82 extern const struct snmp_tree_node snmp_mib2_udp_root;
83 extern const struct snmp_tree_node snmp_mib2_tcp_root;
84 extern const struct snmp_scalar_array_node snmp_mib2_icmp_root;
85 extern const struct snmp_tree_node snmp_mib2_interface_root;
86 extern const struct snmp_scalar_array_node snmp_mib2_system_node;
87 extern const struct snmp_tree_node snmp_mib2_at_root;
88 extern const struct snmp_tree_node snmp_mib2_ip_root;
89 
90 static const struct snmp_node* const mib2_nodes[] = {
91   &snmp_mib2_system_node.node.node,
92   &snmp_mib2_interface_root.node,
93 #if LWIP_ARP && LWIP_IPV4
94   &snmp_mib2_at_root.node,
95 #endif /* LWIP_ARP && LWIP_IPV4 */
96 #if LWIP_IPV4
97   &snmp_mib2_ip_root.node,
98 #endif /* LWIP_IPV4 */
99 #if LWIP_ICMP
100   &snmp_mib2_icmp_root.node.node,
101 #endif /* LWIP_ICMP */
102 #if LWIP_TCP
103   &snmp_mib2_tcp_root.node,
104 #endif /* LWIP_TCP */
105 #if LWIP_UDP
106   &snmp_mib2_udp_root.node,
107 #endif /* LWIP_UDP */
108   &snmp_mib2_snmp_root.node.node
109 };
110 
111 static const struct snmp_tree_node mib2_root = SNMP_CREATE_TREE_NODE(1, mib2_nodes);
112 
113 static const u32_t  mib2_base_oid_arr[] = { 1,3,6,1,2,1 };
114 const struct snmp_mib mib2 = SNMP_MIB_CREATE(mib2_base_oid_arr, &mib2_root.node);
115 
116 #endif /* LWIP_SNMP && SNMP_LWIP_MIB2 */
117