mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-29 05:34:23 +00:00
app/openvpn: update to new APIs
Replace Thread_deprecated, env()->heap(). Ref #1987
This commit is contained in:
parent
a9a8bb0d8f
commit
1f019d65d3
@ -13,9 +13,8 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <os/config.h>
|
#include <base/heap.h>
|
||||||
#include <os/static_root.h>
|
#include <os/static_root.h>
|
||||||
#include <cap_session/connection.h>
|
|
||||||
#include <nic/component.h>
|
#include <nic/component.h>
|
||||||
#include <root/component.h>
|
#include <root/component.h>
|
||||||
#include <libc/component.h>
|
#include <libc/component.h>
|
||||||
@ -39,7 +38,7 @@ extern int genode_argc;
|
|||||||
extern "C" int openvpn_main(int, char*[]);
|
extern "C" int openvpn_main(int, char*[]);
|
||||||
|
|
||||||
|
|
||||||
class Openvpn_thread : public Genode::Thread_deprecated<16UL * 1024 * sizeof (long)>
|
class Openvpn_thread : public Genode::Thread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -49,9 +48,9 @@ class Openvpn_thread : public Genode::Thread_deprecated<16UL * 1024 * sizeof (lo
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Openvpn_thread(int argc, char *argv[])
|
Openvpn_thread(Genode::Env &env, int argc, char *argv[])
|
||||||
:
|
:
|
||||||
Thread_deprecated("openvpn_main"),
|
Thread(env, "openvpn_main", 16UL * 1024 * sizeof (long)),
|
||||||
_argc(argc), _argv(argv),
|
_argc(argc), _argv(argv),
|
||||||
_exitcode(-1)
|
_exitcode(-1)
|
||||||
{ }
|
{ }
|
||||||
@ -203,7 +202,8 @@ class Root : public Genode::Root_component<Openvpn_component, Genode::Single_cli
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Genode::Entrypoint &_ep;
|
Libc::Env &_env;
|
||||||
|
Genode::Heap _heap { _env.ram(), _env.rm() };
|
||||||
Openvpn_thread *_thread = nullptr;
|
Openvpn_thread *_thread = nullptr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -235,9 +235,9 @@ class Root : public Genode::Root_component<Openvpn_component, Genode::Single_cli
|
|||||||
|
|
||||||
Openvpn_component *component = new (Root::md_alloc())
|
Openvpn_component *component = new (Root::md_alloc())
|
||||||
Openvpn_component(tx_buf_size, rx_buf_size,
|
Openvpn_component(tx_buf_size, rx_buf_size,
|
||||||
*env()->heap(),
|
_heap,
|
||||||
*env()->ram_session(),
|
_env.ram(),
|
||||||
_ep);
|
_env.ep());
|
||||||
/**
|
/**
|
||||||
* Setting the pointer in this manner is quite hackish but it has
|
* Setting the pointer in this manner is quite hackish but it has
|
||||||
* to be valid before OpenVPN calls open_tun(), which unfortunatly
|
* to be valid before OpenVPN calls open_tun(), which unfortunatly
|
||||||
@ -245,7 +245,7 @@ class Root : public Genode::Root_component<Openvpn_component, Genode::Single_cli
|
|||||||
*/
|
*/
|
||||||
_tuntap_dev = component;
|
_tuntap_dev = component;
|
||||||
|
|
||||||
_thread = new (Genode::env()->heap()) Openvpn_thread(genode_argc, genode_argv);
|
_thread = new (_heap) Openvpn_thread(_env, genode_argc, genode_argv);
|
||||||
_thread->start();
|
_thread->start();
|
||||||
|
|
||||||
/* wait until OpenVPN configured the TUN/TAP device for the first time */
|
/* wait until OpenVPN configured the TUN/TAP device for the first time */
|
||||||
@ -263,30 +263,19 @@ class Root : public Genode::Root_component<Openvpn_component, Genode::Single_cli
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Root(Genode::Entrypoint &ep, Genode::Allocator &md_alloc)
|
Root(Libc::Env &env)
|
||||||
: Genode::Root_component<Openvpn_component, Genode::Single_client>(&ep.rpc_ep(), &md_alloc),
|
: Genode::Root_component<Openvpn_component, Genode::Single_client>(env.ep(), _heap),
|
||||||
_ep(ep)
|
_env(env)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Main
|
|
||||||
{
|
|
||||||
Genode::Entrypoint &ep;
|
|
||||||
::Root nic_root { ep, *Genode::env()->heap() };
|
|
||||||
|
|
||||||
Main(Genode::Entrypoint &ep) : ep(ep)
|
|
||||||
{
|
|
||||||
Genode::env()->parent()->announce(ep.manage(nic_root));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/***************
|
/***************
|
||||||
** Component **
|
** Component **
|
||||||
***************/
|
***************/
|
||||||
|
|
||||||
void Libc::Component::construct(Libc::Env &env)
|
void Libc::Component::construct(Libc::Env &env)
|
||||||
{
|
{
|
||||||
static Main server(env.ep());
|
static ::Root nic_root(env);
|
||||||
|
env.parent().announce(env.ep().manage(nic_root));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
TARGET = openvpn
|
TARGET = openvpn
|
||||||
|
|
||||||
LIBS += libc libc_pipe libc_lwip_nic_dhcp \
|
LIBS += libc libc_pipe libc_lwip_nic_dhcp \
|
||||||
libcrypto libssl config_args
|
libcrypto libssl
|
||||||
|
|
||||||
OPENVPN_PORT_DIR := $(call select_from_ports,openvpn)
|
OPENVPN_PORT_DIR := $(call select_from_ports,openvpn)
|
||||||
OPENVPN_DIR := $(OPENVPN_PORT_DIR)/src/app/openvpn
|
OPENVPN_DIR := $(OPENVPN_PORT_DIR)/src/app/openvpn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user