diff options
author | Niu,Bing <bing.niu@intel.com> | 2015-04-21 23:12:50 +0800 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2015-04-30 11:13:57 +0300 |
commit | 17a46a15a258aee663728bb8f22fcd999b6723e4 (patch) | |
tree | 46d96562aa43d4166a78c1ab643b2fe4457e97ad /gsupplicant | |
parent | 6cd60c1b90af4d1cbd81c985064e112dde115e0b (diff) | |
download | connman-17a46a15a258aee663728bb8f22fcd999b6723e4.tar.gz |
gsupplicant: Add interface_ap_create_fail to notify AP creation failure
Add new boolean ap_create_inprogress for GSupplicantInterface and set
this boolean to true when the wifi plugin tries to enable an AP. If
gsupplicant receives interface state information as disconnected while
ap_create_inprogress is true, this identifies there is an AP creation
failure. When that happens, gsupplicant will call the
interface_ap_create_fail callback letting the calling wifi plugin to
know about the failure.
This additional functionality is needed as the current functions may
all return success, but enabling the AP can still fail due to not being
a supported feature.
Diffstat (limited to 'gsupplicant')
-rw-r--r-- | gsupplicant/gsupplicant.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | gsupplicant/supplicant.c | 67 |
2 files changed, 64 insertions, 4 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 187dc654..2a87f2fd 100644 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -341,6 +341,7 @@ struct _GSupplicantCallbacks { void (*p2p_support) (GSupplicantInterface *interface); void (*scan_started) (GSupplicantInterface *interface); void (*scan_finished) (GSupplicantInterface *interface); + void (*ap_create_fail) (GSupplicantInterface *interface); void (*network_added) (GSupplicantNetwork *network); void (*network_removed) (GSupplicantNetwork *network); void (*network_changed) (GSupplicantNetwork *network, diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 3e3215c6..81fcadc6 100644..100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -163,6 +163,7 @@ struct _GSupplicantInterface { unsigned int max_scan_ssids; bool p2p_support; bool p2p_finding; + bool ap_create_in_progress; dbus_bool_t ready; GSupplicantState state; dbus_bool_t scanning; @@ -432,6 +433,17 @@ static void callback_scan_started(GSupplicantInterface *interface) callbacks_pointer->scan_started(interface); } +static void callback_ap_create_fail(GSupplicantInterface *interface) +{ + if (!callbacks_pointer) + return; + + if (!callbacks_pointer->scan_started) + return; + + callbacks_pointer->ap_create_fail(interface); +} + static void callback_scan_finished(GSupplicantInterface *interface) { if (!callbacks_pointer) @@ -790,20 +802,59 @@ static void interface_capability(const char *key, DBusMessageIter *iter, key, dbus_message_iter_get_arg_type(iter)); } +struct set_apscan_data +{ + unsigned int ap_scan; + GSupplicantInterface *interface; +}; + static void set_apscan(DBusMessageIter *iter, void *user_data) { - unsigned int ap_scan = *(unsigned int *)user_data; + struct set_apscan_data *data = user_data; + unsigned int ap_scan = data->ap_scan; dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &ap_scan); } +static void set_apscan_complete(const char *error, + DBusMessageIter *iter, void *user_data) +{ + struct set_apscan_data *data = user_data; + GSupplicantInterface *interface = data->interface; + + if (error) { + interface->ap_create_in_progress = false; + SUPPLICANT_DBG("Set AP scan error %s", error); + goto error; + } + + interface->ap_create_in_progress = true; +error: + dbus_free(data); +} + int g_supplicant_interface_set_apscan(GSupplicantInterface *interface, unsigned int ap_scan) { - return supplicant_dbus_property_set(interface->path, + struct set_apscan_data *data; + int ret; + + data = dbus_malloc0(sizeof(*data)); + + if (!data) + return -ENOMEM; + + data->ap_scan = ap_scan; + data->interface = interface; + + ret = supplicant_dbus_property_set(interface->path, SUPPLICANT_INTERFACE ".Interface", - "ApScan", DBUS_TYPE_UINT32_AS_STRING, - set_apscan, NULL, &ap_scan, NULL); + "ApScan", DBUS_TYPE_UINT32_AS_STRING, + set_apscan, set_apscan_complete, data, NULL); + if (ret < 0) + dbus_free(data); + + return ret; } void g_supplicant_interface_set_data(GSupplicantInterface *interface, @@ -1988,6 +2039,14 @@ static void interface_property(const char *key, DBusMessageIter *iter, interface->state = string2state(str); callback_interface_state(interface); } + + if (interface->ap_create_in_progress) { + if (interface->state == G_SUPPLICANT_STATE_DISCONNECTED) + callback_ap_create_fail(interface); + + interface->ap_create_in_progress = false; + } + if (interface->state == G_SUPPLICANT_STATE_DISABLED) interface->ready = FALSE; else |