PacketStreamSender.h 2.1 KB

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