BDatagram_win.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * @file BDatagram_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 BDatagram_sys_addr {
  32. int len;
  33. union {
  34. struct sockaddr generic;
  35. struct sockaddr_in ipv4;
  36. struct sockaddr_in6 ipv6;
  37. } addr;
  38. };
  39. struct BDatagram_s {
  40. BReactor *reactor;
  41. void *user;
  42. BDatagram_handler handler;
  43. SOCKET sock;
  44. LPFN_WSASENDMSG fnWSASendMsg;
  45. LPFN_WSARECVMSG fnWSARecvMsg;
  46. int aborted;
  47. struct {
  48. BReactorIOCPOverlapped olap;
  49. int have_addrs;
  50. BAddr remote_addr;
  51. BIPAddr local_addr;
  52. int inited;
  53. int mtu;
  54. PacketPassInterface iface;
  55. BPending job;
  56. int data_len;
  57. uint8_t *data;
  58. int data_busy;
  59. struct BDatagram_sys_addr sysaddr;
  60. union {
  61. char in[WSA_CMSG_SPACE(sizeof(struct in_pktinfo))];
  62. char in6[WSA_CMSG_SPACE(sizeof(struct in6_pktinfo))];
  63. } cdata;
  64. WSAMSG msg;
  65. } send;
  66. struct {
  67. BReactorIOCPOverlapped olap;
  68. int started;
  69. int have_addrs;
  70. BAddr remote_addr;
  71. BIPAddr local_addr;
  72. int inited;
  73. int mtu;
  74. PacketRecvInterface iface;
  75. BPending job;
  76. int data_have;
  77. uint8_t *data;
  78. int data_busy;
  79. struct BDatagram_sys_addr sysaddr;
  80. union {
  81. char in[WSA_CMSG_SPACE(sizeof(struct in_pktinfo))];
  82. char in6[WSA_CMSG_SPACE(sizeof(struct in6_pktinfo))];
  83. } cdata;
  84. WSAMSG msg;
  85. } recv;
  86. DebugError d_err;
  87. DebugObject d_obj;
  88. };