2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <netinet/in.h>
30 #include <arpa/inet.h>
38 #include "wifi-config.h"
39 #include "wifi-state.h"
40 #include "netsupplicant.h"
41 #include "wifi-key-encryption.h"
43 #define CONNMAN_STORAGE "/var/lib/connman"
45 #define WIFI_SECURITY_NONE "none"
46 #define WIFI_SECURITY_WEP "wep"
47 #define WIFI_SECURITY_WPA_PSK "psk"
48 #define WIFI_SECURITY_EAP "ieee8021x"
49 #define WIFI_SECURITY_SAE "sae"
51 #define WIFI_CONFIG_PREFIX "wifi_"
52 #define MAC_ADDRESS_LENGTH 12
53 #define WIFI_PREFIX_LENGTH MAC_ADDRESS_LENGTH + 6 /* wifi_485a3f2f506a_ */
54 #define PROFILE_PREFIX_LENGTH WIFI_PREFIX_LENGTH + 21 /* /net/connman/service/wifi_485a3f2f506a_ */
56 #define NET_DNS_ADDR_MAX 2
58 #define MAX_WIFI_PROFILES 200
60 struct wifi_eap_config {
61 gchar *anonymous_identity;
65 gchar *private_key_password;
75 gchar *gateway_address;
76 gchar *dns_address[NET_DNS_ADDR_MAX];
93 struct wifi_eap_config *eap_config;
94 wifi_ip_info_s *ip_info;
99 static void __free_wifi_configuration(struct wifi_config *conf)
106 g_free(conf->passphrase);
107 g_free(conf->security_type);
108 g_free(conf->is_hidden);
109 g_free(conf->proxy_address);
110 g_free(conf->last_error);
111 if (conf->eap_config) {
112 g_free(conf->eap_config->anonymous_identity);
113 g_free(conf->eap_config->ca_cert);
114 g_free(conf->eap_config->client_cert);
115 g_free(conf->eap_config->private_key);
116 g_free(conf->eap_config->private_key_password);
117 g_free(conf->eap_config->identity);
118 g_free(conf->eap_config->eap_type);
119 g_free(conf->eap_config->eap_auth_type);
120 g_free(conf->eap_config->subject_match);
121 g_free(conf->eap_config);
125 g_free(conf->ip_info->ip_type);
126 g_free(conf->ip_info->ip_address);
127 g_free(conf->ip_info->subnet_mask);
128 g_free(conf->ip_info->gateway_address);
129 g_free(conf->ip_info->dns_type);
130 conf->ip_info->prefix_length = 0;
132 int i = 0, count = conf->ip_info->dns_count;
134 g_free(conf->ip_info->dns_address[i]);
137 g_free(conf->ip_info);
142 static gboolean __get_mac_address(const gchar *interface_name, gchar **mac_address)
145 char buf[WIFI_MAC_ADDR_LENGTH + 1];
146 char path[WIFI_MAC_PATH_LENGTH];
147 gchar *tmp_mac = NULL;
149 gchar mac[13] = { 0, };
152 snprintf(path, WIFI_MAC_PATH_LENGTH, WIFI_MAC_ADDR_PATH, interface_name);
154 if (0 == access(path, F_OK))
155 fp = fopen(path, "r");
158 if (fgets(buf, sizeof(buf), fp) == NULL) {
159 ERR("Failed to get MAC info from %s\n", path);
164 tmp_mac = (gchar *)malloc(WIFI_MAC_ADDR_LENGTH + 1);
165 if (tmp_mac == NULL) {
166 ERR("malloc() failed");
171 memset(tmp_mac, 0, WIFI_MAC_ADDR_LENGTH + 1);
172 g_strlcpy(tmp_mac, buf, WIFI_MAC_ADDR_LENGTH + 1);
175 ERR("Failed to open file %s\n", path);
177 tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
178 if (tmp_mac == NULL) {
179 ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
185 tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac));
187 while (tmp && tmp[i]) {
193 *mac_address = g_strdup(mac);
199 gboolean wifi_config_get_group_name(const gchar *prefix,
200 const gchar *interface_name, const gchar *config_id, gchar **group_name)
202 gchar *mac_address = NULL;
203 gchar *g_name = NULL;
204 gboolean ret = FALSE;
206 ret = __get_mac_address(interface_name, &mac_address);
207 if ((ret != TRUE) || (strlen(mac_address) == 0)) {
208 ERR("Cannot get WIFI MAC address");
213 g_name = g_strdup_printf("%s%s_%s", prefix, mac_address, config_id);
214 if (g_name == NULL) {
219 *group_name = g_strdup(g_name);
227 static gboolean __get_security_type(const gchar *config_id, gchar **type)
229 if (g_str_has_suffix(config_id, WIFI_SECURITY_NONE) == TRUE) {
230 *type = g_strdup(WIFI_SECURITY_NONE);
231 } else if (g_str_has_suffix(config_id, WIFI_SECURITY_WEP) == TRUE) {
232 *type = g_strdup(WIFI_SECURITY_WEP);
233 } else if (g_str_has_suffix(config_id, WIFI_SECURITY_WPA_PSK) == TRUE) {
234 *type = g_strdup(WIFI_SECURITY_WPA_PSK);
235 } else if (g_str_has_suffix(config_id, WIFI_SECURITY_EAP) == TRUE) {
236 *type = g_strdup(WIFI_SECURITY_EAP);
237 } else if (g_str_has_suffix(config_id, WIFI_SECURITY_SAE) == TRUE) {
238 *type = g_strdup(WIFI_SECURITY_SAE);
247 static gboolean __get_config_id(const gchar *profile, gchar **config_id)
249 *config_id = g_strdup(profile + PROFILE_PREFIX_LENGTH);
250 if (*config_id == NULL) {
259 static GKeyFile *__get_configuration_keyfile(const gchar *group_name)
261 GKeyFile *keyfile = NULL;
264 path = g_strdup_printf(CONNMAN_STORAGE "/%s/settings", group_name);
266 keyfile = netconfig_keyfile_load(path);
268 ERR("keyfile[%s] is NULL", path);
275 static gboolean __remove_file(const gchar *pathname, const gchar *filename)
277 gboolean ret = FALSE;
280 path = g_strdup_printf("%s/%s", pathname, filename);
281 if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) {
283 } else if (g_file_test(path, G_FILE_TEST_IS_REGULAR) == TRUE) {
292 static gboolean __remove_all_files(const gchar *pathname)
295 struct dirent *file = NULL;
297 if ((dir_ptr = opendir(pathname)) == NULL)
300 while ((file = readdir(dir_ptr)) != NULL) {
301 if (strncmp(file->d_name, ".", 1) == 0 || strncmp(file->d_name, "..", 2) == 0)
304 if (__remove_file(pathname, file->d_name) != TRUE) {
305 ERR("Cannot remove [%s/%s]", pathname, file->d_name);
317 static gboolean __remove_configuration(const gchar *pathname)
321 if (__remove_all_files(pathname) != TRUE) {
322 ERR("Cannot remove [%s] directory", pathname);
326 ret = rmdir(pathname);
328 ERR("Cannot remove [%s]", pathname);
334 static gboolean _load_configuration(const gchar *interface_name,
335 const gchar *config_id, struct wifi_config *config)
339 gboolean hidden = FALSE;
340 gboolean ret = FALSE;
342 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
343 interface_name, config_id, &group_name);
345 ERR("Fail to get_wifi_config_group_name");
349 keyfile = __get_configuration_keyfile(group_name);
350 if (keyfile == NULL) {
351 ERR("Fail to __get_configuration_keyfile[%s]", group_name);
356 config->name = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_NAME, NULL);
357 DBG("name [%s]", config->name);
359 if (config->name == NULL) {
360 ERR("Fail to get Name of [%s]", group_name);
361 g_key_file_free(keyfile);
366 __get_security_type(config_id, &config->security_type);
367 if (config->security_type == NULL) {
368 ERR("Fail to _get_security_type");
369 g_key_file_free(keyfile);
373 DBG("security_type [%s]", config->security_type);
375 config->passphrase = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, NULL);
376 DBG("passphrase []");
378 config->proxy_address = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, NULL);
379 if (config->proxy_address)
380 DBG("proxy_address [%s]", config->proxy_address);
382 hidden = g_key_file_get_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, NULL);
384 config->is_hidden = g_strdup("TRUE");
386 config->is_hidden = g_strdup("FALSE");
387 DBG("is_hidden [%s]", config->is_hidden);
389 config->frequency = g_key_file_get_integer(keyfile, group_name, WIFI_CONFIG_FREQUENCY, NULL);
390 if (config->frequency)
391 DBG("Frequency [%d]", config->frequency);
393 if (config->ip_info) {
394 config->ip_info->ip_type = g_key_file_get_string(keyfile, group_name,
395 WIFI_CONFIG_IPV4_METHOD, NULL);
396 if (config->ip_info->ip_type)
397 DBG("IPv4.Method:%s", config->ip_info->ip_type);
399 config->ip_info->ip_address = g_key_file_get_string(keyfile, group_name,
400 WIFI_CONFIG_IPV4_ADDRESS, NULL);
401 if (config->ip_info->ip_address)
402 DBG("IPv4.Address:%s", config->ip_info->ip_address);
406 struct in_addr netmask;
408 GError *error = NULL;
409 prefix_len = g_key_file_get_integer(keyfile, group_name,
410 WIFI_CONFIG_IPV4_SUBNET_MASK, &error);
412 DBG("g_key_file_get_integer failed error[%d: %s]", error->code, error->message);
415 if (prefix_len > 0 && prefix_len < 32) {
416 addr = 0xffffffff << (32 - prefix_len);
417 netmask.s_addr = htonl(addr);
418 mask = inet_ntoa(netmask);
419 config->ip_info->subnet_mask = g_strdup(mask);
421 if (config->ip_info->subnet_mask)
422 DBG("IPv4.SubnetMask:%s", config->ip_info->subnet_mask);
425 config->ip_info->gateway_address = g_key_file_get_string(keyfile,
426 group_name, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, NULL);
427 if (config->ip_info->gateway_address)
428 DBG("IPv4.gateway:%s", config->ip_info->gateway_address);
430 config->ip_info->dns_type = g_key_file_get_string(keyfile, group_name,
431 WIFI_CONFIG_IPV4_DNS_METHOD, NULL);
432 if (config->ip_info->dns_type)
433 DBG("DNS.IPv4Method:%s", config->ip_info->dns_type);
437 nameservers = g_key_file_get_string_list(keyfile, group_name,
438 WIFI_CONFIG_DNS_ADDRESS, &length, NULL);
441 config->ip_info->dns_count = length;
443 while (i < NET_DNS_ADDR_MAX && nameservers[i]) {
444 config->ip_info->dns_address[i] = g_strdup(nameservers[i]);
445 DBG("DNSAddress[%d]:%s", i+1, config->ip_info->dns_address[i]);
449 g_strfreev(nameservers);
454 if (g_strcmp0(config->security_type, WIFI_SECURITY_EAP) == 0) {
455 config->eap_config->anonymous_identity = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, NULL);
456 config->eap_config->ca_cert = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_CACERT, NULL);
457 config->eap_config->client_cert = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_CLIENTCERT, NULL);
458 config->eap_config->private_key = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_PRIVATEKEY, NULL);
459 config->eap_config->private_key_password = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD, NULL);
460 config->eap_config->identity = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_IDENTITY, NULL);
461 config->eap_config->eap_type = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_TYPE, NULL);
462 config->eap_config->eap_auth_type = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_AUTH_TYPE, NULL);
463 config->eap_config->subject_match = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_SUBJECT_MATCH, NULL);
465 if (config->eap_config->anonymous_identity)
466 DBG("anonymous_identity [%s]", config->eap_config->anonymous_identity);
467 if (config->eap_config->ca_cert)
468 DBG("ca_cert [%s]", config->eap_config->ca_cert);
469 if (config->eap_config->client_cert)
470 DBG("client_cert [%s]", config->eap_config->client_cert);
471 if (config->eap_config->private_key)
472 DBG("private_key [%s]", config->eap_config->private_key);
473 if (config->eap_config->private_key_password)
474 DBG("private_key_password [%s]", config->eap_config->private_key_password);
475 if (config->eap_config->identity)
476 DBG("identity [%s]", config->eap_config->identity);
477 if (config->eap_config->eap_type)
478 DBG("eap_type [%s]", config->eap_config->eap_type);
479 if (config->eap_config->eap_auth_type)
480 DBG("eap_auth_type [%s]", config->eap_config->eap_auth_type);
481 if (config->eap_config->subject_match)
482 DBG("subject_match [%s]", config->eap_config->subject_match);
485 config->last_error = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_FAILURE, NULL);
486 if (config->last_error)
487 DBG("last_error [%s]", config->last_error);
489 g_key_file_free(keyfile);
495 gboolean wifi_config_save_configuration(const gchar *interface_name,
496 const gchar *config_id, GKeyFile *keyfile)
501 gboolean ret = FALSE;
503 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
504 interface_name, config_id, &group_name);
506 ERR("Fail to get_wifi_config_group_name");
510 dir = g_strdup_printf(CONNMAN_STORAGE "/%s", group_name);
511 if (g_file_test(dir, G_FILE_TEST_IS_DIR) == TRUE) {
512 if (__remove_configuration(dir) != TRUE) {
513 ERR("[%s] is existed, but cannot remove", dir);
520 if (mkdir(dir, (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) < 0) {
521 ERR("Cannot mkdir %s", dir);
527 path = g_strdup_printf(CONNMAN_STORAGE "/%s/settings", group_name);
528 netconfig_keyfile_save(keyfile, path);
536 static gboolean _remove_configuration(const gchar *interface_name, const gchar *config_id)
538 gboolean ret = FALSE;
542 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
543 interface_name, config_id, &group_name);
545 ERR("Fail to get_wifi_config_group_name");
549 dir = g_strdup_printf(CONNMAN_STORAGE "/%s", group_name);
550 if (g_file_test(dir, G_FILE_TEST_IS_DIR) == TRUE) {
551 if (__remove_configuration(dir) != TRUE) {
552 ERR("[%s] is existed, but cannot remove", dir);
555 INFO("Success to remove [%s]", dir);
559 ERR("[%s] is not existed", dir);
570 static gboolean _set_field(const gchar *interface_name,
571 const gchar *config_id, const gchar *key, const gchar *value)
577 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
578 interface_name, config_id, &group_name);
580 ERR("Fail to get_wifi_config_group_name");
583 DBG("group_name %s", group_name);
585 keyfile = __get_configuration_keyfile(group_name);
586 if (keyfile == NULL) {
587 ERR("Fail to __get_configuration_keyfile");
592 if (g_strcmp0(key, WIFI_CONFIG_PROXY_METHOD) == 0) {
593 g_key_file_set_string(keyfile, group_name, key, value);
594 } else if (g_strcmp0(key, WIFI_CONFIG_PROXY_SERVER) == 0) {
595 g_key_file_set_string(keyfile, group_name, key, value);
596 } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
597 gboolean hidden = FALSE;
598 if (g_strcmp0(value, "TRUE") == 0)
600 g_key_file_set_boolean(keyfile, group_name, key, hidden);
601 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
602 g_key_file_set_string(keyfile, group_name, key, value);
603 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CACERT) == 0) {
604 g_key_file_set_string(keyfile, group_name, key, value);
605 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
606 g_key_file_set_string(keyfile, group_name, key, value);
607 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
608 g_key_file_set_string(keyfile, group_name, key, value);
609 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_IDENTITY) == 0) {
610 g_key_file_set_string(keyfile, group_name, key, value);
611 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_TYPE) == 0) {
612 g_key_file_set_string(keyfile, group_name, key, value);
613 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
614 g_key_file_set_string(keyfile, group_name, key, value);
615 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
616 g_key_file_set_string(keyfile, group_name, key, value);
618 ERR("key[%s] is not supported", key);
622 wifi_config_save_configuration(interface_name, config_id, keyfile);
624 g_key_file_free(keyfile);
630 static gboolean _get_field(const gchar *interface_name,
631 const gchar *config_id, const gchar *key, gchar **value)
636 gboolean hidden = FALSE;
637 gboolean ret = FALSE;
639 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
640 interface_name, config_id, &group_name);
642 ERR("Fail to get_wifi_config_group_name");
645 DBG("group_name %s", group_name);
647 keyfile = __get_configuration_keyfile(group_name);
648 if (keyfile == NULL) {
649 ERR("Fail to __get_configuration_keyfile");
654 if (g_strcmp0(key, WIFI_CONFIG_NAME) == 0) {
655 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_NAME, NULL);
656 } else if (g_strcmp0(key, WIFI_CONFIG_PASSPHRASE) == 0) {
657 gchar *enc_pass = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, NULL);
659 val = _netconfig_decrypt_passphrase(enc_pass);
663 ERR("Failed to decrypt the passphrase");
665 } else if (g_strcmp0(key, WIFI_CONFIG_PROXY_SERVER) == 0) {
666 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, NULL);
667 } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
668 hidden = g_key_file_get_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, NULL);
670 val = g_strdup("TRUE");
672 val = g_strdup("FALSE");
673 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
674 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, NULL);
675 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CACERT) == 0) {
676 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_CACERT, NULL);
677 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
678 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_CLIENTCERT, NULL);
679 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
680 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_PRIVATEKEY, NULL);
681 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_IDENTITY) == 0) {
682 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_IDENTITY, NULL);
683 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_TYPE) == 0) {
684 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_TYPE, NULL);
685 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
686 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_AUTH_TYPE, NULL);
687 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
688 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_SUBJECT_MATCH, NULL);
689 } else if (g_strcmp0(key, WIFI_CONFIG_FAILURE) == 0) {
690 val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_FAILURE, NULL);
692 ERR("Invalid key[%s]", key);
693 val = g_strdup("NOTSUPPORTED");
696 *value = g_strdup(val);
699 g_key_file_free(keyfile);
705 static GSList *_get_list(const char *mac_addr)
708 struct dirent *dp = NULL;
711 dir = opendir(CONNMAN_STORAGE);
713 ERR("Cannot open dir %s", CONNMAN_STORAGE);
717 while ((dp = readdir(dir)) != NULL) {
718 if (g_strcmp0(dp->d_name, ".") == 0 || g_strcmp0(dp->d_name, "..") == 0 ||
719 strncmp(dp->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
723 DBG("%s", dp->d_name);
725 if (netconfig_check_mac_address(dp->d_name, mac_addr)) {
726 gchar *config_id = g_strdup(dp->d_name + WIFI_PREFIX_LENGTH);
727 DBG("%s", config_id);
728 list = g_slist_append(list, g_strdup(config_id));
737 gboolean wifi_config_get_config_id(const gchar *service_profile, gchar **config_id)
739 gboolean ret = FALSE;
742 if ((service_profile == NULL) || (config_id == NULL)) {
743 ERR("Invalid parameter");
747 ret = __get_config_id(service_profile, &val);
748 *config_id = g_strdup(val);
754 gboolean wifi_config_remove_configuration(const gchar *interface_name,
755 const gchar *config_id)
757 gboolean ret = FALSE;
759 ret = _remove_configuration(interface_name, config_id);
764 int __netconfig_hex_char_to_num(char c)
766 if (c >= '0' && c <= '9')
769 if (c >= 'a' && c <= 'f')
772 if (c >= 'A' && c <= 'F')
778 int __netconfig_hex_to_byte(const char *hex)
782 a = __netconfig_hex_char_to_num(*hex++);
786 b = __netconfig_hex_char_to_num(*hex++);
793 int __netconfig_hex_str_to_bin(const char *hex, unsigned char *buf, size_t len)
797 const char *ipos = hex;
798 unsigned char *opos = buf;
800 for (i = 0; i < len; i++) {
801 a = __netconfig_hex_to_byte(ipos);
812 static int __netconfig_byte_to_txt(const unsigned char *src, char **dst, int src_len)
819 ERR("Invalid parameter.");
823 *dst = (char *) g_try_malloc0((2*src_len)+1);
825 ERR("failed to allocate memory to buffer.");
831 for (i = 0; i < src_len; i++) {
832 snprintf(buf, 3, "%02x", src[i]);
840 static int __netconfig_unpack_ay_malloc(unsigned char **dst, GVariantIter *iter)
842 GVariantIter *iter_copy = NULL;
845 unsigned char *tmp_dst = NULL;
847 if (!dst || *dst || !iter) {
848 ERR("Invalid parameter");
852 iter_copy = g_variant_iter_copy(iter);
854 while (g_variant_iter_loop(iter, "y", &tmp))
856 g_variant_iter_free(iter);
858 tmp_dst = (unsigned char *)g_try_malloc0(length + 1);
860 ERR("failed to allocate memory");
861 g_variant_iter_free(iter_copy);
866 while (g_variant_iter_loop(iter_copy, "y", &tmp_dst[length]))
868 g_variant_iter_free(iter_copy);
874 tmp_dst[length] = '\0';
878 DBG("Length [%d]", length);
882 gboolean _add_vsie(const char *interface_name, int frame_id, const char* vsie)
884 GVariant *params = NULL;
885 GVariant *message = NULL;
886 GVariantBuilder *bytearray_builder = NULL;
891 unsigned char *bytearray = NULL;
892 size_t bytearray_len = 0;
894 if (frame_id >= NETCONFIG_VSIE_FRAME_MAX) {
895 DBG("Invalid parameter, frame-id: %d", frame_id);
899 vsie_len = strlen(vsie);
901 DBG("vsie length is zero");
905 bytearray_len = (vsie_len % 2) ? ((vsie_len / 2) + 1) : (vsie_len / 2);
907 bytearray = (unsigned char *) g_try_malloc0(bytearray_len);
908 if (bytearray == NULL) {
909 DBG("Failed to allocate memory to bytearray");
913 if (__netconfig_hex_str_to_bin(vsie, bytearray, bytearray_len) < 0) {
914 DBG("invalid vsie string");
919 bytearray_builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
920 for (i = 0; i < bytearray_len; i++)
921 g_variant_builder_add(bytearray_builder, "y", bytearray[i]);
923 params = g_variant_new("(iay)", frame_id, bytearray_builder);
924 g_variant_builder_unref(bytearray_builder);
926 if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
927 if (if_path == NULL) {
928 ERR("Fail to get wpa_supplicant DBus path");
933 message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
934 if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemAdd", params);
937 if (message == NULL) {
938 ERR("Failed to send command to wpa_supplicant");
943 DBG("Succeeded to add vsie: Frame ID[%d], VSIE[%s]", frame_id, vsie);
949 gboolean _get_vsie(const char *interface_name, int frame_id, char **vsie)
951 GVariant *params = NULL;
952 GVariant *message = NULL;
955 if (frame_id >= NETCONFIG_VSIE_FRAME_MAX) {
956 DBG("Invalid parameter, frame-id: %d", frame_id);
960 if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
961 if (if_path == NULL) {
962 ERR("Fail to get wpa_supplicant DBus path");
966 params = g_variant_new("(i)", frame_id);
968 message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
969 if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemGet", params);
972 if (message == NULL) {
973 ERR("Failed to send command to wpa_supplicant");
976 GVariantIter *iter = NULL;
977 unsigned char *vsie_bytes = NULL;
981 g_variant_get(message, "(ay)", &iter);
983 ERR("vsie is not present");
987 vsie_len = __netconfig_unpack_ay_malloc(&vsie_bytes, iter);
988 if (vsie_bytes == NULL) {
989 ERR("vsie_bytes not allocated");
993 ret = __netconfig_byte_to_txt(vsie_bytes, vsie, vsie_len);
996 ERR("vsie not allocated.");
1003 ERR("Succeeded to get vsie: Frame ID[%d], VSIE[%s]", frame_id, *vsie);
1009 gboolean _remove_vsie(const char *interface_name, int frame_id, const char *vsie)
1011 GVariant *params = NULL;
1012 GVariant *message = NULL;
1013 GVariantBuilder *bytearray_builder = NULL;
1016 size_t vsie_len = 0;
1018 unsigned char *bytearray = NULL;
1019 size_t bytearray_len = 0;
1021 if (frame_id >= NETCONFIG_VSIE_FRAME_MAX) {
1022 DBG("Invalid parameter, frame-id: %d", frame_id);
1026 vsie_len = strlen(vsie);
1027 if (vsie_len == 0) {
1028 DBG("vsie length is zero");
1032 bytearray_len = (vsie_len % 2) ? ((vsie_len / 2) + 1) : (vsie_len / 2);
1034 bytearray = (unsigned char *) g_try_malloc0(bytearray_len);
1035 if (bytearray == NULL) {
1036 DBG("Failed to allocate memory to bytearray");
1040 if (__netconfig_hex_str_to_bin(vsie, bytearray, bytearray_len) < 0) {
1041 DBG("invalid vsie string");
1046 bytearray_builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
1047 for (i = 0; i < bytearray_len; i++)
1048 g_variant_builder_add(bytearray_builder, "y", bytearray[i]);
1050 params = g_variant_new("(iay)", frame_id, bytearray_builder);
1051 g_variant_builder_unref(bytearray_builder);
1053 if_path = netconfig_wifi_get_supplicant_interface_path(interface_name);
1054 if (if_path == NULL) {
1055 ERR("Fail to get wpa_supplicant DBus path");
1060 message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
1061 if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemRem", params);
1064 if (message == NULL) {
1065 ERR("Failed to send command to wpa_supplicant");
1070 DBG("Succeeded to remove vsie: Frame ID[%d], VSIE[%s]", frame_id, vsie);
1077 gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context,
1078 const gchar *ifname)
1081 GSList *config_ids = NULL;
1083 gchar **result = NULL;
1084 const gchar *mac_addr = NULL;
1086 g_return_val_if_fail(wifi != NULL, TRUE);
1088 mac_addr = wifi_state_get_mac_address(ifname);
1090 ERR("Fail to get mac-address");
1091 netconfig_error_no_profile(context);
1095 DBG("%s", mac_addr);
1096 config_ids = _get_list(mac_addr);
1097 if (config_ids == NULL) {
1098 ERR("Fail to get config list");
1099 netconfig_error_no_profile(context);
1103 length = g_slist_length(config_ids);
1104 result = g_new0(gchar *, length + 1);
1105 for (i = 0; i < length; i++) {
1106 gchar *config_id = g_slist_nth_data(config_ids, i);
1107 result[i] = g_strdup(config_id);
1110 config_ids = g_slist_nth(config_ids, 0);
1111 g_slist_free_full(config_ids, g_free);
1113 wifi_complete_get_config_ids(wifi, context, (const gchar * const *)result);
1115 for (i = 0; i < length; i++)
1125 gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
1126 const gchar *ifname, const gchar *config_id)
1128 gboolean ret = FALSE;
1129 GVariantBuilder *b = NULL;
1130 struct wifi_config *conf = NULL;
1132 g_return_val_if_fail(wifi != NULL, TRUE);
1134 conf = g_new0(struct wifi_config, 1);
1135 conf->ip_info = g_new0(wifi_ip_info_s, 1);
1137 ret = _load_configuration(ifname, config_id, conf);
1139 g_free(conf->ip_info);
1141 ERR("Fail to _load_configuration");
1142 netconfig_error_no_profile(context);
1146 b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
1147 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(conf->name));
1148 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SECURITY_TYPE, g_variant_new_string(conf->security_type));
1149 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PASSPHRASE, g_variant_new_string(conf->passphrase));
1150 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string(conf->is_hidden));
1151 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FREQUENCY, g_variant_new_uint32(conf->frequency));
1153 if (conf->proxy_address != NULL)
1154 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(conf->proxy_address));
1156 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string("NONE"));
1158 if (conf->ip_info->ip_type != NULL)
1159 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_METHOD, g_variant_new_string(conf->ip_info->ip_type));
1161 if (conf->ip_info->ip_address != NULL)
1162 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_ADDRESS, g_variant_new_string(conf->ip_info->ip_address));
1164 if (conf->ip_info->subnet_mask != NULL)
1165 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_SUBNET_MASK, g_variant_new_string(conf->ip_info->subnet_mask));
1167 if (conf->ip_info->prefix_length > 0)
1168 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV6_PREFIX_LEN, g_variant_new_int32(conf->ip_info->prefix_length));
1170 if (conf->ip_info->gateway_address != NULL)
1171 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, g_variant_new_string(conf->ip_info->gateway_address));
1173 if (conf->ip_info->dns_type != NULL)
1174 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_DNS_METHOD, g_variant_new_string(conf->ip_info->dns_type));
1176 int i = 0, count = conf->ip_info->dns_count;
1178 if (conf->ip_info->dns_address[i] != NULL)
1179 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_DNS_ADDRESS, g_variant_new_string(conf->ip_info->dns_address[i]));
1184 if (conf->last_error != NULL)
1185 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string(conf->last_error));
1187 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string("ERROR_NONE"));
1189 __free_wifi_configuration(conf);
1191 INFO("Success to load configuration [%s:%s]", ifname, config_id);
1193 wifi_complete_load_configuration(wifi, context, g_variant_builder_end(b));
1194 g_variant_builder_unref(b);
1198 static unsigned char __netconfig_convert_netmask_to_prefixlen(
1199 const char *netmask)
1208 mask = inet_network(netmask);
1211 /* a valid netmask must be 2^n - 1 */
1212 if ((host & (host + 1)) != 0)
1216 for (; mask; mask <<= 1)
1222 gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
1223 const gchar *ifname, const gchar *config_id, GVariant *configuration)
1225 gboolean ret = FALSE;
1226 struct wifi_config *conf = NULL;
1227 GKeyFile *keyfile = NULL;
1231 gchar *group_name = NULL;
1234 struct timeval modified_time;
1236 if ((wifi == NULL) || (config_id == NULL) || (configuration == NULL)) {
1237 ERR("Invalid parameter");
1238 netconfig_error_invalid_parameter(context);
1242 conf = g_new0(struct wifi_config, 1);
1243 conf->ip_info = g_new0(wifi_ip_info_s, 1);
1245 g_variant_get(configuration, "a{sv}", &iter);
1246 while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
1247 if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
1248 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1249 conf->name = g_strdup(g_variant_get_string(value, NULL));
1250 DBG("name [%s]", conf->name);
1254 } else if (g_strcmp0(field, WIFI_CONFIG_SSID) == 0) {
1255 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1256 conf->ssid = g_strdup(g_variant_get_string(value, NULL));
1257 DBG("ssid [%s]", conf->ssid);
1261 } else if (g_strcmp0(field, WIFI_CONFIG_PASSPHRASE) == 0) {
1262 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1263 conf->passphrase = g_strdup(g_variant_get_string(value, NULL));
1264 DBG("passphrase []");
1266 conf->passphrase = NULL;
1268 } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
1269 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1270 conf->is_hidden = g_strdup(g_variant_get_string(value, NULL));
1271 DBG("is_hidden [%s]", conf->is_hidden);
1273 conf->is_hidden = NULL;
1275 } else if (g_strcmp0(field, WIFI_CONFIG_FREQUENCY) == 0) {
1276 if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
1277 conf->frequency = g_variant_get_uint32(value);
1278 DBG("frequency [%d]", conf->frequency);
1280 conf->frequency = 0;
1282 } else if (g_strcmp0(field, WIFI_CONFIG_CREATED) == 0) {
1283 if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
1284 conf->is_created = g_variant_get_boolean(value);
1285 DBG("is_created [%d]", conf->is_created);
1287 conf->is_created = FALSE;
1289 } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_METHOD) == 0) {
1290 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1291 conf->ip_info->ip_type = g_strdup(g_variant_get_string(value, NULL));
1292 DBG("IP config type [%s]", conf->ip_info->ip_type);
1294 conf->ip_info->ip_type = NULL;
1296 } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_ADDRESS) == 0) {
1297 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1298 conf->ip_info->ip_address = g_strdup(g_variant_get_string(value, NULL));
1299 DBG("IP address [%s]", conf->ip_info->ip_address);
1301 conf->ip_info->ip_address = NULL;
1303 } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_SUBNET_MASK) == 0) {
1304 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1305 conf->ip_info->subnet_mask = g_strdup(g_variant_get_string(value, NULL));
1306 DBG("Subnet Mask [%s]", conf->ip_info->subnet_mask);
1308 conf->ip_info->subnet_mask = NULL;
1310 } else if (g_strcmp0(field, WIFI_CONFIG_IPV6_PREFIX_LEN) == 0) {
1311 if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) {
1312 conf->ip_info->prefix_length = g_variant_get_int32(value);
1313 DBG("IPv6 Prefix Length [%d]", conf->ip_info->prefix_length);
1315 conf->ip_info->prefix_length = 0;
1317 } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS) == 0) {
1318 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1319 conf->ip_info->gateway_address = g_strdup(g_variant_get_string(value, NULL));
1320 DBG("Gateway address [%s]", conf->ip_info->gateway_address);
1322 conf->ip_info->gateway_address = NULL;
1324 } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_DNS_METHOD) == 0) {
1325 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1326 conf->ip_info->dns_type = g_strdup(g_variant_get_string(value, NULL));
1327 DBG("DNS config type [%s]", conf->ip_info->dns_type);
1329 conf->ip_info->dns_type = NULL;
1331 } else if (g_strcmp0(field, WIFI_CONFIG_DNS_ADDRESS) == 0) {
1332 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1333 conf->ip_info->dns_address[order] = g_strdup(g_variant_get_string(value, NULL));
1334 DBG("DNS address [%s]", conf->ip_info->dns_address[order]);
1335 conf->ip_info->dns_count = order + 1;
1338 conf->ip_info->dns_address[order++] = NULL;
1340 } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
1341 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1342 conf->proxy_address = g_strdup(g_variant_get_string(value, NULL));
1343 DBG("proxy_address [%s]", conf->proxy_address);
1345 conf->proxy_address = NULL;
1349 conf->favorite = TRUE;
1350 conf->autoconnect = TRUE;
1352 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
1353 ifname, config_id, &group_name);
1355 __free_wifi_configuration(conf);
1356 ERR("Fail to get_wifi_config_group_name");
1357 netconfig_error_fail_save_congifuration(context);
1361 keyfile = g_key_file_new();
1362 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_NAME, conf->name);
1363 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_SSID, conf->ssid);
1365 if (conf->passphrase != NULL) {
1366 gchar *enc_data = NULL;
1368 if (conf->is_created == true)
1369 enc_data = _netconfig_encrypt_passphrase(conf->passphrase);
1371 enc_data = g_strdup(conf->passphrase);
1374 ERR("Failed to encrypt the passphrase");
1376 g_free(conf->passphrase);
1377 conf->passphrase = enc_data;
1380 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, conf->passphrase);
1383 g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_FAVORITE, conf->favorite);
1384 g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_AUTOCONNECT, conf->autoconnect);
1386 rv = gettimeofday(&modified_time, NULL);
1388 struct tm modified_tm;
1390 time_t modified_t = modified_time.tv_sec;
1392 if (localtime_r(&modified_t, &modified_tm)) {
1393 if (strftime(time_buf, sizeof(time_buf), "%FT%TZ", &modified_tm)) {
1394 field = g_strdup(time_buf);
1396 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_MODIFIED, field);
1403 /* Optional field */
1404 if (conf->proxy_address != NULL) {
1405 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_METHOD, "manual");
1406 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, conf->proxy_address);
1409 if (conf->is_hidden != NULL) {
1410 gboolean hidden = FALSE;
1411 if (g_strcmp0(conf->is_hidden, "TRUE") == 0)
1413 g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, hidden);
1416 if (conf->frequency > 0)
1417 g_key_file_set_integer(keyfile, group_name,
1418 WIFI_CONFIG_FREQUENCY, conf->frequency);
1420 if (conf->ip_info->ip_type != NULL)
1421 g_key_file_set_string(keyfile, group_name,
1422 WIFI_CONFIG_IPV4_METHOD, conf->ip_info->ip_type);
1424 if (conf->ip_info->ip_address != NULL)
1425 g_key_file_set_string(keyfile, group_name,
1426 WIFI_CONFIG_IPV4_ADDRESS, conf->ip_info->ip_address);
1428 if (conf->ip_info->subnet_mask != NULL) {
1429 unsigned char prefix_len;
1430 prefix_len = __netconfig_convert_netmask_to_prefixlen(
1431 conf->ip_info->subnet_mask);
1432 if (prefix_len > 0 && prefix_len < 32)
1433 g_key_file_set_integer(keyfile, group_name,
1434 WIFI_CONFIG_IPV4_SUBNET_MASK, prefix_len);
1437 if (conf->ip_info->prefix_length > 0)
1438 g_key_file_set_integer(keyfile, group_name,
1439 WIFI_CONFIG_IPV6_PREFIX_LEN, conf->ip_info->prefix_length);
1441 if (conf->ip_info->gateway_address != NULL)
1442 g_key_file_set_string(keyfile, group_name,
1443 WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, conf->ip_info->gateway_address);
1445 if (conf->ip_info->dns_type != NULL)
1446 g_key_file_set_string(keyfile, group_name,
1447 WIFI_CONFIG_IPV4_DNS_METHOD, conf->ip_info->dns_type);
1449 int i = 0, count = conf->ip_info->dns_count;
1451 if (conf->ip_info->dns_address[i] != NULL)
1452 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_DNS_ADDRESS,
1453 conf->ip_info->dns_address[i]);
1458 ret = wifi_config_save_configuration(ifname, config_id, keyfile);
1460 INFO("Success to save configuration [%s]", config_id);
1461 wifi_complete_save_configuration(wifi, context);
1463 if (get_files_count(CONNMAN_STORAGE) > MAX_WIFI_PROFILES) {
1464 file = get_least_recently_profile(CONNMAN_STORAGE);
1466 gchar *profileName = g_strdup_printf(CONNMAN_STORAGE "/%s", file);
1467 INFO("least modified file: %s", profileName);
1469 if (__remove_configuration(profileName) != TRUE)
1470 DBG("Failed to remove profile: [%s]", profileName);
1472 ERR("Profile: [%s] does not exist", file);
1474 g_free(profileName);
1478 INFO("Fail to save configuration [%s]", config_id);
1479 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSaveConfiguration");
1482 g_key_file_free(keyfile);
1484 __free_wifi_configuration(conf);
1486 g_variant_iter_free(iter);
1491 gboolean handle_load_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context,
1492 const gchar *ifname, const gchar *config_id)
1494 gboolean ret = FALSE;
1495 GVariantBuilder *b = NULL;
1496 struct wifi_config *conf = NULL;
1498 g_return_val_if_fail(wifi != NULL, TRUE);
1500 conf = g_new0(struct wifi_config, 1);
1501 conf->eap_config = g_new0(struct wifi_eap_config, 1);
1502 conf->ip_info = g_new0(wifi_ip_info_s, 1);
1504 ret = _load_configuration(ifname, config_id, conf);
1506 g_free(conf->eap_config);
1507 g_free(conf->ip_info);
1509 ERR("Fail to _load_configuration");
1510 netconfig_error_no_profile(context);
1514 b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
1515 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(conf->name));
1516 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SECURITY_TYPE, g_variant_new_string(conf->security_type));
1517 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string(conf->is_hidden));
1518 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FREQUENCY, g_variant_new_uint32(conf->frequency));
1520 if (conf->proxy_address != NULL)
1521 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(conf->proxy_address));
1523 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string("NONE"));
1525 if (conf->last_error != NULL)
1526 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string(conf->last_error));
1528 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string("ERROR_NONE"));
1530 if (conf->eap_config != NULL) {
1531 if (conf->eap_config->anonymous_identity != NULL)
1532 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string(conf->eap_config->anonymous_identity));
1534 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string("NONE"));
1536 if (conf->eap_config->ca_cert != NULL)
1537 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string(conf->eap_config->ca_cert));
1539 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string("NONE"));
1541 if (conf->eap_config->client_cert != NULL)
1542 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string(conf->eap_config->client_cert));
1544 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string("NONE"));
1546 if (conf->eap_config->private_key != NULL)
1547 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string(conf->eap_config->private_key));
1549 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string("NONE"));
1551 if (conf->eap_config->private_key_password != NULL)
1552 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD, g_variant_new_string(conf->eap_config->private_key_password));
1554 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD, g_variant_new_string("NONE"));
1556 if (conf->eap_config->identity != NULL)
1557 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string(conf->eap_config->identity));
1559 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string("NONE"));
1561 if (conf->eap_config->eap_type != NULL)
1562 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string(conf->eap_config->eap_type));
1564 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string("NONE"));
1566 if (conf->eap_config->eap_auth_type != NULL)
1567 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string(conf->eap_config->eap_auth_type));
1569 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string("NONE"));
1571 if (conf->eap_config->subject_match != NULL)
1572 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string(conf->eap_config->subject_match));
1574 g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string("NONE"));
1577 __free_wifi_configuration(conf);
1579 wifi_complete_load_eap_configuration(wifi, context, g_variant_builder_end(b));
1580 g_variant_builder_unref(b);
1584 gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *context,
1585 const gchar *ifname, const gchar *config_id, GVariant *configuration)
1587 gboolean ret = FALSE;
1588 struct wifi_config *conf = NULL;
1589 GKeyFile *keyfile = NULL;
1593 gchar *group_name = NULL;
1595 if ((wifi == NULL) || (config_id == NULL) || (configuration == NULL)) {
1596 ERR("Invalid parameter");
1597 netconfig_error_invalid_parameter(context);
1601 conf = g_new0(struct wifi_config, 1);
1602 conf->eap_config = g_new0(struct wifi_eap_config, 1);
1604 g_variant_get(configuration, "a{sv}", &iter);
1605 while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
1606 if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
1607 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1608 conf->name = g_strdup(g_variant_get_string(value, NULL));
1609 DBG("name [%s]", conf->name);
1613 } else if (g_strcmp0(field, WIFI_CONFIG_SSID) == 0) {
1614 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1615 conf->ssid = g_strdup(g_variant_get_string(value, NULL));
1616 DBG("ssid [%s]", conf->ssid);
1620 } else if (g_strcmp0(field, WIFI_CONFIG_PASSPHRASE) == 0) {
1621 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1622 conf->passphrase = g_strdup(g_variant_get_string(value, NULL));
1623 DBG("passphrase [%s]", conf->passphrase);
1625 conf->passphrase = NULL;
1627 } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
1628 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1629 conf->is_hidden = g_strdup(g_variant_get_string(value, NULL));
1630 DBG("is_hidden [%s]", conf->is_hidden);
1632 conf->is_hidden = NULL;
1634 } else if (g_strcmp0(field, WIFI_CONFIG_FREQUENCY) == 0) {
1635 if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
1636 conf->frequency = g_variant_get_uint32(value);
1637 DBG("frequency [%d]", conf->frequency);
1639 conf->frequency = 0;
1641 } else if (g_strcmp0(field, WIFI_CONFIG_CREATED) == 0) {
1642 if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
1643 conf->is_created = g_variant_get_boolean(value);
1644 DBG("is_created [%d]", conf->is_created);
1646 conf->is_created = FALSE;
1648 } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
1649 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1650 conf->proxy_address = g_strdup(g_variant_get_string(value, NULL));
1651 DBG("proxy_address [%s]", conf->proxy_address);
1653 conf->proxy_address = NULL;
1655 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
1656 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1657 conf->eap_config->anonymous_identity = g_strdup(g_variant_get_string(value, NULL));
1658 DBG("anonymous_identity [%s]", conf->eap_config->anonymous_identity);
1660 conf->eap_config->anonymous_identity = NULL;
1662 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CACERT) == 0) {
1663 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1664 conf->eap_config->ca_cert = g_strdup(g_variant_get_string(value, NULL));
1665 DBG("ca_cert [%s]", conf->eap_config->ca_cert);
1667 conf->eap_config->ca_cert = NULL;
1669 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
1670 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1671 conf->eap_config->client_cert = g_strdup(g_variant_get_string(value, NULL));
1672 DBG("client_cert [%s]", conf->eap_config->client_cert);
1674 conf->eap_config->client_cert = NULL;
1676 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
1677 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1678 conf->eap_config->private_key = g_strdup(g_variant_get_string(value, NULL));
1679 DBG("private_key [%s]", conf->eap_config->private_key);
1681 conf->eap_config->private_key = NULL;
1683 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD) == 0) {
1684 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1685 conf->eap_config->private_key_password = g_strdup(g_variant_get_string(value, NULL));
1686 DBG("private_key_password[%s]", conf->eap_config->private_key_password);
1688 conf->eap_config->private_key_password = NULL;
1690 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_IDENTITY) == 0) {
1691 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1692 conf->eap_config->identity = g_strdup(g_variant_get_string(value, NULL));
1693 DBG("identity [%s]", conf->eap_config->identity);
1695 conf->eap_config->identity = NULL;
1697 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_TYPE) == 0) {
1698 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1699 conf->eap_config->eap_type = g_strdup(g_variant_get_string(value, NULL));
1700 DBG("eap_type [%s]", conf->eap_config->eap_type);
1702 conf->eap_config->eap_type = NULL;
1704 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
1705 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1706 conf->eap_config->eap_auth_type = g_strdup(g_variant_get_string(value, NULL));
1707 DBG("eap_auth_type [%s]", conf->eap_config->eap_auth_type);
1709 conf->eap_config->eap_auth_type = NULL;
1711 } else if (g_strcmp0(field, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
1712 if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
1713 conf->eap_config->subject_match = g_strdup(g_variant_get_string(value, NULL));
1714 DBG("subject_match [%s]", conf->eap_config->subject_match);
1716 conf->eap_config->subject_match = NULL;
1720 conf->favorite = TRUE;
1721 conf->autoconnect = TRUE;
1723 ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX,
1724 ifname, config_id, &group_name);
1726 __free_wifi_configuration(conf);
1727 ERR("Fail to get_wifi_config_group_name");
1731 keyfile = g_key_file_new();
1732 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_NAME, conf->name);
1733 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_SSID, conf->ssid);
1735 if (conf->passphrase != NULL) {
1736 gchar *enc_data = NULL;
1738 if (conf->is_created == true)
1739 enc_data = _netconfig_encrypt_passphrase(conf->passphrase);
1741 enc_data = g_strdup(conf->passphrase);
1744 ERR("Failed to encrypt the passphrase");
1746 g_free(conf->passphrase);
1747 conf->passphrase = enc_data;
1749 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, conf->passphrase);
1752 g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_FAVORITE, conf->favorite);
1753 g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_AUTOCONNECT, conf->autoconnect);
1755 /* Optional field */
1756 if (conf->proxy_address != NULL) {
1757 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_METHOD, "manual");
1758 g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, conf->proxy_address);
1761 if (conf->is_hidden != NULL) {
1762 gboolean hidden = FALSE;
1763 if (g_strcmp0(conf->is_hidden, "TRUE") == 0)
1765 g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, hidden);
1768 if (conf->frequency > 0)
1769 g_key_file_set_integer(keyfile, group_name,
1770 WIFI_CONFIG_FREQUENCY, conf->frequency);
1772 if (conf->eap_config->anonymous_identity != NULL)
1773 g_key_file_set_string(keyfile, group_name,
1774 WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, conf->eap_config->anonymous_identity);
1776 if (conf->eap_config->ca_cert != NULL)
1777 g_key_file_set_string(keyfile, group_name,
1778 WIFI_CONFIG_EAP_CACERT, conf->eap_config->ca_cert);
1780 if (conf->eap_config->client_cert != NULL)
1781 g_key_file_set_string(keyfile, group_name,
1782 WIFI_CONFIG_EAP_CLIENTCERT, conf->eap_config->client_cert);
1784 if (conf->eap_config->private_key != NULL)
1785 g_key_file_set_string(keyfile, group_name,
1786 WIFI_CONFIG_EAP_PRIVATEKEY, conf->eap_config->private_key);
1788 if (conf->eap_config->private_key_password != NULL)
1789 g_key_file_set_string(keyfile, group_name,
1790 WIFI_CONFIG_EAP_PRIVATEKEY_PASSWORD, conf->eap_config->private_key_password);
1792 if (conf->eap_config->identity != NULL)
1793 g_key_file_set_string(keyfile, group_name,
1794 WIFI_CONFIG_EAP_IDENTITY, conf->eap_config->identity);
1796 if (conf->eap_config->eap_type != NULL)
1797 g_key_file_set_string(keyfile, group_name,
1798 WIFI_CONFIG_EAP_TYPE, conf->eap_config->eap_type);
1800 if (conf->eap_config->eap_auth_type != NULL)
1801 g_key_file_set_string(keyfile, group_name,
1802 WIFI_CONFIG_EAP_AUTH_TYPE, conf->eap_config->eap_auth_type);
1804 if (conf->eap_config->subject_match != NULL)
1805 g_key_file_set_string(keyfile, group_name,
1806 WIFI_CONFIG_EAP_SUBJECT_MATCH, conf->eap_config->subject_match);
1808 ret = wifi_config_save_configuration(ifname, config_id, keyfile);
1810 INFO("Success to save eap configuration [%s]", config_id);
1811 wifi_complete_save_eap_configuration(wifi, context);
1813 INFO("Fail to save eap configuration [%s]", config_id);
1814 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSaveEapConfiguration");
1817 g_key_file_free(keyfile);
1819 __free_wifi_configuration(conf);
1821 g_variant_iter_free(iter);
1826 gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context,
1827 const gchar *ifname, const gchar *config_id)
1829 gboolean ret = FALSE;
1831 if ((wifi == NULL) || (config_id == NULL)) {
1832 ERR("Invalid parameter");
1833 netconfig_error_invalid_parameter(context);
1837 ret = _remove_configuration(ifname, config_id);
1839 /* no configuration or error */
1840 ERR("No [%s] configuration", config_id);
1841 netconfig_error_no_profile(context);
1845 wifi_complete_remove_configuration(wifi, context);
1849 gboolean handle_reset_wifi_config(Wifi *wifi, GDBusMethodInvocation *context)
1851 DIR *dir_ptr = NULL;
1852 struct dirent *file = NULL;
1854 char dir_name[512] = { 0, };
1855 char file_name[1024] = { 0, };
1857 g_return_val_if_fail(wifi != NULL, TRUE);
1859 DBG("Try to remove connman Wi-Fi config files...");
1861 if ((dir_ptr = opendir(CONNMAN_STORAGE)) != NULL) {
1862 while ((file = readdir(dir_ptr)) != NULL) {
1863 if (strncmp(file->d_name, ".", 1) == 0 || strncmp(file->d_name, "..", 2) == 0 ||
1864 strncmp(file->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
1868 snprintf(dir_name, 512, CONNMAN_STORAGE"/%s", file->d_name);
1870 if (lstat(dir_name, &buf) == -1)
1873 DBG("Remove wifi config: %s", file->d_name);
1875 if (S_ISDIR(buf.st_mode)) {
1876 memset(file_name, 0, 1024);
1877 snprintf(file_name, 1024, "%s/data", dir_name);
1879 memset(file_name, 0, 1024);
1880 snprintf(file_name, 1024, "%s/settings", dir_name);
1890 wifi_complete_reset_wifi_config(wifi, context);
1895 /* config field key / value */
1897 * [wifi_macaddress_config_id]
1898 * Name=name (mandatory)
1899 * SSID=SSID (mandatory)
1900 * Frequency=2462 (X)
1902 * AutoConnect=true (Default true)
1903 * Modified=2015-03-20 (X)
1904 * IPv4.method=manual (O)
1905 * IPv4.DHCP.LastAddress=192.0.0.1 (X)
1906 * IPv6.method=auto (X)
1907 * IPv6.privacy=disabled (X)
1908 * IPv4.netmask_prefixlen=24 (X)
1909 * IPv4.local_address=192.0.0.1 (O)
1910 * IPv4.gateway=192.0.0.1 (O ? X ?)
1911 * Nameservers=192.168.43.22; (O)
1912 * Proxy.Method=manual (O)
1913 * Proxy.Servers=trst.com:8888; (O)
1915 gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context,
1916 const gchar *ifname, const gchar *config_id, const gchar *key, const gchar *value)
1918 gboolean ret = FALSE;
1919 gchar *keyfile_key = NULL;
1921 g_return_val_if_fail(wifi != NULL, TRUE);
1922 g_return_val_if_fail(config_id != NULL, TRUE);
1923 g_return_val_if_fail(key != NULL, TRUE);
1925 DBG("Key[%s] Value[%s]", key, value);
1927 if (g_strcmp0(key, WIFI_CONFIG_PROXYADDRESS) == 0) {
1928 ret = _set_field(ifname, config_id, WIFI_CONFIG_PROXY_METHOD, "manual");
1930 ERR("Fail to [%s]set_wifi_config_field(%s/manual)", config_id, WIFI_CONFIG_PROXY_METHOD);
1931 netconfig_error_invalid_parameter(context);
1934 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_PROXY_SERVER);
1935 } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
1936 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_HIDDEN);
1937 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
1938 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY);
1939 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CACERT) == 0) {
1940 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_CACERT);
1941 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
1942 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_CLIENTCERT);
1943 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
1944 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_PRIVATEKEY);
1945 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_IDENTITY) == 0) {
1946 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_IDENTITY);
1947 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_TYPE) == 0) {
1948 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_TYPE);
1949 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
1950 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_AUTH_TYPE);
1951 } else if (g_strcmp0(key, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
1952 keyfile_key = g_strdup_printf("%s", WIFI_CONFIG_EAP_SUBJECT_MATCH);
1954 ERR("Not supported key[%s]", key);
1955 netconfig_error_invalid_parameter(context);
1959 ret = _set_field(ifname, config_id, keyfile_key, (const gchar *)value);
1961 ERR("Fail to [%s]set_wifi_config_field(%s/%s)", config_id, key, value);
1964 if (keyfile_key != NULL)
1965 g_free(keyfile_key);
1967 wifi_complete_set_config_field(wifi, context);
1971 gboolean handle_get_config_passphrase(Wifi *wifi, GDBusMethodInvocation *context,
1972 const gchar *ifname, const gchar *config_id)
1974 gboolean ret = FALSE;
1975 gchar *passphrase = NULL;
1977 if ((wifi == NULL) || (ifname == NULL) || (config_id == NULL)) {
1978 ERR("Invalid parameter");
1979 netconfig_error_invalid_parameter(context);
1983 ret = _get_field(ifname, config_id, WIFI_CONFIG_PASSPHRASE, &passphrase);
1985 ERR("Fail to [%s] _get_field(%s)", config_id, WIFI_CONFIG_PASSPHRASE);
1986 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
1990 wifi_complete_get_config_passphrase(wifi, context, passphrase);
1996 gboolean handle_add_vsie(Wifi *wifi, GDBusMethodInvocation *context,
1997 const gchar *ifname, int frame_id, const gchar *vsie)
1999 DBG("Frame ID: [%d] VSIE: [%s]", frame_id, vsie);
2001 g_return_val_if_fail(wifi != NULL, TRUE);
2002 g_return_val_if_fail(vsie != NULL, TRUE);
2004 gboolean ret = FALSE;
2006 ret = _add_vsie(ifname, frame_id, vsie);
2008 DBG("Failed to add vsie: %s", vsie);
2009 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
2013 wifi_complete_add_vsie(wifi, context);
2017 gboolean handle_get_vsie(Wifi *wifi, GDBusMethodInvocation *context,
2018 const gchar *ifname, int frame_id)
2020 DBG("Frame ID: [%d]", frame_id);
2022 g_return_val_if_fail(wifi != NULL, TRUE);
2024 gboolean ret = FALSE;
2027 ret = _get_vsie(ifname, frame_id, &vsie);
2029 DBG("Failed to get vsie for frame:[%d]", frame_id);
2030 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
2034 DBG("Received vsie: %s", vsie);
2035 wifi_complete_get_vsie(wifi, context, vsie);
2040 gboolean handle_remove_vsie(Wifi *wifi, GDBusMethodInvocation *context,
2041 const gchar *ifname, int frame_id, const gchar *vsie)
2043 DBG("Frame ID: [%d] VSIE: [%s]", frame_id, vsie);
2045 g_return_val_if_fail(wifi != NULL, TRUE);
2046 g_return_val_if_fail(vsie != NULL, TRUE);
2048 gboolean ret = FALSE;
2050 ret = _remove_vsie(ifname, frame_id, vsie);
2052 DBG("Failed to remove vsie: %s", vsie);
2053 netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
2057 wifi_complete_remove_vsie(wifi, context);