66static void icpCount(
void *,
int,
size_t,
int);
106 flags(0), pad(0), shostid(0)
162 e->abandon(__func__);
280 char *urloffset =
nullptr;
285 buf_len +=
sizeof(uint32_t);
287 buf = (
char *)
xcalloc(buf_len, 1);
295 headerp->
length = (uint16_t) htons(buf_len);
301 headerp->
pad = htonl(
pad);
308 urloffset +=
sizeof(uint32_t);
310 memcpy(urloffset, url, strlen(url));
328 debugs(12, 5,
"icpUdpSend: FD " << fd <<
" sending " <<
336 icpLogIcp(to, logcode, len, (
char *) (msg + 1), delay, al);
339 }
else if (0 == delay) {
412 fatal(
"expected ICP opcode\n");
446 debugs(12, 2,
"Access Denied due to lack of ICP access rules.");
453 const auto &answer = checklist.
fastCheck();
454 if (answer.allowed())
457 debugs(12, 2,
"Access Denied for " << from <<
" by " << answer.lastCheckDescription() <<
".");
464 const auto receivedPacketSize =
static_cast<size_t>(header.
length);
465 const auto payloadOffset =
sizeof(header);
469 const auto urlOffset = payloadOffset + ((header.
opcode ==
ICP_QUERY) ?
sizeof(uint32_t) : 0);
473 if (urlOffset >= receivedPacketSize) {
474 debugs(12, 3,
"too small packet from " << from <<
": " << urlOffset <<
" >= " << receivedPacketSize);
480 if (buf[receivedPacketSize - 1] !=
'\0') {
481 debugs(12, 3,
"unterminated URL or trailing garbage from " << from);
485 const auto url = buf + urlOffset;
486 if (urlOffset + strlen(url) + 1 != receivedPacketSize) {
487 debugs(12, 3,
"URL with an embedded NUL or trailing garbage from " << from);
502 const auto mx = MasterXaction::MakePortless<XactionInitiator::initIcp>();
523 const auto url =
icpGetUrl(from, buf, header);
538 src_rtt = ((hops & 0xFFFF) << 16) | (rtt & 0xFFFF);
546 ICP2State state(header, icp_request.getRaw());
581 debugs(12,
DBG_CRITICAL,
"icpHandleIcpV2: Neighbor " << from <<
" returned reqnum = 0");
586 const auto url =
icpGetUrl(from, buf, *
this);
600 debugs(12, 3,
"icpHandleIcpV2: ICP message is too small");
609 if (len != header.
length) {
610 debugs(12, 3,
"icpHandleIcpV2: ICP message is too small");
680 if (xerrno != ECONNREFUSED && xerrno != EHOSTUNREACH)
690 debugs(12, 4,
"icpHandleUdp: FD " << sock <<
": received " <<
691 (
unsigned long int)len <<
" bytes from " << from);
694 debugs(12, 4,
"icpHandleUdp: Ignoring too-small UDP packet");
698 icp_version = (
int) buf[1];
705 debugs(12, 4,
"icpHandleUdp: Ignoring UDP packet sent by myself");
712 " received from " << from);
730 fatal(
"ICP port cannot be opened.");
750 fatal(
"ICP port cannot be opened.");
762 fatal(
"Cannot open Outgoing ICP Port");
774 const auto &conn = answer.
conn;
777 fatal(
"Cannot open ICP Port");
786 fd_note(conn->fd,
"Incoming ICP port");
835icpCount(
void *buf,
int which,
size_t len,
int delay)
839 if (len <
sizeof(*icp))
858 }
else if (
RECV == which) {
876#define N_QUERIED_KEYS 8192
877#define N_QUERIED_KEYS_MASK 8191
883 static int reqnum = 0;
void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *)
#define asyncCallbackFun(dbgSection, dbgLevel, function)
AsyncCall for calling back a function.
const char * icpGetUrl(const Ip::Address &from, const char *, const icp_common_t &)
Acl::Answer const & fastCheck()
void setRequest(HttpRequest *)
configure client request-related fields for the first time
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
struct timeval start_time
The time the master transaction started.
struct timeval trTime
The response time.
MessageSizes clientReplySz
counters for the response sent to client
class AccessLogEntry::CacheDetails cache
class AccessLogEntry::HttpDetails http
void setVirginUrlForMissingRequest(const SBuf &vu)
Remember Client URI (or equivalent) when there is no HttpRequest.
class AccessLogEntry::IcpDetails icp
void host(const char *src)
a delayed icpUdpSend() call
AccessLogEntryPointer ale
sender's master transaction summary
icp_common_t * msg
ICP message with network byte order fields.
Ip::Address address
remote peer (which may not be a cache_peer)
DelayedUdpSend * next
invasive FIFO queue of delayed ICP messages
struct timeval queue_time
queuing timestamp
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
AnyP::Uri url
the request URI
ICP2State(icp_common_t &aHeader, HttpRequest *aRequest)
LogTags * loggingTags() const override
bool isHit() const
whether the cache contains the requested entry
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
ICPState(icp_common_t &aHeader, HttpRequest *aRequest)
bool confirmAndPrepHit(const StoreEntry &) const
either confirms and starts processing a cache hit or returns false
unsigned short port() const
Comm::ConnectionPointer conn
opened listening socket
uint64_t payloadData
total size of payload block(s) excluding transfer encoding overheads
struct SquidConfig::@85 Addrs
struct SquidConfig::@90 onoff
wordlist * mcast_group_list
struct SquidConfig::@91 accessList
struct SquidConfig::@78 Port
ByteCounter r_kbytes_sent
ByteCounter q_kbytes_sent
ByteCounter q_kbytes_recv
ByteCounter r_kbytes_recv
struct StatCounters::@106 icp
bool didCollapse
whether startCollapsingOn() was called and returned true
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
bool hittingRequiresCollapsing() const
whether this entry can feed collapsed requests and only them
static int store_dirs_rebuilding
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
void handleReply(char *buf, Ip::Address &from)
icp_opcode getOpCode() const
static icp_common_t * CreateMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad)
void clientdbUpdate(const Ip::Address &addr, const LogTags <ype, AnyP::ProtocolType p, size_t size)
int clientdbCutoffDenied(const Ip::Address &addr)
int ignoreErrno(int ierrno)
int comm_udp_sendto(int fd, const Ip::Address &to_addr, const void *buf, int len)
void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from)
A const & max(A const &lhs, A const &rhs)
#define debugs(SECTION, LEVEL, CONTENT)
#define COMM_SELECT_WRITE
#define ICP_VERSION_CURRENT
void fatal(const char *message)
void fd_note(int fd, const char *s)
int neighbors_do_private_keys
time_t hit_only_mode_until
int incoming_sockets_accepted
void ipcache_nbgethostbyname(const char *name, IPH *handler, void *handlerData)
icp_opcode icpGetCommonOpcode()
void icpDenyAccess(const Ip::Address &from, const char *const url, const int reqnum, const int fd)
int icpSetCacheKey(const cache_key *key)
void icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from, AccessLogEntry::Pointer al)
HttpRequest::Pointer icpGetRequest(const char *const url, const int reqnum, const int fd, const Ip::Address &from)
void icpConnectionShutdown(void)
void icpHandleIcpV3(int, Ip::Address &, char *, int)
const cache_key * icpGetCacheKey(const char *url, int reqnum)
static void icpHandleIcpV2(int, Ip::Address &, char *, int)
Comm::ConnectionPointer icpOutgoingConn
static void icpCount(void *, int, size_t, int)
Comm::ConnectionPointer icpIncomingConn
static void icpLogIcp(const Ip::Address &, const LogTags_ot, int, const char *, const int, AccessLogEntryPointer &)
updates ALE (if any) and logs the transaction (if needed)
static DelayedUdpSend * IcpQueueTail
static DelayedUdpSend * IcpQueueHead
static void icpUdpSendQueue(int fd, void *)
void HTTPMSGUNLOCK(M *&a)
void HTTPMSGLOCK(Http::Message *a)
const char * icp_opcode_str[]
static void icpIncomingConnectionOpened(Ipc::StartListeningAnswer &)
static void doV2Query(const int fd, Ip::Address &from, const char *const buf, icp_common_t header)
#define N_QUERIED_KEYS_MASK
static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH]
const char * icpGetUrl(const Ip::Address &from, const char *const buf, const icp_common_t &header)
static int icpUdpSend(int fd, const Ip::Address &to, icp_common_t *msg, int delay, AccessLogEntryPointer al)
static bool icpAccessAllowed(const Ip::Address &from, HttpRequest *icp_request)
icpGetRequest() helper that determines whether squid.conf allows the given ICP query
static LogTags_ot icpLogFromICPCode(icp_opcode)
static void icpSyncAle(AccessLogEntryPointer &al, const Ip::Address &caddr, const char *url, int len, int delay)
#define SQUID_MD5_DIGEST_LENGTH
bool IsConnOpen(const Comm::ConnectionPointer &conn)
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
void StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn, FdNoteId, StartListeningCallback &)
void neighborsUdpAck(const cache_key *key, icp_common_t *header, const Ip::Address &from)
void netdbPingSite(const char *hostname)
int netdbHostHops(const char *host)
int netdbHostRtt(const char *host)
int refreshCheckICP(const StoreEntry *entry, HttpRequest *request)
#define rfc1738_escape(x)
#define LOCAL_ARRAY(type, name, size)
#define SQUID_UDP_SO_RCVBUF
unsigned char cache_key
Store key.
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
cache_key * storeKeyCopy(cache_key *dst, const cache_key *src)
const cache_key * storeKeyPublic(const char *url, const HttpRequestMethod &method, const KeyScope keyScope)
int tvSubUsec(struct timeval t1, struct timeval t2)
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
void * xcalloc(size_t n, size_t sz)
const char * xstrerr(int error)