#include "squid.h"
#include "AccessLogEntry.h"
#include "acl/Acl.h"
#include "acl/FilledChecklist.h"
#include "base/AsyncCallbacks.h"
#include "CachePeer.h"
#include "CachePeers.h"
#include "comm.h"
#include "comm/Connection.h"
#include "comm/Loops.h"
#include "compat/xalloc.h"
#include "debug/Messages.h"
#include "globals.h"
#include "htcp.h"
#include "http.h"
#include "http/ContentLengthInterpreter.h"
#include "HttpRequest.h"
#include "icmp/net_db.h"
#include "ip/tools.h"
#include "ipc/StartListening.h"
#include "md5.h"
#include "mem/forward.h"
#include "MemBuf.h"
#include "refresh.h"
#include "SquidConfig.h"
#include "StatCounters.h"
#include "Store.h"
#include "store_key_md5.h"
#include "StoreClient.h"
#include "tools.h"
Go to the source code of this file.
Classes | |
struct | _Countstr |
struct | _htcpHeader |
struct | _htcpDataHeaderSquid |
struct | _htcpDataHeader |
struct | _htcpAuthHeader |
class | htcpSpecifier |
class | htcpDetail |
class | htcpStuff |
Macros | |
#define | N_QUERIED_KEYS 8192 |
Typedefs | |
typedef struct _Countstr | Countstr |
typedef struct _htcpHeader | htcpHeader |
typedef struct _htcpDataHeader | htcpDataHeader |
typedef struct _htcpDataHeaderSquid | htcpDataHeaderSquid |
typedef struct _htcpAuthHeader | htcpAuthHeader |
Enumerations | |
enum | { HTCP_NOP , HTCP_TST , HTCP_MON , HTCP_SET , HTCP_CLR , HTCP_END } |
enum | { AUTH_REQUIRED , AUTH_FAILURE , OPCODE_UNIMPLEMENTED , MAJOR_VERSION_UNSUPPORTED , MINOR_VERSION_UNSUPPORTED , INVALID_OPCODE } |
enum | { RR_REQUEST , RR_RESPONSE } |
Functions | |
static void | htcpIncomingConnectionOpened (Ipc::StartListeningAnswer &) |
static ssize_t | htcpBuildPacket (char *buf, size_t buflen, htcpStuff *stuff) |
static htcpDetail * | htcpUnpackDetail (char *buf, int sz) |
static ssize_t | htcpBuildAuth (char *buf, size_t buflen) |
static ssize_t | htcpBuildCountstr (char *buf, size_t buflen, const char *s, size_t len) |
static ssize_t | htcpBuildData (char *buf, size_t buflen, htcpStuff *stuff) |
static ssize_t | htcpBuildDetail (char *buf, size_t buflen, htcpStuff *stuff) |
static ssize_t | htcpBuildOpData (char *buf, size_t buflen, htcpStuff *stuff) |
static ssize_t | htcpBuildSpecifier (char *buf, size_t buflen, htcpStuff *stuff) |
static ssize_t | htcpBuildTstOpData (char *buf, size_t buflen, htcpStuff *stuff) |
static void | htcpHandleMsg (char *buf, int sz, Ip::Address &from) |
static void | htcpLogHtcp (Ip::Address &, const int, const LogTags_ot, const char *, AccessLogEntryPointer) |
static void | htcpHandleTst (htcpDataHeader *, char *buf, int sz, Ip::Address &from) |
static void | htcpRecv (int fd, void *data) |
static void | htcpSend (const char *buf, int len, Ip::Address &to) |
static void | htcpTstReply (htcpDataHeader *, StoreEntry *, htcpSpecifier *, Ip::Address &) |
static void | htcpHandleTstRequest (htcpDataHeader *, char *buf, int sz, Ip::Address &from) |
static void | htcpHandleTstResponse (htcpDataHeader *, char *, int, Ip::Address &) |
static void | htcpSyncAle (AccessLogEntryPointer &al, const Ip::Address &caddr, const int opcode, const char *url) |
static void | htcpHexdump (const char *tag, const char *s, int sz) |
static ssize_t | htcpBuildClrOpData (char *buf, size_t buflen, htcpStuff *stuff) |
static htcpSpecifier::Pointer | htcpUnpackSpecifier (char *buf, int sz) |
static bool | htcpAccessAllowed (acl_access *acl, const htcpSpecifier::Pointer &s, Ip::Address &from) |
static void | htcpClrReply (htcpDataHeader *dhdr, int purgeSucceeded, Ip::Address &from) |
static void | htcpClrStoreEntry (StoreEntry *e) |
static int | htcpClrStore (const htcpSpecifier::Pointer &s) |
static void | htcpHandleClr (htcpDataHeader *hdr, char *buf, int sz, Ip::Address &from) |
static void | htcpForwardClr (char *buf, int sz) |
void | htcpOpenPorts (void) |
int | htcpQuery (StoreEntry *e, HttpRequest *req, CachePeer *p) |
void | htcpClear (StoreEntry *e, HttpRequest *req, const HttpRequestMethod &, CachePeer *p, htcp_clr_reason reason) |
void | htcpSocketShutdown (void) |
void | htcpClosePorts (void) |
Variables | |
static const char *const | htcpOpcodeStr [] |
static uint32_t | msg_id_counter = 0 |
static Comm::ConnectionPointer | htcpOutgoingConn = nullptr |
static Comm::ConnectionPointer | htcpIncomingConn = nullptr |
static uint32_t | queried_id [N_QUERIED_KEYS] |
static cache_key | queried_keys [N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH] |
static Ip::Address | queried_addr [N_QUERIED_KEYS] |
static int | old_squid_format = 0 |
Macro Definition Documentation
◆ N_QUERIED_KEYS
Typedef Documentation
◆ Countstr
◆ htcpAuthHeader
typedef struct _htcpAuthHeader htcpAuthHeader |
◆ htcpDataHeader
typedef struct _htcpDataHeader htcpDataHeader |
◆ htcpDataHeaderSquid
typedef struct _htcpDataHeaderSquid htcpDataHeaderSquid |
◆ htcpHeader
typedef struct _htcpHeader htcpHeader |
Enumeration Type Documentation
◆ anonymous enum
anonymous enum |
◆ anonymous enum
anonymous enum |
◆ anonymous enum
Function Documentation
◆ htcpAccessAllowed()
|
static |
Definition at line 799 of file htcp.cc.
References Acl::Answer::allowed(), ACLChecklist::fastCheck(), RefCount< C >::getRaw(), ACLFilledChecklist::my_addr, Ip::Address::setNoAddr(), and ACLFilledChecklist::src_addr.
Referenced by htcpHandleClr(), and htcpHandleTstRequest().
◆ htcpBuildAuth()
|
static |
Definition at line 321 of file htcp.cc.
References assert, and _htcpAuthHeader::length.
Referenced by htcpBuildPacket().
◆ htcpBuildClrOpData()
Definition at line 456 of file htcp.cc.
References debugs, fatal_dump(), htcpBuildSpecifier(), htcpStuff::reason, htcpStuff::rr, RR_REQUEST, and RR_RESPONSE.
Referenced by htcpBuildOpData().
◆ htcpBuildCountstr()
Definition at line 335 of file htcp.cc.
References debugs.
Referenced by htcpBuildDetail(), and htcpBuildSpecifier().
◆ htcpBuildData()
Definition at line 500 of file htcp.cc.
References debugs, _htcpDataHeaderSquid::F1, _htcpDataHeader::F1, htcpStuff::f1, htcpBuildOpData(), _htcpDataHeaderSquid::length, _htcpDataHeader::length, _htcpDataHeader::msg_id, htcpStuff::msg_id, old_squid_format, htcpStuff::op, _htcpDataHeaderSquid::opcode, _htcpDataHeader::opcode, _htcpDataHeaderSquid::response, _htcpDataHeader::response, htcpStuff::response, _htcpDataHeaderSquid::RR, _htcpDataHeader::RR, and htcpStuff::rr.
Referenced by htcpBuildPacket().
◆ htcpBuildDetail()
Definition at line 402 of file htcp.cc.
References htcpDetail::cache_hdrs, htcpDetail::cacheHdrsSz, htcpStuff::D, htcpDetail::entity_hdrs, htcpDetail::entityHdrsSz, htcpBuildCountstr(), htcpDetail::resp_hdrs, and htcpDetail::respHdrsSz.
Referenced by htcpBuildTstOpData().
◆ htcpBuildOpData()
Definition at line 476 of file htcp.cc.
References assert, debugs, HTCP_CLR, HTCP_TST, htcpBuildClrOpData(), htcpBuildTstOpData(), htcpOpcodeStr, and htcpStuff::op.
Referenced by htcpBuildData().
◆ htcpBuildPacket()
Definition at line 552 of file htcp.cc.
References debugs, htcpBuildAuth(), htcpBuildData(), _htcpHeader::length, _htcpHeader::major, _htcpHeader::minor, and old_squid_format.
Referenced by htcpClear(), htcpClrReply(), htcpQuery(), and htcpTstReply().
◆ htcpBuildSpecifier()
Definition at line 364 of file htcp.cc.
References debugs, htcpBuildCountstr(), htcpSpecifier::method, htcpSpecifier::req_hdrs, htcpSpecifier::reqHdrsSz, htcpStuff::S, htcpSpecifier::uri, and htcpSpecifier::version.
Referenced by htcpBuildClrOpData(), and htcpBuildTstOpData().
◆ htcpBuildTstOpData()
Definition at line 431 of file htcp.cc.
References debugs, htcpStuff::f1, fatal_dump(), htcpBuildDetail(), htcpBuildSpecifier(), htcpStuff::rr, RR_REQUEST, and RR_RESPONSE.
Referenced by htcpBuildOpData().
◆ htcpClear()
void htcpClear | ( | StoreEntry * | e, |
HttpRequest * | req, | ||
const HttpRequestMethod & | method, | ||
CachePeer * | p, | ||
htcp_clr_reason | reason | ||
) |
Definition at line 1564 of file htcp.cc.
References MemBuf::buf, SBuf::c_str(), HttpHeader::clean(), MemBuf::clean(), debugs, HttpRequest::effectiveRequestUri(), hoRequest, HTCP_CLR, HTCP_CLR_INVALIDATION, CachePeer::htcp_oldsquid, htcpBuildPacket(), htcpIncomingConn, htcpSend(), Http::Message::http_ver, HttpStateData::httpBuildRequestHeader(), HttpRequestMethod::image(), CachePeer::in_addr, MemBuf::init(), Comm::IsConnOpen(), AnyP::ProtocolVersion::major, htcpSpecifier::method, HttpRequest::method, AnyP::ProtocolVersion::minor, msg_id_counter, old_squid_format, CachePeer::options, HttpHeader::packInto(), htcpStuff::reason, htcpSpecifier::req_hdrs, htcpSpecifier::request, RR_REQUEST, htcpStuff::S, sb, htcpSpecifier::uri, and htcpSpecifier::version.
Referenced by neighborsHtcpClear().
◆ htcpClosePorts()
void htcpClosePorts | ( | void | ) |
Definition at line 1645 of file htcp.cc.
References DBG_IMPORTANT, debugs, htcpOutgoingConn, htcpSocketShutdown(), and Comm::Connection::local.
Referenced by mainReconfigureStart(), and SquidShutdown().
◆ htcpClrReply()
|
static |
Definition at line 901 of file htcp.cc.
References debugs, _htcpDataHeader::F1, HTCP_CLR, htcpBuildPacket(), htcpSend(), _htcpDataHeader::msg_id, htcpStuff::response, and RR_RESPONSE.
Referenced by htcpHandleClr().
◆ htcpClrStore()
|
static |
Definition at line 1025 of file htcp.cc.
References debugs, RefCount< C >::getRaw(), htcpClrStoreEntry(), HttpRequest::parseHeader(), and storeGetPublicByRequest().
Referenced by htcpHandleClr().
◆ htcpClrStoreEntry()
|
static |
Definition at line 1018 of file htcp.cc.
References debugs, StoreEntry::releaseRequest(), and StoreEntry::url().
Referenced by htcpClrStore().
◆ htcpForwardClr()
|
static |
Definition at line 1274 of file htcp.cc.
References CurrentCachePeers(), and htcpSend().
Referenced by htcpHandleMsg().
◆ htcpHandleClr()
|
static |
Definition at line 1206 of file htcp.cc.
References SquidConfig::accessList, Config, dash_str, debugs, SquidConfig::htcp_clr, htcpAccessAllowed(), htcpClrReply(), htcpClrStore(), htcpLogHtcp(), htcpUnpackSpecifier(), LOG_UDP_DENIED, LOG_UDP_HIT, LOG_UDP_INVALID, LOG_UDP_MISS, and _htcpDataHeader::opcode.
Referenced by htcpHandleMsg().
◆ htcpHandleMsg()
|
static |
Definition at line 1297 of file htcp.cc.
References debugs, _htcpDataHeaderSquid::F1, _htcpDataHeader::F1, HTCP_CLR, HTCP_END, HTCP_MON, HTCP_NOP, HTCP_SET, HTCP_TST, htcpForwardClr(), htcpHandleClr(), htcpHandleTst(), htcpHexdump(), htcpOpcodeStr, int, _htcpHeader::length, _htcpDataHeaderSquid::length, _htcpDataHeader::length, _htcpHeader::major, _htcpHeader::minor, _htcpDataHeaderSquid::msg_id, _htcpDataHeader::msg_id, old_squid_format, _htcpDataHeaderSquid::opcode, _htcpDataHeader::opcode, _htcpDataHeader::reserved, _htcpDataHeaderSquid::response, _htcpDataHeader::response, _htcpDataHeaderSquid::RR, and _htcpDataHeader::RR.
Referenced by htcpRecv().
◆ htcpHandleTst()
|
static |
Definition at line 1058 of file htcp.cc.
References debugs, htcpHandleTstRequest(), htcpHandleTstResponse(), _htcpDataHeader::RR, and RR_REQUEST.
Referenced by htcpHandleMsg().
◆ htcpHandleTstRequest()
|
static |
Definition at line 1154 of file htcp.cc.
References SquidConfig::accessList, Config, dash_str, debugs, _htcpDataHeader::F1, SquidConfig::htcp, htcpAccessAllowed(), htcpLogHtcp(), htcpUnpackSpecifier(), LOG_UDP_DENIED, LOG_UDP_INVALID, and _htcpDataHeader::opcode.
Referenced by htcpHandleTst().
◆ htcpHandleTstResponse()
|
static |
Definition at line 1084 of file htcp.cc.
References htcpDetail::cache_hdrs, htcpDetail::cacheHdrsSz, HttpHeader::clean(), debugs, htcpDetail::entity_hdrs, htcpDetail::entityHdrsSz, _htcpDataHeader::F1, HtcpReplyData::hdr, HtcpReplyData::hit, htcpUnpackDetail(), _htcpDataHeader::msg_id, HtcpReplyData::msg_id, N_QUERIED_KEYS, neighborsHtcpReply(), HtcpReplyData::parseHeader(), Ip::Address::port(), queried_addr, queried_id, queried_keys, htcpDetail::resp_hdrs, htcpDetail::respHdrsSz, _htcpDataHeader::response, and storeKeyText().
Referenced by htcpHandleTst().
◆ htcpHexdump()
|
static |
Definition at line 291 of file htcp.cc.
References debugs.
Referenced by htcpHandleMsg(), and htcpSend().
◆ htcpIncomingConnectionOpened()
|
static |
Definition at line 1497 of file htcp.cc.
References SquidConfig::Addrs, COMM_SELECT_READ, Config, Ipc::StartListeningAnswer::conn, conn, DBG_CRITICAL, DBG_IMPORTANT, debugs, fatal(), htcpOutgoingConn, htcpRecv(), Comm::IsConnOpen(), Ip::Address::isNoAddr(), Comm::Connection::local, Comm::SetSelect(), and SquidConfig::udp_outgoing.
Referenced by htcpOpenPorts().
◆ htcpLogHtcp()
|
static |
Definition at line 1656 of file htcp.cc.
References accessLogLog(), assert, AccessLogEntry::cache, AccessLogEntry::CacheDetails::code, Config, htcpSyncAle(), LOG_TAG_NONE, SquidConfig::log_udp, SquidConfig::onoff, and LogTags::update().
Referenced by htcpSpecifier::checkedHit(), htcpHandleClr(), and htcpHandleTstRequest().
◆ htcpOpenPorts()
void htcpOpenPorts | ( | void | ) |
Definition at line 1442 of file htcp.cc.
References SquidConfig::Addrs, asyncCallbackFun, comm_open_listener(), COMM_SELECT_READ, Config, DBG_CRITICAL, DBG_IMPORTANT, debugs, Ip::EnableIpv6, enter_suid(), fatal(), Comm::Connection::fd, Ipc::fdnInHtcpSocket, SquidConfig::htcp, htcpIncomingConn, htcpIncomingConnectionOpened(), htcpOutgoingConn, htcpRecv(), Important, IPV6_SPECIAL_SPLITSTACK, Ip::Address::isAnyAddr(), Comm::IsConnOpen(), Ip::Address::isNoAddr(), leave_suid(), Comm::Connection::local, Ip::Address::port(), SquidConfig::Port, Ip::Address::setIPv4(), Comm::SetSelect(), Ipc::StartListening(), SquidConfig::udp_incoming, and SquidConfig::udp_outgoing.
Referenced by serverConnectionsOpen().
◆ htcpQuery()
int htcpQuery | ( | StoreEntry * | e, |
HttpRequest * | req, | ||
CachePeer * | p | ||
) |
Generate and Send an HTCP query to the specified peer.
- Parameters
-
e req p
- Return values
-
1 Successfully sent request. 0 Unable to send request at this time. HTCP may be shutting down or starting up. Don't wait for a reply or count in stats as sent. -1 Error sending request.
Definition at line 1515 of file htcp.cc.
References MemBuf::buf, HttpHeader::clean(), MemBuf::clean(), debugs, hoRequest, CachePeer::htcp_oldsquid, HTCP_TST, htcpBuildPacket(), htcpIncomingConn, htcpSend(), Http::Message::http_ver, HttpStateData::httpBuildRequestHeader(), HttpRequestMethod::image(), CachePeer::in_addr, MemBuf::init(), Comm::IsConnOpen(), hash_link::key, AnyP::ProtocolVersion::major, htcpSpecifier::method, HttpRequest::method, AnyP::ProtocolVersion::minor, htcpStuff::msg_id, msg_id_counter, N_QUERIED_KEYS, old_squid_format, CachePeer::options, HttpHeader::packInto(), queried_addr, queried_id, queried_keys, htcpSpecifier::req_hdrs, RR_REQUEST, htcpStuff::S, sb, storeKeyCopy(), storeKeyText(), htcpSpecifier::uri, StoreEntry::url(), and htcpSpecifier::version.
Referenced by neighborsUdpPing().
◆ htcpRecv()
|
static |
Definition at line 1415 of file htcp.cc.
References COMM_SELECT_READ, comm_udp_recvfrom(), debugs, StatCounters::htcp, htcpHandleMsg(), htcpRecv(), StatCounters::pkts_recv, Comm::SetSelect(), and statCounter.
Referenced by htcpIncomingConnectionOpened(), htcpOpenPorts(), and htcpRecv().
◆ htcpSend()
|
static |
Definition at line 595 of file htcp.cc.
References comm_udp_sendto(), debugs, Comm::Connection::fd, StatCounters::htcp, htcpHexdump(), htcpOutgoingConn, StatCounters::pkts_sent, statCounter, and xstrerr().
Referenced by htcpClear(), htcpClrReply(), htcpForwardClr(), htcpQuery(), and htcpTstReply().
◆ htcpSocketShutdown()
void htcpSocketShutdown | ( | void | ) |
Definition at line 1616 of file htcp.cc.
References assert, COMM_SELECT_READ, DBG_IMPORTANT, debugs, Comm::Connection::fd, htcpIncomingConn, htcpOutgoingConn, Comm::IsConnOpen(), Comm::Connection::local, and Comm::SetSelect().
Referenced by htcpClosePorts(), and serverConnectionsClose().
◆ htcpSyncAle()
|
static |
Definition at line 276 of file htcp.cc.
References AccessLogEntry::cache, AccessLogEntry::CacheDetails::caddr, current_time, AccessLogEntry::htcp, htcpOpcodeStr, AccessLogEntry::HtcpDetails::opcode, AccessLogEntry::setVirginUrlForMissingRequest(), AccessLogEntry::CacheDetails::start_time, AccessLogEntry::CacheDetails::trTime, and AccessLogEntry::url.
Referenced by htcpSpecifier::fillChecklist(), and htcpLogHtcp().
◆ htcpTstReply()
|
static |
Definition at line 812 of file htcp.cc.
References Http::AGE, MemBuf::buf, htcpDetail::cache_hdrs, htcpDetail::cacheHdrsSz, HttpHeader::clean(), MemBuf::clean(), MemBuf::contentSize(), htcpStuff::D, debugs, htcpDetail::entity_hdrs, htcpDetail::entityHdrsSz, Http::EXPIRES, StoreEntry::expires, hoHtcpReply, AnyP::Uri::host(), HTCP_TST, htcpBuildPacket(), htcpSend(), MemBuf::init(), Http::LAST_MODIFIED, StoreEntry::lastModified(), htcpSpecifier::method, _htcpDataHeader::msg_id, netdbHostData(), HttpHeader::packInto(), HttpHeader::putExt(), HttpHeader::putInt(), HttpHeader::putTime(), htcpSpecifier::req_hdrs, htcpSpecifier::reqHdrsSz, htcpSpecifier::request, MemBuf::reset(), htcpDetail::resp_hdrs, htcpDetail::respHdrsSz, htcpStuff::response, RR_RESPONSE, htcpStuff::S, safe_free, squid_curtime, SQUIDHOSTNAMELEN, StoreEntry::timestamp, htcpSpecifier::uri, HttpRequest::url, htcpSpecifier::version, and xstrdup.
Referenced by htcpSpecifier::checkedHit().
◆ htcpUnpackDetail()
|
static |
Definition at line 721 of file htcp.cc.
References htcpDetail::cache_hdrs, htcpDetail::cacheHdrsSz, debugs, htcpDetail::entity_hdrs, htcpDetail::entityHdrsSz, htcpDetail::resp_hdrs, and htcpDetail::respHdrsSz.
Referenced by htcpHandleTstResponse().
◆ htcpUnpackSpecifier()
|
static |
Definition at line 614 of file htcp.cc.
References debugs, HttpRequest::FromUrlXXX(), HttpRequestMethod::HttpRequestMethodXXX(), Http::METHOD_GET, Http::METHOD_NONE, and Store::nil.
Referenced by htcpHandleClr(), and htcpHandleTstRequest().
Variable Documentation
◆ htcpIncomingConn
|
static |
Definition at line 241 of file htcp.cc.
Referenced by htcpClear(), htcpOpenPorts(), htcpQuery(), and htcpSocketShutdown().
◆ htcpOpcodeStr
|
static |
Definition at line 208 of file htcp.cc.
Referenced by htcpBuildOpData(), htcpHandleMsg(), and htcpSyncAle().
◆ htcpOutgoingConn
|
static |
Definition at line 240 of file htcp.cc.
Referenced by htcpClosePorts(), htcpIncomingConnectionOpened(), htcpOpenPorts(), htcpSend(), and htcpSocketShutdown().
◆ msg_id_counter
|
static |
Definition at line 238 of file htcp.cc.
Referenced by htcpClear(), and htcpQuery().
◆ old_squid_format
|
static |
Definition at line 248 of file htcp.cc.
Referenced by htcpBuildData(), htcpBuildPacket(), htcpClear(), htcpHandleMsg(), and htcpQuery().
◆ queried_addr
|
static |
Definition at line 246 of file htcp.cc.
Referenced by htcpHandleTstResponse(), and htcpQuery().
◆ queried_id
|
static |
Definition at line 243 of file htcp.cc.
Referenced by htcpHandleTstResponse(), and htcpQuery().
◆ queried_keys
|
static |
Definition at line 244 of file htcp.cc.
Referenced by htcpHandleTstResponse(), and htcpQuery().