Teonet library
0.4.7
|
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | device |
Macros | |
#define | LIBTUNTAP_H_ |
#define | IF_NAMESIZE 16 |
#define | IF_DESCRSIZE 50 /* XXX: Tests needed on NetBSD and OpenBSD */ |
#define | TUNFD_INVALID_VALUE -1 |
#define | TUNTAP_ID_MAX 256 |
#define | TUNTAP_ID_ANY 257 |
#define | TUNTAP_MODE_ETHERNET 0x0001 |
#define | TUNTAP_MODE_TUNNEL 0x0002 |
#define | TUNTAP_MODE_PERSIST 0x0004 |
#define | TUNTAP_LOG_NONE 0x0000 |
#define | TUNTAP_LOG_DEBUG 0x0001 |
#define | TUNTAP_LOG_INFO 0x0002 |
#define | TUNTAP_LOG_NOTICE 0x0004 |
#define | TUNTAP_LOG_WARN 0x0008 |
#define | TUNTAP_LOG_ERR 0x0016 |
#define | TUNTAP_VERSION_MAJOR 0 |
#define | TUNTAP_VERSION_MINOR 3 |
#define | TUNTAP_VERSION ((TUNTAP_VERSION_MAJOR<<8)|TUNTAP_VERSION_MINOR) |
#define | TUNTAP_GET_FD(x) (x)->tun_fd |
#define | TUNTAP_EXPORT |
Typedefs | |
typedef int | t_tun |
typedef struct in_addr | t_tun_in_addr |
typedef struct in6_addr | t_tun_in6_addr |
typedef void(* | t_tuntap_log )(int, const char *) |
Variables | |
TUNTAP_EXPORT t_tuntap_log | tuntap_log |
#define IF_DESCRSIZE 50 /* XXX: Tests needed on NetBSD and OpenBSD */ |
Referenced by tuntap_set_descr().
#define IF_NAMESIZE 16 |
Referenced by tuntap_set_ifname(), and tuntap_sys_set_ifname().
#define LIBTUNTAP_H_ |
#define TUNFD_INVALID_VALUE -1 |
Referenced by tuntap_init(), tuntap_set_ip(), and tuntap_start().
#define TUNTAP_EXPORT |
#define TUNTAP_GET_FD | ( | x | ) | (x)->tun_fd |
#define TUNTAP_ID_ANY 257 |
Referenced by main(), tuntap_start(), and tuntap_sys_start().
#define TUNTAP_ID_MAX 256 |
Referenced by tuntap_sys_start().
#define TUNTAP_LOG_DEBUG 0x0001 |
Referenced by main(), test_cb(), tuntap_get_hwaddr(), and tuntap_log_default().
#define TUNTAP_LOG_ERR 0x0016 |
Referenced by main(), test_cb(), tuntap_get_hwaddr(), tuntap_get_mtu(), tuntap_log_default(), tuntap_read(), tuntap_set_debug(), tuntap_set_descr(), tuntap_set_ifname(), tuntap_set_ip(), tuntap_set_mtu(), tuntap_set_nonblocking(), tuntap_start(), tuntap_sys_set_descr(), tuntap_sys_set_hwaddr(), tuntap_sys_set_ifname(), tuntap_sys_set_ipv4(), tuntap_sys_start(), and tuntap_write().
#define TUNTAP_LOG_INFO 0x0002 |
Referenced by main(), test_cb(), tuntap_get_readable(), tuntap_log_default(), and tuntap_sys_set_ipv6().
#define TUNTAP_LOG_NONE 0x0000 |
Referenced by tuntap_log_chksum(), tuntap_log_default(), and tuntap_log_hexdump().
#define TUNTAP_LOG_NOTICE 0x0004 |
Referenced by main(), test_cb(), tuntap_get_mtu(), tuntap_get_readable(), tuntap_log_default(), tuntap_read(), tuntap_set_debug(), tuntap_set_descr(), tuntap_set_hwaddr(), tuntap_set_ifname(), tuntap_set_ip(), tuntap_set_mtu(), tuntap_set_nonblocking(), tuntap_start(), tuntap_sys_set_descr(), tuntap_sys_set_ifname(), tuntap_sys_set_ipv6(), and tuntap_write().
#define TUNTAP_LOG_WARN 0x0008 |
Referenced by main(), test_cb(), tuntap_log_default(), tuntap_read(), tuntap_set_debug(), tuntap_set_descr(), tuntap_sys_destroy(), tuntap_sys_start(), and tuntap_write().
#define TUNTAP_MODE_ETHERNET 0x0001 |
Referenced by main(), tuntap_start(), and tuntap_sys_start().
#define TUNTAP_MODE_PERSIST 0x0004 |
Referenced by main(), tuntap_start(), and tuntap_sys_start().
#define TUNTAP_MODE_TUNNEL 0x0002 |
Referenced by main(), tuntap_start(), and tuntap_sys_start().
#define TUNTAP_VERSION ((TUNTAP_VERSION_MAJOR<<8)|TUNTAP_VERSION_MINOR) |
Referenced by tuntap_version().
#define TUNTAP_VERSION_MAJOR 0 |
#define TUNTAP_VERSION_MINOR 3 |
typedef int t_tun |
typedef struct in6_addr t_tun_in6_addr |
typedef struct in_addr t_tun_in_addr |
typedef void(* t_tuntap_log)(int, const char *) |
TUNTAP_EXPORT void tuntap_destroy | ( | struct device * | ) |
References tuntap_release(), and tuntap_sys_destroy().
Referenced by main().
TUNTAP_EXPORT int tuntap_down | ( | struct device * | ) |
References device::ctrl_sock, device::flags, if(), and device::if_name.
TUNTAP_EXPORT char* tuntap_get_hwaddr | ( | struct device * | ) |
References device::hwaddr, TAP_IOCTL_GET_MAC, device::tun_fd, tuntap_log, TUNTAP_LOG_DEBUG, and TUNTAP_LOG_ERR.
Referenced by main().
TUNTAP_EXPORT char* tuntap_get_ifname | ( | struct device * | ) |
References device::if_name.
TUNTAP_EXPORT int tuntap_get_mtu | ( | struct device * | ) |
References device::ctrl_sock, device::if_name, TAP_IOCTL_GET_MTU, device::tun_fd, tuntap_log, TUNTAP_LOG_ERR, and TUNTAP_LOG_NOTICE.
Referenced by main(), and tuntap_get_readable().
TUNTAP_EXPORT int tuntap_get_readable | ( | struct device * | ) |
References device::tun_fd, tuntap_get_mtu(), tuntap_log, TUNTAP_LOG_INFO, and TUNTAP_LOG_NOTICE.
TUNTAP_EXPORT struct device* tuntap_init | ( | void | ) |
References device::ctrl_sock, device::flags, device::hwaddr, device::if_name, malloc(), device::tun_fd, TUNFD_INVALID_VALUE, tuntap_log, and tuntap_log_default().
Referenced by main().
void tuntap_log_chksum | ( | void * | , |
int | |||
) |
References tuntap_log, and TUNTAP_LOG_NONE.
void tuntap_log_default | ( | int | , |
const char * | |||
) |
References TUNTAP_LOG_DEBUG, TUNTAP_LOG_ERR, TUNTAP_LOG_INFO, TUNTAP_LOG_NONE, TUNTAP_LOG_NOTICE, and TUNTAP_LOG_WARN.
Referenced by tuntap_init(), and tuntap_log_set_cb().
void tuntap_log_hexdump | ( | void * | , |
size_t | |||
) |
References tuntap_log, and TUNTAP_LOG_NONE.
TUNTAP_EXPORT void tuntap_log_set_cb | ( | t_tuntap_log | cb | ) |
Copyright (c) 2012, PICHOT Fabien Paul Leonard <pichot.fabienATgmail.com> Copyright (c) 2012, Tristan Le Guern <leguern at="" medu="" dot="" se>="">
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
References tuntap_log, and tuntap_log_default().
Referenced by main().
TUNTAP_EXPORT int tuntap_read | ( | struct device * | , |
void * | , | ||
size_t | |||
) |
References device::tun_fd, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, and TUNTAP_LOG_WARN.
TUNTAP_EXPORT void tuntap_release | ( | struct device * | ) |
References device::ctrl_sock, free(), and device::tun_fd.
Referenced by main(), and tuntap_destroy().
TUNTAP_EXPORT int tuntap_set_debug | ( | struct device * | dev, |
int | |||
) |
References device::tun_fd, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, and TUNTAP_LOG_WARN.
Referenced by main(), and tuntap_start().
TUNTAP_EXPORT int tuntap_set_descr | ( | struct device * | , |
const char * | |||
) |
References IF_DESCRSIZE, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, TUNTAP_LOG_WARN, and tuntap_sys_set_descr().
Referenced by main().
TUNTAP_EXPORT int tuntap_set_hwaddr | ( | struct device * | , |
const char * | |||
) |
References device::hwaddr, tuntap_log, TUNTAP_LOG_NOTICE, and tuntap_sys_set_hwaddr().
Referenced by main().
TUNTAP_EXPORT int tuntap_set_ifname | ( | struct device * | , |
const char * | |||
) |
References device::if_name, IF_NAMESIZE, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, and tuntap_sys_set_ifname().
Referenced by main().
TUNTAP_EXPORT int tuntap_set_ip | ( | struct device * | , |
const char * | , | ||
int | |||
) |
References device::tun_fd, TUNFD_INVALID_VALUE, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, tuntap_sys_set_ipv4(), and tuntap_sys_set_ipv6().
Referenced by main().
TUNTAP_EXPORT int tuntap_set_mtu | ( | struct device * | , |
int | |||
) |
References device::ctrl_sock, device::if_name, device::tun_fd, tuntap_log, TUNTAP_LOG_ERR, and TUNTAP_LOG_NOTICE.
Referenced by main().
TUNTAP_EXPORT int tuntap_set_nonblocking | ( | struct device * | dev, |
int | |||
) |
References device::tun_fd, tuntap_log, TUNTAP_LOG_ERR, and TUNTAP_LOG_NOTICE.
TUNTAP_EXPORT int tuntap_start | ( | struct device * | , |
int | , | ||
int | |||
) |
References device::ctrl_sock, fd, NETWORK_ADAPTERS, device::tun_fd, TUNFD_INVALID_VALUE, TUNTAP_ID_ANY, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, TUNTAP_MODE_ETHERNET, TUNTAP_MODE_PERSIST, TUNTAP_MODE_TUNNEL, tuntap_set_debug(), and tuntap_sys_start().
Referenced by main().
void tuntap_sys_destroy | ( | struct device * | ) |
References device::ctrl_sock, device::if_name, device::tun_fd, tuntap_log, and TUNTAP_LOG_WARN.
Referenced by tuntap_destroy().
int tuntap_sys_set_descr | ( | struct device * | , |
const char * | , | ||
size_t | |||
) |
References device::ctrl_sock, device::if_name, tuntap_log, TUNTAP_LOG_ERR, and TUNTAP_LOG_NOTICE.
Referenced by tuntap_set_descr().
int tuntap_sys_set_hwaddr | ( | struct device * | , |
struct ether_addr * | |||
) |
References device::ctrl_sock, device::if_name, tuntap_log, and TUNTAP_LOG_ERR.
Referenced by tuntap_set_hwaddr().
int tuntap_sys_set_ifname | ( | struct device * | , |
const char * | , | ||
size_t | |||
) |
References device::ctrl_sock, device::if_name, IF_NAMESIZE, tuntap_log, TUNTAP_LOG_ERR, and TUNTAP_LOG_NOTICE.
Referenced by tuntap_set_ifname().
int tuntap_sys_set_ipv4 | ( | struct device * | , |
t_tun_in_addr * | , | ||
uint32_t | |||
) |
References device::ctrl_sock, device::if_name, TAP_IOCTL_CONFIG_DHCP_MASQ, device::tun_fd, tuntap_log, and TUNTAP_LOG_ERR.
Referenced by tuntap_set_ip().
int tuntap_sys_set_ipv6 | ( | struct device * | , |
t_tun_in6_addr * | , | ||
uint32_t | |||
) |
References tuntap_log, TUNTAP_LOG_INFO, and TUNTAP_LOG_NOTICE.
Referenced by tuntap_set_ip().
int tuntap_sys_start | ( | struct device * | , |
int | , | ||
int | |||
) |
References device::ctrl_sock, fd, device::flags, device::hwaddr, device::if_name, TUNTAP_ID_ANY, TUNTAP_ID_MAX, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_WARN, TUNTAP_MODE_ETHERNET, TUNTAP_MODE_PERSIST, and TUNTAP_MODE_TUNNEL.
Referenced by tuntap_start().
TUNTAP_EXPORT int tuntap_up | ( | struct device * | ) |
References device::ctrl_sock, device::flags, if(), and device::if_name.
Referenced by main().
TUNTAP_EXPORT int tuntap_version | ( | void | ) |
References TUNTAP_VERSION.
TUNTAP_EXPORT int tuntap_write | ( | struct device * | , |
void * | , | ||
size_t | |||
) |
References device::tun_fd, tuntap_log, TUNTAP_LOG_ERR, TUNTAP_LOG_NOTICE, and TUNTAP_LOG_WARN.
TUNTAP_EXPORT t_tuntap_log tuntap_log |
Referenced by main(), tuntap_get_hwaddr(), tuntap_get_mtu(), tuntap_get_readable(), tuntap_init(), tuntap_log_chksum(), tuntap_log_hexdump(), tuntap_log_set_cb(), tuntap_read(), tuntap_set_debug(), tuntap_set_descr(), tuntap_set_hwaddr(), tuntap_set_ifname(), tuntap_set_ip(), tuntap_set_mtu(), tuntap_set_nonblocking(), tuntap_start(), tuntap_sys_destroy(), tuntap_sys_set_descr(), tuntap_sys_set_hwaddr(), tuntap_sys_set_ifname(), tuntap_sys_set_ipv4(), tuntap_sys_set_ipv6(), tuntap_sys_start(), and tuntap_write().