--------------------- PatchSet 5972 Date: 2003/10/15 12:27:50 Author: hno Branch: icap_streaming-2_5 Tag: (none) Log: Import of streaming ICAP implementation, suitable for virus scanning or other situations where you want the ICAP server to be able to respond to the client while the original request is still being processed. Members: acconfig.h:1.13.2.3->1.13.2.3.12.1 configure.in:1.42.2.40->1.42.2.40.2.1 src/HttpHeader.c:1.10.6.7->1.10.6.7.2.1 src/Makefile.am:1.13.2.8->1.13.2.8.12.1 src/MemBuf.c:1.5->1.5.50.1 src/cf_gen_defines:1.5->1.5.54.1 src/enums.h:1.29.2.8->1.29.2.8.8.1 src/forward.c:1.13.6.4->1.13.6.4.2.1 src/globals.h:1.14.6.3->1.14.6.3.8.1 src/http.c:1.17.6.9->1.17.6.9.2.1 src/main.c:1.28.6.12->1.28.6.12.2.1 src/mem.c:1.13->1.13.34.1 src/mk-string-arrays.pl:1.2->1.2.146.1 src/pconn.c:1.6->1.6.66.1 src/protos.h:1.41.6.16->1.41.6.16.2.1 src/store.c:1.16.6.5->1.16.6.5.2.1 src/typedefs.h:1.25.6.2->1.25.6.2.6.1 Index: squid/acconfig.h =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/acconfig.h,v retrieving revision 1.13.2.3 retrieving revision 1.13.2.3.12.1 diff -u -r1.13.2.3 -r1.13.2.3.12.1 --- squid/acconfig.h 1 Jul 2002 17:24:48 -0000 1.13.2.3 +++ squid/acconfig.h 15 Oct 2003 12:27:50 -0000 1.13.2.3.12.1 @@ -23,7 +23,7 @@ #ifndef __CONFIGURE_H__ #define __CONFIGURE_H__ @TOP@ -/* $Id: acconfig.h,v 1.13.2.3 2002/07/01 17:24:48 squidadm Exp $ */ +/* $Id: acconfig.h,v 1.13.2.3.12.1 2003/10/15 12:27:50 hno Exp $ */ /* * configure command line used to configure Squid @@ -87,6 +87,13 @@ */ #undef DELAY_POOLS + +/* + * ICAP - Internet Content Adaptation Protocol + */ +#undef USE_ICAP + + /* * If you want to log User-Agent request header values, define this. * By default, they are written to useragent.log in the Squid log Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.42.2.40 retrieving revision 1.42.2.40.2.1 diff -u -r1.42.2.40 -r1.42.2.40.2.1 --- squid/configure.in 15 Sep 2003 02:14:10 -0000 1.42.2.40 +++ squid/configure.in 15 Oct 2003 12:27:50 -0000 1.42.2.40.2.1 @@ -3,7 +3,7 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.42.2.40 2003/09/15 02:14:10 squidadm Exp $ +dnl $Id: configure.in,v 1.42.2.40.2.1 2003/10/15 12:27:50 hno Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.5.STABLE4-CVS) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.42.2.40 $)dnl +AC_REVISION($Revision: 1.42.2.40.2.1 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -433,6 +433,17 @@ fi ]) +dnl Enable ICAP Support +AM_CONDITIONAL(USE_ICAP, false) +AC_ARG_ENABLE(icap, +[ --enable-icap Enable iCAP client capability], +[ if test "$enableval" = "yes" ; then + echo "ICAP support enabled" + AC_DEFINE(USE_ICAP) + AM_CONDITIONAL(USE_ICAP, true) + fi +]) + dnl This is a developer only option. Developers know how to set defines dnl dnl AC_ARG_ENABLE(mem-gen-trace, Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.10.6.7 retrieving revision 1.10.6.7.2.1 diff -u -r1.10.6.7 -r1.10.6.7.2.1 --- squid/src/HttpHeader.c 18 Jul 2003 02:13:40 -0000 1.10.6.7 +++ squid/src/HttpHeader.c 15 Oct 2003 12:27:50 -0000 1.10.6.7.2.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.10.6.7 2003/07/18 02:13:40 squidadm Exp $ + * $Id: HttpHeader.c,v 1.10.6.7.2.1 2003/10/15 12:27:50 hno Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -411,19 +411,24 @@ HttpHeaderStats[hdr->owner].parsedCount++; /* commonn format headers are ":[ws]" lines delimited by */ while (field_start < header_end) { - const char *field_end; + const char *field_end = field_start; const char *field_ptr = field_start; do { - field_end = field_ptr = field_ptr + strcspn(field_ptr, "\r\n"); + int l = strcspn(field_ptr, "\r\n"); + if (l == 0) + break; + field_end = field_ptr = field_ptr + l; /* skip CRLF */ if (*field_ptr == '\r') field_ptr++; if (*field_ptr == '\n') field_ptr++; } - while (*field_ptr == ' ' || *field_ptr == '\t'); + while (field_ptr < header_end && (*field_ptr == ' ' || *field_ptr == '\t')); if (!*field_end || field_end > header_end) return httpHeaderReset(hdr); /* missing */ + if (field_start == field_end) + break; /* blank line */ e = httpHeaderEntryParseCreate(field_start, field_end); if (e != NULL) httpHeaderAddEntry(hdr, e); Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.13.2.8 retrieving revision 1.13.2.8.12.1 diff -u -r1.13.2.8 -r1.13.2.8.12.1 --- squid/src/Makefile.am 10 Nov 2002 22:44:12 -0000 1.13.2.8 +++ squid/src/Makefile.am 15 Oct 2003 12:27:50 -0000 1.13.2.8.12.1 @@ -6,6 +6,12 @@ # Uncomment and customize the following to suit your needs: # +if USE_ICAP +ICAPSOURCE = icap_opt.c icap.c +else +ICAPSOURCE = +endif + if USE_DNSSERVER DNSSOURCE = dns.c DNSSERVER = dnsserver @@ -98,6 +104,8 @@ dnsserver.c \ dns_internal.c \ htcp.c \ + icap.c \ + icap_opt.c \ leakfinder.c \ snmp_core.c \ snmp_agent.c \ @@ -150,6 +158,7 @@ HttpMsg.c \ HttpReply.c \ HttpRequest.c \ + $(ICAPSOURCE) \ icmp.c \ icp_v2.c \ icp_v3.c \ Index: squid/src/MemBuf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/MemBuf.c,v retrieving revision 1.5 retrieving revision 1.5.50.1 diff -u -r1.5 -r1.5.50.1 --- squid/src/MemBuf.c 20 Apr 2001 21:27:11 -0000 1.5 +++ squid/src/MemBuf.c 15 Oct 2003 12:27:50 -0000 1.5.50.1 @@ -1,6 +1,6 @@ /* - * $Id: MemBuf.c,v 1.5 2001/04/20 21:27:11 squidadm Exp $ + * $Id: MemBuf.c,v 1.5.50.1 2003/10/15 12:27:50 hno Exp $ * * DEBUG: section 59 auto-growing Memory Buffer with printf * AUTHOR: Alex Rousskov @@ -150,7 +150,7 @@ (*mb->freefunc) (mb->buf); /* free */ mb->freefunc = NULL; /* freeze */ mb->buf = NULL; - mb->size = mb->capacity = 0; + mb->size = mb->capacity = mb->max_capacity = 0; } /* cleans the buffer without changing its capacity Index: squid/src/cf_gen_defines =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf_gen_defines,v retrieving revision 1.5 retrieving revision 1.5.54.1 diff -u -r1.5 -r1.5.54.1 --- squid/src/cf_gen_defines 3 Dec 2001 08:03:21 -0000 1.5 +++ squid/src/cf_gen_defines 15 Oct 2003 12:27:50 -0000 1.5.54.1 @@ -18,6 +18,7 @@ define["USE_UNLINKD"]="--enable-unlinkd" define["USE_USERAGENT_LOG"]="--enable-useragent-log" define["USE_WCCP"]="--enable-wccp" + define["USE_ICAP"]="--enable-icap" } /^IFDEF:/ { if (define[$2] != "") Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.29.2.8 retrieving revision 1.29.2.8.8.1 diff -u -r1.29.2.8 -r1.29.2.8.8.1 --- squid/src/enums.h 21 Jan 2003 03:15:11 -0000 1.29.2.8 +++ squid/src/enums.h 15 Oct 2003 12:27:51 -0000 1.29.2.8.8.1 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.29.2.8 2003/01/21 03:15:11 squidadm Exp $ + * $Id: enums.h,v 1.29.2.8.8.1 2003/10/15 12:27:51 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -609,6 +609,11 @@ MEM_TLV, MEM_SWAP_LOG_DATA, MEM_CLIENT_REQ_BUF, +#if USE_ICAP + MEM_ICAP_SERVICE_LIST, + MEM_ICAP_CLASS, + MEM_ICAP_ACCESS, +#endif MEM_MAX } mem_type; @@ -738,4 +743,68 @@ #endif +#if USE_ICAP +typedef enum { + ICAP_STATUS_NONE = 0, + ICAP_STATUS_CONTINUE = 100, + ICAP_STATUS_SWITCHING_PROTOCOLS = 101, + ICAP_STATUS_STATUS_OK = 200, + ICAP_CREATED = 201, + ICAP_STATUS_ACCEPTED = 202, + ICAP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203, + ICAP_STATUS_NO_MODIFICATION_NEEDED = 204, + ICAP_STATUS_RESET_CONTENT = 205, + ICAP_STATUS_PARTIAL_CONTENT = 206, + ICAP_STATUS_MULTIPLE_CHOICES = 300, + ICAP_STATUS_MOVED_PERMANENTLY = 301, + ICAP_STATUS_MOVED_TEMPORARILY = 302, + ICAP_STATUS_SEE_OTHER = 303, + ICAP_STATUS_NOT_MODIFIED = 304, + ICAP_STATUS_USE_PROXY = 305, + ICAP_STATUS_BAD_REQUEST = 400, + ICAP_STATUS_UNAUTHORIZED = 401, + ICAP_STATUS_PAYMENT_REQUIRED = 402, + ICAP_STATUS_FORBIDDEN = 403, + ICAP_STATUS_SERVICE_NOT_FOUND = 404, + ICAP_STATUS_METHOD_NOT_ALLOWED = 405, + ICAP_STATUS_NOT_ACCEPTABLE = 406, + ICAP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407, + ICAP_STATUS_REQUEST_TIMEOUT = 408, + ICAP_STATUS_CONFLICT = 409, + ICAP_STATUS_GONE = 410, + ICAP_STATUS_LENGTH_REQUIRED = 411, + ICAP_STATUS_PRECONDITION_FAILED = 412, + ICAP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413, + ICAP_STATUS_REQUEST_URI_TOO_LARGE = 414, + ICAP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415, + ICAP_STATUS_INTERNAL_SERVER_ERROR = 500, + ICAP_STATUS_NOT_IMPLEMENTED = 501, + ICAP_STATUS_BAD_GATEWAY = 502, + ICAP_STATUS_SERVICE_OVERLOADED = 503, + ICAP_STATUS_GATEWAY_TIMEOUT = 504, + ICAP_STATUS_ICAP_VERSION_NOT_SUPPORTED = 505, + ICAP_STATUS_INVALID_HEADER = 600 +} icap_status; + +/* + * these values are used as index in an array, so it seems to be better to + * assign some numbers + */ +typedef enum { + ICAP_SERVICE_NONE, + ICAP_SERVICE_REQMOD_PRECACHE, + ICAP_SERVICE_REQMOD_POSTCACHE, + ICAP_SERVICE_RESPMOD_PRECACHE, + ICAP_SERVICE_RESPMOD_POSTCACHE +} icap_service_t; + +typedef enum { + ICAP_METHOD_NONE, + ICAP_METHOD_OPTION, + ICAP_METHOD_REQMOD, + ICAP_METHOD_RESPMOD +} icap_method_t; + +#endif /* USE_ICAP */ + #endif /* SQUID_ENUMS_H */ Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.13.6.4 retrieving revision 1.13.6.4.2.1 diff -u -r1.13.6.4 -r1.13.6.4.2.1 --- squid/src/forward.c 7 Aug 2003 02:13:44 -0000 1.13.6.4 +++ squid/src/forward.c 15 Oct 2003 12:27:51 -0000 1.13.6.4.2.1 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.13.6.4 2003/08/07 02:13:44 squidadm Exp $ + * $Id: forward.c,v 1.13.6.4.2.1 2003/10/15 12:27:51 hno Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -359,6 +359,7 @@ int fd = -1; ErrorState *err; FwdServer *fs = fwdState->servers; + const char *protocol; const char *host; unsigned short port; time_t ctimeout; @@ -370,20 +371,23 @@ if (fs->peer) { host = fs->peer->host; port = fs->peer->http_port; + protocol = "http"; ctimeout = fs->peer->connect_timeout > 0 ? fs->peer->connect_timeout : Config.Timeout.peer_connect; } else if (fwdState->request->flags.accelerated && Config.Accel.single_host && Config.Accel.host) { host = Config.Accel.host; port = Config.Accel.port; + protocol = "http"; ctimeout = Config.Timeout.connect; } else { host = fwdState->request->host; port = fwdState->request->port; ctimeout = Config.Timeout.connect; + protocol = ProtocolStr[fwdState->request->protocol]; } if (fwdCheckRetriable(fwdState)) { - if ((fd = pconnPop(host, port)) >= 0) { + if ((fd = pconnPop(protocol, host, port)) >= 0) { debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd); fwdState->server_fd = fd; fwdState->n_tries++; @@ -475,6 +479,7 @@ assert(entry->lock_count); EBIT_SET(entry->flags, ENTRY_DISPATCHED); netdbPingSite(request->host); + icapRespmodPreCache(entry, fwdstate); /* * Assert that server_fd is set. This is to guarantee that fwdState * is attached to something and will be deallocated when server_fd Index: squid/src/globals.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/globals.h,v retrieving revision 1.14.6.3 retrieving revision 1.14.6.3.8.1 diff -u -r1.14.6.3 -r1.14.6.3.8.1 --- squid/src/globals.h 14 Jan 2003 03:14:58 -0000 1.14.6.3 +++ squid/src/globals.h 15 Oct 2003 12:27:51 -0000 1.14.6.3.8.1 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.14.6.3 2003/01/14 03:14:58 squidadm Exp $ + * $Id: globals.h,v 1.14.6.3.8.1 2003/10/15 12:27:51 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -168,3 +168,4 @@ #endif #endif /* SQUID_GLOBALS_H */ +extern const char *icap_service_type_str[]; Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.17.6.9 retrieving revision 1.17.6.9.2.1 diff -u -r1.17.6.9 -r1.17.6.9.2.1 --- squid/src/http.c 19 Aug 2003 02:13:55 -0000 1.17.6.9 +++ squid/src/http.c 15 Oct 2003 12:27:51 -0000 1.17.6.9.2.1 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.17.6.9 2003/08/19 02:13:55 squidadm Exp $ + * $Id: http.c,v 1.17.6.9.2.1 2003/10/15 12:27:51 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -657,7 +657,7 @@ #endif comm_remove_close_handler(fd, httpStateFree, httpState); fwdUnregister(fd, httpState->fwd); - pconnPush(fd, request->host, request->port); + pconnPush(fd, "http", request->host, request->port); fwdComplete(httpState->fwd); httpState->fd = -1; httpStateFree(fd, httpState); Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.28.6.12 retrieving revision 1.28.6.12.2.1 diff -u -r1.28.6.12 -r1.28.6.12.2.1 --- squid/src/main.c 20 Sep 2003 02:14:00 -0000 1.28.6.12 +++ squid/src/main.c 15 Oct 2003 12:27:51 -0000 1.28.6.12.2.1 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.28.6.12 2003/09/20 02:14:00 squidadm Exp $ + * $Id: main.c,v 1.28.6.12.2.1 2003/10/15 12:27:51 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -376,6 +376,9 @@ idnsInit(); #endif redirectInit(); +#ifdef USE_ICAP + icapOptInit(); +#endif authenticateInit(&Config.authConfig); externalAclInit(); #if USE_WCCP @@ -419,6 +422,9 @@ dnsInit(); #endif redirectInit(); +#ifdef USE_ICAP + icapOptInit(); +#endif authenticateInit(&Config.authConfig); externalAclInit(); } @@ -504,6 +510,9 @@ idnsInit(); #endif redirectInit(); +#ifdef USE_ICAP + icapOptInit(); +#endif authenticateInit(&Config.authConfig); externalAclInit(); useragentOpenLog(); Index: squid/src/mem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mem.c,v retrieving revision 1.13 retrieving revision 1.13.34.1 diff -u -r1.13 -r1.13.34.1 --- squid/src/mem.c 7 Sep 2001 23:55:49 -0000 1.13 +++ squid/src/mem.c 15 Oct 2003 12:27:51 -0000 1.13.34.1 @@ -1,6 +1,6 @@ /* - * $Id: mem.c,v 1.13 2001/09/07 23:55:49 squidadm Exp $ + * $Id: mem.c,v 1.13.34.1 2003/10/15 12:27:51 hno Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -243,6 +243,12 @@ memDataInit(MEM_CLIENT_REQ_BUF, "clientRequestBuffer", CLIENT_REQ_BUF_SZ, 0); memDataInit(MEM_SWAP_LOG_DATA, "storeSwapLogData", sizeof(storeSwapLogData), 0); +#ifdef USE_ICAP + memDataInit(MEM_ICAP_SERVICE_LIST, "IcapServiceList", sizeof(IcapServiceList), 0); + memDataInit(MEM_ICAP_CLASS, "IcapClass", sizeof(IcapClass), 0); + memDataInit(MEM_ICAP_ACCESS, "IcapAccess", sizeof(IcapAccess), 0); +#endif + /* init string pools */ for (i = 0; i < mem_str_pool_count; i++) { StrPools[i].pool = memPoolCreate(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size); Index: squid/src/mk-string-arrays.pl =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mk-string-arrays.pl,v retrieving revision 1.2 retrieving revision 1.2.146.1 diff -u -r1.2 -r1.2.146.1 --- squid/src/mk-string-arrays.pl 23 Oct 2000 15:04:21 -0000 1.2 +++ squid/src/mk-string-arrays.pl 15 Oct 2003 12:27:51 -0000 1.2.146.1 @@ -1,5 +1,5 @@ #****************************************************************************** -# $Id: mk-string-arrays.pl,v 1.2 2000/10/23 15:04:21 hno Exp $ +# $Id: mk-string-arrays.pl,v 1.2.146.1 2003/10/15 12:27:51 hno Exp $ # # File: mk-strs.pl # @@ -16,6 +16,7 @@ $pat{'icp_opcode'} = "icp_opcode_str"; $pat{'swap_log_op'} = "swap_log_op_str"; $pat{'lookup_t'} = "lookup_t_str"; +$pat{'icap_service_t'} = "icap_service_type_str"; $state = 0; # start state while (<>) { Index: squid/src/pconn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/pconn.c,v retrieving revision 1.6 retrieving revision 1.6.66.1 diff -u -r1.6 -r1.6.66.1 --- squid/src/pconn.c 14 Apr 2001 00:31:02 -0000 1.6 +++ squid/src/pconn.c 15 Oct 2003 12:27:51 -0000 1.6.66.1 @@ -1,6 +1,6 @@ /* - * $Id: pconn.c,v 1.6 2001/04/14 00:31:02 squidadm Exp $ + * $Id: pconn.c,v 1.6.66.1 2003/10/15 12:27:51 hno Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -49,7 +49,7 @@ static PF pconnRead; static PF pconnTimeout; -static const char *pconnKey(const char *host, u_short port); +static const char *pconnKey(const char *protocol, const char *host, u_short port); static hash_table *table = NULL; static struct _pconn *pconnNew(const char *key); static void pconnDelete(struct _pconn *p); @@ -59,10 +59,10 @@ static MemPool *pconn_fds_pool = NULL; static const char * -pconnKey(const char *host, u_short port) +pconnKey(const char *protocol, const char *host, u_short port) { - LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN + 10); - snprintf(buf, SQUIDHOSTNAMELEN + 10, "%s.%d", host, (int) port); + LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN + 20); + snprintf(buf, sizeof(buf), "%s:%d:%s", host, (int) port, protocol); return buf; } @@ -184,11 +184,11 @@ } void -pconnPush(int fd, const char *host, u_short port) +pconnPush(int fd, const char *protocol, const char *host, u_short port) { struct _pconn *p; int *old; - LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10); + const char *key; LOCAL_ARRAY(char, desc, FD_DESC_SZ); if (fdNFree() < (RESERVED_FD << 1)) { debug(48, 3) ("pconnPush: Not many unused FDs\n"); @@ -199,7 +199,7 @@ return; } assert(table != NULL); - strcpy(key, pconnKey(host, port)); + key = pconnKey(protocol, host, port); p = (struct _pconn *) hash_lookup(table, key); if (p == NULL) p = pconnNew(key); @@ -223,14 +223,14 @@ } int -pconnPop(const char *host, u_short port) +pconnPop(const char *protocol, const char *host, u_short port) { struct _pconn *p; hash_link *hptr; int fd = -1; - LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10); + const char *key; assert(table != NULL); - strcpy(key, pconnKey(host, port)); + key = pconnKey(protocol, host, port); hptr = hash_lookup(table, key); if (hptr != NULL) { p = (struct _pconn *) hptr; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.41.6.16 retrieving revision 1.41.6.16.2.1 diff -u -r1.41.6.16 -r1.41.6.16.2.1 --- squid/src/protos.h 11 Aug 2003 02:14:58 -0000 1.41.6.16 +++ squid/src/protos.h 15 Oct 2003 12:27:51 -0000 1.41.6.16.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.41.6.16 2003/08/11 02:14:58 squidadm Exp $ + * $Id: protos.h,v 1.41.6.16.2.1 2003/10/15 12:27:51 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1138,8 +1138,8 @@ extern int errorReservePageId(const char *page_name); extern ErrorState *errorCon(err_type type, http_status); -extern void pconnPush(int, const char *host, u_short port); -extern int pconnPop(const char *host, u_short port); +extern void pconnPush(int, const char *protocol, const char *host, u_short port); +extern int pconnPop(const char *protocol, const char *host, u_short port); extern void pconnInit(void); extern int asnMatchIp(void *, struct in_addr); @@ -1345,4 +1345,19 @@ extern void externalAclShutdown(void); extern char *strtokFile(void); +#ifdef USE_ICAP +/* icap_opt.c */ +extern void icapOptInit(void); +extern void icapOptShutdown(void); +/* for debugging purposes only */ +extern void dump_icap_config(IcapConfig * cfg); + +/* icap.c */ +extern void icapReqmodPreCache(clientHttpRequest *, void (*callback)(void *)); +extern void icapReqmodPostCache(int fd, StoreEntry *, request_t *); +extern void icapRespmodPreCache(StoreEntry *, FwdState *); +extern int icapStoreSetPublicKey(StoreEntry *e); +extern void icapStoreSetPrivateKey(StoreEntry *e); +#endif + #endif /* SQUID_PROTOS_H */ Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.16.6.5 retrieving revision 1.16.6.5.2.1 diff -u -r1.16.6.5 -r1.16.6.5.2.1 --- squid/src/store.c 25 Sep 2003 02:15:40 -0000 1.16.6.5 +++ squid/src/store.c 15 Oct 2003 12:27:51 -0000 1.16.6.5.2.1 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.16.6.5 2003/09/25 02:15:40 squidadm Exp $ + * $Id: store.c,v 1.16.6.5.2.1 2003/10/15 12:27:51 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -364,6 +364,10 @@ storeDirSwapLog(e, SWAP_LOG_DEL); storeHashDelete(e); } +#if USE_ICAP + if (mem && mem->icap_state) + icapStoreSetPrivateKey(e); +#endif if (mem != NULL) { mem->id = getKeyCounter(); newkey = storeKeyPrivate(mem->url, mem->method, mem->id); @@ -384,6 +388,10 @@ if (e->hash.key && !EBIT_TEST(e->flags, KEY_PRIVATE)) return; /* is already public */ assert(mem); +#if USE_ICAP + if (mem->icap_state && icapStoreSetPublicKey(e) != 0) + return; /* dealt with by icap */ +#endif /* * We can't make RELEASE_REQUEST objects public. Depending on * when RELEASE_REQUEST gets set, we might not be swapping out @@ -481,7 +489,11 @@ e->lock_count = 1; /* Note lock here w/o calling storeLock() */ mem = e->mem_obj; mem->method = method; - if (neighbors_do_private_keys || !flags.hierarchical) + if (neighbors_do_private_keys || !flags.hierarchical +#if USE_ICAP + || flags.icap_respmod +#endif + ) storeSetPrivateKey(e); else storeSetPublicKey(e); Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.25.6.2 retrieving revision 1.25.6.2.6.1 diff -u -r1.25.6.2 -r1.25.6.2.6.1 --- squid/src/typedefs.h 12 May 2003 02:14:21 -0000 1.25.6.2 +++ squid/src/typedefs.h 15 Oct 2003 12:27:51 -0000 1.25.6.2.6.1 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.25.6.2 2003/05/12 02:14:21 squidadm Exp $ + * $Id: typedefs.h,v 1.25.6.2.6.1 2003/10/15 12:27:51 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -111,6 +111,15 @@ typedef struct _HttpBody HttpBody; typedef struct _HttpReply HttpReply; typedef struct _HttpStateData HttpStateData; +#ifdef USE_ICAP +typedef struct _Icap_RESPRE_State Icap_RESPRE_State; +typedef struct _IcapConfig IcapConfig; +typedef struct _IcapService IcapService; +typedef struct _IcapServiceList IcapServiceList; +typedef struct _IcapClass IcapClass; +typedef struct _IcapAccess IcapAccess; +typedef struct _IcapOptData IcapOptData; +#endif typedef struct _icpUdpData icpUdpData; typedef struct _clientHttpRequest clientHttpRequest; typedef struct _ConnStateData ConnStateData;