FragmentProtoDisassembler.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * @file FragmentProtoDisassembler.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 encodes packets into packets composed of chunks
  25. * according to FragmentProto.
  26. */
  27. #ifndef BADVPN_CLIENT_CCPROTODISASSEMBLER_H
  28. #define BADVPN_CLIENT_CCPROTODISASSEMBLER_H
  29. #include <stdint.h>
  30. #include <protocol/fragmentproto.h>
  31. #include <base/DebugObject.h>
  32. #include <base/BPending.h>
  33. #include <flow/PacketPassInterface.h>
  34. #include <flow/PacketRecvInterface.h>
  35. /**
  36. * Object which encodes packets into packets composed of chunks
  37. * according to FragmentProto.
  38. *
  39. * Input is with {@link PacketPassInterface}.
  40. * Output is with {@link PacketRecvInterface}.
  41. */
  42. typedef struct {
  43. int output_mtu;
  44. int chunk_mtu;
  45. PacketPassInterface input;
  46. PacketRecvInterface output;
  47. BPending finish_job;
  48. int in_len;
  49. uint8_t *in;
  50. int in_used;
  51. uint8_t *out;
  52. int out_used;
  53. fragmentproto_frameid frame_id;
  54. DebugObject d_obj;
  55. } FragmentProtoDisassembler;
  56. /**
  57. * Initializes the object.
  58. *
  59. * @param o the object
  60. * @param pg pending group we live in
  61. * @param input_mtu maximum input packet size. Must be >=0 and <=UINT16_MAX.
  62. * @param output_mtu maximum output packet size. Must be >sizeof(struct fragmentproto_chunk_header).
  63. * @param chunk_mtu maximum chunk size. Must be >0, or <0 for no explicit limit.
  64. */
  65. void FragmentProtoDisassembler_Init (FragmentProtoDisassembler *o, BPendingGroup *pg, int input_mtu, int output_mtu, int chunk_mtu);
  66. /**
  67. * Frees the object.
  68. *
  69. * @param o the object
  70. */
  71. void FragmentProtoDisassembler_Free (FragmentProtoDisassembler *o);
  72. /**
  73. * Returns the input interface.
  74. *
  75. * @param o the object
  76. * @return input interface
  77. */
  78. PacketPassInterface * FragmentProtoDisassembler_GetInput (FragmentProtoDisassembler *o);
  79. /**
  80. * Returns the output interface.
  81. *
  82. * @param o the object
  83. * @return output interface
  84. */
  85. PacketRecvInterface * FragmentProtoDisassembler_GetOutput (FragmentProtoDisassembler *o);
  86. #endif