]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
fix headers to allow inclusion into C++ source
[thirdparty/squid.git] / src / structs.h
1
2 /*
3 * $Id: structs.h,v 1.430 2002/09/15 06:40:58 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 struct _acl_user_data {
52 splayNode *names;
53 struct {
54 unsigned int case_insensitive:1;
55 unsigned int required:1;
56 } flags;
57 };
58
59 struct _acl_user_ip_data {
60 size_t max;
61 struct {
62 unsigned int strict:1;
63 } flags;
64 };
65
66 struct _acl_ip_data {
67 struct in_addr addr1; /* if addr2 non-zero then its a range */
68 struct in_addr addr2;
69 struct in_addr mask;
70 acl_ip_data *next; /* used for parsing, not for storing */
71 };
72
73 struct _acl_time_data {
74 int weekbits;
75 int start;
76 int stop;
77 acl_time_data *next;
78 };
79
80 struct _acl_name_list {
81 char name[ACL_NAME_SZ];
82 acl_name_list *next;
83 };
84
85 struct _acl_proxy_auth_match_cache {
86 dlink_node link;
87 int matchrv;
88 void *acl_data;
89 };
90
91 struct _auth_user_hash_pointer {
92 /* first two items must be same as hash_link */
93 char *key;
94 auth_user_hash_pointer *next;
95 auth_user_t *auth_user;
96 dlink_node link; /* other hash entries that point to the same auth_user */
97 };
98
99 struct _auth_user_ip_t {
100 dlink_node node;
101 /* IP addr this user authenticated from */
102 struct in_addr ipaddr;
103 time_t ip_expiretime;
104 };
105
106 struct _auth_user_t {
107 /* extra fields for proxy_auth */
108 /* this determines what scheme owns the user data. */
109 auth_type_t auth_type;
110 /* the index +1 in the authscheme_list to the authscheme entry */
111 int auth_module;
112 /* we only have one username associated with a given auth_user struct */
113 auth_user_hash_pointer *usernamehash;
114 /* we may have many proxy-authenticate strings that decode to the same user */
115 dlink_list proxy_auth_list;
116 dlink_list proxy_match_cache;
117 /* what ip addresses has this user been seen at?, plus a list length cache */
118 dlink_list ip_list;
119 size_t ipcount;
120 long expiretime;
121 /* how many references are outstanding to this instance */
122 size_t references;
123 /* the auth scheme has it's own private data area */
124 void *scheme_data;
125 /* the auth_user_request structures that link to this. Yes it could be a splaytree
126 * but how many requests will a single username have in parallel? */
127 dlink_list requests;
128 };
129
130 struct _auth_user_request_t {
131 /* this is the object passed around by client_side and acl functions */
132 /* it has request specific data, and links to user specific data */
133 /* the user */
134 auth_user_t *auth_user;
135 /* return a message on the 407 error pages */
136 char *message;
137 /* any scheme specific request related data */
138 void *scheme_data;
139 /* how many 'processes' are working on this data */
140 size_t references;
141 };
142
143
144 /*
145 * This defines an auth scheme module
146 */
147
148 struct _authscheme_entry {
149 const char *typestr;
150 AUTHSACTIVE *Active;
151 AUTHSADDHEADER *AddHeader;
152 AUTHSADDTRAILER *AddTrailer;
153 AUTHSAUTHED *authenticated;
154 AUTHSAUTHUSER *authAuthenticate;
155 AUTHSCONFIGURED *configured;
156 AUTHSDUMP *dump;
157 AUTHSFIXERR *authFixHeader;
158 AUTHSFREE *FreeUser;
159 AUTHSFREECONFIG *freeconfig;
160 AUTHSUSERNAME *authUserUsername;
161 AUTHSONCLOSEC *oncloseconnection; /*optional */
162 AUTHSCONNLASTHEADER *authConnLastHeader;
163 AUTHSDECODE *decodeauth;
164 AUTHSDIRECTION *getdirection;
165 AUTHSPARSE *parse;
166 AUTHSINIT *init;
167 AUTHSREQFREE *requestFree;
168 AUTHSSHUTDOWN *donefunc;
169 AUTHSSTART *authStart;
170 AUTHSSTATS *authStats;
171 };
172
173 /*
174 * This is a configured auth scheme
175 */
176
177 /* private data types */
178 struct _authScheme {
179 /* pointer to the authscheme_list's string entry */
180 const char *typestr;
181 /* the scheme id in the authscheme_list */
182 int Id;
183 /* the scheme's configuration details. */
184 void *scheme_data;
185 };
186
187 struct _acl_deny_info_list {
188 int err_page_id;
189 char *err_page_name;
190 acl_name_list *acl_list;
191 acl_deny_info_list *next;
192 };
193
194 #if USE_ARP_ACL
195
196 struct _acl_arp_data {
197 char eth[6];
198 };
199
200 #endif
201
202 struct _String {
203 /* never reference these directly! */
204 unsigned short int size; /* buffer size; 64K limit */
205 unsigned short int len; /* current length */
206 char *buf;
207 };
208
209 struct _header_mangler {
210 acl_access *access_list;
211 char *replacement;
212 };
213
214 struct _body_size {
215 dlink_node node;
216 acl_access *access_list;
217 size_t maxsize;
218 };
219
220 struct _http_version_t {
221 unsigned int major;
222 unsigned int minor;
223 };
224
225 #if SQUID_SNMP
226
227 struct _snmp_request_t {
228 u_char *buf;
229 u_char *outbuf;
230 int len;
231 int sock;
232 long reqid;
233 int outlen;
234 struct sockaddr_in from;
235 struct snmp_pdu *PDU;
236 aclCheck_t *acl_checklist;
237 u_char *community;
238 };
239
240 #endif
241
242 struct _acl {
243 char name[ACL_NAME_SZ];
244 squid_acl type;
245 void *data;
246 char *cfgline;
247 acl *next;
248 };
249
250 struct _acl_list {
251 int op;
252 acl *_acl;
253 acl_list *next;
254 };
255
256 struct _acl_access {
257 int allow;
258 acl_list *aclList;
259 char *cfgline;
260 acl_access *next;
261 };
262
263 struct _acl_address {
264 acl_address *next;
265 acl_list *aclList;
266 struct in_addr addr;
267 };
268
269 struct _acl_tos {
270 acl_tos *next;
271 acl_list *aclList;
272 int tos;
273 };
274
275 struct _aclCheck_t {
276 const acl_access *accessList;
277 struct in_addr src_addr;
278 struct in_addr dst_addr;
279 struct in_addr my_addr;
280 unsigned short my_port;
281 request_t *request;
282 /* for acls that look at reply data */
283 HttpReply *reply;
284 ConnStateData *conn; /* hack for ident and NTLM */
285 char rfc931[USER_IDENT_SZ];
286 auth_user_request_t *auth_user_request;
287 acl_lookup_state state[ACL_ENUM_MAX];
288 #if SQUID_SNMP
289 char *snmp_community;
290 #endif
291 PF *callback;
292 void *callback_data;
293 external_acl_entry *extacl_entry;
294 };
295
296 struct _wordlist {
297 char *key;
298 wordlist *next;
299 };
300
301 struct _intlist {
302 int i;
303 intlist *next;
304 };
305
306 struct _intrange {
307 int i;
308 int j;
309 intrange *next;
310 };
311
312 struct _ushortlist {
313 u_short i;
314 ushortlist *next;
315 };
316
317 struct _relist {
318 char *pattern;
319 regex_t regex;
320 relist *next;
321 };
322
323 struct _sockaddr_in_list {
324 struct sockaddr_in s;
325 sockaddr_in_list *next;
326 };
327
328 #if USE_SSL
329 struct _https_port_list {
330 https_port_list *next;
331 struct sockaddr_in s;
332 char *cert;
333 char *key;
334 int version;
335 char *cipher;
336 char *options;
337 };
338
339 #endif
340
341 #if DELAY_POOLS
342 struct _delaySpec {
343 int restore_bps;
344 int max_bytes;
345 };
346
347 /* malloc()'d only as far as used (class * sizeof(delaySpec)!
348 * order of elements very important!
349 */
350 struct _delaySpecSet {
351 delaySpec aggregate;
352 delaySpec individual;
353 delaySpec network;
354 };
355
356 struct _delayConfig {
357 unsigned short pools;
358 unsigned short initial;
359 unsigned char *class;
360 delaySpecSet **rates;
361 acl_access **access;
362 };
363
364 #endif
365
366 struct _RemovalPolicySettings {
367 char *type;
368 wordlist *args;
369 };
370
371 struct _SquidConfig {
372 struct {
373 size_t maxSize;
374 int highWaterMark;
375 int lowWaterMark;
376 } Swap;
377 size_t memMaxSize;
378 struct {
379 char *relayHost;
380 u_short relayPort;
381 peer *_peer;
382 } Wais;
383 struct {
384 size_t min;
385 int pct;
386 size_t max;
387 } quickAbort;
388 size_t readAheadGap;
389 RemovalPolicySettings *replPolicy;
390 RemovalPolicySettings *memPolicy;
391 time_t negativeTtl;
392 time_t negativeDnsTtl;
393 time_t positiveDnsTtl;
394 time_t shutdownLifetime;
395 time_t backgroundPingRate;
396 struct {
397 time_t read;
398 time_t lifetime;
399 time_t connect;
400 time_t peer_connect;
401 time_t request;
402 time_t persistent_request;
403 time_t pconn;
404 time_t siteSelect;
405 time_t deadPeer;
406 int icp_query; /* msec */
407 int icp_query_max; /* msec */
408 int icp_query_min; /* msec */
409 int mcast_icp_query; /* msec */
410 #if USE_IDENT
411 time_t ident;
412 #endif
413 #if !USE_DNSSERVERS
414 time_t idns_retransmit;
415 time_t idns_query;
416 #endif
417 } Timeout;
418 size_t maxRequestHeaderSize;
419 size_t maxRequestBodySize;
420 dlink_list ReplyBodySize;
421 struct {
422 u_short icp;
423 #if USE_HTCP
424 u_short htcp;
425 #endif
426 #if SQUID_SNMP
427 u_short snmp;
428 #endif
429 } Port;
430 struct {
431 sockaddr_in_list *http;
432 #if USE_SSL
433 https_port_list *https;
434 #endif
435 } Sockaddr;
436 #if SQUID_SNMP
437 struct {
438 char *configFile;
439 char *agentInfo;
440 } Snmp;
441 #endif
442 #if USE_WCCP
443 struct {
444 struct in_addr router;
445 struct in_addr incoming;
446 struct in_addr outgoing;
447 int version;
448 } Wccp;
449 #endif
450 char *as_whois_server;
451 struct {
452 char *log;
453 char *access;
454 char *store;
455 char *swap;
456 #if USE_USERAGENT_LOG
457 char *useragent;
458 #endif
459 #if USE_REFERER_LOG
460 char *referer;
461 #endif
462 #if WIP_FWD_LOG
463 char *forward;
464 #endif
465 int rotateNumber;
466 } Log;
467 char *adminEmail;
468 char *effectiveUser;
469 char *effectiveGroup;
470 struct {
471 #if USE_DNSSERVERS
472 char *dnsserver;
473 #endif
474 wordlist *redirect;
475 #if USE_ICMP
476 char *pinger;
477 #endif
478 #if USE_UNLINKD
479 char *unlinkd;
480 #endif
481 char *diskd;
482 } Program;
483 #if USE_DNSSERVERS
484 int dnsChildren;
485 #endif
486 int redirectChildren;
487 time_t authenticateGCInterval;
488 time_t authenticateTTL;
489 time_t authenticateIpTTL;
490 struct {
491 int single_host;
492 char *host;
493 u_short port;
494 } Accel;
495 char *appendDomain;
496 size_t appendDomainLen;
497 char *debugOptions;
498 char *pidFilename;
499 char *mimeTablePathname;
500 char *etcHostsPath;
501 char *visibleHostname;
502 char *uniqueHostname;
503 wordlist *hostnameAliases;
504 char *errHtmlText;
505 struct {
506 char *host;
507 char *file;
508 time_t period;
509 u_short port;
510 } Announce;
511 struct {
512 struct in_addr udp_incoming;
513 struct in_addr udp_outgoing;
514 #if SQUID_SNMP
515 struct in_addr snmp_incoming;
516 struct in_addr snmp_outgoing;
517 #endif
518 struct in_addr client_netmask;
519 } Addrs;
520 size_t tcpRcvBufsz;
521 size_t udpMaxHitObjsz;
522 wordlist *hierarchy_stoplist;
523 wordlist *mcast_group_list;
524 wordlist *dns_testname_list;
525 wordlist *dns_nameservers;
526 peer *peers;
527 int npeers;
528 struct {
529 int size;
530 int low;
531 int high;
532 } ipcache;
533 struct {
534 int size;
535 } fqdncache;
536 int minDirectHops;
537 int minDirectRtt;
538 cachemgr_passwd *passwd_list;
539 struct {
540 int objectsPerBucket;
541 size_t avgObjectSize;
542 size_t maxObjectSize;
543 size_t minObjectSize;
544 size_t maxInMemObjSize;
545 } Store;
546 struct {
547 int high;
548 int low;
549 time_t period;
550 } Netdb;
551 struct {
552 int log_udp;
553 #if USE_DNSSERVERS
554 int res_defnames;
555 #endif
556 int anonymizer;
557 int client_db;
558 int query_icmp;
559 int icp_hit_stale;
560 int buffered_logs;
561 #if ALLOW_SOURCE_PING
562 int source_ping;
563 #endif
564 int common_log;
565 int log_mime_hdrs;
566 int log_fqdn;
567 int announce;
568 int accel_with_proxy;
569 int mem_pools;
570 int test_reachability;
571 int half_closed_clients;
572 #if HTTP_VIOLATIONS
573 int reload_into_ims;
574 #endif
575 int offline;
576 int redir_rewrites_host;
577 int prefer_direct;
578 int nonhierarchical_direct;
579 int strip_query_terms;
580 int redirector_bypass;
581 int ignore_unknown_nameservers;
582 int client_pconns;
583 int server_pconns;
584 #if USE_CACHE_DIGESTS
585 int digest_generation;
586 #endif
587 int log_ip_on_direct;
588 int ie_refresh;
589 int vary_ignore_expire;
590 int pipeline_prefetch;
591 int check_hostnames;
592 int via;
593 int emailErrData;
594 } onoff;
595 acl *aclList;
596 struct {
597 acl_access *http;
598 acl_access *icp;
599 acl_access *miss;
600 acl_access *NeverDirect;
601 acl_access *AlwaysDirect;
602 acl_access *ASlists;
603 acl_access *noCache;
604 #if SQUID_SNMP
605 acl_access *snmp;
606 #endif
607 acl_access *brokenPosts;
608 #if USE_IDENT
609 acl_access *identLookup;
610 #endif
611 acl_access *redirector;
612 acl_access *reply;
613 acl_address *outgoing_address;
614 acl_tos *outgoing_tos;
615 } accessList;
616 acl_deny_info_list *denyInfoList;
617 struct _authConfig {
618 authScheme *schemes;
619 int n_allocated;
620 int n_configured;
621 } authConfig;
622 struct {
623 size_t list_width;
624 int list_wrap;
625 char *anon_user;
626 int passive;
627 int sanitycheck;
628 } Ftp;
629 refresh_t *Refresh;
630 struct _cacheSwap {
631 SwapDir *swapDirs;
632 int n_allocated;
633 int n_configured;
634 } cacheSwap;
635 struct {
636 char *directory;
637 } icons;
638 char *errorDirectory;
639 struct {
640 time_t timeout;
641 int maxtries;
642 } retry;
643 struct {
644 size_t limit;
645 } MemPools;
646 #if DELAY_POOLS
647 delayConfig Delay;
648 #endif
649 struct {
650 int icp_average;
651 int dns_average;
652 int http_average;
653 int icp_min_poll;
654 int dns_min_poll;
655 int http_min_poll;
656 } comm_incoming;
657 int max_open_disk_fds;
658 int uri_whitespace;
659 size_t rangeOffsetLimit;
660 #if MULTICAST_MISS_STREAM
661 struct {
662 struct in_addr addr;
663 int ttl;
664 unsigned short port;
665 char *encode_key;
666 } mcast_miss;
667 #endif
668 header_mangler header_access[HDR_ENUM_END];
669 char *coredump_dir;
670 char *chroot_dir;
671 #if USE_CACHE_DIGESTS
672 struct {
673 int bits_per_entry;
674 time_t rebuild_period;
675 time_t rewrite_period;
676 size_t swapout_chunk_size;
677 int rebuild_chunk_percentage;
678 } digest;
679 #endif
680 #if USE_SSL
681 struct {
682 int unclean_shutdown;
683 } SSL;
684 #endif
685 wordlist *ext_methods;
686 struct {
687 int high_rptm;
688 int high_pf;
689 size_t high_memory;
690 } warnings;
691 char *store_dir_select_algorithm;
692 int sleep_after_fork; /* microseconds */
693 external_acl *externalAclHelperList;
694 };
695
696 struct _SquidConfig2 {
697 struct {
698 char *prefix;
699 int on;
700 } Accel;
701 struct {
702 int enable_purge;
703 } onoff;
704 uid_t effectiveUserID;
705 gid_t effectiveGroupID;
706 };
707
708 struct _close_handler {
709 PF *handler;
710 void *data;
711 close_handler *next;
712 };
713
714 struct _dread_ctrl {
715 int fd;
716 off_t offset;
717 int req_len;
718 char *buf;
719 int end_of_file;
720 DRCB *handler;
721 void *client_data;
722 };
723
724 struct _dnsserver_t {
725 int id;
726 int inpipe;
727 int outpipe;
728 time_t answer;
729 off_t offset;
730 size_t size;
731 char ip_inbuf[DNS_INBUF_SZ];
732 struct timeval dispatch_time;
733 void *data;
734 };
735
736 struct _dwrite_q {
737 off_t file_offset;
738 char *buf;
739 int len;
740 off_t buf_offset;
741 dwrite_q *next;
742 FREE *free_func;
743 };
744
745
746 /* ETag support is rudimantal;
747 * this struct is likely to change
748 * Note: "str" points to memory in HttpHeaderEntry (for now)
749 * so ETags should be used as tmp variables only (for now) */
750 struct _ETag {
751 const char *str; /* quoted-string */
752 int weak; /* true if it is a weak validator */
753 };
754
755 struct _fde {
756 unsigned int type;
757 u_short local_port;
758 u_short remote_port;
759 struct in_addr local_addr;
760 unsigned char tos;
761 char ipaddr[16]; /* dotted decimal address of peer */
762 char desc[FD_DESC_SZ];
763 struct {
764 unsigned int open:1;
765 unsigned int close_request:1;
766 unsigned int write_daemon:1;
767 unsigned int closing:1;
768 unsigned int socket_eof:1;
769 unsigned int nolinger:1;
770 unsigned int nonblocking:1;
771 unsigned int ipc:1;
772 unsigned int called_connect:1;
773 unsigned int nodelay:1;
774 unsigned int close_on_exec:1;
775 unsigned int read_pending:1;
776 } flags;
777 int bytes_read;
778 int bytes_written;
779 int uses; /* ie # req's over persistent conn */
780 struct _fde_disk {
781 DWCB *wrt_handle;
782 void *wrt_handle_data;
783 dwrite_q *write_q;
784 dwrite_q *write_q_tail;
785 off_t offset;
786 } disk;
787 PF *read_handler;
788 void *read_data;
789 PF *write_handler;
790 void *write_data;
791 PF *timeout_handler;
792 time_t timeout;
793 void *timeout_data;
794 void *lifetime_data;
795 close_handler *closeHandler; /* linked list */
796 DEFER *defer_check; /* check if we should defer read */
797 void *defer_data;
798 CommWriteStateData *rwstate; /* State data for comm_write */
799 READ_HANDLER *read_method;
800 WRITE_HANDLER *write_method;
801 #if USE_SSL
802 SSL *ssl;
803 int ssl_shutdown:1;
804 #endif
805 };
806
807 struct _fileMap {
808 int max_n_files;
809 int n_files_in_map;
810 int toggle;
811 int nwords;
812 unsigned long *file_map;
813 };
814
815 /* auto-growing memory-resident buffer with printf interface */
816 /* note: when updating this struct, update MemBufNULL #define */
817 struct _MemBuf {
818 /* public, read-only */
819 char *buf;
820 mb_size_t size; /* used space, does not count 0-terminator */
821
822 /* private, stay away; use interface function instead */
823 mb_size_t max_capacity; /* when grows: assert(new_capacity <= max_capacity) */
824 mb_size_t capacity; /* allocated space */
825 unsigned stolen:1; /* the buffer has been stolen for use by someone else */
826 };
827
828 /* see Packer.c for description */
829 struct _Packer {
830 /* protected, use interface functions instead */
831 append_f append;
832 vprintf_f vprintf;
833 void *real_handler; /* first parameter to real append and vprintf */
834 };
835
836 /* http status line */
837 struct _HttpStatusLine {
838 /* public, read only */
839 http_version_t version;
840 const char *reason; /* points to a _constant_ string (default or supplied), never free()d */
841 http_status status;
842 };
843
844 /*
845 * Note: HttpBody is used only for messages with a small content that is
846 * known a priory (e.g., error messages).
847 */
848 struct _HttpBody {
849 /* private */
850 MemBuf mb;
851 };
852
853 /* http header extention field */
854 struct _HttpHdrExtField {
855 String name; /* field-name from HTTP/1.1 (no column after name) */
856 String value; /* field-value from HTTP/1.1 */
857 };
858
859 /* http cache control header field */
860 struct _HttpHdrCc {
861 int mask;
862 int max_age;
863 int s_maxage;
864 int max_stale;
865 };
866
867 /* http byte-range-spec */
868 struct _HttpHdrRangeSpec {
869 ssize_t offset;
870 ssize_t length;
871 };
872
873 /* There may be more than one byte range specified in the request.
874 * This object holds all range specs in order of their appearence
875 * in the request because we SHOULD preserve that order.
876 */
877 struct _HttpHdrRange {
878 Stack specs;
879 };
880
881 /* http content-range header field */
882 struct _HttpHdrContRange {
883 HttpHdrRangeSpec spec;
884 ssize_t elength; /* entity length, not content length */
885 };
886
887 /* some fields can hold either time or etag specs (e.g. If-Range) */
888 struct _TimeOrTag {
889 ETag tag; /* entity tag */
890 time_t time;
891 int valid; /* true if struct is usable */
892 };
893
894 /* data for iterating thru range specs */
895 struct _HttpHdrRangeIter {
896 HttpHdrRangePos pos;
897 const HttpHdrRangeSpec *spec; /* current spec at pos */
898 ssize_t debt_size; /* bytes left to send from the current spec */
899 ssize_t prefix_size; /* the size of the incoming HTTP msg prefix */
900 String boundary; /* boundary for multipart responses */
901 };
902
903 /* constant attributes of http header fields */
904 struct _HttpHeaderFieldAttrs {
905 const char *name;
906 http_hdr_type id;
907 field_type type;
908 };
909
910 /* per field statistics */
911 struct _HttpHeaderFieldStat {
912 int aliveCount; /* created but not destroyed (count) */
913 int seenCount; /* #fields we've seen */
914 int parsCount; /* #parsing attempts */
915 int errCount; /* #pasring errors */
916 int repCount; /* #repetitons */
917 };
918
919 /* compiled version of HttpHeaderFieldAttrs plus stats */
920 struct _HttpHeaderFieldInfo {
921 http_hdr_type id;
922 String name;
923 field_type type;
924 HttpHeaderFieldStat stat;
925 };
926
927 struct _HttpHeaderEntry {
928 http_hdr_type id;
929 String name;
930 String value;
931 };
932
933 struct _HttpHeader {
934 /* protected, do not use these, use interface functions instead */
935 Array entries; /* parsed fields in raw format */
936 HttpHeaderMask mask; /* bit set <=> entry present */
937 http_hdr_owner_type owner; /* request or reply */
938 int len; /* length when packed, not counting terminating '\0' */
939 };
940
941 struct _HttpReply {
942 /* unsupported, writable, may disappear/change in the future */
943 int hdr_sz; /* sums _stored_ status-line, headers, and <CRLF> */
944
945 /* public, readable; never update these or their .hdr equivalents directly */
946 int content_length;
947 time_t date;
948 time_t last_modified;
949 time_t expires;
950 String content_type;
951 HttpHdrCc *cache_control;
952 HttpHdrContRange *content_range;
953 short int keep_alive;
954
955 /* public, readable */
956 HttpMsgParseState pstate; /* the current parsing state */
957
958 /* public, writable, but use httpReply* interfaces when possible */
959 HttpStatusLine sline;
960 HttpHeader header;
961 HttpBody body; /* for small constant memory-resident text bodies only */
962 size_t maxBodySize;
963 };
964
965 struct _http_state_flags {
966 unsigned int proxying:1;
967 unsigned int keepalive:1;
968 unsigned int only_if_cached:1;
969 };
970
971 struct _HttpStateData {
972 StoreEntry *entry;
973 request_t *request;
974 char *reply_hdr;
975 size_t reply_hdr_size;
976 int reply_hdr_state;
977 peer *_peer; /* peer request made to */
978 int eof; /* reached end-of-object? */
979 request_t *orig_request;
980 int fd;
981 http_state_flags flags;
982 FwdState *fwd;
983 };
984
985 struct _icpUdpData {
986 struct sockaddr_in address;
987 void *msg;
988 size_t len;
989 icpUdpData *next;
990 #ifndef LESS_TIMING
991 struct timeval start;
992 #endif
993 log_type logcode;
994 struct timeval queue_time;
995 };
996
997 struct _ping_data {
998 struct timeval start;
999 struct timeval stop;
1000 int n_sent;
1001 int n_recv;
1002 int n_replies_expected;
1003 int timeout; /* msec */
1004 int timedout;
1005 int w_rtt;
1006 int p_rtt;
1007 };
1008
1009 struct _HierarchyLogEntry {
1010 hier_code code;
1011 char host[SQUIDHOSTNAMELEN];
1012 ping_data ping;
1013 char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
1014 peer_select_alg_t alg; /* peer selection algorithm */
1015 lookup_t cd_lookup; /* cd prediction: none, miss, hit */
1016 int n_choices; /* #peers we selected from (cd only) */
1017 int n_ichoices; /* #peers with known rtt we selected from (cd only) */
1018 struct timeval peer_select_start;
1019 struct timeval store_complete_stop;
1020 };
1021
1022 struct _AccessLogEntry {
1023 const char *url;
1024 struct {
1025 method_t method;
1026 int code;
1027 const char *content_type;
1028 http_version_t version;
1029 } http;
1030 struct {
1031 icp_opcode opcode;
1032 } icp;
1033 struct {
1034 struct in_addr caddr;
1035 size_t size;
1036 log_type code;
1037 int msec;
1038 const char *rfc931;
1039 const char *authuser;
1040 } cache;
1041 struct {
1042 char *request;
1043 char *reply;
1044 } headers;
1045 struct {
1046 const char *method_str;
1047 } _private;
1048 HierarchyLogEntry hier;
1049 };
1050
1051 struct _clientStreamNode {
1052 dlink_node node;
1053 dlink_list *head; /* sucks I know, but hey, the interface is limited */
1054 CSR *readfunc;
1055 CSCB *callback;
1056 CSD *detach; /* tell this node the next one downstream wants no more data */
1057 CSS *status;
1058 void *data; /* Context for the node */
1059 char *readbuf; /* where *this* node wants its data returned; */
1060 size_t readlen; /* how much data *this* node can handle */
1061 off_t readoff; /* where *this* node wants it's data read from in the stream */
1062 };
1063
1064 struct _clientHttpRequest {
1065 ConnStateData *conn;
1066 request_t *request; /* Parsed URL ... */
1067 char *uri;
1068 char *log_uri;
1069 struct {
1070 off_t offset;
1071 size_t size;
1072 } out;
1073 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
1074 size_t req_sz; /* raw request size on input, not current request size */
1075 StoreEntry *entry;
1076 StoreEntry *old_entry;
1077 log_type logType;
1078 struct timeval start;
1079 http_version_t http_ver;
1080 AccessLogEntry al;
1081 struct {
1082 unsigned int accel:1;
1083 unsigned int internal:1;
1084 unsigned int done_copying:1;
1085 unsigned int purging:1;
1086 } flags;
1087 struct {
1088 http_status status;
1089 char *location;
1090 } redirect;
1091 dlink_node active;
1092 dlink_list client_stream;
1093 };
1094
1095 struct _ConnStateData {
1096 int fd;
1097 struct {
1098 char *buf;
1099 off_t offset;
1100 size_t size;
1101 } in;
1102 struct {
1103 size_t size_left; /* How much body left to process */
1104 request_t *request; /* Parameters passed to clientReadBody */
1105 char *buf;
1106 size_t bufsize;
1107 CBCB *callback;
1108 void *cbdata;
1109 } body;
1110 auth_type_t auth_type; /* Is this connection based authentication ? if so
1111 * what type it is. */
1112 /* note this is ONLY connection based because NTLM is against HTTP spec */
1113 /* the user details for connection based authentication */
1114 auth_user_request_t *auth_user_request;
1115 void *currentobject; /* used by the owner of the connection. Opaque otherwise */
1116 struct sockaddr_in peer;
1117 struct sockaddr_in me;
1118 struct in_addr log_addr;
1119 char rfc931[USER_IDENT_SZ];
1120 int nrequests;
1121 struct {
1122 int n;
1123 time_t until;
1124 } defer;
1125 };
1126
1127 struct _ipcache_addrs {
1128 struct in_addr *in_addrs;
1129 unsigned char *bad_mask;
1130 unsigned char count;
1131 unsigned char cur;
1132 unsigned char badcount;
1133 };
1134
1135 struct _domain_ping {
1136 char *domain;
1137 int do_ping; /* boolean */
1138 domain_ping *next;
1139 };
1140
1141 struct _domain_type {
1142 char *domain;
1143 peer_t type;
1144 domain_type *next;
1145 };
1146
1147 #if USE_CACHE_DIGESTS
1148 struct _Version {
1149 short int current; /* current version */
1150 short int required; /* minimal version that can safely handle current version */
1151 };
1152
1153 /* digest control block; used for transmission and storage */
1154 struct _StoreDigestCBlock {
1155 Version ver;
1156 int capacity;
1157 int count;
1158 int del_count;
1159 int mask_size;
1160 unsigned char bits_per_entry;
1161 unsigned char hash_func_count;
1162 short int reserved_short;
1163 int reserved[32 - 6];
1164 };
1165
1166 struct _DigestFetchState {
1167 PeerDigest *pd;
1168 StoreEntry *entry;
1169 StoreEntry *old_entry;
1170 store_client *sc;
1171 store_client *old_sc;
1172 request_t *request;
1173 int offset;
1174 int mask_offset;
1175 time_t start_time;
1176 time_t resp_time;
1177 time_t expires;
1178 struct {
1179 int msg;
1180 int bytes;
1181 } sent, recv;
1182 char buf[SM_PAGE_SIZE];
1183 ssize_t bufofs;
1184 digest_read_state_t state;
1185 };
1186
1187 /* statistics for cache digests and other hit "predictors" */
1188 struct _cd_guess_stats {
1189 /* public, read-only */
1190 int true_hits;
1191 int false_hits;
1192 int true_misses;
1193 int false_misses;
1194 int close_hits; /* tmp, remove it later */
1195 };
1196
1197 struct _PeerDigest {
1198 peer *peer; /* pointer back to peer structure, argh */
1199 CacheDigest *cd; /* actual digest structure */
1200 String host; /* copy of peer->host */
1201 const char *req_result; /* text status of the last request */
1202 struct {
1203 unsigned int needed:1; /* there were requests for this digest */
1204 unsigned int usable:1; /* can be used for lookups */
1205 unsigned int requested:1; /* in process of receiving [fresh] digest */
1206 } flags;
1207 struct {
1208 /* all times are absolute unless augmented with _delay */
1209 time_t initialized; /* creation */
1210 time_t needed; /* first lookup/use by a peer */
1211 time_t next_check; /* next scheduled check/refresh event */
1212 time_t retry_delay; /* delay before re-checking _invalid_ digest */
1213 time_t requested; /* requested a fresh copy of a digest */
1214 time_t req_delay; /* last request response time */
1215 time_t received; /* received the current copy of a digest */
1216 time_t disabled; /* disabled for good */
1217 } times;
1218 struct {
1219 cd_guess_stats guess;
1220 int used_count;
1221 struct {
1222 int msgs;
1223 kb_t kbytes;
1224 } sent, recv;
1225 } stats;
1226 };
1227
1228 #endif
1229
1230 struct _peer {
1231 char *host;
1232 peer_t type;
1233 struct sockaddr_in in_addr;
1234 struct {
1235 int pings_sent;
1236 int pings_acked;
1237 int fetches;
1238 int rtt;
1239 int ignored_replies;
1240 int n_keepalives_sent;
1241 int n_keepalives_recv;
1242 time_t probe_start;
1243 time_t last_query;
1244 time_t last_reply;
1245 time_t last_connect_failure;
1246 time_t last_connect_probe;
1247 int logged_state; /* so we can print dead/revived msgs */
1248 int conn_open; /* current opened connections */
1249 } stats;
1250 struct {
1251 int version;
1252 int counts[ICP_END];
1253 u_short port;
1254 } icp;
1255 #if USE_HTCP
1256 struct {
1257 double version;
1258 int counts[2];
1259 u_short port;
1260 } htcp;
1261 #endif
1262 u_short http_port;
1263 domain_ping *peer_domain;
1264 domain_type *typelist;
1265 acl_access *access;
1266 struct {
1267 unsigned int proxy_only:1;
1268 unsigned int no_query:1;
1269 unsigned int background_ping:1;
1270 unsigned int no_digest:1;
1271 unsigned int default_parent:1;
1272 unsigned int roundrobin:1;
1273 unsigned int weighted_roundrobin:1;
1274 unsigned int mcast_responder:1;
1275 unsigned int closest_only:1;
1276 #if USE_HTCP
1277 unsigned int htcp:1;
1278 #endif
1279 unsigned int no_netdb_exchange:1;
1280 #if DELAY_POOLS
1281 unsigned int no_delay:1;
1282 #endif
1283 unsigned int allow_miss:1;
1284 #if USE_CARP
1285 unsigned int carp:1;
1286 #endif
1287 } options;
1288 int weight;
1289 int basetime;
1290 struct {
1291 double avg_n_members;
1292 int n_times_counted;
1293 int n_replies_expected;
1294 int ttl;
1295 int id;
1296 struct {
1297 unsigned int count_event_pending:1;
1298 unsigned int counting:1;
1299 } flags;
1300 } mcast;
1301 #if USE_CACHE_DIGESTS
1302 PeerDigest *digest;
1303 char *digest_url;
1304 #endif
1305 int tcp_up; /* 0 if a connect() fails */
1306 struct in_addr addresses[10];
1307 int n_addresses;
1308 int rr_count;
1309 int rr_lastcount;
1310 peer *next;
1311 int test_fd;
1312 #if USE_CARP
1313 struct {
1314 unsigned int hash;
1315 double load_multiplier;
1316 double load_factor; /* normalized weight value */
1317 } carp;
1318 #endif
1319 char *login; /* Proxy authorization */
1320 time_t connect_timeout;
1321 int max_conn;
1322 };
1323
1324 struct _net_db_name {
1325 hash_link hash; /* must be first */
1326 net_db_name *next;
1327 netdbEntry *net_db_entry;
1328 };
1329
1330 struct _net_db_peer {
1331 const char *peername;
1332 double hops;
1333 double rtt;
1334 time_t expires;
1335 };
1336
1337 struct _netdbEntry {
1338 hash_link hash; /* must be first */
1339 char network[16];
1340 int pings_sent;
1341 int pings_recv;
1342 double hops;
1343 double rtt;
1344 time_t next_ping_time;
1345 time_t last_use_time;
1346 int link_count;
1347 net_db_name *hosts;
1348 net_db_peer *peers;
1349 int n_peers_alloc;
1350 int n_peers;
1351 };
1352
1353 struct _ps_state {
1354 request_t *request;
1355 StoreEntry *entry;
1356 int always_direct;
1357 int never_direct;
1358 int direct;
1359 PSC *callback;
1360 void *callback_data;
1361 FwdServer *servers;
1362 /*
1363 * Why are these struct sockaddr_in instead of peer *? Because a
1364 * peer structure can become invalid during the peer selection
1365 * phase, specifically after a reconfigure. Thus we need to lookup
1366 * the peer * based on the address when we are finally ready to
1367 * reference the peer structure.
1368 */
1369 struct sockaddr_in first_parent_miss;
1370 struct sockaddr_in closest_parent_miss;
1371 /*
1372 * ->hit and ->secho can be peer* because they should only be
1373 * accessed during the thread when they are set
1374 */
1375 peer *hit;
1376 peer_t hit_type;
1377 #if ALLOW_SOURCE_PING
1378 peer *secho;
1379 #endif
1380 ping_data ping;
1381 aclCheck_t *acl_checklist;
1382 };
1383
1384 #if USE_ICMP
1385 struct _pingerEchoData {
1386 struct in_addr to;
1387 unsigned char opcode;
1388 int psize;
1389 char payload[PINGER_PAYLOAD_SZ];
1390 };
1391
1392 struct _pingerReplyData {
1393 struct in_addr from;
1394 unsigned char opcode;
1395 int rtt;
1396 int hops;
1397 int psize;
1398 char payload[PINGER_PAYLOAD_SZ];
1399 };
1400
1401 #endif
1402
1403 struct _icp_common_t {
1404 unsigned char opcode; /* opcode */
1405 unsigned char version; /* version number */
1406 unsigned short length; /* total length (bytes) */
1407 u_int32_t reqnum; /* req number (req'd for UDP) */
1408 u_int32_t flags;
1409 u_int32_t pad;
1410 u_int32_t shostid; /* sender host id */
1411 };
1412
1413 struct _iostats {
1414 struct {
1415 int reads;
1416 int reads_deferred;
1417 int read_hist[16];
1418 int writes;
1419 int write_hist[16];
1420 } Http, Ftp, Gopher, Wais;
1421 };
1422
1423 struct _mem_node {
1424 char data[SM_PAGE_SIZE];
1425 int len;
1426 mem_node *next;
1427 };
1428
1429 struct _mem_hdr {
1430 mem_node *head;
1431 mem_node *tail;
1432 int origin_offset;
1433 };
1434
1435 /* keep track each client receiving data from that particular StoreEntry */
1436 struct _store_client {
1437 int type;
1438 off_t copy_offset;
1439 off_t cmp_offset;
1440 size_t copy_size;
1441 char *copy_buf;
1442 STCB *callback;
1443 void *callback_data;
1444 #if STORE_CLIENT_LIST_DEBUG
1445 void *owner;
1446 #endif
1447 StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
1448 storeIOState *swapin_sio;
1449 struct {
1450 unsigned int disk_io_pending:1;
1451 unsigned int store_copying:1;
1452 unsigned int copy_event_pending:1;
1453 } flags;
1454 #if DELAY_POOLS
1455 delay_id delay_id;
1456 #endif
1457 dlink_node node;
1458 };
1459
1460
1461 /* Removal policies */
1462
1463 struct _RemovalPolicyNode {
1464 void *data;
1465 };
1466
1467 struct _RemovalPolicy {
1468 const char *_type;
1469 void *_data;
1470 void (*Free) (RemovalPolicy * policy);
1471 void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1472 void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1473 void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1474 void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1475 RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
1476 RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
1477 void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
1478 };
1479
1480 struct _RemovalPolicyWalker {
1481 RemovalPolicy *_policy;
1482 void *_data;
1483 const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
1484 void (*Done) (RemovalPolicyWalker * walker);
1485 };
1486
1487 struct _RemovalPurgeWalker {
1488 RemovalPolicy *_policy;
1489 void *_data;
1490 int scanned, max_scan, locked;
1491 StoreEntry *(*Next) (RemovalPurgeWalker * walker);
1492 void (*Done) (RemovalPurgeWalker * walker);
1493 };
1494
1495 /* This structure can be freed while object is purged out from memory */
1496 struct _MemObject {
1497 method_t method;
1498 char *url;
1499 mem_hdr data_hdr;
1500 off_t inmem_hi;
1501 off_t inmem_lo;
1502 dlink_list clients;
1503 int nclients;
1504 struct {
1505 off_t queue_offset; /* relative to in-mem data */
1506 mem_node *memnode; /* which node we're currently paging out */
1507 storeIOState *sio;
1508 } swapout;
1509 HttpReply *reply;
1510 request_t *request;
1511 struct timeval start_ping;
1512 IRCB *ping_reply_callback;
1513 void *ircb_data;
1514 int fd; /* FD of client creating this entry */
1515 struct {
1516 STABH *callback;
1517 void *data;
1518 } abort;
1519 char *log_url;
1520 RemovalPolicyNode repl;
1521 int id;
1522 ssize_t object_sz;
1523 size_t swap_hdr_sz;
1524 #if URL_CHECKSUM_DEBUG
1525 unsigned int chksum;
1526 #endif
1527 const char *vary_headers;
1528 };
1529
1530 struct _StoreEntry {
1531 hash_link hash; /* must be first */
1532 MemObject *mem_obj;
1533 RemovalPolicyNode repl;
1534 /* START OF ON-DISK STORE_META_STD TLV field */
1535 time_t timestamp;
1536 time_t lastref;
1537 time_t expires;
1538 time_t lastmod;
1539 size_t swap_file_sz;
1540 u_short refcount;
1541 u_short flags;
1542 /* END OF ON-DISK STORE_META_STD */
1543 sfileno swap_filen:25;
1544 sdirno swap_dirn:7;
1545 u_short lock_count; /* Assume < 65536! */
1546 mem_status_t mem_status:3;
1547 ping_status_t ping_status:3;
1548 store_status_t store_status:3;
1549 swap_status_t swap_status:3;
1550 };
1551
1552 struct _SwapDir {
1553 const char *type;
1554 int cur_size;
1555 int low_size;
1556 int max_size;
1557 char *path;
1558 int index; /* This entry's index into the swapDirs array */
1559 ssize_t max_objsize;
1560 RemovalPolicy *repl;
1561 int removals;
1562 int scanned;
1563 struct {
1564 unsigned int selected:1;
1565 unsigned int read_only:1;
1566 } flags;
1567 STINIT *init; /* Initialise the fs */
1568 STNEWFS *newfs; /* Create a new fs */
1569 STDUMP *dump; /* Dump fs config snippet */
1570 STFREE *freefs; /* Free the fs data */
1571 STDBLCHECK *dblcheck; /* Double check the obj integrity */
1572 STSTATFS *statfs; /* Dump fs statistics */
1573 STMAINTAINFS *maintainfs; /* Replacement maintainence */
1574 STCHECKOBJ *checkobj; /* Check if the fs will store an object */
1575 /* These two are notifications */
1576 STREFOBJ *refobj; /* Reference this object */
1577 STUNREFOBJ *unrefobj; /* Unreference this object */
1578 STCALLBACK *callback; /* Handle pending callbacks */
1579 STSYNC *sync; /* Sync the directory */
1580 struct {
1581 STOBJCREATE *create;
1582 STOBJOPEN *open;
1583 STOBJCLOSE *close;
1584 STOBJREAD *read;
1585 STOBJWRITE *write;
1586 STOBJUNLINK *unlink;
1587 } obj;
1588 struct {
1589 STLOGOPEN *open;
1590 STLOGCLOSE *close;
1591 STLOGWRITE *write;
1592 struct {
1593 STLOGCLEANSTART *start;
1594 STLOGCLEANNEXTENTRY *nextentry;
1595 STLOGCLEANWRITE *write;
1596 STLOGCLEANDONE *done;
1597 void *state;
1598 } clean;
1599 int writes_since_clean;
1600 } log;
1601 struct {
1602 int blksize;
1603 } fs;
1604 void *fsdata;
1605 };
1606
1607 struct _request_flags {
1608 unsigned int range:1;
1609 unsigned int nocache:1;
1610 unsigned int ims:1;
1611 unsigned int auth:1;
1612 unsigned int cachable:1;
1613 unsigned int hierarchical:1;
1614 unsigned int loopdetect:1;
1615 unsigned int proxy_keepalive:1;
1616 unsigned int proxying:1;
1617 unsigned int refresh:1;
1618 unsigned int redirected:1;
1619 unsigned int need_validation:1;
1620 #if HTTP_VIOLATIONS
1621 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
1622 #endif
1623 unsigned int accelerated:1;
1624 unsigned int internal:1;
1625 unsigned int internalclient:1;
1626 unsigned int body_sent:1;
1627 unsigned int reset_tcp:1;
1628 };
1629
1630 struct _link_list {
1631 void *ptr;
1632 struct _link_list *next;
1633 };
1634
1635 struct _storeIOState {
1636 sdirno swap_dirn;
1637 sfileno swap_filen;
1638 StoreEntry *e; /* Need this so the FS layers can play god */
1639 mode_t mode;
1640 size_t st_size; /* do stat(2) after read open */
1641 off_t offset; /* current on-disk offset pointer */
1642 STFNCB *file_callback; /* called on delayed sfileno assignments */
1643 STIOCB *callback;
1644 void *callback_data;
1645 struct {
1646 STRCB *callback;
1647 void *callback_data;
1648 } read;
1649 struct {
1650 unsigned int closing:1; /* debugging aid */
1651 } flags;
1652 void *fsstate;
1653 };
1654
1655 struct _request_t {
1656 method_t method;
1657 protocol_t protocol;
1658 char login[MAX_LOGIN_SZ];
1659 char host[SQUIDHOSTNAMELEN + 1];
1660 auth_user_request_t *auth_user_request;
1661 u_short port;
1662 String urlpath;
1663 char *canonical;
1664 int link_count; /* free when zero */
1665 request_flags flags;
1666 HttpHdrCc *cache_control;
1667 HttpHdrRange *range;
1668 http_version_t http_ver;
1669 time_t ims;
1670 int imslen;
1671 int max_forwards;
1672 /* these in_addr's could probably be sockaddr_in's */
1673 struct in_addr client_addr;
1674 struct in_addr my_addr;
1675 unsigned short my_port;
1676 HttpHeader header;
1677 ConnStateData *body_connection; /* used by clientReadBody() */
1678 int content_length;
1679 HierarchyLogEntry hier;
1680 err_type errType;
1681 char *peer_login; /* Configured peer login:password */
1682 time_t lastmod; /* Used on refreshes */
1683 const char *vary_headers; /* Used when varying entities are detected. Changes how the store key is calculated */
1684 };
1685
1686 struct _cachemgr_passwd {
1687 char *passwd;
1688 wordlist *actions;
1689 cachemgr_passwd *next;
1690 };
1691
1692 struct _refresh_t {
1693 const char *pattern;
1694 regex_t compiled_pattern;
1695 time_t min;
1696 double pct;
1697 time_t max;
1698 refresh_t *next;
1699 struct {
1700 unsigned int icase:1;
1701 #if HTTP_VIOLATIONS
1702 unsigned int override_expire:1;
1703 unsigned int override_lastmod:1;
1704 unsigned int reload_into_ims:1;
1705 unsigned int ignore_reload:1;
1706 #endif
1707 } flags;
1708 };
1709
1710 struct _CommWriteStateData {
1711 char *buf;
1712 size_t size;
1713 off_t offset;
1714 CWCB *handler;
1715 void *handler_data;
1716 FREE *free_func;
1717 };
1718
1719 struct _ErrorState {
1720 err_type type;
1721 int page_id;
1722 http_status httpStatus;
1723 auth_user_request_t *auth_user_request;
1724 request_t *request;
1725 char *url;
1726 int xerrno;
1727 char *host;
1728 u_short port;
1729 char *dnsserver_msg;
1730 time_t ttl;
1731 struct in_addr src_addr;
1732 char *redirect_url;
1733 ERCB *callback;
1734 void *callback_data;
1735 struct {
1736 unsigned int flag_cbdata:1;
1737 } flags;
1738 struct {
1739 wordlist *server_msg;
1740 char *request;
1741 char *reply;
1742 } ftp;
1743 char *request_hdrs;
1744 };
1745
1746 /*
1747 * "very generic" histogram;
1748 * see important comments on hbase_f restrictions in StatHist.c
1749 */
1750 struct _StatHist {
1751 int *bins;
1752 int capacity;
1753 double min;
1754 double max;
1755 double scale;
1756 hbase_f *val_in; /* e.g., log() for log-based histogram */
1757 hbase_f *val_out; /* e.g., exp() for log based histogram */
1758 };
1759
1760 /*
1761 * if you add a field to StatCounters,
1762 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1763 */
1764 struct _StatCounters {
1765 struct {
1766 int clients;
1767 int requests;
1768 int hits;
1769 int mem_hits;
1770 int disk_hits;
1771 int errors;
1772 kb_t kbytes_in;
1773 kb_t kbytes_out;
1774 kb_t hit_kbytes_out;
1775 StatHist miss_svc_time;
1776 StatHist nm_svc_time;
1777 StatHist nh_svc_time;
1778 StatHist hit_svc_time;
1779 StatHist all_svc_time;
1780 } client_http;
1781 struct {
1782 struct {
1783 int requests;
1784 int errors;
1785 kb_t kbytes_in;
1786 kb_t kbytes_out;
1787 } all , http, ftp, other;
1788 } server;
1789 struct {
1790 int pkts_sent;
1791 int queries_sent;
1792 int replies_sent;
1793 int pkts_recv;
1794 int queries_recv;
1795 int replies_recv;
1796 int hits_sent;
1797 int hits_recv;
1798 int replies_queued;
1799 int replies_dropped;
1800 kb_t kbytes_sent;
1801 kb_t q_kbytes_sent;
1802 kb_t r_kbytes_sent;
1803 kb_t kbytes_recv;
1804 kb_t q_kbytes_recv;
1805 kb_t r_kbytes_recv;
1806 StatHist query_svc_time;
1807 StatHist reply_svc_time;
1808 int query_timeouts;
1809 int times_used;
1810 } icp;
1811 struct {
1812 int requests;
1813 } unlink;
1814 struct {
1815 StatHist svc_time;
1816 } dns;
1817 struct {
1818 int times_used;
1819 kb_t kbytes_sent;
1820 kb_t kbytes_recv;
1821 kb_t memory;
1822 int msgs_sent;
1823 int msgs_recv;
1824 #if USE_CACHE_DIGESTS
1825 cd_guess_stats guess;
1826 #endif
1827 StatHist on_xition_count;
1828 } cd;
1829 struct {
1830 int times_used;
1831 } netdb;
1832 int page_faults;
1833 int select_loops;
1834 int select_fds;
1835 double select_time;
1836 double cputime;
1837 struct timeval timestamp;
1838 StatHist comm_icp_incoming;
1839 StatHist comm_dns_incoming;
1840 StatHist comm_http_incoming;
1841 StatHist select_fds_hist;
1842 struct {
1843 struct {
1844 int opens;
1845 int closes;
1846 int reads;
1847 int writes;
1848 int seeks;
1849 int unlinks;
1850 } disk;
1851 struct {
1852 int accepts;
1853 int sockets;
1854 int connects;
1855 int binds;
1856 int closes;
1857 int reads;
1858 int writes;
1859 int recvfroms;
1860 int sendtos;
1861 } sock;
1862 #if HAVE_POLL
1863 int polls;
1864 #else
1865 int selects;
1866 #endif
1867 } syscalls;
1868 int aborted_requests;
1869 struct {
1870 int files_cleaned;
1871 int outs;
1872 int ins;
1873 } swap;
1874 };
1875
1876 /* per header statistics */
1877 struct _HttpHeaderStat {
1878 const char *label;
1879 HttpHeaderMask *owner_mask;
1880
1881 StatHist hdrUCountDistr;
1882 StatHist fieldTypeDistr;
1883 StatHist ccTypeDistr;
1884
1885 int parsedCount;
1886 int ccParsedCount;
1887 int destroyedCount;
1888 int busyDestroyedCount;
1889 };
1890
1891
1892 struct _tlv {
1893 char type;
1894 int length;
1895 void *value;
1896 tlv *next;
1897 };
1898
1899 /*
1900 * Do we need to have the dirn in here? I don't think so, since we already
1901 * know the dirn ..
1902 */
1903 struct _storeSwapLogData {
1904 char op;
1905 sfileno swap_filen;
1906 time_t timestamp;
1907 time_t lastref;
1908 time_t expires;
1909 time_t lastmod;
1910 size_t swap_file_sz;
1911 u_short refcount;
1912 u_short flags;
1913 unsigned char key[MD5_DIGEST_CHARS];
1914 };
1915
1916 struct _ClientInfo {
1917 hash_link hash; /* must be first */
1918 struct in_addr addr;
1919 struct {
1920 int result_hist[LOG_TYPE_MAX];
1921 int n_requests;
1922 kb_t kbytes_in;
1923 kb_t kbytes_out;
1924 kb_t hit_kbytes_out;
1925 } Http, Icp;
1926 struct {
1927 time_t time;
1928 int n_req;
1929 int n_denied;
1930 } cutoff;
1931 int n_established; /* number of current established connections */
1932 };
1933
1934 struct _CacheDigest {
1935 /* public, read-only */
1936 char *mask; /* bit mask */
1937 size_t mask_size; /* mask size in bytes */
1938 int capacity; /* expected maximum for .count, not a hard limit */
1939 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1940 int count; /* number of digested entries */
1941 int del_count; /* number of deletions performed so far */
1942 };
1943
1944 struct _FwdServer {
1945 peer *_peer; /* NULL --> origin server */
1946 hier_code code;
1947 FwdServer *next;
1948 };
1949
1950 struct _FwdState {
1951 int client_fd;
1952 StoreEntry *entry;
1953 request_t *request;
1954 FwdServer *servers;
1955 int server_fd;
1956 ErrorState *err;
1957 time_t start;
1958 int n_tries;
1959 #if WIP_FWD_LOG
1960 http_status last_status;
1961 #endif
1962 struct {
1963 unsigned int dont_retry:1;
1964 unsigned int ftp_pasv_failed:1;
1965 } flags;
1966 };
1967
1968 #if USE_HTCP
1969 struct _htcpReplyData {
1970 int hit;
1971 HttpHeader hdr;
1972 u_int32_t msg_id;
1973 double version;
1974 struct {
1975 /* cache-to-origin */
1976 double rtt;
1977 int samp;
1978 int hops;
1979 } cto;
1980 };
1981
1982 #endif
1983
1984
1985 struct _helper_request {
1986 char *buf;
1987 HLPCB *callback;
1988 void *data;
1989 };
1990
1991 struct _helper_stateful_request {
1992 char *buf;
1993 HLPSCB *callback;
1994 int placeholder; /* if 1, this is a dummy request waiting for a stateful helper
1995 * to become available for deferred requests.*/
1996 void *data;
1997 };
1998
1999
2000 struct _helper {
2001 wordlist *cmdline;
2002 dlink_list servers;
2003 dlink_list queue;
2004 const char *id_name;
2005 int n_to_start;
2006 int n_running;
2007 int ipc_type;
2008 time_t last_queue_warn;
2009 struct {
2010 int requests;
2011 int replies;
2012 int queue_size;
2013 int avg_svc_time;
2014 } stats;
2015 };
2016
2017 struct _helper_stateful {
2018 wordlist *cmdline;
2019 dlink_list servers;
2020 dlink_list queue;
2021 const char *id_name;
2022 int n_to_start;
2023 int n_running;
2024 int ipc_type;
2025 MemPool *datapool;
2026 HLPSAVAIL *IsAvailable;
2027 HLPSONEQ *OnEmptyQueue;
2028 time_t last_queue_warn;
2029 struct {
2030 int requests;
2031 int replies;
2032 int queue_size;
2033 int avg_svc_time;
2034 } stats;
2035 };
2036
2037 struct _helper_server {
2038 int index;
2039 int pid;
2040 int rfd;
2041 int wfd;
2042 char *buf;
2043 size_t buf_sz;
2044 off_t offset;
2045 struct timeval dispatch_time;
2046 struct timeval answer_time;
2047 dlink_node link;
2048 helper *parent;
2049 helper_request *request;
2050 struct _helper_flags {
2051 unsigned int alive:1;
2052 unsigned int busy:1;
2053 unsigned int closing:1;
2054 unsigned int shutdown:1;
2055 } flags;
2056 struct {
2057 int uses;
2058 } stats;
2059 };
2060
2061
2062 struct _helper_stateful_server {
2063 int index;
2064 int pid;
2065 int rfd;
2066 int wfd;
2067 char *buf;
2068 size_t buf_sz;
2069 off_t offset;
2070 struct timeval dispatch_time;
2071 struct timeval answer_time;
2072 dlink_node link;
2073 dlink_list queue;
2074 statefulhelper *parent;
2075 helper_stateful_request *request;
2076 struct _helper_stateful_flags {
2077 unsigned int alive:1;
2078 unsigned int busy:1;
2079 unsigned int closing:1;
2080 unsigned int shutdown:1;
2081 stateful_helper_reserve_t reserved;
2082 } flags;
2083 struct {
2084 int uses;
2085 int submits;
2086 int releases;
2087 int deferbyfunc;
2088 int deferbycb;
2089 } stats;
2090 int deferred_requests; /* current number of deferred requests */
2091 void *data; /* State data used by the calling routines */
2092 };
2093
2094 /*
2095 * use this when you need to pass callback data to a blocking
2096 * operation, but you don't want to add that pointer to cbdata
2097 */
2098 struct _generic_cbdata {
2099 void *data;
2100 };
2101
2102 struct _store_rebuild_data {
2103 int objcount; /* # objects successfully reloaded */
2104 int expcount; /* # objects expired */
2105 int scancount; /* # entries scanned or read from state file */
2106 int clashcount; /* # swapfile clashes avoided */
2107 int dupcount; /* # duplicates purged */
2108 int cancelcount; /* # SWAP_LOG_DEL objects purged */
2109 int invalid; /* # bad lines */
2110 int badflags; /* # bad e->flags */
2111 int bad_log_op;
2112 int zero_object_sz;
2113 };
2114
2115 /*
2116 * This defines an fs type
2117 */
2118
2119 struct _storefs_entry {
2120 const char *typestr;
2121 STFSPARSE *parsefunc;
2122 STFSRECONFIGURE *reconfigurefunc;
2123 STFSSHUTDOWN *donefunc;
2124 };
2125
2126 /*
2127 * This defines an repl type
2128 */
2129
2130 struct _storerepl_entry {
2131 const char *typestr;
2132 REMOVALPOLICYCREATE *create;
2133 };
2134
2135 /*
2136 * Async disk IO - this defines a async disk io queue
2137 */
2138
2139 struct _diskd_queue {
2140 int smsgid; /* send sysvmsg id */
2141 int rmsgid; /* recv sysvmsg id */
2142 int wfd; /* queue file descriptor ? */
2143 int away; /* number of requests away */
2144 int sent_count; /* number of messages sent */
2145 int recv_count; /* number of messages received */
2146 struct {
2147 char *buf; /* shm buffer */
2148 link_list *stack;
2149 int id; /* sysvshm id */
2150 } shm;
2151 };
2152
2153 struct _Logfile {
2154 int fd;
2155 char path[MAXPATHLEN];
2156 char *buf;
2157 size_t bufsz;
2158 off_t offset;
2159 struct {
2160 unsigned int fatal:1;
2161 } flags;
2162 };
2163
2164 struct cache_dir_option {
2165 const char *name;
2166 void (*parse) (SwapDir * sd, const char *option, const char *value, int reconfiguring);
2167 void (*dump) (StoreEntry * e, const char *option, SwapDir * sd);
2168 };
2169
2170 #endif /* SQUID_STRUCTS_H */