PacketPassConnector.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <base/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. DebugObject d_obj;
  43. } PacketPassConnector;
  44. /**
  45. * Initializes the object.
  46. * The object is initialized in not connected state.
  47. *
  48. * @param o the object
  49. * @param mtu maximum input packet size. Must be >=0.
  50. * @param pg pending group
  51. */
  52. void PacketPassConnector_Init (PacketPassConnector *o, int mtu, BPendingGroup *pg);
  53. /**
  54. * Frees the object.
  55. *
  56. * @param o the object
  57. */
  58. void PacketPassConnector_Free (PacketPassConnector *o);
  59. /**
  60. * Returns the input interface.
  61. * The MTU of the interface will be as in {@link PacketPassConnector_Init}.
  62. *
  63. * @param o the object
  64. * @return input interface
  65. */
  66. PacketPassInterface * PacketPassConnector_GetInput (PacketPassConnector *o);
  67. /**
  68. * Connects output.
  69. * The object must be in not connected state.
  70. * The object enters connected state.
  71. *
  72. * @param o the object
  73. * @param output output to connect. Its MTU must be >= MTU specified in
  74. * {@link PacketPassConnector_Init}.
  75. */
  76. void PacketPassConnector_ConnectOutput (PacketPassConnector *o, PacketPassInterface *output);
  77. /**
  78. * Disconnects output.
  79. * The object must be in connected state.
  80. * The object enters not connected state.
  81. *
  82. * @param o the object
  83. */
  84. void PacketPassConnector_DisconnectOutput (PacketPassConnector *o);
  85. #endif