]> git.ipfire.org Git - thirdparty/squid.git/blame - src/structs.h
hno squid-2.3.DEVEL3.ftp_all_messages.patch
[thirdparty/squid.git] / src / structs.h
CommitLineData
a8258824 1
9cef6668 2/*
4fe0e1d0 3 * $Id: structs.h,v 1.324 2000/05/02 20:39:28 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
43d4303e 52struct _acl_snmp_comm {
53 char *name;
54 void *community;
55 acl_snmp_comm *next;
56};
57
a8258824 58struct _acl_time_data {
59 int weekbits;
60 int start;
61 int stop;
74fbf3c9 62 acl_time_data *next;
a8258824 63};
64
65struct _acl_name_list {
66 char name[ACL_NAME_SZ];
74fbf3c9 67 acl_name_list *next;
a8258824 68};
69
ec878047 70struct _acl_proxy_auth_user {
71 /* first two items must be same as hash_link */
72 char *user;
73 acl_proxy_auth_user *next;
73e67ee0 74 /* extra fields for proxy_auth */
ec878047 75 char *passwd;
73e67ee0 76 int passwd_ok; /* 1 = passwd checked OK */
77 long expiretime;
9bc73deb 78 struct in_addr ipaddr; /* IP addr this user authenticated from */
79 time_t ip_expiretime;
ec878047 80};
81
a8258824 82struct _acl_deny_info_list {
02922e76 83 int err_page_id;
84 char *err_page_name;
74fbf3c9 85 acl_name_list *acl_list;
86 acl_deny_info_list *next;
a8258824 87};
88
66c75c41 89#if USE_ARP_ACL
cbe3a719 90
66c75c41 91struct _acl_arp_data {
74b7003b 92 char eth[6];
66c75c41 93};
cbe3a719 94
66c75c41 95#endif
96
02922e76 97struct _String {
98 /* never reference these directly! */
a369131d 99 unsigned short int size; /* buffer size; 64K limit */
100 unsigned short int len; /* current length */
02922e76 101 char *buf;
102};
103
1df370e3 104#if SQUID_SNMP
43d4303e 105
a9ddb359 106struct _snmp_request_t {
5e29a294 107 u_char *buf;
108 u_char *outbuf;
2ac76861 109 int len;
110 int sock;
111 long reqid;
112 int outlen;
113 struct sockaddr_in from;
114 struct snmp_pdu *PDU;
115 aclCheck_t *acl_checklist;
5e29a294 116 u_char *community;
a9ddb359 117};
bdf18524 118
1df370e3 119#endif
a97cfa48 120
a8258824 121struct _acl {
122 char name[ACL_NAME_SZ];
123 squid_acl type;
124 void *data;
125 char *cfgline;
bd05e3e3 126 acl *next;
a8258824 127};
128
129struct _acl_list {
130 int op;
bd05e3e3 131 acl *acl;
132 acl_list *next;
a8258824 133};
134
135struct _acl_access {
136 int allow;
bd05e3e3 137 acl_list *acl_list;
a8258824 138 char *cfgline;
bd05e3e3 139 acl_access *next;
a8258824 140};
141
142struct _aclCheck_t {
bd05e3e3 143 const acl_access *access_list;
a8258824 144 struct in_addr src_addr;
145 struct in_addr dst_addr;
ae2c08a2 146 struct in_addr my_addr;
7e3ce7b9 147 unsigned short my_port;
a8258824 148 request_t *request;
3898f57f 149#if USE_IDENT
150 ConnStateData *conn; /* hack for ident */
def67559 151 char ident[USER_IDENT_SZ];
3898f57f 152#endif
73e67ee0 153 acl_proxy_auth_user *auth_user;
a8258824 154 acl_lookup_state state[ACL_ENUM_MAX];
dba79ac5 155#if SQUID_SNMP
156 char *snmp_community;
157#endif
a8258824 158 PF *callback;
159 void *callback_data;
160};
161
162struct _aio_result_t {
163 int aio_return;
164 int aio_errno;
165};
166
167struct _wordlist {
168 char *key;
bd05e3e3 169 wordlist *next;
a8258824 170};
171
172struct _intlist {
173 int i;
bd05e3e3 174 intlist *next;
a8258824 175};
176
8f663d72 177struct _intrange {
178 int i;
179 int j;
180 intrange *next;
181};
182
a8258824 183struct _ushortlist {
184 u_short i;
bd05e3e3 185 ushortlist *next;
a8258824 186};
187
188struct _relist {
189 char *pattern;
190 regex_t regex;
bd05e3e3 191 relist *next;
a8258824 192};
193
7e3ce7b9 194struct _sockaddr_in_list {
195 struct sockaddr_in s;
196 sockaddr_in_list *next;
197};
198
56e64999 199#if DELAY_POOLS
59715b38 200struct _delaySpec {
95e36d02 201 int restore_bps;
202 int max_bytes;
203};
1dfa1d81 204
59715b38 205/* malloc()'d only as far as used (class * sizeof(delaySpec)!
206 * order of elements very important!
207 */
208struct _delaySpecSet {
209 delaySpec aggregate;
210 delaySpec individual;
211 delaySpec network;
212};
213
214struct _delayConfig {
215 unsigned short pools;
216 unsigned short initial;
217 unsigned char *class;
218 delaySpecSet **rates;
219 acl_access **access;
220};
221
56e64999 222#endif
95e36d02 223
a8258824 224struct _SquidConfig {
225 struct {
9906e724 226 size_t maxSize;
a8258824 227 int highWaterMark;
228 int lowWaterMark;
43a70238 229 } Swap;
230 size_t memMaxSize;
a8258824 231 struct {
232 char *relayHost;
233 u_short relayPort;
db1cd23c 234 peer *peer;
a8258824 235 } Wais;
236 struct {
9906e724 237 size_t min;
a8258824 238 int pct;
9906e724 239 size_t max;
a8258824 240 } quickAbort;
2b906e48 241#if HEAP_REPLACEMENT
242 char *replPolicy;
243#else
244 /*
245 * Note: the non-LRU policies do not use referenceAge, but we cannot
246 * remove it until we find out how to implement #else for cf_parser.c
247 */
248#endif
a8258824 249 time_t referenceAge;
250 time_t negativeTtl;
251 time_t negativeDnsTtl;
252 time_t positiveDnsTtl;
253 time_t shutdownLifetime;
a8258824 254 struct {
255 time_t read;
a8258824 256 time_t lifetime;
257 time_t connect;
3f62decd 258 time_t peer_connect;
a8258824 259 time_t request;
603a02fd 260 time_t pconn;
23d92c64 261 time_t siteSelect;
dc835977 262 time_t deadPeer;
98829f69 263 int icp_query; /* msec */
28993292 264 int icp_query_max; /* msec */
98829f69 265 int mcast_icp_query; /* msec */
3898f57f 266#if USE_IDENT
05832ae1 267 time_t ident;
4fe0e1d0 268#endif
269#if !USE_DNSSERVERS
270 time_t idns_retransmit;
271 time_t idns_query;
3898f57f 272#endif
a8258824 273 } Timeout;
0483b991 274 size_t maxRequestHeaderSize;
275 size_t maxRequestBodySize;
276 size_t maxReplyBodySize;
a8258824 277 struct {
a8258824 278 u_short icp;
ace287ee 279#if USE_HTCP
280 u_short htcp;
281#endif
1df370e3 282#if SQUID_SNMP
678c6099 283 u_short snmp;
1df370e3 284#endif
a8258824 285 } Port;
7e3ce7b9 286 struct {
287 sockaddr_in_list *http;
288 } Sockaddr;
1df370e3 289#if SQUID_SNMP
2bbd722b 290 struct {
291 char *configFile;
292 char *agentInfo;
2ac237e2 293 } Snmp;
320e9f36 294#endif
eb824054 295#if USE_WCCP
320e9f36 296 struct {
297 struct in_addr router;
eb824054 298 struct in_addr incoming;
299 struct in_addr outgoing;
320e9f36 300 } Wccp;
1df370e3 301#endif
53ad48e6 302 char *as_whois_server;
a8258824 303 struct {
304 char *log;
305 char *access;
306 char *store;
307 char *swap;
308 char *useragent;
309 int rotateNumber;
a8258824 310 } Log;
a8258824 311 char *adminEmail;
312 char *effectiveUser;
313 char *effectiveGroup;
314 struct {
efd900cb 315#if USE_DNSSERVER
a8258824 316 char *dnsserver;
efd900cb 317#endif
c6d5b87b 318 wordlist *redirect;
f703eacb 319 wordlist *authenticate;
a8258824 320 char *pinger;
321 char *unlinkd;
322 } Program;
efd900cb 323#if USE_DNSSERVER
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;
efd900cb 390#if USE_DNSSERVER
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;
781 int reply_hdr_state;
1294c0fc 782 peer *peer; /* peer request made to */
a8258824 783 int eof; /* reached end-of-object? */
784 request_t *orig_request;
1294c0fc 785 int fd;
b515fc11 786 http_state_flags flags;
db1cd23c 787 FwdState *fwd;
a8258824 788};
789
790struct _icpUdpData {
791 struct sockaddr_in address;
792 void *msg;
793 size_t len;
794 icpUdpData *next;
795#ifndef LESS_TIMING
796 struct timeval start;
797#endif
798 log_type logcode;
17b6e784 799 struct timeval queue_time;
a8258824 800};
801
b4e7f82d 802struct _ping_data {
a8258824 803 struct timeval start;
804 struct timeval stop;
805 int n_sent;
806 int n_recv;
807 int n_replies_expected;
98829f69 808 int timeout; /* msec */
465dc415 809 int timedout;
a8258824 810 int w_rtt;
b3264694 811 int p_rtt;
a8258824 812};
813
814struct _HierarchyLogEntry {
815 hier_code code;
816 char host[SQUIDHOSTNAMELEN];
b4e7f82d 817 ping_data ping;
4b4cd312 818 char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
819 peer_select_alg_t alg; /* peer selection algorithm */
820 lookup_t cd_lookup; /* cd prediction: none, miss, hit */
821 int n_choices; /* #peers we selected from (cd only) */
822 int n_ichoices; /* #peers with known rtt we selected from (cd only) */
39edba21 823 struct timeval peer_select_start;
824 struct timeval store_complete_stop;
a8258824 825};
826
827struct _AccessLogEntry {
828 const char *url;
829 struct {
830 method_t method;
831 int code;
832 const char *content_type;
c68e9c6b 833 float version;
a8258824 834 } http;
835 struct {
836 icp_opcode opcode;
837 } icp;
838 struct {
839 struct in_addr caddr;
840 size_t size;
841 log_type code;
842 int msec;
843 const char *ident;
844 } cache;
a8258824 845 struct {
846 char *request;
847 char *reply;
848 } headers;
849 struct {
850 const char *method_str;
851 } private;
bd05e3e3 852 HierarchyLogEntry hier;
a8258824 853};
854
855struct _clientHttpRequest {
856 ConnStateData *conn;
857 request_t *request; /* Parsed URL ... */
23d92c64 858 char *uri;
859 char *log_uri;
a8258824 860 struct {
78f1250a 861 off_t offset;
862 size_t size;
a8258824 863 } out;
98829f69 864 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
865 size_t req_sz; /* raw request size on input, not current request size */
a8258824 866 StoreEntry *entry;
867 StoreEntry *old_entry;
868 log_type log_type;
6cfa8966 869#if USE_CACHE_DIGESTS
04f0c415 870 const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */
871#endif
9b312a19 872 http_status http_code;
a8258824 873 struct timeval start;
874 float http_ver;
875 int redirect_state;
876 aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */
877 clientHttpRequest *next;
bd05e3e3 878 AccessLogEntry al;
77ed547a 879 struct {
3d94aed0 880 unsigned int accel:1;
881 unsigned int internal:1;
882 unsigned int done_copying:1;
77ed547a 883 } flags;
6d38ef86 884 struct {
885 http_status status;
886 char *location;
887 } redirect;
0f1bc304 888 dlink_node active;
a8258824 889};
890
891struct _ConnStateData {
892 int fd;
893 struct {
894 char *buf;
78f1250a 895 off_t offset;
896 size_t size;
a8258824 897 } in;
898 clientHttpRequest *chr;
899 struct sockaddr_in peer;
900 struct sockaddr_in me;
901 struct in_addr log_addr;
05832ae1 902 char ident[USER_IDENT_SZ];
a8258824 903 int nrequests;
904 int persistent;
da2b3a17 905 struct {
906 int n;
907 time_t until;
908 } defer;
a8258824 909};
910
911struct _ipcache_addrs {
6d1c0d53 912 struct in_addr *in_addrs;
913 unsigned char *bad_mask;
a8258824 914 unsigned char count;
915 unsigned char cur;
22c653cd 916 unsigned char badcount;
a8258824 917};
918
59c4d35b 919struct _ip_pending {
920 IPH *handler;
921 void *handlerData;
922 ip_pending *next;
923};
924
a8258824 925struct _ipcache_entry {
ec878047 926 /* first two items must be equivalent to hash_link */
a8258824 927 char *name;
bd05e3e3 928 ipcache_entry *next;
a8258824 929 time_t lastref;
930 time_t expires;
931 ipcache_addrs addrs;
59c4d35b 932 ip_pending *pending_head;
a8258824 933 char *error_message;
b87b92fb 934 struct timeval request_time;
2ac237e2 935 dlink_node lru;
936 u_char locks;
a8258824 937 ipcache_status_t status:3;
938};
939
59c4d35b 940struct _fqdn_pending {
941 FQDNH *handler;
942 void *handlerData;
943 fqdn_pending *next;
944};
945
1df370e3 946struct _fqdncache_entry {
ec878047 947 /* first two items must be equivalent to hash_link */
1df370e3 948 char *name;
bd05e3e3 949 fqdncache_entry *next;
1df370e3 950 time_t lastref;
951 time_t expires;
952 unsigned char name_count;
953 char *names[FQDN_MAX_NAMES + 1];
59c4d35b 954 fqdn_pending *pending_head;
1df370e3 955 char *error_message;
74addf6c 956 struct timeval request_time;
1df370e3 957 dlink_node lru;
958 unsigned char locks;
959 fqdncache_status_t status:3;
960};
961
a8258824 962struct _domain_ping {
963 char *domain;
964 int do_ping; /* boolean */
bd05e3e3 965 domain_ping *next;
a8258824 966};
967
968struct _domain_type {
969 char *domain;
970 peer_t type;
bd05e3e3 971 domain_type *next;
a8258824 972};
973
c68e9c6b 974#if USE_CACHE_DIGESTS
e41e6dcd 975struct _Version {
4b4cd312 976 short int current; /* current version */
977 short int required; /* minimal version that can safely handle current version */
e41e6dcd 978};
979
980/* digest control block; used for transmission and storage */
981struct _StoreDigestCBlock {
982 Version ver;
983 int capacity;
984 int count;
985 int del_count;
986 int mask_size;
04f0c415 987 unsigned char bits_per_entry;
988 unsigned char hash_func_count;
989 short int reserved_short;
4b4cd312 990 int reserved[32 - 6];
e41e6dcd 991};
992
993struct _DigestFetchState {
e13ee7ad 994 PeerDigest *pd;
e41e6dcd 995 StoreEntry *entry;
996 StoreEntry *old_entry;
e13ee7ad 997 request_t *request;
e41e6dcd 998 int offset;
999 int mask_offset;
1000 time_t start_time;
e13ee7ad 1001 time_t resp_time;
1002 time_t expires;
1003 struct {
1004 int msg;
1005 int bytes;
1006 } sent, recv;
e41e6dcd 1007};
1008
1009/* statistics for cache digests and other hit "predictors" */
1010struct _cd_guess_stats {
1011 /* public, read-only */
1012 int true_hits;
1013 int false_hits;
1014 int true_misses;
1015 int false_misses;
4b4cd312 1016 int close_hits; /* tmp, remove it later */
e41e6dcd 1017};
1018
1019struct _PeerDigest {
4d62b0af 1020 peer *peer; /* pointer back to peer structure, argh */
1021 CacheDigest *cd; /* actual digest structure */
1022 String host; /* copy of peer->host */
e13ee7ad 1023 const char *req_result; /* text status of the last request */
b515fc11 1024 struct {
4d62b0af 1025 unsigned int needed:1; /* there were requests for this digest */
e13ee7ad 1026 unsigned int usable:1; /* can be used for lookups */
79618ba9 1027 unsigned int requested:1; /* in process of receiving [fresh] digest */
b515fc11 1028 } flags;
e13ee7ad 1029 struct {
1030 /* all times are absolute unless augmented with _delay */
1031 time_t initialized; /* creation */
1032 time_t needed; /* first lookup/use by a peer */
1033 time_t next_check; /* next scheduled check/refresh event */
1034 time_t retry_delay; /* delay before re-checking _invalid_ digest */
1035 time_t requested; /* requested a fresh copy of a digest */
4d62b0af 1036 time_t req_delay; /* last request response time */
e13ee7ad 1037 time_t received; /* received the current copy of a digest */
1038 time_t disabled; /* disabled for good */
1039 } times;
e41e6dcd 1040 struct {
1041 cd_guess_stats guess;
1042 int used_count;
e13ee7ad 1043 struct {
1044 int msgs;
1045 kb_t kbytes;
1046 } sent, recv;
e41e6dcd 1047 } stats;
1048};
1049
c68e9c6b 1050#endif
1051
a8258824 1052struct _peer {
1053 char *host;
1054 peer_t type;
1055 struct sockaddr_in in_addr;
1056 struct {
1057 int pings_sent;
1058 int pings_acked;
a8258824 1059 int fetches;
1060 int rtt;
a8258824 1061 int ignored_replies;
1294c0fc 1062 int n_keepalives_sent;
1063 int n_keepalives_recv;
83b381d5 1064 time_t probe_start;
dc835977 1065 time_t last_query;
1066 time_t last_reply;
eb406bb7 1067 time_t last_connect_failure;
1068 time_t last_connect_probe;
dc835977 1069 int logged_state; /* so we can print dead/revived msgs */
a8258824 1070 } stats;
399cabec 1071 struct {
886f2785 1072 int version;
399cabec 1073 int counts[ICP_END];
886f2785 1074 u_short port;
399cabec 1075 } icp;
1076#if USE_HTCP
1077 struct {
1078 double version;
1079 int counts[2];
886f2785 1080 u_short port;
399cabec 1081 } htcp;
1082#endif
a8258824 1083 u_short http_port;
b6a2f15e 1084 domain_ping *peer_domain;
bd05e3e3 1085 domain_type *typelist;
505e35db 1086 acl_access *access;
cd196bc8 1087 struct {
79618ba9 1088 unsigned int proxy_only:1;
1089 unsigned int no_query:1;
1090 unsigned int no_digest:1;
1091 unsigned int default_parent:1;
1092 unsigned int roundrobin:1;
1093 unsigned int mcast_responder:1;
1094 unsigned int closest_only:1;
cd196bc8 1095#if USE_HTCP
79618ba9 1096 unsigned int htcp:1;
cd196bc8 1097#endif
79618ba9 1098 unsigned int no_netdb_exchange:1;
cd196bc8 1099#if DELAY_POOLS
79618ba9 1100 unsigned int no_delay:1;
cd196bc8 1101#endif
987de783 1102 unsigned int allow_miss:1;
cd196bc8 1103 } options;
a8258824 1104 int weight;
1105 struct {
1106 double avg_n_members;
1107 int n_times_counted;
1108 int n_replies_expected;
1109 int ttl;
007b8be4 1110 int id;
b515fc11 1111 struct {
79618ba9 1112 unsigned int count_event_pending:1;
1113 unsigned int counting:1;
ff283ec1 1114 } flags;
a8258824 1115 } mcast;
c68e9c6b 1116#if USE_CACHE_DIGESTS
e13ee7ad 1117 PeerDigest *digest;
7e3ce7b9 1118 char *digest_url;
c68e9c6b 1119#endif
a8258824 1120 int tcp_up; /* 0 if a connect() fails */
a8258824 1121 struct in_addr addresses[10];
1122 int n_addresses;
1123 int rr_count;
82056f1e 1124 int rr_lastcount;
bd05e3e3 1125 peer *next;
a8258824 1126 int test_fd;
afd88fbe 1127#if USE_CARP
1128 struct {
1129 unsigned long hash;
1130 unsigned long load_multiplier;
1131 float load_factor;
1132 } carp;
1133#endif
c68e9c6b 1134 char *login; /* Proxy authorization */
3f62decd 1135 time_t connect_timeout;
a8258824 1136};
1137
1138struct _net_db_name {
1139 char *name;
74fbf3c9 1140 net_db_name *htbl_next;
1141 net_db_name *next;
1142 netdbEntry *net_db_entry;
a8258824 1143};
1144
1145struct _net_db_peer {
1146 char *peername;
1147 double hops;
1148 double rtt;
1149 time_t expires;
1150};
1151
1152struct _netdbEntry {
ec878047 1153 /* first two items must be equivalent to hash_link */
a8258824 1154 char *key;
74fbf3c9 1155 netdbEntry *next;
a8258824 1156 char network[16];
1157 int pings_sent;
1158 int pings_recv;
1159 double hops;
1160 double rtt;
1161 time_t next_ping_time;
1162 time_t last_use_time;
1163 int link_count;
1164 net_db_name *hosts;
1165 net_db_peer *peers;
1166 int n_peers_alloc;
1167 int n_peers;
1168};
1169
1170struct _ps_state {
1171 request_t *request;
1172 StoreEntry *entry;
1173 int always_direct;
1174 int never_direct;
db1cd23c 1175 int direct;
a8258824 1176 PSC *callback;
a8258824 1177 void *callback_data;
db1cd23c 1178 FwdServer *servers;
85223cd7 1179 /*
1180 * Why are these struct sockaddr_in instead of peer *? Because a
1181 * peer structure can become invalid during the peer selection
1182 * phase, specifically after a reconfigure. Thus we need to lookup
1183 * the peer * based on the address when we are finally ready to
1184 * reference the peer structure.
1185 */
1186 struct sockaddr_in first_parent_miss;
1187 struct sockaddr_in closest_parent_miss;
db1cd23c 1188 /*
1189 * ->hit and ->secho can be peer* because they should only be
1190 * accessed during the thread when they are set
1191 */
1192 peer *hit;
1193 peer_t hit_type;
1194#if ALLOW_SOURCE_PING
1195 peer *secho;
1196#endif
b4e7f82d 1197 ping_data ping;
a8258824 1198 aclCheck_t *acl_checklist;
1199};
1200
1201struct _pingerEchoData {
1202 struct in_addr to;
1203 unsigned char opcode;
1204 int psize;
65ae9f56 1205 char payload[PINGER_PAYLOAD_SZ];
a8258824 1206};
1207
1208struct _pingerReplyData {
1209 struct in_addr from;
1210 unsigned char opcode;
1211 int rtt;
1212 int hops;
1213 int psize;
65ae9f56 1214 char payload[PINGER_PAYLOAD_SZ];
a8258824 1215};
1216
1217struct _icp_common_t {
1218 unsigned char opcode; /* opcode */
1219 unsigned char version; /* version number */
1220 unsigned short length; /* total length (bytes) */
1221 u_num32 reqnum; /* req number (req'd for UDP) */
1222 u_num32 flags;
1223 u_num32 pad;
a8258824 1224 u_num32 shostid; /* sender host id */
1225};
1226
a8258824 1227struct _iostats {
1228 struct {
1229 int reads;
1230 int reads_deferred;
1231 int read_hist[16];
1232 int writes;
1233 int write_hist[16];
1234 } Http, Ftp, Gopher, Wais;
1235};
1236
1237struct _mem_node {
1238 char *data;
1239 int len;
1240 mem_node *next;
1241};
1242
1243struct _mem_hdr {
1244 mem_node *head;
1245 mem_node *tail;
1246 int origin_offset;
1247};
1248
a8258824 1249/* keep track each client receiving data from that particular StoreEntry */
1250struct _store_client {
43329771 1251 int type;
a8258824 1252 off_t copy_offset;
1253 off_t seen_offset;
1254 size_t copy_size;
1255 char *copy_buf;
1256 STCB *callback;
1257 void *callback_data;
07304bf9 1258 StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
2391a162 1259 storeIOState *swapin_sio;
f115fadd 1260 struct {
3d94aed0 1261 unsigned int disk_io_pending:1;
1262 unsigned int store_copying:1;
1263 unsigned int copy_event_pending:1;
f115fadd 1264 } flags;
bd05e3e3 1265 store_client *next;
447e176b 1266#if DELAY_POOLS
1267 delay_id delay_id;
1268#endif
a8258824 1269};
1270
1a3db59c 1271
a8258824 1272/* This structure can be freed while object is purged out from memory */
1273struct _MemObject {
2ac237e2 1274 method_t method;
9fb13bb6 1275 char *url;
18fe65d0 1276 mem_hdr data_hdr;
8350fe9b 1277 off_t inmem_hi;
1278 off_t inmem_lo;
bd05e3e3 1279 store_client *clients;
a8258824 1280 int nclients;
8350fe9b 1281 struct {
e3ef2b09 1282 off_t queue_offset; /* relative to in-mem data */
2391a162 1283 storeIOState *sio;
8350fe9b 1284 } swapout;
cb69b4c7 1285 HttpReply *reply;
a8258824 1286 request_t *request;
1287 struct timeval start_ping;
b4e7f82d 1288 IRCB *ping_reply_callback;
a8258824 1289 void *ircb_data;
1290 int fd; /* FD of client creating this entry */
1291 struct {
1292 STABH *callback;
1293 void *data;
1294 } abort;
88738790 1295 char *log_url;
2b906e48 1296#if HEAP_REPLACEMENT
1297 /*
1298 * A MemObject knows where it is in the in-memory heap.
1299 */
1300 heap_node *node;
1301#else
b93bcace 1302 dlink_node lru;
2b906e48 1303#endif
007b8be4 1304 int id;
07304bf9 1305 ssize_t object_sz;
e3ef2b09 1306 size_t swap_hdr_sz;
bc87dc25 1307#if URL_CHECKSUM_DEBUG
1308 unsigned int chksum;
1309#endif
a8258824 1310};
1311
a8258824 1312struct _StoreEntry {
ec878047 1313 /* first two items must be same as hash_link */
9fb13bb6 1314 const cache_key *key;
bd05e3e3 1315 StoreEntry *next;
a8258824 1316 MemObject *mem_obj;
a8258824 1317 time_t timestamp;
1318 time_t lastref;
1319 time_t expires;
1320 time_t lastmod;
07304bf9 1321 size_t swap_file_sz;
a21fbb54 1322 u_short refcount;
d46a87a8 1323 u_short flags;
2391a162 1324 sfileno swap_file_number;
2b906e48 1325#if HEAP_REPLACEMENT
1326 heap_node *node;
2b906e48 1327#else
b93bcace 1328 dlink_node lru;
2b906e48 1329#endif
a3cb7458 1330 u_short lock_count; /* Assume < 65536! */
a8258824 1331 mem_status_t mem_status:3;
1332 ping_status_t ping_status:3;
1333 store_status_t store_status:3;
1334 swap_status_t swap_status:3;
a8258824 1335};
1336
1337struct _SwapDir {
0e4e0e7d 1338 swapdir_t type;
1339 fileMap *map;
a8258824 1340 int cur_size;
c6844e77 1341 int low_size;
a8258824 1342 int max_size;
0e4e0e7d 1343 char *path;
b2c141d4 1344 int index; /* This entry's index into the swapDirs array */
fc8b9fc0 1345 sfileno suggest;
1346 int removals;
1347 int scanned;
72615e4a 1348 struct {
1349 unsigned int selected:1;
b6a2f15e 1350 unsigned int read_only:1;
72615e4a 1351 } flags;
b2c141d4 1352 STINIT *init;
1353 STNEWFS *newfs;
1354 struct {
1355 STOBJOPEN *open;
1356 STOBJCLOSE *close;
1357 STOBJREAD *read;
1358 STOBJWRITE *write;
1359 STOBJUNLINK *unlink;
b2c141d4 1360 } obj;
1361 struct {
1362 STLOGOPEN *open;
1363 STLOGCLOSE *close;
200ba06e 1364 STLOGWRITE *write;
b2c141d4 1365 struct {
1366 STLOGCLEANOPEN *open;
1367 STLOGCLEANWRITE *write;
1368 void *state;
1369 } clean;
1370 } log;
fc8b9fc0 1371#if !HEAP_REPLACEMENT
1372 dlink_list lru_list;
1373 dlink_node *lru_walker;
1374#endif
0e4e0e7d 1375 union {
1376 struct {
1377 int l1;
1378 int l2;
1379 int swaplog_fd;
1380 } ufs;
8798ad05 1381#if USE_DISKD
1382 struct {
1383 int l1;
1384 int l2;
1385 int swaplog_fd;
1386 int smsgid;
1387 int rmsgid;
1388 int wfd;
8798ad05 1389 int away;
c8366e06 1390 struct {
1391 char *buf;
1392 link_list *stack;
1393 int id;
1394 } shm;
8798ad05 1395 } diskd;
1396#endif
0e4e0e7d 1397 } u;
a8258824 1398};
1399
92695e5e 1400struct _request_flags {
3d94aed0 1401 unsigned int range:1;
1402 unsigned int nocache:1;
1403 unsigned int ims:1;
1404 unsigned int auth:1;
1405 unsigned int cachable:1;
1406 unsigned int hierarchical:1;
1407 unsigned int loopdetect:1;
1408 unsigned int proxy_keepalive:1;
1409 unsigned int proxying:1;
1410 unsigned int refresh:1;
1411 unsigned int used_proxy_auth:1;
1412 unsigned int redirected:1;
9689d97c 1413 unsigned int need_validation:1;
9f60cfdf 1414#if HTTP_VIOLATIONS
886f2785 1415 unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */
9f60cfdf 1416#endif
c68e9c6b 1417 unsigned int accelerated:1;
1418 unsigned int internal:1;
92695e5e 1419};
1420
d03d26fb 1421struct _link_list {
1422 void *ptr;
1423 struct _link_list *next;
1424};
1425
2391a162 1426struct _storeIOState {
2391a162 1427 sfileno swap_file_number;
1428 mode_t mode;
1429 size_t st_size; /* do stat(2) after read open */
1430 off_t offset; /* current offset pointer */
1431 STIOCB *callback;
1432 void *callback_data;
1433 struct {
1434 STRCB *callback;
1435 void *callback_data;
1436 } read;
1437 struct {
1438 unsigned int closing:1; /* debugging aid */
1439 } flags;
1440 union {
1441 struct {
819244bf 1442 int fd;
2391a162 1443 struct {
1444 unsigned int close_request:1;
1445 unsigned int reading:1;
1446 unsigned int writing:1;
1447 } flags;
1448 } ufs;
53fa92a5 1449 struct {
1450 int fd;
53fa92a5 1451 struct {
1452 unsigned int close_request:1;
1453 unsigned int reading:1;
1454 unsigned int writing:1;
d03d26fb 1455 unsigned int opening:1;
53fa92a5 1456 } flags;
6f992224 1457 const char *read_buf;
1458 link_list *pending_writes;
1f38f50a 1459 link_list *pending_reads;
53fa92a5 1460 } aufs;
8798ad05 1461#if USE_DISKD
1462 struct {
1463 int id;
1464 struct {
1465 unsigned int reading:1;
1466 unsigned int writing:1;
1467 } flags;
1468 char *read_buf;
1469 } diskd;
1470#endif
2391a162 1471 } type;
1472};
1473
a8258824 1474struct _request_t {
1475 method_t method;
1476 protocol_t protocol;
1477 char login[MAX_LOGIN_SZ];
1478 char host[SQUIDHOSTNAMELEN + 1];
def67559 1479 char user_ident[USER_IDENT_SZ]; /* from proxy auth or ident server */
a8258824 1480 u_short port;
02922e76 1481 String urlpath;
e4a45101 1482 char *canonical;
a8258824 1483 int link_count; /* free when zero */
92695e5e 1484 request_flags flags;
8e092300 1485 HttpHdrCc *cache_control;
d192d11f 1486 HttpHdrRange *range;
a8258824 1487 float http_ver;
1488 time_t ims;
1489 int imslen;
1490 int max_forwards;
7e3ce7b9 1491 /* these in_addr's could probably be sockaddr_in's */
a8258824 1492 struct in_addr client_addr;
3c11d1f5 1493 struct in_addr my_addr;
7e3ce7b9 1494 unsigned short my_port;
99edd1c3 1495 HttpHeader header;
a8258824 1496 char *body;
1497 size_t body_sz;
1f38f50a 1498 int content_length;
bd05e3e3 1499 HierarchyLogEntry hier;
88aad2e5 1500 err_type err_type;
c68e9c6b 1501 char *peer_login; /* Configured peer login:password */
9bc73deb 1502 time_t lastmod; /* Used on refreshes */
a8258824 1503};
1504
1505struct _cachemgr_passwd {
1506 char *passwd;
22f3fd98 1507 wordlist *actions;
bd05e3e3 1508 cachemgr_passwd *next;
a8258824 1509};
1510
1511struct _refresh_t {
1512 char *pattern;
1513 regex_t compiled_pattern;
1514 time_t min;
c3f6d204 1515 double pct;
a8258824 1516 time_t max;
bd05e3e3 1517 refresh_t *next;
c3f6d204 1518 struct {
1dfa1d81 1519 unsigned int icase:1;
9f60cfdf 1520#if HTTP_VIOLATIONS
1dfa1d81 1521 unsigned int override_expire:1;
1522 unsigned int override_lastmod:1;
cbe3a719 1523 unsigned int reload_into_ims:1;
1524 unsigned int ignore_reload:1;
9f60cfdf 1525#endif
c3f6d204 1526 } flags;
a8258824 1527};
1528
1529struct _CommWriteStateData {
1530 char *buf;
1531 size_t size;
1532 off_t offset;
1533 CWCB *handler;
1534 void *handler_data;
74fbf3c9 1535 FREE *free_func;
a8258824 1536};
9b312a19 1537
1538struct _ErrorState {
1539 err_type type;
02922e76 1540 int page_id;
9b312a19 1541 http_status http_status;
1542 request_t *request;
1543 char *url;
c45ed9ad 1544 int xerrno;
9b312a19 1545 char *host;
1546 u_short port;
1547 char *dnsserver_msg;
1548 time_t ttl;
1549 struct in_addr src_addr;
1550 char *redirect_url;
1551 ERCB *callback;
1552 void *callback_data;
b515fc11 1553 struct {
79618ba9 1554 unsigned int flag_cbdata:1;
b515fc11 1555 } flags;
b9916917 1556 struct {
9bc73deb 1557 wordlist *server_msg;
b9916917 1558 char *request;
1559 char *reply;
1560 } ftp;
e144eae4 1561 char *request_hdrs;
9b312a19 1562};
f2908497 1563
12cf1be2 1564/*
1565 * "very generic" histogram;
1566 * see important comments on hbase_f restrictions in StatHist.c
1567 */
1568struct _StatHist {
1569 int *bins;
1570 int capacity;
e9a13293 1571 double min;
1572 double max;
1573 double scale;
95c297ec 1574 hbase_f *val_in; /* e.g., log() for log-based histogram */
1575 hbase_f *val_out; /* e.g., exp() for log based histogram */
7ae52c25 1576};
1577
12cf1be2 1578/*
1579 * if you add a field to StatCounters,
1d803566 1580 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
12cf1be2 1581 */
f2908497 1582struct _StatCounters {
1583 struct {
98829f69 1584 int clients;
f2908497 1585 int requests;
1586 int hits;
4f4d1d6e 1587 int mem_hits;
1588 int disk_hits;
f2908497 1589 int errors;
a7c05555 1590 kb_t kbytes_in;
1591 kb_t kbytes_out;
1592 kb_t hit_kbytes_out;
12cf1be2 1593 StatHist miss_svc_time;
1594 StatHist nm_svc_time;
7c9c84ad 1595 StatHist nh_svc_time;
12cf1be2 1596 StatHist hit_svc_time;
1597 StatHist all_svc_time;
f2908497 1598 } client_http;
7ae52c25 1599 struct {
a0f32775 1600 struct {
1601 int requests;
1602 int errors;
1603 kb_t kbytes_in;
1604 kb_t kbytes_out;
399e85ea 1605 } all , http, ftp, other;
7ae52c25 1606 } server;
f2908497 1607 struct {
1608 int pkts_sent;
071a3ae7 1609 int queries_sent;
1610 int replies_sent;
f2908497 1611 int pkts_recv;
071a3ae7 1612 int queries_recv;
1613 int replies_recv;
a7c05555 1614 int hits_sent;
1615 int hits_recv;
8064065e 1616 int replies_queued;
17b6e784 1617 int replies_dropped;
a7c05555 1618 kb_t kbytes_sent;
071a3ae7 1619 kb_t q_kbytes_sent;
1620 kb_t r_kbytes_sent;
a7c05555 1621 kb_t kbytes_recv;
071a3ae7 1622 kb_t q_kbytes_recv;
1623 kb_t r_kbytes_recv;
12cf1be2 1624 StatHist query_svc_time;
1625 StatHist reply_svc_time;
4b4cd312 1626 int query_timeouts;
c127134a 1627 int times_used;
f2908497 1628 } icp;
1629 struct {
1630 int requests;
1631 } unlink;
9973e9fe 1632 struct {
12cf1be2 1633 StatHist svc_time;
9973e9fe 1634 } dns;
c127134a 1635 struct {
1636 int times_used;
26b164ac 1637 kb_t kbytes_sent;
1638 kb_t kbytes_recv;
c127134a 1639 kb_t memory;
00485c29 1640 int msgs_sent;
1641 int msgs_recv;
c68e9c6b 1642#if USE_CACHE_DIGESTS
4b4cd312 1643 cd_guess_stats guess;
c68e9c6b 1644#endif
69c95dd3 1645 StatHist on_xition_count;
c127134a 1646 } cd;
69c95dd3 1647 struct {
1648 int times_used;
1649 } netdb;
f2908497 1650 int page_faults;
1651 int select_loops;
d239c2f5 1652 int select_fds;
1653 double select_time;
f2908497 1654 double cputime;
d5649d9f 1655 struct timeval timestamp;
c6ecdbc3 1656 StatHist comm_icp_incoming;
ef523f99 1657 StatHist comm_dns_incoming;
c6ecdbc3 1658 StatHist comm_http_incoming;
26d6ee93 1659 StatHist select_fds_hist;
886f2785 1660 struct {
1661 struct {
1662 int opens;
1663 int closes;
1664 int reads;
1665 int writes;
1666 int seeks;
64b54eed 1667 int unlinks;
886f2785 1668 } disk;
1669 struct {
1670 int accepts;
1671 int sockets;
1672 int connects;
1673 int binds;
1674 int closes;
1675 int reads;
1676 int writes;
1677 int recvfroms;
1678 int sendtos;
1679 } sock;
1680#if HAVE_POLL
1681 int polls;
1682#else
1683 int selects;
1684#endif
1685 } syscalls;
2c4f7ab2 1686 int swap_files_cleaned;
bfae3379 1687 int aborted_requests;
f2908497 1688};
69c01cd7 1689
fcd2d3ef 1690/* per header statistics */
1691struct _HttpHeaderStat {
1692 const char *label;
1693 HttpHeaderMask *owner_mask;
1694
1695 StatHist hdrUCountDistr;
1696 StatHist fieldTypeDistr;
1697 StatHist ccTypeDistr;
1698
1699 int parsedCount;
1700 int ccParsedCount;
1701 int destroyedCount;
1702 int busyDestroyedCount;
1703};
1704
1705
69c01cd7 1706struct _tlv {
5830cdb3 1707 char type;
1708 int length;
1709 void *value;
bd05e3e3 1710 tlv *next;
5830cdb3 1711};
1712
07304bf9 1713struct _storeSwapLogData {
5830cdb3 1714 char op;
2391a162 1715 sfileno swap_file_number;
5830cdb3 1716 time_t timestamp;
1717 time_t lastref;
1718 time_t expires;
1719 time_t lastmod;
07304bf9 1720 size_t swap_file_sz;
5830cdb3 1721 u_short refcount;
d46a87a8 1722 u_short flags;
7363fc17 1723 unsigned char key[MD5_DIGEST_CHARS];
69c01cd7 1724};
59c4d35b 1725
02922e76 1726/* object to track per-action memory usage (e.g. #idle objects) */
1727struct _MemMeter {
9bc73deb 1728 ssize_t level; /* current level (count or volume) */
1729 ssize_t hwater_level; /* high water mark */
d8b249ef 1730 time_t hwater_stamp; /* timestamp of last high water mark change */
02922e76 1731};
1732
1733/* object to track per-pool memory usage (alloc = inuse+idle) */
1734struct _MemPoolMeter {
1735 MemMeter alloc;
1736 MemMeter inuse;
1737 MemMeter idle;
1738 gb_t saved;
7f8bbdcd 1739 gb_t total;
02922e76 1740};
1741
1742/* a pool is a [growing] space for objects of the same size */
1743struct _MemPool {
1744 const char *label;
1745 size_t obj_size;
1746 Stack pstack; /* stack for free pointers */
1747 MemPoolMeter meter;
1748};
1749
59c4d35b 1750struct _ClientInfo {
ec878047 1751 /* first two items must be equivalent to hash_link */
59c4d35b 1752 char *key;
ca3c5a71 1753 ClientInfo *next;
59c4d35b 1754 struct in_addr addr;
1755 struct {
1756 int result_hist[LOG_TYPE_MAX];
1757 int n_requests;
ec878047 1758 kb_t kbytes_in;
1759 kb_t kbytes_out;
1760 kb_t hit_kbytes_out;
59c4d35b 1761 } Http, Icp;
1762 struct {
1763 time_t time;
1764 int n_req;
1765 int n_denied;
1766 } cutoff;
9bc73deb 1767 int n_established; /* number of current established connections */
59c4d35b 1768};
c411be12 1769
c411be12 1770struct _CacheDigest {
1771 /* public, read-only */
1afe05c5 1772 char *mask; /* bit mask */
1773 size_t mask_size; /* mask size in bytes */
1774 int capacity; /* expected maximum for .count, not a hard limit */
04f0c415 1775 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1afe05c5 1776 int count; /* number of digested entries */
1777 int del_count; /* number of deletions performed so far */
c411be12 1778};
910169e5 1779
db1cd23c 1780struct _FwdServer {
1781 peer *peer; /* NULL --> origin server */
1782 hier_code code;
1783 FwdServer *next;
1784};
1785
910169e5 1786struct _FwdState {
1787 int client_fd;
1788 StoreEntry *entry;
1789 request_t *request;
1790 FwdServer *servers;
6801f8a8 1791 int server_fd;
ec250dfd 1792 ErrorState *err;
f563eea9 1793 time_t start;
68bd6892 1794 int n_tries;
ee08bdf5 1795 struct {
1796 unsigned int dont_retry:1;
9bc73deb 1797 unsigned int ftp_pasv_failed:1;
ee08bdf5 1798 } flags;
910169e5 1799};
1800
86aebcda 1801#if USE_HTCP
1802struct _htcpReplyData {
886f2785 1803 int hit;
1804 HttpHeader hdr;
1805 u_num32 msg_id;
1806 double version;
1807 struct {
b4e7f82d 1808 /* cache-to-origin */
886f2785 1809 double rtt;
1810 int samp;
1811 int hops;
1812 } cto;
86aebcda 1813};
886f2785 1814
86aebcda 1815#endif
74addf6c 1816
1817
1818struct _helper_request {
1819 char *buf;
1820 HLPCB *callback;
1821 void *data;
1822};
1823
1824struct _helper {
1825 wordlist *cmdline;
1826 dlink_list servers;
1827 dlink_list queue;
1f5f60dd 1828 const char *id_name;
74addf6c 1829 int n_to_start;
1830 int n_running;
1831 int ipc_type;
1832 time_t last_queue_warn;
1833 struct {
1834 int requests;
1835 int replies;
1836 int queue_size;
1837 int avg_svc_time;
1838 } stats;
1839};
1840
1841struct _helper_server {
1842 int index;
1843 int rfd;
1844 int wfd;
1845 char *buf;
1846 size_t buf_sz;
1847 off_t offset;
1848 struct timeval dispatch_time;
1849 struct timeval answer_time;
1850 dlink_node link;
1851 helper *parent;
1852 helper_request *request;
838b993c 1853 struct _helper_flags {
1854 unsigned int alive:1;
1855 unsigned int busy:1;
1856 unsigned int closing:1;
1857 unsigned int shutdown:1;
1858 } flags;
74addf6c 1859 struct {
1860 int uses;
1861 } stats;
1862};
1863
1864/*
1865 * use this when you need to pass callback data to a blocking
1866 * operation, but you don't want to add that pointer to cbdata
1867 */
1868struct _generic_cbdata {
1869 void *data;
1870};
b2c141d4 1871
1872struct _store_rebuild_data {
1873 int objcount; /* # objects successfully reloaded */
1874 int expcount; /* # objects expired */
1875 int scancount; /* # entries scanned or read from state file */
1876 int clashcount; /* # swapfile clashes avoided */
1877 int dupcount; /* # duplicates purged */
1878 int cancelcount; /* # SWAP_LOG_DEL objects purged */
1879 int invalid; /* # bad lines */
1880 int badflags; /* # bad e->flags */
1881 int bad_log_op;
1882 int zero_object_sz;
1883};
5673c2e2 1884
1885struct _Logfile {
1886 int fd;
1887 char path[MAXPATHLEN];
1888 char *buf;
1889 size_t bufsz;
1890 off_t offset;
1891};