2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
13 \defgroup ServerProtocolICPAPI ICP
14 \ingroup ServerProtocol
17 #include "base/RefCount.h"
18 #include "comm/forward.h"
19 #include "icp_opcode.h"
20 #include "ip/Address.h"
22 #include "store_key_md5.h"
23 #include "StoreClient.h"
28 typedef RefCount
<AccessLogEntry
> AccessLogEntryPointer
;
31 * Wire-level ICP header.
32 * DO NOT add or move fields.
33 * DO NOT add virtual methods.
40 unsigned char version
;
41 /** total length (bytes) */
42 unsigned short length
;
43 /** req number (req'd for UDP) */
51 icp_common_t(char *buf
, unsigned int len
);
53 void handleReply(char *buf
, Ip::Address
&from
);
54 icp_opcode
getOpCode() const;
56 /// \returns newly allocated buffer with an ICP message, including header
57 static icp_common_t
*CreateMessage(icp_opcode opcode
, int flags
, const char *url
, int reqnum
, int pad
);
61 \ingroup ServerProtocolICPAPI
64 class ICPState
: public StoreClient
68 ICPState(icp_common_t
&aHeader
, HttpRequest
*aRequest
);
80 virtual LogTags
*loggingTags() override
;
81 virtual void fillChecklist(ACLFilledChecklist
&) const override
;
83 /// either confirms and starts processing a cache hit or returns false
84 bool confirmAndPrepHit(const StoreEntry
&);
86 mutable AccessLogEntryPointer al
;
89 extern Comm::ConnectionPointer icpIncomingConn
;
90 extern Comm::ConnectionPointer icpOutgoingConn
;
91 extern Ip::Address theIcpPublicHostID
;
93 /// \ingroup ServerProtocolICPAPI
94 HttpRequest
* icpGetRequest(char *url
, int reqnum
, int fd
, Ip::Address
&from
);
96 /// \ingroup ServerProtocolICPAPI
97 bool icpAccessAllowed(Ip::Address
&from
, HttpRequest
* icp_request
);
99 /// \ingroup ServerProtocolICPAPI
100 void icpCreateAndSend(icp_opcode
, int flags
, char const *url
, int reqnum
, int pad
, int fd
, const Ip::Address
&from
, AccessLogEntryPointer
);
102 /// \ingroup ServerProtocolICPAPI
103 icp_opcode
icpGetCommonOpcode();
105 /// \ingroup ServerProtocolICPAPI
106 void icpDenyAccess(Ip::Address
&from
, char *url
, int reqnum
, int fd
);
108 /// \ingroup ServerProtocolICPAPI
111 /// \ingroup ServerProtocolICPAPI
112 void icpHandleIcpV3(int, Ip::Address
&, char *, int);
114 /// \ingroup ServerProtocolICPAPI
115 void icpOpenPorts(void);
117 /// \ingroup ServerProtocolICPAPI
118 void icpConnectionShutdown(void);
120 /// \ingroup ServerProtocolICPAPI
121 void icpClosePorts(void);
123 /// \ingroup ServerProtocolICPAPI
124 int icpSetCacheKey(const cache_key
* key
);
126 /// \ingroup ServerProtocolICPAPI
127 const cache_key
*icpGetCacheKey(const char *url
, int reqnum
);
129 #endif /* SQUID_ICP_H */