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"
43 #define PEER_MULTICAST_SIBLINGS 1
45 struct acl_name_list
{
46 char name
[ACL_NAME_SZ
];
50 struct acl_deny_info_list
{
53 acl_name_list
*acl_list
;
54 acl_deny_info_list
*next
;
60 struct _header_mangler
{
61 acl_access
*access_list
;
69 struct _snmp_request_t
{
80 ACLChecklist
*acl_checklist
;
83 struct snmp_session session
;
127 #include "DelayConfig.h"
128 #include "ClientDelayConfig.h"
132 #include "icmp/IcmpConfig.h"
135 #include "HelperChildConfig.h"
137 /* forward decl for SquidConfig, see RemovalPolicy.h */
139 class CpuAffinityMap
;
140 class RemovalPolicySettings
;
147 /* These should be for the Store::Root instance.
148 * this needs pluggable parsing to be done smoothly.
160 int64_t readAheadGap
;
161 RemovalPolicySettings
*replPolicy
;
162 RemovalPolicySettings
*memPolicy
;
163 #if USE_HTTP_VIOLATIONS
166 time_t negativeDnsTtl
;
167 time_t positiveDnsTtl
;
168 time_t shutdownLifetime
;
169 time_t backgroundPingRate
;
179 time_t persistent_request
;
183 int icp_query
; /* msec */
184 int icp_query_max
; /* msec */
185 int icp_query_min
; /* msec */
186 int mcast_icp_query
; /* msec */
190 time_t idns_retransmit
;
195 size_t maxRequestHeaderSize
;
196 int64_t maxRequestBodySize
;
197 int64_t maxChunkedRequestBodySize
;
198 size_t maxReplyHeaderSize
;
199 acl_size_t
*ReplyBodySize
;
214 http_port_list
*http
;
217 https_port_list
*https
;
239 Ip::Address_list
*router
;
241 int forwarding_method
;
243 int assignment_method
;
254 char *as_whois_server
;
259 #if USE_USERAGENT_LOG
272 logformat
*logformats
;
274 customlog
*accesslogs
;
286 char *visible_appname_string
;
287 char *effectiveGroup
;
309 HelperChildConfig dnsChildren
;
312 HelperChildConfig redirectChildren
;
313 time_t authenticateGCInterval
;
314 time_t authenticateTTL
;
315 time_t authenticateIpTTL
;
321 size_t appendDomainLen
;
324 char *mimeTablePathname
;
326 char *visibleHostname
;
327 char *uniqueHostname
;
328 wordlist
*hostnameAliases
;
340 Ip::Address udp_incoming
;
341 Ip::Address udp_outgoing
;
343 Ip::Address snmp_incoming
;
344 Ip::Address snmp_outgoing
;
346 /* FIXME INET6 : this should really be a CIDR value */
347 Ip::Address client_netmask
;
350 size_t udpMaxHitObjsz
;
351 wordlist
*hierarchy_stoplist
;
352 wordlist
*mcast_group_list
;
353 wordlist
*dns_nameservers
;
368 cachemgr_passwd
*passwd_list
;
371 int objectsPerBucket
;
372 int64_t avgObjectSize
;
373 int64_t maxObjectSize
;
374 int64_t minObjectSize
;
375 size_t maxInMemObjSize
;
397 int test_reachability
;
398 int half_closed_clients
;
400 #if USE_HTTP_VIOLATIONS
406 int redir_rewrites_host
;
408 int nonhierarchical_direct
;
409 int strip_query_terms
;
410 int redirector_bypass
;
411 int ignore_unknown_nameservers
;
415 #if USE_CACHE_DIGESTS
417 int digest_generation
;
420 int log_ip_on_direct
;
422 int vary_ignore_expire
;
423 int pipeline_prefetch
;
424 int surrogate_is_remote
;
425 int request_entities
;
426 int detect_broken_server_pconns
;
427 int balance_on_multiple_ip
;
428 int relaxed_header_parser
;
430 int allow_underscore
;
433 int httpd_suppress_version_string
;
434 int global_internal_static
;
437 #if FOLLOW_X_FORWARDED_FOR
438 int acl_uses_indirect_client
;
439 int delay_pool_uses_indirect_client
;
440 int log_uses_indirect_client
;
442 int tproxy_uses_indirect_client
;
444 #endif /* FOLLOW_X_FORWARDED_FOR */
446 int WIN32_IpAddrChangeMonitor
;
447 int memory_cache_first
;
448 int memory_cache_disk
;
451 int forward_max_tries
;
457 acl_access
*adapted_http
;
460 acl_access
*NeverDirect
;
461 acl_access
*AlwaysDirect
;
469 #if USE_HTTP_VIOLATIONS
470 acl_access
*brokenPosts
;
472 acl_access
*redirector
;
474 acl_address
*outgoing_address
;
478 acl_access
*htcp_clr
;
482 acl_access
*ssl_bump
;
484 #if FOLLOW_X_FORWARDED_FOR
485 acl_access
*followXFF
;
486 #endif /* FOLLOW_X_FORWARDED_FOR */
492 acl_deny_info_list
*denyInfoList
;
507 RefCount
<class Store
> *swapDirs
;
512 * I'm sick of having to keep doing this ..
514 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
520 char *errorDirectory
;
522 char *errorDefaultLanguage
;
523 int errorLogMissingLanguages
;
525 char *errorStylesheet
;
538 ClientDelayConfig ClientDelay
;
549 int max_open_disk_fds
;
551 acl_size_t
*rangeOffsetLimit
;
552 #if MULTICAST_MISS_STREAM
563 /* one access list per header type we know of */
564 header_mangler request_header_access
[HDR_ENUM_END
];
565 /* one access list per header type we know of */
566 header_mangler reply_header_access
[HDR_ENUM_END
];
569 #if USE_CACHE_DIGESTS
573 time_t rebuild_period
;
574 time_t rewrite_period
;
575 size_t swapout_chunk_size
;
576 int rebuild_chunk_percentage
;
582 int unclean_shutdown
;
587 wordlist
*ext_methods
;
594 char *store_dir_select_algorithm
;
595 int sleep_after_fork
; /* microseconds */
596 time_t minimum_expiry_time
; /* seconds */
597 external_acl
*externalAclHelperList
;
611 acl_access
*cert_error
;
618 int max_filedescriptors
;
620 CpuAffinityMap
*cpuAffinityMap
;
622 #if USE_LOADABLE_MODULES
623 wordlist
*loadable_module_names
;
626 int client_ip_max_connections
;
629 ssize_t packet_max
; ///< maximum size EDNS advertised for DNS replies.
633 SQUIDCEXTERN SquidConfig Config
;
635 struct SquidConfig2
{
638 int mangle_request_headers
;
640 uid_t effectiveUserID
;
641 gid_t effectiveGroupID
;
644 SQUIDCEXTERN SquidConfig2 Config2
;
646 struct _close_handler
{
672 /* ETag support is rudimantal;
673 * this struct is likely to change
674 * Note: "str" points to memory in HttpHeaderEntry (for now)
675 * so ETags should be used as tmp variables only (for now) */
678 const char *str
; /* quoted-string */
679 int weak
; /* true if it is a weak validator */
684 void *wrt_handle_data
;
686 dwrite_q
*write_q_tail
;
695 unsigned long *file_map
;
699 * Note: HttpBody is used only for messages with a small content that is
700 * known a priory (e.g., error messages).
710 #include "SquidString.h"
711 /* http header extention field */
713 class HttpHdrExtField
715 String name
; /* field-name from HTTP/1.1 (no column after name) */
716 String value
; /* field-value from HTTP/1.1 */
719 /* http cache control header field */
733 /* some fields can hold either time or etag specs (e.g. If-Range) */
736 ETag tag
; /* entity tag */
738 int valid
; /* true if struct is usable */
741 /* per field statistics */
743 class HttpHeaderFieldStat
747 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
749 int aliveCount
; /* created but not destroyed (count) */
750 int seenCount
; /* #fields we've seen */
751 int parsCount
; /* #parsing attempts */
752 int errCount
; /* #pasring errors */
753 int repCount
; /* #repetitons */
756 /* compiled version of HttpHeaderFieldAttrs plus stats */
758 class HttpHeaderFieldInfo
762 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
) {}
767 HttpHeaderFieldStat stat
;
770 struct _http_state_flags
{
771 unsigned int proxying
:1;
772 unsigned int keepalive
:1;
773 unsigned int only_if_cached
:1;
774 unsigned int handling1xx
:1; ///< we are ignoring or forwarding 1xx response
775 unsigned int headers_parsed
:1;
776 unsigned int front_end_https
:2;
777 unsigned int originpeer
:1;
778 unsigned int keepalive_broken
:1;
779 unsigned int abuse_detected
:1;
780 unsigned int request_sent
:1;
781 unsigned int do_next_read
:1;
782 unsigned int consume_body_data
:1;
783 unsigned int chunked
:1; ///< reading a chunked response; TODO: rename
784 unsigned int chunked_request
:1; ///< writing a chunked request
785 unsigned int sentLastChunk
:1; ///< do not try to write last-chunk again
788 struct _ipcache_addrs
{
789 Ip::Address
*in_addrs
;
790 unsigned char *bad_mask
;
793 unsigned char badcount
;
796 struct _domain_ping
{
798 int do_ping
; /* boolean */
802 struct _domain_type
{
808 #if USE_CACHE_DIGESTS
810 /* statistics for cache digests and other hit "predictors" */
812 struct _cd_guess_stats
{
813 /* public, read-only */
818 int close_hits
; /* tmp, remove it later */
839 int n_keepalives_sent
;
840 int n_keepalives_recv
;
844 time_t last_connect_failure
;
845 time_t last_connect_probe
;
846 int logged_state
; /* so we can print dead/revived msgs */
847 int conn_open
; /* current opened connections */
852 int counts
[ICP_END
+1];
865 domain_ping
*peer_domain
;
866 domain_type
*typelist
;
870 unsigned int proxy_only
:1;
871 unsigned int no_query
:1;
872 unsigned int background_ping
:1;
873 unsigned int no_digest
:1;
874 unsigned int default_parent
:1;
875 unsigned int roundrobin
:1;
876 unsigned int weighted_roundrobin
:1;
877 unsigned int mcast_responder
:1;
878 unsigned int closest_only
:1;
881 unsigned int htcp_oldsquid
:1;
882 unsigned int htcp_no_clr
:1;
883 unsigned int htcp_no_purge_clr
:1;
884 unsigned int htcp_only_clr
:1;
885 unsigned int htcp_forward_clr
:1;
887 unsigned int no_netdb_exchange
:1;
889 unsigned int no_delay
:1;
891 unsigned int allow_miss
:1;
893 unsigned int userhash
:1;
894 unsigned int sourcehash
:1;
895 unsigned int originserver
:1;
896 unsigned int no_tproxy
:1;
897 #if PEER_MULTICAST_SIBLINGS
898 unsigned int mcast_siblings
:1;
906 double avg_n_members
;
908 int n_replies_expected
;
913 unsigned int count_event_pending
:1;
914 unsigned int counting
:1;
917 #if USE_CACHE_DIGESTS
923 int tcp_up
; /* 0 if a connect() fails */
925 Ip::Address addresses
[10];
933 double load_multiplier
;
934 double load_factor
; /* normalized weight value */
939 double load_multiplier
;
940 double load_factor
; /* normalized weight value */
945 double load_multiplier
;
946 double load_factor
; /* normalized weight value */
949 char *login
; /* Proxy authorization */
950 time_t connect_timeout
;
951 int connect_fail_limit
;
953 char *domain
; /* Forced domain */
968 SSL_SESSION
*sslSession
;
975 struct _net_db_name
{
976 hash_link hash
; /* must be first */
978 netdbEntry
*net_db_entry
;
981 struct _net_db_peer
{
982 const char *peername
;
989 hash_link hash
; /* must be first */
990 char network
[MAX_IPSTRLEN
];
995 time_t next_ping_time
;
996 time_t last_use_time
;
1006 enum { histSize
= 16 };
1011 int read_hist
[histSize
];
1013 int write_hist
[histSize
];
1020 struct request_flags
{
1021 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),destinationIPLookedUp_(0) {
1022 #if USE_HTTP_VIOLATIONS
1025 #if FOLLOW_X_FORWARDED_FOR
1026 done_follow_x_forwarded_for
= 0;
1027 #endif /* FOLLOW_X_FORWARDED_FOR */
1030 unsigned int range
:1;
1031 unsigned int nocache
:1;
1033 unsigned int auth
:1;
1034 unsigned int cachable
:1;
1035 unsigned int hierarchical
:1;
1036 unsigned int loopdetect
:1;
1037 unsigned int proxy_keepalive
:1;
1038 unsigned int proxying
:
1039 1; /* this should be killed, also in httpstateflags */
1040 unsigned int refresh
:1;
1041 unsigned int redirected
:1;
1042 unsigned int need_validation
:1;
1043 unsigned int fail_on_validation_err
:1; ///< whether we should fail if validation fails
1044 unsigned int stale_if_hit
:1; ///< reply is stale if it is a hit
1045 #if USE_HTTP_VIOLATIONS
1046 unsigned int nocache_hack
:1; /* for changing/ignoring no-cache requests */
1048 unsigned int accelerated
:1;
1049 unsigned int ignore_cc
:1;
1050 unsigned int intercepted
:1; /**< transparently intercepted request */
1051 unsigned int spoof_client_ip
:1; /**< spoof client ip if possible */
1052 unsigned int internal
:1;
1053 unsigned int internalclient
:1;
1054 unsigned int must_keepalive
:1;
1055 unsigned int connection_auth
:1; /** Request wants connection oriented auth */
1056 unsigned int connection_auth_disabled
:1; /** Connection oriented auth can not be supported */
1057 unsigned int connection_proxy_auth
:1; /** Request wants connection oriented auth */
1058 unsigned int pinned
:1; /* Request sent on a pinned connection */
1059 unsigned int auth_sent
:1; /* Authentication forwarded */
1060 unsigned int no_direct
:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1061 unsigned int chunked_reply
:1; /**< Reply with chunked transfer encoding */
1062 unsigned int stream_error
:1; /**< Whether stream error has occured */
1064 // When adding new flags, please update cloneAdaptationImmune() as needed.
1066 bool resetTCP() const;
1068 void clearResetTCP();
1069 void destinationIPLookupCompleted();
1070 bool destinationIPLookedUp() const;
1072 // returns a partial copy of the flags that includes only those flags
1073 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1074 request_flags
cloneAdaptationImmune() const;
1076 #if FOLLOW_X_FORWARDED_FOR
1077 unsigned int done_follow_x_forwarded_for
;
1078 #endif /* FOLLOW_X_FORWARDED_FOR */
1081 unsigned int reset_tcp
:1;
1082 unsigned int destinationIPLookedUp_
:1;
1088 struct _link_list
*next
;
1091 struct _cachemgr_passwd
{
1094 cachemgr_passwd
*next
;
1098 const char *pattern
;
1099 regex_t compiled_pattern
;
1106 unsigned int icase
:1;
1107 unsigned int refresh_ims
:1;
1108 unsigned int store_stale
:1;
1109 #if USE_HTTP_VIOLATIONS
1110 unsigned int override_expire
:1;
1111 unsigned int override_lastmod
:1;
1112 unsigned int reload_into_ims
:1;
1113 unsigned int ignore_reload
:1;
1114 unsigned int ignore_no_cache
:1;
1115 unsigned int ignore_no_store
:1;
1116 unsigned int ignore_must_revalidate
:1;
1117 unsigned int ignore_private
:1;
1118 unsigned int ignore_auth
:1;
1124 * "very generic" histogram;
1125 * see important comments on hbase_f restrictions in StatHist.c
1134 hbase_f
*val_in
; /* e.g., log() for log-based histogram */
1135 hbase_f
*val_out
; /* e.g., exp() for log based histogram */
1139 * if you add a field to StatCounters,
1140 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1143 struct _StatCounters
{
1154 kb_t hit_kbytes_out
;
1155 StatHist miss_svc_time
;
1156 StatHist nm_svc_time
;
1157 StatHist nh_svc_time
;
1158 StatHist hit_svc_time
;
1159 StatHist all_svc_time
;
1169 } all
, http
, ftp
, other
;
1182 int replies_dropped
;
1189 StatHist query_svc_time
;
1190 StatHist reply_svc_time
;
1215 #if USE_CACHE_DIGESTS
1217 cd_guess_stats guess
;
1220 StatHist on_xition_count
;
1227 unsigned long int select_loops
;
1232 struct timeval timestamp
;
1233 StatHist comm_icp_incoming
;
1234 StatHist comm_dns_incoming
;
1235 StatHist comm_http_incoming
;
1236 StatHist select_fds_hist
;
1261 int aborted_requests
;
1270 /* per header statistics */
1272 struct _HttpHeaderStat
{
1274 HttpHeaderMask
*owner_mask
;
1276 StatHist hdrUCountDistr
;
1277 StatHist fieldTypeDistr
;
1278 StatHist ccTypeDistr
;
1279 StatHist scTypeDistr
;
1285 int busyDestroyedCount
;
1289 struct _CacheDigest
{
1290 /* public, read-only */
1291 char *mask
; /* bit mask */
1292 int mask_size
; /* mask size in bytes */
1293 int capacity
; /* expected maximum for .count, not a hard limit */
1294 int bits_per_entry
; /* number of bits allocated for each entry from capacity */
1295 int count
; /* number of digested entries */
1296 int del_count
; /* number of deletions performed so far */
1300 struct _store_rebuild_data
{
1301 int objcount
; /* # objects successfully reloaded */
1302 int expcount
; /* # objects expired */
1303 int scancount
; /* # entries scanned or read from state file */
1304 int clashcount
; /* # swapfile clashes avoided */
1305 int dupcount
; /* # duplicates purged */
1306 int cancelcount
; /* # SWAP_LOG_DEL objects purged */
1307 int invalid
; /* # bad lines */
1308 int badflags
; /* # bad e->flags */
1313 class logformat_token
;
1317 logformat_token
*format
;
1326 logformat
*logFormat
;
1329 customlog_type type
;
1332 #endif /* SQUID_STRUCTS_H */