]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ICP.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ICP.h
CommitLineData
e6ccf245 1/*
e6ccf245 2 *
3 * SQUID Web Proxy Cache http://www.squid-cache.org/
4 * ----------------------------------------------------------
5 *
6 * Squid is the result of efforts by numerous individuals from
7 * the Internet community; see the CONTRIBUTORS file for full
8 * details. Many organizations have provided support for Squid's
9 * development; see the SPONSORS file for full details. Squid is
10 * Copyrighted (C) 2001 by the Regents of the University of
11 * California; see the COPYRIGHT file for full details. Squid
12 * incorporates software developed and/or copyrighted by other
13 * sources; see the CREDITS file for full details.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
26ac0430 19 *
e6ccf245 20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
26ac0430 24 *
e6ccf245 25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28 *
29 */
30
31#ifndef SQUID_ICP_H
32#define SQUID_ICP_H
33
63be0a78 34/**
35 \defgroup ServerProtocolICPAPI ICP
36 \ingroup ServerProtocol
37 */
38
e0d28505 39#include "comm/forward.h"
582c2af2 40#include "icp_opcode.h"
e0d28505 41#include "ip/Address.h"
02c8dde5 42#include "LogTags.h"
602d9612 43#include "StoreClient.h"
e6ccf245 44
582c2af2
FC
45class HttpRequest;
46
077fe581 47/**
63be0a78 48 \ingroup ServerProtocolICPAPI
49 *
077fe581 50 * This struct is the wire-level header.
51 * DO NOT add more move fields on pain of breakage.
e6ccf245 52 * DO NOT add virtual methods.
53 */
26ac0430 54struct _icp_common_t {
63be0a78 55 /** opcode */
56 unsigned char opcode;
57 /** version number */
58 unsigned char version;
59 /** total length (bytes) */
60 unsigned short length;
61 /** req number (req'd for UDP) */
09aabd84
FC
62 uint32_t reqnum;
63 uint32_t flags;
64 uint32_t pad;
63be0a78 65 /** sender host id */
09aabd84 66 uint32_t shostid;
63be0a78 67
68/// \todo I don't believe this header is included in non-c++ code anywhere
d85b8894 69/// the struct should become a public POD class and kill these ifdef.
e6ccf245 70#ifdef __cplusplus
62e76326 71
72 _icp_common_t();
73 _icp_common_t(char *buf, unsigned int len);
74
b7ac5457 75 void handleReply(char *buf, Ip::Address &from);
e6ccf245 76 static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
77 icp_opcode getOpCode() const;
78#endif
79};
09bbee4c
FC
80typedef struct _icp_common_t icp_common_t;
81
e6ccf245 82#ifdef __cplusplus
83
63be0a78 84/// \ingroup ServerProtocolICPAPI
62e76326 85inline icp_opcode & operator++ (icp_opcode & aCode)
86{
1f1ae50a 87 int tmp = (int) aCode;
88 aCode = (icp_opcode) (++tmp);
e6ccf245 89 return aCode;
90}
91
63be0a78 92/**
93 \ingroup ServerProtocolICPAPI
94 \todo mempool this
95 */
62e76326 96class ICPState
97{
98
99public:
63be0a78 100 ICPState(icp_common_t &aHeader, HttpRequest *aRequest);
101 virtual ~ICPState();
e6ccf245 102 icp_common_t header;
190154cf 103 HttpRequest *request;
e6ccf245 104 int fd;
62e76326 105
b7ac5457 106 Ip::Address from;
e6ccf245 107 char *url;
108};
109
110#endif
111
63be0a78 112/// \ingroup ServerProtocolICPAPI
26ac0430 113struct icpUdpData {
65d448bc
AJ
114
115 /// IP address for the remote end. Because we reply to packets from unknown non-peers.
b7ac5457 116 Ip::Address address;
65d448bc 117
d4cb310b 118 void *msg;
119 size_t len;
120 icpUdpData *next;
121#ifndef LESS_TIMING
62e76326 122
d4cb310b 123 struct timeval start;
124#endif
62e76326 125
02c8dde5 126 LogTags logcode;
62e76326 127
d4cb310b 128 struct timeval queue_time;
129};
130
e0d28505
AJ
131extern Comm::ConnectionPointer icpIncomingConn;
132extern Comm::ConnectionPointer icpOutgoingConn;
133extern Ip::Address theIcpPublicHostID;
134
63be0a78 135/// \ingroup ServerProtocolICPAPI
8a648e8d 136HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from);
62e76326 137
63be0a78 138/// \ingroup ServerProtocolICPAPI
8a648e8d 139bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
62e76326 140
63be0a78 141/// \ingroup ServerProtocolICPAPI
8a648e8d 142void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from);
63be0a78 143
144/// \ingroup ServerProtocolICPAPI
8a648e8d 145icp_opcode icpGetCommonOpcode();
e6ccf245 146
63be0a78 147/// \ingroup ServerProtocolICPAPI
02c8dde5 148int icpUdpSend(int, const Ip::Address &, icp_common_t *, LogTags, int);
63be0a78 149
150/// \ingroup ServerProtocolICPAPI
02c8dde5 151LogTags icpLogFromICPCode(icp_opcode opcode);
62e76326 152
63be0a78 153/// \ingroup ServerProtocolICPAPI
b7ac5457 154void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
63be0a78 155
156/// \ingroup ServerProtocolICPAPI
8a648e8d 157PF icpHandleUdp;
63be0a78 158
159/// \ingroup ServerProtocolICPAPI
8a648e8d 160PF icpUdpSendQueue;
62e76326 161
63be0a78 162/// \ingroup ServerProtocolICPAPI
8a648e8d 163void icpHandleIcpV3(int, Ip::Address &, char *, int);
63be0a78 164
165/// \ingroup ServerProtocolICPAPI
8a648e8d 166int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
63be0a78 167
168/// \ingroup ServerProtocolICPAPI
8a648e8d 169void icpOpenPorts(void);
63be0a78 170
171/// \ingroup ServerProtocolICPAPI
8a648e8d 172void icpConnectionShutdown(void);
63be0a78 173
174/// \ingroup ServerProtocolICPAPI
8a648e8d 175void icpClosePorts(void);
63be0a78 176
177/// \ingroup ServerProtocolICPAPI
8a648e8d 178int icpSetCacheKey(const cache_key * key);
e6ccf245 179
63be0a78 180/// \ingroup ServerProtocolICPAPI
8a648e8d 181const cache_key *icpGetCacheKey(const char *url, int reqnum);
e6ccf245 182
e6ccf245 183#endif /* SQUID_ICP_H */