]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/lwIP_Demo_Rowley_ARM7/lwip-1.1.0/src/core/stats.c
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / lwIP_Demo_Rowley_ARM7 / lwip-1.1.0 / src / core / stats.c
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 \r
33 #include <string.h>\r
34 \r
35 #include "lwip/opt.h"\r
36 \r
37 #include "lwip/def.h"\r
38 \r
39 #include "lwip/stats.h"\r
40 #include "lwip/mem.h"\r
41 \r
42 \r
43 #if LWIP_STATS\r
44 struct stats_ lwip_stats;\r
45 \r
46 void\r
47 stats_init(void)\r
48 {\r
49   memset(&lwip_stats, 0, sizeof(struct stats_));\r
50 }\r
51 #if LWIP_STATS_DISPLAY\r
52 void\r
53 stats_display_proto(struct stats_proto *proto, char *name)\r
54 {\r
55   LWIP_PLATFORM_DIAG(("\n%s\n\t", name));\r
56   LWIP_PLATFORM_DIAG(("xmit: %d\n\t", proto->xmit)); \r
57   LWIP_PLATFORM_DIAG(("rexmit: %d\n\t", proto->rexmit)); \r
58   LWIP_PLATFORM_DIAG(("recv: %d\n\t", proto->recv)); \r
59   LWIP_PLATFORM_DIAG(("fw: %d\n\t", proto->fw)); \r
60   LWIP_PLATFORM_DIAG(("drop: %d\n\t", proto->drop)); \r
61   LWIP_PLATFORM_DIAG(("chkerr: %d\n\t", proto->chkerr)); \r
62   LWIP_PLATFORM_DIAG(("lenerr: %d\n\t", proto->lenerr)); \r
63   LWIP_PLATFORM_DIAG(("memerr: %d\n\t", proto->memerr)); \r
64   LWIP_PLATFORM_DIAG(("rterr: %d\n\t", proto->rterr)); \r
65   LWIP_PLATFORM_DIAG(("proterr: %d\n\t", proto->proterr)); \r
66   LWIP_PLATFORM_DIAG(("opterr: %d\n\t", proto->opterr)); \r
67   LWIP_PLATFORM_DIAG(("err: %d\n\t", proto->err)); \r
68   LWIP_PLATFORM_DIAG(("cachehit: %d\n", proto->cachehit)); \r
69 }\r
70 \r
71 void\r
72 stats_display_pbuf(struct stats_pbuf *pbuf)\r
73 {\r
74   LWIP_PLATFORM_DIAG(("\nPBUF\n\t"));\r
75   LWIP_PLATFORM_DIAG(("avail: %d\n\t", pbuf->avail)); \r
76   LWIP_PLATFORM_DIAG(("used: %d\n\t", pbuf->used)); \r
77   LWIP_PLATFORM_DIAG(("max: %d\n\t", pbuf->max)); \r
78   LWIP_PLATFORM_DIAG(("err: %d\n\t", pbuf->err)); \r
79   LWIP_PLATFORM_DIAG(("alloc_locked: %d\n\t", pbuf->alloc_locked)); \r
80   LWIP_PLATFORM_DIAG(("refresh_locked: %d\n", pbuf->refresh_locked)); \r
81 }\r
82 \r
83 void\r
84 stats_display_mem(struct stats_mem *mem, char *name)\r
85 {\r
86   LWIP_PLATFORM_DIAG(("\n MEM %s\n\t", name));\r
87   LWIP_PLATFORM_DIAG(("avail: %d\n\t", mem->avail)); \r
88   LWIP_PLATFORM_DIAG(("used: %d\n\t", mem->used)); \r
89   LWIP_PLATFORM_DIAG(("max: %d\n\t", mem->max)); \r
90   LWIP_PLATFORM_DIAG(("err: %d\n", mem->err));\r
91   \r
92 }\r
93 \r
94 void\r
95 stats_display(void)\r
96 {\r
97   int i;\r
98   char * memp_names[] = {"PBUF", "RAW_PCB", "UDP_PCB", "TCP_PCB", "TCP_PCB_LISTEN",\r
99                         "TCP_SEG", "NETBUF", "NETCONN", "API_MSG", "TCP_MSG", "TIMEOUT"};\r
100   stats_display_proto(&lwip_stats.link, "LINK");\r
101   stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG");\r
102   stats_display_proto(&lwip_stats.ip, "IP");\r
103   stats_display_proto(&lwip_stats.icmp, "ICMP");\r
104   stats_display_proto(&lwip_stats.udp, "UDP");\r
105   stats_display_proto(&lwip_stats.tcp, "TCP");\r
106   stats_display_pbuf(&lwip_stats.pbuf);\r
107   stats_display_mem(&lwip_stats.mem, "HEAP");\r
108   for (i = 0; i < MEMP_MAX; i++) {\r
109     stats_display_mem(&lwip_stats.memp[i], memp_names[i]);\r
110   }\r
111         \r
112 }\r
113 #endif /* LWIP_STATS_DISPLAY */\r
114 #endif /* LWIP_STATS */\r
115 \r