SinglePacketBuffer.h 2.0 KB

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