lokinet/llarp/vpn/common.hpp
Jeff 49b9ad7197
tun code refactor (#1495)
* partial tun code refactor

* take out the trash

* move vpn platform code into llarp/vpn/platform.cpp

* fix hive build

* fix win32

* fix memory leak on win32

* reduce cpu use

* make macos compile

* win32 patches:

* use wepoll for zmq
* use all cores on windows iocp read loop

* fix zmq patch for windows

* clean up cmake for win32

* add uninstall before reinstall option to win32 installer

* more ipv6 stuff

* make it compile

* fix up route poker

* remove an unneeded code block in macos wtf

* always use call to system

* fix route poker behavior on macos

* disable ipv6 on windows for now

* cpu perf improvement:

* colease calls to Router::PumpLL to 1 per event loop wakeup

* set up THEN add addresses

* emulate proactor event loop on win32

* remove excessively verbose error message

* fix issue #1499

* exclude uv_poll from win32 so that it can start up

* update logtag to include directory

* create minidump on windows if there was a crash

* make windows happy

* use dmp suffix on minidump files

* typo fix

* address feedback from jason
* use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR
* quote $@ in apply-patches in case path has spaces in it

* address feedback from tom

* remove llarp/ev/pipe
* add comments for clairification
* make event loop queue size constant named
2021-01-11 18:13:22 -05:00

33 lines
642 B
C++

#pragma once
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
namespace llarp::vpn
{
struct IOCTL
{
const int _fd;
explicit IOCTL(int af) : _fd{::socket(af, SOCK_DGRAM, IPPROTO_IP)}
{
if (_fd == -1)
throw std::invalid_argument{strerror(errno)};
};
~IOCTL()
{
::close(_fd);
}
template <typename Command, typename... Args>
void
ioctl(Command cmd, Args&&... args)
{
if (::ioctl(_fd, cmd, std::forward<Args>(args)...) == -1)
throw std::runtime_error("ioctl failed: " + std::string{strerror(errno)});
}
};
} // namespace llarp::vpn