merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:12:22 +0000 (01:12 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:12:22 +0000 (01:12 +0900)
CMakeLists.txt
debian/changelog
include/net_wifi_private.h
include/wifi.h
packaging/capi-network-wifi.spec
src/libnetwork.c
src/net_wifi.c
test/wifi_test.c

index bfff87f..b799a0d 100644 (file)
@@ -28,7 +28,7 @@ ENDIF("${ARCH}" STREQUAL "arm")
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DTIZEN_DEBUG")
 
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
 aux_source_directory(src SOURCES)
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
@@ -42,7 +42,7 @@ SET_TARGET_PROPERTIES(${fw_name}
      CLEAN_DIRECT_OUTPUT 1
 )
 
-INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
 INSTALL(
         DIRECTORY ${INC_DIR}/ DESTINATION include/network
         FILES_MATCHING
@@ -59,7 +59,7 @@ CONFIGURE_FILE(
     ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
     @ONLY
 )
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
 ADD_SUBDIRECTORY(test)
 
index e2f591e..a964e74 100644 (file)
@@ -1,3 +1,11 @@
+capi-network-wifi (0.1.2-15) unstable; urgency=low
+
+  * Added specific(hidden) scan support
+  * Git: framework/api/wifi
+  * Tag: capi-network-wifi_0.1.2-15
+
+ -- JaeHyun Kim <jeik01.kim@samsung.com>  Tue, 26 Feb 2013 11:19:52 +0900
+
 capi-network-wifi (0.1.2-14) unstable; urgency=low
 
   * Fix memory corruption
index 471b55c..2bab494 100644 (file)
@@ -64,8 +64,11 @@ bool _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state);
 bool _wifi_libnet_get_wifi_state(wifi_connection_state_e* connection_state);
 int _wifi_libnet_get_intf_name(char** name);
 int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void* user_data);
+int _wifi_libnet_scan_hidden_ap(const char *essid,
+                                       wifi_scan_finished_cb callback, void* user_data);
 int _wifi_libnet_get_connected_profile(wifi_ap_h *ap);
 bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data);
+bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data);
 
 int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void* user_data);
 int _wifi_libnet_close_profile(wifi_ap_h ap_h, wifi_disconnected_cb callback, void* user_data);
index 1d8fc4e..da8b9ea 100644 (file)
@@ -233,8 +233,9 @@ typedef void* wifi_ap_h;
 * @param[in]  ap  The access point
 * @param[in]  user_data  The user data passed from the request function
 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
-* @pre  wifi_foreach_found_aps() will invoke this callback.
+* @pre  wifi_foreach_found_aps() and wifi_foreach_found_hidden_aps() will invoke this callback.
 * @see  wifi_foreach_found_aps()
+* @see  wifi_foreach_found_hidden_aps()
 */
 typedef bool(*wifi_found_ap_cb)(wifi_ap_h ap, void* user_data);
 
@@ -243,6 +244,7 @@ typedef bool(*wifi_found_ap_cb)(wifi_ap_h ap, void* user_data);
 * @param[in] error_code  The error code
 * @param[in] user_data The user data passed from the callback registration function
 * @see wifi_scan()
+* @see wifi_scan_hidden_ap()
 * @see wifi_set_background_scan_cb()
 * @see wifi_unset_background_scan_cb()
 */
@@ -437,6 +439,20 @@ int wifi_get_network_interface_name(char** name);
 int wifi_scan(wifi_scan_finished_cb callback, void* user_data);
 
 /**
+* @brief Starts hidden ap scan, asynchronously.
+* @param[in] essid     The essid of hidden ap
+* @param[in] callback  The callback function to be called
+* @param[in] user_data The user data passed to the callback function
+* @return 0 on success, otherwise negative error value.
+* @retval #WIFI_ERROR_NONE  Successful
+* @retval #WIFI_ERROR_INVALID_PARAMETER  Invalid parameter
+* @retval #WIFI_ERROR_INVALID_OPERATION  Invalid operation
+* @retval #WIFI_ERROR_OPERATION_FAILED  Operation failed
+* @post This function invokes wifi_scan_finished_cb().
+*/
+int wifi_scan_hidden_ap(const char* essid, wifi_scan_finished_cb callback, void* user_data);
+
+/**
 * @brief Gets the handle of connected access point.
 * @remarks @a handle must be released with wifi_ap_destroy().
 * @param[out] ap  The handle of access point
@@ -461,6 +477,18 @@ int wifi_get_connected_ap(wifi_ap_h* ap);
 int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data);
 
 /**
+* @brief Gets the result of hidden ap scan.
+* @param[in] callback  The callback to be called
+* @param[in] user_data The user data passed to the callback function
+* @return 0 on success, otherwise negative error value.
+* @retval #WIFI_ERROR_NONE  Successful
+* @retval #WIFI_ERROR_INVALID_PARAMETER  Invalid parameter
+* @retval #WIFI_ERROR_OPERATION_FAILED  Operation failed
+* @post This function invokes wifi_found_ap_cb().
+*/
+int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback, void* user_data);
+
+/**
 * @brief Connects the access point, asynchronously.
 * @param[in] ap  The handle of access point
 * @param[in] callback  The callback function to be called. This can be NULL if you don't want to get the notification.
index 6b3b94e..7efe7ab 100644 (file)
@@ -1,9 +1,9 @@
 Name:       capi-network-wifi
 Summary:    Network Wi-Fi library in TIZEN C API
-Version:    0.1.2_14
+Version:    0.1.2_15
 Release:    1
 Group:      System/Network
-License:    Apache License Version 2.0
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
@@ -11,8 +11,6 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(network)
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
 
 %description
 Network Wi-Fi library in Tizen C API
@@ -31,7 +29,7 @@ Network Wi-Fi library in Tizen C API (Development)
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 
 make %{?_smp_mflags}
 
index e72b58f..87740c4 100755 (executable)
@@ -29,6 +29,8 @@ struct _wifi_cb_s {
        void *bg_scan_user_data;
        wifi_scan_finished_cb scan_request_cb;
        void *scan_request_user_data;
+       wifi_scan_finished_cb scan_hidden_ap_cb;
+       void *scan_hidden_ap_user_data;
        wifi_connection_state_changed_cb connection_state_cb;
        void *connection_state_user_data;
        wifi_activated_cb activated_cb;
@@ -48,6 +50,7 @@ struct _profile_list_s {
 
 static struct _wifi_cb_s wifi_callbacks = {0,};
 static struct _profile_list_s profile_iterator = {0, NULL};
+static struct _profile_list_s hidden_profile_iterator = {0, NULL};
 
 
 static wifi_error_e __libnet_convert_to_ap_error_type(net_err_t err_type)
@@ -155,6 +158,35 @@ static void __libnet_update_profile_iterator(void)
        profile_iterator.profiles = wifi_profiles.profiles;
 }
 
+static void __libnet_update_hidden_profile_iterator(GSList *ap_list)
+{
+       int count;
+       GSList *list = ap_list;
+
+       for (count = 0; list; list = list->next)
+               count++;
+
+       if (count == 0) {
+               WIFI_LOG(WIFI_INFO, "No hidden AP found\n");
+               return;
+       }
+
+       hidden_profile_iterator.count = count;
+       hidden_profile_iterator.profiles = g_try_new0(net_profile_info_t, count);
+
+       list = ap_list;
+       for (count = 0; list; list = list->next) {
+               net_wifi_connection_info_t *ap = list->data;
+               net_profile_info_t *profile = &hidden_profile_iterator.profiles[count];
+
+               g_strlcpy(profile->ProfileInfo.Wlan.essid, ap->essid, NET_WLAN_ESSID_LEN+1);
+               profile->ProfileInfo.Wlan.security_info.sec_mode = ap->security_info.sec_mode;
+               count++;
+       }
+
+       WIFI_LOG(WIFI_INFO, "Hidden AP count : %d\n", count);
+}
+
 static void __libnet_convert_profile_info_to_wifi_info(net_wifi_connection_info_t *wifi_info,
                                                                net_profile_info_t *ap_info)
 {
@@ -251,6 +283,7 @@ static void __libnet_power_on_off_cb(net_event_info_t *event_cb, bool is_request
                        WIFI_LOG(WIFI_INFO, "Wi-Fi State : Power OFF\n");
                        state = WIFI_DEVICE_STATE_DEACTIVATED;
                        __libnet_clear_profile_list(&profile_iterator);
+                       __libnet_clear_profile_list(&hidden_profile_iterator);
                } else {
                        WIFI_LOG(WIFI_INFO, "Wi-Fi State : Unknown\n");
                        error_code = WIFI_ERROR_OPERATION_FAILED;
@@ -269,7 +302,7 @@ static void __libnet_power_on_off_cb(net_event_info_t *event_cb, bool is_request
                wifi_callbacks.device_state_cb(state, wifi_callbacks.device_state_user_data);
 }
 
-static void __libnet_scan_cb(net_event_info_t *event_cb, bool is_requested)
+static void __libnet_scan_cb(net_event_info_t *event_cb)
 {
        wifi_error_e error_code = WIFI_ERROR_NONE;
 
@@ -289,6 +322,27 @@ static void __libnet_scan_cb(net_event_info_t *event_cb, bool is_requested)
                wifi_callbacks.bg_scan_cb(error_code, wifi_callbacks.bg_scan_user_data);
 }
 
+static void __libnet_hidden_scan_cb(net_event_info_t *event_cb)
+{
+       wifi_error_e error_code = WIFI_ERROR_NONE;
+
+       __libnet_clear_profile_list(&hidden_profile_iterator);
+
+       if (event_cb->Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Hidden scan failed!, Error [%d]\n", event_cb->Error);
+               error_code = WIFI_ERROR_OPERATION_FAILED;
+       } else if (event_cb->Data) {
+               GSList *ap_list = event_cb->Data;
+               __libnet_update_hidden_profile_iterator(ap_list);
+       }
+
+       if (wifi_callbacks.scan_hidden_ap_cb) {
+               wifi_callbacks.scan_hidden_ap_cb(error_code, wifi_callbacks.scan_hidden_ap_user_data);
+               wifi_callbacks.scan_hidden_ap_cb = NULL;
+               wifi_callbacks.scan_hidden_ap_user_data = NULL;
+       }
+}
+
 static void __libnet_set_connected_cb(wifi_connected_cb user_cb, void *user_data)
 {
        if (user_cb) {
@@ -423,18 +477,25 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                break;
        case NET_EVENT_WIFI_SCAN_RSP:
        case NET_EVENT_WIFI_SCAN_IND:
-               WIFI_LOG(WIFI_ERROR, "Got wifi scan IND\n");
-               __libnet_scan_cb(event_cb, is_requested);
+               WIFI_LOG(WIFI_INFO, "Got wifi scan IND\n");
+               __libnet_scan_cb(event_cb);
+               break;
+       case NET_EVENT_SPECIFIC_SCAN_RSP:
+               WIFI_LOG(WIFI_INFO, "Got wifi hidden scan RSP\n");
+               break;
+       case NET_EVENT_SPECIFIC_SCAN_IND:
+               WIFI_LOG(WIFI_INFO, "Got wifi hidden scan IND\n");
+               __libnet_hidden_scan_cb(event_cb);
                break;
        case NET_EVENT_WIFI_POWER_RSP:
                is_requested = true;
                /* fall through */
        case NET_EVENT_WIFI_POWER_IND:
-               WIFI_LOG(WIFI_ERROR, "Got wifi power IND\n");
+               WIFI_LOG(WIFI_INFO, "Got wifi power IND\n");
                __libnet_power_on_off_cb(event_cb, is_requested);
                break;
        default :
-               WIFI_LOG(WIFI_ERROR, "Error! Unknown Event\n\n");
+               WIFI_LOG(WIFI_INFO, "Error! Unknown Event\n\n");
        }
 }
 
@@ -455,6 +516,7 @@ bool _wifi_libnet_deinit(void)
                return false;
 
        __libnet_clear_profile_list(&profile_iterator);
+       __libnet_clear_profile_list(&hidden_profile_iterator);
        g_slist_free_full(ap_handle_list, g_free);
        ap_handle_list = NULL;
        memset(&wifi_callbacks, 0, sizeof(struct _wifi_cb_s));
@@ -498,9 +560,12 @@ bool _wifi_libnet_check_ap_validity(wifi_ap_h ap_h)
        for (list = ap_handle_list; list; list = list->next)
                if (ap_h == list->data) return true;
 
-       for (;i < profile_iterator.count;i++)
+       for (; i < profile_iterator.count; i++)
                if (ap_h == &profile_iterator.profiles[i]) return true;
 
+       for (i = 0; i < hidden_profile_iterator.count; i++)
+               if (ap_h == &hidden_profile_iterator.profiles[i]) return true;
+
        return false;
 }
 
@@ -635,6 +700,22 @@ int _wifi_libnet_scan_request(wifi_scan_finished_cb callback, void* user_data)
        return WIFI_ERROR_OPERATION_FAILED;
 }
 
+int _wifi_libnet_scan_hidden_ap(const char *essid,
+                                       wifi_scan_finished_cb callback, void* user_data)
+{
+       int rv;
+       rv = net_specific_scan_wifi(essid);
+
+       if (rv == NET_ERR_NONE) {
+               wifi_callbacks.scan_hidden_ap_cb = callback;
+               wifi_callbacks.scan_hidden_ap_user_data = user_data;
+               return WIFI_ERROR_NONE;
+       } else if (rv == NET_ERR_INVALID_OPERATION)
+               return WIFI_ERROR_INVALID_OPERATION;
+
+       return WIFI_ERROR_OPERATION_FAILED;
+}
+
 int _wifi_libnet_get_connected_profile(wifi_ap_h *ap)
 {
        int i = 0;
@@ -686,6 +767,24 @@ bool _wifi_libnet_foreach_found_aps(wifi_found_ap_cb callback, void *user_data)
        return true;
 }
 
+bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user_data)
+{
+       int i = 0;
+       bool rv = true;
+
+       if (hidden_profile_iterator.count == 0) {
+               WIFI_LOG(WIFI_INFO, "There is no hidden APs.\n");
+               return true;
+       }
+
+       for (;i < hidden_profile_iterator.count;i++) {
+               rv = callback((wifi_ap_h)(&hidden_profile_iterator.profiles[i]), user_data);
+               if (rv == false) break;
+       }
+
+       return true;
+}
+
 int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void* user_data)
 {
        net_profile_info_t *ap_info = ap_h;
index bc31219..b46b09f 100755 (executable)
@@ -183,6 +183,27 @@ int wifi_scan(wifi_scan_finished_cb callback, void* user_data)
        return rv;
 }
 
+int wifi_scan_hidden_ap(const char* essid, wifi_scan_finished_cb callback, void* user_data)
+{
+       int rv;
+
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (is_init == false) {
+               WIFI_LOG(WIFI_ERROR, "Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+       rv = _wifi_libnet_scan_hidden_ap(essid, callback, user_data);
+       if (rv != WIFI_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Error!! Wi-Fi hidden scan failed.\n");
+
+       return rv;
+}
+
 int wifi_get_connected_ap(wifi_ap_h* ap)
 {
        int rv;
@@ -211,6 +232,19 @@ int wifi_foreach_found_aps(wifi_found_ap_cb callback, void* user_data)
        return WIFI_ERROR_NONE;
 }
 
+int wifi_foreach_found_hidden_aps(wifi_found_ap_cb callback, void* user_data)
+{
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_wifi_libnet_foreach_found_hidden_aps(callback, user_data) == false)
+               return WIFI_ERROR_OPERATION_FAILED;
+
+       return WIFI_ERROR_NONE;
+}
+
 int wifi_connect(wifi_ap_h ap, wifi_connected_cb callback, void* user_data)
 {
        if (_wifi_libnet_check_ap_validity(ap) == false) {
index 0c24089..0f11a6d 100644 (file)
@@ -92,6 +92,46 @@ static void __test_scan_request_callback(wifi_error_e error_code, void* user_dat
                        __test_convert_error_to_string(error_code));
 }
 
+static bool __test_found_hidden_aps_callback(wifi_ap_h ap, void *user_data)
+{
+       int rv;
+       char *ap_name;
+       wifi_security_type_e sec_type;
+
+       rv = wifi_ap_get_essid(ap, &ap_name);
+       if (rv != WIFI_ERROR_NONE) {
+               printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+               return false;
+       }
+
+       printf("AP name : %s\n", ap_name);
+
+       if (wifi_ap_get_security_type(ap, &sec_type) == WIFI_ERROR_NONE)
+               printf("Security type : %d\n", sec_type);
+       else
+               printf("Fail to get Security type\n");
+
+       g_free(ap_name);
+       return true;
+}
+
+static void __test_scan_hidden_ap_callback(wifi_error_e error_code, void* user_data)
+{
+       int rv;
+
+       printf("Hidden scan Completed from scan request, error code : %s\n",
+                       __test_convert_error_to_string(error_code));
+
+       if (error_code != WIFI_ERROR_NONE)
+               return;
+
+       rv = wifi_foreach_found_hidden_aps(__test_found_hidden_aps_callback, NULL);
+       if (rv != WIFI_ERROR_NONE) {
+               printf("Fail to get hidden AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+               return;
+       }
+}
+
 static void __test_connection_state_callback(wifi_connection_state_e state, wifi_ap_h ap, void* user_data)
 {
        int rv = 0;
@@ -1147,6 +1187,27 @@ int test_get_ap_info(void)
        return 1;
 }
 
+int test_scan_hidden_ap(void)
+{
+       int rv;
+       char ap_name[33];
+
+       printf("Input a part of hidden AP name to find : ");
+       rv = scanf("%32s", ap_name);
+       if (rv <= 0)
+               return -1;
+
+       rv = wifi_scan_hidden_ap(ap_name, __test_scan_hidden_ap_callback, NULL);
+
+       if (rv != WIFI_ERROR_NONE) {
+               printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       printf("Scan hidden AP succeeded\n");
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -1201,7 +1262,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("g       - Set & connect EAP\n");
                printf("h       - Set IP method type\n");
                printf("i       - Set Proxy method type\n");
-               printf("j       - Get Ap info\n");
+               printf("j       - Get AP info\n");
+               printf("k       - Scan hidden AP\n");
                printf("0       - Exit \n");
 
                printf("ENTER  - Show options menu.......\n");
@@ -1265,6 +1327,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'j':
                rv = test_get_ap_info();
                break;
+       case 'k':
+               rv = test_scan_hidden_ap();
+               break;
        default:
                break;
        }