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