3 * $Id: structs.h,v 1.493 2004/10/18 12:20:10 hno Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
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.
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.
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.
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.
34 #ifndef SQUID_STRUCTS_H
35 #define SQUID_STRUCTS_H
43 dlink_node() : data(NULL
), prev(NULL
), next(NULL
){}
58 char name
[ACL_NAME_SZ
];
62 struct _acl_proxy_auth_match_cache
69 struct _acl_deny_info_list
73 acl_name_list
*acl_list
;
74 acl_deny_info_list
*next
;
80 struct _header_mangler
82 acl_access
*access_list
;
89 acl_access
*access_list
;
96 struct _snmp_request_t
105 struct sockaddr_in from
;
107 struct snmp_pdu
*PDU
;
108 ACLChecklist
*acl_checklist
;
156 struct _sockaddr_in_list
159 struct sockaddr_in s
;
160 sockaddr_in_list
*next
;
163 struct _http_port_list
165 http_port_list
*next
;
167 struct sockaddr_in s
;
168 char *protocol
; /* protocol name */
169 char *name
; /* visible name */
170 char *defaultsite
; /* default web site */
172 unsigned int transparent
:
173 1; /* transparent proxy */
176 1; /* HTTP accelerator */
179 1; /* uses host header */
181 int vport
; /* virtual port support, -1 for dynamic, >0 static*/
187 struct _https_port_list
189 http_port_list http
; /* must be first */
206 #include "DelayConfig.h"
209 struct _RemovalPolicySettings
248 RemovalPolicySettings
*replPolicy
;
249 RemovalPolicySettings
*memPolicy
;
251 time_t negativeDnsTtl
;
252 time_t positiveDnsTtl
;
253 time_t shutdownLifetime
;
254 time_t backgroundPingRate
;
264 time_t persistent_request
;
268 int icp_query
; /* msec */
269 int icp_query_max
; /* msec */
270 int icp_query_min
; /* msec */
271 int mcast_icp_query
; /* msec */
278 time_t idns_retransmit
;
285 size_t maxRequestHeaderSize
;
286 size_t maxRequestBodySize
;
287 acl_size_t
*ReplyBodySize
;
307 http_port_list
*http
;
310 https_port_list
*https
;
331 struct in_addr router
;
333 struct in_addr incoming
;
335 struct in_addr outgoing
;
342 char *as_whois_server
;
349 #if USE_USERAGENT_LOG
362 logformat
*logformats
;
364 customlog
*accesslogs
;
372 char *effectiveGroup
;
404 int redirectChildren
;
405 int redirectConcurrency
;
406 time_t authenticateGCInterval
;
407 time_t authenticateTTL
;
408 time_t authenticateIpTTL
;
420 size_t appendDomainLen
;
423 char *mimeTablePathname
;
425 char *visibleHostname
;
426 char *uniqueHostname
;
427 wordlist
*hostnameAliases
;
443 struct in_addr udp_incoming
;
445 struct in_addr udp_outgoing
;
448 struct in_addr snmp_incoming
;
450 struct in_addr snmp_outgoing
;
453 struct in_addr client_netmask
;
458 size_t udpMaxHitObjsz
;
459 wordlist
*hierarchy_stoplist
;
460 wordlist
*mcast_group_list
;
461 wordlist
*dns_testname_list
;
462 wordlist
*dns_nameservers
;
483 cachemgr_passwd
*passwd_list
;
487 int objectsPerBucket
;
488 size_t avgObjectSize
;
489 size_t maxObjectSize
;
490 size_t minObjectSize
;
491 size_t maxInMemObjSize
;
518 #if ALLOW_SOURCE_PING
528 int test_reachability
;
529 int half_closed_clients
;
536 int redir_rewrites_host
;
538 int nonhierarchical_direct
;
539 int strip_query_terms
;
540 int redirector_bypass
;
541 int ignore_unknown_nameservers
;
544 #if USE_CACHE_DIGESTS
546 int digest_generation
;
549 int log_ip_on_direct
;
551 int vary_ignore_expire
;
552 int pipeline_prefetch
;
555 int surrogate_is_remote
;
558 int request_entities
;
559 int balance_on_multiple_ip
;
574 acl_access
*NeverDirect
;
575 acl_access
*AlwaysDirect
;
584 acl_access
*brokenPosts
;
587 acl_access
*identLookup
;
590 acl_access
*redirector
;
592 acl_address
*outgoing_address
;
593 acl_tos
*outgoing_tos
;
597 acl_deny_info_list
*denyInfoList
;
598 authConfig authConfiguration
;
629 char *errorDirectory
;
660 int max_open_disk_fds
;
662 size_t rangeOffsetLimit
;
663 #if MULTICAST_MISS_STREAM
677 header_mangler header_access
[HDR_ENUM_END
];
680 #if USE_CACHE_DIGESTS
685 time_t rebuild_period
;
686 time_t rewrite_period
;
687 size_t swapout_chunk_size
;
688 int rebuild_chunk_percentage
;
697 int unclean_shutdown
;
704 wordlist
*ext_methods
;
714 char *store_dir_select_algorithm
;
715 int sleep_after_fork
; /* microseconds */
716 external_acl
*externalAclHelperList
;
745 uid_t effectiveUserID
;
746 gid_t effectiveGroupID
;
749 struct _close_handler
775 char ip_inbuf
[DNS_INBUF_SZ
];
777 struct timeval dispatch_time
;
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) */
799 const char *str
; /* quoted-string */
800 int weak
; /* true if it is a weak validator */
806 void *wrt_handle_data
;
808 dwrite_q
*write_q_tail
;
818 unsigned long *file_map
;
821 /* see Packer.c for description */
825 /* protected, use interface functions instead */
828 void *real_handler
; /* first parameter to real append and vprintf */
833 * Note: HttpBody is used only for messages with a small content that is
834 * known a priory (e.g., error messages).
844 #include "SquidString.h"
845 /* http header extention field */
847 class HttpHdrExtField
849 String name
; /* field-name from HTTP/1.1 (no column after name) */
850 String value
; /* field-value from HTTP/1.1 */
853 /* http cache control header field */
863 /* some fields can hold either time or etag specs (e.g. If-Range) */
867 ETag tag
; /* entity tag */
869 int valid
; /* true if struct is usable */
872 /* per field statistics */
874 class HttpHeaderFieldStat
878 HttpHeaderFieldStat() : aliveCount(0), seenCount(0), parsCount(0), errCount(0), repCount(0){}
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 */
887 /* compiled version of HttpHeaderFieldAttrs plus stats */
889 class HttpHeaderFieldInfo
893 HttpHeaderFieldInfo() : id (HDR_ACCEPT
), type (ftInvalid
){}
898 HttpHeaderFieldStat stat
;
901 class HttpHeaderEntry
905 MEMPROXY_CLASS(HttpHeaderEntry
);
911 /* bah. remove this when HttpHeaderEntry is moved
914 extern void xassert(const char *, const char *, int);
915 MEMPROXY_CLASS_INLINE(HttpHeaderEntry
)
917 /* http surogate control header field */
919 struct _HttpHdrScTarget
934 struct _http_state_flags
937 unsigned int proxying
:
940 unsigned int keepalive
:
943 unsigned int only_if_cached
:
946 unsigned int headers_pushed
:
949 unsigned int front_end_https
:
952 unsigned int originpeer
:
956 struct _ipcache_addrs
959 struct in_addr
*in_addrs
;
960 unsigned char *bad_mask
;
963 unsigned char badcount
;
969 int do_ping
; /* boolean */
980 #if USE_CACHE_DIGESTS
984 short int current
; /* current version */
985 short int required
; /* minimal version that can safely handle current version */
988 /* digest control block; used for transmission and storage */
990 struct _StoreDigestCBlock
997 unsigned char bits_per_entry
;
998 unsigned char hash_func_count
;
999 short int reserved_short
;
1000 int reserved
[32 - 6];
1003 struct _DigestFetchState
1007 StoreEntry
*old_entry
;
1009 store_client
*old_sc
;
1010 HttpRequest
*request
;
1024 char buf
[SM_PAGE_SIZE
];
1026 digest_read_state_t state
;
1029 /* statistics for cache digests and other hit "predictors" */
1031 struct _cd_guess_stats
1033 /* public, read-only */
1038 int close_hits
; /* tmp, remove it later */
1045 void *operator new (size_t);
1046 void operator delete(void *);
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 */
1056 unsigned int needed
:
1057 1; /* there were requests for this digest */
1059 unsigned int usable
:
1060 1; /* can be used for lookups */
1062 unsigned int requested
:
1063 1; /* in process of receiving [fresh] digest */
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 */
1085 cd_guess_stats guess
;
1100 CBDATA_CLASS(PeerDigest
);
1111 struct sockaddr_in in_addr
;
1119 int ignored_replies
;
1120 int n_keepalives_sent
;
1121 int n_keepalives_recv
;
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 */
1136 int counts
[ICP_END
];
1154 domain_ping
*peer_domain
;
1155 domain_type
*typelist
;
1161 unsigned int proxy_only
:
1164 unsigned int no_query
:
1167 unsigned int background_ping
:
1170 unsigned int no_digest
:
1173 unsigned int default_parent
:
1176 unsigned int roundrobin
:
1179 unsigned int weighted_roundrobin
:
1182 unsigned int mcast_responder
:
1185 unsigned int closest_only
:
1193 unsigned int no_netdb_exchange
:
1197 unsigned int no_delay
:
1201 unsigned int allow_miss
:
1209 unsigned int originserver
:
1219 double avg_n_members
;
1220 int n_times_counted
;
1221 int n_replies_expected
;
1228 unsigned int count_event_pending
:
1231 unsigned int counting
:
1239 #if USE_CACHE_DIGESTS
1245 int tcp_up
; /* 0 if a connect() fails */
1247 struct in_addr addresses
[10];
1258 double load_multiplier
;
1259 double load_factor
; /* normalized weight value */
1265 char *login
; /* Proxy authorization */
1266 time_t connect_timeout
;
1268 char *domain
; /* Forced domain */
1281 SSL_CTX
*sslContext
;
1282 SSL_SESSION
*sslSession
;
1285 int front_end_https
;
1290 hash_link hash
; /* must be first */
1292 netdbEntry
*net_db_entry
;
1297 const char *peername
;
1305 hash_link hash
; /* must be first */
1311 time_t next_ping_time
;
1312 time_t last_use_time
;
1323 struct _pingerEchoData
1327 unsigned char opcode
;
1329 char payload
[PINGER_PAYLOAD_SZ
];
1332 struct _pingerReplyData
1335 struct in_addr from
;
1336 unsigned char opcode
;
1340 char payload
[PINGER_PAYLOAD_SZ
];
1357 Http
, Ftp
, Gopher
, Wais
;
1360 /* Removal policies */
1362 struct _RemovalPolicyNode
1367 struct _RemovalPolicy
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
);
1381 struct _RemovalPolicyWalker
1383 RemovalPolicy
*_policy
;
1385 const StoreEntry
*(*Next
) (RemovalPolicyWalker
* walker
);
1386 void (*Done
) (RemovalPolicyWalker
* walker
);
1389 struct _RemovalPurgeWalker
1391 RemovalPolicy
*_policy
;
1393 int scanned
, max_scan
, locked
;
1394 StoreEntry
*(*Next
) (RemovalPurgeWalker
* walker
);
1395 void (*Done
) (RemovalPurgeWalker
* walker
);
1398 struct request_flags
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)
1411 unsigned int nocache
:
1420 unsigned int cachable
:
1423 unsigned int hierarchical
:
1426 unsigned int loopdetect
:
1429 unsigned int proxy_keepalive
:
1432 unsigned int proxying
:
1433 1; /* this should be killed, also in httpstateflags */
1435 unsigned int refresh
:
1438 unsigned int redirected
:
1441 unsigned int need_validation
:
1445 unsigned int nocache_hack
:
1446 1; /* for changing/ignoring no-cache requests */
1449 unsigned int accelerated
:
1452 unsigned int transparent
:
1455 unsigned int internal
:
1458 unsigned int internalclient
:
1461 unsigned int body_sent
:
1463 bool resetTCP() const;
1465 void clearResetTCP();
1466 void destinationIPLookupCompleted();
1467 bool destinationIPLookedUp() const;
1471 unsigned int reset_tcp
:
1474 unsigned int destinationIPLookedUp_
:
1482 struct _link_list
*next
;
1485 struct _cachemgr_passwd
1489 cachemgr_passwd
*next
;
1494 const char *pattern
;
1495 regex_t compiled_pattern
;
1508 unsigned int override_expire
:
1511 unsigned int override_lastmod
:
1514 unsigned int reload_into_ims
:
1517 unsigned int ignore_reload
:
1526 struct _CommWriteStateData
1540 http_status httpStatus
;
1541 auth_user_request_t
*auth_user_request
;
1542 HttpRequest
*request
;
1547 char *dnsserver_msg
;
1550 struct in_addr src_addr
;
1553 void *callback_data
;
1558 unsigned int flag_cbdata
:
1566 wordlist
*server_msg
;
1573 char *err_msg
; /* Preformatted error message from the cache */
1577 * "very generic" histogram;
1578 * see important comments on hbase_f restrictions in StatHist.c
1588 hbase_f
*val_in
; /* e.g., log() for log-based histogram */
1589 hbase_f
*val_out
; /* e.g., exp() for log based histogram */
1593 * if you add a field to StatCounters,
1594 * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
1597 struct _StatCounters
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
;
1631 all
, http
, ftp
, other
;
1647 int replies_dropped
;
1654 StatHist query_svc_time
;
1655 StatHist reply_svc_time
;
1692 #if USE_CACHE_DIGESTS
1694 cd_guess_stats guess
;
1697 StatHist on_xition_count
;
1714 struct timeval timestamp
;
1715 StatHist comm_icp_incoming
;
1716 StatHist comm_dns_incoming
;
1717 StatHist comm_http_incoming
;
1718 StatHist select_fds_hist
;
1760 int aborted_requests
;
1772 /* per header statistics */
1774 struct _HttpHeaderStat
1777 HttpHeaderMask
*owner_mask
;
1779 StatHist hdrUCountDistr
;
1780 StatHist fieldTypeDistr
;
1781 StatHist ccTypeDistr
;
1782 StatHist scTypeDistr
;
1788 int busyDestroyedCount
;
1794 hash_link hash
; /* must be first */
1796 struct in_addr addr
;
1800 int result_hist
[LOG_TYPE_MAX
];
1804 kb_t hit_kbytes_out
;
1817 int n_established
; /* number of current established connections */
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 */
1834 peer
*_peer
; /* NULL --> origin server */
1843 HttpRequest
*request
;
1852 http_status last_status
;
1858 unsigned int dont_retry
:
1861 unsigned int ftp_pasv_failed
:
1868 class helper_request
;
1875 const char *id_name
;
1879 unsigned int concurrency
;
1880 time_t last_queue_warn
;
1893 struct _helper_stateful
1898 const char *id_name
;
1902 MemAllocatorProxy
*datapool
;
1903 HLPSAVAIL
*IsAvailable
;
1904 HLPSONEQ
*OnEmptyQueue
;
1905 time_t last_queue_warn
;
1918 struct _helper_server
1932 helper_request
**requests
;
1934 struct _helper_flags
1937 unsigned int writing
:
1943 unsigned int closing
:
1946 unsigned int shutdown
:
1955 unsigned int pending
;
1961 class helper_stateful_request
;
1963 struct _helper_stateful_server
1969 /* MemBuf wqueue; */
1970 /* MemBuf writebuf; */
1975 struct timeval dispatch_time
;
1977 struct timeval answer_time
;
1980 statefulhelper
*parent
;
1981 helper_stateful_request
*request
;
1983 struct _helper_stateful_flags
1992 unsigned int closing
:
1995 unsigned int shutdown
:
1997 stateful_helper_reserve_t reserved
;
2012 int deferred_requests
; /* current number of deferred requests */
2013 void *data
; /* State data used by the calling routines */
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
2021 struct _generic_cbdata
2026 struct _store_rebuild_data
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 */
2041 * This defines an repl type
2044 struct _storerepl_entry
2046 const char *typestr
;
2047 REMOVALPOLICYCREATE
*create
;
2051 * Async disk IO - this defines a async disk io queue
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 */
2065 char *buf
; /* shm buffer */
2067 int id
; /* sysvshm id */
2076 char path
[MAXPATHLEN
];
2094 logformat_token
*format
;
2102 logformat
*logFormat
;
2105 customlog_type type
;
2108 struct cache_dir_option
2111 void (*parse
) (SwapDir
* sd
, const char *option
, const char *value
, int reconfiguring
);
2112 void (*dump
) (StoreEntry
* e
, const char *option
, SwapDir
const * sd
);
2115 #endif /* SQUID_STRUCTS_H */