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