StreamRecvConnector.h 2.3 KB

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