StreamRecvConnector.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. int in_blocking;
  42. DebugObject d_obj;
  43. } StreamRecvConnector;
  44. /**
  45. * Initializes the object.
  46. * The object is initialized in not connected state.
  47. *
  48. * @param o the object
  49. * @param pg pending group
  50. */
  51. void StreamRecvConnector_Init (StreamRecvConnector *o, BPendingGroup *pg);
  52. /**
  53. * Frees the object.
  54. *
  55. * @param o the object
  56. */
  57. void StreamRecvConnector_Free (StreamRecvConnector *o);
  58. /**
  59. * Returns the output interface.
  60. *
  61. * @param o the object
  62. * @return output interface
  63. */
  64. StreamRecvInterface * StreamRecvConnector_GetOutput (StreamRecvConnector *o);
  65. /**
  66. * Connects input.
  67. * The object must be in not connected state.
  68. * The object enters connected state.
  69. *
  70. * @param o the object
  71. * @param output input to connect
  72. */
  73. void StreamRecvConnector_ConnectInput (StreamRecvConnector *o, StreamRecvInterface *input);
  74. /**
  75. * Disconnects input.
  76. * The object must be in connected state.
  77. * The object enters not connected state.
  78. *
  79. * @param o the object
  80. */
  81. void StreamRecvConnector_DisconnectInput (StreamRecvConnector *o);
  82. #endif