]> git.ipfire.org Git - thirdparty/squid.git/blame - src/structs.h
Bug #874: rough port of the http_reply_header_size functionality
[thirdparty/squid.git] / src / structs.h
CommitLineData
a8258824 1
9cef6668 2/*
4eb368f9 3 * $Id: structs.h,v 1.499 2004/12/21 17:52:53 robertc Exp $
9cef6668 4 *
5 *
2b6662ba 6 * SQUID Web Proxy Cache http://www.squid-cache.org/
9cef6668 7 * ----------------------------------------------------------
8 *
2b6662ba 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.
9cef6668 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
b5638623 34#ifndef SQUID_STRUCTS_H
35#define SQUID_STRUCTS_H
36
0009ba2f 37#include "config.h"
0009ba2f 38
2d8c0b1a 39class dlink_node
62e76326 40{
2d8c0b1a 41
42public:
43 dlink_node() : data(NULL), prev(NULL), next(NULL){}
44
0f1bc304 45 void *data;
46 dlink_node *prev;
47 dlink_node *next;
48};
49
62e76326 50struct _dlink_list
51{
0f1bc304 52 dlink_node *head;
53 dlink_node *tail;
54};
55
62e76326 56struct _acl_name_list
57{
a8258824 58 char name[ACL_NAME_SZ];
74fbf3c9 59 acl_name_list *next;
a8258824 60};
61
62e76326 62struct _acl_proxy_auth_match_cache
63{
94439e4e 64 dlink_node link;
65 int matchrv;
66 void *acl_data;
67};
68
62e76326 69struct _acl_deny_info_list
70{
e6ccf245 71 err_type err_page_id;
02922e76 72 char *err_page_name;
74fbf3c9 73 acl_name_list *acl_list;
74 acl_deny_info_list *next;
a8258824 75};
76
02922e76 77
8000a965 78class acl_access;
62e76326 79
80struct _header_mangler
81{
6bccf575 82 acl_access *access_list;
83 char *replacement;
84};
85
62e76326 86struct _body_size
87{
a560ee93 88 dlink_node node;
89 acl_access *access_list;
90 size_t maxsize;
91};
92
ccf44862 93
1df370e3 94#if SQUID_SNMP
43d4303e 95
62e76326 96struct _snmp_request_t
97{
5e29a294 98 u_char *buf;
99 u_char *outbuf;
2ac76861 100 int len;
101 int sock;
102 long reqid;
103 int outlen;
62e76326 104
2ac76861 105 struct sockaddr_in from;
62e76326 106
2ac76861 107 struct snmp_pdu *PDU;
4fb35c3c 108 ACLChecklist *acl_checklist;
5e29a294 109 u_char *community;
a9ddb359 110};
bdf18524 111
1df370e3 112#endif
a97cfa48 113
a8258824 114
62e76326 115struct _acl_address
116{
d6827718 117 acl_address *next;
29b8d8d6 118 acl_list *aclList;
62e76326 119
d6827718 120 struct in_addr addr;
121};
122
62e76326 123struct _acl_tos
124{
d6827718 125 acl_tos *next;
29b8d8d6 126 acl_list *aclList;
d6827718 127 int tos;
128};
129
ef1955a5 130struct _acl_size_t
131{
132 acl_size_t *next;
133 acl_list *aclList;
134 size_t size;
135};
136
62e76326 137struct _wordlist
138{
a8258824 139 char *key;
bd05e3e3 140 wordlist *next;
a8258824 141};
142
62e76326 143struct _ushortlist
144{
a8258824 145 u_short i;
bd05e3e3 146 ushortlist *next;
a8258824 147};
148
62e76326 149struct _relist
150{
a8258824 151 char *pattern;
152 regex_t regex;
bd05e3e3 153 relist *next;
a8258824 154};
155
62e76326 156struct _sockaddr_in_list
157{
158
7e3ce7b9 159 struct sockaddr_in s;
160 sockaddr_in_list *next;
161};
162
fbdba7c4 163struct _http_port_list
164{
165 http_port_list *next;
166
167 struct sockaddr_in s;
168 char *protocol; /* protocol name */
169 char *name; /* visible name */
170 char *defaultsite; /* default web site */
171
172unsigned int transparent:
173 1; /* transparent proxy */
174
175unsigned int accel:
176 1; /* HTTP accelerator */
177
178unsigned int vhost:
179 1; /* uses host header */
180
181 int vport; /* virtual port support, -1 for dynamic, >0 static*/
182};
183
184
d193a436 185#if USE_SSL
62e76326 186
187struct _https_port_list
188{
fbdba7c4 189 http_port_list http; /* must be first */
d193a436 190 char *cert;
191 char *key;
79d4ccdf 192 int version;
193 char *cipher;
194 char *options;
a7ad6e4e 195 char *clientca;
196 char *cafile;
197 char *capath;
35105e4b 198 char *dhfile;
a7ad6e4e 199 char *sslflags;
200 SSL_CTX *sslContext;
d193a436 201};
62e76326 202
d193a436 203#endif
94439e4e 204
56e64999 205#if DELAY_POOLS
b67e2c8c 206#include "DelayConfig.h"
56e64999 207#endif
95e36d02 208
62e76326 209struct _RemovalPolicySettings
210{
6a566b9c 211 char *type;
212 wordlist *args;
213};
214
1e5562e3 215class external_acl;
216
62e76326 217struct _SquidConfig
218{
219
220 struct
221 {
222 size_t maxSize;
223 int highWaterMark;
224 int lowWaterMark;
225 }
226
227 Swap;
43a70238 228 size_t memMaxSize;
62e76326 229
230 struct
231 {
232 char *relayHost;
233 u_short relayPort;
234 peer *_peer;
235 }
236
237 Wais;
238
239 struct
240 {
241 size_t min;
242 int pct;
243 size_t max;
244 }
245
246 quickAbort;
7e820f36 247 size_t readAheadGap;
6a566b9c 248 RemovalPolicySettings *replPolicy;
249 RemovalPolicySettings *memPolicy;
a8258824 250 time_t negativeTtl;
251 time_t negativeDnsTtl;
252 time_t positiveDnsTtl;
253 time_t shutdownLifetime;
d1b63fc8 254 time_t backgroundPingRate;
62e76326 255
256 struct
257 {
258 time_t read;
259 time_t lifetime;
260 time_t connect;
777831e0 261 time_t forward;
62e76326 262 time_t peer_connect;
263 time_t request;
264 time_t persistent_request;
265 time_t pconn;
266 time_t siteSelect;
267 time_t deadPeer;
268 int icp_query; /* msec */
269 int icp_query_max; /* msec */
270 int icp_query_min; /* msec */
271 int mcast_icp_query; /* msec */
3898f57f 272#if USE_IDENT
62e76326 273
274 time_t ident;
4fe0e1d0 275#endif
276#if !USE_DNSSERVERS
62e76326 277
278 time_t idns_retransmit;
279 time_t idns_query;
3898f57f 280#endif
62e76326 281
282 }
283
284 Timeout;
0483b991 285 size_t maxRequestHeaderSize;
286 size_t maxRequestBodySize;
4eb368f9 287 size_t maxReplyHeaderSize;
ef1955a5 288 acl_size_t *ReplyBodySize;
62e76326 289
290 struct
291 {
292 u_short icp;
ace287ee 293#if USE_HTCP
62e76326 294
295 u_short htcp;
ace287ee 296#endif
1df370e3 297#if SQUID_SNMP
62e76326 298
299 u_short snmp;
1df370e3 300#endif
62e76326 301
302 }
303
304 Port;
305
306 struct
307 {
308 http_port_list *http;
1f7c9178 309#if USE_SSL
62e76326 310
311 https_port_list *https;
1f7c9178 312#endif
62e76326 313
314 }
315
316 Sockaddr;
1df370e3 317#if SQUID_SNMP
62e76326 318
319 struct
320 {
321 char *configFile;
322 char *agentInfo;
323 }
324
325 Snmp;
320e9f36 326#endif
eb824054 327#if USE_WCCP
62e76326 328
329 struct
330 {
331
332 struct in_addr router;
333
334 struct in_addr incoming;
335
336 struct in_addr outgoing;
337 int version;
338 }
339
340 Wccp;
1df370e3 341#endif
62e76326 342
53ad48e6 343 char *as_whois_server;
62e76326 344
345 struct
346 {
347 char *log;
62e76326 348 char *store;
349 char *swap;
82839306 350#if USE_USERAGENT_LOG
62e76326 351
352 char *useragent;
fd2c5549 353#endif
354#if USE_REFERER_LOG
62e76326 355
356 char *referer;
225644d7 357#endif
358#if WIP_FWD_LOG
62e76326 359
360 char *forward;
82839306 361#endif
62e76326 362
7684c4b1 363 logformat *logformats;
364
365 customlog *accesslogs;
366
62e76326 367 int rotateNumber;
368 }
369
370 Log;
a8258824 371 char *adminEmail;
372 char *effectiveUser;
373 char *effectiveGroup;
62e76326 374
375 struct
376 {
82839306 377#if USE_DNSSERVERS
62e76326 378 char *dnsserver;
efd900cb 379#endif
62e76326 380
381 wordlist *redirect;
82839306 382#if USE_ICMP
62e76326 383
384 char *pinger;
82839306 385#endif
a3d0a19d 386#if USE_UNLINKD
62e76326 387
388 char *unlinkd;
a3d0a19d 389#endif
62e76326 390
391 char *diskd;
307b83b7 392#if USE_SSL
393
394 char *ssl_password;
395#endif
396
62e76326 397 }
398
399 Program;
82839306 400#if USE_DNSSERVERS
62e76326 401
a8258824 402 int dnsChildren;
efd900cb 403#endif
62e76326 404
a8258824 405 int redirectChildren;
07eca7e0 406 int redirectConcurrency;
94439e4e 407 time_t authenticateGCInterval;
70a76033 408 time_t authenticateTTL;
409 time_t authenticateIpTTL;
43ae1d95 410
411 struct
412 {
413#if ESI
414 char *surrogate_id;
415#endif
416
417 }
418
419 Accel;
a8258824 420 char *appendDomain;
421 size_t appendDomainLen;
422 char *debugOptions;
423 char *pidFilename;
424 char *mimeTablePathname;
0e70aa1e 425 char *etcHostsPath;
a8258824 426 char *visibleHostname;
98829f69 427 char *uniqueHostname;
1f38f50a 428 wordlist *hostnameAliases;
a8258824 429 char *errHtmlText;
62e76326 430
431 struct
432 {
433 char *host;
434 char *file;
435 time_t period;
436 u_short port;
437 }
438
439 Announce;
440
441 struct
442 {
443
444 struct in_addr udp_incoming;
445
446 struct in_addr udp_outgoing;
15dcc168 447#if SQUID_SNMP
62e76326 448
449 struct in_addr snmp_incoming;
450
451 struct in_addr snmp_outgoing;
15dcc168 452#endif
62e76326 453
454 struct in_addr client_netmask;
455 }
456
457 Addrs;
9906e724 458 size_t tcpRcvBufsz;
459 size_t udpMaxHitObjsz;
a8258824 460 wordlist *hierarchy_stoplist;
461 wordlist *mcast_group_list;
462 wordlist *dns_testname_list;
09c483ec 463 wordlist *dns_nameservers;
40a1495e 464 peer *peers;
465 int npeers;
62e76326 466
467 struct
468 {
469 int size;
470 int low;
471 int high;
472 }
473
474 ipcache;
475
476 struct
477 {
478 int size;
479 }
480
481 fqdncache;
a8258824 482 int minDirectHops;
5f84d830 483 int minDirectRtt;
a8258824 484 cachemgr_passwd *passwd_list;
62e76326 485
486 struct
487 {
488 int objectsPerBucket;
489 size_t avgObjectSize;
490 size_t maxObjectSize;
491 size_t minObjectSize;
492 size_t maxInMemObjSize;
493 }
494
495 Store;
496
497 struct
498 {
499 int high;
500 int low;
501 time_t period;
502 }
503
504 Netdb;
505
506 struct
507 {
508 int log_udp;
82839306 509#if USE_DNSSERVERS
62e76326 510
511 int res_defnames;
efd900cb 512#endif
62e76326 513
514 int anonymizer;
515 int client_db;
516 int query_icmp;
517 int icp_hit_stale;
518 int buffered_logs;
0ab965da 519#if ALLOW_SOURCE_PING
62e76326 520
521 int source_ping;
0ab965da 522#endif
62e76326 523
524 int common_log;
525 int log_mime_hdrs;
526 int log_fqdn;
527 int announce;
528 int mem_pools;
529 int test_reachability;
530 int half_closed_clients;
9f60cfdf 531#if HTTP_VIOLATIONS
62e76326 532
533 int reload_into_ims;
9f60cfdf 534#endif
62e76326 535
536 int offline;
537 int redir_rewrites_host;
538 int prefer_direct;
539 int nonhierarchical_direct;
540 int strip_query_terms;
541 int redirector_bypass;
542 int ignore_unknown_nameservers;
543 int client_pconns;
544 int server_pconns;
7e3ce7b9 545#if USE_CACHE_DIGESTS
62e76326 546
547 int digest_generation;
7e3ce7b9 548#endif
62e76326 549
550 int log_ip_on_direct;
551 int ie_refresh;
552 int vary_ignore_expire;
553 int pipeline_prefetch;
43ae1d95 554#if ESI
555
556 int surrogate_is_remote;
557#endif
558
62e76326 559 int request_entities;
a12a049a 560 int balance_on_multiple_ip;
62e76326 561 int check_hostnames;
562 int via;
563 int emailErrData;
564 }
565
566 onoff;
97427e90 567
568 class ACL *aclList;
62e76326 569
570 struct
571 {
572 acl_access *http;
573 acl_access *icp;
574 acl_access *miss;
575 acl_access *NeverDirect;
576 acl_access *AlwaysDirect;
577 acl_access *ASlists;
578 acl_access *noCache;
7684c4b1 579 acl_access *log;
dba79ac5 580#if SQUID_SNMP
62e76326 581
582 acl_access *snmp;
dba79ac5 583#endif
62e76326 584
585 acl_access *brokenPosts;
3898f57f 586#if USE_IDENT
62e76326 587
588 acl_access *identLookup;
3898f57f 589#endif
62e76326 590
591 acl_access *redirector;
592 acl_access *reply;
593 acl_address *outgoing_address;
594 acl_tos *outgoing_tos;
595 }
596
597 accessList;
bd05e3e3 598 acl_deny_info_list *denyInfoList;
e6ccf245 599 authConfig authConfiguration;
62e76326 600
601 struct
602 {
603 size_t list_width;
604 int list_wrap;
605 char *anon_user;
606 int passive;
607 int sanitycheck;
dad0fe12 608 int telnet;
62e76326 609 }
610
611 Ftp;
a8258824 612 refresh_t *Refresh;
62e76326 613
614 struct _cacheSwap
615 {
616 SwapDir **swapDirs;
617 int n_allocated;
618 int n_configured;
619 }
620
621 cacheSwap;
622
623 struct
624 {
625 char *directory;
e72a0ec0 626 int use_short_names;
62e76326 627 }
628
629 icons;
9b312a19 630 char *errorDirectory;
62e76326 631
632 struct
633 {
62e76326 634 int maxtries;
635 }
636
637 retry;
638
639 struct
640 {
641 size_t limit;
642 }
643
644 MemPools;
95e36d02 645#if DELAY_POOLS
62e76326 646
b67e2c8c 647 DelayConfig Delay;
95e36d02 648#endif
62e76326 649
650 struct
651 {
652 int icp_average;
653 int dns_average;
654 int http_average;
655 int icp_min_poll;
656 int dns_min_poll;
657 int http_min_poll;
658 }
659
660 comm_incoming;
c5f627c2 661 int max_open_disk_fds;
d548ee64 662 int uri_whitespace;
c68e9c6b 663 size_t rangeOffsetLimit;
e66d7923 664#if MULTICAST_MISS_STREAM
62e76326 665
666 struct
667 {
668
669 struct in_addr addr;
670 int ttl;
671 unsigned short port;
672 char *encode_key;
673 }
674
675 mcast_miss;
e66d7923 676#endif
62e76326 677
8c01ada0 678 header_mangler request_header_access[HDR_ENUM_END];
679 header_mangler reply_header_access[HDR_ENUM_END];
b6a2f15e 680 char *coredump_dir;
efd900cb 681 char *chroot_dir;
7e3ce7b9 682#if USE_CACHE_DIGESTS
62e76326 683
684 struct
685 {
686 int bits_per_entry;
687 time_t rebuild_period;
688 time_t rewrite_period;
689 size_t swapout_chunk_size;
690 int rebuild_chunk_percentage;
691 }
692
693 digest;
1f7c9178 694#endif
695#if USE_SSL
62e76326 696
697 struct
698 {
699 int unclean_shutdown;
700 char *ssl_engine;
701 }
702
703 SSL;
7e3ce7b9 704#endif
62e76326 705
56fe752e 706 wordlist *ext_methods;
62e76326 707
708 struct
709 {
710 int high_rptm;
711 int high_pf;
712 size_t high_memory;
713 }
714
715 warnings;
65a53c8e 716 char *store_dir_select_algorithm;
1fbbdcb0 717 int sleep_after_fork; /* microseconds */
d9572179 718 external_acl *externalAclHelperList;
a7ad6e4e 719#if USE_SSL
62e76326 720
721 struct
722 {
723 char *cert;
724 char *key;
725 int version;
726 char *options;
727 char *cipher;
728 char *cafile;
729 char *capath;
730 char *flags;
731 SSL_CTX *sslContext;
732 }
733
734 ssl_client;
a7ad6e4e 735#endif
a8258824 736};
737
62e76326 738struct _SquidConfig2
739{
740
741 struct
742 {
743 int enable_purge;
744 }
745
746 onoff;
d20b1cd0 747 uid_t effectiveUserID;
748 gid_t effectiveGroupID;
a8258824 749};
750
62e76326 751struct _close_handler
752{
a8258824 753 PF *handler;
754 void *data;
755 close_handler *next;
756};
757
62e76326 758struct _dread_ctrl
759{
a8258824 760 int fd;
761 off_t offset;
762 int req_len;
763 char *buf;
764 int end_of_file;
765 DRCB *handler;
766 void *client_data;
767};
768
62e76326 769struct _dnsserver_t
770{
a8258824 771 int id;
a8258824 772 int inpipe;
773 int outpipe;
774 time_t answer;
78f1250a 775 off_t offset;
776 size_t size;
e144eae4 777 char ip_inbuf[DNS_INBUF_SZ];
62e76326 778
a8258824 779 struct timeval dispatch_time;
780 void *data;
781};
782
62e76326 783struct _dwrite_q
784{
d377699f 785 off_t file_offset;
a8258824 786 char *buf;
787 int len;
d377699f 788 off_t buf_offset;
bd05e3e3 789 dwrite_q *next;
74fbf3c9 790 FREE *free_func;
a8258824 791};
792
a9771e51 793
794/* ETag support is rudimantal;
795 * this struct is likely to change
796 * Note: "str" points to memory in HttpHeaderEntry (for now)
797 * so ETags should be used as tmp variables only (for now) */
62e76326 798
799struct _ETag
800{
98829f69 801 const char *str; /* quoted-string */
802 int weak; /* true if it is a weak validator */
a9771e51 803};
804
62e76326 805struct _fde_disk
806{
e6ccf245 807 DWCB *wrt_handle;
808 void *wrt_handle_data;
809 dwrite_q *write_q;
810 dwrite_q *write_q_tail;
811 off_t offset;
812};
813
62e76326 814struct _fileMap
815{
a8258824 816 int max_n_files;
817 int n_files_in_map;
a8258824 818 int toggle;
819 int nwords;
820 unsigned long *file_map;
821};
822
1d21d91d 823/* see Packer.c for description */
62e76326 824
825struct _Packer
826{
1d21d91d 827 /* protected, use interface functions instead */
828 append_f append;
829 vprintf_f vprintf;
830 void *real_handler; /* first parameter to real append and vprintf */
831};
832
adba4a64 833
834/*
1d21d91d 835 * Note: HttpBody is used only for messages with a small content that is
adba4a64 836 * known a priory (e.g., error messages).
837 */
528b2c61 838#include "MemBuf.h"
62e76326 839
840struct _HttpBody
841{
1d21d91d 842 /* private */
843 MemBuf mb;
adba4a64 844};
845
cf414c2d 846#include "SquidString.h"
2ecaa5e7 847/* http header extention field */
62e76326 848
0353e724 849class HttpHdrExtField
62e76326 850{
a369131d 851 String name; /* field-name from HTTP/1.1 (no column after name) */
852 String value; /* field-value from HTTP/1.1 */
2ecaa5e7 853};
adba4a64 854
399e85ea 855/* http cache control header field */
62e76326 856
857struct _HttpHdrCc
858{
4f087419 859 int mask;
d8b249ef 860 int max_age;
7e3ce7b9 861 int s_maxage;
49ff0930 862 int max_stale;
a8258824 863};
ee1679df 864
a9771e51 865/* some fields can hold either time or etag specs (e.g. If-Range) */
62e76326 866
867struct _TimeOrTag
868{
98829f69 869 ETag tag; /* entity tag */
a9771e51 870 time_t time;
98829f69 871 int valid; /* true if struct is usable */
a9771e51 872};
873
7faf2bdb 874/* per field statistics */
62e76326 875
0353e724 876class HttpHeaderFieldStat
62e76326 877{
0353e724 878
879public:
880 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0){}
881
399e85ea 882 int aliveCount; /* created but not destroyed (count) */
d8b249ef 883 int seenCount; /* #fields we've seen */
399e85ea 884 int parsCount; /* #parsing attempts */
885 int errCount; /* #pasring errors */
886 int repCount; /* #repetitons */
7faf2bdb 887};
888
d8b249ef 889/* compiled version of HttpHeaderFieldAttrs plus stats */
62e76326 890
0353e724 891class HttpHeaderFieldInfo
62e76326 892{
0353e724 893
894public:
895 HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid){}
896
de336bbe 897 http_hdr_type id;
898 String name;
899 field_type type;
7faf2bdb 900 HttpHeaderFieldStat stat;
901};
902
0353e724 903class HttpHeaderEntry
62e76326 904{
0353e724 905
906public:
b001e822 907 MEMPROXY_CLASS(HttpHeaderEntry);
d8b249ef 908 http_hdr_type id;
909 String name;
910 String value;
911};
4f087419 912
b001e822 913/* bah. remove this when HttpHeaderEntry is moved
914 * out
915 */
b001e822 916MEMPROXY_CLASS_INLINE(HttpHeaderEntry)
917
43ae1d95 918/* http surogate control header field */
919
920struct _HttpHdrScTarget
921{
922 dlink_node node;
923 int mask;
924 int max_age;
925 int max_stale;
926 String content;
927 String target;
928};
929
930struct _HttpHdrSc
931{
932 dlink_list targets;
933};
934
62e76326 935struct _http_state_flags
936{
937
938unsigned int proxying:
939 1;
940
941unsigned int keepalive:
942 1;
943
944unsigned int only_if_cached:
945 1;
946
947unsigned int headers_pushed:
948 1;
949
950unsigned int front_end_https:
951 2;
952
953unsigned int originpeer:
954 1;
b515fc11 955};
a8258824 956
62e76326 957struct _ipcache_addrs
958{
959
6d1c0d53 960 struct in_addr *in_addrs;
961 unsigned char *bad_mask;
a8258824 962 unsigned char count;
963 unsigned char cur;
22c653cd 964 unsigned char badcount;
a8258824 965};
966
62e76326 967struct _domain_ping
968{
a8258824 969 char *domain;
970 int do_ping; /* boolean */
bd05e3e3 971 domain_ping *next;
a8258824 972};
973
62e76326 974struct _domain_type
975{
a8258824 976 char *domain;
977 peer_t type;
bd05e3e3 978 domain_type *next;
a8258824 979};
980
c68e9c6b 981#if USE_CACHE_DIGESTS
62e76326 982
983struct _Version
984{
4b4cd312 985 short int current; /* current version */
986 short int required; /* minimal version that can safely handle current version */
e41e6dcd 987};
988
989/* digest control block; used for transmission and storage */
62e76326 990
991struct _StoreDigestCBlock
992{
e41e6dcd 993 Version ver;
994 int capacity;
995 int count;
996 int del_count;
997 int mask_size;
04f0c415 998 unsigned char bits_per_entry;
999 unsigned char hash_func_count;
1000 short int reserved_short;
4b4cd312 1001 int reserved[32 - 6];
e41e6dcd 1002};
1003
62e76326 1004struct _DigestFetchState
1005{
e13ee7ad 1006 PeerDigest *pd;
e41e6dcd 1007 StoreEntry *entry;
1008 StoreEntry *old_entry;
06d2839d 1009 store_client *sc;
1010 store_client *old_sc;
190154cf 1011 HttpRequest *request;
e41e6dcd 1012 int offset;
1013 int mask_offset;
1014 time_t start_time;
e13ee7ad 1015 time_t resp_time;
1016 time_t expires;
62e76326 1017
1018 struct
1019 {
1020 int msg;
1021 int bytes;
1022 }
1023
1024 sent, recv;
add2192d 1025 char buf[SM_PAGE_SIZE];
3dfaa3d2 1026 ssize_t bufofs;
add2192d 1027 digest_read_state_t state;
e41e6dcd 1028};
1029
1030/* statistics for cache digests and other hit "predictors" */
62e76326 1031
1032struct _cd_guess_stats
1033{
e41e6dcd 1034 /* public, read-only */
1035 int true_hits;
1036 int false_hits;
1037 int true_misses;
1038 int false_misses;
4b4cd312 1039 int close_hits; /* tmp, remove it later */
e41e6dcd 1040};
1041
0353e724 1042class PeerDigest
62e76326 1043{
1044
0353e724 1045public:
1046 void *operator new (size_t);
1047 void operator delete(void *);
0353e724 1048
e6ccf245 1049 struct _peer *peer; /* pointer back to peer structure, argh */
4d62b0af 1050 CacheDigest *cd; /* actual digest structure */
1051 String host; /* copy of peer->host */
e13ee7ad 1052 const char *req_result; /* text status of the last request */
62e76326 1053
1054 struct
1055 {
1056
1057unsigned int needed:
1058 1; /* there were requests for this digest */
1059
1060unsigned int usable:
1061 1; /* can be used for lookups */
1062
1063unsigned int requested:
1064 1; /* in process of receiving [fresh] digest */
1065 }
1066
1067 flags;
1068
1069 struct
1070 {
1071 /* all times are absolute unless augmented with _delay */
1072 time_t initialized; /* creation */
1073 time_t needed; /* first lookup/use by a peer */
1074 time_t next_check; /* next scheduled check/refresh event */
1075 time_t retry_delay; /* delay before re-checking _invalid_ digest */
1076 time_t requested; /* requested a fresh copy of a digest */
1077 time_t req_delay; /* last request response time */
1078 time_t received; /* received the current copy of a digest */
1079 time_t disabled; /* disabled for good */
1080 }
1081
1082 times;
1083
1084 struct
1085 {
1086 cd_guess_stats guess;
1087 int used_count;
1088
1089 struct
1090 {
1091 int msgs;
1092 kb_t kbytes;
1093 }
1094
1095 sent, recv;
1096 }
1097
1098 stats;
0353e724 1099
1100private:
1101 CBDATA_CLASS(PeerDigest);
e41e6dcd 1102};
1103
c68e9c6b 1104#endif
1105
62e76326 1106struct _peer
1107{
be753325 1108 char *name;
a8258824 1109 char *host;
1110 peer_t type;
62e76326 1111
a8258824 1112 struct sockaddr_in in_addr;
62e76326 1113
1114 struct
1115 {
1116 int pings_sent;
1117 int pings_acked;
1118 int fetches;
1119 int rtt;
1120 int ignored_replies;
1121 int n_keepalives_sent;
1122 int n_keepalives_recv;
1123 time_t probe_start;
1124 time_t last_query;
1125 time_t last_reply;
1126 time_t last_connect_failure;
1127 time_t last_connect_probe;
1128 int logged_state; /* so we can print dead/revived msgs */
1129 int conn_open; /* current opened connections */
1130 }
1131
1132 stats;
1133
1134 struct
1135 {
1136 int version;
1137 int counts[ICP_END];
1138 u_short port;
1139 }
1140
1141 icp;
399cabec 1142#if USE_HTCP
62e76326 1143
1144 struct
1145 {
1146 double version;
1147 int counts[2];
1148 u_short port;
1149 }
1150
1151 htcp;
399cabec 1152#endif
62e76326 1153
a8258824 1154 u_short http_port;
b6a2f15e 1155 domain_ping *peer_domain;
bd05e3e3 1156 domain_type *typelist;
505e35db 1157 acl_access *access;
62e76326 1158
1159 struct
1160 {
1161
1162unsigned int proxy_only:
1163 1;
1164
1165unsigned int no_query:
1166 1;
1167
1168unsigned int background_ping:
1169 1;
1170
1171unsigned int no_digest:
1172 1;
1173
1174unsigned int default_parent:
1175 1;
1176
1177unsigned int roundrobin:
1178 1;
1179
1180unsigned int weighted_roundrobin:
1181 1;
1182
1183unsigned int mcast_responder:
1184 1;
1185
1186unsigned int closest_only:
1187 1;
cd196bc8 1188#if USE_HTCP
62e76326 1189
1190unsigned int htcp:
1191 1;
cd196bc8 1192#endif
62e76326 1193
1194unsigned int no_netdb_exchange:
1195 1;
cd196bc8 1196#if DELAY_POOLS
62e76326 1197
1198unsigned int no_delay:
1199 1;
cd196bc8 1200#endif
62e76326 1201
1202unsigned int allow_miss:
1203 1;
b3995439 1204#if USE_CARP
62e76326 1205
1206unsigned int carp:
1207 1;
b3995439 1208#endif
62e76326 1209
1210unsigned int originserver:
1211 1;
1212 }
1213
1214 options;
a8258824 1215 int weight;
d1b63fc8 1216 int basetime;
62e76326 1217
1218 struct
1219 {
1220 double avg_n_members;
1221 int n_times_counted;
1222 int n_replies_expected;
1223 int ttl;
1224 int id;
1225
1226 struct
1227 {
1228
1229unsigned int count_event_pending:
1230 1;
1231
1232unsigned int counting:
1233 1;
1234 }
1235
1236 flags;
1237 }
1238
1239 mcast;
c68e9c6b 1240#if USE_CACHE_DIGESTS
62e76326 1241
e13ee7ad 1242 PeerDigest *digest;
7e3ce7b9 1243 char *digest_url;
c68e9c6b 1244#endif
62e76326 1245
a8258824 1246 int tcp_up; /* 0 if a connect() fails */
62e76326 1247
a8258824 1248 struct in_addr addresses[10];
1249 int n_addresses;
1250 int rr_count;
82056f1e 1251 int rr_lastcount;
bd05e3e3 1252 peer *next;
a8258824 1253 int test_fd;
afd88fbe 1254#if USE_CARP
62e76326 1255
1256 struct
1257 {
1258 unsigned int hash;
1259 double load_multiplier;
1260 double load_factor; /* normalized weight value */
1261 }
1262
1263 carp;
afd88fbe 1264#endif
62e76326 1265
c68e9c6b 1266 char *login; /* Proxy authorization */
3f62decd 1267 time_t connect_timeout;
c7f9eb6d 1268 int max_conn;
be753325 1269 char *domain; /* Forced domain */
a7ad6e4e 1270#if USE_SSL
62e76326 1271
a7ad6e4e 1272 int use_ssl;
1273 char *sslcert;
1274 char *sslkey;
1275 int sslversion;
1276 char *ssloptions;
1277 char *sslcipher;
1278 char *sslcafile;
1279 char *sslcapath;
1280 char *sslflags;
1281 char *ssldomain;
1282 SSL_CTX *sslContext;
f38c5e43 1283 SSL_SESSION *sslSession;
a7ad6e4e 1284#endif
62e76326 1285
a7ad6e4e 1286 int front_end_https;
a8258824 1287};
1288
62e76326 1289struct _net_db_name
1290{
186477c1 1291 hash_link hash; /* must be first */
74fbf3c9 1292 net_db_name *next;
1293 netdbEntry *net_db_entry;
a8258824 1294};
1295
62e76326 1296struct _net_db_peer
1297{
6b53c392 1298 const char *peername;
a8258824 1299 double hops;
1300 double rtt;
1301 time_t expires;
1302};
1303
62e76326 1304struct _netdbEntry
1305{
186477c1 1306 hash_link hash; /* must be first */
a8258824 1307 char network[16];
1308 int pings_sent;
1309 int pings_recv;
1310 double hops;
1311 double rtt;
1312 time_t next_ping_time;
1313 time_t last_use_time;
1314 int link_count;
1315 net_db_name *hosts;
1316 net_db_peer *peers;
1317 int n_peers_alloc;
1318 int n_peers;
1319};
1320
a8258824 1321
6b53c392 1322#if USE_ICMP
62e76326 1323
1324struct _pingerEchoData
1325{
1326
a8258824 1327 struct in_addr to;
1328 unsigned char opcode;
1329 int psize;
65ae9f56 1330 char payload[PINGER_PAYLOAD_SZ];
a8258824 1331};
1332
62e76326 1333struct _pingerReplyData
1334{
1335
a8258824 1336 struct in_addr from;
1337 unsigned char opcode;
1338 int rtt;
1339 int hops;
1340 int psize;
65ae9f56 1341 char payload[PINGER_PAYLOAD_SZ];
a8258824 1342};
a4b8110e 1343
6b53c392 1344#endif
a8258824 1345
62e76326 1346struct _iostats
1347{
1348
1349 struct
1350 {
1351 int reads;
1352 int reads_deferred;
1353 int read_hist[16];
1354 int writes;
1355 int write_hist[16];
1356 }
1357
1358 Http, Ftp, Gopher, Wais;
a8258824 1359};
1360
6a566b9c 1361/* Removal policies */
1362
b9ae18aa 1363class RemovalPolicyNode
62e76326 1364{
b9ae18aa 1365
1366public:
1367 RemovalPolicyNode() : data(NULL) {}
1368
6a566b9c 1369 void *data;
1370};
1371
62e76326 1372struct _RemovalPolicy
1373{
c193c972 1374 const char *_type;
6a566b9c 1375 void *_data;
c1dd71ae 1376 void (*Free) (RemovalPolicy * policy);
1377 void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1378 void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1379 void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1380 void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1381 RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
1382 RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
8a3e7d9e 1383 void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
6a566b9c 1384};
1385
62e76326 1386struct _RemovalPolicyWalker
1387{
6a566b9c 1388 RemovalPolicy *_policy;
1389 void *_data;
c1dd71ae 1390 const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
1391 void (*Done) (RemovalPolicyWalker * walker);
6a566b9c 1392};
1393
62e76326 1394struct _RemovalPurgeWalker
1395{
6a566b9c 1396 RemovalPolicy *_policy;
1397 void *_data;
1398 int scanned, max_scan, locked;
c1dd71ae 1399 StoreEntry *(*Next) (RemovalPurgeWalker * walker);
1400 void (*Done) (RemovalPurgeWalker * walker);
6a566b9c 1401};
1402
62e76326 1403struct request_flags
1404{
d048c262 1405 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),transparent(0),internal(0),internalclient(0),body_sent(0),destinationIPLookedUp_(0)
62e76326 1406 {
e429f975 1407#if HTTP_VIOLATIONS
72eee553 1408 nocache_hack = 0;
e429f975 1409#endif
62e76326 1410
1411 }
1412
1413unsigned int range:
1414 1;
1415
1416unsigned int nocache:
1417 1;
1418
1419unsigned int ims:
1420 1;
1421
1422unsigned int auth:
1423 1;
1424
1425unsigned int cachable:
1426 1;
1427
1428unsigned int hierarchical:
1429 1;
1430
1431unsigned int loopdetect:
1432 1;
1433
1434unsigned int proxy_keepalive:
1435 1;
1436
1437unsigned int proxying:
1438 1; /* this should be killed, also in httpstateflags */
1439
1440unsigned int refresh:
1441 1;
1442
1443unsigned int redirected:
1444 1;
1445
1446unsigned int need_validation:
1447 1;
9f60cfdf 1448#if HTTP_VIOLATIONS
62e76326 1449
1450unsigned int nocache_hack:
1451 1; /* for changing/ignoring no-cache requests */
9f60cfdf 1452#endif
62e76326 1453
1454unsigned int accelerated:
1455 1;
1456
d048c262 1457unsigned int transparent:
1458 1;
1459
62e76326 1460unsigned int internal:
1461 1;
1462
1463unsigned int internalclient:
1464 1;
1465
1466unsigned int body_sent:
1467 1;
e429f975 1468 bool resetTCP() const;
1469 void setResetTCP();
1470 void clearResetTCP();
8000a965 1471 void destinationIPLookupCompleted();
1472 bool destinationIPLookedUp() const;
62e76326 1473
e429f975 1474private:
62e76326 1475
1476unsigned int reset_tcp:
1477 1;
1478
1479unsigned int destinationIPLookedUp_:
1480 1;
92695e5e 1481};
1482
62e76326 1483struct _link_list
1484{
d03d26fb 1485 void *ptr;
62e76326 1486
d03d26fb 1487 struct _link_list *next;
1488};
1489
62e76326 1490struct _cachemgr_passwd
1491{
a8258824 1492 char *passwd;
22f3fd98 1493 wordlist *actions;
bd05e3e3 1494 cachemgr_passwd *next;
a8258824 1495};
1496
62e76326 1497struct _refresh_t
1498{
a2c963ae 1499 const char *pattern;
a8258824 1500 regex_t compiled_pattern;
1501 time_t min;
c3f6d204 1502 double pct;
a8258824 1503 time_t max;
bd05e3e3 1504 refresh_t *next;
62e76326 1505
1506 struct
1507 {
1508
1509unsigned int icase:
1510 1;
9f60cfdf 1511#if HTTP_VIOLATIONS
62e76326 1512
1513unsigned int override_expire:
1514 1;
1515
1516unsigned int override_lastmod:
1517 1;
1518
1519unsigned int reload_into_ims:
1520 1;
1521
1522unsigned int ignore_reload:
1523 1;
38f9c547 1524
1525unsigned int ignore_no_cache:
1526 1;
1527
1528unsigned int ignore_no_store:
1529 1;
1530
1531unsigned int ignore_private:
1532 1;
1533
1534unsigned int ignore_auth:
1535 1;
9f60cfdf 1536#endif
62e76326 1537
1538 }
1539
1540 flags;
a8258824 1541};
1542
62e76326 1543struct _CommWriteStateData
1544{
a8258824 1545 char *buf;
1546 size_t size;
1547 off_t offset;
1548 CWCB *handler;
1549 void *handler_data;
74fbf3c9 1550 FREE *free_func;
a8258824 1551};
9b312a19 1552
62e76326 1553struct _ErrorState
1554{
9b312a19 1555 err_type type;
02922e76 1556 int page_id;
29b8d8d6 1557 http_status httpStatus;
94439e4e 1558 auth_user_request_t *auth_user_request;
190154cf 1559 HttpRequest *request;
9b312a19 1560 char *url;
c45ed9ad 1561 int xerrno;
9b312a19 1562 char *host;
1563 u_short port;
1564 char *dnsserver_msg;
1565 time_t ttl;
62e76326 1566
9b312a19 1567 struct in_addr src_addr;
1568 char *redirect_url;
1569 ERCB *callback;
1570 void *callback_data;
62e76326 1571
1572 struct
1573 {
1574
1575unsigned int flag_cbdata:
1576 1;
1577 }
1578
1579 flags;
1580
1581 struct
1582 {
1583 wordlist *server_msg;
1584 char *request;
1585 char *reply;
1586 }
1587
1588 ftp;
e144eae4 1589 char *request_hdrs;
43ae1d95 1590 char *err_msg; /* Preformatted error message from the cache */
9b312a19 1591};
f2908497 1592
12cf1be2 1593/*
1594 * "very generic" histogram;
1595 * see important comments on hbase_f restrictions in StatHist.c
1596 */
62e76326 1597
1598struct _StatHist
1599{
12cf1be2 1600 int *bins;
1601 int capacity;
e9a13293 1602 double min;
1603 double max;
1604 double scale;
95c297ec 1605 hbase_f *val_in; /* e.g., log() for log-based histogram */
1606 hbase_f *val_out; /* e.g., exp() for log based histogram */
7ae52c25 1607};
1608
12cf1be2 1609/*
1610 * if you add a field to StatCounters,
1d803566 1611 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
12cf1be2 1612 */
62e76326 1613
1614struct _StatCounters
1615{
1616
1617 struct
1618 {
1619 int clients;
1620 int requests;
1621 int hits;
1622 int mem_hits;
1623 int disk_hits;
1624 int errors;
1625 kb_t kbytes_in;
1626 kb_t kbytes_out;
1627 kb_t hit_kbytes_out;
1628 StatHist miss_svc_time;
1629 StatHist nm_svc_time;
1630 StatHist nh_svc_time;
1631 StatHist hit_svc_time;
1632 StatHist all_svc_time;
1633 }
1634
1635 client_http;
1636
1637 struct
1638 {
1639
1640 struct
1641 {
1642 int requests;
1643 int errors;
1644 kb_t kbytes_in;
1645 kb_t kbytes_out;
1646 }
1647
1648 all , http, ftp, other;
1649 }
1650
1651 server;
1652
1653 struct
1654 {
1655 int pkts_sent;
1656 int queries_sent;
1657 int replies_sent;
1658 int pkts_recv;
1659 int queries_recv;
1660 int replies_recv;
1661 int hits_sent;
1662 int hits_recv;
1663 int replies_queued;
1664 int replies_dropped;
1665 kb_t kbytes_sent;
1666 kb_t q_kbytes_sent;
1667 kb_t r_kbytes_sent;
1668 kb_t kbytes_recv;
1669 kb_t q_kbytes_recv;
1670 kb_t r_kbytes_recv;
1671 StatHist query_svc_time;
1672 StatHist reply_svc_time;
1673 int query_timeouts;
1674 int times_used;
1675 }
1676
1677 icp;
1678
c4ebc830 1679 struct
1680 {
1681 int pkts_sent;
1682 int pkts_recv;
1683 }
1684
1685 htcp;
1686
62e76326 1687 struct
1688 {
1689 int requests;
1690 }
1691
1692 unlink;
1693
1694 struct
1695 {
1696 StatHist svc_time;
1697 }
1698
1699 dns;
1700
1701 struct
1702 {
1703 int times_used;
1704 kb_t kbytes_sent;
1705 kb_t kbytes_recv;
1706 kb_t memory;
1707 int msgs_sent;
1708 int msgs_recv;
c68e9c6b 1709#if USE_CACHE_DIGESTS
62e76326 1710
1711 cd_guess_stats guess;
c68e9c6b 1712#endif
62e76326 1713
1714 StatHist on_xition_count;
1715 }
1716
1717 cd;
1718
1719 struct
1720 {
1721 int times_used;
1722 }
1723
1724 netdb;
f2908497 1725 int page_faults;
1726 int select_loops;
d239c2f5 1727 int select_fds;
1728 double select_time;
f2908497 1729 double cputime;
62e76326 1730
d5649d9f 1731 struct timeval timestamp;
c6ecdbc3 1732 StatHist comm_icp_incoming;
ef523f99 1733 StatHist comm_dns_incoming;
c6ecdbc3 1734 StatHist comm_http_incoming;
26d6ee93 1735 StatHist select_fds_hist;
62e76326 1736
1737 struct
1738 {
1739
1740 struct
1741 {
1742 int opens;
1743 int closes;
1744 int reads;
1745 int writes;
1746 int seeks;
1747 int unlinks;
1748 }
1749
1750 disk;
1751
1752 struct
1753 {
1754 int accepts;
1755 int sockets;
1756 int connects;
1757 int binds;
1758 int closes;
1759 int reads;
1760 int writes;
1761 int recvfroms;
1762 int sendtos;
1763 }
1764
1765 sock;
886f2785 1766#if HAVE_POLL
62e76326 1767
1768 int polls;
886f2785 1769#else
62e76326 1770
1771 int selects;
886f2785 1772#endif
62e76326 1773
1774 }
1775
1776 syscalls;
bfae3379 1777 int aborted_requests;
62e76326 1778
1779 struct
1780 {
1781 int files_cleaned;
1782 int outs;
1783 int ins;
1784 }
1785
1786 swap;
f2908497 1787};
69c01cd7 1788
fcd2d3ef 1789/* per header statistics */
62e76326 1790
1791struct _HttpHeaderStat
1792{
fcd2d3ef 1793 const char *label;
1794 HttpHeaderMask *owner_mask;
1795
1796 StatHist hdrUCountDistr;
1797 StatHist fieldTypeDistr;
1798 StatHist ccTypeDistr;
43ae1d95 1799 StatHist scTypeDistr;
fcd2d3ef 1800
1801 int parsedCount;
1802 int ccParsedCount;
43ae1d95 1803 int scParsedCount;
fcd2d3ef 1804 int destroyedCount;
1805 int busyDestroyedCount;
1806};
1807
59c4d35b 1808
62e76326 1809struct _ClientInfo
1810{
186477c1 1811 hash_link hash; /* must be first */
62e76326 1812
59c4d35b 1813 struct in_addr addr;
62e76326 1814
1815 struct
1816 {
1817 int result_hist[LOG_TYPE_MAX];
1818 int n_requests;
1819 kb_t kbytes_in;
1820 kb_t kbytes_out;
1821 kb_t hit_kbytes_out;
1822 }
1823
1824 Http, Icp;
1825
1826 struct
1827 {
1828 time_t time;
1829 int n_req;
1830 int n_denied;
1831 }
1832
1833 cutoff;
9bc73deb 1834 int n_established; /* number of current established connections */
a0eba6bc 1835 time_t last_seen;
59c4d35b 1836};
c411be12 1837
62e76326 1838struct _CacheDigest
1839{
c411be12 1840 /* public, read-only */
1afe05c5 1841 char *mask; /* bit mask */
1842 size_t mask_size; /* mask size in bytes */
1843 int capacity; /* expected maximum for .count, not a hard limit */
04f0c415 1844 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1afe05c5 1845 int count; /* number of digested entries */
1846 int del_count; /* number of deletions performed so far */
c411be12 1847};
910169e5 1848
62e76326 1849struct _FwdServer
1850{
29b8d8d6 1851 peer *_peer; /* NULL --> origin server */
db1cd23c 1852 hier_code code;
1853 FwdServer *next;
1854};
1855
62e76326 1856struct _FwdState
1857{
910169e5 1858 int client_fd;
1859 StoreEntry *entry;
190154cf 1860 HttpRequest *request;
910169e5 1861 FwdServer *servers;
6801f8a8 1862 int server_fd;
ec250dfd 1863 ErrorState *err;
f563eea9 1864 time_t start;
68bd6892 1865 int n_tries;
4ed0e075 1866 int origin_tries;
225644d7 1867#if WIP_FWD_LOG
62e76326 1868
225644d7 1869 http_status last_status;
1870#endif
62e76326 1871
1872 struct
1873 {
1874
1875unsigned int dont_retry:
1876 1;
1877
1878unsigned int ftp_pasv_failed:
1879 1;
1880 }
1881
1882 flags;
910169e5 1883};
1884
51ee7c82 1885class helper_request;
94439e4e 1886
62e76326 1887struct _helper
1888{
74addf6c 1889 wordlist *cmdline;
1890 dlink_list servers;
1891 dlink_list queue;
1f5f60dd 1892 const char *id_name;
74addf6c 1893 int n_to_start;
1894 int n_running;
1895 int ipc_type;
07eca7e0 1896 unsigned int concurrency;
74addf6c 1897 time_t last_queue_warn;
62e76326 1898
1899 struct
1900 {
1901 int requests;
1902 int replies;
1903 int queue_size;
1904 int avg_svc_time;
1905 }
1906
1907 stats;
74addf6c 1908};
1909
62e76326 1910struct _helper_stateful
1911{
94439e4e 1912 wordlist *cmdline;
1913 dlink_list servers;
1914 dlink_list queue;
1915 const char *id_name;
1916 int n_to_start;
1917 int n_running;
1918 int ipc_type;
b001e822 1919 MemAllocatorProxy *datapool;
94439e4e 1920 HLPSAVAIL *IsAvailable;
1921 HLPSONEQ *OnEmptyQueue;
1922 time_t last_queue_warn;
62e76326 1923
1924 struct
1925 {
1926 int requests;
1927 int replies;
1928 int queue_size;
1929 int avg_svc_time;
1930 }
1931
1932 stats;
94439e4e 1933};
1934
62e76326 1935struct _helper_server
1936{
74addf6c 1937 int index;
7d2bd2b5 1938 int pid;
74addf6c 1939 int rfd;
1940 int wfd;
07eca7e0 1941 MemBuf wqueue;
1942 MemBuf writebuf;
1943 char *rbuf;
1944 size_t rbuf_sz;
1945 off_t roffset;
62e76326 1946
74addf6c 1947 dlink_node link;
1948 helper *parent;
07eca7e0 1949 helper_request **requests;
62e76326 1950
1951 struct _helper_flags
1952 {
1953
07eca7e0 1954unsigned int writing:
62e76326 1955 1;
1956
07eca7e0 1957unsigned int alive:
62e76326 1958 1;
1959
1960unsigned int closing:
1961 1;
1962
1963unsigned int shutdown:
1964 1;
1965 }
1966
1967 flags;
1968
1969 struct
1970 {
1971 int uses;
07eca7e0 1972 unsigned int pending;
62e76326 1973 }
1974
1975 stats;
74addf6c 1976};
1977
51ee7c82 1978class helper_stateful_request;
94439e4e 1979
62e76326 1980struct _helper_stateful_server
1981{
94439e4e 1982 int index;
5d146f7d 1983 int pid;
94439e4e 1984 int rfd;
1985 int wfd;
07eca7e0 1986 /* MemBuf wqueue; */
1987 /* MemBuf writebuf; */
1988 char *rbuf;
1989 size_t rbuf_sz;
1990 off_t roffset;
62e76326 1991
94439e4e 1992 struct timeval dispatch_time;
62e76326 1993
94439e4e 1994 struct timeval answer_time;
1995 dlink_node link;
1996 dlink_list queue;
1997 statefulhelper *parent;
1998 helper_stateful_request *request;
62e76326 1999
2000 struct _helper_stateful_flags
2001 {
2002
2003unsigned int alive:
2004 1;
2005
2006unsigned int busy:
2007 1;
2008
2009unsigned int closing:
2010 1;
2011
2012unsigned int shutdown:
2013 1;
2014 stateful_helper_reserve_t reserved;
2015 }
2016
2017 flags;
2018
2019 struct
2020 {
2021 int uses;
2022 int submits;
2023 int releases;
2024 int deferbyfunc;
2025 int deferbycb;
2026 }
2027
2028 stats;
32754419 2029 int deferred_requests; /* current number of deferred requests */
94439e4e 2030 void *data; /* State data used by the calling routines */
2031};
2032
74addf6c 2033/*
2034 * use this when you need to pass callback data to a blocking
2035 * operation, but you don't want to add that pointer to cbdata
2036 */
62e76326 2037
2038struct _generic_cbdata
2039{
74addf6c 2040 void *data;
2041};
b2c141d4 2042
62e76326 2043struct _store_rebuild_data
2044{
b2c141d4 2045 int objcount; /* # objects successfully reloaded */
2046 int expcount; /* # objects expired */
2047 int scancount; /* # entries scanned or read from state file */
2048 int clashcount; /* # swapfile clashes avoided */
2049 int dupcount; /* # duplicates purged */
2050 int cancelcount; /* # SWAP_LOG_DEL objects purged */
2051 int invalid; /* # bad lines */
2052 int badflags; /* # bad e->flags */
2053 int bad_log_op;
2054 int zero_object_sz;
2055};
5673c2e2 2056
22d38e05 2057/*
2058 * This defines an repl type
2059 */
2060
62e76326 2061struct _storerepl_entry
2062{
a2c963ae 2063 const char *typestr;
22d38e05 2064 REMOVALPOLICYCREATE *create;
2065};
2066
cd748f27 2067/*
2068 * Async disk IO - this defines a async disk io queue
2069 */
2070
62e76326 2071struct _diskd_queue
2072{
cd748f27 2073 int smsgid; /* send sysvmsg id */
2074 int rmsgid; /* recv sysvmsg id */
2075 int wfd; /* queue file descriptor ? */
2076 int away; /* number of requests away */
2077 int sent_count; /* number of messages sent */
2078 int recv_count; /* number of messages received */
62e76326 2079
2080 struct
2081 {
2082 char *buf; /* shm buffer */
2083 link_list *stack;
2084 int id; /* sysvshm id */
2085 }
2086
2087 shm;
cd748f27 2088};
2089
62e76326 2090struct _Logfile
2091{
5673c2e2 2092 int fd;
2093 char path[MAXPATHLEN];
2094 char *buf;
2095 size_t bufsz;
2096 off_t offset;
62e76326 2097
2098 struct
2099 {
2100
2101unsigned int fatal:
2102 1;
2103 }
2104
2105 flags;
5673c2e2 2106};
8e8d4f30 2107
7684c4b1 2108struct _logformat
2109{
2110 char *name;
2111 logformat_token *format;
2112 logformat *next;
2113};
2114
2115struct _customlog
2116{
2117 char *filename;
2118 acl_list *aclList;
2119 logformat *logFormat;
2120 Logfile *logfile;
2121 customlog *next;
2122 customlog_type type;
2123};
2124
62e76326 2125struct cache_dir_option
2126{
c193c972 2127 const char *name;
8e8d4f30 2128 void (*parse) (SwapDir * sd, const char *option, const char *value, int reconfiguring);
d3b3ab85 2129 void (*dump) (StoreEntry * e, const char *option, SwapDir const * sd);
8e8d4f30 2130};
b5638623 2131
2132#endif /* SQUID_STRUCTS_H */