STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
snmp.h
Go to the documentation of this file.
1 
7 /*
8  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification,
12  * are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  * derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31  * OF SUCH DAMAGE.
32  *
33  * This file is part of the lwIP TCP/IP stack.
34  *
35  * Author: Dirk Ziegelmeier <dziegel@gmx.de>
36  *
37  */
38 #ifndef LWIP_HDR_SNMP_H
39 #define LWIP_HDR_SNMP_H
40 
41 #include "lwip/opt.h"
42 #include "lwip/ip_addr.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 struct udp_pcb;
49 struct netif;
50 
51 /* MIB2 statistics functions */
52 #if MIB2_STATS /* don't build if not configured for use in lwipopts.h */
53 
56 enum snmp_ifType {
57  snmp_ifType_other=1, /* none of the following */
58  snmp_ifType_regular1822,
59  snmp_ifType_hdh1822,
60  snmp_ifType_ddn_x25,
61  snmp_ifType_rfc877_x25,
62  snmp_ifType_ethernet_csmacd,
63  snmp_ifType_iso88023_csmacd,
64  snmp_ifType_iso88024_tokenBus,
65  snmp_ifType_iso88025_tokenRing,
66  snmp_ifType_iso88026_man,
67  snmp_ifType_starLan,
68  snmp_ifType_proteon_10Mbit,
69  snmp_ifType_proteon_80Mbit,
70  snmp_ifType_hyperchannel,
71  snmp_ifType_fddi,
72  snmp_ifType_lapb,
73  snmp_ifType_sdlc,
74  snmp_ifType_ds1, /* T-1 */
75  snmp_ifType_e1, /* european equiv. of T-1 */
76  snmp_ifType_basicISDN,
77  snmp_ifType_primaryISDN, /* proprietary serial */
78  snmp_ifType_propPointToPointSerial,
79  snmp_ifType_ppp,
80  snmp_ifType_softwareLoopback,
81  snmp_ifType_eon, /* CLNP over IP [11] */
82  snmp_ifType_ethernet_3Mbit,
83  snmp_ifType_nsip, /* XNS over IP */
84  snmp_ifType_slip, /* generic SLIP */
85  snmp_ifType_ultra, /* ULTRA technologies */
86  snmp_ifType_ds3, /* T-3 */
87  snmp_ifType_sip, /* SMDS */
88  snmp_ifType_frame_relay
89 };
90 
91 /* This macro has a precision of ~49 days because sys_now returns u32_t. #define your own if you want ~490 days. */
92 #ifndef MIB2_COPY_SYSUPTIME_TO
93 #define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10))
94 #endif
95 
96 #define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0)
97 #define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0)
98 
99 #define MIB2_INIT_NETIF(netif, type, speed) do { \
100  /* use "snmp_ifType" enum from snmp_mib2.h for "type", snmp_ifType_ethernet_csmacd by example */ \
101  (netif)->link_type = (type); \
102  /* your link speed here (units: bits per second) */ \
103  (netif)->link_speed = (speed);\
104  (netif)->ts = 0; \
105  (netif)->mib2_counters.ifinoctets = 0; \
106  (netif)->mib2_counters.ifinucastpkts = 0; \
107  (netif)->mib2_counters.ifinnucastpkts = 0; \
108  (netif)->mib2_counters.ifindiscards = 0; \
109  (netif)->mib2_counters.ifinerrors = 0; \
110  (netif)->mib2_counters.ifinunknownprotos = 0; \
111  (netif)->mib2_counters.ifoutoctets = 0; \
112  (netif)->mib2_counters.ifoutucastpkts = 0; \
113  (netif)->mib2_counters.ifoutnucastpkts = 0; \
114  (netif)->mib2_counters.ifoutdiscards = 0; \
115  (netif)->mib2_counters.ifouterrors = 0; } while(0)
116 #else /* MIB2_STATS */
117 #ifndef MIB2_COPY_SYSUPTIME_TO
118 #define MIB2_COPY_SYSUPTIME_TO(ptrToVal)
119 #endif
120 #define MIB2_INIT_NETIF(netif, type, speed)
121 #define MIB2_STATS_NETIF_INC(n, x)
122 #define MIB2_STATS_NETIF_ADD(n, x, val)
123 #endif /* MIB2_STATS */
124 
125 /* LWIP MIB2 callbacks */
126 #if LWIP_MIB2_CALLBACKS /* don't build if not configured for use in lwipopts.h */
127 /* network interface */
128 void mib2_netif_added(struct netif *ni);
129 void mib2_netif_removed(struct netif *ni);
130 
131 #if LWIP_IPV4 && LWIP_ARP
132 /* ARP (for atTable and ipNetToMediaTable) */
133 void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip);
134 void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip);
135 #else /* LWIP_IPV4 && LWIP_ARP */
136 #define mib2_add_arp_entry(ni,ip)
137 #define mib2_remove_arp_entry(ni,ip)
138 #endif /* LWIP_IPV4 && LWIP_ARP */
139 
140 /* IP */
141 #if LWIP_IPV4
142 void mib2_add_ip4(struct netif *ni);
143 void mib2_remove_ip4(struct netif *ni);
144 void mib2_add_route_ip4(u8_t dflt, struct netif *ni);
145 void mib2_remove_route_ip4(u8_t dflt, struct netif *ni);
146 #endif /* LWIP_IPV4 */
147 
148 /* UDP */
149 #if LWIP_UDP
150 void mib2_udp_bind(struct udp_pcb *pcb);
151 void mib2_udp_unbind(struct udp_pcb *pcb);
152 #endif /* LWIP_UDP */
153 
154 #else /* LWIP_MIB2_CALLBACKS */
155 /* LWIP_MIB2_CALLBACKS support not available */
156 /* define everything to be empty */
157 
158 /* network interface */
159 #define mib2_netif_added(ni)
160 #define mib2_netif_removed(ni)
161 
162 /* ARP */
163 #define mib2_add_arp_entry(ni,ip)
164 #define mib2_remove_arp_entry(ni,ip)
165 
166 /* IP */
167 #define mib2_add_ip4(ni)
168 #define mib2_remove_ip4(ni)
169 #define mib2_add_route_ip4(dflt, ni)
170 #define mib2_remove_route_ip4(dflt, ni)
171 
172 /* UDP */
173 #define mib2_udp_bind(pcb)
174 #define mib2_udp_unbind(pcb)
175 #endif /* LWIP_MIB2_CALLBACKS */
176 
177 /* for source-code compatibility reasons only, can be removed (not used internally) */
178 #define NETIF_INIT_SNMP MIB2_INIT_NETIF
179 #define snmp_add_ifinoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifinoctets, value)
180 #define snmp_inc_ifinucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinucastpkts)
181 #define snmp_inc_ifinnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinnucastpkts)
182 #define snmp_inc_ifindiscards(ni) MIB2_STATS_NETIF_INC(ni, ifindiscards)
183 #define snmp_inc_ifinerrors(ni) MIB2_STATS_NETIF_INC(ni, ifinerrors)
184 #define snmp_inc_ifinunknownprotos(ni) MIB2_STATS_NETIF_INC(ni, ifinunknownprotos)
185 #define snmp_add_ifoutoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifoutoctets, value)
186 #define snmp_inc_ifoutucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutucastpkts)
187 #define snmp_inc_ifoutnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutnucastpkts)
188 #define snmp_inc_ifoutdiscards(ni) MIB2_STATS_NETIF_INC(ni, ifoutdiscards)
189 #define snmp_inc_ifouterrors(ni) MIB2_STATS_NETIF_INC(ni, ifouterrors)
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif /* LWIP_HDR_SNMP_H */
196 
#define mib2_remove_arp_entry(ni, ip)
Definition: snmp.h:164
#define mib2_remove_ip4(ni)
Definition: snmp.h:168
#define mib2_udp_unbind(pcb)
Definition: snmp.h:174
#define mib2_udp_bind(pcb)
Definition: snmp.h:173
#define mib2_add_route_ip4(dflt, ni)
Definition: snmp.h:169
#define mib2_add_arp_entry(ni, ip)
Definition: snmp.h:163
#define mib2_netif_added(ni)
Definition: snmp.h:159
Definition: netif.h:182
unsigned char u8_t
Definition: cc.h:38
#define mib2_remove_route_ip4(dflt, ni)
Definition: snmp.h:170
#define mib2_netif_removed(ni)
Definition: snmp.h:160
#define mib2_add_ip4(ni)
Definition: snmp.h:167