21
20
* it under the terms of the GNU General Public License as published by
22
21
* the Free Software Foundation; either version 2 of the License, or
23
22
* (at your option) any later version.
25
24
* This program is distributed in the hope that it will be useful,
26
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of
27
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
27
* GNU General Public License for more details.
30
29
* You should have received a copy of the GNU General Public License
31
30
* along with this program; if not, write to the Free Software
32
31
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36
\defgroup ServerProtocolICPInternal3 ICPv3 Internals
37
\ingroup ServerProtocolICPAPI
39
43
#include "HttpRequest.h"
45
/// \ingroup ServerProtocolICPInternal3
41
46
class ICP3State : public ICPState, public StoreClient
45
ICP3State(icp_common_t &aHeader, HttpRequest *aRequest):
46
ICPState(aHeader, aRequest)
50
ICP3State(icp_common_t &aHeader, HttpRequest *aRequest) :
51
ICPState(aHeader, aRequest) {}
50
54
void created (StoreEntry *newEntry);
57
/// \ingroup ServerProtocolICPInternal3
55
doV3Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header)
59
doV3Query(int fd, IpAddress &from, char *buf, icp_common_t header)
57
61
/* We have a valid packet */
58
62
char *url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
59
HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, &from);
63
HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, from);
64
if (!icpAccessAllowed(&from, icp_request))
66
icpDenyAccess (&from, url, header.reqnum, fd);
68
if (!icpAccessAllowed(from, icp_request)) {
69
icpDenyAccess (from, url, header.reqnum, fd);
67
70
delete icp_request;
80
83
StoreEntry::getPublic (state, url, METHOD_GET);
83
ICP3State::~ICP3State ()
86
ICP3State::~ICP3State()
87
ICP3State::created (StoreEntry *newEntry)
90
ICP3State::created(StoreEntry *newEntry)
89
92
StoreEntry *entry = newEntry->isNull () ? NULL : newEntry;
90
93
debugs(12, 5, "icpHandleIcpV3: OPCODE " << icp_opcode_str[header.opcode]);
98
101
codeToSend = icpGetCommonOpcode();
100
icpCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, &from);
103
icpCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, from);
109
/// \ingroup ServerProtocolICPInternal3
105
110
/* Currently Harvest cached-2.x uses ICP_VERSION_3 */
108
icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
112
icpHandleIcpV3(int fd, IpAddress&from, char *buf, int len)
112
115
debugs(12, 3, "icpHandleIcpV3: ICP message is too small");
118
121
* Length field should match the number of bytes read
121
if (len != header.length)
124
if (len != header.length) {
123
125
debugs(12, 3, "icpHandleIcpV3: ICP message is too small");
127
switch (header.opcode)
129
switch (header.opcode) {
131
doV3Query(fd, from,buf, header);
132
doV3Query(fd, from, buf, header);
135
#if ALLOW_SOURCE_PING