2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
13 \defgroup ServerProtocolICPAPI ICP
14 \ingroup ServerProtocol
17 #include "comm/forward.h"
18 #include "icp_opcode.h"
19 #include "ip/Address.h"
21 #include "StoreClient.h"
26 \ingroup ServerProtocolICPAPI
28 * This struct is the wire-level header.
29 * DO NOT add more move fields on pain of breakage.
30 * DO NOT add virtual methods.
32 struct _icp_common_t
{
36 unsigned char version
;
37 /** total length (bytes) */
38 unsigned short length
;
39 /** req number (req'd for UDP) */
46 /// \todo I don't believe this header is included in non-c++ code anywhere
47 /// the struct should become a public POD class and kill these ifdef.
51 _icp_common_t(char *buf
, unsigned int len
);
53 void handleReply(char *buf
, Ip::Address
&from
);
54 static _icp_common_t
*createMessage(icp_opcode opcode
, int flags
, const char *url
, int reqnum
, int pad
);
55 icp_opcode
getOpCode() const;
58 typedef struct _icp_common_t icp_common_t
;
62 /// \ingroup ServerProtocolICPAPI
63 inline icp_opcode
& operator++ (icp_opcode
& aCode
)
65 int tmp
= (int) aCode
;
66 aCode
= (icp_opcode
) (++tmp
);
71 \ingroup ServerProtocolICPAPI
78 ICPState(icp_common_t
&aHeader
, HttpRequest
*aRequest
);
90 /// \ingroup ServerProtocolICPAPI
93 /// IP address for the remote end. Because we reply to packets from unknown non-peers.
101 struct timeval start
;
106 struct timeval queue_time
;
109 extern Comm::ConnectionPointer icpIncomingConn
;
110 extern Comm::ConnectionPointer icpOutgoingConn
;
111 extern Ip::Address theIcpPublicHostID
;
113 /// \ingroup ServerProtocolICPAPI
114 HttpRequest
* icpGetRequest(char *url
, int reqnum
, int fd
, Ip::Address
&from
);
116 /// \ingroup ServerProtocolICPAPI
117 bool icpAccessAllowed(Ip::Address
&from
, HttpRequest
* icp_request
);
119 /// \ingroup ServerProtocolICPAPI
120 void icpCreateAndSend(icp_opcode
, int flags
, char const *url
, int reqnum
, int pad
, int fd
, const Ip::Address
&from
);
122 /// \ingroup ServerProtocolICPAPI
123 icp_opcode
icpGetCommonOpcode();
125 /// \ingroup ServerProtocolICPAPI
126 int icpUdpSend(int, const Ip::Address
&, icp_common_t
*, LogTags
, int);
128 /// \ingroup ServerProtocolICPAPI
129 LogTags
icpLogFromICPCode(icp_opcode opcode
);
131 /// \ingroup ServerProtocolICPAPI
132 void icpDenyAccess(Ip::Address
&from
, char *url
, int reqnum
, int fd
);
134 /// \ingroup ServerProtocolICPAPI
137 /// \ingroup ServerProtocolICPAPI
140 /// \ingroup ServerProtocolICPAPI
141 void icpHandleIcpV3(int, Ip::Address
&, char *, int);
143 /// \ingroup ServerProtocolICPAPI
144 int icpCheckUdpHit(StoreEntry
*, HttpRequest
* request
);
146 /// \ingroup ServerProtocolICPAPI
147 void icpOpenPorts(void);
149 /// \ingroup ServerProtocolICPAPI
150 void icpConnectionShutdown(void);
152 /// \ingroup ServerProtocolICPAPI
153 void icpClosePorts(void);
155 /// \ingroup ServerProtocolICPAPI
156 int icpSetCacheKey(const cache_key
* key
);
158 /// \ingroup ServerProtocolICPAPI
159 const cache_key
*icpGetCacheKey(const char *url
, int reqnum
);
161 #endif /* SQUID_ICP_H */