Release 2.0 beta
[framework/connectivity/libnet-client.git] / src / network-internal.c
1 /*
2  *  Network Client Library
3  *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.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
9
10 * http://www.tizenopensource.org/license
11
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.
17  *
18  */
19
20
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif /* __cplusplus */
25
26 /*****************************************************************************
27  *      Standard headers
28  *****************************************************************************/
29 #include <stdio.h> 
30 #include <errno.h> 
31 #include <stdlib.h> 
32 #include <string.h> 
33 #include <glib.h>
34
35 #include <dbus/dbus.h> 
36
37 #include <sys/types.h>
38 #include <sys/wait.h>
39
40 #include <fcntl.h>
41 #include <sys/ioctl.h>
42 #include <net/if.h>
43 #include <net/if_arp.h>
44 #include <linux/if_ether.h>
45
46 /*****************************************************************************
47  *      Platform headers
48  *****************************************************************************/
49
50 #include "network-internal.h"
51 #include "network-dbus-request.h"
52
53 /*****************************************************************************
54  *      Macros and Typedefs
55  *****************************************************************************/
56
57 /*****************************************************************************
58  *      Local Functions Declaration
59  *****************************************************************************/
60
61 /*****************************************************************************
62  *      Global Functions
63  *****************************************************************************/
64
65 /*****************************************************************************
66  *      Extern Global Variables
67  *****************************************************************************/
68 extern network_info_t NetworkInfo;
69
70 /*****************************************************************************
71  *      Global Variables
72  *****************************************************************************/
73
74 /** set all request to FALSE (0) */
75 network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = {{0, }, };
76
77 struct {
78         pthread_mutex_t callback_mutex;
79         pthread_mutex_t wifi_state_mutex;
80 } networkinfo_mutex;
81
82 /*****************************************************************************
83  *      Local Functions Definition
84  *****************************************************************************/
85
86 char *__convert_eap_type_to_string(gchar eap_type)
87 {
88         switch (eap_type) {
89         case WLAN_SEC_EAP_TYPE_PEAP:
90                 return "peap";
91
92         case WLAN_SEC_EAP_TYPE_TLS:
93                 return "tls";
94
95         case WLAN_SEC_EAP_TYPE_TTLS:
96                 return "ttls";
97
98         case WLAN_SEC_EAP_TYPE_SIM:
99                 return "sim";
100
101         case WLAN_SEC_EAP_TYPE_AKA:
102                 return "aka";
103
104         default:
105                 return NULL;
106         }
107 }
108
109 char *__convert_eap_auth_to_string(gchar eap_auth)
110 {
111         switch (eap_auth) {
112         case WLAN_SEC_EAP_AUTH_NONE:
113                 return "NONE";
114
115         case WLAN_SEC_EAP_AUTH_PAP:
116                 return "PAP";
117
118         case WLAN_SEC_EAP_AUTH_MSCHAP:
119                 return "MSCHAP";
120
121         case WLAN_SEC_EAP_AUTH_MSCHAPV2:
122                 return "MSCHAPV2";
123
124         case WLAN_SEC_EAP_AUTH_GTC:
125                 return "GTC";
126
127         case WLAN_SEC_EAP_AUTH_MD5:
128                 return "MD5";
129
130         default:
131                 return NULL;
132         }
133 }
134
135 /*****************************************************************************
136  *      Global Functions Definition
137  *****************************************************************************/
138
139 char* _net_print_error(net_err_t error)
140 {
141         switch (error) {
142                 /** No error */
143         case NET_ERR_NONE:
144                 return "NET_ERR_NONE";
145
146                 /* Common Error value */
147
148                 /** Error unknown */
149         case NET_ERR_UNKNOWN:
150                 return "NET_ERR_UNKNOWN";
151
152                 /* Client Register related Errors used in API return */
153
154                 /** Application is already registered */
155         case NET_ERR_APP_ALREADY_REGISTERED:
156                 return "NET_ERR_APP_ALREADY_REGISTERED";
157                 /** Application is not registered */
158         case NET_ERR_APP_NOT_REGISTERED:
159                 return "NET_ERR_APP_NOT_REGISTERED";
160
161                 /* Connection Related Error */
162
163                 /** No active connection exists for the given profile name */
164         case NET_ERR_NO_ACTIVE_CONNECTIONS:
165                 return "NET_ERR_NO_ACTIVE_CONNECTIONS";
166                 /** Active connection already exists for the given profile name  */
167         case NET_ERR_ACTIVE_CONNECTION_EXISTS:
168                 return "NET_ERR_ACTIVE_CONNECTION_EXISTS";
169
170                 /** Connection failure : out of range */
171         case NET_ERR_CONNECTION_OUT_OF_RANGE:
172                 return "NET_ERR_CONNECTION_OUT_OF_RANGE";
173                 /** Connection failure : pin missing */
174         case NET_ERR_CONNECTION_PIN_MISSING:
175                 return "NET_ERR_CONNECTION_PIN_MISSING";
176                 /** Connection failure : dhcp failed */
177         case NET_ERR_CONNECTION_DHCP_FAILED:
178                 return "NET_ERR_CONNECTION_DHCP_FAILED";
179                 /** Connection failure */
180         case NET_ERR_CONNECTION_CONNECT_FAILED:
181                 return "NET_ERR_CONNECTION_CONNECT_FAILED";
182                 /** Connection failure : login failed */
183         case NET_ERR_CONNECTION_LOGIN_FAILED:
184                 return "NET_ERR_CONNECTION_LOGIN_FAILED";
185                 /** Connection failure : authentication failed */
186         case NET_ERR_CONNECTION_AUTH_FAILED:
187                 return "NET_ERR_CONNECTION_AUTH_FAILED";
188                 /** Connection failure : invalid key */
189         case NET_ERR_CONNECTION_INVALID_KEY:
190                 return "NET_ERR_CONNECTION_INVALID_KEY";
191
192                 /* Other Error */
193
194                 /** Access is denied */
195         case NET_ERR_ACCESS_DENIED:
196                 return "NET_ERR_ACCESS_DENIED";
197                 /** Operation is in progress */
198         case NET_ERR_IN_PROGRESS:
199                 return "NET_ERR_IN_PROGRESS";
200                 /** Operation was aborted by client or network*/
201         case NET_ERR_OPERATION_ABORTED:
202                 return "NET_ERR_OPERATION_ABORTED";
203                 /** Invalid value of API parameter */
204         case NET_ERR_INVALID_PARAM:
205                 return "NET_ERR_INVALID_PARAM";
206                 /** invalid operation depending on current state */
207         case NET_ERR_INVALID_OPERATION:
208                 return "NET_ERR_INVALID_OPERATION";
209
210                 /** Feature not supported */
211         case NET_ERR_NOT_SUPPORTED:
212                 return "NET_ERR_NOT_SUPPORTED";
213                 /** TimeOut Error */
214         case NET_ERR_TIME_OUT:
215                 return "NET_ERR_TIME_OUT";
216                 /** Network service is not available*/
217         case NET_ERR_NO_SERVICE:
218                 return "NET_ERR_NO_SERVICE";
219                 /** DBus can't find appropriate method */
220         case NET_ERR_UNKNOWN_METHOD:
221                 return "NET_ERR_UNKNOWN_METHOD";
222         default:
223                 return "INVALID";
224         }
225 }
226
227 net_device_t _net_get_tech_type_from_path(const char *profile_name)
228 {
229         __NETWORK_FUNC_ENTER__;
230
231         net_device_t device_type = NET_DEVICE_UNKNOWN;
232
233         if (g_str_has_prefix(profile_name, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
234                 device_type = NET_DEVICE_WIFI;
235         else if (g_str_has_prefix(profile_name, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE)
236                 device_type = NET_DEVICE_CELLULAR;
237         else if (g_str_has_prefix(profile_name, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE)
238                 device_type = NET_DEVICE_ETHERNET;
239
240         __NETWORK_FUNC_EXIT__;
241         return device_type;
242 }
243
244 char* _net_get_string(DBusMessage* msg)
245 {
246         __NETWORK_FUNC_ENTER__;
247
248         DBusMessageIter args;
249         char* sigvalue = NULL;
250
251         if (!dbus_message_iter_init(msg, &args)) {
252                 NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
253         } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) {
254                 NETWORK_LOG(NETWORK_LOW, "Argument is not string\n");
255         } else {
256                 dbus_message_iter_get_basic(&args, &sigvalue);
257         }
258
259         __NETWORK_FUNC_EXIT__;
260         return sigvalue;
261 }
262
263 unsigned long long _net_get_uint64(DBusMessage* msg)
264 {
265         DBusMessageIter args;
266         unsigned long long sigvalue = 0;
267
268         if (!dbus_message_iter_init(msg, &args)) {
269                 NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
270         } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_UINT64) {
271                 NETWORK_LOG(NETWORK_LOW, "Argument is not uint64\n");
272         } else {
273                 dbus_message_iter_get_basic(&args, &sigvalue);
274         }
275
276         return sigvalue;
277 }
278
279 char* _net_get_object(DBusMessage* msg)
280 {
281         __NETWORK_FUNC_ENTER__;
282
283         DBusMessageIter args;
284         char* sigvalue = NULL;
285
286         if (!dbus_message_iter_init(msg, &args)) {
287                 NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
288         } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) {
289                 NETWORK_LOG(NETWORK_LOW, "Argument is not string\n");
290         } else {
291                 dbus_message_iter_get_basic(&args, &sigvalue);
292         }
293
294         __NETWORK_FUNC_EXIT__;
295         return sigvalue;
296 }
297
298 int _net_get_boolean(DBusMessage* msg)
299 {
300         __NETWORK_FUNC_ENTER__;
301
302         DBusMessageIter args;
303         dbus_bool_t val = FALSE;
304         int retvalue = FALSE;
305
306         if (!dbus_message_iter_init(msg, &args)) {
307                 NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
308         } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_BOOLEAN) {
309                 NETWORK_LOG(NETWORK_LOW, "Argument is not boolean\n");
310         } else {
311                 dbus_message_iter_get_basic(&args, &val);
312
313                 if (val)
314                         retvalue = TRUE;
315                 else
316                         retvalue = FALSE;
317         }
318
319         __NETWORK_FUNC_EXIT__;
320         return retvalue;
321 }
322
323 int _net_get_path(DBusMessage *msg, char *profile_name)
324 {
325         __NETWORK_FUNC_ENTER__;
326
327         char* ProfileName = NULL;
328
329         ProfileName = (char*)dbus_message_get_path(msg);
330         snprintf(profile_name, strlen(ProfileName) + 1, "%s", ProfileName);
331
332         __NETWORK_FUNC_EXIT__;
333
334         return NET_ERR_NONE;
335 }
336
337 int _net_get_tech_state(DBusMessage* msg, network_get_tech_state_info_t* tech_state)
338 {
339         __NETWORK_FUNC_ENTER__;
340
341         net_err_t Error = NET_ERR_NONE;
342         DBusMessageIter args, dict;
343
344         if (!dbus_message_iter_init(msg, &args)) {
345                 NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
346                 Error = NET_ERR_UNKNOWN;
347                 goto done;
348         }
349
350         dbus_message_iter_recurse(&args, &dict);
351
352         while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
353                 DBusMessageIter key_iter, sub_iter1, sub_iter2;
354                 const char *key = NULL;
355                 const char *tech_name = NULL;
356
357                 dbus_message_iter_recurse(&dict, &key_iter);
358                 dbus_message_iter_get_basic(&key_iter, &key);
359
360                 if (strcmp(key, "AvailableTechnologies") == 0 ||
361                     strcmp(key, "EnabledTechnologies") == 0 ||
362                     strcmp(key, "ConnectedTechnologies") == 0) {
363                         dbus_message_iter_next(&key_iter);
364                         dbus_message_iter_recurse(&key_iter, &sub_iter1);
365
366                         if (dbus_message_iter_get_arg_type(&sub_iter1) == DBUS_TYPE_ARRAY)
367                                 dbus_message_iter_recurse(&sub_iter1, &sub_iter2);
368                         else
369                                 goto next_dict;
370
371                         while (dbus_message_iter_get_arg_type(&sub_iter2) == DBUS_TYPE_STRING) {
372                                 dbus_message_iter_get_basic(&sub_iter2, &tech_name);
373                                 if (tech_name != NULL &&
374                                     strcmp(tech_name, tech_state->technology) == 0) {
375                                         if (strcmp(key, "AvailableTechnologies") == 0)
376                                                 tech_state->AvailableTechnology = TRUE;
377                                         else if (strcmp(key, "EnabledTechnologies") == 0)
378                                                 tech_state->EnabledTechnology = TRUE;
379                                         else
380                                                 tech_state->ConnectedTechnology = TRUE;
381                                 }
382
383                                 dbus_message_iter_next(&sub_iter2);
384                         }
385                 } else if (strcmp(key, "DefaultTechnology") == 0) {
386                         dbus_message_iter_next(&key_iter);
387                         dbus_message_iter_recurse(&key_iter, &sub_iter1);
388
389                         if (dbus_message_iter_get_arg_type(&sub_iter1) == DBUS_TYPE_STRING) {
390                                 dbus_message_iter_get_basic(&sub_iter1, &tech_name);
391                                 if (tech_name != NULL && strcmp(tech_name, tech_state->technology) == 0)
392                                         tech_state->DefaultTechnology = TRUE;
393                         }
394                 }
395 next_dict:
396                 dbus_message_iter_next(&dict);
397         }
398
399 done:
400         __NETWORK_FUNC_EXIT__;
401         return Error;
402 }
403
404 /** This function is used only to open Wi-Fi connection with hidden APs */
405 int _net_open_connection_with_wifi_info(const net_wifi_connection_info_t* wifi_info)
406 {
407         __NETWORK_FUNC_ENTER__;
408
409         net_err_t Error = NET_ERR_NONE;
410
411         net_wifi_connect_service_info_t wifi_connection_info;
412         memset(&wifi_connection_info, 0, sizeof(net_wifi_connect_service_info_t));
413
414         wifi_connection_info.type = g_strdup("wifi");
415
416         if (wifi_info->wlan_mode == NETPM_WLAN_CONNMODE_ADHOC)
417                 wifi_connection_info.mode = g_strdup("adhoc");
418         else
419                 wifi_connection_info.mode = g_strdup("managed");
420
421         wifi_connection_info.ssid = g_strdup(wifi_info->essid);
422
423         switch (wifi_info->security_info.sec_mode) {
424         case WLAN_SEC_MODE_NONE:
425                 wifi_connection_info.security = g_strdup("none");
426                 break;
427
428         case WLAN_SEC_MODE_WEP:
429                 wifi_connection_info.security = g_strdup("wep");
430                 wifi_connection_info.passphrase = g_strdup(wifi_info->security_info.authentication.wep.wepKey);
431                 break;
432
433         /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
434         case WLAN_SEC_MODE_WPA_PSK:
435                 wifi_connection_info.security = g_strdup("psk");
436                 wifi_connection_info.passphrase = g_strdup(wifi_info->security_info.authentication.psk.pskKey);
437                 break;
438
439         /** WPA2-PSK */
440         /** WPA-PSK / WPA2-PSK supported */
441         case WLAN_SEC_MODE_WPA2_PSK:
442                 wifi_connection_info.security = g_strdup("rsn");
443                 wifi_connection_info.passphrase = g_strdup(wifi_info->security_info.authentication.psk.pskKey);
444                 break;
445
446         case WLAN_SEC_MODE_IEEE8021X:
447                 wifi_connection_info.security = g_strdup("ieee8021x");
448
449                 wifi_connection_info.eap_type = g_strdup(
450                                 __convert_eap_type_to_string(wifi_info->security_info.authentication.eap.eap_type));
451                 wifi_connection_info.eap_auth = g_strdup(
452                                 __convert_eap_auth_to_string(wifi_info->security_info.authentication.eap.eap_auth));
453
454                 if (wifi_info->security_info.authentication.eap.username != NULL)
455                         if (strlen(wifi_info->security_info.authentication.eap.username) > 0)
456                                 wifi_connection_info.identity = g_strdup(wifi_info->security_info.authentication.eap.username);
457
458                 if (wifi_info->security_info.authentication.eap.password != NULL)
459                         if (strlen(wifi_info->security_info.authentication.eap.password) > 0)
460                                 wifi_connection_info.password = g_strdup(wifi_info->security_info.authentication.eap.password);
461
462                 if (wifi_info->security_info.authentication.eap.ca_cert_filename != NULL)
463                         if (strlen(wifi_info->security_info.authentication.eap.ca_cert_filename) > 0)
464                                 wifi_connection_info.ca_cert_file = g_strdup(wifi_info->security_info.authentication.eap.ca_cert_filename);
465
466                 if (wifi_info->security_info.authentication.eap.client_cert_filename != NULL)
467                         if (strlen(wifi_info->security_info.authentication.eap.client_cert_filename) > 0)
468                                 wifi_connection_info.client_cert_file = g_strdup(wifi_info->security_info.authentication.eap.client_cert_filename);
469
470                 if (wifi_info->security_info.authentication.eap.private_key_filename != NULL)
471                         if (strlen(wifi_info->security_info.authentication.eap.private_key_filename) > 0)
472                                 wifi_connection_info.private_key_file = g_strdup(wifi_info->security_info.authentication.eap.private_key_filename);
473
474                 if (wifi_info->security_info.authentication.eap.private_key_passwd != NULL)
475                         if (strlen(wifi_info->security_info.authentication.eap.private_key_passwd) > 0)
476                                 wifi_connection_info.private_key_password = g_strdup(wifi_info->security_info.authentication.eap.private_key_passwd);
477
478                 break;
479
480         default:
481                 NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid security type\n");
482                 __NETWORK_FUNC_EXIT__;
483                 return NET_ERR_INVALID_PARAM;
484         }
485
486         NETWORK_LOG(NETWORK_HIGH,
487                         "Parameters: type:\t%s\nmode:\t%s\nssid:\t%s\nsecurity:\t%s\npassphrase:\t%s\n",
488                         wifi_connection_info.type, wifi_connection_info.mode,
489                         wifi_connection_info.ssid, wifi_connection_info.security,
490                         wifi_connection_info.passphrase);
491
492         if (wifi_info->security_info.sec_mode == WLAN_SEC_MODE_IEEE8021X) {
493                 NETWORK_LOG(NETWORK_HIGH,
494                                 "Wi-Fi Enterprise type:\t%s\nauth:\t%s\nidentity:\t%s\npassword:\t%s\n",
495                                 wifi_connection_info.eap_type, wifi_connection_info.eap_auth,
496                                 wifi_connection_info.identity, wifi_connection_info.password);
497                 NETWORK_LOG(NETWORK_HIGH,
498                                 "CA cert:\t%s\nClient cert:\t%s\nPrivate key:\t%s\nPrivate key password:\t%s\n",
499                                 wifi_connection_info.ca_cert_file, wifi_connection_info.client_cert_file,
500                                 wifi_connection_info.private_key_file, wifi_connection_info.private_key_password);
501         }
502
503         if ((Error = _net_dbus_connect_service(&wifi_connection_info)) != NET_ERR_NONE)
504                 NETWORK_LOG(NETWORK_EXCEPTION, "Failed to request connect service. Error [%s]\n",
505                                 _net_print_error(Error));
506         else
507                 NETWORK_LOG(NETWORK_HIGH, "Successfully requested to connect service\n");
508
509         g_free(wifi_connection_info.type);
510         g_free(wifi_connection_info.mode);
511         g_free(wifi_connection_info.ssid);
512         g_free(wifi_connection_info.security);
513         g_free(wifi_connection_info.passphrase);
514         g_free(wifi_connection_info.eap_type);
515         g_free(wifi_connection_info.eap_auth);
516         g_free(wifi_connection_info.identity);
517         g_free(wifi_connection_info.password);
518         g_free(wifi_connection_info.ca_cert_file);
519         g_free(wifi_connection_info.client_cert_file);
520         g_free(wifi_connection_info.private_key_file);
521         g_free(wifi_connection_info.private_key_password);
522
523         __NETWORK_FUNC_EXIT__;
524         return Error;
525 }
526
527 int _net_mutex_init(void)
528 {
529         __NETWORK_FUNC_ENTER__;
530
531         if (pthread_mutex_init(&networkinfo_mutex.callback_mutex, NULL) != 0) {
532                 NETWORK_LOG(NETWORK_ERROR, "Mutex for callback initialization failed!\n");
533                 __NETWORK_FUNC_EXIT__;
534                 return NET_ERR_UNKNOWN;
535         }
536
537         if (pthread_mutex_init(&networkinfo_mutex.wifi_state_mutex, NULL) != 0) {
538                 NETWORK_LOG(NETWORK_ERROR, "Mutex for wifi state initialization failed!\n");
539                 pthread_mutex_destroy(&networkinfo_mutex.callback_mutex);
540                 __NETWORK_FUNC_EXIT__;
541                 return NET_ERR_UNKNOWN;
542         }
543
544         __NETWORK_FUNC_EXIT__;
545         return NET_ERR_NONE;
546 }
547
548 void _net_mutex_destroy(void)
549 {
550         __NETWORK_FUNC_ENTER__;
551
552         pthread_mutex_destroy(&networkinfo_mutex.callback_mutex);
553         pthread_mutex_destroy(&networkinfo_mutex.wifi_state_mutex);
554
555         __NETWORK_FUNC_EXIT__;
556 }
557
558 void _net_client_callback(net_event_info_t *event_data)
559 {
560         pthread_mutex_lock(&networkinfo_mutex.callback_mutex);
561         __NETWORK_FUNC_ENTER__;
562
563         if (NetworkInfo.ClientEventCb != NULL)
564                 NetworkInfo.ClientEventCb(event_data, NetworkInfo.user_data);
565
566         if (NetworkInfo.ClientEventCb_conn != NULL)
567                 NetworkInfo.ClientEventCb_conn(event_data, NetworkInfo.user_data_conn);
568
569         if (NetworkInfo.ClientEventCb_wifi != NULL)
570                 NetworkInfo.ClientEventCb_wifi(event_data, NetworkInfo.user_data_wifi);
571
572         __NETWORK_FUNC_EXIT__;
573         pthread_mutex_unlock(&networkinfo_mutex.callback_mutex);
574 }
575
576 net_wifi_state_t _net_get_wifi_state(void)
577 {
578         pthread_mutex_lock(&networkinfo_mutex.wifi_state_mutex);
579         __NETWORK_FUNC_ENTER__;
580
581         net_err_t Error = NET_ERR_NONE;
582         network_get_tech_state_info_t tech_state = {{0,},};
583         net_wifi_state_t wifi_state = WIFI_UNKNOWN;
584
585         snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "wifi");
586         Error = _net_dbus_get_technology_state(&tech_state);
587         if (Error != NET_ERR_NONE) {
588                 NETWORK_LOG(NETWORK_ERROR,
589                         "Error!!! _net_dbus_get_technology_state() failed. Error [%s]\n",
590                         _net_print_error(Error));
591                 goto state_done;
592         }
593
594         if (tech_state.EnabledTechnology == TRUE &&
595             tech_state.AvailableTechnology == TRUE)
596                 wifi_state = WIFI_ON;
597         else
598                 wifi_state = WIFI_OFF;
599
600 state_done:
601         __NETWORK_FUNC_EXIT__;
602         pthread_mutex_unlock(&networkinfo_mutex.wifi_state_mutex);
603         return wifi_state;
604 }
605
606 void _net_clear_request_table(void)
607 {
608         __NETWORK_FUNC_ENTER__;
609
610         int i = 0;
611
612         for (i = 0;i < NETWORK_REQUEST_TYPE_MAX;i++)
613                 memset(&request_table[i], 0, sizeof(network_request_table_t));
614
615         __NETWORK_FUNC_EXIT__;
616 }
617
618 #ifdef __cplusplus
619 }
620 #endif /* __cplusplus */