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"
41 #include "icp_opcode.h"
44 #include <openssl/ssl.h>
47 #define PEER_MULTICAST_SIBLINGS 1
49 struct acl_name_list
{
50 char name
[ACL_NAME_SZ
];
54 struct acl_deny_info_list
{
57 acl_name_list
*acl_list
;
58 acl_deny_info_list
*next
;
64 struct _header_mangler
{
65 acl_access
*access_list
;
73 struct _snmp_request_t
{
84 ACLChecklist
*acl_checklist
;
87 struct snmp_session session
;
132 #include "DelayConfig.h"
133 #include "ClientDelayConfig.h"
137 #include "icmp/IcmpConfig.h"
140 #include "HelperChildConfig.h"
142 /* forward decl for SquidConfig, see RemovalPolicy.h */
144 class CpuAffinityMap
;
145 class RemovalPolicySettings
;
153 /// Used for boolean enabled/disabled options with complex default logic.
154 /// Allows Squid to compute the right default after configuration.
155 /// Checks that not-yet-defined option values are not used.
158 // TODO: generalize to non-boolean option types
160 YesNoNone(): option(0) {}
162 /// returns true iff enabled; asserts if the option has not been configured
163 operator void *() const; // TODO: use a fancy/safer version of the operator
165 /// enables or disables the option;
166 void configure(bool beSet
);
168 /// whether the option was enabled or disabled, by user or Squid
169 bool configured() const { return option
!= 0; }
172 enum { optUnspecified
= -1, optDisabled
= 0, optEnabled
= 1 };
173 int option
; ///< configured value or zero
179 /* These should be for the Store::Root instance.
180 * this needs pluggable parsing to be done smoothly.
186 YesNoNone memShared
; ///< whether the memory cache is shared among workers
194 int64_t readAheadGap
;
195 RemovalPolicySettings
*replPolicy
;
196 RemovalPolicySettings
*memPolicy
;
197 #if USE_HTTP_VIOLATIONS
201 time_t negativeDnsTtl
;
202 time_t positiveDnsTtl
;
203 time_t shutdownLifetime
;
204 time_t backgroundPingRate
;
214 time_t clientIdlePconn
;
215 time_t serverIdlePconn
;
218 int icp_query
; /* msec */
219 int icp_query_max
; /* msec */
220 int icp_query_min
; /* msec */
221 int mcast_icp_query
; /* msec */
224 time_msec_t idns_retransmit
;
225 time_msec_t idns_query
;
229 size_t maxRequestHeaderSize
;
230 int64_t maxRequestBodySize
;
231 int64_t maxChunkedRequestBodySize
;
232 size_t maxRequestBufferSize
;
233 size_t maxReplyHeaderSize
;
234 acl_size_t
*ReplyBodySize
;
251 AnyP::PortCfg
*https
;
272 Ip::Address_list
*router
;
274 int forwarding_method
;
276 int assignment_method
;
287 char *as_whois_server
;
292 customlog
*accesslogs
;
302 char *visible_appname_string
;
303 char *effectiveGroup
;
324 HelperChildConfig dnsChildren
;
327 HelperChildConfig redirectChildren
;
328 time_t authenticateGCInterval
;
329 time_t authenticateTTL
;
330 time_t authenticateIpTTL
;
336 size_t appendDomainLen
;
339 char *mimeTablePathname
;
341 char *visibleHostname
;
342 char *uniqueHostname
;
343 wordlist
*hostnameAliases
;
355 Ip::Address udp_incoming
;
356 Ip::Address udp_outgoing
;
358 Ip::Address snmp_incoming
;
359 Ip::Address snmp_outgoing
;
361 /* FIXME INET6 : this should really be a CIDR value */
362 Ip::Address client_netmask
;
365 size_t udpMaxHitObjsz
;
366 wordlist
*hierarchy_stoplist
;
367 wordlist
*mcast_group_list
;
368 wordlist
*dns_nameservers
;
383 cachemgr_passwd
*passwd_list
;
386 int objectsPerBucket
;
387 int64_t avgObjectSize
;
388 int64_t maxObjectSize
;
389 int64_t minObjectSize
;
390 size_t maxInMemObjSize
;
412 int test_reachability
;
413 int half_closed_clients
;
415 #if USE_HTTP_VIOLATIONS
421 int redir_rewrites_host
;
423 int nonhierarchical_direct
;
424 int strip_query_terms
;
425 int redirector_bypass
;
426 int ignore_unknown_nameservers
;
430 #if USE_CACHE_DIGESTS
432 int digest_generation
;
436 int vary_ignore_expire
;
437 int pipeline_prefetch
;
438 int surrogate_is_remote
;
439 int request_entities
;
440 int detect_broken_server_pconns
;
441 int balance_on_multiple_ip
;
442 int relaxed_header_parser
;
444 int allow_underscore
;
447 int httpd_suppress_version_string
;
448 int global_internal_static
;
450 #if FOLLOW_X_FORWARDED_FOR
451 int acl_uses_indirect_client
;
452 int delay_pool_uses_indirect_client
;
453 int log_uses_indirect_client
;
455 int tproxy_uses_indirect_client
;
457 #endif /* FOLLOW_X_FORWARDED_FOR */
459 int WIN32_IpAddrChangeMonitor
;
460 int memory_cache_first
;
461 int memory_cache_disk
;
462 int hostStrictVerify
;
463 int client_dst_passthru
;
466 int forward_max_tries
;
473 acl_access
*adapted_http
;
476 acl_access
*NeverDirect
;
477 acl_access
*AlwaysDirect
;
485 #if USE_HTTP_VIOLATIONS
486 acl_access
*brokenPosts
;
488 acl_access
*redirector
;
490 acl_address
*outgoing_address
;
494 acl_access
*htcp_clr
;
498 acl_access
*ssl_bump
;
500 #if FOLLOW_X_FORWARDED_FOR
501 acl_access
*followXFF
;
502 #endif /* FOLLOW_X_FORWARDED_FOR */
508 acl_deny_info_list
*denyInfoList
;
524 RefCount
<SwapDir
> *swapDirs
;
527 /// number of disk processes required to support all cache_dirs
531 * I'm sick of having to keep doing this ..
533 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
539 char *errorDirectory
;
541 char *errorDefaultLanguage
;
542 int errorLogMissingLanguages
;
544 char *errorStylesheet
;
556 ClientDelayConfig ClientDelay
;
565 int max_open_disk_fds
;
567 acl_size_t
*rangeOffsetLimit
;
568 #if MULTICAST_MISS_STREAM
579 /* one access list per header type we know of */
580 header_mangler request_header_access
[HDR_ENUM_END
];
581 /* one access list per header type we know of */
582 header_mangler reply_header_access
[HDR_ENUM_END
];
585 #if USE_CACHE_DIGESTS
589 time_t rebuild_period
;
590 time_t rewrite_period
;
591 size_t swapout_chunk_size
;
592 int rebuild_chunk_percentage
;
598 int unclean_shutdown
;
603 wordlist
*ext_methods
;
610 char *store_dir_select_algorithm
;
611 int sleep_after_fork
; /* microseconds */
612 time_t minimum_expiry_time
; /* seconds */
613 external_acl
*externalAclHelperList
;
627 acl_access
*cert_error
;
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 struct _close_handler
{
690 void *wrt_handle_data
;
692 dwrite_q
*write_q_tail
;
697 /* per field statistics */
699 class HttpHeaderFieldStat
703 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
705 int aliveCount
; /* created but not destroyed (count) */
706 int seenCount
; /* #fields we've seen */
707 int parsCount
; /* #parsing attempts */
708 int errCount
; /* #pasring errors */
709 int repCount
; /* #repetitons */
712 /* compiled version of HttpHeaderFieldAttrs plus stats */
713 #include "SquidString.h"
715 class HttpHeaderFieldInfo
719 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
724 HttpHeaderFieldStat stat
;
727 struct _http_state_flags
{
728 unsigned int proxying
:1;
729 unsigned int keepalive
:1;
730 unsigned int only_if_cached
:1;
731 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
732 unsigned int headers_parsed
:1;
733 unsigned int front_end_https
:2;
734 unsigned int originpeer
:1;
735 unsigned int keepalive_broken
:1;
736 unsigned int abuse_detected
:1;
737 unsigned int request_sent
:1;
738 unsigned int do_next_read
:1;
739 unsigned int consume_body_data
:1;
740 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
741 unsigned int chunked_request
:1; ///< writing a chunked request
742 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
745 struct _domain_ping
{
747 int do_ping
; /* boolean */
751 struct _domain_type
{
773 int n_keepalives_sent
;
774 int n_keepalives_recv
;
778 time_t last_connect_failure
;
779 time_t last_connect_probe
;
780 int logged_state
; /* so we can print dead/revived msgs */
781 int conn_open
; /* current opened connections */
786 int counts
[ICP_END
+1];
798 unsigned short http_port
;
799 domain_ping
*peer_domain
;
800 domain_type
*typelist
;
804 unsigned int proxy_only
:1;
805 unsigned int no_query
:1;
806 unsigned int background_ping
:1;
807 unsigned int no_digest
:1;
808 unsigned int default_parent
:1;
809 unsigned int roundrobin
:1;
810 unsigned int weighted_roundrobin
:1;
811 unsigned int mcast_responder
:1;
812 unsigned int closest_only
:1;
815 unsigned int htcp_oldsquid
:1;
816 unsigned int htcp_no_clr
:1;
817 unsigned int htcp_no_purge_clr
:1;
818 unsigned int htcp_only_clr
:1;
819 unsigned int htcp_forward_clr
:1;
821 unsigned int no_netdb_exchange
:1;
823 unsigned int no_delay
:1;
825 unsigned int allow_miss
:1;
828 unsigned int set
:1; //If false, whole url is to be used. Overrides others
829 unsigned int scheme
:1;
833 unsigned int params
:1;
836 unsigned int userhash
:1;
838 unsigned int sourcehash
:1;
839 unsigned int originserver
:1;
840 unsigned int no_tproxy
:1;
841 #if PEER_MULTICAST_SIBLINGS
842 unsigned int mcast_siblings
:1;
850 double avg_n_members
;
852 int n_replies_expected
;
857 unsigned int count_event_pending
:1;
858 unsigned int counting
:1;
861 #if USE_CACHE_DIGESTS
867 int tcp_up
; /* 0 if a connect() fails */
869 Ip::Address addresses
[10];
877 double load_multiplier
;
878 double load_factor
; /* normalized weight value */
883 double load_multiplier
;
884 double load_factor
; /* normalized weight value */
889 double load_multiplier
;
890 double load_factor
; /* normalized weight value */
893 char *login
; /* Proxy authorization */
894 time_t connect_timeout
;
895 int connect_fail_limit
;
897 char *domain
; /* Forced domain */
912 SSL_SESSION
*sslSession
;
919 struct _net_db_name
{
920 hash_link hash
; /* must be first */
922 netdbEntry
*net_db_entry
;
925 struct _net_db_peer
{
926 const char *peername
;
933 hash_link hash
; /* must be first */
934 char network
[MAX_IPSTRLEN
];
939 time_t next_ping_time
;
940 time_t last_use_time
;
950 enum { histSize
= 16 };
955 int read_hist
[histSize
];
957 int write_hist
[histSize
];
964 struct request_flags
{
965 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),
967 spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),chunked_reply(0),stream_error(0),sslBumped(0),destinationIPLookedUp_(0) {
968 #if USE_HTTP_VIOLATIONS
971 #if FOLLOW_X_FORWARDED_FOR
972 done_follow_x_forwarded_for
= 0;
973 #endif /* FOLLOW_X_FORWARDED_FOR */
976 unsigned int range
:1;
977 unsigned int nocache
:1; ///< whether the response to this request may be READ from cache
980 unsigned int cachable
:1; ///< whether the response to thie request may be stored in the cache
981 unsigned int hierarchical
:1;
982 unsigned int loopdetect
:1;
983 unsigned int proxy_keepalive
:1;
984 unsigned int proxying
:
985 1; /* this should be killed, also in httpstateflags */
986 unsigned int refresh
:1;
987 unsigned int redirected
:1;
988 unsigned int need_validation
:1;
989 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
990 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
991 #if USE_HTTP_VIOLATIONS
992 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
994 unsigned int accelerated
:1;
995 unsigned int ignore_cc
:1;
996 unsigned int intercepted
:1; ///< intercepted request
997 unsigned int hostVerified
:1; ///< whether the Host: header passed verification
998 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
999 unsigned int internal
:1;
1000 unsigned int internalclient
:1;
1001 unsigned int must_keepalive
:1;
1002 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
1003 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
1004 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
1005 unsigned int pinned
:1; /* Request sent on a pinned connection */
1006 unsigned int auth_sent
:1; /* Authentication forwarded */
1007 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1008 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
1009 unsigned int stream_error
:1; /**< Whether stream error has occured */
1010 unsigned int sslBumped
:1; /**< ssl-bumped request*/
1012 // When adding new flags, please update cloneAdaptationImmune() as needed.
1014 bool resetTCP() const;
1016 void clearResetTCP();
1017 void destinationIPLookupCompleted();
1018 bool destinationIPLookedUp() const;
1020 // returns a partial copy of the flags that includes only those flags
1021 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1022 request_flags
cloneAdaptationImmune() const;
1024 #if FOLLOW_X_FORWARDED_FOR
1025 unsigned int done_follow_x_forwarded_for
;
1026 #endif /* FOLLOW_X_FORWARDED_FOR */
1029 unsigned int reset_tcp
:1;
1030 unsigned int destinationIPLookedUp_
:1;
1036 struct _link_list
*next
;
1039 struct _cachemgr_passwd
{
1042 cachemgr_passwd
*next
;
1046 const char *pattern
;
1047 regex_t compiled_pattern
;
1054 unsigned int icase
:1;
1055 unsigned int refresh_ims
:1;
1056 unsigned int store_stale
:1;
1057 #if USE_HTTP_VIOLATIONS
1058 unsigned int override_expire
:1;
1059 unsigned int override_lastmod
:1;
1060 unsigned int reload_into_ims
:1;
1061 unsigned int ignore_reload
:1;
1062 unsigned int ignore_no_cache
:1;
1063 unsigned int ignore_no_store
:1;
1064 unsigned int ignore_must_revalidate
:1;
1065 unsigned int ignore_private
:1;
1066 unsigned int ignore_auth
:1;
1073 struct _CacheDigest
{
1074 /* public, read-only */
1075 char *mask
; /* bit mask */
1076 int mask_size
; /* mask size in bytes */
1077 int capacity
; /* expected maximum for .count, not a hard limit */
1078 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
1079 int count
; /* number of digested entries */
1080 int del_count
; /* number of deletions performed so far */
1084 struct _store_rebuild_data
{
1085 int objcount
; /* # objects successfully reloaded */
1086 int expcount
; /* # objects expired */
1087 int scancount
; /* # entries scanned or read from state file */
1088 int clashcount
; /* # swapfile clashes avoided */
1089 int dupcount
; /* # duplicates purged */
1090 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
1091 int invalid
; /* # bad lines */
1092 int badflags
; /* # bad e->flags */
1099 #include "format/Format.h"
1100 #include "log/Formats.h"
1104 Format::Format
*logFormat
;
1107 Log::Format::log_type type
;
1110 #endif /* SQUID_STRUCTS_H */