diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-18 19:35:13 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-18 19:35:13 +0200 |
commit | 5e47662205a982f2c487d392e6e6850824606b27 (patch) | |
tree | b79c81b3c6654736f09e3310a074eaeeda0a77fd | |
parent | fb591d64e8790572d7327a5b744b5190ddc86151 (diff) | |
download | neard-5e47662205a982f2c487d392e6e6850824606b27.tar.gz neard-5e47662205a982f2c487d392e6e6850824606b27.tar.bz2 neard-5e47662205a982f2c487d392e6e6850824606b27.zip |
ndef: Fallback to the WiFi agent when missing an SSID
When the D-Bus message does not contain an SSID (and optionalyy a
passphrase) then we fallback to the WiFi WSC agent. If it's running
in tethering mode then it will reply with an already built WSC TLV
array.
This is needed to push WiFi WSC configuration token over SNEP. Android
is going to support that as a simplified WiFi Handover.
-rw-r--r-- | src/ndef.c | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -3092,6 +3092,9 @@ static void get_wsc_data(DBusMessageIter iter, char **ssid, char **pass) { DBG(""); + *ssid = NULL; + *pass = NULL; + while (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INVALID) { const char *key; @@ -3214,9 +3217,38 @@ static struct near_ndef_message *build_mime_record(DBusMessage *msg) dbus_message_iter_get_basic(&var_iter, &mime_str); if (g_strcmp0(mime_str, WIFI_WSC_MIME_STRING) == 0) { + struct near_ndef_message *mime; + struct carrier_data *carrier; + get_wsc_data(arr_iter, &ssid, &passphrase); - return near_ndef_prepare_wsc_record(ssid, - passphrase); + if (ssid != NULL) + return near_ndef_prepare_wsc_record( + ssid, passphrase); + + /* + * If we did not get an SSID and optionally + * a passphrase from the DBus message, then + * we try to get one from the WiFi-WSC agent. + */ + carrier = __near_agent_handover_request_data( + HO_AGENT_WIFI, NULL); + if (carrier == NULL) + return NULL; + + mime = ndef_message_alloc_complete( + WIFI_WSC_MIME_STRING, carrier->size, + NULL, 0, RECORD_TNF_MIME, TRUE, TRUE); + if (mime == NULL) { + g_free(carrier); + return NULL; + } + + memcpy(mime->data + mime->offset, + carrier->data, carrier->size); + + g_free(carrier); + + return mime; } } |