]> git.ipfire.org Git - thirdparty/squid.git/blob - src/icmp/net_db.h
Supply AccessLogEntry (ALE) for more fast ACL checks. (#182)
[thirdparty/squid.git] / src / icmp / net_db.h
1 /*
2 * Copyright (C) 1996-2018 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 ICMP_NET_DB_H
10 #define ICMP_NET_DB_H
11
12 #include "hash.h"
13 #include "ip/forward.h"
14 #include "mem/forward.h"
15
16 class CachePeer;
17 class HttpRequest;
18 class netdbEntry;
19 class PeerSelector;
20 class StoreEntry;
21 class URL;
22
23 class net_db_name:
24 public hash_link /* must be first */
25 {
26 MEMPROXY_CLASS(net_db_name);
27
28 public:
29 net_db_name(const char *name, netdbEntry *);
30 ~net_db_name() { xfree(key); }
31
32 net_db_name *next;
33 netdbEntry *net_db_entry;
34 };
35
36 // POD
37 class net_db_peer
38 {
39 public:
40 const char *peername;
41 double hops;
42 double rtt;
43 time_t expires;
44 };
45
46 class netdbEntry:
47 public hash_link /* must be first */
48 {
49 MEMPROXY_CLASS(netdbEntry);
50
51 public:
52 netdbEntry() { *network = 0; }
53
54 char network[MAX_IPSTRLEN];
55 int pings_sent = 0;
56 int pings_recv = 0;
57 double hops = 0;
58 double rtt = 1.0;
59 time_t next_ping_time = 0;
60 time_t last_use_time = 0;
61 int link_count = 0;
62 net_db_name *hosts = nullptr;
63 net_db_peer *peers = nullptr;
64 int n_peers_alloc = 0;
65 int n_peers = 0;
66 };
67
68 void netdbInit(void);
69
70 void netdbHandlePingReply(const Ip::Address &from, int hops, int rtt);
71 void netdbPingSite(const char *hostname);
72 void netdbDump(StoreEntry *);
73
74 void netdbFreeMemory(void);
75 int netdbHostHops(const char *host);
76 int netdbHostRtt(const char *host);
77 void netdbUpdatePeer(const URL &, CachePeer * e, int rtt, int hops);
78
79 void netdbDeleteAddrNetwork(Ip::Address &addr);
80 void netdbBinaryExchange(StoreEntry *);
81 void netdbExchangeStart(void *);
82
83 void netdbExchangeUpdatePeer(Ip::Address &, CachePeer *, double, double);
84 CachePeer *netdbClosestParent(PeerSelector *);
85 void netdbHostData(const char *host, int *samp, int *rtt, int *hops);
86
87 #endif /* ICMP_NET_DB_H */
88