Rename 'disable_gateway' and 'del_routes'
cover Rename 'disable_gateway' and 'del_routes'
This renames and documents 'disable_gateway' and 'del_routes'.
Grant Erickson (3):
connection: Rename 'disable_gateway'.
connection: Rename 'del_routes'.
connection: Document 'del_gateway_routes{,_if_active}'.
src/connection.c | 91 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 7 deletions(-)
Signature · 1 line
2.42.0
PATCH 1/3 connection: Rename 'disable_gateway'.
This renames 'disable_gateway' as 'del_gateway_routes_if_active'. The former is a bit of a misnomer since it is not possible to actually "disable" a gateway and its associated routes. The latter, revised name more accurately reflect its purpose and conditional action.
--- src/connection.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
src/connection.c +5 -5
@@ -621,7 +621,7 @@ static int del_routes(struct gateway_data *data,return (status4 <0 ? status4 : status6); } -static int disable_gateway (struct gateway_data *data, +static int del_gateway_routes_if_active (struct gateway_data *data,enum connman_ipconfig_type type) {bool active = false;
@@ -695,7 +695,7 @@ static int disable_gateway(struct gateway_data *data,* #gateway_config. * * @sa __connman_connection_gateway_add -* @sa disable_gateway +* @sa del_gateway_routes_if_active * */ static int add_gateway(struct connman_service *service,
@@ -753,7 +753,7 @@ static int add_gateway(struct connman_service *service,if (old) {DBG ("Replacing gw %p ipv4 %p ipv6 %p" , old, old->ipv4_config, old->ipv6_config); -disable_gateway (old, type); +del_gateway_routes_if_active (old, type);if (type ==CONNMAN_IPCONFIG_TYPE_IPV4 ) { temp_data->ipv6_config = old->ipv6_config; old->ipv6_config =NULL ;
@@ -1463,7 +1463,7 @@ void __connman_connection_gateway_remove(struct connman_service *service,/* Remove all active routes associated with this gateway data. */ - err =disable_gateway (data, type); + err =del_gateway_routes_if_active (data, type);/* * We remove the service from the service/gateway map only if ALL
@@ -1660,7 +1660,7 @@ void __connman_connection_cleanup(void)while (g_hash_table_iter_next (&iter, &key, &value)) {struct gateway_data *data = value; -disable_gateway (data,CONNMAN_IPCONFIG_TYPE_ALL ); +del_gateway_routes_if_active (data,CONNMAN_IPCONFIG_TYPE_ALL ); }g_hash_table_destroy (gateway_hash);
Signature · 1 line
2.42.0
PATCH 2/3 connection: Rename 'del_routes'.
In reply to Grant EricksonThis renames 'del_routes' as 'del_gateway_routes' to align with the revised name of its sole caller, 'del_gateway_routes_if_active'.
--- src/connection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/connection.c +2 -2
@@ -567,7 +567,7 @@ static void set_vpn_routes(struct gateway_data *new_gateway, } } -static int del_routes (struct gateway_data *data, +static int del_gateway_routes (struct gateway_data *data,enum connman_ipconfig_type type) {int status4 =0 , status6 =0 ;
@@ -640,7 +640,7 @@ static int del_gateway_routes_if_active(struct gateway_data *data,DBG ("type %d active %d" , type, active);if (active) -return del_routes (data, type); +return del_gateway_routes (data, type);return 0 ; }
Signature · 1 line
2.42.0
PATCH 3/3 connection: Document 'del_gateway_routes{,_if_active}'.
In reply to Grant EricksonThis adds documentation to the 'del_gateway_routes{,_if_active}' functions.
--- src/connection.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+)
src/connection.c +77 -0
@@ -567,6 +567,46 @@ static void set_vpn_routes(struct gateway_data *new_gateway, } } +/** +* @brief +* Delete all gateway, or default router, default or host routes +* for the gateway data. +* +* This attempts to delete, or remove, all gateway, or default +* router, default or host routes associated with the specified +* gateway data. +* +* @note +* Deletions or removals are restricted to the network * interface +* associated with the network interface index specified by * the +* @a data @a index field. +* +* @param[in] data A pointer to the mutable gateway data for which +* to delete or remove all gateway, or default +* router, default or host routes. +* @param[in] type The IP configuration type for which the gateway, +* or default router, default or host routes are to +* be deleted or removed. +* +* @retval 0 If successful. +* @retval -EPERM If the current process does not have the +* credentials or capabilities to delete routes. +* @retval -EINVAL If the routing information to be deleted was +* invalid. +* @retval -EFAULT If the address to the routing information to be +* deleted was invalid. +* @retval -ESRCH A request was made to delete a non-existing +* routing entry. +* +* @sa connman_inet_clear_gateway_address +* @sa connman_inet_clear_gateway_interface +* @sa connman_inet_clear_ipv6_gateway_address +* @sa connman_inet_clear_ipv6_gateway_interface +* @sa connman_inet_del_host_route +* @sa connman_inet_del_ipv6_host_route +* @sa del_gateway_routes_if_active +* +*/ static int del_gateway_routes (struct gateway_data *data,enum connman_ipconfig_type type) {
@@ -621,6 +661,43 @@ static int del_gateway_routes(struct gateway_data *data,return (status4 <0 ? status4 : status6); } +/** +* @brief +* Delete all gateway, or default router, default or host routes +* for the gateway data, if they are active. +* +* This attempts to delete, or remove, all gateway, or default +* router, default or host routes associated with the specified +* gateway data, if the corresponding gateway configuration for the +* specified type, @a type, is marked as active. +* +* @note +* Deletions or removals are restricted to the network interface +* associated with the network interface index specified by the +* @a data @a index field. +* +* @param[in] data A pointer to the mutable gateway data for which +* to delete or remove all gateway, or default +* router, default or host routes, if they are +* active. +* @param[in] type The IP configuration type for which the gateway, +* or default router, default or host routes are to +* be deleted or removed. +* +* @retval 0 If successful. +* @retval -EINVAL If data is null, if type is +* #CONNMAN_IPCONFIG_TYPE_UNKNOWN, if the routing +* information to be deleted was invalid. +* @retval -EPERM If the current process does not have the +* credentials or capabilities to delete routes. +* @retval -EFAULT If the address to the routing information to be +* deleted was invalid. +* @retval -ESRCH A request was made to delete a non-existing +* routing entry. +* +* @sa del_gateway_routes +* +*/ static int del_gateway_routes_if_active (struct gateway_data *data,enum connman_ipconfig_type type) {
Signature · 1 line
2.42.0