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