mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-03 06:57:27 +00:00
working in openbsd now
This commit is contained in:
parent
d15c72c29c
commit
25bb52c585
11
tun.c
11
tun.c
|
@ -31,7 +31,7 @@
|
||||||
#define TUN_MAX_TRY 50
|
#define TUN_MAX_TRY 50
|
||||||
|
|
||||||
char *tun_device = NULL;
|
char *tun_device = NULL;
|
||||||
char *if_name = NULL;
|
char if_name[50];
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ open_tun()
|
||||||
|
|
||||||
if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) {
|
if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) {
|
||||||
printf("Opened %s\n", ifreq.ifr_name);
|
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;
|
return tun_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ open_tun()
|
||||||
|
|
||||||
if ((tun_fd = open(tun_name, O_RDWR)) >= 0) {
|
if ((tun_fd = open(tun_name, O_RDWR)) >= 0) {
|
||||||
printf("Opened %s\n", tun_name);
|
printf("Opened %s\n", tun_name);
|
||||||
if_name = strdup(tun_name);
|
snprintf(if_name, sizeof(if_name), "tun%d", i);
|
||||||
return tun_fd;
|
return tun_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +160,8 @@ tun_setip(const char *ip)
|
||||||
"/sbin/ifconfig %s %s netmask 255.255.255.0",
|
"/sbin/ifconfig %s %s netmask 255.255.255.0",
|
||||||
if_name,
|
if_name,
|
||||||
ip);
|
ip);
|
||||||
|
|
||||||
|
printf("Setting IP of %s to %s\n", if_name, ip);
|
||||||
#ifndef LINUX
|
#ifndef LINUX
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -171,9 +173,8 @@ tun_setip(const char *ip)
|
||||||
"/sbin/route add %s/24 %s",
|
"/sbin/route add %s/24 %s",
|
||||||
ip, ip);
|
ip, ip);
|
||||||
}
|
}
|
||||||
|
printf("Adding route %s/24 to %s\n", ip, ip);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("Setting IP of %s to %s\n", if_name, ip);
|
|
||||||
return system(cmdline);
|
return system(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue