Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Committer:
mkersh3
Date:
Thu Apr 04 05:26:09 2013 +0000
Revision:
0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.

Who changed what in which revision?

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