2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
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.
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.
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.
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.
29 #ifndef SQUID_STRUCTS_H
30 #define SQUID_STRUCTS_H
38 #include "ip/Address.h"
40 /* needed for the global config */
41 #include "HttpHeader.h"
42 #include "HttpHeaderTools.h"
45 #include "icp_opcode.h"
48 #include <openssl/ssl.h>
51 #define PEER_MULTICAST_SIBLINGS 1
53 struct acl_name_list
{
54 char name
[ACL_NAME_SZ
];
58 struct acl_deny_info_list
{
61 acl_name_list
*acl_list
;
62 acl_deny_info_list
*next
;
69 #include "snmp_session.h"
70 struct _snmp_request_t
{
81 ACLChecklist
*acl_checklist
;
84 struct snmp_session session
;
124 #include "DelayConfig.h"
125 #include "ClientDelayConfig.h"
129 #include "icmp/IcmpConfig.h"
132 #include "HelperChildConfig.h"
134 /* forward decl for SquidConfig, see RemovalPolicy.h */
136 class CpuAffinityMap
;
137 class RemovalPolicySettings
;
141 class cachemgr_passwd
;
149 class close_handler
{
179 void *wrt_handle_data
;
181 dwrite_q
*write_q_tail
;
185 /* per field statistics */
187 class HttpHeaderFieldStat
191 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
193 int aliveCount
; /* created but not destroyed (count) */
194 int seenCount
; /* #fields we've seen */
195 int parsCount
; /* #parsing attempts */
196 int errCount
; /* #pasring errors */
197 int repCount
; /* #repetitons */
200 /* compiled version of HttpHeaderFieldAttrs plus stats */
201 #include "SquidString.h"
203 class HttpHeaderFieldInfo
207 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
212 HttpHeaderFieldStat stat
;
215 class http_state_flags
{
217 unsigned int proxying
:1;
218 unsigned int keepalive
:1;
219 unsigned int only_if_cached
:1;
220 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
221 unsigned int headers_parsed
:1;
222 unsigned int front_end_https
:2;
223 unsigned int originpeer
:1;
224 unsigned int keepalive_broken
:1;
225 unsigned int abuse_detected
:1;
226 unsigned int request_sent
:1;
227 unsigned int do_next_read
:1;
228 unsigned int consume_body_data
:1;
229 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
230 unsigned int chunked_request
:1; ///< writing a chunked request
231 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
237 int do_ping
; /* boolean */
264 int n_keepalives_sent
;
265 int n_keepalives_recv
;
269 time_t last_connect_failure
;
270 time_t last_connect_probe
;
271 int logged_state
; /* so we can print dead/revived msgs */
272 int conn_open
; /* current opened connections */
277 int counts
[ICP_END
+1];
289 unsigned short http_port
;
290 domain_ping
*peer_domain
;
291 domain_type
*typelist
;
295 unsigned int proxy_only
:1;
296 unsigned int no_query
:1;
297 unsigned int background_ping
:1;
298 unsigned int no_digest
:1;
299 unsigned int default_parent
:1;
300 unsigned int roundrobin
:1;
301 unsigned int weighted_roundrobin
:1;
302 unsigned int mcast_responder
:1;
303 unsigned int closest_only
:1;
306 unsigned int htcp_oldsquid
:1;
307 unsigned int htcp_no_clr
:1;
308 unsigned int htcp_no_purge_clr
:1;
309 unsigned int htcp_only_clr
:1;
310 unsigned int htcp_forward_clr
:1;
312 unsigned int no_netdb_exchange
:1;
314 unsigned int no_delay
:1;
316 unsigned int allow_miss
:1;
319 unsigned int set
:1; //If false, whole url is to be used. Overrides others
320 unsigned int scheme
:1;
324 unsigned int params
:1;
327 unsigned int userhash
:1;
329 unsigned int sourcehash
:1;
330 unsigned int originserver
:1;
331 unsigned int no_tproxy
:1;
332 #if PEER_MULTICAST_SIBLINGS
333 unsigned int mcast_siblings
:1;
341 double avg_n_members
;
343 int n_replies_expected
;
348 unsigned int count_event_pending
:1;
349 unsigned int counting
:1;
352 #if USE_CACHE_DIGESTS
358 int tcp_up
; /* 0 if a connect() fails */
360 Ip::Address addresses
[10];
368 double load_multiplier
;
369 double load_factor
; /* normalized weight value */
374 double load_multiplier
;
375 double load_factor
; /* normalized weight value */
380 double load_multiplier
;
381 double load_factor
; /* normalized weight value */
384 char *login
; /* Proxy authorization */
385 time_t connect_timeout
;
386 int connect_fail_limit
;
388 char *domain
; /* Forced domain */
403 SSL_SESSION
*sslSession
;
414 hash_link hash
; /* must be first */
416 netdbEntry
*net_db_entry
;
421 const char *peername
;
429 hash_link hash
; /* must be first */
430 char network
[MAX_IPSTRLEN
];
435 time_t next_ping_time
;
436 time_t last_use_time
;
446 static const int histSize
=16;
448 // enum { histSize = 16 };
453 int read_hist
[histSize
];
455 int write_hist
[histSize
];
461 struct request_flags
{
462 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) {
463 #if USE_HTTP_VIOLATIONS
466 #if FOLLOW_X_FORWARDED_FOR
467 done_follow_x_forwarded_for
= 0;
468 #endif /* FOLLOW_X_FORWARDED_FOR */
471 unsigned int range
:1;
472 unsigned int nocache
:1; ///< whether the response to this request may be READ from cache
475 unsigned int cachable
:1; ///< whether the response to thie request may be stored in the cache
476 unsigned int hierarchical
:1;
477 unsigned int loopdetect
:1;
478 unsigned int proxy_keepalive
:1;
479 unsigned int proxying
:
480 1; /* this should be killed, also in httpstateflags */
481 unsigned int refresh
:1;
482 unsigned int redirected
:1;
483 unsigned int need_validation
:1;
484 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
485 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
486 #if USE_HTTP_VIOLATIONS
487 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
489 unsigned int accelerated
:1;
490 unsigned int ignore_cc
:1;
491 unsigned int intercepted
:1; ///< intercepted request
492 unsigned int hostVerified
:1; ///< whether the Host: header passed verification
493 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
494 unsigned int internal
:1;
495 unsigned int internalclient
:1;
496 unsigned int must_keepalive
:1;
497 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
498 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
499 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
500 unsigned int pinned
:1; /* Request sent on a pinned connection */
501 unsigned int canRePin
:1; ///< OK to reopen a failed pinned connection
502 unsigned int auth_sent
:1; /* Authentication forwarded */
503 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
504 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
505 unsigned int stream_error
:1; /**< Whether stream error has occured */
506 unsigned int sslPeek
:1; ///< internal ssl-bump request to get server cert
507 unsigned int sslBumped
:1; /**< ssl-bumped request*/
509 // When adding new flags, please update cloneAdaptationImmune() as needed.
511 bool resetTCP() const;
513 void clearResetTCP();
514 void destinationIPLookupCompleted();
515 bool destinationIPLookedUp() const;
517 // returns a partial copy of the flags that includes only those flags
518 // that are safe for a related (e.g., ICAP-adapted) request to inherit
519 request_flags
cloneAdaptationImmune() const;
521 #if FOLLOW_X_FORWARDED_FOR
522 unsigned int done_follow_x_forwarded_for
;
523 #endif /* FOLLOW_X_FORWARDED_FOR */
526 unsigned int reset_tcp
:1;
527 unsigned int destinationIPLookedUp_
:1;
531 class cachemgr_passwd
{
535 cachemgr_passwd
*next
;
541 regex_t compiled_pattern
;
548 unsigned int icase
:1;
549 unsigned int refresh_ims
:1;
550 unsigned int store_stale
:1;
551 #if USE_HTTP_VIOLATIONS
552 unsigned int override_expire
:1;
553 unsigned int override_lastmod
:1;
554 unsigned int reload_into_ims
:1;
555 unsigned int ignore_reload
:1;
556 unsigned int ignore_no_cache
:1;
557 unsigned int ignore_no_store
:1;
558 unsigned int ignore_must_revalidate
:1;
559 unsigned int ignore_private
:1;
560 unsigned int ignore_auth
:1;
568 /* public, read-only */
569 char *mask
; /* bit mask */
570 int mask_size
; /* mask size in bytes */
571 int capacity
; /* expected maximum for .count, not a hard limit */
572 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
573 int count
; /* number of digested entries */
574 int del_count
; /* number of deletions performed so far */
577 struct _store_rebuild_data
{
578 int objcount
; /* # objects successfully reloaded */
579 int expcount
; /* # objects expired */
580 int scancount
; /* # entries scanned or read from state file */
581 int clashcount
; /* # swapfile clashes avoided */
582 int dupcount
; /* # duplicates purged */
583 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
584 int invalid
; /* # bad lines */
585 int badflags
; /* # bad e->flags */
591 struct _sslproxy_cert_sign
{
594 sslproxy_cert_sign
*next
;
597 struct _sslproxy_cert_adapt
{
601 sslproxy_cert_adapt
*next
;
607 #include "format/Format.h"
608 #include "log/Formats.h"
613 Format::Format
*logFormat
;
616 Log::Format::log_type type
;
619 #endif /* SQUID_STRUCTS_H */