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
37 /* needed for the global config */
38 #include "HttpHeader.h"
39 #include "HttpHeaderTools.h"
42 #include "icp_opcode.h"
45 #include <openssl/ssl.h>
48 #define PEER_MULTICAST_SIBLINGS 1
50 struct acl_name_list
{
51 char name
[ACL_NAME_SZ
];
55 struct acl_deny_info_list
{
58 acl_name_list
*acl_list
;
59 acl_deny_info_list
*next
;
66 struct _snmp_request_t
{
77 ACLChecklist
*acl_checklist
;
80 struct snmp_session session
;
125 #include "DelayConfig.h"
126 #include "ClientDelayConfig.h"
130 #include "icmp/IcmpConfig.h"
133 #include "HelperChildConfig.h"
135 /* forward decl for SquidConfig, see RemovalPolicy.h */
137 class CpuAffinityMap
;
138 class RemovalPolicySettings
;
147 /// Used for boolean enabled/disabled options with complex default logic.
148 /// Allows Squid to compute the right default after configuration.
149 /// Checks that not-yet-defined option values are not used.
152 // TODO: generalize to non-boolean option types
154 YesNoNone(): option(0) {}
156 /// returns true iff enabled; asserts if the option has not been configured
157 operator void *() const; // TODO: use a fancy/safer version of the operator
159 /// enables or disables the option;
160 void configure(bool beSet
);
162 /// whether the option was enabled or disabled, by user or Squid
163 bool configured() const { return option
!= 0; }
166 enum { optUnspecified
= -1, optDisabled
= 0, optEnabled
= 1 };
167 int option
; ///< configured value or zero
173 /* These should be for the Store::Root instance.
174 * this needs pluggable parsing to be done smoothly.
180 YesNoNone memShared
; ///< whether the memory cache is shared among workers
188 int64_t readAheadGap
;
189 RemovalPolicySettings
*replPolicy
;
190 RemovalPolicySettings
*memPolicy
;
191 #if USE_HTTP_VIOLATIONS
195 time_t negativeDnsTtl
;
196 time_t positiveDnsTtl
;
197 time_t shutdownLifetime
;
198 time_t backgroundPingRate
;
208 time_t clientIdlePconn
;
209 time_t serverIdlePconn
;
212 int icp_query
; /* msec */
213 int icp_query_max
; /* msec */
214 int icp_query_min
; /* msec */
215 int mcast_icp_query
; /* msec */
218 time_msec_t idns_retransmit
;
219 time_msec_t idns_query
;
223 size_t maxRequestHeaderSize
;
224 int64_t maxRequestBodySize
;
225 int64_t maxChunkedRequestBodySize
;
226 size_t maxRequestBufferSize
;
227 size_t maxReplyHeaderSize
;
228 acl_size_t
*ReplyBodySize
;
245 AnyP::PortCfg
*https
;
266 Ip::Address_list
*router
;
268 int forwarding_method
;
270 int assignment_method
;
281 char *as_whois_server
;
286 customlog
*accesslogs
;
296 char *visible_appname_string
;
297 char *effectiveGroup
;
318 HelperChildConfig dnsChildren
;
321 HelperChildConfig redirectChildren
;
322 time_t authenticateGCInterval
;
323 time_t authenticateTTL
;
324 time_t authenticateIpTTL
;
330 size_t appendDomainLen
;
333 char *mimeTablePathname
;
335 char *visibleHostname
;
336 char *uniqueHostname
;
337 wordlist
*hostnameAliases
;
349 Ip::Address udp_incoming
;
350 Ip::Address udp_outgoing
;
352 Ip::Address snmp_incoming
;
353 Ip::Address snmp_outgoing
;
355 /* FIXME INET6 : this should really be a CIDR value */
356 Ip::Address client_netmask
;
359 size_t udpMaxHitObjsz
;
360 wordlist
*hierarchy_stoplist
;
361 wordlist
*mcast_group_list
;
362 wordlist
*dns_nameservers
;
377 cachemgr_passwd
*passwd_list
;
380 int objectsPerBucket
;
381 int64_t avgObjectSize
;
382 int64_t maxObjectSize
;
383 int64_t minObjectSize
;
384 size_t maxInMemObjSize
;
406 int test_reachability
;
407 int half_closed_clients
;
409 #if USE_HTTP_VIOLATIONS
415 int redir_rewrites_host
;
417 int nonhierarchical_direct
;
418 int strip_query_terms
;
419 int redirector_bypass
;
420 int ignore_unknown_nameservers
;
424 #if USE_CACHE_DIGESTS
426 int digest_generation
;
430 int vary_ignore_expire
;
431 int pipeline_prefetch
;
432 int surrogate_is_remote
;
433 int request_entities
;
434 int detect_broken_server_pconns
;
435 int balance_on_multiple_ip
;
436 int relaxed_header_parser
;
438 int allow_underscore
;
441 int httpd_suppress_version_string
;
442 int global_internal_static
;
444 #if FOLLOW_X_FORWARDED_FOR
445 int acl_uses_indirect_client
;
446 int delay_pool_uses_indirect_client
;
447 int log_uses_indirect_client
;
449 int tproxy_uses_indirect_client
;
451 #endif /* FOLLOW_X_FORWARDED_FOR */
453 int WIN32_IpAddrChangeMonitor
;
454 int memory_cache_first
;
455 int memory_cache_disk
;
456 int hostStrictVerify
;
457 int client_dst_passthru
;
460 int forward_max_tries
;
467 acl_access
*adapted_http
;
470 acl_access
*NeverDirect
;
471 acl_access
*AlwaysDirect
;
479 #if USE_HTTP_VIOLATIONS
480 acl_access
*brokenPosts
;
482 acl_access
*redirector
;
484 acl_address
*outgoing_address
;
488 acl_access
*htcp_clr
;
492 acl_access
*ssl_bump
;
494 #if FOLLOW_X_FORWARDED_FOR
495 acl_access
*followXFF
;
496 #endif /* FOLLOW_X_FORWARDED_FOR */
502 acl_deny_info_list
*denyInfoList
;
518 RefCount
<SwapDir
> *swapDirs
;
521 /// number of disk processes required to support all cache_dirs
525 * I'm sick of having to keep doing this ..
527 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
533 char *errorDirectory
;
535 char *errorDefaultLanguage
;
536 int errorLogMissingLanguages
;
538 char *errorStylesheet
;
550 ClientDelayConfig ClientDelay
;
559 int max_open_disk_fds
;
561 acl_size_t
*rangeOffsetLimit
;
562 #if MULTICAST_MISS_STREAM
573 /// request_header_access and request_header_replace
574 HeaderManglers
*request_header_access
;
575 /// reply_header_access and reply_header_replace
576 HeaderManglers
*reply_header_access
;
579 #if USE_CACHE_DIGESTS
583 time_t rebuild_period
;
584 time_t rewrite_period
;
585 size_t swapout_chunk_size
;
586 int rebuild_chunk_percentage
;
592 int unclean_shutdown
;
597 wordlist
*ext_methods
;
604 char *store_dir_select_algorithm
;
605 int sleep_after_fork
; /* microseconds */
606 time_t minimum_expiry_time
; /* seconds */
607 external_acl
*externalAclHelperList
;
621 acl_access
*cert_error
;
628 int max_filedescriptors
;
630 CpuAffinityMap
*cpuAffinityMap
;
632 #if USE_LOADABLE_MODULES
633 wordlist
*loadable_module_names
;
636 int client_ip_max_connections
;
639 int v4_first
; ///< Place IPv4 first in the order of DNS results.
640 ssize_t packet_max
; ///< maximum size EDNS advertised for DNS replies.
644 SQUIDCEXTERN SquidConfig Config
;
646 struct SquidConfig2
{
649 int mangle_request_headers
;
651 uid_t effectiveUserID
;
652 gid_t effectiveGroupID
;
655 SQUIDCEXTERN SquidConfig2 Config2
;
657 struct _close_handler
{
684 void *wrt_handle_data
;
686 dwrite_q
*write_q_tail
;
691 /* per field statistics */
693 class HttpHeaderFieldStat
697 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
699 int aliveCount
; /* created but not destroyed (count) */
700 int seenCount
; /* #fields we've seen */
701 int parsCount
; /* #parsing attempts */
702 int errCount
; /* #pasring errors */
703 int repCount
; /* #repetitons */
706 /* compiled version of HttpHeaderFieldAttrs plus stats */
707 #include "SquidString.h"
709 class HttpHeaderFieldInfo
713 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
718 HttpHeaderFieldStat stat
;
721 struct _http_state_flags
{
722 unsigned int proxying
:1;
723 unsigned int keepalive
:1;
724 unsigned int only_if_cached
:1;
725 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
726 unsigned int headers_parsed
:1;
727 unsigned int front_end_https
:2;
728 unsigned int originpeer
:1;
729 unsigned int keepalive_broken
:1;
730 unsigned int abuse_detected
:1;
731 unsigned int request_sent
:1;
732 unsigned int do_next_read
:1;
733 unsigned int consume_body_data
:1;
734 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
735 unsigned int chunked_request
:1; ///< writing a chunked request
736 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
739 struct _domain_ping
{
741 int do_ping
; /* boolean */
745 struct _domain_type
{
767 int n_keepalives_sent
;
768 int n_keepalives_recv
;
772 time_t last_connect_failure
;
773 time_t last_connect_probe
;
774 int logged_state
; /* so we can print dead/revived msgs */
775 int conn_open
; /* current opened connections */
780 int counts
[ICP_END
+1];
792 unsigned short http_port
;
793 domain_ping
*peer_domain
;
794 domain_type
*typelist
;
798 unsigned int proxy_only
:1;
799 unsigned int no_query
:1;
800 unsigned int background_ping
:1;
801 unsigned int no_digest
:1;
802 unsigned int default_parent
:1;
803 unsigned int roundrobin
:1;
804 unsigned int weighted_roundrobin
:1;
805 unsigned int mcast_responder
:1;
806 unsigned int closest_only
:1;
809 unsigned int htcp_oldsquid
:1;
810 unsigned int htcp_no_clr
:1;
811 unsigned int htcp_no_purge_clr
:1;
812 unsigned int htcp_only_clr
:1;
813 unsigned int htcp_forward_clr
:1;
815 unsigned int no_netdb_exchange
:1;
817 unsigned int no_delay
:1;
819 unsigned int allow_miss
:1;
822 unsigned int set
:1; //If false, whole url is to be used. Overrides others
823 unsigned int scheme
:1;
827 unsigned int params
:1;
830 unsigned int userhash
:1;
832 unsigned int sourcehash
:1;
833 unsigned int originserver
:1;
834 unsigned int no_tproxy
:1;
835 #if PEER_MULTICAST_SIBLINGS
836 unsigned int mcast_siblings
:1;
844 double avg_n_members
;
846 int n_replies_expected
;
851 unsigned int count_event_pending
:1;
852 unsigned int counting
:1;
855 #if USE_CACHE_DIGESTS
861 int tcp_up
; /* 0 if a connect() fails */
863 Ip::Address addresses
[10];
871 double load_multiplier
;
872 double load_factor
; /* normalized weight value */
877 double load_multiplier
;
878 double load_factor
; /* normalized weight value */
883 double load_multiplier
;
884 double load_factor
; /* normalized weight value */
887 char *login
; /* Proxy authorization */
888 time_t connect_timeout
;
889 int connect_fail_limit
;
891 char *domain
; /* Forced domain */
906 SSL_SESSION
*sslSession
;
913 struct _net_db_name
{
914 hash_link hash
; /* must be first */
916 netdbEntry
*net_db_entry
;
919 struct _net_db_peer
{
920 const char *peername
;
927 hash_link hash
; /* must be first */
928 char network
[MAX_IPSTRLEN
];
933 time_t next_ping_time
;
934 time_t last_use_time
;
944 enum { histSize
= 16 };
949 int read_hist
[histSize
];
951 int write_hist
[histSize
];
958 struct request_flags
{
959 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),
961 spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),chunked_reply(0),stream_error(0),sslBumped(0),destinationIPLookedUp_(0) {
962 #if USE_HTTP_VIOLATIONS
965 #if FOLLOW_X_FORWARDED_FOR
966 done_follow_x_forwarded_for
= 0;
967 #endif /* FOLLOW_X_FORWARDED_FOR */
970 unsigned int range
:1;
971 unsigned int nocache
:1; ///< whether the response to this request may be READ from cache
974 unsigned int cachable
:1; ///< whether the response to thie request may be stored in the cache
975 unsigned int hierarchical
:1;
976 unsigned int loopdetect
:1;
977 unsigned int proxy_keepalive
:1;
978 unsigned int proxying
:
979 1; /* this should be killed, also in httpstateflags */
980 unsigned int refresh
:1;
981 unsigned int redirected
:1;
982 unsigned int need_validation
:1;
983 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
984 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
985 #if USE_HTTP_VIOLATIONS
986 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
988 unsigned int accelerated
:1;
989 unsigned int ignore_cc
:1;
990 unsigned int intercepted
:1; ///< intercepted request
991 unsigned int hostVerified
:1; ///< whether the Host: header passed verification
992 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
993 unsigned int internal
:1;
994 unsigned int internalclient
:1;
995 unsigned int must_keepalive
:1;
996 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
997 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
998 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
999 unsigned int pinned
:1; /* Request sent on a pinned connection */
1000 unsigned int auth_sent
:1; /* Authentication forwarded */
1001 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1002 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
1003 unsigned int stream_error
:1; /**< Whether stream error has occured */
1004 unsigned int sslBumped
:1; /**< ssl-bumped request*/
1006 // When adding new flags, please update cloneAdaptationImmune() as needed.
1008 bool resetTCP() const;
1010 void clearResetTCP();
1011 void destinationIPLookupCompleted();
1012 bool destinationIPLookedUp() const;
1014 // returns a partial copy of the flags that includes only those flags
1015 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1016 request_flags
cloneAdaptationImmune() const;
1018 #if FOLLOW_X_FORWARDED_FOR
1019 unsigned int done_follow_x_forwarded_for
;
1020 #endif /* FOLLOW_X_FORWARDED_FOR */
1023 unsigned int reset_tcp
:1;
1024 unsigned int destinationIPLookedUp_
:1;
1030 struct _link_list
*next
;
1033 struct _cachemgr_passwd
{
1036 cachemgr_passwd
*next
;
1040 const char *pattern
;
1041 regex_t compiled_pattern
;
1048 unsigned int icase
:1;
1049 unsigned int refresh_ims
:1;
1050 unsigned int store_stale
:1;
1051 #if USE_HTTP_VIOLATIONS
1052 unsigned int override_expire
:1;
1053 unsigned int override_lastmod
:1;
1054 unsigned int reload_into_ims
:1;
1055 unsigned int ignore_reload
:1;
1056 unsigned int ignore_no_cache
:1;
1057 unsigned int ignore_no_store
:1;
1058 unsigned int ignore_must_revalidate
:1;
1059 unsigned int ignore_private
:1;
1060 unsigned int ignore_auth
:1;
1067 struct _CacheDigest
{
1068 /* public, read-only */
1069 char *mask
; /* bit mask */
1070 int mask_size
; /* mask size in bytes */
1071 int capacity
; /* expected maximum for .count, not a hard limit */
1072 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
1073 int count
; /* number of digested entries */
1074 int del_count
; /* number of deletions performed so far */
1078 struct _store_rebuild_data
{
1079 int objcount
; /* # objects successfully reloaded */
1080 int expcount
; /* # objects expired */
1081 int scancount
; /* # entries scanned or read from state file */
1082 int clashcount
; /* # swapfile clashes avoided */
1083 int dupcount
; /* # duplicates purged */
1084 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
1085 int invalid
; /* # bad lines */
1086 int badflags
; /* # bad e->flags */
1093 #include "format/Format.h"
1094 #include "log/Formats.h"
1098 Format::Format
*logFormat
;
1101 Log::Format::log_type type
;
1104 #endif /* SQUID_STRUCTS_H */