#if !(__GNUC__ <= 4 && __GNUC_MINOR__ < 8)
int wfd_util_get_current_time(unsigned long *cur_time);
#endif
+
+void *wfd_util_plugin_init(wfd_manager_s *manager);
+int wfd_util_plugin_deinit(wfd_manager_s *manager);
+void *wfd_util_prd_plugin_init(wfd_manager_s *manager);
+int wfd_util_prd_plugin_deinit(wfd_manager_s *manager);
+
gboolean wfd_util_execute_file(const char *file_path, char *const args[], char *const envs[]);
int wfd_util_freq_to_channel(int freq);
int wfd_util_channel_to_freq(int channel);
Name: wifi-direct-manager
Summary: Wi-Fi Direct manger
-Version: 1.2.260
+Version: 1.2.261
Release: 1
Group: Network & Connectivity/Wireless
License: Apache-2.0
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(libsystemd-login)
BuildRequires: pkgconfig(libtzplatform-config)
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
BuildRequires: cmake
Requires: net-tools
Requires: toybox-symlinks-dhcpd
Requires: toybox-symlinks-dhcp
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
%description
Manager for handling wifi-direct functionalities
export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
%ifarch %{arm}
export ARCH=arm
%endif
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCHITECTURE=$ARCH \
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCHITECTURE=$ARCH \
%if ! 0%{?model_build_feature_network_tethering_disable}
-DTIZEN_TETHERING_ENABLE=0 \
%endif
-DTZ_SYS_RO_ETC=%{TZ_SYS_RO_ETC} \
-DTZ_SYS_VAR=%{TZ_SYS_VAR} \
-DTZ_SYS_ETC=%{TZ_SYS_ETC} \
- -DTZ_SYS_RUN=%{TZ_SYS_RUN}
+ -DTZ_SYS_RUN=%{TZ_SYS_RUN} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
make %{?_smp_mflags}
%endif
%attr(755,-,-) %{_sbindir}/p2p_supp.sh
%attr(755,-,-) %{_bindir}/wfd-manager
+%if 0%{?gtests:1}
+ %{_bindir}/gtest*
+%endif
%files -n wifi-direct-plugin-wpasupplicant
%manifest wifi-direct-plugin-wpasupplicant.manifest
return FALSE;
}
-
g_owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
WFD_MANAGER_SERVICE,
G_BUS_NAME_OWNER_FLAGS_NONE,
* @version 0.1
*/
#include <glib.h>
+#include <glib-object.h>
#include <wifi-direct.h>
#include "wifi-direct-log.h"
#include "wifi-direct-oem.h"
#include "wifi-direct-manager.h"
+#include "wifi-direct-dbus.h"
+#include "wifi-direct-util.h"
int main(int argc, char *argv[])
return -1;
}
+ /**
+ * wfd_manager_plugin initialization
+ */
+ manager->plugin_handle = wfd_util_plugin_init(manager);
+ if (!manager->plugin_handle) {
+ WDS_LOGE("Failed to initialize plugin");
+ wfd_manager_unload(manager);
+ __WDS_LOG_FUNC_EXIT__;
+ return -1;
+ }
+ WDS_LOGD("Succeeded to load plugin");
+#if defined TIZEN_ENABLE_PRD
+ /**
+ * wfd_manager_prd_plugin initialization
+ */
+ manager->prd_plugin_handle = wfd_prd_util_plugin_init(manager);
+ if (!manager->prd_plugin_handle)
+ WDS_LOGW("Failed to initialize prd plugin");
+ else
+ WDS_LOGD("Succeeded to load plugin");
+#endif /* TIZEN_ENABLE_PRD */
+
+ if (!wfd_manager_dbus_init()) {
+ WDS_LOGE("Failed to DBus");
+ wfd_util_plugin_deinit(manager);
+ wfd_manager_unload();
+ __WDS_LOG_FUNC_EXIT__;
+ return -1;
+ }
+
main_loop = g_main_loop_new(NULL, FALSE);
if (main_loop == NULL) {
WDS_LOGE("Failed to create GMainLoop structure");
manager->main_loop = main_loop;
g_main_loop_run(main_loop);
+ wfd_manager_dbus_unregister_nameowner_signal();
+
+ wfd_manager_dbus_unregister();
+ wfd_manager_dbus_deinit();
+
+#if defined TIZEN_ENABLE_PRD
+ wfd_util_prd_plugin_deinit(manager);
+#endif /* TIZEN_ENABLE_PRD */
+
+ wfd_util_plugin_deinit(manager);
+
wfd_manager_unload();
__WDS_LOG_FUNC_EXIT__;
#include <stdio.h>
#include <stdlib.h>
-#include <dlfcn.h>
-#include <sys/utsname.h>
#include <time.h>
#include <errno.h>
#include <string.h>
return 0;
}
-static void *wfd_plugin_init(wfd_manager_s *manager)
-{
- __WDS_LOG_FUNC_ENTER__;
- void *handle;
- struct utsname kernel_info;
- int res;
- char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-
- if (!manager) {
- WDS_LOGE("Invalid parameter");
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- res = uname(&kernel_info);
- if (res) {
- WDS_LOGE("Failed to detect target type");
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
- WDS_LOGD("Node name [%s], HW ID [%s]", kernel_info.nodename, kernel_info.machine);
-
- errno = 0;
-
-#if defined(TIZEN_ARCH_64)
- handle = dlopen(SUPPL_PLUGIN_64BIT_PATH, RTLD_NOW);
-#else
- handle = dlopen(SUPPL_PLUGIN_PATH, RTLD_NOW);
-#endif
- if (!handle) {
- WDS_LOGE("Failed to open shared object. [%s]", dlerror());
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- errno = 0;
- int (*plugin_load)(wfd_oem_ops_s **ops) = NULL;
- plugin_load = (int (*)(wfd_oem_ops_s **ops)) dlsym(handle, "wfd_plugin_load");
- if (!plugin_load) {
- strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
- WDS_LOGE("Failed to load symbol. Error = [%s]", error_buf);
- dlclose(handle);
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- wfd_oem_ops_s *temp_ops;
- (*plugin_load)(&temp_ops);
- manager->oem_ops = temp_ops;
-
- res = wfd_oem_init(temp_ops);
- if (res < 0) {
- WDS_LOGE("Failed to initialize OEM");
- dlclose(handle);
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- /* Configure the plugin here,
- * using config file parameters */
- res = wfd_oem_configure(manager->oem_ops, manager->wfd_oem_conf);
- if (res < 0) {
- WDS_LOGE("Failed to configure OEM");
- dlclose(handle);
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- WDS_LOGD("Succeeded to initialize OEM");
-
- __WDS_LOG_FUNC_EXIT__;
- return handle;
-}
-
-static int wfd_plugin_deinit(wfd_manager_s *manager)
-{
- __WDS_LOG_FUNC_ENTER__;
-
- if (!manager || !manager->plugin_handle) {
- WDS_LOGE("Invalid parameter");
- __WDS_LOG_FUNC_EXIT__;
- return -1;
- }
-
- dlclose(manager->plugin_handle);
- manager->plugin_handle = NULL;
-
- __WDS_LOG_FUNC_EXIT__;
- return 0;
-}
-
-#if defined TIZEN_ENABLE_PRD
-static void *wfd_prd_plugin_init(wfd_manager_s *manager)
-{
- __WDS_LOG_FUNC_ENTER__;
- void *handle;
- struct utsname kernel_info;
- int res;
-
- if (!manager) {
- WDS_LOGE("Invalid parameter");
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- res = uname(&kernel_info);
- if (res) {
- WDS_LOGE("Failed to detect target type");
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
- WDS_LOGD("Node name [%s], HW ID [%s]", kernel_info.nodename, kernel_info.machine);
-
- errno = 0;
-
-#if defined(TIZEN_ARCH_64)
- handle = dlopen(SUPPL_PRD_PLUGIN_64BIT_PATH, RTLD_NOW);
-#else
- handle = dlopen(SUPPL_PRD_PLUGIN_PATH, RTLD_NOW);
-#endif
- if (!handle) {
- WDS_LOGE("Failed to open shared object. [%s]", dlerror());
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- errno = 0;
- int (*plugin_load)(wfd_oem_ops_s **ops) = NULL;
- plugin_load = (int (*)(wfd_oem_ops_s **ops)) dlsym(handle, "wfd_prd_plugin_load");
- if (!plugin_load) {
- WDS_LOGE("Failed to load symbol. Error = [%s]", strerror(errno));
- dlclose(handle);
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
-
- (*plugin_load)((wfd_oem_ops_s **)&manager->oem_ops);
-
- res = wfd_oem_prd_init((wfd_oem_ops_s *)manager->oem_ops);
- if (res < 0) {
- WDS_LOGE("Failed to initialize PRD OEM");
- dlclose(handle);
- __WDS_LOG_FUNC_EXIT__;
- return NULL;
- }
- WDS_LOGD("Succeeded to initialize PRD OEM");
-
- __WDS_LOG_FUNC_EXIT__;
- return handle;
-}
-
-static int wfd_prd_plugin_deinit(wfd_manager_s *manager)
-{
- __WDS_LOG_FUNC_ENTER__;
-
- if (!manager || !manager->prd_plugin_handle) {
- WDS_LOGE("Invalid parameter");
- __WDS_LOG_FUNC_EXIT__;
- return -1;
- }
-
- dlclose(manager->prd_plugin_handle);
- manager->prd_plugin_handle = NULL;
-
- __WDS_LOG_FUNC_EXIT__;
- return 0;
-}
-#endif /* TIZEN_ENABLE_PRD */
-
int wfd_manager_load()
{
__WDS_LOG_FUNC_ENTER__;
}
WDS_LOGD("Succeeded to initialize manager");
- /**
- * wfd_manager_plugin initialization
- */
- g_manager->plugin_handle = wfd_plugin_init(g_manager);
- if (!g_manager->plugin_handle) {
- WDS_LOGE("Failed to initialize plugin");
- wfd_manager_deinit(g_manager);
- __WDS_LOG_FUNC_EXIT__;
- return -1;
- }
- WDS_LOGD("Succeeded to load plugin");
-
if (wfd_manager_iface_init() != 0) {
WDS_LOGE("Failed to initialize iface");
wfd_manager_deinit(g_manager);
return -1;
}
WDS_LOGD("Succeeded to load iface");
-#if defined TIZEN_ENABLE_PRD
- /**
- * wfd_manager_prd_plugin initialization
- */
- g_manager->prd_plugin_handle = wfd_prd_plugin_init(g_manager);
- if (!g_manager->prd_plugin_handle)
- WDS_LOGW("Failed to initialize prd plugin");
- else
- WDS_LOGD("Succeeded to load plugin");
-#endif /* TIZEN_ENABLE_PRD */
-
- if (!wfd_manager_dbus_init()) {
- WDS_LOGE("Failed to DBus");
- wfd_plugin_deinit(g_manager);
- wfd_manager_deinit(g_manager);
- __WDS_LOG_FUNC_EXIT__;
- return -1;
- }
__WDS_LOG_FUNC_EXIT__;
return 0;
void wfd_manager_unload()
{
__WDS_LOG_FUNC_ENTER__;
- wfd_manager_dbus_unregister_nameowner_signal();
-
- wfd_manager_dbus_unregister();
- wfd_manager_dbus_deinit();
-
-#if defined TIZEN_ENABLE_PRD
- wfd_prd_plugin_deinit(g_manager);
-#endif /* TIZEN_ENABLE_PRD */
wfd_manager_iface_deinit();
- wfd_plugin_deinit(g_manager);
wfd_manager_deinit(g_manager);
+
__WDS_LOG_FUNC_EXIT__;
return;
}
#include <fcntl.h>
#include <time.h>
#include <errno.h>
+#include <dlfcn.h>
+#include <sys/utsname.h>
#include <glib.h>
return;
}
+void *wfd_util_plugin_init(wfd_manager_s *manager)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ void *handle;
+ struct utsname kernel_info;
+ int res;
+ char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+
+ if (!manager) {
+ WDS_LOGE("Invalid parameter");
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ res = uname(&kernel_info);
+ if (res) {
+ WDS_LOGE("Failed to detect target type");
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+ WDS_LOGD("Node name [%s], HW ID [%s]", kernel_info.nodename, kernel_info.machine);
+
+ errno = 0;
+
+#if defined(TIZEN_ARCH_64)
+ handle = dlopen(SUPPL_PLUGIN_64BIT_PATH, RTLD_NOW);
+#else
+ handle = dlopen(SUPPL_PLUGIN_PATH, RTLD_NOW);
+#endif
+ if (!handle) {
+ WDS_LOGE("Failed to open shared object. [%s]", dlerror());
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ errno = 0;
+ int (*plugin_load)(wfd_oem_ops_s **ops) = NULL;
+ plugin_load = (int (*)(wfd_oem_ops_s **ops)) dlsym(handle, "wfd_plugin_load");
+ if (!plugin_load) {
+ strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+ WDS_LOGE("Failed to load symbol. Error = [%s]", error_buf);
+ dlclose(handle);
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ wfd_oem_ops_s *temp_ops;
+ (*plugin_load)(&temp_ops);
+ manager->oem_ops = temp_ops;
+
+ res = wfd_oem_init(temp_ops);
+ if (res < 0) {
+ WDS_LOGE("Failed to initialize OEM");
+ dlclose(handle);
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ /* Configure the plugin here,
+ * using config file parameters */
+ res = wfd_oem_configure(manager->oem_ops, manager->wfd_oem_conf);
+ if (res < 0) {
+ WDS_LOGE("Failed to configure OEM");
+ dlclose(handle);
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ WDS_LOGD("Succeeded to initialize OEM");
+
+ __WDS_LOG_FUNC_EXIT__;
+ return handle;
+}
+
+int wfd_util_plugin_deinit(wfd_manager_s *manager)
+{
+ __WDS_LOG_FUNC_ENTER__;
+
+ if (!manager || !manager->plugin_handle) {
+ WDS_LOGE("Invalid parameter");
+ __WDS_LOG_FUNC_EXIT__;
+ return -1;
+ }
+
+ dlclose(manager->plugin_handle);
+ manager->plugin_handle = NULL;
+
+ __WDS_LOG_FUNC_EXIT__;
+ return 0;
+}
+
+#if defined TIZEN_ENABLE_PRD
+void *wfd_util_prd_plugin_init(wfd_manager_s *manager)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ void *handle;
+ struct utsname kernel_info;
+ int res;
+
+ if (!manager) {
+ WDS_LOGE("Invalid parameter");
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ res = uname(&kernel_info);
+ if (res) {
+ WDS_LOGE("Failed to detect target type");
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+ WDS_LOGD("Node name [%s], HW ID [%s]", kernel_info.nodename, kernel_info.machine);
+
+ errno = 0;
+
+#if defined(TIZEN_ARCH_64)
+ handle = dlopen(SUPPL_PRD_PLUGIN_64BIT_PATH, RTLD_NOW);
+#else
+ handle = dlopen(SUPPL_PRD_PLUGIN_PATH, RTLD_NOW);
+#endif
+ if (!handle) {
+ WDS_LOGE("Failed to open shared object. [%s]", dlerror());
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ errno = 0;
+ int (*plugin_load)(wfd_oem_ops_s **ops) = NULL;
+ plugin_load = (int (*)(wfd_oem_ops_s **ops)) dlsym(handle, "wfd_prd_plugin_load");
+ if (!plugin_load) {
+ WDS_LOGE("Failed to load symbol. Error = [%s]", strerror(errno));
+ dlclose(handle);
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+
+ (*plugin_load)((wfd_oem_ops_s **)&manager->oem_ops);
+
+ res = wfd_oem_prd_init((wfd_oem_ops_s *)manager->oem_ops);
+ if (res < 0) {
+ WDS_LOGE("Failed to initialize PRD OEM");
+ dlclose(handle);
+ __WDS_LOG_FUNC_EXIT__;
+ return NULL;
+ }
+ WDS_LOGD("Succeeded to initialize PRD OEM");
+
+ __WDS_LOG_FUNC_EXIT__;
+ return handle;
+}
+
+int wfd_util_prd_plugin_deinit(wfd_manager_s *manager)
+{
+ __WDS_LOG_FUNC_ENTER__;
+
+ if (!manager || !manager->prd_plugin_handle) {
+ WDS_LOGE("Invalid parameter");
+ __WDS_LOG_FUNC_EXIT__;
+ return -1;
+ }
+
+ dlclose(manager->prd_plugin_handle);
+ manager->prd_plugin_handle = NULL;
+
+ __WDS_LOG_FUNC_EXIT__;
+ return 0;
+}
+#endif /* TIZEN_ENABLE_PRD */
+
void wfd_util_load_wfd_conf(wfd_manager_s * manager)
{
__WDS_LOG_FUNC_ENTER__;