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
;
152 /* These should be for the Store::Root instance.
153 * this needs pluggable parsing to be done smoothly.
165 int64_t readAheadGap
;
166 RemovalPolicySettings
*replPolicy
;
167 RemovalPolicySettings
*memPolicy
;
168 #if USE_HTTP_VIOLATIONS
172 time_t negativeDnsTtl
;
173 time_t positiveDnsTtl
;
174 time_t shutdownLifetime
;
175 time_t backgroundPingRate
;
185 time_t persistent_request
;
189 int icp_query
; /* msec */
190 int icp_query_max
; /* msec */
191 int icp_query_min
; /* msec */
192 int mcast_icp_query
; /* msec */
196 time_msec_t idns_retransmit
;
197 time_msec_t idns_query
;
201 size_t maxRequestHeaderSize
;
202 int64_t maxRequestBodySize
;
203 int64_t maxChunkedRequestBodySize
;
204 size_t maxRequestBufferSize
;
205 size_t maxReplyHeaderSize
;
206 acl_size_t
*ReplyBodySize
;
221 http_port_list
*http
;
224 https_port_list
*https
;
246 Ip::Address_list
*router
;
248 int forwarding_method
;
250 int assignment_method
;
261 char *as_whois_server
;
266 customlog
*accesslogs
;
276 char *visible_appname_string
;
277 char *effectiveGroup
;
299 HelperChildConfig dnsChildren
;
302 HelperChildConfig redirectChildren
;
303 time_t authenticateGCInterval
;
304 time_t authenticateTTL
;
305 time_t authenticateIpTTL
;
311 size_t appendDomainLen
;
314 char *mimeTablePathname
;
316 char *visibleHostname
;
317 char *uniqueHostname
;
318 wordlist
*hostnameAliases
;
330 Ip::Address udp_incoming
;
331 Ip::Address udp_outgoing
;
333 Ip::Address snmp_incoming
;
334 Ip::Address snmp_outgoing
;
336 /* FIXME INET6 : this should really be a CIDR value */
337 Ip::Address client_netmask
;
340 size_t udpMaxHitObjsz
;
341 wordlist
*hierarchy_stoplist
;
342 wordlist
*mcast_group_list
;
343 wordlist
*dns_nameservers
;
358 cachemgr_passwd
*passwd_list
;
361 int objectsPerBucket
;
362 int64_t avgObjectSize
;
363 int64_t maxObjectSize
;
364 int64_t minObjectSize
;
365 size_t maxInMemObjSize
;
387 int test_reachability
;
388 int half_closed_clients
;
390 #if USE_HTTP_VIOLATIONS
396 int redir_rewrites_host
;
398 int nonhierarchical_direct
;
399 int strip_query_terms
;
400 int redirector_bypass
;
401 int ignore_unknown_nameservers
;
405 #if USE_CACHE_DIGESTS
407 int digest_generation
;
410 int log_ip_on_direct
;
412 int vary_ignore_expire
;
413 int pipeline_prefetch
;
414 int surrogate_is_remote
;
415 int request_entities
;
416 int detect_broken_server_pconns
;
417 int balance_on_multiple_ip
;
418 int relaxed_header_parser
;
420 int allow_underscore
;
423 int httpd_suppress_version_string
;
424 int global_internal_static
;
427 #if FOLLOW_X_FORWARDED_FOR
428 int acl_uses_indirect_client
;
429 int delay_pool_uses_indirect_client
;
430 int log_uses_indirect_client
;
432 int tproxy_uses_indirect_client
;
434 #endif /* FOLLOW_X_FORWARDED_FOR */
436 int WIN32_IpAddrChangeMonitor
;
437 int memory_cache_first
;
438 int memory_cache_disk
;
441 int forward_max_tries
;
448 acl_access
*adapted_http
;
451 acl_access
*NeverDirect
;
452 acl_access
*AlwaysDirect
;
460 #if USE_HTTP_VIOLATIONS
461 acl_access
*brokenPosts
;
463 acl_access
*redirector
;
465 acl_address
*outgoing_address
;
469 acl_access
*htcp_clr
;
473 acl_access
*ssl_bump
;
475 #if FOLLOW_X_FORWARDED_FOR
476 acl_access
*followXFF
;
477 #endif /* FOLLOW_X_FORWARDED_FOR */
483 acl_deny_info_list
*denyInfoList
;
499 RefCount
<class Store
> *swapDirs
;
504 * I'm sick of having to keep doing this ..
506 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
512 char *errorDirectory
;
514 char *errorDefaultLanguage
;
515 int errorLogMissingLanguages
;
517 char *errorStylesheet
;
529 ClientDelayConfig ClientDelay
;
540 int max_open_disk_fds
;
542 acl_size_t
*rangeOffsetLimit
;
543 #if MULTICAST_MISS_STREAM
554 /* one access list per header type we know of */
555 header_mangler request_header_access
[HDR_ENUM_END
];
556 /* one access list per header type we know of */
557 header_mangler reply_header_access
[HDR_ENUM_END
];
560 #if USE_CACHE_DIGESTS
564 time_t rebuild_period
;
565 time_t rewrite_period
;
566 size_t swapout_chunk_size
;
567 int rebuild_chunk_percentage
;
573 int unclean_shutdown
;
578 wordlist
*ext_methods
;
585 char *store_dir_select_algorithm
;
586 int sleep_after_fork
; /* microseconds */
587 time_t minimum_expiry_time
; /* seconds */
588 external_acl
*externalAclHelperList
;
602 acl_access
*cert_error
;
609 int max_filedescriptors
;
611 CpuAffinityMap
*cpuAffinityMap
;
613 #if USE_LOADABLE_MODULES
614 wordlist
*loadable_module_names
;
617 int client_ip_max_connections
;
620 ssize_t packet_max
; ///< maximum size EDNS advertised for DNS replies.
624 SQUIDCEXTERN SquidConfig Config
;
626 struct SquidConfig2
{
629 int mangle_request_headers
;
631 uid_t effectiveUserID
;
632 gid_t effectiveGroupID
;
635 SQUIDCEXTERN SquidConfig2 Config2
;
637 struct _close_handler
{
663 /* ETag support is rudimantal;
664 * this struct is likely to change
665 * Note: "str" points to memory in HttpHeaderEntry (for now)
666 * so ETags should be used as tmp variables only (for now) */
669 const char *str
; /* quoted-string */
670 int weak
; /* true if it is a weak validator */
675 void *wrt_handle_data
;
677 dwrite_q
*write_q_tail
;
686 unsigned long *file_map
;
690 * Note: HttpBody is used only for messages with a small content that is
691 * known a priory (e.g., error messages).
701 #include "SquidString.h"
702 /* http header extention field */
704 class HttpHdrExtField
706 String name
; /* field-name from HTTP/1.1 (no column after name) */
707 String value
; /* field-value from HTTP/1.1 */
710 /* http cache control header field */
725 /* some fields can hold either time or etag specs (e.g. If-Range) */
728 ETag tag
; /* entity tag */
730 int valid
; /* true if struct is usable */
733 /* per field statistics */
735 class HttpHeaderFieldStat
739 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
741 int aliveCount
; /* created but not destroyed (count) */
742 int seenCount
; /* #fields we've seen */
743 int parsCount
; /* #parsing attempts */
744 int errCount
; /* #pasring errors */
745 int repCount
; /* #repetitons */
748 /* compiled version of HttpHeaderFieldAttrs plus stats */
750 class HttpHeaderFieldInfo
754 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
759 HttpHeaderFieldStat stat
;
762 struct _http_state_flags
{
763 unsigned int proxying
:1;
764 unsigned int keepalive
:1;
765 unsigned int only_if_cached
:1;
766 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
767 unsigned int headers_parsed
:1;
768 unsigned int front_end_https
:2;
769 unsigned int originpeer
:1;
770 unsigned int keepalive_broken
:1;
771 unsigned int abuse_detected
:1;
772 unsigned int request_sent
:1;
773 unsigned int do_next_read
:1;
774 unsigned int consume_body_data
:1;
775 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
776 unsigned int chunked_request
:1; ///< writing a chunked request
777 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
780 struct _domain_ping
{
782 int do_ping
; /* boolean */
786 struct _domain_type
{
792 #if USE_CACHE_DIGESTS
794 /* statistics for cache digests and other hit "predictors" */
796 struct _cd_guess_stats
{
797 /* public, read-only */
802 int close_hits
; /* tmp, remove it later */
823 int n_keepalives_sent
;
824 int n_keepalives_recv
;
828 time_t last_connect_failure
;
829 time_t last_connect_probe
;
830 int logged_state
; /* so we can print dead/revived msgs */
831 int conn_open
; /* current opened connections */
836 int counts
[ICP_END
+1];
849 domain_ping
*peer_domain
;
850 domain_type
*typelist
;
854 unsigned int proxy_only
:1;
855 unsigned int no_query
:1;
856 unsigned int background_ping
:1;
857 unsigned int no_digest
:1;
858 unsigned int default_parent
:1;
859 unsigned int roundrobin
:1;
860 unsigned int weighted_roundrobin
:1;
861 unsigned int mcast_responder
:1;
862 unsigned int closest_only
:1;
865 unsigned int htcp_oldsquid
:1;
866 unsigned int htcp_no_clr
:1;
867 unsigned int htcp_no_purge_clr
:1;
868 unsigned int htcp_only_clr
:1;
869 unsigned int htcp_forward_clr
:1;
871 unsigned int no_netdb_exchange
:1;
873 unsigned int no_delay
:1;
875 unsigned int allow_miss
:1;
878 unsigned int userhash
:1;
880 unsigned int sourcehash
:1;
881 unsigned int originserver
:1;
882 unsigned int no_tproxy
:1;
883 #if PEER_MULTICAST_SIBLINGS
884 unsigned int mcast_siblings
:1;
892 double avg_n_members
;
894 int n_replies_expected
;
899 unsigned int count_event_pending
:1;
900 unsigned int counting
:1;
903 #if USE_CACHE_DIGESTS
909 int tcp_up
; /* 0 if a connect() fails */
911 Ip::Address addresses
[10];
919 double load_multiplier
;
920 double load_factor
; /* normalized weight value */
925 double load_multiplier
;
926 double load_factor
; /* normalized weight value */
931 double load_multiplier
;
932 double load_factor
; /* normalized weight value */
935 char *login
; /* Proxy authorization */
936 time_t connect_timeout
;
937 int connect_fail_limit
;
939 char *domain
; /* Forced domain */
954 SSL_SESSION
*sslSession
;
961 struct _net_db_name
{
962 hash_link hash
; /* must be first */
964 netdbEntry
*net_db_entry
;
967 struct _net_db_peer
{
968 const char *peername
;
975 hash_link hash
; /* must be first */
976 char network
[MAX_IPSTRLEN
];
981 time_t next_ping_time
;
982 time_t last_use_time
;
992 enum { histSize
= 16 };
997 int read_hist
[histSize
];
999 int write_hist
[histSize
];
1006 struct request_flags
{
1007 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),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),chunked_reply(0),stream_error(0),sslBumped(0),destinationIPLookedUp_(0) {
1008 #if USE_HTTP_VIOLATIONS
1011 #if FOLLOW_X_FORWARDED_FOR
1012 done_follow_x_forwarded_for
= 0;
1013 #endif /* FOLLOW_X_FORWARDED_FOR */
1016 unsigned int range
:1;
1017 unsigned int nocache
:1;
1019 unsigned int auth
:1;
1020 unsigned int cachable
:1;
1021 unsigned int hierarchical
:1;
1022 unsigned int loopdetect
:1;
1023 unsigned int proxy_keepalive
:1;
1024 unsigned int proxying
:
1025 1; /* this should be killed, also in httpstateflags */
1026 unsigned int refresh
:1;
1027 unsigned int redirected
:1;
1028 unsigned int need_validation
:1;
1029 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
1030 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
1031 #if USE_HTTP_VIOLATIONS
1032 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
1034 unsigned int accelerated
:1;
1035 unsigned int ignore_cc
:1;
1036 unsigned int intercepted
:1; /**< transparently intercepted request */
1037 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
1038 unsigned int internal
:1;
1039 unsigned int internalclient
:1;
1040 unsigned int must_keepalive
:1;
1041 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
1042 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
1043 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
1044 unsigned int pinned
:1; /* Request sent on a pinned connection */
1045 unsigned int auth_sent
:1; /* Authentication forwarded */
1046 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1047 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
1048 unsigned int stream_error
:1; /**< Whether stream error has occured */
1049 unsigned int sslBumped
:1; /**< ssl-bumped request*/
1051 // When adding new flags, please update cloneAdaptationImmune() as needed.
1053 bool resetTCP() const;
1055 void clearResetTCP();
1056 void destinationIPLookupCompleted();
1057 bool destinationIPLookedUp() const;
1059 // returns a partial copy of the flags that includes only those flags
1060 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1061 request_flags
cloneAdaptationImmune() const;
1063 #if FOLLOW_X_FORWARDED_FOR
1064 unsigned int done_follow_x_forwarded_for
;
1065 #endif /* FOLLOW_X_FORWARDED_FOR */
1068 unsigned int reset_tcp
:1;
1069 unsigned int destinationIPLookedUp_
:1;
1075 struct _link_list
*next
;
1078 struct _cachemgr_passwd
{
1081 cachemgr_passwd
*next
;
1085 const char *pattern
;
1086 regex_t compiled_pattern
;
1093 unsigned int icase
:1;
1094 unsigned int refresh_ims
:1;
1095 unsigned int store_stale
:1;
1096 #if USE_HTTP_VIOLATIONS
1097 unsigned int override_expire
:1;
1098 unsigned int override_lastmod
:1;
1099 unsigned int reload_into_ims
:1;
1100 unsigned int ignore_reload
:1;
1101 unsigned int ignore_no_cache
:1;
1102 unsigned int ignore_no_store
:1;
1103 unsigned int ignore_must_revalidate
:1;
1104 unsigned int ignore_private
:1;
1105 unsigned int ignore_auth
:1;
1112 * "very generic" histogram;
1113 * see important comments on hbase_f restrictions in StatHist.c
1122 hbase_f
*val_in
; /* e.g., log() for log-based histogram */
1123 hbase_f
*val_out
; /* e.g., exp() for log based histogram */
1127 * if you add a field to StatCounters,
1128 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1131 struct _StatCounters
{
1142 kb_t hit_kbytes_out
;
1143 StatHist miss_svc_time
;
1144 StatHist nm_svc_time
;
1145 StatHist nh_svc_time
;
1146 StatHist hit_svc_time
;
1147 StatHist all_svc_time
;
1157 } all
, http
, ftp
, other
;
1170 int replies_dropped
;
1177 StatHist query_svc_time
;
1178 StatHist reply_svc_time
;
1203 #if USE_CACHE_DIGESTS
1205 cd_guess_stats guess
;
1208 StatHist on_xition_count
;
1215 unsigned long int select_loops
;
1220 struct timeval timestamp
;
1221 StatHist comm_icp_incoming
;
1222 StatHist comm_dns_incoming
;
1223 StatHist comm_http_incoming
;
1224 StatHist select_fds_hist
;
1249 int aborted_requests
;
1258 /* per header statistics */
1260 struct _HttpHeaderStat
{
1262 HttpHeaderMask
*owner_mask
;
1264 StatHist hdrUCountDistr
;
1265 StatHist fieldTypeDistr
;
1266 StatHist ccTypeDistr
;
1267 StatHist scTypeDistr
;
1273 int busyDestroyedCount
;
1277 struct _CacheDigest
{
1278 /* public, read-only */
1279 char *mask
; /* bit mask */
1280 int mask_size
; /* mask size in bytes */
1281 int capacity
; /* expected maximum for .count, not a hard limit */
1282 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
1283 int count
; /* number of digested entries */
1284 int del_count
; /* number of deletions performed so far */
1288 struct _store_rebuild_data
{
1289 int objcount
; /* # objects successfully reloaded */
1290 int expcount
; /* # objects expired */
1291 int scancount
; /* # entries scanned or read from state file */
1292 int clashcount
; /* # swapfile clashes avoided */
1293 int dupcount
; /* # duplicates purged */
1294 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
1295 int invalid
; /* # bad lines */
1296 int badflags
; /* # bad e->flags */
1304 #include "log/Formats.h"
1308 logformat
*logFormat
;
1311 Log::Format::log_type type
;
1314 #endif /* SQUID_STRUCTS_H */