]> git.ipfire.org Git - thirdparty/squid.git/blame - src/structs.h
- Separated raw HTTP headers from their "compiled" values. Squid is now
[thirdparty/squid.git] / src / structs.h
CommitLineData
a8258824 1
399e85ea 2
a8258824 3struct _acl_ip_data {
4 struct in_addr addr1; /* if addr2 non-zero then its a range */
5 struct in_addr addr2;
6 struct in_addr mask;
7#ifndef USE_SPLAY_TREE
74fbf3c9 8 acl_ip_data *next;
a8258824 9#endif
10};
11
12struct _acl_time_data {
13 int weekbits;
14 int start;
15 int stop;
74fbf3c9 16 acl_time_data *next;
a8258824 17};
18
19struct _acl_name_list {
20 char name[ACL_NAME_SZ];
74fbf3c9 21 acl_name_list *next;
a8258824 22};
23
afe95a7e 24struct _acl_proxy_auth {
25 char *filename;
26 time_t last_time;
27 time_t change_time;
28 int check_interval;
29 hash_table *hash;
30};
31
a8258824 32struct _acl_deny_info_list {
02922e76 33 int err_page_id;
34 char *err_page_name;
74fbf3c9 35 acl_name_list *acl_list;
36 acl_deny_info_list *next;
a8258824 37};
38
66c75c41 39#if USE_ARP_ACL
40struct _acl_arp_data {
53ad48e6 41 unsigned char eth[6];
66c75c41 42#ifndef USE_SPLAY_TREE
74fbf3c9 43 acl_arp_data *next;
66c75c41 44#endif
45};
194dd3b8 46
66c75c41 47#endif
48
02922e76 49struct _String {
50 /* never reference these directly! */
a369131d 51 unsigned short int size; /* buffer size; 64K limit */
52 unsigned short int len; /* current length */
02922e76 53 char *buf;
54};
55
1df370e3 56#if SQUID_SNMP
bdf18524 57struct _snmp_request_t {
5e29a294 58 u_char *buf;
59 u_char *outbuf;
2ac76861 60 int len;
61 int sock;
62 long reqid;
63 int outlen;
64 struct sockaddr_in from;
65 struct snmp_pdu *PDU;
66 aclCheck_t *acl_checklist;
5e29a294 67 u_char *community;
bdf18524 68};
69
6ccb94e5 70typedef struct _viewEntry {
71 char viewName[32];
72 int viewIndex;
73 int viewType;
74 int viewSubtreeLen;
75 oid viewSubtree[32];
76 struct _viewEntry *next;
77} viewEntry;
78
79typedef struct _communityEntry {
80 char name[64];
81 int readView;
82 int writeView;
bdf18524 83 struct _acl_access *acls;
6ccb94e5 84 struct _communityEntry *next;
85} communityEntry;
86
87typedef struct _usecEntry {
88 u_char userName[32];
89 int userLen;
90 int qoS;
91 u_char authKey[16];
92 u_char privKey[16];
93 int noauthReadView;
94 int noauthWriteView;
95 int authReadView;
96 int authWriteView;
97 struct _usecEntry *next;
98} usecEntry;
194dd3b8 99
1df370e3 100#endif
a97cfa48 101
a8258824 102struct _acl {
103 char name[ACL_NAME_SZ];
104 squid_acl type;
105 void *data;
106 char *cfgline;
107 struct _acl *next;
108};
109
110struct _acl_list {
111 int op;
112 struct _acl *acl;
113 struct _acl_list *next;
114};
115
116struct _acl_access {
117 int allow;
118 struct _acl_list *acl_list;
119 char *cfgline;
120 struct _acl_access *next;
121};
122
bdf18524 123
a8258824 124struct _aclCheck_t {
125 const struct _acl_access *access_list;
126 struct in_addr src_addr;
127 struct in_addr dst_addr;
128 request_t *request;
129 char ident[ICP_IDENT_SZ];
130 char browser[BROWSERNAMELEN];
131 acl_lookup_state state[ACL_ENUM_MAX];
132 PF *callback;
133 void *callback_data;
134};
135
136struct _aio_result_t {
137 int aio_return;
138 int aio_errno;
139};
140
141struct _wordlist {
142 char *key;
143 struct _wordlist *next;
144};
145
146struct _intlist {
147 int i;
148 struct _intlist *next;
149};
150
151struct _ushortlist {
152 u_short i;
153 struct _ushortlist *next;
154};
155
156struct _relist {
157 char *pattern;
158 regex_t regex;
159 struct _relist *next;
160};
161
a8258824 162struct _SquidConfig {
163 struct {
9906e724 164 size_t maxSize;
a8258824 165 int highWaterMark;
166 int lowWaterMark;
167 } Mem , Swap;
168 struct {
169 char *relayHost;
170 u_short relayPort;
171 } Wais;
172 struct {
9906e724 173 size_t min;
a8258824 174 int pct;
9906e724 175 size_t max;
a8258824 176 } quickAbort;
177 time_t referenceAge;
178 time_t negativeTtl;
179 time_t negativeDnsTtl;
180 time_t positiveDnsTtl;
181 time_t shutdownLifetime;
182 time_t neighborTimeout;
a8258824 183 struct {
184 time_t read;
a8258824 185 time_t lifetime;
186 time_t connect;
187 time_t request;
603a02fd 188 time_t pconn;
23d92c64 189 time_t siteSelect;
dc835977 190 time_t deadPeer;
a8258824 191 } Timeout;
9906e724 192 size_t maxRequestSize;
a8258824 193 struct {
194 ushortlist *http;
195 u_short icp;
ace287ee 196#if USE_HTCP
197 u_short htcp;
198#endif
1df370e3 199#if SQUID_SNMP
678c6099 200 u_short snmp;
1df370e3 201#endif
a8258824 202 } Port;
1df370e3 203#if SQUID_SNMP
2bbd722b 204 struct {
205 char *configFile;
206 char *agentInfo;
207 char *mibPath;
a97cfa48 208 char *trap_community;
209 char *trap_sink;
2bbd722b 210 u_short localPort;
211 int do_queueing;
a97cfa48 212 int conf_authtraps;
5e14bf6d 213 wordlist *snmpconf;
be335c22 214 viewEntry *views;
215 usecEntry *users;
216 communityEntry *communities;
2ac237e2 217 } Snmp;
1df370e3 218#endif
53ad48e6 219 char *as_whois_server;
a8258824 220 struct {
221 char *log;
222 char *access;
223 char *store;
224 char *swap;
225 char *useragent;
226 int rotateNumber;
a8258824 227 } Log;
a8258824 228 char *adminEmail;
229 char *effectiveUser;
230 char *effectiveGroup;
231 struct {
232 char *dnsserver;
233 char *redirect;
234 char *pinger;
235 char *unlinkd;
236 } Program;
237 int dnsChildren;
238 int redirectChildren;
a8258824 239 struct {
240 char *host;
241 u_short port;
a8258824 242 } Accel;
243 char *appendDomain;
244 size_t appendDomainLen;
245 char *debugOptions;
246 char *pidFilename;
247 char *mimeTablePathname;
248 char *visibleHostname;
249 char *errHtmlText;
250 struct {
251 char *host;
252 char *file;
253 time_t period;
a8258824 254 u_short port;
255 } Announce;
256 struct {
257 struct in_addr tcp_incoming;
258 struct in_addr tcp_outgoing;
259 struct in_addr udp_incoming;
2bbd722b 260 struct in_addr udp_outgoing;
678c6099 261 struct in_addr snmp_incoming;
2bbd722b 262 struct in_addr snmp_outgoing;
a8258824 263 struct in_addr client_netmask;
264 } Addrs;
9906e724 265 size_t tcpRcvBufsz;
266 size_t udpMaxHitObjsz;
a8258824 267 wordlist *cache_stoplist;
268 wordlist *hierarchy_stoplist;
269 wordlist *mcast_group_list;
270 wordlist *dns_testname_list;
09c483ec 271 wordlist *dns_nameservers;
a8258824 272 relist *cache_stop_relist;
40a1495e 273 peer *peers;
274 int npeers;
a8258824 275 struct {
89de058c 276 int size;
a8258824 277 int low;
278 int high;
279 } ipcache;
280 int minDirectHops;
281 cachemgr_passwd *passwd_list;
282 struct {
283 int objectsPerBucket;
9906e724 284 size_t avgObjectSize;
285 size_t maxObjectSize;
a8258824 286 } Store;
287 struct {
288 int high;
289 int low;
290 time_t period;
291 } Netdb;
292 struct {
293 int log_udp;
294 int enable_purge;
295 int res_defnames;
296 int anonymizer;
297 int client_db;
298 int query_icmp;
88738790 299 int icp_hit_stale;
78f1250a 300 int buffered_logs;
0ab965da 301#if ALLOW_SOURCE_PING
9b312a19 302 int source_ping;
0ab965da 303#endif
9b312a19 304 int common_log;
305 int log_mime_hdrs;
306 int ident_lookup;
17a0a4ee 307 int log_fqdn;
308 int announce;
309 int accel_with_proxy;
3f6c0fb2 310 int mem_pools;
194dd3b8 311 int test_reachability;
17a0a4ee 312 } onoff;
a8258824 313 struct _acl *aclList;
314 struct {
315 struct _acl_access *http;
316 struct _acl_access *icp;
317 struct _acl_access *miss;
318 struct _acl_access *NeverDirect;
319 struct _acl_access *AlwaysDirect;
53ad48e6 320 struct _acl_access *ASlists;
a8258824 321 } accessList;
322 struct _acl_deny_info_list *denyInfoList;
323 struct {
324 size_t list_width;
325 int list_wrap;
a8258824 326 char *anon_user;
327 } Ftp;
328 refresh_t *Refresh;
329 struct _cacheSwap {
a47b9029 330 SwapDir *swapDirs;
331 int n_allocated;
332 int n_configured;
a8258824 333 } cacheSwap;
88738790 334 char *fake_ua;
365cb147 335 struct {
336 char *directory;
365cb147 337 } icons;
9b312a19 338 char *errorDirectory;
22c653cd 339 struct {
340 time_t timeout;
341 int maxtries;
342 } retry;
7021844c 343 struct {
344 size_t limit;
345 } MemPools;
a8258824 346};
347
348struct _SquidConfig2 {
349 struct {
350 char *prefix;
351 int on;
352 } Accel;
353};
354
355struct _close_handler {
356 PF *handler;
357 void *data;
358 close_handler *next;
359};
360
361struct _dread_ctrl {
362 int fd;
363 off_t offset;
364 int req_len;
365 char *buf;
366 int end_of_file;
367 DRCB *handler;
368 void *client_data;
369};
370
371struct _dnsserver_t {
372 int id;
373 int flags;
374 int inpipe;
375 int outpipe;
376 time_t answer;
78f1250a 377 off_t offset;
378 size_t size;
e144eae4 379 char ip_inbuf[DNS_INBUF_SZ];
a8258824 380 struct timeval dispatch_time;
381 void *data;
382};
383
384struct _dnsStatData {
385 int requests;
386 int replies;
387 int hist[DefaultDnsChildrenMax];
388};
389
390struct _dwrite_q {
d377699f 391 off_t file_offset;
a8258824 392 char *buf;
393 int len;
d377699f 394 off_t buf_offset;
a8258824 395 struct _dwrite_q *next;
74fbf3c9 396 FREE *free_func;
a8258824 397};
398
a8258824 399struct _fde {
400 unsigned int type;
401 unsigned int open;
402 u_short local_port;
403 u_short remote_port;
404 char ipaddr[16]; /* dotted decimal address of peer */
405 char desc[FD_DESC_SZ];
406 int flags;
407 int bytes_read;
408 int bytes_written;
b716a8ad 409 int uses; /* ie # req's over persistent conn */
a8258824 410 struct _fde_disk {
411 DWCB *wrt_handle;
412 void *wrt_handle_data;
413 dwrite_q *write_q;
414 dwrite_q *write_q_tail;
711982d8 415 off_t offset;
a8258824 416 } disk;
417 PF *read_handler;
418 void *read_data;
419 PF *write_handler;
420 void *write_data;
421 PF *timeout_handler;
422 time_t timeout;
423 void *timeout_data;
cb69b4c7 424 void *lifetime_data;
a8258824 425 close_handler *close_handler; /* linked list */
da2b3a17 426 DEFER *defer_check; /* check if we should defer read */
70a9dab4 427 void *defer_data;
a8258824 428 CommWriteStateData *rwstate; /* State data for comm_write */
22c653cd 429 time_t connect_timeout;
a8258824 430};
431
432struct _fileMap {
433 int max_n_files;
434 int n_files_in_map;
a8258824 435 int toggle;
436 int nwords;
437 unsigned long *file_map;
438};
439
a8258824 440struct _hash_link {
441 char *key;
442 struct _hash_link *next;
443 void *item;
444};
445
446struct _hash_table {
447 int valid;
448 hash_link **buckets;
449 HASHCMP *cmp;
450 HASHHASH *hash;
451 unsigned int size;
452 unsigned int current_slot;
453 hash_link *current_ptr;
454};
455
adba4a64 456/* http status line */
457struct _HttpStatusLine {
458 /* public, read only */
459 double version;
2ac76861 460 const char *reason; /* points to a _constant_ string (default or supplied), never free()d */
adba4a64 461 http_status status;
462};
463
464/*
465 * Note: HttpBody is used only for messages with a small text content that is
466 * known a priory (e.g., error messages).
467 */
468struct _HttpBody {
469 /* private, never dereference these */
2ac76861 470 char *buf; /* null terminating _text_ buffer, not for binary stuff */
471 FREE *freefunc; /* used to free() .buf */
adba4a64 472 int size;
473};
474
2ecaa5e7 475/* http header extention field */
476struct _HttpHdrExtField {
a369131d 477 String name; /* field-name from HTTP/1.1 (no column after name) */
478 String value; /* field-value from HTTP/1.1 */
2ecaa5e7 479};
adba4a64 480
399e85ea 481/* http cache control header field */
7faf2bdb 482struct _HttpHdrCc {
4f087419 483 int mask;
d8b249ef 484 int max_age;
a8258824 485};
ee1679df 486
b5107edb 487/* http byte-range-spec */
488struct _HttpHdrRangeSpec {
489 size_t offset;
490 size_t length;
491};
492
493/* There may be more than one byte range specified in the request.
59c4d35b 494 * This object holds all range specs in order of their appearence
495 * in the request because we SHOULD preserve that order.
496 */
b5107edb 497struct _HttpHdrRange {
498 Stack specs;
499};
7faf2bdb 500
d76fcfa7 501/* http content-range header field */
502struct _HttpHdrContRange {
503 HttpHdrRangeSpec spec;
a369131d 504 size_t elength; /* entity length, not content length */
d76fcfa7 505};
506
507
7faf2bdb 508/* per field statistics */
509struct _HttpHeaderFieldStat {
399e85ea 510 int aliveCount; /* created but not destroyed (count) */
d8b249ef 511 int seenCount; /* #fields we've seen */
399e85ea 512 int parsCount; /* #parsing attempts */
513 int errCount; /* #pasring errors */
514 int repCount; /* #repetitons */
7faf2bdb 515};
516
7faf2bdb 517/* constant attributes of http header fields */
de336bbe 518struct _HttpHeaderFieldAttrs {
7faf2bdb 519 const char *name;
520 http_hdr_type id;
521 field_type type;
de336bbe 522};
523
d8b249ef 524/* compiled version of HttpHeaderFieldAttrs plus stats */
de336bbe 525struct _HttpHeaderFieldInfo {
526 http_hdr_type id;
527 String name;
528 field_type type;
7faf2bdb 529 HttpHeaderFieldStat stat;
530};
531
d8b249ef 532struct _HttpHeaderEntry {
533 http_hdr_type id;
534 String name;
535 String value;
536};
4f087419 537
d8b249ef 538struct _HttpHeader {
4f087419 539 /* protected, do not use these, use interface functions instead */
d8b249ef 540 Array entries; /* parsed fields in raw format */
541 HttpHeaderMask mask; /* bit set <=> entry present */
4f087419 542};
543
adba4a64 544struct _HttpReply {
545 /* unsupported, writable, may disappear/change in the future */
2ac76861 546 int hdr_sz; /* sums _stored_ status-line, headers, and <CRLF> */
adba4a64 547
d8b249ef 548 /* public, readable; never update these or their .hdr equivalents directly */
549 int content_length;
550 time_t date;
551 time_t last_modified;
552 time_t expires;
553 String content_type;
554 HttpHdrCc *cache_control;
555 HttpHdrContRange *content_range;
556 short int pconn_keep_alive;
557
adba4a64 558 /* public, readable */
2ac76861 559 HttpMsgParseState pstate; /* the current parsing state */
4f087419 560
de336bbe 561 /* public, writable, but use httpReply* interfaces when possible */
adba4a64 562 HttpStatusLine sline;
d8b249ef 563 HttpHeader header;
564 HttpBody body; /* for small constant memory-resident text bodies only */
adba4a64 565};
cb69b4c7 566
a8258824 567
568struct _HttpStateData {
569 StoreEntry *entry;
570 request_t *request;
571 char *reply_hdr;
572 int reply_hdr_state;
1294c0fc 573 peer *peer; /* peer request made to */
a8258824 574 int eof; /* reached end-of-object? */
575 request_t *orig_request;
1294c0fc 576 int fd;
603a02fd 577 int flags;
a8258824 578};
579
580struct _icpUdpData {
581 struct sockaddr_in address;
582 void *msg;
583 size_t len;
584 icpUdpData *next;
585#ifndef LESS_TIMING
586 struct timeval start;
587#endif
588 log_type logcode;
589 protocol_t proto;
590};
591
592struct _icp_ping_data {
593 struct timeval start;
594 struct timeval stop;
595 int n_sent;
596 int n_recv;
597 int n_replies_expected;
598 int timeout;
599 int w_rtt;
b3264694 600 int p_rtt;
a8258824 601};
602
603struct _HierarchyLogEntry {
604 hier_code code;
605 char host[SQUIDHOSTNAMELEN];
ee1679df 606 icp_ping_data icp;
a8258824 607};
608
609struct _AccessLogEntry {
610 const char *url;
611 struct {
612 method_t method;
613 int code;
614 const char *content_type;
615 } http;
616 struct {
617 icp_opcode opcode;
618 } icp;
619 struct {
620 struct in_addr caddr;
621 size_t size;
622 log_type code;
623 int msec;
624 const char *ident;
625 } cache;
626 struct _HierarchyLogEntry hier;
627 struct {
628 char *request;
629 char *reply;
630 } headers;
631 struct {
632 const char *method_str;
633 } private;
634};
635
636struct _clientHttpRequest {
637 ConnStateData *conn;
638 request_t *request; /* Parsed URL ... */
23d92c64 639 char *uri;
640 char *log_uri;
a8258824 641 struct {
642 char *buf;
78f1250a 643 off_t offset;
644 size_t size;
a8258824 645 } out;
646 size_t req_sz;
647 StoreEntry *entry;
648 StoreEntry *old_entry;
649 log_type log_type;
9b312a19 650 http_status http_code;
a8258824 651 int accel;
4162ee3b 652 int internal; /* Set to true on /squid-internal/ request, to prevent looping */
a8258824 653 struct timeval start;
654 float http_ver;
655 int redirect_state;
656 aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */
657 clientHttpRequest *next;
658 struct _AccessLogEntry al;
659};
660
661struct _ConnStateData {
662 int fd;
663 struct {
664 char *buf;
78f1250a 665 off_t offset;
666 size_t size;
a8258824 667 } in;
668 clientHttpRequest *chr;
669 struct sockaddr_in peer;
670 struct sockaddr_in me;
671 struct in_addr log_addr;
672 struct {
673 int fd;
674 char ident[ICP_IDENT_SZ];
675 IDCB *callback;
676 int state;
425ad52e 677 void *callback_data;
a8258824 678 } ident;
679 CommWriteStateData *commWriteState;
680 int nrequests;
681 int persistent;
da2b3a17 682 struct {
683 int n;
684 time_t until;
685 } defer;
a8258824 686};
687
2ac237e2 688struct _dlink_node {
689 void *data;
690 dlink_node *prev;
691 dlink_node *next;
692};
693
694struct _dlink_list {
695 dlink_node *head;
696 dlink_node *tail;
697};
698
a8258824 699struct _ipcache_addrs {
6d1c0d53 700 struct in_addr *in_addrs;
701 unsigned char *bad_mask;
a8258824 702 unsigned char count;
703 unsigned char cur;
22c653cd 704 unsigned char badcount;
a8258824 705};
706
59c4d35b 707struct _ip_pending {
708 IPH *handler;
709 void *handlerData;
710 ip_pending *next;
711};
712
a8258824 713struct _ipcache_entry {
714 /* first two items must be equivalent to hash_link in hash.h */
715 char *name;
716 struct _ipcache_entry *next;
717 time_t lastref;
718 time_t expires;
719 ipcache_addrs addrs;
59c4d35b 720 ip_pending *pending_head;
a8258824 721 char *error_message;
2ac237e2 722 dlink_node lru;
723 u_char locks;
a8258824 724 ipcache_status_t status:3;
725};
726
59c4d35b 727struct _fqdn_pending {
728 FQDNH *handler;
729 void *handlerData;
730 fqdn_pending *next;
731};
732
1df370e3 733struct _fqdncache_entry {
734 /* first two items must be equivalent to hash_link in hash.h */
735 char *name;
736 struct _fqdncache_entry *next;
737 time_t lastref;
738 time_t expires;
739 unsigned char name_count;
740 char *names[FQDN_MAX_NAMES + 1];
59c4d35b 741 fqdn_pending *pending_head;
1df370e3 742 char *error_message;
743 dlink_node lru;
744 unsigned char locks;
745 fqdncache_status_t status:3;
746};
747
a8258824 748struct _domain_ping {
749 char *domain;
750 int do_ping; /* boolean */
751 struct _domain_ping *next;
752};
753
754struct _domain_type {
755 char *domain;
756 peer_t type;
757 struct _domain_type *next;
758};
759
760struct _peer {
761 char *host;
762 peer_t type;
763 struct sockaddr_in in_addr;
764 struct {
765 int pings_sent;
766 int pings_acked;
a8258824 767 int fetches;
768 int rtt;
27cd7235 769 int counts[ICP_END];
a8258824 770 int ignored_replies;
1294c0fc 771 int n_keepalives_sent;
772 int n_keepalives_recv;
dc835977 773 time_t last_query;
774 time_t last_reply;
775 int logged_state; /* so we can print dead/revived msgs */
a8258824 776 } stats;
777 u_short icp_port;
ace287ee 778#if USE_HTCP
779 u_short htcp_port;
780#endif
a8258824 781 u_short http_port;
782 int icp_version;
783 struct _domain_ping *pinglist;
784 struct _domain_type *typelist;
785 struct _acl_list *acls;
786 int options;
787 int weight;
788 struct {
789 double avg_n_members;
790 int n_times_counted;
791 int n_replies_expected;
792 int ttl;
9fb13bb6 793 u_num32 reqnum;
a8258824 794 int flags;
795 } mcast;
796 int tcp_up; /* 0 if a connect() fails */
797 time_t last_fail_time;
798 struct in_addr addresses[10];
799 int n_addresses;
800 int rr_count;
801 struct _peer *next;
802 int ip_lookup_pending;
88738790 803 int ck_conn_event_pend;
a8258824 804 int test_fd;
805};
806
807struct _net_db_name {
808 char *name;
74fbf3c9 809 net_db_name *htbl_next;
810 net_db_name *next;
811 netdbEntry *net_db_entry;
a8258824 812};
813
814struct _net_db_peer {
815 char *peername;
816 double hops;
817 double rtt;
818 time_t expires;
819};
820
821struct _netdbEntry {
822 char *key;
74fbf3c9 823 netdbEntry *next;
a8258824 824 char network[16];
825 int pings_sent;
826 int pings_recv;
827 double hops;
828 double rtt;
829 time_t next_ping_time;
830 time_t last_use_time;
831 int link_count;
832 net_db_name *hosts;
833 net_db_peer *peers;
834 int n_peers_alloc;
835 int n_peers;
836};
837
838struct _ps_state {
839 request_t *request;
840 StoreEntry *entry;
841 int always_direct;
842 int never_direct;
843 PSC *callback;
844 PSC *fail_callback;
845 void *callback_data;
846 peer *first_parent_miss;
847 peer *closest_parent_miss;
a369131d 848 peer *single_parent;
a8258824 849 icp_ping_data icp;
850 aclCheck_t *acl_checklist;
851};
852
853struct _pingerEchoData {
854 struct in_addr to;
855 unsigned char opcode;
856 int psize;
857 char payload[8192];
858};
859
860struct _pingerReplyData {
861 struct in_addr from;
862 unsigned char opcode;
863 int rtt;
864 int hops;
865 int psize;
866 char payload[8192];
867};
868
869struct _icp_common_t {
870 unsigned char opcode; /* opcode */
871 unsigned char version; /* version number */
872 unsigned short length; /* total length (bytes) */
873 u_num32 reqnum; /* req number (req'd for UDP) */
874 u_num32 flags;
875 u_num32 pad;
a8258824 876 u_num32 shostid; /* sender host id */
877};
878
a8258824 879struct _iostats {
880 struct {
881 int reads;
882 int reads_deferred;
883 int read_hist[16];
884 int writes;
885 int write_hist[16];
886 } Http, Ftp, Gopher, Wais;
887};
888
1a3db59c 889/* auto-growing memory-resident buffer with printf interface */
890struct _MemBuf {
891 /* public, read-only */
892 char *buf;
2ac76861 893 mb_size_t size; /* used space, does not count 0-terminator */
1a3db59c 894
895 /* private, stay away; use interface function instead */
2ac76861 896 mb_size_t max_capacity; /* when grows: assert(new_capacity <= max_capacity) */
897 mb_size_t capacity; /* allocated space */
898 FREE *freefunc; /* what to use to free the buffer, NULL after memBufFreeFunc() is called */
1a3db59c 899};
900
adba4a64 901/* see Packer.c for description */
902struct _Packer {
903 /* protected, use interface functions instead */
904 append_f append;
905 vprintf_f vprintf;
2ac76861 906 void *real_handler; /* first parameter to real append and vprintf */
adba4a64 907};
908
1a3db59c 909
a8258824 910struct _mem_node {
911 char *data;
912 int len;
913 mem_node *next;
914};
915
916struct _mem_hdr {
917 mem_node *head;
918 mem_node *tail;
919 int origin_offset;
920};
921
a8258824 922/* keep track each client receiving data from that particular StoreEntry */
923struct _store_client {
43329771 924 int type;
a8258824 925 off_t copy_offset;
926 off_t seen_offset;
927 size_t copy_size;
928 char *copy_buf;
929 STCB *callback;
930 void *callback_data;
07304bf9 931 StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
79d39a72 932 int swapin_fd;
6cf028ab 933 int disk_op_in_progress;
43329771 934 struct _store_client *next;
a8258824 935};
936
1a3db59c 937
a8258824 938/* This structure can be freed while object is purged out from memory */
939struct _MemObject {
2ac237e2 940 method_t method;
9fb13bb6 941 char *url;
a8258824 942 mem_hdr *data;
8350fe9b 943 off_t inmem_hi;
944 off_t inmem_lo;
a8258824 945 struct _store_client *clients;
946 int nclients;
8350fe9b 947 struct {
e3ef2b09 948 off_t queue_offset; /* relative to in-mem data */
949 off_t done_offset; /* relative to swap file with meta headers! */
8350fe9b 950 int fd;
25354045 951 void *ctrl;
8350fe9b 952 } swapout;
cb69b4c7 953 HttpReply *reply;
a8258824 954 request_t *request;
955 struct timeval start_ping;
956 IRCB *icp_reply_callback;
957 void *ircb_data;
958 int fd; /* FD of client creating this entry */
959 struct {
960 STABH *callback;
961 void *data;
962 } abort;
88738790 963 char *log_url;
b93bcace 964 dlink_node lru;
9fb13bb6 965 u_num32 reqnum;
07304bf9 966 ssize_t object_sz;
e3ef2b09 967 size_t swap_hdr_sz;
a8258824 968};
969
a8258824 970struct _StoreEntry {
971 /* first two items must be same as hash_link in hash.h */
9fb13bb6 972 const cache_key *key;
b93bcace 973 struct _StoreEntry *next;
a8258824 974 MemObject *mem_obj;
a8258824 975 time_t timestamp;
976 time_t lastref;
977 time_t expires;
978 time_t lastmod;
07304bf9 979 size_t swap_file_sz;
a21fbb54 980 u_short refcount;
981 u_short flag;
982
a8258824 983 int swap_file_number;
b93bcace 984 dlink_node lru;
2ac237e2 985 u_char lock_count; /* Assume < 256! */
a8258824 986 mem_status_t mem_status:3;
987 ping_status_t ping_status:3;
988 store_status_t store_status:3;
989 swap_status_t swap_status:3;
a8258824 990};
991
992struct _SwapDir {
993 char *path;
994 int l1;
995 int l2;
996 int cur_size;
997 int max_size;
998 int read_only;
999 int suggest;
1000 fileMap *map;
1001 int swaplog_fd;
1002};
1003
1004struct _request_t {
1005 method_t method;
1006 protocol_t protocol;
1007 char login[MAX_LOGIN_SZ];
1008 char host[SQUIDHOSTNAMELEN + 1];
1009 u_short port;
02922e76 1010 String urlpath;
a8258824 1011 int link_count; /* free when zero */
1012 int flags;
d8b249ef 1013 HttpHdrCc *cache_control; /* not used yet */
a8258824 1014 time_t max_age;
1015 float http_ver;
1016 time_t ims;
1017 int imslen;
1018 int max_forwards;
1019 struct in_addr client_addr;
1020 char *headers;
1021 size_t headers_sz;
1022 char *body;
1023 size_t body_sz;
1024 struct _HierarchyLogEntry hier;
88aad2e5 1025 err_type err_type;
a8258824 1026};
1027
1028struct _cachemgr_passwd {
1029 char *passwd;
22f3fd98 1030 wordlist *actions;
a8258824 1031 struct _cachemgr_passwd *next;
1032};
1033
1034struct _refresh_t {
1035 char *pattern;
1036 regex_t compiled_pattern;
1037 time_t min;
1038 int pct;
1039 time_t max;
1040 struct _refresh_t *next;
1041};
1042
1043struct _CommWriteStateData {
1044 char *buf;
1045 size_t size;
1046 off_t offset;
1047 CWCB *handler;
1048 void *handler_data;
74fbf3c9 1049 FREE *free_func;
a8258824 1050};
9b312a19 1051
1052struct _ErrorState {
1053 err_type type;
02922e76 1054 int page_id;
9b312a19 1055 http_status http_status;
1056 request_t *request;
1057 char *url;
c45ed9ad 1058 int xerrno;
9b312a19 1059 char *host;
1060 u_short port;
1061 char *dnsserver_msg;
1062 time_t ttl;
1063 struct in_addr src_addr;
1064 char *redirect_url;
1065 ERCB *callback;
1066 void *callback_data;
bb0929d8 1067 int flags;
b9916917 1068 struct {
1069 char *request;
1070 char *reply;
1071 } ftp;
e144eae4 1072 char *request_hdrs;
9b312a19 1073};
f2908497 1074
12cf1be2 1075/*
1076 * "very generic" histogram;
1077 * see important comments on hbase_f restrictions in StatHist.c
1078 */
1079struct _StatHist {
1080 int *bins;
1081 int capacity;
e9a13293 1082 double min;
1083 double max;
1084 double scale;
2ac76861 1085 hbase_f val_in; /* e.g., log() for log-based histogram */
1086 hbase_f val_out; /* e.g., exp() for log based histogram */
7ae52c25 1087};
1088
12cf1be2 1089/*
1090 * if you add a field to StatCounters,
1d803566 1091 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
12cf1be2 1092 */
f2908497 1093struct _StatCounters {
1094 struct {
1095 int requests;
1096 int hits;
1097 int errors;
a7c05555 1098 kb_t kbytes_in;
1099 kb_t kbytes_out;
1100 kb_t hit_kbytes_out;
12cf1be2 1101 StatHist miss_svc_time;
1102 StatHist nm_svc_time;
1103 StatHist hit_svc_time;
1104 StatHist all_svc_time;
f2908497 1105 } client_http;
7ae52c25 1106 struct {
a0f32775 1107 struct {
1108 int requests;
1109 int errors;
1110 kb_t kbytes_in;
1111 kb_t kbytes_out;
399e85ea 1112 } all , http, ftp, other;
7ae52c25 1113 } server;
f2908497 1114 struct {
1115 int pkts_sent;
1116 int pkts_recv;
a7c05555 1117 int hits_sent;
1118 int hits_recv;
1119 kb_t kbytes_sent;
1120 kb_t kbytes_recv;
12cf1be2 1121 StatHist query_svc_time;
1122 StatHist reply_svc_time;
f2908497 1123 } icp;
1124 struct {
1125 int requests;
1126 } unlink;
9973e9fe 1127 struct {
12cf1be2 1128 StatHist svc_time;
9973e9fe 1129 } dns;
f2908497 1130 int page_faults;
1131 int select_loops;
1132 double cputime;
d5649d9f 1133 struct timeval timestamp;
f2908497 1134};
69c01cd7 1135
1136struct _tlv {
5830cdb3 1137 char type;
1138 int length;
1139 void *value;
1140 struct _tlv *next;
1141};
1142
07304bf9 1143struct _storeSwapLogData {
5830cdb3 1144 char op;
1145 int swap_file_number;
1146 time_t timestamp;
1147 time_t lastref;
1148 time_t expires;
1149 time_t lastmod;
07304bf9 1150 size_t swap_file_sz;
5830cdb3 1151 u_short refcount;
1152 u_short flags;
7363fc17 1153 unsigned char key[MD5_DIGEST_CHARS];
69c01cd7 1154};
59c4d35b 1155
02922e76 1156/* object to track per-action memory usage (e.g. #idle objects) */
1157struct _MemMeter {
1158 size_t level; /* current level (count or volume) */
d8b249ef 1159 size_t hwater_level; /* high water mark */
1160 time_t hwater_stamp; /* timestamp of last high water mark change */
02922e76 1161};
1162
1163/* object to track per-pool memory usage (alloc = inuse+idle) */
1164struct _MemPoolMeter {
1165 MemMeter alloc;
1166 MemMeter inuse;
1167 MemMeter idle;
1168 gb_t saved;
1169};
1170
1171/* a pool is a [growing] space for objects of the same size */
1172struct _MemPool {
1173 const char *label;
1174 size_t obj_size;
1175 Stack pstack; /* stack for free pointers */
1176 MemPoolMeter meter;
1177};
1178
59c4d35b 1179struct _ClientInfo {
1180 char *key;
1181 struct client_info *next;
1182 struct in_addr addr;
1183 struct {
1184 int result_hist[LOG_TYPE_MAX];
1185 int n_requests;
1186 } Http, Icp;
1187 struct {
1188 time_t time;
1189 int n_req;
1190 int n_denied;
1191 } cutoff;
1192};