DPRelay.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file DPRelay.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. #ifndef BADVPN_CLIENT_DPRELAY_H
  23. #define BADVPN_CLIENT_DPRELAY_H
  24. #include <stdint.h>
  25. #include <limits.h>
  26. #include <protocol/scproto.h>
  27. #include <protocol/dataproto.h>
  28. #include <misc/debug.h>
  29. #include <structure/LinkedList1.h>
  30. #include <system/DebugObject.h>
  31. #include <flow/BufferWriter.h>
  32. #include <client/DataProto.h>
  33. struct DPRelay_flow;
  34. typedef struct {
  35. int frame_mtu;
  36. BufferWriter writer;
  37. DataProtoSource device;
  38. struct DPRelay_flow *current_flow;
  39. DebugObject d_obj;
  40. DebugCounter d_ctr;
  41. } DPRelayRouter;
  42. typedef struct {
  43. DPRelayRouter *router;
  44. peerid_t source_id;
  45. LinkedList1 flows_list;
  46. DebugObject d_obj;
  47. } DPRelaySource;
  48. typedef struct {
  49. peerid_t dest_id;
  50. DataProtoSink *dest;
  51. LinkedList1 flows_list;
  52. DebugObject d_obj;
  53. } DPRelaySink;
  54. struct DPRelay_flow {
  55. DPRelaySource *src;
  56. DPRelaySink *sink;
  57. DataProtoFlow dpls;
  58. LinkedList1Node src_list_node;
  59. LinkedList1Node sink_list_node;
  60. };
  61. int DPRelayRouter_Init (DPRelayRouter *o, int frame_mtu, BReactor *reactor) WARN_UNUSED;
  62. void DPRelayRouter_Free (DPRelayRouter *o);
  63. void DPRelayRouter_SubmitFrame (DPRelayRouter *o, DPRelaySource *src, DPRelaySink *sink, uint8_t *data, int data_len, int num_packets, int inactivity_time);
  64. void DPRelaySource_Init (DPRelaySource *o, DPRelayRouter *router, peerid_t source_id, BReactor *reactor);
  65. void DPRelaySource_Free (DPRelaySource *o);
  66. void DPRelaySource_PrepareFreeDestinations (DPRelaySource *o);
  67. void DPRelaySink_Init (DPRelaySink *o, peerid_t dest_id);
  68. void DPRelaySink_Free (DPRelaySink *o);
  69. void DPRelaySink_Attach (DPRelaySink *o, DataProtoSink *dest);
  70. void DPRelaySink_Detach (DPRelaySink *o);
  71. #endif