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