From d399c8468aedc975d52632624786681a3a7ceacc Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 3 Feb 2009 23:56:14 +0000 Subject: new ifconfig syntax (only command line parser yet) --- src/linux/tun.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'src/linux/tun.c') 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); */ } -- cgit v1.2.3