]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ICP.h
Mentioned creation of diskers in cache_dir rock documentation.
[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"
e6ccf245 42#include "StoreClient.h"
43
582c2af2
FC
44class HttpRequest;
45
077fe581 46/**
63be0a78 47 \ingroup ServerProtocolICPAPI
48 *
077fe581 49 * This struct is the wire-level header.
50 * DO NOT add more move fields on pain of breakage.
e6ccf245 51 * DO NOT add virtual methods.
52 */
26ac0430 53struct _icp_common_t {
63be0a78 54 /** opcode */
55 unsigned char opcode;
56 /** version number */
57 unsigned char version;
58 /** total length (bytes) */
59 unsigned short length;
60 /** req number (req'd for UDP) */
09aabd84
FC
61 uint32_t reqnum;
62 uint32_t flags;
63 uint32_t pad;
63be0a78 64 /** sender host id */
09aabd84 65 uint32_t shostid;
63be0a78 66
67/// \todo I don't believe this header is included in non-c++ code anywhere
d85b8894 68/// the struct should become a public POD class and kill these ifdef.
e6ccf245 69#ifdef __cplusplus
62e76326 70
71 _icp_common_t();
72 _icp_common_t(char *buf, unsigned int len);
73
b7ac5457 74 void handleReply(char *buf, Ip::Address &from);
e6ccf245 75 static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
76 icp_opcode getOpCode() const;
77#endif
78};
09bbee4c
FC
79typedef struct _icp_common_t icp_common_t;
80
e6ccf245 81#ifdef __cplusplus
82
63be0a78 83/// \ingroup ServerProtocolICPAPI
62e76326 84inline icp_opcode & operator++ (icp_opcode & aCode)
85{
1f1ae50a 86 int tmp = (int) aCode;
87 aCode = (icp_opcode) (++tmp);
e6ccf245 88 return aCode;
89}
90
63be0a78 91/**
92 \ingroup ServerProtocolICPAPI
93 \todo mempool this
94 */
62e76326 95class ICPState
96{
97
98public:
63be0a78 99 ICPState(icp_common_t &aHeader, HttpRequest *aRequest);
100 virtual ~ICPState();
e6ccf245 101 icp_common_t header;
190154cf 102 HttpRequest *request;
e6ccf245 103 int fd;
62e76326 104
b7ac5457 105 Ip::Address from;
e6ccf245 106 char *url;
107};
108
109#endif
110
63be0a78 111/// \ingroup ServerProtocolICPAPI
26ac0430 112struct icpUdpData {
65d448bc
AJ
113
114 /// IP address for the remote end. Because we reply to packets from unknown non-peers.
b7ac5457 115 Ip::Address address;
65d448bc 116
d4cb310b 117 void *msg;
118 size_t len;
119 icpUdpData *next;
120#ifndef LESS_TIMING
62e76326 121
d4cb310b 122 struct timeval start;
123#endif
62e76326 124
d4cb310b 125 log_type logcode;
62e76326 126
d4cb310b 127 struct timeval queue_time;
128};
129
e0d28505
AJ
130extern Comm::ConnectionPointer icpIncomingConn;
131extern Comm::ConnectionPointer icpOutgoingConn;
132extern Ip::Address theIcpPublicHostID;
133
63be0a78 134/// \ingroup ServerProtocolICPAPI
8a648e8d 135HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from);
62e76326 136
63be0a78 137/// \ingroup ServerProtocolICPAPI
8a648e8d 138bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
62e76326 139
63be0a78 140/// \ingroup ServerProtocolICPAPI
8a648e8d 141void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from);
63be0a78 142
143/// \ingroup ServerProtocolICPAPI
8a648e8d 144icp_opcode icpGetCommonOpcode();
e6ccf245 145
63be0a78 146/// \ingroup ServerProtocolICPAPI
8a648e8d 147int icpUdpSend(int, const Ip::Address &, icp_common_t *, log_type, int);
63be0a78 148
149/// \ingroup ServerProtocolICPAPI
8a648e8d 150log_type icpLogFromICPCode(icp_opcode opcode);
62e76326 151
63be0a78 152/// \ingroup ServerProtocolICPAPI
b7ac5457 153void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
63be0a78 154
155/// \ingroup ServerProtocolICPAPI
8a648e8d 156PF icpHandleUdp;
63be0a78 157
158/// \ingroup ServerProtocolICPAPI
8a648e8d 159PF icpUdpSendQueue;
62e76326 160
63be0a78 161/// \ingroup ServerProtocolICPAPI
8a648e8d 162void icpHandleIcpV3(int, Ip::Address &, char *, int);
63be0a78 163
164/// \ingroup ServerProtocolICPAPI
8a648e8d 165int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
63be0a78 166
167/// \ingroup ServerProtocolICPAPI
8a648e8d 168void icpOpenPorts(void);
63be0a78 169
170/// \ingroup ServerProtocolICPAPI
8a648e8d 171void icpConnectionShutdown(void);
63be0a78 172
173/// \ingroup ServerProtocolICPAPI
8a648e8d 174void icpClosePorts(void);
63be0a78 175
176/// \ingroup ServerProtocolICPAPI
8a648e8d 177int icpSetCacheKey(const cache_key * key);
e6ccf245 178
63be0a78 179/// \ingroup ServerProtocolICPAPI
8a648e8d 180const cache_key *icpGetCacheKey(const char *url, int reqnum);
e6ccf245 181
e6ccf245 182#endif /* SQUID_ICP_H */