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