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 /// Used for boolean enabled/disabled options with complex default logic.
150 /// Allows Squid to compute the right default after configuration.
151 /// Checks that not-yet-defined option values are not used.
154 // TODO: generalize to non-boolean option types
156 YesNoNone(): option(0) {}
158 /// returns true iff enabled; asserts if the option has not been configured
159 operator void *() const; // TODO: use a fancy/safer version of the operator
161 /// enables or disables the option;
162 void configure(bool beSet
);
164 /// whether the option was enabled or disabled, by user or Squid
165 bool configured() const { return option
!= 0; }
168 enum { optUnspecified
= -1, optDisabled
= 0, optEnabled
= 1 };
169 int option
; ///< configured value or zero
175 /* These should be for the Store::Root instance.
176 * this needs pluggable parsing to be done smoothly.
182 YesNoNone memShared
; ///< whether the memory cache is shared among workers
190 int64_t readAheadGap
;
191 RemovalPolicySettings
*replPolicy
;
192 RemovalPolicySettings
*memPolicy
;
193 #if USE_HTTP_VIOLATIONS
197 time_t negativeDnsTtl
;
198 time_t positiveDnsTtl
;
199 time_t shutdownLifetime
;
200 time_t backgroundPingRate
;
210 time_t clientIdlePconn
;
211 time_t serverIdlePconn
;
214 int icp_query
; /* msec */
215 int icp_query_max
; /* msec */
216 int icp_query_min
; /* msec */
217 int mcast_icp_query
; /* msec */
220 time_msec_t idns_retransmit
;
221 time_msec_t idns_query
;
225 size_t maxRequestHeaderSize
;
226 int64_t maxRequestBodySize
;
227 int64_t maxChunkedRequestBodySize
;
228 size_t maxRequestBufferSize
;
229 size_t maxReplyHeaderSize
;
230 acl_size_t
*ReplyBodySize
;
247 AnyP::PortCfg
*https
;
268 Ip::Address_list
*router
;
270 int forwarding_method
;
272 int assignment_method
;
283 char *as_whois_server
;
288 customlog
*accesslogs
;
298 char *visible_appname_string
;
299 char *effectiveGroup
;
320 HelperChildConfig dnsChildren
;
323 HelperChildConfig redirectChildren
;
324 time_t authenticateGCInterval
;
325 time_t authenticateTTL
;
326 time_t authenticateIpTTL
;
332 size_t appendDomainLen
;
335 char *mimeTablePathname
;
337 char *visibleHostname
;
338 char *uniqueHostname
;
339 wordlist
*hostnameAliases
;
351 Ip::Address udp_incoming
;
352 Ip::Address udp_outgoing
;
354 Ip::Address snmp_incoming
;
355 Ip::Address snmp_outgoing
;
357 /* FIXME INET6 : this should really be a CIDR value */
358 Ip::Address client_netmask
;
361 size_t udpMaxHitObjsz
;
362 wordlist
*hierarchy_stoplist
;
363 wordlist
*mcast_group_list
;
364 wordlist
*dns_nameservers
;
379 cachemgr_passwd
*passwd_list
;
382 int objectsPerBucket
;
383 int64_t avgObjectSize
;
384 int64_t maxObjectSize
;
385 int64_t minObjectSize
;
386 size_t maxInMemObjSize
;
408 int test_reachability
;
409 int half_closed_clients
;
411 #if USE_HTTP_VIOLATIONS
417 int redir_rewrites_host
;
419 int nonhierarchical_direct
;
420 int strip_query_terms
;
421 int redirector_bypass
;
422 int ignore_unknown_nameservers
;
426 #if USE_CACHE_DIGESTS
428 int digest_generation
;
432 int vary_ignore_expire
;
433 int pipeline_prefetch
;
434 int surrogate_is_remote
;
435 int request_entities
;
436 int detect_broken_server_pconns
;
437 int balance_on_multiple_ip
;
438 int relaxed_header_parser
;
440 int allow_underscore
;
443 int httpd_suppress_version_string
;
444 int global_internal_static
;
446 #if FOLLOW_X_FORWARDED_FOR
447 int acl_uses_indirect_client
;
448 int delay_pool_uses_indirect_client
;
449 int log_uses_indirect_client
;
451 int tproxy_uses_indirect_client
;
453 #endif /* FOLLOW_X_FORWARDED_FOR */
455 int WIN32_IpAddrChangeMonitor
;
456 int memory_cache_first
;
457 int memory_cache_disk
;
458 int hostStrictVerify
;
459 int client_dst_passthru
;
462 int forward_max_tries
;
469 acl_access
*adapted_http
;
472 acl_access
*NeverDirect
;
473 acl_access
*AlwaysDirect
;
481 #if USE_HTTP_VIOLATIONS
482 acl_access
*brokenPosts
;
484 acl_access
*redirector
;
486 acl_address
*outgoing_address
;
490 acl_access
*htcp_clr
;
494 acl_access
*ssl_bump
;
496 #if FOLLOW_X_FORWARDED_FOR
497 acl_access
*followXFF
;
498 #endif /* FOLLOW_X_FORWARDED_FOR */
504 acl_deny_info_list
*denyInfoList
;
520 RefCount
<SwapDir
> *swapDirs
;
523 /// number of disk processes required to support all cache_dirs
527 * I'm sick of having to keep doing this ..
529 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
535 char *errorDirectory
;
537 char *errorDefaultLanguage
;
538 int errorLogMissingLanguages
;
540 char *errorStylesheet
;
552 ClientDelayConfig ClientDelay
;
561 int max_open_disk_fds
;
563 acl_size_t
*rangeOffsetLimit
;
564 #if MULTICAST_MISS_STREAM
575 /// request_header_access and request_header_replace
576 HeaderManglers
*request_header_access
;
577 /// reply_header_access and reply_header_replace
578 HeaderManglers
*reply_header_access
;
579 ///request_header_add access list
580 HeaderWithAclList
*request_header_add
;
583 #if USE_CACHE_DIGESTS
587 time_t rebuild_period
;
588 time_t rewrite_period
;
589 size_t swapout_chunk_size
;
590 int rebuild_chunk_percentage
;
596 int unclean_shutdown
;
601 wordlist
*ext_methods
;
608 char *store_dir_select_algorithm
;
609 int sleep_after_fork
; /* microseconds */
610 time_t minimum_expiry_time
; /* seconds */
611 external_acl
*externalAclHelperList
;
625 acl_access
*cert_error
;
627 sslproxy_cert_sign
*cert_sign
;
628 sslproxy_cert_adapt
*cert_adapt
;
634 int max_filedescriptors
;
636 CpuAffinityMap
*cpuAffinityMap
;
638 #if USE_LOADABLE_MODULES
639 wordlist
*loadable_module_names
;
642 int client_ip_max_connections
;
645 int v4_first
; ///< Place IPv4 first in the order of DNS results.
646 ssize_t packet_max
; ///< maximum size EDNS advertised for DNS replies.
650 SQUIDCEXTERN SquidConfig Config
;
652 struct SquidConfig2
{
655 int mangle_request_headers
;
657 uid_t effectiveUserID
;
658 gid_t effectiveGroupID
;
661 SQUIDCEXTERN SquidConfig2 Config2
;
663 class close_handler
{
693 void *wrt_handle_data
;
695 dwrite_q
*write_q_tail
;
699 /* per field statistics */
701 class HttpHeaderFieldStat
705 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
707 int aliveCount
; /* created but not destroyed (count) */
708 int seenCount
; /* #fields we've seen */
709 int parsCount
; /* #parsing attempts */
710 int errCount
; /* #pasring errors */
711 int repCount
; /* #repetitons */
714 /* compiled version of HttpHeaderFieldAttrs plus stats */
715 #include "SquidString.h"
717 class HttpHeaderFieldInfo
721 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
726 HttpHeaderFieldStat stat
;
729 class http_state_flags
{
731 unsigned int proxying
:1;
732 unsigned int keepalive
:1;
733 unsigned int only_if_cached
:1;
734 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
735 unsigned int headers_parsed
:1;
736 unsigned int front_end_https
:2;
737 unsigned int originpeer
:1;
738 unsigned int keepalive_broken
:1;
739 unsigned int abuse_detected
:1;
740 unsigned int request_sent
:1;
741 unsigned int do_next_read
:1;
742 unsigned int consume_body_data
:1;
743 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
744 unsigned int chunked_request
:1; ///< writing a chunked request
745 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
751 int do_ping
; /* boolean */
778 int n_keepalives_sent
;
779 int n_keepalives_recv
;
783 time_t last_connect_failure
;
784 time_t last_connect_probe
;
785 int logged_state
; /* so we can print dead/revived msgs */
786 int conn_open
; /* current opened connections */
791 int counts
[ICP_END
+1];
803 unsigned short http_port
;
804 domain_ping
*peer_domain
;
805 domain_type
*typelist
;
809 unsigned int proxy_only
:1;
810 unsigned int no_query
:1;
811 unsigned int background_ping
:1;
812 unsigned int no_digest
:1;
813 unsigned int default_parent
:1;
814 unsigned int roundrobin
:1;
815 unsigned int weighted_roundrobin
:1;
816 unsigned int mcast_responder
:1;
817 unsigned int closest_only
:1;
820 unsigned int htcp_oldsquid
:1;
821 unsigned int htcp_no_clr
:1;
822 unsigned int htcp_no_purge_clr
:1;
823 unsigned int htcp_only_clr
:1;
824 unsigned int htcp_forward_clr
:1;
826 unsigned int no_netdb_exchange
:1;
828 unsigned int no_delay
:1;
830 unsigned int allow_miss
:1;
833 unsigned int set
:1; //If false, whole url is to be used. Overrides others
834 unsigned int scheme
:1;
838 unsigned int params
:1;
841 unsigned int userhash
:1;
843 unsigned int sourcehash
:1;
844 unsigned int originserver
:1;
845 unsigned int no_tproxy
:1;
846 #if PEER_MULTICAST_SIBLINGS
847 unsigned int mcast_siblings
:1;
855 double avg_n_members
;
857 int n_replies_expected
;
862 unsigned int count_event_pending
:1;
863 unsigned int counting
:1;
866 #if USE_CACHE_DIGESTS
872 int tcp_up
; /* 0 if a connect() fails */
874 Ip::Address addresses
[10];
882 double load_multiplier
;
883 double load_factor
; /* normalized weight value */
888 double load_multiplier
;
889 double load_factor
; /* normalized weight value */
894 double load_multiplier
;
895 double load_factor
; /* normalized weight value */
898 char *login
; /* Proxy authorization */
899 time_t connect_timeout
;
900 int connect_fail_limit
;
902 char *domain
; /* Forced domain */
917 SSL_SESSION
*sslSession
;
928 hash_link hash
; /* must be first */
930 netdbEntry
*net_db_entry
;
935 const char *peername
;
943 hash_link hash
; /* must be first */
944 char network
[MAX_IPSTRLEN
];
949 time_t next_ping_time
;
950 time_t last_use_time
;
960 static const int histSize
=16;
962 // enum { histSize = 16 };
967 int read_hist
[histSize
];
969 int write_hist
[histSize
];
975 struct request_flags
{
976 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) {
977 #if USE_HTTP_VIOLATIONS
980 #if FOLLOW_X_FORWARDED_FOR
981 done_follow_x_forwarded_for
= 0;
982 #endif /* FOLLOW_X_FORWARDED_FOR */
985 unsigned int range
:1;
986 unsigned int nocache
:1; ///< whether the response to this request may be READ from cache
989 unsigned int cachable
:1; ///< whether the response to thie request may be stored in the cache
990 unsigned int hierarchical
:1;
991 unsigned int loopdetect
:1;
992 unsigned int proxy_keepalive
:1;
993 unsigned int proxying
:
994 1; /* this should be killed, also in httpstateflags */
995 unsigned int refresh
:1;
996 unsigned int redirected
:1;
997 unsigned int need_validation
:1;
998 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
999 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
1000 #if USE_HTTP_VIOLATIONS
1001 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
1003 unsigned int accelerated
:1;
1004 unsigned int ignore_cc
:1;
1005 unsigned int intercepted
:1; ///< intercepted request
1006 unsigned int hostVerified
:1; ///< whether the Host: header passed verification
1007 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
1008 unsigned int internal
:1;
1009 unsigned int internalclient
:1;
1010 unsigned int must_keepalive
:1;
1011 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
1012 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
1013 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
1014 unsigned int pinned
:1; /* Request sent on a pinned connection */
1015 unsigned int canRePin
:1; ///< OK to reopen a failed pinned connection
1016 unsigned int auth_sent
:1; /* Authentication forwarded */
1017 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1018 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
1019 unsigned int stream_error
:1; /**< Whether stream error has occured */
1020 unsigned int sslPeek
:1; ///< internal ssl-bump request to get server cert
1021 unsigned int sslBumped
:1; /**< ssl-bumped request*/
1023 // When adding new flags, please update cloneAdaptationImmune() as needed.
1025 bool resetTCP() const;
1027 void clearResetTCP();
1028 void destinationIPLookupCompleted();
1029 bool destinationIPLookedUp() const;
1031 // returns a partial copy of the flags that includes only those flags
1032 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1033 request_flags
cloneAdaptationImmune() const;
1035 #if FOLLOW_X_FORWARDED_FOR
1036 unsigned int done_follow_x_forwarded_for
;
1037 #endif /* FOLLOW_X_FORWARDED_FOR */
1040 unsigned int reset_tcp
:1;
1041 unsigned int destinationIPLookedUp_
:1;
1045 class cachemgr_passwd
{
1049 cachemgr_passwd
*next
;
1054 const char *pattern
;
1055 regex_t compiled_pattern
;
1062 unsigned int icase
:1;
1063 unsigned int refresh_ims
:1;
1064 unsigned int store_stale
:1;
1065 #if USE_HTTP_VIOLATIONS
1066 unsigned int override_expire
:1;
1067 unsigned int override_lastmod
:1;
1068 unsigned int reload_into_ims
:1;
1069 unsigned int ignore_reload
:1;
1070 unsigned int ignore_no_cache
:1;
1071 unsigned int ignore_no_store
:1;
1072 unsigned int ignore_must_revalidate
:1;
1073 unsigned int ignore_private
:1;
1074 unsigned int ignore_auth
:1;
1082 /* public, read-only */
1083 char *mask
; /* bit mask */
1084 int mask_size
; /* mask size in bytes */
1085 int capacity
; /* expected maximum for .count, not a hard limit */
1086 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
1087 int count
; /* number of digested entries */
1088 int del_count
; /* number of deletions performed so far */
1091 struct _store_rebuild_data
{
1092 int objcount
; /* # objects successfully reloaded */
1093 int expcount
; /* # objects expired */
1094 int scancount
; /* # entries scanned or read from state file */
1095 int clashcount
; /* # swapfile clashes avoided */
1096 int dupcount
; /* # duplicates purged */
1097 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
1098 int invalid
; /* # bad lines */
1099 int badflags
; /* # bad e->flags */
1105 struct _sslproxy_cert_sign
{
1108 sslproxy_cert_sign
*next
;
1111 struct _sslproxy_cert_adapt
{
1115 sslproxy_cert_adapt
*next
;
1121 #include "format/Format.h"
1122 #include "log/Formats.h"
1127 Format::Format
*logFormat
;
1130 Log::Format::log_type type
;
1133 #endif /* SQUID_STRUCTS_H */