tun.c: refactor driver detection and make it case-insensitive
PATCH 1/1 tun.c: refactor driver detection and make it case-insensitive
Hardware IDs are case insensitive on Windows.
Furthermore the driver detection logic has been made more explicit and easier to read.
Signed-off-by Simon Rozman <[email protected]...>
--- src/openvpn/tun.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
src/openvpn/tun.c +11 -3
@@ -3692,11 +3692,19 @@ get_tap_reg(struct gc_arena *gc)if (status ==ERROR_SUCCESS && data_type ==REG_SZ ) { +/* Is this adapter supported? */ enum windows_driver_type windows_driver =WINDOWS_DRIVER_UNSPECIFIED ; +if (strcasecmp (component_id,TAP_WIN_COMPONENT_ID ) ==0 || +strcasecmp (component_id,"root\\" TAP_WIN_COMPONENT_ID ) ==0 ) + { + windows_driver =WINDOWS_DRIVER_TAP_WINDOWS6 ; + } +else if (strcasecmp (component_id,WINTUN_COMPONENT_ID ) ==0 ) + { + windows_driver =WINDOWS_DRIVER_WINTUN ; + } -if ((windows_driver =WINDOWS_DRIVER_TAP_WINDOWS6 , !strcmp (component_id,TAP_WIN_COMPONENT_ID )) - || (windows_driver =WINDOWS_DRIVER_TAP_WINDOWS6 , !strcmp (component_id,"root\\" TAP_WIN_COMPONENT_ID )) - || (windows_driver =WINDOWS_DRIVER_WINTUN , !strcmp (component_id,WINTUN_COMPONENT_ID ))) +if (windows_driver !=WINDOWS_DRIVER_UNSPECIFIED ) {struct tap_reg *reg; ALLOC_OBJ_CLEAR_GC(reg, struct tap_reg, gc);
Signature · 1 line
2.24.1.windows.2
Your patch has been applied to the master branch.
And, indeed, thanks for that :-) - I do remember complaining about the old code - technically correct but very hard to read. The new code is much easier to read (and should do the same, except for the case insensitivity).
Test compiled on Ubuntu 16.04 / MinGW.
commit 0b8714f627b2d740be7f8ff6f42cd276030e6d67
Author: Simon Rozman Date: Wed Feb 5 18:55:56 2020 +0100
tun.c: refactor driver detection and make it case-insensitive
Signed-off-by: Simon Rozman <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg19365.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering