]> git.sur5r.net Git - freertos/blob - Demo/Common/ethernet/lwIP_130/src/include/lwip/stats.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / Common / ethernet / lwIP_130 / src / include / lwip / stats.h
1 /*\r
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without modification,\r
6  * are permitted provided that the following conditions are met:\r
7  *\r
8  * 1. Redistributions of source code must retain the above copyright notice,\r
9  *    this list of conditions and the following disclaimer.\r
10  * 2. Redistributions in binary form must reproduce the above copyright notice,\r
11  *    this list of conditions and the following disclaimer in the documentation\r
12  *    and/or other materials provided with the distribution.\r
13  * 3. The name of the author may not be used to endorse or promote products\r
14  *    derived from this software without specific prior written permission.\r
15  *\r
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED\r
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT\r
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT\r
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\r
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY\r
25  * OF SUCH DAMAGE.\r
26  *\r
27  * This file is part of the lwIP TCP/IP stack.\r
28  *\r
29  * Author: Adam Dunkels <adam@sics.se>\r
30  *\r
31  */\r
32 #ifndef __LWIP_STATS_H__\r
33 #define __LWIP_STATS_H__\r
34 \r
35 #include "lwip/opt.h"\r
36 \r
37 #include "lwip/mem.h"\r
38 #include "lwip/memp.h"\r
39 \r
40 #ifdef __cplusplus\r
41 extern "C" {\r
42 #endif\r
43 \r
44 #if LWIP_STATS\r
45 \r
46 #ifndef LWIP_STATS_LARGE\r
47 #define LWIP_STATS_LARGE 0\r
48 #endif\r
49 \r
50 #if LWIP_STATS_LARGE\r
51 #define STAT_COUNTER     u32_t\r
52 #define STAT_COUNTER_F   U32_F\r
53 #else\r
54 #define STAT_COUNTER     u16_t\r
55 #define STAT_COUNTER_F   U16_F\r
56 #endif\r
57 \r
58 struct stats_proto {\r
59   STAT_COUNTER xmit;             /* Transmitted packets. */\r
60   STAT_COUNTER rexmit;           /* Retransmitted packets. */\r
61   STAT_COUNTER recv;             /* Received packets. */\r
62   STAT_COUNTER fw;               /* Forwarded packets. */\r
63   STAT_COUNTER drop;             /* Dropped packets. */\r
64   STAT_COUNTER chkerr;           /* Checksum error. */\r
65   STAT_COUNTER lenerr;           /* Invalid length error. */\r
66   STAT_COUNTER memerr;           /* Out of memory error. */\r
67   STAT_COUNTER rterr;            /* Routing error. */\r
68   STAT_COUNTER proterr;          /* Protocol error. */\r
69   STAT_COUNTER opterr;           /* Error in options. */\r
70   STAT_COUNTER err;              /* Misc error. */\r
71   STAT_COUNTER cachehit;\r
72 };\r
73 \r
74 struct stats_igmp {\r
75   STAT_COUNTER lenerr;           /* Invalid length error. */\r
76   STAT_COUNTER chkerr;           /* Checksum error. */\r
77   STAT_COUNTER v1_rxed;          /* */\r
78   STAT_COUNTER join_sent;        /* */\r
79   STAT_COUNTER leave_sent;       /* */\r
80   STAT_COUNTER unicast_query;    /* */\r
81   STAT_COUNTER report_sent;      /* */\r
82   STAT_COUNTER report_rxed;      /* */\r
83   STAT_COUNTER group_query_rxed; /* */\r
84 };\r
85 \r
86 struct stats_mem {\r
87   mem_size_t avail;\r
88   mem_size_t used;\r
89   mem_size_t max;\r
90   mem_size_t err;\r
91 };\r
92 \r
93 struct stats_syselem {\r
94   STAT_COUNTER used;\r
95   STAT_COUNTER max;\r
96   STAT_COUNTER err;\r
97 };\r
98 \r
99 struct stats_sys {\r
100   struct stats_syselem sem;\r
101   struct stats_syselem mbox;\r
102 };\r
103 \r
104 struct stats_ {\r
105 #if LINK_STATS\r
106   struct stats_proto link;\r
107 #endif\r
108 #if ETHARP_STATS\r
109   struct stats_proto etharp;\r
110 #endif\r
111 #if IPFRAG_STATS\r
112   struct stats_proto ip_frag;\r
113 #endif\r
114 #if IP_STATS\r
115   struct stats_proto ip;\r
116 #endif\r
117 #if ICMP_STATS\r
118   struct stats_proto icmp;\r
119 #endif\r
120 #if IGMP_STATS\r
121   struct stats_igmp igmp;\r
122 #endif\r
123 #if UDP_STATS\r
124   struct stats_proto udp;\r
125 #endif\r
126 #if TCP_STATS\r
127   struct stats_proto tcp;\r
128 #endif\r
129 #if MEM_STATS\r
130   struct stats_mem mem;\r
131 #endif\r
132 #if MEMP_STATS\r
133   struct stats_mem memp[MEMP_MAX];\r
134 #endif\r
135 #if SYS_STATS\r
136   struct stats_sys sys;\r
137 #endif\r
138 };\r
139 \r
140 extern struct stats_ lwip_stats;\r
141 \r
142 #define stats_init() /* Compatibility define, not init needed. */\r
143 \r
144 #define STATS_INC(x) ++lwip_stats.x\r
145 #else\r
146 #define stats_init()\r
147 #define STATS_INC(x)\r
148 #endif /* LWIP_STATS */\r
149 \r
150 #if TCP_STATS\r
151 #define TCP_STATS_INC(x) STATS_INC(x)\r
152 #else\r
153 #define TCP_STATS_INC(x)\r
154 #endif\r
155 \r
156 #if UDP_STATS\r
157 #define UDP_STATS_INC(x) STATS_INC(x)\r
158 #else\r
159 #define UDP_STATS_INC(x)\r
160 #endif\r
161 \r
162 #if ICMP_STATS\r
163 #define ICMP_STATS_INC(x) STATS_INC(x)\r
164 #else\r
165 #define ICMP_STATS_INC(x)\r
166 #endif\r
167 \r
168 #if IGMP_STATS\r
169 #define IGMP_STATS_INC(x) STATS_INC(x)\r
170 #else\r
171 #define IGMP_STATS_INC(x)\r
172 #endif\r
173 \r
174 #if IP_STATS\r
175 #define IP_STATS_INC(x) STATS_INC(x)\r
176 #else\r
177 #define IP_STATS_INC(x)\r
178 #endif\r
179 \r
180 #if IPFRAG_STATS\r
181 #define IPFRAG_STATS_INC(x) STATS_INC(x)\r
182 #else\r
183 #define IPFRAG_STATS_INC(x)\r
184 #endif\r
185 \r
186 #if ETHARP_STATS\r
187 #define ETHARP_STATS_INC(x) STATS_INC(x)\r
188 #else\r
189 #define ETHARP_STATS_INC(x)\r
190 #endif\r
191 \r
192 #if LINK_STATS\r
193 #define LINK_STATS_INC(x) STATS_INC(x)\r
194 #else\r
195 #define LINK_STATS_INC(x)\r
196 #endif\r
197 \r
198 /* Display of statistics */\r
199 #if LWIP_STATS_DISPLAY\r
200 void stats_display(void);\r
201 #else\r
202 #define stats_display()\r
203 #endif /* LWIP_STATS_DISPLAY */\r
204 \r
205 #ifdef __cplusplus\r
206 }\r
207 #endif\r
208 \r
209 #endif /* __LWIP_STATS_H__ */\r