StreamRecvConnector.h 2.4 KB

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