diff options
author | Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com> | 2013-04-04 17:02:35 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-04-05 16:17:47 +0200 |
commit | 04f18f7c59b5731b79a9b400bc49dd0351354081 (patch) | |
tree | 0221a5becbf9ffc0715fc1119d5d85e859cd8f6d | |
parent | 23c24f7f00a2f55b9aaaaab59a4bcb7729b86a7b (diff) | |
download | neard-04f18f7c59b5731b79a9b400bc49dd0351354081.tar.gz neard-04f18f7c59b5731b79a9b400bc49dd0351354081.tar.bz2 neard-04f18f7c59b5731b79a9b400bc49dd0351354081.zip |
ndef: Add api to prepare mime type wsc record
Added api to prepare MIME type WSC record for unit tests.
-rw-r--r-- | include/ndef.h | 3 | ||||
-rw-r--r-- | src/ndef.c | 28 |
2 files changed, 18 insertions, 13 deletions
diff --git a/include/ndef.h b/include/ndef.h index cd1a678..14fd581 100644 --- a/include/ndef.h +++ b/include/ndef.h @@ -68,4 +68,7 @@ near_bool_t near_ndef_record_cmp_mime(struct near_ndef_record *rec1, size_t near_ndef_data_length(struct near_ndef_record *data); uint8_t *near_ndef_data_ptr(struct near_ndef_record *data); +struct near_ndef_message *near_ndef_prepare_wsc_record(char *ssid, + char *passphrase); + #endif @@ -3116,28 +3116,26 @@ static void get_wsc_data(DBusMessageIter iter, char **ssid, char **pass) } } -static struct near_ndef_message *build_mime_wifi_wsc(DBusMessageIter iter) +struct near_ndef_message *near_ndef_prepare_wsc_record(char *ssid, + char *passphrase) { - char *ssid = NULL, *pass = NULL; uint16_t ssid_len, pass_len, key_type; uint8_t temp_key[2]; uint8_t *tlv; uint32_t tlv_len, offset; struct near_ndef_message *mime; - get_wsc_data(iter, &ssid, &pass); - /* At least SSID is required in case of open network */ if (ssid == NULL) return NULL; - DBG("SSID %s Passphrase %s", ssid, pass); + DBG("SSID %s Passphrase %s", ssid, passphrase); /* Prepare TLV from ssid and passphrasse */ ssid_len = strlen(ssid); - if (pass != NULL) { - pass_len = strlen(pass); + if (passphrase != NULL) { + pass_len = strlen(passphrase); key_type = WIFI_WSC_KEY_PSK; } else { pass_len = 0; @@ -3149,7 +3147,7 @@ static struct near_ndef_message *build_mime_wifi_wsc(DBusMessageIter iter) /* add authentication type length */ tlv_len += WIFI_WSC_ID_LENGTH + WIFI_WSC_ID_DATA_LENGTH + 2; /* add network key length */ - if (pass != NULL) + if (passphrase != NULL) tlv_len += WIFI_WSC_ID_LENGTH + WIFI_WSC_ID_DATA_LENGTH + pass_len; @@ -3173,9 +3171,10 @@ static struct near_ndef_message *build_mime_wifi_wsc(DBusMessageIter iter) (uint8_t *) temp_key); /* copy Network Key */ - if (pass != NULL) + if (passphrase != NULL) offset += fill_wifi_wsc_data(tlv + offset, WIFI_WSC_ID_KEY, - pass_len, (uint8_t *) pass); + pass_len, + (uint8_t *) passphrase); mime = ndef_message_alloc_complete(WIFI_WSC_MIME_STRING, tlv_len, NULL, 0, RECORD_TNF_MIME, TRUE, TRUE); @@ -3193,7 +3192,7 @@ static struct near_ndef_message *build_mime_wifi_wsc(DBusMessageIter iter) static struct near_ndef_message *build_mime_record(DBusMessage *msg) { DBusMessageIter iter, arr_iter; - char *key, *mime_str; + char *key, *mime_str, *ssid, *passphrase; DBG(""); @@ -3213,8 +3212,11 @@ static struct near_ndef_message *build_mime_record(DBusMessage *msg) dbus_message_iter_recurse(&ent_iter, &var_iter); dbus_message_iter_get_basic(&var_iter, &mime_str); - if (g_strcmp0(mime_str, WIFI_WSC_MIME_STRING) == 0) - return build_mime_wifi_wsc(arr_iter); + if (g_strcmp0(mime_str, WIFI_WSC_MIME_STRING) == 0) { + get_wsc_data(arr_iter, &ssid, &passphrase); + return near_ndef_prepare_wsc_record(ssid, + passphrase); + } } |