]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
Summary: Merge from delay-class-4
[thirdparty/squid.git] / src / structs.h
1
2 /*
3 * $Id: structs.h,v 1.446 2003/02/05 10:36:55 robertc Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34 #ifndef SQUID_STRUCTS_H
35 #define SQUID_STRUCTS_H
36
37 #include "config.h"
38 #include "splay.h"
39
40 struct _dlink_node {
41 void *data;
42 dlink_node *prev;
43 dlink_node *next;
44 };
45
46 struct _dlink_list {
47 dlink_node *head;
48 dlink_node *tail;
49 };
50
51 #if USE_SSL
52 struct _acl_cert_data {
53 splayNode *values;
54 char *attribute;
55 };
56 #endif
57
58 struct _acl_user_data {
59 splayNode *names;
60 struct {
61 unsigned int case_insensitive:1;
62 unsigned int required:1;
63 } flags;
64 };
65
66 struct _acl_user_ip_data {
67 size_t max;
68 struct {
69 unsigned int strict:1;
70 } flags;
71 };
72
73 struct _acl_ip_data {
74 struct in_addr addr1; /* if addr2 non-zero then its a range */
75 struct in_addr addr2;
76 struct in_addr mask;
77 acl_ip_data *next; /* used for parsing, not for storing */
78 };
79
80 struct _acl_time_data {
81 int weekbits;
82 int start;
83 int stop;
84 acl_time_data *next;
85 };
86
87 struct _acl_name_list {
88 char name[ACL_NAME_SZ];
89 acl_name_list *next;
90 };
91
92 struct _acl_proxy_auth_match_cache {
93 dlink_node link;
94 int matchrv;
95 void *acl_data;
96 };
97
98 struct _acl_deny_info_list {
99 err_type err_page_id;
100 char *err_page_name;
101 acl_name_list *acl_list;
102 acl_deny_info_list *next;
103 };
104
105 #if USE_ARP_ACL
106
107 struct _acl_arp_data {
108 char eth[6];
109 };
110
111 #endif
112
113
114 struct _header_mangler {
115 acl_access *access_list;
116 char *replacement;
117 };
118
119 struct _body_size {
120 dlink_node node;
121 acl_access *access_list;
122 size_t maxsize;
123 };
124
125 struct _http_version_t {
126 unsigned int major;
127 unsigned int minor;
128 };
129
130 #if SQUID_SNMP
131
132 struct _snmp_request_t {
133 u_char *buf;
134 u_char *outbuf;
135 int len;
136 int sock;
137 long reqid;
138 int outlen;
139 struct sockaddr_in from;
140 struct snmp_pdu *PDU;
141 ACLChecklist *acl_checklist;
142 u_char *community;
143 };
144
145 #endif
146
147 struct _acl {
148 char name[ACL_NAME_SZ];
149 squid_acl type;
150 void *data;
151 char *cfgline;
152 acl *next;
153 };
154
155 struct _acl_list {
156 int op;
157 acl *_acl;
158 acl_list *next;
159 };
160
161 class acl_access {
162 public:
163 allow_t allow;
164 acl_list *aclList;
165 char *cfgline;
166 acl_access *next;
167 };
168
169 struct _acl_address {
170 acl_address *next;
171 acl_list *aclList;
172 struct in_addr addr;
173 };
174
175 struct _acl_tos {
176 acl_tos *next;
177 acl_list *aclList;
178 int tos;
179 };
180
181 struct _wordlist {
182 char *key;
183 wordlist *next;
184 };
185
186 struct _intlist {
187 int i;
188 intlist *next;
189 };
190
191 struct _intrange {
192 int i;
193 int j;
194 intrange *next;
195 };
196
197 struct _ushortlist {
198 u_short i;
199 ushortlist *next;
200 };
201
202 struct _relist {
203 char *pattern;
204 regex_t regex;
205 relist *next;
206 };
207
208 struct _sockaddr_in_list {
209 struct sockaddr_in s;
210 sockaddr_in_list *next;
211 };
212
213 #if USE_SSL
214 struct _https_port_list {
215 https_port_list *next;
216 struct sockaddr_in s;
217 char *cert;
218 char *key;
219 int version;
220 char *cipher;
221 char *options;
222 char *clientca;
223 char *cafile;
224 char *capath;
225 char *sslflags;
226 SSL_CTX *sslContext;
227 };
228 #endif
229
230 #if DELAY_POOLS
231 #include "DelayConfig.h"
232 #endif
233
234 struct _authConfig {
235 authScheme *schemes;
236 int n_allocated;
237 int n_configured;
238 };
239
240 struct _RemovalPolicySettings {
241 char *type;
242 wordlist *args;
243 };
244
245 struct _SquidConfig {
246 struct {
247 size_t maxSize;
248 int highWaterMark;
249 int lowWaterMark;
250 } Swap;
251 size_t memMaxSize;
252 struct {
253 char *relayHost;
254 u_short relayPort;
255 peer *_peer;
256 } Wais;
257 struct {
258 size_t min;
259 int pct;
260 size_t max;
261 } quickAbort;
262 size_t readAheadGap;
263 RemovalPolicySettings *replPolicy;
264 RemovalPolicySettings *memPolicy;
265 time_t negativeTtl;
266 time_t negativeDnsTtl;
267 time_t positiveDnsTtl;
268 time_t shutdownLifetime;
269 time_t backgroundPingRate;
270 struct {
271 time_t read;
272 time_t lifetime;
273 time_t connect;
274 time_t peer_connect;
275 time_t request;
276 time_t persistent_request;
277 time_t pconn;
278 time_t siteSelect;
279 time_t deadPeer;
280 int icp_query; /* msec */
281 int icp_query_max; /* msec */
282 int icp_query_min; /* msec */
283 int mcast_icp_query; /* msec */
284 #if USE_IDENT
285 time_t ident;
286 #endif
287 #if !USE_DNSSERVERS
288 time_t idns_retransmit;
289 time_t idns_query;
290 #endif
291 } Timeout;
292 size_t maxRequestHeaderSize;
293 size_t maxRequestBodySize;
294 dlink_list ReplyBodySize;
295 struct {
296 u_short icp;
297 #if USE_HTCP
298 u_short htcp;
299 #endif
300 #if SQUID_SNMP
301 u_short snmp;
302 #endif
303 } Port;
304 struct {
305 sockaddr_in_list *http;
306 #if USE_SSL
307 https_port_list *https;
308 #endif
309 } Sockaddr;
310 #if SQUID_SNMP
311 struct {
312 char *configFile;
313 char *agentInfo;
314 } Snmp;
315 #endif
316 #if USE_WCCP
317 struct {
318 struct in_addr router;
319 struct in_addr incoming;
320 struct in_addr outgoing;
321 int version;
322 } Wccp;
323 #endif
324 char *as_whois_server;
325 struct {
326 char *log;
327 char *access;
328 char *store;
329 char *swap;
330 #if USE_USERAGENT_LOG
331 char *useragent;
332 #endif
333 #if USE_REFERER_LOG
334 char *referer;
335 #endif
336 #if WIP_FWD_LOG
337 char *forward;
338 #endif
339 int rotateNumber;
340 } Log;
341 char *adminEmail;
342 char *effectiveUser;
343 char *effectiveGroup;
344 struct {
345 #if USE_DNSSERVERS
346 char *dnsserver;
347 #endif
348 wordlist *redirect;
349 #if USE_ICMP
350 char *pinger;
351 #endif
352 #if USE_UNLINKD
353 char *unlinkd;
354 #endif
355 char *diskd;
356 } Program;
357 #if USE_DNSSERVERS
358 int dnsChildren;
359 #endif
360 int redirectChildren;
361 time_t authenticateGCInterval;
362 time_t authenticateTTL;
363 time_t authenticateIpTTL;
364 struct {
365 int single_host;
366 char *host;
367 u_short port;
368 } Accel;
369 char *appendDomain;
370 size_t appendDomainLen;
371 char *debugOptions;
372 char *pidFilename;
373 char *mimeTablePathname;
374 char *etcHostsPath;
375 char *visibleHostname;
376 char *uniqueHostname;
377 wordlist *hostnameAliases;
378 char *errHtmlText;
379 struct {
380 char *host;
381 char *file;
382 time_t period;
383 u_short port;
384 } Announce;
385 struct {
386 struct in_addr udp_incoming;
387 struct in_addr udp_outgoing;
388 #if SQUID_SNMP
389 struct in_addr snmp_incoming;
390 struct in_addr snmp_outgoing;
391 #endif
392 struct in_addr client_netmask;
393 } Addrs;
394 size_t tcpRcvBufsz;
395 size_t udpMaxHitObjsz;
396 wordlist *hierarchy_stoplist;
397 wordlist *mcast_group_list;
398 wordlist *dns_testname_list;
399 wordlist *dns_nameservers;
400 peer *peers;
401 int npeers;
402 struct {
403 int size;
404 int low;
405 int high;
406 } ipcache;
407 struct {
408 int size;
409 } fqdncache;
410 int minDirectHops;
411 int minDirectRtt;
412 cachemgr_passwd *passwd_list;
413 struct {
414 int objectsPerBucket;
415 size_t avgObjectSize;
416 size_t maxObjectSize;
417 size_t minObjectSize;
418 size_t maxInMemObjSize;
419 } Store;
420 struct {
421 int high;
422 int low;
423 time_t period;
424 } Netdb;
425 struct {
426 int log_udp;
427 #if USE_DNSSERVERS
428 int res_defnames;
429 #endif
430 int anonymizer;
431 int client_db;
432 int query_icmp;
433 int icp_hit_stale;
434 int buffered_logs;
435 #if ALLOW_SOURCE_PING
436 int source_ping;
437 #endif
438 int common_log;
439 int log_mime_hdrs;
440 int log_fqdn;
441 int announce;
442 int accel_with_proxy;
443 int mem_pools;
444 int test_reachability;
445 int half_closed_clients;
446 #if HTTP_VIOLATIONS
447 int reload_into_ims;
448 #endif
449 int offline;
450 int redir_rewrites_host;
451 int prefer_direct;
452 int nonhierarchical_direct;
453 int strip_query_terms;
454 int redirector_bypass;
455 int ignore_unknown_nameservers;
456 int client_pconns;
457 int server_pconns;
458 #if USE_CACHE_DIGESTS
459 int digest_generation;
460 #endif
461 int log_ip_on_direct;
462 int ie_refresh;
463 int vary_ignore_expire;
464 int pipeline_prefetch;
465 int request_entities;
466 int check_hostnames;
467 int via;
468 int emailErrData;
469 } onoff;
470 acl *aclList;
471 struct {
472 acl_access *http;
473 acl_access *icp;
474 acl_access *miss;
475 acl_access *NeverDirect;
476 acl_access *AlwaysDirect;
477 acl_access *ASlists;
478 acl_access *noCache;
479 #if SQUID_SNMP
480 acl_access *snmp;
481 #endif
482 acl_access *brokenPosts;
483 #if USE_IDENT
484 acl_access *identLookup;
485 #endif
486 acl_access *redirector;
487 acl_access *reply;
488 acl_address *outgoing_address;
489 acl_tos *outgoing_tos;
490 } accessList;
491 acl_deny_info_list *denyInfoList;
492 authConfig authConfiguration;
493 struct {
494 size_t list_width;
495 int list_wrap;
496 char *anon_user;
497 int passive;
498 int sanitycheck;
499 } Ftp;
500 refresh_t *Refresh;
501 struct _cacheSwap {
502 SwapDir **swapDirs;
503 int n_allocated;
504 int n_configured;
505 } cacheSwap;
506 struct {
507 char *directory;
508 } icons;
509 char *errorDirectory;
510 struct {
511 time_t timeout;
512 int maxtries;
513 } retry;
514 struct {
515 size_t limit;
516 } MemPools;
517 #if DELAY_POOLS
518 DelayConfig Delay;
519 #endif
520 struct {
521 int icp_average;
522 int dns_average;
523 int http_average;
524 int icp_min_poll;
525 int dns_min_poll;
526 int http_min_poll;
527 } comm_incoming;
528 int max_open_disk_fds;
529 int uri_whitespace;
530 size_t rangeOffsetLimit;
531 #if MULTICAST_MISS_STREAM
532 struct {
533 struct in_addr addr;
534 int ttl;
535 unsigned short port;
536 char *encode_key;
537 } mcast_miss;
538 #endif
539 header_mangler header_access[HDR_ENUM_END];
540 char *coredump_dir;
541 char *chroot_dir;
542 #if USE_CACHE_DIGESTS
543 struct {
544 int bits_per_entry;
545 time_t rebuild_period;
546 time_t rewrite_period;
547 size_t swapout_chunk_size;
548 int rebuild_chunk_percentage;
549 } digest;
550 #endif
551 #if USE_SSL
552 struct {
553 int unclean_shutdown;
554 char *ssl_engine;
555 } SSL;
556 #endif
557 wordlist *ext_methods;
558 struct {
559 int high_rptm;
560 int high_pf;
561 size_t high_memory;
562 } warnings;
563 char *store_dir_select_algorithm;
564 int sleep_after_fork; /* microseconds */
565 external_acl *externalAclHelperList;
566 #if USE_SSL
567 struct {
568 char *cert;
569 char *key;
570 int version;
571 char *options;
572 char *cipher;
573 char *cafile;
574 char *capath;
575 char *flags;
576 SSL_CTX *sslContext;
577 } ssl_client;
578 #endif
579 };
580
581 struct _SquidConfig2 {
582 struct {
583 char *prefix;
584 int on;
585 } Accel;
586 struct {
587 int enable_purge;
588 } onoff;
589 uid_t effectiveUserID;
590 gid_t effectiveGroupID;
591 };
592
593 struct _close_handler {
594 PF *handler;
595 void *data;
596 close_handler *next;
597 };
598
599 struct _dread_ctrl {
600 int fd;
601 off_t offset;
602 int req_len;
603 char *buf;
604 int end_of_file;
605 DRCB *handler;
606 void *client_data;
607 };
608
609 struct _dnsserver_t {
610 int id;
611 int inpipe;
612 int outpipe;
613 time_t answer;
614 off_t offset;
615 size_t size;
616 char ip_inbuf[DNS_INBUF_SZ];
617 struct timeval dispatch_time;
618 void *data;
619 };
620
621 struct _dwrite_q {
622 off_t file_offset;
623 char *buf;
624 int len;
625 off_t buf_offset;
626 dwrite_q *next;
627 FREE *free_func;
628 };
629
630
631 /* ETag support is rudimantal;
632 * this struct is likely to change
633 * Note: "str" points to memory in HttpHeaderEntry (for now)
634 * so ETags should be used as tmp variables only (for now) */
635 struct _ETag {
636 const char *str; /* quoted-string */
637 int weak; /* true if it is a weak validator */
638 };
639
640 struct _fde_disk {
641 DWCB *wrt_handle;
642 void *wrt_handle_data;
643 dwrite_q *write_q;
644 dwrite_q *write_q_tail;
645 off_t offset;
646 };
647
648 struct _fileMap {
649 int max_n_files;
650 int n_files_in_map;
651 int toggle;
652 int nwords;
653 unsigned long *file_map;
654 };
655
656 /* see Packer.c for description */
657 struct _Packer {
658 /* protected, use interface functions instead */
659 append_f append;
660 vprintf_f vprintf;
661 void *real_handler; /* first parameter to real append and vprintf */
662 };
663
664 /* http status line */
665 struct _HttpStatusLine {
666 /* public, read only */
667 http_version_t version;
668 const char *reason; /* points to a _constant_ string (default or supplied), never free()d */
669 http_status status;
670 };
671
672 /*
673 * Note: HttpBody is used only for messages with a small content that is
674 * known a priory (e.g., error messages).
675 */
676 #include "MemBuf.h"
677 struct _HttpBody {
678 /* private */
679 MemBuf mb;
680 };
681
682 #include "SquidString.h"
683 /* http header extention field */
684 struct _HttpHdrExtField {
685 String name; /* field-name from HTTP/1.1 (no column after name) */
686 String value; /* field-value from HTTP/1.1 */
687 };
688
689 /* http cache control header field */
690 struct _HttpHdrCc {
691 int mask;
692 int max_age;
693 int s_maxage;
694 int max_stale;
695 };
696
697 /* some fields can hold either time or etag specs (e.g. If-Range) */
698 struct _TimeOrTag {
699 ETag tag; /* entity tag */
700 time_t time;
701 int valid; /* true if struct is usable */
702 };
703
704 /* per field statistics */
705 struct _HttpHeaderFieldStat {
706 int aliveCount; /* created but not destroyed (count) */
707 int seenCount; /* #fields we've seen */
708 int parsCount; /* #parsing attempts */
709 int errCount; /* #pasring errors */
710 int repCount; /* #repetitons */
711 };
712
713 /* compiled version of HttpHeaderFieldAttrs plus stats */
714 struct _HttpHeaderFieldInfo {
715 http_hdr_type id;
716 String name;
717 field_type type;
718 HttpHeaderFieldStat stat;
719 };
720
721 struct _HttpHeaderEntry {
722 http_hdr_type id;
723 String name;
724 String value;
725 };
726
727 struct _HttpHeader {
728 /* protected, do not use these, use interface functions instead */
729 Array entries; /* parsed fields in raw format */
730 HttpHeaderMask mask; /* bit set <=> entry present */
731 http_hdr_owner_type owner; /* request or reply */
732 int len; /* length when packed, not counting terminating '\0' */
733 };
734
735 class HttpHdrContRange;
736 struct _HttpReply {
737 /* unsupported, writable, may disappear/change in the future */
738 int hdr_sz; /* sums _stored_ status-line, headers, and <CRLF> */
739
740 /* public, readable; never update these or their .hdr equivalents directly */
741 int content_length;
742 time_t date;
743 time_t last_modified;
744 time_t expires;
745 String content_type;
746 HttpHdrCc *cache_control;
747 HttpHdrContRange *content_range;
748 short int keep_alive;
749
750 /* public, readable */
751 HttpMsgParseState pstate; /* the current parsing state */
752
753 /* public, writable, but use httpReply* interfaces when possible */
754 HttpStatusLine sline;
755 HttpHeader header;
756 HttpBody body; /* for small constant memory-resident text bodies only */
757 size_t maxBodySize;
758 };
759
760 struct _http_state_flags {
761 unsigned int proxying:1;
762 unsigned int keepalive:1;
763 unsigned int only_if_cached:1;
764 unsigned int headers_pushed:1;
765 unsigned int front_end_https:2;
766 };
767
768 struct _ping_data {
769 struct timeval start;
770 struct timeval stop;
771 int n_sent;
772 int n_recv;
773 int n_replies_expected;
774 int timeout; /* msec */
775 int timedout;
776 int w_rtt;
777 int p_rtt;
778 };
779
780 struct _HierarchyLogEntry {
781 hier_code code;
782 char host[SQUIDHOSTNAMELEN];
783 ping_data ping;
784 char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
785 lookup_t cd_lookup; /* cd prediction: none, miss, hit */
786 int n_choices; /* #peers we selected from (cd only) */
787 int n_ichoices; /* #peers with known rtt we selected from (cd only) */
788 struct timeval peer_select_start;
789 struct timeval store_complete_stop;
790 };
791
792 struct _AccessLogEntry {
793 const char *url;
794 struct {
795 method_t method;
796 int code;
797 const char *content_type;
798 http_version_t version;
799 } http;
800 struct {
801 icp_opcode opcode;
802 } icp;
803 struct {
804 struct in_addr caddr;
805 size_t size;
806 log_type code;
807 int msec;
808 const char *rfc931;
809 const char *authuser;
810 #if USE_SSL
811 const char *ssluser;
812 #endif
813 } cache;
814 struct {
815 char *request;
816 char *reply;
817 } headers;
818 struct {
819 const char *method_str;
820 } _private;
821 HierarchyLogEntry hier;
822 };
823
824 struct _ConnStateData {
825 int fd;
826 struct {
827 char *buf;
828 size_t notYetUsed;
829 size_t allocatedSize;
830 } in;
831 struct {
832 size_t size_left; /* How much body left to process */
833 request_t *request; /* Parameters passed to clientReadBody */
834 char *buf;
835 size_t bufsize;
836 CBCB *callback;
837 void *cbdata;
838 } body;
839 auth_type_t auth_type; /* Is this connection based authentication ? if so
840 * what type it is. */
841 /* note this is ONLY connection based because NTLM is against HTTP spec */
842 /* the user details for connection based authentication */
843 auth_user_request_t *auth_user_request;
844 void *currentobject; /* used by the owner of the connection. Opaque otherwise */
845 struct sockaddr_in peer;
846 struct sockaddr_in me;
847 struct in_addr log_addr;
848 char rfc931[USER_IDENT_SZ];
849 int nrequests;
850 struct {
851 int n;
852 time_t until;
853 } defer;
854 struct {
855 int readMoreRequests:1;
856 } flags;
857 bool reading;
858 };
859
860 struct _ipcache_addrs {
861 struct in_addr *in_addrs;
862 unsigned char *bad_mask;
863 unsigned char count;
864 unsigned char cur;
865 unsigned char badcount;
866 };
867
868 struct _domain_ping {
869 char *domain;
870 int do_ping; /* boolean */
871 domain_ping *next;
872 };
873
874 struct _domain_type {
875 char *domain;
876 peer_t type;
877 domain_type *next;
878 };
879
880 #if USE_CACHE_DIGESTS
881 struct _Version {
882 short int current; /* current version */
883 short int required; /* minimal version that can safely handle current version */
884 };
885
886 /* digest control block; used for transmission and storage */
887 struct _StoreDigestCBlock {
888 Version ver;
889 int capacity;
890 int count;
891 int del_count;
892 int mask_size;
893 unsigned char bits_per_entry;
894 unsigned char hash_func_count;
895 short int reserved_short;
896 int reserved[32 - 6];
897 };
898
899 struct _DigestFetchState {
900 PeerDigest *pd;
901 StoreEntry *entry;
902 StoreEntry *old_entry;
903 store_client *sc;
904 store_client *old_sc;
905 request_t *request;
906 int offset;
907 int mask_offset;
908 time_t start_time;
909 time_t resp_time;
910 time_t expires;
911 struct {
912 int msg;
913 int bytes;
914 } sent, recv;
915 char buf[SM_PAGE_SIZE];
916 ssize_t bufofs;
917 digest_read_state_t state;
918 };
919
920 /* statistics for cache digests and other hit "predictors" */
921 struct _cd_guess_stats {
922 /* public, read-only */
923 int true_hits;
924 int false_hits;
925 int true_misses;
926 int false_misses;
927 int close_hits; /* tmp, remove it later */
928 };
929
930 struct _PeerDigest {
931 struct _peer *peer; /* pointer back to peer structure, argh */
932 CacheDigest *cd; /* actual digest structure */
933 String host; /* copy of peer->host */
934 const char *req_result; /* text status of the last request */
935 struct {
936 unsigned int needed:1; /* there were requests for this digest */
937 unsigned int usable:1; /* can be used for lookups */
938 unsigned int requested:1; /* in process of receiving [fresh] digest */
939 } flags;
940 struct {
941 /* all times are absolute unless augmented with _delay */
942 time_t initialized; /* creation */
943 time_t needed; /* first lookup/use by a peer */
944 time_t next_check; /* next scheduled check/refresh event */
945 time_t retry_delay; /* delay before re-checking _invalid_ digest */
946 time_t requested; /* requested a fresh copy of a digest */
947 time_t req_delay; /* last request response time */
948 time_t received; /* received the current copy of a digest */
949 time_t disabled; /* disabled for good */
950 } times;
951 struct {
952 cd_guess_stats guess;
953 int used_count;
954 struct {
955 int msgs;
956 kb_t kbytes;
957 } sent, recv;
958 } stats;
959 };
960
961 #endif
962
963 struct _peer {
964 char *host;
965 peer_t type;
966 struct sockaddr_in in_addr;
967 struct {
968 int pings_sent;
969 int pings_acked;
970 int fetches;
971 int rtt;
972 int ignored_replies;
973 int n_keepalives_sent;
974 int n_keepalives_recv;
975 time_t probe_start;
976 time_t last_query;
977 time_t last_reply;
978 time_t last_connect_failure;
979 time_t last_connect_probe;
980 int logged_state; /* so we can print dead/revived msgs */
981 int conn_open; /* current opened connections */
982 } stats;
983 struct {
984 int version;
985 int counts[ICP_END];
986 u_short port;
987 } icp;
988 #if USE_HTCP
989 struct {
990 double version;
991 int counts[2];
992 u_short port;
993 } htcp;
994 #endif
995 u_short http_port;
996 domain_ping *peer_domain;
997 domain_type *typelist;
998 acl_access *access;
999 struct {
1000 unsigned int proxy_only:1;
1001 unsigned int no_query:1;
1002 unsigned int background_ping:1;
1003 unsigned int no_digest:1;
1004 unsigned int default_parent:1;
1005 unsigned int roundrobin:1;
1006 unsigned int weighted_roundrobin:1;
1007 unsigned int mcast_responder:1;
1008 unsigned int closest_only:1;
1009 #if USE_HTCP
1010 unsigned int htcp:1;
1011 #endif
1012 unsigned int no_netdb_exchange:1;
1013 #if DELAY_POOLS
1014 unsigned int no_delay:1;
1015 #endif
1016 unsigned int allow_miss:1;
1017 #if USE_CARP
1018 unsigned int carp:1;
1019 #endif
1020 } options;
1021 int weight;
1022 int basetime;
1023 struct {
1024 double avg_n_members;
1025 int n_times_counted;
1026 int n_replies_expected;
1027 int ttl;
1028 int id;
1029 struct {
1030 unsigned int count_event_pending:1;
1031 unsigned int counting:1;
1032 } flags;
1033 } mcast;
1034 #if USE_CACHE_DIGESTS
1035 PeerDigest *digest;
1036 char *digest_url;
1037 #endif
1038 int tcp_up; /* 0 if a connect() fails */
1039 struct in_addr addresses[10];
1040 int n_addresses;
1041 int rr_count;
1042 int rr_lastcount;
1043 peer *next;
1044 int test_fd;
1045 #if USE_CARP
1046 struct {
1047 unsigned int hash;
1048 double load_multiplier;
1049 double load_factor; /* normalized weight value */
1050 } carp;
1051 #endif
1052 char *login; /* Proxy authorization */
1053 time_t connect_timeout;
1054 int max_conn;
1055 #if USE_SSL
1056 int use_ssl;
1057 char *sslcert;
1058 char *sslkey;
1059 int sslversion;
1060 char *ssloptions;
1061 char *sslcipher;
1062 char *sslcafile;
1063 char *sslcapath;
1064 char *sslflags;
1065 char *ssldomain;
1066 SSL_CTX *sslContext;
1067 #endif
1068 int front_end_https;
1069 };
1070
1071 struct _net_db_name {
1072 hash_link hash; /* must be first */
1073 net_db_name *next;
1074 netdbEntry *net_db_entry;
1075 };
1076
1077 struct _net_db_peer {
1078 const char *peername;
1079 double hops;
1080 double rtt;
1081 time_t expires;
1082 };
1083
1084 struct _netdbEntry {
1085 hash_link hash; /* must be first */
1086 char network[16];
1087 int pings_sent;
1088 int pings_recv;
1089 double hops;
1090 double rtt;
1091 time_t next_ping_time;
1092 time_t last_use_time;
1093 int link_count;
1094 net_db_name *hosts;
1095 net_db_peer *peers;
1096 int n_peers_alloc;
1097 int n_peers;
1098 };
1099
1100 struct _ps_state {
1101 request_t *request;
1102 StoreEntry *entry;
1103 int always_direct;
1104 int never_direct;
1105 int direct;
1106 PSC *callback;
1107 void *callback_data;
1108 FwdServer *servers;
1109 /*
1110 * Why are these struct sockaddr_in instead of peer *? Because a
1111 * peer structure can become invalid during the peer selection
1112 * phase, specifically after a reconfigure. Thus we need to lookup
1113 * the peer * based on the address when we are finally ready to
1114 * reference the peer structure.
1115 */
1116 struct sockaddr_in first_parent_miss;
1117 struct sockaddr_in closest_parent_miss;
1118 /*
1119 * ->hit and ->secho can be peer* because they should only be
1120 * accessed during the thread when they are set
1121 */
1122 peer *hit;
1123 peer_t hit_type;
1124 #if ALLOW_SOURCE_PING
1125 peer *secho;
1126 #endif
1127 ping_data ping;
1128 ACLChecklist *acl_checklist;
1129 };
1130
1131 #if USE_ICMP
1132 struct _pingerEchoData {
1133 struct in_addr to;
1134 unsigned char opcode;
1135 int psize;
1136 char payload[PINGER_PAYLOAD_SZ];
1137 };
1138
1139 struct _pingerReplyData {
1140 struct in_addr from;
1141 unsigned char opcode;
1142 int rtt;
1143 int hops;
1144 int psize;
1145 char payload[PINGER_PAYLOAD_SZ];
1146 };
1147
1148 #endif
1149
1150 struct _iostats {
1151 struct {
1152 int reads;
1153 int reads_deferred;
1154 int read_hist[16];
1155 int writes;
1156 int write_hist[16];
1157 } Http, Ftp, Gopher, Wais;
1158 };
1159
1160 /* Removal policies */
1161
1162 struct _RemovalPolicyNode {
1163 void *data;
1164 };
1165
1166 struct _RemovalPolicy {
1167 const char *_type;
1168 void *_data;
1169 void (*Free) (RemovalPolicy * policy);
1170 void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1171 void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1172 void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1173 void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1174 RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
1175 RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
1176 void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
1177 };
1178
1179 struct _RemovalPolicyWalker {
1180 RemovalPolicy *_policy;
1181 void *_data;
1182 const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
1183 void (*Done) (RemovalPolicyWalker * walker);
1184 };
1185
1186 struct _RemovalPurgeWalker {
1187 RemovalPolicy *_policy;
1188 void *_data;
1189 int scanned, max_scan, locked;
1190 StoreEntry *(*Next) (RemovalPurgeWalker * walker);
1191 void (*Done) (RemovalPurgeWalker * walker);
1192 };
1193
1194 /* To hard to pull this into another file just yet.
1195 * SO, we stop globals.c seeing it
1196 */
1197 #ifdef __cplusplus
1198 struct request_flags {
1199 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),internal(0),internalclient(0),body_sent(0)
1200 {
1201 #if HTTP_VIOLATIONS
1202 nocache_hack = 1;
1203 #endif
1204 }
1205 unsigned int range:1;
1206 unsigned int nocache:1;
1207 unsigned int ims:1;
1208 unsigned int auth:1;
1209 unsigned int cachable:1;
1210 unsigned int hierarchical:1;
1211 unsigned int loopdetect:1;
1212 unsigned int proxy_keepalive:1;
1213 unsigned int proxying:1;
1214 unsigned int refresh:1;
1215 unsigned int redirected:1;
1216 unsigned int need_validation:1;
1217 #if HTTP_VIOLATIONS
1218 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
1219 #endif
1220 unsigned int accelerated:1;
1221 unsigned int internal:1;
1222 unsigned int internalclient:1;
1223 unsigned int body_sent:1;
1224 bool resetTCP() const;
1225 void setResetTCP();
1226 void clearResetTCP();
1227 private:
1228 unsigned int reset_tcp:1;
1229 };
1230
1231 struct _link_list {
1232 void *ptr;
1233 struct _link_list *next;
1234 };
1235
1236 class HttpHdrRange;
1237 class request_t {
1238 public:
1239 bool multipartRangeRequest() const;
1240
1241 method_t method;
1242 protocol_t protocol;
1243 char login[MAX_LOGIN_SZ];
1244 char host[SQUIDHOSTNAMELEN + 1];
1245 auth_user_request_t *auth_user_request;
1246 u_short port;
1247 String urlpath;
1248 char *canonical;
1249 int link_count; /* free when zero */
1250 request_flags flags;
1251 HttpHdrCc *cache_control;
1252 HttpHdrRange *range;
1253 http_version_t http_ver;
1254 time_t ims;
1255 int imslen;
1256 int max_forwards;
1257 /* these in_addr's could probably be sockaddr_in's */
1258 struct in_addr client_addr;
1259 struct in_addr my_addr;
1260 unsigned short my_port;
1261 HttpHeader header;
1262 ConnStateData *body_connection; /* used by clientReadBody() */
1263 int content_length;
1264 HierarchyLogEntry hier;
1265 err_type errType;
1266 char *peer_login; /* Configured peer login:password */
1267 time_t lastmod; /* Used on refreshes */
1268 const char *vary_headers; /* Used when varying entities are detected. Changes how the store key is calculated */
1269 };
1270 #endif
1271 struct _cachemgr_passwd {
1272 char *passwd;
1273 wordlist *actions;
1274 cachemgr_passwd *next;
1275 };
1276
1277 struct _refresh_t {
1278 const char *pattern;
1279 regex_t compiled_pattern;
1280 time_t min;
1281 double pct;
1282 time_t max;
1283 refresh_t *next;
1284 struct {
1285 unsigned int icase:1;
1286 #if HTTP_VIOLATIONS
1287 unsigned int override_expire:1;
1288 unsigned int override_lastmod:1;
1289 unsigned int reload_into_ims:1;
1290 unsigned int ignore_reload:1;
1291 #endif
1292 } flags;
1293 };
1294
1295 struct _CommWriteStateData {
1296 char *buf;
1297 size_t size;
1298 off_t offset;
1299 CWCB *handler;
1300 void *handler_data;
1301 FREE *free_func;
1302 };
1303
1304 struct _ErrorState {
1305 err_type type;
1306 int page_id;
1307 http_status httpStatus;
1308 auth_user_request_t *auth_user_request;
1309 request_t *request;
1310 char *url;
1311 int xerrno;
1312 char *host;
1313 u_short port;
1314 char *dnsserver_msg;
1315 time_t ttl;
1316 struct in_addr src_addr;
1317 char *redirect_url;
1318 ERCB *callback;
1319 void *callback_data;
1320 struct {
1321 unsigned int flag_cbdata:1;
1322 } flags;
1323 struct {
1324 wordlist *server_msg;
1325 char *request;
1326 char *reply;
1327 } ftp;
1328 char *request_hdrs;
1329 };
1330
1331 /*
1332 * "very generic" histogram;
1333 * see important comments on hbase_f restrictions in StatHist.c
1334 */
1335 struct _StatHist {
1336 int *bins;
1337 int capacity;
1338 double min;
1339 double max;
1340 double scale;
1341 hbase_f *val_in; /* e.g., log() for log-based histogram */
1342 hbase_f *val_out; /* e.g., exp() for log based histogram */
1343 };
1344
1345 /*
1346 * if you add a field to StatCounters,
1347 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1348 */
1349 struct _StatCounters {
1350 struct {
1351 int clients;
1352 int requests;
1353 int hits;
1354 int mem_hits;
1355 int disk_hits;
1356 int errors;
1357 kb_t kbytes_in;
1358 kb_t kbytes_out;
1359 kb_t hit_kbytes_out;
1360 StatHist miss_svc_time;
1361 StatHist nm_svc_time;
1362 StatHist nh_svc_time;
1363 StatHist hit_svc_time;
1364 StatHist all_svc_time;
1365 } client_http;
1366 struct {
1367 struct {
1368 int requests;
1369 int errors;
1370 kb_t kbytes_in;
1371 kb_t kbytes_out;
1372 } all , http, ftp, other;
1373 } server;
1374 struct {
1375 int pkts_sent;
1376 int queries_sent;
1377 int replies_sent;
1378 int pkts_recv;
1379 int queries_recv;
1380 int replies_recv;
1381 int hits_sent;
1382 int hits_recv;
1383 int replies_queued;
1384 int replies_dropped;
1385 kb_t kbytes_sent;
1386 kb_t q_kbytes_sent;
1387 kb_t r_kbytes_sent;
1388 kb_t kbytes_recv;
1389 kb_t q_kbytes_recv;
1390 kb_t r_kbytes_recv;
1391 StatHist query_svc_time;
1392 StatHist reply_svc_time;
1393 int query_timeouts;
1394 int times_used;
1395 } icp;
1396 struct {
1397 int requests;
1398 } unlink;
1399 struct {
1400 StatHist svc_time;
1401 } dns;
1402 struct {
1403 int times_used;
1404 kb_t kbytes_sent;
1405 kb_t kbytes_recv;
1406 kb_t memory;
1407 int msgs_sent;
1408 int msgs_recv;
1409 #if USE_CACHE_DIGESTS
1410 cd_guess_stats guess;
1411 #endif
1412 StatHist on_xition_count;
1413 } cd;
1414 struct {
1415 int times_used;
1416 } netdb;
1417 int page_faults;
1418 int select_loops;
1419 int select_fds;
1420 double select_time;
1421 double cputime;
1422 struct timeval timestamp;
1423 StatHist comm_icp_incoming;
1424 StatHist comm_dns_incoming;
1425 StatHist comm_http_incoming;
1426 StatHist select_fds_hist;
1427 struct {
1428 struct {
1429 int opens;
1430 int closes;
1431 int reads;
1432 int writes;
1433 int seeks;
1434 int unlinks;
1435 } disk;
1436 struct {
1437 int accepts;
1438 int sockets;
1439 int connects;
1440 int binds;
1441 int closes;
1442 int reads;
1443 int writes;
1444 int recvfroms;
1445 int sendtos;
1446 } sock;
1447 #if HAVE_POLL
1448 int polls;
1449 #else
1450 int selects;
1451 #endif
1452 } syscalls;
1453 int aborted_requests;
1454 struct {
1455 int files_cleaned;
1456 int outs;
1457 int ins;
1458 } swap;
1459 };
1460
1461 /* per header statistics */
1462 struct _HttpHeaderStat {
1463 const char *label;
1464 HttpHeaderMask *owner_mask;
1465
1466 StatHist hdrUCountDistr;
1467 StatHist fieldTypeDistr;
1468 StatHist ccTypeDistr;
1469
1470 int parsedCount;
1471 int ccParsedCount;
1472 int destroyedCount;
1473 int busyDestroyedCount;
1474 };
1475
1476 /*
1477 * Do we need to have the dirn in here? I don't think so, since we already
1478 * know the dirn ..
1479 */
1480 struct _storeSwapLogData {
1481 char op;
1482 sfileno swap_filen;
1483 time_t timestamp;
1484 time_t lastref;
1485 time_t expires;
1486 time_t lastmod;
1487 size_t swap_file_sz;
1488 u_short refcount;
1489 u_short flags;
1490 unsigned char key[MD5_DIGEST_CHARS];
1491 };
1492
1493 struct _ClientInfo {
1494 hash_link hash; /* must be first */
1495 struct in_addr addr;
1496 struct {
1497 int result_hist[LOG_TYPE_MAX];
1498 int n_requests;
1499 kb_t kbytes_in;
1500 kb_t kbytes_out;
1501 kb_t hit_kbytes_out;
1502 } Http, Icp;
1503 struct {
1504 time_t time;
1505 int n_req;
1506 int n_denied;
1507 } cutoff;
1508 int n_established; /* number of current established connections */
1509 };
1510
1511 struct _CacheDigest {
1512 /* public, read-only */
1513 char *mask; /* bit mask */
1514 size_t mask_size; /* mask size in bytes */
1515 int capacity; /* expected maximum for .count, not a hard limit */
1516 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1517 int count; /* number of digested entries */
1518 int del_count; /* number of deletions performed so far */
1519 };
1520
1521 struct _FwdServer {
1522 peer *_peer; /* NULL --> origin server */
1523 hier_code code;
1524 FwdServer *next;
1525 };
1526
1527 struct _FwdState {
1528 int client_fd;
1529 StoreEntry *entry;
1530 request_t *request;
1531 FwdServer *servers;
1532 int server_fd;
1533 ErrorState *err;
1534 time_t start;
1535 int n_tries;
1536 #if WIP_FWD_LOG
1537 http_status last_status;
1538 #endif
1539 struct {
1540 unsigned int dont_retry:1;
1541 unsigned int ftp_pasv_failed:1;
1542 } flags;
1543 };
1544
1545 #if USE_HTCP
1546 struct _htcpReplyData {
1547 int hit;
1548 HttpHeader hdr;
1549 u_int32_t msg_id;
1550 double version;
1551 struct {
1552 /* cache-to-origin */
1553 double rtt;
1554 int samp;
1555 int hops;
1556 } cto;
1557 };
1558
1559 #endif
1560
1561
1562 struct _helper_request {
1563 char *buf;
1564 HLPCB *callback;
1565 void *data;
1566 };
1567
1568 struct _helper_stateful_request {
1569 char *buf;
1570 HLPSCB *callback;
1571 int placeholder; /* if 1, this is a dummy request waiting for a stateful helper
1572 * to become available for deferred requests.*/
1573 void *data;
1574 };
1575
1576
1577 struct _helper {
1578 wordlist *cmdline;
1579 dlink_list servers;
1580 dlink_list queue;
1581 const char *id_name;
1582 int n_to_start;
1583 int n_running;
1584 int ipc_type;
1585 time_t last_queue_warn;
1586 struct {
1587 int requests;
1588 int replies;
1589 int queue_size;
1590 int avg_svc_time;
1591 } stats;
1592 };
1593
1594 struct _helper_stateful {
1595 wordlist *cmdline;
1596 dlink_list servers;
1597 dlink_list queue;
1598 const char *id_name;
1599 int n_to_start;
1600 int n_running;
1601 int ipc_type;
1602 MemPool *datapool;
1603 HLPSAVAIL *IsAvailable;
1604 HLPSONEQ *OnEmptyQueue;
1605 time_t last_queue_warn;
1606 struct {
1607 int requests;
1608 int replies;
1609 int queue_size;
1610 int avg_svc_time;
1611 } stats;
1612 };
1613
1614 struct _helper_server {
1615 int index;
1616 int pid;
1617 int rfd;
1618 int wfd;
1619 char *buf;
1620 size_t buf_sz;
1621 off_t offset;
1622 struct timeval dispatch_time;
1623 struct timeval answer_time;
1624 dlink_node link;
1625 helper *parent;
1626 helper_request *request;
1627 struct _helper_flags {
1628 unsigned int alive:1;
1629 unsigned int busy:1;
1630 unsigned int closing:1;
1631 unsigned int shutdown:1;
1632 } flags;
1633 struct {
1634 int uses;
1635 } stats;
1636 };
1637
1638
1639 struct _helper_stateful_server {
1640 int index;
1641 int pid;
1642 int rfd;
1643 int wfd;
1644 char *buf;
1645 size_t buf_sz;
1646 off_t offset;
1647 struct timeval dispatch_time;
1648 struct timeval answer_time;
1649 dlink_node link;
1650 dlink_list queue;
1651 statefulhelper *parent;
1652 helper_stateful_request *request;
1653 struct _helper_stateful_flags {
1654 unsigned int alive:1;
1655 unsigned int busy:1;
1656 unsigned int closing:1;
1657 unsigned int shutdown:1;
1658 stateful_helper_reserve_t reserved;
1659 } flags;
1660 struct {
1661 int uses;
1662 int submits;
1663 int releases;
1664 int deferbyfunc;
1665 int deferbycb;
1666 } stats;
1667 int deferred_requests; /* current number of deferred requests */
1668 void *data; /* State data used by the calling routines */
1669 };
1670
1671 /*
1672 * use this when you need to pass callback data to a blocking
1673 * operation, but you don't want to add that pointer to cbdata
1674 */
1675 struct _generic_cbdata {
1676 void *data;
1677 };
1678
1679 struct _store_rebuild_data {
1680 int objcount; /* # objects successfully reloaded */
1681 int expcount; /* # objects expired */
1682 int scancount; /* # entries scanned or read from state file */
1683 int clashcount; /* # swapfile clashes avoided */
1684 int dupcount; /* # duplicates purged */
1685 int cancelcount; /* # SWAP_LOG_DEL objects purged */
1686 int invalid; /* # bad lines */
1687 int badflags; /* # bad e->flags */
1688 int bad_log_op;
1689 int zero_object_sz;
1690 };
1691
1692 /*
1693 * This defines an fs type
1694 */
1695
1696 struct _storefs_entry {
1697 const char *typestr;
1698 STFSSHUTDOWN *donefunc;
1699 STFSNEW *newfunc;
1700 };
1701
1702 /*
1703 * This defines an repl type
1704 */
1705
1706 struct _storerepl_entry {
1707 const char *typestr;
1708 REMOVALPOLICYCREATE *create;
1709 };
1710
1711 /*
1712 * Async disk IO - this defines a async disk io queue
1713 */
1714
1715 struct _diskd_queue {
1716 int smsgid; /* send sysvmsg id */
1717 int rmsgid; /* recv sysvmsg id */
1718 int wfd; /* queue file descriptor ? */
1719 int away; /* number of requests away */
1720 int sent_count; /* number of messages sent */
1721 int recv_count; /* number of messages received */
1722 struct {
1723 char *buf; /* shm buffer */
1724 link_list *stack;
1725 int id; /* sysvshm id */
1726 } shm;
1727 };
1728
1729 struct _Logfile {
1730 int fd;
1731 char path[MAXPATHLEN];
1732 char *buf;
1733 size_t bufsz;
1734 off_t offset;
1735 struct {
1736 unsigned int fatal:1;
1737 } flags;
1738 };
1739
1740 struct cache_dir_option {
1741 const char *name;
1742 void (*parse) (SwapDir * sd, const char *option, const char *value, int reconfiguring);
1743 void (*dump) (StoreEntry * e, const char *option, SwapDir const * sd);
1744 };
1745
1746 #endif /* SQUID_STRUCTS_H */