17 #include <sys/types.h>
21 # include <sys/socket.h>
25 # if defined __linux__
26 # include <linux/if.h>
30 # include <netinet/in.h>
31 # include <netinet/if_ether.h>
48 # define ETHER_ADDR_LEN ETH_ALEN
49 # elif defined Windows
50 # define ETHER_ADDR_LEN 6
53 # if defined IFNAMSIZ && !defined IF_NAMESIZE
54 # define IF_NAMESIZE IFNAMSIZ
55 # elif !defined IF_NAMESIZE
56 # define IF_NAMESIZE 16
59 # define IF_DESCRSIZE 50
61 # if defined TUNSETDEBUG
62 # define TUNSDEBUG TUNSETDEBUG
66 # define TUNFD_INVALID_VALUE INVALID_HANDLE_VALUE
68 # define TUNFD_INVALID_VALUE -1
91 # define snprintf(x, y, z, ...) _snprintf_s((x), (y), (y), (z), __VA_ARGS__);
92 # define strncat(x, y, z) strncat_s((x), _countof(x), (y), (z));
93 # define strdup(x) _strdup(x)
96 # define TUNTAP_ID_MAX 256
97 # define TUNTAP_ID_ANY 257
99 # define TUNTAP_MODE_ETHERNET 0x0001
100 # define TUNTAP_MODE_TUNNEL 0x0002
101 # define TUNTAP_MODE_PERSIST 0x0004
103 # define TUNTAP_LOG_NONE 0x0000
104 # define TUNTAP_LOG_DEBUG 0x0001
105 # define TUNTAP_LOG_INFO 0x0002
106 # define TUNTAP_LOG_NOTICE 0x0004
107 # define TUNTAP_LOG_WARN 0x0008
108 # define TUNTAP_LOG_ERR 0x0016
111 # define TUNTAP_VERSION_MAJOR 0
112 # define TUNTAP_VERSION_MINOR 3
113 # define TUNTAP_VERSION ((TUNTAP_VERSION_MAJOR<<8)|TUNTAP_VERSION_MINOR)
115 # define TUNTAP_GET_FD(x) (x)->tun_fd
119 # if defined(tuntap_EXPORTS)
120 # define TUNTAP_EXPORT __declspec(dllexport)
122 # define TUNTAP_EXPORT __declspec(dllimport)
125 # define TUNTAP_EXPORT
void tuntap_log_default(int, const char *)
Definition: tuntap_log.c:37
int t_tun
Definition: tuntap.h:82
int tuntap_sys_set_ifname(struct device *, const char *, size_t)
Definition: tuntap-unix-aix.c:75
TUNTAP_EXPORT void tuntap_log_set_cb(t_tuntap_log cb)
Copyright (c) 2012, PICHOT Fabien Paul Leonard <pichot.fabienATgmail.com> Copyright (c) 2012...
Definition: tuntap_log.c:29
TUNTAP_EXPORT int tuntap_set_debug(struct device *dev, int)
Definition: tuntap-unix.c:321
int flags
Definition: tuntap.h:135
#define TUNTAP_EXPORT
Definition: tuntap.h:125
TUNTAP_EXPORT char * tuntap_get_ifname(struct device *)
Definition: tuntap.c:59
TUNTAP_EXPORT int tuntap_read(struct device *, void *, size_t)
Definition: tuntap-unix.c:254
TUNTAP_EXPORT struct device * tuntap_init(void)
Definition: tuntap.c:36
unsigned char hwaddr[ETHER_ADDR_LEN]
Definition: tuntap.h:136
int tuntap_sys_set_hwaddr(struct device *, struct ether_addr *)
Definition: tuntap-unix-aix.c:53
TUNTAP_EXPORT char * tuntap_get_hwaddr(struct device *)
Definition: tuntap-unix.c:140
TUNTAP_EXPORT t_tuntap_log tuntap_log
Definition: tuntap.h:142
void(* t_tuntap_log)(int, const char *)
Definition: tuntap.h:141
TUNTAP_EXPORT int tuntap_set_mtu(struct device *, int)
Definition: tuntap-unix.c:233
TUNTAP_EXPORT int tuntap_up(struct device *)
Definition: tuntap-unix.c:179
TUNTAP_EXPORT int tuntap_get_readable(struct device *)
Definition: tuntap-unix.c:290
void tuntap_sys_destroy(struct device *)
Definition: tuntap-unix-aix.c:48
TUNTAP_EXPORT void tuntap_destroy(struct device *)
Definition: tuntap.c:53
TUNTAP_EXPORT int tuntap_get_mtu(struct device *)
Definition: tuntap-unix.c:213
TUNTAP_EXPORT int tuntap_start(struct device *, int, int)
Definition: tuntap-unix.c:46
int ctrl_sock
Definition: tuntap.h:134
TUNTAP_EXPORT int tuntap_write(struct device *, void *, size_t)
Definition: tuntap-unix.c:272
struct in6_addr t_tun_in6_addr
Definition: tuntap.h:84
int tuntap_sys_set_ipv6(struct device *, t_tun_in6_addr *, uint32_t)
Definition: tuntap-unix-aix.c:66
void tuntap_log_chksum(void *, int)
Definition: tuntap_log.c:125
char if_name[IF_NAMESIZE]
Definition: tuntap.h:137
TUNTAP_EXPORT int tuntap_set_descr(struct device *, const char *)
Definition: tuntap-unix.c:95
TUNTAP_EXPORT int tuntap_set_hwaddr(struct device *, const char *)
Definition: tuntap-unix.c:148
#define IF_NAMESIZE
Definition: tuntap.h:56
struct in_addr t_tun_in_addr
Definition: tuntap.h:83
int tuntap_sys_start(struct device *, int, int)
Definition: tuntap-unix-aix.c:43
TUNTAP_EXPORT int tuntap_version(void)
Definition: tuntap.c:64
int tuntap_sys_set_ipv4(struct device *, t_tun_in_addr *, uint32_t)
Definition: tuntap-unix-aix.c:58
t_tun tun_fd
Definition: tuntap.h:133
void tuntap_log_hexdump(void *, size_t)
Definition: tuntap_log.c:69
TUNTAP_EXPORT void tuntap_release(struct device *)
Definition: tuntap-unix.c:88
TUNTAP_EXPORT int tuntap_down(struct device *)
Definition: tuntap-unix.c:196
int tuntap_sys_set_descr(struct device *, const char *, size_t)
Definition: tuntap-unix-aix.c:85
TUNTAP_EXPORT int tuntap_set_nonblocking(struct device *dev, int)
Definition: tuntap-unix.c:303
TUNTAP_EXPORT int tuntap_set_ifname(struct device *, const char *)
Definition: tuntap-unix.c:116
TUNTAP_EXPORT int tuntap_set_ip(struct device *, const char *, int)
Definition: tuntap.c:69