summaryrefslogtreecommitdiff
path: root/src/tun.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tun.h')
-rw-r--r--src/tun.h32
1 files changed, 32 insertions, 0 deletions
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 <stdlib.h>
+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