StreamRecvConnector.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file StreamRecvConnector.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. * @section DESCRIPTION
  23. *
  24. * A {@link StreamRecvInterface} layer which allows the input to be
  25. * connected and disconnected on the fly.
  26. */
  27. #ifndef BADVPN_FLOW_STREAMRECVCONNECTOR_H
  28. #define BADVPN_FLOW_STREAMRECVCONNECTOR_H
  29. #include <stdint.h>
  30. #include <misc/dead.h>
  31. #include <system/DebugObject.h>
  32. #include <system/BPending.h>
  33. #include <flow/StreamRecvInterface.h>
  34. /**
  35. * A {@link StreamRecvInterface} layer which allows the input to be
  36. * connected and disconnected on the fly.
  37. */
  38. typedef struct {
  39. DebugObject d_obj;
  40. dead_t dead;
  41. StreamRecvInterface output;
  42. int out_avail;
  43. uint8_t *out;
  44. StreamRecvInterface *input;
  45. dead_t input_dead;
  46. int in_blocking;
  47. BPending continue_job;
  48. } StreamRecvConnector;
  49. /**
  50. * Initializes the object.
  51. * The object is initialized in not connected state.
  52. *
  53. * @param o the object
  54. * @param pg pending group
  55. */
  56. void StreamRecvConnector_Init (StreamRecvConnector *o, BPendingGroup *pg);
  57. /**
  58. * Frees the object.
  59. *
  60. * @param o the object
  61. */
  62. void StreamRecvConnector_Free (StreamRecvConnector *o);
  63. /**
  64. * Returns the output interface.
  65. *
  66. * @param o the object
  67. * @return output interface
  68. */
  69. StreamRecvInterface * StreamRecvConnector_GetOutput (StreamRecvConnector *o);
  70. /**
  71. * Connects input.
  72. * The object must be in not connected state.
  73. * The object enters connected state.
  74. *
  75. * @param o the object
  76. * @param output input to connect
  77. */
  78. void StreamRecvConnector_ConnectInput (StreamRecvConnector *o, StreamRecvInterface *input);
  79. /**
  80. * Disconnects input.
  81. * The object must be in connected state.
  82. * The object enters not connected state.
  83. *
  84. * @param o the object
  85. */
  86. void StreamRecvConnector_DisconnectInput (StreamRecvConnector *o);
  87. #endif