xref: /third_party/lwip/src/apps/snmp/snmp_mib2.c (revision 195972f6)
1195972f6Sopenharmony_ci/**
2195972f6Sopenharmony_ci * @file
3195972f6Sopenharmony_ci * Management Information Base II (RFC1213) objects and functions.
4195972f6Sopenharmony_ci */
5195972f6Sopenharmony_ci
6195972f6Sopenharmony_ci/*
7195972f6Sopenharmony_ci * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
8195972f6Sopenharmony_ci * All rights reserved.
9195972f6Sopenharmony_ci *
10195972f6Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification,
11195972f6Sopenharmony_ci * are permitted provided that the following conditions are met:
12195972f6Sopenharmony_ci *
13195972f6Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice,
14195972f6Sopenharmony_ci *    this list of conditions and the following disclaimer.
15195972f6Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice,
16195972f6Sopenharmony_ci *    this list of conditions and the following disclaimer in the documentation
17195972f6Sopenharmony_ci *    and/or other materials provided with the distribution.
18195972f6Sopenharmony_ci * 3. The name of the author may not be used to endorse or promote products
19195972f6Sopenharmony_ci *    derived from this software without specific prior written permission.
20195972f6Sopenharmony_ci *
21195972f6Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22195972f6Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23195972f6Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24195972f6Sopenharmony_ci * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25195972f6Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26195972f6Sopenharmony_ci * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27195972f6Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28195972f6Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29195972f6Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30195972f6Sopenharmony_ci * OF SUCH DAMAGE.
31195972f6Sopenharmony_ci *
32195972f6Sopenharmony_ci * Author: Dirk Ziegelmeier <dziegel@gmx.de>
33195972f6Sopenharmony_ci *         Christiaan Simons <christiaan.simons@axon.tv>
34195972f6Sopenharmony_ci */
35195972f6Sopenharmony_ci
36195972f6Sopenharmony_ci/**
37195972f6Sopenharmony_ci * @defgroup snmp_mib2 MIB2
38195972f6Sopenharmony_ci * @ingroup snmp
39195972f6Sopenharmony_ci */
40195972f6Sopenharmony_ci
41195972f6Sopenharmony_ci#include "lwip/apps/snmp_opts.h"
42195972f6Sopenharmony_ci
43195972f6Sopenharmony_ci#if LWIP_SNMP && SNMP_LWIP_MIB2 /* don't build if not configured for use in lwipopts.h */
44195972f6Sopenharmony_ci
45195972f6Sopenharmony_ci#if !LWIP_STATS
46195972f6Sopenharmony_ci#error LWIP_SNMP MIB2 needs LWIP_STATS (for MIB2)
47195972f6Sopenharmony_ci#endif
48195972f6Sopenharmony_ci#if !MIB2_STATS
49195972f6Sopenharmony_ci#error LWIP_SNMP MIB2 needs MIB2_STATS (for MIB2)
50195972f6Sopenharmony_ci#endif
51195972f6Sopenharmony_ci
52195972f6Sopenharmony_ci#include "lwip/snmp.h"
53195972f6Sopenharmony_ci#include "lwip/apps/snmp.h"
54195972f6Sopenharmony_ci#include "lwip/apps/snmp_core.h"
55195972f6Sopenharmony_ci#include "lwip/apps/snmp_mib2.h"
56195972f6Sopenharmony_ci#include "lwip/apps/snmp_scalar.h"
57195972f6Sopenharmony_ci
58195972f6Sopenharmony_ci#if SNMP_USE_NETCONN
59195972f6Sopenharmony_ci#include "lwip/tcpip.h"
60195972f6Sopenharmony_ci#include "lwip/priv/tcpip_priv.h"
61195972f6Sopenharmony_civoid
62195972f6Sopenharmony_cisnmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void *arg)
63195972f6Sopenharmony_ci{
64195972f6Sopenharmony_ci#if LWIP_TCPIP_CORE_LOCKING
65195972f6Sopenharmony_ci  LOCK_TCPIP_CORE();
66195972f6Sopenharmony_ci  fn(arg);
67195972f6Sopenharmony_ci  UNLOCK_TCPIP_CORE();
68195972f6Sopenharmony_ci#else
69195972f6Sopenharmony_ci  tcpip_callback(fn, arg);
70195972f6Sopenharmony_ci#endif
71195972f6Sopenharmony_ci}
72195972f6Sopenharmony_ci
73195972f6Sopenharmony_cistruct snmp_threadsync_instance snmp_mib2_lwip_locks;
74195972f6Sopenharmony_ci#endif
75195972f6Sopenharmony_ci
76195972f6Sopenharmony_ci/* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */
77195972f6Sopenharmony_ci/* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */
78195972f6Sopenharmony_ci/* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
79195972f6Sopenharmony_ci
80195972f6Sopenharmony_ci/* --- mib-2 .1.3.6.1.2.1 ----------------------------------------------------- */
81195972f6Sopenharmony_ciextern const struct snmp_scalar_array_node snmp_mib2_snmp_root;
82195972f6Sopenharmony_ciextern const struct snmp_tree_node snmp_mib2_udp_root;
83195972f6Sopenharmony_ciextern const struct snmp_tree_node snmp_mib2_tcp_root;
84195972f6Sopenharmony_ciextern const struct snmp_scalar_array_node snmp_mib2_icmp_root;
85195972f6Sopenharmony_ciextern const struct snmp_tree_node snmp_mib2_interface_root;
86195972f6Sopenharmony_ciextern const struct snmp_scalar_array_node snmp_mib2_system_node;
87195972f6Sopenharmony_ciextern const struct snmp_tree_node snmp_mib2_at_root;
88195972f6Sopenharmony_ciextern const struct snmp_tree_node snmp_mib2_ip_root;
89195972f6Sopenharmony_ci
90195972f6Sopenharmony_cistatic const struct snmp_node *const mib2_nodes[] = {
91195972f6Sopenharmony_ci  &snmp_mib2_system_node.node.node,
92195972f6Sopenharmony_ci  &snmp_mib2_interface_root.node,
93195972f6Sopenharmony_ci#if LWIP_ARP && LWIP_IPV4
94195972f6Sopenharmony_ci  &snmp_mib2_at_root.node,
95195972f6Sopenharmony_ci#endif /* LWIP_ARP && LWIP_IPV4 */
96195972f6Sopenharmony_ci#if LWIP_IPV4
97195972f6Sopenharmony_ci  &snmp_mib2_ip_root.node,
98195972f6Sopenharmony_ci#endif /* LWIP_IPV4 */
99195972f6Sopenharmony_ci#if LWIP_ICMP
100195972f6Sopenharmony_ci  &snmp_mib2_icmp_root.node.node,
101195972f6Sopenharmony_ci#endif /* LWIP_ICMP */
102195972f6Sopenharmony_ci#if LWIP_TCP
103195972f6Sopenharmony_ci  &snmp_mib2_tcp_root.node,
104195972f6Sopenharmony_ci#endif /* LWIP_TCP */
105195972f6Sopenharmony_ci#if LWIP_UDP
106195972f6Sopenharmony_ci  &snmp_mib2_udp_root.node,
107195972f6Sopenharmony_ci#endif /* LWIP_UDP */
108195972f6Sopenharmony_ci  &snmp_mib2_snmp_root.node.node
109195972f6Sopenharmony_ci};
110195972f6Sopenharmony_ci
111195972f6Sopenharmony_cistatic const struct snmp_tree_node mib2_root = SNMP_CREATE_TREE_NODE(1, mib2_nodes);
112195972f6Sopenharmony_ci
113195972f6Sopenharmony_cistatic const u32_t  mib2_base_oid_arr[] = { 1, 3, 6, 1, 2, 1 };
114195972f6Sopenharmony_ciconst struct snmp_mib mib2 = SNMP_MIB_CREATE(mib2_base_oid_arr, &mib2_root.node);
115195972f6Sopenharmony_ci
116195972f6Sopenharmony_ci#endif /* LWIP_SNMP && SNMP_LWIP_MIB2 */
117