Add a callback parameter to '__connman_wispr_start'.
PATCH 1/1 Add a callback parameter to '__connman_wispr_start'.
The addition of this callback provides two benefits.
The first is making static the implementation of the WISPr closure function defined in service.c.
The second is that it will make easier closing several failure path "holes" that currently do not properly "bookend" requests to '__connman_wispr_start' by making the closure of those holes independent of the function providing the closure.
--- src/connman.h | 10 ++++++---- src/service.c | 9 ++++++--- src/wispr.c | 16 +++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-)
src/connman.h +6 -4
@@ -523,10 +523,15 @@ void __connman_wpad_cleanup(void);int __connman_wpad_start (struct connman_service *service);void __connman_wpad_stop (struct connman_service *service); +typedef void (*__connman_wispr_cb_t ) (struct connman_service *service, +enum connman_ipconfig_type type, +bool success); +int __connman_wispr_init (void );void __connman_wispr_cleanup (void );int __connman_wispr_start (struct connman_service *service, -enum connman_ipconfig_type type); +enum connman_ipconfig_type type, +__connman_wispr_cb_t callback);void __connman_wispr_stop (struct connman_service *service);#include <connman/technology.h>
@@ -734,9 +739,6 @@ int __connman_service_set_mdns(struct connman_service *service,void __connman_service_set_string (struct connman_service *service,const char *key,const char *value); -void __connman_service_online_check (struct connman_service *service, -enum connman_ipconfig_type type, -bool success);int __connman_service_ipconfig_indicate_state (struct connman_service *service,enum connman_service_state new_state,enum connman_ipconfig_type type);
src/service.c +6 -3
@@ -157,6 +157,9 @@ static struct connman_ipconfig *create_ip6config(struct connman_service *servicestatic void dns_changed (struct connman_service *service);static void vpn_auto_connect (void );static void trigger_autoconnect (struct connman_service *service); +static void complete_online_check (struct connman_service *service, +enum connman_ipconfig_type type, +bool success);struct find_data {const char *path;
@@ -3621,7 +3624,7 @@ void __connman_service_wispr_start(struct connman_service *service, service->online_check_interval_ipv6 = online_check_initial_interval; -__connman_wispr_start (service, type); +__connman_wispr_start (service, type, complete_online_check); } static DBusMessage *set_property(DBusConnection *conn,
@@ -6347,7 +6350,7 @@ static void redo_wispr(struct connman_service *service,__connman_ipconfig_type2string (type), service, service->name); -__connman_wispr_start (service, type); +__connman_wispr_start (service, type, complete_online_check);connman_service_unref (service); }
@@ -6373,7 +6376,7 @@ static gboolean redo_wispr_ipv6(gpointer user_data)return FALSE; } -void __connman_service_online_check (struct connman_service *service, +static void complete_online_check (struct connman_service *service,enum connman_ipconfig_type type,bool success) {
src/wispr.c +9 -7
@@ -59,6 +59,7 @@ struct connman_wispr_portal_context {int refcount;struct connman_service *service;enum connman_ipconfig_type type; +__connman_wispr_cb_t cb;struct connman_wispr_portal *wispr_portal;/* Portal/WISPr common */
@@ -483,7 +484,7 @@ static void portal_manage_status(GWebResult *result, CONNMAN_SERVICE_STATE_ONLINE, type);if (enable_online_to_ready_transition) -__connman_service_online_check (service, type, true); + wp_context->cb (service, type, true); } static bool wispr_route_request(const char *address, int ai_family,
@@ -821,8 +822,7 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) goto done;case 400 :case 404 : -__connman_service_online_check (wp_context->service, - wp_context->type, false); + wp_context->cb (wp_context->service, wp_context->type, false);break ;case 505 :
@@ -989,16 +989,17 @@ done: }int __connman_wispr_start (struct connman_service *service, -enum connman_ipconfig_type type) +enum connman_ipconfig_type type, +__connman_wispr_cb_t callback) {struct connman_wispr_portal_context *wp_context =NULL ;struct connman_wispr_portal *wispr_portal =NULL ;int index, err; -DBG ("service %p %s" , service, -__connman_ipconfig_type2string (type)); +DBG ("service %p %s callback %p" , service, +__connman_ipconfig_type2string (type), callback); -if (!wispr_portal_hash) +if (!wispr_portal_hash || !callback)return -EINVAL ;switch (connman_service_get_type (service)) {
@@ -1048,6 +1049,7 @@ int __connman_wispr_start(struct connman_service *service, wp_context->service = service; wp_context->type = type; + wp_context->cb = callback; wp_context->wispr_portal = wispr_portal;if (type ==CONNMAN_IPCONFIG_TYPE_IPV4 )
Signature · 1 line
2.32.0
PATCH v2 1/1 Add a callback parameter to '__connman_wispr_start'.
This callback provides two benefits.
The first is making static the implementation of the WISPr closure function defined in src/service.c.
The second is that it will make easier closing several failure path "holes" that currently do not properly "bookend" requests to '__connman_wispr_start' by making the closure of those holes independent of the function providing the closure.
--- src/connman.h | 10 ++++++---- src/service.c | 9 ++++++--- src/wispr.c | 16 +++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-)
src/connman.h +6 -4
@@ -523,10 +523,15 @@ void __connman_wpad_cleanup(void);int __connman_wpad_start (struct connman_service *service);void __connman_wpad_stop (struct connman_service *service); +typedef void (*__connman_wispr_cb_t ) (struct connman_service *service, +enum connman_ipconfig_type type, +bool success); +int __connman_wispr_init (void );void __connman_wispr_cleanup (void );int __connman_wispr_start (struct connman_service *service, -enum connman_ipconfig_type type); +enum connman_ipconfig_type type, +__connman_wispr_cb_t callback);void __connman_wispr_stop (struct connman_service *service);#include <connman/technology.h>
@@ -734,9 +739,6 @@ int __connman_service_set_mdns(struct connman_service *service,void __connman_service_set_string (struct connman_service *service,const char *key,const char *value); -void __connman_service_online_check (struct connman_service *service, -enum connman_ipconfig_type type, -bool success);int __connman_service_ipconfig_indicate_state (struct connman_service *service,enum connman_service_state new_state,enum connman_ipconfig_type type);
src/service.c +6 -3
@@ -157,6 +157,9 @@ static struct connman_ipconfig *create_ip6config(struct connman_service *servicestatic void dns_changed (struct connman_service *service);static void vpn_auto_connect (void );static void trigger_autoconnect (struct connman_service *service); +static void complete_online_check (struct connman_service *service, +enum connman_ipconfig_type type, +bool success);struct find_data {const char *path;
@@ -3640,7 +3643,7 @@ void __connman_service_wispr_start(struct connman_service *service, service->online_check_interval_ipv6 = online_check_initial_interval; -__connman_wispr_start (service, type); +__connman_wispr_start (service, type, complete_online_check); } static DBusMessage *set_property(DBusConnection *conn,
@@ -6370,7 +6373,7 @@ static void redo_wispr(struct connman_service *service,__connman_ipconfig_type2string (type), service, service->name); -__connman_wispr_start (service, type); +__connman_wispr_start (service, type, complete_online_check);connman_service_unref (service); }
@@ -6396,7 +6399,7 @@ static gboolean redo_wispr_ipv6(gpointer user_data)return FALSE; } -void __connman_service_online_check (struct connman_service *service, +static void complete_online_check (struct connman_service *service,enum connman_ipconfig_type type,bool success) {
src/wispr.c +9 -7
@@ -59,6 +59,7 @@ struct connman_wispr_portal_context {int refcount;struct connman_service *service;enum connman_ipconfig_type type; +__connman_wispr_cb_t cb;struct connman_wispr_portal *wispr_portal;/* Portal/WISPr common */
@@ -483,7 +484,7 @@ static void portal_manage_status(GWebResult *result, CONNMAN_SERVICE_STATE_ONLINE, type);if (enable_online_to_ready_transition) -__connman_service_online_check (service, type, true); + wp_context->cb (service, type, true); } static bool wispr_route_request(const char *address, int ai_family,
@@ -821,8 +822,7 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) goto done;case 400 :case 404 : -__connman_service_online_check (wp_context->service, - wp_context->type, false); + wp_context->cb (wp_context->service, wp_context->type, false);break ;case 505 :
@@ -992,17 +992,18 @@ done: }int __connman_wispr_start (struct connman_service *service, -enum connman_ipconfig_type type) +enum connman_ipconfig_type type, +__connman_wispr_cb_t callback) {struct connman_wispr_portal_context *wp_context =NULL ;struct connman_wispr_portal *wispr_portal =NULL ;int index, err; -DBG ("service %p (%s) type %d (%s)" , +DBG ("service %p (%s) type %d (%s) callback %p" , service,connman_service_get_identifier (service), - type,__connman_ipconfig_type2string (type)); + type,__connman_ipconfig_type2string (type), callback); -if (!wispr_portal_hash) +if (!wispr_portal_hash || !callback)return -EINVAL ;switch (connman_service_get_type (service)) {
@@ -1052,6 +1053,7 @@ int __connman_wispr_start(struct connman_service *service, wp_context->service = service; wp_context->type = type; + wp_context->cb = callback; wp_context->wispr_portal = wispr_portal;if (type ==CONNMAN_IPCONFIG_TYPE_IPV4 )
Signature · 1 line
2.42.0
Hi Grant,
Quoted 10 lines
This callback provides two benefits.
The first is making static the implementation of the WISPr closure function defined in
src/service.c.The second is that it will make easier closing several failure path "holes" that currently do not properly "bookend" requests to '
__connman_wispr_start' by making the closure of those holes independent of the function providing the closure.
---
Quoted 4 lines
src/connman.h | 10 ++++++---- src/service.c | 9 ++++++--- src/wispr.c | 16 +++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-)
patch has been applied.
Regards
Marcel