]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
Sync with trunk
[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 Store;
148
149 struct SquidConfig {
150
151 struct {
152 /* These should be for the Store::Root instance.
153 * this needs pluggable parsing to be done smoothly.
154 */
155 int highWaterMark;
156 int lowWaterMark;
157 } Swap;
158 size_t memMaxSize;
159
160 struct {
161 int64_t min;
162 int pct;
163 int64_t max;
164 } quickAbort;
165 int64_t readAheadGap;
166 RemovalPolicySettings *replPolicy;
167 RemovalPolicySettings *memPolicy;
168 #if USE_HTTP_VIOLATIONS
169 time_t negativeTtl;
170 #endif
171 time_t maxStale;
172 time_t negativeDnsTtl;
173 time_t positiveDnsTtl;
174 time_t shutdownLifetime;
175 time_t backgroundPingRate;
176
177 struct {
178 time_t read;
179 time_t write;
180 time_t lifetime;
181 time_t connect;
182 time_t forward;
183 time_t peer_connect;
184 time_t request;
185 time_t persistent_request;
186 time_t pconn;
187 time_t siteSelect;
188 time_t deadPeer;
189 int icp_query; /* msec */
190 int icp_query_max; /* msec */
191 int icp_query_min; /* msec */
192 int mcast_icp_query; /* msec */
193
194 #if !USE_DNSSERVERS
195
196 time_msec_t idns_retransmit;
197 time_msec_t idns_query;
198 #endif
199
200 } Timeout;
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;
207
208 struct {
209 u_short icp;
210 #if USE_HTCP
211
212 u_short htcp;
213 #endif
214 #if SQUID_SNMP
215
216 u_short snmp;
217 #endif
218 } Port;
219
220 struct {
221 http_port_list *http;
222 #if USE_SSL
223
224 https_port_list *https;
225 #endif
226
227 } Sockaddr;
228 #if SQUID_SNMP
229
230 struct {
231 char *configFile;
232 char *agentInfo;
233 } Snmp;
234 #endif
235 #if USE_WCCP
236
237 struct {
238 Ip::Address router;
239 Ip::Address address;
240 int version;
241 } Wccp;
242 #endif
243 #if USE_WCCPv2
244
245 struct {
246 Ip::Address_list *router;
247 Ip::Address address;
248 int forwarding_method;
249 int return_method;
250 int assignment_method;
251 int weight;
252 int rebuildwait;
253 void *info;
254 } Wccp2;
255 #endif
256
257 #if USE_ICMP
258 IcmpConfig pinger;
259 #endif
260
261 char *as_whois_server;
262
263 struct {
264 char *store;
265 char *swap;
266 customlog *accesslogs;
267 #if ICAP_CLIENT
268 customlog *icaplogs;
269 #endif
270 int rotateNumber;
271 } Log;
272 char *adminEmail;
273 char *EmailFrom;
274 char *EmailProgram;
275 char *effectiveUser;
276 char *visible_appname_string;
277 char *effectiveGroup;
278
279 struct {
280 #if USE_DNSSERVERS
281 char *dnsserver;
282 #endif
283
284 wordlist *redirect;
285 #if USE_UNLINKD
286
287 char *unlinkd;
288 #endif
289
290 char *diskd;
291 #if USE_SSL
292
293 char *ssl_password;
294 #endif
295
296 } Program;
297 #if USE_DNSSERVERS
298
299 HelperChildConfig dnsChildren;
300 #endif
301
302 HelperChildConfig redirectChildren;
303 time_t authenticateGCInterval;
304 time_t authenticateTTL;
305 time_t authenticateIpTTL;
306
307 struct {
308 char *surrogate_id;
309 } Accel;
310 char *appendDomain;
311 size_t appendDomainLen;
312 char *pidFilename;
313 char *netdbFilename;
314 char *mimeTablePathname;
315 char *etcHostsPath;
316 char *visibleHostname;
317 char *uniqueHostname;
318 wordlist *hostnameAliases;
319 char *errHtmlText;
320
321 struct {
322 char *host;
323 char *file;
324 time_t period;
325 u_short port;
326 } Announce;
327
328 struct {
329
330 Ip::Address udp_incoming;
331 Ip::Address udp_outgoing;
332 #if SQUID_SNMP
333 Ip::Address snmp_incoming;
334 Ip::Address snmp_outgoing;
335 #endif
336 /* FIXME INET6 : this should really be a CIDR value */
337 Ip::Address client_netmask;
338 } Addrs;
339 size_t tcpRcvBufsz;
340 size_t udpMaxHitObjsz;
341 wordlist *hierarchy_stoplist;
342 wordlist *mcast_group_list;
343 wordlist *dns_nameservers;
344 peer *peers;
345 int npeers;
346
347 struct {
348 int size;
349 int low;
350 int high;
351 } ipcache;
352
353 struct {
354 int size;
355 } fqdncache;
356 int minDirectHops;
357 int minDirectRtt;
358 cachemgr_passwd *passwd_list;
359
360 struct {
361 int objectsPerBucket;
362 int64_t avgObjectSize;
363 int64_t maxObjectSize;
364 int64_t minObjectSize;
365 size_t maxInMemObjSize;
366 } Store;
367
368 struct {
369 int high;
370 int low;
371 time_t period;
372 } Netdb;
373
374 struct {
375 int log_udp;
376 int res_defnames;
377 int anonymizer;
378 int client_db;
379 int query_icmp;
380 int icp_hit_stale;
381 int buffered_logs;
382 int common_log;
383 int log_mime_hdrs;
384 int log_fqdn;
385 int announce;
386 int mem_pools;
387 int test_reachability;
388 int half_closed_clients;
389 int refresh_all_ims;
390 #if USE_HTTP_VIOLATIONS
391
392 int reload_into_ims;
393 #endif
394
395 int offline;
396 int redir_rewrites_host;
397 int prefer_direct;
398 int nonhierarchical_direct;
399 int strip_query_terms;
400 int redirector_bypass;
401 int ignore_unknown_nameservers;
402 int client_pconns;
403 int server_pconns;
404 int error_pconns;
405 #if USE_CACHE_DIGESTS
406
407 int digest_generation;
408 #endif
409
410 int log_ip_on_direct;
411 int ie_refresh;
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;
419 int check_hostnames;
420 int allow_underscore;
421 int via;
422 int emailErrData;
423 int httpd_suppress_version_string;
424 int global_internal_static;
425 int dns_require_A;
426
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;
431 #if LINUX_NETFILTER
432 int tproxy_uses_indirect_client;
433 #endif
434 #endif /* FOLLOW_X_FORWARDED_FOR */
435
436 int WIN32_IpAddrChangeMonitor;
437 int memory_cache_first;
438 int memory_cache_disk;
439 } onoff;
440
441 int forward_max_tries;
442 int connect_retries;
443
444 class ACL *aclList;
445
446 struct {
447 acl_access *http;
448 acl_access *adapted_http;
449 acl_access *icp;
450 acl_access *miss;
451 acl_access *NeverDirect;
452 acl_access *AlwaysDirect;
453 acl_access *ASlists;
454 acl_access *noCache;
455 acl_access *log;
456 #if SQUID_SNMP
457
458 acl_access *snmp;
459 #endif
460 #if USE_HTTP_VIOLATIONS
461 acl_access *brokenPosts;
462 #endif
463 acl_access *redirector;
464 acl_access *reply;
465 acl_address *outgoing_address;
466 #if USE_HTCP
467
468 acl_access *htcp;
469 acl_access *htcp_clr;
470 #endif
471
472 #if USE_SSL
473 acl_access *ssl_bump;
474 #endif
475 #if FOLLOW_X_FORWARDED_FOR
476 acl_access *followXFF;
477 #endif /* FOLLOW_X_FORWARDED_FOR */
478
479 #if ICAP_CLIENT
480 acl_access* icap;
481 #endif
482 } accessList;
483 acl_deny_info_list *denyInfoList;
484
485 struct {
486 size_t list_width;
487 int list_wrap;
488 char *anon_user;
489 int passive;
490 int epsv_all;
491 int epsv;
492 int eprt;
493 int sanitycheck;
494 int telnet;
495 } Ftp;
496 refresh_t *Refresh;
497
498 struct _cacheSwap {
499 RefCount<class Store> *swapDirs;
500 int n_allocated;
501 int n_configured;
502 } cacheSwap;
503 /*
504 * I'm sick of having to keep doing this ..
505 */
506 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
507
508 struct {
509 char *directory;
510 int use_short_names;
511 } icons;
512 char *errorDirectory;
513 #if USE_ERR_LOCALES
514 char *errorDefaultLanguage;
515 int errorLogMissingLanguages;
516 #endif
517 char *errorStylesheet;
518
519 struct {
520 int onerror;
521 } retry;
522
523 struct {
524 int64_t limit;
525 } MemPools;
526 #if USE_DELAY_POOLS
527
528 DelayConfig Delay;
529 ClientDelayConfig ClientDelay;
530 #endif
531
532 struct {
533 int icp_average;
534 int dns_average;
535 int http_average;
536 int icp_min_poll;
537 int dns_min_poll;
538 int http_min_poll;
539 } comm_incoming;
540 int max_open_disk_fds;
541 int uri_whitespace;
542 acl_size_t *rangeOffsetLimit;
543 #if MULTICAST_MISS_STREAM
544
545 struct {
546
547 Ip::Address addr;
548 int ttl;
549 unsigned short port;
550 char *encode_key;
551 } mcast_miss;
552 #endif
553
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];
558 char *coredump_dir;
559 char *chroot_dir;
560 #if USE_CACHE_DIGESTS
561
562 struct {
563 int bits_per_entry;
564 time_t rebuild_period;
565 time_t rewrite_period;
566 size_t swapout_chunk_size;
567 int rebuild_chunk_percentage;
568 } digest;
569 #endif
570 #if USE_SSL
571
572 struct {
573 int unclean_shutdown;
574 char *ssl_engine;
575 } SSL;
576 #endif
577
578 wordlist *ext_methods;
579
580 struct {
581 int high_rptm;
582 int high_pf;
583 size_t high_memory;
584 } warnings;
585 char *store_dir_select_algorithm;
586 int sleep_after_fork; /* microseconds */
587 time_t minimum_expiry_time; /* seconds */
588 external_acl *externalAclHelperList;
589
590 #if USE_SSL
591
592 struct {
593 char *cert;
594 char *key;
595 int version;
596 char *options;
597 char *cipher;
598 char *cafile;
599 char *capath;
600 char *crlfile;
601 char *flags;
602 acl_access *cert_error;
603 SSL_CTX *sslContext;
604 } ssl_client;
605 #endif
606
607 char *accept_filter;
608 int umask;
609 int max_filedescriptors;
610 int workers;
611 CpuAffinityMap *cpuAffinityMap;
612
613 #if USE_LOADABLE_MODULES
614 wordlist *loadable_module_names;
615 #endif
616
617 int client_ip_max_connections;
618
619 struct {
620 ssize_t packet_max; ///< maximum size EDNS advertised for DNS replies.
621 } dns;
622 };
623
624 SQUIDCEXTERN SquidConfig Config;
625
626 struct SquidConfig2 {
627 struct {
628 int enable_purge;
629 int mangle_request_headers;
630 } onoff;
631 uid_t effectiveUserID;
632 gid_t effectiveGroupID;
633 };
634
635 SQUIDCEXTERN SquidConfig2 Config2;
636
637 struct _close_handler {
638 PF *handler;
639 void *data;
640 close_handler *next;
641 };
642
643 struct _dread_ctrl {
644 int fd;
645 off_t offset;
646 int req_len;
647 char *buf;
648 int end_of_file;
649 DRCB *handler;
650 void *client_data;
651 };
652
653 struct _dwrite_q {
654 off_t file_offset;
655 char *buf;
656 size_t len;
657 size_t buf_offset;
658 dwrite_q *next;
659 FREE *free_func;
660 };
661
662
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) */
667
668 struct _ETag {
669 const char *str; /* quoted-string */
670 int weak; /* true if it is a weak validator */
671 };
672
673 struct _fde_disk {
674 DWCB *wrt_handle;
675 void *wrt_handle_data;
676 dwrite_q *write_q;
677 dwrite_q *write_q_tail;
678 off_t offset;
679 };
680
681 struct _fileMap {
682 int max_n_files;
683 int n_files_in_map;
684 int toggle;
685 int nwords;
686 unsigned long *file_map;
687 };
688
689 /*
690 * Note: HttpBody is used only for messages with a small content that is
691 * known a priory (e.g., error messages).
692 */
693
694 class MemBuf;
695
696 struct _HttpBody {
697 /* private */
698 MemBuf *mb;
699 };
700
701 #include "SquidString.h"
702 /* http header extention field */
703
704 class HttpHdrExtField
705 {
706 String name; /* field-name from HTTP/1.1 (no column after name) */
707 String value; /* field-value from HTTP/1.1 */
708 };
709
710 /* http cache control header field */
711
712 class HttpHdrCc
713 {
714
715 public:
716 int mask;
717 int max_age;
718 int s_maxage;
719 int max_stale;
720 int stale_if_error;
721 int min_fresh;
722 String other;
723 };
724
725 /* some fields can hold either time or etag specs (e.g. If-Range) */
726
727 struct _TimeOrTag {
728 ETag tag; /* entity tag */
729 time_t time;
730 int valid; /* true if struct is usable */
731 };
732
733 /* per field statistics */
734
735 class HttpHeaderFieldStat
736 {
737
738 public:
739 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
740
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 */
746 };
747
748 /* compiled version of HttpHeaderFieldAttrs plus stats */
749
750 class HttpHeaderFieldInfo
751 {
752
753 public:
754 HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid) {}
755
756 http_hdr_type id;
757 String name;
758 field_type type;
759 HttpHeaderFieldStat stat;
760 };
761
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
778 };
779
780 struct _domain_ping {
781 char *domain;
782 int do_ping; /* boolean */
783 domain_ping *next;
784 };
785
786 struct _domain_type {
787 char *domain;
788 peer_t type;
789 domain_type *next;
790 };
791
792 #if USE_CACHE_DIGESTS
793
794 /* statistics for cache digests and other hit "predictors" */
795
796 struct _cd_guess_stats {
797 /* public, read-only */
798 int true_hits;
799 int false_hits;
800 int true_misses;
801 int false_misses;
802 int close_hits; /* tmp, remove it later */
803 };
804
805 #endif
806
807 class PeerDigest;
808
809 struct peer {
810 u_int index;
811 char *name;
812 char *host;
813 peer_t type;
814
815 Ip::Address in_addr;
816
817 struct {
818 int pings_sent;
819 int pings_acked;
820 int fetches;
821 int rtt;
822 int ignored_replies;
823 int n_keepalives_sent;
824 int n_keepalives_recv;
825 time_t probe_start;
826 time_t last_query;
827 time_t last_reply;
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 */
832 } stats;
833
834 struct {
835 int version;
836 int counts[ICP_END+1];
837 u_short port;
838 } icp;
839
840 #if USE_HTCP
841 struct {
842 double version;
843 int counts[2];
844 u_short port;
845 } htcp;
846 #endif
847
848 u_short http_port;
849 domain_ping *peer_domain;
850 domain_type *typelist;
851 acl_access *access;
852
853 struct {
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;
863 #if USE_HTCP
864 unsigned int htcp: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;
870 #endif
871 unsigned int no_netdb_exchange:1;
872 #if USE_DELAY_POOLS
873 unsigned int no_delay:1;
874 #endif
875 unsigned int allow_miss:1;
876 unsigned int carp:1;
877 #if USE_AUTH
878 unsigned int userhash:1;
879 #endif
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;
885 #endif
886 } options;
887
888 int weight;
889 int basetime;
890
891 struct {
892 double avg_n_members;
893 int n_times_counted;
894 int n_replies_expected;
895 int ttl;
896 int id;
897
898 struct {
899 unsigned int count_event_pending:1;
900 unsigned int counting:1;
901 } flags;
902 } mcast;
903 #if USE_CACHE_DIGESTS
904
905 PeerDigest *digest;
906 char *digest_url;
907 #endif
908
909 int tcp_up; /* 0 if a connect() fails */
910
911 Ip::Address addresses[10];
912 int n_addresses;
913 int rr_count;
914 peer *next;
915 int testing_now;
916
917 struct {
918 unsigned int hash;
919 double load_multiplier;
920 double load_factor; /* normalized weight value */
921 } carp;
922 #if USE_AUTH
923 struct {
924 unsigned int hash;
925 double load_multiplier;
926 double load_factor; /* normalized weight value */
927 } userhash;
928 #endif
929 struct {
930 unsigned int hash;
931 double load_multiplier;
932 double load_factor; /* normalized weight value */
933 } sourcehash;
934
935 char *login; /* Proxy authorization */
936 time_t connect_timeout;
937 int connect_fail_limit;
938 int max_conn;
939 char *domain; /* Forced domain */
940 #if USE_SSL
941
942 int use_ssl;
943 char *sslcert;
944 char *sslkey;
945 int sslversion;
946 char *ssloptions;
947 char *sslcipher;
948 char *sslcafile;
949 char *sslcapath;
950 char *sslcrlfile;
951 char *sslflags;
952 char *ssldomain;
953 SSL_CTX *sslContext;
954 SSL_SESSION *sslSession;
955 #endif
956
957 int front_end_https;
958 int connection_auth;
959 };
960
961 struct _net_db_name {
962 hash_link hash; /* must be first */
963 net_db_name *next;
964 netdbEntry *net_db_entry;
965 };
966
967 struct _net_db_peer {
968 const char *peername;
969 double hops;
970 double rtt;
971 time_t expires;
972 };
973
974 struct _netdbEntry {
975 hash_link hash; /* must be first */
976 char network[MAX_IPSTRLEN];
977 int pings_sent;
978 int pings_recv;
979 double hops;
980 double rtt;
981 time_t next_ping_time;
982 time_t last_use_time;
983 int link_count;
984 net_db_name *hosts;
985 net_db_peer *peers;
986 int n_peers_alloc;
987 int n_peers;
988 };
989
990 struct _iostats {
991
992 enum { histSize = 16 };
993
994 struct {
995 int reads;
996 int reads_deferred;
997 int read_hist[histSize];
998 int writes;
999 int write_hist[histSize];
1000 }
1001
1002 Http, Ftp, Gopher;
1003 };
1004
1005
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
1009 nocache_hack = 0;
1010 #endif
1011 #if FOLLOW_X_FORWARDED_FOR
1012 done_follow_x_forwarded_for = 0;
1013 #endif /* FOLLOW_X_FORWARDED_FOR */
1014 }
1015
1016 unsigned int range:1;
1017 unsigned int nocache:1;
1018 unsigned int ims: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 */
1033 #endif
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*/
1050
1051 // When adding new flags, please update cloneAdaptationImmune() as needed.
1052
1053 bool resetTCP() const;
1054 void setResetTCP();
1055 void clearResetTCP();
1056 void destinationIPLookupCompleted();
1057 bool destinationIPLookedUp() const;
1058
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;
1062
1063 #if FOLLOW_X_FORWARDED_FOR
1064 unsigned int done_follow_x_forwarded_for;
1065 #endif /* FOLLOW_X_FORWARDED_FOR */
1066 private:
1067
1068 unsigned int reset_tcp:1;
1069 unsigned int destinationIPLookedUp_:1;
1070 };
1071
1072 struct _link_list {
1073 void *ptr;
1074
1075 struct _link_list *next;
1076 };
1077
1078 struct _cachemgr_passwd {
1079 char *passwd;
1080 wordlist *actions;
1081 cachemgr_passwd *next;
1082 };
1083
1084 struct _refresh_t {
1085 const char *pattern;
1086 regex_t compiled_pattern;
1087 time_t min;
1088 double pct;
1089 time_t max;
1090 refresh_t *next;
1091
1092 struct {
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;
1106 #endif
1107 } flags;
1108 int max_stale;
1109 };
1110
1111 /*
1112 * "very generic" histogram;
1113 * see important comments on hbase_f restrictions in StatHist.c
1114 */
1115
1116 struct _StatHist {
1117 int *bins;
1118 int capacity;
1119 double min;
1120 double max;
1121 double scale;
1122 hbase_f *val_in; /* e.g., log() for log-based histogram */
1123 hbase_f *val_out; /* e.g., exp() for log based histogram */
1124 };
1125
1126 /*
1127 * if you add a field to StatCounters,
1128 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1129 */
1130
1131 struct _StatCounters {
1132
1133 struct {
1134 int clients;
1135 int requests;
1136 int hits;
1137 int mem_hits;
1138 int disk_hits;
1139 int errors;
1140 kb_t kbytes_in;
1141 kb_t kbytes_out;
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;
1148 } client_http;
1149
1150 struct {
1151
1152 struct {
1153 int requests;
1154 int errors;
1155 kb_t kbytes_in;
1156 kb_t kbytes_out;
1157 } all , http, ftp, other;
1158 } server;
1159
1160 struct {
1161 int pkts_sent;
1162 int queries_sent;
1163 int replies_sent;
1164 int pkts_recv;
1165 int queries_recv;
1166 int replies_recv;
1167 int hits_sent;
1168 int hits_recv;
1169 int replies_queued;
1170 int replies_dropped;
1171 kb_t kbytes_sent;
1172 kb_t q_kbytes_sent;
1173 kb_t r_kbytes_sent;
1174 kb_t kbytes_recv;
1175 kb_t q_kbytes_recv;
1176 kb_t r_kbytes_recv;
1177 StatHist query_svc_time;
1178 StatHist reply_svc_time;
1179 int query_timeouts;
1180 int times_used;
1181 } icp;
1182
1183 struct {
1184 int pkts_sent;
1185 int pkts_recv;
1186 } htcp;
1187
1188 struct {
1189 int requests;
1190 } unlink;
1191
1192 struct {
1193 StatHist svc_time;
1194 } dns;
1195
1196 struct {
1197 int times_used;
1198 kb_t kbytes_sent;
1199 kb_t kbytes_recv;
1200 kb_t memory;
1201 int msgs_sent;
1202 int msgs_recv;
1203 #if USE_CACHE_DIGESTS
1204
1205 cd_guess_stats guess;
1206 #endif
1207
1208 StatHist on_xition_count;
1209 } cd;
1210
1211 struct {
1212 int times_used;
1213 } netdb;
1214 int page_faults;
1215 unsigned long int select_loops;
1216 int select_fds;
1217 double select_time;
1218 double cputime;
1219
1220 struct timeval timestamp;
1221 StatHist comm_icp_incoming;
1222 StatHist comm_dns_incoming;
1223 StatHist comm_http_incoming;
1224 StatHist select_fds_hist;
1225
1226 struct {
1227 struct {
1228 int opens;
1229 int closes;
1230 int reads;
1231 int writes;
1232 int seeks;
1233 int unlinks;
1234 } disk;
1235
1236 struct {
1237 int accepts;
1238 int sockets;
1239 int connects;
1240 int binds;
1241 int closes;
1242 int reads;
1243 int writes;
1244 int recvfroms;
1245 int sendtos;
1246 } sock;
1247 int selects;
1248 } syscalls;
1249 int aborted_requests;
1250
1251 struct {
1252 int files_cleaned;
1253 int outs;
1254 int ins;
1255 } swap;
1256 };
1257
1258 /* per header statistics */
1259
1260 struct _HttpHeaderStat {
1261 const char *label;
1262 HttpHeaderMask *owner_mask;
1263
1264 StatHist hdrUCountDistr;
1265 StatHist fieldTypeDistr;
1266 StatHist ccTypeDistr;
1267 StatHist scTypeDistr;
1268
1269 int parsedCount;
1270 int ccParsedCount;
1271 int scParsedCount;
1272 int destroyedCount;
1273 int busyDestroyedCount;
1274 };
1275
1276
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 */
1285 };
1286
1287
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 */
1297 int bad_log_op;
1298 int zero_object_sz;
1299 };
1300
1301 class Logfile;
1302 class logformat;
1303
1304 #include "log/Formats.h"
1305 struct _customlog {
1306 char *filename;
1307 ACLList *aclList;
1308 logformat *logFormat;
1309 Logfile *logfile;
1310 customlog *next;
1311 Log::Format::log_type type;
1312 };
1313
1314 #endif /* SQUID_STRUCTS_H */