DPReceive.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 <flow/PacketPassFairQueue.h>
  34. #include <client/DataProto.h>
  35. #include <client/DPRelay.h>
  36. #include <client/FrameDecider.h>
  37. typedef void (*DPReceiveReceiver_forgotten_cb) (void *user);
  38. struct DPReceiveReceiver_s;
  39. typedef struct {
  40. BReactor *reactor;
  41. int relay_flow_buffer_size;
  42. int relay_flow_inactivity_time;
  43. int device_mtu;
  44. int packet_mtu;
  45. DPRelayRouter relay_router;
  46. PacketPassFairQueue queue;
  47. int have_peer_id;
  48. peerid_t peer_id;
  49. int freeing;
  50. LinkedList2 peers_list;
  51. struct DPReceiveReceiver_s *forgotten_receiver;
  52. DebugObject d_obj;
  53. } DPReceiveDevice;
  54. typedef struct {
  55. DPReceiveDevice *device;
  56. peerid_t peer_id;
  57. FrameDeciderPeer *decider_peer;
  58. int is_relay_client;
  59. DPRelaySource relay_source;
  60. DPRelaySink relay_sink;
  61. DataProtoSink *dp_sink;
  62. LinkedList2Node list_node;
  63. DebugObject d_obj;
  64. DebugCounter d_receivers_ctr;
  65. } DPReceivePeer;
  66. typedef struct DPReceiveReceiver_s {
  67. DPReceivePeer *peer;
  68. DPReceiveDevice *device;
  69. PacketPassFairQueueFlow qflow;
  70. PacketPassInterface *qflow_if;
  71. PacketPassInterface recv_if;
  72. DPReceiveReceiver_forgotten_cb forgotten_cb;
  73. void *forgotten_user;
  74. DebugObject d_obj;
  75. } DPReceiveReceiver;
  76. int DPReceiveDevice_Init (DPReceiveDevice *o, PacketPassInterface *output, BReactor *reactor, int relay_flow_buffer_size, int relay_flow_inactivity_time) WARN_UNUSED;
  77. void DPReceiveDevice_Free (DPReceiveDevice *o);
  78. void DPReceiveDevice_PrepareFree (DPReceiveDevice *o);
  79. void DPReceiveDevice_SetPeerID (DPReceiveDevice *o, peerid_t peer_id);
  80. void DPReceivePeer_Init (DPReceivePeer *o, DPReceiveDevice *device, peerid_t peer_id, FrameDeciderPeer *decider_peer, int is_relay_client);
  81. void DPReceivePeer_Free (DPReceivePeer *o);
  82. void DPReceivePeer_AttachSink (DPReceivePeer *o, DataProtoSink *dp_sink);
  83. void DPReceivePeer_DetachSink (DPReceivePeer *o);
  84. void DPReceiveReceiver_Init (DPReceiveReceiver *o, DPReceivePeer *peer);
  85. void DPReceiveReceiver_Free (DPReceiveReceiver *o);
  86. PacketPassInterface * DPReceiveReceiver_GetInput (DPReceiveReceiver *o);
  87. int DPReceiveReceiver_IsBusy (DPReceiveReceiver *o);
  88. void DPReceiveReceiver_Forget (DPReceiveReceiver *o, DPReceiveReceiver_forgotten_cb forgotten_cb, void *user);
  89. #endif