Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
NetBSD fixes from Sergey Svishchev
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Dec 5, 2008
1 parent bb319b0 commit 6c68ec1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions dtls.c
Expand Up @@ -27,6 +27,7 @@
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <netinet/in.h>
#include <openssl/err.h>
#include <fcntl.h>
#include <string.h>
Expand Down
35 changes: 17 additions & 18 deletions tun.c
Expand Up @@ -24,16 +24,16 @@

#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <sys/ioctl.h>
#ifndef __APPLE__
#ifdef __linux__
#include <linux/if_tun.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <errno.h>

Expand Down Expand Up @@ -243,22 +243,7 @@ int setup_tun(struct openconnect_info *vpninfo)
vpninfo->script_tun = child;
vpninfo->ifname = "(script)";
} else {
#ifdef __APPLE__
static char tun_name[80];
int i;
for (i=0; i < 255; i++) {
sprintf(tun_name, "/dev/tun%d", i);
tun_fd = open(tun_name, O_RDWR);
if (tun_fd >= 0)
break;
}
if (tun_fd < 0) {
perror("open tun");
exit(1);
}
vpninfo->ifname = tun_name + 5;
#else

#ifdef IFF_TUN /* Linux */
tun_fd = open("/dev/net/tun", O_RDWR);
if (tun_fd < 0) {
vpninfo->progress(vpninfo, PRG_ERR,
Expand All @@ -280,6 +265,20 @@ int setup_tun(struct openconnect_info *vpninfo)
if (!vpninfo->ifname)
vpninfo->ifname = strdup(ifr.ifr_name);

#else /* BSD et al have /dev/tun$x devices */
static char tun_name[80];
int i;
for (i=0; i < 255; i++) {
sprintf(tun_name, "/dev/tun%d", i);
tun_fd = open(tun_name, O_RDWR);
if (tun_fd >= 0)
break;
}
if (tun_fd < 0) {
perror("open tun");
exit(1);
}
vpninfo->ifname = tun_name + 5;
#endif
if (vpninfo->vpnc_script) {
script_config_tun(vpninfo);
Expand Down

0 comments on commit 6c68ec1

Please sign in to comment.