]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ICP.h
Fix clang (with its own libc++) build after 9865de7 (#661)
[thirdparty/squid.git] / src / ICP.h
CommitLineData
e6ccf245 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
e6ccf245 3 *
bbc27441
AJ
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.
e6ccf245 7 */
8
9#ifndef SQUID_ICP_H
10#define SQUID_ICP_H
11
63be0a78 12/**
13 \defgroup ServerProtocolICPAPI ICP
14 \ingroup ServerProtocol
15 */
16
819be284 17#include "base/RefCount.h"
e0d28505 18#include "comm/forward.h"
582c2af2 19#include "icp_opcode.h"
e0d28505 20#include "ip/Address.h"
02c8dde5 21#include "LogTags.h"
e1ba42a4 22#include "store_key_md5.h"
9c947ba7 23#include "StoreClient.h"
e6ccf245 24
819be284 25class AccessLogEntry;
582c2af2
FC
26class HttpRequest;
27
819be284
EB
28typedef RefCount<AccessLogEntry> AccessLogEntryPointer;
29
077fe581 30/**
cb835136
AR
31 * Wire-level ICP header.
32 * DO NOT add or move fields.
e6ccf245 33 * DO NOT add virtual methods.
34 */
cb835136
AR
35class icp_common_t {
36public:
63be0a78 37 /** opcode */
38 unsigned char opcode;
39 /** version number */
40 unsigned char version;
41 /** total length (bytes) */
42 unsigned short length;
43 /** req number (req'd for UDP) */
09aabd84
FC
44 uint32_t reqnum;
45 uint32_t flags;
46 uint32_t pad;
63be0a78 47 /** sender host id */
09aabd84 48 uint32_t shostid;
63be0a78 49
cb835136
AR
50 icp_common_t();
51 icp_common_t(char *buf, unsigned int len);
62e76326 52
b7ac5457 53 void handleReply(char *buf, Ip::Address &from);
e6ccf245 54 icp_opcode getOpCode() const;
09bbee4c 55
cb835136
AR
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);
58};
e6ccf245 59
63be0a78 60/**
61 \ingroup ServerProtocolICPAPI
62 \todo mempool this
63 */
819be284 64class ICPState: public StoreClient
62e76326 65{
66
67public:
63be0a78 68 ICPState(icp_common_t &aHeader, HttpRequest *aRequest);
69 virtual ~ICPState();
819be284 70
e6ccf245 71 icp_common_t header;
190154cf 72 HttpRequest *request;
e6ccf245 73 int fd;
62e76326 74
b7ac5457 75 Ip::Address from;
e6ccf245 76 char *url;
819be284
EB
77
78protected:
79 /* StoreClient API */
d2a6dcba 80 virtual LogTags *loggingTags() override;
819be284 81 virtual void fillChecklist(ACLFilledChecklist &) const override;
62e76326 82
d2a6dcba
EB
83 /// either confirms and starts processing a cache hit or returns false
84 bool confirmAndPrepHit(const StoreEntry &);
62e76326 85
d2a6dcba 86 mutable AccessLogEntryPointer al;
d4cb310b 87};
88
e0d28505
AJ
89extern Comm::ConnectionPointer icpIncomingConn;
90extern Comm::ConnectionPointer icpOutgoingConn;
91extern Ip::Address theIcpPublicHostID;
92
63be0a78 93/// \ingroup ServerProtocolICPAPI
8a648e8d 94HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from);
62e76326 95
63be0a78 96/// \ingroup ServerProtocolICPAPI
8a648e8d 97bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
62e76326 98
63be0a78 99/// \ingroup ServerProtocolICPAPI
819be284 100void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from, AccessLogEntryPointer);
63be0a78 101
102/// \ingroup ServerProtocolICPAPI
8a648e8d 103icp_opcode icpGetCommonOpcode();
e6ccf245 104
63be0a78 105/// \ingroup ServerProtocolICPAPI
b7ac5457 106void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
63be0a78 107
108/// \ingroup ServerProtocolICPAPI
8a648e8d 109PF icpHandleUdp;
63be0a78 110
63be0a78 111/// \ingroup ServerProtocolICPAPI
8a648e8d 112void icpHandleIcpV3(int, Ip::Address &, char *, int);
63be0a78 113
63be0a78 114/// \ingroup ServerProtocolICPAPI
8a648e8d 115void icpOpenPorts(void);
63be0a78 116
117/// \ingroup ServerProtocolICPAPI
8a648e8d 118void icpConnectionShutdown(void);
63be0a78 119
120/// \ingroup ServerProtocolICPAPI
8a648e8d 121void icpClosePorts(void);
63be0a78 122
123/// \ingroup ServerProtocolICPAPI
8a648e8d 124int icpSetCacheKey(const cache_key * key);
e6ccf245 125
63be0a78 126/// \ingroup ServerProtocolICPAPI
8a648e8d 127const cache_key *icpGetCacheKey(const char *url, int reqnum);
e6ccf245 128
e6ccf245 129#endif /* SQUID_ICP_H */
f53969cc 130