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