2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
14 #include "ip/Address.h"
15 #include "ip/forward.h"
16 #include "security/forward.h"
17 #include "typedefs.h" //DRCB, DWCB
24 * READ_HANDLER functions return < 0 if, and only if, they fail with an error.
25 * On error, they must pass back an error code in 'errno'.
27 typedef int READ_HANDLER(int, char *, int);
30 * WRITE_HANDLER functions return < 0 if, and only if, they fail with an error.
31 * On error, they must pass back an error code in 'errno'.
33 typedef int WRITE_HANDLER(int, const char *, int);
40 void *wrt_handle_data
;
42 dwrite_q
*write_q_tail
;
44 _fde_disk() { memset(this, 0, sizeof(_fde_disk
)); }
53 /// True if comm_close for this fd has been called
54 bool closing() { return flags
.close_request
; }
56 /* NOTE: memset is used on fdes today. 20030715 RBC */
57 static void DumpStats (StoreEntry
*);
59 char const *remoteAddr() const;
60 void dumpStats (StoreEntry
&, int);
61 bool readPending(int);
66 /// global table of FD and their state.
70 unsigned short remote_port
;
72 Ip::Address local_addr
;
73 tos_t tosToServer
; /**< The TOS value for packets going towards the server.
74 See also tosFromServer. */
75 nfmark_t nfmarkToServer
; /**< The netfilter mark for packets going towards the server.
76 See also nfmarkFromServer. */
78 char ipaddr
[MAX_IPSTRLEN
]; /* dotted decimal address of peer */
79 char desc
[FD_DESC_SZ
];
83 bool close_request
; ///< true if file_ or comm_close has been called
93 //bool write_pending; //XXX seems not to be used
98 int64_t bytes_written
;
101 int uses
; /* ie # req's over persistent conn */
105 ClientInfo
* clientInfo
;/* pointer to client info used in client write limiter or NULL if not present */
107 unsigned epoll_state
;
114 AsyncCall::Pointer timeoutHandler
;
118 AsyncCall::Pointer closeHandler
;
119 AsyncCall::Pointer halfClosedReader
; /// read handler for half-closed fds
120 READ_HANDLER
*read_method
;
121 WRITE_HANDLER
*write_method
;
122 Security::SessionPointer ssl
;
123 Security::ContextPointer dynamicTlsContext
; ///< cached and then freed when fd is closed
129 tos_t tosFromServer
; /**< Stores the TOS flags of the packets from the remote server.
130 See FwdState::dispatch(). Note that this differs to
131 tosToServer in that this is the value we *receive* from the,
132 connection, whereas tosToServer is the value to set on packets
134 unsigned int nfmarkFromServer
; /**< Stores the Netfilter mark value of the connection from the remote
135 server. See FwdState::dispatch(). Note that this differs to
136 nfmarkToServer in that this is the value we *receive* from the,
137 connection, whereas nfmarkToServer is the value to set on packets
140 /** Clear the fde class back to NULL equivalent. */
141 inline void clear() {
144 local_addr
.setEmpty();
148 memset(ipaddr
, '\0', MAX_IPSTRLEN
);
149 memset(desc
,'\0',FD_DESC_SZ
);
150 memset(&flags
,0,sizeof(_fde_flags
));
160 write_handler
= NULL
;
162 timeoutHandler
= NULL
;
165 lifetime_data
= NULL
;
167 halfClosedReader
= NULL
;
171 dynamicTlsContext
.reset();
173 win32
.handle
= (long)NULL
;
175 tosFromServer
= '\0';
176 nfmarkFromServer
= 0;
180 #define fd_table fde::Table
184 #define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
185 #define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
187 #endif /* SQUID_FDE_H */