From: Antonio Quartulli Date: Mon, 11 Jul 2022 12:23:48 +0000 (+0200) Subject: options: don't export local function pre_connect_save() X-Git-Tag: v2.6_beta1~170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad085464b15d63324846d0a5151141f58ccb5a34;p=thirdparty%2Fopenvpn.git options: don't export local function pre_connect_save() The pre_connect_save() function is not used outside of options.c, therefore it should not be exported. Make it static and move definition before its invocation. Move also pre_connect_restore() along with it in order to keep the two close to each other. Cc: Arne Schwabe Signed-off-by: Antonio Quartulli Acked-by: Heiko Hund Message-Id: <20220711122348.8756-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24666.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 233c02e04..ade62d3f5 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3204,6 +3204,125 @@ remap_redirect_gateway_flags(struct options *opt) } #endif +/* + * Save/Restore certain option defaults before --pull is applied. + */ + +static void +pre_connect_save(struct options *o) +{ + ALLOC_OBJ_CLEAR_GC(o->pre_connect, struct options_pre_connect, &o->gc); + o->pre_connect->tuntap_options = o->tuntap_options; + o->pre_connect->tuntap_options_defined = true; + o->pre_connect->foreign_option_index = o->foreign_option_index; + + if (o->routes) + { + o->pre_connect->routes = clone_route_option_list(o->routes, &o->gc); + o->pre_connect->routes_defined = true; + } + if (o->routes_ipv6) + { + o->pre_connect->routes_ipv6 = clone_route_ipv6_option_list(o->routes_ipv6, &o->gc); + o->pre_connect->routes_ipv6_defined = true; + } + if (o->client_nat) + { + o->pre_connect->client_nat = clone_client_nat_option_list(o->client_nat, &o->gc); + o->pre_connect->client_nat_defined = true; + } + + o->pre_connect->route_default_gateway = o->route_default_gateway; + o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway; + + o->pre_connect->dns_options = clone_dns_options(o->dns_options, &o->gc); + + /* NCP related options that can be overwritten by a push */ + o->pre_connect->ciphername = o->ciphername; + o->pre_connect->authname = o->authname; + + /* Ping related options should be reset to the config values on reconnect */ + o->pre_connect->ping_rec_timeout = o->ping_rec_timeout; + o->pre_connect->ping_rec_timeout_action = o->ping_rec_timeout_action; + o->pre_connect->ping_send_timeout = o->ping_send_timeout; + + /* Miscellaneous Options */ +#ifdef USE_COMP + o->pre_connect->comp = o->comp; +#endif +} + +void +pre_connect_restore(struct options *o, struct gc_arena *gc) +{ + const struct options_pre_connect *pp = o->pre_connect; + if (pp) + { + CLEAR(o->tuntap_options); + if (pp->tuntap_options_defined) + { + o->tuntap_options = pp->tuntap_options; + } + + if (pp->routes_defined) + { + rol_check_alloc(o); + copy_route_option_list(o->routes, pp->routes, gc); + } + else + { + o->routes = NULL; + } + + if (pp->routes_ipv6_defined) + { + rol6_check_alloc(o); + copy_route_ipv6_option_list(o->routes_ipv6, pp->routes_ipv6, gc); + } + else + { + o->routes_ipv6 = NULL; + } + + o->route_default_gateway = pp->route_default_gateway; + o->route_ipv6_default_gateway = pp->route_ipv6_default_gateway; + + /* Free DNS options and reset them to pre-pull state */ + gc_free(&o->dns_options.gc); + struct gc_arena dns_gc = gc_new(); + o->dns_options = clone_dns_options(pp->dns_options, &dns_gc); + o->dns_options.gc = dns_gc; + + if (pp->client_nat_defined) + { + cnol_check_alloc(o); + copy_client_nat_option_list(o->client_nat, pp->client_nat); + } + else + { + o->client_nat = NULL; + } + + o->foreign_option_index = pp->foreign_option_index; + + o->ciphername = pp->ciphername; + o->authname = pp->authname; + + o->ping_rec_timeout = pp->ping_rec_timeout; + o->ping_rec_timeout_action = pp->ping_rec_timeout_action; + o->ping_send_timeout = pp->ping_send_timeout; + + /* Miscellaneous Options */ +#ifdef USE_COMP + o->comp = pp->comp; +#endif + } + + o->push_continuation = 0; + o->push_option_types_found = 0; + o->data_channel_crypto_flags = 0; +} + static void options_postprocess_mutate_invariant(struct options *options) { @@ -3909,125 +4028,6 @@ options_postprocess_pull(struct options *o, struct env_set *es) return success; } -/* - * Save/Restore certain option defaults before --pull is applied. - */ - -void -pre_connect_save(struct options *o) -{ - ALLOC_OBJ_CLEAR_GC(o->pre_connect, struct options_pre_connect, &o->gc); - o->pre_connect->tuntap_options = o->tuntap_options; - o->pre_connect->tuntap_options_defined = true; - o->pre_connect->foreign_option_index = o->foreign_option_index; - - if (o->routes) - { - o->pre_connect->routes = clone_route_option_list(o->routes, &o->gc); - o->pre_connect->routes_defined = true; - } - if (o->routes_ipv6) - { - o->pre_connect->routes_ipv6 = clone_route_ipv6_option_list(o->routes_ipv6, &o->gc); - o->pre_connect->routes_ipv6_defined = true; - } - if (o->client_nat) - { - o->pre_connect->client_nat = clone_client_nat_option_list(o->client_nat, &o->gc); - o->pre_connect->client_nat_defined = true; - } - - o->pre_connect->route_default_gateway = o->route_default_gateway; - o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway; - - o->pre_connect->dns_options = clone_dns_options(o->dns_options, &o->gc); - - /* NCP related options that can be overwritten by a push */ - o->pre_connect->ciphername = o->ciphername; - o->pre_connect->authname = o->authname; - - /* Ping related options should be reset to the config values on reconnect */ - o->pre_connect->ping_rec_timeout = o->ping_rec_timeout; - o->pre_connect->ping_rec_timeout_action = o->ping_rec_timeout_action; - o->pre_connect->ping_send_timeout = o->ping_send_timeout; - - /* Miscellaneous Options */ -#ifdef USE_COMP - o->pre_connect->comp = o->comp; -#endif -} - -void -pre_connect_restore(struct options *o, struct gc_arena *gc) -{ - const struct options_pre_connect *pp = o->pre_connect; - if (pp) - { - CLEAR(o->tuntap_options); - if (pp->tuntap_options_defined) - { - o->tuntap_options = pp->tuntap_options; - } - - if (pp->routes_defined) - { - rol_check_alloc(o); - copy_route_option_list(o->routes, pp->routes, gc); - } - else - { - o->routes = NULL; - } - - if (pp->routes_ipv6_defined) - { - rol6_check_alloc(o); - copy_route_ipv6_option_list(o->routes_ipv6, pp->routes_ipv6, gc); - } - else - { - o->routes_ipv6 = NULL; - } - - o->route_default_gateway = pp->route_default_gateway; - o->route_ipv6_default_gateway = pp->route_ipv6_default_gateway; - - /* Free DNS options and reset them to pre-pull state */ - gc_free(&o->dns_options.gc); - struct gc_arena dns_gc = gc_new(); - o->dns_options = clone_dns_options(pp->dns_options, &dns_gc); - o->dns_options.gc = dns_gc; - - if (pp->client_nat_defined) - { - cnol_check_alloc(o); - copy_client_nat_option_list(o->client_nat, pp->client_nat); - } - else - { - o->client_nat = NULL; - } - - o->foreign_option_index = pp->foreign_option_index; - - o->ciphername = pp->ciphername; - o->authname = pp->authname; - - o->ping_rec_timeout = pp->ping_rec_timeout; - o->ping_rec_timeout_action = pp->ping_rec_timeout_action; - o->ping_send_timeout = pp->ping_send_timeout; - - /* Miscellaneous Options */ -#ifdef USE_COMP - o->comp = pp->comp; -#endif - } - - o->push_continuation = 0; - o->push_option_types_found = 0; - o->data_channel_crypto_flags = 0; -} - /* * Build an options string to represent data channel encryption options. * This string must match exactly between peers. The keysize is checked diff --git a/src/openvpn/options.h b/src/openvpn/options.h index f7e3f2659..d6eb278bb 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -817,8 +817,6 @@ void options_postprocess(struct options *options, struct env_set *es); bool options_postprocess_pull(struct options *o, struct env_set *es); -void pre_connect_save(struct options *o); - void pre_connect_restore(struct options *o, struct gc_arena *gc); bool apply_push_options(struct options *options,