SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
v1.1 release includes ioAlarm traps

Who changed what in which revision?

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