]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fde.h
Prep for 3.3.12 and 3.4.4
[thirdparty/squid.git] / src / fde.h
CommitLineData
528b2c61 1/*
528b2c61 2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
9e008dda 18 *
528b2c61 19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
9e008dda 23 *
528b2c61 24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
29
30#ifndef SQUID_FDE_H
31#define SQUID_FDE_H
cc192b50 32
a46d2c0e 33#include "comm.h"
1328cfb7 34#include "defines.h"
96d89ea0 35#include "ip/Address.h"
528b2c61 36
a011edee
FC
37#if USE_SSL
38#include <openssl/ssl.h>
39#endif
40
9a0a18de 41#if USE_DELAY_POOLS
b4cd430a
CT
42class ClientInfo;
43#endif
1328cfb7 44
781ce8ff 45class PconnPool;
1328cfb7 46class dwrite_q;
e4a14600
A
47class _fde_disk
48{
1328cfb7
FC
49public:
50 DWCB *wrt_handle;
51 void *wrt_handle_data;
52 dwrite_q *write_q;
53 dwrite_q *write_q_tail;
54 off_t offset;
82afb125 55 _fde_disk() { memset(this, 0, sizeof(_fde_disk)); }
1328cfb7 56};
781ce8ff 57
62e76326 58class fde
59{
60
528b2c61 61public:
cc192b50 62 fde() { clear(); };
9e008dda 63
82ec8dfc
AR
64 /// True if comm_close for this fd has been called
65 bool closing() { return flags.close_request; }
cc192b50 66
75faaa7a 67 /* NOTE: memset is used on fdes today. 20030715 RBC */
528b2c61 68 static void DumpStats (StoreEntry *);
62e76326 69
528b2c61 70 char const *remoteAddr() const;
71 void dumpStats (StoreEntry &, int);
72 bool readPending(int);
781ce8ff 73 void noteUse(PconnPool *);
528b2c61 74
b115733c 75public:
f9fb22f5
AJ
76
77 /// global table of FD and their state.
78 static fde* Table;
79
528b2c61 80 unsigned int type;
f45dd259 81 unsigned short remote_port;
62e76326 82
b7ac5457 83 Ip::Address local_addr;
425de4c8
AJ
84 tos_t tosToServer; /**< The TOS value for packets going towards the server.
85 See also tosFromServer. */
86 nfmark_t nfmarkToServer; /**< The netfilter mark for packets going towards the server.
87 See also nfmarkFromServer. */
cc192b50 88 int sock_family;
89 char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
528b2c61 90 char desc[FD_DESC_SZ];
62e76326 91
b115733c 92 struct _fde_flags {
be4d35dc
FC
93 bool open;
94 bool close_request; ///< true if file_ or comm_close has been called
95 bool write_daemon;
96 bool socket_eof;
97 bool nolinger;
98 bool nonblocking;
99 bool ipc;
100 bool called_connect;
101 bool nodelay;
102 bool close_on_exec;
103 bool read_pending;
104 //bool write_pending; //XXX seems not to be used
105 bool transparent;
aeb090a2 106 } flags;
62e76326 107
47f6e231 108 int64_t bytes_read;
109 int64_t bytes_written;
781ce8ff 110
aeb090a2 111 struct {
781ce8ff 112 int uses; /* ie # req's over persistent conn */
113 PconnPool *pool;
aeb090a2 114 } pconn;
781ce8ff 115
9a0a18de 116#if USE_DELAY_POOLS
b4cd430a
CT
117 ClientInfo * clientInfo;/* pointer to client info used in client write limiter or NULL if not present */
118#endif
751406fe 119 unsigned epoll_state;
62e76326 120
82afb125 121 _fde_disk disk;
528b2c61 122 PF *read_handler;
123 void *read_data;
124 PF *write_handler;
125 void *write_data;
5c2c2194 126 AsyncCall::Pointer timeoutHandler;
528b2c61 127 time_t timeout;
5ef5e5cc 128 time_t writeStart;
528b2c61 129 void *lifetime_data;
5c2c2194 130 AsyncCall::Pointer closeHandler;
74257126 131 AsyncCall::Pointer halfClosedReader; /// read handler for half-closed fds
51026b54 132 CommWriteStateData *wstate; /* State data for comm_write */
528b2c61 133 READ_HANDLER *read_method;
134 WRITE_HANDLER *write_method;
135#if USE_SSL
136 SSL *ssl;
95d2589c 137 SSL_CTX *dynamicSslContext; ///< cached and then freed when fd is closed
528b2c61 138#endif
7aa9bb3e 139#if _SQUID_WINDOWS_
9e008dda 140 struct {
629b5f75 141 long handle;
aeb090a2 142 } win32;
629b5f75 143#endif
425de4c8
AJ
144 tos_t tosFromServer; /**< Stores the TOS flags of the packets from the remote server.
145 See FwdState::dispatch(). Note that this differs to
146 tosToServer in that this is the value we *receive* from the,
147 connection, whereas tosToServer is the value to set on packets
148 *leaving* Squid. */
149 unsigned int nfmarkFromServer; /**< Stores the Netfilter mark value of the connection from the remote
150 server. See FwdState::dispatch(). Note that this differs to
151 nfmarkToServer in that this is the value we *receive* from the,
152 connection, whereas nfmarkToServer is the value to set on packets
153 *leaving* Squid. */
629b5f75 154
bf81adb4
AR
155private:
156 /** Clear the fde class back to NULL equivalent. */
157 inline void clear() {
b115733c
AJ
158 type = 0;
159 remote_port = 0;
4dd643d5 160 local_addr.setEmpty();
f4f6c2e0
AJ
161 tosToServer = '\0';
162 nfmarkToServer = 0;
b115733c
AJ
163 sock_family = 0;
164 memset(ipaddr, '\0', MAX_IPSTRLEN);
165 memset(desc,'\0',FD_DESC_SZ);
9b8bdcab 166 memset(&flags,0,sizeof(_fde_flags));
b115733c
AJ
167 bytes_read = 0;
168 bytes_written = 0;
169 pconn.uses = 0;
170 pconn.pool = NULL;
9a0a18de 171#if USE_DELAY_POOLS
b4cd430a 172 clientInfo = NULL;
d15c7ffc 173#endif
b115733c 174 epoll_state = 0;
b115733c
AJ
175 read_handler = NULL;
176 read_data = NULL;
177 write_handler = NULL;
178 write_data = NULL;
bf81adb4 179 timeoutHandler = NULL;
b115733c
AJ
180 timeout = 0;
181 writeStart = 0;
182 lifetime_data = NULL;
bf81adb4 183 closeHandler = NULL;
74257126 184 halfClosedReader = NULL;
b115733c
AJ
185 wstate = NULL;
186 read_method = NULL;
187 write_method = NULL;
188#if USE_SSL
189 ssl = NULL;
95d2589c 190 dynamicSslContext = NULL;
b115733c 191#endif
7aa9bb3e 192#if _SQUID_WINDOWS_
b115733c
AJ
193 win32.handle = NULL;
194#endif
f4f6c2e0
AJ
195 tosFromServer = '\0';
196 nfmarkFromServer = 0;
bf81adb4 197 }
528b2c61 198};
199
f9fb22f5
AJ
200#define fd_table fde::Table
201
d9c252f2 202int fdNFree(void);
04f55905 203
ef364f64
AJ
204#define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
205#define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
206
528b2c61 207#endif /* SQUID_FDE_H */