ReactOS 0.4.16-dev-336-gb667d82
stats.h
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 *
32 * This file is part of the lwIP TCP/IP stack.
33 *
34 * Author: Adam Dunkels <adam@sics.se>
35 *
36 */
37#ifndef LWIP_HDR_STATS_H
38#define LWIP_HDR_STATS_H
39
40#include "lwip/opt.h"
41
42#include "lwip/mem.h"
43#include "lwip/memp.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#if LWIP_STATS
50
51#ifndef LWIP_STATS_LARGE
52#define LWIP_STATS_LARGE 0
53#endif
54
55#if LWIP_STATS_LARGE
56#define STAT_COUNTER u32_t
57#define STAT_COUNTER_F U32_F
58#else
59#define STAT_COUNTER u16_t
60#define STAT_COUNTER_F U16_F
61#endif
62
64struct stats_proto {
65 STAT_COUNTER xmit; /* Transmitted packets. */
66 STAT_COUNTER recv; /* Received packets. */
67 STAT_COUNTER fw; /* Forwarded packets. */
68 STAT_COUNTER drop; /* Dropped packets. */
69 STAT_COUNTER chkerr; /* Checksum error. */
70 STAT_COUNTER lenerr; /* Invalid length error. */
71 STAT_COUNTER memerr; /* Out of memory error. */
72 STAT_COUNTER rterr; /* Routing error. */
73 STAT_COUNTER proterr; /* Protocol error. */
74 STAT_COUNTER opterr; /* Error in options. */
75 STAT_COUNTER err; /* Misc error. */
76 STAT_COUNTER cachehit;
77};
78
80struct stats_igmp {
81 STAT_COUNTER xmit; /* Transmitted packets. */
82 STAT_COUNTER recv; /* Received packets. */
83 STAT_COUNTER drop; /* Dropped packets. */
84 STAT_COUNTER chkerr; /* Checksum error. */
85 STAT_COUNTER lenerr; /* Invalid length error. */
86 STAT_COUNTER memerr; /* Out of memory error. */
87 STAT_COUNTER proterr; /* Protocol error. */
88 STAT_COUNTER rx_v1; /* Received v1 frames. */
89 STAT_COUNTER rx_group; /* Received group-specific queries. */
90 STAT_COUNTER rx_general; /* Received general queries. */
91 STAT_COUNTER rx_report; /* Received reports. */
92 STAT_COUNTER tx_join; /* Sent joins. */
93 STAT_COUNTER tx_leave; /* Sent leaves. */
94 STAT_COUNTER tx_report; /* Sent reports. */
95};
96
98struct stats_mem {
99#if defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY
100 const char *name;
101#endif /* defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY */
102 STAT_COUNTER err;
106 STAT_COUNTER illegal;
107};
108
110struct stats_syselem {
111 STAT_COUNTER used;
112 STAT_COUNTER max;
113 STAT_COUNTER err;
114};
115
117struct stats_sys {
118 struct stats_syselem sem;
119 struct stats_syselem mutex;
120 struct stats_syselem mbox;
121};
122
124struct stats_mib2 {
125 /* IP */
126 u32_t ipinhdrerrors;
127 u32_t ipinaddrerrors;
128 u32_t ipinunknownprotos;
129 u32_t ipindiscards;
130 u32_t ipindelivers;
131 u32_t ipoutrequests;
132 u32_t ipoutdiscards;
133 u32_t ipoutnoroutes;
134 u32_t ipreasmoks;
135 u32_t ipreasmfails;
136 u32_t ipfragoks;
137 u32_t ipfragfails;
138 u32_t ipfragcreates;
139 u32_t ipreasmreqds;
140 u32_t ipforwdatagrams;
141 u32_t ipinreceives;
142
143 /* TCP */
144 u32_t tcpactiveopens;
145 u32_t tcppassiveopens;
146 u32_t tcpattemptfails;
147 u32_t tcpestabresets;
148 u32_t tcpoutsegs;
149 u32_t tcpretranssegs;
150 u32_t tcpinsegs;
151 u32_t tcpinerrs;
152 u32_t tcpoutrsts;
153
154 /* UDP */
155 u32_t udpindatagrams;
156 u32_t udpnoports;
157 u32_t udpinerrors;
158 u32_t udpoutdatagrams;
159
160 /* ICMP */
161 u32_t icmpinmsgs;
162 u32_t icmpinerrors;
163 u32_t icmpindestunreachs;
164 u32_t icmpintimeexcds;
165 u32_t icmpinparmprobs;
166 u32_t icmpinsrcquenchs;
167 u32_t icmpinredirects;
168 u32_t icmpinechos;
169 u32_t icmpinechoreps;
170 u32_t icmpintimestamps;
171 u32_t icmpintimestampreps;
172 u32_t icmpinaddrmasks;
173 u32_t icmpinaddrmaskreps;
174 u32_t icmpoutmsgs;
175 u32_t icmpouterrors;
176 u32_t icmpoutdestunreachs;
177 u32_t icmpouttimeexcds;
178 u32_t icmpoutechos; /* can be incremented by user application ('ping') */
179 u32_t icmpoutechoreps;
180};
181
186struct stats_mib2_netif_ctrs {
188 u32_t ifinoctets;
191 u32_t ifinucastpkts;
194 u32_t ifinnucastpkts;
198 u32_t ifindiscards;
203 u32_t ifinerrors;
210 u32_t ifinunknownprotos;
212 u32_t ifoutoctets;
216 u32_t ifoutucastpkts;
220 u32_t ifoutnucastpkts;
224 u32_t ifoutdiscards;
228 u32_t ifouterrors;
229};
230
232struct stats_ {
233#if LINK_STATS
235 struct stats_proto link;
236#endif
237#if ETHARP_STATS
239 struct stats_proto etharp;
240#endif
241#if IPFRAG_STATS
243 struct stats_proto ip_frag;
244#endif
245#if IP_STATS
247 struct stats_proto ip;
248#endif
249#if ICMP_STATS
251 struct stats_proto icmp;
252#endif
253#if IGMP_STATS
255 struct stats_igmp igmp;
256#endif
257#if UDP_STATS
259 struct stats_proto udp;
260#endif
261#if TCP_STATS
263 struct stats_proto tcp;
264#endif
265#if MEM_STATS
267 struct stats_mem mem;
268#endif
269#if MEMP_STATS
271 struct stats_mem *memp[MEMP_MAX];
272#endif
273#if SYS_STATS
275 struct stats_sys sys;
276#endif
277#if IP6_STATS
279 struct stats_proto ip6;
280#endif
281#if ICMP6_STATS
283 struct stats_proto icmp6;
284#endif
285#if IP6_FRAG_STATS
287 struct stats_proto ip6_frag;
288#endif
289#if MLD6_STATS
291 struct stats_igmp mld6;
292#endif
293#if ND6_STATS
295 struct stats_proto nd6;
296#endif
297#if MIB2_STATS
299 struct stats_mib2 mib2;
300#endif
301};
302
304extern struct stats_ lwip_stats;
305
307void stats_init(void);
308
309#define STATS_INC(x) ++lwip_stats.x
310#define STATS_DEC(x) --lwip_stats.x
311#define STATS_INC_USED(x, y, type) do { lwip_stats.x.used = (type)(lwip_stats.x.used + y); \
312 if (lwip_stats.x.max < lwip_stats.x.used) { \
313 lwip_stats.x.max = lwip_stats.x.used; \
314 } \
315 } while(0)
316#define STATS_GET(x) lwip_stats.x
317#else /* LWIP_STATS */
318#define stats_init()
319#define STATS_INC(x)
320#define STATS_DEC(x)
321#define STATS_INC_USED(x, y, type)
322#endif /* LWIP_STATS */
323
324#if TCP_STATS
325#define TCP_STATS_INC(x) STATS_INC(x)
326#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
327#else
328#define TCP_STATS_INC(x)
329#define TCP_STATS_DISPLAY()
330#endif
331
332#if UDP_STATS
333#define UDP_STATS_INC(x) STATS_INC(x)
334#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
335#else
336#define UDP_STATS_INC(x)
337#define UDP_STATS_DISPLAY()
338#endif
339
340#if ICMP_STATS
341#define ICMP_STATS_INC(x) STATS_INC(x)
342#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
343#else
344#define ICMP_STATS_INC(x)
345#define ICMP_STATS_DISPLAY()
346#endif
347
348#if IGMP_STATS
349#define IGMP_STATS_INC(x) STATS_INC(x)
350#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp, "IGMP")
351#else
352#define IGMP_STATS_INC(x)
353#define IGMP_STATS_DISPLAY()
354#endif
355
356#if IP_STATS
357#define IP_STATS_INC(x) STATS_INC(x)
358#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
359#else
360#define IP_STATS_INC(x)
361#define IP_STATS_DISPLAY()
362#endif
363
364#if IPFRAG_STATS
365#define IPFRAG_STATS_INC(x) STATS_INC(x)
366#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
367#else
368#define IPFRAG_STATS_INC(x)
369#define IPFRAG_STATS_DISPLAY()
370#endif
371
372#if ETHARP_STATS
373#define ETHARP_STATS_INC(x) STATS_INC(x)
374#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
375#else
376#define ETHARP_STATS_INC(x)
377#define ETHARP_STATS_DISPLAY()
378#endif
379
380#if LINK_STATS
381#define LINK_STATS_INC(x) STATS_INC(x)
382#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
383#else
384#define LINK_STATS_INC(x)
385#define LINK_STATS_DISPLAY()
386#endif
387
388#if MEM_STATS
389#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
390#define MEM_STATS_INC(x) STATS_INC(mem.x)
391#define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y, mem_size_t)
392#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x = (mem_size_t)((lwip_stats.mem.x) - (y))
393#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
394#else
395#define MEM_STATS_AVAIL(x, y)
396#define MEM_STATS_INC(x)
397#define MEM_STATS_INC_USED(x, y)
398#define MEM_STATS_DEC_USED(x, y)
399#define MEM_STATS_DISPLAY()
400#endif
401
402 #if MEMP_STATS
403#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i]->x)
404#define MEMP_STATS_DISPLAY(i) stats_display_memp(lwip_stats.memp[i], i)
405#define MEMP_STATS_GET(x, i) STATS_GET(memp[i]->x)
406 #else
407#define MEMP_STATS_DEC(x, i)
408#define MEMP_STATS_DISPLAY(i)
409#define MEMP_STATS_GET(x, i) 0
410#endif
411
412#if SYS_STATS
413#define SYS_STATS_INC(x) STATS_INC(sys.x)
414#define SYS_STATS_DEC(x) STATS_DEC(sys.x)
415#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1, STAT_COUNTER)
416#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
417#else
418#define SYS_STATS_INC(x)
419#define SYS_STATS_DEC(x)
420#define SYS_STATS_INC_USED(x)
421#define SYS_STATS_DISPLAY()
422#endif
423
424#if IP6_STATS
425#define IP6_STATS_INC(x) STATS_INC(x)
426#define IP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6, "IPv6")
427#else
428#define IP6_STATS_INC(x)
429#define IP6_STATS_DISPLAY()
430#endif
431
432#if ICMP6_STATS
433#define ICMP6_STATS_INC(x) STATS_INC(x)
434#define ICMP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp6, "ICMPv6")
435#else
436#define ICMP6_STATS_INC(x)
437#define ICMP6_STATS_DISPLAY()
438#endif
439
440#if IP6_FRAG_STATS
441#define IP6_FRAG_STATS_INC(x) STATS_INC(x)
442#define IP6_FRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6_frag, "IPv6 FRAG")
443#else
444#define IP6_FRAG_STATS_INC(x)
445#define IP6_FRAG_STATS_DISPLAY()
446#endif
447
448#if MLD6_STATS
449#define MLD6_STATS_INC(x) STATS_INC(x)
450#define MLD6_STATS_DISPLAY() stats_display_igmp(&lwip_stats.mld6, "MLDv1")
451#else
452#define MLD6_STATS_INC(x)
453#define MLD6_STATS_DISPLAY()
454#endif
455
456#if ND6_STATS
457#define ND6_STATS_INC(x) STATS_INC(x)
458#define ND6_STATS_DISPLAY() stats_display_proto(&lwip_stats.nd6, "ND")
459#else
460#define ND6_STATS_INC(x)
461#define ND6_STATS_DISPLAY()
462#endif
463
464#if MIB2_STATS
465#define MIB2_STATS_INC(x) STATS_INC(x)
466#else
467#define MIB2_STATS_INC(x)
468#endif
469
470/* Display of statistics */
471#if LWIP_STATS_DISPLAY
472void stats_display(void);
473void stats_display_proto(struct stats_proto *proto, const char *name);
474void stats_display_igmp(struct stats_igmp *igmp, const char *name);
475void stats_display_mem(struct stats_mem *mem, const char *name);
476void stats_display_memp(struct stats_mem *mem, int index);
477void stats_display_sys(struct stats_sys *sys);
478#else /* LWIP_STATS_DISPLAY */
479#define stats_display()
480#define stats_display_proto(proto, name)
481#define stats_display_igmp(igmp, name)
482#define stats_display_mem(mem, name)
483#define stats_display_memp(mem, index)
484#define stats_display_sys(sys)
485#endif /* LWIP_STATS_DISPLAY */
486
487#ifdef __cplusplus
488}
489#endif
490
491#endif /* LWIP_HDR_STATS_H */
static int used
Definition: adh-main.c:39
static int avail
Definition: adh-main.c:39
int opterr
Definition: getopt.c:46
const WCHAR * link
Definition: db.cpp:997
static UINT mib2[]
Definition: main.c:83
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
u16_t mem_size_t
Definition: mem.h:67
GLuint index
Definition: glext.h:6031
uint32_t u32_t
Definition: arch.h:129
@ MEMP_MAX
Definition: memp.h:55
static HANDLE sem
Definition: sync.c:674
#define ip6_frag
Definition: netiodef.h:210
#define err(...)
#define stats_display_proto(proto, name)
Definition: stats.h:480
#define stats_display_igmp(igmp, name)
Definition: stats.h:481
#define stats_display_memp(mem, index)
Definition: stats.h:483
#define stats_init()
Definition: stats.h:318
#define stats_display_mem(mem, name)
Definition: stats.h:482
#define stats_display_sys(sys)
Definition: stats.h:484
#define stats_display()
Definition: stats.h:479
Definition: ip_icmp.h:52
Definition: dhcpd.h:62
Definition: mem.c:349
Definition: memp_priv.h:69
Definition: module.h:456
Definition: name.c:39
#define max(a, b)
Definition: svc.c:63