diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2022-06-16 00:47:39 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2022-06-17 11:08:46 -0500 |
commit | 3dbe68f4251dbdcab8abe3746001590abc939d27 (patch) | |
tree | d64a3bedd463e63a76d1e18ed626c8d417a16f35 | |
parent | d6842d892e15d76ed31be9b5fa5b90fec072e4c5 (diff) |
netconfig: Add l_netconfig_reset_config
-rw-r--r-- | ell/ell.sym | 1 | ||||
-rw-r--r-- | ell/netconfig.c | 20 | ||||
-rw-r--r-- | ell/netconfig.h | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/ell/ell.sym b/ell/ell.sym index 50f89097..38422e7d 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -748,6 +748,7 @@ global: l_netconfig_set_dns_override; l_netconfig_set_domain_names_override; l_netconfig_check_config; + l_netconfig_reset_config; l_netconfig_start; l_netconfig_stop; l_netconfig_get_dhcp_client; diff --git a/ell/netconfig.c b/ell/netconfig.c index c9a22f6b..b4e9802c 100644 --- a/ell/netconfig.c +++ b/ell/netconfig.c @@ -1292,6 +1292,26 @@ LIB_EXPORT bool l_netconfig_check_config(struct l_netconfig *netconfig) return netconfig_check_config(netconfig); } +LIB_EXPORT bool l_netconfig_reset_config(struct l_netconfig *netconfig) +{ + if (unlikely(!netconfig || netconfig->started)) + return false; + + l_netconfig_set_hostname(netconfig, NULL); + l_netconfig_set_route_priority(netconfig, 0); + l_netconfig_set_family_enabled(netconfig, AF_INET, true); + l_netconfig_set_static_addr(netconfig, AF_INET, NULL); + l_netconfig_set_gateway_override(netconfig, AF_INET, NULL); + l_netconfig_set_dns_override(netconfig, AF_INET, NULL); + l_netconfig_set_domain_names_override(netconfig, AF_INET, NULL); + l_netconfig_set_family_enabled(netconfig, AF_INET6, false); + l_netconfig_set_static_addr(netconfig, AF_INET6, NULL); + l_netconfig_set_gateway_override(netconfig, AF_INET6, NULL); + l_netconfig_set_dns_override(netconfig, AF_INET6, NULL); + l_netconfig_set_domain_names_override(netconfig, AF_INET6, NULL); + return true; +} + static void netconfig_add_v4_static_address_routes(struct l_netconfig *nc) { char ip[INET_ADDRSTRLEN]; diff --git a/ell/netconfig.h b/ell/netconfig.h index 69100a23..d845c55d 100644 --- a/ell/netconfig.h +++ b/ell/netconfig.h @@ -69,6 +69,7 @@ bool l_netconfig_set_dns_override(struct l_netconfig *netconfig, uint8_t family, bool l_netconfig_set_domain_names_override(struct l_netconfig *netconfig, uint8_t family, char **names); bool l_netconfig_check_config(struct l_netconfig *netconfig); +bool l_netconfig_reset_config(struct l_netconfig *netconfig); bool l_netconfig_start(struct l_netconfig *netconfig); void l_netconfig_stop(struct l_netconfig *netconfig); |