FragmentProtoDisassembler.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_FLOW_CCPROTODISASSEMBLER_H
  28. #define BADVPN_FLOW_CCPROTODISASSEMBLER_H
  29. #include <stdint.h>
  30. #include <protocol/fragmentproto.h>
  31. #include <system/DebugObject.h>
  32. #include <system/BReactor.h>
  33. #include <system/BTime.h>
  34. #include <flow/PacketPassInterface.h>
  35. #include <flow/PacketRecvInterface.h>
  36. /**
  37. * Object which encodes packets into packets composed of chunks
  38. * according to FragmentProto.
  39. *
  40. * Input is with {@link PacketPassInterface}.
  41. * Output is with {@link PacketRecvInterface}.
  42. */
  43. typedef struct {
  44. BReactor *reactor;
  45. int input_mtu;
  46. int output_mtu;
  47. int chunk_mtu;
  48. btime_t latency;
  49. PacketPassInterface input;
  50. PacketRecvInterface output;
  51. BTimer timer;
  52. int in_len;
  53. uint8_t *in;
  54. int in_used;
  55. uint8_t *out;
  56. int out_used;
  57. fragmentproto_frameid frame_id;
  58. DebugObject d_obj;
  59. } FragmentProtoDisassembler;
  60. /**
  61. * Initializes the object.
  62. *
  63. * @param o the object
  64. * @param reactor reactor we live in
  65. * @param input_mtu maximum input packet size. Must be >=0 and <2^16
  66. * @param output_mtu maximum output packet size. Must be >sizeof(struct fragmentproto_chunk_header).
  67. * @param chunk_mtu maximum chunk size. Must be >0, or <0 for no explicit limit.
  68. * @param latency maximum time a pending output packet with some data can wait for more data
  69. * before being sent out. If nonnegative, a timer will be used. If negative,
  70. * packets will always be sent out immediately. If low latency is desired,
  71. * prefer setting this to zero rather than negative.
  72. */
  73. void FragmentProtoDisassembler_Init (FragmentProtoDisassembler *o, BReactor *reactor, int input_mtu, int output_mtu, int chunk_mtu, btime_t latency);
  74. /**
  75. * Frees the object.
  76. *
  77. * @param o the object
  78. */
  79. void FragmentProtoDisassembler_Free (FragmentProtoDisassembler *o);
  80. /**
  81. * Returns the input interface.
  82. *
  83. * @param o the object
  84. * @return input interface
  85. */
  86. PacketPassInterface * FragmentProtoDisassembler_GetInput (FragmentProtoDisassembler *o);
  87. /**
  88. * Returns the output interface.
  89. *
  90. * @param o the object
  91. * @return output interface
  92. */
  93. PacketRecvInterface * FragmentProtoDisassembler_GetOutput (FragmentProtoDisassembler *o);
  94. #endif