From 3f9fa03e027ef6db9ae7f8f5815a16e6ad6dd66c Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 27 Dec 2008 15:20:28 +0000 Subject: added first version of tun device (needs furhter testing) --- src/tun.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/tun.h') diff --git a/src/tun.h b/src/tun.h index 24bde6a..5b42f61 100644 --- a/src/tun.h +++ b/src/tun.h @@ -35,6 +35,38 @@ #ifndef _TUN_H_ #define _TUN_H_ +#include +typedef unsigned char u_int8_t; +typedef unsigned short int u_int16_t; +typedef unsigned int u_int32_t; + + +enum device_type_enum { TYPE_UNDEF, TYPE_TUN, TYPE_TAP }; +typedef enum device_type_enum device_type_t; + +struct tun_device_struct { + int fd_; + unsigned int with_pi_; + char* actual_name_; + device_type_t type_; + u_int16_t mtu_; + char* local_; + char* remote_netmask_; +}; +typedef struct tun_device_struct tun_device_t; + +void tun_init(tun_device_t** dev, const char* dev_name, const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp); +void tun_init_post(tun_device_t* dev); +void tun_do_ifconfig(tun_device_t* dev); +void tun_close(tun_device_t** dev); + +int tun_read(tun_device_t* dev, u_int8_t* buf, u_int32_t len); +int tun_write(tun_device_t* dev, u_int8_t* buf, u_int32_t len); + +// in tun_helper.h +void tun_conf(tun_device_t* dev, const char* dev_name, const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp, u_int16_t mtu); +int tun_fix_return(int ret, size_t pi_length); +const char* tun_get_type_string(tun_device_t* dev); #endif -- cgit v1.2.3