Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add separate list-taps.exe "test"
This should help debug user reports of tailing to find tap devices,
like https://gitlab.com/openconnect/openconnect/issues/88

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Dec 17, 2019
1 parent 0be961a commit 051ec3b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/Makefile.am
Expand Up @@ -81,6 +81,9 @@ TESTS_ENVIRONMENT = srcdir="$(srcdir)" \

C_TESTS = lzstest seqtest

if OPENCONNECT_WIN32
C_TESTS += list-taps
endif

if CHECK_DTLS
C_TESTS += bad_dtls_test
Expand Down
46 changes: 46 additions & 0 deletions tests/list-taps.c
@@ -0,0 +1,46 @@
/*
* OpenConnect (SSL + DTLS) VPN client
*
* Copyright © 2019 David Woodhouse
*
* Author: David Woodhouse <dwmw2@infradead.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/

#include <config.h>

#include <stdint.h>
#include <stdio.h>

#define __OPENCONNECT_INTERNAL_H__

#define vpn_progress(v, d, ...) printf(__VA_ARGS__)
#define _(x) x

struct openconnect_info {
char *ifname;
};

#define __LIST_TAPS__

#include "../tun-win32.c"

static intptr_t print_tun(struct openconnect_info *vpninfo, char *guid, wchar_t *wname)
{
printf("Found tun device '%S'\n", wname);
return 0;
}

int main(void)
{
search_taps(NULL, print_tun, 1);
return 0;
}
4 changes: 4 additions & 0 deletions tun-win32.c
Expand Up @@ -160,6 +160,8 @@ static intptr_t search_taps(struct openconnect_info *vpninfo, tap_callback *cb,
return ret;
}

#ifndef __LIST_TAPS__

static int get_adapter_index(struct openconnect_info *vpninfo, char *guid)
{
struct oc_text_buf *buf = buf_alloc();
Expand Down Expand Up @@ -445,3 +447,5 @@ int openconnect_setup_tun_script(struct openconnect_info *vpninfo,
_("Spawning tunnel scripts is not yet supported on Windows\n"));
return -1;
}

#endif /* __LIST_TAPS__ */

0 comments on commit 051ec3b

Please sign in to comment.