]> git.ipfire.org Git - thirdparty/squid.git/blob - src/structs.h
2ac1adf719710d52c608d32923b3f1c74db724b0
[thirdparty/squid.git] / src / structs.h
1
2 /*
3 * $Id: structs.h,v 1.493 2004/10/18 12:20:10 hno Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see 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
34 #ifndef SQUID_STRUCTS_H
35 #define SQUID_STRUCTS_H
36
37 #include "config.h"
38
39 class dlink_node
40 {
41
42 public:
43 dlink_node() : data(NULL), prev(NULL), next(NULL){}
44
45 void *data;
46 dlink_node *prev;
47 dlink_node *next;
48 };
49
50 struct _dlink_list
51 {
52 dlink_node *head;
53 dlink_node *tail;
54 };
55
56 struct _acl_name_list
57 {
58 char name[ACL_NAME_SZ];
59 acl_name_list *next;
60 };
61
62 struct _acl_proxy_auth_match_cache
63 {
64 dlink_node link;
65 int matchrv;
66 void *acl_data;
67 };
68
69 struct _acl_deny_info_list
70 {
71 err_type err_page_id;
72 char *err_page_name;
73 acl_name_list *acl_list;
74 acl_deny_info_list *next;
75 };
76
77
78 class acl_access;
79
80 struct _header_mangler
81 {
82 acl_access *access_list;
83 char *replacement;
84 };
85
86 struct _body_size
87 {
88 dlink_node node;
89 acl_access *access_list;
90 size_t maxsize;
91 };
92
93
94 #if SQUID_SNMP
95
96 struct _snmp_request_t
97 {
98 u_char *buf;
99 u_char *outbuf;
100 int len;
101 int sock;
102 long reqid;
103 int outlen;
104
105 struct sockaddr_in from;
106
107 struct snmp_pdu *PDU;
108 ACLChecklist *acl_checklist;
109 u_char *community;
110 };
111
112 #endif
113
114
115 struct _acl_address
116 {
117 acl_address *next;
118 acl_list *aclList;
119
120 struct in_addr addr;
121 };
122
123 struct _acl_tos
124 {
125 acl_tos *next;
126 acl_list *aclList;
127 int tos;
128 };
129
130 struct _acl_size_t
131 {
132 acl_size_t *next;
133 acl_list *aclList;
134 size_t size;
135 };
136
137 struct _wordlist
138 {
139 char *key;
140 wordlist *next;
141 };
142
143 struct _ushortlist
144 {
145 u_short i;
146 ushortlist *next;
147 };
148
149 struct _relist
150 {
151 char *pattern;
152 regex_t regex;
153 relist *next;
154 };
155
156 struct _sockaddr_in_list
157 {
158
159 struct sockaddr_in s;
160 sockaddr_in_list *next;
161 };
162
163 struct _http_port_list
164 {
165 http_port_list *next;
166
167 struct sockaddr_in s;
168 char *protocol; /* protocol name */
169 char *name; /* visible name */
170 char *defaultsite; /* default web site */
171
172 unsigned int transparent:
173 1; /* transparent proxy */
174
175 unsigned int accel:
176 1; /* HTTP accelerator */
177
178 unsigned int vhost:
179 1; /* uses host header */
180
181 int vport; /* virtual port support, -1 for dynamic, >0 static*/
182 };
183
184
185 #if USE_SSL
186
187 struct _https_port_list
188 {
189 http_port_list http; /* must be first */
190 char *cert;
191 char *key;
192 int version;
193 char *cipher;
194 char *options;
195 char *clientca;
196 char *cafile;
197 char *capath;
198 char *dhfile;
199 char *sslflags;
200 SSL_CTX *sslContext;
201 };
202
203 #endif
204
205 #if DELAY_POOLS
206 #include "DelayConfig.h"
207 #endif
208
209 struct _RemovalPolicySettings
210 {
211 char *type;
212 wordlist *args;
213 };
214
215 class external_acl;
216
217 struct _SquidConfig
218 {
219
220 struct
221 {
222 size_t maxSize;
223 int highWaterMark;
224 int lowWaterMark;
225 }
226
227 Swap;
228 size_t memMaxSize;
229
230 struct
231 {
232 char *relayHost;
233 u_short relayPort;
234 peer *_peer;
235 }
236
237 Wais;
238
239 struct
240 {
241 size_t min;
242 int pct;
243 size_t max;
244 }
245
246 quickAbort;
247 size_t readAheadGap;
248 RemovalPolicySettings *replPolicy;
249 RemovalPolicySettings *memPolicy;
250 time_t negativeTtl;
251 time_t negativeDnsTtl;
252 time_t positiveDnsTtl;
253 time_t shutdownLifetime;
254 time_t backgroundPingRate;
255
256 struct
257 {
258 time_t read;
259 time_t lifetime;
260 time_t connect;
261 time_t forward;
262 time_t peer_connect;
263 time_t request;
264 time_t persistent_request;
265 time_t pconn;
266 time_t siteSelect;
267 time_t deadPeer;
268 int icp_query; /* msec */
269 int icp_query_max; /* msec */
270 int icp_query_min; /* msec */
271 int mcast_icp_query; /* msec */
272 #if USE_IDENT
273
274 time_t ident;
275 #endif
276 #if !USE_DNSSERVERS
277
278 time_t idns_retransmit;
279 time_t idns_query;
280 #endif
281
282 }
283
284 Timeout;
285 size_t maxRequestHeaderSize;
286 size_t maxRequestBodySize;
287 acl_size_t *ReplyBodySize;
288
289 struct
290 {
291 u_short icp;
292 #if USE_HTCP
293
294 u_short htcp;
295 #endif
296 #if SQUID_SNMP
297
298 u_short snmp;
299 #endif
300
301 }
302
303 Port;
304
305 struct
306 {
307 http_port_list *http;
308 #if USE_SSL
309
310 https_port_list *https;
311 #endif
312
313 }
314
315 Sockaddr;
316 #if SQUID_SNMP
317
318 struct
319 {
320 char *configFile;
321 char *agentInfo;
322 }
323
324 Snmp;
325 #endif
326 #if USE_WCCP
327
328 struct
329 {
330
331 struct in_addr router;
332
333 struct in_addr incoming;
334
335 struct in_addr outgoing;
336 int version;
337 }
338
339 Wccp;
340 #endif
341
342 char *as_whois_server;
343
344 struct
345 {
346 char *log;
347 char *store;
348 char *swap;
349 #if USE_USERAGENT_LOG
350
351 char *useragent;
352 #endif
353 #if USE_REFERER_LOG
354
355 char *referer;
356 #endif
357 #if WIP_FWD_LOG
358
359 char *forward;
360 #endif
361
362 logformat *logformats;
363
364 customlog *accesslogs;
365
366 int rotateNumber;
367 }
368
369 Log;
370 char *adminEmail;
371 char *effectiveUser;
372 char *effectiveGroup;
373
374 struct
375 {
376 #if USE_DNSSERVERS
377 char *dnsserver;
378 #endif
379
380 wordlist *redirect;
381 #if USE_ICMP
382
383 char *pinger;
384 #endif
385 #if USE_UNLINKD
386
387 char *unlinkd;
388 #endif
389
390 char *diskd;
391 #if USE_SSL
392
393 char *ssl_password;
394 #endif
395
396 }
397
398 Program;
399 #if USE_DNSSERVERS
400
401 int dnsChildren;
402 #endif
403
404 int redirectChildren;
405 int redirectConcurrency;
406 time_t authenticateGCInterval;
407 time_t authenticateTTL;
408 time_t authenticateIpTTL;
409
410 struct
411 {
412 #if ESI
413 char *surrogate_id;
414 #endif
415
416 }
417
418 Accel;
419 char *appendDomain;
420 size_t appendDomainLen;
421 char *debugOptions;
422 char *pidFilename;
423 char *mimeTablePathname;
424 char *etcHostsPath;
425 char *visibleHostname;
426 char *uniqueHostname;
427 wordlist *hostnameAliases;
428 char *errHtmlText;
429
430 struct
431 {
432 char *host;
433 char *file;
434 time_t period;
435 u_short port;
436 }
437
438 Announce;
439
440 struct
441 {
442
443 struct in_addr udp_incoming;
444
445 struct in_addr udp_outgoing;
446 #if SQUID_SNMP
447
448 struct in_addr snmp_incoming;
449
450 struct in_addr snmp_outgoing;
451 #endif
452
453 struct in_addr client_netmask;
454 }
455
456 Addrs;
457 size_t tcpRcvBufsz;
458 size_t udpMaxHitObjsz;
459 wordlist *hierarchy_stoplist;
460 wordlist *mcast_group_list;
461 wordlist *dns_testname_list;
462 wordlist *dns_nameservers;
463 peer *peers;
464 int npeers;
465
466 struct
467 {
468 int size;
469 int low;
470 int high;
471 }
472
473 ipcache;
474
475 struct
476 {
477 int size;
478 }
479
480 fqdncache;
481 int minDirectHops;
482 int minDirectRtt;
483 cachemgr_passwd *passwd_list;
484
485 struct
486 {
487 int objectsPerBucket;
488 size_t avgObjectSize;
489 size_t maxObjectSize;
490 size_t minObjectSize;
491 size_t maxInMemObjSize;
492 }
493
494 Store;
495
496 struct
497 {
498 int high;
499 int low;
500 time_t period;
501 }
502
503 Netdb;
504
505 struct
506 {
507 int log_udp;
508 #if USE_DNSSERVERS
509
510 int res_defnames;
511 #endif
512
513 int anonymizer;
514 int client_db;
515 int query_icmp;
516 int icp_hit_stale;
517 int buffered_logs;
518 #if ALLOW_SOURCE_PING
519
520 int source_ping;
521 #endif
522
523 int common_log;
524 int log_mime_hdrs;
525 int log_fqdn;
526 int announce;
527 int mem_pools;
528 int test_reachability;
529 int half_closed_clients;
530 #if HTTP_VIOLATIONS
531
532 int reload_into_ims;
533 #endif
534
535 int offline;
536 int redir_rewrites_host;
537 int prefer_direct;
538 int nonhierarchical_direct;
539 int strip_query_terms;
540 int redirector_bypass;
541 int ignore_unknown_nameservers;
542 int client_pconns;
543 int server_pconns;
544 #if USE_CACHE_DIGESTS
545
546 int digest_generation;
547 #endif
548
549 int log_ip_on_direct;
550 int ie_refresh;
551 int vary_ignore_expire;
552 int pipeline_prefetch;
553 #if ESI
554
555 int surrogate_is_remote;
556 #endif
557
558 int request_entities;
559 int balance_on_multiple_ip;
560 int check_hostnames;
561 int via;
562 int emailErrData;
563 }
564
565 onoff;
566
567 class ACL *aclList;
568
569 struct
570 {
571 acl_access *http;
572 acl_access *icp;
573 acl_access *miss;
574 acl_access *NeverDirect;
575 acl_access *AlwaysDirect;
576 acl_access *ASlists;
577 acl_access *noCache;
578 acl_access *log;
579 #if SQUID_SNMP
580
581 acl_access *snmp;
582 #endif
583
584 acl_access *brokenPosts;
585 #if USE_IDENT
586
587 acl_access *identLookup;
588 #endif
589
590 acl_access *redirector;
591 acl_access *reply;
592 acl_address *outgoing_address;
593 acl_tos *outgoing_tos;
594 }
595
596 accessList;
597 acl_deny_info_list *denyInfoList;
598 authConfig authConfiguration;
599
600 struct
601 {
602 size_t list_width;
603 int list_wrap;
604 char *anon_user;
605 int passive;
606 int sanitycheck;
607 int telnet;
608 }
609
610 Ftp;
611 refresh_t *Refresh;
612
613 struct _cacheSwap
614 {
615 SwapDir **swapDirs;
616 int n_allocated;
617 int n_configured;
618 }
619
620 cacheSwap;
621
622 struct
623 {
624 char *directory;
625 int use_short_names;
626 }
627
628 icons;
629 char *errorDirectory;
630
631 struct
632 {
633 int maxtries;
634 }
635
636 retry;
637
638 struct
639 {
640 size_t limit;
641 }
642
643 MemPools;
644 #if DELAY_POOLS
645
646 DelayConfig Delay;
647 #endif
648
649 struct
650 {
651 int icp_average;
652 int dns_average;
653 int http_average;
654 int icp_min_poll;
655 int dns_min_poll;
656 int http_min_poll;
657 }
658
659 comm_incoming;
660 int max_open_disk_fds;
661 int uri_whitespace;
662 size_t rangeOffsetLimit;
663 #if MULTICAST_MISS_STREAM
664
665 struct
666 {
667
668 struct in_addr addr;
669 int ttl;
670 unsigned short port;
671 char *encode_key;
672 }
673
674 mcast_miss;
675 #endif
676
677 header_mangler header_access[HDR_ENUM_END];
678 char *coredump_dir;
679 char *chroot_dir;
680 #if USE_CACHE_DIGESTS
681
682 struct
683 {
684 int bits_per_entry;
685 time_t rebuild_period;
686 time_t rewrite_period;
687 size_t swapout_chunk_size;
688 int rebuild_chunk_percentage;
689 }
690
691 digest;
692 #endif
693 #if USE_SSL
694
695 struct
696 {
697 int unclean_shutdown;
698 char *ssl_engine;
699 }
700
701 SSL;
702 #endif
703
704 wordlist *ext_methods;
705
706 struct
707 {
708 int high_rptm;
709 int high_pf;
710 size_t high_memory;
711 }
712
713 warnings;
714 char *store_dir_select_algorithm;
715 int sleep_after_fork; /* microseconds */
716 external_acl *externalAclHelperList;
717 #if USE_SSL
718
719 struct
720 {
721 char *cert;
722 char *key;
723 int version;
724 char *options;
725 char *cipher;
726 char *cafile;
727 char *capath;
728 char *flags;
729 SSL_CTX *sslContext;
730 }
731
732 ssl_client;
733 #endif
734 };
735
736 struct _SquidConfig2
737 {
738
739 struct
740 {
741 int enable_purge;
742 }
743
744 onoff;
745 uid_t effectiveUserID;
746 gid_t effectiveGroupID;
747 };
748
749 struct _close_handler
750 {
751 PF *handler;
752 void *data;
753 close_handler *next;
754 };
755
756 struct _dread_ctrl
757 {
758 int fd;
759 off_t offset;
760 int req_len;
761 char *buf;
762 int end_of_file;
763 DRCB *handler;
764 void *client_data;
765 };
766
767 struct _dnsserver_t
768 {
769 int id;
770 int inpipe;
771 int outpipe;
772 time_t answer;
773 off_t offset;
774 size_t size;
775 char ip_inbuf[DNS_INBUF_SZ];
776
777 struct timeval dispatch_time;
778 void *data;
779 };
780
781 struct _dwrite_q
782 {
783 off_t file_offset;
784 char *buf;
785 int len;
786 off_t buf_offset;
787 dwrite_q *next;
788 FREE *free_func;
789 };
790
791
792 /* ETag support is rudimantal;
793 * this struct is likely to change
794 * Note: "str" points to memory in HttpHeaderEntry (for now)
795 * so ETags should be used as tmp variables only (for now) */
796
797 struct _ETag
798 {
799 const char *str; /* quoted-string */
800 int weak; /* true if it is a weak validator */
801 };
802
803 struct _fde_disk
804 {
805 DWCB *wrt_handle;
806 void *wrt_handle_data;
807 dwrite_q *write_q;
808 dwrite_q *write_q_tail;
809 off_t offset;
810 };
811
812 struct _fileMap
813 {
814 int max_n_files;
815 int n_files_in_map;
816 int toggle;
817 int nwords;
818 unsigned long *file_map;
819 };
820
821 /* see Packer.c for description */
822
823 struct _Packer
824 {
825 /* protected, use interface functions instead */
826 append_f append;
827 vprintf_f vprintf;
828 void *real_handler; /* first parameter to real append and vprintf */
829 };
830
831
832 /*
833 * Note: HttpBody is used only for messages with a small content that is
834 * known a priory (e.g., error messages).
835 */
836 #include "MemBuf.h"
837
838 struct _HttpBody
839 {
840 /* private */
841 MemBuf mb;
842 };
843
844 #include "SquidString.h"
845 /* http header extention field */
846
847 class HttpHdrExtField
848 {
849 String name; /* field-name from HTTP/1.1 (no column after name) */
850 String value; /* field-value from HTTP/1.1 */
851 };
852
853 /* http cache control header field */
854
855 struct _HttpHdrCc
856 {
857 int mask;
858 int max_age;
859 int s_maxage;
860 int max_stale;
861 };
862
863 /* some fields can hold either time or etag specs (e.g. If-Range) */
864
865 struct _TimeOrTag
866 {
867 ETag tag; /* entity tag */
868 time_t time;
869 int valid; /* true if struct is usable */
870 };
871
872 /* per field statistics */
873
874 class HttpHeaderFieldStat
875 {
876
877 public:
878 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0){}
879
880 int aliveCount; /* created but not destroyed (count) */
881 int seenCount; /* #fields we've seen */
882 int parsCount; /* #parsing attempts */
883 int errCount; /* #pasring errors */
884 int repCount; /* #repetitons */
885 };
886
887 /* compiled version of HttpHeaderFieldAttrs plus stats */
888
889 class HttpHeaderFieldInfo
890 {
891
892 public:
893 HttpHeaderFieldInfo() : id (HDR_ACCEPT), type (ftInvalid){}
894
895 http_hdr_type id;
896 String name;
897 field_type type;
898 HttpHeaderFieldStat stat;
899 };
900
901 class HttpHeaderEntry
902 {
903
904 public:
905 MEMPROXY_CLASS(HttpHeaderEntry);
906 http_hdr_type id;
907 String name;
908 String value;
909 };
910
911 /* bah. remove this when HttpHeaderEntry is moved
912 * out
913 */
914 extern void xassert(const char *, const char *, int);
915 MEMPROXY_CLASS_INLINE(HttpHeaderEntry)
916
917 /* http surogate control header field */
918
919 struct _HttpHdrScTarget
920 {
921 dlink_node node;
922 int mask;
923 int max_age;
924 int max_stale;
925 String content;
926 String target;
927 };
928
929 struct _HttpHdrSc
930 {
931 dlink_list targets;
932 };
933
934 struct _http_state_flags
935 {
936
937 unsigned int proxying:
938 1;
939
940 unsigned int keepalive:
941 1;
942
943 unsigned int only_if_cached:
944 1;
945
946 unsigned int headers_pushed:
947 1;
948
949 unsigned int front_end_https:
950 2;
951
952 unsigned int originpeer:
953 1;
954 };
955
956 struct _ipcache_addrs
957 {
958
959 struct in_addr *in_addrs;
960 unsigned char *bad_mask;
961 unsigned char count;
962 unsigned char cur;
963 unsigned char badcount;
964 };
965
966 struct _domain_ping
967 {
968 char *domain;
969 int do_ping; /* boolean */
970 domain_ping *next;
971 };
972
973 struct _domain_type
974 {
975 char *domain;
976 peer_t type;
977 domain_type *next;
978 };
979
980 #if USE_CACHE_DIGESTS
981
982 struct _Version
983 {
984 short int current; /* current version */
985 short int required; /* minimal version that can safely handle current version */
986 };
987
988 /* digest control block; used for transmission and storage */
989
990 struct _StoreDigestCBlock
991 {
992 Version ver;
993 int capacity;
994 int count;
995 int del_count;
996 int mask_size;
997 unsigned char bits_per_entry;
998 unsigned char hash_func_count;
999 short int reserved_short;
1000 int reserved[32 - 6];
1001 };
1002
1003 struct _DigestFetchState
1004 {
1005 PeerDigest *pd;
1006 StoreEntry *entry;
1007 StoreEntry *old_entry;
1008 store_client *sc;
1009 store_client *old_sc;
1010 HttpRequest *request;
1011 int offset;
1012 int mask_offset;
1013 time_t start_time;
1014 time_t resp_time;
1015 time_t expires;
1016
1017 struct
1018 {
1019 int msg;
1020 int bytes;
1021 }
1022
1023 sent, recv;
1024 char buf[SM_PAGE_SIZE];
1025 ssize_t bufofs;
1026 digest_read_state_t state;
1027 };
1028
1029 /* statistics for cache digests and other hit "predictors" */
1030
1031 struct _cd_guess_stats
1032 {
1033 /* public, read-only */
1034 int true_hits;
1035 int false_hits;
1036 int true_misses;
1037 int false_misses;
1038 int close_hits; /* tmp, remove it later */
1039 };
1040
1041 class PeerDigest
1042 {
1043
1044 public:
1045 void *operator new (size_t);
1046 void operator delete(void *);
1047
1048 struct _peer *peer; /* pointer back to peer structure, argh */
1049 CacheDigest *cd; /* actual digest structure */
1050 String host; /* copy of peer->host */
1051 const char *req_result; /* text status of the last request */
1052
1053 struct
1054 {
1055
1056 unsigned int needed:
1057 1; /* there were requests for this digest */
1058
1059 unsigned int usable:
1060 1; /* can be used for lookups */
1061
1062 unsigned int requested:
1063 1; /* in process of receiving [fresh] digest */
1064 }
1065
1066 flags;
1067
1068 struct
1069 {
1070 /* all times are absolute unless augmented with _delay */
1071 time_t initialized; /* creation */
1072 time_t needed; /* first lookup/use by a peer */
1073 time_t next_check; /* next scheduled check/refresh event */
1074 time_t retry_delay; /* delay before re-checking _invalid_ digest */
1075 time_t requested; /* requested a fresh copy of a digest */
1076 time_t req_delay; /* last request response time */
1077 time_t received; /* received the current copy of a digest */
1078 time_t disabled; /* disabled for good */
1079 }
1080
1081 times;
1082
1083 struct
1084 {
1085 cd_guess_stats guess;
1086 int used_count;
1087
1088 struct
1089 {
1090 int msgs;
1091 kb_t kbytes;
1092 }
1093
1094 sent, recv;
1095 }
1096
1097 stats;
1098
1099 private:
1100 CBDATA_CLASS(PeerDigest);
1101 };
1102
1103 #endif
1104
1105 struct _peer
1106 {
1107 char *name;
1108 char *host;
1109 peer_t type;
1110
1111 struct sockaddr_in in_addr;
1112
1113 struct
1114 {
1115 int pings_sent;
1116 int pings_acked;
1117 int fetches;
1118 int rtt;
1119 int ignored_replies;
1120 int n_keepalives_sent;
1121 int n_keepalives_recv;
1122 time_t probe_start;
1123 time_t last_query;
1124 time_t last_reply;
1125 time_t last_connect_failure;
1126 time_t last_connect_probe;
1127 int logged_state; /* so we can print dead/revived msgs */
1128 int conn_open; /* current opened connections */
1129 }
1130
1131 stats;
1132
1133 struct
1134 {
1135 int version;
1136 int counts[ICP_END];
1137 u_short port;
1138 }
1139
1140 icp;
1141 #if USE_HTCP
1142
1143 struct
1144 {
1145 double version;
1146 int counts[2];
1147 u_short port;
1148 }
1149
1150 htcp;
1151 #endif
1152
1153 u_short http_port;
1154 domain_ping *peer_domain;
1155 domain_type *typelist;
1156 acl_access *access;
1157
1158 struct
1159 {
1160
1161 unsigned int proxy_only:
1162 1;
1163
1164 unsigned int no_query:
1165 1;
1166
1167 unsigned int background_ping:
1168 1;
1169
1170 unsigned int no_digest:
1171 1;
1172
1173 unsigned int default_parent:
1174 1;
1175
1176 unsigned int roundrobin:
1177 1;
1178
1179 unsigned int weighted_roundrobin:
1180 1;
1181
1182 unsigned int mcast_responder:
1183 1;
1184
1185 unsigned int closest_only:
1186 1;
1187 #if USE_HTCP
1188
1189 unsigned int htcp:
1190 1;
1191 #endif
1192
1193 unsigned int no_netdb_exchange:
1194 1;
1195 #if DELAY_POOLS
1196
1197 unsigned int no_delay:
1198 1;
1199 #endif
1200
1201 unsigned int allow_miss:
1202 1;
1203 #if USE_CARP
1204
1205 unsigned int carp:
1206 1;
1207 #endif
1208
1209 unsigned int originserver:
1210 1;
1211 }
1212
1213 options;
1214 int weight;
1215 int basetime;
1216
1217 struct
1218 {
1219 double avg_n_members;
1220 int n_times_counted;
1221 int n_replies_expected;
1222 int ttl;
1223 int id;
1224
1225 struct
1226 {
1227
1228 unsigned int count_event_pending:
1229 1;
1230
1231 unsigned int counting:
1232 1;
1233 }
1234
1235 flags;
1236 }
1237
1238 mcast;
1239 #if USE_CACHE_DIGESTS
1240
1241 PeerDigest *digest;
1242 char *digest_url;
1243 #endif
1244
1245 int tcp_up; /* 0 if a connect() fails */
1246
1247 struct in_addr addresses[10];
1248 int n_addresses;
1249 int rr_count;
1250 int rr_lastcount;
1251 peer *next;
1252 int test_fd;
1253 #if USE_CARP
1254
1255 struct
1256 {
1257 unsigned int hash;
1258 double load_multiplier;
1259 double load_factor; /* normalized weight value */
1260 }
1261
1262 carp;
1263 #endif
1264
1265 char *login; /* Proxy authorization */
1266 time_t connect_timeout;
1267 int max_conn;
1268 char *domain; /* Forced domain */
1269 #if USE_SSL
1270
1271 int use_ssl;
1272 char *sslcert;
1273 char *sslkey;
1274 int sslversion;
1275 char *ssloptions;
1276 char *sslcipher;
1277 char *sslcafile;
1278 char *sslcapath;
1279 char *sslflags;
1280 char *ssldomain;
1281 SSL_CTX *sslContext;
1282 SSL_SESSION *sslSession;
1283 #endif
1284
1285 int front_end_https;
1286 };
1287
1288 struct _net_db_name
1289 {
1290 hash_link hash; /* must be first */
1291 net_db_name *next;
1292 netdbEntry *net_db_entry;
1293 };
1294
1295 struct _net_db_peer
1296 {
1297 const char *peername;
1298 double hops;
1299 double rtt;
1300 time_t expires;
1301 };
1302
1303 struct _netdbEntry
1304 {
1305 hash_link hash; /* must be first */
1306 char network[16];
1307 int pings_sent;
1308 int pings_recv;
1309 double hops;
1310 double rtt;
1311 time_t next_ping_time;
1312 time_t last_use_time;
1313 int link_count;
1314 net_db_name *hosts;
1315 net_db_peer *peers;
1316 int n_peers_alloc;
1317 int n_peers;
1318 };
1319
1320
1321 #if USE_ICMP
1322
1323 struct _pingerEchoData
1324 {
1325
1326 struct in_addr to;
1327 unsigned char opcode;
1328 int psize;
1329 char payload[PINGER_PAYLOAD_SZ];
1330 };
1331
1332 struct _pingerReplyData
1333 {
1334
1335 struct in_addr from;
1336 unsigned char opcode;
1337 int rtt;
1338 int hops;
1339 int psize;
1340 char payload[PINGER_PAYLOAD_SZ];
1341 };
1342
1343 #endif
1344
1345 struct _iostats
1346 {
1347
1348 struct
1349 {
1350 int reads;
1351 int reads_deferred;
1352 int read_hist[16];
1353 int writes;
1354 int write_hist[16];
1355 }
1356
1357 Http, Ftp, Gopher, Wais;
1358 };
1359
1360 /* Removal policies */
1361
1362 struct _RemovalPolicyNode
1363 {
1364 void *data;
1365 };
1366
1367 struct _RemovalPolicy
1368 {
1369 const char *_type;
1370 void *_data;
1371 void (*Free) (RemovalPolicy * policy);
1372 void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1373 void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
1374 void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1375 void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
1376 RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
1377 RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
1378 void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
1379 };
1380
1381 struct _RemovalPolicyWalker
1382 {
1383 RemovalPolicy *_policy;
1384 void *_data;
1385 const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
1386 void (*Done) (RemovalPolicyWalker * walker);
1387 };
1388
1389 struct _RemovalPurgeWalker
1390 {
1391 RemovalPolicy *_policy;
1392 void *_data;
1393 int scanned, max_scan, locked;
1394 StoreEntry *(*Next) (RemovalPurgeWalker * walker);
1395 void (*Done) (RemovalPurgeWalker * walker);
1396 };
1397
1398 struct request_flags
1399 {
1400 request_flags():range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),accelerated(0),transparent(0),internal(0),internalclient(0),body_sent(0),destinationIPLookedUp_(0)
1401 {
1402 #if HTTP_VIOLATIONS
1403 nocache_hack = 0;
1404 #endif
1405
1406 }
1407
1408 unsigned int range:
1409 1;
1410
1411 unsigned int nocache:
1412 1;
1413
1414 unsigned int ims:
1415 1;
1416
1417 unsigned int auth:
1418 1;
1419
1420 unsigned int cachable:
1421 1;
1422
1423 unsigned int hierarchical:
1424 1;
1425
1426 unsigned int loopdetect:
1427 1;
1428
1429 unsigned int proxy_keepalive:
1430 1;
1431
1432 unsigned int proxying:
1433 1; /* this should be killed, also in httpstateflags */
1434
1435 unsigned int refresh:
1436 1;
1437
1438 unsigned int redirected:
1439 1;
1440
1441 unsigned int need_validation:
1442 1;
1443 #if HTTP_VIOLATIONS
1444
1445 unsigned int nocache_hack:
1446 1; /* for changing/ignoring no-cache requests */
1447 #endif
1448
1449 unsigned int accelerated:
1450 1;
1451
1452 unsigned int transparent:
1453 1;
1454
1455 unsigned int internal:
1456 1;
1457
1458 unsigned int internalclient:
1459 1;
1460
1461 unsigned int body_sent:
1462 1;
1463 bool resetTCP() const;
1464 void setResetTCP();
1465 void clearResetTCP();
1466 void destinationIPLookupCompleted();
1467 bool destinationIPLookedUp() const;
1468
1469 private:
1470
1471 unsigned int reset_tcp:
1472 1;
1473
1474 unsigned int destinationIPLookedUp_:
1475 1;
1476 };
1477
1478 struct _link_list
1479 {
1480 void *ptr;
1481
1482 struct _link_list *next;
1483 };
1484
1485 struct _cachemgr_passwd
1486 {
1487 char *passwd;
1488 wordlist *actions;
1489 cachemgr_passwd *next;
1490 };
1491
1492 struct _refresh_t
1493 {
1494 const char *pattern;
1495 regex_t compiled_pattern;
1496 time_t min;
1497 double pct;
1498 time_t max;
1499 refresh_t *next;
1500
1501 struct
1502 {
1503
1504 unsigned int icase:
1505 1;
1506 #if HTTP_VIOLATIONS
1507
1508 unsigned int override_expire:
1509 1;
1510
1511 unsigned int override_lastmod:
1512 1;
1513
1514 unsigned int reload_into_ims:
1515 1;
1516
1517 unsigned int ignore_reload:
1518 1;
1519 #endif
1520
1521 }
1522
1523 flags;
1524 };
1525
1526 struct _CommWriteStateData
1527 {
1528 char *buf;
1529 size_t size;
1530 off_t offset;
1531 CWCB *handler;
1532 void *handler_data;
1533 FREE *free_func;
1534 };
1535
1536 struct _ErrorState
1537 {
1538 err_type type;
1539 int page_id;
1540 http_status httpStatus;
1541 auth_user_request_t *auth_user_request;
1542 HttpRequest *request;
1543 char *url;
1544 int xerrno;
1545 char *host;
1546 u_short port;
1547 char *dnsserver_msg;
1548 time_t ttl;
1549
1550 struct in_addr src_addr;
1551 char *redirect_url;
1552 ERCB *callback;
1553 void *callback_data;
1554
1555 struct
1556 {
1557
1558 unsigned int flag_cbdata:
1559 1;
1560 }
1561
1562 flags;
1563
1564 struct
1565 {
1566 wordlist *server_msg;
1567 char *request;
1568 char *reply;
1569 }
1570
1571 ftp;
1572 char *request_hdrs;
1573 char *err_msg; /* Preformatted error message from the cache */
1574 };
1575
1576 /*
1577 * "very generic" histogram;
1578 * see important comments on hbase_f restrictions in StatHist.c
1579 */
1580
1581 struct _StatHist
1582 {
1583 int *bins;
1584 int capacity;
1585 double min;
1586 double max;
1587 double scale;
1588 hbase_f *val_in; /* e.g., log() for log-based histogram */
1589 hbase_f *val_out; /* e.g., exp() for log based histogram */
1590 };
1591
1592 /*
1593 * if you add a field to StatCounters,
1594 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1595 */
1596
1597 struct _StatCounters
1598 {
1599
1600 struct
1601 {
1602 int clients;
1603 int requests;
1604 int hits;
1605 int mem_hits;
1606 int disk_hits;
1607 int errors;
1608 kb_t kbytes_in;
1609 kb_t kbytes_out;
1610 kb_t hit_kbytes_out;
1611 StatHist miss_svc_time;
1612 StatHist nm_svc_time;
1613 StatHist nh_svc_time;
1614 StatHist hit_svc_time;
1615 StatHist all_svc_time;
1616 }
1617
1618 client_http;
1619
1620 struct
1621 {
1622
1623 struct
1624 {
1625 int requests;
1626 int errors;
1627 kb_t kbytes_in;
1628 kb_t kbytes_out;
1629 }
1630
1631 all , http, ftp, other;
1632 }
1633
1634 server;
1635
1636 struct
1637 {
1638 int pkts_sent;
1639 int queries_sent;
1640 int replies_sent;
1641 int pkts_recv;
1642 int queries_recv;
1643 int replies_recv;
1644 int hits_sent;
1645 int hits_recv;
1646 int replies_queued;
1647 int replies_dropped;
1648 kb_t kbytes_sent;
1649 kb_t q_kbytes_sent;
1650 kb_t r_kbytes_sent;
1651 kb_t kbytes_recv;
1652 kb_t q_kbytes_recv;
1653 kb_t r_kbytes_recv;
1654 StatHist query_svc_time;
1655 StatHist reply_svc_time;
1656 int query_timeouts;
1657 int times_used;
1658 }
1659
1660 icp;
1661
1662 struct
1663 {
1664 int pkts_sent;
1665 int pkts_recv;
1666 }
1667
1668 htcp;
1669
1670 struct
1671 {
1672 int requests;
1673 }
1674
1675 unlink;
1676
1677 struct
1678 {
1679 StatHist svc_time;
1680 }
1681
1682 dns;
1683
1684 struct
1685 {
1686 int times_used;
1687 kb_t kbytes_sent;
1688 kb_t kbytes_recv;
1689 kb_t memory;
1690 int msgs_sent;
1691 int msgs_recv;
1692 #if USE_CACHE_DIGESTS
1693
1694 cd_guess_stats guess;
1695 #endif
1696
1697 StatHist on_xition_count;
1698 }
1699
1700 cd;
1701
1702 struct
1703 {
1704 int times_used;
1705 }
1706
1707 netdb;
1708 int page_faults;
1709 int select_loops;
1710 int select_fds;
1711 double select_time;
1712 double cputime;
1713
1714 struct timeval timestamp;
1715 StatHist comm_icp_incoming;
1716 StatHist comm_dns_incoming;
1717 StatHist comm_http_incoming;
1718 StatHist select_fds_hist;
1719
1720 struct
1721 {
1722
1723 struct
1724 {
1725 int opens;
1726 int closes;
1727 int reads;
1728 int writes;
1729 int seeks;
1730 int unlinks;
1731 }
1732
1733 disk;
1734
1735 struct
1736 {
1737 int accepts;
1738 int sockets;
1739 int connects;
1740 int binds;
1741 int closes;
1742 int reads;
1743 int writes;
1744 int recvfroms;
1745 int sendtos;
1746 }
1747
1748 sock;
1749 #if HAVE_POLL
1750
1751 int polls;
1752 #else
1753
1754 int selects;
1755 #endif
1756
1757 }
1758
1759 syscalls;
1760 int aborted_requests;
1761
1762 struct
1763 {
1764 int files_cleaned;
1765 int outs;
1766 int ins;
1767 }
1768
1769 swap;
1770 };
1771
1772 /* per header statistics */
1773
1774 struct _HttpHeaderStat
1775 {
1776 const char *label;
1777 HttpHeaderMask *owner_mask;
1778
1779 StatHist hdrUCountDistr;
1780 StatHist fieldTypeDistr;
1781 StatHist ccTypeDistr;
1782 StatHist scTypeDistr;
1783
1784 int parsedCount;
1785 int ccParsedCount;
1786 int scParsedCount;
1787 int destroyedCount;
1788 int busyDestroyedCount;
1789 };
1790
1791
1792 struct _ClientInfo
1793 {
1794 hash_link hash; /* must be first */
1795
1796 struct in_addr addr;
1797
1798 struct
1799 {
1800 int result_hist[LOG_TYPE_MAX];
1801 int n_requests;
1802 kb_t kbytes_in;
1803 kb_t kbytes_out;
1804 kb_t hit_kbytes_out;
1805 }
1806
1807 Http, Icp;
1808
1809 struct
1810 {
1811 time_t time;
1812 int n_req;
1813 int n_denied;
1814 }
1815
1816 cutoff;
1817 int n_established; /* number of current established connections */
1818 time_t last_seen;
1819 };
1820
1821 struct _CacheDigest
1822 {
1823 /* public, read-only */
1824 char *mask; /* bit mask */
1825 size_t mask_size; /* mask size in bytes */
1826 int capacity; /* expected maximum for .count, not a hard limit */
1827 int bits_per_entry; /* number of bits allocated for each entry from capacity */
1828 int count; /* number of digested entries */
1829 int del_count; /* number of deletions performed so far */
1830 };
1831
1832 struct _FwdServer
1833 {
1834 peer *_peer; /* NULL --> origin server */
1835 hier_code code;
1836 FwdServer *next;
1837 };
1838
1839 struct _FwdState
1840 {
1841 int client_fd;
1842 StoreEntry *entry;
1843 HttpRequest *request;
1844 FwdServer *servers;
1845 int server_fd;
1846 ErrorState *err;
1847 time_t start;
1848 int n_tries;
1849 int origin_tries;
1850 #if WIP_FWD_LOG
1851
1852 http_status last_status;
1853 #endif
1854
1855 struct
1856 {
1857
1858 unsigned int dont_retry:
1859 1;
1860
1861 unsigned int ftp_pasv_failed:
1862 1;
1863 }
1864
1865 flags;
1866 };
1867
1868 class helper_request;
1869
1870 struct _helper
1871 {
1872 wordlist *cmdline;
1873 dlink_list servers;
1874 dlink_list queue;
1875 const char *id_name;
1876 int n_to_start;
1877 int n_running;
1878 int ipc_type;
1879 unsigned int concurrency;
1880 time_t last_queue_warn;
1881
1882 struct
1883 {
1884 int requests;
1885 int replies;
1886 int queue_size;
1887 int avg_svc_time;
1888 }
1889
1890 stats;
1891 };
1892
1893 struct _helper_stateful
1894 {
1895 wordlist *cmdline;
1896 dlink_list servers;
1897 dlink_list queue;
1898 const char *id_name;
1899 int n_to_start;
1900 int n_running;
1901 int ipc_type;
1902 MemAllocatorProxy *datapool;
1903 HLPSAVAIL *IsAvailable;
1904 HLPSONEQ *OnEmptyQueue;
1905 time_t last_queue_warn;
1906
1907 struct
1908 {
1909 int requests;
1910 int replies;
1911 int queue_size;
1912 int avg_svc_time;
1913 }
1914
1915 stats;
1916 };
1917
1918 struct _helper_server
1919 {
1920 int index;
1921 int pid;
1922 int rfd;
1923 int wfd;
1924 MemBuf wqueue;
1925 MemBuf writebuf;
1926 char *rbuf;
1927 size_t rbuf_sz;
1928 off_t roffset;
1929
1930 dlink_node link;
1931 helper *parent;
1932 helper_request **requests;
1933
1934 struct _helper_flags
1935 {
1936
1937 unsigned int writing:
1938 1;
1939
1940 unsigned int alive:
1941 1;
1942
1943 unsigned int closing:
1944 1;
1945
1946 unsigned int shutdown:
1947 1;
1948 }
1949
1950 flags;
1951
1952 struct
1953 {
1954 int uses;
1955 unsigned int pending;
1956 }
1957
1958 stats;
1959 };
1960
1961 class helper_stateful_request;
1962
1963 struct _helper_stateful_server
1964 {
1965 int index;
1966 int pid;
1967 int rfd;
1968 int wfd;
1969 /* MemBuf wqueue; */
1970 /* MemBuf writebuf; */
1971 char *rbuf;
1972 size_t rbuf_sz;
1973 off_t roffset;
1974
1975 struct timeval dispatch_time;
1976
1977 struct timeval answer_time;
1978 dlink_node link;
1979 dlink_list queue;
1980 statefulhelper *parent;
1981 helper_stateful_request *request;
1982
1983 struct _helper_stateful_flags
1984 {
1985
1986 unsigned int alive:
1987 1;
1988
1989 unsigned int busy:
1990 1;
1991
1992 unsigned int closing:
1993 1;
1994
1995 unsigned int shutdown:
1996 1;
1997 stateful_helper_reserve_t reserved;
1998 }
1999
2000 flags;
2001
2002 struct
2003 {
2004 int uses;
2005 int submits;
2006 int releases;
2007 int deferbyfunc;
2008 int deferbycb;
2009 }
2010
2011 stats;
2012 int deferred_requests; /* current number of deferred requests */
2013 void *data; /* State data used by the calling routines */
2014 };
2015
2016 /*
2017 * use this when you need to pass callback data to a blocking
2018 * operation, but you don't want to add that pointer to cbdata
2019 */
2020
2021 struct _generic_cbdata
2022 {
2023 void *data;
2024 };
2025
2026 struct _store_rebuild_data
2027 {
2028 int objcount; /* # objects successfully reloaded */
2029 int expcount; /* # objects expired */
2030 int scancount; /* # entries scanned or read from state file */
2031 int clashcount; /* # swapfile clashes avoided */
2032 int dupcount; /* # duplicates purged */
2033 int cancelcount; /* # SWAP_LOG_DEL objects purged */
2034 int invalid; /* # bad lines */
2035 int badflags; /* # bad e->flags */
2036 int bad_log_op;
2037 int zero_object_sz;
2038 };
2039
2040 /*
2041 * This defines an repl type
2042 */
2043
2044 struct _storerepl_entry
2045 {
2046 const char *typestr;
2047 REMOVALPOLICYCREATE *create;
2048 };
2049
2050 /*
2051 * Async disk IO - this defines a async disk io queue
2052 */
2053
2054 struct _diskd_queue
2055 {
2056 int smsgid; /* send sysvmsg id */
2057 int rmsgid; /* recv sysvmsg id */
2058 int wfd; /* queue file descriptor ? */
2059 int away; /* number of requests away */
2060 int sent_count; /* number of messages sent */
2061 int recv_count; /* number of messages received */
2062
2063 struct
2064 {
2065 char *buf; /* shm buffer */
2066 link_list *stack;
2067 int id; /* sysvshm id */
2068 }
2069
2070 shm;
2071 };
2072
2073 struct _Logfile
2074 {
2075 int fd;
2076 char path[MAXPATHLEN];
2077 char *buf;
2078 size_t bufsz;
2079 off_t offset;
2080
2081 struct
2082 {
2083
2084 unsigned int fatal:
2085 1;
2086 }
2087
2088 flags;
2089 };
2090
2091 struct _logformat
2092 {
2093 char *name;
2094 logformat_token *format;
2095 logformat *next;
2096 };
2097
2098 struct _customlog
2099 {
2100 char *filename;
2101 acl_list *aclList;
2102 logformat *logFormat;
2103 Logfile *logfile;
2104 customlog *next;
2105 customlog_type type;
2106 };
2107
2108 struct cache_dir_option
2109 {
2110 const char *name;
2111 void (*parse) (SwapDir * sd, const char *option, const char *value, int reconfiguring);
2112 void (*dump) (StoreEntry * e, const char *option, SwapDir const * sd);
2113 };
2114
2115 #endif /* SQUID_STRUCTS_H */