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