2 * DEBUG: section 12 Internet Cache Protocol (ICP)
3 * AUTHOR: Duane Wessels
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 \defgroup ServerProtocolICPInternal2 ICPv2 Internals
35 \ingroup ServerProtocolICPAPI
39 #include "AccessLogEntry.h"
41 #include "acl/FilledChecklist.h"
42 #include "client_db.h"
44 #include "comm/Connection.h"
45 #include "comm/Loops.h"
46 #include "comm/UdpOpenDialer.h"
48 #include "HttpRequest.h"
49 #include "icmp/net_db.h"
51 #include "ip/Address.h"
55 #include "multicast.h"
56 #include "neighbors.h"
59 #include "SquidConfig.h"
60 #include "SquidTime.h"
61 #include "StatCounters.h"
63 #include "store_key_md5.h"
72 static void icpIncomingConnectionOpened(const Comm::ConnectionPointer
&conn
, int errNo
);
74 /// \ingroup ServerProtocolICPInternal2
75 static void icpLogIcp(const Ip::Address
&, LogTags
, int, const char *, int);
77 /// \ingroup ServerProtocolICPInternal2
78 static void icpHandleIcpV2(int, Ip::Address
&, char *, int);
80 /// \ingroup ServerProtocolICPInternal2
81 static void icpCount(void *, int, size_t, int);
84 \ingroup ServerProtocolICPInternal2
85 * IcpQueueHead is global so comm_incoming() knows whether or not
86 * to call icpUdpSendQueue.
88 static icpUdpData
*IcpQueueHead
= NULL
;
89 /// \ingroup ServerProtocolICPInternal2
90 static icpUdpData
*IcpQueueTail
= NULL
;
92 /// \ingroup ServerProtocolICPInternal2
93 Comm::ConnectionPointer icpIncomingConn
= NULL
;
94 /// \ingroup ServerProtocolICPInternal2
95 Comm::ConnectionPointer icpOutgoingConn
= NULL
;
98 _icp_common_t::_icp_common_t() :
99 opcode(ICP_INVALID
), version(0), length(0), reqnum(0),
100 flags(0), pad(0), shostid(0)
103 _icp_common_t::_icp_common_t(char *buf
, unsigned int len
) :
104 opcode(ICP_INVALID
), version(0), reqnum(0), flags(0), pad(0), shostid(0)
106 if (len
< sizeof(_icp_common_t
)) {
107 /* mark as invalid */
112 memcpy(this, buf
, sizeof(icp_common_t
));
114 * Convert network order sensitive fields
116 length
= ntohs(length
);
117 reqnum
= ntohl(reqnum
);
118 flags
= ntohl(flags
);
123 _icp_common_t::getOpCode() const
125 if (opcode
> (char)ICP_END
)
128 return (icp_opcode
)opcode
;
133 ICPState::ICPState(icp_common_t
&aHeader
, HttpRequest
*aRequest
):
139 HTTPMSGLOCK(request
);
142 ICPState::~ICPState()
145 HTTPMSGUNLOCK(request
);
152 /// \ingroup ServerProtocolICPInternal2
153 class ICP2State
: public ICPState
, public StoreClient
157 ICP2State(icp_common_t
& aHeader
, HttpRequest
*aRequest
):
158 ICPState(aHeader
, aRequest
),rtt(0),src_rtt(0),flags(0) {}
161 void created(StoreEntry
* newEntry
);
168 ICP2State::~ICP2State()
172 ICP2State::created(StoreEntry
*newEntry
)
174 StoreEntry
*entry
= newEntry
->isNull () ? NULL
: newEntry
;
175 debugs(12, 5, "icpHandleIcpV2: OPCODE " << icp_opcode_str
[header
.opcode
]);
176 icp_opcode codeToSend
;
178 if (icpCheckUdpHit(entry
, request
)) {
179 codeToSend
= ICP_HIT
;
182 if (Config
.onoff
.test_reachability
&& rtt
== 0) {
183 if ((rtt
= netdbHostRtt(request
->GetHost())) == 0)
184 netdbPingSite(request
->GetHost());
186 #endif /* USE_ICMP */
188 if (icpGetCommonOpcode() != ICP_ERR
)
189 codeToSend
= icpGetCommonOpcode();
190 else if (Config
.onoff
.test_reachability
&& rtt
== 0)
191 codeToSend
= ICP_MISS_NOFETCH
;
193 codeToSend
= ICP_MISS
;
196 icpCreateAndSend(codeToSend
, flags
, url
, header
.reqnum
, src_rtt
, fd
, from
);
202 /// \ingroup ServerProtocolICPInternal2
204 icpLogIcp(const Ip::Address
&caddr
, LogTags logcode
, int len
, const char *url
, int delay
)
206 AccessLogEntry::Pointer al
= new AccessLogEntry();
208 if (LOG_TAG_NONE
== logcode
)
211 if (LOG_ICP_QUERY
== logcode
)
214 clientdbUpdate(caddr
, logcode
, AnyP::PROTO_ICP
, len
);
216 if (!Config
.onoff
.log_udp
)
219 al
->icp
.opcode
= ICP_QUERY
;
223 al
->cache
.caddr
= caddr
;
225 // XXX: move to use icp.clientReply instead
226 al
->http
.clientReplySz
.payloadData
= len
;
228 al
->cache
.code
= logcode
;
230 al
->cache
.msec
= delay
;
232 accessLogLog(al
, NULL
);
235 /// \ingroup ServerProtocolICPInternal2
237 icpUdpSendQueue(int fd
, void *unused
)
241 while ((q
= IcpQueueHead
) != NULL
) {
242 int delay
= tvSubUsec(q
->queue_time
, current_time
);
243 /* increment delay to prevent looping */
244 const int x
= icpUdpSend(fd
, q
->address
, (icp_common_t
*) q
->msg
, q
->logcode
, ++delay
);
245 IcpQueueHead
= q
->next
;
254 _icp_common_t::createMessage(
262 icp_common_t
*headerp
= NULL
;
263 char *urloffset
= NULL
;
265 buf_len
= sizeof(icp_common_t
) + strlen(url
) + 1;
267 if (opcode
== ICP_QUERY
)
268 buf_len
+= sizeof(uint32_t);
270 buf
= (char *) xcalloc(buf_len
, 1);
272 headerp
= (icp_common_t
*) (void *) buf
;
274 headerp
->opcode
= (char) opcode
;
276 headerp
->version
= ICP_VERSION_CURRENT
;
278 headerp
->length
= (uint16_t) htons(buf_len
);
280 headerp
->reqnum
= htonl(reqnum
);
282 headerp
->flags
= htonl(flags
);
284 headerp
->pad
= htonl(pad
);
286 headerp
->shostid
= 0;
288 urloffset
= buf
+ sizeof(icp_common_t
);
290 if (opcode
== ICP_QUERY
)
291 urloffset
+= sizeof(uint32_t);
293 memcpy(urloffset
, url
, strlen(url
));
295 return (icp_common_t
*)buf
;
300 const Ip::Address
&to
,
308 len
= (int) ntohs(msg
->length
);
309 debugs(12, 5, "icpUdpSend: FD " << fd
<< " sending " <<
310 icp_opcode_str
[msg
->opcode
] << ", " << len
<< " bytes to " << to
);
312 x
= comm_udp_sendto(fd
, to
, msg
, len
);
315 /* successfully written */
316 icpLogIcp(to
, logcode
, len
, (char *) (msg
+ 1), delay
);
317 icpCount(msg
, SENT
, (size_t) len
, delay
);
319 } else if (0 == delay
) {
320 /* send failed, but queue it */
321 queue
= (icpUdpData
*) xcalloc(1, sizeof(icpUdpData
));
324 queue
->len
= (int) ntohs(msg
->length
);
325 queue
->queue_time
= current_time
;
326 queue
->logcode
= logcode
;
328 if (IcpQueueHead
== NULL
) {
329 IcpQueueHead
= queue
;
330 IcpQueueTail
= queue
;
331 } else if (IcpQueueTail
== IcpQueueHead
) {
332 IcpQueueTail
= queue
;
333 IcpQueueHead
->next
= queue
;
335 IcpQueueTail
->next
= queue
;
336 IcpQueueTail
= queue
;
339 Comm::SetSelect(fd
, COMM_SELECT_WRITE
, icpUdpSendQueue
, NULL
, 0);
340 ++statCounter
.icp
.replies_queued
;
343 ++statCounter
.icp
.replies_dropped
;
350 icpCheckUdpHit(StoreEntry
* e
, HttpRequest
* request
)
355 if (!e
->validToSend())
358 if (Config
.onoff
.icp_hit_stale
)
361 if (refreshCheckICP(e
, request
))
368 * This routine selects an ICP opcode for ICP misses.
370 \retval ICP_ERR no opcode selected here
371 \retval ICP_MISS_NOFETCH store is rebuilding, no fetch is possible yet
376 /* if store is rebuilding, return a UDP_MISS_NOFETCH */
378 if ((StoreController::store_dirs_rebuilding
&& opt_reload_hit_only
) ||
379 hit_only_mode_until
> squid_curtime
) {
380 return ICP_MISS_NOFETCH
;
387 icpLogFromICPCode(icp_opcode opcode
)
389 if (opcode
== ICP_ERR
)
390 return LOG_UDP_INVALID
;
392 if (opcode
== ICP_DENIED
)
393 return LOG_UDP_DENIED
;
395 if (opcode
== ICP_HIT
)
398 if (opcode
== ICP_MISS
)
401 if (opcode
== ICP_MISS_NOFETCH
)
402 return LOG_UDP_MISS_NOFETCH
;
404 fatal("expected ICP opcode\n");
406 return LOG_UDP_INVALID
;
410 icpCreateAndSend(icp_opcode opcode
, int flags
, char const *url
, int reqnum
, int pad
, int fd
, const Ip::Address
&from
)
412 icp_common_t
*reply
= _icp_common_t::createMessage(opcode
, flags
, url
, reqnum
, pad
);
413 icpUdpSend(fd
, from
, reply
, icpLogFromICPCode(opcode
), 0);
417 icpDenyAccess(Ip::Address
&from
, char *url
, int reqnum
, int fd
)
419 debugs(12, 2, "icpDenyAccess: Access Denied for " << from
<< " by " << AclMatchedName
<< ".");
421 if (clientdbCutoffDenied(from
)) {
423 * count this DENIED query in the clientdb, even though
424 * we're not sending an ICP reply...
426 clientdbUpdate(from
, LOG_UDP_DENIED
, AnyP::PROTO_ICP
, 0);
428 icpCreateAndSend(ICP_DENIED
, 0, url
, reqnum
, 0, fd
, from
);
433 icpAccessAllowed(Ip::Address
&from
, HttpRequest
* icp_request
)
435 /* absent any explicit rules, we deny all */
436 if (!Config
.accessList
.icp
)
439 ACLFilledChecklist
checklist(Config
.accessList
.icp
, icp_request
, NULL
);
440 checklist
.src_addr
= from
;
441 checklist
.my_addr
.setNoAddr();
442 return (checklist
.fastCheck() == ACCESS_ALLOWED
);
446 icpGetUrlToSend(char *url
)
448 if (strpbrk(url
, w_space
))
449 return rfc1738_escape(url
);
455 icpGetRequest(char *url
, int reqnum
, int fd
, Ip::Address
&from
)
457 if (strpbrk(url
, w_space
)) {
458 url
= rfc1738_escape(url
);
459 icpCreateAndSend(ICP_ERR
, 0, rfc1738_escape(url
), reqnum
, 0, fd
, from
);
465 if ((result
= HttpRequest::CreateFromUrl(url
)) == NULL
)
466 icpCreateAndSend(ICP_ERR
, 0, url
, reqnum
, 0, fd
, from
);
473 doV2Query(int fd
, Ip::Address
&from
, char *buf
, icp_common_t header
)
478 /* We have a valid packet */
479 char *url
= buf
+ sizeof(icp_common_t
) + sizeof(uint32_t);
480 HttpRequest
*icp_request
= icpGetRequest(url
, header
.reqnum
, fd
, from
);
485 HTTPMSGLOCK(icp_request
);
487 if (!icpAccessAllowed(from
, icp_request
)) {
488 icpDenyAccess(from
, url
, header
.reqnum
, fd
);
489 HTTPMSGUNLOCK(icp_request
);
493 if (header
.flags
& ICP_FLAG_SRC_RTT
) {
494 rtt
= netdbHostRtt(icp_request
->GetHost());
495 int hops
= netdbHostHops(icp_request
->GetHost());
496 src_rtt
= ((hops
& 0xFFFF) << 16) | (rtt
& 0xFFFF);
499 flags
|= ICP_FLAG_SRC_RTT
;
501 #endif /* USE_ICMP */
503 /* The peer is allowed to use this cache */
504 ICP2State
*state
= new ICP2State(header
, icp_request
);
507 state
->url
= xstrdup(url
);
508 state
->flags
= flags
;
510 state
->src_rtt
= src_rtt
;
512 StoreEntry::getPublic(state
, url
, Http::METHOD_GET
);
514 HTTPMSGUNLOCK(icp_request
);
518 _icp_common_t::handleReply(char *buf
, Ip::Address
&from
)
520 if (neighbors_do_private_keys
&& reqnum
== 0) {
521 debugs(12, DBG_CRITICAL
, "icpHandleIcpV2: Neighbor " << from
<< " returned reqnum = 0");
522 debugs(12, DBG_CRITICAL
, "icpHandleIcpV2: Disabling use of private keys");
523 neighbors_do_private_keys
= 0;
526 char *url
= buf
+ sizeof(icp_common_t
);
527 debugs(12, 3, "icpHandleIcpV2: " << icp_opcode_str
[opcode
] << " from " << from
<< " for '" << url
<< "'");
529 const cache_key
*key
= icpGetCacheKey(url
, (int) reqnum
);
530 /* call neighborsUdpAck even if ping_status != PING_WAITING */
531 neighborsUdpAck(key
, this, from
);
535 icpHandleIcpV2(int fd
, Ip::Address
&from
, char *buf
, int len
)
538 debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
542 icp_common_t
header(buf
, len
);
544 * Length field should match the number of bytes read
547 if (len
!= header
.length
) {
548 debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
552 switch (header
.opcode
) {
555 /* We have a valid packet */
556 doV2Query(fd
, from
, buf
, header
);
567 case ICP_MISS_NOFETCH
:
568 header
.handleReply(buf
, from
);
577 debugs(12, DBG_CRITICAL
, "icpHandleIcpV2: UNKNOWN OPCODE: " << header
.opcode
<< " from " << from
);
585 icpPktDump(icp_common_t
* pkt
)
589 debugs(12, 9, "opcode: " << std::setw(3) << pkt
->opcode
<< " " << icp_opcode_str
[pkt
->opcode
]);
590 debugs(12, 9, "version: "<< std::left
<< std::setw(8) << pkt
->version
);
591 debugs(12, 9, "length: "<< std::left
<< std::setw(8) << ntohs(pkt
->length
));
592 debugs(12, 9, "reqnum: "<< std::left
<< std::setw(8) << ntohl(pkt
->reqnum
));
593 debugs(12, 9, "flags: "<< std::left
<< std::hex
<< std::setw(8) << ntohl(pkt
->flags
));
594 a
= (struct in_addr
)pkt
->shostid
;
595 debugs(12, 9, "shostid: " << a
);
596 debugs(12, 9, "payload: " << (char *) pkt
+ sizeof(icp_common_t
));
602 icpHandleUdp(int sock
, void *data
)
604 int *N
= &incoming_sockets_accepted
;
607 LOCAL_ARRAY(char, buf
, SQUID_UDP_SO_RCVBUF
);
610 int max
= INCOMING_UDP_MAX
;
611 Comm::SetSelect(sock
, COMM_SELECT_READ
, icpHandleUdp
, NULL
, 0);
615 len
= comm_udp_recvfrom(sock
,
617 SQUID_UDP_SO_RCVBUF
- 1,
625 if (ignoreErrno(errno
))
629 /* Some Linux systems seem to set the FD for reading and then
630 * return ECONNREFUSED when sendto() fails and generates an ICMP
631 * port unreachable message. */
632 /* or maybe an EHOSTUNREACH "No route to host" message */
633 if (errno
!= ECONNREFUSED
&& errno
!= EHOSTUNREACH
)
636 debugs(50, DBG_IMPORTANT
, "icpHandleUdp: FD " << sock
<< " recvfrom: " << xstrerror());
642 icpCount(buf
, RECV
, (size_t) len
, 0);
644 debugs(12, 4, "icpHandleUdp: FD " << sock
<< ": received " <<
645 (unsigned long int)len
<< " bytes from " << from
);
647 #ifdef ICP_PACKET_DUMP
652 if ((size_t) len
< sizeof(icp_common_t
)) {
653 debugs(12, 4, "icpHandleUdp: Ignoring too-small UDP packet");
657 icp_version
= (int) buf
[1]; /* cheat! */
659 if (icpOutgoingConn
->local
== from
)
660 // ignore ICP packets which loop back (multicast usually)
661 debugs(12, 4, "icpHandleUdp: Ignoring UDP packet sent by myself");
662 else if (icp_version
== ICP_VERSION_2
)
663 icpHandleIcpV2(sock
, from
, buf
, len
);
664 else if (icp_version
== ICP_VERSION_3
)
665 icpHandleIcpV3(sock
, from
, buf
, len
);
667 debugs(12, DBG_IMPORTANT
, "WARNING: Unused ICP version " << icp_version
<<
668 " received from " << from
);
677 if ((port
= Config
.Port
.icp
) <= 0)
680 icpIncomingConn
= new Comm::Connection
;
681 icpIncomingConn
->local
= Config
.Addrs
.udp_incoming
;
682 icpIncomingConn
->local
.port(port
);
684 if (!Ip::EnableIpv6
&& !icpIncomingConn
->local
.setIPv4()) {
685 debugs(12, DBG_CRITICAL
, "ERROR: IPv6 is disabled. " << icpIncomingConn
->local
<< " is not an IPv4 address.");
686 fatal("ICP port cannot be opened.");
688 /* split-stack for now requires default IPv4-only ICP */
689 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& icpIncomingConn
->local
.isAnyAddr()) {
690 icpIncomingConn
->local
.setIPv4();
693 AsyncCall::Pointer call
= asyncCall(12, 2,
694 "icpIncomingConnectionOpened",
695 Comm::UdpOpenDialer(&icpIncomingConnectionOpened
));
697 Ipc::StartListening(SOCK_DGRAM
,
700 Ipc::fdnInIcpSocket
, call
);
702 if ( !Config
.Addrs
.udp_outgoing
.isNoAddr() ) {
703 icpOutgoingConn
= new Comm::Connection
;
704 icpOutgoingConn
->local
= Config
.Addrs
.udp_outgoing
;
705 icpOutgoingConn
->local
.port(port
);
707 if (!Ip::EnableIpv6
&& !icpOutgoingConn
->local
.setIPv4()) {
708 debugs(49, DBG_CRITICAL
, "ERROR: IPv6 is disabled. " << icpOutgoingConn
->local
<< " is not an IPv4 address.");
709 fatal("ICP port cannot be opened.");
711 /* split-stack for now requires default IPv4-only ICP */
712 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& icpOutgoingConn
->local
.isAnyAddr()) {
713 icpOutgoingConn
->local
.setIPv4();
717 comm_open_listener(SOCK_DGRAM
, IPPROTO_UDP
, icpOutgoingConn
, "Outgoing ICP Port");
720 if (!Comm::IsConnOpen(icpOutgoingConn
))
721 fatal("Cannot open Outgoing ICP Port");
723 debugs(12, DBG_CRITICAL
, "Sending ICP messages from " << icpOutgoingConn
->local
);
725 Comm::SetSelect(icpOutgoingConn
->fd
, COMM_SELECT_READ
, icpHandleUdp
, NULL
, 0);
726 fd_note(icpOutgoingConn
->fd
, "Outgoing ICP socket");
731 icpIncomingConnectionOpened(const Comm::ConnectionPointer
&conn
, int errNo
)
733 if (!Comm::IsConnOpen(conn
))
734 fatal("Cannot open ICP Port");
736 Comm::SetSelect(conn
->fd
, COMM_SELECT_READ
, icpHandleUdp
, NULL
, 0);
738 for (const wordlist
*s
= Config
.mcast_group_list
; s
; s
= s
->next
)
739 ipcache_nbgethostbyname(s
->key
, mcastJoinGroups
, NULL
); // XXX: pass the conn for mcastJoinGroups usage.
741 debugs(12, DBG_IMPORTANT
, "Accepting ICP messages on " << conn
->local
);
743 fd_note(conn
->fd
, "Incoming ICP port");
745 if (Config
.Addrs
.udp_outgoing
.isNoAddr()) {
746 icpOutgoingConn
= conn
;
747 debugs(12, DBG_IMPORTANT
, "Sending ICP messages from " << icpOutgoingConn
->local
);
752 * icpConnectionShutdown only closes the 'in' socket if it is
753 * different than the 'out' socket.
756 icpConnectionShutdown(void)
758 if (!Comm::IsConnOpen(icpIncomingConn
))
761 debugs(12, DBG_IMPORTANT
, "Stop receiving ICP on " << icpIncomingConn
->local
);
763 /** Release the 'in' socket for lazy closure.
764 * in and out sockets may be sharing one same FD.
765 * This prevents this function from executing repeatedly.
767 icpIncomingConn
= NULL
;
770 * Normally we only write to the outgoing ICP socket, but
771 * we also have a read handler there to catch messages sent
772 * to that specific interface. During shutdown, we must
773 * disable reading on the outgoing socket.
775 assert(Comm::IsConnOpen(icpOutgoingConn
));
777 Comm::SetSelect(icpOutgoingConn
->fd
, COMM_SELECT_READ
, NULL
, NULL
, 0);
783 icpConnectionShutdown();
785 if (icpOutgoingConn
!= NULL
) {
786 debugs(12, DBG_IMPORTANT
, "Stop sending ICP from " << icpOutgoingConn
->local
);
787 icpOutgoingConn
= NULL
;
792 icpCount(void *buf
, int which
, size_t len
, int delay
)
794 icp_common_t
*icp
= (icp_common_t
*) buf
;
796 if (len
< sizeof(*icp
))
800 ++statCounter
.icp
.pkts_sent
;
801 kb_incr(&statCounter
.icp
.kbytes_sent
, len
);
803 if (ICP_QUERY
== icp
->opcode
) {
804 ++statCounter
.icp
.queries_sent
;
805 kb_incr(&statCounter
.icp
.q_kbytes_sent
, len
);
807 ++statCounter
.icp
.replies_sent
;
808 kb_incr(&statCounter
.icp
.r_kbytes_sent
, len
);
809 /* this is the sent-reply service time */
810 statCounter
.icp
.replySvcTime
.count(delay
);
813 if (ICP_HIT
== icp
->opcode
)
814 ++statCounter
.icp
.hits_sent
;
815 } else if (RECV
== which
) {
816 ++statCounter
.icp
.pkts_recv
;
817 kb_incr(&statCounter
.icp
.kbytes_recv
, len
);
819 if (ICP_QUERY
== icp
->opcode
) {
820 ++statCounter
.icp
.queries_recv
;
821 kb_incr(&statCounter
.icp
.q_kbytes_recv
, len
);
823 ++statCounter
.icp
.replies_recv
;
824 kb_incr(&statCounter
.icp
.r_kbytes_recv
, len
);
825 /* statCounter.icp.querySvcTime set in clientUpdateCounters */
828 if (ICP_HIT
== icp
->opcode
)
829 ++statCounter
.icp
.hits_recv
;
833 #define N_QUERIED_KEYS 8192
834 #define N_QUERIED_KEYS_MASK 8191
835 static cache_key queried_keys
[N_QUERIED_KEYS
][SQUID_MD5_DIGEST_LENGTH
];
838 icpSetCacheKey(const cache_key
* key
)
840 static int reqnum
= 0;
845 storeKeyCopy(queried_keys
[reqnum
& N_QUERIED_KEYS_MASK
], key
);
851 icpGetCacheKey(const char *url
, int reqnum
)
853 if (neighbors_do_private_keys
&& reqnum
)
854 return queried_keys
[reqnum
& N_QUERIED_KEYS_MASK
];
856 return storeKeyPublic(url
, Http::METHOD_GET
);