]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
renamed refresh_t to RefreshPattern and moved to own header file.
[thirdparty/squid.git] / src / structs.h
1 /*
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
29 #ifndef SQUID_STRUCTS_H
30 #define SQUID_STRUCTS_H
31
32 #include "cbdata.h"
33 #include "defines.h"
34 #include "dlink.h"
35 #include "hash.h"
36 #include "ip/Address.h"
37
38 /* needed for the global config */
39 #include "HttpHeader.h"
40 #include "HttpHeaderTools.h"
41
42 #define PEER_MULTICAST_SIBLINGS 1
43
44 class ACLChecklist;
45
46 #if SQUID_SNMP
47
48 #include "snmp_session.h"
49 class snmp_request_t {
50 public:
51 u_char *buf;
52 u_char *outbuf;
53 int len;
54 int sock;
55 long reqid;
56 int outlen;
57
58 Ip::Address from;
59
60 struct snmp_pdu *PDU;
61 ACLChecklist *acl_checklist;
62 u_char *community;
63
64 struct snmp_session session;
65 };
66
67 #endif
68
69 class ACLList;
70
71 struct acl_tos {
72 acl_tos *next;
73 ACLList *aclList;
74 tos_t tos;
75 };
76
77 struct acl_nfmark {
78 acl_nfmark *next;
79 ACLList *aclList;
80 nfmark_t nfmark;
81 };
82
83 struct acl_size_t {
84 acl_size_t *next;
85 ACLList *aclList;
86 int64_t size;
87 };
88
89 #if USE_DELAY_POOLS
90 #include "DelayConfig.h"
91 #include "ClientDelayConfig.h"
92 #endif
93
94 #if USE_ICMP
95 #include "icmp/IcmpConfig.h"
96 #endif
97
98 #include "HelperChildConfig.h"
99
100 /* forward decl for SquidConfig, see RemovalPolicy.h */
101
102 class CpuAffinityMap;
103 class RemovalPolicySettings;
104 class external_acl;
105 class Store;
106 class CustomLog;
107 class cachemgr_passwd;
108 namespace AnyP
109 {
110 struct PortCfg;
111 }
112 class SwapDir;
113
114 class close_handler {
115 public:
116 PF *handler;
117 void *data;
118 close_handler *next;
119 };
120
121 class dread_ctrl {
122 public:
123 int fd;
124 off_t offset;
125 int req_len;
126 char *buf;
127 int end_of_file;
128 DRCB *handler;
129 void *client_data;
130 };
131
132 class dwrite_q {
133 public:
134 off_t file_offset;
135 char *buf;
136 size_t len;
137 size_t buf_offset;
138 dwrite_q *next;
139 FREE *free_func;
140 };
141
142 struct _fde_disk {
143 DWCB *wrt_handle;
144 void *wrt_handle_data;
145 dwrite_q *write_q;
146 dwrite_q *write_q_tail;
147 off_t offset;
148 };
149
150
151 class http_state_flags {
152 public:
153 unsigned int proxying:1;
154 unsigned int keepalive:1;
155 unsigned int only_if_cached:1;
156 unsigned int handling1xx:1; ///< we are ignoring or forwarding 1xx response
157 unsigned int headers_parsed:1;
158 unsigned int front_end_https:2;
159 unsigned int originpeer:1;
160 unsigned int keepalive_broken:1;
161 unsigned int abuse_detected:1;
162 unsigned int request_sent:1;
163 unsigned int do_next_read:1;
164 unsigned int consume_body_data:1;
165 unsigned int chunked:1; ///< reading a chunked response; TODO: rename
166 unsigned int chunked_request:1; ///< writing a chunked request
167 unsigned int sentLastChunk:1; ///< do not try to write last-chunk again
168 };
169
170 class domain_ping {
171 public:
172 char *domain;
173 int do_ping; /* boolean */
174 domain_ping *next;
175 };
176
177 class domain_type {
178 public:
179 char *domain;
180 peer_t type;
181 domain_type *next;
182 };
183
184 class PeerDigest;
185
186
187 class netdbEntry;
188
189 class net_db_name {
190 public:
191 hash_link hash; /* must be first */
192 net_db_name *next;
193 netdbEntry *net_db_entry;
194 };
195
196 class net_db_peer {
197 public:
198 const char *peername;
199 double hops;
200 double rtt;
201 time_t expires;
202 };
203
204 class netdbEntry {
205 public:
206 hash_link hash; /* must be first */
207 char network[MAX_IPSTRLEN];
208 int pings_sent;
209 int pings_recv;
210 double hops;
211 double rtt;
212 time_t next_ping_time;
213 time_t last_use_time;
214 int link_count;
215 net_db_name *hosts;
216 net_db_peer *peers;
217 int n_peers_alloc;
218 int n_peers;
219 };
220
221 class iostats {
222 public:
223 static const int histSize=16;
224
225 // enum { histSize = 16 };
226
227 struct {
228 int reads;
229 int reads_deferred;
230 int read_hist[histSize];
231 int writes;
232 int write_hist[histSize];
233 }
234
235 Http, Ftp, Gopher;
236 };
237
238 struct request_flags {
239 request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),fail_on_validation_err(0),stale_if_hit(0),accelerated(0),ignore_cc(0),intercepted(0),hostVerified(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),pinned(0),canRePin(0),chunked_reply(0),stream_error(0),sslPeek(0),sslBumped(0),destinationIPLookedUp_(0) {
240 #if USE_HTTP_VIOLATIONS
241 nocache_hack = 0;
242 #endif
243 #if FOLLOW_X_FORWARDED_FOR
244 done_follow_x_forwarded_for = 0;
245 #endif /* FOLLOW_X_FORWARDED_FOR */
246 }
247
248 unsigned int range:1;
249 unsigned int nocache:1; ///< whether the response to this request may be READ from cache
250 unsigned int ims:1;
251 unsigned int auth:1;
252 unsigned int cachable:1; ///< whether the response to thie request may be stored in the cache
253 unsigned int hierarchical:1;
254 unsigned int loopdetect:1;
255 unsigned int proxy_keepalive:1;
256 unsigned int proxying:
257 1; /* this should be killed, also in httpstateflags */
258 unsigned int refresh:1;
259 unsigned int redirected:1;
260 unsigned int need_validation:1;
261 unsigned int fail_on_validation_err:1; ///< whether we should fail if validation fails
262 unsigned int stale_if_hit:1; ///< reply is stale if it is a hit
263 #if USE_HTTP_VIOLATIONS
264 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
265 #endif
266 unsigned int accelerated:1;
267 unsigned int ignore_cc:1;
268 unsigned int intercepted:1; ///< intercepted request
269 unsigned int hostVerified:1; ///< whether the Host: header passed verification
270 unsigned int spoof_client_ip:1; /**< spoof client ip if possible */
271 unsigned int internal:1;
272 unsigned int internalclient:1;
273 unsigned int must_keepalive:1;
274 unsigned int connection_auth:1; /** Request wants connection oriented auth */
275 unsigned int connection_auth_disabled:1; /** Connection oriented auth can not be supported */
276 unsigned int connection_proxy_auth:1; /** Request wants connection oriented auth */
277 unsigned int pinned:1; /* Request sent on a pinned connection */
278 unsigned int canRePin:1; ///< OK to reopen a failed pinned connection
279 unsigned int auth_sent:1; /* Authentication forwarded */
280 unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
281 unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
282 unsigned int stream_error:1; /**< Whether stream error has occured */
283 unsigned int sslPeek:1; ///< internal ssl-bump request to get server cert
284 unsigned int sslBumped:1; /**< ssl-bumped request*/
285
286 // When adding new flags, please update cloneAdaptationImmune() as needed.
287
288 bool resetTCP() const;
289 void setResetTCP();
290 void clearResetTCP();
291 void destinationIPLookupCompleted();
292 bool destinationIPLookedUp() const;
293
294 // returns a partial copy of the flags that includes only those flags
295 // that are safe for a related (e.g., ICAP-adapted) request to inherit
296 request_flags cloneAdaptationImmune() const;
297
298 #if FOLLOW_X_FORWARDED_FOR
299 unsigned int done_follow_x_forwarded_for;
300 #endif /* FOLLOW_X_FORWARDED_FOR */
301 private:
302
303 unsigned int reset_tcp:1;
304 unsigned int destinationIPLookedUp_:1;
305 };
306
307
308 class cachemgr_passwd {
309 public:
310 char *passwd;
311 wordlist *actions;
312 cachemgr_passwd *next;
313 };
314
315
316 #if USE_SSL
317 struct _sslproxy_cert_sign {
318 int alg;
319 ACLList *aclList;
320 sslproxy_cert_sign *next;
321 };
322
323 struct _sslproxy_cert_adapt {
324 int alg;
325 char *param;
326 ACLList *aclList;
327 sslproxy_cert_adapt *next;
328 };
329 #endif
330
331 #endif /* SQUID_STRUCTS_H */