]> git.ipfire.org Git - thirdparty/squid.git/blame - src/structs.h
hno squid-2.3.STABLE1.http_reply_null_character.patch
[thirdparty/squid.git] / src / structs.h
CommitLineData
a8258824 1
9cef6668 2/*
304d289e 3 * $Id: structs.h,v 1.327 2000/05/02 21:21:09 hno Exp $
9cef6668 4 *
5 *
6 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from the
10 * Internet community. Development is led by Duane Wessels of the
11 * National Laboratory for Applied Network Research and funded by the
12 * National Science Foundation. Squid is Copyrighted (C) 1998 by
efd900cb 13 * the Regents of the University of California. Please see the
14 * COPYRIGHT file for full details. Squid incorporates software
15 * developed and/or copyrighted by other sources. Please see the
16 * 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
0f1bc304 34struct _dlink_node {
35 void *data;
36 dlink_node *prev;
37 dlink_node *next;
38};
39
40struct _dlink_list {
41 dlink_node *head;
42 dlink_node *tail;
43};
44
a8258824 45struct _acl_ip_data {
46 struct in_addr addr1; /* if addr2 non-zero then its a range */
47 struct in_addr addr2;
48 struct in_addr mask;
1a106e18 49 acl_ip_data *next; /* used for parsing, not for storing */
a8258824 50};
51
52struct _acl_time_data {
53 int weekbits;
54 int start;
55 int stop;
74fbf3c9 56 acl_time_data *next;
a8258824 57};
58
59struct _acl_name_list {
60 char name[ACL_NAME_SZ];
74fbf3c9 61 acl_name_list *next;
a8258824 62};
63
ec878047 64struct _acl_proxy_auth_user {
65 /* first two items must be same as hash_link */
66 char *user;
67 acl_proxy_auth_user *next;
73e67ee0 68 /* extra fields for proxy_auth */
ec878047 69 char *passwd;
73e67ee0 70 int passwd_ok; /* 1 = passwd checked OK */
71 long expiretime;
9bc73deb 72 struct in_addr ipaddr; /* IP addr this user authenticated from */
73 time_t ip_expiretime;
ec878047 74};
75
a8258824 76struct _acl_deny_info_list {
02922e76 77 int err_page_id;
78 char *err_page_name;
74fbf3c9 79 acl_name_list *acl_list;
80 acl_deny_info_list *next;
a8258824 81};
82
66c75c41 83#if USE_ARP_ACL
cbe3a719 84
66c75c41 85struct _acl_arp_data {
74b7003b 86 char eth[6];
66c75c41 87};
cbe3a719 88
66c75c41 89#endif
90
02922e76 91struct _String {
92 /* never reference these directly! */
a369131d 93 unsigned short int size; /* buffer size; 64K limit */
94 unsigned short int len; /* current length */
02922e76 95 char *buf;
96};
97
1df370e3 98#if SQUID_SNMP
43d4303e 99
a9ddb359 100struct _snmp_request_t {
5e29a294 101 u_char *buf;
102 u_char *outbuf;
2ac76861 103 int len;
104 int sock;
105 long reqid;
106 int outlen;
107 struct sockaddr_in from;
108 struct snmp_pdu *PDU;
109 aclCheck_t *acl_checklist;
5e29a294 110 u_char *community;
a9ddb359 111};
bdf18524 112
1df370e3 113#endif
a97cfa48 114
a8258824 115struct _acl {
116 char name[ACL_NAME_SZ];
117 squid_acl type;
118 void *data;
119 char *cfgline;
bd05e3e3 120 acl *next;
a8258824 121};
122
123struct _acl_list {
124 int op;
bd05e3e3 125 acl *acl;
126 acl_list *next;
a8258824 127};
128
129struct _acl_access {
130 int allow;
bd05e3e3 131 acl_list *acl_list;
a8258824 132 char *cfgline;
bd05e3e3 133 acl_access *next;
a8258824 134};
135
136struct _aclCheck_t {
bd05e3e3 137 const acl_access *access_list;
a8258824 138 struct in_addr src_addr;
139 struct in_addr dst_addr;
ae2c08a2 140 struct in_addr my_addr;
7e3ce7b9 141 unsigned short my_port;
a8258824 142 request_t *request;
3898f57f 143#if USE_IDENT
144 ConnStateData *conn; /* hack for ident */
def67559 145 char ident[USER_IDENT_SZ];
3898f57f 146#endif
73e67ee0 147 acl_proxy_auth_user *auth_user;
a8258824 148 acl_lookup_state state[ACL_ENUM_MAX];
dba79ac5 149#if SQUID_SNMP
150 char *snmp_community;
151#endif
a8258824 152 PF *callback;
153 void *callback_data;
154};
155
156struct _aio_result_t {
157 int aio_return;
158 int aio_errno;
159};
160
161struct _wordlist {
162 char *key;
bd05e3e3 163 wordlist *next;
a8258824 164};
165
166struct _intlist {
167 int i;
bd05e3e3 168 intlist *next;
a8258824 169};
170
8f663d72 171struct _intrange {
172 int i;
173 int j;
174 intrange *next;
175};
176
a8258824 177struct _ushortlist {
178 u_short i;
bd05e3e3 179 ushortlist *next;
a8258824 180};
181
182struct _relist {
183 char *pattern;
184 regex_t regex;
bd05e3e3 185 relist *next;
a8258824 186};
187
7e3ce7b9 188struct _sockaddr_in_list {
189 struct sockaddr_in s;
190 sockaddr_in_list *next;
191};
192
56e64999 193#if DELAY_POOLS
59715b38 194struct _delaySpec {
95e36d02 195 int restore_bps;
196 int max_bytes;
197};
1dfa1d81 198
59715b38 199/* malloc()'d only as far as used (class * sizeof(delaySpec)!
200 * order of elements very important!
201 */
202struct _delaySpecSet {
203 delaySpec aggregate;
204 delaySpec individual;
205 delaySpec network;
206};
207
208struct _delayConfig {
209 unsigned short pools;
210 unsigned short initial;
211 unsigned char *class;
212 delaySpecSet **rates;
213 acl_access **access;
214};
215
56e64999 216#endif
95e36d02 217
a8258824 218struct _SquidConfig {
219 struct {
9906e724 220 size_t maxSize;
a8258824 221 int highWaterMark;
222 int lowWaterMark;
43a70238 223 } Swap;
224 size_t memMaxSize;
a8258824 225 struct {
226 char *relayHost;
227 u_short relayPort;
db1cd23c 228 peer *peer;
a8258824 229 } Wais;
230 struct {
9906e724 231 size_t min;
a8258824 232 int pct;
9906e724 233 size_t max;
a8258824 234 } quickAbort;
2b906e48 235#if HEAP_REPLACEMENT
236 char *replPolicy;
237#else
238 /*
239 * Note: the non-LRU policies do not use referenceAge, but we cannot
240 * remove it until we find out how to implement #else for cf_parser.c
241 */
242#endif
a8258824 243 time_t referenceAge;
244 time_t negativeTtl;
245 time_t negativeDnsTtl;
246 time_t positiveDnsTtl;
247 time_t shutdownLifetime;
a8258824 248 struct {
249 time_t read;
a8258824 250 time_t lifetime;
251 time_t connect;
3f62decd 252 time_t peer_connect;
a8258824 253 time_t request;
603a02fd 254 time_t pconn;
23d92c64 255 time_t siteSelect;
dc835977 256 time_t deadPeer;
98829f69 257 int icp_query; /* msec */
28993292 258 int icp_query_max; /* msec */
98829f69 259 int mcast_icp_query; /* msec */
3898f57f 260#if USE_IDENT
05832ae1 261 time_t ident;
4fe0e1d0 262#endif
263#if !USE_DNSSERVERS
264 time_t idns_retransmit;
265 time_t idns_query;
3898f57f 266#endif
a8258824 267 } Timeout;
0483b991 268 size_t maxRequestHeaderSize;
269 size_t maxRequestBodySize;
270 size_t maxReplyBodySize;
a8258824 271 struct {
a8258824 272 u_short icp;
ace287ee 273#if USE_HTCP
274 u_short htcp;
275#endif
1df370e3 276#if SQUID_SNMP
678c6099 277 u_short snmp;
1df370e3 278#endif
a8258824 279 } Port;
7e3ce7b9 280 struct {
281 sockaddr_in_list *http;
282 } Sockaddr;
1df370e3 283#if SQUID_SNMP
2bbd722b 284 struct {
285 char *configFile;
286 char *agentInfo;
2ac237e2 287 } Snmp;
320e9f36 288#endif
eb824054 289#if USE_WCCP
320e9f36 290 struct {
291 struct in_addr router;
eb824054 292 struct in_addr incoming;
293 struct in_addr outgoing;
320e9f36 294 } Wccp;
1df370e3 295#endif
53ad48e6 296 char *as_whois_server;
a8258824 297 struct {
298 char *log;
299 char *access;
300 char *store;
301 char *swap;
82839306 302#if USE_USERAGENT_LOG
a8258824 303 char *useragent;
82839306 304#endif
a8258824 305 int rotateNumber;
a8258824 306 } Log;
a8258824 307 char *adminEmail;
308 char *effectiveUser;
309 char *effectiveGroup;
310 struct {
82839306 311#if USE_DNSSERVERS
a8258824 312 char *dnsserver;
efd900cb 313#endif
c6d5b87b 314 wordlist *redirect;
f703eacb 315 wordlist *authenticate;
82839306 316#if USE_ICMP
a8258824 317 char *pinger;
82839306 318#endif
319#if USE_UNLINKD
a8258824 320 char *unlinkd;
82839306 321#endif
a8258824 322 } Program;
82839306 323#if USE_DNSSERVERS
a8258824 324 int dnsChildren;
efd900cb 325#endif
a8258824 326 int redirectChildren;
73e67ee0 327 int authenticateChildren;
c68e9c6b 328 int authenticateTTL;
9bc73deb 329 int authenticateIpTTL;
a8258824 330 struct {
13c7936a 331 int single_host;
a8258824 332 char *host;
333 u_short port;
a8258824 334 } Accel;
335 char *appendDomain;
336 size_t appendDomainLen;
337 char *debugOptions;
338 char *pidFilename;
339 char *mimeTablePathname;
340 char *visibleHostname;
98829f69 341 char *uniqueHostname;
1f38f50a 342 wordlist *hostnameAliases;
a8258824 343 char *errHtmlText;
344 struct {
345 char *host;
346 char *file;
347 time_t period;
a8258824 348 u_short port;
349 } Announce;
350 struct {
a8258824 351 struct in_addr tcp_outgoing;
352 struct in_addr udp_incoming;
2bbd722b 353 struct in_addr udp_outgoing;
15dcc168 354#if SQUID_SNMP
678c6099 355 struct in_addr snmp_incoming;
2bbd722b 356 struct in_addr snmp_outgoing;
15dcc168 357#endif
a8258824 358 struct in_addr client_netmask;
359 } Addrs;
9906e724 360 size_t tcpRcvBufsz;
361 size_t udpMaxHitObjsz;
a8258824 362 wordlist *hierarchy_stoplist;
363 wordlist *mcast_group_list;
364 wordlist *dns_testname_list;
09c483ec 365 wordlist *dns_nameservers;
40a1495e 366 peer *peers;
367 int npeers;
a8258824 368 struct {
89de058c 369 int size;
a8258824 370 int low;
371 int high;
372 } ipcache;
e55650e3 373 struct {
374 int size;
375 } fqdncache;
a8258824 376 int minDirectHops;
377 cachemgr_passwd *passwd_list;
378 struct {
379 int objectsPerBucket;
9906e724 380 size_t avgObjectSize;
381 size_t maxObjectSize;
a8258824 382 } Store;
383 struct {
384 int high;
385 int low;
386 time_t period;
387 } Netdb;
388 struct {
389 int log_udp;
82839306 390#if USE_DNSSERVERS
a8258824 391 int res_defnames;
efd900cb 392#endif
a8258824 393 int anonymizer;
394 int client_db;
395 int query_icmp;
88738790 396 int icp_hit_stale;
78f1250a 397 int buffered_logs;
0ab965da 398#if ALLOW_SOURCE_PING
9b312a19 399 int source_ping;
0ab965da 400#endif
9b312a19 401 int common_log;
402 int log_mime_hdrs;
17a0a4ee 403 int log_fqdn;
404 int announce;
405 int accel_with_proxy;
3f6c0fb2 406 int mem_pools;
194dd3b8 407 int test_reachability;
ea285003 408 int half_closed_clients;
9f60cfdf 409#if HTTP_VIOLATIONS
465dc415 410 int reload_into_ims;
9f60cfdf 411#endif
b540e168 412 int offline;
c68e9c6b 413 int redir_rewrites_host;
9b094667 414 int prefer_direct;
168dfda9 415 int nonhierarchical_direct;
bcbc11b0 416 int strip_query_terms;
07476a7f 417 int redirector_bypass;
9bc73deb 418 int ignore_unknown_nameservers;
efd900cb 419 int client_pconns;
420 int server_pconns;
7e3ce7b9 421#if USE_CACHE_DIGESTS
422 int digest_generation;
423#endif
890b0fa8 424 int log_ip_on_direct;
17a0a4ee 425 } onoff;
bd05e3e3 426 acl *aclList;
a8258824 427 struct {
bd05e3e3 428 acl_access *http;
429 acl_access *icp;
430 acl_access *miss;
431 acl_access *NeverDirect;
432 acl_access *AlwaysDirect;
433 acl_access *ASlists;
434 acl_access *noCache;
dba79ac5 435#if SQUID_SNMP
436 acl_access *snmp;
437#endif
376bb137 438 acl_access *brokenPosts;
3898f57f 439#if USE_IDENT
a40699cd 440 acl_access *identLookup;
3898f57f 441#endif
9bc73deb 442 acl_access *redirector;
a8258824 443 } accessList;
bd05e3e3 444 acl_deny_info_list *denyInfoList;
f715bd3a 445 char *proxyAuthRealm;
a8258824 446 struct {
447 size_t list_width;
448 int list_wrap;
a8258824 449 char *anon_user;
450 } Ftp;
451 refresh_t *Refresh;
452 struct _cacheSwap {
a47b9029 453 SwapDir *swapDirs;
454 int n_allocated;
455 int n_configured;
a8258824 456 } cacheSwap;
88738790 457 char *fake_ua;
365cb147 458 struct {
459 char *directory;
365cb147 460 } icons;
9b312a19 461 char *errorDirectory;
22c653cd 462 struct {
463 time_t timeout;
464 int maxtries;
465 } retry;
7021844c 466 struct {
467 size_t limit;
468 } MemPools;
95e36d02 469#if DELAY_POOLS
59715b38 470 delayConfig Delay;
95e36d02 471#endif
6be2389e 472 struct {
473 int icp_average;
ef523f99 474 int dns_average;
6be2389e 475 int http_average;
476 int icp_min_poll;
ef523f99 477 int dns_min_poll;
6be2389e 478 int http_min_poll;
479 } comm_incoming;
c5f627c2 480 int max_open_disk_fds;
d548ee64 481 int uri_whitespace;
c68e9c6b 482 size_t rangeOffsetLimit;
e66d7923 483#if MULTICAST_MISS_STREAM
484 struct {
485 struct in_addr addr;
7e3ce7b9 486 int ttl;
e66d7923 487 unsigned short port;
488 char *encode_key;
489 } mcast_miss;
490#endif
5bcad01d 491 HttpHeaderMask anonymize_headers;
b6a2f15e 492 char *coredump_dir;
efd900cb 493 char *chroot_dir;
7e3ce7b9 494#if USE_CACHE_DIGESTS
495 struct {
496 int bits_per_entry;
efd900cb 497 time_t rebuild_period;
498 time_t rewrite_period;
499 size_t swapout_chunk_size;
7e3ce7b9 500 int rebuild_chunk_percentage;
501 } digest;
502#endif
708ef61c 503#if USE_DISKD
504 struct {
505 int magic1;
506 int magic2;
507 } diskd;
508#endif
a8258824 509};
510
511struct _SquidConfig2 {
512 struct {
513 char *prefix;
514 int on;
515 } Accel;
53cb32a9 516 struct {
517 int enable_purge;
518 } onoff;
a8258824 519};
520
521struct _close_handler {
522 PF *handler;
523 void *data;
524 close_handler *next;
525};
526
527struct _dread_ctrl {
528 int fd;
529 off_t offset;
530 int req_len;
531 char *buf;
532 int end_of_file;
533 DRCB *handler;
534 void *client_data;
535};
536
537struct _dnsserver_t {
538 int id;
a8258824 539 int inpipe;
540 int outpipe;
541 time_t answer;
78f1250a 542 off_t offset;
543 size_t size;
e144eae4 544 char ip_inbuf[DNS_INBUF_SZ];
a8258824 545 struct timeval dispatch_time;
546 void *data;
547};
548
549struct _dnsStatData {
550 int requests;
551 int replies;
552 int hist[DefaultDnsChildrenMax];
553};
554
555struct _dwrite_q {
d377699f 556 off_t file_offset;
a8258824 557 char *buf;
558 int len;
d377699f 559 off_t buf_offset;
bd05e3e3 560 dwrite_q *next;
74fbf3c9 561 FREE *free_func;
a8258824 562};
563
a9771e51 564
565/* ETag support is rudimantal;
566 * this struct is likely to change
567 * Note: "str" points to memory in HttpHeaderEntry (for now)
568 * so ETags should be used as tmp variables only (for now) */
569struct _ETag {
98829f69 570 const char *str; /* quoted-string */
571 int weak; /* true if it is a weak validator */
a9771e51 572};
573
a8258824 574struct _fde {
575 unsigned int type;
a8258824 576 u_short local_port;
577 u_short remote_port;
578 char ipaddr[16]; /* dotted decimal address of peer */
579 char desc[FD_DESC_SZ];
58a6c186 580 struct {
60c0b5a2 581 unsigned int open:1;
3d94aed0 582 unsigned int close_request:1;
583 unsigned int write_daemon:1;
584 unsigned int closing:1;
585 unsigned int socket_eof:1;
586 unsigned int nolinger:1;
587 unsigned int nonblocking:1;
588 unsigned int ipc:1;
b5568a61 589 unsigned int called_connect:1;
58a6c186 590 } flags;
a8258824 591 int bytes_read;
592 int bytes_written;
b716a8ad 593 int uses; /* ie # req's over persistent conn */
a8258824 594 struct _fde_disk {
595 DWCB *wrt_handle;
596 void *wrt_handle_data;
597 dwrite_q *write_q;
598 dwrite_q *write_q_tail;
711982d8 599 off_t offset;
a8258824 600 } disk;
601 PF *read_handler;
602 void *read_data;
603 PF *write_handler;
604 void *write_data;
605 PF *timeout_handler;
606 time_t timeout;
607 void *timeout_data;
cb69b4c7 608 void *lifetime_data;
a8258824 609 close_handler *close_handler; /* linked list */
da2b3a17 610 DEFER *defer_check; /* check if we should defer read */
70a9dab4 611 void *defer_data;
a8258824 612 CommWriteStateData *rwstate; /* State data for comm_write */
613};
614
615struct _fileMap {
616 int max_n_files;
617 int n_files_in_map;
a8258824 618 int toggle;
619 int nwords;
620 unsigned long *file_map;
621};
622
1d21d91d 623/* auto-growing memory-resident buffer with printf interface */
624/* note: when updating this struct, update MemBufNULL #define */
625struct _MemBuf {
626 /* public, read-only */
627 char *buf;
628 mb_size_t size; /* used space, does not count 0-terminator */
629
630 /* private, stay away; use interface function instead */
631 mb_size_t max_capacity; /* when grows: assert(new_capacity <= max_capacity) */
632 mb_size_t capacity; /* allocated space */
633 FREE *freefunc; /* what to use to free the buffer, NULL after memBufFreeFunc() is called */
634};
635
636/* see Packer.c for description */
637struct _Packer {
638 /* protected, use interface functions instead */
639 append_f append;
640 vprintf_f vprintf;
641 void *real_handler; /* first parameter to real append and vprintf */
642};
643
adba4a64 644/* http status line */
645struct _HttpStatusLine {
646 /* public, read only */
99edd1c3 647 float version;
2ac76861 648 const char *reason; /* points to a _constant_ string (default or supplied), never free()d */
adba4a64 649 http_status status;
650};
651
652/*
1d21d91d 653 * Note: HttpBody is used only for messages with a small content that is
adba4a64 654 * known a priory (e.g., error messages).
655 */
656struct _HttpBody {
1d21d91d 657 /* private */
658 MemBuf mb;
adba4a64 659};
660
2ecaa5e7 661/* http header extention field */
662struct _HttpHdrExtField {
a369131d 663 String name; /* field-name from HTTP/1.1 (no column after name) */
664 String value; /* field-value from HTTP/1.1 */
2ecaa5e7 665};
adba4a64 666
399e85ea 667/* http cache control header field */
7faf2bdb 668struct _HttpHdrCc {
4f087419 669 int mask;
d8b249ef 670 int max_age;
7e3ce7b9 671 int s_maxage;
a8258824 672};
ee1679df 673
b5107edb 674/* http byte-range-spec */
675struct _HttpHdrRangeSpec {
9bc73deb 676 ssize_t offset;
677 ssize_t length;
b5107edb 678};
679
680/* There may be more than one byte range specified in the request.
59c4d35b 681 * This object holds all range specs in order of their appearence
682 * in the request because we SHOULD preserve that order.
683 */
b5107edb 684struct _HttpHdrRange {
685 Stack specs;
686};
7faf2bdb 687
d76fcfa7 688/* http content-range header field */
689struct _HttpHdrContRange {
690 HttpHdrRangeSpec spec;
9bc73deb 691 ssize_t elength; /* entity length, not content length */
d76fcfa7 692};
693
a9771e51 694/* some fields can hold either time or etag specs (e.g. If-Range) */
695struct _TimeOrTag {
98829f69 696 ETag tag; /* entity tag */
a9771e51 697 time_t time;
98829f69 698 int valid; /* true if struct is usable */
a9771e51 699};
700
d192d11f 701/* data for iterating thru range specs */
98829f69 702struct _HttpHdrRangeIter {
d192d11f 703 HttpHdrRangePos pos;
98829f69 704 const HttpHdrRangeSpec *spec; /* current spec at pos */
9bc73deb 705 ssize_t debt_size; /* bytes left to send from the current spec */
706 ssize_t prefix_size; /* the size of the incoming HTTP msg prefix */
98829f69 707 String boundary; /* boundary for multipart responses */
d192d11f 708};
d76fcfa7 709
fcd2d3ef 710/* constant attributes of http header fields */
711struct _HttpHeaderFieldAttrs {
712 const char *name;
713 http_hdr_type id;
714 field_type type;
715};
716
7faf2bdb 717/* per field statistics */
718struct _HttpHeaderFieldStat {
399e85ea 719 int aliveCount; /* created but not destroyed (count) */
d8b249ef 720 int seenCount; /* #fields we've seen */
399e85ea 721 int parsCount; /* #parsing attempts */
722 int errCount; /* #pasring errors */
723 int repCount; /* #repetitons */
7faf2bdb 724};
725
d8b249ef 726/* compiled version of HttpHeaderFieldAttrs plus stats */
de336bbe 727struct _HttpHeaderFieldInfo {
728 http_hdr_type id;
729 String name;
730 field_type type;
7faf2bdb 731 HttpHeaderFieldStat stat;
732};
733
d8b249ef 734struct _HttpHeaderEntry {
735 http_hdr_type id;
736 String name;
737 String value;
738};
4f087419 739
d8b249ef 740struct _HttpHeader {
4f087419 741 /* protected, do not use these, use interface functions instead */
ec878047 742 Array entries; /* parsed fields in raw format */
743 HttpHeaderMask mask; /* bit set <=> entry present */
eeb423fb 744 http_hdr_owner_type owner; /* request or reply */
745 int len; /* length when packed, not counting terminating '\0' */
4f087419 746};
747
adba4a64 748struct _HttpReply {
749 /* unsupported, writable, may disappear/change in the future */
2ac76861 750 int hdr_sz; /* sums _stored_ status-line, headers, and <CRLF> */
adba4a64 751
d8b249ef 752 /* public, readable; never update these or their .hdr equivalents directly */
753 int content_length;
754 time_t date;
755 time_t last_modified;
756 time_t expires;
ec878047 757 String content_type;
d8b249ef 758 HttpHdrCc *cache_control;
759 HttpHdrContRange *content_range;
9f5a2895 760 short int keep_alive;
d8b249ef 761
adba4a64 762 /* public, readable */
2ac76861 763 HttpMsgParseState pstate; /* the current parsing state */
4f087419 764
de336bbe 765 /* public, writable, but use httpReply* interfaces when possible */
adba4a64 766 HttpStatusLine sline;
d8b249ef 767 HttpHeader header;
768 HttpBody body; /* for small constant memory-resident text bodies only */
adba4a64 769};
cb69b4c7 770
b515fc11 771struct _http_state_flags {
79618ba9 772 unsigned int proxying:1;
773 unsigned int keepalive:1;
db1cd23c 774 unsigned int only_if_cached:1;
b515fc11 775};
a8258824 776
777struct _HttpStateData {
778 StoreEntry *entry;
779 request_t *request;
780 char *reply_hdr;
304d289e 781 size_t reply_hdr_size;
a8258824 782 int reply_hdr_state;
1294c0fc 783 peer *peer; /* peer request made to */
a8258824 784 int eof; /* reached end-of-object? */
785 request_t *orig_request;
1294c0fc 786 int fd;
b515fc11 787 http_state_flags flags;
db1cd23c 788 FwdState *fwd;
a8258824 789};
790
791struct _icpUdpData {
792 struct sockaddr_in address;
793 void *msg;
794 size_t len;
795 icpUdpData *next;
796#ifndef LESS_TIMING
797 struct timeval start;
798#endif
799 log_type logcode;
17b6e784 800 struct timeval queue_time;
a8258824 801};
802
b4e7f82d 803struct _ping_data {
a8258824 804 struct timeval start;
805 struct timeval stop;
806 int n_sent;
807 int n_recv;
808 int n_replies_expected;
98829f69 809 int timeout; /* msec */
465dc415 810 int timedout;
a8258824 811 int w_rtt;
b3264694 812 int p_rtt;
a8258824 813};
814
815struct _HierarchyLogEntry {
816 hier_code code;
817 char host[SQUIDHOSTNAMELEN];
b4e7f82d 818 ping_data ping;
4b4cd312 819 char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
820 peer_select_alg_t alg; /* peer selection algorithm */
821 lookup_t cd_lookup; /* cd prediction: none, miss, hit */
822 int n_choices; /* #peers we selected from (cd only) */
823 int n_ichoices; /* #peers with known rtt we selected from (cd only) */
39edba21 824 struct timeval peer_select_start;
825 struct timeval store_complete_stop;
a8258824 826};
827
828struct _AccessLogEntry {
829 const char *url;
830 struct {
831 method_t method;
832 int code;
833 const char *content_type;
c68e9c6b 834 float version;
a8258824 835 } http;
836 struct {
837 icp_opcode opcode;
838 } icp;
839 struct {
840 struct in_addr caddr;
841 size_t size;
842 log_type code;
843 int msec;
844 const char *ident;
845 } cache;
a8258824 846 struct {
847 char *request;
848 char *reply;
849 } headers;
850 struct {
851 const char *method_str;
852 } private;
bd05e3e3 853 HierarchyLogEntry hier;
a8258824 854};
855
856struct _clientHttpRequest {
857 ConnStateData *conn;
858 request_t *request; /* Parsed URL ... */
23d92c64 859 char *uri;
860 char *log_uri;
a8258824 861 struct {
78f1250a 862 off_t offset;
863 size_t size;
a8258824 864 } out;
98829f69 865 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
866 size_t req_sz; /* raw request size on input, not current request size */
a8258824 867 StoreEntry *entry;
868 StoreEntry *old_entry;
869 log_type log_type;
6cfa8966 870#if USE_CACHE_DIGESTS
04f0c415 871 const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */
872#endif
9b312a19 873 http_status http_code;
a8258824 874 struct timeval start;
875 float http_ver;
876 int redirect_state;
877 aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */
878 clientHttpRequest *next;
bd05e3e3 879 AccessLogEntry al;
77ed547a 880 struct {
3d94aed0 881 unsigned int accel:1;
882 unsigned int internal:1;
883 unsigned int done_copying:1;
77ed547a 884 } flags;
6d38ef86 885 struct {
886 http_status status;
887 char *location;
888 } redirect;
0f1bc304 889 dlink_node active;
a8258824 890};
891
892struct _ConnStateData {
893 int fd;
894 struct {
895 char *buf;
78f1250a 896 off_t offset;
897 size_t size;
a8258824 898 } in;
899 clientHttpRequest *chr;
900 struct sockaddr_in peer;
901 struct sockaddr_in me;
902 struct in_addr log_addr;
05832ae1 903 char ident[USER_IDENT_SZ];
a8258824 904 int nrequests;
905 int persistent;
da2b3a17 906 struct {
907 int n;
908 time_t until;
909 } defer;
a8258824 910};
911
912struct _ipcache_addrs {
6d1c0d53 913 struct in_addr *in_addrs;
914 unsigned char *bad_mask;
a8258824 915 unsigned char count;
916 unsigned char cur;
22c653cd 917 unsigned char badcount;
a8258824 918};
919
59c4d35b 920struct _ip_pending {
921 IPH *handler;
922 void *handlerData;
923 ip_pending *next;
924};
925
a8258824 926struct _ipcache_entry {
ec878047 927 /* first two items must be equivalent to hash_link */
a8258824 928 char *name;
bd05e3e3 929 ipcache_entry *next;
a8258824 930 time_t lastref;
931 time_t expires;
932 ipcache_addrs addrs;
59c4d35b 933 ip_pending *pending_head;
a8258824 934 char *error_message;
b87b92fb 935 struct timeval request_time;
2ac237e2 936 dlink_node lru;
937 u_char locks;
a8258824 938 ipcache_status_t status:3;
939};
940
59c4d35b 941struct _fqdn_pending {
942 FQDNH *handler;
943 void *handlerData;
944 fqdn_pending *next;
945};
946
1df370e3 947struct _fqdncache_entry {
ec878047 948 /* first two items must be equivalent to hash_link */
1df370e3 949 char *name;
bd05e3e3 950 fqdncache_entry *next;
1df370e3 951 time_t lastref;
952 time_t expires;
953 unsigned char name_count;
954 char *names[FQDN_MAX_NAMES + 1];
59c4d35b 955 fqdn_pending *pending_head;
1df370e3 956 char *error_message;
74addf6c 957 struct timeval request_time;
1df370e3 958 dlink_node lru;
959 unsigned char locks;
960 fqdncache_status_t status:3;
961};
962
a8258824 963struct _domain_ping {
964 char *domain;
965 int do_ping; /* boolean */
bd05e3e3 966 domain_ping *next;
a8258824 967};
968
969struct _domain_type {
970 char *domain;
971 peer_t type;
bd05e3e3 972 domain_type *next;
a8258824 973};
974
c68e9c6b 975#if USE_CACHE_DIGESTS
e41e6dcd 976struct _Version {
4b4cd312 977 short int current; /* current version */
978 short int required; /* minimal version that can safely handle current version */
e41e6dcd 979};
980
981/* digest control block; used for transmission and storage */
982struct _StoreDigestCBlock {
983 Version ver;
984 int capacity;
985 int count;
986 int del_count;
987 int mask_size;
04f0c415 988 unsigned char bits_per_entry;
989 unsigned char hash_func_count;
990 short int reserved_short;
4b4cd312 991 int reserved[32 - 6];
e41e6dcd 992};
993
994struct _DigestFetchState {
e13ee7ad 995 PeerDigest *pd;
e41e6dcd 996 StoreEntry *entry;
997 StoreEntry *old_entry;
e13ee7ad 998 request_t *request;
e41e6dcd 999 int offset;
1000 int mask_offset;
1001 time_t start_time;
e13ee7ad 1002 time_t resp_time;
1003 time_t expires;
1004 struct {
1005 int msg;
1006 int bytes;
1007 } sent, recv;
e41e6dcd 1008};
1009
1010/* statistics for cache digests and other hit "predictors" */
1011struct _cd_guess_stats {
1012 /* public, read-only */
1013 int true_hits;
1014 int false_hits;
1015 int true_misses;
1016 int false_misses;
4b4cd312 1017 int close_hits; /* tmp, remove it later */
e41e6dcd 1018};
1019
1020struct _PeerDigest {
4d62b0af 1021 peer *peer; /* pointer back to peer structure, argh */
1022 CacheDigest *cd; /* actual digest structure */
1023 String host; /* copy of peer->host */
e13ee7ad 1024 const char *req_result; /* text status of the last request */
b515fc11 1025 struct {
4d62b0af 1026 unsigned int needed:1; /* there were requests for this digest */
e13ee7ad 1027 unsigned int usable:1; /* can be used for lookups */
79618ba9 1028 unsigned int requested:1; /* in process of receiving [fresh] digest */
b515fc11 1029 } flags;
e13ee7ad 1030 struct {
1031 /* all times are absolute unless augmented with _delay */
1032 time_t initialized; /* creation */
1033 time_t needed; /* first lookup/use by a peer */
1034 time_t next_check; /* next scheduled check/refresh event */
1035 time_t retry_delay; /* delay before re-checking _invalid_ digest */
1036 time_t requested; /* requested a fresh copy of a digest */
4d62b0af 1037 time_t req_delay; /* last request response time */
e13ee7ad 1038 time_t received; /* received the current copy of a digest */
1039 time_t disabled; /* disabled for good */
1040 } times;
e41e6dcd 1041 struct {
1042 cd_guess_stats guess;
1043 int used_count;
e13ee7ad 1044 struct {
1045 int msgs;
1046 kb_t kbytes;
1047 } sent, recv;
e41e6dcd 1048 } stats;
1049};
1050
c68e9c6b 1051#endif
1052
a8258824 1053struct _peer {
1054 char *host;
1055 peer_t type;
1056 struct sockaddr_in in_addr;
1057 struct {
1058 int pings_sent;
1059 int pings_acked;
a8258824 1060 int fetches;
1061 int rtt;
a8258824 1062 int ignored_replies;
1294c0fc 1063 int n_keepalives_sent;
1064 int n_keepalives_recv;
83b381d5 1065 time_t probe_start;
dc835977 1066 time_t last_query;
1067 time_t last_reply;
eb406bb7 1068 time_t last_connect_failure;
1069 time_t last_connect_probe;
dc835977 1070 int logged_state; /* so we can print dead/revived msgs */
a8258824 1071 } stats;
399cabec 1072 struct {
886f2785 1073 int version;
399cabec 1074 int counts[ICP_END];
886f2785 1075 u_short port;
399cabec 1076 } icp;
1077#if USE_HTCP
1078 struct {
1079 double version;
1080 int counts[2];
886f2785 1081 u_short port;
399cabec 1082 } htcp;
1083#endif
a8258824 1084 u_short http_port;
b6a2f15e 1085 domain_ping *peer_domain;
bd05e3e3 1086 domain_type *typelist;
505e35db 1087 acl_access *access;
cd196bc8 1088 struct {
79618ba9 1089 unsigned int proxy_only:1;
1090 unsigned int no_query:1;
1091 unsigned int no_digest:1;
1092 unsigned int default_parent:1;
1093 unsigned int roundrobin:1;
1094 unsigned int mcast_responder:1;
1095 unsigned int closest_only:1;
cd196bc8 1096#if USE_HTCP
79618ba9 1097 unsigned int htcp:1;
cd196bc8 1098#endif
79618ba9 1099 unsigned int no_netdb_exchange:1;
cd196bc8 1100#if DELAY_POOLS
79618ba9 1101 unsigned int no_delay:1;
cd196bc8 1102#endif
987de783 1103 unsigned int allow_miss:1;
cd196bc8 1104 } options;
a8258824 1105 int weight;
1106 struct {
1107 double avg_n_members;
1108 int n_times_counted;
1109 int n_replies_expected;
1110 int ttl;
007b8be4 1111 int id;
b515fc11 1112 struct {
79618ba9 1113 unsigned int count_event_pending:1;
1114 unsigned int counting:1;
ff283ec1 1115 } flags;
a8258824 1116 } mcast;
c68e9c6b 1117#if USE_CACHE_DIGESTS
e13ee7ad 1118 PeerDigest *digest;
7e3ce7b9 1119 char *digest_url;
c68e9c6b 1120#endif
a8258824 1121 int tcp_up; /* 0 if a connect() fails */
a8258824 1122 struct in_addr addresses[10];
1123 int n_addresses;
1124 int rr_count;
82056f1e 1125 int rr_lastcount;
bd05e3e3 1126 peer *next;
a8258824 1127 int test_fd;
afd88fbe 1128#if USE_CARP
1129 struct {
1130 unsigned long hash;
1131 unsigned long load_multiplier;
1132 float load_factor;
1133 } carp;
1134#endif
c68e9c6b 1135 char *login; /* Proxy authorization */
3f62decd 1136 time_t connect_timeout;
a8258824 1137};
1138
1139struct _net_db_name {
1140 char *name;
74fbf3c9 1141 net_db_name *htbl_next;
1142 net_db_name *next;
1143 netdbEntry *net_db_entry;
a8258824 1144};
1145
1146struct _net_db_peer {
6b53c392 1147 const char *peername;
a8258824 1148 double hops;
1149 double rtt;
1150 time_t expires;
1151};
1152
1153struct _netdbEntry {
ec878047 1154 /* first two items must be equivalent to hash_link */
a8258824 1155 char *key;
74fbf3c9 1156 netdbEntry *next;
a8258824 1157 char network[16];
1158 int pings_sent;
1159 int pings_recv;
1160 double hops;
1161 double rtt;
1162 time_t next_ping_time;
1163 time_t last_use_time;
1164 int link_count;
1165 net_db_name *hosts;
1166 net_db_peer *peers;
1167 int n_peers_alloc;
1168 int n_peers;
1169};
1170
1171struct _ps_state {
1172 request_t *request;
1173 StoreEntry *entry;
1174 int always_direct;
1175 int never_direct;
db1cd23c 1176 int direct;
a8258824 1177 PSC *callback;
a8258824 1178 void *callback_data;
db1cd23c 1179 FwdServer *servers;
85223cd7 1180 /*
1181 * Why are these struct sockaddr_in instead of peer *? Because a
1182 * peer structure can become invalid during the peer selection
1183 * phase, specifically after a reconfigure. Thus we need to lookup
1184 * the peer * based on the address when we are finally ready to
1185 * reference the peer structure.
1186 */
1187 struct sockaddr_in first_parent_miss;
1188 struct sockaddr_in closest_parent_miss;
db1cd23c 1189 /*
1190 * ->hit and ->secho can be peer* because they should only be
1191 * accessed during the thread when they are set
1192 */
1193 peer *hit;
1194 peer_t hit_type;
1195#if ALLOW_SOURCE_PING
1196 peer *secho;
1197#endif
b4e7f82d 1198 ping_data ping;
a8258824 1199 aclCheck_t *acl_checklist;
1200};
1201
6b53c392 1202#if USE_ICMP
a8258824 1203struct _pingerEchoData {
1204 struct in_addr to;
1205 unsigned char opcode;
1206 int psize;
65ae9f56 1207 char payload[PINGER_PAYLOAD_SZ];
a8258824 1208};
1209
1210struct _pingerReplyData {
1211 struct in_addr from;
1212 unsigned char opcode;
1213 int rtt;
1214 int hops;
1215 int psize;
65ae9f56 1216 char payload[PINGER_PAYLOAD_SZ];
a8258824 1217};
6b53c392 1218#endif
a8258824 1219
1220struct _icp_common_t {
1221 unsigned char opcode; /* opcode */
1222 unsigned char version; /* version number */
1223 unsigned short length; /* total length (bytes) */
1224 u_num32 reqnum; /* req number (req'd for UDP) */
1225 u_num32 flags;
1226 u_num32 pad;
a8258824 1227 u_num32 shostid; /* sender host id */
1228};
1229
a8258824 1230struct _iostats {
1231 struct {
1232 int reads;
1233 int reads_deferred;
1234 int read_hist[16];
1235 int writes;
1236 int write_hist[16];
1237 } Http, Ftp, Gopher, Wais;
1238};
1239
1240struct _mem_node {
1241 char *data;
1242 int len;
1243 mem_node *next;
1244};
1245
1246struct _mem_hdr {
1247 mem_node *head;
1248 mem_node *tail;
1249 int origin_offset;
1250};
1251
a8258824 1252/* keep track each client receiving data from that particular StoreEntry */
1253struct _store_client {
43329771 1254 int type;
a8258824 1255 off_t copy_offset;
1256 off_t seen_offset;
1257 size_t copy_size;
1258 char *copy_buf;
1259 STCB *callback;
1260 void *callback_data;
07304bf9 1261 StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
2391a162 1262 storeIOState *swapin_sio;
f115fadd 1263 struct {
3d94aed0 1264 unsigned int disk_io_pending:1;
1265 unsigned int store_copying:1;
1266 unsigned int copy_event_pending:1;
f115fadd 1267 } flags;
bd05e3e3 1268 store_client *next;
447e176b 1269#if DELAY_POOLS
1270 delay_id delay_id;
1271#endif
a8258824 1272};
1273
1a3db59c 1274
a8258824 1275/* This structure can be freed while object is purged out from memory */
1276struct _MemObject {
2ac237e2 1277 method_t method;
9fb13bb6 1278 char *url;
18fe65d0 1279 mem_hdr data_hdr;
8350fe9b 1280 off_t inmem_hi;
1281 off_t inmem_lo;
bd05e3e3 1282 store_client *clients;
a8258824 1283 int nclients;
8350fe9b 1284 struct {
e3ef2b09 1285 off_t queue_offset; /* relative to in-mem data */
2391a162 1286 storeIOState *sio;
8350fe9b 1287 } swapout;
cb69b4c7 1288 HttpReply *reply;
a8258824 1289 request_t *request;
1290 struct timeval start_ping;
b4e7f82d 1291 IRCB *ping_reply_callback;
a8258824 1292 void *ircb_data;
1293 int fd; /* FD of client creating this entry */
1294 struct {
1295 STABH *callback;
1296 void *data;
1297 } abort;
88738790 1298 char *log_url;
2b906e48 1299#if HEAP_REPLACEMENT
1300 /*
1301 * A MemObject knows where it is in the in-memory heap.
1302 */
1303 heap_node *node;
1304#else
b93bcace 1305 dlink_node lru;
2b906e48 1306#endif
007b8be4 1307 int id;
07304bf9 1308 ssize_t object_sz;
e3ef2b09 1309 size_t swap_hdr_sz;
bc87dc25 1310#if URL_CHECKSUM_DEBUG
1311 unsigned int chksum;
1312#endif
a8258824 1313};
1314
a8258824 1315struct _StoreEntry {
ec878047 1316 /* first two items must be same as hash_link */
9fb13bb6 1317 const cache_key *key;
bd05e3e3 1318 StoreEntry *next;
a8258824 1319 MemObject *mem_obj;
a8258824 1320 time_t timestamp;
1321 time_t lastref;
1322 time_t expires;
1323 time_t lastmod;
07304bf9 1324 size_t swap_file_sz;
a21fbb54 1325 u_short refcount;
d46a87a8 1326 u_short flags;
2391a162 1327 sfileno swap_file_number;
2b906e48 1328#if HEAP_REPLACEMENT
1329 heap_node *node;
2b906e48 1330#else
b93bcace 1331 dlink_node lru;
2b906e48 1332#endif
a3cb7458 1333 u_short lock_count; /* Assume < 65536! */
a8258824 1334 mem_status_t mem_status:3;
1335 ping_status_t ping_status:3;
1336 store_status_t store_status:3;
1337 swap_status_t swap_status:3;
a8258824 1338};
1339
1340struct _SwapDir {
0e4e0e7d 1341 swapdir_t type;
1342 fileMap *map;
a8258824 1343 int cur_size;
c6844e77 1344 int low_size;
a8258824 1345 int max_size;
0e4e0e7d 1346 char *path;
b2c141d4 1347 int index; /* This entry's index into the swapDirs array */
fc8b9fc0 1348 sfileno suggest;
1349 int removals;
1350 int scanned;
72615e4a 1351 struct {
1352 unsigned int selected:1;
b6a2f15e 1353 unsigned int read_only:1;
72615e4a 1354 } flags;
b2c141d4 1355 STINIT *init;
1356 STNEWFS *newfs;
1357 struct {
1358 STOBJOPEN *open;
1359 STOBJCLOSE *close;
1360 STOBJREAD *read;
1361 STOBJWRITE *write;
1362 STOBJUNLINK *unlink;
b2c141d4 1363 } obj;
1364 struct {
1365 STLOGOPEN *open;
1366 STLOGCLOSE *close;
200ba06e 1367 STLOGWRITE *write;
b2c141d4 1368 struct {
1369 STLOGCLEANOPEN *open;
1370 STLOGCLEANWRITE *write;
1371 void *state;
1372 } clean;
1373 } log;
fc8b9fc0 1374#if !HEAP_REPLACEMENT
1375 dlink_list lru_list;
1376 dlink_node *lru_walker;
1377#endif
0e4e0e7d 1378 union {
1379 struct {
1380 int l1;
1381 int l2;
1382 int swaplog_fd;
1383 } ufs;
8798ad05 1384#if USE_DISKD
1385 struct {
1386 int l1;
1387 int l2;
1388 int swaplog_fd;
1389 int smsgid;
1390 int rmsgid;
1391 int wfd;
8798ad05 1392 int away;
c8366e06 1393 struct {
1394 char *buf;
1395 link_list *stack;
1396 int id;
1397 } shm;
8798ad05 1398 } diskd;
1399#endif
0e4e0e7d 1400 } u;
a8258824 1401};
1402
92695e5e 1403struct _request_flags {
3d94aed0 1404 unsigned int range:1;
1405 unsigned int nocache:1;
1406 unsigned int ims:1;
1407 unsigned int auth:1;
1408 unsigned int cachable:1;
1409 unsigned int hierarchical:1;
1410 unsigned int loopdetect:1;
1411 unsigned int proxy_keepalive:1;
1412 unsigned int proxying:1;
1413 unsigned int refresh:1;
1414 unsigned int used_proxy_auth:1;
1415 unsigned int redirected:1;
9689d97c 1416 unsigned int need_validation:1;
9f60cfdf 1417#if HTTP_VIOLATIONS
886f2785 1418 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
9f60cfdf 1419#endif
c68e9c6b 1420 unsigned int accelerated:1;
1421 unsigned int internal:1;
92695e5e 1422};
1423
d03d26fb 1424struct _link_list {
1425 void *ptr;
1426 struct _link_list *next;
1427};
1428
2391a162 1429struct _storeIOState {
2391a162 1430 sfileno swap_file_number;
1431 mode_t mode;
1432 size_t st_size; /* do stat(2) after read open */
1433 off_t offset; /* current offset pointer */
1434 STIOCB *callback;
1435 void *callback_data;
1436 struct {
1437 STRCB *callback;
1438 void *callback_data;
1439 } read;
1440 struct {
1441 unsigned int closing:1; /* debugging aid */
1442 } flags;
1443 union {
1444 struct {
819244bf 1445 int fd;
2391a162 1446 struct {
1447 unsigned int close_request:1;
1448 unsigned int reading:1;
1449 unsigned int writing:1;
1450 } flags;
1451 } ufs;
53fa92a5 1452 struct {
1453 int fd;
53fa92a5 1454 struct {
1455 unsigned int close_request:1;
1456 unsigned int reading:1;
1457 unsigned int writing:1;
d03d26fb 1458 unsigned int opening:1;
53fa92a5 1459 } flags;
6f992224 1460 const char *read_buf;
1461 link_list *pending_writes;
1f38f50a 1462 link_list *pending_reads;
53fa92a5 1463 } aufs;
8798ad05 1464#if USE_DISKD
1465 struct {
1466 int id;
1467 struct {
1468 unsigned int reading:1;
1469 unsigned int writing:1;
1470 } flags;
1471 char *read_buf;
1472 } diskd;
1473#endif
2391a162 1474 } type;
1475};
1476
a8258824 1477struct _request_t {
1478 method_t method;
1479 protocol_t protocol;
1480 char login[MAX_LOGIN_SZ];
1481 char host[SQUIDHOSTNAMELEN + 1];
def67559 1482 char user_ident[USER_IDENT_SZ]; /* from proxy auth or ident server */
a8258824 1483 u_short port;
02922e76 1484 String urlpath;
e4a45101 1485 char *canonical;
a8258824 1486 int link_count; /* free when zero */
92695e5e 1487 request_flags flags;
8e092300 1488 HttpHdrCc *cache_control;
d192d11f 1489 HttpHdrRange *range;
a8258824 1490 float http_ver;
1491 time_t ims;
1492 int imslen;
1493 int max_forwards;
7e3ce7b9 1494 /* these in_addr's could probably be sockaddr_in's */
a8258824 1495 struct in_addr client_addr;
3c11d1f5 1496 struct in_addr my_addr;
7e3ce7b9 1497 unsigned short my_port;
99edd1c3 1498 HttpHeader header;
a8258824 1499 char *body;
1500 size_t body_sz;
1f38f50a 1501 int content_length;
bd05e3e3 1502 HierarchyLogEntry hier;
88aad2e5 1503 err_type err_type;
c68e9c6b 1504 char *peer_login; /* Configured peer login:password */
9bc73deb 1505 time_t lastmod; /* Used on refreshes */
a8258824 1506};
1507
1508struct _cachemgr_passwd {
1509 char *passwd;
22f3fd98 1510 wordlist *actions;
bd05e3e3 1511 cachemgr_passwd *next;
a8258824 1512};
1513
1514struct _refresh_t {
1515 char *pattern;
1516 regex_t compiled_pattern;
1517 time_t min;
c3f6d204 1518 double pct;
a8258824 1519 time_t max;
bd05e3e3 1520 refresh_t *next;
c3f6d204 1521 struct {
1dfa1d81 1522 unsigned int icase:1;
9f60cfdf 1523#if HTTP_VIOLATIONS
1dfa1d81 1524 unsigned int override_expire:1;
1525 unsigned int override_lastmod:1;
cbe3a719 1526 unsigned int reload_into_ims:1;
1527 unsigned int ignore_reload:1;
9f60cfdf 1528#endif
c3f6d204 1529 } flags;
a8258824 1530};
1531
1532struct _CommWriteStateData {
1533 char *buf;
1534 size_t size;
1535 off_t offset;
1536 CWCB *handler;
1537 void *handler_data;
74fbf3c9 1538 FREE *free_func;
a8258824 1539};
9b312a19 1540
1541struct _ErrorState {
1542 err_type type;
02922e76 1543 int page_id;
9b312a19 1544 http_status http_status;
1545 request_t *request;
1546 char *url;
c45ed9ad 1547 int xerrno;
9b312a19 1548 char *host;
1549 u_short port;
1550 char *dnsserver_msg;
1551 time_t ttl;
1552 struct in_addr src_addr;
1553 char *redirect_url;
1554 ERCB *callback;
1555 void *callback_data;
b515fc11 1556 struct {
79618ba9 1557 unsigned int flag_cbdata:1;
b515fc11 1558 } flags;
b9916917 1559 struct {
9bc73deb 1560 wordlist *server_msg;
b9916917 1561 char *request;
1562 char *reply;
1563 } ftp;
e144eae4 1564 char *request_hdrs;
9b312a19 1565};
f2908497 1566
12cf1be2 1567/*
1568 * "very generic" histogram;
1569 * see important comments on hbase_f restrictions in StatHist.c
1570 */
1571struct _StatHist {
1572 int *bins;
1573 int capacity;
e9a13293 1574 double min;
1575 double max;
1576 double scale;
95c297ec 1577 hbase_f *val_in; /* e.g., log() for log-based histogram */
1578 hbase_f *val_out; /* e.g., exp() for log based histogram */
7ae52c25 1579};
1580
12cf1be2 1581/*
1582 * if you add a field to StatCounters,
1d803566 1583 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
12cf1be2 1584 */
f2908497 1585struct _StatCounters {
1586 struct {
98829f69 1587 int clients;
f2908497 1588 int requests;
1589 int hits;
4f4d1d6e 1590 int mem_hits;
1591 int disk_hits;
f2908497 1592 int errors;
a7c05555 1593 kb_t kbytes_in;
1594 kb_t kbytes_out;
1595 kb_t hit_kbytes_out;
12cf1be2 1596 StatHist miss_svc_time;
1597 StatHist nm_svc_time;
7c9c84ad 1598 StatHist nh_svc_time;
12cf1be2 1599 StatHist hit_svc_time;
1600 StatHist all_svc_time;
f2908497 1601 } client_http;
7ae52c25 1602 struct {
a0f32775 1603 struct {
1604 int requests;
1605 int errors;
1606 kb_t kbytes_in;
1607 kb_t kbytes_out;
399e85ea 1608 } all , http, ftp, other;
7ae52c25 1609 } server;
f2908497 1610 struct {
1611 int pkts_sent;
071a3ae7 1612 int queries_sent;
1613 int replies_sent;
f2908497 1614 int pkts_recv;
071a3ae7 1615 int queries_recv;
1616 int replies_recv;
a7c05555 1617 int hits_sent;
1618 int hits_recv;
8064065e 1619 int replies_queued;
17b6e784 1620 int replies_dropped;
a7c05555 1621 kb_t kbytes_sent;
071a3ae7 1622 kb_t q_kbytes_sent;
1623 kb_t r_kbytes_sent;
a7c05555 1624 kb_t kbytes_recv;
071a3ae7 1625 kb_t q_kbytes_recv;
1626 kb_t r_kbytes_recv;
12cf1be2 1627 StatHist query_svc_time;
1628 StatHist reply_svc_time;
4b4cd312 1629 int query_timeouts;
c127134a 1630 int times_used;
f2908497 1631 } icp;
1632 struct {
1633 int requests;
1634 } unlink;
9973e9fe 1635 struct {
12cf1be2 1636 StatHist svc_time;
9973e9fe 1637 } dns;
c127134a 1638 struct {
1639 int times_used;
26b164ac 1640 kb_t kbytes_sent;
1641 kb_t kbytes_recv;
c127134a 1642 kb_t memory;
00485c29 1643 int msgs_sent;
1644 int msgs_recv;
c68e9c6b 1645#if USE_CACHE_DIGESTS
4b4cd312 1646 cd_guess_stats guess;
c68e9c6b 1647#endif
69c95dd3 1648 StatHist on_xition_count;
c127134a 1649 } cd;
69c95dd3 1650 struct {
1651 int times_used;
1652 } netdb;
f2908497 1653 int page_faults;
1654 int select_loops;
d239c2f5 1655 int select_fds;
1656 double select_time;
f2908497 1657 double cputime;
d5649d9f 1658 struct timeval timestamp;
c6ecdbc3 1659 StatHist comm_icp_incoming;
ef523f99 1660 StatHist comm_dns_incoming;
c6ecdbc3 1661 StatHist comm_http_incoming;
26d6ee93 1662 StatHist select_fds_hist;
886f2785 1663 struct {
1664 struct {
1665 int opens;
1666 int closes;
1667 int reads;
1668 int writes;
1669 int seeks;
64b54eed 1670 int unlinks;
886f2785 1671 } disk;
1672 struct {
1673 int accepts;
1674 int sockets;
1675 int connects;
1676 int binds;
1677 int closes;
1678 int reads;
1679 int writes;
1680 int recvfroms;
1681 int sendtos;
1682 } sock;
1683#if HAVE_POLL
1684 int polls;
1685#else
1686 int selects;
1687#endif
1688 } syscalls;
2c4f7ab2 1689 int swap_files_cleaned;
bfae3379 1690 int aborted_requests;
f2908497 1691};
69c01cd7 1692
fcd2d3ef 1693/* per header statistics */
1694struct _HttpHeaderStat {
1695 const char *label;
1696 HttpHeaderMask *owner_mask;
1697
1698 StatHist hdrUCountDistr;
1699 StatHist fieldTypeDistr;
1700 StatHist ccTypeDistr;
1701
1702 int parsedCount;
1703 int ccParsedCount;
1704 int destroyedCount;
1705 int busyDestroyedCount;
1706};
1707
1708
69c01cd7 1709struct _tlv {
5830cdb3 1710 char type;
1711 int length;
1712 void *value;
bd05e3e3 1713 tlv *next;
5830cdb3 1714};
1715
07304bf9 1716struct _storeSwapLogData {
5830cdb3 1717 char op;
2391a162 1718 sfileno swap_file_number;
5830cdb3 1719 time_t timestamp;
1720 time_t lastref;
1721 time_t expires;
1722 time_t lastmod;
07304bf9 1723 size_t swap_file_sz;
5830cdb3 1724 u_short refcount;
d46a87a8 1725 u_short flags;
7363fc17 1726 unsigned char key[MD5_DIGEST_CHARS];
69c01cd7 1727};
59c4d35b 1728
02922e76 1729/* object to track per-action memory usage (e.g. #idle objects) */
1730struct _MemMeter {
9bc73deb 1731 ssize_t level; /* current level (count or volume) */
1732 ssize_t hwater_level; /* high water mark */
d8b249ef 1733 time_t hwater_stamp; /* timestamp of last high water mark change */
02922e76 1734};
1735
1736/* object to track per-pool memory usage (alloc = inuse+idle) */
1737struct _MemPoolMeter {
1738 MemMeter alloc;
1739 MemMeter inuse;
1740 MemMeter idle;
1741 gb_t saved;
7f8bbdcd 1742 gb_t total;
02922e76 1743};
1744
1745/* a pool is a [growing] space for objects of the same size */
1746struct _MemPool {
1747 const char *label;
1748 size_t obj_size;
1749 Stack pstack; /* stack for free pointers */
1750 MemPoolMeter meter;
1751};
1752
59c4d35b 1753struct _ClientInfo {
ec878047 1754 /* first two items must be equivalent to hash_link */
59c4d35b 1755 char *key;
ca3c5a71 1756 ClientInfo *next;
59c4d35b 1757 struct in_addr addr;
1758 struct {
1759 int result_hist[LOG_TYPE_MAX];
1760 int n_requests;
ec878047 1761 kb_t kbytes_in;
1762 kb_t kbytes_out;
1763 kb_t hit_kbytes_out;
59c4d35b 1764 } Http, Icp;
1765 struct {
1766 time_t time;
1767 int n_req;
1768 int n_denied;
1769 } cutoff;
9bc73deb 1770 int n_established; /* number of current established connections */
59c4d35b 1771};
c411be12 1772
c411be12 1773struct _CacheDigest {
1774 /* public, read-only */
1afe05c5 1775 char *mask; /* bit mask */
1776 size_t mask_size; /* mask size in bytes */
1777 int capacity; /* expected maximum for .count, not a hard limit */
04f0c415 1778 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1afe05c5 1779 int count; /* number of digested entries */
1780 int del_count; /* number of deletions performed so far */
c411be12 1781};
910169e5 1782
db1cd23c 1783struct _FwdServer {
1784 peer *peer; /* NULL --> origin server */
1785 hier_code code;
1786 FwdServer *next;
1787};
1788
910169e5 1789struct _FwdState {
1790 int client_fd;
1791 StoreEntry *entry;
1792 request_t *request;
1793 FwdServer *servers;
6801f8a8 1794 int server_fd;
ec250dfd 1795 ErrorState *err;
f563eea9 1796 time_t start;
68bd6892 1797 int n_tries;
ee08bdf5 1798 struct {
1799 unsigned int dont_retry:1;
9bc73deb 1800 unsigned int ftp_pasv_failed:1;
ee08bdf5 1801 } flags;
910169e5 1802};
1803
86aebcda 1804#if USE_HTCP
1805struct _htcpReplyData {
886f2785 1806 int hit;
1807 HttpHeader hdr;
1808 u_num32 msg_id;
1809 double version;
1810 struct {
b4e7f82d 1811 /* cache-to-origin */
886f2785 1812 double rtt;
1813 int samp;
1814 int hops;
1815 } cto;
86aebcda 1816};
886f2785 1817
86aebcda 1818#endif
74addf6c 1819
1820
1821struct _helper_request {
1822 char *buf;
1823 HLPCB *callback;
1824 void *data;
1825};
1826
1827struct _helper {
1828 wordlist *cmdline;
1829 dlink_list servers;
1830 dlink_list queue;
1f5f60dd 1831 const char *id_name;
74addf6c 1832 int n_to_start;
1833 int n_running;
1834 int ipc_type;
1835 time_t last_queue_warn;
1836 struct {
1837 int requests;
1838 int replies;
1839 int queue_size;
1840 int avg_svc_time;
1841 } stats;
1842};
1843
1844struct _helper_server {
1845 int index;
1846 int rfd;
1847 int wfd;
1848 char *buf;
1849 size_t buf_sz;
1850 off_t offset;
1851 struct timeval dispatch_time;
1852 struct timeval answer_time;
1853 dlink_node link;
1854 helper *parent;
1855 helper_request *request;
838b993c 1856 struct _helper_flags {
1857 unsigned int alive:1;
1858 unsigned int busy:1;
1859 unsigned int closing:1;
1860 unsigned int shutdown:1;
1861 } flags;
74addf6c 1862 struct {
1863 int uses;
1864 } stats;
1865};
1866
1867/*
1868 * use this when you need to pass callback data to a blocking
1869 * operation, but you don't want to add that pointer to cbdata
1870 */
1871struct _generic_cbdata {
1872 void *data;
1873};
b2c141d4 1874
1875struct _store_rebuild_data {
1876 int objcount; /* # objects successfully reloaded */
1877 int expcount; /* # objects expired */
1878 int scancount; /* # entries scanned or read from state file */
1879 int clashcount; /* # swapfile clashes avoided */
1880 int dupcount; /* # duplicates purged */
1881 int cancelcount; /* # SWAP_LOG_DEL objects purged */
1882 int invalid; /* # bad lines */
1883 int badflags; /* # bad e->flags */
1884 int bad_log_op;
1885 int zero_object_sz;
1886};
5673c2e2 1887
1888struct _Logfile {
1889 int fd;
1890 char path[MAXPATHLEN];
1891 char *buf;
1892 size_t bufsz;
1893 off_t offset;
1894};