]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | class CachePeer; | |
17 | class HttpRequest; | |
18 | class netdbEntry; | |
19 | class StoreEntry; | |
20 | class URL; | |
21 | ||
22 | class net_db_name | |
23 | { | |
24 | MEMPROXY_CLASS(net_db_name); | |
25 | ||
26 | public: | |
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 | |
36 | class net_db_peer | |
37 | { | |
38 | public: | |
39 | const char *peername; | |
40 | double hops; | |
41 | double rtt; | |
42 | time_t expires; | |
43 | }; | |
44 | ||
45 | class netdbEntry | |
46 | { | |
47 | MEMPROXY_CLASS(netdbEntry); | |
48 | ||
49 | public: | |
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 | ||
67 | void netdbInit(void); | |
68 | ||
69 | void netdbHandlePingReply(const Ip::Address &from, int hops, int rtt); | |
70 | void netdbPingSite(const char *hostname); | |
71 | void netdbDump(StoreEntry *); | |
72 | ||
73 | void netdbFreeMemory(void); | |
74 | int netdbHostHops(const char *host); | |
75 | int netdbHostRtt(const char *host); | |
76 | void netdbUpdatePeer(const URL &, CachePeer * e, int rtt, int hops); | |
77 | ||
78 | void netdbDeleteAddrNetwork(Ip::Address &addr); | |
79 | void netdbBinaryExchange(StoreEntry *); | |
80 | void netdbExchangeStart(void *); | |
81 | ||
82 | void netdbExchangeUpdatePeer(Ip::Address &, CachePeer *, double, double); | |
83 | CachePeer *netdbClosestParent(HttpRequest *); | |
84 | void netdbHostData(const char *host, int *samp, int *rtt, int *hops); | |
85 | ||
86 | #endif /* ICMP_NET_DB_H */ | |
87 |