]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ICP.h
Refactored --enable-xmalloc-statistics
[thirdparty/squid.git] / src / ICP.h
CommitLineData
e6ccf245 1/*
262a0e14 2 * $Id$
e6ccf245 3 *
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
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.
16 *
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.
26ac0430 21 *
e6ccf245 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.
26ac0430 26 *
e6ccf245 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.
30 *
31 */
32
33#ifndef SQUID_ICP_H
34#define SQUID_ICP_H
35
63be0a78 36/**
37 \defgroup ServerProtocolICPAPI ICP
38 \ingroup ServerProtocol
39 */
40
e6ccf245 41#include "StoreClient.h"
42
077fe581 43/**
63be0a78 44 \ingroup ServerProtocolICPAPI
45 *
077fe581 46 * This struct is the wire-level header.
47 * DO NOT add more move fields on pain of breakage.
e6ccf245 48 * DO NOT add virtual methods.
49 */
26ac0430 50struct _icp_common_t {
63be0a78 51 /** opcode */
52 unsigned char opcode;
53 /** version number */
54 unsigned char version;
55 /** total length (bytes) */
56 unsigned short length;
57 /** req number (req'd for UDP) */
58 u_int32_t reqnum;
e6ccf245 59 u_int32_t flags;
60 u_int32_t pad;
63be0a78 61 /** sender host id */
62 u_int32_t shostid;
63
64/// \todo I don't believe this header is included in non-c++ code anywhere
d85b8894 65/// the struct should become a public POD class and kill these ifdef.
e6ccf245 66#ifdef __cplusplus
62e76326 67
68 _icp_common_t();
69 _icp_common_t(char *buf, unsigned int len);
70
b7ac5457 71 void handleReply(char *buf, Ip::Address &from);
e6ccf245 72 static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
73 icp_opcode getOpCode() const;
74#endif
75};
76
77#ifdef __cplusplus
78
63be0a78 79/// \ingroup ServerProtocolICPAPI
62e76326 80inline icp_opcode & operator++ (icp_opcode & aCode)
81{
1f1ae50a 82 int tmp = (int) aCode;
83 aCode = (icp_opcode) (++tmp);
e6ccf245 84 return aCode;
85}
86
87
63be0a78 88/**
89 \ingroup ServerProtocolICPAPI
90 \todo mempool this
91 */
62e76326 92class ICPState
93{
94
95public:
63be0a78 96 ICPState(icp_common_t &aHeader, HttpRequest *aRequest);
97 virtual ~ICPState();
e6ccf245 98 icp_common_t header;
190154cf 99 HttpRequest *request;
e6ccf245 100 int fd;
62e76326 101
b7ac5457 102 Ip::Address from;
e6ccf245 103 char *url;
104};
105
106#endif
107
63be0a78 108/// \ingroup ServerProtocolICPAPI
26ac0430 109struct icpUdpData {
b7ac5457 110 Ip::Address address;
d4cb310b 111 void *msg;
112 size_t len;
113 icpUdpData *next;
114#ifndef LESS_TIMING
62e76326 115
d4cb310b 116 struct timeval start;
117#endif
62e76326 118
d4cb310b 119 log_type logcode;
62e76326 120
d4cb310b 121 struct timeval queue_time;
122};
123
63be0a78 124/// \ingroup ServerProtocolICPAPI
b7ac5457 125HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from);
62e76326 126
63be0a78 127/// \ingroup ServerProtocolICPAPI
b7ac5457 128int icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
62e76326 129
63be0a78 130/// \ingroup ServerProtocolICPAPI
b7ac5457 131SQUIDCEXTERN void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from);
63be0a78 132
133/// \ingroup ServerProtocolICPAPI
e6ccf245 134extern icp_opcode icpGetCommonOpcode();
135
63be0a78 136/// \ingroup ServerProtocolICPAPI
b7ac5457 137SQUIDCEXTERN int icpUdpSend(int, const Ip::Address &, icp_common_t *, log_type, int);
63be0a78 138
139/// \ingroup ServerProtocolICPAPI
e6ccf245 140SQUIDCEXTERN log_type icpLogFromICPCode(icp_opcode opcode);
62e76326 141
63be0a78 142/// \ingroup ServerProtocolICPAPI
b7ac5457 143void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
63be0a78 144
145/// \ingroup ServerProtocolICPAPI
e6ccf245 146SQUIDCEXTERN PF icpHandleUdp;
63be0a78 147
148/// \ingroup ServerProtocolICPAPI
e6ccf245 149SQUIDCEXTERN PF icpUdpSendQueue;
62e76326 150
63be0a78 151/// \ingroup ServerProtocolICPAPI
b7ac5457 152SQUIDCEXTERN void icpHandleIcpV3(int, Ip::Address &, char *, int);
63be0a78 153
154/// \ingroup ServerProtocolICPAPI
190154cf 155SQUIDCEXTERN int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
63be0a78 156
157/// \ingroup ServerProtocolICPAPI
e6ccf245 158SQUIDCEXTERN void icpConnectionsOpen(void);
63be0a78 159
160/// \ingroup ServerProtocolICPAPI
e6ccf245 161SQUIDCEXTERN void icpConnectionShutdown(void);
63be0a78 162
163/// \ingroup ServerProtocolICPAPI
e6ccf245 164SQUIDCEXTERN void icpConnectionClose(void);
63be0a78 165
166/// \ingroup ServerProtocolICPAPI
e6ccf245 167SQUIDCEXTERN int icpSetCacheKey(const cache_key * key);
e6ccf245 168
63be0a78 169/// \ingroup ServerProtocolICPAPI
170SQUIDCEXTERN const cache_key *icpGetCacheKey(const char *url, int reqnum);
e6ccf245 171
e6ccf245 172#endif /* SQUID_ICP_H */