]> git.ipfire.org Git - thirdparty/squid.git/blame - src/structs.h
fixed debug statement
[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;
484 time_t 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
4f087419 508/* a storage for an entry of one of possible types (for lower level routines) */
509union _field_store {
510 int v_int;
511 time_t v_time;
4f7e9dbb 512 String v_str;
de336bbe 513 const String *v_cpstr;
7faf2bdb 514 HttpHdrCc *v_pcc;
b5107edb 515 HttpHdrRange *v_prange;
d76fcfa7 516 HttpHdrContRange *v_pcont_range;
4f087419 517};
518
7faf2bdb 519/* per field statistics */
520struct _HttpHeaderFieldStat {
399e85ea 521 int aliveCount; /* created but not destroyed (count) */
522 int parsCount; /* #parsing attempts */
523 int errCount; /* #pasring errors */
524 int repCount; /* #repetitons */
7faf2bdb 525};
526
7faf2bdb 527/* constant attributes of http header fields */
de336bbe 528struct _HttpHeaderFieldAttrs {
7faf2bdb 529 const char *name;
530 http_hdr_type id;
531 field_type type;
de336bbe 532};
533
534/* compiled version HttpHeaderFieldAttrs plus stats */
535struct _HttpHeaderFieldInfo {
536 http_hdr_type id;
537 String name;
538 field_type type;
7faf2bdb 539 HttpHeaderFieldStat stat;
540};
541
4f087419 542struct _HttpHeader {
543 /* public, read only */
2ac76861 544 int emask; /* bits set for present entries */
4f087419 545
546 /* protected, do not use these, use interface functions instead */
2ac76861 547 int capacity; /* max #entries before we have to grow */
548 int ucount; /* #entries used, including holes */
4f087419 549 HttpHeaderEntry *entries;
550};
551
552
adba4a64 553struct _HttpReply {
554 /* unsupported, writable, may disappear/change in the future */
2ac76861 555 int hdr_sz; /* sums _stored_ status-line, headers, and <CRLF> */
adba4a64 556
557 /* public, readable */
2ac76861 558 HttpMsgParseState pstate; /* the current parsing state */
4f087419 559
de336bbe 560 /* public, writable, but use httpReply* interfaces when possible */
adba4a64 561 HttpStatusLine sline;
562 HttpHeader hdr;
2ac76861 563 HttpBody body; /* used for small constant memory-resident text bodies only */
adba4a64 564};
cb69b4c7 565
a8258824 566
567struct _HttpStateData {
568 StoreEntry *entry;
569 request_t *request;
570 char *reply_hdr;
571 int reply_hdr_state;
1294c0fc 572 peer *peer; /* peer request made to */
a8258824 573 int eof; /* reached end-of-object? */
574 request_t *orig_request;
1294c0fc 575 int fd;
603a02fd 576 int flags;
a8258824 577};
578
579struct _icpUdpData {
580 struct sockaddr_in address;
581 void *msg;
582 size_t len;
583 icpUdpData *next;
584#ifndef LESS_TIMING
585 struct timeval start;
586#endif
587 log_type logcode;
588 protocol_t proto;
589};
590
591struct _icp_ping_data {
592 struct timeval start;
593 struct timeval stop;
594 int n_sent;
595 int n_recv;
596 int n_replies_expected;
597 int timeout;
598 int w_rtt;
b3264694 599 int p_rtt;
a8258824 600};
601
602struct _HierarchyLogEntry {
603 hier_code code;
604 char host[SQUIDHOSTNAMELEN];
ee1679df 605 icp_ping_data icp;
a8258824 606};
607
608struct _AccessLogEntry {
609 const char *url;
610 struct {
611 method_t method;
612 int code;
613 const char *content_type;
614 } http;
615 struct {
616 icp_opcode opcode;
617 } icp;
618 struct {
619 struct in_addr caddr;
620 size_t size;
621 log_type code;
622 int msec;
623 const char *ident;
624 } cache;
625 struct _HierarchyLogEntry hier;
626 struct {
627 char *request;
628 char *reply;
629 } headers;
630 struct {
631 const char *method_str;
632 } private;
633};
634
635struct _clientHttpRequest {
636 ConnStateData *conn;
637 request_t *request; /* Parsed URL ... */
23d92c64 638 char *uri;
639 char *log_uri;
a8258824 640 struct {
641 char *buf;
78f1250a 642 off_t offset;
643 size_t size;
a8258824 644 } out;
645 size_t req_sz;
646 StoreEntry *entry;
647 StoreEntry *old_entry;
648 log_type log_type;
9b312a19 649 http_status http_code;
a8258824 650 int accel;
4162ee3b 651 int internal; /* Set to true on /squid-internal/ request, to prevent looping */
a8258824 652 struct timeval start;
653 float http_ver;
654 int redirect_state;
655 aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */
656 clientHttpRequest *next;
657 struct _AccessLogEntry al;
658};
659
660struct _ConnStateData {
661 int fd;
662 struct {
663 char *buf;
78f1250a 664 off_t offset;
665 size_t size;
a8258824 666 } in;
667 clientHttpRequest *chr;
668 struct sockaddr_in peer;
669 struct sockaddr_in me;
670 struct in_addr log_addr;
671 struct {
672 int fd;
673 char ident[ICP_IDENT_SZ];
674 IDCB *callback;
675 int state;
425ad52e 676 void *callback_data;
a8258824 677 } ident;
678 CommWriteStateData *commWriteState;
679 int nrequests;
680 int persistent;
da2b3a17 681 struct {
682 int n;
683 time_t until;
684 } defer;
a8258824 685};
686
2ac237e2 687struct _dlink_node {
688 void *data;
689 dlink_node *prev;
690 dlink_node *next;
691};
692
693struct _dlink_list {
694 dlink_node *head;
695 dlink_node *tail;
696};
697
a8258824 698struct _ipcache_addrs {
6d1c0d53 699 struct in_addr *in_addrs;
700 unsigned char *bad_mask;
a8258824 701 unsigned char count;
702 unsigned char cur;
22c653cd 703 unsigned char badcount;
a8258824 704};
705
59c4d35b 706struct _ip_pending {
707 IPH *handler;
708 void *handlerData;
709 ip_pending *next;
710};
711
a8258824 712struct _ipcache_entry {
713 /* first two items must be equivalent to hash_link in hash.h */
714 char *name;
715 struct _ipcache_entry *next;
716 time_t lastref;
717 time_t expires;
718 ipcache_addrs addrs;
59c4d35b 719 ip_pending *pending_head;
a8258824 720 char *error_message;
2ac237e2 721 dlink_node lru;
722 u_char locks;
a8258824 723 ipcache_status_t status:3;
724};
725
59c4d35b 726struct _fqdn_pending {
727 FQDNH *handler;
728 void *handlerData;
729 fqdn_pending *next;
730};
731
1df370e3 732struct _fqdncache_entry {
733 /* first two items must be equivalent to hash_link in hash.h */
734 char *name;
735 struct _fqdncache_entry *next;
736 time_t lastref;
737 time_t expires;
738 unsigned char name_count;
739 char *names[FQDN_MAX_NAMES + 1];
59c4d35b 740 fqdn_pending *pending_head;
1df370e3 741 char *error_message;
742 dlink_node lru;
743 unsigned char locks;
744 fqdncache_status_t status:3;
745};
746
a8258824 747struct _domain_ping {
748 char *domain;
749 int do_ping; /* boolean */
750 struct _domain_ping *next;
751};
752
753struct _domain_type {
754 char *domain;
755 peer_t type;
756 struct _domain_type *next;
757};
758
759struct _peer {
760 char *host;
761 peer_t type;
762 struct sockaddr_in in_addr;
763 struct {
764 int pings_sent;
765 int pings_acked;
a8258824 766 int fetches;
767 int rtt;
27cd7235 768 int counts[ICP_END];
a8258824 769 int ignored_replies;
1294c0fc 770 int n_keepalives_sent;
771 int n_keepalives_recv;
dc835977 772 time_t last_query;
773 time_t last_reply;
774 int logged_state; /* so we can print dead/revived msgs */
a8258824 775 } stats;
776 u_short icp_port;
ace287ee 777#if USE_HTCP
778 u_short htcp_port;
779#endif
a8258824 780 u_short http_port;
781 int icp_version;
782 struct _domain_ping *pinglist;
783 struct _domain_type *typelist;
784 struct _acl_list *acls;
785 int options;
786 int weight;
787 struct {
788 double avg_n_members;
789 int n_times_counted;
790 int n_replies_expected;
791 int ttl;
9fb13bb6 792 u_num32 reqnum;
a8258824 793 int flags;
794 } mcast;
795 int tcp_up; /* 0 if a connect() fails */
796 time_t last_fail_time;
797 struct in_addr addresses[10];
798 int n_addresses;
799 int rr_count;
800 struct _peer *next;
801 int ip_lookup_pending;
88738790 802 int ck_conn_event_pend;
a8258824 803 int test_fd;
804};
805
806struct _net_db_name {
807 char *name;
74fbf3c9 808 net_db_name *htbl_next;
809 net_db_name *next;
810 netdbEntry *net_db_entry;
a8258824 811};
812
813struct _net_db_peer {
814 char *peername;
815 double hops;
816 double rtt;
817 time_t expires;
818};
819
820struct _netdbEntry {
821 char *key;
74fbf3c9 822 netdbEntry *next;
a8258824 823 char network[16];
824 int pings_sent;
825 int pings_recv;
826 double hops;
827 double rtt;
828 time_t next_ping_time;
829 time_t last_use_time;
830 int link_count;
831 net_db_name *hosts;
832 net_db_peer *peers;
833 int n_peers_alloc;
834 int n_peers;
835};
836
837struct _ps_state {
838 request_t *request;
839 StoreEntry *entry;
840 int always_direct;
841 int never_direct;
842 PSC *callback;
843 PSC *fail_callback;
844 void *callback_data;
845 peer *first_parent_miss;
846 peer *closest_parent_miss;
a369131d 847 peer *single_parent;
a8258824 848 icp_ping_data icp;
849 aclCheck_t *acl_checklist;
850};
851
852struct _pingerEchoData {
853 struct in_addr to;
854 unsigned char opcode;
855 int psize;
856 char payload[8192];
857};
858
859struct _pingerReplyData {
860 struct in_addr from;
861 unsigned char opcode;
862 int rtt;
863 int hops;
864 int psize;
865 char payload[8192];
866};
867
868struct _icp_common_t {
869 unsigned char opcode; /* opcode */
870 unsigned char version; /* version number */
871 unsigned short length; /* total length (bytes) */
872 u_num32 reqnum; /* req number (req'd for UDP) */
873 u_num32 flags;
874 u_num32 pad;
a8258824 875 u_num32 shostid; /* sender host id */
876};
877
a8258824 878struct _iostats {
879 struct {
880 int reads;
881 int reads_deferred;
882 int read_hist[16];
883 int writes;
884 int write_hist[16];
885 } Http, Ftp, Gopher, Wais;
886};
887
1a3db59c 888/* auto-growing memory-resident buffer with printf interface */
889struct _MemBuf {
890 /* public, read-only */
891 char *buf;
2ac76861 892 mb_size_t size; /* used space, does not count 0-terminator */
1a3db59c 893
894 /* private, stay away; use interface function instead */
2ac76861 895 mb_size_t max_capacity; /* when grows: assert(new_capacity <= max_capacity) */
896 mb_size_t capacity; /* allocated space */
897 FREE *freefunc; /* what to use to free the buffer, NULL after memBufFreeFunc() is called */
1a3db59c 898};
899
adba4a64 900/* see Packer.c for description */
901struct _Packer {
902 /* protected, use interface functions instead */
903 append_f append;
904 vprintf_f vprintf;
2ac76861 905 void *real_handler; /* first parameter to real append and vprintf */
adba4a64 906};
907
1a3db59c 908
a8258824 909struct _mem_node {
910 char *data;
911 int len;
912 mem_node *next;
913};
914
915struct _mem_hdr {
916 mem_node *head;
917 mem_node *tail;
918 int origin_offset;
919};
920
a8258824 921/* keep track each client receiving data from that particular StoreEntry */
922struct _store_client {
43329771 923 int type;
a8258824 924 off_t copy_offset;
925 off_t seen_offset;
926 size_t copy_size;
927 char *copy_buf;
928 STCB *callback;
929 void *callback_data;
07304bf9 930 StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
79d39a72 931 int swapin_fd;
6cf028ab 932 int disk_op_in_progress;
43329771 933 struct _store_client *next;
a8258824 934};
935
1a3db59c 936
a8258824 937/* This structure can be freed while object is purged out from memory */
938struct _MemObject {
2ac237e2 939 method_t method;
9fb13bb6 940 char *url;
a8258824 941 mem_hdr *data;
8350fe9b 942 off_t inmem_hi;
943 off_t inmem_lo;
a8258824 944 struct _store_client *clients;
945 int nclients;
8350fe9b 946 struct {
e3ef2b09 947 off_t queue_offset; /* relative to in-mem data */
948 off_t done_offset; /* relative to swap file with meta headers! */
8350fe9b 949 int fd;
25354045 950 void *ctrl;
8350fe9b 951 } swapout;
cb69b4c7 952 HttpReply *reply;
a8258824 953 request_t *request;
954 struct timeval start_ping;
955 IRCB *icp_reply_callback;
956 void *ircb_data;
957 int fd; /* FD of client creating this entry */
958 struct {
959 STABH *callback;
960 void *data;
961 } abort;
88738790 962 char *log_url;
b93bcace 963 dlink_node lru;
9fb13bb6 964 u_num32 reqnum;
07304bf9 965 ssize_t object_sz;
e3ef2b09 966 size_t swap_hdr_sz;
a8258824 967};
968
a8258824 969struct _StoreEntry {
970 /* first two items must be same as hash_link in hash.h */
9fb13bb6 971 const cache_key *key;
b93bcace 972 struct _StoreEntry *next;
a8258824 973 MemObject *mem_obj;
a8258824 974 time_t timestamp;
975 time_t lastref;
976 time_t expires;
977 time_t lastmod;
07304bf9 978 size_t swap_file_sz;
a21fbb54 979 u_short refcount;
980 u_short flag;
981
a8258824 982 int swap_file_number;
b93bcace 983 dlink_node lru;
2ac237e2 984 u_char lock_count; /* Assume < 256! */
a8258824 985 mem_status_t mem_status:3;
986 ping_status_t ping_status:3;
987 store_status_t store_status:3;
988 swap_status_t swap_status:3;
a8258824 989};
990
991struct _SwapDir {
992 char *path;
993 int l1;
994 int l2;
995 int cur_size;
996 int max_size;
997 int read_only;
998 int suggest;
999 fileMap *map;
1000 int swaplog_fd;
1001};
1002
1003struct _request_t {
1004 method_t method;
1005 protocol_t protocol;
1006 char login[MAX_LOGIN_SZ];
1007 char host[SQUIDHOSTNAMELEN + 1];
1008 u_short port;
02922e76 1009 String urlpath;
a8258824 1010 int link_count; /* free when zero */
1011 int flags;
1012 time_t max_age;
1013 float http_ver;
1014 time_t ims;
1015 int imslen;
1016 int max_forwards;
1017 struct in_addr client_addr;
1018 char *headers;
1019 size_t headers_sz;
1020 char *body;
1021 size_t body_sz;
1022 struct _HierarchyLogEntry hier;
88aad2e5 1023 err_type err_type;
a8258824 1024};
1025
1026struct _cachemgr_passwd {
1027 char *passwd;
22f3fd98 1028 wordlist *actions;
a8258824 1029 struct _cachemgr_passwd *next;
1030};
1031
1032struct _refresh_t {
1033 char *pattern;
1034 regex_t compiled_pattern;
1035 time_t min;
1036 int pct;
1037 time_t max;
1038 struct _refresh_t *next;
1039};
1040
1041struct _CommWriteStateData {
1042 char *buf;
1043 size_t size;
1044 off_t offset;
1045 CWCB *handler;
1046 void *handler_data;
74fbf3c9 1047 FREE *free_func;
a8258824 1048};
9b312a19 1049
1050struct _ErrorState {
1051 err_type type;
02922e76 1052 int page_id;
9b312a19 1053 http_status http_status;
1054 request_t *request;
1055 char *url;
c45ed9ad 1056 int xerrno;
9b312a19 1057 char *host;
1058 u_short port;
1059 char *dnsserver_msg;
1060 time_t ttl;
1061 struct in_addr src_addr;
1062 char *redirect_url;
1063 ERCB *callback;
1064 void *callback_data;
bb0929d8 1065 int flags;
b9916917 1066 struct {
1067 char *request;
1068 char *reply;
1069 } ftp;
e144eae4 1070 char *request_hdrs;
9b312a19 1071};
f2908497 1072
12cf1be2 1073/*
1074 * "very generic" histogram;
1075 * see important comments on hbase_f restrictions in StatHist.c
1076 */
1077struct _StatHist {
1078 int *bins;
1079 int capacity;
e9a13293 1080 double min;
1081 double max;
1082 double scale;
2ac76861 1083 hbase_f val_in; /* e.g., log() for log-based histogram */
1084 hbase_f val_out; /* e.g., exp() for log based histogram */
7ae52c25 1085};
1086
12cf1be2 1087/*
1088 * if you add a field to StatCounters,
1d803566 1089 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
12cf1be2 1090 */
f2908497 1091struct _StatCounters {
1092 struct {
1093 int requests;
1094 int hits;
1095 int errors;
a7c05555 1096 kb_t kbytes_in;
1097 kb_t kbytes_out;
1098 kb_t hit_kbytes_out;
12cf1be2 1099 StatHist miss_svc_time;
1100 StatHist nm_svc_time;
1101 StatHist hit_svc_time;
1102 StatHist all_svc_time;
f2908497 1103 } client_http;
7ae52c25 1104 struct {
a0f32775 1105 struct {
1106 int requests;
1107 int errors;
1108 kb_t kbytes_in;
1109 kb_t kbytes_out;
399e85ea 1110 } all , http, ftp, other;
7ae52c25 1111 } server;
f2908497 1112 struct {
1113 int pkts_sent;
1114 int pkts_recv;
a7c05555 1115 int hits_sent;
1116 int hits_recv;
1117 kb_t kbytes_sent;
1118 kb_t kbytes_recv;
12cf1be2 1119 StatHist query_svc_time;
1120 StatHist reply_svc_time;
f2908497 1121 } icp;
1122 struct {
1123 int requests;
1124 } unlink;
9973e9fe 1125 struct {
12cf1be2 1126 StatHist svc_time;
9973e9fe 1127 } dns;
f2908497 1128 int page_faults;
1129 int select_loops;
1130 double cputime;
d5649d9f 1131 struct timeval timestamp;
f2908497 1132};
69c01cd7 1133
1134struct _tlv {
5830cdb3 1135 char type;
1136 int length;
1137 void *value;
1138 struct _tlv *next;
1139};
1140
07304bf9 1141struct _storeSwapLogData {
5830cdb3 1142 char op;
1143 int swap_file_number;
1144 time_t timestamp;
1145 time_t lastref;
1146 time_t expires;
1147 time_t lastmod;
07304bf9 1148 size_t swap_file_sz;
5830cdb3 1149 u_short refcount;
1150 u_short flags;
7363fc17 1151 unsigned char key[MD5_DIGEST_CHARS];
69c01cd7 1152};
59c4d35b 1153
02922e76 1154/* object to track per-action memory usage (e.g. #idle objects) */
1155struct _MemMeter {
1156 size_t level; /* current level (count or volume) */
1157 size_t hwater; /* high water mark */
1158};
1159
1160/* object to track per-pool memory usage (alloc = inuse+idle) */
1161struct _MemPoolMeter {
1162 MemMeter alloc;
1163 MemMeter inuse;
1164 MemMeter idle;
1165 gb_t saved;
1166};
1167
1168/* a pool is a [growing] space for objects of the same size */
1169struct _MemPool {
1170 const char *label;
1171 size_t obj_size;
1172 Stack pstack; /* stack for free pointers */
1173 MemPoolMeter meter;
1174};
1175
59c4d35b 1176struct _ClientInfo {
1177 char *key;
1178 struct client_info *next;
1179 struct in_addr addr;
1180 struct {
1181 int result_hist[LOG_TYPE_MAX];
1182 int n_requests;
1183 } Http, Icp;
1184 struct {
1185 time_t time;
1186 int n_req;
1187 int n_denied;
1188 } cutoff;
1189};