OpenVPN
Functions
tun_afunix.c File Reference
#include "syshead.h"
#include "tun.h"
#include "fdmisc.h"
#include "run_command.h"
#include "manage.h"
#include "win32.h"
#include "wfp_block.h"
#include "argv.h"
#include "options.h"
#include "socket.h"
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
Include dependency graph for tun_afunix.c:

Go to the source code of this file.

Functions

static void tun_afunix_exec_child (const char *dev_node, struct tuntap *tt, struct env_set *env)
 
void open_tun_afunix (struct options *o, int mtu, struct tuntap *tt, struct env_set *orig_env)
 Opens an AF_UNIX based tun device.
 
void close_tun_afunix (struct tuntap *tt)
 Closes the socket used for the AF_UNIX based device.
 
ssize_t write_tun_afunix (struct tuntap *tt, uint8_t *buf, int len)
 Writes a packet to a AF_UNIX based tun device.
 
ssize_t read_tun_afunix (struct tuntap *tt, uint8_t *buf, int len)
 Reads a packet from a AF_UNIX based tun device.
 

Function Documentation

◆ close_tun_afunix()

void close_tun_afunix ( struct tuntap tt)

Closes the socket used for the AF_UNIX based device.

Also sends a SIGINT to the child process that was spawned to handle the tun device

Definition at line 129 of file tun_afunix.c.

References tuntap::actual_name, tuntap::afunix, ASSERT, and afunix_context::childprocess.

Referenced by do_close_tun_simple().

◆ open_tun_afunix()

void open_tun_afunix ( struct options o,
int  mtu,
struct tuntap tt,
struct env_set env 
)

Opens an AF_UNIX based tun device.

This also executes the command that the user provided taking care of implementing the actual tun device.

Definition at line 74 of file tun_afunix.c.

References tuntap::actual_name, options::dev, options::dev_node, options::dev_type, dev_type_string(), env_set_create(), env_set_inherit(), gc, gc_free(), gc_new(), options::lladdr, M_ERR, msg, options::route_default_gateway, set_cloexec(), setenv_int(), setenv_str(), socket_set_buffers(), string_alloc(), and tun_afunix_exec_child().

Referenced by open_tun_backend().

◆ read_tun_afunix()

ssize_t read_tun_afunix ( struct tuntap tt,
uint8_t *  buf,
int  len 
)

Reads a packet from a AF_UNIX based tun device.

Definition at line 157 of file tun_afunix.c.

References tuntap::afunix, afunix_context::childprocess, M_WARN, msg, openvpn_waitpid_check(), and read.

Referenced by read_incoming_tun().

◆ tun_afunix_exec_child()

static void tun_afunix_exec_child ( const char *  dev_node,
struct tuntap tt,
struct env_set env 
)
static

◆ write_tun_afunix()

ssize_t write_tun_afunix ( struct tuntap tt,
uint8_t *  buf,
int  len 
)

Writes a packet to a AF_UNIX based tun device.

Definition at line 144 of file tun_afunix.c.

References tuntap::afunix, afunix_context::childprocess, M_WARN, msg, openvpn_waitpid_check(), and write.

Referenced by process_outgoing_tun().