]> git.ipfire.org Git - thirdparty/squid.git/blame - src/structs.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / structs.h
CommitLineData
9cef6668 1/*
2b6662ba 2 * SQUID Web Proxy Cache http://www.squid-cache.org/
9cef6668 3 * ----------------------------------------------------------
4 *
2b6662ba 5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
9cef6668 13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
9e008dda 18 *
9cef6668 19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
9e008dda 23 *
9cef6668 24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
b5638623 29#ifndef SQUID_STRUCTS_H
30#define SQUID_STRUCTS_H
31
c8f4eac4 32#include "RefCount.h"
4c9da963 33#include "cbdata.h"
582c2af2 34#include "defines.h"
25b6a907 35#include "dlink.h"
4b981814 36#include "err_type.h"
582c2af2
FC
37#include "hash.h"
38#include "ip/Address.h"
4b981814 39
25b6a907 40/* needed for the global config */
41#include "HttpHeader.h"
3b07476b 42#include "HttpHeaderTools.h"
0f1bc304 43
4b981814
AJ
44/* for ICP_END */
45#include "icp_opcode.h"
46
4db984be
CT
47#if USE_SSL
48#include <openssl/ssl.h>
49#endif
50
8a368316
AJ
51#define PEER_MULTICAST_SIBLINGS 1
52
9e008dda 53struct acl_name_list {
a8258824 54 char name[ACL_NAME_SZ];
74fbf3c9 55 acl_name_list *next;
a8258824 56};
57
9e008dda 58struct acl_deny_info_list {
e6ccf245 59 err_type err_page_id;
02922e76 60 char *err_page_name;
74fbf3c9 61 acl_name_list *acl_list;
62 acl_deny_info_list *next;
a8258824 63};
64
e1f7507e
AJ
65class ACLChecklist;
66
1df370e3 67#if SQUID_SNMP
43d4303e 68
582c2af2 69#include "snmp_session.h"
9e008dda 70struct _snmp_request_t {
5e29a294 71 u_char *buf;
72 u_char *outbuf;
2ac76861 73 int len;
74 int sock;
75 long reqid;
76 int outlen;
62e76326 77
b7ac5457 78 Ip::Address from;
62e76326 79
2ac76861 80 struct snmp_pdu *PDU;
4fb35c3c 81 ACLChecklist *acl_checklist;
5e29a294 82 u_char *community;
0536fdfc 83
84 struct snmp_session session;
a9ddb359 85};
bdf18524 86
1df370e3 87#endif
a97cfa48 88
e1f7507e 89class ACLList;
a8258824 90
9e008dda 91struct acl_address {
d6827718 92 acl_address *next;
76cd39d7 93 ACLList *aclList;
62e76326 94
b7ac5457 95 Ip::Address addr;
d6827718 96};
97
9e008dda 98struct acl_tos {
d6827718 99 acl_tos *next;
76cd39d7 100 ACLList *aclList;
425de4c8
AJ
101 tos_t tos;
102};
103
104struct acl_nfmark {
105 acl_nfmark *next;
106 ACLList *aclList;
107 nfmark_t nfmark;
d6827718 108};
109
9e008dda 110struct acl_size_t {
ef1955a5 111 acl_size_t *next;
76cd39d7 112 ACLList *aclList;
47f6e231 113 int64_t size;
ef1955a5 114};
115
9e008dda 116struct ushortlist {
f45dd259 117 unsigned short i;
bd05e3e3 118 ushortlist *next;
a8258824 119};
120
9e008dda 121struct relist {
ae315d9c 122 int flags;
a8258824 123 char *pattern;
124 regex_t regex;
bd05e3e3 125 relist *next;
a8258824 126};
127
9a0a18de 128#if USE_DELAY_POOLS
b67e2c8c 129#include "DelayConfig.h"
b4cd430a 130#include "ClientDelayConfig.h"
56e64999 131#endif
95e36d02 132
cc192b50 133#if USE_ICMP
663ff9aa 134#include "icmp/IcmpConfig.h"
cc192b50 135#endif
136
48d54e4d
AJ
137#include "HelperChildConfig.h"
138
aa839030 139/* forward decl for SquidConfig, see RemovalPolicy.h */
b7d249f9 140
96c2bb61 141class CpuAffinityMap;
aa839030 142class RemovalPolicySettings;
1e5562e3 143class external_acl;
859741ed 144class Store;
04401ab0
A
145namespace AnyP
146{
65d448bc
AJ
147struct PortCfg;
148}
7d3c4ca1 149class SwapDir;
c8f4eac4 150
57af1e3f
AR
151/// Used for boolean enabled/disabled options with complex default logic.
152/// Allows Squid to compute the right default after configuration.
153/// Checks that not-yet-defined option values are not used.
9199139f
AR
154class YesNoNone
155{
57af1e3f
AR
156// TODO: generalize to non-boolean option types
157public:
5a59faa4 158 YesNoNone(): option(0) {}
57af1e3f
AR
159
160 /// returns true iff enabled; asserts if the option has not been configured
161 operator void *() const; // TODO: use a fancy/safer version of the operator
162
9199139f 163 /// enables or disables the option;
57af1e3f
AR
164 void configure(bool beSet);
165
166 /// whether the option was enabled or disabled, by user or Squid
167 bool configured() const { return option != 0; }
168
169private:
170 enum { optUnspecified = -1, optDisabled = 0, optEnabled = 1 };
171 int option; ///< configured value or zero
172};
c8f4eac4 173
9e008dda 174struct SquidConfig {
62e76326 175
9e008dda 176 struct {
c8f4eac4 177 /* These should be for the Store::Root instance.
178 * this needs pluggable parsing to be done smoothly.
179 */
62e76326 180 int highWaterMark;
181 int lowWaterMark;
3d0ac046 182 } Swap;
57af1e3f
AR
183
184 YesNoNone memShared; ///< whether the memory cache is shared among workers
43a70238 185 size_t memMaxSize;
62e76326 186
9e008dda 187 struct {
47f6e231 188 int64_t min;
62e76326 189 int pct;
47f6e231 190 int64_t max;
3d0ac046 191 } quickAbort;
47f6e231 192 int64_t readAheadGap;
6a566b9c 193 RemovalPolicySettings *replPolicy;
194 RemovalPolicySettings *memPolicy;
626096be 195#if USE_HTTP_VIOLATIONS
a8258824 196 time_t negativeTtl;
ac9cc053 197#endif
570d3f75 198 time_t maxStale;
a8258824 199 time_t negativeDnsTtl;
200 time_t positiveDnsTtl;
201 time_t shutdownLifetime;
d1b63fc8 202 time_t backgroundPingRate;
62e76326 203
9e008dda 204 struct {
62e76326 205 time_t read;
5ef5e5cc 206 time_t write;
62e76326 207 time_t lifetime;
208 time_t connect;
777831e0 209 time_t forward;
62e76326 210 time_t peer_connect;
211 time_t request;
97b32442
AJ
212 time_t clientIdlePconn;
213 time_t serverIdlePconn;
62e76326 214 time_t siteSelect;
215 time_t deadPeer;
216 int icp_query; /* msec */
217 int icp_query_max; /* msec */
218 int icp_query_min; /* msec */
219 int mcast_icp_query; /* msec */
62e76326 220
f64091a7 221#if !USE_DNSHELPER
fd0f51c4
CT
222 time_msec_t idns_retransmit;
223 time_msec_t idns_query;
3898f57f 224#endif
62e76326 225
3d0ac046 226 } Timeout;
0483b991 227 size_t maxRequestHeaderSize;
47f6e231 228 int64_t maxRequestBodySize;
3ff65596 229 int64_t maxChunkedRequestBodySize;
1368d115 230 size_t maxRequestBufferSize;
4eb368f9 231 size_t maxReplyHeaderSize;
ef1955a5 232 acl_size_t *ReplyBodySize;
62e76326 233
9e008dda 234 struct {
f45dd259 235 unsigned short icp;
ace287ee 236#if USE_HTCP
62e76326 237
f45dd259 238 unsigned short htcp;
ace287ee 239#endif
1df370e3 240#if SQUID_SNMP
62e76326 241
f45dd259 242 unsigned short snmp;
1df370e3 243#endif
3d0ac046 244 } Port;
62e76326 245
9e008dda 246 struct {
65d448bc 247 AnyP::PortCfg *http;
1f7c9178 248#if USE_SSL
65d448bc 249 AnyP::PortCfg *https;
1f7c9178 250#endif
3d0ac046 251 } Sockaddr;
1df370e3 252#if SQUID_SNMP
62e76326 253
9e008dda 254 struct {
62e76326 255 char *configFile;
256 char *agentInfo;
3d0ac046 257 } Snmp;
320e9f36 258#endif
eb824054 259#if USE_WCCP
62e76326 260
9e008dda 261 struct {
b7ac5457
AJ
262 Ip::Address router;
263 Ip::Address address;
62e76326 264 int version;
3d0ac046 265 } Wccp;
1df370e3 266#endif
0b0cfcf2 267#if USE_WCCPv2
268
9e008dda 269 struct {
b7ac5457
AJ
270 Ip::Address_list *router;
271 Ip::Address address;
0b0cfcf2 272 int forwarding_method;
273 int return_method;
b7d249f9 274 int assignment_method;
275 int weight;
f67332d3 276 int rebuildwait;
0b0cfcf2 277 void *info;
2fadd50d 278 } Wccp2;
0b0cfcf2 279#endif
62e76326 280
cc192b50 281#if USE_ICMP
663ff9aa 282 IcmpConfig pinger;
cc192b50 283#endif
284
53ad48e6 285 char *as_whois_server;
62e76326 286
9e008dda 287 struct {
62e76326 288 char *store;
289 char *swap;
7684c4b1 290 customlog *accesslogs;
e1381638 291#if ICAP_CLIENT
3ff65596
AR
292 customlog *icaplogs;
293#endif
62e76326 294 int rotateNumber;
2fadd50d 295 } Log;
a8258824 296 char *adminEmail;
abacf776 297 char *EmailFrom;
d084bf20 298 char *EmailProgram;
a8258824 299 char *effectiveUser;
d3caee79 300 char *visible_appname_string;
a8258824 301 char *effectiveGroup;
62e76326 302
9e008dda 303 struct {
f64091a7 304#if USE_DNSHELPER
62e76326 305 char *dnsserver;
efd900cb 306#endif
62e76326 307
308 wordlist *redirect;
a3d0a19d 309#if USE_UNLINKD
62e76326 310
311 char *unlinkd;
a3d0a19d 312#endif
62e76326 313
314 char *diskd;
307b83b7 315#if USE_SSL
316
317 char *ssl_password;
318#endif
319
2fadd50d 320 } Program;
f64091a7 321#if USE_DNSHELPER
48d54e4d 322 HelperChildConfig dnsChildren;
efd900cb 323#endif
62e76326 324
48d54e4d 325 HelperChildConfig redirectChildren;
94439e4e 326 time_t authenticateGCInterval;
70a76033 327 time_t authenticateTTL;
328 time_t authenticateIpTTL;
43ae1d95 329
9e008dda 330 struct {
43ae1d95 331 char *surrogate_id;
2fadd50d 332 } Accel;
a8258824 333 char *appendDomain;
334 size_t appendDomainLen;
a8258824 335 char *pidFilename;
2b753521 336 char *netdbFilename;
a8258824 337 char *mimeTablePathname;
0e70aa1e 338 char *etcHostsPath;
a8258824 339 char *visibleHostname;
98829f69 340 char *uniqueHostname;
1f38f50a 341 wordlist *hostnameAliases;
a8258824 342 char *errHtmlText;
62e76326 343
9e008dda 344 struct {
62e76326 345 char *host;
346 char *file;
347 time_t period;
f45dd259 348 unsigned short port;
2fadd50d 349 } Announce;
62e76326 350
9e008dda 351 struct {
62e76326 352
b7ac5457
AJ
353 Ip::Address udp_incoming;
354 Ip::Address udp_outgoing;
15dcc168 355#if SQUID_SNMP
b7ac5457
AJ
356 Ip::Address snmp_incoming;
357 Ip::Address snmp_outgoing;
15dcc168 358#endif
cc192b50 359 /* FIXME INET6 : this should really be a CIDR value */
b7ac5457 360 Ip::Address client_netmask;
2fadd50d 361 } Addrs;
9906e724 362 size_t tcpRcvBufsz;
363 size_t udpMaxHitObjsz;
a8258824 364 wordlist *hierarchy_stoplist;
365 wordlist *mcast_group_list;
09c483ec 366 wordlist *dns_nameservers;
40a1495e 367 peer *peers;
368 int npeers;
62e76326 369
9e008dda 370 struct {
62e76326 371 int size;
372 int low;
373 int high;
2fadd50d 374 } ipcache;
62e76326 375
9e008dda 376 struct {
62e76326 377 int size;
2fadd50d 378 } fqdncache;
a8258824 379 int minDirectHops;
5f84d830 380 int minDirectRtt;
a8258824 381 cachemgr_passwd *passwd_list;
62e76326 382
9e008dda 383 struct {
62e76326 384 int objectsPerBucket;
3e62bd58 385 int64_t avgObjectSize;
47f6e231 386 int64_t maxObjectSize;
387 int64_t minObjectSize;
62e76326 388 size_t maxInMemObjSize;
2fadd50d 389 } Store;
62e76326 390
9e008dda 391 struct {
62e76326 392 int high;
393 int low;
394 time_t period;
2fadd50d 395 } Netdb;
62e76326 396
9e008dda 397 struct {
62e76326 398 int log_udp;
62e76326 399 int res_defnames;
62e76326 400 int anonymizer;
401 int client_db;
402 int query_icmp;
403 int icp_hit_stale;
404 int buffered_logs;
62e76326 405 int common_log;
406 int log_mime_hdrs;
407 int log_fqdn;
408 int announce;
409 int mem_pools;
410 int test_reachability;
411 int half_closed_clients;
4c3ef9b2 412 int refresh_all_ims;
626096be 413#if USE_HTTP_VIOLATIONS
62e76326 414
415 int reload_into_ims;
9f60cfdf 416#endif
62e76326 417
418 int offline;
419 int redir_rewrites_host;
420 int prefer_direct;
421 int nonhierarchical_direct;
422 int strip_query_terms;
423 int redirector_bypass;
424 int ignore_unknown_nameservers;
425 int client_pconns;
426 int server_pconns;
58850d15 427 int error_pconns;
7e3ce7b9 428#if USE_CACHE_DIGESTS
62e76326 429
430 int digest_generation;
7e3ce7b9 431#endif
62e76326 432
62e76326 433 int ie_refresh;
434 int vary_ignore_expire;
435 int pipeline_prefetch;
43ae1d95 436 int surrogate_is_remote;
62e76326 437 int request_entities;
21b92762 438 int detect_broken_server_pconns;
a12a049a 439 int balance_on_multiple_ip;
52d3f198 440 int relaxed_header_parser;
62e76326 441 int check_hostnames;
a78278e2 442 int allow_underscore;
62e76326 443 int via;
444 int emailErrData;
d3caee79 445 int httpd_suppress_version_string;
f024c970 446 int global_internal_static;
3d674977
AJ
447
448#if FOLLOW_X_FORWARDED_FOR
449 int acl_uses_indirect_client;
450 int delay_pool_uses_indirect_client;
451 int log_uses_indirect_client;
96d64448
AJ
452#if LINUX_NETFILTER
453 int tproxy_uses_indirect_client;
454#endif
3d674977
AJ
455#endif /* FOLLOW_X_FORWARDED_FOR */
456
b6696974 457 int WIN32_IpAddrChangeMonitor;
ff4b33f4
HN
458 int memory_cache_first;
459 int memory_cache_disk;
90529125 460 int hostStrictVerify;
bfe4e2fe 461 int client_dst_passthru;
2fadd50d 462 } onoff;
97427e90 463
437823b4 464 int forward_max_tries;
31ef19cd 465 int connect_retries;
437823b4 466
97427e90 467 class ACL *aclList;
62e76326 468
9e008dda 469 struct {
62e76326 470 acl_access *http;
533493da 471 acl_access *adapted_http;
62e76326 472 acl_access *icp;
473 acl_access *miss;
474 acl_access *NeverDirect;
475 acl_access *AlwaysDirect;
476 acl_access *ASlists;
477 acl_access *noCache;
7684c4b1 478 acl_access *log;
dba79ac5 479#if SQUID_SNMP
62e76326 480
481 acl_access *snmp;
dba79ac5 482#endif
626096be 483#if USE_HTTP_VIOLATIONS
62e76326 484 acl_access *brokenPosts;
aa49962c 485#endif
62e76326 486 acl_access *redirector;
487 acl_access *reply;
488 acl_address *outgoing_address;
5401aa8d 489#if USE_HTCP
490
491 acl_access *htcp;
492 acl_access *htcp_clr;
493#endif
9e008dda 494
4c9da963 495#if USE_SSL
496 acl_access *ssl_bump;
497#endif
3d674977
AJ
498#if FOLLOW_X_FORWARDED_FOR
499 acl_access *followXFF;
500#endif /* FOLLOW_X_FORWARDED_FOR */
5401aa8d 501
3ff65596
AR
502#if ICAP_CLIENT
503 acl_access* icap;
504#endif
2fadd50d 505 } accessList;
bd05e3e3 506 acl_deny_info_list *denyInfoList;
62e76326 507
9e008dda 508 struct {
62e76326 509 size_t list_width;
510 int list_wrap;
511 char *anon_user;
512 int passive;
a689bd4e 513 int epsv_all;
51ee534d 514 int epsv;
63ee5443 515 int eprt;
62e76326 516 int sanitycheck;
dad0fe12 517 int telnet;
2fadd50d 518 } Ftp;
a8258824 519 refresh_t *Refresh;
62e76326 520
9e008dda 521 struct _cacheSwap {
7d3c4ca1 522 RefCount<SwapDir> *swapDirs;
62e76326 523 int n_allocated;
524 int n_configured;
9e2229b9 525 /// number of disk processes required to support all cache_dirs
14911a4e 526 int n_strands;
2fadd50d 527 } cacheSwap;
cdb527f0
A
528 /*
529 * I'm sick of having to keep doing this ..
530 */
ef364f64 531#define INDEXSD(i) (Config.cacheSwap.swapDirs[(i)].getRaw())
62e76326 532
9e008dda 533 struct {
62e76326 534 char *directory;
e72a0ec0 535 int use_short_names;
2fadd50d 536 } icons;
9b312a19 537 char *errorDirectory;
43000484
AJ
538#if USE_ERR_LOCALES
539 char *errorDefaultLanguage;
c411820c 540 int errorLogMissingLanguages;
43000484 541#endif
5b52cb6c 542 char *errorStylesheet;
62e76326 543
9e008dda 544 struct {
5894ad28 545 int onerror;
2fadd50d 546 } retry;
62e76326 547
9e008dda 548 struct {
70be1349 549 int64_t limit;
2fadd50d 550 } MemPools;
9a0a18de 551#if USE_DELAY_POOLS
62e76326 552
b67e2c8c 553 DelayConfig Delay;
b4cd430a 554 ClientDelayConfig ClientDelay;
95e36d02 555#endif
62e76326 556
9e008dda 557 struct {
65d448bc
AJ
558 struct {
559 int average;
560 int min_poll;
561 } dns, udp, tcp;
2fadd50d 562 } comm_incoming;
c5f627c2 563 int max_open_disk_fds;
d548ee64 564 int uri_whitespace;
11e3fa1c 565 acl_size_t *rangeOffsetLimit;
e66d7923 566#if MULTICAST_MISS_STREAM
62e76326 567
9e008dda 568 struct {
62e76326 569
b7ac5457 570 Ip::Address addr;
62e76326 571 int ttl;
572 unsigned short port;
573 char *encode_key;
2fadd50d 574 } mcast_miss;
e66d7923 575#endif
62e76326 576
3b07476b
CT
577 /// request_header_access and request_header_replace
578 HeaderManglers *request_header_access;
579 /// reply_header_access and reply_header_replace
580 HeaderManglers *reply_header_access;
f4698e0b
CT
581 ///request_header_add access list
582 HeaderWithAclList *request_header_add;
b6a2f15e 583 char *coredump_dir;
efd900cb 584 char *chroot_dir;
7e3ce7b9 585#if USE_CACHE_DIGESTS
62e76326 586
9e008dda 587 struct {
62e76326 588 int bits_per_entry;
589 time_t rebuild_period;
590 time_t rewrite_period;
591 size_t swapout_chunk_size;
592 int rebuild_chunk_percentage;
2fadd50d 593 } digest;
1f7c9178 594#endif
595#if USE_SSL
62e76326 596
9e008dda 597 struct {
62e76326 598 int unclean_shutdown;
599 char *ssl_engine;
2fadd50d 600 } SSL;
7e3ce7b9 601#endif
62e76326 602
56fe752e 603 wordlist *ext_methods;
62e76326 604
9e008dda 605 struct {
62e76326 606 int high_rptm;
607 int high_pf;
608 size_t high_memory;
2fadd50d 609 } warnings;
65a53c8e 610 char *store_dir_select_algorithm;
1fbbdcb0 611 int sleep_after_fork; /* microseconds */
6a2f3fcf 612 time_t minimum_expiry_time; /* seconds */
d9572179 613 external_acl *externalAclHelperList;
575cb927 614
a7ad6e4e 615#if USE_SSL
62e76326 616
9e008dda 617 struct {
62e76326 618 char *cert;
619 char *key;
620 int version;
621 char *options;
622 char *cipher;
623 char *cafile;
624 char *capath;
a82a4fe4 625 char *crlfile;
62e76326 626 char *flags;
4c9da963 627 acl_access *cert_error;
62e76326 628 SSL_CTX *sslContext;
aebe6888 629 sslproxy_cert_sign *cert_sign;
fb2178bb 630 sslproxy_cert_adapt *cert_adapt;
2fadd50d 631 } ssl_client;
a7ad6e4e 632#endif
cc9f92d4 633
cc9f92d4 634 char *accept_filter;
c642c141 635 int umask;
f3f0f563 636 int max_filedescriptors;
13aeac35 637 int workers;
96c2bb61 638 CpuAffinityMap *cpuAffinityMap;
57afc994
AR
639
640#if USE_LOADABLE_MODULES
641 wordlist *loadable_module_names;
642#endif
ab2ecb0e
AJ
643
644 int client_ip_max_connections;
e210930b
AJ
645
646 struct {
5a0da9ec 647 int v4_first; ///< Place IPv4 first in the order of DNS results.
e210930b
AJ
648 ssize_t packet_max; ///< maximum size EDNS advertised for DNS replies.
649 } dns;
a8258824 650};
651
e1f7507e 652SQUIDCEXTERN SquidConfig Config;
62e76326 653
9e008dda
AJ
654struct SquidConfig2 {
655 struct {
62e76326 656 int enable_purge;
4f56514c 657 int mangle_request_headers;
2fadd50d 658 } onoff;
d20b1cd0 659 uid_t effectiveUserID;
660 gid_t effectiveGroupID;
a8258824 661};
662
e1f7507e
AJ
663SQUIDCEXTERN SquidConfig2 Config2;
664
9e008dda 665struct _close_handler {
a8258824 666 PF *handler;
667 void *data;
668 close_handler *next;
669};
670
9e008dda 671struct _dread_ctrl {
a8258824 672 int fd;
673 off_t offset;
674 int req_len;
675 char *buf;
676 int end_of_file;
677 DRCB *handler;
678 void *client_data;
679};
680
9e008dda 681struct _dwrite_q {
d377699f 682 off_t file_offset;
a8258824 683 char *buf;
57d55dfa 684 size_t len;
685 size_t buf_offset;
bd05e3e3 686 dwrite_q *next;
74fbf3c9 687 FREE *free_func;
a8258824 688};
689
9e008dda 690struct _fde_disk {
e6ccf245 691 DWCB *wrt_handle;
692 void *wrt_handle_data;
693 dwrite_q *write_q;
694 dwrite_q *write_q_tail;
695 off_t offset;
696};
697
7faf2bdb 698/* per field statistics */
62e76326 699
0353e724 700class HttpHeaderFieldStat
62e76326 701{
0353e724 702
703public:
9e008dda 704 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0) {}
0353e724 705
399e85ea 706 int aliveCount; /* created but not destroyed (count) */
d8b249ef 707 int seenCount; /* #fields we've seen */
399e85ea 708 int parsCount; /* #parsing attempts */
709 int errCount; /* #pasring errors */
710 int repCount; /* #repetitons */
7faf2bdb 711};
712
d8b249ef 713/* compiled version of HttpHeaderFieldAttrs plus stats */
58a4c2a2 714#include "SquidString.h"
62e76326 715
0353e724 716class HttpHeaderFieldInfo
62e76326 717{
0353e724 718
719public:
9e008dda 720 HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid) {}
0353e724 721
de336bbe 722 http_hdr_type id;
30abd221 723 String name;
de336bbe 724 field_type type;
7faf2bdb 725 HttpHeaderFieldStat stat;
726};
727
9e008dda 728struct _http_state_flags {
3d0ac046
HN
729 unsigned int proxying:1;
730 unsigned int keepalive:1;
731 unsigned int only_if_cached:1;
655daa06 732 unsigned int handling1xx:1; ///< we are ignoring or forwarding 1xx response
3d0ac046
HN
733 unsigned int headers_parsed:1;
734 unsigned int front_end_https:2;
735 unsigned int originpeer:1;
736 unsigned int keepalive_broken:1;
737 unsigned int abuse_detected:1;
738 unsigned int request_sent:1;
739 unsigned int do_next_read:1;
740 unsigned int consume_body_data:1;
e31a1e67
AR
741 unsigned int chunked:1; ///< reading a chunked response; TODO: rename
742 unsigned int chunked_request:1; ///< writing a chunked request
39cb8c41 743 unsigned int sentLastChunk:1; ///< do not try to write last-chunk again
b515fc11 744};
a8258824 745
9e008dda 746struct _domain_ping {
a8258824 747 char *domain;
748 int do_ping; /* boolean */
bd05e3e3 749 domain_ping *next;
a8258824 750};
751
9e008dda 752struct _domain_type {
a8258824 753 char *domain;
754 peer_t type;
bd05e3e3 755 domain_type *next;
a8258824 756};
757
e1f7507e
AJ
758class PeerDigest;
759
9e008dda 760struct peer {
cc192b50 761 u_int index;
be753325 762 char *name;
a8258824 763 char *host;
764 peer_t type;
62e76326 765
b7ac5457 766 Ip::Address in_addr;
62e76326 767
9e008dda 768 struct {
62e76326 769 int pings_sent;
770 int pings_acked;
771 int fetches;
772 int rtt;
773 int ignored_replies;
774 int n_keepalives_sent;
775 int n_keepalives_recv;
776 time_t probe_start;
777 time_t last_query;
778 time_t last_reply;
779 time_t last_connect_failure;
780 time_t last_connect_probe;
781 int logged_state; /* so we can print dead/revived msgs */
782 int conn_open; /* current opened connections */
2fadd50d 783 } stats;
62e76326 784
9e008dda 785 struct {
62e76326 786 int version;
093bce8b 787 int counts[ICP_END+1];
f45dd259 788 unsigned short port;
2fadd50d 789 } icp;
62e76326 790
a8b1cdf6 791#if USE_HTCP
9e008dda 792 struct {
62e76326 793 double version;
794 int counts[2];
f45dd259 795 unsigned short port;
2fadd50d 796 } htcp;
399cabec 797#endif
62e76326 798
f45dd259 799 unsigned short http_port;
b6a2f15e 800 domain_ping *peer_domain;
bd05e3e3 801 domain_type *typelist;
505e35db 802 acl_access *access;
62e76326 803
9e008dda 804 struct {
3d0ac046
HN
805 unsigned int proxy_only:1;
806 unsigned int no_query:1;
807 unsigned int background_ping:1;
808 unsigned int no_digest:1;
809 unsigned int default_parent:1;
810 unsigned int roundrobin:1;
811 unsigned int weighted_roundrobin:1;
812 unsigned int mcast_responder:1;
813 unsigned int closest_only:1;
cd196bc8 814#if USE_HTCP
3d0ac046
HN
815 unsigned int htcp:1;
816 unsigned int htcp_oldsquid:1;
4f4fa815
BR
817 unsigned int htcp_no_clr:1;
818 unsigned int htcp_no_purge_clr:1;
819 unsigned int htcp_only_clr:1;
820 unsigned int htcp_forward_clr:1;
cd196bc8 821#endif
3d0ac046 822 unsigned int no_netdb_exchange:1;
9a0a18de 823#if USE_DELAY_POOLS
3d0ac046 824 unsigned int no_delay:1;
cd196bc8 825#endif
3d0ac046 826 unsigned int allow_miss:1;
3d0ac046 827 unsigned int carp:1;
de03b596 828 struct {
96f6f33b
A
829 unsigned int set:1; //If false, whole url is to be used. Overrides others
830 unsigned int scheme:1;
831 unsigned int host:1;
832 unsigned int port:1;
833 unsigned int path:1;
834 unsigned int params:1;
de03b596 835 } carp_key;
2f1431ea 836#if USE_AUTH
f7e1d9ce 837 unsigned int userhash:1;
2f1431ea 838#endif
f7e1d9ce 839 unsigned int sourcehash:1;
3d0ac046 840 unsigned int originserver:1;
b0758e04 841 unsigned int no_tproxy:1;
8a368316
AJ
842#if PEER_MULTICAST_SIBLINGS
843 unsigned int mcast_siblings:1;
844#endif
3d0ac046 845 } options;
62e76326 846
a8258824 847 int weight;
d1b63fc8 848 int basetime;
62e76326 849
9e008dda 850 struct {
62e76326 851 double avg_n_members;
852 int n_times_counted;
853 int n_replies_expected;
854 int ttl;
855 int id;
856
9e008dda 857 struct {
3d0ac046
HN
858 unsigned int count_event_pending:1;
859 unsigned int counting:1;
860 } flags;
861 } mcast;
c68e9c6b 862#if USE_CACHE_DIGESTS
62e76326 863
e13ee7ad 864 PeerDigest *digest;
7e3ce7b9 865 char *digest_url;
c68e9c6b 866#endif
62e76326 867
a8258824 868 int tcp_up; /* 0 if a connect() fails */
62e76326 869
b7ac5457 870 Ip::Address addresses[10];
a8258824 871 int n_addresses;
872 int rr_count;
bd05e3e3 873 peer *next;
aed188fd 874 int testing_now;
62e76326 875
9e008dda 876 struct {
62e76326 877 unsigned int hash;
878 double load_multiplier;
879 double load_factor; /* normalized weight value */
2fadd50d 880 } carp;
2f1431ea 881#if USE_AUTH
9e008dda 882 struct {
f7e1d9ce
HN
883 unsigned int hash;
884 double load_multiplier;
885 double load_factor; /* normalized weight value */
886 } userhash;
2f1431ea 887#endif
9e008dda 888 struct {
f7e1d9ce
HN
889 unsigned int hash;
890 double load_multiplier;
891 double load_factor; /* normalized weight value */
892 } sourcehash;
893
c68e9c6b 894 char *login; /* Proxy authorization */
3f62decd 895 time_t connect_timeout;
ff9970cc 896 int connect_fail_limit;
c7f9eb6d 897 int max_conn;
be753325 898 char *domain; /* Forced domain */
a7ad6e4e 899#if USE_SSL
62e76326 900
a7ad6e4e 901 int use_ssl;
902 char *sslcert;
903 char *sslkey;
904 int sslversion;
905 char *ssloptions;
906 char *sslcipher;
907 char *sslcafile;
908 char *sslcapath;
a82a4fe4 909 char *sslcrlfile;
a7ad6e4e 910 char *sslflags;
911 char *ssldomain;
912 SSL_CTX *sslContext;
f38c5e43 913 SSL_SESSION *sslSession;
a7ad6e4e 914#endif
62e76326 915
a7ad6e4e 916 int front_end_https;
d67acb4e 917 int connection_auth;
a8258824 918};
919
9e008dda 920struct _net_db_name {
186477c1 921 hash_link hash; /* must be first */
74fbf3c9 922 net_db_name *next;
923 netdbEntry *net_db_entry;
a8258824 924};
925
9e008dda 926struct _net_db_peer {
6b53c392 927 const char *peername;
a8258824 928 double hops;
929 double rtt;
930 time_t expires;
931};
932
9e008dda 933struct _netdbEntry {
186477c1 934 hash_link hash; /* must be first */
cc192b50 935 char network[MAX_IPSTRLEN];
a8258824 936 int pings_sent;
937 int pings_recv;
938 double hops;
939 double rtt;
940 time_t next_ping_time;
941 time_t last_use_time;
942 int link_count;
943 net_db_name *hosts;
944 net_db_peer *peers;
945 int n_peers_alloc;
946 int n_peers;
947};
948
9e008dda 949struct _iostats {
62e76326 950
8822ebee
AR
951 enum { histSize = 16 };
952
9e008dda 953 struct {
62e76326 954 int reads;
955 int reads_deferred;
8822ebee 956 int read_hist[histSize];
62e76326 957 int writes;
8822ebee 958 int write_hist[histSize];
62e76326 959 }
960
db80e881 961 Http, Ftp, Gopher;
a8258824 962};
963
9e008dda 964struct request_flags {
03f00a11 965 request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),fail_on_validation_err(0),stale_if_hit(0),accelerated(0),ignore_cc(0),intercepted(0),hostVerified(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),pinned(0),canRePin(0),chunked_reply(0),stream_error(0),sslPeek(0),sslBumped(0),destinationIPLookedUp_(0) {
626096be 966#if USE_HTTP_VIOLATIONS
72eee553 967 nocache_hack = 0;
e429f975 968#endif
3d674977 969#if FOLLOW_X_FORWARDED_FOR
9e008dda 970 done_follow_x_forwarded_for = 0;
3d674977 971#endif /* FOLLOW_X_FORWARDED_FOR */
62e76326 972 }
973
3d0ac046 974 unsigned int range:1;
2962f8b8 975 unsigned int nocache:1; ///< whether the response to this request may be READ from cache
3d0ac046
HN
976 unsigned int ims:1;
977 unsigned int auth:1;
2962f8b8 978 unsigned int cachable:1; ///< whether the response to thie request may be stored in the cache
3d0ac046
HN
979 unsigned int hierarchical:1;
980 unsigned int loopdetect:1;
981 unsigned int proxy_keepalive:1;
9e008dda
AJ
982unsigned int proxying:
983 1; /* this should be killed, also in httpstateflags */
3d0ac046
HN
984 unsigned int refresh:1;
985 unsigned int redirected:1;
986 unsigned int need_validation:1;
7948b784 987 unsigned int fail_on_validation_err:1; ///< whether we should fail if validation fails
bcfba8bd 988 unsigned int stale_if_hit:1; ///< reply is stale if it is a hit
626096be 989#if USE_HTTP_VIOLATIONS
3d0ac046 990 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
9f60cfdf 991#endif
3d0ac046 992 unsigned int accelerated:1;
432bc83c 993 unsigned int ignore_cc:1;
2962f8b8
AJ
994 unsigned int intercepted:1; ///< intercepted request
995 unsigned int hostVerified:1; ///< whether the Host: header passed verification
f165d2fb 996 unsigned int spoof_client_ip:1; /**< spoof client ip if possible */
3d0ac046
HN
997 unsigned int internal:1;
998 unsigned int internalclient:1;
999 unsigned int must_keepalive:1;
d67acb4e
AJ
1000 unsigned int connection_auth:1; /** Request wants connection oriented auth */
1001 unsigned int connection_auth_disabled:1; /** Connection oriented auth can not be supported */
1002 unsigned int connection_proxy_auth:1; /** Request wants connection oriented auth */
1003 unsigned int pinned:1; /* Request sent on a pinned connection */
85563fd9 1004 unsigned int canRePin:1; ///< OK to reopen a failed pinned connection
d67acb4e 1005 unsigned int auth_sent:1; /* Authentication forwarded */
7f7bdd96 1006 unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
4ad60609
AR
1007 unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
1008 unsigned int stream_error:1; /**< Whether stream error has occured */
2c065fc8 1009 unsigned int sslPeek:1; ///< internal ssl-bump request to get server cert
b68415a1 1010 unsigned int sslBumped:1; /**< ssl-bumped request*/
5f8252d2 1011
1012 // When adding new flags, please update cloneAdaptationImmune() as needed.
1013
e429f975 1014 bool resetTCP() const;
1015 void setResetTCP();
1016 void clearResetTCP();
8000a965 1017 void destinationIPLookupCompleted();
1018 bool destinationIPLookedUp() const;
62e76326 1019
5f8252d2 1020 // returns a partial copy of the flags that includes only those flags
1021 // that are safe for a related (e.g., ICAP-adapted) request to inherit
1022 request_flags cloneAdaptationImmune() const;
1023
3d674977
AJ
1024#if FOLLOW_X_FORWARDED_FOR
1025 unsigned int done_follow_x_forwarded_for;
1026#endif /* FOLLOW_X_FORWARDED_FOR */
e429f975 1027private:
62e76326 1028
3d0ac046
HN
1029 unsigned int reset_tcp:1;
1030 unsigned int destinationIPLookedUp_:1;
92695e5e 1031};
1032
9e008dda 1033struct _link_list {
d03d26fb 1034 void *ptr;
62e76326 1035
d03d26fb 1036 struct _link_list *next;
1037};
1038
9e008dda 1039struct _cachemgr_passwd {
a8258824 1040 char *passwd;
22f3fd98 1041 wordlist *actions;
bd05e3e3 1042 cachemgr_passwd *next;
a8258824 1043};
1044
9e008dda 1045struct _refresh_t {
a2c963ae 1046 const char *pattern;
a8258824 1047 regex_t compiled_pattern;
1048 time_t min;
c3f6d204 1049 double pct;
a8258824 1050 time_t max;
bd05e3e3 1051 refresh_t *next;
62e76326 1052
9e008dda 1053 struct {
3d0ac046
HN
1054 unsigned int icase:1;
1055 unsigned int refresh_ims:1;
3d8b6ba4 1056 unsigned int store_stale:1;
626096be 1057#if USE_HTTP_VIOLATIONS
3d0ac046
HN
1058 unsigned int override_expire:1;
1059 unsigned int override_lastmod:1;
1060 unsigned int reload_into_ims:1;
1061 unsigned int ignore_reload:1;
1062 unsigned int ignore_no_cache:1;
1063 unsigned int ignore_no_store:1;
4ca08219 1064 unsigned int ignore_must_revalidate:1;
3d0ac046
HN
1065 unsigned int ignore_private:1;
1066 unsigned int ignore_auth:1;
9f60cfdf 1067#endif
3d0ac046 1068 } flags;
570d3f75 1069 int max_stale;
a8258824 1070};
1071
9e008dda 1072struct _CacheDigest {
c411be12 1073 /* public, read-only */
1afe05c5 1074 char *mask; /* bit mask */
57d55dfa 1075 int mask_size; /* mask size in bytes */
1afe05c5 1076 int capacity; /* expected maximum for .count, not a hard limit */
04f0c415 1077 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1afe05c5 1078 int count; /* number of digested entries */
1079 int del_count; /* number of deletions performed so far */
c411be12 1080};
910169e5 1081
9e008dda 1082struct _store_rebuild_data {
b2c141d4 1083 int objcount; /* # objects successfully reloaded */
1084 int expcount; /* # objects expired */
1085 int scancount; /* # entries scanned or read from state file */
1086 int clashcount; /* # swapfile clashes avoided */
1087 int dupcount; /* # duplicates purged */
1088 int cancelcount; /* # SWAP_LOG_DEL objects purged */
1089 int invalid; /* # bad lines */
1090 int badflags; /* # bad e->flags */
1091 int bad_log_op;
1092 int zero_object_sz;
1093};
5673c2e2 1094
fb2178bb 1095#if USE_SSL
aebe6888
CT
1096struct _sslproxy_cert_sign {
1097 int alg;
1098 ACLList *aclList;
1099 sslproxy_cert_sign *next;
1100};
1101
fb2178bb
CT
1102struct _sslproxy_cert_adapt {
1103 int alg;
1104 char *param;
1105 ACLList *aclList;
1106 sslproxy_cert_adapt *next;
1107};
1108#endif
1109
82b7abe3
AJ
1110class Logfile;
1111
38e16f92 1112#include "format/Format.h"
20efa1c2 1113#include "log/Formats.h"
9e008dda 1114struct _customlog {
7684c4b1 1115 char *filename;
76cd39d7 1116 ACLList *aclList;
38e16f92 1117 Format::Format *logFormat;
7684c4b1 1118 Logfile *logfile;
1119 customlog *next;
20efa1c2 1120 Log::Format::log_type type;
7684c4b1 1121};
1122
b5638623 1123#endif /* SQUID_STRUCTS_H */