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