PacketStreamSender.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @file PacketStreamSender.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. * Object which forwards packets obtained with {@link PacketPassInterface}
  25. * as a stream with {@link StreamPassInterface} (i.e. it concatenates them).
  26. */
  27. #ifndef BADVPN_FLOW_PACKETSTREAMSENDER_H
  28. #define BADVPN_FLOW_PACKETSTREAMSENDER_H
  29. #include <stdint.h>
  30. #include <system/DebugObject.h>
  31. #include <flow/PacketPassInterface.h>
  32. #include <flow/StreamPassInterface.h>
  33. /**
  34. * Object which forwards packets obtained with {@link PacketPassInterface}
  35. * as a stream with {@link StreamPassInterface} (i.e. it concatenates them).
  36. */
  37. typedef struct {
  38. DebugObject d_obj;
  39. PacketPassInterface input;
  40. StreamPassInterface *output;
  41. int in_len;
  42. uint8_t *in;
  43. int in_used;
  44. } PacketStreamSender;
  45. /**
  46. * Initializes the object.
  47. *
  48. * @param s the object
  49. * @param output output interface
  50. * @param mtu input MTU. Must be >=0.
  51. * @param pg pending group
  52. */
  53. void PacketStreamSender_Init (PacketStreamSender *s, StreamPassInterface *output, int mtu, BPendingGroup *pg);
  54. /**
  55. * Frees the object.
  56. *
  57. * @param s the object
  58. */
  59. void PacketStreamSender_Free (PacketStreamSender *s);
  60. /**
  61. * Returns the input interface.
  62. * Its MTU will be as in {@link PacketStreamSender_Init}.
  63. *
  64. * @param s the object
  65. * @return input interface
  66. */
  67. PacketPassInterface * PacketStreamSender_GetInput (PacketStreamSender *s);
  68. #endif