You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/include/llarp/handlers/tun.hpp

59 lines
1.2 KiB
C++

#ifndef LLARP_HANDLERS_TUN_HPP
#define LLARP_HANDLERS_TUN_HPP
6 years ago
#include <llarp/ev.h>
#include <llarp/service/endpoint.hpp>
#include <llarp/threading.hpp>
namespace llarp
{
namespace handlers
{
6 years ago
struct TunEndpoint : public service::Endpoint
{
6 years ago
static constexpr int DefaultNetmask = 16;
static constexpr char DefaultIfname[] = "lokinet0";
static constexpr char DefaultDstAddr[] = "10.10.0.1";
static constexpr char DefaultSrcAddr[] = "10.10.0.2";
TunEndpoint(const std::string& nickname, llarp_router* r);
~TunEndpoint();
bool
SetOption(const std::string& k, const std::string& v);
void
Tick(llarp_time_t now);
void
TickTun(llarp_time_t now);
bool
Start();
/// set up tun interface, blocking
bool
SetupTun();
/// overrides Endpoint
bool
SetupNetworking();
llarp_tun_io tunif;
static void
tunifTick(llarp_tun_io* t);
static void
tunifRecvPkt(llarp_tun_io* t, const void* pkt, ssize_t sz);
static void
handleTickTun(void* u);
private:
std::promise< bool > m_TunSetupResult;
};
} // namespace handlers
} // namespace llarp
6 years ago
#endif