summaryrefslogtreecommitdiff
path: root/src/linux
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-02-03 23:56:14 +0000
committerChristian Pointner <equinox@anytun.org>2009-02-03 23:56:14 +0000
commitd399c8468aedc975d52632624786681a3a7ceacc (patch)
tree9ecd5d78a56ccef3e18a001685b88c0447da09d2 /src/linux
parentdroping privileges without chroot is now possible (diff)
new ifconfig syntax (only command line parser yet)
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/tun.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/linux/tun.c b/src/linux/tun.c
index 88d6d6e..d8044b5 100644
--- a/src/linux/tun.c
+++ b/src/linux/tun.c
@@ -52,12 +52,11 @@
#include "log.h"
-int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp)
-{
+int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, const char* ifcfg_addr, u_int16_t ifcfg_prefix){
if(!dev)
return;
- tun_conf(dev, dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400);
+ tun_conf(dev, dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400);
dev->actual_name_ = NULL;
dev->fd_ = open(DEFAULT_DEVICE, O_RDWR);
@@ -103,7 +102,7 @@ int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, cons
return -2;
}
- if(ifcfg_lp && ifcfg_rnmp)
+ if(ifcfg_addr)
tun_do_ifconfig(dev);
return 0;
@@ -125,11 +124,8 @@ void tun_close(tun_device_t* dev)
if(dev->actual_name_)
free(dev->actual_name_);
- if(dev->local_)
- free(dev->local_);
-
- if(dev->remote_netmask_)
- free(dev->remote_netmask_);
+ if(dev->net_addr_)
+ free(dev->net_addr_);
}
int tun_read(tun_device_t* dev, u_int8_t* buf, u_int32_t len)
@@ -184,25 +180,25 @@ int tun_write(tun_device_t* dev, u_int8_t* buf, u_int32_t len)
void tun_do_ifconfig(tun_device_t* dev)
{
- if(!dev || !dev->actual_name_ || !dev->local_ || !dev->remote_netmask_)
+ if(!dev || !dev->actual_name_ || !dev->net_addr_)
return;
- char* command = NULL;
- if(dev->type_ == TYPE_TUN)
- asprintf(&command, "/sbin/ifconfig %s %s pointopoint %s mtu %d", dev->actual_name_, dev->local_, dev->remote_netmask_, dev->mtu_);
- else
- asprintf(&command, "/sbin/ifconfig %s %s netmask %s mtu %d", dev->actual_name_, dev->local_, dev->remote_netmask_, dev->mtu_);
+/* char* command = NULL; */
+/* if(dev->type_ == TYPE_TUN) */
+/* asprintf(&command, "/sbin/ifconfig %s %s pointopoint %s mtu %d", dev->actual_name_, dev->local_, dev->remote_netmask_, dev->mtu_); */
+/* else */
+/* asprintf(&command, "/sbin/ifconfig %s %s netmask %s mtu %d", dev->actual_name_, dev->local_, dev->remote_netmask_, dev->mtu_); */
- if(!command) {
- log_printf(ERR, "Execution of ifconfig failed");
- return;
- }
+/* if(!command) { */
+/* log_printf(ERR, "Execution of ifconfig failed"); */
+/* return; */
+/* } */
- int result = system(command);
- if(result == -1)
- log_printf(ERR, "Execution of ifconfig failed");
- else
- log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result));
+/* int result = system(command); */
+/* if(result == -1) */
+/* log_printf(ERR, "Execution of ifconfig failed"); */
+/* else */
+/* log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result)); */
- free(command);
+/* free(command); */
}