source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/wifiHD/src/SOFTWARE_FRAMEWORK/SERVICES/LWIP/lwip-1.3.2/src/include/lwip/stats.h @ 46

Last change on this file since 46 was 46, checked in by jrpelegrina, 4 years ago

First release to Xenial

File size: 8.1 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/*
4 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 *    this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 *    this list of conditions and the following disclaimer in the documentation
14 *    and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 *    derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27 * OF SUCH DAMAGE.
28 *
29 * This file is part of the lwIP TCP/IP stack.
30 *
31 * Author: Adam Dunkels <adam@sics.se>
32 *
33 */
34#ifndef __LWIP_STATS_H__
35#define __LWIP_STATS_H__
36
37#include "lwip/opt.h"
38
39#include "lwip/mem.h"
40#include "lwip/memp.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#if LWIP_STATS
47
48#ifndef LWIP_STATS_LARGE
49#define LWIP_STATS_LARGE 0
50#endif
51
52#if LWIP_STATS_LARGE
53#define STAT_COUNTER     u32_t
54#define STAT_COUNTER_F   U32_F
55#else
56#define STAT_COUNTER     u16_t
57#define STAT_COUNTER_F   U16_F
58#endif
59
60struct stats_proto {
61  STAT_COUNTER xmit;             /* Transmitted packets. */
62  STAT_COUNTER recv;             /* Received packets. */
63  STAT_COUNTER fw;               /* Forwarded packets. */
64  STAT_COUNTER drop;             /* Dropped packets. */
65  STAT_COUNTER chkerr;           /* Checksum error. */
66  STAT_COUNTER lenerr;           /* Invalid length error. */
67  STAT_COUNTER memerr;           /* Out of memory error. */
68  STAT_COUNTER rterr;            /* Routing error. */
69  STAT_COUNTER proterr;          /* Protocol error. */
70  STAT_COUNTER opterr;           /* Error in options. */
71  STAT_COUNTER err;              /* Misc error. */
72  STAT_COUNTER cachehit;
73};
74
75struct stats_igmp {
76  STAT_COUNTER lenerr;           /* Invalid length error. */
77  STAT_COUNTER chkerr;           /* Checksum error. */
78  STAT_COUNTER v1_rxed;          /* */
79  STAT_COUNTER join_sent;        /* */
80  STAT_COUNTER leave_sent;       /* */
81  STAT_COUNTER unicast_query;    /* */
82  STAT_COUNTER report_sent;      /* */
83  STAT_COUNTER report_rxed;      /* */
84  STAT_COUNTER group_query_rxed; /* */
85};
86
87struct stats_mem {
88  mem_size_t avail;
89  mem_size_t used;
90  mem_size_t max;
91  STAT_COUNTER err;
92  STAT_COUNTER illegal;
93};
94
95struct stats_syselem {
96  STAT_COUNTER used;
97  STAT_COUNTER max;
98  STAT_COUNTER err;
99};
100
101struct stats_sys {
102  struct stats_syselem sem;
103  struct stats_syselem mbox;
104};
105
106struct stats_ {
107#if LINK_STATS
108  struct stats_proto link;
109#endif
110#if ETHARP_STATS
111  struct stats_proto etharp;
112#endif
113#if IPFRAG_STATS
114  struct stats_proto ip_frag;
115#endif
116#if IP_STATS
117  struct stats_proto ip;
118#endif
119#if ICMP_STATS
120  struct stats_proto icmp;
121#endif
122#if IGMP_STATS
123  struct stats_igmp igmp;
124#endif
125#if UDP_STATS
126  struct stats_proto udp;
127#endif
128#if TCP_STATS
129  struct stats_proto tcp;
130#endif
131#if MEM_STATS
132  struct stats_mem mem;
133#endif
134#if MEMP_STATS
135  struct stats_mem memp[MEMP_MAX];
136#endif
137#if SYS_STATS
138  struct stats_sys sys;
139#endif
140};
141
142extern struct stats_ lwip_stats;
143
144#define stats_init() /* Compatibility define, not init needed. */
145
146#define STATS_INC(x) ++lwip_stats.x
147#define STATS_DEC(x) --lwip_stats.x
148#else
149#define stats_init()
150#define STATS_INC(x)
151#define STATS_DEC(x)
152#endif /* LWIP_STATS */
153
154#if TCP_STATS
155#define TCP_STATS_INC(x) STATS_INC(x)
156#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
157#else
158#define TCP_STATS_INC(x)
159#define TCP_STATS_DISPLAY()
160#endif
161
162#if UDP_STATS
163#define UDP_STATS_INC(x) STATS_INC(x)
164#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
165#else
166#define UDP_STATS_INC(x)
167#define UDP_STATS_DISPLAY()
168#endif
169
170#if ICMP_STATS
171#define ICMP_STATS_INC(x) STATS_INC(x)
172#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
173#else
174#define ICMP_STATS_INC(x)
175#define ICMP_STATS_DISPLAY()
176#endif
177
178#if IGMP_STATS
179#define IGMP_STATS_INC(x) STATS_INC(x)
180#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp)
181#else
182#define IGMP_STATS_INC(x)
183#define IGMP_STATS_DISPLAY()
184#endif
185
186#if IP_STATS
187#define IP_STATS_INC(x) STATS_INC(x)
188#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
189#else
190#define IP_STATS_INC(x)
191#define IP_STATS_DISPLAY()
192#endif
193
194#if IPFRAG_STATS
195#define IPFRAG_STATS_INC(x) STATS_INC(x)
196#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
197#else
198#define IPFRAG_STATS_INC(x)
199#define IPFRAG_STATS_DISPLAY()
200#endif
201
202#if ETHARP_STATS
203#define ETHARP_STATS_INC(x) STATS_INC(x)
204#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
205#else
206#define ETHARP_STATS_INC(x)
207#define ETHARP_STATS_DISPLAY()
208#endif
209
210#if LINK_STATS
211#define LINK_STATS_INC(x) STATS_INC(x)
212#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
213#else
214#define LINK_STATS_INC(x)
215#define LINK_STATS_DISPLAY()
216#endif
217
218#if MEM_STATS
219#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
220#define MEM_STATS_INC(x) STATS_INC(mem.x)
221#define MEM_STATS_INC_USED(x, y) do { lwip_stats.mem.used += y; \
222                                    if (lwip_stats.mem.max < lwip_stats.mem.used) { \
223                                        lwip_stats.mem.max = lwip_stats.mem.used; \
224                                    } \
225                                 } while(0)
226#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
227#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
228#else
229#define MEM_STATS_AVAIL(x, y)
230#define MEM_STATS_INC(x)
231#define MEM_STATS_INC_USED(x, y)
232#define MEM_STATS_DEC_USED(x, y)
233#define MEM_STATS_DISPLAY()
234#endif
235
236#if MEMP_STATS
237#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
238#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
239#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
240#define MEMP_STATS_INC_USED(x, i) do { ++lwip_stats.memp[i].used; \
241                                    if (lwip_stats.memp[i].max < lwip_stats.memp[i].used) { \
242                                        lwip_stats.memp[i].max = lwip_stats.memp[i].used; \
243                                    } \
244                                 } while(0)
245#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
246#else
247#define MEMP_STATS_AVAIL(x, i, y)
248#define MEMP_STATS_INC(x, i)
249#define MEMP_STATS_DEC(x, i)
250#define MEMP_STATS_INC_USED(x, i)
251#define MEMP_STATS_DISPLAY(i)
252#endif
253
254#if SYS_STATS
255#define SYS_STATS_INC(x) STATS_INC(sys.x)
256#define SYS_STATS_DEC(x) STATS_DEC(sys.x)
257#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
258#else
259#define SYS_STATS_INC(x)
260#define SYS_STATS_DEC(x)
261#define SYS_STATS_DISPLAY()
262#endif
263
264/* Display of statistics */
265#if LWIP_STATS_DISPLAY
266void stats_display(void);
267void stats_display_proto(struct stats_proto *proto, char *name);
268void stats_display_igmp(struct stats_igmp *igmp);
269void stats_display_mem(struct stats_mem *mem, char *name);
270void stats_display_memp(struct stats_mem *mem, int index);
271void stats_display_sys(struct stats_sys *sys);
272#else
273#define stats_display()
274#define stats_display_proto(proto, name)
275#define stats_display_igmp(igmp)
276#define stats_display_mem(mem, name)
277#define stats_display_memp(mem, index)
278#define stats_display_sys(sys)
279#endif /* LWIP_STATS_DISPLAY */
280
281#ifdef __cplusplus
282}
283#endif
284
285#endif /* __LWIP_STATS_H__ */
Note: See TracBrowser for help on using the repository browser.