2 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "wifi_config_private.h"
19 #include "net_wifi_private.h"
24 EXPORT_API int wifi_config_create(const char *name, const char *passphrase, wifi_security_type_e security_type, wifi_config_h *config)
26 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_create");
27 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
29 struct _wifi_config *h = NULL;
31 if (_wifi_is_init() == false) {
32 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
33 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
36 if (config == NULL || name == NULL) {
37 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
38 return WIFI_ERROR_INVALID_PARAMETER;
41 h = g_new0(struct _wifi_config, 1);
43 return WIFI_ERROR_OUT_OF_MEMORY;
45 h->name = g_strdup(name);
46 h->passphrase = g_strdup(passphrase);
47 h->security_type = security_type;
50 h->proxy_address = NULL;
51 h->address_family = WIFI_ADDRESS_FAMILY_IPV4;
54 if (security_type == WIFI_SECURITY_TYPE_EAP) {
55 h->eap_config = g_new0(struct _wifi_eap_config, 1);
56 if (h->eap_config == NULL) {
57 g_free(h->name); //LCOV_EXCL_LINE
58 g_free(h->passphrase); //LCOV_EXCL_LINE
59 g_free(h); //LCOV_EXCL_LINE
60 return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
63 h->eap_config->ca_cert = NULL;
64 h->eap_config->client_cert = NULL;
65 h->eap_config->private_key = NULL;
66 h->eap_config->anonymous_identity = NULL;
67 h->eap_config->identity = NULL;
68 h->eap_config->subject_match = NULL;
69 h->eap_config->eap_type = -1;
70 h->eap_config->eap_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
73 *config = (wifi_config_h)h;
75 return WIFI_ERROR_NONE;
78 EXPORT_API int wifi_config_clone(wifi_config_h origin, wifi_config_h *cloned_config)
80 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_clone");
81 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
83 struct _wifi_config *h = NULL;
84 struct _wifi_config *config = NULL;
86 if (_wifi_is_init() == false) {
87 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
88 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
91 if (origin == NULL || cloned_config == NULL) {
92 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
93 return WIFI_ERROR_INVALID_PARAMETER;
96 config = (struct _wifi_config *)origin;
98 h = g_new0(struct _wifi_config, 1);
100 return WIFI_ERROR_OUT_OF_MEMORY;
102 h->name = g_strdup(config->name);
103 h->passphrase = g_strdup(config->passphrase);
104 h->security_type = config->security_type;
105 h->is_saved = config->is_saved;
106 h->is_hidden = config->is_hidden;
107 h->proxy_address = g_strdup(config->proxy_address);
108 h->address_family = config->address_family;
110 if (config->eap_config) {
111 h->eap_config = g_new0(struct _wifi_eap_config, 1);
112 if (h->eap_config == NULL) {
113 g_free(h->name); //LCOV_EXCL_LINE
114 g_free(h->passphrase); //LCOV_EXCL_LINE
115 g_free(h->proxy_address); //LCOV_EXCL_LINE
116 g_free(h); //LCOV_EXCL_LINE
117 return WIFI_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
120 h->eap_config->ca_cert = g_strdup(config->eap_config->ca_cert);
121 h->eap_config->client_cert = g_strdup(config->eap_config->client_cert);
122 h->eap_config->private_key = g_strdup(config->eap_config->private_key);
123 h->eap_config->anonymous_identity = g_strdup(config->eap_config->anonymous_identity);
124 h->eap_config->identity = g_strdup(config->eap_config->identity);
125 h->eap_config->subject_match = g_strdup(config->eap_config->subject_match);
126 h->eap_config->eap_type = config->eap_config->eap_type;
127 h->eap_config->eap_auth_type = config->eap_config->eap_auth_type;
130 *cloned_config = (wifi_config_h)h;
132 return WIFI_ERROR_NONE;
135 EXPORT_API int wifi_config_destroy(wifi_config_h config)
137 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_destroy");
138 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
140 struct _wifi_config *h = (struct _wifi_config *)config;
142 if (_wifi_is_init() == false) {
143 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
144 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
147 if (config == NULL) {
148 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
149 return WIFI_ERROR_INVALID_PARAMETER;
153 g_free(h->passphrase);
154 g_free(h->proxy_address);
156 g_free(h->eap_config->ca_cert);
157 g_free(h->eap_config->client_cert);
158 g_free(h->eap_config->private_key);
159 g_free(h->eap_config->anonymous_identity);
160 g_free(h->eap_config->identity);
161 g_free(h->eap_config->subject_match);
162 g_free(h->eap_config);
166 return WIFI_ERROR_NONE;
169 EXPORT_API int wifi_config_save_configuration(wifi_config_h config)
171 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_save");
172 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
174 int ret = WIFI_ERROR_NONE;
175 wifi_dbus *dbus_h = NULL;
176 struct _wifi_config *h = (struct _wifi_config *)config;
178 if (_wifi_is_init() == false) {
179 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
180 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
183 if (config == NULL || h->name == NULL) {
184 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
185 return WIFI_ERROR_INVALID_PARAMETER;
188 dbus_h = _wifi_get_dbus_handle();
189 if (dbus_h == NULL) {
190 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); //LCOV_EXCL_LINE
191 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
194 if (h->security_type == WIFI_SECURITY_TYPE_EAP) {
195 ret = wifi_save_eap_configurations(dbus_h, h->name, h->passphrase, h->security_type, h->proxy_address, h->eap_config, h->is_hidden);
196 if (ret != WIFI_ERROR_NONE)
197 WIFI_LOG(WIFI_ERROR, "Fail to wifi_save_eap_configurations"); //LCOV_EXCL_LINE
199 ret = wifi_save_configurations(dbus_h, h->name, h->passphrase, h->security_type, h->proxy_address, h->is_hidden);
200 if (ret != WIFI_ERROR_NONE)
201 WIFI_LOG(WIFI_ERROR, "Fail to save configurations [%d]", ret); //LCOV_EXCL_LINE
209 EXPORT_API int wifi_config_remove(wifi_config_h config)
211 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_remove");
212 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
213 int ret = WIFI_ERROR_NONE;
214 struct _wifi_config *h = (struct _wifi_config *)config;
216 if (_wifi_is_init() == false) {
217 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
218 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
221 if (config == NULL || h->name == NULL) {
222 WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
223 return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
226 if (h->is_saved == TRUE) {
227 wifi_dbus *dbus_h = NULL;
228 gchar *config_id = NULL;
230 dbus_h = _wifi_get_dbus_handle();
231 if (dbus_h == NULL) {
232 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
233 return WIFI_ERROR_INVALID_OPERATION;
236 config_id = wifi_config_get_config_id(h->name, h->security_type);
238 ret = wifi_remove_configurations(dbus_h, config_id);
239 if (ret != WIFI_ERROR_NONE)
240 WIFI_LOG(WIFI_ERROR, "Fail to remove configurations [%d]", ret);
248 EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, void *user_data)
250 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_foreach_configuration");
251 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
253 int ret = WIFI_ERROR_NONE;
254 wifi_dbus *dbus_h = NULL;
255 GSList *config_ids = NULL;
257 if (_wifi_is_init() == false) {
258 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
259 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
262 if (callback == NULL) {
263 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
264 return WIFI_ERROR_INVALID_PARAMETER;
267 dbus_h = _wifi_get_dbus_handle();
268 if (dbus_h == NULL) {
269 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection"); //LCOV_EXCL_LINE
270 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
273 config_ids = wifi_config_get_config_id_list(dbus_h);
274 if (config_ids == NULL) {
275 WIFI_LOG(WIFI_ERROR, "Fail to wifi_get_config_id_list"); //LCOV_EXCL_LINE
276 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
281 struct _wifi_config *h;
282 gchar *id = config_ids->data;
284 h = g_new0(struct _wifi_config, 1);
286 ret = WIFI_ERROR_OUT_OF_MEMORY;
290 if (g_str_has_suffix(id, "ieee8021x") == TRUE) {
291 h->eap_config = g_new0(struct _wifi_eap_config, 1);
292 if (h->eap_config == NULL) {
293 ret = WIFI_ERROR_OUT_OF_MEMORY;
296 ret = wifi_load_eap_configurations(dbus_h, id, &h->name,
297 &h->security_type, &h->proxy_address, &h->is_hidden, &h->eap_config, &h->last_error);
299 ret = wifi_load_configurations(dbus_h, id, &h->name,
300 &h->security_type, &h->proxy_address, &h->is_hidden, &h->last_error);
303 if (ret != WIFI_ERROR_NONE) {
304 WIFI_LOG(WIFI_ERROR, "Fail to load configurations [%d]", ret); //LCOV_EXCL_LINE
305 return ret; //LCOV_EXCL_LINE
308 h->address_family = WIFI_ADDRESS_FAMILY_IPV4;
310 rv = callback((wifi_config_h)h, user_data);
312 g_free(h->proxy_address);
314 g_free(h->eap_config->ca_cert);
315 g_free(h->eap_config->client_cert);
316 g_free(h->eap_config->private_key);
317 g_free(h->eap_config->anonymous_identity);
318 g_free(h->eap_config->identity);
319 g_free(h->eap_config->subject_match);
320 g_free(h->eap_config);
328 config_ids = config_ids->next;
331 config_ids = g_slist_nth(config_ids, 0);
332 g_slist_free_full(config_ids, g_free);
337 EXPORT_API int wifi_config_get_name(wifi_config_h config, char **name)
339 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_name");
340 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
342 struct _wifi_config *h = (struct _wifi_config *)config;
344 if (_wifi_is_init() == false) {
345 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
346 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
349 if (config == NULL || name == NULL) {
350 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
351 return WIFI_ERROR_INVALID_PARAMETER;
355 *name = g_strdup(h->name);
359 return WIFI_ERROR_NONE;
362 EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security_type_e *security_type)
364 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_security_type");
365 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
367 struct _wifi_config *h = (struct _wifi_config *)config;
369 if (_wifi_is_init() == false) {
370 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
371 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
374 if (config == NULL || security_type == NULL) {
375 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
376 return WIFI_ERROR_INVALID_PARAMETER;
379 *security_type = h->security_type;
381 return WIFI_ERROR_NONE;
385 * wifi configuration set field
387 EXPORT_API int wifi_config_set_proxy_address(wifi_config_h config, wifi_address_family_e address_family, const char *proxy_address)
389 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_proxy_address");
390 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
392 struct _wifi_config *h = (struct _wifi_config *)config;
393 int ret = WIFI_ERROR_NONE;
395 if (_wifi_is_init() == false) {
396 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
397 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
400 if (config == NULL) {
401 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
402 return WIFI_ERROR_INVALID_PARAMETER;
404 if ((address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
405 WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
406 return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
409 if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
410 WIFI_LOG(WIFI_ERROR, "Not supported yet"); //LCOV_EXCL_LINE
411 return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; //LCOV_EXCL_LINE
414 h->address_family = address_family;
415 h->proxy_address = g_strdup(proxy_address);
417 if (h->is_saved == TRUE) {
419 wifi_dbus *dbus_h = NULL;
420 gchar *config_id = NULL;
422 dbus_h = _wifi_get_dbus_handle();
423 if (dbus_h == NULL) {
424 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
425 return WIFI_ERROR_INVALID_OPERATION;
428 config_id = wifi_config_get_config_id(h->name, h->security_type);
430 ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_PROXYADDRESS, proxy_address);
431 if (ret != WIFI_ERROR_NONE)
432 WIFI_LOG(WIFI_ERROR, "Fail to set proxy address [%d]", ret);
441 EXPORT_API int wifi_config_get_proxy_address(wifi_config_h config, wifi_address_family_e *address_family, char **proxy_address)
443 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_proxy_address");
444 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
446 struct _wifi_config *h = (struct _wifi_config *)config;
448 if (_wifi_is_init() == false) {
449 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
450 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
453 if (config == NULL || address_family == NULL || proxy_address == NULL) {
454 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
455 return WIFI_ERROR_INVALID_PARAMETER;
458 *address_family = h->address_family;
459 *proxy_address = g_strdup(h->proxy_address);
461 return WIFI_ERROR_NONE;
464 EXPORT_API int wifi_config_set_hidden_ap_property(wifi_config_h config, bool hidden)
466 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_hidden_ap_property");
467 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
469 struct _wifi_config *h = (struct _wifi_config *)config;
470 int ret = WIFI_ERROR_NONE;
472 if (_wifi_is_init() == false) {
473 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
474 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
477 if (config == NULL) {
478 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
479 return WIFI_ERROR_INVALID_PARAMETER;
482 h->is_hidden = hidden;
484 if (h->is_saved == TRUE) {
486 wifi_dbus *dbus_h = NULL;
487 char *config_id = NULL;
490 dbus_h = _wifi_get_dbus_handle();
491 if (dbus_h == NULL) {
492 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
493 return WIFI_ERROR_INVALID_OPERATION;
496 config_id = wifi_config_get_config_id(h->name, h->security_type);
498 if (h->is_hidden == TRUE)
499 hidden = g_strdup("TRUE");
501 hidden = g_strdup("FALSE");
503 ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_HIDDEN, hidden);
504 if (ret != WIFI_ERROR_NONE)
505 WIFI_LOG(WIFI_ERROR, "Fail to set hidden [%d]", ret);
515 EXPORT_API int wifi_config_get_hidden_ap_property(wifi_config_h config, bool *hidden)
517 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_hidden_ap_property");
518 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
520 struct _wifi_config *h = (struct _wifi_config *)config;
522 if (_wifi_is_init() == false) {
523 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
524 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
527 if (config == NULL || hidden == NULL) {
528 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
529 return WIFI_ERROR_INVALID_PARAMETER;
532 *hidden = h->is_hidden;
534 return WIFI_ERROR_NONE;
537 EXPORT_API int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char** anonymous_identity)
539 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_anonymous_identity");
540 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
542 struct _wifi_config *h = (struct _wifi_config *)config;
545 return WIFI_ERROR_INVALID_PARAMETER;
546 if (h->eap_config == NULL)
547 return WIFI_ERROR_INVALID_PARAMETER;
548 if (anonymous_identity == NULL)
549 return WIFI_ERROR_INVALID_PARAMETER;
551 *anonymous_identity = g_strdup(h->eap_config->anonymous_identity);
553 return WIFI_ERROR_NONE;
556 EXPORT_API int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char* anonymous_identity)
558 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_anonymous_identity");
559 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
561 struct _wifi_config *h = (struct _wifi_config *)config;
564 return WIFI_ERROR_INVALID_PARAMETER;
565 if (h->eap_config == NULL)
566 return WIFI_ERROR_INVALID_PARAMETER;
568 h->eap_config->anonymous_identity = g_strdup(anonymous_identity);
570 if (h->is_saved == TRUE) {
572 wifi_dbus *dbus_h = NULL;
573 gchar *config_id = NULL;
575 dbus_h = _wifi_get_dbus_handle();
576 if (dbus_h == NULL) {
577 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
578 return WIFI_ERROR_INVALID_OPERATION;
581 config_id = wifi_config_get_config_id(h->name, h->security_type);
583 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, anonymous_identity);
589 return WIFI_ERROR_NONE;
592 EXPORT_API int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char** ca_cert)
594 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_ca_cert_file");
595 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
597 struct _wifi_config *h = (struct _wifi_config *)config;
600 return WIFI_ERROR_INVALID_PARAMETER;
601 if (h->eap_config == NULL)
602 return WIFI_ERROR_INVALID_PARAMETER;
604 return WIFI_ERROR_INVALID_PARAMETER;
606 *ca_cert = g_strdup(h->eap_config->ca_cert);
608 return WIFI_ERROR_NONE;
611 EXPORT_API int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char* ca_cert)
613 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_ca_cert_file");
614 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
616 struct _wifi_config *h = (struct _wifi_config *)config;
619 return WIFI_ERROR_INVALID_PARAMETER;
620 if (h->eap_config == NULL)
621 return WIFI_ERROR_INVALID_PARAMETER;
623 h->eap_config->ca_cert = g_strdup(ca_cert);
625 if (h->is_saved == TRUE) {
627 wifi_dbus *dbus_h = NULL;
628 gchar *config_id = NULL;
630 dbus_h = _wifi_get_dbus_handle();
631 if (dbus_h == NULL) {
632 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
633 return WIFI_ERROR_INVALID_OPERATION;
636 config_id = wifi_config_get_config_id(h->name, h->security_type);
638 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CACERT, ca_cert);
644 return WIFI_ERROR_NONE;
647 EXPORT_API int wifi_config_get_eap_client_cert_file(wifi_config_h config, char** client_cert)
649 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_client_cert_file");
650 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
652 struct _wifi_config *h = (struct _wifi_config *)config;
655 return WIFI_ERROR_INVALID_PARAMETER;
656 if (h->eap_config == NULL)
657 return WIFI_ERROR_INVALID_PARAMETER;
658 if (client_cert == NULL)
659 return WIFI_ERROR_INVALID_PARAMETER;
661 *client_cert = g_strdup(h->eap_config->client_cert);
663 return WIFI_ERROR_NONE;
666 EXPORT_API int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char* private_key, const char* client_cert)
668 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_client_cert_file");
669 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
671 struct _wifi_config *h = (struct _wifi_config *)config;
674 return WIFI_ERROR_INVALID_PARAMETER;
675 if (h->eap_config == NULL)
676 return WIFI_ERROR_INVALID_PARAMETER;
678 h->eap_config->private_key = g_strdup(private_key);
679 h->eap_config->client_cert = g_strdup(client_cert);
681 if (h->is_saved == TRUE) {
683 wifi_dbus *dbus_h = NULL;
684 gchar *config_id = NULL;
686 dbus_h = _wifi_get_dbus_handle();
687 if (dbus_h == NULL) {
688 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
689 return WIFI_ERROR_INVALID_OPERATION;
692 config_id = wifi_config_get_config_id(h->name, h->security_type);
694 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CLIENTCERT, client_cert);
695 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_PRIVATEKEY, private_key);
701 return WIFI_ERROR_NONE;
704 EXPORT_API int wifi_config_get_eap_identity(wifi_config_h config, char** identity)
706 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_identity");
707 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
709 struct _wifi_config *h = (struct _wifi_config *)config;
712 return WIFI_ERROR_INVALID_PARAMETER;
713 if (h->eap_config == NULL)
714 return WIFI_ERROR_INVALID_PARAMETER;
715 if (identity == NULL)
716 return WIFI_ERROR_INVALID_PARAMETER;
718 *identity = g_strdup(h->eap_config->identity);
720 return WIFI_ERROR_NONE;
723 EXPORT_API int wifi_config_set_eap_identity(wifi_config_h config, const char* identity)
725 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_identity");
726 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
728 struct _wifi_config *h = (struct _wifi_config *)config;
731 return WIFI_ERROR_INVALID_PARAMETER;
732 if (h->eap_config == NULL)
733 return WIFI_ERROR_INVALID_PARAMETER;
735 h->eap_config->identity = g_strdup(identity);
737 if (h->is_saved == TRUE) {
739 wifi_dbus *dbus_h = NULL;
740 gchar *config_id = NULL;
742 dbus_h = _wifi_get_dbus_handle();
743 if (dbus_h == NULL) {
744 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
745 return WIFI_ERROR_INVALID_OPERATION;
748 config_id = wifi_config_get_config_id(h->name, h->security_type);
750 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_IDENTITY, identity);
756 return WIFI_ERROR_NONE;
759 EXPORT_API int wifi_config_get_eap_type(wifi_config_h config, wifi_eap_type_e *eap_type)
761 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_type");
762 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
764 struct _wifi_config *h = (struct _wifi_config *)config;
767 return WIFI_ERROR_INVALID_PARAMETER;
768 if (h->eap_config == NULL)
769 return WIFI_ERROR_INVALID_PARAMETER;
770 if (eap_type == NULL)
771 return WIFI_ERROR_INVALID_PARAMETER;
773 *eap_type = h->eap_config->eap_type;
775 return WIFI_ERROR_NONE;
778 EXPORT_API int wifi_config_set_eap_type(wifi_config_h config, wifi_eap_type_e eap_type)
780 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_type");
781 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
783 struct _wifi_config *h = (struct _wifi_config *)config;
786 return WIFI_ERROR_INVALID_PARAMETER;
787 if (h->eap_config == NULL)
788 return WIFI_ERROR_INVALID_PARAMETER;
790 h->eap_config->eap_type = eap_type;
792 if (h->is_saved == TRUE) {
794 wifi_dbus *dbus_h = NULL;
795 gchar *config_id = NULL;
798 dbus_h = _wifi_get_dbus_handle();
799 if (dbus_h == NULL) {
800 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
801 return WIFI_ERROR_INVALID_OPERATION;
804 config_id = wifi_config_get_config_id(h->name, h->security_type);
806 value = wifi_eap_type_to_string(eap_type);
808 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_TYPE, value);
815 return WIFI_ERROR_NONE;
818 EXPORT_API int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e* eap_auth_type)
820 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_auth_type");
821 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
823 struct _wifi_config *h = (struct _wifi_config *)config;
826 return WIFI_ERROR_INVALID_PARAMETER;
827 if (h->eap_config == NULL)
828 return WIFI_ERROR_INVALID_PARAMETER;
829 if (eap_auth_type == NULL)
830 return WIFI_ERROR_INVALID_PARAMETER;
832 *eap_auth_type = h->eap_config->eap_auth_type;
834 return WIFI_ERROR_NONE;
837 EXPORT_API int wifi_config_set_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e eap_auth_type)
839 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_auth_type");
840 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
842 struct _wifi_config *h = (struct _wifi_config *)config;
845 return WIFI_ERROR_INVALID_PARAMETER;
846 if (h->eap_config == NULL)
847 return WIFI_ERROR_INVALID_PARAMETER;
849 h->eap_config->eap_auth_type = eap_auth_type;
851 if (h->is_saved == TRUE) {
853 wifi_dbus *dbus_h = NULL;
854 gchar *config_id = NULL;
857 dbus_h = _wifi_get_dbus_handle();
858 if (dbus_h == NULL) {
859 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
860 return WIFI_ERROR_INVALID_OPERATION;
863 config_id = wifi_config_get_config_id(h->name, h->security_type);
865 value = wifi_eap_auth_type_to_string(eap_auth_type);
867 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_AUTH_TYPE, value);
874 return WIFI_ERROR_NONE;
877 EXPORT_API int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match)
879 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_subject_match");
880 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
882 struct _wifi_config *h = (struct _wifi_config *)config;
885 return WIFI_ERROR_INVALID_PARAMETER;
886 if (h->eap_config == NULL)
887 return WIFI_ERROR_INVALID_PARAMETER;
888 if (subject_match == NULL)
889 return WIFI_ERROR_INVALID_PARAMETER;
891 *subject_match = g_strdup(h->eap_config->subject_match);
893 return WIFI_ERROR_NONE;
896 EXPORT_API int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match)
898 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_subject_match");
899 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
901 struct _wifi_config *h = (struct _wifi_config *)config;
904 return WIFI_ERROR_INVALID_PARAMETER;
905 if (h->eap_config == NULL)
906 return WIFI_ERROR_INVALID_PARAMETER;
908 h->eap_config->subject_match = g_strdup(subject_match);
910 if (h->is_saved == TRUE) {
912 wifi_dbus *dbus_h = NULL;
913 gchar *config_id = NULL;
915 dbus_h = _wifi_get_dbus_handle();
916 if (dbus_h == NULL) {
917 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
918 return WIFI_ERROR_INVALID_OPERATION;
921 config_id = wifi_config_get_config_id(h->name, h->security_type);
923 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_SUBJECT_MATCH, subject_match);
929 return WIFI_ERROR_NONE;