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