ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:39:15 2014 +0000
Revision:
2:14b689a85306
Parent:
0:7766f6712673
bug fix

Who changed what in which revision?

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