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
306 h->address_family = WIFI_ADDRESS_FAMILY_IPV4;
308 rv = callback((wifi_config_h)h, user_data);
310 g_free(h->proxy_address);
312 g_free(h->eap_config->ca_cert);
313 g_free(h->eap_config->client_cert);
314 g_free(h->eap_config->private_key);
315 g_free(h->eap_config->anonymous_identity);
316 g_free(h->eap_config->identity);
317 g_free(h->eap_config->subject_match);
318 g_free(h->eap_config);
327 config_ids = config_ids->next;
330 config_ids = g_slist_nth(config_ids, 0);
331 g_slist_free_full(config_ids, g_free);
333 return WIFI_ERROR_NONE;
336 EXPORT_API int wifi_config_get_name(wifi_config_h config, char **name)
338 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_name");
339 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
341 struct _wifi_config *h = (struct _wifi_config *)config;
343 if (_wifi_is_init() == false) {
344 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
345 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
348 if (config == NULL || name == NULL) {
349 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
350 return WIFI_ERROR_INVALID_PARAMETER;
354 *name = g_strdup(h->name);
358 return WIFI_ERROR_NONE;
361 EXPORT_API int wifi_config_get_security_type(wifi_config_h config, wifi_security_type_e *security_type)
363 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_security_type");
364 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
366 struct _wifi_config *h = (struct _wifi_config *)config;
368 if (_wifi_is_init() == false) {
369 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
370 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
373 if (config == NULL || security_type == NULL) {
374 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
375 return WIFI_ERROR_INVALID_PARAMETER;
378 *security_type = h->security_type;
380 return WIFI_ERROR_NONE;
384 * wifi configuration set field
386 EXPORT_API int wifi_config_set_proxy_address(wifi_config_h config, wifi_address_family_e address_family, const char *proxy_address)
388 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_proxy_address");
389 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
391 struct _wifi_config *h = (struct _wifi_config *)config;
392 int ret = WIFI_ERROR_NONE;
394 if (_wifi_is_init() == false) {
395 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
396 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
399 if (config == NULL) {
400 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
401 return WIFI_ERROR_INVALID_PARAMETER;
403 if ((address_family != WIFI_ADDRESS_FAMILY_IPV4 && address_family != WIFI_ADDRESS_FAMILY_IPV6)) {
404 WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
405 return WIFI_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
408 if (address_family == WIFI_ADDRESS_FAMILY_IPV6) {
409 WIFI_LOG(WIFI_ERROR, "Not supported yet"); //LCOV_EXCL_LINE
410 return WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; //LCOV_EXCL_LINE
413 h->address_family = address_family;
414 h->proxy_address = g_strdup(proxy_address);
416 if (h->is_saved == TRUE) {
418 wifi_dbus *dbus_h = NULL;
419 gchar *config_id = NULL;
421 dbus_h = _wifi_get_dbus_handle();
422 if (dbus_h == NULL) {
423 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
424 return WIFI_ERROR_INVALID_OPERATION;
427 config_id = wifi_config_get_config_id(h->name, h->security_type);
429 ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_PROXYADDRESS, proxy_address);
430 if (ret != WIFI_ERROR_NONE)
431 WIFI_LOG(WIFI_ERROR, "Fail to set proxy address [%d]", ret);
440 EXPORT_API int wifi_config_get_proxy_address(wifi_config_h config, wifi_address_family_e *address_family, char **proxy_address)
442 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_proxy_address");
443 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
445 struct _wifi_config *h = (struct _wifi_config *)config;
447 if (_wifi_is_init() == false) {
448 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
449 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
452 if (config == NULL || address_family == NULL || proxy_address == NULL) {
453 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
454 return WIFI_ERROR_INVALID_PARAMETER;
457 *address_family = h->address_family;
458 *proxy_address = g_strdup(h->proxy_address);
460 return WIFI_ERROR_NONE;
463 EXPORT_API int wifi_config_set_hidden_ap_property(wifi_config_h config, bool hidden)
465 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_hidden_ap_property");
466 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
468 struct _wifi_config *h = (struct _wifi_config *)config;
469 int ret = WIFI_ERROR_NONE;
471 if (_wifi_is_init() == false) {
472 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
473 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
476 if (config == NULL) {
477 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
478 return WIFI_ERROR_INVALID_PARAMETER;
481 h->is_hidden = hidden;
483 if (h->is_saved == TRUE) {
485 wifi_dbus *dbus_h = NULL;
486 char *config_id = NULL;
489 dbus_h = _wifi_get_dbus_handle();
490 if (dbus_h == NULL) {
491 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
492 return WIFI_ERROR_INVALID_OPERATION;
495 config_id = wifi_config_get_config_id(h->name, h->security_type);
497 if (h->is_hidden == TRUE)
498 hidden = g_strdup("TRUE");
500 hidden = g_strdup("FALSE");
502 ret = wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_HIDDEN, hidden);
503 if (ret != WIFI_ERROR_NONE)
504 WIFI_LOG(WIFI_ERROR, "Fail to set hidden [%d]", ret);
514 EXPORT_API int wifi_config_get_hidden_ap_property(wifi_config_h config, bool *hidden)
516 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_hidden_ap_property");
517 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
519 struct _wifi_config *h = (struct _wifi_config *)config;
521 if (_wifi_is_init() == false) {
522 WIFI_LOG(WIFI_ERROR, "Not initialized"); //LCOV_EXCL_LINE
523 return WIFI_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
526 if (config == NULL || hidden == NULL) {
527 WIFI_LOG(WIFI_ERROR, "Invalid parameter");
528 return WIFI_ERROR_INVALID_PARAMETER;
531 *hidden = h->is_hidden;
533 return WIFI_ERROR_NONE;
536 EXPORT_API int wifi_config_get_eap_anonymous_identity(wifi_config_h config, char** anonymous_identity)
538 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_anonymous_identity");
539 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
541 struct _wifi_config *h = (struct _wifi_config *)config;
544 return WIFI_ERROR_INVALID_PARAMETER;
545 if (h->eap_config == NULL)
546 return WIFI_ERROR_INVALID_PARAMETER;
547 if (anonymous_identity == NULL)
548 return WIFI_ERROR_INVALID_PARAMETER;
550 *anonymous_identity = g_strdup(h->eap_config->anonymous_identity);
552 return WIFI_ERROR_NONE;
555 EXPORT_API int wifi_config_set_eap_anonymous_identity(wifi_config_h config, const char* anonymous_identity)
557 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_anonymous_identity");
558 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
560 struct _wifi_config *h = (struct _wifi_config *)config;
563 return WIFI_ERROR_INVALID_PARAMETER;
564 if (h->eap_config == NULL)
565 return WIFI_ERROR_INVALID_PARAMETER;
567 h->eap_config->anonymous_identity = g_strdup(anonymous_identity);
569 if (h->is_saved == TRUE) {
571 wifi_dbus *dbus_h = NULL;
572 gchar *config_id = NULL;
574 dbus_h = _wifi_get_dbus_handle();
575 if (dbus_h == NULL) {
576 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
577 return WIFI_ERROR_INVALID_OPERATION;
580 config_id = wifi_config_get_config_id(h->name, h->security_type);
582 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, anonymous_identity);
588 return WIFI_ERROR_NONE;
591 EXPORT_API int wifi_config_get_eap_ca_cert_file(wifi_config_h config, char** ca_cert)
593 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_ca_cert_file");
594 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
596 struct _wifi_config *h = (struct _wifi_config *)config;
599 return WIFI_ERROR_INVALID_PARAMETER;
600 if (h->eap_config == NULL)
601 return WIFI_ERROR_INVALID_PARAMETER;
603 return WIFI_ERROR_INVALID_PARAMETER;
605 *ca_cert = g_strdup(h->eap_config->ca_cert);
607 return WIFI_ERROR_NONE;
610 EXPORT_API int wifi_config_set_eap_ca_cert_file(wifi_config_h config, const char* ca_cert)
612 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_ca_cert_file");
613 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
615 struct _wifi_config *h = (struct _wifi_config *)config;
618 return WIFI_ERROR_INVALID_PARAMETER;
619 if (h->eap_config == NULL)
620 return WIFI_ERROR_INVALID_PARAMETER;
622 h->eap_config->ca_cert = g_strdup(ca_cert);
624 if (h->is_saved == TRUE) {
626 wifi_dbus *dbus_h = NULL;
627 gchar *config_id = NULL;
629 dbus_h = _wifi_get_dbus_handle();
630 if (dbus_h == NULL) {
631 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
632 return WIFI_ERROR_INVALID_OPERATION;
635 config_id = wifi_config_get_config_id(h->name, h->security_type);
637 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CACERT, ca_cert);
643 return WIFI_ERROR_NONE;
646 EXPORT_API int wifi_config_get_eap_client_cert_file(wifi_config_h config, char** client_cert)
648 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_client_cert_file");
649 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
651 struct _wifi_config *h = (struct _wifi_config *)config;
654 return WIFI_ERROR_INVALID_PARAMETER;
655 if (h->eap_config == NULL)
656 return WIFI_ERROR_INVALID_PARAMETER;
657 if (client_cert == NULL)
658 return WIFI_ERROR_INVALID_PARAMETER;
660 *client_cert = g_strdup(h->eap_config->client_cert);
662 return WIFI_ERROR_NONE;
665 EXPORT_API int wifi_config_set_eap_client_cert_file(wifi_config_h config, const char* private_key, const char* client_cert)
667 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_client_cert_file");
668 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
670 struct _wifi_config *h = (struct _wifi_config *)config;
673 return WIFI_ERROR_INVALID_PARAMETER;
674 if (h->eap_config == NULL)
675 return WIFI_ERROR_INVALID_PARAMETER;
677 h->eap_config->private_key = g_strdup(private_key);
678 h->eap_config->client_cert = g_strdup(client_cert);
680 if (h->is_saved == TRUE) {
682 wifi_dbus *dbus_h = NULL;
683 gchar *config_id = NULL;
685 dbus_h = _wifi_get_dbus_handle();
686 if (dbus_h == NULL) {
687 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
688 return WIFI_ERROR_INVALID_OPERATION;
691 config_id = wifi_config_get_config_id(h->name, h->security_type);
693 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_CLIENTCERT, client_cert);
694 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_PRIVATEKEY, private_key);
700 return WIFI_ERROR_NONE;
703 EXPORT_API int wifi_config_get_eap_identity(wifi_config_h config, char** identity)
705 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_identity");
706 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
708 struct _wifi_config *h = (struct _wifi_config *)config;
711 return WIFI_ERROR_INVALID_PARAMETER;
712 if (h->eap_config == NULL)
713 return WIFI_ERROR_INVALID_PARAMETER;
714 if (identity == NULL)
715 return WIFI_ERROR_INVALID_PARAMETER;
717 *identity = g_strdup(h->eap_config->identity);
719 return WIFI_ERROR_NONE;
722 EXPORT_API int wifi_config_set_eap_identity(wifi_config_h config, const char* identity)
724 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_identity");
725 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
727 struct _wifi_config *h = (struct _wifi_config *)config;
730 return WIFI_ERROR_INVALID_PARAMETER;
731 if (h->eap_config == NULL)
732 return WIFI_ERROR_INVALID_PARAMETER;
734 h->eap_config->identity = g_strdup(identity);
736 if (h->is_saved == TRUE) {
738 wifi_dbus *dbus_h = NULL;
739 gchar *config_id = NULL;
741 dbus_h = _wifi_get_dbus_handle();
742 if (dbus_h == NULL) {
743 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
744 return WIFI_ERROR_INVALID_OPERATION;
747 config_id = wifi_config_get_config_id(h->name, h->security_type);
749 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_IDENTITY, identity);
755 return WIFI_ERROR_NONE;
758 EXPORT_API int wifi_config_get_eap_type(wifi_config_h config, wifi_eap_type_e *eap_type)
760 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_type");
761 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
763 struct _wifi_config *h = (struct _wifi_config *)config;
766 return WIFI_ERROR_INVALID_PARAMETER;
767 if (h->eap_config == NULL)
768 return WIFI_ERROR_INVALID_PARAMETER;
769 if (eap_type == NULL)
770 return WIFI_ERROR_INVALID_PARAMETER;
772 *eap_type = h->eap_config->eap_type;
774 return WIFI_ERROR_NONE;
777 EXPORT_API int wifi_config_set_eap_type(wifi_config_h config, wifi_eap_type_e eap_type)
779 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_type");
780 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
782 struct _wifi_config *h = (struct _wifi_config *)config;
785 return WIFI_ERROR_INVALID_PARAMETER;
786 if (h->eap_config == NULL)
787 return WIFI_ERROR_INVALID_PARAMETER;
789 h->eap_config->eap_type = eap_type;
791 if (h->is_saved == TRUE) {
793 wifi_dbus *dbus_h = NULL;
794 gchar *config_id = NULL;
797 dbus_h = _wifi_get_dbus_handle();
798 if (dbus_h == NULL) {
799 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
800 return WIFI_ERROR_INVALID_OPERATION;
803 config_id = wifi_config_get_config_id(h->name, h->security_type);
805 value = wifi_eap_type_to_string(eap_type);
807 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_TYPE, value);
814 return WIFI_ERROR_NONE;
817 EXPORT_API int wifi_config_get_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e* eap_auth_type)
819 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_auth_type");
820 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
822 struct _wifi_config *h = (struct _wifi_config *)config;
825 return WIFI_ERROR_INVALID_PARAMETER;
826 if (h->eap_config == NULL)
827 return WIFI_ERROR_INVALID_PARAMETER;
828 if (eap_auth_type == NULL)
829 return WIFI_ERROR_INVALID_PARAMETER;
831 *eap_auth_type = h->eap_config->eap_auth_type;
833 return WIFI_ERROR_NONE;
836 EXPORT_API int wifi_config_set_eap_auth_type(wifi_config_h config, wifi_eap_auth_type_e eap_auth_type)
838 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_auth_type");
839 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
841 struct _wifi_config *h = (struct _wifi_config *)config;
844 return WIFI_ERROR_INVALID_PARAMETER;
845 if (h->eap_config == NULL)
846 return WIFI_ERROR_INVALID_PARAMETER;
848 h->eap_config->eap_auth_type = eap_auth_type;
850 if (h->is_saved == TRUE) {
852 wifi_dbus *dbus_h = NULL;
853 gchar *config_id = NULL;
856 dbus_h = _wifi_get_dbus_handle();
857 if (dbus_h == NULL) {
858 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
859 return WIFI_ERROR_INVALID_OPERATION;
862 config_id = wifi_config_get_config_id(h->name, h->security_type);
864 value = wifi_eap_auth_type_to_string(eap_auth_type);
866 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_AUTH_TYPE, value);
873 return WIFI_ERROR_NONE;
876 EXPORT_API int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match)
878 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_get_eap_subject_match");
879 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
881 struct _wifi_config *h = (struct _wifi_config *)config;
884 return WIFI_ERROR_INVALID_PARAMETER;
885 if (h->eap_config == NULL)
886 return WIFI_ERROR_INVALID_PARAMETER;
887 if (subject_match == NULL)
888 return WIFI_ERROR_INVALID_PARAMETER;
890 *subject_match = g_strdup(h->eap_config->subject_match);
892 return WIFI_ERROR_NONE;
895 EXPORT_API int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match)
897 DEPRECATED_LOG(__FUNCTION__, "wifi_manager_config_set_eap_subject_match");
898 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
900 struct _wifi_config *h = (struct _wifi_config *)config;
903 return WIFI_ERROR_INVALID_PARAMETER;
904 if (h->eap_config == NULL)
905 return WIFI_ERROR_INVALID_PARAMETER;
907 h->eap_config->subject_match = g_strdup(subject_match);
909 if (h->is_saved == TRUE) {
911 wifi_dbus *dbus_h = NULL;
912 gchar *config_id = NULL;
914 dbus_h = _wifi_get_dbus_handle();
915 if (dbus_h == NULL) {
916 WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
917 return WIFI_ERROR_INVALID_OPERATION;
920 config_id = wifi_config_get_config_id(h->name, h->security_type);
922 wifi_configuration_set_field(dbus_h, config_id, WIFI_CONFIG_EAP_SUBJECT_MATCH, subject_match);
928 return WIFI_ERROR_NONE;