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
;
577 ///request_header_add access list
578 HeaderWithAclList
*request_header_add
;
581 #if USE_CACHE_DIGESTS
585 time_t rebuild_period
;
586 time_t rewrite_period
;
587 size_t swapout_chunk_size
;
588 int rebuild_chunk_percentage
;
594 int unclean_shutdown
;
599 wordlist
*ext_methods
;
606 char *store_dir_select_algorithm
;
607 int sleep_after_fork
; /* microseconds */
608 time_t minimum_expiry_time
; /* seconds */
609 external_acl
*externalAclHelperList
;
623 acl_access
*cert_error
;
625 sslproxy_cert_sign
*cert_sign
;
626 sslproxy_cert_adapt
*cert_adapt
;
632 int max_filedescriptors
;
634 CpuAffinityMap
*cpuAffinityMap
;
636 #if USE_LOADABLE_MODULES
637 wordlist
*loadable_module_names
;
640 int client_ip_max_connections
;
643 int v4_first
; ///< Place IPv4 first in the order of DNS results.
644 ssize_t packet_max
; ///< maximum size EDNS advertised for DNS replies.
648 SQUIDCEXTERN SquidConfig Config
;
650 struct SquidConfig2
{
653 int mangle_request_headers
;
655 uid_t effectiveUserID
;
656 gid_t effectiveGroupID
;
659 SQUIDCEXTERN SquidConfig2 Config2
;
661 struct _close_handler
{
688 void *wrt_handle_data
;
690 dwrite_q
*write_q_tail
;
695 /* per field statistics */
697 class HttpHeaderFieldStat
701 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
703 int aliveCount
; /* created but not destroyed (count) */
704 int seenCount
; /* #fields we've seen */
705 int parsCount
; /* #parsing attempts */
706 int errCount
; /* #pasring errors */
707 int repCount
; /* #repetitons */
710 /* compiled version of HttpHeaderFieldAttrs plus stats */
711 #include "SquidString.h"
713 class HttpHeaderFieldInfo
717 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
722 HttpHeaderFieldStat stat
;
725 struct _http_state_flags
{
726 unsigned int proxying
:1;
727 unsigned int keepalive
:1;
728 unsigned int only_if_cached
:1;
729 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
730 unsigned int headers_parsed
:1;
731 unsigned int front_end_https
:2;
732 unsigned int originpeer
:1;
733 unsigned int keepalive_broken
:1;
734 unsigned int abuse_detected
:1;
735 unsigned int request_sent
:1;
736 unsigned int do_next_read
:1;
737 unsigned int consume_body_data
:1;
738 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
739 unsigned int chunked_request
:1; ///< writing a chunked request
740 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
743 struct _domain_ping
{
745 int do_ping
; /* boolean */
749 struct _domain_type
{
771 int n_keepalives_sent
;
772 int n_keepalives_recv
;
776 time_t last_connect_failure
;
777 time_t last_connect_probe
;
778 int logged_state
; /* so we can print dead/revived msgs */
779 int conn_open
; /* current opened connections */
784 int counts
[ICP_END
+1];
796 unsigned short http_port
;
797 domain_ping
*peer_domain
;
798 domain_type
*typelist
;
802 unsigned int proxy_only
:1;
803 unsigned int no_query
:1;
804 unsigned int background_ping
:1;
805 unsigned int no_digest
:1;
806 unsigned int default_parent
:1;
807 unsigned int roundrobin
:1;
808 unsigned int weighted_roundrobin
:1;
809 unsigned int mcast_responder
:1;
810 unsigned int closest_only
:1;
813 unsigned int htcp_oldsquid
:1;
814 unsigned int htcp_no_clr
:1;
815 unsigned int htcp_no_purge_clr
:1;
816 unsigned int htcp_only_clr
:1;
817 unsigned int htcp_forward_clr
:1;
819 unsigned int no_netdb_exchange
:1;
821 unsigned int no_delay
:1;
823 unsigned int allow_miss
:1;
826 unsigned int set
:1; //If false, whole url is to be used. Overrides others
827 unsigned int scheme
:1;
831 unsigned int params
:1;
834 unsigned int userhash
:1;
836 unsigned int sourcehash
:1;
837 unsigned int originserver
:1;
838 unsigned int no_tproxy
:1;
839 #if PEER_MULTICAST_SIBLINGS
840 unsigned int mcast_siblings
:1;
848 double avg_n_members
;
850 int n_replies_expected
;
855 unsigned int count_event_pending
:1;
856 unsigned int counting
:1;
859 #if USE_CACHE_DIGESTS
865 int tcp_up
; /* 0 if a connect() fails */
867 Ip::Address addresses
[10];
875 double load_multiplier
;
876 double load_factor
; /* normalized weight value */
881 double load_multiplier
;
882 double load_factor
; /* normalized weight value */
887 double load_multiplier
;
888 double load_factor
; /* normalized weight value */
891 char *login
; /* Proxy authorization */
892 time_t connect_timeout
;
893 int connect_fail_limit
;
895 char *domain
; /* Forced domain */
910 SSL_SESSION
*sslSession
;
917 struct _net_db_name
{
918 hash_link hash
; /* must be first */
920 netdbEntry
*net_db_entry
;
923 struct _net_db_peer
{
924 const char *peername
;
931 hash_link hash
; /* must be first */
932 char network
[MAX_IPSTRLEN
];
937 time_t next_ping_time
;
938 time_t last_use_time
;
948 enum { histSize
= 16 };
953 int read_hist
[histSize
];
955 int write_hist
[histSize
];
962 struct request_flags
{
963 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) {
964 #if USE_HTTP_VIOLATIONS
967 #if FOLLOW_X_FORWARDED_FOR
968 done_follow_x_forwarded_for
= 0;
969 #endif /* FOLLOW_X_FORWARDED_FOR */
972 unsigned int range
:1;
973 unsigned int nocache
:1; ///< whether the response to this request may be READ from cache
976 unsigned int cachable
:1; ///< whether the response to thie request may be stored in the cache
977 unsigned int hierarchical
:1;
978 unsigned int loopdetect
:1;
979 unsigned int proxy_keepalive
:1;
980 unsigned int proxying
:
981 1; /* this should be killed, also in httpstateflags */
982 unsigned int refresh
:1;
983 unsigned int redirected
:1;
984 unsigned int need_validation
:1;
985 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
986 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
987 #if USE_HTTP_VIOLATIONS
988 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
990 unsigned int accelerated
:1;
991 unsigned int ignore_cc
:1;
992 unsigned int intercepted
:1; ///< intercepted request
993 unsigned int hostVerified
:1; ///< whether the Host: header passed verification
994 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
995 unsigned int internal
:1;
996 unsigned int internalclient
:1;
997 unsigned int must_keepalive
:1;
998 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
999 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
1000 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
1001 unsigned int pinned
:1; /* Request sent on a pinned connection */
1002 unsigned int canRePin
:1; ///< OK to reopen a failed pinned connection
1003 unsigned int auth_sent
:1; /* Authentication forwarded */
1004 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1005 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
1006 unsigned int stream_error
:1; /**< Whether stream error has occured */
1007 unsigned int sslPeek
:1; ///< internal ssl-bump request to get server cert
1008 unsigned int sslBumped
:1; /**< ssl-bumped request*/
1010 // When adding new flags, please update cloneAdaptationImmune() as needed.
1012 bool resetTCP() const;
1014 void clearResetTCP();
1015 void destinationIPLookupCompleted();
1016 bool destinationIPLookedUp() const;
1018 // returns a partial copy of the flags that includes only those flags
1019 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1020 request_flags
cloneAdaptationImmune() const;
1022 #if FOLLOW_X_FORWARDED_FOR
1023 unsigned int done_follow_x_forwarded_for
;
1024 #endif /* FOLLOW_X_FORWARDED_FOR */
1027 unsigned int reset_tcp
:1;
1028 unsigned int destinationIPLookedUp_
:1;
1034 struct _link_list
*next
;
1037 struct _cachemgr_passwd
{
1040 cachemgr_passwd
*next
;
1044 const char *pattern
;
1045 regex_t compiled_pattern
;
1052 unsigned int icase
:1;
1053 unsigned int refresh_ims
:1;
1054 unsigned int store_stale
:1;
1055 #if USE_HTTP_VIOLATIONS
1056 unsigned int override_expire
:1;
1057 unsigned int override_lastmod
:1;
1058 unsigned int reload_into_ims
:1;
1059 unsigned int ignore_reload
:1;
1060 unsigned int ignore_no_cache
:1;
1061 unsigned int ignore_no_store
:1;
1062 unsigned int ignore_must_revalidate
:1;
1063 unsigned int ignore_private
:1;
1064 unsigned int ignore_auth
:1;
1071 struct _CacheDigest
{
1072 /* public, read-only */
1073 char *mask
; /* bit mask */
1074 int mask_size
; /* mask size in bytes */
1075 int capacity
; /* expected maximum for .count, not a hard limit */
1076 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
1077 int count
; /* number of digested entries */
1078 int del_count
; /* number of deletions performed so far */
1082 struct _store_rebuild_data
{
1083 int objcount
; /* # objects successfully reloaded */
1084 int expcount
; /* # objects expired */
1085 int scancount
; /* # entries scanned or read from state file */
1086 int clashcount
; /* # swapfile clashes avoided */
1087 int dupcount
; /* # duplicates purged */
1088 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
1089 int invalid
; /* # bad lines */
1090 int badflags
; /* # bad e->flags */
1096 struct _sslproxy_cert_sign
{
1099 sslproxy_cert_sign
*next
;
1102 struct _sslproxy_cert_adapt
{
1106 sslproxy_cert_adapt
*next
;
1112 #include "format/Format.h"
1113 #include "log/Formats.h"
1117 Format::Format
*logFormat
;
1120 Log::Format::log_type type
;
1123 #endif /* SQUID_STRUCTS_H */