HTTPClient using static IP

Dependencies:   mbed

Committer:
mr_q
Date:
Mon May 30 11:53:37 2011 +0000
Revision:
0:d8f2f7d5f31b
v0.01 Draft

Who changed what in which revision?

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