Allow certain DHCP options to be used without DHCP server
PATCH 1/1 Allow certain DHCP options to be used without DHCP server
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN, ADAPTER_DOMAIN_SUFFIX, DNS, WINS
don't require DHCP server in order to be used.
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
--- src/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 13 ++++++++++++- 2 files changed, 35 insertions(+), 17 deletions(-)
src/openvpn/options.c +23 -16
@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_INT (dhcp_options);SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);
@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )
@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {
@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {
@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])
@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32
src/openvpn/tun.h +12 -1
@@ -62,6 +62,17 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* this is a bitmask */ +enum dhcp_options_type { +DHCP_OPTIONS_NONE =0 , + +/* option doesn't require DHCP server */ +DHCP_OPTIONS_DHCP_OPTIONAL =1 , + +/* option requires DHCP server */ +DHCP_OPTIONS_DHCP_REQUIRED =2 +}; +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;
@@ -90,7 +101,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +enum dhcp_options_type dhcp_options;const char *domain;/* DOMAIN (15) */
Signature · 1 line
2.23.0.windows.1
PATCH v2 1/1 Allow certain DHCP options to be used without DHCP server
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN, ADAPTER_DOMAIN_SUFFIX, DNS, WINS
don't require DHCP server in order to be used.
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
This fixes https://github.com/OpenVPN/openvpn/issues/239
---
v2: replace enum with defines, which are more suitable
as bit flags
src/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 6 +++++- 2 files changed, 28 insertions(+), 17 deletions(-)
src/openvpn/options.c +23 -16
@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_INT (dhcp_options);SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);
@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )
@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {
@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {
@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])
@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32
src/openvpn/tun.h +5 -1
@@ -62,6 +62,10 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* bit flags for DHCP options */ +#define DHCP_OPTIONS_DHCP_OPTIONAL (1<<0) +#define DHCP_OPTIONS_DHCP_REQUIRED (1<<1) +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;
@@ -90,7 +94,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +int dhcp_options;const char *domain;/* DOMAIN (15) */
Signature · 1 line
2.23.0.windows.1
Hi,
Quoted 30 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN,
ADAPTER_DOMAIN_SUFFIX, DNS, WINSdon't require DHCP server in order to be used.
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
This fixes https://github.com/OpenVPN/openvpn/issues/239
Reported-by Marek ZarychtaSigned-off-by Lev Stipakov <[email protected]...>---
v2: replace enum with defines, which are more suitable
as bit flagssrc/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 6 +++++- 2 files changed, 28 insertions(+), 17 deletions(-)src/openvpn/options.c +0
-0
src/openvpn/options.c show_tuntap_options(const struct tuntap_options *o) · line 1293
Quoted 5 lines
src/openvpn/options.c +1
-1@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_INT (dhcp_options);
wouldn't SHOW_UNSIGNED be more appropriate since this is a bitfield?
This is its definition:
options.c:987:#define SHOW_UNSIGNED(var) SHOW_PARM(var, o->var, "0x%08x")
Cheers,
Quoted 137 lines
src/openvpn/options.c +22
-15SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32src/openvpn/tun.h +5
-1@@ -62,6 +62,10 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* bit flags for DHCP options */ +#define DHCP_OPTIONS_DHCP_OPTIONAL (1<<0) +#define DHCP_OPTIONS_DHCP_REQUIRED (1<<1) +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;@@ -90,7 +94,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +int dhcp_options;const char *domain;/* DOMAIN (15) */
Signature · 1 line
Antonio Quartulli
This definition seems to be unused by the way :)
I am not sure if "0x00000003" is better than "3" (we have only two flags). Something like 00000011b would be clearer, but we don't have SHOW_BINARY.
ti 7. helmik. 2023 klo 15.36 Antonio Quartulli ([email protected]...) kirjoitti:
Quoted 188 lines
Hi,
Quoted 30 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN,
ADAPTER_DOMAIN_SUFFIX, DNS, WINSdon't require DHCP server in order to be used.
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
This fixes https://github.com/OpenVPN/openvpn/issues/239
Reported-by Marek ZarychtaSigned-off-by Lev Stipakov <[email protected]...>---
v2: replace enum with defines, which are more suitable
as bit flagssrc/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 6 +++++- 2 files changed, 28 insertions(+), 17 deletions(-)src/openvpn/options.c +0
-0src/openvpn/options.c show_tuntap_options(const struct tuntap_options *o) · line 1293
Quoted 5 lines
src/openvpn/options.c +1
-1@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_INT (dhcp_options);wouldn't
SHOW_UNSIGNEDbe more appropriate since this is a bitfield?This is its definition:
options.c:987:#define
SHOW_UNSIGNED(var)SHOW_PARM(var, o->var, "0x%08x")Cheers,
Quoted 129 lines
src/openvpn/options.c +22
-15SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32src/openvpn/tun.h +4
-0@@ -62,6 +62,10 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* bit flags for DHCP options */ +#define DHCP_OPTIONS_DHCP_OPTIONAL (1<<0) +#define DHCP_OPTIONS_DHCP_REQUIRED (1<<1) +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;src/openvpn/tun.h struct tuntap_options { · line 100
Quoted 8 lines
src/openvpn/tun.h +1
-1@@ -90,7 +94,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +int dhcp_options;const char *domain;/* DOMAIN (15) */ --
Antonio Quartulli
Signature · 1 line
-Lev
Hi,
Quoted 5 lines · Lev Stipakov
This definition seems to be unused by the way :)
I am not sure if "
0x00000003" is better than "3" (we have only two flags). Something like00000011bwould be clearer, but we don't haveSHOW_BINARY.
Personally I find the hex representation better when you want to print a bitfield.
The fact we are using hex kinda tells me already that it's not the value "3" that we care about.
And later is may become "10". Imho it just gets more confusing.
Cheers,
Quoted 193 lines
ti 7. helmik. 2023 klo 15.36 Antonio Quartulli ([email protected]...) kirjoitti:
Quoted 188 lines
Hi,
Quoted 30 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN,
ADAPTER_DOMAIN_SUFFIX, DNS, WINSdon't require DHCP server in order to be used.
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
This fixes https://github.com/OpenVPN/openvpn/issues/239
Reported-by Marek ZarychtaSigned-off-by Lev Stipakov <[email protected]...>---
v2: replace enum with defines, which are more suitable
as bit flagssrc/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 6 +++++- 2 files changed, 28 insertions(+), 17 deletions(-)src/openvpn/options.c +0
-0src/openvpn/options.c show_tuntap_options(const struct tuntap_options *o) · line 1293
Quoted 5 lines
src/openvpn/options.c +1
-1@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_INT (dhcp_options);wouldn't
SHOW_UNSIGNEDbe more appropriate since this is a bitfield?This is its definition:
options.c:987:#define
SHOW_UNSIGNED(var)SHOW_PARM(var, o->var, "0x%08x")Cheers,
Quoted 129 lines
src/openvpn/options.c +22
-15SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32src/openvpn/tun.h +4
-0@@ -62,6 +62,10 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* bit flags for DHCP options */ +#define DHCP_OPTIONS_DHCP_OPTIONAL (1<<0) +#define DHCP_OPTIONS_DHCP_REQUIRED (1<<1) +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;src/openvpn/tun.h struct tuntap_options { · line 100
Quoted 8 lines
src/openvpn/tun.h +1
-1@@ -90,7 +94,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +int dhcp_options;const char *domain;/* DOMAIN (15) */ --
Antonio Quartulli
Signature · 1 line
Antonio Quartulli
PATCH v3 1/1 Allow certain DHCP options to be used without DHCP server
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN, ADAPTER_DOMAIN_SUFFIX, DNS, WINS
don't require DHCP server in order to be used.
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
---
v3: replace SHOW_INT with SHOW_UNSIGNED
v2: replace enum with defines, which are more suitable
as bit flags
src/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 6 +++++- 2 files changed, 28 insertions(+), 17 deletions(-)
src/openvpn/options.c +23 -16
@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_UNSIGNED (dhcp_options);SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);
@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )
@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {
@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {
@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])
@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32
src/openvpn/tun.h +5 -1
@@ -62,6 +62,10 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* bit flags for DHCP options */ +#define DHCP_OPTIONS_DHCP_OPTIONAL (1<<0) +#define DHCP_OPTIONS_DHCP_REQUIRED (1<<1) +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;
@@ -90,7 +94,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +int dhcp_options;const char *domain;/* DOMAIN (15) */
Signature · 1 line
2.23.0.windows.1
Hi,
Quoted 8 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Followin DHCP options:
DOMAIN,
ADAPTER_DOMAIN_SUFFIX, DNS, WINSdon't require DHCP server in order to be used.
Quoted 7 lines
This change allows those options to be used with dco and wintun drivers. If an option specified which requires DHCP server and tap-windows6 driver is not used, print a clear error message instead of obscure reference to --ip-win32.
Reported-by Marek ZarychtaSigned-off-by Lev Stipakov <[email protected]...>
Code makes sense and does what it says.
However, please not that I did not test this code path explicitly as my testing capabilities on Windows are pretty limited.
Cheers,
Quoted 156 lines
---
v3: replaceSHOW_INTwithSHOW_UNSIGNED
v2: replace enum with defines, which are more suitable
as bit flagssrc/openvpn/options.c | 39 +++++++++++++++++++++++---------------- src/openvpn/tun.h | 6 +++++- 2 files changed, 28 insertions(+), 17 deletions(-)src/openvpn/options.c +23
-16@@ -1290,7 +1290,7 @@ show_tuntap_options(const struct tuntap_options *o)SHOW_INT (dhcp_masq_offset);SHOW_INT (dhcp_lease_time);SHOW_INT (tap_sleep); -SHOW_BOOL (dhcp_options); +SHOW_UNSIGNED (dhcp_options);SHOW_BOOL (dhcp_renew);SHOW_BOOL (dhcp_pre_release);SHOW_STR (domain);@@ -2478,12 +2478,20 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"On Windows, --ip-win32 doesn't make sense unless --ifconfig is also used" ); } -if (options->tuntap_options.dhcp_options - && options->windows_driver !=WINDOWS_DRIVER_WINTUN - && options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ - && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) +if (options->tuntap_options.dhcp_options &DHCP_OPTIONS_DHCP_REQUIRED ) { -msg (M_USAGE ,"--dhcp-option requires --ip-win32 dynamic or adaptive" ); +const char *prefix ="Some dhcp-options require DHCP server" ; +if (options->windows_driver !=WINDOWS_DRIVER_TAP_WINDOWS6 ) + { +msg (M_USAGE ,"%s, which is not supported by selected %s driver" , + prefix,print_windows_driver (options->windows_driver)); + } +else if (options->tuntap_options.ip_win32_type !=IPW32_SET_DHCP_MASQ + && options->tuntap_options.ip_win32_type !=IPW32_SET_ADAPTIVE ) + { +msg (M_USAGE ,"%s, which requires --ip-win32 dynamic or adaptive" , + prefix); + } }if (options->windows_driver ==WINDOWS_DRIVER_WINTUN && dev !=DEV_TYPE_TUN )@@ -8083,16 +8091,17 @@ add_option(struct options *options, {struct tuntap_options *o = &options->tuntap_options;VERIFY_PERMISSION (OPT_P_DHCPDNS ); -bool ipv6dns = false;if ((streq (p[1 ],"DOMAIN" ) ||streq (p[1 ],"ADAPTER_DOMAIN_SUFFIX" )) && p[2 ] && !p[3 ]) { o->domain = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NBS" ) && p[2 ] && !p[3 ]) { o->netbios_scope = p[2 ]; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBT" ) && p[2 ] && !p[3 ]) {@@ -8104,31 +8113,35 @@ add_option(struct options *options, goto err; } o->netbios_node_type = t; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if ((streq (p[1 ],"DNS" ) ||streq (p[1 ],"DNS6" )) && p[2 ] && !p[3 ] && (!strstr (p[2 ],":" ) ||ipv6_addr_safe (p[2 ]))) {if (strstr (p[2 ],":" )) { - ipv6dns = true;dhcp_option_dns6_parse (p[2 ], o->dns6, &o->dns6_len, msglevel); }else {dhcp_option_address_parse ("DNS" , p[2 ], o->dns, &o->dns_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; } }else if (streq (p[1 ],"WINS" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("WINS" , p[2 ], o->wins, &o->wins_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_OPTIONAL ; }else if (streq (p[1 ],"NTP" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NTP" , p[2 ], o->ntp, &o->ntp_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"NBDD" ) && p[2 ] && !p[3 ]) {dhcp_option_address_parse ("NBDD" , p[2 ], o->nbdd, &o->nbdd_len, msglevel); + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DOMAIN-SEARCH" ) && p[2 ] && !p[3 ]) {@@ -8141,10 +8154,12 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option %s: maximum of %d search entries can be specified" , p[1 ],N_SEARCH_LIST_LEN ); } + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; }else if (streq (p[1 ],"DISABLE-NBT" ) && !p[2 ]) { o->disable_nbt =1 ; + o->dhcp_options |=DHCP_OPTIONS_DHCP_REQUIRED ; } #if defined(TARGET_ANDROID) else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4])@@ -8158,14 +8173,6 @@ add_option(struct options *options,msg (msglevel,"--dhcp-option: unknown option type '%s' or missing or unknown parameter" , p[1 ]); goto err; } - -/* flag that we have options to give to the TAP driver's DHCPv4 server -* - skipped for "DNS6", as that's not a DHCPv4 option -*/ -if (!ipv6dns) - { - o->dhcp_options = true; - } }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ #ifdef _WIN32src/openvpn/tun.h +5
-1@@ -62,6 +62,10 @@ enum windows_driver_type {#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 +/* bit flags for DHCP options */ +#define DHCP_OPTIONS_DHCP_OPTIONAL (1<<0) +#define DHCP_OPTIONS_DHCP_REQUIRED (1<<1) +struct tuntap_options {/* --ip-win32 options */ bool ip_win32_defined;@@ -90,7 +94,7 @@ struct tuntap_options {/* --dhcp-option options */ -bool dhcp_options; +int dhcp_options;const char *domain;/* DOMAIN (15) */
Signature · 1 line
Antonio Quartulli
Code looks good, and compiles on MinGW. Didn't actually test the various combinations.
Your patch has been applied to the master and release/2.6 branch.
commit 469158f93ea52a6c2f821890ef599299183aa020 (master) commit 442fde78a1f1f512762a4b2c4db958a3d56410d1 (release/2.6)
Author: Lev Stipakov Date: Tue Feb 7 16:54:16 2023 +0200
Allow certain DHCP options to be used without DHCP server
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg26169.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering