1
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
105
106
110
111
112
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
142
143
144
145
146
147
148
149
150
153
154
157
158
159
160
164
165
166
167
168
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* ... */
/* ... */
#ifndef LWIP_HDR_SNMP_H
#define LWIP_HDR_SNMP_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern "C" {
#endif
struct udp_pcb;
struct netif;
/* ... */
#if MIB2_STATS
/* ... */
enum snmp_ifType {
snmp_ifType_other=1,
snmp_ifType_regular1822,
snmp_ifType_hdh1822,
snmp_ifType_ddn_x25,
snmp_ifType_rfc877_x25,
snmp_ifType_ethernet_csmacd,
snmp_ifType_iso88023_csmacd,
snmp_ifType_iso88024_tokenBus,
snmp_ifType_iso88025_tokenRing,
snmp_ifType_iso88026_man,
snmp_ifType_starLan,
snmp_ifType_proteon_10Mbit,
snmp_ifType_proteon_80Mbit,
snmp_ifType_hyperchannel,
snmp_ifType_fddi,
snmp_ifType_lapb,
snmp_ifType_sdlc,
snmp_ifType_ds1,
snmp_ifType_e1,
snmp_ifType_basicISDN,
snmp_ifType_primaryISDN,
snmp_ifType_propPointToPointSerial,
snmp_ifType_ppp,
snmp_ifType_softwareLoopback,
snmp_ifType_eon,
snmp_ifType_ethernet_3Mbit,
snmp_ifType_nsip,
snmp_ifType_slip,
snmp_ifType_ultra,
snmp_ifType_ds3,
snmp_ifType_sip,
snmp_ifType_frame_relay
...};
#ifndef MIB2_COPY_SYSUPTIME_TO
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10))
#endif
/* ... */
#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0)
/* ... */
#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0)
/* ... */
#define MIB2_INIT_NETIF(netif, type, speed) do { \
(netif)->link_type = (type); \
(netif)->link_speed = (speed);\
(netif)->ts = 0; \
(netif)->mib2_counters.ifinoctets = 0; \
(netif)->mib2_counters.ifinucastpkts = 0; \
(netif)->mib2_counters.ifinnucastpkts = 0; \
(netif)->mib2_counters.ifindiscards = 0; \
(netif)->mib2_counters.ifinerrors = 0; \
(netif)->mib2_counters.ifinunknownprotos = 0; \
(netif)->mib2_counters.ifoutoctets = 0; \
(netif)->mib2_counters.ifoutucastpkts = 0; \
(netif)->mib2_counters.ifoutnucastpkts = 0; \
(netif)->mib2_counters.ifoutdiscards = 0; \
(netif)->mib2_counters.ifouterrors = 0; ...} while(0)...
/* ... */#else
#ifndef MIB2_COPY_SYSUPTIME_TO
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal)
#endif
#define MIB2_INIT_NETIF(netif, type, speed)
#define MIB2_STATS_NETIF_INC(n, x)
#define MIB2_STATS_NETIF_ADD(n, x, val)
/* ... */#endif
#if LWIP_MIB2_CALLBACKS
void mib2_netif_added(struct netif *ni);
void mib2_netif_removed(struct netif *ni);
#if LWIP_IPV4 && LWIP_ARP
void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip);
void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip);/* ... */
#else
#define mib2_add_arp_entry(ni,ip)
#define mib2_remove_arp_entry(ni,ip)
/* ... */#endif
#if LWIP_IPV4
void mib2_add_ip4(struct netif *ni);
void mib2_remove_ip4(struct netif *ni);
void mib2_add_route_ip4(u8_t dflt, struct netif *ni);
void mib2_remove_route_ip4(u8_t dflt, struct netif *ni);/* ... */
#endif
#if LWIP_UDP
void mib2_udp_bind(struct udp_pcb *pcb);
void mib2_udp_unbind(struct udp_pcb *pcb);/* ... */
#endif
/* ... */
#else
#define mib2_netif_added(ni)
#define mib2_netif_removed(ni)
#define mib2_add_arp_entry(ni,ip)
#define mib2_remove_arp_entry(ni,ip)
#define mib2_add_ip4(ni)
#define mib2_remove_ip4(ni)
#define mib2_add_route_ip4(dflt, ni)
#define mib2_remove_route_ip4(dflt, ni)
#define mib2_udp_bind(pcb)
#define mib2_udp_unbind(pcb)
10 defines#endif/* ... */
#define NETIF_INIT_SNMP MIB2_INIT_NETIF
#define snmp_add_ifinoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifinoctets, value)
#define snmp_inc_ifinucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinucastpkts)
#define snmp_inc_ifinnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinnucastpkts)
#define snmp_inc_ifindiscards(ni) MIB2_STATS_NETIF_INC(ni, ifindiscards)
#define snmp_inc_ifinerrors(ni) MIB2_STATS_NETIF_INC(ni, ifinerrors)
#define snmp_inc_ifinunknownprotos(ni) MIB2_STATS_NETIF_INC(ni, ifinunknownprotos)
#define snmp_add_ifoutoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifoutoctets, value)
#define snmp_inc_ifoutucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutucastpkts)
#define snmp_inc_ifoutnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutnucastpkts)
#define snmp_inc_ifoutdiscards(ni) MIB2_STATS_NETIF_INC(ni, ifoutdiscards)
#define snmp_inc_ifouterrors(ni) MIB2_STATS_NETIF_INC(ni, ifouterrors)
12 defines
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif