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