DPReceive.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @file DPReceive.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. * Receive processing for the VPN client.
  25. */
  26. #ifndef BADVPN_CLIENT_DPRECEIVE_H
  27. #define BADVPN_CLIENT_DPRECEIVE_H
  28. #include <protocol/scproto.h>
  29. #include <misc/debugcounter.h>
  30. #include <misc/debug.h>
  31. #include <structure/LinkedList2.h>
  32. #include <base/DebugObject.h>
  33. #include <client/DataProto.h>
  34. #include <client/DPRelay.h>
  35. #include <client/FrameDecider.h>
  36. typedef void (*DPReceiveDevice_output_func) (void *output_user, uint8_t *data, int data_len);
  37. struct DPReceiveReceiver_s;
  38. typedef struct {
  39. int device_mtu;
  40. DPReceiveDevice_output_func output_func;
  41. void *output_func_user;
  42. BReactor *reactor;
  43. int relay_flow_buffer_size;
  44. int relay_flow_inactivity_time;
  45. int packet_mtu;
  46. DPRelayRouter relay_router;
  47. int have_peer_id;
  48. peerid_t peer_id;
  49. LinkedList2 peers_list;
  50. DebugObject d_obj;
  51. } DPReceiveDevice;
  52. typedef struct {
  53. DPReceiveDevice *device;
  54. peerid_t peer_id;
  55. FrameDeciderPeer *decider_peer;
  56. int is_relay_client;
  57. DPRelaySource relay_source;
  58. DPRelaySink relay_sink;
  59. DataProtoSink *dp_sink;
  60. LinkedList2Node list_node;
  61. DebugObject d_obj;
  62. DebugCounter d_receivers_ctr;
  63. } DPReceivePeer;
  64. typedef struct DPReceiveReceiver_s {
  65. DPReceivePeer *peer;
  66. DPReceiveDevice *device;
  67. PacketPassInterface recv_if;
  68. DebugObject d_obj;
  69. } DPReceiveReceiver;
  70. int DPReceiveDevice_Init (DPReceiveDevice *o, int device_mtu, DPReceiveDevice_output_func output_func, void *output_func_user, BReactor *reactor, int relay_flow_buffer_size, int relay_flow_inactivity_time) WARN_UNUSED;
  71. void DPReceiveDevice_Free (DPReceiveDevice *o);
  72. void DPReceiveDevice_SetPeerID (DPReceiveDevice *o, peerid_t peer_id);
  73. void DPReceivePeer_Init (DPReceivePeer *o, DPReceiveDevice *device, peerid_t peer_id, FrameDeciderPeer *decider_peer, int is_relay_client);
  74. void DPReceivePeer_Free (DPReceivePeer *o);
  75. void DPReceivePeer_AttachSink (DPReceivePeer *o, DataProtoSink *dp_sink);
  76. void DPReceivePeer_DetachSink (DPReceivePeer *o);
  77. void DPReceiveReceiver_Init (DPReceiveReceiver *o, DPReceivePeer *peer);
  78. void DPReceiveReceiver_Free (DPReceiveReceiver *o);
  79. PacketPassInterface * DPReceiveReceiver_GetInput (DPReceiveReceiver *o);
  80. #endif