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