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