Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Split out os_setup_tun() for Windows vs. sane platforms
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 13, 2014
1 parent d0ec3d4 commit c3d166f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions openconnect-internal.h
Expand Up @@ -445,18 +445,17 @@ int dumb_socketpair(int socks[2], int make_overlapped);
} while (0)

/****************************************************************************/
/* tun-win32.c */
int win32_setup_tun(struct openconnect_info *vpninfo);

/* script.c */
int setenv_int(const char *opt, int value);
void set_script_env(struct openconnect_info *vpninfo);
int script_config_tun(struct openconnect_info *vpninfo, const char *reason);

/* tun.c */
/* tun.c / tun-win32.c */
void os_shutdown_tun(struct openconnect_info *vpninfo);
int os_read_tun(struct openconnect_info *vpninfo, struct pkt *pkt, int new_pkt);
int os_write_tun(struct openconnect_info *vpninfo, struct pkt *pkt);
int os_setup_tun(struct openconnect_info *vpninfo);

/* dtls.c */
unsigned char unhex(const char *data);
Expand Down
2 changes: 1 addition & 1 deletion tun-win32.c
Expand Up @@ -196,7 +196,7 @@ static int open_tun(struct openconnect_info *vpninfo, char *guid, char *name)
return 1;
}

int win32_setup_tun(struct openconnect_info *vpninfo)
int os_setup_tun(struct openconnect_info *vpninfo)
{
if (search_taps(vpninfo, open_tun) != 1)
return -1;
Expand Down
9 changes: 4 additions & 5 deletions tun.c
Expand Up @@ -143,6 +143,8 @@ static int link_proto(int unit_nr, const char *devname, uint64_t flags)
}
#endif

#ifndef _WIN32

#ifdef SIOCIFCREATE
static int bsd_open_tun(char *tun_name)
{
Expand Down Expand Up @@ -171,12 +173,10 @@ static int bsd_open_tun(char *tun_name)
#define bsd_open_tun(tun_name) open(tun_name, O_RDWR)
#endif

static int os_setup_tun(struct openconnect_info *vpninfo)
int os_setup_tun(struct openconnect_info *vpninfo)
{
int tun_fd = -1;
#ifdef _WIN32
tun_fd = win32_setup_tun(vpninfo);
#elif defined(IFF_TUN) /* Linux */
#ifdef IFF_TUN /* Linux */
struct ifreq ifr;
int tunerr;

Expand Down Expand Up @@ -322,7 +322,6 @@ static int os_setup_tun(struct openconnect_info *vpninfo)
return tun_fd;
}

#ifndef _WIN32
int openconnect_setup_tun_fd(struct openconnect_info *vpninfo, int tun_fd)
{
set_fd_cloexec(tun_fd);
Expand Down

0 comments on commit c3d166f

Please sign in to comment.