]> git.ipfire.org Git - thirdparty/squid.git/blob - tools/squidclient/Ping.h
SourceFormat Enforcement
[thirdparty/squid.git] / tools / squidclient / Ping.h
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef _SQUID_TOOLS_CLIENT_PING_H
10 #define _SQUID_TOOLS_CLIENT_PING_H
11
12 /**
13 * API for looping the squidclient request message
14 * repeatedly.
15 */
16 namespace Ping
17 {
18
19 /// parameters controlling 'ping' mode message looping.
20 class TheConfig
21 {
22 public:
23 TheConfig() : enable(false), count(0), interval(1*1000) {}
24
25 /// display Ping Options command line help to stderr
26 void usage();
27
28 /**
29 * parse --ping command line options
30 * \return true if there are other options still to parse
31 */
32 bool parseCommandOpts(int argc, char *argv[], int c, int &optIndex);
33
34 bool enable;
35 int count;
36 int interval;
37 };
38
39 extern TheConfig Config;
40
41 /// initialize the squidclient ping mode
42 uint32_t Init();
43
44 /// whether ping loop is completed at the given iteration.
45 inline bool LoopDone(int i)
46 {
47 return !Ping::Config.enable || (Ping::Config.count && i >= Ping::Config.count);
48 }
49
50 /// start timing a new transaction
51 void TimerStart();
52
53 /// calculate and display the statictics for a complete transaction
54 /// \param fsize number of bytes transferred during this transaction (for KB/s measure)
55 void TimerStop(size_t fsize);
56
57 /// display summary of ping data collected
58 void DisplayStats();
59
60 } // namespace Ping
61
62 #endif /* _SQUID_TOOLS_CLIENT_PING_H */
63