2 * Network Configuration Module
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file declares wifi direct util functions.
23 * @file wifi-direct-util.h
24 * @author Gibyoung Kim (lastkgb.kim@samsung.com)
28 #ifndef __WIFI_DIRECT_UTIL_H__
29 #define __WIFI_DIRECT_UTIL_H__
31 #if defined TIZEN_MOBILE
32 # define DEFAULT_MAC_FILE_PATH "/opt/etc/.mac.info"
33 #endif /* TIZEN_MOBILE */
36 # if defined TIZEN_WIFI_MODULE_BUNDLE
37 # define DEFAULT_MAC_FILE_PATH "/sys/class/net/wlan0/address"
38 # else /* TIZEN_WIFI_MODULE_BUNDLE */
39 # define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
40 # endif /* TIZEN_WIFI_MODULE_BUNDLE */
43 #ifndef DEFAULT_MAC_FILE_PATH
44 # define DEFAULT_MAC_FILE_PATH "/sys/class/net/p2p0/address"
47 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
48 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
49 #define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3]
50 #define IPSTR "%d.%d.%d.%d"
51 #define ZEROIP "0.0.0.0"
52 #define MAC2SECSTR(a) (a)[0], (a)[4], (a)[5]
53 #define MACSECSTR "%02x:%02x:%02x"
54 #define IP2SECSTR(a) (a)[0], (a)[3]
55 #define IPSECSTR "%d..%d"
57 #define VCONFKEY_DHCPS_IP_LEASE "memory/private/wifi_direct_manager/dhcp_ip_lease"
58 #define VCONFKEY_DHCPC_SERVER_IP "memory/private/wifi_direct_manager/dhcpc_server_ip"
59 #define VCONFKEY_LOCAL_IP "memory/private/wifi_direct_manager/p2p_local_ip"
60 #define DHCP_DUMP_FILE "/tmp/dhcp-client-table"
61 #define COUNTRY_CODE_FILE "/usr/etc/wifi-direct/ccode.conf"
62 #define MAX_DHCP_DUMP_SIZE 64 // Single lease format: [99:66:dd:00:11:aa 192.168.16.20 00:00:60]
70 #define LOG_TAG "WIFI_DIRECT_MANAGER"
72 #define WDS_LOGV(format, args...) LOGV(format, ##args)
73 #define WDS_LOGD(format, args...) LOGD(format, ##args)
74 #define WDS_LOGI(format, args...) LOGI(format, ##args)
75 #define WDS_LOGW(format, args...) LOGW(format, ##args)
76 #define WDS_LOGE(format, args...) LOGE(format, ##args)
77 #define WDS_LOGF(format, args...) LOGF(format, ##args)
79 #define __WDS_LOG_FUNC_ENTER__ LOGD("Enter")
80 #define __WDS_LOG_FUNC_EXIT__ LOGD("Quit")
82 #define WDS_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
83 #define WDS_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
87 #define WDS_LOGV(format, args...)
88 #define WDS_LOGD(format, args...)
89 #define WDS_LOGI(format, args...)
90 #define WDS_LOGW(format, args...)
91 #define WDS_LOGE(format, args...)
92 #define WDS_LOGF(format, args...)
94 #define __WDS_LOG_FUNC_ENTER__
95 #define __WDS_LOG_FUNC_EXIT__
97 #define WDS_SECLOGI(format, args...)
98 #define WDS_SECLOGD(format, args...)
100 #endif /* USE_DLOG */
102 #if !(__GNUC__ <= 4 && __GNUC_MINOR__ < 8)
103 int wfd_util_get_current_time(unsigned long *cur_time);
105 gboolean wfd_util_execute_file(const char *file_path, char *const args[], char *const envs[]);
106 int wfd_util_freq_to_channel(int freq);
107 int wfd_util_channel_to_freq(int channel);
108 int wfd_util_get_phone_name(char *phone_name);
109 void wfd_util_set_dev_name_notification();
110 void wfd_util_unset_dev_name_notification();
111 int wfd_util_set_country();
113 int wfd_util_check_wifi_state();
114 int wfd_util_check_mobile_ap_state();
115 int wfd_util_wifi_direct_activatable();
117 int wfd_util_get_wifi_direct_state();
119 int wfd_util_set_wifi_direct_state(int state);
120 int wfd_util_get_local_dev_mac(unsigned char *dev_mac);
122 #ifdef TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT
123 int wfd_util_start_wifi_direct_popup();
124 int wfd_util_stop_wifi_direct_popup();
125 #endif /* TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT */
127 int wfd_util_dhcps_start();
128 int wfd_util_dhcps_wait_ip_leased(wfd_device_s *peer);
129 int wfd_util_dhcps_stop();
130 int wfd_util_dhcpc_start(wfd_device_s *peer);
131 int wfd_util_dhcpc_stop();
132 int wfd_util_dhcpc_get_ip(char *ifname, unsigned char *ip_addr, int is_IPv6);
133 int wfd_util_dhcpc_get_server_ip(unsigned char* ip_addr);
134 int wfd_util_local_get_ip(char *ifname, unsigned char *ip_addr, int is_IPv6);
135 #ifdef TIZEN_FEATURE_IP_OVER_EAPOL
136 int wfd_util_ip_over_eap_assign(wfd_device_s *peer, const char *ifname);
137 #ifdef TIZEN_WLAN_BOARD_SPRD
138 int wfd_util_static_ip_unset(const char *ifname);
139 #endif /* TIZEN_WLAN_BOARD_SPRD */
140 #endif /* TIZEN_FEATURE_IP_OVER_EAPOL */
141 #endif /* __WIFI_DIRECT_UTIL_H__ */