PacketPassConnector.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * @file PacketPassConnector.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 PacketPassInterface} layer which allows the output to be
  25. * connected and disconnected on the fly.
  26. */
  27. #ifndef BADVPN_FLOW_PACKETPASSCONNECTOR_H
  28. #define BADVPN_FLOW_PACKETPASSCONNECTOR_H
  29. #include <stdint.h>
  30. #include <system/DebugObject.h>
  31. #include <flow/PacketPassInterface.h>
  32. /**
  33. * A {@link PacketPassInterface} layer which allows the output to be
  34. * connected and disconnected on the fly.
  35. */
  36. typedef struct {
  37. PacketPassInterface input;
  38. int input_mtu;
  39. int in_len;
  40. uint8_t *in;
  41. PacketPassInterface *output;
  42. int out_blocking;
  43. DebugObject d_obj;
  44. } PacketPassConnector;
  45. /**
  46. * Initializes the object.
  47. * The object is initialized in not connected state.
  48. *
  49. * @param o the object
  50. * @param mtu maximum input packet size. Must be >=0.
  51. * @param pg pending group
  52. */
  53. void PacketPassConnector_Init (PacketPassConnector *o, int mtu, BPendingGroup *pg);
  54. /**
  55. * Frees the object.
  56. *
  57. * @param o the object
  58. */
  59. void PacketPassConnector_Free (PacketPassConnector *o);
  60. /**
  61. * Returns the input interface.
  62. * The MTU of the interface will be as in {@link PacketPassConnector_Init}.
  63. *
  64. * @param o the object
  65. * @return input interface
  66. */
  67. PacketPassInterface * PacketPassConnector_GetInput (PacketPassConnector *o);
  68. /**
  69. * Connects output.
  70. * The object must be in not connected state.
  71. * The object enters connected state.
  72. *
  73. * @param o the object
  74. * @param output output to connect. Its MTU must be >= MTU specified in
  75. * {@link PacketPassConnector_Init}.
  76. */
  77. void PacketPassConnector_ConnectOutput (PacketPassConnector *o, PacketPassInterface *output);
  78. /**
  79. * Disconnects output.
  80. * The object must be in connected state.
  81. * The object enters not connected state.
  82. *
  83. * @param o the object
  84. */
  85. void PacketPassConnector_DisconnectOutput (PacketPassConnector *o);
  86. #endif