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