2 * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
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.
20 #include "sa_common.h"
22 #include "setup_network.h"
23 #include "input_file.h"
24 #include "net_connection.h"
25 #include "wifi-manager.h"
28 wifi_manager_h wifi_h;
34 static char *__print_connection_state(sa_network_state_e state)
37 case SA_NETWORK_STATE_DISCONNECTED:
38 return "Disconnected";
39 case SA_NETWORK_STATE_PROGRESSING:
41 case SA_NETWORK_STATE_CONNECTED:
48 static const char *__print_wifi_state(connection_wifi_state_e state)
51 case CONNECTION_WIFI_STATE_DEACTIVATED:
53 case CONNECTION_WIFI_STATE_DISCONNECTED:
54 return "Disconnected";
55 case CONNECTION_WIFI_STATE_CONNECTED:
62 static const char *__print_error(connection_error_e error)
65 case CONNECTION_ERROR_NONE:
66 return "CONNECTION_ERROR_NONE";
67 case CONNECTION_ERROR_INVALID_PARAMETER:
68 return "CONNECTION_ERROR_INVALID_PARAMETER";
69 case CONNECTION_ERROR_OUT_OF_MEMORY:
70 return "CONNECTION_ERROR_OUT_OF_MEMORY";
71 case CONNECTION_ERROR_INVALID_OPERATION:
72 return "CONNECTION_ERROR_INVALID_OPERATION";
73 case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
74 return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
75 case CONNECTION_ERROR_OPERATION_FAILED:
76 return "CONNECTION_ERROR_OPERATION_FAILED";
77 case CONNECTION_ERROR_ITERATOR_END:
78 return "CONNECTION_ERROR_ITERATOR_END";
79 case CONNECTION_ERROR_NO_CONNECTION:
80 return "CONNECTION_ERROR_NO_CONNECTION";
81 case CONNECTION_ERROR_NOW_IN_PROGRESS:
82 return "CONNECTION_ERROR_NOW_IN_PROGRESS";
83 case CONNECTION_ERROR_ALREADY_EXISTS:
84 return "CONNECTION_ERROR_ALREADY_EXISTS";
85 case CONNECTION_ERROR_OPERATION_ABORTED:
86 return "CONNECTION_ERROR_OPERATION_ABORTED";
87 case CONNECTION_ERROR_DHCP_FAILED:
88 return "CONNECTION_ERROR_DHCP_FAILED";
89 case CONNECTION_ERROR_INVALID_KEY:
90 return "CONNECTION_ERROR_INVALID_KEY";
91 case CONNECTION_ERROR_NO_REPLY:
92 return "CONNECTION_ERROR_NO_REPLY";
93 case CONNECTION_ERROR_PERMISSION_DENIED:
94 return "CONNECTION_ERROR_PERMISSION_DENIED";
95 case CONNECTION_ERROR_NOT_SUPPORTED:
96 return "CONNECTION_ERROR_NOT_SUPPORTED";
98 return "CONNECTION_ERROR_UNKNOWN";
102 static const char *__print_connection_type(connection_type_e type)
105 case CONNECTION_TYPE_DISCONNECTED:
106 return "Disconnected";
107 case CONNECTION_TYPE_WIFI:
109 case CONNECTION_TYPE_CELLULAR:
111 case CONNECTION_TYPE_ETHERNET:
113 case CONNECTION_TYPE_BT:
115 case CONNECTION_TYPE_NET_PROXY:
122 static const char *__print_network_type(sa_network_type_e type)
125 case SA_NETWORK_TYPE_ETH:
127 case SA_NETWORK_TYPE_WIFI:
134 static const char *__print_wifi_error(wifi_manager_error_e err_type)
137 case WIFI_MANAGER_ERROR_NONE:
139 case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
140 return "INVALID_PARAMETER";
141 case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
142 return "OUT_OF_MEMORY";
143 case WIFI_MANAGER_ERROR_INVALID_OPERATION:
144 return "INVALID_OPERATION";
145 case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
146 return "ADDRESS_FAMILY_NOT_SUPPORTED";
147 case WIFI_MANAGER_ERROR_OPERATION_FAILED:
148 return "OPERATION_FAILED";
149 case WIFI_MANAGER_ERROR_NO_CONNECTION:
150 return "NO_CONNECTION";
151 case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
152 return "NOW_IN_PROGRESS";
153 case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
154 return "ALREADY_EXISTS";
155 case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
156 return "OPERATION_ABORTED";
157 case WIFI_MANAGER_ERROR_DHCP_FAILED:
158 return "DHCP_FAILED";
159 case WIFI_MANAGER_ERROR_INVALID_KEY:
160 return "INVALID_KEY";
161 case WIFI_MANAGER_ERROR_OUT_OF_RANGE:
162 return "OUT_OF_RANGE";
163 case WIFI_MANAGER_ERROR_PIN_MISSING:
164 return "PIN_MISSING";
165 case WIFI_MANAGER_ERROR_CONNECT_FAILED:
166 return "CONNECT_FAILED";
167 case WIFI_MANAGER_ERROR_LOGIN_FAILED:
168 return "LOGIN_FAILED";
169 case WIFI_MANAGER_ERROR_AUTHENTICATION_FAILED:
170 return "AUTH_FAILED";
171 case WIFI_MANAGER_ERROR_NO_REPLY:
173 case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
174 return "SECURITY_RESTRICTED";
175 case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
176 return "ALREADY_INITIALIZED";
177 case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
178 return "PERMISSION_DENIED";
179 case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
180 return "NOT_SUPPORTED";
181 case WIFI_MANAGER_ERROR_WPS_OVERLAP:
182 return "WPS_OVERLAP";
183 case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
184 return "WPS_TIMEOUT";
185 case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
186 return "WPS_WEP_PROHIBITED";
192 static void __wifi_exit_loop(_wifi_data_s * wifi_data)
194 _D("__wifi_exit_loop !!!");
196 g_main_loop_quit((GMainLoop *) wifi_data->loop);
199 static void __wifi_connected_cb(wifi_manager_error_e result, void *user_data)
201 _wifi_data_s *wifi_data = (_wifi_data_s *) user_data;
203 if (result == WIFI_MANAGER_ERROR_NONE)
204 _D("__wifi_connected_cb() connected Successfully !!!");
206 _D("__wifi_connected_cb() connection Failed!(%s)", __print_wifi_error(result));
208 __wifi_exit_loop(wifi_data);
211 // CAUTION : this callback function should be boolean type.
212 // return true : continue search ap (not found)
213 // return false : stop search ap (found)
214 static bool __wifi_connect_ap_cb(wifi_manager_ap_h ap, void *user_data)
216 _wifi_data_s *wifi_data = (_wifi_data_s *) user_data;
218 _D("__wifi_connect_ap_cb()");
221 char *ap_name = NULL;
223 rv = wifi_manager_ap_get_essid(ap, &ap_name);
224 if (rv != WIFI_MANAGER_ERROR_NONE) {
225 _D("Fail to get AP name [%s]", __print_wifi_error((wifi_manager_error_e) rv));
229 _D("AP name = [%s]/[%s]", ap_name, wifi_data->ssid);
232 if (g_strcmp0(ap_name, wifi_data->ssid) == 0) {
233 bool required = FALSE;
235 _D("OK!!! connect AP [%s]", ap_name);
237 rv = wifi_manager_ap_is_passphrase_required(ap, &required);
239 if (rv == WIFI_MANAGER_ERROR_NONE) {
241 _D(" passphrase1 : [%s]", wifi_data->password);
242 rv = wifi_manager_ap_set_passphrase(ap, wifi_data->password);
243 if (rv != WIFI_MANAGER_ERROR_NONE) {
244 _D("Fail to set passphrase : %s", __print_wifi_error(rv));
245 __wifi_exit_loop(wifi_data);
248 if (rv == WIFI_MANAGER_ERROR_NONE) {
249 rv = wifi_manager_connect(wifi_data->wifi_h, ap, __wifi_connected_cb, wifi_data);
250 if (rv != WIFI_MANAGER_ERROR_NONE) {
251 _D("Fail to connection request [%s] : %s", ap_name, __print_wifi_error(rv));
252 __wifi_exit_loop(wifi_data);
254 _D("Success to connection request [%s]", ap_name);
258 _D("Fail to passphrase_required request [%s]", __print_wifi_error(rv));
259 __wifi_exit_loop(wifi_data);
270 static void __wifi_scan_finished_cb(wifi_manager_error_e result, void *user_data)
273 _wifi_data_s *wifi_data = (_wifi_data_s *) user_data;
275 _D("__wifi_scan_finished_cb() result=[%s]", __print_wifi_error(result));
277 rv = wifi_manager_foreach_found_ap(wifi_data->wifi_h, __wifi_connect_ap_cb, wifi_data);
279 if (rv != WIFI_MANAGER_ERROR_NONE)
280 _E("Fail to connect (can't get AP list) [%s]", __print_wifi_error(rv));
282 _D("Connection step finished");
283 // If ssid is not able to find, setup-adaptor service will be completed by systemd
286 static void __wifi_state_changed_cb(wifi_manager_device_state_e state, void *user_data)
288 _wifi_data_s *wifi_data = (_wifi_data_s *) user_data;
290 _D("__wifi_state_changed_cb() state=[%d]", state);
292 if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
293 wifi_manager_scan(wifi_data->wifi_h, __wifi_scan_finished_cb, wifi_data);
294 wifi_manager_unset_device_state_changed_cb(wifi_data->wifi_h);
298 static void __wifi_activate_cb(wifi_manager_error_e result, void *user_data)
300 _D("__wifi_activate_cb() result=[%s]", __print_wifi_error(result));
303 static int __wifi_connect_main(sa_wifi_s * info)
305 GMainLoop *gmain_loop = NULL;
306 GMainContext *context;
308 _wifi_data_s wifi_data = { 0, };
311 sa_error_e ret = SA_ERROR_NONE;
312 wifi_manager_h wifi_h = NULL;
314 _D("__wifi_connect_main (ssid=%s, pw=%s)", info->ssid, info->password);
317 _E("invalid input (sa_wifi_s*)");
321 context = g_main_context_new();
323 if (context != NULL) {
324 g_main_context_push_thread_default(context); // should be.. to get mainloop message in thread
325 gmain_loop = g_main_loop_new(context, FALSE);
327 if (gmain_loop != NULL) {
328 rv = wifi_manager_initialize(&wifi_h);
330 if (rv == WIFI_MANAGER_ERROR_NONE) {
331 // fill the token data
332 wifi_data.ssid = info->ssid;
333 wifi_data.password = info->password;
334 wifi_data.loop = gmain_loop;
335 wifi_data.wifi_h = wifi_h;
337 rv = wifi_manager_set_device_state_changed_cb(wifi_h, __wifi_state_changed_cb, (void *)&wifi_data);
338 if (rv == WIFI_MANAGER_ERROR_NONE) {
339 rv = wifi_manager_activate(wifi_h, __wifi_activate_cb, NULL);
340 if (rv == WIFI_MANAGER_ERROR_ALREADY_EXISTS) {
341 _D("wifi_manager_active alreay exists");
342 wifi_manager_scan(wifi_h, __wifi_scan_finished_cb, (void *)&wifi_data);
343 } else if (rv != WIFI_MANAGER_ERROR_NONE) {
344 _E("wifi_manager_activated failed.[%s]", __print_wifi_error(rv));
345 ret = SA_ERROR_UNKNOWN;
348 ret = SA_ERROR_UNKNOWN;
349 _E("wifi_manager_set_device_state_changed_cb error");
352 ret = SA_ERROR_UNKNOWN;
353 _E("Wifi init failed [%s]", __print_wifi_error(rv));
356 if (ret == SA_ERROR_NONE)
357 g_main_loop_run(gmain_loop);
359 g_main_loop_unref(gmain_loop);
360 g_main_context_unref(context);
362 if (wifi_h != NULL) {
363 wifi_manager_unset_scan_state_changed_cb(wifi_h);
364 wifi_manager_unset_connection_state_changed_cb(wifi_h);
370 if (wifi_h != NULL) {
371 rv = wifi_manager_deinitialize(wifi_h);
372 if (rv != WIFI_MANAGER_ERROR_NONE) {
373 _D("Fail to deinitialize.");
374 ret = SA_ERROR_UNKNOWN;
378 g_main_context_unref(context);
379 _E("Fail to create g_main_loop");
382 _E("Fail to create g_main_context");
385 _D("__wifi_connect_main completed.");
390 connection_h eth_connect;
392 static bool __eth_get_user_selected_profile(connection_profile_h * profile, bool select)
396 connection_profile_type_e profile_type;
397 connection_profile_state_e profile_state;
398 connection_profile_iterator_h profile_iter;
399 connection_profile_h profile_h;
401 rv = connection_get_profile_iterator(eth_connect, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
402 if (rv != CONNECTION_ERROR_NONE) {
403 printf("Fail to get profile iterator error\n");
407 while (connection_profile_iterator_has_next(profile_iter)) {
408 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
409 printf("Fail to get profile handle\n");
413 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
414 printf("Fail to get profile name\n");
418 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
419 printf("Fail to get profile type\n");
420 g_free(profile_name);
424 if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) {
425 printf("Fail to get profile state\n");
426 g_free(profile_name);
430 if (!strncmp(profile_name, "eth0", strlen("eth0"))) {
431 printf("profile > %s\n", profile_name);
433 *profile = profile_h;
435 g_free(profile_name);
441 static int __eth_update_ip_info(sa_eth_s * info, connection_profile_h profile, connection_address_family_e address_family)
445 _D("ipaddress =%s", info->staticInfo->ipAddress);
446 if (strlen(info->staticInfo->ipAddress) > 0) {
447 rv = connection_profile_set_ip_address(profile, address_family, info->staticInfo->ipAddress);
448 if (rv != CONNECTION_ERROR_NONE)
452 _D("netmask =%s", info->staticInfo->netmask);
453 if (strlen(info->staticInfo->netmask) > 0) {
454 rv = connection_profile_set_subnet_mask(profile, address_family, info->staticInfo->netmask);
455 if (rv != CONNECTION_ERROR_NONE)
460 if (strlen(info->staticInfo->defaultGateway) > 0) {
461 rv = connection_profile_set_gateway_address(profile, address_family, info->staticInfo->defaultGateway);
462 if (rv != CONNECTION_ERROR_NONE)
464 _D("gateway =%s", info->staticInfo->defaultGateway);
466 if (strlen(info->staticInfo->primaryDnsServer) > 0) {
467 rv = connection_profile_set_dns_address(profile, 1, address_family, info->staticInfo->primaryDnsServer);
468 if (rv != CONNECTION_ERROR_NONE)
471 _D("DNS 1 =%s", info->staticInfo->primaryDnsServer);
473 if (strlen(info->staticInfo->secondaryDnsServer) > 0) {
474 rv = connection_profile_set_dns_address(profile, 2, address_family, info->staticInfo->secondaryDnsServer);
475 if (rv != CONNECTION_ERROR_NONE)
477 _D("DNS 2 =%s", info->staticInfo->secondaryDnsServer);
484 static int __eth_update_ip(sa_eth_s * info)
488 connection_profile_type_e prof_type;
489 connection_profile_h profile = NULL;
490 int address_family = 0; // IPv4
492 //printf("\n** Choose a profile to update. **\n");
493 if (__eth_get_user_selected_profile(&profile, true) == false) {
494 _D("profile failed \n");
498 // If ethernet cable is detached, it should be retried after rebooting.
499 // return 1 is retry case, 0 is non-error and -1 is error to be completed
500 ret = connection_profile_get_type(profile, &prof_type);
501 if (ret == CONNECTION_ERROR_INVALID_PARAMETER) {
502 _D("profile connection error!! [%d]", ret);
504 } else if (ret != CONNECTION_ERROR_NONE) {
508 if (connection_profile_set_ip_config_type(profile, address_family, CONNECTION_IP_CONFIG_TYPE_STATIC) != CONNECTION_ERROR_NONE) {
509 _D("setting error !!\n");
512 if (__eth_update_ip_info(info, profile, address_family) != 1) {
513 _D("ip setting error!!\n");
517 if (connection_profile_set_proxy_type(profile, CONNECTION_PROXY_TYPE_DIRECT) != CONNECTION_ERROR_NONE)
520 if (connection_update_profile(eth_connect, profile) != CONNECTION_ERROR_NONE) {
521 _D("profile update error !!\n");
525 _D("operation sucess\n");
529 static int __eth_register_client(void)
532 if (CONNECTION_ERROR_NONE != connection_create(ð_connect)) {
533 _D("Client registration failed \n");
537 _D("Client registration success\n");
541 static int __eth_deregister_client(void)
545 if (eth_connect != NULL)
546 rv = connection_destroy(eth_connect);
548 _D("Cannot deregister : Handle is NULL\n");
549 rv = CONNECTION_ERROR_INVALID_OPERATION;
552 if (rv != CONNECTION_ERROR_NONE) {
553 _D("Client deregistration fail\n");
558 _D("Client deregistration success\n");
563 static int __ethernet_connect_main(sa_eth_s * info)
570 if (__eth_register_client() == 1) {
571 ret = __eth_update_ip(info);
573 __eth_deregister_client();
575 _D("connection error!!!\n");
580 static int __network_get_wifi_state(connection_h connection, connection_wifi_state_e * wifi_state)
584 if (connection == NULL)
587 rv = connection_get_wifi_state(connection, wifi_state);
588 if (rv != CONNECTION_ERROR_NONE)
589 _D("Fail to get WiFi state [%s]", __print_error(rv));
591 _D("Retval = [%s] WiFi state [%s]", __print_error(rv), __print_wifi_state(*wifi_state));
596 static sa_error_e __network_get_state(sa_network_state_e * conn_state, sa_network_type_e * conn_type)
598 connection_h connection = NULL;
599 sa_error_e ret = SA_ERROR_UNKNOWN;
600 connection_type_e net_state;
601 connection_wifi_state_e wifi_state;
604 rv = connection_create(&connection);
605 if (rv != CONNECTION_ERROR_NONE) {
606 _E("create connection handle error [%s]", __print_error(rv));
609 // check network state(eth/wifi)
610 rv = connection_get_type(connection, &net_state);
611 if (rv != CONNECTION_ERROR_NONE) {
612 _E("Fail to get network state [%s]", __print_error(rv));
615 _D("Retval = [%s] network connection state [%s]", __print_error(rv), __print_connection_type(net_state));
616 if (CONNECTION_TYPE_DISCONNECTED == net_state) {
617 *conn_state = SA_NETWORK_STATE_DISCONNECTED;
618 } else if (CONNECTION_TYPE_WIFI == net_state) {
619 *conn_type = SA_NETWORK_TYPE_WIFI;
621 if (!__network_get_wifi_state(connection, &wifi_state)) {
622 if (wifi_state == CONNECTION_WIFI_STATE_CONNECTED)
623 *conn_state = SA_NETWORK_STATE_CONNECTED;
625 *conn_state = SA_NETWORK_STATE_DISCONNECTED;
627 } else if (CONNECTION_TYPE_ETHERNET == net_state) {
628 *conn_type = SA_NETWORK_TYPE_ETH;
629 *conn_state = SA_NETWORK_STATE_CONNECTED;
631 *conn_state = SA_NETWORK_STATE_UNKNOWN;
632 *conn_type = SA_NETWORK_TYPE_NONE;
636 rv = connection_destroy(connection);
637 if (rv != CONNECTION_ERROR_NONE) {
638 _E("connection destroy fail [%s]", __print_error(rv));
645 extern void sa_inputfile_flag(void);
647 static sa_error_e __network_connect(sa_network_s * info)
649 sa_error_e ret = SA_ERROR_NONE;
654 return SA_ERROR_INVALID_PARAMETER;
656 if (info->wifi != NULL) {
657 _D("----------- wifi info -----------");
658 _D("info|wifi|enabled(%d)", info->wifi->enabled);
659 _D("info|wifi|dhcpEnabled(%d)", info->wifi->dhcpEnabled);
660 _D("info|wifi|ssid(%s)", info->wifi->ssid);
661 _D("info|wifi|password(%s)", info->wifi->password);
662 if (info->wifi->staticInfo != NULL) {
663 _D("info|wifi|staticInfo|ipAddress(%s)", info->wifi->staticInfo->ipAddress);
664 _D("info|wifi|staticInfo|netmask(%s)", info->wifi->staticInfo->netmask);
665 _D("info|wifi|staticInfo|defaultGateway(%s)", info->wifi->staticInfo->defaultGateway);
666 _D("info|wifi|staticInfo|primaryDnsServer(%s)", info->wifi->staticInfo->primaryDnsServer);
667 _D("info|wifi|staticInfo|secondaryDnsServer(%s)", info->wifi->staticInfo->secondaryDnsServer);
671 if (info->eth != NULL) {
672 _D("----------- ethernet info -----------");
673 _D("info|eth|enabled(%d)", info->eth->enabled);
674 _D("info|eth|dhcpEnabled(%d)", info->eth->dhcpEnabled);
675 if (info->eth->staticInfo != NULL) {
676 _D("info|eth|staticInfo|ipAddress(%s)", info->eth->staticInfo->ipAddress);
677 _D("info|eth|staticInfo|netmask(%s)", info->eth->staticInfo->netmask);
678 _D("info|eth|staticInfo|defaultGateway(%s)", info->eth->staticInfo->defaultGateway);
679 _D("info|eth|staticInfo|primaryDnsServer(%s)", info->eth->staticInfo->primaryDnsServer);
680 _D("info|eth|staticInfo|secondaryDnsServer(%s)", info->eth->staticInfo->secondaryDnsServer);
684 if (info->eth != NULL) {
685 // decide whether it will be set according to policy
686 if ((info->eth->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET)) {
687 retEth = __ethernet_connect_main(info->eth);
688 _D("return ethernet [%d]", retEth);
690 _D("retry after rebooting, do not remove completion flag");
692 sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET);
694 // if eth info is null, ethernet completion flag is set
695 sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET);
698 // if eth info is null, ethernet completion flag is set
699 sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET);
702 if (info->wifi != NULL) {
703 if ((info->wifi->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI)) {
704 retWifi = __wifi_connect_main(info->wifi);
706 _D("return wifi [%d]", retWifi);
708 _D("wifi enabled flag is false");
711 sa_inputfile_set_completion_flag(SA_FILE_CONFIG_WIFI);
716 sa_error_e sa_setup_network(sa_network_s * network)
718 sa_error_e ret = SA_ERROR_NONE;
720 if (network == NULL) {
721 _E("__set_network is null");
722 return SA_ERROR_INVALID_PARAMETER;
724 // 1. check network state
725 // 2. if it is connected, read detail info
726 ret = __network_connect(network);