summaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-helper-vpn.c
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-02-02 22:42:11 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-02-02 22:42:11 +0000
commitb13a84b528dc581a6c1a042317f8e9cc3874642e (patch)
treeaa3634560272e8975e66f2254860921e6fa99b82 /src/vpn/gnunet-helper-vpn.c
parentdf4003f4dca054be8ca8c4d1c87dc9ba3df8a810 (diff)
create the tun-interfaces with a name choosen by the user
Diffstat (limited to 'src/vpn/gnunet-helper-vpn.c')
-rw-r--r--src/vpn/gnunet-helper-vpn.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c
index 37ec71868..554019d7c 100644
--- a/src/vpn/gnunet-helper-vpn.c
+++ b/src/vpn/gnunet-helper-vpn.c
@@ -30,7 +30,6 @@
* have your name added to the list):
*
* - Philipp Tölke
- * - Christian Grothoff
*/
#include "platform.h"
#include <linux/if_tun.h>
@@ -96,7 +95,7 @@ init_tun (char *dev)
memset (&ifr, 0, sizeof (ifr));
ifr.ifr_flags = IFF_TUN;
- if ('\0' == *dev)
+ if ('\0' != *dev)
strncpy (ifr.ifr_name, dev, IFNAMSIZ);
if (-1 == ioctl (fd, TUNSETIFF, (void *) &ifr))
@@ -532,24 +531,26 @@ main (int argc, char **argv)
char dev[IFNAMSIZ];
int fd_tun;
- memset (dev, 0, IFNAMSIZ);
- if (-1 == (fd_tun = init_tun (dev)))
+ if (6 != argc)
{
fprintf (stderr,
- "Fatal: could not initialize tun-interface\n");
+ "Fatal: must supply 5 arguments!\n");
return 1;
}
- if (5 != argc)
+ strncpy(dev, argv[1], IFNAMSIZ);
+ dev[IFNAMSIZ - 1] = '\0';
+
+ if (-1 == (fd_tun = init_tun (dev)))
{
fprintf (stderr,
- "Fatal: must supply 4 arguments!\n");
+ "Fatal: could not initialize tun-interface\n");
return 1;
}
{
- const char *address = argv[1];
- long prefix_len = atol(argv[2]);
+ const char *address = argv[2];
+ long prefix_len = atol(argv[3]);
if ( (prefix_len < 1) || (prefix_len > 127) )
{
@@ -561,8 +562,8 @@ main (int argc, char **argv)
}
{
- const char *address = argv[3];
- const char *mask = argv[4];
+ const char *address = argv[4];
+ const char *mask = argv[5];
set_address4 (dev, address, mask);
}