#include "wifi-background-scan.h"
#include "wifi-tdls.h"
#include "ip-conflict-detect.h"
+#include "wifi-key-encryption.h"
#if defined TIZEN_DEBUG_ENABLE
#include "network-dump.h"
#define NETWORK_LOG_DUMP_SCRIPT "/opt/var/lib/net-config/network_log_dump.sh"
netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
}
+static void _find_service_and_set_passphrase(char *ssid, char *key)
+{
+ GString *str;
+ GVariant *reply = NULL;
+ int i, j, ssid_len;
+ char *service_path;
+ char *dev_mac_addr;
+ char ident[13];
+ gchar *enc_passphrase;
+
+ ssid_len = strlen(ssid);
+
+ str = g_string_sized_new((ssid_len * 2) + 55);
+ if (!str)
+ return;
+
+ dev_mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+ if (!dev_mac_addr) {
+ ERR("Failed to get mac address from vconf key");
+ g_string_free(str, TRUE);
+ return;
+ }
+
+ j = 0;
+ for (i = 0; dev_mac_addr[i]; i++) {
+ if (dev_mac_addr[i] != ':')
+ ident[j++] = dev_mac_addr[i];
+ }
+ ident[j] = '\0';
+
+ g_string_append_printf(str, "%s%s_", CONNMAN_WIFI_SERVICE_PROFILE_PREFIX,
+ ident);
+ free(dev_mac_addr);
+
+ for (i = 0; i < ssid_len; i++) {
+ if (ssid[i] != '"')
+ g_string_append_printf(str, "%02x", ssid[i]);
+ }
+
+ g_string_append_printf(str, "_managed_psk");
+
+ service_path = g_string_free(str, FALSE);
+
+ enc_passphrase = _netconfig_encrypt_passphrase(key);
+ if (!enc_passphrase) {
+ ERR("Failed to encrypt passphrase");
+ g_free(service_path);
+ return;
+ }
+
+ INFO("wps service_path %s Passphrase %s", service_path, enc_passphrase);
+
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, service_path,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty",
+ g_variant_new("(sv)", "Passphrase",
+ g_variant_new_string(enc_passphrase)));
+ if (reply != NULL)
+ g_variant_unref(reply);
+ else
+ ERR("Failed to set passphrase");
+
+ g_free(service_path);
+
+ return;
+}
+
static void _supplicant_wifi_wps_credentials(GVariant *param)
{
gchar *key;
int config_error = 0;
int error_indication = 0;
gsize ssid_len = 0;
+ char *key_mgmt = NULL;
if (param == NULL) {
ERR("Param is NULL");
INFO("wps password len %d ", key_len);
if (key_len > 0) {
- t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar));
+ t_key = g_variant_get_fixed_array(variant, &key_len,
+ sizeof(guchar));
if (!t_key) {
g_free(key);
g_variant_unref(variant);
SLOGI("WPS AP Security ->Open");
} else if (g_strcmp0(key, "SSID") == 0) {
const char *t_key = NULL;
- t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
+ t_key = g_variant_get_fixed_array(variant, &ssid_len,
+ sizeof(guchar));
INFO("wps ssid_len is %d ", ssid_len);
if (!t_key) {
g_free(key);
ssid_len = 0;
}
INFO("SSID in process credentials %s", ssid);
+ } else if (g_strcmp0(key, "AuthType") == 0) {
+ gchar *auth_type;
+ GVariantIter *var_iter;
+ g_variant_get(variant, "as", &var_iter);
+ while (g_variant_iter_loop(var_iter, "s", &auth_type)) {
+ INFO("wps auth_type %s", auth_type);
+ if (g_strcmp0(auth_type, "wpa-psk") == 0 ||
+ g_strcmp0(auth_type, "wpa2-psk") == 0)
+ key_mgmt = "psk";
+ else if (g_strcmp0(auth_type, "open") == 0)
+ key_mgmt = "none";
+ }
+ g_variant_iter_free(var_iter);
+ } else if (g_strcmp0(key, "EncrType") == 0) {
+ gchar *encr_type;
+ GVariantIter *var_iter;
+ g_variant_get(variant, "as", &var_iter);
+ while (g_variant_iter_loop(var_iter, "s", &encr_type))
+ INFO("wps encr_type %s", encr_type);
+ g_variant_iter_free(var_iter);
+ } else if (g_strcmp0(key, "BSSID") == 0) {
+ const guchar *bssid;
+ gsize bssid_len;
+ bssid = g_variant_get_fixed_array(variant, &bssid_len,
+ sizeof(guchar));
+ if (bssid && bssid_len == 6)
+ INFO("wps BSSID %2x:%2x:%2x:%2x:%2x:%2x", bssid[0], bssid[1],
+ bssid[2], bssid[3], bssid[4], bssid[5]);
}
}
g_variant_iter_free(iter);
+ if (g_strcmp0(key_mgmt, "psk") == 0)
+ _find_service_and_set_passphrase(ssid, wps_key);
+
#if 0
/*
* Notify WPS Credentials only when requested through WPS PBC