]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
Merged from 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 unsigned 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 {
154 // TODO: generalize to non-boolean option types
155 public:
156 YesNoNone(): option(0) {}
157
158 /// returns true iff enabled; asserts if the option has not been configured
159 operator void *() const; // TODO: use a fancy/safer version of the operator
160
161 /// enables or disables the option;
162 void configure(bool beSet);
163
164 /// whether the option was enabled or disabled, by user or Squid
165 bool configured() const { return option != 0; }
166
167 private:
168 enum { optUnspecified = -1, optDisabled = 0, optEnabled = 1 };
169 int option; ///< configured value or zero
170 };
171
172 struct SquidConfig {
173
174 struct {
175 /* These should be for the Store::Root instance.
176 * this needs pluggable parsing to be done smoothly.
177 */
178 int highWaterMark;
179 int lowWaterMark;
180 } Swap;
181
182 YesNoNone memShared; ///< whether the memory cache is shared among workers
183 size_t memMaxSize;
184
185 struct {
186 int64_t min;
187 int pct;
188 int64_t max;
189 } quickAbort;
190 int64_t readAheadGap;
191 RemovalPolicySettings *replPolicy;
192 RemovalPolicySettings *memPolicy;
193 #if USE_HTTP_VIOLATIONS
194 time_t negativeTtl;
195 #endif
196 time_t maxStale;
197 time_t negativeDnsTtl;
198 time_t positiveDnsTtl;
199 time_t shutdownLifetime;
200 time_t backgroundPingRate;
201
202 struct {
203 time_t read;
204 time_t write;
205 time_t lifetime;
206 time_t connect;
207 time_t forward;
208 time_t peer_connect;
209 time_t request;
210 time_t persistent_request;
211 time_t pconn;
212 time_t siteSelect;
213 time_t deadPeer;
214 int icp_query; /* msec */
215 int icp_query_max; /* msec */
216 int icp_query_min; /* msec */
217 int mcast_icp_query; /* msec */
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 unsigned short icp;
235 #if USE_HTCP
236
237 unsigned short htcp;
238 #endif
239 #if SQUID_SNMP
240
241 unsigned 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 unsigned 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 ie_refresh;
436 int vary_ignore_expire;
437 int pipeline_prefetch;
438 int surrogate_is_remote;
439 int request_entities;
440 int detect_broken_server_pconns;
441 int balance_on_multiple_ip;
442 int relaxed_header_parser;
443 int check_hostnames;
444 int allow_underscore;
445 int via;
446 int emailErrData;
447 int httpd_suppress_version_string;
448 int global_internal_static;
449 int dns_require_A;
450
451 #if FOLLOW_X_FORWARDED_FOR
452 int acl_uses_indirect_client;
453 int delay_pool_uses_indirect_client;
454 int log_uses_indirect_client;
455 #if LINUX_NETFILTER
456 int tproxy_uses_indirect_client;
457 #endif
458 #endif /* FOLLOW_X_FORWARDED_FOR */
459
460 int WIN32_IpAddrChangeMonitor;
461 int memory_cache_first;
462 int memory_cache_disk;
463 int client_dst_passthru;
464 } onoff;
465
466 int forward_max_tries;
467 int connect_retries;
468
469 class ACL *aclList;
470
471 struct {
472 acl_access *http;
473 acl_access *adapted_http;
474 acl_access *icp;
475 acl_access *miss;
476 acl_access *NeverDirect;
477 acl_access *AlwaysDirect;
478 acl_access *ASlists;
479 acl_access *noCache;
480 acl_access *log;
481 #if SQUID_SNMP
482
483 acl_access *snmp;
484 #endif
485 #if USE_HTTP_VIOLATIONS
486 acl_access *brokenPosts;
487 #endif
488 acl_access *redirector;
489 acl_access *reply;
490 acl_address *outgoing_address;
491 #if USE_HTCP
492
493 acl_access *htcp;
494 acl_access *htcp_clr;
495 #endif
496
497 #if USE_SSL
498 acl_access *ssl_bump;
499 #endif
500 #if FOLLOW_X_FORWARDED_FOR
501 acl_access *followXFF;
502 #endif /* FOLLOW_X_FORWARDED_FOR */
503
504 #if ICAP_CLIENT
505 acl_access* icap;
506 #endif
507 } accessList;
508 acl_deny_info_list *denyInfoList;
509
510 struct {
511 size_t list_width;
512 int list_wrap;
513 char *anon_user;
514 int passive;
515 int epsv_all;
516 int epsv;
517 int eprt;
518 int sanitycheck;
519 int telnet;
520 } Ftp;
521 refresh_t *Refresh;
522
523 struct _cacheSwap {
524 RefCount<SwapDir> *swapDirs;
525 int n_allocated;
526 int n_configured;
527 /// number of disk processes required to support all cache_dirs
528 int n_strands;
529 } cacheSwap;
530 /*
531 * I'm sick of having to keep doing this ..
532 */
533 #define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
534
535 struct {
536 char *directory;
537 int use_short_names;
538 } icons;
539 char *errorDirectory;
540 #if USE_ERR_LOCALES
541 char *errorDefaultLanguage;
542 int errorLogMissingLanguages;
543 #endif
544 char *errorStylesheet;
545
546 struct {
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 struct _fde_disk {
690 DWCB *wrt_handle;
691 void *wrt_handle_data;
692 dwrite_q *write_q;
693 dwrite_q *write_q_tail;
694 off_t offset;
695 };
696
697 struct _fileMap {
698 int max_n_files;
699 int n_files_in_map;
700 int toggle;
701 int nwords;
702 unsigned long *file_map;
703 };
704
705 /*
706 * Note: HttpBody is used only for messages with a small content that is
707 * known a priory (e.g., error messages).
708 */
709
710 class MemBuf;
711
712 struct _HttpBody {
713 /* private */
714 MemBuf *mb;
715 };
716
717 #include "SquidString.h"
718 /* http header extention field */
719
720 class HttpHdrExtField
721 {
722 String name; /* field-name from HTTP/1.1 (no column after name) */
723 String value; /* field-value from HTTP/1.1 */
724 };
725
726 /* per field statistics */
727
728 class HttpHeaderFieldStat
729 {
730
731 public:
732 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
733
734 int aliveCount; /* created but not destroyed (count) */
735 int seenCount; /* #fields we've seen */
736 int parsCount; /* #parsing attempts */
737 int errCount; /* #pasring errors */
738 int repCount; /* #repetitons */
739 };
740
741 /* compiled version of HttpHeaderFieldAttrs plus stats */
742
743 class HttpHeaderFieldInfo
744 {
745
746 public:
747 HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid) {}
748
749 http_hdr_type id;
750 String name;
751 field_type type;
752 HttpHeaderFieldStat stat;
753 };
754
755 struct _http_state_flags {
756 unsigned int proxying:1;
757 unsigned int keepalive:1;
758 unsigned int only_if_cached:1;
759 unsigned int handling1xx:1; ///< we are ignoring or forwarding 1xx response
760 unsigned int headers_parsed:1;
761 unsigned int front_end_https:2;
762 unsigned int originpeer:1;
763 unsigned int keepalive_broken:1;
764 unsigned int abuse_detected:1;
765 unsigned int request_sent:1;
766 unsigned int do_next_read:1;
767 unsigned int consume_body_data:1;
768 unsigned int chunked:1; ///< reading a chunked response; TODO: rename
769 unsigned int chunked_request:1; ///< writing a chunked request
770 unsigned int sentLastChunk:1; ///< do not try to write last-chunk again
771 };
772
773 struct _domain_ping {
774 char *domain;
775 int do_ping; /* boolean */
776 domain_ping *next;
777 };
778
779 struct _domain_type {
780 char *domain;
781 peer_t type;
782 domain_type *next;
783 };
784
785 #if USE_CACHE_DIGESTS
786
787 /* statistics for cache digests and other hit "predictors" */
788
789 struct _cd_guess_stats {
790 /* public, read-only */
791 int true_hits;
792 int false_hits;
793 int true_misses;
794 int false_misses;
795 int close_hits; /* tmp, remove it later */
796 };
797
798 #endif
799
800 class PeerDigest;
801
802 struct peer {
803 u_int index;
804 char *name;
805 char *host;
806 peer_t type;
807
808 Ip::Address in_addr;
809
810 struct {
811 int pings_sent;
812 int pings_acked;
813 int fetches;
814 int rtt;
815 int ignored_replies;
816 int n_keepalives_sent;
817 int n_keepalives_recv;
818 time_t probe_start;
819 time_t last_query;
820 time_t last_reply;
821 time_t last_connect_failure;
822 time_t last_connect_probe;
823 int logged_state; /* so we can print dead/revived msgs */
824 int conn_open; /* current opened connections */
825 } stats;
826
827 struct {
828 int version;
829 int counts[ICP_END+1];
830 unsigned short port;
831 } icp;
832
833 #if USE_HTCP
834 struct {
835 double version;
836 int counts[2];
837 unsigned short port;
838 } htcp;
839 #endif
840
841 unsigned short http_port;
842 domain_ping *peer_domain;
843 domain_type *typelist;
844 acl_access *access;
845
846 struct {
847 unsigned int proxy_only:1;
848 unsigned int no_query:1;
849 unsigned int background_ping:1;
850 unsigned int no_digest:1;
851 unsigned int default_parent:1;
852 unsigned int roundrobin:1;
853 unsigned int weighted_roundrobin:1;
854 unsigned int mcast_responder:1;
855 unsigned int closest_only:1;
856 #if USE_HTCP
857 unsigned int htcp:1;
858 unsigned int htcp_oldsquid:1;
859 unsigned int htcp_no_clr:1;
860 unsigned int htcp_no_purge_clr:1;
861 unsigned int htcp_only_clr:1;
862 unsigned int htcp_forward_clr:1;
863 #endif
864 unsigned int no_netdb_exchange:1;
865 #if USE_DELAY_POOLS
866 unsigned int no_delay:1;
867 #endif
868 unsigned int allow_miss:1;
869 unsigned int carp:1;
870 struct {
871 unsigned int set:1; //If false, whole url is to be used. Overrides others
872 unsigned int scheme:1;
873 unsigned int host:1;
874 unsigned int port:1;
875 unsigned int path:1;
876 unsigned int params:1;
877 } carp_key;
878 #if USE_AUTH
879 unsigned int userhash:1;
880 #endif
881 unsigned int sourcehash:1;
882 unsigned int originserver:1;
883 unsigned int no_tproxy:1;
884 #if PEER_MULTICAST_SIBLINGS
885 unsigned int mcast_siblings:1;
886 #endif
887 } options;
888
889 int weight;
890 int basetime;
891
892 struct {
893 double avg_n_members;
894 int n_times_counted;
895 int n_replies_expected;
896 int ttl;
897 int id;
898
899 struct {
900 unsigned int count_event_pending:1;
901 unsigned int counting:1;
902 } flags;
903 } mcast;
904 #if USE_CACHE_DIGESTS
905
906 PeerDigest *digest;
907 char *digest_url;
908 #endif
909
910 int tcp_up; /* 0 if a connect() fails */
911
912 Ip::Address addresses[10];
913 int n_addresses;
914 int rr_count;
915 peer *next;
916 int testing_now;
917
918 struct {
919 unsigned int hash;
920 double load_multiplier;
921 double load_factor; /* normalized weight value */
922 } carp;
923 #if USE_AUTH
924 struct {
925 unsigned int hash;
926 double load_multiplier;
927 double load_factor; /* normalized weight value */
928 } userhash;
929 #endif
930 struct {
931 unsigned int hash;
932 double load_multiplier;
933 double load_factor; /* normalized weight value */
934 } sourcehash;
935
936 char *login; /* Proxy authorization */
937 time_t connect_timeout;
938 int connect_fail_limit;
939 int max_conn;
940 char *domain; /* Forced domain */
941 #if USE_SSL
942
943 int use_ssl;
944 char *sslcert;
945 char *sslkey;
946 int sslversion;
947 char *ssloptions;
948 char *sslcipher;
949 char *sslcafile;
950 char *sslcapath;
951 char *sslcrlfile;
952 char *sslflags;
953 char *ssldomain;
954 SSL_CTX *sslContext;
955 SSL_SESSION *sslSession;
956 #endif
957
958 int front_end_https;
959 int connection_auth;
960 };
961
962 struct _net_db_name {
963 hash_link hash; /* must be first */
964 net_db_name *next;
965 netdbEntry *net_db_entry;
966 };
967
968 struct _net_db_peer {
969 const char *peername;
970 double hops;
971 double rtt;
972 time_t expires;
973 };
974
975 struct _netdbEntry {
976 hash_link hash; /* must be first */
977 char network[MAX_IPSTRLEN];
978 int pings_sent;
979 int pings_recv;
980 double hops;
981 double rtt;
982 time_t next_ping_time;
983 time_t last_use_time;
984 int link_count;
985 net_db_name *hosts;
986 net_db_peer *peers;
987 int n_peers_alloc;
988 int n_peers;
989 };
990
991 struct _iostats {
992
993 enum { histSize = 16 };
994
995 struct {
996 int reads;
997 int reads_deferred;
998 int read_hist[histSize];
999 int writes;
1000 int write_hist[histSize];
1001 }
1002
1003 Http, Ftp, Gopher;
1004 };
1005
1006
1007 struct request_flags {
1008 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) {
1009 #if USE_HTTP_VIOLATIONS
1010 nocache_hack = 0;
1011 #endif
1012 #if FOLLOW_X_FORWARDED_FOR
1013 done_follow_x_forwarded_for = 0;
1014 #endif /* FOLLOW_X_FORWARDED_FOR */
1015 }
1016
1017 unsigned int range:1;
1018 unsigned int nocache:1;
1019 unsigned int ims:1;
1020 unsigned int auth:1;
1021 unsigned int cachable:1;
1022 unsigned int hierarchical:1;
1023 unsigned int loopdetect:1;
1024 unsigned int proxy_keepalive:1;
1025 unsigned int proxying:
1026 1; /* this should be killed, also in httpstateflags */
1027 unsigned int refresh:1;
1028 unsigned int redirected:1;
1029 unsigned int need_validation:1;
1030 unsigned int fail_on_validation_err:1; ///< whether we should fail if validation fails
1031 unsigned int stale_if_hit:1; ///< reply is stale if it is a hit
1032 #if USE_HTTP_VIOLATIONS
1033 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
1034 #endif
1035 unsigned int accelerated:1;
1036 unsigned int ignore_cc:1;
1037 unsigned int intercepted:1; /**< transparently intercepted request */
1038 unsigned int spoof_client_ip:1; /**< spoof client ip if possible */
1039 unsigned int internal:1;
1040 unsigned int internalclient:1;
1041 unsigned int must_keepalive:1;
1042 unsigned int connection_auth:1; /** Request wants connection oriented auth */
1043 unsigned int connection_auth_disabled:1; /** Connection oriented auth can not be supported */
1044 unsigned int connection_proxy_auth:1; /** Request wants connection oriented auth */
1045 unsigned int pinned:1; /* Request sent on a pinned connection */
1046 unsigned int auth_sent:1; /* Authentication forwarded */
1047 unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
1048 unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
1049 unsigned int stream_error:1; /**< Whether stream error has occured */
1050 unsigned int sslBumped:1; /**< ssl-bumped request*/
1051
1052 // When adding new flags, please update cloneAdaptationImmune() as needed.
1053
1054 bool resetTCP() const;
1055 void setResetTCP();
1056 void clearResetTCP();
1057 void destinationIPLookupCompleted();
1058 bool destinationIPLookedUp() const;
1059
1060 // returns a partial copy of the flags that includes only those flags
1061 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1062 request_flags cloneAdaptationImmune() const;
1063
1064 #if FOLLOW_X_FORWARDED_FOR
1065 unsigned int done_follow_x_forwarded_for;
1066 #endif /* FOLLOW_X_FORWARDED_FOR */
1067 private:
1068
1069 unsigned int reset_tcp:1;
1070 unsigned int destinationIPLookedUp_:1;
1071 };
1072
1073 struct _link_list {
1074 void *ptr;
1075
1076 struct _link_list *next;
1077 };
1078
1079 struct _cachemgr_passwd {
1080 char *passwd;
1081 wordlist *actions;
1082 cachemgr_passwd *next;
1083 };
1084
1085 struct _refresh_t {
1086 const char *pattern;
1087 regex_t compiled_pattern;
1088 time_t min;
1089 double pct;
1090 time_t max;
1091 refresh_t *next;
1092
1093 struct {
1094 unsigned int icase:1;
1095 unsigned int refresh_ims:1;
1096 unsigned int store_stale:1;
1097 #if USE_HTTP_VIOLATIONS
1098 unsigned int override_expire:1;
1099 unsigned int override_lastmod:1;
1100 unsigned int reload_into_ims:1;
1101 unsigned int ignore_reload:1;
1102 unsigned int ignore_no_cache:1;
1103 unsigned int ignore_no_store:1;
1104 unsigned int ignore_must_revalidate:1;
1105 unsigned int ignore_private:1;
1106 unsigned int ignore_auth:1;
1107 #endif
1108 } flags;
1109 int max_stale;
1110 };
1111
1112 /*
1113 * "very generic" histogram;
1114 * see important comments on hbase_f restrictions in StatHist.c
1115 */
1116
1117 struct _StatHist {
1118 int *bins;
1119 int capacity;
1120 double min;
1121 double max;
1122 double scale;
1123 hbase_f *val_in; /* e.g., log() for log-based histogram */
1124 hbase_f *val_out; /* e.g., exp() for log based histogram */
1125 };
1126
1127 /*
1128 * if you add a field to StatCounters,
1129 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1130 */
1131
1132 struct _StatCounters {
1133
1134 struct {
1135 int clients;
1136 int requests;
1137 int hits;
1138 int mem_hits;
1139 int disk_hits;
1140 int errors;
1141 kb_t kbytes_in;
1142 kb_t kbytes_out;
1143 kb_t hit_kbytes_out;
1144 StatHist miss_svc_time;
1145 StatHist nm_svc_time;
1146 StatHist nh_svc_time;
1147 StatHist hit_svc_time;
1148 StatHist all_svc_time;
1149 } client_http;
1150
1151 struct {
1152
1153 struct {
1154 int requests;
1155 int errors;
1156 kb_t kbytes_in;
1157 kb_t kbytes_out;
1158 } all , http, ftp, other;
1159 } server;
1160
1161 struct {
1162 int pkts_sent;
1163 int queries_sent;
1164 int replies_sent;
1165 int pkts_recv;
1166 int queries_recv;
1167 int replies_recv;
1168 int hits_sent;
1169 int hits_recv;
1170 int replies_queued;
1171 int replies_dropped;
1172 kb_t kbytes_sent;
1173 kb_t q_kbytes_sent;
1174 kb_t r_kbytes_sent;
1175 kb_t kbytes_recv;
1176 kb_t q_kbytes_recv;
1177 kb_t r_kbytes_recv;
1178 StatHist query_svc_time;
1179 StatHist reply_svc_time;
1180 int query_timeouts;
1181 int times_used;
1182 } icp;
1183
1184 struct {
1185 int pkts_sent;
1186 int pkts_recv;
1187 } htcp;
1188
1189 struct {
1190 int requests;
1191 } unlink;
1192
1193 struct {
1194 StatHist svc_time;
1195 } dns;
1196
1197 struct {
1198 int times_used;
1199 kb_t kbytes_sent;
1200 kb_t kbytes_recv;
1201 kb_t memory;
1202 int msgs_sent;
1203 int msgs_recv;
1204 #if USE_CACHE_DIGESTS
1205
1206 cd_guess_stats guess;
1207 #endif
1208
1209 StatHist on_xition_count;
1210 } cd;
1211
1212 struct {
1213 int times_used;
1214 } netdb;
1215 int page_faults;
1216 unsigned long int select_loops;
1217 int select_fds;
1218 double select_time;
1219 double cputime;
1220
1221 struct timeval timestamp;
1222 StatHist comm_icp_incoming;
1223 StatHist comm_dns_incoming;
1224 StatHist comm_http_incoming;
1225 StatHist select_fds_hist;
1226
1227 struct {
1228 struct {
1229 int opens;
1230 int closes;
1231 int reads;
1232 int writes;
1233 int seeks;
1234 int unlinks;
1235 } disk;
1236
1237 struct {
1238 int accepts;
1239 int sockets;
1240 int connects;
1241 int binds;
1242 int closes;
1243 int reads;
1244 int writes;
1245 int recvfroms;
1246 int sendtos;
1247 } sock;
1248 int selects;
1249 } syscalls;
1250 int aborted_requests;
1251
1252 struct {
1253 int files_cleaned;
1254 int outs;
1255 int ins;
1256 } swap;
1257 };
1258
1259 /* per header statistics */
1260
1261 struct _HttpHeaderStat {
1262 const char *label;
1263 HttpHeaderMask *owner_mask;
1264
1265 StatHist hdrUCountDistr;
1266 StatHist fieldTypeDistr;
1267 StatHist ccTypeDistr;
1268 StatHist scTypeDistr;
1269
1270 int parsedCount;
1271 int ccParsedCount;
1272 int scParsedCount;
1273 int destroyedCount;
1274 int busyDestroyedCount;
1275 };
1276
1277
1278 struct _CacheDigest {
1279 /* public, read-only */
1280 char *mask; /* bit mask */
1281 int mask_size; /* mask size in bytes */
1282 int capacity; /* expected maximum for .count, not a hard limit */
1283 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1284 int count; /* number of digested entries */
1285 int del_count; /* number of deletions performed so far */
1286 };
1287
1288
1289 struct _store_rebuild_data {
1290 int objcount; /* # objects successfully reloaded */
1291 int expcount; /* # objects expired */
1292 int scancount; /* # entries scanned or read from state file */
1293 int clashcount; /* # swapfile clashes avoided */
1294 int dupcount; /* # duplicates purged */
1295 int cancelcount; /* # SWAP_LOG_DEL objects purged */
1296 int invalid; /* # bad lines */
1297 int badflags; /* # bad e->flags */
1298 int bad_log_op;
1299 int zero_object_sz;
1300 };
1301
1302 class Logfile;
1303
1304 #include "format/Format.h"
1305 #include "log/Formats.h"
1306 struct _customlog {
1307 char *filename;
1308 ACLList *aclList;
1309 Format::Format *logFormat;
1310 Logfile *logfile;
1311 customlog *next;
1312 Log::Format::log_type type;
1313 };
1314
1315 #endif /* SQUID_STRUCTS_H */