FOREACH(flag ${daemon_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
+
+IF (BUILD_GTESTS)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -fvisibility=default -fprofile-arcs -ftest-coverage")
+ELSE (BUILD_GTESTS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
+ENDIF (BUILD_GTESTS)
##Address-Space Layout Randomization
MESSAGE(" - Address-Space Layout Randomizations")
ADD_DEFINITIONS(-DTIZEN_FEATURE_MESH_ON_DEMAND)
ENDIF(TIZEN_FEATURE_MESH_ON_DEMAND)
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS(-DBUILD_GCOV)
+ENDIF(BUILD_GCOV)
+
MESSAGE(" - Generating... dbus interface")
SET(INTROSPECTION_PATH ${CMAKE_CURRENT_SOURCE_DIR}/introspection)
ADD_CUSTOM_COMMAND(
MESSAGE(" - Copying...meshd")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/wmesh.sh.in ${CMAKE_SOURCE_DIR}/files/wmesh.sh @ONLY)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/wmesh.sh DESTINATION ${SBIN_DIR})
+
+IF(BUILD_GTESTS)
+ ADD_SUBDIRECTORY(unittest)
+ENDIF(BUILD_GTESTS)
#define NOTUSED(var) (var = var)
#define wmeshd_check_null_ret_error(name, value, error) do { \
+ /* LCOV_EXCL_START */ \
if (G_UNLIKELY(NULL == (value))) { \
WMESH_LOGE("%s is NULL", name); \
return error; \
} \
+ /* LCOV_EXCL_STOP */ \
} while (FALSE)
#define wmeshd_check_null_ret(name, value) do { \
+ /* LCOV_EXCL_START */ \
if (G_UNLIKELY(NULL == (value))) { \
WMESH_LOGE("%s is NULL", name); \
return; \
} \
+ /* LCOV_EXCL_STOP */ \
} while (FALSE)
#endif /* __WMESH_UTIL_H__ */
%define CHECK_WMESH_PRIVILEGE False
+%define gcov 1
+%define gtests 1
Name: wifi-mesh-manager
Summary: Wi-Fi mesh network daemon
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-network-wifi-manager)
BuildRequires: cmake
+
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
+
# if wmeshd do dhcp instead of connman
Requires: net-tools
Requires: toybox-symlinks-dhcp
CFLAGS=$(echo $CFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
CXXFLAGS=$(echo $CXXFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
+%if 0%{?gcov:1}
+export LDFLAGS+=" -lgcov"
+%endif
+
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DTIZEN_FEATURE_MESH_ON_DEMAND=1 \
-DLIB_DIR=%{_libdir} \
-DBIN_DIR=%{_bindir} \
- -DSBIN_DIR=%{_sbindir}
+ -DSBIN_DIR=%{_sbindir} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
make %{?_smp_mflags}
%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
%attr(644,root,root) %{_unitdir}/wmeshd.service
%attr(750,root,root) %{_sbindir}/wmesh.sh
+
+%if 0%{?gtests:1}
+ %{_bindir}/gtest*
+%endif
+
#define ERROR_MESSAGE_LENGTH 256
+/* LCOV_EXCL_START */
int wmesh_bridge_create(const char* bridge_name)
{
int ret = WMESHD_ERROR_NONE;
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGE("Failed to open socket [%s(%d)]", str_error, errno);
return WMESHD_ERROR_IO_ERROR;
}
#endif
if (val < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- WMESH_LOGD("Failed to delete interface [%s] from bridge [%s(%d)]",
+ WMESH_LOGE("Failed to delete interface [%s] from bridge [%s(%d)]",
interface, str_error, errno);
ret = WMESHD_ERROR_IO_ERROR;
return ret;
}
+/* LCOV_EXCL_STOP */
int wmesh_bridge_set_stp(const char* bridge_name, bool state)
{
stp_state, 0, 0 };
if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ - 1) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", bridge_name);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
+ /* LCOV_EXCL_START */
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGE("Failed to open socket [%s(%d)]", str_error, errno);
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", bridge_name);
val = ioctl(br_fd, SIOCDEVPRIVATE, &ifr);
if (val < 0) {
+ /* LCOV_EXCL_START */
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
WMESH_LOGE("Failed to set bridge[%s] stp state", bridge_name);
WMESH_LOGE(" %s(%d)", str_error, errno);
ret = WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
close(br_fd);
static int _wmesh_gdbus_get_mesh_network_property(wmesh_service *service,
const gchar* object_path, wmesh_network_info_s *result);
+/* LCOV_EXCL_START */
static int __channel_to_frequency(int channel, enum nl80211_band band)
{
if (channel <= 0)
else
return 0;
}
-
+/* LCOV_EXCL_STOP */
static GDBusProxy *_proxy_get_connman(wmesh_service *service)
{
GDBusProxy *proxy = NULL;
CONNMAN_INTERFACE_MANAGER,
NULL, NULL);
} else
- proxy = _gproxy_connman;
+ proxy = _gproxy_connman; //LCOV_EXCL_LINE
return proxy;
}
CONNMAN_INTERFACE_MESH,
NULL, NULL);
} else
- proxy = _gproxy_connman_mesh;
+ proxy = _gproxy_connman_mesh; //LCOV_EXCL_LINE
return proxy;
}
CONNMAN_INTERFACE_TECH, /* interface Name */
NULL, NULL);
} else
- proxy = _gproxy_connman_ethernet;
+ proxy = _gproxy_connman_ethernet; //LCOV_EXCL_LINE
return proxy;
}
CONNMAN_INTERFACE_TECH,
NULL, NULL);
} else
- proxy = _gproxy_connman_technology;
+ proxy = _gproxy_connman_technology; //LCOV_EXCL_LINE
return proxy;
}
+/* LCOV_EXCL_START */
static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec,
gpointer *user_data)
{
g_free(name_owner);
}
+/* LCOV_EXCL_STOP */
static int _wmeshd_create_gdbus_call(wmesh_service *service)
{
GError *error = NULL;
if (NULL == service)
- return WMESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
if (NULL != service->connection)
- return WMESHD_ERROR_ALREADY_REGISTERED;
+ return WMESHD_ERROR_ALREADY_REGISTERED; //LCOV_EXCL_LINE
service->connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (service->connection == NULL) {
+ /* LCOV_EXCL_START */
if (error != NULL) {
WMESH_LOGE("Failed to connect to the D-BUS daemon [%s]", error->message);
g_error_free(error);
}
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
id = g_signal_connect(service->connection, "notify::g-name-owner",
G_CALLBACK(_dbus_name_owner_notify), service);
if (0 == id) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_signal_connect() Fail");
g_object_unref(service->connection);
service->connection = NULL;
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
return WMESHD_ERROR_NONE;
}
+/* LCOV_EXCL_START */
static void _wmeshd_signal_handler(GDBusConnection *connection,
const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
const gchar *signal_name, GVariant *parameters, gpointer user_data)
ret = _wmesh_gdbus_get_mesh_network_property(service, object_path, &network_info);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Cannot get valid network property !");
+ WMESH_LOGE("Cannot get valid network property !"); //LCOV_EXCL_LINE
if (g_strcmp0("association", var) == 0) {
/* Joined mesh network */
g_free(network_info.bssid);
}
}
+/* LCOV_EXCL_STOP */
static void _wmeshd_subscribe_event(wmesh_service *service)
{
"ScanDone", "/", NULL,
G_DBUS_CALL_FLAGS_NONE, _wmeshd_signal_handler, service, NULL);
if (0 == id) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
return;
+ /* LCOV_EXCL_STOP */
}
service->dbus_sub_ids = g_list_append(service->dbus_sub_ids, GUINT_TO_POINTER(id));
WMESH_LOGD("[Signal subscribe] : ScanDone (%d)", id);
NULL,
G_DBUS_CALL_FLAGS_NONE, _wmeshd_signal_handler, service, NULL);
if (0 == id) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
return;
+ /* LCOV_EXCL_STOP */
}
service->dbus_sub_ids = g_list_append(service->dbus_sub_ids, GUINT_TO_POINTER(id));
WMESH_LOGD("[Signal subscribe] : PropertyChanged (%d)", id);
rv = _wmeshd_create_gdbus_call(service);
if (WMESHD_ERROR_NONE != rv)
- return rv;
+ return rv; /* LCOV_EXCL_LINE */
service->ca = g_cancellable_new();
int rv;
if (NULL == service)
- return WMESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */
/* Unsubscribe events */
_wmeshd_unsubscribe_event(service);
-1, NULL, &error);
if (variant) {
WMESH_LOGD("Successfully requested. [MeshInterfaceAdd]");
+ /* LCOV_EXCL_START */
} else if (error) {
ret = WMESHD_ERROR_IO_ERROR;
WMESH_LOGE("Failed DBus call [%s]", error->message);
ret = WMESHD_ERROR_INVALID_PARAMETER;
g_error_free(error);
}
-
+ /* LCOV_EXCL_STOP */
return ret;
}
-1, NULL, &error);
if (variant) {
WMESH_LOGD("Successfully requested. [MeshInterfaceRemove]");
+ /* LCOV_EXCL_START */
} else if (error) {
ret = WMESHD_ERROR_IO_ERROR;
WMESH_LOGE("Failed DBus call [%s]", error->message);
ret = WMESHD_ERROR_NONE;
g_error_free(error);
}
+ /* LCOV_EXCL_STOP */
return ret;
}
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- WMESH_LOGD("Successfully requested. [MeshSpecificScan]");
+ WMESH_LOGD("Successfully requested. [MeshSpecificScan]"); /* LCOV_EXCL_LINE */
+ /* LCOV_EXCL_START */
} else if (error) {
WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_STOP */
return WMESHD_ERROR_NONE;
}
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- WMESH_LOGD("Successfully requested. [AbortScan]");
+ WMESH_LOGD("Successfully requested. [AbortScan]"); /* LCOV_EXCL_LINE */
+ /* LCOV_EXCL_START */
} else if (error) {
ret = WMESHD_ERROR_IO_ERROR;
WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
}
+ /* LCOV_EXCL_START */
return ret;
}
+/* LCOV_EXCL_START */
static void _on_scan_result_destroy(gpointer data)
{
wmesh_scan_result_s *scan_item = (wmesh_scan_result_s *)data;
g_free(peer->address);
g_free(peer);
}
+/* LCOV_EXCL_STOP */
static void _get_joined_network(wmesh_service *service, GVariant *variant)
{
const gchar* buf = NULL;
g_variant_get(variant, "(a(oa{sv}))", &peer);
+ /* LCOV_EXCL_START */
while ((child = g_variant_iter_next_value(peer))) {
wmesh_network_info_s *joined_info = NULL;
gboolean valid_state = TRUE;
/* If found, stop loop iteration */
break;
}
+ /* LCOV_EXCL_STOP */
g_variant_iter_free(peer);
}
+
static void _get_mesh_peers(wmesh_service *service, GVariant *variant)
{
GVariantIter *peer = NULL;
const gchar* obj_path = NULL;
g_variant_get(variant, "(a(oa{sv}))", &peer);
+ /* LCOV_EXCL_START */
while ((child = g_variant_iter_next_value(peer))) {
wmesh_scan_result_s *scan_info = NULL;
g_variant_iter_free(property);
}
+ /* LCOV_EXCL_STOP */
g_variant_iter_free(peer);
}
g_variant_get(variant, "(a(a{sv}))", &peer);
while ((child = g_variant_iter_next_value(peer))) {
+ /* LCOV_EXCL_START */
wmesh_peer_info_s *peer_info = NULL;
peer_info = g_try_new0(wmesh_peer_info_s, 1);
service->connected_mesh_peers =
g_list_prepend(service->connected_mesh_peers, peer_info);
+ /* LCOV_EXCL_STOP */
}
g_variant_iter_free(peer);
}
WMESH_LOGD("Successfully requested. [GetMeshPeers]");
if (service->scanned_mesh_network) {
+ /* LCOV_EXCL_START */
g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy);
service->scanned_mesh_network = NULL;
+ /* LCOV_EXCL_STOP */
}
_get_mesh_peers(service, variant);
/* List item is saved with reversed order for efficiency. */
service->scanned_mesh_network =
g_list_reverse(service->scanned_mesh_network);
+ /* LCOV_EXCL_START */
} else if (error) {
WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_STOP */
return WMESHD_ERROR_NONE;
}
WMESH_LOGD("Successfully requested. [GetMeshPeers]");
if (service->joined_network) {
+ /* LCOV_EXCL_START */
g_free(service->joined_network->mesh_id);
g_free(service->joined_network->bssid);
g_free(service->joined_network->ipv4_address);
g_free(service->joined_network->ipv4_netmask);
g_free(service->joined_network);
service->joined_network = NULL;
+ /* LCOV_EXCL_STOP */
}
_get_joined_network(service, variant);
+ /* LCOV_EXCL_START */
} else if (error) {
WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_STOP */
return WMESHD_ERROR_NONE;
}
+/* LCOV_EXCL_START */
int wmesh_gdbus_get_connected_peers(wmesh_service *service)
{
GVariant *variant = NULL;
}
g_variant_iter_free(property);
}
+/* LCOV_EXCL_STOP */
static int _wmesh_gdbus_get_mesh_network_property(wmesh_service *service,
const gchar* object_path, wmesh_network_info_s *result)
/* Get properties */
_get_mesh_property(variant, result);
+ /* LCOV_EXCL_START */
} else if (error) {
- WMESH_LOGE("Failed DBus call [%s]", error->message);
+ LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_STOP */
return WMESHD_ERROR_NONE;
}
-1, NULL, &error);
g_variant_builder_unref(&builder);
if (variant) {
- WMESH_LOGD("Successfully requested. [MeshCreateNetwork]");
+ WMESH_LOGD("Successfully requested. [MeshCreateNetwork]"); /* LCOV_EXCL_LINE */
+ /* LCOV_EXCL_START */
} else if (error) {
WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_STOP */
return WMESHD_ERROR_NONE;
}
+/* LCOV_EXCL_START */
int wmesh_gdbus_set_passphrase(wmesh_service *service, wmesh_scan_result_s *info, gchar *passphrase)
{
int ret = WMESHD_ERROR_NONE;
if (variant) {
WMESH_LOGD("Successfully requested. [SetProperty]");
} else if (error) {
- WMESH_LOGE("Failed DBus call [%s]", error->message);
+ LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
ret = WMESHD_ERROR_IO_ERROR;
}
if (variant) {
WMESH_LOGD("Successfully requested. [Disconnect]");
} else if (error) {
- WMESH_LOGE("Failed DBus call [%s]", error->message);
+ LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
if (variant) {
WMESH_LOGD("Successfully requested. [Remove]");
} else if (error) {
- WMESH_LOGE("Failed DBus call [%s]", error->message);
+ LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return WMESHD_ERROR_IO_ERROR;
}
return ret;
}
+/* LCOV_EXCL_STOP */
int wmesh_gdbus_set_mesh_gate(wmesh_service *service)
{
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- WMESH_LOGD("Successfully requested. [SetMeshGate]");
+ WMESH_LOGD("Successfully requested. [SetMeshGate]"); /* LCOV_EXCL_LINE */
+ /* LCOV_EXCL_START */
} else if (error) {
ret = WMESHD_ERROR_IO_ERROR;
WMESH_LOGE("Failed DBus call [%s]", error->message);
ret = WMESHD_ERROR_INVALID_PARAMETER;
g_error_free(error);
}
+ /* LCOV_EXCL_STOP */
return ret;
}
+/* LCOV_EXCL_START */
int wmesh_gdbus_mesh_remove_peer(wmesh_service *service, char *peer)
{
GVariant *variant = NULL;
return ret;
}
+/* LCOV_EXCL_STOP */
ETHERNET_CABLE_ATTACHED
} cable_state_e;
+/* LCOV_EXCL_START */
int wmesh_interface_set(const char *interface, const char* ip_addr,
wmesh_set_interface_type_e type)
{
return res;
}
#endif
+/* LCOV_EXCL_STOP */
static bool _check_interface_exists(const char* if_name)
{
}
}
- return false;
+ return false; //LCOV_EXCL_LINE
}
/* Check if interface is bridged */
ret = access(buf, F_OK);
if (ret >= 0) {
/* This name is exists. */
- return true;
+ return true; //LCOV_EXCL_LINE
}
}
- return false;
+ return false; //LCOV_EXCL_LINE
}
+/* LCOV_EXCL_START */
char* wmesh_interface_get_address(const char* if_name)
{
FILE *pf;
return result;
}
+/* LCOV_EXCL_STOP */
int wmesh_interface_initialize(wmesh_interface_s *info)
{
if (NULL == info) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
info->bridge_interface = g_strdup(MESH_DEFAULT_BRIDGE_INTERFACE);
if (NULL == info->bridge_interface) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get bridge interface !");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
info->base_interface = g_strdup(MESH_DEFAULT_BASE_INTERFACE);
if (NULL == info->bridge_interface) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get base interface !");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
info->mesh_interface = g_strdup(MESH_DEFAULT_MESH_INTERFACE);
if (NULL == info->bridge_interface) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get mesh interface !");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
info->softap_interface = g_strdup(MESH_DEFAULT_SOFTAP_INTERFACE);
if (0 == access(file_path, F_OK)) {
fd = fopen(file_path, "r");
if (fd == NULL) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Error! Could not open /sys/class/net/%s/carrier file",
interface);
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
} else {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Error! Could not access /sys/class/net/%s/carrier file",
interface);
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
errno = 0;
rv = fscanf(fd, "%d", &ret);
if (rv < 0) {
+ /* LCOV_EXCL_START */
strerror_r(errno, error_buf, 256);
WMESH_LOGE("Error! Failed to read from file, rv:[%d], error:[%s]",
rv, error_buf);
fclose(fd);
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
if (ret == 1) {
WMESH_LOGD("/sys/class/net/%s/carrier : [%d]", interface, ret);
*status = ETHERNET_CABLE_ATTACHED;
WMESH_LOGD("/sys/class/net/%s/carrier : [%d]", interface, ret);
*status = ETHERNET_CABLE_DETACHED;
}
+ /* LCOV_EXCL_STOP */
fclose(fd);
return WMESHD_ERROR_NONE;
cable_state_e cable_state = ETHERNET_CABLE_DETACHED;
if (NULL == external_interface || NULL == state)
- return WMESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
bool ex = _check_interface_exists(external_interface);
if (FALSE == ex) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("External interface[%s] was not found.", external_interface);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
/* If external interface seems Ethernet, check cable state */
if (g_str_has_prefix(external_interface, "eth")) {
ret = _check_ethernet_cable_plugin_status(external_interface, &cable_state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get Ethernet cable state");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
}
*state = FALSE;
if (ETHERNET_CABLE_ATTACHED == cable_state)
- *state = TRUE;
+ *state = TRUE; /* LCOV_EXCL_LINE */
return WMESHD_ERROR_NONE;
}
bool ex = FALSE;
if (NULL == interface || strlen(interface) == 0)
- return WMESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
ex = _check_interface_exists(interface);
if (FALSE == ex) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Interface[%s] was not found.", interface);
return WMESHD_ERROR_NO_DATA;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
if (NULL == bridge || NULL == interface ||
strlen(bridge) == 0 || strlen(interface) == 0)
- return WMESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
ex = _check_bridge_interface_exists(bridge, interface);
if (FALSE == ex) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Interface[%s] was not found.", interface);
return WMESHD_ERROR_NO_DATA;
+ /* LCOV_EXCL_STOP */
}
- return WMESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE; /* LCOV_EXCL_LINE */
}
state->nl_socket = nl_socket_alloc();
if (!state->nl_socket) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to allocate netlink socket.");
return WMESHD_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
if (genl_connect(state->nl_socket)) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to connect to generic netlink.");
err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
nl_socket_set_buffer_size(state->nl_socket, 8192, 8192);
state->nl80211_id = genl_ctrl_resolve(state->nl_socket, "nl80211");
if (state->nl80211_id < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("nl80211 not found.");
err = WMESHD_ERROR_NO_DATA;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
return 0;
DESTROY:
+ /* LCOV_EXCL_START */
nl_socket_free(state->nl_socket);
return err;
+ /* LCOV_EXCL_STOP */
}
static void __clean_nl80211(mesh_nl_state *state)
{
if (!state)
- return;
+ return; /* LCOV_EXCL_LINE */
if (state->nl_socket) {
nl_socket_free(state->nl_socket);
int device_index = 0;
if (NULL == if_name) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
device_index = if_nametoindex(if_name);
if (device_index == 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("No interface index found [%s]", if_name);
return WMESHD_ERROR_NO_DATA;
+ /* LCOV_EXCL_STOP */
}
- *index = device_index;
+ *index = device_index; /* LCOV_EXCL_LINE */
- return WMESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE; /* LCOV_EXCL_LINE */
}
+/* LCOV_EXCL_START */
static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
{
mesh_nl_state *state = (mesh_nl_state *)arg;
return NL_STOP;
}
+/* LCOV_EXCL_STOP */
static int ack_simple_handler(struct nl_msg *msg, void *arg)
{
genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL);
if (!tb[CTRL_ATTR_MCAST_GROUPS])
- return NL_SKIP;
+ return NL_SKIP; //LCOV_EXCL_LINE
nla_for_each_nested(mcast_group, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcast_group) {
struct nlattr *tb_mcast_group[CTRL_ATTR_MCAST_GRP_MAX + 1];
if (!tb_mcast_group[CTRL_ATTR_MCAST_GRP_NAME] ||
!tb_mcast_group[CTRL_ATTR_MCAST_GRP_ID])
- continue;
+ continue; //LCOV_EXCL_LINE
if (strncmp(nla_data(tb_mcast_group[CTRL_ATTR_MCAST_GRP_NAME]),
group->group,
nla_len(tb_mcast_group[CTRL_ATTR_MCAST_GRP_NAME])))
- continue;
+ continue; //LCOV_EXCL_LINE
group->id = nla_get_u32(tb_mcast_group[CTRL_ATTR_MCAST_GRP_ID]);
WMESH_LOGD("mcast group id [%d]", group->id);
msg = nlmsg_alloc();
if (!msg)
- return -ENOMEM;
+ return -ENOMEM; //LCOV_EXCL_LINE
cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!cb) {
+ /* LCOV_EXCL_START */
ret = -ENOMEM;
goto FAILURE;
+ /* LCOV_EXCL_STOP */
}
ctrlid = genl_ctrl_resolve(sock, "nlctrl");
ret = nl_send_auto(sock, msg);
if (ret < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_send_auto");
goto out;
+ /* LCOV_EXCL_STOP */
}
ret = 1;
/* Configuration multicast group */
mcid = __nl_get_multicast_id(state->nl_socket, "nl80211", "config");
if (mcid < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get nl80211 config");
return mcid;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Mesh multicast id (config): [%d]", mcid);
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
+ /* LCOV_EXCL_STOP */
}
/* Scan multicast group */
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
+ /* LCOV_EXCL_STOP */
}
}
WMESH_LOGD("Mesh multicast id (scan): [%d]", mcid);
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
+ /* LCOV_EXCL_STOP */
}
}
WMESH_LOGD("Mesh multicast id (regulatory): [%d]", mcid);
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
+ /* LCOV_EXCL_STOP */
}
}
WMESH_LOGD("Mesh multicast id (mlme): [%d]", mcid);
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
+ /* LCOV_EXCL_STOP */
}
}
WMESH_LOGD("Mesh multicast id (vendor): [%d]", mcid);
static void _delete_mesh_nl_state(mesh_nl_state **state)
{
if (NULL == state || NULL == *state)
- return;
+ return; //LCOV_EXCL_LINE
g_free(*state);
*state = NULL;
}
+/* LCOV_EXCL_START */
static int valid_handler(struct nl_msg *msg, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
return NL_SKIP;
}
+/* LCOV_EXCL_STOP */
static int no_seq_check(struct nl_msg *msg, void *arg)
{
static void __clean_netlink_message(mesh_nl_state *state)
{
if (!state)
- return;
+ return; /* LCOV_EXCL_LINE */
if (state->cb)
nl_cb_put(state->cb);
int err = WMESHD_ERROR_NONE;
if (NULL == state) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter !");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
/* Create netlink message */
state->msg = nlmsg_alloc();
if (NULL == state->msg) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to allocate netlink message");
return WMESHD_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
/* NL_CB_DEFAULT */
state->cb = nl_cb_alloc(NL_CB_DEFAULT);
state->s_cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!state->cb) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to allocate netlink callback");
err = WMESHD_ERROR_OUT_OF_MEMORY;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Set socket callback */
return WMESHD_ERROR_NONE;
DESTROY:
+ /* LCOV_EXCL_START */
__clean_netlink_message(state);
return err;
+ /* LCOV_EXCL_STOP */
}
static gboolean _on_socket_event_io_received(GIOChannel *source,
WMESH_LOGD("[Event] I/O received");
while (nl_recvmsgs_report(state->nl_socket, state->cb) > 0)
- WMESH_LOGD(" count [%02d]", ++test);
+ WMESH_LOGD(" count [%02d]", ++test); //LCOV_EXCL_LINE
/* Do not remove I/O source */
return TRUE;
"%02x:%02x:%02x:%02x:%02x:%02x",
arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
}
+
+/* LCOV_EXCL_START */
#if defined(NL80211_STA_INFO_CHAIN_SIGNAL) || defined(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)
static char *get_chain_signal(struct nlattr *attr_list)
{
if (nla_parse_nested(rate_info, NL80211_RATE_INFO_MAX, bitrate_attr, rate_policy)) {
if (buf)
- snprintf(buf, buflen, "failed to parse nested rate attributes!");
+ snprintf(buf, buflen, "failed to parse nested rate attributes!"); //LCOV_EXCL_LINE
return 0;
}
return NL_SKIP;
}
+/* LCOV_EXCL_STOP */
static int _send_nl_set_mesh_parameter(const char* mesh_if_name,
const char* param_name, unsigned int value)
ret = __initialize_nl80211(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize nl80211");
return ret;
+ /* LCOV_EXCL_STOP */
}
ret = __initialize_netlink_message(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Set command into message */
/* Add attributes into message */
ret = __get_device_index_from_string(mesh_if_name, &device_index);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get mesh device index");
err = ret;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
container = nla_nest_start(state.msg, NL80211_ATTR_MESH_PARAMS);
if (!container) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Logic need to be changed if additional parameter is required */
NLA_PUT_U8(state.msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
(uint8_t)value);
} else {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Parameter [%s] is not required !", param_name);
nla_nest_end(state.msg, container);
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
nla_nest_end(state.msg, container);
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* sync response */
return err;
nla_put_failure:
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
static int _send_nl_get_station_info(const char* if_name, GList **station_list)
ret = __initialize_nl80211(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize nl80211");
return ret;
+ /* LCOV_EXCL_STOP */
}
ret = __initialize_netlink_message(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Set command into message */
WMESH_LOGD("Dump station list with interface [%s]", if_name);
ret = __get_device_index_from_string(if_name, &device_index);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get mesh interface device index");
err = ret;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* sync response */
state.callback_state = MESH_NL_CALLBACK_TRYING;
while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
+ /* LCOV_EXCL_START */
WMESH_LOGD(" count [%02d]", ++test);
nl_recvmsgs(state.nl_socket, state.cb);
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Finished");
return err;
nla_put_failure:
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
static int _send_nl_get_mpath_info(const char* if_name, GList **mpath_list)
ret = __initialize_nl80211(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize nl80211");
return ret;
+ /* LCOV_EXCL_STOP */
}
ret = __initialize_netlink_message(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Set command into message */
WMESH_LOGD("Dump station list with interface [%s]", if_name);
ret = __get_device_index_from_string(if_name, &device_index);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get mesh interface device index");
err = ret;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* sync response */
state.callback_state = MESH_NL_CALLBACK_TRYING;
while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
+ /* LCOV_EXCL_START */
WMESH_LOGD(" count [%02d]", ++test);
nl_recvmsgs(state.nl_socket, state.cb);
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Finished");
return err;
nla_put_failure:
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
static int _send_nl_get_meshconf_info(wmesh_service *service)
ret = __initialize_nl80211(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize nl80211");
return ret;
+ /* LCOV_EXCL_STOP */
}
ret = __initialize_netlink_message(&state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Set command into message */
service->interface_info->mesh_interface);
ret = __get_device_index_from_string(
service->interface_info->mesh_interface, &device_index);
- if (WMESHD_ERROR_NONE != ret) {
+ if (WMESHD_ERROR_NONE != ret)
+ /* LCOV_EXCL_START */{
WMESH_LOGE("Failed to get mesh interface device index");
err = ret;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* sync response */
state.callback_state = MESH_NL_CALLBACK_TRYING;
while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
+ /* LCOV_EXCL_START */
WMESH_LOGD(" count [%02d]", ++test);
nl_recvmsgs(state.nl_socket, state.cb);
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Finished");
return err;
nla_put_failure:
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
static int _send_nl_register_event_handler(wmesh_service *service)
GIOChannel *recv_channel = NULL;
if (event_state) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Already event handler registered !");
return WMESHD_ERROR_IN_PROGRESS;
+ /* LCOV_EXCL_STOP */
}
event_state = _create_mesh_nl_state("");
ret = __initialize_nl80211(event_state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize nl80211");
return ret;
+ /* LCOV_EXCL_STOP */
}
/* Subscribe multicast group should be proceed before scanning */
ret = __prepare_listen_events(event_state);
if (ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("__prepare_listen_events : [%d]", ret);
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
ret = __initialize_netlink_message(event_state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
+ /* LCOV_EXCL_STOP */
}
/* Set command into message */
/* Change socket type to non-blocking */
ret = nl_socket_set_nonblocking(event_state->nl_socket);
if (ret < 0)
- WMESH_LOGE("Failed to non-blocking socket [%s](%d)", nl_geterror(ret), ret);
+ WMESH_LOGE("Failed to non-blocking socket [%s](%d)", nl_geterror(ret), ret); /* LCOV_EXCL_LINE */
/* Register I/O callback to wait asynchronously */
+ /* LCOV_EXCL_START */
if (FALSE == event_state->error_occured) {
recv_channel = g_io_channel_unix_new(nl_socket_get_fd(event_state->nl_socket));
event_state->event_source = g_io_add_watch(recv_channel,
WMESH_LOGE("Error responded. Failed to register event callback !!");
goto DESTROY;
}
+ /* LCOV_EXCL_STOP */
/* Resource should be free on I/O callback */
return WMESHD_ERROR_NONE;
DESTROY:
+ /* LCOV_EXCL_START */
__clean_netlink_message(event_state);
__clean_nl80211(event_state);
_delete_mesh_nl_state(&event_state);
return err;
+ /* LCOV_EXCL_STOP */
}
+/* LCOV_EXCL_STOP */
int wmesh_netlink_set_mesh_parameter(const char* mesh_if_name,
const char* param_name, unsigned int value)
int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Set mesh[%s] param [%s] value [%d]",
int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
if (NULL == station_list) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", station_list);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Get connected stations");
int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
if (NULL == mpath_list) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", mpath_list);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Get current mpath info");
int ret = WMESHD_ERROR_NONE;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter [%p]", service);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Get current Mesh Config info");
#define MESH_MONITORING_TIME 5
#define MESH_MAXIMUM_BEACON_LOST_COUNT 10
+/* LCOV_EXCL_START */
static void _on_station_list_destroy(gpointer data)
{
wmesh_station_info_s *info = (wmesh_station_info_s*)data;
return ret;
}
+
#if 0
static gboolean _get_mpath_info(void *pdata)
{
return G_SOURCE_CONTINUE;
}
+/* LCOV_EXCL_STOP */
int wmesh_start_monitor_service(void *pdata)
{
wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
if (service->monitor_timer)
- wmesh_stop_monitor_service(pdata);
+ wmesh_stop_monitor_service(pdata); /* LCOV_EXCL_LINE */
- service->monitor_timer = g_timeout_add_seconds(MESH_MONITORING_TIME, _on_mesh_monitor_cb, service);
+ service->monitor_timer = g_timeout_add_seconds(MESH_MONITORING_TIME,
+ _on_mesh_monitor_cb, service);
WMESH_LOGD("Peer Monitoring Service Started");
}
WMESH_LOGD("Peer Monitoring Service Stopped");
-
- /* After mesh interface is removed then ethernet is disabled when ethernet
- * interface is bridged, so try to enable ethernet again */
- WMESH_LOGD("Enable ethernet interface");
- wmesh_gdbus_enable_ethernet_interface(service, true);
return ret;
}
ret = wmesh_interface_check_external_exists(external_interface, &state);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get external interface state !");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD(" Ethernet cable state [%s]",
(state) ? "Connected" : "Disconnected");
/* Turn STP on */
ret = wmesh_bridge_set_stp(bridge_interface, TRUE);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to turn STP on !");
return ret;
+ /* LCOV_EXCL_STOP */
}
/* Set mesh parameters */
ret = wmesh_netlink_set_mesh_parameter(mesh_interface,
"mesh_hwmp_rootmode", 4);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 4");
+ WMESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 4"); //LCOV_EXCL_LINE
ret = wmesh_netlink_set_mesh_parameter(mesh_interface,
"mesh_gate_announcements", 1);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to set [mesh_gate_announcements] : 1");
+ WMESH_LOGE("Failed to set [mesh_gate_announcements] : 1"); //LCOV_EXCL_LINE
return WMESHD_ERROR_NONE;
}
ret = wmesh_netlink_set_mesh_parameter(mesh_interface,
"mesh_hwmp_rootmode", 0);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 0");
+ WMESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 0"); //LCOV_EXCL_LINE
ret = wmesh_netlink_set_mesh_parameter(mesh_interface,
"mesh_gate_announcements", 0);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to set [mesh_gate_announcements] : 0");
+ WMESH_LOGE("Failed to set [mesh_gate_announcements] : 0"); //LCOV_EXCL_LINE
/* Turn STP off */
ret = wmesh_bridge_set_stp(bridge_interface, FALSE);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to turn STP off!");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
}
+/* LCOV_EXCL_START */
int wmesh_request_add_bridge_interface(const char* bridge_interface,
const char* interface)
{
return WMESHD_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
int wmesh_request_remove_bridge_interface(const char* bridge_interface,
const char* interface)
int ret = WMESHD_ERROR_NONE;
if (NULL == bridge_interface || NULL == interface) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameters");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("Removing interface[%s] from bridge[%s]...", interface, bridge_interface);
ret = wmesh_interface_check_bridge_interface_exists(bridge_interface, interface);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGD("Interface is not exist in bridge");
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
/* Remove external interface into bridge */
ret = wmesh_bridge_del_interface(bridge_interface, interface);
if (WMESHD_ERROR_NONE != ret) {
}
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
int wmesh_request_set_softap_config(const char* softap_interface,
ret = wmesh_softap_set_configuration(softap_interface, ssid, mode, channel,
visibility, max_sta, security, passphrase);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to set Configuration for SoftAP");
return ret;
+ /* LCOV_EXCL_STOP */
}
return ret;
ret = wmesh_softap_get_configuration(softap_interface, ssid, mode, channel,
visibility, max_sta, security, passphrase);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get Configuration for SoftAP");
return ret;
+ /* LCOV_EXCL_STOP */
}
return ret;
WMESH_LOGD("Request to turn SoftAP on");
ret = wmesh_softap_enable_softap(softap_interface);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to wmesh_softap_enable_softap");
return ret;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
/* Add softAP interface into bridge */
ret = wmesh_request_add_bridge_interface(bridge_interface, softap_interface);
if (WMESHD_ERROR_NONE != ret) {
}
return ret;
+ /* LCOV_EXCL_STOP */
}
int wmesh_request_disable_softap(
/* Remove softAP interface from bridge */
ret = wmesh_request_remove_bridge_interface(bridge_interface, softap_interface);
if (WMESHD_ERROR_NONE != ret)
- return ret;
+ return ret; //LCOV_EXCL_LINE
return ret;
}
/* Get station info */
ret = wmesh_netlink_get_station_info(mesh_interface, station_list);
if (WMESHD_ERROR_NONE != ret)
- return ret;
+ return ret; //LCOV_EXCL_LINE
return WMESHD_ERROR_NONE;
}
/* Get MPath info */
ret = wmesh_netlink_get_mpath_info(mesh_interface, mpath_list);
if (WMESHD_ERROR_NONE != ret)
- return ret;
+ return ret; //LCOV_EXCL_LINE
return WMESHD_ERROR_NONE;
}
/* Get MPath info */
ret = wmesh_netlink_get_meshconf_info(service);
if (WMESHD_ERROR_NONE != ret)
- return ret;
+ return ret; //LCOV_EXCL_LINE
return WMESHD_ERROR_NONE;
}
/* Get MPath info */
ret = wmesh_netlink_register_event_handler(service);
if (WMESHD_ERROR_NONE != ret)
- return ret;
+ return ret; //LCOV_EXCL_LINE
return WMESHD_ERROR_NONE;
}
/* Get MPath info */
ret = wmesh_netlink_unregister_event_handler();
if (WMESHD_ERROR_NONE != ret)
- return ret;
+ return ret; //LCOV_EXCL_LINE
return WMESHD_ERROR_NONE;
}
wmesh_interface_s *info = NULL;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Enable mesh network");
info = service->interface_info;
ret = wmesh_interface_check(info->mesh_interface);
if (WMESHD_ERROR_NONE == ret) {
+ /* LCOV_EXCL_START */
/* Interface already exists */
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
ret = wmesh_gdbus_create_mesh_interface(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to create mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
{
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Disable mesh network");
ret = wmesh_gdbus_remove_mesh_interface(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to disable mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
{
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Request scan for mesh network");
ret = wmesh_gdbus_mesh_scan(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to request scan for mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
{
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Request specific scan for mesh network");
ret = wmesh_gdbus_mesh_specific_scan(service, mesh_id, channel);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to request specific scan for mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
{
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Cancel scan for mesh network");
ret = wmesh_gdbus_mesh_cancel_scan(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to cancel scan for mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
{
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Get mesh networks");
ret = wmesh_gdbus_get_mesh_networks(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get mesh networks !");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
}
if (FALSE == found)
- return WMESHD_ERROR_NO_DATA;
+ return WMESHD_ERROR_NO_DATA; //LCOV_EXCL_LINE
return ret;
}
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Get joined mesh network");
ret = wmesh_gdbus_get_joined_mesh_network(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get joined mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Get connected mesh peers");
ret = wmesh_gdbus_get_connected_peers(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get connected mesh peers");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
int ret;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Create a new mesh network");
ret = wmesh_gdbus_create_network(service, mesh_id, channel, sec);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to create mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
wmesh_scan_result_s *info = NULL;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Connect mesh network");
ret = _select_matched_network(service->scanned_mesh_network,
mesh_id, channel, sec, &info);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to mesh_network_get_first_mesh_network");
return ret;
+ /* LCOV_EXCL_STOP */
}
/* Set passphrase */
if (NULL != passphrase) {
ret = wmesh_gdbus_set_passphrase(service, info, passphrase);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to set passphrase for mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
} else {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Passphrase is required !");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
}
ret = wmesh_gdbus_connect_network(service, info);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to connect mesh network");
return ret;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
wmesh_scan_result_s *info = NULL;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Disconnect mesh network");
ret = _select_matched_network(service->scanned_mesh_network,
mesh_id, channel, sec, &info);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to _select_matched_network");
return ret;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
ret = wmesh_gdbus_disconnect_network(service, info);
if (WMESHD_ERROR_NONE != ret) {
WMESH_LOGE("Failed to disconnect mesh network");
}
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
int wmesh_request_remove_mesh_network(wmesh_service *service,
wmesh_scan_result_s *info = NULL;
if (NULL == service) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("[IPC] Remove mesh network");
ret = _select_matched_network(service->scanned_mesh_network,
mesh_id, channel, sec, &info);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to _select_matched_network");
return ret;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
ret = wmesh_gdbus_remove_network(service, info);
if (WMESHD_ERROR_NONE != ret) {
WMESH_LOGE("Failed to remove mesh network");
}
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
/* Notifications */
#define CASE_TO_STR(x) case x: return #x;
+/* LCOV_EXCL_START */
static const char* wifi_error_to_string(wifi_manager_error_e err)
{
switch (err) {
return "WIFI_MANAGER_ERROR_UNKNOWN";
}
}
+/* LCOV_EXCL_STOP */
NetWmesh* wmeshd_dbus_get_object()
{
return meshd_dbus_object;
}
+/* LCOV_EXCL_START */
int64_t wmeshd_dbus_generate_signal_number()
{
static int64_t i = 0;
return g_strcmp0(client->bus_name, b);
}
+/* LCOV_EXCL_STOP */
static inline GList* _wmeshd_dbus_client_list_find_client(const gchar *owner)
{
g_mutex_lock(&meshd_dbus_client_list_mutex);
client = _wmeshd_dbus_client_list_find_client(old_owner);
if (client) { /* found bus name in our bus list */
+ /* LCOV_EXCL_START */
WMESH_LOGD("bus(%s) stopped", old_owner);
meshd_dbus_client_list = g_list_remove_link(meshd_dbus_client_list, client);
+ /* LCOV_EXCL_STOP */
}
g_mutex_unlock(&meshd_dbus_client_list_mutex);
if (client) {
+ /* LCOV_EXCL_START */
ret = _wmeshd_dbus_client_list_cleanup(client);
if (WMESHD_ERROR_NONE != ret)
WMESH_LOGE("_wmeshd_dbus_client_list_cleanup() Fail(%d)", ret);
+ /* LCOV_EXCL_STOP */
}
}
}
NULL,
NULL);
if (0 == id) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_dbus_connection_signal_subscribe() Fail");
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
return WMESHD_ERROR_NONE;
/* Initialize Wi-Fi driver */
ret = wifi_manager_initialize(&wifi_handle);
- if (WIFI_MANAGER_ERROR_NONE != ret)
+ if (WIFI_MANAGER_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to get wifi manager handle ! [%s(%X)]",
wifi_error_to_string(ret), ret);
+ /* LCOV_EXCL_STOP */
+ }
wifi_manager_is_activated(wifi_handle, &wifi_activated);
if (false == wifi_activated) {
+ /* LCOV_EXCL_START */
ret = wifi_manager_activate(wifi_handle, NULL, NULL);
if (WIFI_MANAGER_ERROR_NONE != ret)
WMESH_LOGE("Failed to activate wifi ! [%s(%X)]",
wifi_error_to_string(ret), ret);
+ /* LCOV_EXCL_STOP */
}
wifi_manager_deinitialize(wifi_handle);
if (service->mesh_activated) {
+ /* LCOV_EXCL_START */
/* Already activated */
manager_complete_enable(object, invocation, WMESHD_ERROR_NONE);
goto FINISH;
+ /* LCOV_EXCL_STOP */
}
/* Do API response first */
/* Register event handler first */
ret = wmesh_request_register_event_handler(service);
if (WMESHD_ERROR_IN_PROGRESS == ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Currently set netlink event handler !! [%d]", ret);
ret = WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
} else if (WMESHD_ERROR_NONE != ret) {
- WMESH_LOGE("Failed to register mesh event handler !! [%d]", ret);
+ WMESH_LOGE("Failed to register mesh event handler !! [%d]", ret); //LCOV_EXCL_LINE
}
ret = wmesh_interface_initialize(service->interface_info);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to wmesh_interface_initialize [%d]", ret);
goto FINISH;
+ /* LCOV_EXCL_STOP */
}
FINISH:
ret = wmesh_request_unregister_event_handler();
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to unregister mesh event handler !! [%d]", ret);
+ WMESH_LOGE("Failed to unregister mesh event handler !! [%d]", ret); //LCOV_EXCL_LINE
/* Terminate daemon */
wmeshd_service_exit(service);
ret = wmesh_request_scan(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_scan !");
+ WMESH_LOGE("Failed to wmesh_request_scan !"); //LCOV_EXCL_LINE
net_wmesh_complete_scan(object, invocation, ret);
ret = wmesh_request_specific_scan(service, mesh_id, channel);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_specific_scan !");
+ WMESH_LOGE("Failed to wmesh_request_specific_scan !"); //LCOV_EXCL_LINE
net_wmesh_complete_specific_scan(object, invocation, ret);
ret = wmesh_request_cancel_scan(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_cancel_scan");
+ WMESH_LOGE("Failed to wmesh_request_cancel_scan"); //LCOV_EXCL_LINE
net_wmesh_complete_cancel_scan(object, invocation, ret);
return TRUE;
}
+/* LCOV_EXCL_START */
static void _on_scan_result_destroy(gpointer data)
{
wmesh_scan_result_s *scan_item = (wmesh_scan_result_s *)data;
g_free(info);
}
}
+/* LCOV_EXCL_STOP */
static gboolean _wmeshd_dbus_handle_get_found_mesh_networks(NetWmesh *object,
GDBusMethodInvocation *invocation,
ret = wmesh_request_get_networks(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_get_networks");
+ WMESH_LOGE("Failed to wmesh_request_get_networks"); //LCOV_EXCL_LINE
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
/* scanned_mesh_network would be filled above request */
iter = service->scanned_mesh_network;
while (iter != NULL) {
+ /* LCOV_EXCL_START */
scan_item = (wmesh_scan_result_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_close(&builder);
iter = g_list_next(iter);
+ /* LCOV_EXCL_STOP */
}
networks = g_variant_builder_end(&builder);
/* It handles creating virtual network and bridge */
ret = wmesh_request_enable_network(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_enable_network [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_request_enable_network [%d]", ret); //LCOV_EXCL_LINE
wmesh_start_monitor_service(service);
wmeshd_check_null_ret_error("info", info, FALSE);
if (FALSE == service->mesh_activated) {
+ /* LCOV_EXCL_START */
WMESH_LOGD("Mesh network is not activated yet");
ret = WMESHD_ERROR_OPERATION_FAILED;
net_wmesh_complete_disable_mesh(object, invocation, ret);
return TRUE;
+ /* LCOV_EXCL_STOP */
}
ret = wmesh_request_disable_network(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to disable mesh network !");
+ WMESH_LOGE("Failed to disable mesh network !"); //LCOV_EXCL_LINE
/* Stop Mesh Node Monitoring Service */
wmesh_stop_monitor_service(service);
/* It handles creating virtual network and bridge */
ret = wmesh_interface_check(service->interface_info->mesh_interface);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Mesh Interface doesn't exists");
state = FALSE;
+ /* LCOV_EXCL_STOP */
}
net_wmesh_complete_is_mesh_enabled(object, invocation, state);
ret = wmesh_request_get_joined_network(service);
if (WMESHD_ERROR_NONE == ret) {
+ /* LCOV_EXCL_START */
if (service->joined_network)
state = TRUE;
+ /* LCOV_EXCL_STOP */
}
net_wmesh_complete_is_joined(object, invocation, state, ret);
if (WMESHD_ERROR_NONE == ret) {
joined = service->joined_network;
if (joined) {
+ /* LCOV_EXCL_START */
net_wmesh_complete_get_joined_mesh_network(object, invocation,
joined->mesh_id, joined->bssid,
joined->channel, (int)joined->security,
joined->state, joined->ipv4_type, joined->ipv4_address,
joined->ipv4_netmask, ret);
+ /* LCOV_EXCL_STOP */
} else {
net_wmesh_complete_get_joined_mesh_network(object, invocation,
- "", "", 0, 0, 0, 0, "", "", WMESHD_ERROR_NO_DATA);
+ "", "", 0, 0, 0, 0, "", "", WMESHD_ERROR_NO_DATA); /* LCOV_EXCL_LINE */
}
} else {
net_wmesh_complete_get_joined_mesh_network(object, invocation,
- "", "", 0, 0, 0, 0, "", "", ret);
+ "", "", 0, 0, 0, 0, "", "", ret); /* LCOV_EXCL_LINE */
}
return TRUE;
ret = wmesh_request_get_connected_peers(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_get_connected_peers");
+ WMESH_LOGE("Failed to wmesh_request_get_connected_peers"); //LCOV_EXCL_LINE
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
iter = service->connected_mesh_peers;
while (iter != NULL) {
+ /* LCOV_EXCL_START */
peer = (wmesh_peer_info_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_close(&builder);
iter = g_list_next(iter);
+ /* LCOV_EXCL_STOP */
}
peer_list = g_variant_builder_end(&builder);
/* Set STP and gate_announce for connmand */
ret = wmesh_gdbus_set_mesh_gate(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret); //LCOV_EXCL_LINE
/* Set STP and gate_announce right now */
ret = wmesh_request_set_mesh_gate(info->bridge_interface,
info->mesh_interface, info->external_interface);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret); //LCOV_EXCL_LINE
net_wmesh_complete_set_gate(object, invocation, ret);
/* Set STP and gate_announce for connmand */
ret = wmesh_gdbus_set_mesh_gate(service);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret); //LCOV_EXCL_LINE
/* Unset STP and Gate Annouce right now */
ret = wmesh_request_unset_mesh_gate(info->bridge_interface,
info->mesh_interface, info->external_interface);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_unset_mesh_gate [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_request_unset_mesh_gate [%d]", ret); //LCOV_EXCL_LINE
net_wmesh_complete_unset_gate(object, invocation, ret);
ssid, mode, channel, visibility, max_sta,
security, passphrase);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_set_softap_config [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_request_set_softap_config [%d]", ret); //LCOV_EXCL_LINE
net_wmesh_complete_set_softap(object, invocation, ret);
ret = wmesh_request_get_softap_config(&interface, &ssid, &mode, &channel,
&visibility, &max_sta, &security, &passphrase);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to wmesh_request_get_softap_config [%d]", ret);
net_wmesh_complete_get_softap(object, invocation, "", "", 0, 0, 0, 0,
"", ret);
return FALSE;
+ /* LCOV_EXCL_STOP */
}
WMESH_LOGD("SSID : %s", ssid);
if (security == 1)
net_wmesh_complete_get_softap(object, invocation, ssid, mode, channel,
- visibility, max_sta, security, passphrase, ret);
+ visibility, max_sta, security, passphrase, ret); /* LCOV_EXCL_LINE */
else
net_wmesh_complete_get_softap(object, invocation, ssid, mode, channel,
- visibility, max_sta, security, "", ret);
+ visibility, max_sta, security, "", ret); /* LCOV_EXCL_LINE */
return TRUE;
}
/* Check softAP interface and execute it */
ret = wmesh_request_enable_softap(info->bridge_interface, info->softap_interface);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_enable_softap [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_request_enable_softap [%d]", ret); //LCOV_EXCL_LINE
net_wmesh_complete_enable_softap(object, invocation, ret);
/* Destroy softAP */
ret = wmesh_request_disable_softap(info->bridge_interface, info->softap_interface);
if (WMESHD_ERROR_NONE != ret)
- WMESH_LOGE("Failed to wmesh_request_disable_softap [%d]", ret);
+ WMESH_LOGE("Failed to wmesh_request_disable_softap [%d]", ret); //LCOV_EXCL_LINE
net_wmesh_complete_disable_softap(object, invocation, ret);
wmesh_interface_s *info = service->interface_info;
if (station_type == WMESHD_STATION_TYPE_MESH_POINT) {
+ /* LCOV_EXCL_START */
/* Clear mesh station list */
g_list_free_full(service->station_list, _on_station_list_destroy);
service->station_list = NULL;
G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Invalid station type");
return FALSE;
+ /* LCOV_EXCL_STOP */
}
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to wmesh_request_get_station_info");
g_dbus_method_invocation_return_error(invocation,
G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Request Failed");
+ /* LCOV_EXCL_STOP */
} else {
- /*
- * sh-3.2# iw mesh0 station dump
- * Station 7c:dd:90:62:37:cf (on mesh0)
- * inactive time: 1685 ms
- * rx bytes: 34174
- * rx packets: 1181
- * tx bytes: 6877
- * tx packets: 76
- * tx retries: 0
- * tx failed: 0
- * beacon loss: 0
- * signal: -64 dBm
- * signal avg: -63 dBm
- * tx bitrate: 54.0 MBit/s
- * rx bitrate: 5.5 MBit/s
- * mesh llid: 51731
- * mesh plid: 35432
- * mesh plink: ESTAB
- * mesh local PS mode: ACTIVE
- * mesh peer PS mode: ACTIVE
- * mesh non-peer PS mode: ACTIVE
- * authorized: yes
- * authenticated: yes
- * associated: yes
- * preamble: long
- * WMM/WME: yes
- * MFP: no
- * TDLS peer: no
- * DTIM period: 0
- * beacon interval:1000
- * short slot time:yes
- * connected time: 256 seconds
- */
+ /*
+ * sh-3.2# iw mesh0 station dump
+ * Station 7c:dd:90:62:37:cf (on mesh0)
+ * inactive time: 1685 ms
+ * rx bytes: 34174
+ * rx packets: 1181
+ * tx bytes: 6877
+ * tx packets: 76
+ * tx retries: 0
+ * tx failed: 0
+ * beacon loss: 0
+ * signal: -64 dBm
+ * signal avg: -63 dBm
+ * tx bitrate: 54.0 MBit/s
+ * rx bitrate: 5.5 MBit/s
+ * mesh llid: 51731
+ * mesh plid: 35432
+ * mesh plink: ESTAB
+ * mesh local PS mode: ACTIVE
+ * mesh peer PS mode: ACTIVE
+ * mesh non-peer PS mode: ACTIVE
+ * authorized: yes
+ * authenticated: yes
+ * associated: yes
+ * preamble: long
+ * WMM/WME: yes
+ * MFP: no
+ * TDLS peer: no
+ * DTIM period: 0
+ * beacon interval:1000
+ * short slot time:yes
+ * connected time: 256 seconds
+ */
+
+ /* LCOV_EXCL_START */
/* Get station information and make variant data */
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
g_object_unref(station);
}
+ /* LCOV_EXCL_STOP */
return TRUE;
}
ret = wmesh_request_get_mpath_info(
info->mesh_interface, &service->mpath_list);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to wmesh_request_get_mpath_info");
g_dbus_method_invocation_return_error(invocation,
G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Request Failed");
+ /* LCOV_EXCL_STOP */
} else {
- /*
- * Example) sh-3.2# iw mesh0 mpath dump
- * DEST ADDR NEXT HOP IFACE SN METRIC QLEN EXPTIME DTIM DRET FLAGS
- * 7c:dd:90:62:37:cf 7c:dd:90:62:37:cf mesh0 221 152 0 10 100 0 0x5
- */
+ /*
+ * Example) sh-3.2# iw mesh0 mpath dump
+ * DEST ADDR NEXT HOP IFACE SN METRIC QLEN EXPTIME DTIM DRET FLAGS
+ * 7c:dd:90:62:37:cf 7c:dd:90:62:37:cf mesh0 221 152 0 10 100 0 0x5
+ */
+
+ /* LCOV_EXCL_START */
/* Get mesh path information and make variant data */
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
net_wmesh_complete_get_mpath_info(object, invocation, mpath_data, ret);
g_object_unref(mpath_data);
+ /* LCOV_EXCL_STOP */
}
return TRUE;
ret = wmesh_request_get_meshconf_info(service);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to wmesh_request_get_mpath_info");
g_dbus_method_invocation_return_error(invocation,
G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Request Failed");
+ /* LCOV_EXCL_STOP */
} else {
/* Get mesh path information and make variant data */
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
meshd_activator_dbus_object = manager_skeleton_new();
if (NULL == meshd_activator_dbus_object) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("manager_skeleton_new() Fail");
return;
+ /* LCOV_EXCL_STOP */
}
g_signal_connect(meshd_activator_dbus_object, "handle-enable",
G_DBUS_INTERFACE_SKELETON(meshd_activator_dbus_object),
conn, WMESH_DBUS_MANAGER_OBJPATH, &error);
if (FALSE == ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
g_error_free(error);
+ /* LCOV_EXCL_STOP */
}
}
meshd_dbus_object = net_wmesh_skeleton_new();
if (NULL == meshd_dbus_object) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("net_wmesh_skeleton_new() Fail");
return;
+ /* LCOV_EXCL_STOP */
}
g_signal_connect(meshd_dbus_object, "handle-scan",
ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(meshd_dbus_object),
conn, WMESH_DBUS_OBJPATH, &error);
if (FALSE == ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
g_error_free(error);
+ /* LCOV_EXCL_STOP */
}
ret = _wmeshd_dbus_subscribe_name_owner_changed(conn);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("_wmeshd_dbus_subscribe_name_owner_changed() Fail(%d)", ret);
return;
+ /* LCOV_EXCL_STOP */
}
}
+/* LCOV_EXCL_START */
static void _wmeshd_dbus_on_name_lost(GDBusConnection *conn, const gchar *name,
gpointer user_data)
{
WMESH_LOGD("Lost the name %s", name);
}
+/* LCOV_EXCL_STOP */
static void _wmeshd_dbus_on_name_acquired(GDBusConnection *conn, const gchar *name,
gpointer user_data)
service,
NULL);
if (0 == id) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g_bus_own_name() Fail");
return FALSE;
+ /* LCOV_EXCL_STOP */
}
/* Get D-Bus owner to activate mesh service daemon */
g_free(info->external_interface);
if (service->joined_network) {
+ /* LCOV_EXCL_START */
g_free(service->joined_network->mesh_id);
g_free(service->joined_network->bssid);
g_free(service->joined_network);
service->joined_network = NULL;
+ /* LCOV_EXCL_STOP */
}
/* Clear scan list */
if (service->scanned_mesh_network)
- g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy);
+ g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy); /* LCOV_EXCL_LINE */
service->scanned_mesh_network = NULL;
/* Clear connected peers list */
if (service->connected_mesh_peers)
- g_list_free_full(service->connected_mesh_peers, _on_peer_info_destroy);
+ g_list_free_full(service->connected_mesh_peers, _on_peer_info_destroy); /* LCOV_EXCL_LINE */
service->connected_mesh_peers = NULL;
/* Clear mesh path list */
if (service->mpath_list)
- g_list_free_full(service->mpath_list, _on_mpath_list_destroy);
+ g_list_free_full(service->mpath_list, _on_mpath_list_destroy); /* LCOV_EXCL_LINE */
service->mpath_list = NULL;
/* Clear mesh station list */
if (service->station_list)
- g_list_free_full(service->station_list, _on_station_list_destroy);
+ g_list_free_full(service->station_list, _on_station_list_destroy); /* LCOV_EXCL_LINE */
service->station_list = NULL;
/* Clear mesh station list */
if (service->softap_station_list)
- g_list_free_full(service->softap_station_list,
- _on_station_list_destroy);
+ g_list_free_full(service->softap_station_list, _on_station_list_destroy); /* LCOV_EXCL_LINE */
service->softap_station_list = NULL;
g_free(service->interface_info);
/* Initialize dbus interface */
ret = _wmeshd_dbus_interface_init(service);
if (FALSE == ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("_wmeshd_dbus_interface_init failed!!!");
return FALSE;
+ /* LCOV_EXCL_STOP */
}
return TRUE;
/* Create g-main loop */
service->main_loop = g_main_loop_new(NULL, FALSE);
if (G_UNLIKELY(NULL == service->main_loop)) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("g-main loop creation failed!!!");
g_free(service);
return NULL;
+ /* LCOV_EXCL_STOP */
}
return service;
if (pass == NULL || salt == NULL || psk == NULL
|| psk_len < (SHA256_DIGEST_LENGTH * 2 + 1)) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
if (!PKCS5_PBKDF2_HMAC_SHA1(pass, strlen(pass),
salt, strlen((const char *)salt),
PSK_ITERATION_COUNT, sizeof(buf), buf)) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Getting psk is failed");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
char *hw_mode = NULL;
if (mode == NULL)
- hw_mode = g_strdup("g");
+ hw_mode = g_strdup("g"); /* LCOV_EXCL_LINE */
else
hw_mode = g_strdup(mode);
ret = __get_psk_hexascii(passphrase,
(const unsigned char *)ssid, key, sizeof(key));
if (ret != WMESHD_ERROR_NONE) {
+ /* LCOV_EXCL_START */
g_free(conf);
WMESH_LOGE("hex conversion failed");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
snprintf(buf, sizeof(buf),
"wpa=2\nrsn_pairwise=CCMP\nwpa_psk=%s\n", key);
conf = g_strconcat(old_conf, buf, NULL);
g_free(old_conf);
} else {
- WMESH_LOGD("Open connection [%s]", security);
+ WMESH_LOGD("Open connection [%s]", security); /* LCOV_EXCL_LINE */
}
fp = fopen(HOSTAPD_MESH_CONF_FILE, "w");
if (NULL == fp) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Could not create the file [%s].", HOSTAPD_MESH_CONF_FILE);
g_free(conf);
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
if (conf) {
fp = fopen(HOSTAPD_MESH_CONF_FILE, "r");
if (fp == NULL) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Failed to read file");
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
if (!softap_interface || !ssid || !security || !passphrase || !mode ||
!channel || !visibility || !max_sta) {
+ /* LCOV_EXCL_START */
fclose(fp);
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
*security = 0;
struct stat stat_buf;
if (fd == NULL || intf == NULL) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("fd is NULL");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
*fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (*fd < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("socket is failed");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
src.sun_family = AF_UNIX;
g_strlcpy(src.sun_path, intf, sizeof(src.sun_path));
if (stat(src.sun_path, &stat_buf) == 0)
- unlink(src.sun_path);
+ unlink(src.sun_path); /* LCOV_EXCL_LINE */
if (bind(*fd, (struct sockaddr *)&src, sizeof(src)) < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("bind is failed");
close(*fd);
*fd = -1;
unlink(src.sun_path);
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
snprintf(ctrl_intf, sizeof(ctrl_intf), "%s/%s",
while (connect(*fd, (struct sockaddr *)&dest, sizeof(dest)) < 0) {
if (++retry >= HOSTAPD_RETRY_MAX)
- goto FAIL;
+ goto FAIL; //LCOV_EXCL_LINE
usleep(HOSTAPD_RETRY_DELAY);
}
+ /* LCOV_EXCL_START */
WMESH_LOGD("Successfully open interface[%s] to hostapd", intf);
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
FAIL:
WMESH_LOGE("Cannot make connection to hostapd");
return WMESHD_ERROR_OPERATION_FAILED;
}
+/* LCOV_EXCL_START */
static int __close_hostapd_intf(int *fd)
{
if (fd == NULL) {
return WMESHD_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
static int __get_pid_of_hostapd(pid_t *pid)
{
snprintf(file_path, 256, "%s", HOSTAPD_PID_FILE);
if (0 == access(file_path, F_OK)) {
+ /* LCOV_EXCL_START */
fd = fopen(file_path, "r");
if (fd == NULL) {
WMESH_LOGE("Error! Could not open pid file");
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_STOP */
} else {
WMESH_LOGE("Error! Could not access pid file");
return WMESHD_ERROR_IO_ERROR;
}
+ /* LCOV_EXCL_START */
errno = 0;
rv = fscanf(fd, "%d", &ret);
if (rv < 0) {
fclose(fd);
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP*/
}
static int __terminate_hostapd()
/* Get pid */
ret = __get_pid_of_hostapd(&hostapd_pid);
if (WMESHD_ERROR_NONE != ret) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("There is no hostapd");
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
if (hostapd_pid == 0) {
WMESH_LOGE("There is no hostapd");
return WMESHD_ERROR_NONE;
kill(hostapd_pid, SIGTERM);
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
static int __execute_hostapd()
ret = __get_pid_of_hostapd(&pid);
if (0 != pid) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("hostapd is running already");
return WMESHD_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
pid = fork();
if (pid < 0) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("fork failed");
return WMESHD_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
if (pid == 0) {
"-P", HOSTAPD_PID_FILE,
"-ddd", "-B",
(char *)NULL)) {
- WMESH_LOGE("execl failed");
+ WMESH_LOGE("execl failed"); /* LCOV_EXCL_LINE */
}
-
+ /* LCOV_EXCL_START */
WMESH_LOGE("Should not get here!");
exit(1);
+ /* LCOV_EXCL_STOP */
} else {
/* Reap child */
waitpid(pid, &status, 0);
int ret = WMESHD_ERROR_NONE;
if (NULL == softap_interface) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Invalid parameter");
return WMESHD_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
ret = __execute_hostapd();
if (ret != WMESHD_ERROR_NONE) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("__execute_hostapd is failed");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
ret = __open_hostapd_intf(softap_interface,
&hostapd_ctrl_fd, MH_CTRL_INTF);
if (ret != WMESHD_ERROR_NONE) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("__open_hostapd_intf is failed");
__terminate_hostapd();
+ /* LCOV_EXCL_STOP */
}
return ret;
ret = __terminate_hostapd();
if (ret != WMESHD_ERROR_NONE) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("__execute_hostapd is failed");
return WMESHD_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
return ret;
ret = __get_pid_of_hostapd(&hostapd_pid);
if (ret != WMESHD_ERROR_NONE) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("hostapd is not running");
return false;
+ /* LCOV_EXCL_STOP */
}
+ /* LCOV_EXCL_START */
if (hostapd_pid == 0) {
WMESH_LOGD("hostapd is not running");
return false;
}
return true;
+ /* LCOV_EXCL_STOP */
}
/**< mesh service */
wmesh_service *meshsvc;
+#if (BUILD_GCOV != 0)
+extern void __gcov_flush(void);
+#endif
+
int main(int argc, char *argv[])
{
wmesh_service *service = NULL;
int ret_code = 0;
gboolean ret;
- __WMESH_LOG_FUNC_ENTER__;
+ __WMESH_LOG_FUNC_ENTER__; //LCOV_EXCL_LINE
#if !GLIB_CHECK_VERSION(2, 32, 0)
if (!g_thread_supported())
WMESH_LOGI("service mainloop start");
+#if (BUILD_GCOV != 0)
+ setenv("GCOV_PREFIX", "/tmp/", 1);
+#endif
+
/* Create mesh service */
meshsvc = service = wmeshd_service_new();
/* Initialize mesh service interface layer */
ret = wmeshd_service_interface_init(service);
if (G_UNLIKELY(FALSE == ret)) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("wmeshd_service_interface_init failed!");
goto END;
+ /* LCOV_EXCL_STOP */
}
/* Run mesh service */
ret = wmeshd_service_run(service);
if (G_UNLIKELY(FALSE == ret)) {
+ /* LCOV_EXCL_START */
WMESH_LOGE("Run service failed!");
ret_code = EXIT_FAILURE;
+ /* LCOV_EXCL_STOP */
}
END:
wmeshd_service_free(service);
meshsvc = NULL;
- __WMESH_LOG_FUNC_EXIT__;
- return 0;
+#if (BUILD_GCOV != 0)
+ __gcov_flush();
+#endif
+
+ __WMESH_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return ret_code;
}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(gtest-wifi-mesh-manager C CXX)
+
+SET(GTEST_TEST "gtest-wifi-mesh-manager")
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(REQUIRES_LIST ${REQUIRES_LIST}
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST})
+
+FOREACH(flag ${GTEST_TEST_PKG_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+FILE(GLOB GTEST_TEST_SRCS *.cpp)
+SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS})
+
+ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS})
+TARGET_LINK_LIBRARIES(${GTEST_TEST} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} -ldl -lgcov)
+
+INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION ${BIN_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "gdbus.h"
+
+GDbus::GDbus()
+{
+ this->m_pConnection = NULL;
+ this->m_pCancellable = NULL;
+}
+
+GDbus::~GDbus()
+{
+ GDBusConnection *conn = this->m_pConnection;
+ GCancellable *cancel = this->m_pCancellable;
+
+ if (cancel) {
+ g_cancellable_cancel(cancel);
+ g_object_unref(cancel);
+ cancel = NULL;
+ }
+
+ if (conn) {
+ g_object_unref(conn);
+ conn = NULL;
+ }
+}
+
+error_e GDbus::Create(void)
+{
+ GError *err = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+
+ this->m_pConnection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (this->m_pConnection == NULL) {
+ if (err != NULL) {
+ GLOGD("Failed to connect to the D-BUS daemon [%s]", err->message);
+ g_error_free(err);
+ }
+
+ return ERROR_OPERATION_FAILED;
+ }
+
+ this->m_pCancellable = g_cancellable_new();
+
+ return ERROR_NONE;
+}
+
+error_e GDbus::Destroy(void)
+{
+ g_cancellable_cancel(this->m_pCancellable);
+ g_object_unref(this->m_pCancellable);
+ this->m_pCancellable = NULL;
+
+ g_object_unref(this->m_pConnection);
+ this->m_pConnection = NULL;
+
+ return ERROR_NONE;
+}
+
+GDBusConnection *GDbus::GetConnection(void)
+{
+ return this->m_pConnection;
+}
+
+GCancellable *GDbus::GetCancellable(void)
+{
+ return this->m_pCancellable;
+}
+
+error_e GDbus::ConvertErrorStringToEnum(const char *error)
+{
+ if (NULL != strstr(error, "NoReply"))
+ return ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "Failed"))
+ return ERROR_OPERATION_FAILED;
+ else if (NULL != strstr(error, "UnknownMethod"))
+ return ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "InvalidArguments"))
+ return ERROR_INVALID_PARAMETER;
+ else if (NULL != strstr(error, "AccessDenied"))
+ return ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "PermissionDenied"))
+ return ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "NotSupported"))
+ return ERROR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "InProgress"))
+ return ERROR_IN_PROGRESS;
+
+ return ERROR_OPERATION_FAILED;
+}
+
+GVariant *GDbus::InvokeMethod(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, error_e *dbus_error)
+{
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *connection = NULL;
+ *dbus_error = ERROR_NONE;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ GLOGD("GDBusconnection is NULL");
+ *dbus_error = ERROR_NOT_INITIALIZED;
+ return reply;
+ }
+
+ reply = g_dbus_connection_call_sync(connection,
+ dest,
+ path,
+ iface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ GetCancellable(),
+ &error);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ GLOGD("g_dbus_connection_call_sync() failed "
+ "error [%d: %s]", error->code, error->message);
+ *dbus_error = ConvertErrorStringToEnum(error->message);
+ g_error_free(error);
+ } else {
+ GLOGD("g_dbus_connection_call_sync() failed");
+ *dbus_error = ERROR_OPERATION_FAILED;
+ }
+
+ return NULL;
+ }
+
+ return reply;
+}
+
+error_e GDbus::InvokeMethodNonblock(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func, void *user_data)
+{
+ GDBusConnection *connection = NULL;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ GLOGD("GDBusconnection is NULL");
+ return ERROR_NOT_INITIALIZED;
+ }
+
+ g_dbus_connection_call(connection,
+ dest,
+ path,
+ iface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ timeout,
+ GetCancellable(),
+ (GAsyncReadyCallback) notify_func,
+ (gpointer)user_data);
+
+ return ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __WIFI_MESH_MGR_GDBUS_H__
+#define __WIFI_MESH_MGR_GDBUS_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "wmeshmgr.h"
+
+#define GMAINTIMEOUT 10000
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define WIFI_MESH_MGR_SERVICE "net.wmesh"
+#define WIFI_MESH_MGR_INTERFACE WIFI_MESH_MGR_SERVICE
+
+#define WIFI_MESH_MGR_MANAGER_INTERFACE WIFI_MESH_MGR_SERVICE ".manager"
+
+#define WIFI_MESH_MGR_MANAGER_PATH "/net/wmesh/manager"
+#define WIFI_MESH_MGR_PATH "/net/wmesh"
+
+#define WIFI_MESH_MGR_METHOD_MANAGER_START "enable"
+#define WIFI_MESH_MGR_METHOD_MANAGER_STOP "disable"
+#define WIFI_MESH_MGR_METHOD_SCAN "scan"
+#define WIFI_MESH_MGR_METHOD_SPECIFIC_SCAN "specific_scan"
+#define WIFI_MESH_MGR_METHOD_CANCEL_SCAN "cancel_scan"
+#define WIFI_MESH_MGR_METHOD_GET_FOUND_MESH_NETWORKS "get_found_mesh_networks"
+#define WIFI_MESH_MGR_METHOD_GET_CONNECTED_PEERS "get_connected_peers"
+#define WIFI_MESH_MGR_METHOD_ENABLE_MESH "enable_mesh"
+#define WIFI_MESH_MGR_METHOD_DISABLE_MESH "disable_mesh"
+#define WIFI_MESH_MGR_METHOD_IS_MESH_ENABLED "is_mesh_enabled"
+#define WIFI_MESH_MGR_METHOD_IS_JOINED "is_joined"
+#define WIFI_MESH_MGR_METHOD_GET_JOINED_MESH_NETWORK "get_joined_mesh_network"
+#define WIFI_MESH_MGR_METHOD_SET_GATE "set_gate"
+#define WIFI_MESH_MGR_METHOD_UNSET_GATE "unset_gate"
+#define WIFI_MESH_MGR_METHOD_SET_SOFTAP "set_softap"
+#define WIFI_MESH_MGR_METHOD_GET_SOFTAP "get_softap"
+#define WIFI_MESH_MGR_METHOD_ENABLE_SOFTAP "enable_softap"
+#define WIFI_MESH_MGR_METHOD_DISABLE_SOFTAP "disable_softap"
+#define WIFI_MESH_MGR_METHOD_IS_SOFTAP_ENABLED "is_softap_enabled"
+#define WIFI_MESH_MGR_METHOD_CREATE_MESH_NETWORK "create_mesh_network"
+#define WIFI_MESH_MGR_METHOD_CONNECT_MESH_NETWORK "connect_mesh_network"
+#define WIFI_MESH_MGR_METHOD_DISCONNECT_MESH_NETWORK "disconnect_mesh_network"
+#define WIFI_MESH_MGR_METHOD_FORGET_MESH_NETWORK "forget_mesh_network"
+#define WIFI_MESH_MGR_METHOD_SET_INTERFACES "set_interfaces"
+#define WIFI_MESH_MGR_METHOD_GET_STATION_INFO "get_station_info"
+#define WIFI_MESH_MGR_METHOD_GET_MPATH_INFO "get_mpath_info"
+#define WIFI_MESH_MGR_METHOD_GET_MESHCONF_INFO "get_meshconf_info"
+
+
+class GDbus {
+private:
+ GDBusConnection *m_pConnection;
+ GCancellable *m_pCancellable;
+public:
+ GDbus();
+ ~GDbus();
+ error_e Create(void);
+ error_e Destroy(void);
+ GDBusConnection *GetConnection(void);
+ GCancellable *GetCancellable(void);
+ error_e ConvertErrorStringToEnum(const char *error);
+ GVariant *InvokeMethod(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, error_e *dbus_error);
+ error_e InvokeMethodNonblock(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func, void *user_data);
+};
+
+#endif /* __WIFI_MESH_MGR_GDBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "manager.h"
+
+Manager::Manager()
+{
+ Create();
+}
+
+Manager::~Manager()
+{
+ Destroy();
+}
+
+error_e Manager::EnableManager(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+ int result = 0;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE".manager",
+ WIFI_MESH_MGR_MANAGER_PATH,
+ WIFI_MESH_MGR_MANAGER_INTERFACE,
+ WIFI_MESH_MGR_METHOD_MANAGER_START,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(i)", &result);
+ GLOGD("Successfully stop manager [%d]", result);
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e Manager::DisableManager(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+ int result = 0;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_MANAGER_PATH,
+ WIFI_MESH_MGR_MANAGER_INTERFACE,
+ WIFI_MESH_MGR_METHOD_MANAGER_STOP,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(i)", &result);
+ GLOGD("Successfully stop manager [%d]", result);
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __WIFI_MESH_MANAGER_H__
+#define __WIFI_MESH_MANAGER_H__
+
+#include "wmeshmgr.h"
+#include "gdbus.h"
+
+#define WMESHD_STATION_TYPE_MESH_POINT 0
+
+class Manager:public GDbus {
+private:
+public:
+ Manager();
+ ~Manager();
+ error_e EnableManager(void);
+ error_e DisableManager(void);
+};
+
+
+#endif /* __WIFI_MESH_MANAGER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+
+#include "manager.h"
+#include "wmesh.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+char *mesh_id = (char *)"gtestnetwork";
+
+TEST(WifiMeshManager, Enable_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager mgr;
+
+ ret = mgr.EnableManager();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, EnableMesh_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.EnableMesh();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, Scan_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.Scan();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, SpecificScan_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.SpecificScan(mesh_id, 161);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, CancelScan_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.CancelScan();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetFoundMeshNetworks_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetFoundMeshNetworks();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetConnectedPeers_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetConnectedPeers();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, IsMeshEnabled_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.IsMeshEnabled();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, IsJoined_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.IsJoined();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetJoinedMeshNetwork_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetJoinedMeshNetwork();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, SetGate_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.SetGate(true, 4, true);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, UnsetGate_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.UnsetGate();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, SetSoftap_p)
+{
+ static char ssid[] = "gtestnetwork";
+ static char passphrase[] = "00000000";
+ static int channel = 1;
+ static int visibility = 1;
+ static int max_stations = 10;
+ static int security = 2;
+
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.SetSoftap(ssid, passphrase,
+ channel, visibility, max_stations, security);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetSoftap_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetSoftap();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, EnableSoftap_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.EnableSoftap();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, DisableSoftap_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.DisableSoftap();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, IsSoftapEnabled_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.IsSoftapEnabled();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, CreateMeshNetwork_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.CreateMeshNetwork(mesh_id, 1, 2);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, ConnectMeshNetwork_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+ char *passphrase = (char *)"00000000";
+
+ ret = w.ConnectMeshNetwork(mesh_id, 1, 2, passphrase);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetStationInfo_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetStationInfo(WMESHD_STATION_TYPE_MESH_POINT);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetMpathInfo_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetMpathInfo();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, GetMeshconfInfo_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.GetMeshconfInfo();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, DisconnectMeshNetwork_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.DisconnectMeshNetwork(mesh_id, 1, 2);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, ForgetMeshNetwork_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.ForgetMeshNetwork(mesh_id, 1, 2);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, SetInterfaces_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+ char *mesh = (char *)"mesh0";
+ char *gate = (char *)"eth0";
+ char *softap = (char *)"wlan0";
+
+ ret = w.SetInterfaces(mesh, gate, softap);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, DisableMesh_p)
+{
+ error_e ret = ERROR_NONE;
+ Wmesh w;
+
+ ret = w.DisableMesh();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(WifiMeshManager, Disable_p)
+{
+ error_e ret = ERROR_NONE;
+ Manager mgr;
+
+ ret = mgr.DisableManager();
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+int main(int argc, char **argv)
+{
+ InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "wmesh.h"
+
+Wmesh::Wmesh()
+{
+ Create();
+}
+
+Wmesh::~Wmesh()
+{
+ Destroy();
+}
+error_e Wmesh::Scan(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_SCAN,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform scan");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::SpecificScan(char *mesh_id, int channel)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_SPECIFIC_SCAN,
+ g_variant_new("(si)", mesh_id, channel),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform specific_scan");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::CancelScan(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_CANCEL_SCAN,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform cancel_scan");
+
+ return ERROR_NONE;
+}
+
+error_e Wmesh::GetFoundMeshNetworks(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_FOUND_MESH_NETWORKS,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform get_found_mesh_networks");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::GetConnectedPeers(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_CONNECTED_PEERS,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform get_connceted_peers");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::EnableMesh(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_ENABLE_MESH,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform enable_mesh");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::DisableMesh(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_DISABLE_MESH,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform disable_mesh");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::IsMeshEnabled(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_IS_MESH_ENABLED,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform is_mesh_enabled");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::IsJoined(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_IS_JOINED,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform is_joined");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::GetJoinedMeshNetwork(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_JOINED_MESH_NETWORK,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform get_joined_mesh_network");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::SetGate(bool gate_announce, int hwmp_root_mode, bool stp)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_SET_GATE,
+ g_variant_new("(bqq)", gate_announce, hwmp_root_mode, stp),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform set_gate");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::UnsetGate(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_UNSET_GATE,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform unset_gate");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::SetSoftap(char *ssid, char *passphrase, int channel,
+ int visibility, int max_stations, int security)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+ char buf[2] = {0, };
+
+ if (channel <= 13) {
+ buf[0] = 'g';
+ buf[1] = 0;
+ } else {
+ buf[0] = 'a';
+ buf[1] = 0;
+ }
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_SET_SOFTAP,
+ g_variant_new("(sssiiii)", ssid, passphrase, buf,
+ channel, visibility, max_stations, security),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform set_softap");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::GetSoftap(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_SOFTAP,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform get_softap");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::EnableSoftap(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_ENABLE_SOFTAP,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform enabe_softap");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::DisableSoftap(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_DISABLE_SOFTAP,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform disable_softap");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::IsSoftapEnabled(void)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_IS_SOFTAP_ENABLED,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform is_softap_enabled");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::CreateMeshNetwork(char *mesh_id, int channel, int security)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_CREATE_MESH_NETWORK,
+ g_variant_new("(sii)", mesh_id, channel, security),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform create_mesh_network");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::ConnectMeshNetwork(char *mesh_id, int channel, int security,
+ char *passphrase)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_CONNECT_MESH_NETWORK,
+ g_variant_new("(siis)", mesh_id, channel, security, passphrase),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform connect_mesh_network");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::DisconnectMeshNetwork(char *mesh_id, int channel, int security)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_DISCONNECT_MESH_NETWORK,
+ g_variant_new("(sii)", mesh_id, channel, security),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform disconnect_mesh_network");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::ForgetMeshNetwork(char *mesh_id, int channel, int security)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_FORGET_MESH_NETWORK,
+ g_variant_new("(sii)", mesh_id, channel, security),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform forget_mesh_network");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::SetInterfaces(char *mesh, char *gate, char *softap)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_SET_INTERFACES,
+ g_variant_new("(sss)", mesh, gate, softap),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GLOGD("Succeeded to perform set_interfaces");
+
+ return ERROR_NONE;
+}
+error_e Wmesh::GetStationInfo(int sta_type)
+{
+ bool is_started;
+ GVariant *msg1 = NULL;
+ GVariant *msg2 = NULL;
+ error_e error = ERROR_NONE;
+
+ msg1 = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_IS_MESH_ENABLED,
+ NULL,
+ &error);
+
+ if (msg1 == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(msg1, "(b)", &is_started);
+ g_variant_unref(msg1);
+ if (TRUE == is_started) {
+ msg2 = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_STATION_INFO,
+ g_variant_new("(i)", sta_type),
+ &error);
+
+ if (msg2 == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ } else {
+ g_variant_unref(msg2);
+ }
+
+ GLOGD("Succeeded to perform get_station_info");
+ }
+
+ return ERROR_NONE;
+}
+error_e Wmesh::GetMpathInfo(void)
+{
+ bool is_started;
+ GVariant *msg1 = NULL;
+ GVariant *msg2 = NULL;
+ error_e error = ERROR_NONE;
+
+ msg1 = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_IS_MESH_ENABLED,
+ NULL,
+ &error);
+
+ if (msg1 == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(msg1, "(b)", &is_started);
+ g_variant_unref(msg1);
+ if (TRUE == is_started) {
+ msg2 = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_MPATH_INFO,
+ NULL,
+ &error);
+
+ if (msg2 == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ } else {
+ g_variant_unref(msg2);
+ }
+
+ GLOGD("Succeeded to perform get_mpath_info");
+ }
+
+ return ERROR_NONE;
+}
+error_e Wmesh::GetMeshconfInfo(void)
+{
+ bool is_started;
+ GVariant *msg1 = NULL;
+ GVariant *msg2 = NULL;
+ error_e error = ERROR_NONE;
+
+ msg1 = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_IS_MESH_ENABLED,
+ NULL,
+ &error);
+
+ if (msg1 == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(msg1, "(b)", &is_started);
+ g_variant_unref(msg1);
+ if (TRUE == is_started) {
+ msg2 = InvokeMethod(WIFI_MESH_MGR_SERVICE,
+ WIFI_MESH_MGR_PATH,
+ WIFI_MESH_MGR_INTERFACE,
+ WIFI_MESH_MGR_METHOD_GET_MESHCONF_INFO,
+ NULL,
+ &error);
+
+ if (msg2 == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ } else {
+ g_variant_unref(msg2);
+ }
+
+ GLOGD("Succeeded to perform get_meshconf_info");
+ }
+
+ return ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __WMESH_MGR_H__
+#define __WMESH_MGR_H__
+
+#include "wmeshmgr.h"
+#include "gdbus.h"
+
+class Wmesh:public GDbus {
+public:
+ Wmesh();
+ ~Wmesh();
+ error_e Scan(void);
+ error_e SpecificScan(char *mesh_id, int channel);
+ error_e CancelScan(void);
+ error_e GetFoundMeshNetworks(void);
+ error_e GetConnectedPeers(void);
+ error_e EnableMesh(void);
+ error_e DisableMesh(void);
+ error_e IsMeshEnabled(void);
+ error_e IsJoined(void);
+ error_e GetJoinedMeshNetwork(void);
+ error_e SetGate(bool gate_announce, int hwmp_root_mode, bool stp);
+ error_e UnsetGate(void);
+ error_e SetSoftap(char *ssid, char *passphrase, int channel,
+ int visibility, int max_stations, int security);
+ error_e GetSoftap(void);
+ error_e EnableSoftap(void);
+ error_e DisableSoftap(void);
+ error_e IsSoftapEnabled(void);
+ error_e CreateMeshNetwork(char *mesh_id, int channel, int security);
+ error_e ConnectMeshNetwork(char *mesh_id, int channel, int security,
+ char *passphrase);
+ error_e DisconnectMeshNetwork(char *mesh_id, int channel, int security);
+ error_e ForgetMeshNetwork(char *mesh_id, int channel, int security);
+ error_e SetInterfaces(char *mesh, char *gate, char *softap);
+ error_e GetStationInfo(int sta_type);
+ error_e GetMpathInfo(void);
+ error_e GetMeshconfInfo(void);
+};
+
+
+#endif /* __WMESH_MGR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __WIFI_MESH_MGR_H__
+#define __WIFI_MESH_MGR_H__
+
+#include <glib.h>
+
+#ifdef USE_DLOG
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "WIFI_MESH_GTEST"
+#define GLOGD(format, args...) LOGD(format, ##args)
+#else
+#define GLOGD(format, args...)
+#endif
+
+typedef enum {
+ ERROR_NONE = 0,
+ ERROR_NOT_PERMITTED = -1,
+ ERROR_OUT_OF_MEMORY = -2,
+ ERROR_PERMISSION_DENIED = -3,
+ ERROR_RESOURCE_BUSY = -4,
+ ERROR_INVALID_OPERATION = -5,
+ ERROR_INVALID_PARAMETER = -6,
+ ERROR_NOT_SUPPORTED = -7,
+ ERROR_OPERATION_FAILED = -8,
+ ERROR_NOT_INITIALIZED = -9,
+ ERROR_ALREADY_INITIALIZED = -10,
+ ERROR_IN_PROGRESS = -11,
+} error_e;
+
+
+#endif /* __WIFI_MESH_MGR_H__ */