------------------------------------------------------------ revno: 13602 revision-id: squid3@treenet.co.nz-20140924140755-ccmq1j4i90j1efy7 parent: squid3@treenet.co.nz-20140923063634-zbypstpfj4wlna6l committer: Amos Jeffries branch nick: trunk timestamp: Wed 2014-09-24 07:07:55 -0700 message: SourceLayout: shuffle helper protocol primitives to helper/libhelper.la * create namespace Helper in helper/libhelper.la and subdirectory * shuffle HelperReply::Result_ to Helper::ResultCode in helper/ResultCode.h * shuffle HelperReply to Helper::Reply in helper/Reply.* * move helper_request to Helper::Request in helper/Request.h * link to helper/forward.h for predefines ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140924140755-ccmq1j4i90j1efy7 # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 2f5d4b3ad6885478cb2d0718def7aca503068d72 # timestamp: 2014-09-25 05:53:43 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140923063634-\ # zbypstpfj4wlna6l # # Begin patch === modified file 'configure.ac' --- configure.ac 2014-09-19 17:52:22 +0000 +++ configure.ac 2014-09-24 14:07:55 +0000 @@ -3783,6 +3783,7 @@ src/esi/Makefile src/eui/Makefile src/format/Makefile + src/helper/Makefile src/http/Makefile src/icmp/Makefile src/ident/Makefile === modified file 'src/ClientRequestContext.h' --- src/ClientRequestContext.h 2014-09-13 13:59:43 +0000 +++ src/ClientRequestContext.h 2014-09-24 14:07:55 +0000 @@ -11,6 +11,7 @@ #include "base/RefCount.h" #include "cbdata.h" +#include "helper/forward.h" #include "ipcache.h" #if USE_ADAPTATION @@ -22,8 +23,6 @@ class DnsLookupDetails; class ErrorState; -class HelperReply; - class ClientRequestContext : public RefCountable { @@ -39,9 +38,9 @@ void clientAccessCheck2(); void clientAccessCheckDone(const allow_t &answer); void clientRedirectStart(); - void clientRedirectDone(const HelperReply &reply); + void clientRedirectDone(const Helper::Reply &reply); void clientStoreIdStart(); - void clientStoreIdDone(const HelperReply &reply); + void clientStoreIdDone(const Helper::Reply &reply); void checkNoCache(); void checkNoCacheDone(const allow_t &answer); #if USE_ADAPTATION === modified file 'src/Makefile.am' --- src/Makefile.am 2014-09-22 17:39:41 +0000 +++ src/Makefile.am 2014-09-24 14:07:55 +0000 @@ -47,8 +47,8 @@ LoadableModules.h \ LoadableModules.cc -SUBDIRS = base anyp ftp parser comm eui acl format clients servers fs repl -DIST_SUBDIRS = base anyp ftp parser comm eui acl format clients servers fs repl +SUBDIRS = base anyp helper ftp parser comm eui acl format clients servers fs repl +DIST_SUBDIRS = base anyp helper ftp parser comm eui acl format clients servers fs repl if ENABLE_AUTH SUBDIRS += auth @@ -375,8 +375,6 @@ helper.h \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ hier_code.h \ HierarchyLogEntry.h \ $(HTCPSOURCE) \ @@ -630,6 +628,7 @@ anyp/libanyp.la \ comm/libcomm.la \ eui/libeui.la \ + helper/libhelper.la \ http/libsquid-http.la \ icmp/libicmp.la icmp/libicmp-core.la \ log/liblog.la \ @@ -1477,8 +1476,6 @@ helper.cc \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ $(HTCPSOURCE) \ HttpStateFlags.h \ http.cc \ @@ -1607,6 +1604,7 @@ tests_testCacheManager_LDADD = \ clients/libclients.la \ servers/libservers.la \ + helper/libhelper.la \ http/libsquid-http.la \ ftp/libftp.la \ ident/libident.la \ @@ -1896,8 +1894,6 @@ helper.cc \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ hier_code.h \ $(HTCPSOURCE) \ http.cc \ @@ -2042,6 +2038,7 @@ tests_testEvent_LDADD = \ clients/libclients.la \ servers/libservers.la \ + helper/libhelper.la \ http/libsquid-http.la \ ftp/libftp.la \ ident/libident.la \ @@ -2147,8 +2144,6 @@ helper.cc \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ hier_code.h \ $(HTCPSOURCE) \ http.cc \ @@ -2293,6 +2288,7 @@ tests_testEventLoop_LDADD = \ clients/libclients.la \ servers/libservers.la \ + helper/libhelper.la \ http/libsquid-http.la \ ftp/libftp.la \ ident/libident.la \ @@ -2394,8 +2390,6 @@ helper.cc \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ hier_code.h \ $(HTCPSOURCE) \ http.cc \ @@ -2537,6 +2531,7 @@ tests_test_http_range_LDADD = \ clients/libclients.la \ servers/libservers.la \ + helper/libhelper.la \ http/libsquid-http.la \ ftp/libftp.la \ ident/libident.la \ @@ -2703,8 +2698,6 @@ helper.cc \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ hier_code.h \ $(HTCPSOURCE) \ http.cc \ @@ -2830,6 +2823,7 @@ tests_testHttpRequest_LDADD = \ clients/libclients.la \ servers/libservers.la \ + helper/libhelper.la \ ftp/libftp.la \ ident/libident.la \ acl/libacls.la \ @@ -3524,8 +3518,6 @@ helper.cc \ HelperChildConfig.h \ HelperChildConfig.cc \ - HelperReply.cc \ - HelperReply.h \ hier_code.h \ $(HTCPSOURCE) \ http.cc \ @@ -3672,6 +3664,7 @@ tests_testURL_LDADD = \ clients/libclients.la \ servers/libservers.la \ + helper/libhelper.la \ http/libsquid-http.la \ ftp/libftp.la \ anyp/libanyp.la \ === modified file 'src/auth/State.h' --- src/auth/State.h 2014-09-13 13:59:43 +0000 +++ src/auth/State.h 2014-09-24 14:07:55 +0000 @@ -13,7 +13,6 @@ #include "auth/UserRequest.h" #include "cbdata.h" -#include "helper.h" namespace Auth { === modified file 'src/auth/UserRequest.h' --- src/auth/UserRequest.h 2014-09-13 13:59:43 +0000 +++ src/auth/UserRequest.h 2014-09-24 14:07:55 +0000 @@ -16,7 +16,7 @@ #include "auth/Scheme.h" #include "auth/User.h" #include "dlink.h" -#include "helper.h" +#include "helper/forward.h" #include "HttpHeader.h" #include "ip/Address.h" === modified file 'src/auth/basic/UserRequest.cc' --- src/auth/basic/UserRequest.cc 2014-09-13 13:59:43 +0000 +++ src/auth/basic/UserRequest.cc 2014-09-24 14:07:55 +0000 @@ -15,7 +15,8 @@ #include "charset.h" #include "Debug.h" #include "format/Format.h" -#include "HelperReply.h" +#include "helper.h" +#include "helper/Reply.h" #include "HttpMsg.h" #include "HttpRequest.h" #include "MemBuf.h" @@ -159,7 +160,7 @@ } void -Auth::Basic::UserRequest::HandleReply(void *data, const HelperReply &reply) +Auth::Basic::UserRequest::HandleReply(void *data, const Helper::Reply &reply) { Auth::StateData *r = static_cast(data); void *cbdata; @@ -178,7 +179,7 @@ assert(basic_auth != NULL); - if (reply.result == HelperReply::Okay) + if (reply.result == Helper::ResultCode::Okay) basic_auth->credentials(Auth::Ok); else { basic_auth->credentials(Auth::Failed); === modified file 'src/auth/basic/auth_basic.cc' --- src/auth/basic/auth_basic.cc 2014-09-13 13:59:43 +0000 +++ src/auth/basic/auth_basic.cc 2014-09-24 14:07:55 +0000 @@ -21,6 +21,7 @@ #include "auth/State.h" #include "cache_cf.h" #include "charset.h" +#include "helper.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "mgr/Registration.h" === modified file 'src/auth/basic/auth_basic.h' --- src/auth/basic/auth_basic.h 2014-09-13 13:59:43 +0000 +++ src/auth/basic/auth_basic.h 2014-09-24 14:07:55 +0000 @@ -6,18 +6,13 @@ * Please see the COPYING and CONTRIBUTORS files for details. */ -/* - * auth_basic.h - * Internal declarations for the basic auth module - */ - #ifndef __AUTH_BASIC_H__ #define __AUTH_BASIC_H__ #include "auth/Config.h" #include "auth/Gadgets.h" #include "auth/UserRequest.h" -#include "helper.h" +#include "helper/forward.h" #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ === modified file 'src/auth/digest/UserRequest.cc' --- src/auth/digest/UserRequest.cc 2014-09-13 13:59:43 +0000 +++ src/auth/digest/UserRequest.cc 2014-09-24 14:07:55 +0000 @@ -14,6 +14,8 @@ #include "auth/State.h" #include "charset.h" #include "format/Format.h" +#include "helper.h" +#include "helper/Reply.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" @@ -313,7 +315,7 @@ } void -Auth::Digest::UserRequest::HandleReply(void *data, const HelperReply &reply) +Auth::Digest::UserRequest::HandleReply(void *data, const Helper::Reply &reply) { Auth::StateData *replyData = static_cast(data); debugs(29, 9, HERE << "reply=" << reply); @@ -327,7 +329,7 @@ static bool oldHelperWarningDone = false; switch (reply.result) { - case HelperReply::Unknown: { + case Helper::ResultCode::Unknown: { // Squid 3.3 and older the digest helper only returns a HA1 hash (no "OK") // the HA1 will be found in content() for these responses. if (!oldHelperWarningDone) { @@ -344,7 +346,7 @@ } break; - case HelperReply::Okay: { + case Helper::ResultCode::Okay: { /* allow this because the digest_request pointer is purely local */ Auth::Digest::User *digest_user = dynamic_cast(auth_user_request->user().getRaw()); assert(digest_user != NULL); @@ -359,15 +361,15 @@ } break; - case HelperReply::TT: + case Helper::ResultCode::TT: debugs(29, DBG_IMPORTANT, "ERROR: Digest auth does not support the result code received. Using the wrong helper program? received: " << reply); // fall through to next case. Handle this as an ERR response. - case HelperReply::BrokenHelper: + case Helper::ResultCode::BrokenHelper: // TODO retry the broken lookup on another helper? // fall through to next case for now. Handle this as an ERR response silently. - case HelperReply::Error: { + case Helper::ResultCode::Error: { /* allow this because the digest_request pointer is purely local */ Auth::Digest::UserRequest *digest_request = dynamic_cast(auth_user_request.getRaw()); assert(digest_request); === modified file 'src/auth/digest/auth_digest.cc' --- src/auth/digest/auth_digest.cc 2014-09-13 13:59:43 +0000 +++ src/auth/digest/auth_digest.cc 2014-09-24 14:07:55 +0000 @@ -22,6 +22,7 @@ #include "base64.h" #include "cache_cf.h" #include "event.h" +#include "helper.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" === modified file 'src/auth/digest/auth_digest.h' --- src/auth/digest/auth_digest.h 2014-09-13 13:59:43 +0000 +++ src/auth/digest/auth_digest.h 2014-09-24 14:07:55 +0000 @@ -6,18 +6,13 @@ * Please see the COPYING and CONTRIBUTORS files for details. */ -/* - * auth_digest.h - * Internal declarations for the digest auth module - */ - #ifndef __AUTH_DIGEST_H__ #define __AUTH_DIGEST_H__ #include "auth/Config.h" #include "auth/Gadgets.h" #include "auth/UserRequest.h" -#include "helper.h" +#include "helper/forward.h" #include "rfc2617.h" namespace Auth === modified file 'src/auth/negotiate/UserRequest.cc' --- src/auth/negotiate/UserRequest.cc 2014-09-13 13:59:43 +0000 +++ src/auth/negotiate/UserRequest.cc 2014-09-24 14:07:55 +0000 @@ -16,6 +16,7 @@ #include "format/Format.h" #include "globals.h" #include "helper.h" +#include "helper/Reply.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" @@ -241,7 +242,7 @@ } void -Auth::Negotiate::UserRequest::HandleReply(void *data, const HelperReply &reply) +Auth::Negotiate::UserRequest::HandleReply(void *data, const Helper::Reply &reply) { Auth::StateData *r = static_cast(data); @@ -276,7 +277,7 @@ assert(reply.whichServer == lm_request->authserver); switch (reply.result) { - case HelperReply::TT: + case Helper::ResultCode::TT: /* we have been given a blob to send to the client */ safe_free(lm_request->server_blob); lm_request->request->flags.mustKeepalive = true; @@ -292,7 +293,7 @@ } break; - case HelperReply::Okay: { + case Helper::ResultCode::Okay: { const char *userNote = reply.notes.findFirst("user"); const char *tokenNote = reply.notes.findFirst("token"); if (userNote == NULL || tokenNote == NULL) { @@ -339,7 +340,7 @@ } break; - case HelperReply::Error: { + case Helper::ResultCode::Error: { const char *messageNote = reply.notes.find("message"); const char *tokenNote = reply.notes.findFirst("token"); @@ -357,18 +358,18 @@ } break; - case HelperReply::Unknown: + case Helper::ResultCode::Unknown: debugs(29, DBG_IMPORTANT, "ERROR: Negotiate Authentication Helper '" << reply.whichServer << "' crashed!."); /* continue to the next case */ - case HelperReply::BrokenHelper: { + case Helper::ResultCode::BrokenHelper: { /* TODO kick off a refresh process. This can occur after a YR or after * a KK. If after a YR release the helper and resubmit the request via * Authenticate Negotiate start. * If after a KK deny the user's request w/ 407 and mark the helper as * Needing YR. */ const char *errNote = reply.notes.find("message"); - if (reply.result == HelperReply::Unknown) + if (reply.result == Helper::ResultCode::Unknown) auth_user_request->denyMessage("Internal Error"); else if (errNote != NULL) auth_user_request->denyMessage(errNote); === modified file 'src/auth/negotiate/auth_negotiate.cc' --- src/auth/negotiate/auth_negotiate.cc 2014-09-13 13:59:43 +0000 +++ src/auth/negotiate/auth_negotiate.cc 2014-09-24 14:07:55 +0000 @@ -21,6 +21,7 @@ #include "auth/State.h" #include "cache_cf.h" #include "client_side.h" +#include "helper.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" === modified file 'src/auth/negotiate/auth_negotiate.h' --- src/auth/negotiate/auth_negotiate.h 2014-09-13 13:59:43 +0000 +++ src/auth/negotiate/auth_negotiate.h 2014-09-24 14:07:55 +0000 @@ -6,25 +6,14 @@ * Please see the COPYING and CONTRIBUTORS files for details. */ -/* - * auth_negotiate.h - * Internal declarations for the negotiate auth module - */ - #ifndef __AUTH_NEGOTIATE_H__ #define __AUTH_NEGOTIATE_H__ #include "auth/Config.h" #include "auth/Gadgets.h" #include "auth/UserRequest.h" -#include "helper.h" - -/** - \defgroup AuthNegotiateAPI Negotiate Authentication API - \ingroup AuthAPI - */ - -/// \ingroup AuthNegotiateAPI +#include "helper/forward.h" + #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ namespace Auth === modified file 'src/auth/ntlm/UserRequest.cc' --- src/auth/ntlm/UserRequest.cc 2014-09-13 13:59:43 +0000 +++ src/auth/ntlm/UserRequest.cc 2014-09-24 14:07:55 +0000 @@ -15,6 +15,8 @@ #include "client_side.h" #include "format/Format.h" #include "globals.h" +#include "helper.h" +#include "helper/Reply.h" #include "HttpMsg.h" #include "HttpRequest.h" #include "MemBuf.h" @@ -235,7 +237,7 @@ } void -Auth::Ntlm::UserRequest::HandleReply(void *data, const HelperReply &reply) +Auth::Ntlm::UserRequest::HandleReply(void *data, const Helper::Reply &reply) { Auth::StateData *r = static_cast(data); @@ -270,7 +272,7 @@ assert(reply.whichServer == lm_request->authserver); switch (reply.result) { - case HelperReply::TT: + case Helper::ResultCode::TT: /* we have been given a blob to send to the client */ safe_free(lm_request->server_blob); lm_request->request->flags.mustKeepalive = true; @@ -286,7 +288,7 @@ } break; - case HelperReply::Okay: { + case Helper::ResultCode::Okay: { /* we're finished, release the helper */ const char *userLabel = reply.notes.findFirst("user"); if (!userLabel) { @@ -332,7 +334,7 @@ } break; - case HelperReply::Error: { + case Helper::ResultCode::Error: { /* authentication failure (wrong password, etc.) */ const char *errNote = reply.notes.find("message"); if (errNote != NULL) @@ -346,18 +348,18 @@ } break; - case HelperReply::Unknown: + case Helper::ResultCode::Unknown: debugs(29, DBG_IMPORTANT, "ERROR: NTLM Authentication Helper '" << reply.whichServer << "' crashed!."); /* continue to the next case */ - case HelperReply::BrokenHelper: { + case Helper::ResultCode::BrokenHelper: { /* TODO kick off a refresh process. This can occur after a YR or after * a KK. If after a YR release the helper and resubmit the request via * Authenticate NTLM start. * If after a KK deny the user's request w/ 407 and mark the helper as * Needing YR. */ const char *errNote = reply.notes.find("message"); - if (reply.result == HelperReply::Unknown) + if (reply.result == Helper::ResultCode::Unknown) auth_user_request->denyMessage("Internal Error"); else if (errNote != NULL) auth_user_request->denyMessage(errNote); === modified file 'src/auth/ntlm/auth_ntlm.cc' --- src/auth/ntlm/auth_ntlm.cc 2014-09-13 13:59:43 +0000 +++ src/auth/ntlm/auth_ntlm.cc 2014-09-24 14:07:55 +0000 @@ -21,6 +21,7 @@ #include "auth/State.h" #include "cache_cf.h" #include "client_side.h" +#include "helper.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" === modified file 'src/auth/ntlm/auth_ntlm.h' --- src/auth/ntlm/auth_ntlm.h 2014-09-13 13:59:43 +0000 +++ src/auth/ntlm/auth_ntlm.h 2014-09-24 14:07:55 +0000 @@ -12,7 +12,7 @@ #include "auth/Config.h" #include "auth/Gadgets.h" #include "auth/UserRequest.h" -#include "helper.h" +#include "helper/forward.h" #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ === modified file 'src/client_side.cc' --- src/client_side.cc 2014-09-22 19:06:19 +0000 +++ src/client_side.cc 2014-09-24 14:07:55 +0000 @@ -83,6 +83,8 @@ #include "fqdncache.h" #include "FwdState.h" #include "globals.h" +#include "helper.h" +#include "helper/Reply.h" #include "http.h" #include "HttpHdrContRange.h" #include "HttpHeaderTools.h" @@ -3924,16 +3926,16 @@ } void -ConnStateData::sslCrtdHandleReplyWrapper(void *data, const HelperReply &reply) +ConnStateData::sslCrtdHandleReplyWrapper(void *data, const Helper::Reply &reply) { ConnStateData * state_data = (ConnStateData *)(data); state_data->sslCrtdHandleReply(reply); } void -ConnStateData::sslCrtdHandleReply(const HelperReply &reply) +ConnStateData::sslCrtdHandleReply(const Helper::Reply &reply) { - if (reply.result == HelperReply::BrokenHelper) { + if (reply.result == Helper::ResultCode::BrokenHelper) { debugs(33, 5, HERE << "Certificate for " << sslConnectHostOrIp << " cannot be generated. ssl_crtd response: " << reply); } else if (!reply.other().hasContent()) { debugs(1, DBG_IMPORTANT, HERE << "\"ssl_crtd\" helper returned reply."); @@ -3942,7 +3944,7 @@ if (reply_message.parse(reply.other().content(), reply.other().contentSize()) != Ssl::CrtdMessage::OK) { debugs(33, 5, HERE << "Reply from ssl_crtd for " << sslConnectHostOrIp << " is incorrect"); } else { - if (reply.result != HelperReply::Okay) { + if (reply.result != Helper::ResultCode::Okay) { debugs(33, 5, HERE << "Certificate for " << sslConnectHostOrIp << " cannot be generated. ssl_crtd response: " << reply_message.getBody()); } else { debugs(33, 5, HERE << "Certificate for " << sslConnectHostOrIp << " was successfully recieved from ssl_crtd"); === modified file 'src/client_side.h' --- src/client_side.h 2014-09-22 19:06:19 +0000 +++ src/client_side.h 2014-09-24 14:07:55 +0000 @@ -13,6 +13,7 @@ #include "clientStreamForward.h" #include "comm.h" +#include "helper/forward.h" #include "HttpControlMsg.h" #include "HttpParser.h" #include "ipc/FdNotes.h" @@ -28,7 +29,6 @@ class ClientHttpRequest; class clientStreamNode; class ChunkedCodingParser; -class HelperReply; namespace AnyP { class PortCfg; @@ -350,9 +350,9 @@ */ void getSslContextDone(SSL_CTX * sslContext, bool isNew = false); /// Callback function. It is called when squid receive message from ssl_crtd. - static void sslCrtdHandleReplyWrapper(void *data, const HelperReply &reply); + static void sslCrtdHandleReplyWrapper(void *data, const Helper::Reply &reply); /// Proccess response from ssl_crtd. - void sslCrtdHandleReply(const HelperReply &reply); + void sslCrtdHandleReply(const Helper::Reply &reply); void switchToHttps(HttpRequest *request, Ssl::BumpMode bumpServerMode); bool switchedToHttps() const { return switchedToHttps_; } === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2014-09-13 13:59:43 +0000 +++ src/client_side_request.cc 2014-09-24 14:07:55 +0000 @@ -35,6 +35,7 @@ #include "format/Token.h" #include "gopher.h" #include "helper.h" +#include "helper/Reply.h" #include "http.h" #include "HttpHdrCc.h" #include "HttpReply.h" @@ -863,8 +864,8 @@ if (answer == ACCESS_ALLOWED) redirectStart(http, clientRedirectDoneWrapper, context); else { - HelperReply nilReply; - nilReply.result = HelperReply::Error; + Helper::Reply nilReply; + nilReply.result = Helper::ResultCode::Error; context->clientRedirectDone(nilReply); } } @@ -896,8 +897,8 @@ storeIdStart(http, clientStoreIdDoneWrapper, context); else { debugs(85, 3, "access denied expected ERR reply handling: " << answer); - HelperReply nilReply; - nilReply.result = HelperReply::Error; + Helper::Reply nilReply; + nilReply.result = Helper::ResultCode::Error; context->clientStoreIdDone(nilReply); } } @@ -1178,7 +1179,7 @@ } void -clientRedirectDoneWrapper(void *data, const HelperReply &result) +clientRedirectDoneWrapper(void *data, const Helper::Reply &result) { ClientRequestContext *calloutContext = (ClientRequestContext *)data; @@ -1189,7 +1190,7 @@ } void -clientStoreIdDoneWrapper(void *data, const HelperReply &result) +clientStoreIdDoneWrapper(void *data, const Helper::Reply &result) { ClientRequestContext *calloutContext = (ClientRequestContext *)data; @@ -1200,7 +1201,7 @@ } void -ClientRequestContext::clientRedirectDone(const HelperReply &reply) +ClientRequestContext::clientRedirectDone(const Helper::Reply &reply) { HttpRequest *old_request = http->request; debugs(85, 5, HERE << "'" << http->uri << "' result=" << reply); @@ -1215,14 +1216,14 @@ UpdateRequestNotes(http->getConn(), *old_request, reply.notes); switch (reply.result) { - case HelperReply::Unknown: - case HelperReply::TT: + case Helper::ResultCode::Unknown: + case Helper::ResultCode::TT: // Handler in redirect.cc should have already mapped Unknown // IF it contained valid entry for the old URL-rewrite helper protocol debugs(85, DBG_IMPORTANT, "ERROR: URL rewrite helper returned invalid result code. Wrong helper? " << reply); break; - case HelperReply::BrokenHelper: + case Helper::ResultCode::BrokenHelper: debugs(85, DBG_IMPORTANT, "ERROR: URL rewrite helper: " << reply << ", attempt #" << (redirect_fail_count+1) << " of 2"); if (redirect_fail_count < 2) { // XXX: make this configurable ? ++redirect_fail_count; @@ -1231,11 +1232,11 @@ } break; - case HelperReply::Error: + case Helper::ResultCode::Error: // no change to be done. break; - case HelperReply::Okay: { + case Helper::ResultCode::Okay: { // #1: redirect with a specific status code OK status=NNN url="..." // #2: redirect with a default status code OK url="..." // #3: re-write the URL OK rewrite-url="..." @@ -1321,7 +1322,7 @@ * This method handles the different replies from StoreID helper. */ void -ClientRequestContext::clientStoreIdDone(const HelperReply &reply) +ClientRequestContext::clientStoreIdDone(const Helper::Reply &reply) { HttpRequest *old_request = http->request; debugs(85, 5, "'" << http->uri << "' result=" << reply); @@ -1336,14 +1337,14 @@ UpdateRequestNotes(http->getConn(), *old_request, reply.notes); switch (reply.result) { - case HelperReply::Unknown: - case HelperReply::TT: + case Helper::ResultCode::Unknown: + case Helper::ResultCode::TT: // Handler in redirect.cc should have already mapped Unknown // IF it contained valid entry for the old helper protocol debugs(85, DBG_IMPORTANT, "ERROR: storeID helper returned invalid result code. Wrong helper? " << reply); break; - case HelperReply::BrokenHelper: + case Helper::ResultCode::BrokenHelper: debugs(85, DBG_IMPORTANT, "ERROR: storeID helper: " << reply << ", attempt #" << (store_id_fail_count+1) << " of 2"); if (store_id_fail_count < 2) { // XXX: make this configurable ? ++store_id_fail_count; @@ -1352,11 +1353,11 @@ } break; - case HelperReply::Error: + case Helper::ResultCode::Error: // no change to be done. break; - case HelperReply::Okay: { + case Helper::ResultCode::Okay: { const char *urlNote = reply.notes.findFirst("store-id"); // prevent broken helpers causing too much damage. If old URL == new URL skip the re-write. === modified file 'src/external_acl.cc' --- src/external_acl.cc 2014-09-13 13:59:43 +0000 +++ src/external_acl.cc 2014-09-24 14:07:55 +0000 @@ -20,6 +20,7 @@ #include "fde.h" #include "format/ByteCode.h" #include "helper.h" +#include "helper/Reply.h" #include "HttpHeaderTools.h" #include "HttpReply.h" #include "HttpRequest.h" @@ -1292,7 +1293,7 @@ * with \-escaping on any whitespace, quotes, or slashes (\). */ static void -externalAclHandleReply(void *data, const HelperReply &reply) +externalAclHandleReply(void *data, const Helper::Reply &reply) { externalAclState *state = static_cast(data); externalAclState *next; @@ -1302,11 +1303,11 @@ debugs(82, 2, HERE << "reply=" << reply); - if (reply.result == HelperReply::Okay) + if (reply.result == Helper::ResultCode::Okay) entryData.result = ACCESS_ALLOWED; // XXX: handle other non-DENIED results better - // XXX: make entryData store a proper HelperReply object instead of copying. + // XXX: make entryData store a proper Helper::Reply object instead of copying. entryData.notes.append(&reply.notes); @@ -1336,7 +1337,7 @@ if (cbdataReferenceValid(state->def)) { // only cache OK and ERR results. - if (reply.result == HelperReply::Okay || reply.result == HelperReply::Error) + if (reply.result == Helper::ResultCode::Okay || reply.result == Helper::ResultCode::Error) entry = external_acl_cache_add(state->def, state->key, entryData); else { external_acl_entry *oldentry = (external_acl_entry *)hash_lookup(state->def->cache, state->key); === modified file 'src/fqdncache.cc' --- src/fqdncache.cc 2014-09-13 13:59:43 +0000 +++ src/fqdncache.cc 2014-09-24 14:07:55 +0000 @@ -13,7 +13,6 @@ #include "DnsLookupDetails.h" #include "event.h" #include "helper.h" -#include "HelperReply.h" #include "Mem.h" #include "mgr/Registration.h" #include "SquidConfig.h" === added directory 'src/helper' === modified file 'src/helper.cc' --- src/helper.cc 2014-09-23 06:36:34 +0000 +++ src/helper.cc 2014-09-24 14:07:55 +0000 @@ -18,6 +18,8 @@ #include "fde.h" #include "format/Quoting.h" #include "helper.h" +#include "helper/Reply.h" +#include "helper/Request.h" #include "Mem.h" #include "MemBuf.h" #include "SquidIpc.h" @@ -44,17 +46,17 @@ static IOCB helperStatefulHandleRead; static void helperServerFree(helper_server *srv); static void helperStatefulServerFree(helper_stateful_server *srv); -static void Enqueue(helper * hlp, helper_request *); -static helper_request *Dequeue(helper * hlp); -static helper_request *StatefulDequeue(statefulhelper * hlp); +static void Enqueue(helper * hlp, Helper::Request *); +static Helper::Request *Dequeue(helper * hlp); +static Helper::Request *StatefulDequeue(statefulhelper * hlp); static helper_server *GetFirstAvailable(helper * hlp); static helper_stateful_server *StatefulGetFirstAvailable(statefulhelper * hlp); -static void helperDispatch(helper_server * srv, helper_request * r); -static void helperStatefulDispatch(helper_stateful_server * srv, helper_request * r); +static void helperDispatch(helper_server * srv, Helper::Request * r); +static void helperStatefulDispatch(helper_stateful_server * srv, Helper::Request * r); static void helperKickQueue(helper * hlp); static void helperStatefulKickQueue(statefulhelper * hlp); static void helperStatefulServerDone(helper_stateful_server * srv); -static void StatefulEnqueue(statefulhelper * hlp, helper_request * r); +static void StatefulEnqueue(statefulhelper * hlp, Helper::Request * r); static bool helperStartStats(StoreEntry *sentry, void *hlp, const char *label); CBDATA_CLASS_INIT(helper); @@ -208,7 +210,7 @@ srv->rbuf = (char *)memAllocBuf(ReadBufMinSize, &srv->rbuf_sz); srv->wqueue = new MemBuf; srv->roffset = 0; - srv->requests = (helper_request **)xcalloc(hlp->childs.concurrency ? hlp->childs.concurrency : 1, sizeof(*srv->requests)); + srv->requests = (Helper::Request **)xcalloc(hlp->childs.concurrency ? hlp->childs.concurrency : 1, sizeof(*srv->requests)); srv->parent = cbdataReference(hlp); dlinkAddTail(srv, &srv->link, &hlp->servers); @@ -368,12 +370,12 @@ { if (hlp == NULL) { debugs(84, 3, "helperSubmit: hlp == NULL"); - HelperReply nilReply; + Helper::Reply nilReply; callback(data, nilReply); return; } - helper_request *r = new helper_request(callback, data, buf); + Helper::Request *r = new Helper::Request(callback, data, buf); helper_server *srv; if ((srv = GetFirstAvailable(hlp))) @@ -390,12 +392,12 @@ { if (hlp == NULL) { debugs(84, 3, "helperStatefulSubmit: hlp == NULL"); - HelperReply nilReply; + Helper::Reply nilReply; callback(data, nilReply); return; } - helper_request *r = new helper_request(callback, data, buf); + Helper::Request *r = new Helper::Request(callback, data, buf); if ((buf != NULL) && lastserver) { debugs(84, 5, "StatefulSubmit with lastserver " << lastserver); @@ -660,7 +662,7 @@ helperServerFree(helper_server *srv) { helper *hlp = srv->parent; - helper_request *r; + Helper::Request *r; int i, concurrency = hlp->childs.concurrency; if (!concurrency) @@ -714,7 +716,7 @@ void *cbdata; if (cbdataReferenceValidDone(r->data, &cbdata)) { - HelperReply nilReply; + Helper::Reply nilReply; r->callback(cbdata, nilReply); } @@ -733,7 +735,7 @@ helperStatefulServerFree(helper_stateful_server *srv) { statefulhelper *hlp = srv->parent; - helper_request *r; + Helper::Request *r; if (srv->rbuf) { memFreeBuf(srv->rbuf_sz, srv->rbuf); @@ -780,7 +782,7 @@ void *cbdata; if (cbdataReferenceValidDone(r->data, &cbdata)) { - HelperReply nilReply; + Helper::Reply nilReply; nilReply.whichServer = srv; r->callback(cbdata, nilReply); } @@ -802,7 +804,7 @@ static void helperReturnBuffer(int request_number, helper_server * srv, helper * hlp, char * msg, char * msg_end) { - helper_request *r = srv->requests[request_number]; + Helper::Request *r = srv->requests[request_number]; if (r) { HLPCB *callback = r->callback; @@ -812,7 +814,7 @@ void *cbdata = NULL; if (cbdataReferenceValidDone(r->data, &cbdata)) { - HelperReply response(msg, (msg_end-msg)); + Helper::Reply response(msg, (msg_end-msg)); callback(cbdata, response); } @@ -944,7 +946,7 @@ { char *t = NULL; helper_stateful_server *srv = (helper_stateful_server *)data; - helper_request *r; + Helper::Request *r; statefulhelper *hlp = srv->parent; assert(cbdataReferenceValid(data)); @@ -995,14 +997,14 @@ *t = '\0'; if (r && cbdataReferenceValid(r->data)) { - HelperReply res(srv->rbuf, (t - srv->rbuf)); + Helper::Reply res(srv->rbuf, (t - srv->rbuf)); res.whichServer = srv; r->callback(r->data, res); } else { debugs(84, DBG_IMPORTANT, "StatefulHandleRead: no callback data registered"); called = 0; } - // only skip off the \0's _after_ passing its location in HelperReply above + // only skip off the \0's _after_ passing its location in Helper::Reply above t += skip; /** @@ -1059,7 +1061,7 @@ } static void -Enqueue(helper * hlp, helper_request * r) +Enqueue(helper * hlp, Helper::Request * r) { dlink_node *link = (dlink_node *)memAllocate(MEM_DLINK_NODE); dlinkAddTail(r, link, &hlp->queue); @@ -1092,7 +1094,7 @@ } static void -StatefulEnqueue(statefulhelper * hlp, helper_request * r) +StatefulEnqueue(statefulhelper * hlp, Helper::Request * r) { dlink_node *link = (dlink_node *)memAllocate(MEM_DLINK_NODE); dlinkAddTail(r, link, &hlp->queue); @@ -1124,14 +1126,14 @@ debugs(84, DBG_CRITICAL, "WARNING: Consider increasing the number of " << hlp->id_name << " processes in your config file."); } -static helper_request * +static Helper::Request * Dequeue(helper * hlp) { dlink_node *link; - helper_request *r = NULL; + Helper::Request *r = NULL; if ((link = hlp->queue.head)) { - r = (helper_request *)link->data; + r = (Helper::Request *)link->data; dlinkDelete(link, &hlp->queue); memFree(link, MEM_DLINK_NODE); -- hlp->stats.queue_size; @@ -1140,14 +1142,14 @@ return r; } -static helper_request * +static Helper::Request * StatefulDequeue(statefulhelper * hlp) { dlink_node *link; - helper_request *r = NULL; + Helper::Request *r = NULL; if ((link = hlp->queue.head)) { - r = (helper_request *)link->data; + r = (Helper::Request *)link->data; dlinkDelete(link, &hlp->queue); memFree(link, MEM_DLINK_NODE); -- hlp->stats.queue_size; @@ -1263,10 +1265,10 @@ } static void -helperDispatch(helper_server * srv, helper_request * r) +helperDispatch(helper_server * srv, Helper::Request * r) { helper *hlp = srv->parent; - helper_request **ptr = NULL; + Helper::Request **ptr = NULL; unsigned int slot; if (!cbdataReferenceValid(r->data)) { @@ -1319,7 +1321,7 @@ } static void -helperStatefulDispatch(helper_stateful_server * srv, helper_request * r) +helperStatefulDispatch(helper_stateful_server * srv, Helper::Request * r) { statefulhelper *hlp = srv->parent; @@ -1336,7 +1338,7 @@ /* a callback is needed before this request can _use_ a helper. */ /* we don't care about releasing this helper. The request NEVER * gets to the helper. So we throw away the return code */ - HelperReply nilReply; + Helper::Reply nilReply; nilReply.whichServer = srv; r->callback(r->data, nilReply); /* throw away the placeholder */ @@ -1368,7 +1370,7 @@ static void helperKickQueue(helper * hlp) { - helper_request *r; + Helper::Request *r; helper_server *srv; while ((srv = GetFirstAvailable(hlp)) && (r = Dequeue(hlp))) @@ -1378,7 +1380,7 @@ static void helperStatefulKickQueue(statefulhelper * hlp) { - helper_request *r; + Helper::Request *r; helper_stateful_server *srv; while ((srv = StatefulGetFirstAvailable(hlp)) && (r = StatefulDequeue(hlp))) === modified file 'src/helper.h' --- src/helper.h 2014-09-23 06:36:34 +0000 +++ src/helper.h 2014-09-24 14:07:55 +0000 @@ -16,14 +16,10 @@ #include "cbdata.h" #include "comm/forward.h" #include "dlink.h" +#include "helper/forward.h" #include "HelperChildConfig.h" -#include "HelperReply.h" #include "ip/Address.h" -class helper_request; - -typedef void HLPCB(void *, const HelperReply &reply); - class helper { public: @@ -141,7 +137,7 @@ MemBuf *writebuf; helper *parent; - helper_request **requests; + Helper::Request **requests; private: CBDATA_CLASS2(helper_server); @@ -154,7 +150,7 @@ /* MemBuf writebuf; */ statefulhelper *parent; - helper_request *request; + Helper::Request *request; void *data; /* State data used by the calling routines */ @@ -162,31 +158,6 @@ CBDATA_CLASS2(helper_stateful_server); }; -class helper_request -{ -public: - helper_request(HLPCB *c, void *d, const char *b) : - buf(b ? xstrdup(b) : NULL), - callback(c), - data(cbdataReference(d)), - placeholder(b == NULL) - {} - ~helper_request() { - cbdataReferenceDone(data); - xfree(buf); - } - - MEMPROXY_CLASS(helper_request); - char *buf; - HLPCB *callback; - void *data; - - int placeholder; /* if 1, this is a dummy request waiting for a stateful helper to become available */ - struct timeval dispatch_time; -}; - -MEMPROXY_CLASS_INLINE(helper_request); - /* helper.c */ void helperOpenServers(helper * hlp); void helperStatefulOpenServers(statefulhelper * hlp); === added file 'src/helper/Makefile.am' --- src/helper/Makefile.am 1970-01-01 00:00:00 +0000 +++ src/helper/Makefile.am 2014-09-24 14:07:55 +0000 @@ -0,0 +1,18 @@ +## Copyright (C) 1996-2014 The Squid Software Foundation and contributors +## +## Squid software is distributed under GPLv2+ license and includes +## contributions from numerous individuals and organizations. +## Please see the COPYING and CONTRIBUTORS files for details. +## + +include $(top_srcdir)/src/Common.am +include $(top_srcdir)/src/TestHeaders.am + +noinst_LTLIBRARIES = libhelper.la + +libhelper_la_SOURCES = \ + forward.h \ + Reply.cc \ + Reply.h \ + Request.h \ + ResultCode.h === renamed file 'src/HelperReply.cc' => 'src/helper/Reply.cc' --- src/HelperReply.cc 2014-09-13 13:59:43 +0000 +++ src/helper/Reply.cc 2014-09-24 14:07:55 +0000 @@ -12,25 +12,25 @@ #include "ConfigParser.h" #include "Debug.h" #include "helper.h" -#include "HelperReply.h" +#include "helper/Reply.h" #include "rfc1738.h" #include "SquidString.h" -HelperReply::HelperReply(char *buf, size_t len) : - result(HelperReply::Unknown), +Helper::Reply::Reply(char *buf, size_t len) : + result(Helper::ResultCode::Unknown), whichServer(NULL) { parse(buf,len); } void -HelperReply::parse(char *buf, size_t len) +Helper::Reply::parse(char *buf, size_t len) { debugs(84, 3, "Parsing helper buffer"); // check we have something to parse if (!buf || len < 1) { // empty line response was the old URL-rewriter interface ERR response. - result = HelperReply::Error; + result = Helper::ResultCode::Error; // for now ensure that legacy handlers are not presented with NULL strings. debugs(84, 3, "Reply length is smaller than 1 or none at all "); other_.init(1,1); @@ -50,19 +50,19 @@ // we must also check for the ' ' character after the response token (if anything) if (!strncmp(p,"OK",2) && (len == 2 || p[2] == ' ')) { debugs(84, 3, "helper Result = OK"); - result = HelperReply::Okay; + result = Helper::ResultCode::Okay; p+=2; } else if (!strncmp(p,"ERR",3) && (len == 3 || p[3] == ' ')) { debugs(84, 3, "helper Result = ERR"); - result = HelperReply::Error; + result = Helper::ResultCode::Error; p+=3; } else if (!strncmp(p,"BH",2) && (len == 2 || p[2] == ' ')) { debugs(84, 3, "helper Result = BH"); - result = HelperReply::BrokenHelper; + result = Helper::ResultCode::BrokenHelper; p+=2; } else if (!strncmp(p,"TT ",3)) { // NTLM challenge token - result = HelperReply::TT; + result = Helper::ResultCode::TT; p+=3; // followed by an auth token char *w1 = strwordtok(NULL, &p); @@ -73,13 +73,13 @@ notes.add("token",authToken.content()); } else { // token field is mandatory on this response code - result = HelperReply::BrokenHelper; + result = Helper::ResultCode::BrokenHelper; notes.add("message","Missing 'token' data"); } } else if (!strncmp(p,"AF ",3)) { // NTLM/Negotate OK response - result = HelperReply::Okay; + result = Helper::ResultCode::Okay; p+=3; // followed by: // an optional auth token and user field @@ -107,7 +107,7 @@ } } else if (!strncmp(p,"NA ",3)) { // NTLM fail-closed ERR response - result = HelperReply::Error; + result = Helper::ResultCode::Error; p+=3; sawNA=true; } @@ -127,7 +127,7 @@ parseResponseKeys(); // Hack for backward-compatibility: BH and NA used to be a text message... - if (other().hasContent() && (sawNA || result == HelperReply::BrokenHelper)) { + if (other().hasContent() && (sawNA || result == Helper::ResultCode::BrokenHelper)) { notes.add("message",other().content()); modifiableOther().clean(); } @@ -154,7 +154,7 @@ } void -HelperReply::parseResponseKeys() +Helper::Reply::parseResponseKeys() { // parse a "key=value" pair off the 'other()' buffer. while (other().hasContent()) { @@ -187,23 +187,23 @@ } std::ostream & -operator <<(std::ostream &os, const HelperReply &r) +operator <<(std::ostream &os, const Helper::Reply &r) { os << "{result="; switch (r.result) { - case HelperReply::Okay: + case Helper::ResultCode::Okay: os << "OK"; break; - case HelperReply::Error: + case Helper::ResultCode::Error: os << "ERR"; break; - case HelperReply::BrokenHelper: + case Helper::ResultCode::BrokenHelper: os << "BH"; break; - case HelperReply::TT: + case Helper::ResultCode::TT: os << "TT"; break; - case HelperReply::Unknown: + case Helper::ResultCode::Unknown: os << "Unknown"; break; } === renamed file 'src/HelperReply.h' => 'src/helper/Reply.h' --- src/HelperReply.h 2014-09-13 13:59:43 +0000 +++ src/helper/Reply.h 2014-09-24 14:07:55 +0000 @@ -6,38 +6,41 @@ * Please see the COPYING and CONTRIBUTORS files for details. */ -#ifndef _SQUID_SRC_HELPERREPLY_H -#define _SQUID_SRC_HELPERREPLY_H +#ifndef _SQUID_SRC_HELPER_REPLY_H +#define _SQUID_SRC_HELPER_REPLY_H #include "base/CbcPointer.h" +#include "helper/forward.h" +#include "helper/ResultCode.h" #include "MemBuf.h" #include "Notes.h" #include -class helper_stateful_server; +namespace Helper +{ /** * This object stores the reply message from a helper lookup * It provides parser routing to accept a raw buffer and process the * helper reply into fields for easy access by callers */ -class HelperReply +class Reply { private: // copy are prohibited for now - HelperReply(const HelperReply &r); - HelperReply &operator =(const HelperReply &r); + Reply(const Helper::Reply &r); + Reply &operator =(const Helper::Reply &r); public: - HelperReply() : result(HelperReply::Unknown), notes(), whichServer(NULL) { + Reply() : result(Helper::ResultCode::Unknown), notes(), whichServer(NULL) { other_.init(1,1); other_.terminate(); } // create/parse details from the msg buffer provided // XXX: buf should be const but parse() needs non-const for now - HelperReply(char *buf, size_t len); + Reply(char *buf, size_t len); const MemBuf &other() const { return other_; } @@ -59,16 +62,7 @@ public: /// The helper response 'result' field. - enum Result_ { - Unknown, // no result code received, or unknown result code - Okay, // "OK" indicating success/positive result - Error, // "ERR" indicating success/negative result - BrokenHelper, // "BH" indicating failure due to helper internal problems. - - // result codes for backward compatibility with NTLM/Negotiate - // TODO: migrate to a variant of the above results with kv-pair parameters - TT - } result; + Helper::ResultCode result; // list of key=value pairs the helper produced NotePairs notes; @@ -83,6 +77,8 @@ MemBuf other_; }; -std::ostream &operator <<(std::ostream &os, const HelperReply &r); - -#endif /* _SQUID_SRC_HELPERREPLY_H */ +} // namespace Helper + +std::ostream &operator <<(std::ostream &os, const Helper::Reply &r); + +#endif /* _SQUID_SRC_HELPER_REPLY_H */ === added file 'src/helper/Request.h' --- src/helper/Request.h 1970-01-01 00:00:00 +0000 +++ src/helper/Request.h 2014-09-24 14:07:55 +0000 @@ -0,0 +1,44 @@ +/* + * Copyright (C) 1996-2014 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#ifndef _SQUID_SRC_HELPER_REQUEST_H +#define _SQUID_SRC_HELPER_REQUEST_H + +#include "helper/forward.h" + +namespace Helper +{ + +class Request +{ +public: + Request(HLPCB *c, void *d, const char *b) : + buf(b ? xstrdup(b) : NULL), + callback(c), + data(cbdataReference(d)), + placeholder(b == NULL) + {} + ~Request() { + cbdataReferenceDone(data); + xfree(buf); + } + + MEMPROXY_CLASS(Helper::Request); + char *buf; + HLPCB *callback; + void *data; + + int placeholder; /* if 1, this is a dummy request waiting for a stateful helper to become available */ + struct timeval dispatch_time; +}; + +} // namespace Helper + +MEMPROXY_CLASS_INLINE(Helper::Request); + +#endif /* _SQUID_SRC_HELPER_REQUEST_H */ === added file 'src/helper/ResultCode.h' --- src/helper/ResultCode.h 1970-01-01 00:00:00 +0000 +++ src/helper/ResultCode.h 2014-09-24 14:07:55 +0000 @@ -0,0 +1,29 @@ +/* + * Copyright (C) 1996-2014 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#ifndef _SQUID_SRC_HELPER_RESULTCODE_H +#define _SQUID_SRC_HELPER_RESULTCODE_H + +namespace Helper +{ + +/// enumeration value for the helper response 'result' field. +enum ResultCode { + Unknown, // no result code received, or unknown result code + Okay, // "OK" indicating success/positive result + Error, // "ERR" indicating success/negative result + BrokenHelper, // "BH" indicating failure due to helper internal problems. + + // result codes for backward compatibility with NTLM/Negotiate + // TODO: migrate to a variant of the above results with kv-pair parameters + TT +}; + +} // namespace Helper + +#endif /* _SQUID_SRC_HELPER_RESULTCODE_H */ === added file 'src/helper/forward.h' --- src/helper/forward.h 1970-01-01 00:00:00 +0000 +++ src/helper/forward.h 2014-09-24 14:07:55 +0000 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 1996-2014 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#ifndef SQUID_SRC_HELPER_FORWARD_H +#define SQUID_SRC_HELPER_FORWARD_H + +class helper; +class statefulhelper; + +/// helper protocol primitives +namespace Helper +{ + +class Reply; +class Request; + +} // namespace Helper + +typedef void HLPCB(void *, const Helper::Reply &); + +#endif /* SQUID_SRC_HELPER_FORWARD_H */ === modified file 'src/redirect.cc' --- src/redirect.cc 2014-09-13 13:59:43 +0000 +++ src/redirect.cc 2014-09-24 14:07:55 +0000 @@ -17,6 +17,8 @@ #include "fde.h" #include "format/Format.h" #include "globals.h" +#include "helper.h" +#include "helper/Reply.h" #include "HttpRequest.h" #include "mgr/Registration.h" #include "redirect.h" @@ -74,7 +76,7 @@ } static void -redirectHandleReply(void *data, const HelperReply &reply) +redirectHandleReply(void *data, const Helper::Reply &reply) { RedirectStateData *r = static_cast(data); debugs(61, 5, HERE << "reply=" << reply); @@ -83,7 +85,7 @@ // and to map the old helper response format(s) into new format result code and key=value pairs // it can be removed when the helpers are all updated to the normalized "OK/ERR kv-pairs" format - if (reply.result == HelperReply::Unknown) { + if (reply.result == Helper::ResultCode::Unknown) { // BACKWARD COMPATIBILITY 2012-06-15: // Some nasty old helpers send back the entire input line including extra format keys. // This is especially bad for simple perl search-replace filter scripts. @@ -111,12 +113,12 @@ */ char * result = reply.modifiableOther().content(); - HelperReply newReply; + Helper::Reply newReply; // BACKWARD COMPATIBILITY 2012-06-15: - // We got HelperReply::Unknown reply result but new - // RedirectStateData handlers require HelperReply::Okay, + // We got Helper::ResultCode::Unknown reply result but new + // RedirectStateData handlers require Helper::ResultCode::Okay, // else will drop the helper reply - newReply.result = HelperReply::Okay; + newReply.result = Helper::ResultCode::Okay; newReply.notes.append(&reply.notes); // check and parse for obsoleted Squid-2 urlgroup feature @@ -175,7 +177,7 @@ } static void -storeIdHandleReply(void *data, const HelperReply &reply) +storeIdHandleReply(void *data, const Helper::Reply &reply) { RedirectStateData *r = static_cast(data); debugs(61, 5,"StoreId helper: reply=" << reply); @@ -292,8 +294,8 @@ if (Config.onoff.redirector_bypass && redirectors->stats.queue_size) { /* Skip redirector if there is one request queued */ ++redirectorBypassed; - HelperReply bypassReply; - bypassReply.result = HelperReply::Okay; + Helper::Reply bypassReply; + bypassReply.result = Helper::ResultCode::Okay; bypassReply.notes.add("message","URL rewrite/redirect queue too long. Bypassed."); handler(data, bypassReply); return; @@ -316,9 +318,9 @@ if (Config.onoff.store_id_bypass && storeIds->stats.queue_size) { /* Skip StoreID Helper if there is one request queued */ ++storeIdBypassed; - HelperReply bypassReply; + Helper::Reply bypassReply; - bypassReply.result = HelperReply::Okay; + bypassReply.result = Helper::ResultCode::Okay; bypassReply.notes.add("message","StoreId helper queue too long. Bypassed."); handler(data, bypassReply); === modified file 'src/ssl/PeerConnector.cc' --- src/ssl/PeerConnector.cc 2014-09-13 13:59:43 +0000 +++ src/ssl/PeerConnector.cc 2014-09-24 14:07:55 +0000 @@ -17,6 +17,7 @@ #include "errorpage.h" #include "fde.h" #include "globals.h" +#include "helper/ResultCode.h" #include "HttpRequest.h" #include "neighbors.h" #include "SquidConfig.h" @@ -364,9 +365,9 @@ debugs(83,5, request->GetHost() << " cert validation result: " << validationResponse.resultCode); - if (validationResponse.resultCode == HelperReply::Error) + if (validationResponse.resultCode == ::Helper::ResultCode::Error) errs = sslCrtvdCheckForErrors(validationResponse, errDetails); - else if (validationResponse.resultCode != HelperReply::Okay) + else if (validationResponse.resultCode != ::Helper::ResultCode::Okay) validatorFailed = true; if (!errDetails && !validatorFailed) { === modified file 'src/ssl/cert_validate_message.h' --- src/ssl/cert_validate_message.h 2014-09-13 13:59:43 +0000 +++ src/ssl/cert_validate_message.h 2014-09-24 14:07:55 +0000 @@ -9,7 +9,7 @@ #ifndef SQUID_SSL_CERT_VALIDATE_MESSAGE_H #define SQUID_SSL_CERT_VALIDATE_MESSAGE_H -#include "HelperReply.h" +#include "helper/ResultCode.h" #include "ssl/crtd_message.h" #include "ssl/support.h" @@ -61,7 +61,7 @@ /// If none found a new RecvdError item added with the given id; RecvdError &getError(int errorId); RecvdErrors errors; ///< The list of parsed errors - HelperReply::Result_ resultCode; ///< The helper result code + Helper::ResultCode resultCode; ///< The helper result code }; /** === modified file 'src/ssl/helper.cc' --- src/ssl/helper.cc 2014-09-13 13:59:43 +0000 +++ src/ssl/helper.cc 2014-09-24 14:07:55 +0000 @@ -8,6 +8,8 @@ #include "squid.h" #include "anyp/PortCfg.h" +#include "../helper.h" +#include "helper/Reply.h" #include "SquidConfig.h" #include "SquidString.h" #include "SquidTime.h" @@ -105,8 +107,8 @@ if (squid_curtime - first_warn > 3 * 60) fatal("SSL servers not responding for 3 minutes"); debugs(34, DBG_IMPORTANT, HERE << "Queue overload, rejecting"); - HelperReply failReply; - failReply.result = HelperReply::BrokenHelper; + ::Helper::Reply failReply; + failReply.result = ::Helper::ResultCode::BrokenHelper; failReply.notes.add("message", "error 45 Temporary network problem, please retry later"); callback(data, failReply); return; @@ -212,7 +214,7 @@ CBDATA_CLASS_INIT(submitData); static void -sslCrtvdHandleReplyWrapper(void *data, const HelperReply &reply) +sslCrtvdHandleReplyWrapper(void *data, const ::Helper::Reply &reply) { Ssl::CertValidationMsg replyMsg(Ssl::CrtdMessage::REPLY); Ssl::CertValidationResponse *validationResponse = new Ssl::CertValidationResponse; @@ -220,21 +222,21 @@ submitData *crtdvdData = static_cast(data); STACK_OF(X509) *peerCerts = SSL_get_peer_cert_chain(crtdvdData->ssl); - if (reply.result == HelperReply::BrokenHelper) { + if (reply.result == ::Helper::ResultCode::BrokenHelper) { debugs(83, DBG_IMPORTANT, "\"ssl_crtvd\" helper error response: " << reply.other().content()); - validationResponse->resultCode = HelperReply::BrokenHelper; + validationResponse->resultCode = ::Helper::ResultCode::BrokenHelper; } else if (replyMsg.parse(reply.other().content(), reply.other().contentSize()) != Ssl::CrtdMessage::OK || !replyMsg.parseResponse(*validationResponse, peerCerts, error) ) { debugs(83, DBG_IMPORTANT, "WARNING: Reply from ssl_crtvd for " << " is incorrect"); debugs(83, DBG_IMPORTANT, "Certificate cannot be validated. ssl_crtvd response: " << replyMsg.getBody()); - validationResponse->resultCode = HelperReply::BrokenHelper; + validationResponse->resultCode = ::Helper::ResultCode::BrokenHelper; } else validationResponse->resultCode = reply.result; crtdvdData->callback(crtdvdData->data, *validationResponse); if (Ssl::CertValidationHelper::HelperCache && - (validationResponse->resultCode == HelperReply::Okay || validationResponse->resultCode == HelperReply::Error)) { + (validationResponse->resultCode == ::Helper::ResultCode::Okay || validationResponse->resultCode == ::Helper::ResultCode::Error)) { Ssl::CertValidationHelper::HelperCache->add(crtdvdData->query.c_str(), validationResponse); } else delete validationResponse; @@ -256,7 +258,7 @@ fatal("ssl_crtvd queue being overloaded for long time"); debugs(83, DBG_IMPORTANT, "WARNING: ssl_crtvd queue overload, rejecting"); Ssl::CertValidationResponse resp; - resp.resultCode = HelperReply::BrokenHelper; + resp.resultCode = ::Helper::ResultCode::BrokenHelper; callback(data, resp); return; } === modified file 'src/ssl/helper.h' --- src/ssl/helper.h 2014-09-13 13:59:43 +0000 +++ src/ssl/helper.h 2014-09-24 14:07:55 +0000 @@ -9,8 +9,8 @@ #ifndef SQUID_SSL_HELPER_H #define SQUID_SSL_HELPER_H -#include "../helper.h" #include "base/LruMap.h" +#include "helper/forward.h" #include "ssl/cert_validate_message.h" #include "ssl/crtd_message.h" === modified file 'src/tests/stub_client_side.cc' --- src/tests/stub_client_side.cc 2014-09-12 23:00:48 +0000 +++ src/tests/stub_client_side.cc 2014-09-24 14:07:55 +0000 @@ -73,8 +73,8 @@ void ConnStateData::httpsPeeked(Comm::ConnectionPointer serverConnection) STUB void ConnStateData::getSslContextStart() STUB void ConnStateData::getSslContextDone(SSL_CTX * sslContext, bool isNew) STUB -void ConnStateData::sslCrtdHandleReplyWrapper(void *data, const HelperReply &reply) STUB -void ConnStateData::sslCrtdHandleReply(const HelperReply &reply) STUB +void ConnStateData::sslCrtdHandleReplyWrapper(void *data, const Helper::Reply &reply) STUB +void ConnStateData::sslCrtdHandleReply(const Helper::Reply &reply) STUB void ConnStateData::switchToHttps(HttpRequest *request, Ssl::BumpMode bumpServerMode) STUB void ConnStateData::buildSslCertGenerationParams(Ssl::CertificateProperties &certProperties) STUB bool ConnStateData::serveDelayedError(ClientSocketContext *context) STUB_RETVAL(false)