PacketCopier.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file PacketCopier.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 copies packets.
  25. */
  26. #ifndef BADVPN_FLOW_PACKETCOPIER_H
  27. #define BADVPN_FLOW_PACKETCOPIER_H
  28. #include <stdint.h>
  29. #include <flow/PacketPassInterface.h>
  30. #include <flow/PacketRecvInterface.h>
  31. /**
  32. * Object which copies packets.
  33. * Input is via {@link PacketPassInterface}.
  34. * Output is via {@link PacketRecvInterface}.
  35. */
  36. typedef struct {
  37. DebugObject d_obj;
  38. PacketPassInterface input;
  39. PacketRecvInterface output;
  40. int in_len;
  41. uint8_t *in;
  42. int out_have;
  43. uint8_t *out;
  44. } PacketCopier;
  45. /**
  46. * Initializes the object.
  47. *
  48. * @param o the object
  49. * @param mtu maximum packet size. Must be >=0.
  50. * @param pg pending group
  51. */
  52. void PacketCopier_Init (PacketCopier *o, int mtu, BPendingGroup *pg);
  53. /**
  54. * Frees the object.
  55. *
  56. * @param o the object
  57. */
  58. void PacketCopier_Free (PacketCopier *o);
  59. /**
  60. * Returns the input interface.
  61. * The MTU of the interface will as in {@link PacketCopier_Init}.
  62. * The interface will support cancel functionality.
  63. *
  64. * @return input interface
  65. */
  66. PacketPassInterface * PacketCopier_GetInput (PacketCopier *o);
  67. /**
  68. * Returns the output interface.
  69. * The MTU of the interface will be as in {@link PacketCopier_Init}.
  70. *
  71. * @return output interface
  72. */
  73. PacketRecvInterface * PacketCopier_GetOutput (PacketCopier *o);
  74. #endif