2019-10-04 18:10:58 +00:00
|
|
|
#ifndef LLARP_EV_VPNIO_HPP
|
|
|
|
#define LLARP_EV_VPNIO_HPP
|
|
|
|
#include <net/ip.hpp>
|
|
|
|
#include <util/thread/queue.hpp>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
struct llarp_main;
|
|
|
|
struct llarp_vpn_io;
|
|
|
|
|
|
|
|
struct llarp_vpn_pkt_queue
|
|
|
|
{
|
|
|
|
using Packet_t = llarp::net::IPPacket;
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp::thread::Queue<Packet_t> queue;
|
2019-10-04 18:10:58 +00:00
|
|
|
|
|
|
|
llarp_vpn_pkt_queue() : queue(1024){};
|
|
|
|
~llarp_vpn_pkt_queue() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct llarp_vpn_pkt_writer : public llarp_vpn_pkt_queue
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct llarp_vpn_pkt_reader : public llarp_vpn_pkt_queue
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct llarp_vpn_io_impl
|
|
|
|
{
|
|
|
|
llarp_vpn_io_impl(llarp_main* p, llarp_vpn_io* io) : ptr(p), parent(io)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
~llarp_vpn_io_impl() = default;
|
|
|
|
|
|
|
|
llarp_main* ptr;
|
|
|
|
llarp_vpn_io* parent;
|
|
|
|
|
|
|
|
llarp_vpn_pkt_writer writer;
|
|
|
|
llarp_vpn_pkt_reader reader;
|
|
|
|
|
|
|
|
void
|
|
|
|
AsyncClose();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
CallSafe(std::function<void(void)> f);
|
2019-10-04 18:10:58 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Expunge();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|