Index: stats.h
===================================================================
RCS file: /sources/lwip/lwip/src/include/lwip/stats.h,v
retrieving revision 1.19
diff -u -r1.19 stats.h
--- stats.h	28 Nov 2007 21:25:07 -0000	1.19
+++ stats.h	19 Jun 2008 17:43:09 -0000
@@ -57,7 +57,6 @@
 
 struct stats_proto {
   STAT_COUNTER xmit;             /* Transmitted packets. */
-  STAT_COUNTER rexmit;           /* Retransmitted packets. */
   STAT_COUNTER recv;             /* Received packets. */
   STAT_COUNTER fw;               /* Forwarded packets. */
   STAT_COUNTER drop;             /* Dropped packets. */
@@ -142,64 +141,137 @@
 #define stats_init() /* Compatibility define, not init needed. */
 
 #define STATS_INC(x) ++lwip_stats.x
+#define STATS_DEC(x) --lwip_stats.x
 #else
 #define stats_init()
 #define STATS_INC(x)
+#define STATS_DEC(x)
 #endif /* LWIP_STATS */
 
 #if TCP_STATS
-#define TCP_STATS_INC(x) STATS_INC(x)
+#define TCP_STATS_INC(x) STATS_INC(tcp.x)
+#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
 #else
 #define TCP_STATS_INC(x)
 #endif
 
 #if UDP_STATS
-#define UDP_STATS_INC(x) STATS_INC(x)
+#define UDP_STATS_INC(x) STATS_INC(udp.x)
+#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
 #else
 #define UDP_STATS_INC(x)
+#define UDP_STATS_DISPLAY()
 #endif
 
 #if ICMP_STATS
-#define ICMP_STATS_INC(x) STATS_INC(x)
+#define ICMP_STATS_INC(x) STATS_INC(icmp.x)
+#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
 #else
 #define ICMP_STATS_INC(x)
+#define ICMP_STATS_DISPLAY()
 #endif
 
 #if IGMP_STATS
-#define IGMP_STATS_INC(x) STATS_INC(x)
+#define IGMP_STATS_INC(x) STATS_INC(igmp.x)
+#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp)
 #else
 #define IGMP_STATS_INC(x)
+#define IGMP_STATS_DISPLAY()
 #endif
 
 #if IP_STATS
-#define IP_STATS_INC(x) STATS_INC(x)
+#define IP_STATS_INC(x) STATS_INC(ip.x)
+#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
 #else
 #define IP_STATS_INC(x)
+#define IP_STATS_DISPLAY()
 #endif
 
 #if IPFRAG_STATS
-#define IPFRAG_STATS_INC(x) STATS_INC(x)
+#define IPFRAG_STATS_INC(x) STATS_INC(ip_frag.x)
+#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
 #else
 #define IPFRAG_STATS_INC(x)
+#define IPFRAG_STATS_DISPLAY()
 #endif
 
 #if ETHARP_STATS
-#define ETHARP_STATS_INC(x) STATS_INC(x)
+#define ETHARP_STATS_INC(x) STATS_INC(etharp.x)
+#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
 #else
 #define ETHARP_STATS_INC(x)
+#define ETHARP_STATS_DISPLAY()
 #endif
 
 #if LINK_STATS
-#define LINK_STATS_INC(x) STATS_INC(x)
+#define LINK_STATS_INC(x) STATS_INC(link.x)
+#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
 #else
 #define LINK_STATS_INC(x)
+#define LINK_STATS_DISPLAY()
+#endif
+
+#if MEM_STATS
+#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
+#define MEM_STATS_INC(x) STATS_INC(mem.x)
+#define MEM_STATS_INC_USED(x, y) do { lwip_stats.mem.used += y; \
+                                    if (lwip_stats.mem.max < lwip_stats.mem.used) { \
+                                        lwip_stats.mem.max = lwip_stats.mem.used; \
+                                    } \
+                                 } while(0)
+#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
+#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
+#else
+#define MEM_STATS_AVAIL(x)
+#define MEM_STATS_INC(x)
+#define MEM_STATS_INC_USED(x)
+#define MEM_STATS_DEC_USED(x)
+#define MEM_STATS_DISPLAY()
+#endif
+
+#if MEMP_STATS
+#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
+#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
+#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
+#define MEMP_STATS_INC_USED(x, i) do { ++lwip_stats.memp[i].used; \
+                                    if (lwip_stats.memp[i].max < lwip_stats.memp[i].used) { \
+                                        lwip_stats.memp[i].max = lwip_stats.memp[i].used; \
+                                    } \
+                                 } while(0)
+#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
+#else
+#define MEMP_STATS_AVAIL(x)
+#define MEMP_STATS_INC(x)
+#define MEMP_STATS_DEC(x)
+#define MEMP_STATS_INC_USED(x)
+#define MEMP_STATS_DISPLAY()
+#endif
+
+#if SYS_STATS
+#define SYS_STATS_INC(x) STATS_INC(sys.x)
+#define SYS_STATS_DEC(x) STATS_DEC(sys.x)
+#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
+#else
+#define SYS_STATS_INC(x)
+#define SYS_STATS_DEC(x)
+#define SYS_STATS_DISPLAY()
 #endif
 
 /* Display of statistics */
 #if LWIP_STATS_DISPLAY
 void stats_display(void);
+void stats_display_proto(struct stats_proto *proto, char *name);
+void stats_display_igmp(struct stats_igmp *igmp);
+void stats_display_mem(struct stats_mem *mem, char *name);
+void stats_display_memp(struct stats_mem *mem, int index);
+void stats_display_sys(struct stats_sys *sys);
 #else
 #define stats_display()
+#define stats_display_proto(proto, name)
+#define stats_display_igmp(igmp)
+#define stats_display_mem(mem, name)
+#define stats_display_memp(mem, int index)
+#define stats_display_sys(sys)
 #endif /* LWIP_STATS_DISPLAY */
 
 #ifdef __cplusplus
