]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
Added disk_io_timeout to squid.conf to control approximately how long Squid
[thirdparty/squid.git] / src / structs.h
1 /*
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
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.
13 *
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.
18 *
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.
23 *
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.
27 *
28 */
29 #ifndef SQUID_STRUCTS_H
30 #define SQUID_STRUCTS_H
31
32 #include "RefCount.h"
33 #include "cbdata.h"
34 #include "dlink.h"
35 #include "err_type.h"
36
37 /* needed for the global config */
38 #include "HttpHeader.h"
39
40 /* for ICP_END */
41 #include "icp_opcode.h"
42
43 #if USE_SSL
44 #include <openssl/ssl.h>
45 #endif
46
47 #define PEER_MULTICAST_SIBLINGS 1
48
49 struct acl_name_list {
50 char name[ACL_NAME_SZ];
51 acl_name_list *next;
52 };
53
54 struct acl_deny_info_list {
55 err_type err_page_id;
56 char *err_page_name;
57 acl_name_list *acl_list;
58 acl_deny_info_list *next;
59 };
60
61
62 class acl_access;
63
64 struct _header_mangler {
65 acl_access *access_list;
66 char *replacement;
67 };
68
69 class ACLChecklist;
70
71 #if SQUID_SNMP
72
73 struct _snmp_request_t {
74 u_char *buf;
75 u_char *outbuf;
76 int len;
77 int sock;
78 long reqid;
79 int outlen;
80
81 Ip::Address from;
82
83 struct snmp_pdu *PDU;
84 ACLChecklist *acl_checklist;
85 u_char *community;
86
87 struct snmp_session session;
88 };
89
90 #endif
91
92 class ACLList;
93
94 struct acl_address {
95 acl_address *next;
96 ACLList *aclList;
97
98 Ip::Address addr;
99 };
100
101 struct acl_tos {
102 acl_tos *next;
103 ACLList *aclList;
104 tos_t tos;
105 };
106
107 struct acl_nfmark {
108 acl_nfmark *next;
109 ACLList *aclList;
110 nfmark_t nfmark;
111 };
112
113 struct acl_size_t {
114 acl_size_t *next;
115 ACLList *aclList;
116 int64_t size;
117 };
118
119 struct ushortlist {
120 u_short i;
121 ushortlist *next;
122 };
123
124 struct relist {
125 int flags;
126 char *pattern;
127 regex_t regex;
128 relist *next;
129 };
130
131 #if USE_DELAY_POOLS
132 #include "DelayConfig.h"
133 #include "ClientDelayConfig.h"
134 #endif
135
136 #if USE_ICMP
137 #include "icmp/IcmpConfig.h"
138 #endif
139
140 #include "HelperChildConfig.h"
141
142 /* forward decl for SquidConfig, see RemovalPolicy.h */
143
144 class CpuAffinityMap;
145 class RemovalPolicySettings;
146 class external_acl;
147 class SwapDir;
148
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.
152 class YesNoNone {
153 // TODO: generalize to non-boolean option types
154 public:
155 YesNoNone();
156
157 /// returns true iff enabled; asserts if the option has not been configured
158 operator void *() const; // TODO: use a fancy/safer version of the operator
159
160 /// enables or disables the option;
161 void configure(bool beSet);
162
163 /// whether the option was enabled or disabled, by user or Squid
164 bool configured() const { return option != 0; }
165
166 private:
167 enum { optUnspecified = -1, optDisabled = 0, optEnabled = 1 };
168 int option; ///< configured value or zero
169 };
170
171 struct SquidConfig {
172
173 struct {
174 /* These should be for the Store::Root instance.
175 * this needs pluggable parsing to be done smoothly.
176 */
177 int highWaterMark;
178 int lowWaterMark;
179 } Swap;
180
181 YesNoNone memShared; ///< whether the memory cache is shared among workers
182 size_t memMaxSize;
183
184 struct {
185 int64_t min;
186 int pct;
187 int64_t max;
188 } quickAbort;
189 int64_t readAheadGap;
190 RemovalPolicySettings *replPolicy;
191 RemovalPolicySettings *memPolicy;
192 #if USE_HTTP_VIOLATIONS
193 time_t negativeTtl;
194 #endif
195 time_t maxStale;
196 time_t negativeDnsTtl;
197 time_t positiveDnsTtl;
198 time_t shutdownLifetime;
199 time_t backgroundPingRate;
200
201 struct {
202 time_t read;
203 time_t write;
204 time_t lifetime;
205 time_t connect;
206 time_t forward;
207 time_t peer_connect;
208 time_t request;
209 time_t persistent_request;
210 time_t pconn;
211 time_t siteSelect;
212 time_t deadPeer;
213 int icp_query; /* msec */
214 int icp_query_max; /* msec */
215 int icp_query_min; /* msec */
216 int mcast_icp_query; /* msec */
217 time_msec_t disk_io;
218
219 #if !USE_DNSSERVERS
220
221 time_msec_t idns_retransmit;
222 time_msec_t idns_query;
223 #endif
224
225 } Timeout;
226 size_t maxRequestHeaderSize;
227 int64_t maxRequestBodySize;
228 int64_t maxChunkedRequestBodySize;
229 size_t maxRequestBufferSize;
230 size_t maxReplyHeaderSize;
231 acl_size_t *ReplyBodySize;
232
233 struct {
234 u_short icp;
235 #if USE_HTCP
236
237 u_short htcp;
238 #endif
239 #if SQUID_SNMP
240
241 u_short snmp;
242 #endif
243 } Port;
244
245 struct {
246 http_port_list *http;
247 #if USE_SSL
248
249 https_port_list *https;
250 #endif
251
252 } Sockaddr;
253 #if SQUID_SNMP
254
255 struct {
256 char *configFile;
257 char *agentInfo;
258 } Snmp;
259 #endif
260 #if USE_WCCP
261
262 struct {
263 Ip::Address router;
264 Ip::Address address;
265 int version;
266 } Wccp;
267 #endif
268 #if USE_WCCPv2
269
270 struct {
271 Ip::Address_list *router;
272 Ip::Address address;
273 int forwarding_method;
274 int return_method;
275 int assignment_method;
276 int weight;
277 int rebuildwait;
278 void *info;
279 } Wccp2;
280 #endif
281
282 #if USE_ICMP
283 IcmpConfig pinger;
284 #endif
285
286 char *as_whois_server;
287
288 struct {
289 char *store;
290 char *swap;
291 customlog *accesslogs;
292 #if ICAP_CLIENT
293 customlog *icaplogs;
294 #endif
295 int rotateNumber;
296 } Log;
297 char *adminEmail;
298 char *EmailFrom;
299 char *EmailProgram;
300 char *effectiveUser;
301 char *visible_appname_string;
302 char *effectiveGroup;
303
304 struct {
305 #if USE_DNSSERVERS
306 char *dnsserver;
307 #endif
308
309 wordlist *redirect;
310 #if USE_UNLINKD
311
312 char *unlinkd;
313 #endif
314
315 char *diskd;
316 #if USE_SSL
317
318 char *ssl_password;
319 #endif
320
321 } Program;
322 #if USE_DNSSERVERS
323
324 HelperChildConfig dnsChildren;
325 #endif
326
327 HelperChildConfig redirectChildren;
328 time_t authenticateGCInterval;
329 time_t authenticateTTL;
330 time_t authenticateIpTTL;
331
332 struct {
333 char *surrogate_id;
334 } Accel;
335 char *appendDomain;
336 size_t appendDomainLen;
337 char *pidFilename;
338 char *netdbFilename;
339 char *mimeTablePathname;
340 char *etcHostsPath;
341 char *visibleHostname;
342 char *uniqueHostname;
343 wordlist *hostnameAliases;
344 char *errHtmlText;
345
346 struct {
347 char *host;
348 char *file;
349 time_t period;
350 u_short port;
351 } Announce;
352
353 struct {
354
355 Ip::Address udp_incoming;
356 Ip::Address udp_outgoing;
357 #if SQUID_SNMP
358 Ip::Address snmp_incoming;
359 Ip::Address snmp_outgoing;
360 #endif
361 /* FIXME INET6 : this should really be a CIDR value */
362 Ip::Address client_netmask;
363 } Addrs;
364 size_t tcpRcvBufsz;
365 size_t udpMaxHitObjsz;
366 wordlist *hierarchy_stoplist;
367 wordlist *mcast_group_list;
368 wordlist *dns_nameservers;
369 peer *peers;
370 int npeers;
371
372 struct {
373 int size;
374 int low;
375 int high;
376 } ipcache;
377
378 struct {
379 int size;
380 } fqdncache;
381 int minDirectHops;
382 int minDirectRtt;
383 cachemgr_passwd *passwd_list;
384
385 struct {
386 int objectsPerBucket;
387 int64_t avgObjectSize;
388 int64_t maxObjectSize;
389 int64_t minObjectSize;
390 size_t maxInMemObjSize;
391 } Store;
392
393 struct {
394 int high;
395 int low;
396 time_t period;
397 } Netdb;
398
399 struct {
400 int log_udp;
401 int res_defnames;
402 int anonymizer;
403 int client_db;
404 int query_icmp;
405 int icp_hit_stale;
406 int buffered_logs;
407 int common_log;
408 int log_mime_hdrs;
409 int log_fqdn;
410 int announce;
411 int mem_pools;
412 int test_reachability;
413 int half_closed_clients;
414 int refresh_all_ims;
415 #if USE_HTTP_VIOLATIONS
416
417 int reload_into_ims;
418 #endif
419
420 int offline;
421 int redir_rewrites_host;
422 int prefer_direct;
423 int nonhierarchical_direct;
424 int strip_query_terms;
425 int redirector_bypass;
426 int ignore_unknown_nameservers;
427 int client_pconns;
428 int server_pconns;
429 int error_pconns;
430 #if USE_CACHE_DIGESTS
431
432 int digest_generation;
433 #endif
434
435 int log_ip_on_direct;
436 int ie_refresh;
437 int vary_ignore_expire;
438 int pipeline_prefetch;
439 int surrogate_is_remote;
440 int request_entities;
441 int detect_broken_server_pconns;
442 int balance_on_multiple_ip;
443 int relaxed_header_parser;
444 int check_hostnames;
445 int allow_underscore;
446 int via;
447 int emailErrData;
448 int httpd_suppress_version_string;
449 int global_internal_static;
450 int dns_require_A;
451
452 #if FOLLOW_X_FORWARDED_FOR
453 int acl_uses_indirect_client;
454 int delay_pool_uses_indirect_client;
455 int log_uses_indirect_client;
456 #if LINUX_NETFILTER
457 int tproxy_uses_indirect_client;
458 #endif
459 #endif /* FOLLOW_X_FORWARDED_FOR */
460
461 int WIN32_IpAddrChangeMonitor;
462 int memory_cache_first;
463 int memory_cache_disk;
464 } onoff;
465
466 int forward_max_tries;
467
468 class ACL *aclList;
469
470 struct {
471 acl_access *http;
472 acl_access *adapted_http;
473 acl_access *icp;
474 acl_access *miss;
475 acl_access *NeverDirect;
476 acl_access *AlwaysDirect;
477 acl_access *ASlists;
478 acl_access *noCache;
479 acl_access *log;
480 #if SQUID_SNMP
481
482 acl_access *snmp;
483 #endif
484 #if USE_HTTP_VIOLATIONS
485 acl_access *brokenPosts;
486 #endif
487 acl_access *redirector;
488 acl_access *reply;
489 acl_address *outgoing_address;
490 #if USE_HTCP
491
492 acl_access *htcp;
493 acl_access *htcp_clr;
494 #endif
495
496 #if USE_SSL
497 acl_access *ssl_bump;
498 #endif
499 #if FOLLOW_X_FORWARDED_FOR
500 acl_access *followXFF;
501 #endif /* FOLLOW_X_FORWARDED_FOR */
502
503 #if ICAP_CLIENT
504 acl_access* icap;
505 #endif
506 } accessList;
507 acl_deny_info_list *denyInfoList;
508
509 struct {
510 size_t list_width;
511 int list_wrap;
512 char *anon_user;
513 int passive;
514 int epsv_all;
515 int epsv;
516 int eprt;
517 int sanitycheck;
518 int telnet;
519 } Ftp;
520 refresh_t *Refresh;
521
522 struct _cacheSwap {
523 RefCount<SwapDir> *swapDirs;
524 int n_allocated;
525 int n_configured;
526 ///< number of disk processes required to support all cache_dirs
527 int n_strands;
528 } cacheSwap;
529 /*
530 * I'm sick of having to keep doing this ..
531 */
532 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
533
534 struct {
535 char *directory;
536 int use_short_names;
537 } icons;
538 char *errorDirectory;
539 #if USE_ERR_LOCALES
540 char *errorDefaultLanguage;
541 int errorLogMissingLanguages;
542 #endif
543 char *errorStylesheet;
544
545 struct {
546 int maxtries;
547 int onerror;
548 } retry;
549
550 struct {
551 int64_t limit;
552 } MemPools;
553 #if USE_DELAY_POOLS
554
555 DelayConfig Delay;
556 ClientDelayConfig ClientDelay;
557 #endif
558
559 struct {
560 int icp_average;
561 int dns_average;
562 int http_average;
563 int icp_min_poll;
564 int dns_min_poll;
565 int http_min_poll;
566 } comm_incoming;
567 int max_open_disk_fds;
568 int uri_whitespace;
569 acl_size_t *rangeOffsetLimit;
570 #if MULTICAST_MISS_STREAM
571
572 struct {
573
574 Ip::Address addr;
575 int ttl;
576 unsigned short port;
577 char *encode_key;
578 } mcast_miss;
579 #endif
580
581 /* one access list per header type we know of */
582 header_mangler request_header_access[HDR_ENUM_END];
583 /* one access list per header type we know of */
584 header_mangler reply_header_access[HDR_ENUM_END];
585 char *coredump_dir;
586 char *chroot_dir;
587 #if USE_CACHE_DIGESTS
588
589 struct {
590 int bits_per_entry;
591 time_t rebuild_period;
592 time_t rewrite_period;
593 size_t swapout_chunk_size;
594 int rebuild_chunk_percentage;
595 } digest;
596 #endif
597 #if USE_SSL
598
599 struct {
600 int unclean_shutdown;
601 char *ssl_engine;
602 } SSL;
603 #endif
604
605 wordlist *ext_methods;
606
607 struct {
608 int high_rptm;
609 int high_pf;
610 size_t high_memory;
611 } warnings;
612 char *store_dir_select_algorithm;
613 int sleep_after_fork; /* microseconds */
614 time_t minimum_expiry_time; /* seconds */
615 external_acl *externalAclHelperList;
616
617 #if USE_SSL
618
619 struct {
620 char *cert;
621 char *key;
622 int version;
623 char *options;
624 char *cipher;
625 char *cafile;
626 char *capath;
627 char *crlfile;
628 char *flags;
629 acl_access *cert_error;
630 SSL_CTX *sslContext;
631 } ssl_client;
632 #endif
633
634 char *accept_filter;
635 int umask;
636 int max_filedescriptors;
637 int workers;
638 CpuAffinityMap *cpuAffinityMap;
639
640 #if USE_LOADABLE_MODULES
641 wordlist *loadable_module_names;
642 #endif
643
644 int client_ip_max_connections;
645
646 struct {
647 ssize_t packet_max; ///< maximum size EDNS advertised for DNS replies.
648 } dns;
649 };
650
651 SQUIDCEXTERN SquidConfig Config;
652
653 struct SquidConfig2 {
654 struct {
655 int enable_purge;
656 int mangle_request_headers;
657 } onoff;
658 uid_t effectiveUserID;
659 gid_t effectiveGroupID;
660 };
661
662 SQUIDCEXTERN SquidConfig2 Config2;
663
664 struct _close_handler {
665 PF *handler;
666 void *data;
667 close_handler *next;
668 };
669
670 struct _dread_ctrl {
671 int fd;
672 off_t offset;
673 int req_len;
674 char *buf;
675 int end_of_file;
676 DRCB *handler;
677 void *client_data;
678 };
679
680 struct _dwrite_q {
681 off_t file_offset;
682 char *buf;
683 size_t len;
684 size_t buf_offset;
685 dwrite_q *next;
686 FREE *free_func;
687 };
688
689
690 /* ETag support is rudimantal;
691 * this struct is likely to change
692 * Note: "str" points to memory in HttpHeaderEntry (for now)
693 * so ETags should be used as tmp variables only (for now) */
694
695 struct _ETag {
696 const char *str; /* quoted-string */
697 int weak; /* true if it is a weak validator */
698 };
699
700 struct _fde_disk {
701 DWCB *wrt_handle;
702 void *wrt_handle_data;
703 dwrite_q *write_q;
704 dwrite_q *write_q_tail;
705 off_t offset;
706 };
707
708 struct _fileMap {
709 int max_n_files;
710 int n_files_in_map;
711 int toggle;
712 int nwords;
713 unsigned long *file_map;
714 };
715
716 /*
717 * Note: HttpBody is used only for messages with a small content that is
718 * known a priory (e.g., error messages).
719 */
720
721 class MemBuf;
722
723 struct _HttpBody {
724 /* private */
725 MemBuf *mb;
726 };
727
728 #include "SquidString.h"
729 /* http header extention field */
730
731 class HttpHdrExtField
732 {
733 String name; /* field-name from HTTP/1.1 (no column after name) */
734 String value; /* field-value from HTTP/1.1 */
735 };
736
737 /* http cache control header field */
738
739 class HttpHdrCc
740 {
741
742 public:
743 int mask;
744 int max_age;
745 int s_maxage;
746 int max_stale;
747 int stale_if_error;
748 int min_fresh;
749 String other;
750 };
751
752 /* some fields can hold either time or etag specs (e.g. If-Range) */
753
754 struct _TimeOrTag {
755 ETag tag; /* entity tag */
756 time_t time;
757 int valid; /* true if struct is usable */
758 };
759
760 /* per field statistics */
761
762 class HttpHeaderFieldStat
763 {
764
765 public:
766 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
767
768 int aliveCount; /* created but not destroyed (count) */
769 int seenCount; /* #fields we've seen */
770 int parsCount; /* #parsing attempts */
771 int errCount; /* #pasring errors */
772 int repCount; /* #repetitons */
773 };
774
775 /* compiled version of HttpHeaderFieldAttrs plus stats */
776
777 class HttpHeaderFieldInfo
778 {
779
780 public:
781 HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid) {}
782
783 http_hdr_type id;
784 String name;
785 field_type type;
786 HttpHeaderFieldStat stat;
787 };
788
789 struct _http_state_flags {
790 unsigned int proxying:1;
791 unsigned int keepalive:1;
792 unsigned int only_if_cached:1;
793 unsigned int handling1xx:1; ///< we are ignoring or forwarding 1xx response
794 unsigned int headers_parsed:1;
795 unsigned int front_end_https:2;
796 unsigned int originpeer:1;
797 unsigned int keepalive_broken:1;
798 unsigned int abuse_detected:1;
799 unsigned int request_sent:1;
800 unsigned int do_next_read:1;
801 unsigned int consume_body_data:1;
802 unsigned int chunked:1; ///< reading a chunked response; TODO: rename
803 unsigned int chunked_request:1; ///< writing a chunked request
804 unsigned int sentLastChunk:1; ///< do not try to write last-chunk again
805 };
806
807 struct _ipcache_addrs {
808 Ip::Address *in_addrs;
809 unsigned char *bad_mask;
810 unsigned char count;
811 unsigned char cur;
812 unsigned char badcount;
813 };
814
815 struct _domain_ping {
816 char *domain;
817 int do_ping; /* boolean */
818 domain_ping *next;
819 };
820
821 struct _domain_type {
822 char *domain;
823 peer_t type;
824 domain_type *next;
825 };
826
827 #if USE_CACHE_DIGESTS
828
829 /* statistics for cache digests and other hit "predictors" */
830
831 struct _cd_guess_stats {
832 /* public, read-only */
833 int true_hits;
834 int false_hits;
835 int true_misses;
836 int false_misses;
837 int close_hits; /* tmp, remove it later */
838 };
839
840 #endif
841
842 class PeerDigest;
843
844 struct peer {
845 u_int index;
846 char *name;
847 char *host;
848 peer_t type;
849
850 Ip::Address in_addr;
851
852 struct {
853 int pings_sent;
854 int pings_acked;
855 int fetches;
856 int rtt;
857 int ignored_replies;
858 int n_keepalives_sent;
859 int n_keepalives_recv;
860 time_t probe_start;
861 time_t last_query;
862 time_t last_reply;
863 time_t last_connect_failure;
864 time_t last_connect_probe;
865 int logged_state; /* so we can print dead/revived msgs */
866 int conn_open; /* current opened connections */
867 } stats;
868
869 struct {
870 int version;
871 int counts[ICP_END+1];
872 u_short port;
873 } icp;
874
875 #if USE_HTCP
876 struct {
877 double version;
878 int counts[2];
879 u_short port;
880 } htcp;
881 #endif
882
883 u_short http_port;
884 domain_ping *peer_domain;
885 domain_type *typelist;
886 acl_access *access;
887
888 struct {
889 unsigned int proxy_only:1;
890 unsigned int no_query:1;
891 unsigned int background_ping:1;
892 unsigned int no_digest:1;
893 unsigned int default_parent:1;
894 unsigned int roundrobin:1;
895 unsigned int weighted_roundrobin:1;
896 unsigned int mcast_responder:1;
897 unsigned int closest_only:1;
898 #if USE_HTCP
899 unsigned int htcp:1;
900 unsigned int htcp_oldsquid:1;
901 unsigned int htcp_no_clr:1;
902 unsigned int htcp_no_purge_clr:1;
903 unsigned int htcp_only_clr:1;
904 unsigned int htcp_forward_clr:1;
905 #endif
906 unsigned int no_netdb_exchange:1;
907 #if USE_DELAY_POOLS
908 unsigned int no_delay:1;
909 #endif
910 unsigned int allow_miss:1;
911 unsigned int carp:1;
912 #if USE_AUTH
913 unsigned int userhash:1;
914 #endif
915 unsigned int sourcehash:1;
916 unsigned int originserver:1;
917 unsigned int no_tproxy:1;
918 #if PEER_MULTICAST_SIBLINGS
919 unsigned int mcast_siblings:1;
920 #endif
921 } options;
922
923 int weight;
924 int basetime;
925
926 struct {
927 double avg_n_members;
928 int n_times_counted;
929 int n_replies_expected;
930 int ttl;
931 int id;
932
933 struct {
934 unsigned int count_event_pending:1;
935 unsigned int counting:1;
936 } flags;
937 } mcast;
938 #if USE_CACHE_DIGESTS
939
940 PeerDigest *digest;
941 char *digest_url;
942 #endif
943
944 int tcp_up; /* 0 if a connect() fails */
945
946 Ip::Address addresses[10];
947 int n_addresses;
948 int rr_count;
949 peer *next;
950 int test_fd;
951
952 struct {
953 unsigned int hash;
954 double load_multiplier;
955 double load_factor; /* normalized weight value */
956 } carp;
957 #if USE_AUTH
958 struct {
959 unsigned int hash;
960 double load_multiplier;
961 double load_factor; /* normalized weight value */
962 } userhash;
963 #endif
964 struct {
965 unsigned int hash;
966 double load_multiplier;
967 double load_factor; /* normalized weight value */
968 } sourcehash;
969
970 char *login; /* Proxy authorization */
971 time_t connect_timeout;
972 int connect_fail_limit;
973 int max_conn;
974 char *domain; /* Forced domain */
975 #if USE_SSL
976
977 int use_ssl;
978 char *sslcert;
979 char *sslkey;
980 int sslversion;
981 char *ssloptions;
982 char *sslcipher;
983 char *sslcafile;
984 char *sslcapath;
985 char *sslcrlfile;
986 char *sslflags;
987 char *ssldomain;
988 SSL_CTX *sslContext;
989 SSL_SESSION *sslSession;
990 #endif
991
992 int front_end_https;
993 int connection_auth;
994 };
995
996 struct _net_db_name {
997 hash_link hash; /* must be first */
998 net_db_name *next;
999 netdbEntry *net_db_entry;
1000 };
1001
1002 struct _net_db_peer {
1003 const char *peername;
1004 double hops;
1005 double rtt;
1006 time_t expires;
1007 };
1008
1009 struct _netdbEntry {
1010 hash_link hash; /* must be first */
1011 char network[MAX_IPSTRLEN];
1012 int pings_sent;
1013 int pings_recv;
1014 double hops;
1015 double rtt;
1016 time_t next_ping_time;
1017 time_t last_use_time;
1018 int link_count;
1019 net_db_name *hosts;
1020 net_db_peer *peers;
1021 int n_peers_alloc;
1022 int n_peers;
1023 };
1024
1025 struct _iostats {
1026
1027 enum { histSize = 16 };
1028
1029 struct {
1030 int reads;
1031 int reads_deferred;
1032 int read_hist[histSize];
1033 int writes;
1034 int write_hist[histSize];
1035 }
1036
1037 Http, Ftp, Gopher;
1038 };
1039
1040
1041 struct request_flags {
1042 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) {
1043 #if USE_HTTP_VIOLATIONS
1044 nocache_hack = 0;
1045 #endif
1046 #if FOLLOW_X_FORWARDED_FOR
1047 done_follow_x_forwarded_for = 0;
1048 #endif /* FOLLOW_X_FORWARDED_FOR */
1049 }
1050
1051 unsigned int range:1;
1052 unsigned int nocache:1;
1053 unsigned int ims:1;
1054 unsigned int auth:1;
1055 unsigned int cachable:1;
1056 unsigned int hierarchical:1;
1057 unsigned int loopdetect:1;
1058 unsigned int proxy_keepalive:1;
1059 unsigned int proxying:
1060 1; /* this should be killed, also in httpstateflags */
1061 unsigned int refresh:1;
1062 unsigned int redirected:1;
1063 unsigned int need_validation:1;
1064 unsigned int fail_on_validation_err:1; ///< whether we should fail if validation fails
1065 unsigned int stale_if_hit:1; ///< reply is stale if it is a hit
1066 #if USE_HTTP_VIOLATIONS
1067 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
1068 #endif
1069 unsigned int accelerated:1;
1070 unsigned int ignore_cc:1;
1071 unsigned int intercepted:1; /**< transparently intercepted request */
1072 unsigned int spoof_client_ip:1; /**< spoof client ip if possible */
1073 unsigned int internal:1;
1074 unsigned int internalclient:1;
1075 unsigned int must_keepalive:1;
1076 unsigned int connection_auth:1; /** Request wants connection oriented auth */
1077 unsigned int connection_auth_disabled:1; /** Connection oriented auth can not be supported */
1078 unsigned int connection_proxy_auth:1; /** Request wants connection oriented auth */
1079 unsigned int pinned:1; /* Request sent on a pinned connection */
1080 unsigned int auth_sent:1; /* Authentication forwarded */
1081 unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1082 unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
1083 unsigned int stream_error:1; /**< Whether stream error has occured */
1084 unsigned int sslBumped:1; /**< ssl-bumped request*/
1085
1086 // When adding new flags, please update cloneAdaptationImmune() as needed.
1087
1088 bool resetTCP() const;
1089 void setResetTCP();
1090 void clearResetTCP();
1091 void destinationIPLookupCompleted();
1092 bool destinationIPLookedUp() const;
1093
1094 // returns a partial copy of the flags that includes only those flags
1095 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1096 request_flags cloneAdaptationImmune() const;
1097
1098 #if FOLLOW_X_FORWARDED_FOR
1099 unsigned int done_follow_x_forwarded_for;
1100 #endif /* FOLLOW_X_FORWARDED_FOR */
1101 private:
1102
1103 unsigned int reset_tcp:1;
1104 unsigned int destinationIPLookedUp_:1;
1105 };
1106
1107 struct _link_list {
1108 void *ptr;
1109
1110 struct _link_list *next;
1111 };
1112
1113 struct _cachemgr_passwd {
1114 char *passwd;
1115 wordlist *actions;
1116 cachemgr_passwd *next;
1117 };
1118
1119 struct _refresh_t {
1120 const char *pattern;
1121 regex_t compiled_pattern;
1122 time_t min;
1123 double pct;
1124 time_t max;
1125 refresh_t *next;
1126
1127 struct {
1128 unsigned int icase:1;
1129 unsigned int refresh_ims:1;
1130 unsigned int store_stale:1;
1131 #if USE_HTTP_VIOLATIONS
1132 unsigned int override_expire:1;
1133 unsigned int override_lastmod:1;
1134 unsigned int reload_into_ims:1;
1135 unsigned int ignore_reload:1;
1136 unsigned int ignore_no_cache:1;
1137 unsigned int ignore_no_store:1;
1138 unsigned int ignore_must_revalidate:1;
1139 unsigned int ignore_private:1;
1140 unsigned int ignore_auth:1;
1141 #endif
1142 } flags;
1143 int max_stale;
1144 };
1145
1146 /*
1147 * "very generic" histogram;
1148 * see important comments on hbase_f restrictions in StatHist.c
1149 */
1150
1151 struct _StatHist {
1152 int *bins;
1153 int capacity;
1154 double min;
1155 double max;
1156 double scale;
1157 hbase_f *val_in; /* e.g., log() for log-based histogram */
1158 hbase_f *val_out; /* e.g., exp() for log based histogram */
1159 };
1160
1161 /*
1162 * if you add a field to StatCounters,
1163 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1164 */
1165
1166 struct _StatCounters {
1167
1168 struct {
1169 int clients;
1170 int requests;
1171 int hits;
1172 int mem_hits;
1173 int disk_hits;
1174 int errors;
1175 kb_t kbytes_in;
1176 kb_t kbytes_out;
1177 kb_t hit_kbytes_out;
1178 StatHist miss_svc_time;
1179 StatHist nm_svc_time;
1180 StatHist nh_svc_time;
1181 StatHist hit_svc_time;
1182 StatHist all_svc_time;
1183 } client_http;
1184
1185 struct {
1186
1187 struct {
1188 int requests;
1189 int errors;
1190 kb_t kbytes_in;
1191 kb_t kbytes_out;
1192 } all , http, ftp, other;
1193 } server;
1194
1195 struct {
1196 int pkts_sent;
1197 int queries_sent;
1198 int replies_sent;
1199 int pkts_recv;
1200 int queries_recv;
1201 int replies_recv;
1202 int hits_sent;
1203 int hits_recv;
1204 int replies_queued;
1205 int replies_dropped;
1206 kb_t kbytes_sent;
1207 kb_t q_kbytes_sent;
1208 kb_t r_kbytes_sent;
1209 kb_t kbytes_recv;
1210 kb_t q_kbytes_recv;
1211 kb_t r_kbytes_recv;
1212 StatHist query_svc_time;
1213 StatHist reply_svc_time;
1214 int query_timeouts;
1215 int times_used;
1216 } icp;
1217
1218 struct {
1219 int pkts_sent;
1220 int pkts_recv;
1221 } htcp;
1222
1223 struct {
1224 int requests;
1225 } unlink;
1226
1227 struct {
1228 StatHist svc_time;
1229 } dns;
1230
1231 struct {
1232 int times_used;
1233 kb_t kbytes_sent;
1234 kb_t kbytes_recv;
1235 kb_t memory;
1236 int msgs_sent;
1237 int msgs_recv;
1238 #if USE_CACHE_DIGESTS
1239
1240 cd_guess_stats guess;
1241 #endif
1242
1243 StatHist on_xition_count;
1244 } cd;
1245
1246 struct {
1247 int times_used;
1248 } netdb;
1249 int page_faults;
1250 unsigned long int select_loops;
1251 int select_fds;
1252 double select_time;
1253 double cputime;
1254
1255 struct timeval timestamp;
1256 StatHist comm_icp_incoming;
1257 StatHist comm_dns_incoming;
1258 StatHist comm_http_incoming;
1259 StatHist select_fds_hist;
1260
1261 struct {
1262 struct {
1263 int opens;
1264 int closes;
1265 int reads;
1266 int writes;
1267 int seeks;
1268 int unlinks;
1269 } disk;
1270
1271 struct {
1272 int accepts;
1273 int sockets;
1274 int connects;
1275 int binds;
1276 int closes;
1277 int reads;
1278 int writes;
1279 int recvfroms;
1280 int sendtos;
1281 } sock;
1282 int selects;
1283 } syscalls;
1284 int aborted_requests;
1285
1286 struct {
1287 int files_cleaned;
1288 int outs;
1289 int ins;
1290 } swap;
1291 };
1292
1293 /* per header statistics */
1294
1295 struct _HttpHeaderStat {
1296 const char *label;
1297 HttpHeaderMask *owner_mask;
1298
1299 StatHist hdrUCountDistr;
1300 StatHist fieldTypeDistr;
1301 StatHist ccTypeDistr;
1302 StatHist scTypeDistr;
1303
1304 int parsedCount;
1305 int ccParsedCount;
1306 int scParsedCount;
1307 int destroyedCount;
1308 int busyDestroyedCount;
1309 };
1310
1311
1312 struct _CacheDigest {
1313 /* public, read-only */
1314 char *mask; /* bit mask */
1315 int mask_size; /* mask size in bytes */
1316 int capacity; /* expected maximum for .count, not a hard limit */
1317 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1318 int count; /* number of digested entries */
1319 int del_count; /* number of deletions performed so far */
1320 };
1321
1322
1323 struct _store_rebuild_data {
1324 int objcount; /* # objects successfully reloaded */
1325 int expcount; /* # objects expired */
1326 int scancount; /* # entries scanned or read from state file */
1327 int clashcount; /* # swapfile clashes avoided */
1328 int dupcount; /* # duplicates purged */
1329 int cancelcount; /* # SWAP_LOG_DEL objects purged */
1330 int invalid; /* # bad lines */
1331 int badflags; /* # bad e->flags */
1332 int bad_log_op;
1333 int zero_object_sz;
1334 };
1335
1336 class Logfile;
1337 class logformat;
1338
1339 #include "log/Formats.h"
1340 struct _customlog {
1341 char *filename;
1342 ACLList *aclList;
1343 logformat *logFormat;
1344 Logfile *logfile;
1345 customlog *next;
1346 Log::Format::log_type type;
1347 };
1348
1349 #endif /* SQUID_STRUCTS_H */