]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ICP.h
Import IPv6 support from squid3-ipv6 branch to 3-HEAD.
[thirdparty/squid.git] / src / ICP.h
1
2 /*
3 * $Id: ICP.h,v 1.10 2007/12/14 23:11:45 amosjeffries Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34 #ifndef SQUID_ICP_H
35 #define SQUID_ICP_H
36
37 #include "StoreClient.h"
38
39 /**
40 * This struct is the wire-level header.
41 * DO NOT add more move fields on pain of breakage.
42 * DO NOT add virtual methods.
43 */
44 struct _icp_common_t
45 {
46 unsigned char opcode; /* opcode */
47 unsigned char version; /* version number */
48 unsigned short length; /* total length (bytes) */
49 u_int32_t reqnum; /* req number (req'd for UDP) */
50 u_int32_t flags;
51 u_int32_t pad;
52 u_int32_t shostid; /* sender host id */
53 #ifdef __cplusplus
54
55 _icp_common_t();
56 _icp_common_t(char *buf, unsigned int len);
57
58 void handleReply(char *buf, IPAddress &from);
59 static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
60 icp_opcode getOpCode() const;
61 #endif
62 };
63
64 #ifdef __cplusplus
65
66 inline icp_opcode & operator++ (icp_opcode & aCode)
67 {
68 int tmp = (int) aCode;
69 aCode = (icp_opcode) (++tmp);
70 return aCode;
71 }
72
73
74 /** \todo mempool this */
75 class ICPState
76 {
77
78 public:
79 ICPState(icp_common_t &, HttpRequest *);
80 virtual ~ ICPState();
81 icp_common_t header;
82 HttpRequest *request;
83 int fd;
84
85 IPAddress from;
86 char *url;
87 };
88
89 #endif
90
91 struct icpUdpData
92 {
93 IPAddress address;
94 void *msg;
95 size_t len;
96 icpUdpData *next;
97 #ifndef LESS_TIMING
98
99 struct timeval start;
100 #endif
101
102 log_type logcode;
103
104 struct timeval queue_time;
105 };
106
107
108 HttpRequest* icpGetRequest(char *url, int reqnum, int fd, IPAddress &from);
109
110 int icpAccessAllowed(IPAddress &from, HttpRequest * icp_request);
111
112 SQUIDCEXTERN void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const IPAddress &from);
113 extern icp_opcode icpGetCommonOpcode();
114
115 SQUIDCEXTERN int icpUdpSend(int, const IPAddress &, icp_common_t *, log_type, int);
116 SQUIDCEXTERN log_type icpLogFromICPCode(icp_opcode opcode);
117
118 void icpDenyAccess(IPAddress &from, char *url, int reqnum, int fd);
119 SQUIDCEXTERN PF icpHandleUdp;
120 SQUIDCEXTERN PF icpUdpSendQueue;
121
122 SQUIDCEXTERN void icpHandleIcpV3(int, IPAddress &, char *, int);
123 SQUIDCEXTERN int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
124 SQUIDCEXTERN void icpConnectionsOpen(void);
125 SQUIDCEXTERN void icpConnectionShutdown(void);
126 SQUIDCEXTERN void icpConnectionClose(void);
127 SQUIDCEXTERN int icpSetCacheKey(const cache_key * key);
128 SQUIDCEXTERN const cache_key *icpGetCacheKey(const char *url, int reqnum);
129
130
131 #endif /* SQUID_ICP_H */