return str;
}
-static int __config_save(const char *ssid, GKeyFile *keyfile)
+static int __config_save(const char *mac_addr, GKeyFile *keyfile)
{
gchar *data = NULL;
gchar *config_file = NULL;
FILE *file = NULL;
int err = 0;
- config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR, ssid);
+ config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR, mac_addr);
if (config_file == NULL) {
err = -ENOMEM;
goto out;
return err;
}
-static int __config_delete(const char *ssid)
+static int __config_delete(const char *mac_addr, const char *ssid)
{
int err = 0;
gchar *group_name = NULL;
GKeyFile *keyfile = NULL;
GError *error = NULL;
- config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR, ssid);
+ config_file = g_strdup_printf("%s/%s.config", CONNMAN_STORAGEDIR, mac_addr);
if (config_file == NULL)
return -ENOMEM;
ERR("Failed to remove %s", cert_path);
g_free(cert_path);
- dirname = g_strdup_printf("%s/%s", WIFI_CERT_STORAGEDIR, ssid);
+ dirname = g_strdup_printf("%s/%s_%s", WIFI_CERT_STORAGEDIR, mac_addr, ssid);
if (dirname != NULL) {
if (g_file_test(dirname, G_FILE_TEST_EXISTS) == TRUE)
if (g_file_test(dirname, G_FILE_TEST_IS_DIR) == TRUE)
return result;
}
-static gboolean __netconfig_create_config(GVariant *fields)
+static gboolean __netconfig_create_config(const char *profile, GVariant *fields)
{
GKeyFile *keyfile = NULL;
GVariantIter *iter;
gboolean updated = FALSE;
gchar *cert_file = NULL;
gchar *cert_path = NULL;
+ char mac_str[13] = { 0, };
int err = 0;
g_variant_get(fields, "a{ss}", &iter);
goto out;
}
+ memcpy(mac_str, &profile[strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX)], 12);
+ mac_str[12] = '\0';
+
/* Create unique service group name */
group_name = g_strdup_printf("service_%s", encoded_ssid);
if (group_name == NULL) {
cert_file++;
- dirname = g_strdup_printf("%s/%s",
- WIFI_CERT_STORAGEDIR, encoded_ssid);
+ dirname = g_strdup_printf("%s/%s_%s", WIFI_CERT_STORAGEDIR,
+ mac_str, encoded_ssid);
if (dirname == NULL) {
ERR("Failed to create dirname");
g_free(field);
}
g_free(dirname);
- cert_path = g_strdup_printf("%s/%s/%s",
- WIFI_CERT_STORAGEDIR, encoded_ssid, cert_file);
+ cert_path = g_strdup_printf("%s/%s_%s/%s", WIFI_CERT_STORAGEDIR,
+ mac_str, encoded_ssid, cert_file);
if (cert_path == NULL) {
ERR("Failed to create cert path");
g_free(field);
}
}
- err = __config_save((const char *)encoded_ssid, keyfile);
+ err = __config_save(mac_str, keyfile);
if (err < 0)
- ERR("Failed to create configuration %s[%d]", encoded_ssid, err);
+ ERR("Failed to create configuration %s[%d]", mac_str, err);
else {
- DBG("Successfully created %s", encoded_ssid);
+ DBG("Successfully created %s", mac_str);
updated = TRUE;
}
int ssid_len = 0;
int err = 0;
const char *interface_name = NULL;
+ char mac_str[13] = { 0, };
if (NULL == profile) {
ERR("Invalid profile name");
}
g_strlcpy(ssid, essid, ssid_len + 1); /* include NULL-terminated */
- err = __config_delete((const char *)ssid);
+
+ memcpy(mac_str, &profile[strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX)], 12);
+ mac_str[12] = '\0';
+
+ err = __config_delete(mac_str, ssid);
if (err < 0) {
ERR("Failed to delete configuration %s[%d]", ssid, err);
g_free(ssid);
return TRUE;
}
- updated = __netconfig_create_config(fields);
+ updated = __netconfig_create_config(service, fields);
if (updated == TRUE) {
wifi_complete_create_eap_config(wifi, context);