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