]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fde.h
sourceformat: split protos.h into more specific headers, change many functions' likag...
[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
FC
46class dwrite_q;
47class _fde_disk {
48public:
49 DWCB *wrt_handle;
50 void *wrt_handle_data;
51 dwrite_q *write_q;
52 dwrite_q *write_q_tail;
53 off_t offset;
54};
781ce8ff 55
62e76326 56class fde
57{
58
528b2c61 59public:
cc192b50 60 fde() { clear(); };
9e008dda 61
82ec8dfc
AR
62 /// True if comm_close for this fd has been called
63 bool closing() { return flags.close_request; }
cc192b50 64
75faaa7a 65 /* NOTE: memset is used on fdes today. 20030715 RBC */
528b2c61 66 static void DumpStats (StoreEntry *);
62e76326 67
528b2c61 68 char const *remoteAddr() const;
69 void dumpStats (StoreEntry &, int);
70 bool readPending(int);
781ce8ff 71 void noteUse(PconnPool *);
528b2c61 72
b115733c 73public:
528b2c61 74 unsigned int type;
f45dd259 75 unsigned short remote_port;
62e76326 76
b7ac5457 77 Ip::Address local_addr;
425de4c8
AJ
78 tos_t tosToServer; /**< The TOS value for packets going towards the server.
79 See also tosFromServer. */
80 nfmark_t nfmarkToServer; /**< The netfilter mark for packets going towards the server.
81 See also nfmarkFromServer. */
cc192b50 82 int sock_family;
83 char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
528b2c61 84 char desc[FD_DESC_SZ];
62e76326 85
b115733c 86 struct _fde_flags {
9e008dda
AJ
87 unsigned int open:1;
88 unsigned int close_request:1; // file_ or comm_close has been called
89 unsigned int write_daemon:1;
90 unsigned int socket_eof:1;
91 unsigned int nolinger:1;
92 unsigned int nonblocking:1;
93 unsigned int ipc:1;
94 unsigned int called_connect:1;
95 unsigned int nodelay:1;
96 unsigned int close_on_exec:1;
97 unsigned int read_pending:1;
98 unsigned int write_pending:1;
3949d8b7 99 unsigned int transparent:1;
aeb090a2 100 } flags;
62e76326 101
47f6e231 102 int64_t bytes_read;
103 int64_t bytes_written;
781ce8ff 104
aeb090a2 105 struct {
781ce8ff 106 int uses; /* ie # req's over persistent conn */
107 PconnPool *pool;
aeb090a2 108 } pconn;
781ce8ff 109
9a0a18de 110#if USE_DELAY_POOLS
b4cd430a
CT
111 ClientInfo * clientInfo;/* pointer to client info used in client write limiter or NULL if not present */
112#endif
751406fe 113 unsigned epoll_state;
62e76326 114
528b2c61 115 struct _fde_disk disk;
116 PF *read_handler;
117 void *read_data;
118 PF *write_handler;
119 void *write_data;
5c2c2194 120 AsyncCall::Pointer timeoutHandler;
528b2c61 121 time_t timeout;
5ef5e5cc 122 time_t writeStart;
528b2c61 123 void *lifetime_data;
5c2c2194 124 AsyncCall::Pointer closeHandler;
74257126 125 AsyncCall::Pointer halfClosedReader; /// read handler for half-closed fds
51026b54 126 CommWriteStateData *wstate; /* State data for comm_write */
528b2c61 127 READ_HANDLER *read_method;
128 WRITE_HANDLER *write_method;
129#if USE_SSL
130 SSL *ssl;
95d2589c 131 SSL_CTX *dynamicSslContext; ///< cached and then freed when fd is closed
528b2c61 132#endif
1191b93b 133#if _SQUID_MSWIN_
9e008dda 134 struct {
629b5f75 135 long handle;
aeb090a2 136 } win32;
629b5f75 137#endif
425de4c8
AJ
138 tos_t tosFromServer; /**< Stores the TOS flags of the packets from the remote server.
139 See FwdState::dispatch(). Note that this differs to
140 tosToServer in that this is the value we *receive* from the,
141 connection, whereas tosToServer is the value to set on packets
142 *leaving* Squid. */
143 unsigned int nfmarkFromServer; /**< Stores the Netfilter mark value of the connection from the remote
144 server. See FwdState::dispatch(). Note that this differs to
145 nfmarkToServer in that this is the value we *receive* from the,
146 connection, whereas nfmarkToServer is the value to set on packets
147 *leaving* Squid. */
629b5f75 148
bf81adb4
AR
149private:
150 /** Clear the fde class back to NULL equivalent. */
151 inline void clear() {
b115733c
AJ
152 type = 0;
153 remote_port = 0;
154 local_addr.SetEmpty();
f4f6c2e0
AJ
155 tosToServer = '\0';
156 nfmarkToServer = 0;
b115733c
AJ
157 sock_family = 0;
158 memset(ipaddr, '\0', MAX_IPSTRLEN);
159 memset(desc,'\0',FD_DESC_SZ);
9b8bdcab 160 memset(&flags,0,sizeof(_fde_flags));
b115733c
AJ
161 bytes_read = 0;
162 bytes_written = 0;
163 pconn.uses = 0;
164 pconn.pool = NULL;
9a0a18de 165#if USE_DELAY_POOLS
b4cd430a 166 clientInfo = NULL;
d15c7ffc 167#endif
b115733c 168 epoll_state = 0;
9b8bdcab 169 memset(&disk, 0, sizeof(_fde_disk));
b115733c
AJ
170 read_handler = NULL;
171 read_data = NULL;
172 write_handler = NULL;
173 write_data = NULL;
bf81adb4 174 timeoutHandler = NULL;
b115733c
AJ
175 timeout = 0;
176 writeStart = 0;
177 lifetime_data = NULL;
bf81adb4 178 closeHandler = NULL;
74257126 179 halfClosedReader = NULL;
b115733c
AJ
180 wstate = NULL;
181 read_method = NULL;
182 write_method = NULL;
183#if USE_SSL
184 ssl = NULL;
95d2589c 185 dynamicSslContext = NULL;
b115733c 186#endif
1191b93b 187#if _SQUID_MSWIN_
b115733c
AJ
188 win32.handle = NULL;
189#endif
f4f6c2e0
AJ
190 tosFromServer = '\0';
191 nfmarkFromServer = 0;
bf81adb4 192 }
528b2c61 193};
194
04f55905
AJ
195SQUIDCEXTERN int fdNFree(void);
196
ef364f64
AJ
197#define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
198#define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
199
528b2c61 200#endif /* SQUID_FDE_H */