BConnection_win.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * @file BConnection_win.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #include <windows.h>
  23. #include <winsock2.h>
  24. #ifdef BADVPN_USE_SHIPPED_MSWSOCK
  25. # include <misc/mswsock.h>
  26. #else
  27. # include <mswsock.h>
  28. #endif
  29. #include <misc/debugerror.h>
  30. #include <base/DebugObject.h>
  31. struct BListener_addrbuf_stub {
  32. union {
  33. struct sockaddr_in ipv4;
  34. struct sockaddr_in6 ipv6;
  35. } addr;
  36. uint8_t extra[16];
  37. };
  38. struct BListener_s {
  39. BReactor *reactor;
  40. void *user;
  41. BListener_handler handler;
  42. int sys_family;
  43. SOCKET sock;
  44. LPFN_ACCEPTEX fnAcceptEx;
  45. LPFN_GETACCEPTEXSOCKADDRS fnGetAcceptExSockaddrs;
  46. BReactorIOCPOverlapped olap;
  47. SOCKET newsock;
  48. uint8_t addrbuf[2 * sizeof(struct BListener_addrbuf_stub)];
  49. BPending next_job;
  50. int busy;
  51. int ready;
  52. DebugObject d_obj;
  53. };
  54. struct BConnector_s {
  55. BReactor *reactor;
  56. void *user;
  57. BConnector_handler handler;
  58. SOCKET sock;
  59. LPFN_CONNECTEX fnConnectEx;
  60. BReactorIOCPOverlapped olap;
  61. int busy;
  62. int ready;
  63. DebugObject d_obj;
  64. };
  65. struct BConnection_s {
  66. BReactor *reactor;
  67. void *user;
  68. BConnection_handler handler;
  69. SOCKET sock;
  70. int aborted;
  71. struct {
  72. BReactorIOCPOverlapped olap;
  73. int inited;
  74. StreamPassInterface iface;
  75. int busy;
  76. int busy_data_len;
  77. } send;
  78. struct {
  79. BReactorIOCPOverlapped olap;
  80. int closed;
  81. int inited;
  82. StreamRecvInterface iface;
  83. int busy;
  84. int busy_data_len;
  85. } recv;
  86. DebugError d_err;
  87. DebugObject d_obj;
  88. };