summaryrefslogtreecommitdiff
path: root/src/linux/tun.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-06-24 01:03:50 +0000
committerChristian Pointner <equinox@anytun.org>2009-06-24 01:03:50 +0000
commit3dd375cf0b3becc14a1b0435e6a330c26af6bb43 (patch)
tree580108950c01ff895f2bc88b2ef584b4eb78355d /src/linux/tun.c
parentfixed build for no-crypt target (diff)
linux tun device now uses uanytun_exec for ifconfig call
Diffstat (limited to 'src/linux/tun.c')
-rw-r--r--src/linux/tun.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/linux/tun.c b/src/linux/tun.c
index c2187a6..e46e5ee 100644
--- a/src/linux/tun.c
+++ b/src/linux/tun.c
@@ -54,6 +54,7 @@
#define DEFAULT_DEVICE "/dev/net/tun"
#include "log.h"
+#include "sysexec.h"
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)
@@ -189,18 +190,15 @@ void tun_do_ifconfig(tun_device_t* dev)
if(!dev || !dev->actual_name_ || !dev->net_addr_ || !dev->net_mask_)
return;
- char* command = NULL;
- asprintf(&command, "/sbin/ifconfig %s %s netmask %s mtu %d", dev->actual_name_, dev->net_addr_, dev->net_mask_, dev->mtu_);
- if(!command) {
+ char* mtu_str = NULL;
+ asprintf(&mtu_str, "%d", dev->mtu_);
+ if(!mtu_str) {
log_printf(ERROR, "Execution of ifconfig failed");
return;
}
- int result = system(command);
- if(result == -1)
- log_printf(ERROR, "Execution of ifconfig failed");
- else
- log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result));
+ char* const argv[] = { dev->actual_name_, dev->net_addr_, "netmask", dev->net_mask_, "mtu", mtu_str, NULL };
+ uanytun_exec("/sbin/ifconfig", argv, NULL);
- free(command);
+ free(mtu_str);
}