Port of LwIP performed by Ralf in 2010. Not recommended for use with recent mbed libraries, but good demos of raw LwIP possible
Dependents: LwIP_raw_API_serverExample tiny-dtls
Core/lwIP/core/stats.c@0:0791c1fece8e, 2012-09-18 (annotated)
- Committer:
- RodColeman
- Date:
- Tue Sep 18 14:41:24 2012 +0000
- Revision:
- 0:0791c1fece8e
[mbed] converted /Eth_TCP_Wei_Server/lwip
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RodColeman | 0:0791c1fece8e | 1 | /** |
RodColeman | 0:0791c1fece8e | 2 | * @file |
RodColeman | 0:0791c1fece8e | 3 | * Statistics module |
RodColeman | 0:0791c1fece8e | 4 | * |
RodColeman | 0:0791c1fece8e | 5 | */ |
RodColeman | 0:0791c1fece8e | 6 | |
RodColeman | 0:0791c1fece8e | 7 | /* |
RodColeman | 0:0791c1fece8e | 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
RodColeman | 0:0791c1fece8e | 9 | * All rights reserved. |
RodColeman | 0:0791c1fece8e | 10 | * |
RodColeman | 0:0791c1fece8e | 11 | * Redistribution and use in source and binary forms, with or without modification, |
RodColeman | 0:0791c1fece8e | 12 | * are permitted provided that the following conditions are met: |
RodColeman | 0:0791c1fece8e | 13 | * |
RodColeman | 0:0791c1fece8e | 14 | * 1. Redistributions of source code must retain the above copyright notice, |
RodColeman | 0:0791c1fece8e | 15 | * this list of conditions and the following disclaimer. |
RodColeman | 0:0791c1fece8e | 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
RodColeman | 0:0791c1fece8e | 17 | * this list of conditions and the following disclaimer in the documentation |
RodColeman | 0:0791c1fece8e | 18 | * and/or other materials provided with the distribution. |
RodColeman | 0:0791c1fece8e | 19 | * 3. The name of the author may not be used to endorse or promote products |
RodColeman | 0:0791c1fece8e | 20 | * derived from this software without specific prior written permission. |
RodColeman | 0:0791c1fece8e | 21 | * |
RodColeman | 0:0791c1fece8e | 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
RodColeman | 0:0791c1fece8e | 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
RodColeman | 0:0791c1fece8e | 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
RodColeman | 0:0791c1fece8e | 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
RodColeman | 0:0791c1fece8e | 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
RodColeman | 0:0791c1fece8e | 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
RodColeman | 0:0791c1fece8e | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
RodColeman | 0:0791c1fece8e | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
RodColeman | 0:0791c1fece8e | 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
RodColeman | 0:0791c1fece8e | 31 | * OF SUCH DAMAGE. |
RodColeman | 0:0791c1fece8e | 32 | * |
RodColeman | 0:0791c1fece8e | 33 | * This file is part of the lwIP TCP/IP stack. |
RodColeman | 0:0791c1fece8e | 34 | * |
RodColeman | 0:0791c1fece8e | 35 | * Author: Adam Dunkels <adam@sics.se> |
RodColeman | 0:0791c1fece8e | 36 | * |
RodColeman | 0:0791c1fece8e | 37 | */ |
RodColeman | 0:0791c1fece8e | 38 | |
RodColeman | 0:0791c1fece8e | 39 | #include "lwip/opt.h" |
RodColeman | 0:0791c1fece8e | 40 | |
RodColeman | 0:0791c1fece8e | 41 | #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */ |
RodColeman | 0:0791c1fece8e | 42 | |
RodColeman | 0:0791c1fece8e | 43 | #include "lwip/def.h" |
RodColeman | 0:0791c1fece8e | 44 | #include "lwip/stats.h" |
RodColeman | 0:0791c1fece8e | 45 | #include "lwip/mem.h" |
RodColeman | 0:0791c1fece8e | 46 | |
RodColeman | 0:0791c1fece8e | 47 | #include <string.h> |
RodColeman | 0:0791c1fece8e | 48 | |
RodColeman | 0:0791c1fece8e | 49 | struct stats_ lwip_stats; |
RodColeman | 0:0791c1fece8e | 50 | |
RodColeman | 0:0791c1fece8e | 51 | #if LWIP_STATS_DISPLAY |
RodColeman | 0:0791c1fece8e | 52 | void |
RodColeman | 0:0791c1fece8e | 53 | stats_display_proto(struct stats_proto *proto, char *name) |
RodColeman | 0:0791c1fece8e | 54 | { |
RodColeman | 0:0791c1fece8e | 55 | LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); |
RodColeman | 0:0791c1fece8e | 56 | LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); |
RodColeman | 0:0791c1fece8e | 57 | LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); |
RodColeman | 0:0791c1fece8e | 58 | LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); |
RodColeman | 0:0791c1fece8e | 59 | LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); |
RodColeman | 0:0791c1fece8e | 60 | LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); |
RodColeman | 0:0791c1fece8e | 61 | LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); |
RodColeman | 0:0791c1fece8e | 62 | LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); |
RodColeman | 0:0791c1fece8e | 63 | LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); |
RodColeman | 0:0791c1fece8e | 64 | LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); |
RodColeman | 0:0791c1fece8e | 65 | LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); |
RodColeman | 0:0791c1fece8e | 66 | LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); |
RodColeman | 0:0791c1fece8e | 67 | LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); |
RodColeman | 0:0791c1fece8e | 68 | } |
RodColeman | 0:0791c1fece8e | 69 | |
RodColeman | 0:0791c1fece8e | 70 | #if IGMP_STATS |
RodColeman | 0:0791c1fece8e | 71 | void |
RodColeman | 0:0791c1fece8e | 72 | stats_display_igmp(struct stats_igmp *igmp) |
RodColeman | 0:0791c1fece8e | 73 | { |
RodColeman | 0:0791c1fece8e | 74 | LWIP_PLATFORM_DIAG(("\nIGMP\n\t")); |
RodColeman | 0:0791c1fece8e | 75 | LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); |
RodColeman | 0:0791c1fece8e | 76 | LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); |
RodColeman | 0:0791c1fece8e | 77 | LWIP_PLATFORM_DIAG(("v1_rxed: %"STAT_COUNTER_F"\n\t", igmp->v1_rxed)); |
RodColeman | 0:0791c1fece8e | 78 | LWIP_PLATFORM_DIAG(("join_sent: %"STAT_COUNTER_F"\n\t", igmp->join_sent)); |
RodColeman | 0:0791c1fece8e | 79 | LWIP_PLATFORM_DIAG(("leave_sent: %"STAT_COUNTER_F"\n\t", igmp->leave_sent)); |
RodColeman | 0:0791c1fece8e | 80 | LWIP_PLATFORM_DIAG(("unicast_query: %"STAT_COUNTER_F"\n\t", igmp->unicast_query)); |
RodColeman | 0:0791c1fece8e | 81 | LWIP_PLATFORM_DIAG(("report_sent: %"STAT_COUNTER_F"\n\t", igmp->report_sent)); |
RodColeman | 0:0791c1fece8e | 82 | LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed)); |
RodColeman | 0:0791c1fece8e | 83 | LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed)); |
RodColeman | 0:0791c1fece8e | 84 | } |
RodColeman | 0:0791c1fece8e | 85 | #endif /* IGMP_STATS */ |
RodColeman | 0:0791c1fece8e | 86 | |
RodColeman | 0:0791c1fece8e | 87 | #if MEM_STATS || MEMP_STATS |
RodColeman | 0:0791c1fece8e | 88 | void |
RodColeman | 0:0791c1fece8e | 89 | stats_display_mem(struct stats_mem *mem, char *name) |
RodColeman | 0:0791c1fece8e | 90 | { |
RodColeman | 0:0791c1fece8e | 91 | LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); |
RodColeman | 0:0791c1fece8e | 92 | LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); |
RodColeman | 0:0791c1fece8e | 93 | LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); |
RodColeman | 0:0791c1fece8e | 94 | LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); |
RodColeman | 0:0791c1fece8e | 95 | LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); |
RodColeman | 0:0791c1fece8e | 96 | } |
RodColeman | 0:0791c1fece8e | 97 | |
RodColeman | 0:0791c1fece8e | 98 | #if MEMP_STATS |
RodColeman | 0:0791c1fece8e | 99 | void |
RodColeman | 0:0791c1fece8e | 100 | stats_display_memp(struct stats_mem *mem, int index) |
RodColeman | 0:0791c1fece8e | 101 | { |
RodColeman | 0:0791c1fece8e | 102 | char * memp_names[] = { |
RodColeman | 0:0791c1fece8e | 103 | #define LWIP_MEMPOOL(name,num,size,desc) desc, |
RodColeman | 0:0791c1fece8e | 104 | #include "lwip/memp_std.h" |
RodColeman | 0:0791c1fece8e | 105 | }; |
RodColeman | 0:0791c1fece8e | 106 | if(index < MEMP_MAX) { |
RodColeman | 0:0791c1fece8e | 107 | stats_display_mem(mem, memp_names[index]); |
RodColeman | 0:0791c1fece8e | 108 | } |
RodColeman | 0:0791c1fece8e | 109 | } |
RodColeman | 0:0791c1fece8e | 110 | #endif /* MEMP_STATS */ |
RodColeman | 0:0791c1fece8e | 111 | #endif /* MEM_STATS || MEMP_STATS */ |
RodColeman | 0:0791c1fece8e | 112 | |
RodColeman | 0:0791c1fece8e | 113 | #if SYS_STATS |
RodColeman | 0:0791c1fece8e | 114 | void |
RodColeman | 0:0791c1fece8e | 115 | stats_display_sys(struct stats_sys *sys) |
RodColeman | 0:0791c1fece8e | 116 | { |
RodColeman | 0:0791c1fece8e | 117 | LWIP_PLATFORM_DIAG(("\nSYS\n\t")); |
RodColeman | 0:0791c1fece8e | 118 | LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); |
RodColeman | 0:0791c1fece8e | 119 | LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); |
RodColeman | 0:0791c1fece8e | 120 | LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); |
RodColeman | 0:0791c1fece8e | 121 | LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); |
RodColeman | 0:0791c1fece8e | 122 | LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); |
RodColeman | 0:0791c1fece8e | 123 | LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); |
RodColeman | 0:0791c1fece8e | 124 | } |
RodColeman | 0:0791c1fece8e | 125 | #endif /* SYS_STATS */ |
RodColeman | 0:0791c1fece8e | 126 | |
RodColeman | 0:0791c1fece8e | 127 | void |
RodColeman | 0:0791c1fece8e | 128 | stats_display(void) |
RodColeman | 0:0791c1fece8e | 129 | { |
RodColeman | 0:0791c1fece8e | 130 | s16_t i; |
RodColeman | 0:0791c1fece8e | 131 | |
RodColeman | 0:0791c1fece8e | 132 | LINK_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 133 | ETHARP_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 134 | IPFRAG_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 135 | IP_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 136 | IGMP_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 137 | ICMP_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 138 | UDP_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 139 | TCP_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 140 | MEM_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 141 | for (i = 0; i < MEMP_MAX; i++) { |
RodColeman | 0:0791c1fece8e | 142 | MEMP_STATS_DISPLAY(i); |
RodColeman | 0:0791c1fece8e | 143 | } |
RodColeman | 0:0791c1fece8e | 144 | SYS_STATS_DISPLAY(); |
RodColeman | 0:0791c1fece8e | 145 | } |
RodColeman | 0:0791c1fece8e | 146 | #endif /* LWIP_STATS_DISPLAY */ |
RodColeman | 0:0791c1fece8e | 147 | |
RodColeman | 0:0791c1fece8e | 148 | #endif /* LWIP_STATS */ |
RodColeman | 0:0791c1fece8e | 149 |