]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
Renamed acl_deny_info_list to AclDenyInfoList and moved to own header file in acl/
[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 "acl/AclNameList.h"
33 #include "cbdata.h"
34 #include "defines.h"
35 #include "dlink.h"
36 #include "err_type.h"
37 #include "hash.h"
38 #include "ip/Address.h"
39 #include "RefCount.h"
40
41 /* needed for the global config */
42 #include "HttpHeader.h"
43 #include "HttpHeaderTools.h"
44
45 /* for ICP_END */
46 #include "icp_opcode.h"
47
48 #define PEER_MULTICAST_SIBLINGS 1
49
50 class ACLChecklist;
51
52 #if SQUID_SNMP
53
54 #include "snmp_session.h"
55 struct _snmp_request_t {
56 u_char *buf;
57 u_char *outbuf;
58 int len;
59 int sock;
60 long reqid;
61 int outlen;
62
63 Ip::Address from;
64
65 struct snmp_pdu *PDU;
66 ACLChecklist *acl_checklist;
67 u_char *community;
68
69 struct snmp_session session;
70 };
71
72 #endif
73
74 class ACLList;
75
76 struct acl_address {
77 acl_address *next;
78 ACLList *aclList;
79
80 Ip::Address addr;
81 };
82
83 struct acl_tos {
84 acl_tos *next;
85 ACLList *aclList;
86 tos_t tos;
87 };
88
89 struct acl_nfmark {
90 acl_nfmark *next;
91 ACLList *aclList;
92 nfmark_t nfmark;
93 };
94
95 struct acl_size_t {
96 acl_size_t *next;
97 ACLList *aclList;
98 int64_t size;
99 };
100
101 struct relist {
102 int flags;
103 char *pattern;
104 regex_t regex;
105 relist *next;
106 };
107
108 #if USE_DELAY_POOLS
109 #include "DelayConfig.h"
110 #include "ClientDelayConfig.h"
111 #endif
112
113 #if USE_ICMP
114 #include "icmp/IcmpConfig.h"
115 #endif
116
117 #include "HelperChildConfig.h"
118
119 /* forward decl for SquidConfig, see RemovalPolicy.h */
120
121 class CpuAffinityMap;
122 class RemovalPolicySettings;
123 class external_acl;
124 class Store;
125 class customlog;
126 class cachemgr_passwd;
127 class refresh_t;
128 namespace AnyP
129 {
130 struct PortCfg;
131 }
132 class SwapDir;
133
134 class close_handler {
135 public:
136 PF *handler;
137 void *data;
138 close_handler *next;
139 };
140
141 class dread_ctrl {
142 public:
143 int fd;
144 off_t offset;
145 int req_len;
146 char *buf;
147 int end_of_file;
148 DRCB *handler;
149 void *client_data;
150 };
151
152 class dwrite_q {
153 public:
154 off_t file_offset;
155 char *buf;
156 size_t len;
157 size_t buf_offset;
158 dwrite_q *next;
159 FREE *free_func;
160 };
161
162 struct _fde_disk {
163 DWCB *wrt_handle;
164 void *wrt_handle_data;
165 dwrite_q *write_q;
166 dwrite_q *write_q_tail;
167 off_t offset;
168 };
169
170
171 class http_state_flags {
172 public:
173 unsigned int proxying:1;
174 unsigned int keepalive:1;
175 unsigned int only_if_cached:1;
176 unsigned int handling1xx:1; ///< we are ignoring or forwarding 1xx response
177 unsigned int headers_parsed:1;
178 unsigned int front_end_https:2;
179 unsigned int originpeer:1;
180 unsigned int keepalive_broken:1;
181 unsigned int abuse_detected:1;
182 unsigned int request_sent:1;
183 unsigned int do_next_read:1;
184 unsigned int consume_body_data:1;
185 unsigned int chunked:1; ///< reading a chunked response; TODO: rename
186 unsigned int chunked_request:1; ///< writing a chunked request
187 unsigned int sentLastChunk:1; ///< do not try to write last-chunk again
188 };
189
190 class domain_ping {
191 public:
192 char *domain;
193 int do_ping; /* boolean */
194 domain_ping *next;
195 };
196
197 class domain_type {
198 public:
199 char *domain;
200 peer_t type;
201 domain_type *next;
202 };
203
204 class PeerDigest;
205
206
207 class netdbEntry;
208
209 class net_db_name {
210 public:
211 hash_link hash; /* must be first */
212 net_db_name *next;
213 netdbEntry *net_db_entry;
214 };
215
216 class net_db_peer {
217 public:
218 const char *peername;
219 double hops;
220 double rtt;
221 time_t expires;
222 };
223
224 class netdbEntry {
225 public:
226 hash_link hash; /* must be first */
227 char network[MAX_IPSTRLEN];
228 int pings_sent;
229 int pings_recv;
230 double hops;
231 double rtt;
232 time_t next_ping_time;
233 time_t last_use_time;
234 int link_count;
235 net_db_name *hosts;
236 net_db_peer *peers;
237 int n_peers_alloc;
238 int n_peers;
239 };
240
241 class iostats {
242 public:
243 static const int histSize=16;
244
245 // enum { histSize = 16 };
246
247 struct {
248 int reads;
249 int reads_deferred;
250 int read_hist[histSize];
251 int writes;
252 int write_hist[histSize];
253 }
254
255 Http, Ftp, Gopher;
256 };
257
258 struct request_flags {
259 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) {
260 #if USE_HTTP_VIOLATIONS
261 nocache_hack = 0;
262 #endif
263 #if FOLLOW_X_FORWARDED_FOR
264 done_follow_x_forwarded_for = 0;
265 #endif /* FOLLOW_X_FORWARDED_FOR */
266 }
267
268 unsigned int range:1;
269 unsigned int nocache:1; ///< whether the response to this request may be READ from cache
270 unsigned int ims:1;
271 unsigned int auth:1;
272 unsigned int cachable:1; ///< whether the response to thie request may be stored in the cache
273 unsigned int hierarchical:1;
274 unsigned int loopdetect:1;
275 unsigned int proxy_keepalive:1;
276 unsigned int proxying:
277 1; /* this should be killed, also in httpstateflags */
278 unsigned int refresh:1;
279 unsigned int redirected:1;
280 unsigned int need_validation:1;
281 unsigned int fail_on_validation_err:1; ///< whether we should fail if validation fails
282 unsigned int stale_if_hit:1; ///< reply is stale if it is a hit
283 #if USE_HTTP_VIOLATIONS
284 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
285 #endif
286 unsigned int accelerated:1;
287 unsigned int ignore_cc:1;
288 unsigned int intercepted:1; ///< intercepted request
289 unsigned int hostVerified:1; ///< whether the Host: header passed verification
290 unsigned int spoof_client_ip:1; /**< spoof client ip if possible */
291 unsigned int internal:1;
292 unsigned int internalclient:1;
293 unsigned int must_keepalive:1;
294 unsigned int connection_auth:1; /** Request wants connection oriented auth */
295 unsigned int connection_auth_disabled:1; /** Connection oriented auth can not be supported */
296 unsigned int connection_proxy_auth:1; /** Request wants connection oriented auth */
297 unsigned int pinned:1; /* Request sent on a pinned connection */
298 unsigned int canRePin:1; ///< OK to reopen a failed pinned connection
299 unsigned int auth_sent:1; /* Authentication forwarded */
300 unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
301 unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
302 unsigned int stream_error:1; /**< Whether stream error has occured */
303 unsigned int sslPeek:1; ///< internal ssl-bump request to get server cert
304 unsigned int sslBumped:1; /**< ssl-bumped request*/
305
306 // When adding new flags, please update cloneAdaptationImmune() as needed.
307
308 bool resetTCP() const;
309 void setResetTCP();
310 void clearResetTCP();
311 void destinationIPLookupCompleted();
312 bool destinationIPLookedUp() const;
313
314 // returns a partial copy of the flags that includes only those flags
315 // that are safe for a related (e.g., ICAP-adapted) request to inherit
316 request_flags cloneAdaptationImmune() const;
317
318 #if FOLLOW_X_FORWARDED_FOR
319 unsigned int done_follow_x_forwarded_for;
320 #endif /* FOLLOW_X_FORWARDED_FOR */
321 private:
322
323 unsigned int reset_tcp:1;
324 unsigned int destinationIPLookedUp_:1;
325 };
326
327
328 class cachemgr_passwd {
329 public:
330 char *passwd;
331 wordlist *actions;
332 cachemgr_passwd *next;
333 };
334
335 class refresh_t {
336 public:
337 const char *pattern;
338 regex_t compiled_pattern;
339 time_t min;
340 double pct;
341 time_t max;
342 refresh_t *next;
343
344 struct {
345 unsigned int icase:1;
346 unsigned int refresh_ims:1;
347 unsigned int store_stale:1;
348 #if USE_HTTP_VIOLATIONS
349 unsigned int override_expire:1;
350 unsigned int override_lastmod:1;
351 unsigned int reload_into_ims:1;
352 unsigned int ignore_reload:1;
353 unsigned int ignore_no_cache:1;
354 unsigned int ignore_no_store:1;
355 unsigned int ignore_must_revalidate:1;
356 unsigned int ignore_private:1;
357 unsigned int ignore_auth:1;
358 #endif
359 } flags;
360 int max_stale;
361 };
362
363 class CacheDigest {
364 public:
365 /* public, read-only */
366 char *mask; /* bit mask */
367 int mask_size; /* mask size in bytes */
368 int capacity; /* expected maximum for .count, not a hard limit */
369 int bits_per_entry; /* number of bits allocated for each entry from capacity */
370 int count; /* number of digested entries */
371 int del_count; /* number of deletions performed so far */
372 };
373
374 struct _store_rebuild_data {
375 int objcount; /* # objects successfully reloaded */
376 int expcount; /* # objects expired */
377 int scancount; /* # entries scanned or read from state file */
378 int clashcount; /* # swapfile clashes avoided */
379 int dupcount; /* # duplicates purged */
380 int cancelcount; /* # SWAP_LOG_DEL objects purged */
381 int invalid; /* # bad lines */
382 int badflags; /* # bad e->flags */
383 int bad_log_op;
384 int zero_object_sz;
385 };
386
387 #if USE_SSL
388 struct _sslproxy_cert_sign {
389 int alg;
390 ACLList *aclList;
391 sslproxy_cert_sign *next;
392 };
393
394 struct _sslproxy_cert_adapt {
395 int alg;
396 char *param;
397 ACLList *aclList;
398 sslproxy_cert_adapt *next;
399 };
400 #endif
401
402 class Logfile;
403
404 #include "format/Format.h"
405 #include "log/Formats.h"
406 class customlog {
407 public:
408 char *filename;
409 ACLList *aclList;
410 Format::Format *logFormat;
411 Logfile *logfile;
412 customlog *next;
413 Log::Format::log_type type;
414 };
415
416 #endif /* SQUID_STRUCTS_H */