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