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