From 25bb52c585fbc73ad9f02f10134cfd39f67ef53e Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Sun, 11 Jun 2006 15:29:37 +0000 Subject: [PATCH] working in openbsd now --- tun.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tun.c b/tun.c index bf3a8c6..bf3cfd1 100644 --- a/tun.c +++ b/tun.c @@ -31,7 +31,7 @@ #define TUN_MAX_TRY 50 char *tun_device = NULL; -char *if_name = NULL; +char if_name[50]; #ifdef LINUX @@ -63,7 +63,7 @@ open_tun() if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) { printf("Opened %s\n", ifreq.ifr_name); - if_name = strdup(ifreq.ifr_name); + snprintf(if_name, sizeof(if_name), "dns%d", i); return tun_fd; } @@ -98,7 +98,7 @@ open_tun() if ((tun_fd = open(tun_name, O_RDWR)) >= 0) { printf("Opened %s\n", tun_name); - if_name = strdup(tun_name); + snprintf(if_name, sizeof(if_name), "tun%d", i); return tun_fd; } @@ -160,6 +160,8 @@ tun_setip(const char *ip) "/sbin/ifconfig %s %s netmask 255.255.255.0", if_name, ip); + + printf("Setting IP of %s to %s\n", if_name, ip); #ifndef LINUX int r; @@ -171,9 +173,8 @@ tun_setip(const char *ip) "/sbin/route add %s/24 %s", ip, ip); } + printf("Adding route %s/24 to %s\n", ip, ip); #endif - - printf("Setting IP of %s to %s\n", if_name, ip); return system(cmdline); }