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