modded version Dirk-Willem van Gulik's Bonjour/Zerconf library http://mbed.org/users/dirkx/code/Bonjour/

Dependents:   OSCtoCVConverter

Fork of Bonjour by Dirk-Willem van Gulik (NXP/mbed)

Committer:
casiotone401
Date:
Thu Oct 16 14:13:21 2014 +0000
Revision:
8:275256b5d807
Parent:
7:105191e07767
minor change

Who changed what in which revision?

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