/** * @file * Statistics API (to be used from TCPIP thread) *//* ... *//* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels <adam@sics.se> * *//* ... */#ifndefLWIP_HDR_STATS_H#defineLWIP_HDR_STATS_H#include"lwip/opt.h"#include"lwip/mem.h"#include"lwip/memp.h"#ifdef__cplusplusextern"C"{#endif#ifLWIP_STATS#ifndefLWIP_STATS_LARGE#defineLWIP_STATS_LARGE0#endif#ifLWIP_STATS_LARGE#defineSTAT_COUNTERu32_t#defineSTAT_COUNTER_FU32_F/* ... */#else#defineSTAT_COUNTERu16_t#defineSTAT_COUNTER_FU16_F/* ... */#endif/** Protocol related stats */structstats_proto{STAT_COUNTERxmit;/* Transmitted packets. */STAT_COUNTERrecv;/* Received packets. */STAT_COUNTERfw;/* Forwarded packets. */STAT_COUNTERdrop;/* Dropped packets. */STAT_COUNTERchkerr;/* Checksum error. */STAT_COUNTERlenerr;/* Invalid length error. */STAT_COUNTERmemerr;/* Out of memory error. */STAT_COUNTERrterr;/* Routing error. */STAT_COUNTERproterr;/* Protocol error. */STAT_COUNTERopterr;/* Error in options. */STAT_COUNTERerr;/* Misc error. */STAT_COUNTERcachehit;...};/** IGMP stats */structstats_igmp{STAT_COUNTERxmit;/* Transmitted packets. */STAT_COUNTERrecv;/* Received packets. */STAT_COUNTERdrop;/* Dropped packets. */STAT_COUNTERchkerr;/* Checksum error. */STAT_COUNTERlenerr;/* Invalid length error. */STAT_COUNTERmemerr;/* Out of memory error. */STAT_COUNTERproterr;/* Protocol error. */STAT_COUNTERrx_v1;/* Received v1 frames. */STAT_COUNTERrx_group;/* Received group-specific queries. */STAT_COUNTERrx_general;/* Received general queries. */STAT_COUNTERrx_report;/* Received reports. */STAT_COUNTERtx_join;/* Sent joins. */STAT_COUNTERtx_leave;/* Sent leaves. */STAT_COUNTERtx_report;/* Sent reports. */...};/** Memory stats */structstats_mem{#ifdefined(LWIP_DEBUG)||LWIP_STATS_DISPLAYconstchar*name;#endif/* defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY */STAT_COUNTERerr;mem_size_tavail;mem_size_tused;mem_size_tmax;STAT_COUNTERillegal;...};/** System element stats */structstats_syselem{STAT_COUNTERused;STAT_COUNTERmax;STAT_COUNTERerr;...};/** System stats */structstats_sys{structstats_syselemsem;structstats_syselemmutex;structstats_syselemmbox;...};/** SNMP MIB2 stats */structstats_mib2{/* IP */u32_tipinhdrerrors;u32_tipinaddrerrors;u32_tipinunknownprotos;u32_tipindiscards;u32_tipindelivers;u32_tipoutrequests;u32_tipoutdiscards;u32_tipoutnoroutes;u32_tipreasmoks;u32_tipreasmfails;u32_tipfragoks;u32_tipfragfails;u32_tipfragcreates;u32_tipreasmreqds;u32_tipforwdatagrams;u32_tipinreceives;/* TCP */u32_ttcpactiveopens;u32_ttcppassiveopens;u32_ttcpattemptfails;u32_ttcpestabresets;u32_ttcpoutsegs;u32_ttcpretranssegs;u32_ttcpinsegs;u32_ttcpinerrs;u32_ttcpoutrsts;/* UDP */u32_tudpindatagrams;u32_tudpnoports;u32_tudpinerrors;u32_tudpoutdatagrams;/* ICMP */u32_ticmpinmsgs;u32_ticmpinerrors;u32_ticmpindestunreachs;u32_ticmpintimeexcds;u32_ticmpinparmprobs;u32_ticmpinsrcquenchs;u32_ticmpinredirects;u32_ticmpinechos;u32_ticmpinechoreps;u32_ticmpintimestamps;u32_ticmpintimestampreps;u32_ticmpinaddrmasks;u32_ticmpinaddrmaskreps;u32_ticmpoutmsgs;u32_ticmpouterrors;u32_ticmpoutdestunreachs;u32_ticmpouttimeexcds;u32_ticmpoutechos;/* can be incremented by user application ('ping') */u32_ticmpoutechoreps;...};/** * @ingroup netif_mib2 * SNMP MIB2 interface stats *//* ... */structstats_mib2_netif_ctrs{/** The total number of octets received on the interface, including framing characters */u32_tifinoctets;/** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were * not addressed to a multicast or broadcast address at this sub-layer *//* ... */u32_tifinucastpkts;/** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were * addressed to a multicast or broadcast address at this sub-layer *//* ... */u32_tifinnucastpkts;/** The number of inbound packets which were chosen to be discarded even though no errors had * been detected to prevent their being deliverable to a higher-layer protocol. One possible * reason for discarding such a packet could be to free up buffer space *//* ... */u32_tifindiscards;/** For packet-oriented interfaces, the number of inbound packets that contained errors * preventing them from being deliverable to a higher-layer protocol. For character- * oriented or fixed-length interfaces, the number of inbound transmission units that * contained errors preventing them from being deliverable to a higher-layer protocol. *//* ... */u32_tifinerrors;/** For packet-oriented interfaces, the number of packets received via the interface which * were discarded because of an unknown or unsupported protocol. For character-oriented * or fixed-length interfaces that support protocol multiplexing the number of transmission * units received via the interface which were discarded because of an unknown or unsupported * protocol. For any interface that does not support protocol multiplexing, this counter will * always be 0 *//* ... */u32_tifinunknownprotos;/** The total number of octets transmitted out of the interface, including framing characters. */u32_tifoutoctets;/** The total number of packets that higher-level protocols requested be transmitted, and * which were not addressed to a multicast or broadcast address at this sub-layer, including * those that were discarded or not sent. *//* ... */u32_tifoutucastpkts;/** The total number of packets that higher-level protocols requested be transmitted, and which * were addressed to a multicast or broadcast address at this sub-layer, including * those that were discarded or not sent. *//* ... */u32_tifoutnucastpkts;/** The number of outbound packets which were chosen to be discarded even though no errors had * been detected to prevent their being transmitted. One possible reason for discarding * such a packet could be to free up buffer space. *//* ... */u32_tifoutdiscards;/** For packet-oriented interfaces, the number of outbound packets that could not be transmitted * because of errors. For character-oriented or fixed-length interfaces, the number of outbound * transmission units that could not be transmitted because of errors. *//* ... */u32_tifouterrors;...};/** lwIP stats container */structstats_{#ifLINK_STATS/** Link level */structstats_protolink;/* ... */#endif#ifETHARP_STATS/** ARP */structstats_protoetharp;/* ... */#endif#ifIPFRAG_STATS/** Fragmentation */structstats_protoip_frag;/* ... */#endif#ifIP_STATS/** IP */structstats_protoip;/* ... */#endif#ifICMP_STATS/** ICMP */structstats_protoicmp;/* ... */#endif#ifIGMP_STATS/** IGMP */structstats_igmpigmp;/* ... */#endif#ifUDP_STATS/** UDP */structstats_protoudp;/* ... */#endif#ifTCP_STATS/** TCP */structstats_prototcp;/* ... */#endif#ifMEM_STATS/** Heap */structstats_memmem;/* ... */#endif#ifMEMP_STATS/** Internal memory pools */structstats_mem*memp[MEMP_MAX];/* ... */#endif#ifSYS_STATS/** System */structstats_syssys;/* ... */#endif#ifIP6_STATS/** IPv6 */structstats_protoip6;/* ... */#endif#ifICMP6_STATS/** ICMP6 */structstats_protoicmp6;/* ... */#endif#ifIP6_FRAG_STATS/** IPv6 fragmentation */structstats_protoip6_frag;/* ... */#endif#ifMLD6_STATS/** Multicast listener discovery */structstats_igmpmld6;/* ... */#endif#ifND6_STATS/** Neighbor discovery */structstats_protond6;/* ... */#endif#ifMIB2_STATS/** SNMP MIB2 */structstats_mib2mib2;/* ... */#endif...};/** Global variable containing lwIP internal statistics. Add this to your debugger's watchlist. */externstructstats_lwip_stats;/** Init statistics */voidstats_init(void);#defineSTATS_INC(x)++lwip_stats.x#defineSTATS_DEC(x)--lwip_stats.x#defineSTATS_INC_USED(x,y,type)do{lwip_stats.x.used=(type)(lwip_stats.x.used+y);\if(lwip_stats.x.max<lwip_stats.x.used){\lwip_stats.x.max=lwip_stats.x.used;\}if (lwip_stats.x.max < lwip_stats.x.used) { ... }\...}while(0)...#defineSTATS_GET(x)lwip_stats.x/* ... */#else/* LWIP_STATS */#definestats_init()#defineSTATS_INC(x)#defineSTATS_DEC(x)#defineSTATS_INC_USED(x,y,type)/* ... */#endif/* LWIP_STATS */#ifTCP_STATS#defineTCP_STATS_INC(x)STATS_INC(x)#defineTCP_STATS_DISPLAY()stats_display_proto(&lwip_stats.tcp,"TCP")/* ... */#else#defineTCP_STATS_INC(x)#defineTCP_STATS_DISPLAY()/* ... */#endif#ifUDP_STATS#defineUDP_STATS_INC(x)STATS_INC(x)#defineUDP_STATS_DISPLAY()stats_display_proto(&lwip_stats.udp,"UDP")/* ... */#else#defineUDP_STATS_INC(x)#defineUDP_STATS_DISPLAY()/* ... */#endif#ifICMP_STATS#defineICMP_STATS_INC(x)STATS_INC(x)#defineICMP_STATS_DISPLAY()stats_display_proto(&lwip_stats.icmp,"ICMP")/* ... */#else#defineICMP_STATS_INC(x)#defineICMP_STATS_DISPLAY()/* ... */#endif#ifIGMP_STATS#defineIGMP_STATS_INC(x)STATS_INC(x)#defineIGMP_STATS_DISPLAY()stats_display_igmp(&lwip_stats.igmp,"IGMP")/* ... */#else#defineIGMP_STATS_INC(x)#defineIGMP_STATS_DISPLAY()/* ... */#endif#ifIP_STATS#defineIP_STATS_INC(x)STATS_INC(x)#defineIP_STATS_DISPLAY()stats_display_proto(&lwip_stats.ip,"IP")/* ... */#else#defineIP_STATS_INC(x)#defineIP_STATS_DISPLAY()/* ... */#endif#ifIPFRAG_STATS#defineIPFRAG_STATS_INC(x)STATS_INC(x)#defineIPFRAG_STATS_DISPLAY()stats_display_proto(&lwip_stats.ip_frag,"IP_FRAG")/* ... */#else#defineIPFRAG_STATS_INC(x)#defineIPFRAG_STATS_DISPLAY()/* ... */#endif#ifETHARP_STATS#defineETHARP_STATS_INC(x)STATS_INC(x)#defineETHARP_STATS_DISPLAY()stats_display_proto(&lwip_stats.etharp,"ETHARP")/* ... */#else#defineETHARP_STATS_INC(x)#defineETHARP_STATS_DISPLAY()/* ... */#endif#ifLINK_STATS#defineLINK_STATS_INC(x)STATS_INC(x)#defineLINK_STATS_DISPLAY()stats_display_proto(&lwip_stats.link,"LINK")/* ... */#else#defineLINK_STATS_INC(x)#defineLINK_STATS_DISPLAY()/* ... */#endif#ifMEM_STATS#defineMEM_STATS_AVAIL(x,y)lwip_stats.mem.x=y#defineMEM_STATS_INC(x)STATS_INC(mem.x)#defineMEM_STATS_INC_USED(x,y)STATS_INC_USED(mem,y,mem_size_t)#defineMEM_STATS_DEC_USED(x,y)lwip_stats.mem.x=(mem_size_t)((lwip_stats.mem.x)-(y))#defineMEM_STATS_DISPLAY()stats_display_mem(&lwip_stats.mem,"HEAP")/* ... */#else#defineMEM_STATS_AVAIL(x,y)#defineMEM_STATS_INC(x)#defineMEM_STATS_INC_USED(x,y)#defineMEM_STATS_DEC_USED(x,y)#defineMEM_STATS_DISPLAY()/* ... */#endif#ifMEMP_STATS#defineMEMP_STATS_DEC(x,i)STATS_DEC(memp[i]->x)#defineMEMP_STATS_DISPLAY(i)stats_display_memp(lwip_stats.memp[i],i)#defineMEMP_STATS_GET(x,i)STATS_GET(memp[i]->x)/* ... */#else#defineMEMP_STATS_DEC(x,i)#defineMEMP_STATS_DISPLAY(i)#defineMEMP_STATS_GET(x,i)0/* ... */#endif#ifSYS_STATS#defineSYS_STATS_INC(x)STATS_INC(sys.x)#defineSYS_STATS_DEC(x)STATS_DEC(sys.x)#defineSYS_STATS_INC_USED(x)STATS_INC_USED(sys.x,1,STAT_COUNTER)#defineSYS_STATS_DISPLAY()stats_display_sys(&lwip_stats.sys)/* ... */#else#defineSYS_STATS_INC(x)#defineSYS_STATS_DEC(x)#defineSYS_STATS_INC_USED(x)#defineSYS_STATS_DISPLAY()/* ... */#endif#ifIP6_STATS#defineIP6_STATS_INC(x)STATS_INC(x)#defineIP6_STATS_DISPLAY()stats_display_proto(&lwip_stats.ip6,"IPv6")/* ... */#else#defineIP6_STATS_INC(x)#defineIP6_STATS_DISPLAY()/* ... */#endif#ifICMP6_STATS#defineICMP6_STATS_INC(x)STATS_INC(x)#defineICMP6_STATS_DISPLAY()stats_display_proto(&lwip_stats.icmp6,"ICMPv6")/* ... */#else#defineICMP6_STATS_INC(x)#defineICMP6_STATS_DISPLAY()/* ... */#endif#ifIP6_FRAG_STATS#defineIP6_FRAG_STATS_INC(x)STATS_INC(x)#defineIP6_FRAG_STATS_DISPLAY()stats_display_proto(&lwip_stats.ip6_frag,"IPv6 FRAG")/* ... */#else#defineIP6_FRAG_STATS_INC(x)#defineIP6_FRAG_STATS_DISPLAY()/* ... */#endif#ifMLD6_STATS#defineMLD6_STATS_INC(x)STATS_INC(x)#defineMLD6_STATS_DISPLAY()stats_display_igmp(&lwip_stats.mld6,"MLDv1")/* ... */#else#defineMLD6_STATS_INC(x)#defineMLD6_STATS_DISPLAY()/* ... */#endif#ifND6_STATS#defineND6_STATS_INC(x)STATS_INC(x)#defineND6_STATS_DISPLAY()stats_display_proto(&lwip_stats.nd6,"ND")/* ... */#else#defineND6_STATS_INC(x)#defineND6_STATS_DISPLAY()/* ... */#endif#ifMIB2_STATS#defineMIB2_STATS_INC(x)STATS_INC(x)#else#defineMIB2_STATS_INC(x)#endif/* Display of statistics */#ifLWIP_STATS_DISPLAYvoidstats_display(void);voidstats_display_proto(structstats_proto*proto,constchar*name);voidstats_display_igmp(structstats_igmp*igmp,constchar*name);voidstats_display_mem(structstats_mem*mem,constchar*name);voidstats_display_memp(structstats_mem*mem,intindex);voidstats_display_sys(structstats_sys*sys);/* ... */#else/* LWIP_STATS_DISPLAY */#definestats_display()#definestats_display_proto(proto,name)#definestats_display_igmp(igmp,name)#definestats_display_mem(mem,name)#definestats_display_memp(mem,index)#definestats_display_sys(sys)/* ... */#endif/* LWIP_STATS_DISPLAY */#ifdef__cplusplus}extern "C" { ... }#endif/* ... */#endif/* LWIP_HDR_STATS_H */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.