PageRenderTime 59ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/squid-3.2.0.16/src/fde.h

#
C Header | 185 lines | 125 code | 19 blank | 41 comment | 0 complexity | 7ffce8a8fe1c8176c6d87259174e9659 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /*
  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.
  18. *
  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.
  23. *
  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. #ifndef SQUID_FDE_H
  30. #define SQUID_FDE_H
  31. #include "comm.h"
  32. #include "ip/Address.h"
  33. #if USE_DELAY_POOLS
  34. class ClientInfo;
  35. #endif
  36. class PconnPool;
  37. class fde
  38. {
  39. public:
  40. fde() { clear(); };
  41. /// True if comm_close for this fd has been called
  42. bool closing() { return flags.close_request; }
  43. /* NOTE: memset is used on fdes today. 20030715 RBC */
  44. static void DumpStats (StoreEntry *);
  45. char const *remoteAddr() const;
  46. void dumpStats (StoreEntry &, int);
  47. bool readPending(int);
  48. void noteUse(PconnPool *);
  49. public:
  50. unsigned int type;
  51. unsigned short remote_port;
  52. Ip::Address local_addr;
  53. tos_t tosToServer; /**< The TOS value for packets going towards the server.
  54. See also tosFromServer. */
  55. nfmark_t nfmarkToServer; /**< The netfilter mark for packets going towards the server.
  56. See also nfmarkFromServer. */
  57. int sock_family;
  58. char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
  59. char desc[FD_DESC_SZ];
  60. struct _fde_flags {
  61. unsigned int open:1;
  62. unsigned int close_request:1; // file_ or comm_close has been called
  63. unsigned int write_daemon:1;
  64. unsigned int socket_eof:1;
  65. unsigned int nolinger:1;
  66. unsigned int nonblocking:1;
  67. unsigned int ipc:1;
  68. unsigned int called_connect:1;
  69. unsigned int nodelay:1;
  70. unsigned int close_on_exec:1;
  71. unsigned int read_pending:1;
  72. unsigned int write_pending:1;
  73. unsigned int transparent:1;
  74. } flags;
  75. int64_t bytes_read;
  76. int64_t bytes_written;
  77. struct {
  78. int uses; /* ie # req's over persistent conn */
  79. PconnPool *pool;
  80. } pconn;
  81. #if USE_DELAY_POOLS
  82. ClientInfo * clientInfo;/* pointer to client info used in client write limiter or NULL if not present */
  83. #endif
  84. unsigned epoll_state;
  85. struct _fde_disk disk;
  86. PF *read_handler;
  87. void *read_data;
  88. PF *write_handler;
  89. void *write_data;
  90. AsyncCall::Pointer timeoutHandler;
  91. time_t timeout;
  92. time_t writeStart;
  93. void *lifetime_data;
  94. AsyncCall::Pointer closeHandler;
  95. AsyncCall::Pointer halfClosedReader; /// read handler for half-closed fds
  96. CommWriteStateData *wstate; /* State data for comm_write */
  97. READ_HANDLER *read_method;
  98. WRITE_HANDLER *write_method;
  99. #if USE_SSL
  100. SSL *ssl;
  101. SSL_CTX *dynamicSslContext; ///< cached and then freed when fd is closed
  102. #endif
  103. #if _SQUID_MSWIN_
  104. struct {
  105. long handle;
  106. } win32;
  107. #endif
  108. tos_t tosFromServer; /**< Stores the TOS flags of the packets from the remote server.
  109. See FwdState::dispatch(). Note that this differs to
  110. tosToServer in that this is the value we *receive* from the,
  111. connection, whereas tosToServer is the value to set on packets
  112. *leaving* Squid. */
  113. unsigned int nfmarkFromServer; /**< Stores the Netfilter mark value of the connection from the remote
  114. server. See FwdState::dispatch(). Note that this differs to
  115. nfmarkToServer in that this is the value we *receive* from the,
  116. connection, whereas nfmarkToServer is the value to set on packets
  117. *leaving* Squid. */
  118. private:
  119. /** Clear the fde class back to NULL equivalent. */
  120. inline void clear() {
  121. type = 0;
  122. remote_port = 0;
  123. local_addr.SetEmpty();
  124. tosToServer = '\0';
  125. nfmarkToServer = 0;
  126. sock_family = 0;
  127. memset(ipaddr, '\0', MAX_IPSTRLEN);
  128. memset(desc,'\0',FD_DESC_SZ);
  129. memset(&flags,0,sizeof(_fde_flags));
  130. bytes_read = 0;
  131. bytes_written = 0;
  132. pconn.uses = 0;
  133. pconn.pool = NULL;
  134. #if USE_DELAY_POOLS
  135. clientInfo = NULL;
  136. #endif
  137. epoll_state = 0;
  138. memset(&disk, 0, sizeof(_fde_disk));
  139. read_handler = NULL;
  140. read_data = NULL;
  141. write_handler = NULL;
  142. write_data = NULL;
  143. timeoutHandler = NULL;
  144. timeout = 0;
  145. writeStart = 0;
  146. lifetime_data = NULL;
  147. closeHandler = NULL;
  148. halfClosedReader = NULL;
  149. wstate = NULL;
  150. read_method = NULL;
  151. write_method = NULL;
  152. #if USE_SSL
  153. ssl = NULL;
  154. dynamicSslContext = NULL;
  155. #endif
  156. #if _SQUID_MSWIN_
  157. win32.handle = NULL;
  158. #endif
  159. tosFromServer = '\0';
  160. nfmarkFromServer = 0;
  161. }
  162. };
  163. SQUIDCEXTERN int fdNFree(void);
  164. #define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
  165. #define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
  166. #endif /* SQUID_FDE_H */