]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/icmp/net_db.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / icmp / net_db.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2020 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 "anyp/forward.h"
13#include "hash.h"
14#include "ip/forward.h"
15#include "mem/forward.h"
16
17class CachePeer;
18class HttpRequest;
19class netdbEntry;
20class PeerSelector;
21class StoreEntry;
22
23class net_db_name:
24 public hash_link /* must be first */
25{
26 MEMPROXY_CLASS(net_db_name);
27
28public:
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
37class net_db_peer
38{
39public:
40 const char *peername;
41 double hops;
42 double rtt;
43 time_t expires;
44};
45
46class netdbEntry:
47 public hash_link /* must be first */
48{
49 MEMPROXY_CLASS(netdbEntry);
50
51public:
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
68void netdbInit(void);
69
70void netdbHandlePingReply(const Ip::Address &from, int hops, int rtt);
71void netdbPingSite(const char *hostname);
72void netdbDump(StoreEntry *);
73
74void netdbFreeMemory(void);
75int netdbHostHops(const char *host);
76int netdbHostRtt(const char *host);
77void netdbUpdatePeer(const AnyP::Uri &, CachePeer *, int rtt, int hops);
78
79void netdbDeleteAddrNetwork(Ip::Address &addr);
80void netdbBinaryExchange(StoreEntry *);
81void netdbExchangeStart(void *);
82
83void netdbExchangeUpdatePeer(Ip::Address &, CachePeer *, double, double);
84CachePeer *netdbClosestParent(PeerSelector *);
85void netdbHostData(const char *host, int *samp, int *rtt, int *hops);
86
87#endif /* ICMP_NET_DB_H */
88