StreamPacketSender.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @file StreamPacketSender.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. #ifndef BADVPN_STREAMPACKETSENDER_H
  23. #define BADVPN_STREAMPACKETSENDER_H
  24. #include <base/DebugObject.h>
  25. #include <flow/StreamPassInterface.h>
  26. #include <flow/PacketPassInterface.h>
  27. /**
  28. * Object which breaks an input stream into output packets. The resulting
  29. * packets will have positive length, and, when concatenated, will form the
  30. * original stream.
  31. *
  32. * Input is with {@link StreamPassInterface}.
  33. * Output is with {@link PacketPassInterface}.
  34. */
  35. typedef struct {
  36. PacketPassInterface *output;
  37. int output_mtu;
  38. StreamPassInterface input;
  39. int sending_len;
  40. DebugObject d_obj;
  41. } StreamPacketSender;
  42. /**
  43. * Initializes the object.
  44. *
  45. * @param o the object
  46. * @param output output interface. Its MTU must be >0.
  47. * @param pg pending group we live in
  48. */
  49. void StreamPacketSender_Init (StreamPacketSender *o, PacketPassInterface *output, BPendingGroup *pg);
  50. /**
  51. * Frees the object.
  52. *
  53. * @param o the object
  54. */
  55. void StreamPacketSender_Free (StreamPacketSender *o);
  56. /**
  57. * Returns the input interface.
  58. *
  59. * @param o the object
  60. * @return input interface
  61. */
  62. StreamPassInterface * StreamPacketSender_GetInput (StreamPacketSender *o);
  63. #endif