BConnection_unix.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @file BConnection_unix.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 <misc/debugerror.h>
  23. #include <base/DebugObject.h>
  24. #define BCONNECTION_SEND_LIMIT 2
  25. #define BCONNECTION_RECV_LIMIT 2
  26. #define BCONNECTION_LISTEN_BACKLOG 128
  27. struct BListener_s {
  28. BReactor *reactor;
  29. void *user;
  30. BListener_handler handler;
  31. int fd;
  32. BFileDescriptor bfd;
  33. BPending default_job;
  34. DebugObject d_obj;
  35. };
  36. struct BConnector_s {
  37. BReactor *reactor;
  38. void *user;
  39. BConnector_handler handler;
  40. BPending job;
  41. int fd;
  42. int connected;
  43. int have_bfd;
  44. BFileDescriptor bfd;
  45. DebugObject d_obj;
  46. };
  47. struct BConnection_s {
  48. BReactor *reactor;
  49. void *user;
  50. BConnection_handler handler;
  51. int fd;
  52. int close_fd;
  53. BFileDescriptor bfd;
  54. int wait_events;
  55. struct {
  56. BReactorLimit limit;
  57. int inited;
  58. StreamPassInterface iface;
  59. BPending job;
  60. int busy;
  61. const uint8_t *busy_data;
  62. int busy_data_len;
  63. } send;
  64. struct {
  65. BReactorLimit limit;
  66. int inited;
  67. int closed;
  68. StreamRecvInterface iface;
  69. BPending job;
  70. int busy;
  71. uint8_t *busy_data;
  72. int busy_data_avail;
  73. } recv;
  74. DebugError d_err;
  75. DebugObject d_obj;
  76. };