SinglePacketBuffer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @file SinglePacketBuffer.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. * Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output
  25. * than can store only a single packet.
  26. */
  27. #ifndef BADVPN_FLOW_SINGLEPACKETBUFFER_H
  28. #define BADVPN_FLOW_SINGLEPACKETBUFFER_H
  29. #include <stdint.h>
  30. #include <misc/debug.h>
  31. #include <system/DebugObject.h>
  32. #include <flow/PacketRecvInterface.h>
  33. #include <flow/PacketPassInterface.h>
  34. /**
  35. * Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output
  36. * than can store only a single packet.
  37. */
  38. typedef struct {
  39. DebugObject d_obj;
  40. PacketRecvInterface *input;
  41. PacketPassInterface *output;
  42. uint8_t *buf;
  43. } SinglePacketBuffer;
  44. /**
  45. * Initializes the object.
  46. * Output MTU must be >= input MTU.
  47. *
  48. * @param o the object
  49. * @param input input interface
  50. * @param output output interface
  51. * @param pg pending group
  52. * @return 1 on success, 0 on failure
  53. */
  54. int SinglePacketBuffer_Init (SinglePacketBuffer *o, PacketRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg) WARN_UNUSED;
  55. /**
  56. * Frees the object
  57. *
  58. * @param o the object
  59. */
  60. void SinglePacketBuffer_Free (SinglePacketBuffer *o);
  61. #endif