CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(meshd C)
+PROJECT(wmeshd C)
MESSAGE(===================================================================)
MESSAGE(Building...meshd)
ADD_CUSTOM_COMMAND(
OUTPUT dbus
COMMAND gdbus-codegen
- --interface-prefix net.mesh.
- --generate-c-code mesh-generated-code
+ --interface-prefix net.wmesh.
+ --generate-c-code wmesh-generated-code
#--c-namespace mesh
--c-generate-object-manager
--generate-docbook generated-docs
- ${INTROSPECTION_PATH}/mesh.xml
- ${INTROSPECTION_PATH}/manager.xml
+ ${INTROSPECTION_PATH}/wmesh.xml
+ ${INTROSPECTION_PATH}/wmanager.xml
COMMENT "Generating mesh GDBus .c/.h"
)
ADD_CUSTOM_TARGET(GENERATED_DBUS_CODE DEPENDS dbus)
MESSAGE(" - Compiling...")
FILE(GLOB DAEMON_SRCS *.c ${CMAKE_SOURCE_DIR}/src/*.c)
-SET(DAEMON_SRCS ${DAEMON_SRCS} ${CMAKE_SOURCE_DIR}/mesh-generated-code.c)
-SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/mesh-generated-code.c PROPERTIES GENERATED TRUE)
+SET(DAEMON_SRCS ${DAEMON_SRCS} ${CMAKE_SOURCE_DIR}/wmesh-generated-code.c)
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/wmesh-generated-code.c PROPERTIES GENERATED TRUE)
INCLUDE_DIRECTORIES(${daemon_pkgs_INCLUDE_DIRS})
LINK_DIRECTORIES(${daemon_pkgs_LIBRARY_DIRS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
MESSAGE(" - Copying...meshd")
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/files/mesh.sh.in ${CMAKE_SOURCE_DIR}/files/mesh.sh @ONLY)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/files/mesh.sh DESTINATION ${SBIN_DIR})
+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})
+++ /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 __MESH_GDBUS_H__
-#define __MESH_GDBUS_H__
-
-#include "mesh.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* DBus object paths of connman */
-#define CONNMAN_SERVER_NAME "net.connman"
-#define CONNMAN_OBJECT_PATH "/"
-#define CONNMAN_OBJECT_PATH_MESH "/net/connman/mesh"
-#define CONNMAN_OBJECT_PATH_TECH_MESH "/net/connman/technology/mesh"
-
-/* DBus interfaces of connman */
-#define CONNMAN_INTERFACE_MANAGER "net.connman.Manager"
-#define CONNMAN_INTERFACE_MESH "net.connman.Mesh"
-#define CONNMAN_INTERFACE_TECH "net.connman.Technology"
-
-#define MESH_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */
-
-int meshd_dbus_start(mesh_service *service);
-int meshd_dbus_stop(mesh_service *service);
-
-int mesh_gdbus_create_mesh_interface(mesh_service *service);
-int mesh_gdbus_remove_mesh_interface(mesh_service *service);
-int mesh_gdbus_mesh_scan(mesh_service *service);
-int mesh_gdbus_mesh_specific_scan(mesh_service *service, gchar *mesh_id,
- gint channel);
-int mesh_gdbus_mesh_cancel_scan(mesh_service *service);
-int mesh_gdbus_get_mesh_networks(mesh_service *service);
-int mesh_gdbus_get_joined_mesh_network(mesh_service *service);
-int mesh_gdbus_get_connected_peers(mesh_service *service);
-
-int mesh_gdbus_create_network(mesh_service *service, gchar *mesh_id,
- gint channel, meshd_security_type_e sec);
-int mesh_gdbus_set_passphrase(mesh_service *service, mesh_scan_result_s *info,
- gchar *passphrase);
-int mesh_gdbus_connect_network(mesh_service *service, mesh_scan_result_s *info);
-int mesh_gdbus_disconnect_network(mesh_service *service, mesh_scan_result_s *info);
-int mesh_gdbus_remove_network(mesh_service *service, mesh_scan_result_s *info);
-int mesh_gdbus_enable_ethernet_interface(mesh_service *service, bool state);
-int mesh_gdbus_set_mesh_gate(mesh_service *service);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /** __MESH_GDBUS_H__ */
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 __MESH_INTERFACE_H__
-#define __MESH_INTERFACE_H__
-
-typedef enum {
- MESH_INTERFACE_UP = 1, /**< Interface up */
- MESH_INTERFACE_DOWN, /**< Interface down */
- MESH_INTERFACE_DO_NOTHING, /**< Do not handle up/down */
-} mesh_set_interface_type_e;
-
-int mesh_interface_set(const char* interface, const char* ip_addr,
- mesh_set_interface_type_e type);
-//int mesh_interface_set_mac_addr(const char* interface, const char* mac_addr);
-int mesh_interface_initialize(mesh_interface_s *info);
-int mesh_interface_check(const char* interface);
-int mesh_interface_check_external_exists(
- const char* external_interface, bool *state);
-int mesh_interface_check_bridge_interface_exists(const char* bridge, const char* interface);
-char* mesh_interface_get_address(const char* if_name);
-
-#endif /* __MESH_INTERFACE_H__ */
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 __MESH_LOG_H__
-#define __MESH_LOG_H__
-
-#ifdef USE_DLOG
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "MESH_MANAGER"
-
-#define MESH_LOGV(format, args...) LOGV(format, ##args)
-#define MESH_LOGD(format, args...) LOGD(format, ##args)
-#define MESH_LOGI(format, args...) LOGI(format, ##args)
-#define MESH_LOGW(format, args...) LOGW(format, ##args)
-#define MESH_LOGE(format, args...) LOGE(format, ##args)
-#define MESH_LOGF(format, args...) LOGF(format, ##args)
-
-#define __MESH_LOG_FUNC_ENTER__ LOGD("Enter")
-#define __MESH_LOG_FUNC_EXIT__ LOGD("Quit")
-
-#define MESH_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
-#define MESH_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
-
-#else /* USE_DLOG */
-
-#define MESH_LOGV(format, args...)
-#define MESH_LOGD(format, args...)
-#define MESH_LOGI(format, args...)
-#define MESH_LOGW(format, args...)
-#define MESH_LOGE(format, args...)
-#define MESH_LOGF(format, args...)
-
-#define __MESH_LOG_FUNC_ENTER__
-#define __MESH_LOG_FUNC_EXIT__
-
-#define MESH_SECLOGI(format, args...)
-#define MESH_SECLOGD(format, args...)
-
-#endif /* USE_DLOG */
-
-#endif /* __MESH_LOG_H__ */
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 __MESH_REQUEST_H__
-#define __MESH_REQUEST_H__
-
-/* Newly functions */
-int mesh_request_enable_network(mesh_service *service);
-int mesh_request_disable_network(mesh_service *service);
-int mesh_request_scan(mesh_service *service);
-int mesh_request_specific_scan(mesh_service *service, gchar *mesh_id,
- gint channel);
-int mesh_request_cancel_scan(mesh_service *service);
-int mesh_request_get_networks(mesh_service *service);
-int mesh_request_get_joined_network(mesh_service *service);
-int mesh_request_get_connected_peers(mesh_service *service);
-
-int mesh_request_create_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, meshd_security_type_e sec);
-int mesh_request_connect_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, meshd_security_type_e sec, gchar *passphrase);
-int mesh_request_disconnect_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, meshd_security_type_e sec);
-int mesh_request_remove_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, meshd_security_type_e sec);
-
-int mesh_request_set_mesh_gate(const char* bridge_interface,
- const char* mesh_interface, const char* external_interface);
-int mesh_request_unset_mesh_gate(const char* bridge_interface,
- const char* mesh_interface, const char* external_interface);
-
-
-/* Bridge network */
-int mesh_request_add_bridge_interface(const char* bridge_interface,
- const char* interface);
-int mesh_request_remove_bridge_interface(const char* bridge_interface,
- const char* interface);
-
-/* Soft AP */
-int mesh_request_set_softap_config(const char* softap_interface,
- const char *ssid, const char* mode, int channel, int visibility,
- int max_sta, int security, const char* passphrase);
-int mesh_request_enable_softap(
- const char* bridge_interface, const char* softap_interface);
-int mesh_request_disable_softap(
- const char* bridge_interface, const char* softap_interface);
-
-/* Mesh Station & path */
-int mesh_request_get_station_info(const char* mesh_interface, GList **station_list);
-int mesh_request_get_mpath_info(const char* mesh_interface, GList **mpath_list);
-
-int mesh_request_register_event_handler();
-int mesh_request_unregister_event_handler();
-
-/* Notifications */
-void mesh_notify_scan_done();
-void mesh_notify_connection_state(const char* mesh_id, const char* bssid,
- int channel, meshd_security_type_e sec, meshd_connection_state_e state);
-void mesh_notify_station_joined(const char* bssid);
-void mesh_notify_station_left(const char* bssid);
-
-#endif /* __MESH_REQUEST_H__ */
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 __MESH_SERVICE_INTERFACE_H__
-#define __MESH_SERVICE_INTERFACE_H__
-
-#include "mesh-generated-code.h"
-
-/**< Mesh D-BUS service*/
-#define MESH_DBUS_SERVICE "net.mesh"
-
-/**< Mesh D-BUS service path */
-#define MESH_DBUS_PATH "/net/mesh"
-
-#ifndef MESH_DBUS_INTERFACE
-#define MESH_DBUS_INTERFACE "net.mesh"
-//#warning "MESH_DBUS_INTERFACE is redefined"
-#endif
-
-#ifndef MESH_DBUS_OBJPATH
-#define MESH_DBUS_OBJPATH "/net/mesh"
-//#warning "MESH_DBUS_OBJPATH is redefined"
-#endif
-
-#ifndef MESH_DBUS_MANAGER_OBJPATH
-#define MESH_DBUS_MANAGER_OBJPATH "/net/mesh/manager"
-//#warning "MESH_DBUS_MANAGER_OBJPATH is redefined"
-#endif
-
-NetMesh* meshd_dbus_get_object();
-int64_t meshd_dbus_generate_signal_number();
-gboolean meshd_service_interface_init(mesh_service *service);
-void meshd_service_interface_deinit(mesh_service *service);
-
-#endif /* __MESH_SERVICE_INTERFACE_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_BRIDGE_H__
-#define __MESH_BRIDGE_H__
+#ifndef __WMESH_BRIDGE_H__
+#define __WMESH_BRIDGE_H__
-int mesh_bridge_create(const char* interface);
-int mesh_bridge_remove(const char* interface);
-int mesh_bridge_add_interface(const char* bridge_name, const char* interface);
-int mesh_bridge_del_interface(const char* bridge_name, const char* interface);
-int mesh_bridge_set_stp(const char* bridge_name, bool state);
+int wmesh_bridge_create(const char* interface);
+int wmesh_bridge_remove(const char* interface);
+int wmesh_bridge_add_interface(const char* bridge_name, const char* interface);
+int wmesh_bridge_del_interface(const char* bridge_name, const char* interface);
+int wmesh_bridge_set_stp(const char* bridge_name, bool state);
-#endif /* __MESH_BRIDGE_H__ */
+#endif /* __WMESH_BRIDGE_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 __WMESH_GDBUS_H__
+#define __WMESH_GDBUS_H__
+
+#include "wmesh.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* DBus object paths of connman */
+#define CONNMAN_SERVER_NAME "net.connman"
+#define CONNMAN_OBJECT_PATH "/"
+#define CONNMAN_OBJECT_PATH_MESH "/net/connman/mesh"
+#define CONNMAN_OBJECT_PATH_TECH_MESH "/net/connman/technology/mesh"
+
+/* DBus interfaces of connman */
+#define CONNMAN_INTERFACE_MANAGER "net.connman.Manager"
+#define CONNMAN_INTERFACE_MESH "net.connman.Mesh"
+#define CONNMAN_INTERFACE_TECH "net.connman.Technology"
+
+#define WMESH_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */
+
+int wmeshd_dbus_start(wmesh_service *service);
+int wmeshd_dbus_stop(wmesh_service *service);
+
+int wmesh_gdbus_create_mesh_interface(wmesh_service *service);
+int wmesh_gdbus_remove_mesh_interface(wmesh_service *service);
+int wmesh_gdbus_mesh_scan(wmesh_service *service);
+int wmesh_gdbus_mesh_specific_scan(wmesh_service *service, gchar *mesh_id,
+ gint channel);
+int wmesh_gdbus_mesh_cancel_scan(wmesh_service *service);
+int wmesh_gdbus_get_mesh_networks(wmesh_service *service);
+int wmesh_gdbus_get_joined_mesh_network(wmesh_service *service);
+int wmesh_gdbus_get_connected_peers(wmesh_service *service);
+
+int wmesh_gdbus_create_network(wmesh_service *service, gchar *mesh_id,
+ gint channel, wmeshd_security_type_e sec);
+int wmesh_gdbus_set_passphrase(wmesh_service *service, wmesh_scan_result_s *info,
+ gchar *passphrase);
+int wmesh_gdbus_connect_network(wmesh_service *service, wmesh_scan_result_s *info);
+int wmesh_gdbus_disconnect_network(wmesh_service *service, wmesh_scan_result_s *info);
+int wmesh_gdbus_remove_network(wmesh_service *service, wmesh_scan_result_s *info);
+int wmesh_gdbus_enable_ethernet_interface(wmesh_service *service, bool state);
+int wmesh_gdbus_set_mesh_gate(wmesh_service *service);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __WMESH_GDBUS_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * 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_INTERFACE_H__
+#define __WMESH_INTERFACE_H__
+
+typedef enum {
+ WMESH_INTERFACE_UP = 1, /**< Interface up */
+ WMESH_INTERFACE_DOWN, /**< Interface down */
+ WMESH_INTERFACE_DO_NOTHING, /**< Do not handle up/down */
+} wmesh_set_interface_type_e;
+
+int wmesh_interface_set(const char* interface, const char* ip_addr,
+ wmesh_set_interface_type_e type);
+//int wmesh_interface_set_mac_addr(const char* interface, const char* mac_addr);
+int wmesh_interface_initialize(wmesh_interface_s *info);
+int wmesh_interface_check(const char* interface);
+int wmesh_interface_check_external_exists(
+ const char* external_interface, bool *state);
+int wmesh_interface_check_bridge_interface_exists(const char* bridge, const char* interface);
+char* wmesh_interface_get_address(const char* if_name);
+
+#endif /* __WMESH_INTERFACE_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * 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_LOG_H__
+#define __WMESH_LOG_H__
+
+#ifdef USE_DLOG
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "WMESH_MANAGER"
+
+#define WMESH_LOGV(format, args...) LOGV(format, ##args)
+#define WMESH_LOGD(format, args...) LOGD(format, ##args)
+#define WMESH_LOGI(format, args...) LOGI(format, ##args)
+#define WMESH_LOGW(format, args...) LOGW(format, ##args)
+#define WMESH_LOGE(format, args...) LOGE(format, ##args)
+#define WMESH_LOGF(format, args...) LOGF(format, ##args)
+
+#define __WMESH_LOG_FUNC_ENTER__ LOGD("Enter")
+#define __WMESH_LOG_FUNC_EXIT__ LOGD("Quit")
+
+#define WMESH_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define WMESH_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#else /* USE_DLOG */
+
+#define WMESH_LOGV(format, args...)
+#define WMESH_LOGD(format, args...)
+#define WMESH_LOGI(format, args...)
+#define WMESH_LOGW(format, args...)
+#define WMESH_LOGE(format, args...)
+#define WMESH_LOGF(format, args...)
+
+#define __WMESH_LOG_FUNC_ENTER__
+#define __WMESH_LOG_FUNC_EXIT__
+
+#define WMESH_SECLOGI(format, args...)
+#define WMESH_SECLOGD(format, args...)
+
+#endif /* USE_DLOG */
+
+#endif /* __WMESH_LOG_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_NETLINK_H__
-#define __MESH_NETLINK_H__
+#ifndef __WMESH_NETLINK_H__
+#define __WMESH_NETLINK_H__
-int mesh_netlink_set_mesh_parameter(const char* mesh_if_name,
+int wmesh_netlink_set_mesh_parameter(const char* mesh_if_name,
const char* param_name, unsigned int value);
-int mesh_netlink_get_station_info(const char* mesh_if_name, GList **station_list);
-int mesh_netlink_del_station_info(const char* mesh_if_name, char *peer);
-int mesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list);
+int wmesh_netlink_get_station_info(const char* mesh_if_name, GList **station_list);
+int wmesh_netlink_del_station_info(const char* mesh_if_name, char *peer);
+int wmesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list);
-int mesh_netlink_register_event_handler();
-int mesh_netlink_unregister_event_handler();
+int wmesh_netlink_register_event_handler();
+int wmesh_netlink_unregister_event_handler();
-#endif /* __MESH_NETLINK_H__ */
+#endif /* __WMESH_NETLINK_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_MONITOR_H__
-#define __MESH_MONITOR_H__
+#ifndef __WMESH_MONITOR_H__
+#define __WMESH_MONITOR_H__
-int mesh_start_monitor_service(void *pdata);
-int mesh_stop_monitor_service(void *pdata);
-#endif /* __MESH_MONITOR_H__ */
\ No newline at end of file
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int wmesh_start_monitor_service(void *pdata);
+int wmesh_stop_monitor_service(void *pdata);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WMESH_MONITOR_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * 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_REQUEST_H__
+#define __WMESH_REQUEST_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Newly functions */
+int wmesh_request_enable_network(wmesh_service *service);
+int wmesh_request_disable_network(wmesh_service *service);
+int wmesh_request_scan(wmesh_service *service);
+int wmesh_request_specific_scan(wmesh_service *service, gchar *mesh_id,
+ gint channel);
+int wmesh_request_cancel_scan(wmesh_service *service);
+int wmesh_request_get_networks(wmesh_service *service);
+int wmesh_request_get_joined_network(wmesh_service *service);
+int wmesh_request_get_connected_peers(wmesh_service *service);
+
+int wmesh_request_create_mesh_network(wmesh_service *service, gchar *mesh_id,
+ gint channel, wmeshd_security_type_e sec);
+int wmesh_request_connect_mesh_network(wmesh_service *service, gchar *mesh_id,
+ gint channel, wmeshd_security_type_e sec, gchar *passphrase);
+int wmesh_request_disconnect_mesh_network(wmesh_service *service,
+ gchar *mesh_id, gint channel, wmeshd_security_type_e sec);
+int wmesh_request_remove_mesh_network(wmesh_service *service,
+ gchar *mesh_id, gint channel, wmeshd_security_type_e sec);
+
+int wmesh_request_set_mesh_gate(const char* bridge_interface,
+ const char* mesh_interface, const char* external_interface);
+int wmesh_request_unset_mesh_gate(const char* bridge_interface,
+ const char* mesh_interface, const char* external_interface);
+
+
+/* Bridge network */
+int wmesh_request_add_bridge_interface(const char* bridge_interface,
+ const char* interface);
+int wmesh_request_remove_bridge_interface(const char* bridge_interface,
+ const char* interface);
+
+/* Soft AP */
+int wmesh_request_set_softap_config(const char* softap_interface,
+ const char *ssid, const char* mode, int channel, int visibility,
+ int max_sta, int security, const char* passphrase);
+int wmesh_request_enable_softap(
+ const char* bridge_interface, const char* softap_interface);
+int wmesh_request_disable_softap(
+ const char* bridge_interface, const char* softap_interface);
+
+/* Mesh Station & path */
+int wmesh_request_get_station_info(const char* mesh_interface, GList **station_list);
+int wmesh_request_get_mpath_info(const char* mesh_interface, GList **mpath_list);
+
+int wmesh_request_register_event_handler();
+int wmesh_request_unregister_event_handler();
+
+/* Notifications */
+void wmesh_notify_scan_done();
+void wmesh_notify_connection_state(const char* mesh_id, const char* bssid,
+ int channel, wmeshd_security_type_e sec, wmeshd_connection_state_e state);
+void wmesh_notify_station_joined(const char* bssid);
+void wmesh_notify_station_left(const char* bssid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WMESH_REQUEST_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * 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_SERVICE_INTERFACE_H__
+#define __WMESH_SERVICE_INTERFACE_H__
+
+#include "wmesh-generated-code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**< Mesh D-BUS service*/
+#define WMESH_DBUS_SERVICE "net.wmesh"
+
+/**< Mesh D-BUS service path */
+#define WMESH_DBUS_PATH "/net/wmesh"
+
+#ifndef WMESH_DBUS_INTERFACE
+#define WMESH_DBUS_INTERFACE "net.wmesh"
+//#warning "WMESH_DBUS_INTERFACE is redefined"
+#endif
+
+#ifndef WMESH_DBUS_OBJPATH
+#define WMESH_DBUS_OBJPATH "/net/wmesh"
+//#warning "WMESH_DBUS_OBJPATH is redefined"
+#endif
+
+#ifndef WMESH_DBUS_MANAGER_OBJPATH
+#define WMESH_DBUS_MANAGER_OBJPATH "/net/wmesh/manager"
+//#warning "WMESH_DBUS_MANAGER_OBJPATH is redefined"
+#endif
+
+NetWmesh* wmeshd_dbus_get_object();
+int64_t wmeshd_dbus_generate_signal_number();
+gboolean wmeshd_service_interface_init(wmesh_service *service);
+void wmeshd_service_interface_deinit(wmesh_service *service);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WMESH_SERVICE_INTERFACE_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_SERVICE_H__
-#define __MESH_SERVICE_H__
+#ifndef __WMESH_SERVICE_H__
+#define __WMESH_SERVICE_H__
-mesh_service *meshd_service_new();
-void meshd_service_free(mesh_service *service);
-gboolean meshd_service_run(mesh_service *service);
-gboolean meshd_service_exit(mesh_service *service);
+#ifdef __cplusplus
+extern "C" {
+#endif
- #endif /* __MESH_SERVICE_H__ */
\ No newline at end of file
+wmesh_service *wmeshd_service_new();
+void wmeshd_service_free(wmesh_service *service);
+gboolean wmeshd_service_run(wmesh_service *service);
+gboolean wmeshd_service_exit(wmesh_service *service);
+
+#ifdef __cplusplus
+}
+#endif
+
+ #endif /* __WMESH_SERVICE_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_SOFTAP_H__
-#define __MESH_SOFTAP_H__
+#ifndef __WMESH_SOFTAP_H__
+#define __WMESH_SOFTAP_H__
-int mesh_softap_set_configuration(const char* softap_interface,
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int wmesh_softap_set_configuration(const char* softap_interface,
const char *ssid, const char* mode, int channel, int visibility,
int max_sta, int security, const char* passphrase);
-int mesh_softap_enable_softap();
-int mesh_softap_disable_softap();
+int wmesh_softap_enable_softap();
+int wmesh_softap_disable_softap();
+
+#ifdef __cplusplus
+}
+#endif
- #endif /* __MESH_SOFTAP_H__ */
\ No newline at end of file
+ #endif /* __WMESH_SOFTAP_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_UTIL_H__
-#define __MESH_UTIL_H__
+#ifndef __WMESH_UTIL_H__
+#define __WMESH_UTIL_H__
#include <glib.h>
#define NOTUSED(var) (var = var)
-#define meshd_check_null_ret_error(name, value, error) do { \
+#define wmeshd_check_null_ret_error(name, value, error) do { \
if (G_UNLIKELY(NULL == (value))) { \
- MESH_LOGE("%s is NULL", name); \
+ WMESH_LOGE("%s is NULL", name); \
return error; \
} \
} while (FALSE)
-#define meshd_check_null_ret(name, value) do { \
+#define wmeshd_check_null_ret(name, value) do { \
if (G_UNLIKELY(NULL == (value))) { \
- MESH_LOGE("%s is NULL", name); \
+ WMESH_LOGE("%s is NULL", name); \
return; \
} \
} while (FALSE)
-#endif /* __MESH_UTIL_H__ */
+#endif /* __WMESH_UTIL_H__ */
* limitations under the License.
*
*/
-#ifndef __MESH_H__
-#define __MESH_H__
+#ifndef __WMESH_H__
+#define __WMESH_H__
#include <glib.h>
#include <gio/gio.h>
/**< Internal error code with mesh daemon. It should be matched with API side */
typedef enum {
- MESHD_ERROR_NONE = 0, /**< Successful */
- MESHD_ERROR_IO_ERROR, /**< I/O error */
- MESHD_ERROR_NO_DATA, /**< Data not exists */
- MESHD_ERROR_OUT_OF_MEMORY, /**< out of memory */
- MESHD_ERROR_OPERATION_FAILED, /**< operation failed */
- MESHD_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- MESHD_ERROR_ALREADY_REGISTERED, /**< Request already registered */
- MESHD_ERROR_IN_PROGRESS /**< operation is in progress */
+ WMESHD_ERROR_NONE = 0, /**< Successful */
+ WMESHD_ERROR_IO_ERROR, /**< I/O error */
+ WMESHD_ERROR_NO_DATA, /**< Data not exists */
+ WMESHD_ERROR_OUT_OF_MEMORY, /**< out of memory */
+ WMESHD_ERROR_OPERATION_FAILED, /**< operation failed */
+ WMESHD_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ WMESHD_ERROR_ALREADY_REGISTERED, /**< Request already registered */
+ WMESHD_ERROR_IN_PROGRESS /**< operation is in progress */
} meshd_error_e;
/**< Internal enum for connection state. It should be matched with API side */
typedef enum {
- MESHD_CONNECTION_STATE_DISCONNECTED = 0, /**< Disconnected state */
- MESHD_CONNECTION_STATE_ASSOCIATION, /**< Association state */
- MESHD_CONNECTION_STATE_CONFIGURATION, /**< Configuration state */
- MESHD_CONNECTION_STATE_CONNECTED /**< Connected state */
-} meshd_connection_state_e;
+ WMESHD_CONNECTION_STATE_DISCONNECTED = 0, /**< Disconnected state */
+ WMESHD_CONNECTION_STATE_ASSOCIATION, /**< Association state */
+ WMESHD_CONNECTION_STATE_CONFIGURATION, /**< Configuration state */
+ WMESHD_CONNECTION_STATE_CONNECTED /**< Connected state */
+} wmeshd_connection_state_e;
/**< Internal enum for security type. It should be matched with API side */
typedef enum {
- MESHD_SECURITY_NONE = 0, /**< No security */
- MESHD_SECURITY_SAE, /**< SAE */
-} meshd_security_type_e;
+ WMESHD_SECURITY_NONE = 0, /**< No security */
+ WMESHD_SECURITY_SAE, /**< SAE */
+} wmeshd_security_type_e;
/**< mesh interface information structure */
typedef struct {
bool gate_announce; /**< Gate Announce Dnable/Disable */
int hwmp_root_mode; /**< HWMP Root Mode (0, 2,3 or 4) */
int stp; /**< Spanning Tree Protocol Enable/Disablel */
-} mesh_interface_s;
+} wmesh_interface_s;
/**< Saved mesh network list structure */
-typedef struct _mesh_network_info {
+typedef struct _wmesh_network_info {
char* mesh_id; /**< The mesh id */
char* bssid; /**< BSSID */
int channel; /**< Channel */
- meshd_security_type_e security; /**< Security type */
- meshd_connection_state_e state; /**< Connection state */
-} mesh_network_info_s;
+ wmeshd_security_type_e security; /**< Security type */
+ wmeshd_connection_state_e state; /**< Connection state */
+} wmesh_network_info_s;
/**< Mesh network scan result structure */
typedef struct {
gint rssi; /**< RSSI */
gint channel; /**< Channel */
gint data_rate; /**< Data rate */
- meshd_security_type_e security; /**< Security type */
- meshd_connection_state_e state; /**< Connection state */
-} mesh_scan_result_s;
+ wmeshd_security_type_e security; /**< Security type */
+ wmeshd_connection_state_e state; /**< Connection state */
+} wmesh_scan_result_s;
/**< Mesh peer structure */
typedef struct {
gchar *address; /**< MAC address of connected peer */
-} mesh_peer_info_s;
+} wmesh_peer_info_s;
/**< Connected mesh network station */
typedef struct {
gboolean short_preamble; /**< short preamble */
gboolean short_slot_time; /**< short slot time supported ex) yes */
guint connected_time; /**< connected time : ex) 256 seconds */
-} mesh_station_info_s;
+} wmesh_station_info_s;
/**< Mesh path information structure */
typedef struct {
guint discovery_timeout; /**< Discovery timeout */
guchar discovery_retries; /**< Discovery retries */
guchar flags; /**< Flags */
-} mesh_mpath_info_s;
+} wmesh_mpath_info_s;
/**< mesh service structure */
-typedef struct _mesh_service {
+typedef struct _wmesh_service {
GMainLoop *main_loop; /**< Service main-loop */
guint dbus_id; /**< D-Bus id */
guint activation_dbus_id; /**< D-Bus id for activation */
GCancellable *ca; /**< Cancellable object for D-Bus call (Daemon->other) */
GList *dbus_sub_ids; /**< The list of subscribed signals */
- mesh_interface_s *interface_info; /**< Name of network interfaces */
+ wmesh_interface_s *interface_info; /**< Name of network interfaces */
gboolean mesh_activated; /**< Stored if mesh network is activated */
GList *scanned_mesh_network; /**< Scanned mesh network list */
GList *connected_mesh_peers; /**< Connected mesh peer list */
- mesh_network_info_s *joined_network; /**< Joined network info */
+ wmesh_network_info_s *joined_network; /**< Joined network info */
GList *station_list; /**< Mesh station list */
GList *mpath_list; /**< MPath list */
int netlink_fd; /**< Netlink event socket file descriptor */
int monitor_timer; /**< Timer ID for peer monitoring service */
-} mesh_service;
+} wmesh_service;
- #endif /* __MESH_H__ */
+ #endif /* __WMESH_H__ */
-gdbus-codegen --interface-prefix net.mesh. \
- --generate-c-code mesh-generated-code \
+gdbus-codegen --interface-prefix net.wmesh. \
+ --generate-c-code wmesh-generated-code \
--c-generate-object-manager \
--generate-docbook generated-docs \
- mesh.xml \
- manager.xml
+ wmesh.xml \
+ wmanager.xml
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<node>
- <interface name="net.mesh.manager">
+ <interface name="net.wmesh.manager">
<!-- Method definitions -->
<method name="enable">
<arg type="i" name="result" direction="out"/>
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">\r
\r
<node>\r
- <interface name="net.mesh">\r
+ <interface name="net.wmesh">\r
<!-- Method definitions -->\r
<method name="scan">\r
<arg type="i" name="result" direction="out"/>\r
+++ /dev/null
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <policy user="root">
- <allow own="net.mesh"/>
- <allow own="net.mesh.manager"/>
- <allow send_destination="net.mesh"/>
- <allow send_destination="net.mesh.manager"/>
- <allow receive_sender="net.mesh"/>
- </policy>
- <policy context="default">
- <allow send_destination="net.mesh" send_interface="net.mesh" />
- <allow send_destination="net.mesh.manager" send_interface="net.mesh.manager" />
-
- <!-- Manager -->
- <check send_destination="net.mesh.manager" send_interface="net.mesh.manager"
- send_member="enable" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh.manager" send_interface="net.mesh.manager"
- send_member="disable" privilege="http://tizen.org/privilege/mesh"/>
-
- <!-- Normal methods -->
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="scan" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="specific_scan" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="cancel_scan" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="get_found_mesh_networks" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="get_connected_peers" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="enable_mesh" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="disable_mesh" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="get_joined_mesh_network" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="set_gate" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="unset_gate" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="set_softap" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="enable_softap" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="disable_softap" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="create_mesh_network" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="connect_mesh_network" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="disconnect_mesh_network" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="forget_mesh_network" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="set_interfaces" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="get_station_info" privilege="http://tizen.org/privilege/mesh"/>
- <check send_destination="net.mesh" send_interface="net.mesh"
- send_member="get_mpath_info" privilege="http://tizen.org/privilege/mesh"/>
-
- </policy>
-</busconfig>
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="net.wmesh"/>
+ <allow own="net.wmesh.manager"/>
+ <allow send_destination="net.wmesh"/>
+ <allow send_destination="net.wmesh.manager"/>
+ <allow receive_sender="net.wmesh"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="net.wmesh" send_interface="net.wmesh" />
+ <allow send_destination="net.wmesh.manager" send_interface="net.wmesh.manager" />
+
+ <!-- Manager -->
+ <check send_destination="net.wmesh.manager" send_interface="net.wmesh.manager"
+ send_member="enable" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh.manager" send_interface="net.wmesh.manager"
+ send_member="disable" privilege="http://tizen.org/privilege/wmesh"/>
+
+ <!-- Normal methods -->
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="scan" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="specific_scan" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="cancel_scan" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="get_found_mesh_networks" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="get_connected_peers" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="enable_mesh" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="disable_mesh" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="get_joined_mesh_network" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="set_gate" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="unset_gate" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="set_softap" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="enable_softap" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="disable_softap" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="create_mesh_network" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="connect_mesh_network" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="disconnect_mesh_network" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="forget_mesh_network" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="set_interfaces" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="get_station_info" privilege="http://tizen.org/privilege/wmesh"/>
+ <check send_destination="net.wmesh" send_interface="net.wmesh"
+ send_member="get_mpath_info" privilege="http://tizen.org/privilege/wmesh"/>
+
+ </policy>
+</busconfig>
+++ /dev/null
-[D-BUS Service]
-Name=net.mesh.manager
-
-Exec=/bin/false
-User=root
-SystemdService=meshd.service
--- /dev/null
+[D-BUS Service]
+Name=net.wmesh.manager
+
+Exec=/bin/false
+User=root
+SystemdService=wmeshd.service
[Unit]
-Description=Mesh Network Manager service
+Description=Wi-Fi Mesh Network Manager service
Requires=dbus.socket
After=dbus.socket
[Service]
Type=dbus
-BusName=net.mesh.manager
+BusName=net.wmesh.manager
SmackProcessLabel=System
-ExecStart=/usr/bin/meshd
+ExecStart=/usr/bin/wmeshd
CapabilityBoundingSet=~CAP_MAC_ADMIN
CapabilityBoundingSet=~CAP_MAC_OVERRIDE
-%define CHECK_MESH_PRIVILEGE False
+%define CHECK_WMESH_PRIVILEGE False
-Name: meshd
-Summary: mesh network daemon
+Name: wmeshd
+Summary: Wi-Fi mesh network daemon
Version: 0.0.1
Release: 1
Group: Network & Connectivity/Wireless
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-Source1: dbus-meshd.conf
-Source2: net.mesh.service
-Source3: meshd.service
+Source1: dbus-wmeshd.conf
+Source2: net.wmesh.service
+Source3: wmeshd.service
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(gio-unix-2.0)
Requires: toybox-symlinks-dhcp
%description
-Manager for handling mesh network
+Manager for handling Wi-Fi mesh network
%prep
%setup -q
chmod 644 %{SOURCE1}
chmod 644 %{SOURCE2}
chmod 644 %{SOURCE3}
-%if %{CHECK_MESH_PRIVILEGE} == "True"
-cp -a %{SOURCE1} ./meshd.conf
+%if %{CHECK_WMESH_PRIVILEGE} == "True"
+cp -a %{SOURCE1} ./wmeshd.conf
%endif
cp -a %{SOURCE2} .
cp -a %{SOURCE3} .
%make_install
-%if %{CHECK_MESH_PRIVILEGE} == "True"
+%if %{CHECK_WMESH_PRIVILEGE} == "True"
mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
-cp meshd.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/meshd.conf
+cp wmeshd.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/wmeshd.conf
%endif
mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/
-cp net.mesh.service %{buildroot}%{_datadir}/dbus-1/system-services/net.mesh.service
+cp net.wmesh.service %{buildroot}%{_datadir}/dbus-1/system-services/net.wmesh.service
mkdir -p %{buildroot}%{_unitdir}
-cp meshd.service %{buildroot}%{_unitdir}/meshd.service
+cp wmeshd.service %{buildroot}%{_unitdir}/wmeshd.service
%post
-chmod 755 %{_sbindir}/mesh.sh
+chmod 755 %{_sbindir}/wmesh.sh
# For configuration files
-mkdir -p %TZ_SYS_VAR/lib/mesh
+mkdir -p %TZ_SYS_VAR/lib/wmesh
%files
-%manifest meshd.manifest
+%manifest wmeshd.manifest
%license LICENSE
%defattr(-,root,root,-)
-%caps(cap_net_raw,cap_net_admin=eip) %attr(750,system,system) %{_bindir}/meshd
-%if %{CHECK_MESH_PRIVILEGE} == "True"
-%config %{_sysconfdir}/dbus-1/system.d/meshd.conf
+%caps(cap_net_raw,cap_net_admin=eip) %attr(750,system,system) %{_bindir}/wmeshd
+%if %{CHECK_WMESH_PRIVILEGE} == "True"
+%config %{_sysconfdir}/dbus-1/system.d/wmeshd.conf
%endif
%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
-%attr(644,root,root) %{_unitdir}/meshd.service
-%attr(750,root,root) %{_sbindir}/mesh.sh
+%attr(644,root,root) %{_unitdir}/wmeshd.service
+%attr(750,root,root) %{_sbindir}/wmesh.sh
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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 <stdlib.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service-interface.h"
-#include "mesh-generated-code.h"
-
-#include "mesh-bridge.h"
-#include "mesh-netlink.h"
-#include "mesh-interface.h"
-#include "mesh-request.h"
-#include "mesh-softap.h"
-#include "mesh-gdbus.h"
-
-int mesh_request_set_mesh_gate(const char* bridge_interface,
- const char* mesh_interface, const char* external_interface)
-{
- int ret = MESHD_ERROR_NONE;
- bool state = FALSE;
-
- ret = mesh_interface_check_external_exists(external_interface, &state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get external interface state !");
- return MESHD_ERROR_OPERATION_FAILED;
- }
- MESH_LOGD(" Ethernet cable state [%s]",
- (state) ? "Connected" : "Disconnected");
-
- /* Turn STP on */
- ret = mesh_bridge_set_stp(bridge_interface, TRUE);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to turn STP on !");
- return ret;
- }
-
- /* Set mesh parameters */
- ret = mesh_netlink_set_mesh_parameter(mesh_interface,
- "mesh_hwmp_rootmode", 4);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 4");
-
- ret = mesh_netlink_set_mesh_parameter(mesh_interface,
- "mesh_gate_announcements", 1);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to set [mesh_gate_announcements] : 1");
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_unset_mesh_gate(const char* bridge_interface,
- const char* mesh_interface, const char* external_interface)
-{
- int ret = MESHD_ERROR_NONE;
-
- NOTUSED(external_interface);
-
- /* Set mesh parameters */
- ret = mesh_netlink_set_mesh_parameter(mesh_interface,
- "mesh_hwmp_rootmode", 0);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to set [mesh_hwmp_rootmode] : 0");
-
- ret = mesh_netlink_set_mesh_parameter(mesh_interface,
- "mesh_gate_announcements", 0);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to set [mesh_gate_announcements] : 0");
-
- /* Turn STP off */
- ret = mesh_bridge_set_stp(bridge_interface, FALSE);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to turn STP off!");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_add_bridge_interface(const char* bridge_interface,
- const char* interface)
-{
- int ret = MESHD_ERROR_NONE;
-
- if (NULL == bridge_interface || NULL == interface) {
- MESH_LOGE("Invalid parameters");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("Adding interface[%s] into bridge[%s]...", interface, bridge_interface);
-
- /* Add external interface into bridge */
- ret = mesh_bridge_add_interface(bridge_interface, interface);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to add interface !");
- return ret;
- }
-
- /* Make external interface down */
- ret = mesh_interface_set(interface, NULL, MESH_INTERFACE_DOWN);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to change external interface state");
- return ret;
- }
-
- /* Make external interface up with cleared IP */
- ret = mesh_interface_set(interface, "0.0.0.0", MESH_INTERFACE_UP);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to change external interface state");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_remove_bridge_interface(const char* bridge_interface,
- const char* interface)
-{
- int ret = MESHD_ERROR_NONE;
-
- if (NULL == bridge_interface || NULL == interface) {
- MESH_LOGE("Invalid parameters");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("Removing interface[%s] from bridge[%s]...", interface, bridge_interface);
-
- ret = mesh_interface_check_bridge_interface_exists(bridge_interface, interface);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGD("Interface is not exist in bridge");
- return MESHD_ERROR_NONE;
- }
-
- /* Remove external interface into bridge */
- ret = mesh_bridge_del_interface(bridge_interface, interface);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to remove interface !");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_set_softap_config(const char* softap_interface,
- const char *ssid, const char* mode, int channel, int visibility,
- int max_sta, int security, const char* passphrase)
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Setting configuration for SoftAP");
-
- ret = mesh_softap_set_configuration(softap_interface, ssid, mode, channel,
- visibility, max_sta, security, passphrase);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to set Configuration for SoftAP");
- return ret;
- }
-
- return ret;
-}
-
-int mesh_request_enable_softap(
- const char* bridge_interface, const char* softap_interface)
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Request to turn SoftAP on");
- ret = mesh_softap_enable_softap(softap_interface);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_softap_enable_softap");
- return ret;
- }
-
- /* Add softAP interface into bridge */
- ret = mesh_request_add_bridge_interface(bridge_interface, softap_interface);
- if (MESHD_ERROR_NONE != ret) {
- mesh_softap_disable_softap();
- return ret;
- }
-
- return ret;
-}
-
-int mesh_request_disable_softap(
- const char* bridge_interface, const char* softap_interface)
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Request to turn SoftAP off");
- ret = mesh_softap_disable_softap();
-
- /* Remove softAP interface from bridge */
- ret = mesh_request_remove_bridge_interface(bridge_interface, softap_interface);
- if (MESHD_ERROR_NONE != ret)
- return ret;
-
- return ret;
-}
-
-int mesh_request_get_station_info(const char* mesh_interface, GList **station_list)
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Request to get station info");
-
- /* Get station info */
- ret = mesh_netlink_get_station_info(mesh_interface, station_list);
- if (MESHD_ERROR_NONE != ret)
- return ret;
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_get_mpath_info(const char* mesh_interface, GList **mpath_list)
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Request to get mpath info");
-
- /* Get MPath info */
- ret = mesh_netlink_get_mpath_info(mesh_interface, mpath_list);
- if (MESHD_ERROR_NONE != ret)
- return ret;
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_register_event_handler()
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Request to register mesh event handler");
-
- /* Get MPath info */
- ret = mesh_netlink_register_event_handler();
- if (MESHD_ERROR_NONE != ret)
- return ret;
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_unregister_event_handler()
-{
- int ret = MESHD_ERROR_NONE;
-
- MESH_LOGD("Request to unregister mesh event handler");
-
- /* Get MPath info */
- ret = mesh_netlink_unregister_event_handler();
- if (MESHD_ERROR_NONE != ret)
- return ret;
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_enable_network(mesh_service *service)
-{
- int ret;
- mesh_interface_s *info = NULL;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Enable mesh network");
-
- /* Check if mesh interface exists */
- info = service->interface_info;
- ret = mesh_interface_check(info->mesh_interface);
- if (MESHD_ERROR_NONE == ret) {
- /* Interface already exists */
- return MESHD_ERROR_NONE;
- }
-
- ret = mesh_gdbus_create_mesh_interface(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to create mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_disable_network(mesh_service *service)
-{
- int ret;
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Disable mesh network");
-
- ret = mesh_gdbus_remove_mesh_interface(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to disable mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_scan(mesh_service *service)
-{
- int ret;
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Request scan for mesh network");
-
- ret = mesh_gdbus_mesh_scan(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to request scan for mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_specific_scan(mesh_service *service, gchar *mesh_id, gint channel)
-{
- int ret;
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Request specific scan for mesh network");
-
- ret = mesh_gdbus_mesh_specific_scan(service, mesh_id, channel);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to request specific scan for mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_cancel_scan(mesh_service *service)
-{
- int ret;
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Cancel scan for mesh network");
-
- ret = mesh_gdbus_mesh_cancel_scan(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to cancel scan for mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_get_networks(mesh_service *service)
-{
- int ret;
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Get mesh networks");
-
- ret = mesh_gdbus_get_mesh_networks(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get mesh networks !");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-static int _select_matched_network(GList *scanned_network,
- const char *mesh_id, int mesh_channel, meshd_security_type_e sec,
- mesh_scan_result_s **info)
-{
- int ret = MESHD_ERROR_NONE;
- GList *iter = NULL;
- mesh_scan_result_s *item = NULL;
- gboolean found = FALSE;
-
- meshd_check_null_ret_error("scanned_network", scanned_network,
- MESHD_ERROR_INVALID_PARAMETER);
-
- iter = scanned_network;
- while (iter != NULL) {
- item = (mesh_scan_result_s*)iter->data;
-
- if (g_strcmp0(mesh_id, item->mesh_id) == 0) {
- if (item->channel == mesh_channel && item->security == sec) {
- *info = item;
- found = TRUE;
- break;
- }
- }
- iter = g_list_next(iter);
- }
-
- if (FALSE == found)
- return MESHD_ERROR_NO_DATA;
-
- return ret;
-}
-
-int mesh_request_get_joined_network(mesh_service *service)
-{
- int ret;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Get joined mesh network");
-
- ret = mesh_gdbus_get_joined_mesh_network(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get joined mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_get_connected_peers(mesh_service *service)
-{
- int ret;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Get connected mesh peers");
-
- ret = mesh_gdbus_get_connected_peers(service);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get connected mesh peers");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_create_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, meshd_security_type_e sec)
-{
- int ret;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Create a new mesh network");
-
- ret = mesh_gdbus_create_network(service, mesh_id, channel, sec);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to create mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_connect_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, meshd_security_type_e sec, gchar *passphrase)
-{
- int ret;
- mesh_scan_result_s *info = NULL;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Connect mesh network");
-
- /* Get mesh_id and channel from saved network */
- ret = _select_matched_network(service->scanned_mesh_network,
- mesh_id, channel, sec, &info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_network_get_first_mesh_network");
- return ret;
- }
-
- /* Set passphrase */
- if (MESHD_SECURITY_NONE != sec) {
- if (NULL != passphrase) {
- ret = mesh_gdbus_set_passphrase(service, info, passphrase);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to set passphrase for mesh network");
- return ret;
- }
- } else {
- MESH_LOGE("Passphrase is required !");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
- }
-
- ret = mesh_gdbus_connect_network(service, info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to connect mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_disconnect_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, meshd_security_type_e sec)
-{
- int ret;
- mesh_scan_result_s *info = NULL;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Disconnect mesh network");
-
- /* Get mesh_id and channel from saved network */
- ret = _select_matched_network(service->scanned_mesh_network,
- mesh_id, channel, sec, &info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to _select_matched_network");
- return ret;
- }
-
- ret = mesh_gdbus_disconnect_network(service, info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to disconnect mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-int mesh_request_remove_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, meshd_security_type_e sec)
-{
- int ret;
- mesh_scan_result_s *info = NULL;
-
- if (NULL == service) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
- }
-
- MESH_LOGD("[IPC] Remove mesh network");
-
- /* Get mesh_id and channel from saved network */
- ret = _select_matched_network(service->scanned_mesh_network,
- mesh_id, channel, sec, &info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to _select_matched_network");
- return ret;
- }
-
- ret = mesh_gdbus_remove_network(service, info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to remove mesh network");
- return ret;
- }
-
- return MESHD_ERROR_NONE;
-}
-
-/* Notifications */
-void mesh_notify_scan_done()
-{
- NetMesh *object = meshd_dbus_get_object();
-
- net_mesh_emit_scan_done(object);
-}
-
-void mesh_notify_connection_state(const char* mesh_id, const char* bssid,
- int channel, meshd_security_type_e sec, meshd_connection_state_e state)
-{
- NetMesh *object = meshd_dbus_get_object();
-
- net_mesh_emit_connection_state(object, mesh_id, bssid, channel, (int)sec, (int)state);
-}
-
-void mesh_notify_station_joined(const char* bssid)
-{
- NetMesh *object = meshd_dbus_get_object();
-
- net_mesh_emit_sta_joined(object, bssid);
-}
-
-void mesh_notify_station_left(const char* bssid)
-{
- NetMesh *object = meshd_dbus_get_object();
-
- net_mesh_emit_sta_left(object, bssid);
-}
extern unsigned int if_nametoindex(const char *__ifname);
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
-#include "mesh-bridge.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-service.h"
+#include "wmesh-bridge.h"
#define ERROR_MESSAGE_LENGTH 256
-int mesh_bridge_create(const char* bridge_name)
+int wmesh_bridge_create(const char* bridge_name)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
int val = 0;
int br_fd = 0;
char bridge[IFNAMSIZ];
#endif
if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", bridge_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", bridge_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
snprintf(bridge, IFNAMSIZ, "%s", bridge_name);
#endif
if (val < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to create bridge [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to create bridge [%s(%d)]", str_error, errno);
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
}
close(br_fd);
return ret;
}
-int mesh_bridge_remove(const char* bridge_name)
+int wmesh_bridge_remove(const char* bridge_name)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
int val = 0;
int br_fd = 0;
char bridge[IFNAMSIZ];
#endif
if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", bridge_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", bridge_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
snprintf(bridge, IFNAMSIZ, "%s", bridge_name);
#endif
if (val < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to remove bridge [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to remove bridge [%s(%d)]", str_error, errno);
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
}
close(br_fd);
return ret;
}
-int mesh_bridge_add_interface(const char* bridge_name, const char* interface)
+int wmesh_bridge_add_interface(const char* bridge_name, const char* interface)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
int val = 0;
int br_fd = 0;
#endif
if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", bridge_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", bridge_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (NULL == interface || strlen(interface) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", interface);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", interface);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", bridge_name);
#endif
if (val < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to add interface [%s] into bridge [%s(%d)]",
+ WMESH_LOGD("Failed to add interface [%s] into bridge [%s(%d)]",
interface, str_error, errno);
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
}
close(br_fd);
return ret;
}
-int mesh_bridge_del_interface(const char* bridge_name, const char* interface)
+int wmesh_bridge_del_interface(const char* bridge_name, const char* interface)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
int val = 0;
int br_fd = 0;
#endif
if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", bridge_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", bridge_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (NULL == interface || strlen(interface) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", interface);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", interface);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", bridge_name);
#endif
if (val < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to delete interface [%s] from bridge [%s(%d)]",
+ WMESH_LOGD("Failed to delete interface [%s] from bridge [%s(%d)]",
interface, str_error, errno);
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
}
close(br_fd);
return ret;
}
-int mesh_bridge_set_stp(const char* bridge_name, bool state)
+int wmesh_bridge_set_stp(const char* bridge_name, bool state)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
int val = 0;
int br_fd = 0;
char str_error[ERROR_MESSAGE_LENGTH];
stp_state, 0, 0 };
if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", bridge_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", bridge_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
br_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (br_fd < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
+ WMESH_LOGD("Failed to open socket [%s(%d)]", str_error, errno);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
strncpy(ifr.ifr_name, bridge_name, IFNAMSIZ);
val = ioctl(br_fd, SIOCDEVPRIVATE, &ifr);
if (val < 0) {
strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH);
- MESH_LOGE("Failed to set bridge[%s] stp state", bridge_name);
- MESH_LOGE(" %s(%d)", str_error, errno);
+ WMESH_LOGE("Failed to set bridge[%s] stp state", bridge_name);
+ WMESH_LOGE(" %s(%d)", str_error, errno);
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
}
close(br_fd);
* limitations under the License.
*/
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-gdbus.h"
-#include "mesh-request.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-gdbus.h"
+#include "wmesh-request.h"
#include <linux/nl80211.h>
static GDBusProxy *_gproxy_connman_technology = NULL;
static GDBusProxy *_gproxy_connman_ethernet = NULL;
-static int _meshd_close_gdbus_call(mesh_service *service);
-static int _mesh_gdbus_get_mesh_network_property(mesh_service *service,
- const gchar* object_path, mesh_network_info_s *result);
+static int _wmeshd_close_gdbus_call(wmesh_service *service);
+static int _wmesh_gdbus_get_mesh_network_property(wmesh_service *service,
+ const gchar* object_path, wmesh_network_info_s *result);
static int __channel_to_frequency(int channel, enum nl80211_band band)
{
return 0;
}
-static GDBusProxy *_proxy_get_connman(mesh_service *service)
+static GDBusProxy *_proxy_get_connman(wmesh_service *service)
{
GDBusProxy *proxy = NULL;
- meshd_check_null_ret_error("service", service, NULL);
+ wmeshd_check_null_ret_error("service", service, NULL);
if (NULL == _gproxy_connman) {
proxy = g_dbus_proxy_new_sync(service->connection,
return proxy;
}
-static GDBusProxy *_proxy_get_connman_mesh(mesh_service *service)
+static GDBusProxy *_proxy_get_connman_mesh(wmesh_service *service)
{
GDBusProxy *proxy = NULL;
- meshd_check_null_ret_error("service", service, NULL);
+ wmeshd_check_null_ret_error("service", service, NULL);
if (NULL == _gproxy_connman_mesh) {
proxy = g_dbus_proxy_new_sync(service->connection,
return proxy;
}
-static GDBusProxy *_proxy_get_connman_ethernet(mesh_service *service)
+static GDBusProxy *_proxy_get_connman_ethernet(wmesh_service *service)
{
GDBusProxy *proxy = NULL;
- meshd_check_null_ret_error("service", service, NULL);
+ wmeshd_check_null_ret_error("service", service, NULL);
if (NULL == _gproxy_connman_ethernet) {
proxy = g_dbus_proxy_new_sync(service->connection,
return proxy;
}
-static GDBusProxy *_proxy_get_connman_technology(mesh_service *service)
+static GDBusProxy *_proxy_get_connman_technology(wmesh_service *service)
{
GDBusProxy *proxy = NULL;
- meshd_check_null_ret_error("service", service, NULL);
+ wmeshd_check_null_ret_error("service", service, NULL);
if (NULL == _gproxy_connman_technology) {
proxy = g_dbus_proxy_new_sync(service->connection,
{
GDBusProxy *proxy = G_DBUS_PROXY(object);
gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
- mesh_service *service = (mesh_service*)user_data;
+ wmesh_service *service = (wmesh_service*)user_data;
NOTUSED(pspec);
if (NULL == name_owner) {
- MESH_LOGE("name_owner is not exists !");
- _meshd_close_gdbus_call(service);
+ WMESH_LOGE("name_owner is not exists !");
+ _wmeshd_close_gdbus_call(service);
}
g_free(name_owner);
}
-static int _meshd_create_gdbus_call(mesh_service *service)
+static int _wmeshd_create_gdbus_call(wmesh_service *service)
{
int id;
GError *error = NULL;
if (NULL == service)
- return MESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER;
if (NULL != service->connection)
- return MESHD_ERROR_ALREADY_REGISTERED;
+ return WMESHD_ERROR_ALREADY_REGISTERED;
service->connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (service->connection == NULL) {
if (error != NULL) {
- MESH_LOGE("Failed to connect to the D-BUS daemon [%s]", error->message);
+ WMESH_LOGE("Failed to connect to the D-BUS daemon [%s]", error->message);
g_error_free(error);
}
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
id = g_signal_connect(service->connection, "notify::g-name-owner",
G_CALLBACK(_dbus_name_owner_notify), service);
if (0 == id) {
- MESH_LOGE("g_signal_connect() Fail");
+ WMESH_LOGE("g_signal_connect() Fail");
g_object_unref(service->connection);
service->connection = NULL;
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-static int _meshd_close_gdbus_call(mesh_service *service)
+static int _wmeshd_close_gdbus_call(wmesh_service *service)
{
/* CHECK: is connection ref count required? */
g_object_unref(service->connection);
service->connection = NULL;
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-static void _meshd_signal_handler(GDBusConnection *connection,
+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)
{
- mesh_service *service = (mesh_service*)user_data;
- mesh_network_info_s network_info = { 0, 0, 0, 0, 0 };
- int ret = MESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service*)user_data;
+ wmesh_network_info_s network_info = { 0, 0, 0, 0, 0 };
+ int ret = WMESHD_ERROR_NONE;
- meshd_check_null_ret("user_data", user_data);
+ wmeshd_check_null_ret("user_data", user_data);
NOTUSED(connection);
NOTUSED(sender_name);
NOTUSED(interface_name);
- MESH_LOGD("signal received = %s", signal_name);
+ WMESH_LOGD("signal received = %s", signal_name);
if (0 == g_strcmp0(signal_name, "ScanDone")) {
/* TODO: Handle event */
- mesh_notify_scan_done();
+ wmesh_notify_scan_done();
} else if (0 == g_strcmp0(signal_name, "PropertyChanged")) {
const gchar* var = NULL;
gchar* key = NULL;
GVariant *variant = NULL;
- meshd_connection_state_e state = MESHD_CONNECTION_STATE_DISCONNECTED;
+ wmeshd_connection_state_e state = WMESHD_CONNECTION_STATE_DISCONNECTED;
if (NULL == parameters) {
- MESH_LOGE("Unexpected parameter");
+ WMESH_LOGE("Unexpected parameter");
return;
}
g_variant_get(parameters, "(sv)", &key, &variant);
if (NULL == variant) {
- MESH_LOGE("Invalid variant");
+ WMESH_LOGE("Invalid variant");
return;
}
/* State [???] */
var = g_variant_get_string(variant, NULL);
- MESH_LOGD(" %s [%s]", key, var);
- MESH_LOGD(" %s", object_path);
+ WMESH_LOGD(" %s [%s]", key, var);
+ WMESH_LOGD(" %s", object_path);
- ret = _mesh_gdbus_get_mesh_network_property(service, object_path, &network_info);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Cannot get valid network property !");
+ ret = _wmesh_gdbus_get_mesh_network_property(service, object_path, &network_info);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Cannot get valid network property !");
if (g_strcmp0("association", var) == 0) {
/* Joined mesh network */
- state = MESHD_CONNECTION_STATE_ASSOCIATION;
+ state = WMESHD_CONNECTION_STATE_ASSOCIATION;
} else if (g_strcmp0("configuration", var) == 0) {
/* Trying to get IP address */
- state = MESHD_CONNECTION_STATE_CONFIGURATION;
+ state = WMESHD_CONNECTION_STATE_CONFIGURATION;
} else if (g_strcmp0("ready", var) == 0 || g_strcmp0("online", var) == 0) {
/* IP address is obtained */
- state = MESHD_CONNECTION_STATE_CONNECTED;
+ state = WMESHD_CONNECTION_STATE_CONNECTED;
} else if (g_strcmp0("disconnect", var) == 0 || g_strcmp0("failure", var) == 0) {
- state = MESHD_CONNECTION_STATE_DISCONNECTED;
+ state = WMESHD_CONNECTION_STATE_DISCONNECTED;
} else {
- MESH_LOGE(" Unhandled state !");
+ WMESH_LOGE(" Unhandled state !");
g_free(network_info.mesh_id);
g_free(network_info.bssid);
return;
}
- mesh_notify_connection_state(network_info.mesh_id, network_info.bssid,
+ wmesh_notify_connection_state(network_info.mesh_id, network_info.bssid,
network_info.channel, network_info.security, state);
g_free(network_info.mesh_id);
}
}
-static void _meshd_subscribe_event(mesh_service *service)
+static void _wmeshd_subscribe_event(wmesh_service *service)
{
unsigned int id = 0;
- meshd_check_null_ret("service", service);
+ wmeshd_check_null_ret("service", service);
id = g_dbus_connection_signal_subscribe(
(GDBusConnection *)service->connection,
CONNMAN_SERVER_NAME, CONNMAN_INTERFACE_MANAGER,
"ScanDone", "/", NULL,
- G_DBUS_CALL_FLAGS_NONE, _meshd_signal_handler, service, NULL);
+ G_DBUS_CALL_FLAGS_NONE, _wmeshd_signal_handler, service, NULL);
if (0 == id) {
- MESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
+ WMESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
return;
}
service->dbus_sub_ids = g_list_append(service->dbus_sub_ids, GUINT_TO_POINTER(id));
- MESH_LOGD("[Signal subscribe] : ScanDone (%d)", id);
+ WMESH_LOGD("[Signal subscribe] : ScanDone (%d)", id);
/* To monitor mesh profiles */
id = g_dbus_connection_signal_subscribe(
"PropertyChanged",
NULL, /* Path */
NULL,
- G_DBUS_CALL_FLAGS_NONE, _meshd_signal_handler, service, NULL);
+ G_DBUS_CALL_FLAGS_NONE, _wmeshd_signal_handler, service, NULL);
if (0 == id) {
- MESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
+ WMESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
return;
}
service->dbus_sub_ids = g_list_append(service->dbus_sub_ids, GUINT_TO_POINTER(id));
- MESH_LOGD("[Signal subscribe] : PropertyChanged (%d)", id);
+ WMESH_LOGD("[Signal subscribe] : PropertyChanged (%d)", id);
/* End of subscription */
}
static void _on_unsubscribe_ids(gpointer data, gpointer user_data)
{
unsigned int id = GPOINTER_TO_UINT(data);
- mesh_service *service = (mesh_service*)user_data;
+ wmesh_service *service = (wmesh_service*)user_data;
- MESH_LOGD("[Signal unsubscribe] : %d", id);
+ WMESH_LOGD("[Signal unsubscribe] : %d", id);
g_dbus_connection_signal_unsubscribe(
(GDBusConnection *)service->connection, id);
}
-static void _meshd_unsubscribe_event(mesh_service *service)
+static void _wmeshd_unsubscribe_event(wmesh_service *service)
{
- meshd_check_null_ret("service", service);
+ wmeshd_check_null_ret("service", service);
g_list_foreach(service->dbus_sub_ids, _on_unsubscribe_ids, service);
service->dbus_sub_ids = NULL;
}
-int meshd_dbus_start(mesh_service *service)
+int wmeshd_dbus_start(wmesh_service *service)
{
int rv;
- rv = _meshd_create_gdbus_call(service);
- if (MESHD_ERROR_NONE != rv)
+ rv = _wmeshd_create_gdbus_call(service);
+ if (WMESHD_ERROR_NONE != rv)
return rv;
service->ca = g_cancellable_new();
/* Create all required proxies here */
_gproxy_connman = _proxy_get_connman(service);
- meshd_check_null_ret_error("_gproxy_connman", _gproxy_connman,
- MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("_gproxy_connman", _gproxy_connman,
+ WMESHD_ERROR_IO_ERROR);
g_dbus_proxy_set_default_timeout(
- G_DBUS_PROXY(_gproxy_connman), MESH_DBUS_PROXY_TIMEOUT);
+ G_DBUS_PROXY(_gproxy_connman), WMESH_DBUS_PROXY_TIMEOUT);
_gproxy_connman_mesh = _proxy_get_connman_mesh(service);
- meshd_check_null_ret_error("_gproxy_connman_mesh", _gproxy_connman_mesh,
- MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("_gproxy_connman_mesh", _gproxy_connman_mesh,
+ WMESHD_ERROR_IO_ERROR);
g_dbus_proxy_set_default_timeout(
- G_DBUS_PROXY(_gproxy_connman_mesh), MESH_DBUS_PROXY_TIMEOUT);
+ G_DBUS_PROXY(_gproxy_connman_mesh), WMESH_DBUS_PROXY_TIMEOUT);
_gproxy_connman_technology = _proxy_get_connman_technology(service);
- meshd_check_null_ret_error("_gproxy_connman_technology", _gproxy_connman_technology,
- MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology", _gproxy_connman_technology,
+ WMESHD_ERROR_IO_ERROR);
g_dbus_proxy_set_default_timeout(
- G_DBUS_PROXY(_gproxy_connman_technology), MESH_DBUS_PROXY_TIMEOUT);
+ G_DBUS_PROXY(_gproxy_connman_technology), WMESH_DBUS_PROXY_TIMEOUT);
_gproxy_connman_ethernet = _proxy_get_connman_ethernet(service);
- meshd_check_null_ret_error("_gproxy_connman_ethernet", _gproxy_connman_ethernet,
- MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("_gproxy_connman_ethernet", _gproxy_connman_ethernet,
+ WMESHD_ERROR_IO_ERROR);
g_dbus_proxy_set_default_timeout(
- G_DBUS_PROXY(_gproxy_connman_ethernet), MESH_DBUS_PROXY_TIMEOUT);
+ G_DBUS_PROXY(_gproxy_connman_ethernet), WMESH_DBUS_PROXY_TIMEOUT);
/* Subscribe events */
- _meshd_subscribe_event(service);
+ _wmeshd_subscribe_event(service);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int meshd_dbus_stop(mesh_service *service)
+int wmeshd_dbus_stop(wmesh_service *service)
{
int rv;
if (NULL == service)
- return MESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER;
/* Unsubscribe events */
- _meshd_unsubscribe_event(service);
+ _wmeshd_unsubscribe_event(service);
/* Unref all proxies here */
if (_gproxy_connman) {
g_object_unref(service->ca);
service->ca = NULL;
- rv = _meshd_close_gdbus_call(service);
+ rv = _wmeshd_close_gdbus_call(service);
return rv;
}
-int mesh_gdbus_create_mesh_interface(mesh_service *service)
+int wmesh_gdbus_create_mesh_interface(wmesh_service *service)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
GVariant *var_dict = NULL;
GVariantDict dict;
- mesh_interface_s *info = NULL;
+ wmesh_interface_s *info = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
info = service->interface_info;
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [MeshInterfaceAdd]");
+ WMESH_LOGD("Successfully requested. [MeshInterfaceAdd]");
} else if (error) {
- ret = MESHD_ERROR_IO_ERROR;
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ ret = WMESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
/* Interface not exists */
if (g_strrstr(error->message, "No such device"))
- ret = MESHD_ERROR_INVALID_PARAMETER;
+ ret = WMESHD_ERROR_INVALID_PARAMETER;
g_error_free(error);
}
return ret;
}
-int mesh_gdbus_remove_mesh_interface(mesh_service *service)
+int wmesh_gdbus_remove_mesh_interface(wmesh_service *service)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
GVariant *var_dict = NULL;
GVariantDict dict;
- mesh_interface_s *info = NULL;
+ wmesh_interface_s *info = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
info = service->interface_info;
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [MeshInterfaceRemove]");
+ WMESH_LOGD("Successfully requested. [MeshInterfaceRemove]");
} else if (error) {
- ret = MESHD_ERROR_IO_ERROR;
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ ret = WMESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
/* Interface not exists (Not created yet) */
if (g_strrstr(error->message, "No such device"))
- ret = MESHD_ERROR_NONE;
+ ret = WMESHD_ERROR_NONE;
g_error_free(error);
}
return ret;
}
-int mesh_gdbus_mesh_scan(mesh_service *service)
+int wmesh_gdbus_mesh_scan(wmesh_service *service)
{
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
g_dbus_proxy_call(_gproxy_connman_technology, "Scan",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, NULL, NULL);
- MESH_LOGD("Successfully requested. [Scan]");
+ WMESH_LOGD("Successfully requested. [Scan]");
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_mesh_specific_scan(mesh_service *service, gchar *mesh_id, gint channel)
+int wmesh_gdbus_mesh_specific_scan(wmesh_service *service, gchar *mesh_id, gint channel)
{
GVariant *variant = NULL;
GError *error = NULL;
enum nl80211_band band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
gushort freq = __channel_to_frequency(channel, band);
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
g_variant_dict_init(&dict, NULL);
g_variant_dict_insert(&dict, "Name", "s", mesh_id);
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [MeshSpecificScan]");
+ WMESH_LOGD("Successfully requested. [MeshSpecificScan]");
} else if (error) {
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_mesh_cancel_scan(mesh_service *service)
+int wmesh_gdbus_mesh_cancel_scan(wmesh_service *service)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
GVariant *var_dict = NULL;
GVariantDict dict;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
g_variant_dict_init(&dict, NULL);
var_dict = g_variant_dict_end(&dict);
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [AbortScan]");
+ WMESH_LOGD("Successfully requested. [AbortScan]");
} else if (error) {
- ret = MESHD_ERROR_IO_ERROR;
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ ret = WMESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
/* Scan is not in progress */
if (g_strrstr(error->message, "Already exists"))
- ret = MESHD_ERROR_NONE;
+ ret = WMESHD_ERROR_NONE;
g_error_free(error);
}
static void _on_scan_result_destroy(gpointer data)
{
- mesh_scan_result_s *scan_item = (mesh_scan_result_s *)data;
+ wmesh_scan_result_s *scan_item = (wmesh_scan_result_s *)data;
if (scan_item) {
g_free(scan_item->mesh_id);
static void _on_peer_info_destroy(gpointer data)
{
- mesh_peer_info_s *peer = (mesh_peer_info_s *)data;
+ wmesh_peer_info_s *peer = (wmesh_peer_info_s *)data;
if (peer)
g_free(peer->address);
g_free(peer);
}
-static void _get_joined_network(mesh_service *service, GVariant *variant)
+static void _get_joined_network(wmesh_service *service, GVariant *variant)
{
GVariantIter *peer = NULL;
GVariantIter *property = NULL;
g_variant_get(variant, "(a(oa{sv}))", &peer);
while ((child = g_variant_iter_next_value(peer))) {
- mesh_network_info_s *joined_info = NULL;
+ wmesh_network_info_s *joined_info = NULL;
gboolean valid_state = TRUE;
g_variant_get(child, "(oa{sv})", &obj_path, &property);
- MESH_LOGD(" Object: [%s]", obj_path);
+ WMESH_LOGD(" Object: [%s]", obj_path);
if (NULL == obj_path) {
- MESH_LOGE("Null object");
+ WMESH_LOGE("Null object");
continue;
}
/* Create an information structure for joined network */
- joined_info = g_try_new0(mesh_network_info_s, 1);
+ joined_info = g_try_new0(wmesh_network_info_s, 1);
if (NULL == joined_info) {
- MESH_LOGE("Failed to allocate !");
+ WMESH_LOGE("Failed to allocate !");
return;
}
joined_info->bssid = g_strdup(buf);
} else if (strcasecmp(key, "State") == 0) {
buf = g_variant_get_string(val, &len);
- MESH_LOGD(" State : %s", buf);
+ WMESH_LOGD(" State : %s", buf);
/* Skip ignorable state */
if (g_strcmp0(buf, "idle") == 0
valid_state = FALSE;
break;
} else if (g_strcmp0(buf, "association") == 0) {
- joined_info->state = MESHD_CONNECTION_STATE_ASSOCIATION;
+ joined_info->state = WMESHD_CONNECTION_STATE_ASSOCIATION;
} else if (g_strcmp0(buf, "configuration") == 0) {
- joined_info->state = MESHD_CONNECTION_STATE_CONFIGURATION;
+ joined_info->state = WMESHD_CONNECTION_STATE_CONFIGURATION;
} else if (g_strcmp0(buf, "ready") == 0 || g_strcmp0(buf, "online") == 0) {
- joined_info->state = MESHD_CONNECTION_STATE_CONNECTED;
+ joined_info->state = WMESHD_CONNECTION_STATE_CONNECTED;
}
} else if (strcasecmp(key, "Security") == 0) {
buf = g_variant_get_string(val, &len);
if (g_strcmp0("sae", buf) == 0)
- joined_info->security = MESHD_SECURITY_SAE;
+ joined_info->security = WMESHD_SECURITY_SAE;
else
- joined_info->security = MESHD_SECURITY_NONE;
+ joined_info->security = WMESHD_SECURITY_NONE;
} else if (strcasecmp(key, "Frequency") == 0) {
joined_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
}
continue;
}
- MESH_LOGD(" Mesh ID : %s", joined_info->mesh_id);
- MESH_LOGD(" BSSID : %s", joined_info->bssid);
- MESH_LOGD(" Channel : %d", joined_info->channel);
- MESH_LOGD(" Security : %s",
- (MESHD_SECURITY_SAE == joined_info->security) ? "SAE" : "NONE");
+ WMESH_LOGD(" Mesh ID : %s", joined_info->mesh_id);
+ WMESH_LOGD(" BSSID : %s", joined_info->bssid);
+ WMESH_LOGD(" Channel : %d", joined_info->channel);
+ WMESH_LOGD(" Security : %s",
+ (WMESHD_SECURITY_SAE == joined_info->security) ? "SAE" : "NONE");
service->joined_network = joined_info;
g_variant_iter_free(property);
g_variant_iter_free(peer);
}
-static void _get_mesh_peers(mesh_service *service, GVariant *variant)
+static void _get_mesh_peers(wmesh_service *service, GVariant *variant)
{
GVariantIter *peer = NULL;
GVariantIter *property = NULL;
g_variant_get(variant, "(a(oa{sv}))", &peer);
while ((child = g_variant_iter_next_value(peer))) {
- mesh_scan_result_s *scan_info = NULL;
+ wmesh_scan_result_s *scan_info = NULL;
- scan_info = g_try_new0(mesh_scan_result_s, 1);
+ scan_info = g_try_new0(wmesh_scan_result_s, 1);
if (NULL == scan_info) {
- MESH_LOGE("Failed to allocate !");
+ WMESH_LOGE("Failed to allocate !");
return;
}
g_variant_get(child, "(oa{sv})", &obj_path, &property);
if (NULL == obj_path) {
- MESH_LOGE("Null object");
+ WMESH_LOGE("Null object");
g_free(scan_info);
continue;
}
- MESH_LOGD(" Obj path : [%s]", obj_path);
+ WMESH_LOGD(" Obj path : [%s]", obj_path);
scan_info->object_path = g_strdup(obj_path);
while (g_variant_iter_loop(property, "{sv}", &key, &val)) {
if (strcasecmp(key, "Name") == 0) {
const char *buf = g_variant_get_string(val, &len);
scan_info->mesh_id = g_strdup(buf);
- MESH_LOGD(" Mesh ID : %s", scan_info->mesh_id);
+ WMESH_LOGD(" Mesh ID : %s", scan_info->mesh_id);
} else if (strcasecmp(key, "BSSID") == 0) {
const char *buf = g_variant_get_string(val, &len);
scan_info->bssid = g_strdup(buf);
- MESH_LOGD(" BSSID : %s", scan_info->bssid);
+ WMESH_LOGD(" BSSID : %s", scan_info->bssid);
} else if (strcasecmp(key, "State") == 0) {
const char *buf = g_variant_get_string(val, &len);
- MESH_LOGD(" State : %s", buf);
+ WMESH_LOGD(" State : %s", buf);
if (g_strcmp0(buf, "idle") == 0
|| g_strcmp0(buf, "disconnect") == 0
|| g_strcmp0(buf, "failure") == 0) {
- scan_info->state = MESHD_CONNECTION_STATE_DISCONNECTED;
+ scan_info->state = WMESHD_CONNECTION_STATE_DISCONNECTED;
} else if (g_strcmp0(buf, "association") == 0) {
- scan_info->state = MESHD_CONNECTION_STATE_ASSOCIATION;
+ scan_info->state = WMESHD_CONNECTION_STATE_ASSOCIATION;
} else if (g_strcmp0(buf, "configuration") == 0) {
- scan_info->state = MESHD_CONNECTION_STATE_CONFIGURATION;
+ scan_info->state = WMESHD_CONNECTION_STATE_CONFIGURATION;
} else if (g_strcmp0(buf, "ready") == 0 || g_strcmp0(buf, "online") == 0) {
- scan_info->state = MESHD_CONNECTION_STATE_CONNECTED;
+ scan_info->state = WMESHD_CONNECTION_STATE_CONNECTED;
}
} else if (strcasecmp(key, "Security") == 0) {
const char *buf = g_variant_get_string(val, &len);
- MESH_LOGD(" Security : %s", buf);
+ WMESH_LOGD(" Security : %s", buf);
if (g_strcmp0("sae", buf) == 0)
- scan_info->security = MESHD_SECURITY_SAE;
+ scan_info->security = WMESHD_SECURITY_SAE;
else
- scan_info->security = MESHD_SECURITY_NONE;
+ scan_info->security = WMESHD_SECURITY_NONE;
} else if (strcasecmp(key, "Frequency") == 0) {
scan_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
- MESH_LOGD(" Channel : %d", scan_info->channel);
+ WMESH_LOGD(" Channel : %d", scan_info->channel);
} else if (strcasecmp(key, "Favorite") == 0) {
const char *buf = g_variant_get_string(val, &len);
- MESH_LOGD(" Favorite : %s", buf);
+ WMESH_LOGD(" Favorite : %s", buf);
} else if (strcasecmp(key, "Strength") == 0) {
scan_info->rssi = (gint)g_variant_get_byte(val);
- MESH_LOGD(" RSSI : %d", scan_info->rssi);
+ WMESH_LOGD(" RSSI : %d", scan_info->rssi);
}
}
/* Last element */
g_variant_iter_free(peer);
}
-static void _get_connected_mesh_peers(mesh_service *service, GVariant *variant)
+static void _get_connected_mesh_peers(wmesh_service *service, GVariant *variant)
{
GVariantIter *peer = NULL;
GVariant *val = NULL;
g_variant_get(variant, "(a(a{sv}))", &peer);
while ((child = g_variant_iter_next_value(peer))) {
- mesh_peer_info_s *peer_info = NULL;
+ wmesh_peer_info_s *peer_info = NULL;
- peer_info = g_try_new0(mesh_peer_info_s, 1);
+ peer_info = g_try_new0(wmesh_peer_info_s, 1);
if (NULL == peer_info) {
- MESH_LOGE("Failed to allocate !");
+ WMESH_LOGE("Failed to allocate !");
return;
}
if (NULL != val) {
const char *buf = g_variant_get_string(val, &len);
peer_info->address = g_strdup(buf);
- MESH_LOGD(" Address : %s", peer_info->address);
+ WMESH_LOGD(" Address : %s", peer_info->address);
g_variant_unref(val);
} else {
- MESH_LOGE("Unable to get address !");
+ WMESH_LOGE("Unable to get address !");
g_free(peer_info);
continue;
}
g_variant_iter_free(peer);
}
-int mesh_gdbus_get_mesh_networks(mesh_service *service)
+int wmesh_gdbus_get_mesh_networks(wmesh_service *service)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman",
- _gproxy_connman, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman",
+ _gproxy_connman, WMESHD_ERROR_IO_ERROR);
variant = g_dbus_proxy_call_sync(_gproxy_connman, "GetMeshPeers",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [GetMeshPeers]");
+ WMESH_LOGD("Successfully requested. [GetMeshPeers]");
if (service->scanned_mesh_network) {
g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy);
service->scanned_mesh_network =
g_list_reverse(service->scanned_mesh_network);
} else if (error) {
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_get_joined_mesh_network(mesh_service *service)
+int wmesh_gdbus_get_joined_mesh_network(wmesh_service *service)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman",
- _gproxy_connman, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman",
+ _gproxy_connman, WMESHD_ERROR_IO_ERROR);
variant = g_dbus_proxy_call_sync(_gproxy_connman, "GetMeshPeers",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [GetMeshPeers]");
+ WMESH_LOGD("Successfully requested. [GetMeshPeers]");
if (service->joined_network) {
g_free(service->joined_network->mesh_id);
_get_joined_network(service, variant);
} else if (error) {
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_get_connected_peers(mesh_service *service)
+int wmesh_gdbus_get_connected_peers(wmesh_service *service)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman",
- _gproxy_connman, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman",
+ _gproxy_connman, WMESHD_ERROR_IO_ERROR);
variant = g_dbus_proxy_call_sync(_gproxy_connman, "GetConnectedMeshPeers",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [GetConnectedMeshPeers]");
+ WMESH_LOGD("Successfully requested. [GetConnectedMeshPeers]");
if (service->connected_mesh_peers) {
g_list_free_full(service->connected_mesh_peers, _on_peer_info_destroy);
service->connected_mesh_peers =
g_list_reverse(service->connected_mesh_peers);
} else if (error) {
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-static void _get_mesh_property(GVariant *variant, mesh_network_info_s *result)
+static void _get_mesh_property(GVariant *variant, wmesh_network_info_s *result)
{
GVariantIter *property = NULL;
gchar *key = NULL;
GVariant *val = NULL;
gsize len = 0;
- MESH_LOGD("Type [%s]", g_variant_get_type_string(variant));
+ WMESH_LOGD("Type [%s]", g_variant_get_type_string(variant));
g_variant_get(variant, "(a{sv})", &property);
if (strcasecmp(key, "Name") == 0) {
const char *buf = g_variant_get_string(val, &len);
result->mesh_id = g_strdup(buf);
- MESH_LOGD(" Mesh ID : %s", result->mesh_id);
+ WMESH_LOGD(" Mesh ID : %s", result->mesh_id);
} else if (strcasecmp(key, "BSSID") == 0) {
const char *buf = g_variant_get_string(val, &len);
result->bssid = g_strdup(buf);
- MESH_LOGD(" BSSID : %s", result->bssid);
+ WMESH_LOGD(" BSSID : %s", result->bssid);
} else if (strcasecmp(key, "State") == 0) {
const char *buf = g_variant_get_string(val, &len);
- MESH_LOGD(" State : %s", buf);
+ WMESH_LOGD(" State : %s", buf);
if (g_strcmp0(buf, "idle") == 0
|| g_strcmp0(buf, "disconnect") == 0
|| g_strcmp0(buf, "failure") == 0) {
- result->state = MESHD_CONNECTION_STATE_DISCONNECTED;
+ result->state = WMESHD_CONNECTION_STATE_DISCONNECTED;
} else if (g_strcmp0(buf, "association") == 0) {
- result->state = MESHD_CONNECTION_STATE_ASSOCIATION;
+ result->state = WMESHD_CONNECTION_STATE_ASSOCIATION;
} else if (g_strcmp0(buf, "configuration") == 0) {
- result->state = MESHD_CONNECTION_STATE_CONFIGURATION;
+ result->state = WMESHD_CONNECTION_STATE_CONFIGURATION;
} else if (g_strcmp0(buf, "ready") == 0 || g_strcmp0(buf, "online") == 0) {
- result->state = MESHD_CONNECTION_STATE_CONNECTED;
+ result->state = WMESHD_CONNECTION_STATE_CONNECTED;
}
} else if (strcasecmp(key, "Security") == 0) {
const char *buf = g_variant_get_string(val, &len);
- MESH_LOGD(" Security : %s", buf);
+ WMESH_LOGD(" Security : %s", buf);
if (g_strcmp0("sae", buf) == 0)
- result->security = MESHD_SECURITY_SAE;
+ result->security = WMESHD_SECURITY_SAE;
else
- result->security = MESHD_SECURITY_NONE;
+ result->security = WMESHD_SECURITY_NONE;
} else if (strcasecmp(key, "Frequency") == 0) {
result->channel = __frequency_to_channel(g_variant_get_uint16(val));
- MESH_LOGD(" Channel : %d", result->channel);
+ WMESH_LOGD(" Channel : %d", result->channel);
} else if (strcasecmp(key, "Favorite") == 0) {
const char *buf = g_variant_get_string(val, &len);
- MESH_LOGD(" Favorite : %s", buf);
+ WMESH_LOGD(" Favorite : %s", buf);
} else if (strcasecmp(key, "Strength") == 0) {
gint rssi = (gint)g_variant_get_byte(val);
- MESH_LOGD(" RSSI : %d", rssi);
+ WMESH_LOGD(" RSSI : %d", rssi);
}
}
g_variant_iter_free(property);
}
-static int _mesh_gdbus_get_mesh_network_property(mesh_service *service,
- const gchar* object_path, mesh_network_info_s *result)
+static int _wmesh_gdbus_get_mesh_network_property(wmesh_service *service,
+ const gchar* object_path, wmesh_network_info_s *result)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("result", result, MESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("result", result, WMESHD_ERROR_INVALID_PARAMETER);
variant = g_dbus_connection_call_sync(service->connection,
CONNMAN_SERVER_NAME,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [GetProperties]");
+ WMESH_LOGD("Successfully requested. [GetProperties]");
/* Get properties */
_get_mesh_property(variant, result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_create_network(mesh_service *service, gchar *mesh_id,
- gint channel, meshd_security_type_e sec)
+int wmesh_gdbus_create_network(wmesh_service *service, gchar *mesh_id,
+ gint channel, wmeshd_security_type_e sec)
{
GVariant *variant = NULL;
GError *error = NULL;
GVariant *var_dict = NULL;
GVariantBuilder builder;
- const gchar* security = (MESHD_SECURITY_SAE == sec) ? "sae" : "none";
+ const gchar* security = (WMESHD_SECURITY_SAE == sec) ? "sae" : "none";
enum nl80211_band band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
gushort freq = __channel_to_frequency(channel, band);
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}"));
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [MeshCreateNetwork]");
+ WMESH_LOGD("Successfully requested. [MeshCreateNetwork]");
} else if (error) {
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_set_passphrase(mesh_service *service, mesh_scan_result_s *info, gchar *passphrase)
+int wmesh_gdbus_set_passphrase(wmesh_service *service, wmesh_scan_result_s *info, gchar *passphrase)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("passphrase", passphrase, MESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("passphrase", passphrase, WMESHD_ERROR_INVALID_PARAMETER);
variant = g_dbus_connection_call_sync(service->connection,
CONNMAN_SERVER_NAME,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [SetProperty]");
+ WMESH_LOGD("Successfully requested. [SetProperty]");
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
#if 0
static void on_response_connect_network(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GError *error = NULL;
GVariant *variant = NULL;
variant = g_dbus_connection_call_finish(
G_DBUS_CONNECTION(source_object), res, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [Connect]");
+ WMESH_LOGD("Successfully requested. [Connect]");
/* TODO: Unregister property change event */
} else if (error) {
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
LOGE("Failed DBus call [%s]", error->message);
if (g_strrstr(error->message, "Already exists"))
- ret = MESHD_ERROR_ALREADY_REGISTERED;
+ ret = WMESHD_ERROR_ALREADY_REGISTERED;
else if (g_strrstr(error->message, "In progress"))
- ret = MESHD_ERROR_IN_PROGRESS;
+ ret = WMESHD_ERROR_IN_PROGRESS;
else
- ret = MESHD_ERROR_IO_ERROR;
+ ret = WMESHD_ERROR_IO_ERROR;
g_error_free(error);
}
}
#endif
-int mesh_gdbus_connect_network(mesh_service *service, mesh_scan_result_s *info)
+int wmesh_gdbus_connect_network(wmesh_service *service, wmesh_scan_result_s *info)
{
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("info", info, WMESHD_ERROR_INVALID_PARAMETER);
g_dbus_connection_call(service->connection,
CONNMAN_SERVER_NAME,
-1,
NULL, /* G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED */
NULL, NULL);
- MESH_LOGD("Successfully requested. [Connect]");
+ WMESH_LOGD("Successfully requested. [Connect]");
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_disconnect_network(mesh_service *service, mesh_scan_result_s *info)
+int wmesh_gdbus_disconnect_network(wmesh_service *service, wmesh_scan_result_s *info)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("info", info, WMESHD_ERROR_INVALID_PARAMETER);
variant = g_dbus_connection_call_sync(service->connection,
CONNMAN_SERVER_NAME,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [Disconnect]");
+ WMESH_LOGD("Successfully requested. [Disconnect]");
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_remove_network(mesh_service *service, mesh_scan_result_s *info)
+int wmesh_gdbus_remove_network(wmesh_service *service, wmesh_scan_result_s *info)
{
GVariant *variant = NULL;
GError *error = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("info", info, WMESHD_ERROR_INVALID_PARAMETER);
variant = g_dbus_connection_call_sync(service->connection,
CONNMAN_SERVER_NAME,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [Remove]");
+ WMESH_LOGD("Successfully requested. [Remove]");
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_gdbus_enable_ethernet_interface(mesh_service *service, bool state)
+int wmesh_gdbus_enable_ethernet_interface(wmesh_service *service, bool state)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
- mesh_interface_s *info = NULL;
+ wmesh_interface_s *info = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
info = service->interface_info;
- meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("info", info, WMESHD_ERROR_INVALID_PARAMETER);
variant = g_dbus_proxy_call_sync(_gproxy_connman_ethernet, "SetProperty",
g_variant_new("(sv)", "Powered", g_variant_new_boolean(state)),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [Powered]");
+ WMESH_LOGD("Successfully requested. [Powered]");
} else if (error) {
- ret = MESHD_ERROR_IO_ERROR;
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ ret = WMESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
/* Interface not exists (Not created yet) */
if (g_strrstr(error->message, "No such device"))
- ret = MESHD_ERROR_NONE;
+ ret = WMESHD_ERROR_NONE;
g_error_free(error);
}
return ret;
}
-int mesh_gdbus_set_mesh_gate(mesh_service *service)
+int wmesh_gdbus_set_mesh_gate(wmesh_service *service)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
GVariant *var_dict = NULL;
GVariantDict dict;
- mesh_interface_s *info = NULL;
+ wmesh_interface_s *info = NULL;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("connection", service->connection,
- MESHD_ERROR_INVALID_PARAMETER);
- meshd_check_null_ret_error("_gproxy_connman_technology",
- _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("connection", service->connection,
+ WMESHD_ERROR_INVALID_PARAMETER);
+ wmeshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, WMESHD_ERROR_IO_ERROR);
info = service->interface_info;
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- MESH_LOGD("Successfully requested. [SetMeshGate]");
+ WMESH_LOGD("Successfully requested. [SetMeshGate]");
} else if (error) {
- ret = MESHD_ERROR_IO_ERROR;
- MESH_LOGE("Failed DBus call [%s]", error->message);
+ ret = WMESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Failed DBus call [%s]", error->message);
/* Interface not exists */
if (g_strrstr(error->message, "No such device"))
- ret = MESHD_ERROR_INVALID_PARAMETER;
+ ret = WMESHD_ERROR_INVALID_PARAMETER;
g_error_free(error);
}
#include <errno.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
-#include "mesh-interface.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-service.h"
+#include "wmesh-interface.h"
#define IPV4_MAX_LENGTH 16
#define BUF_LENGTH 256
ETHERNET_CABLE_ATTACHED
} cable_state_e;
-int mesh_interface_set(const char *interface, const char* ip_addr,
- mesh_set_interface_type_e type)
+int wmesh_interface_set(const char *interface, const char* ip_addr,
+ wmesh_set_interface_type_e type)
{
int sock = 0;
struct ifreq ifr;
char buf[BUF_LENGTH] = {0,};
if (interface == NULL) {
- MESH_LOGE("Invalid interface name !");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid interface name !");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
- MESH_LOGE("Cannot open network interface socket");
- return MESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Cannot open network interface socket");
+ return WMESHD_ERROR_IO_ERROR;
}
- MESH_LOGD("Initialize interface [%s]...", interface);
+ WMESH_LOGD("Initialize interface [%s]...", interface);
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", interface);
/* Set IP Address */
sai.sin_port = 0;
snprintf(ip, IPV4_MAX_LENGTH, "%s", ip_addr);
- MESH_LOGD("Setting IP address: [%s]\n", ip);
+ WMESH_LOGD("Setting IP address: [%s]\n", ip);
if (!inet_aton(ip, &sai.sin_addr)) {
- MESH_LOGE("Failed to convert ip address");
+ WMESH_LOGE("Failed to convert ip address");
close(sock);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
memcpy(&ifr.ifr_addr, &sai, sizeof(sai));
ret = ioctl(sock, SIOCSIFADDR, &ifr);
if (ret < 0) {
(void) strerror_r(errno, buf, BUF_LENGTH);
- MESH_LOGE("Failed to set IP[%s] for interface[%s] : %s",
+ WMESH_LOGE("Failed to set IP[%s] for interface[%s] : %s",
ip, ifr.ifr_name, buf);
}
}
/* Get status flag */
if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) {
(void) strerror_r(errno, buf, BUF_LENGTH);
- MESH_LOGE("Failed to get interface[%s] status : %s",
+ WMESH_LOGE("Failed to get interface[%s] status : %s",
ifr.ifr_name, buf);
}
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", interface);
/* Set status flag */
- if (MESH_INTERFACE_UP == type) {
+ if (WMESH_INTERFACE_UP == type) {
ifr.ifr_flags |= (IFF_UP);
if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) {
(void) strerror_r(errno, buf, BUF_LENGTH);
- MESH_LOGE("Failed to change interface[%s] status UP : %s",
+ WMESH_LOGE("Failed to change interface[%s] status UP : %s",
ifr.ifr_name, buf);
}
- } else if (MESH_INTERFACE_DOWN == type) {
+ } else if (WMESH_INTERFACE_DOWN == type) {
ifr.ifr_flags &= (~IFF_UP);
if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) {
(void) strerror_r(errno, buf, BUF_LENGTH);
- MESH_LOGE("Failed to change interface[%s] status DOWN : %s",
+ WMESH_LOGE("Failed to change interface[%s] status DOWN : %s",
ifr.ifr_name, buf);
}
} else {
- MESH_LOGD("Do not change up/down status");
+ WMESH_LOGD("Do not change up/down status");
}
close(sock);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
#if 0
/* This name is exists. use it */
snprintf(buf, sizeof(buf), "%s%d", prefix, i);
res = g_strdup(buf);
- MESH_LOGD(" use [%s]", res);
+ WMESH_LOGD(" use [%s]", res);
break;
}
}
/* This name is not exists. use it */
snprintf(buf, sizeof(buf), "%s%d", prefix, i);
res = g_strdup(buf);
- MESH_LOGD(" use [%s]", res);
+ WMESH_LOGD(" use [%s]", res);
break;
}
}
return false;
}
-char* mesh_interface_get_address(const char* if_name)
+char* wmesh_interface_get_address(const char* if_name)
{
FILE *pf;
char buf[32] = { 0, };
pf = fopen(buf, "r");
if (NULL != pf) {
fgets(buf, 31, pf);
- MESH_LOGD("Interface[%s] address[%s]", if_name, buf);
+ WMESH_LOGD("Interface[%s] address[%s]", if_name, buf);
if (strlen(buf) > 0)
result = g_strdup(buf);
return result;
}
-int mesh_interface_initialize(mesh_interface_s *info)
+int wmesh_interface_initialize(wmesh_interface_s *info)
{
if (NULL == info) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
info->bridge_interface = g_strdup(MESH_DEFAULT_BRIDGE_INTERFACE);
if (NULL == info->bridge_interface) {
- MESH_LOGE("Failed to get bridge interface !");
- return MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("Failed to get bridge interface !");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
info->base_interface = g_strdup(MESH_DEFAULT_BASE_INTERFACE);
if (NULL == info->bridge_interface) {
- MESH_LOGE("Failed to get base interface !");
- return MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("Failed to get base interface !");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
info->mesh_interface = g_strdup(MESH_DEFAULT_MESH_INTERFACE);
if (NULL == info->bridge_interface) {
- MESH_LOGE("Failed to get mesh interface !");
- return MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("Failed to get mesh interface !");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
info->softap_interface = g_strdup(MESH_DEFAULT_SOFTAP_INTERFACE);
info->external_interface = g_strdup(MESH_DEFAULT_EXTERNAL_INTERFACE);
- MESH_LOGD("Interface configuration for mesh network :");
- MESH_LOGD(" Base : [%s]", info->base_interface);
- MESH_LOGD(" Mesh : [%s]", info->mesh_interface);
- MESH_LOGD(" Bridge : [%s]", info->bridge_interface);
- MESH_LOGD(" SoftAP : [%s]", info->softap_interface);
- MESH_LOGD(" External: [%s]", info->external_interface);
+ WMESH_LOGD("Interface configuration for mesh network :");
+ WMESH_LOGD(" Base : [%s]", info->base_interface);
+ WMESH_LOGD(" Mesh : [%s]", info->mesh_interface);
+ WMESH_LOGD(" Bridge : [%s]", info->bridge_interface);
+ WMESH_LOGD(" SoftAP : [%s]", info->softap_interface);
+ WMESH_LOGD(" External: [%s]", info->external_interface);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int _check_ethernet_cable_plugin_status(const char* interface,
if (0 == access(file_path, F_OK)) {
fd = fopen(file_path, "r");
if (fd == NULL) {
- MESH_LOGE("Error! Could not open /sys/class/net/%s/carrier file",
+ WMESH_LOGE("Error! Could not open /sys/class/net/%s/carrier file",
interface);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
} else {
- MESH_LOGE("Error! Could not access /sys/class/net/%s/carrier file",
+ WMESH_LOGE("Error! Could not access /sys/class/net/%s/carrier file",
interface);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
errno = 0;
rv = fscanf(fd, "%d", &ret);
if (rv < 0) {
strerror_r(errno, error_buf, 256);
- MESH_LOGE("Error! Failed to read from file, rv:[%d], error:[%s]",
+ WMESH_LOGE("Error! Failed to read from file, rv:[%d], error:[%s]",
rv, error_buf);
fclose(fd);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
if (ret == 1) {
- MESH_LOGD("/sys/class/net/%s/carrier : [%d]", interface, ret);
+ WMESH_LOGD("/sys/class/net/%s/carrier : [%d]", interface, ret);
*status = ETHERNET_CABLE_ATTACHED;
} else if (ret == 0) {
- MESH_LOGD("/sys/class/net/%s/carrier : [%d]", interface, ret);
+ WMESH_LOGD("/sys/class/net/%s/carrier : [%d]", interface, ret);
*status = ETHERNET_CABLE_DETACHED;
}
fclose(fd);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_interface_check_external_exists(const char* external_interface, bool *state)
+int wmesh_interface_check_external_exists(const char* external_interface, bool *state)
{
/* TODO: Current logic checks only ethernet interface.
This logic should consider wireless interface if can */
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
cable_state_e cable_state = ETHERNET_CABLE_DETACHED;
if (NULL == external_interface || NULL == state)
- return MESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER;
bool ex = _check_interface_exists(external_interface);
if (FALSE == ex) {
- MESH_LOGE("External interface[%s] was not found.", external_interface);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("External interface[%s] was not found.", external_interface);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
/* 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 (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get Ethernet cable state");
- return MESHD_ERROR_OPERATION_FAILED;
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get Ethernet cable state");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
}
if (ETHERNET_CABLE_ATTACHED == cable_state)
*state = TRUE;
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_interface_check(const char* interface)
+int wmesh_interface_check(const char* interface)
{
bool ex = FALSE;
if (NULL == interface || strlen(interface) == 0)
- return MESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER;
ex = _check_interface_exists(interface);
if (FALSE == ex) {
- MESH_LOGE("Interface[%s] was not found.", interface);
- return MESHD_ERROR_NO_DATA;
+ WMESH_LOGE("Interface[%s] was not found.", interface);
+ return WMESHD_ERROR_NO_DATA;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_interface_check_bridge_interface_exists(const char* bridge, const char* interface)
+int wmesh_interface_check_bridge_interface_exists(const char* bridge, const char* interface)
{
bool ex = FALSE;
if (NULL == bridge || NULL == interface ||
strlen(bridge) == 0 || strlen(interface) == 0)
- return MESHD_ERROR_INVALID_PARAMETER;
+ return WMESHD_ERROR_INVALID_PARAMETER;
ex = _check_bridge_interface_exists(bridge, interface);
if (FALSE == ex) {
- MESH_LOGE("Interface[%s] was not found.", interface);
- return MESHD_ERROR_NO_DATA;
+ WMESH_LOGE("Interface[%s] was not found.", interface);
+ return WMESHD_ERROR_NO_DATA;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
#include <netlink/attr.h>
#include <netlink/netlink.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-netlink.h"
-#include "mesh-request.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-netlink.h"
+#include "wmesh-request.h"
#include <linux/nl80211.h>
//#include "nl80211.h"
static int __initialize_nl80211(mesh_nl_state *state)
{
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
state->nl_socket = nl_socket_alloc();
if (!state->nl_socket) {
- MESH_LOGE("Failed to allocate netlink socket.");
- return MESHD_ERROR_OUT_OF_MEMORY;
+ WMESH_LOGE("Failed to allocate netlink socket.");
+ return WMESHD_ERROR_OUT_OF_MEMORY;
}
if (genl_connect(state->nl_socket)) {
- MESH_LOGE("Failed to connect to generic netlink.");
- err = MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("Failed to connect to generic netlink.");
+ err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
}
state->nl80211_id = genl_ctrl_resolve(state->nl_socket, "nl80211");
if (state->nl80211_id < 0) {
- MESH_LOGE("nl80211 not found.");
- err = MESHD_ERROR_NO_DATA;
+ WMESH_LOGE("nl80211 not found.");
+ err = WMESHD_ERROR_NO_DATA;
goto DESTROY;
}
int device_index = 0;
if (NULL == if_name) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
device_index = if_nametoindex(if_name);
if (device_index == 0) {
- MESH_LOGE("No interface index found [%s]", if_name);
- return MESHD_ERROR_NO_DATA;
+ WMESH_LOGE("No interface index found [%s]", if_name);
+ return WMESHD_ERROR_NO_DATA;
}
*index = device_index;
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
state->error_occured = TRUE;
strerror_r(err->error, buf, 255);
- MESH_LOGD("error_handler");
- MESH_LOGE(" %s (%d)", buf, err->error);
+ WMESH_LOGD("error_handler");
+ WMESH_LOGE(" %s (%d)", buf, err->error);
return NL_STOP;
}
state->callback_state = MESH_NL_CALLBACK_FINISHED;
- MESH_LOGD("finish_handler");
+ WMESH_LOGD("finish_handler");
NOTUSED(msg);
return NL_SKIP;
state->callback_state = MESH_NL_CALLBACK_FINISHED;
- MESH_LOGD("ack_handler");
+ WMESH_LOGD("ack_handler");
NOTUSED(msg);
return NL_STOP;
(void) msg;
*ret = 0;
- MESH_LOGD("ack_simple_handler");
+ WMESH_LOGD("ack_simple_handler");
return NL_STOP;
}
struct nlattr *mcast_group;
int rem_mcast_group;
- MESH_LOGD("family_handler");
+ WMESH_LOGD("family_handler");
nla_parse(tb, CTRL_ATTR_MAX,
genlmsg_attrdata(gnlh, 0),
continue;
group->id = nla_get_u32(tb_mcast_group[CTRL_ATTR_MCAST_GRP_ID]);
- MESH_LOGD("mcast group id [%d]", group->id);
+ WMESH_LOGD("mcast group id [%d]", group->id);
break;
}
ret = nl_send_auto(sock, msg);
if (ret < 0) {
- MESH_LOGE("Failed to nl_send_auto");
+ WMESH_LOGE("Failed to nl_send_auto");
goto out;
}
if (ret == 0)
ret = group_args.id;
- MESH_LOGD("mcid : [%d]", ret);
+ WMESH_LOGD("mcid : [%d]", ret);
nla_put_failure:
out:
/* Configuration multicast group */
mcid = __nl_get_multicast_id(state->nl_socket, "nl80211", "config");
if (mcid < 0) {
- MESH_LOGE("Failed to get nl80211 config");
+ WMESH_LOGE("Failed to get nl80211 config");
return mcid;
}
- MESH_LOGD("Mesh multicast id (config): [%d]", mcid);
+ WMESH_LOGD("Mesh multicast id (config): [%d]", mcid);
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
- MESH_LOGE("Failed to nl_socket_add_membership");
+ WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
}
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
- MESH_LOGE("Failed to nl_socket_add_membership");
+ WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
}
}
- MESH_LOGD("Mesh multicast id (scan): [%d]", mcid);
+ WMESH_LOGD("Mesh multicast id (scan): [%d]", mcid);
/* Regulatory multicast group */
mcid = __nl_get_multicast_id(state->nl_socket, "nl80211", "regulatory");
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
- MESH_LOGE("Failed to nl_socket_add_membership");
+ WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
}
}
- MESH_LOGD("Mesh multicast id (regulatory): [%d]", mcid);
+ WMESH_LOGD("Mesh multicast id (regulatory): [%d]", mcid);
/* MLME multicast group */
mcid = __nl_get_multicast_id(state->nl_socket, "nl80211", "mlme");
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
- MESH_LOGE("Failed to nl_socket_add_membership");
+ WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
}
}
- MESH_LOGD("Mesh multicast id (mlme): [%d]", mcid);
+ WMESH_LOGD("Mesh multicast id (mlme): [%d]", mcid);
mcid = __nl_get_multicast_id(state->nl_socket, "nl80211", "vendor");
if (mcid >= 0) {
ret = nl_socket_add_membership(state->nl_socket, mcid);
if (ret) {
- MESH_LOGE("Failed to nl_socket_add_membership");
+ WMESH_LOGE("Failed to nl_socket_add_membership");
return ret;
}
}
- MESH_LOGD("Mesh multicast id (vendor): [%d]", mcid);
+ WMESH_LOGD("Mesh multicast id (vendor): [%d]", mcid);
return 0;
}
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
mesh_nl_state *state = (mesh_nl_state *)arg;
- MESH_LOGD("valid_handler");
+ WMESH_LOGD("valid_handler");
if (gnlh->cmd == NL80211_CMD_SCAN_ABORTED) {
- MESH_LOGD(" Got NL80211_CMD_SCAN_ABORTED.");
+ WMESH_LOGD(" Got NL80211_CMD_SCAN_ABORTED.");
state->callback_state = MESH_NL_CALLBACK_FINISHED;
/* Notify scan done status */
- mesh_notify_scan_done();
+ wmesh_notify_scan_done();
} else if (gnlh->cmd == NL80211_CMD_NEW_SCAN_RESULTS) {
- MESH_LOGD(" Got NL80211_CMD_NEW_SCAN_RESULTS.");
+ WMESH_LOGD(" Got NL80211_CMD_NEW_SCAN_RESULTS.");
state->callback_state = MESH_NL_CALLBACK_FINISHED;
/* Notify scan done status */
- mesh_notify_scan_done();
+ wmesh_notify_scan_done();
} else {
- MESH_LOGD(" Got [%d]", gnlh->cmd);
+ WMESH_LOGD(" Got [%d]", gnlh->cmd);
}
return NL_SKIP;
state->s_cb = NULL;
state->msg = NULL;
- MESH_LOGD("message and callback cleaned");
+ WMESH_LOGD("message and callback cleaned");
}
static int __initialize_netlink_message(mesh_nl_state *state)
{
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
if (NULL == state) {
- MESH_LOGE("Invalid parameter !");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter !");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
/* Create netlink message */
state->msg = nlmsg_alloc();
if (NULL == state->msg) {
- MESH_LOGE("Failed to allocate netlink message");
- return MESHD_ERROR_OUT_OF_MEMORY;
+ WMESH_LOGE("Failed to allocate netlink message");
+ return WMESHD_ERROR_OUT_OF_MEMORY;
}
/* NL_CB_DEFAULT */
state->cb = nl_cb_alloc(NL_CB_DEFAULT);
state->s_cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!state->cb) {
- MESH_LOGE("Failed to allocate netlink callback");
- err = MESHD_ERROR_OUT_OF_MEMORY;
+ WMESH_LOGE("Failed to allocate netlink callback");
+ err = WMESHD_ERROR_OUT_OF_MEMORY;
goto DESTROY;
}
nl_cb_set(state->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, state);
nl_cb_set(state->cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, state);
- MESH_LOGD("netlink socket initialized");
+ WMESH_LOGD("netlink socket initialized");
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
DESTROY:
__clean_netlink_message(state);
NOTUSED(source);
NOTUSED(condition);
- MESH_LOGD("[Event] I/O received");
+ WMESH_LOGD("[Event] I/O received");
while (nl_recvmsgs_report(state->nl_socket, state->cb) > 0)
- MESH_LOGD(" count [%02d]", ++test);
+ WMESH_LOGD(" count [%02d]", ++test);
/* Do not remove I/O source */
return TRUE;
return rate;
}
-static void parse_bss_param(struct nlattr *bss_param_attr, mesh_station_info_s *station_info)
+static void parse_bss_param(struct nlattr *bss_param_attr, wmesh_station_info_s *station_info)
{
struct nlattr *bss_param_info[NL80211_STA_BSS_PARAM_MAX + 1], *info;
static struct nla_policy bss_poilcy[NL80211_STA_BSS_PARAM_MAX + 1] = {
};
if (nla_parse_nested(bss_param_info, NL80211_STA_BSS_PARAM_MAX, bss_param_attr, bss_poilcy))
- MESH_LOGE("failed to parse nested bss param attributes!");
+ WMESH_LOGE("failed to parse nested bss param attributes!");
info = bss_param_info[NL80211_STA_BSS_PARAM_DTIM_PERIOD];
if (info) {
station_info->dtim_period = nla_get_u8(info);
- MESH_LOGD(" DTIM period:\t%u", station_info->dtim_period);
+ WMESH_LOGD(" DTIM period:\t%u", station_info->dtim_period);
}
info = bss_param_info[NL80211_STA_BSS_PARAM_BEACON_INTERVAL];
if (info) {
station_info->beacon_interval = nla_get_u16(info);
- MESH_LOGD(" beacon interval:%u", station_info->beacon_interval);
+ WMESH_LOGD(" beacon interval:%u", station_info->beacon_interval);
}
info = bss_param_info[NL80211_STA_BSS_PARAM_CTS_PROT];
if (info) {
- MESH_LOGD(" CTS protection:");
+ WMESH_LOGD(" CTS protection:");
if (nla_get_u16(info)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->cts_protection = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->cts_protection = FALSE;
}
}
info = bss_param_info[NL80211_STA_BSS_PARAM_SHORT_PREAMBLE];
if (info) {
- MESH_LOGD(" short preamble:");
+ WMESH_LOGD(" short preamble:");
if (nla_get_u16(info)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->short_preamble = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->short_preamble = FALSE;
}
}
info = bss_param_info[NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME];
if (info) {
- MESH_LOGD(" short slot time:");
+ WMESH_LOGD(" short slot time:");
if (nla_get_u16(info)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->short_slot_time = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->short_slot_time = FALSE;
}
}
switch (pm) {
case NL80211_MESH_POWER_ACTIVE:
- MESH_LOGD("ACTIVE");
+ WMESH_LOGD("ACTIVE");
break;
case NL80211_MESH_POWER_LIGHT_SLEEP:
- MESH_LOGD("LIGHT SLEEP");
+ WMESH_LOGD("LIGHT SLEEP");
break;
case NL80211_MESH_POWER_DEEP_SLEEP:
- MESH_LOGD("DEEP SLEEP");
+ WMESH_LOGD("DEEP SLEEP");
break;
default:
- MESH_LOGD("UNKNOWN");
+ WMESH_LOGD("UNKNOWN");
break;
}
}
#endif /* NL80211_STA_INFO_CHAIN_SIGNAL */
char *attr_mac = NULL;
mesh_nl_state *state = (mesh_nl_state *)arg;
- mesh_station_info_s *station_info = NULL;
+ wmesh_station_info_s *station_info = NULL;
nla_parse(attr_info, NL80211_ATTR_MAX,
genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL);
if (!attr_info[NL80211_ATTR_STA_INFO]) {
- MESH_LOGE("[Station] missing station stats !");
+ WMESH_LOGE("[Station] missing station stats !");
return NL_SKIP;
}
if (nla_parse_nested(sta_info, NL80211_STA_INFO_MAX,
attr_info[NL80211_ATTR_STA_INFO], stats_policy)) {
- MESH_LOGE("[Station] Failed to parse nested attributes!");
+ WMESH_LOGE("[Station] Failed to parse nested attributes!");
return NL_SKIP;
}
/* Allocation */
- station_info = g_try_new0(mesh_station_info_s, 1);
+ station_info = g_try_new0(wmesh_station_info_s, 1);
if (NULL == station_info) {
- MESH_LOGE("Failed to allocate station info !");
+ WMESH_LOGE("Failed to allocate station info !");
return NL_SKIP;
}
attr_mac[3], attr_mac[4], attr_mac[5]);
if_indextoname(nla_get_u32(attr_info[NL80211_ATTR_IFINDEX]), dev);
station_info->bssid = g_strdup(mac_addr);
- MESH_LOGD("Station %s [dev %s]", station_info->bssid, dev);
+ WMESH_LOGD("Station %s [dev %s]", station_info->bssid, dev);
/* Inactive time */
if (0 != sta_info[NL80211_STA_INFO_INACTIVE_TIME]) {
station_info->inactive_time =
nla_get_u32(sta_info[NL80211_STA_INFO_INACTIVE_TIME]);
- MESH_LOGE(" inactive time:\t%u ms", station_info->inactive_time);
+ WMESH_LOGE(" inactive time:\t%u ms", station_info->inactive_time);
}
/* RX Bytes */
if (0 != sta_info[NL80211_STA_INFO_RX_BYTES]) {
station_info->rx_bytes =
nla_get_u32(sta_info[NL80211_STA_INFO_RX_BYTES]);
- MESH_LOGD(" rx bytes:\t%u", station_info->rx_bytes);
+ WMESH_LOGD(" rx bytes:\t%u", station_info->rx_bytes);
} else if (0 != sta_info[NL80211_STA_INFO_RX_BYTES64]) {
station_info->rx_bytes =
(unsigned long long)nla_get_u64(sta_info[NL80211_STA_INFO_RX_BYTES64]);
- MESH_LOGE(" rx bytes:\t%llu", station_info->rx_bytes);
+ WMESH_LOGE(" rx bytes:\t%llu", station_info->rx_bytes);
}
/* RX Packets */
if (0 != sta_info[NL80211_STA_INFO_RX_PACKETS]) {
station_info->rx_packets =
nla_get_u32(sta_info[NL80211_STA_INFO_RX_PACKETS]);
- MESH_LOGD(" rx packets:\t%u", station_info->rx_packets);
+ WMESH_LOGD(" rx packets:\t%u", station_info->rx_packets);
}
/* TX Bytes */
if (0 != sta_info[NL80211_STA_INFO_TX_BYTES]) {
station_info->tx_bytes =
nla_get_u32(sta_info[NL80211_STA_INFO_TX_BYTES]);
- MESH_LOGD(" tx bytes:\t%u", station_info->tx_bytes);
+ WMESH_LOGD(" tx bytes:\t%u", station_info->tx_bytes);
} else if (0 != sta_info[NL80211_STA_INFO_TX_BYTES64]) {
station_info->tx_bytes =
(unsigned long long)nla_get_u64(sta_info[NL80211_STA_INFO_TX_BYTES64]);
- MESH_LOGD(" tx bytes:\t%llu", station_info->rx_packets);
+ WMESH_LOGD(" tx bytes:\t%llu", station_info->rx_packets);
}
/* LLID, PLID */
if (0 != sta_info[NL80211_STA_INFO_LLID]) {
station_info->llid = nla_get_u16(sta_info[NL80211_STA_INFO_LLID]);
- MESH_LOGD(" mesh llid:\t%d", station_info->llid);
+ WMESH_LOGD(" mesh llid:\t%d", station_info->llid);
}
if (0 != sta_info[NL80211_STA_INFO_PLID]) {
station_info->llid = nla_get_u16(sta_info[NL80211_STA_INFO_PLID]);
- MESH_LOGD(" mesh plid:\t%d", station_info->plid);
+ WMESH_LOGD(" mesh plid:\t%d", station_info->plid);
}
/* Plink state */
snprintf(state_name, 10, "%s", "UNKNOWN");
break;
}
- MESH_LOGD(" mesh plink:\t%s", state_name);
+ WMESH_LOGD(" mesh plink:\t%s", state_name);
}
#ifdef NL80211_STA_INFO_CHAIN_SIGNAL
/* RSSI Signal */
if (0 != sta_info[NL80211_STA_INFO_SIGNAL]) {
station_info->rssi =
(int8_t)nla_get_u8(sta_info[NL80211_STA_INFO_SIGNAL]);
- MESH_LOGD(" signal: \t%d %sdBm", station_info->rssi, chain);
+ WMESH_LOGD(" signal: \t%d %sdBm", station_info->rssi, chain);
}
#endif /* NL80211_STA_INFO_CHAIN_SIGNAL */
/* TX Bitrate */
char buf[100];
station_info->tx_bitrate =
parse_bitrate(sta_info[NL80211_STA_INFO_TX_BITRATE], buf, sizeof(buf));
- MESH_LOGD(" tx bitrate:\t%s", buf);
+ WMESH_LOGD(" tx bitrate:\t%s", buf);
}
if (0 != sta_info[NL80211_STA_INFO_TX_PACKETS]) {
station_info->tx_packets =
nla_get_u32(sta_info[NL80211_STA_INFO_TX_PACKETS]);
- MESH_LOGD(" tx packets:\t%u", station_info->tx_packets);
+ WMESH_LOGD(" tx packets:\t%u", station_info->tx_packets);
}
if (0 != sta_info[NL80211_STA_INFO_TX_RETRIES]) {
station_info->tx_retries =
nla_get_u32(sta_info[NL80211_STA_INFO_TX_RETRIES]);
- MESH_LOGD(" tx retries:\t%u", station_info->tx_retries);
+ WMESH_LOGD(" tx retries:\t%u", station_info->tx_retries);
}
if (0 != sta_info[NL80211_STA_INFO_TX_FAILED]) {
station_info->tx_failed =
nla_get_u32(sta_info[NL80211_STA_INFO_TX_FAILED]);
- MESH_LOGD(" tx failed:\t%u", station_info->tx_failed);
+ WMESH_LOGD(" tx failed:\t%u", station_info->tx_failed);
}
#ifdef NL80211_STA_INFO_CHAIN_SIGNAL_AVG
/* Signal average */
if (0 != sta_info[NL80211_STA_INFO_SIGNAL_AVG]) {
station_info->rssi_avg =
(int8_t)nla_get_u8(sta_info[NL80211_STA_INFO_SIGNAL_AVG]);
- MESH_LOGD(" signal avg:\t%d %sdBm", station_info->rssi_avg, chain);
+ WMESH_LOGD(" signal avg:\t%d %sdBm", station_info->rssi_avg, chain);
}
#endif /* NL80211_STA_INFO_CHAIN_SIGNAL_AVG */
if (0 != sta_info[NL80211_STA_INFO_RX_BITRATE]) {
char buf[100];
station_info->rx_bitrate =
parse_bitrate(sta_info[NL80211_STA_INFO_RX_BITRATE], buf, sizeof(buf));
- MESH_LOGD(" rx bitrate:\t%s", buf);
+ WMESH_LOGD(" rx bitrate:\t%s", buf);
}
if (0 != sta_info[NL80211_STA_INFO_BSS_PARAM])
if (0 != sta_info[NL80211_STA_INFO_CONNECTED_TIME]) {
station_info->connected_time =
nla_get_u32(sta_info[NL80211_STA_INFO_CONNECTED_TIME]);
- MESH_LOGD(" connected time:\t%u seconds", station_info->connected_time);
+ WMESH_LOGD(" connected time:\t%u seconds", station_info->connected_time);
}
if (0 != sta_info[NL80211_STA_INFO_STA_FLAGS]) {
nla_data(sta_info[NL80211_STA_INFO_STA_FLAGS]);
if (sta_flags->mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
- MESH_LOGD(" authorized:");
+ WMESH_LOGD(" authorized:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->authorized = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->authorized = FALSE;
}
}
if (sta_flags->mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
- MESH_LOGD(" authenticated:");
+ WMESH_LOGD(" authenticated:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->authenticated = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->authenticated = FALSE;
}
}
if (sta_flags->mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
- MESH_LOGD(" associated:");
+ WMESH_LOGD(" associated:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->associated = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->associated = FALSE;
}
}
if (sta_flags->mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
- MESH_LOGD(" preamble:");
+ WMESH_LOGD(" preamble:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
- MESH_LOGD(" short");
+ WMESH_LOGD(" short");
station_info->preamble = TRUE;
} else {
- MESH_LOGD(" long");
+ WMESH_LOGD(" long");
station_info->preamble = FALSE;
}
}
if (sta_flags->mask & BIT(NL80211_STA_FLAG_WME)) {
- MESH_LOGD(" WMM/WME:");
+ WMESH_LOGD(" WMM/WME:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_WME)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->wme = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->wme = FALSE;
}
}
if (sta_flags->mask & BIT(NL80211_STA_FLAG_MFP)) {
- MESH_LOGD(" MFP:");
+ WMESH_LOGD(" MFP:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_MFP)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->mfp = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->mfp = FALSE;
}
}
if (sta_flags->mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
- MESH_LOGD(" TDLS peer:");
+ WMESH_LOGD(" TDLS peer:");
if (sta_flags->set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
- MESH_LOGD(" yes");
+ WMESH_LOGD(" yes");
station_info->tdls_peer = TRUE;
} else {
- MESH_LOGD(" no");
+ WMESH_LOGD(" no");
station_info->tdls_peer = FALSE;
}
}
if (0 != sta_info[NL80211_STA_INFO_BEACON_LOSS]) {
station_info->beacon_loss =
nla_get_u32(sta_info[NL80211_STA_INFO_BEACON_LOSS]);
- MESH_LOGD(" beacon loss:\t%u", station_info->beacon_loss);
+ WMESH_LOGD(" beacon loss:\t%u", station_info->beacon_loss);
}
if (0 != sta_info[NL80211_STA_INFO_T_OFFSET]) {
station_info->t_offset =
(unsigned long long)nla_get_u64(sta_info[NL80211_STA_INFO_T_OFFSET]);
- MESH_LOGD(" Toffset:\t%llu us", station_info->t_offset);
+ WMESH_LOGD(" Toffset:\t%llu us", station_info->t_offset);
}
if (0 != sta_info[NL80211_STA_INFO_LOCAL_PM]) {
station_info->local_ps_mode =
nla_get_u32(sta_info[NL80211_STA_INFO_LOCAL_PM]);
- MESH_LOGD(" mesh local PS mode:\t");
+ WMESH_LOGD(" mesh local PS mode:\t");
print_power_mode(sta_info[NL80211_STA_INFO_LOCAL_PM]);
}
if (0 != sta_info[NL80211_STA_INFO_PEER_PM]) {
station_info->peer_ps_mode =
nla_get_u32(sta_info[NL80211_STA_INFO_PEER_PM]);
- MESH_LOGD(" mesh peer PS mode:\t");
+ WMESH_LOGD(" mesh peer PS mode:\t");
print_power_mode(sta_info[NL80211_STA_INFO_PEER_PM]);
}
if (0 != sta_info[NL80211_STA_INFO_NONPEER_PM]) {
station_info->non_peer_ps_mode =
nla_get_u32(sta_info[NL80211_STA_INFO_NONPEER_PM]);
- MESH_LOGD(" mesh non-peer PS mode:\t");
+ WMESH_LOGD(" mesh non-peer PS mode:\t");
print_power_mode(sta_info[NL80211_STA_INFO_NONPEER_PM]);
}
#ifdef NL80211_STA_INFO_RX_DROP_MISC
if (0 != sta_info[NL80211_STA_INFO_RX_DROP_MISC]) {
station_info->rx_drop_misc =
(unsigned long long)nla_get_u64(sta_info[NL80211_STA_INFO_RX_DROP_MISC]);
- MESH_LOGD(" rx drop misc:\t%llu", station_info->rx_drop_misc);
+ WMESH_LOGD(" rx drop misc:\t%llu", station_info->rx_drop_misc);
}
#endif /* NL80211_STA_INFO_RX_DROP_MISC */
if (0 != sta_info[NL80211_STA_INFO_BEACON_RX]) {
station_info->beacon_rx =
(unsigned long long)nla_get_u64(sta_info[NL80211_STA_INFO_BEACON_RX]);
- MESH_LOGD(" beacon rx:\t%llu", station_info->beacon_rx);
+ WMESH_LOGD(" beacon rx:\t%llu", station_info->beacon_rx);
}
#endif /* NL80211_STA_INFO_BEACON_RX */
if (0 != sta_info[NL80211_STA_INFO_BEACON_SIGNAL_AVG]) {
station_info->beacon_signal_avg =
nla_get_u8(sta_info[NL80211_STA_INFO_BEACON_SIGNAL_AVG]);
- MESH_LOGD(" beacon signal avg:\t%d dBm", station_info->beacon_signal_avg);
+ WMESH_LOGD(" beacon signal avg:\t%d dBm", station_info->beacon_signal_avg);
}
#endif /* NL80211_STA_INFO_BEACON_SIGNAL_AVG */
if (0 != sta_info[NL80211_STA_INFO_RX_DURATION]) {
station_info->rx_duration =
(unsigned long long)nla_get_u64(sta_info[NL80211_STA_INFO_RX_DURATION]);
- MESH_LOGD(" rx duration:\t%lld us", station_info->rx_duration);
+ WMESH_LOGD(" rx duration:\t%lld us", station_info->rx_duration);
}
#endif /* NL80211_STA_INFO_RX_DURATION */
- MESH_LOGD("");
+ WMESH_LOGD("");
*(state->station_list) = g_list_prepend(*(state->station_list), station_info);
return NL_SKIP;
};
mesh_nl_state *state = (mesh_nl_state *)arg;
- mesh_mpath_info_s *mpath_info = NULL;
+ wmesh_mpath_info_s *mpath_info = NULL;
nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL);
*/
if (!tb[NL80211_ATTR_MPATH_INFO]) {
- MESH_LOGE("missing mesh path info!");
+ WMESH_LOGE("missing mesh path info!");
return NL_SKIP;
}
if (nla_parse_nested(pinfo, NL80211_MPATH_INFO_MAX,
tb[NL80211_ATTR_MPATH_INFO],
mpath_policy)) {
- MESH_LOGE("failed to parse nested attributes!");
+ WMESH_LOGE("failed to parse nested attributes!");
return NL_SKIP;
}
- mpath_info = g_try_new0(mesh_mpath_info_s, 1);
+ mpath_info = g_try_new0(wmesh_mpath_info_s, 1);
if (NULL == mpath_info) {
- MESH_LOGE("Failed to allocate mesh path info !");
+ WMESH_LOGE("Failed to allocate mesh path info !");
return NL_SKIP;
}
mac_addr_n2a(dst, nla_data(tb[NL80211_ATTR_MAC]));
mpath_info->dest_addr = g_strdup(dst);
- MESH_LOGD("Destination Address : %s", mpath_info->dest_addr);
+ WMESH_LOGD("Destination Address : %s", mpath_info->dest_addr);
mac_addr_n2a(next_hop, nla_data(tb[NL80211_ATTR_MPATH_NEXT_HOP]));
mpath_info->next_hop = g_strdup(next_hop);
- MESH_LOGD("Next hop Address : %s", mpath_info->next_hop);
+ WMESH_LOGD("Next hop Address : %s", mpath_info->next_hop);
if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), dev);
mpath_info->interface = g_strdup(dev);
- MESH_LOGD("Interface : %s", mpath_info->interface);
+ WMESH_LOGD("Interface : %s", mpath_info->interface);
if (pinfo[NL80211_MPATH_INFO_SN]) {
mpath_info->sn = nla_get_u32(pinfo[NL80211_MPATH_INFO_SN]);
- MESH_LOGD("SN : %u", mpath_info->sn);
+ WMESH_LOGD("SN : %u", mpath_info->sn);
}
if (pinfo[NL80211_MPATH_INFO_METRIC]) {
mpath_info->metric = nla_get_u32(pinfo[NL80211_MPATH_INFO_METRIC]);
- MESH_LOGD("Metric : %u", mpath_info->metric);
+ WMESH_LOGD("Metric : %u", mpath_info->metric);
}
if (pinfo[NL80211_MPATH_INFO_FRAME_QLEN]) {
mpath_info->qlen = nla_get_u32(pinfo[NL80211_MPATH_INFO_FRAME_QLEN]);
- MESH_LOGD("QLEN : %u", mpath_info->qlen);
+ WMESH_LOGD("QLEN : %u", mpath_info->qlen);
}
if (pinfo[NL80211_MPATH_INFO_EXPTIME]) {
mpath_info->exptime = nla_get_u32(pinfo[NL80211_MPATH_INFO_EXPTIME]);
- MESH_LOGD("ExpTime : %u", mpath_info->exptime);
+ WMESH_LOGD("ExpTime : %u", mpath_info->exptime);
}
if (pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]) {
mpath_info->discovery_timeout =
nla_get_u32(pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]);
- MESH_LOGD("Discovery Timeout : %u", mpath_info->discovery_timeout);
+ WMESH_LOGD("Discovery Timeout : %u", mpath_info->discovery_timeout);
}
if (pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]) {
mpath_info->discovery_retries =
nla_get_u8(pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]);
- MESH_LOGD("Discovery Retries : %u", mpath_info->discovery_retries);
+ WMESH_LOGD("Discovery Retries : %u", mpath_info->discovery_retries);
}
if (pinfo[NL80211_MPATH_INFO_FLAGS]) {
mpath_info->flags = nla_get_u8(pinfo[NL80211_MPATH_INFO_FLAGS]);
- MESH_LOGD("Flags : 0x%x", mpath_info->flags);
+ WMESH_LOGD("Flags : 0x%x", mpath_info->flags);
}
- MESH_LOGD("");
+ WMESH_LOGD("");
*(state->mpath_list) = g_list_prepend(*(state->mpath_list), mpath_info);
return NL_SKIP;
if (tb[NL80211_ATTR_IFINDEX]) {
if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
- MESH_LOGD("%s: ", ifname);
+ WMESH_LOGD("%s: ", ifname);
}
switch (gnlh->cmd) {
case NL80211_CMD_NEW_STATION:
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
- MESH_LOGD("[%s] new station [%s]", ifname, macbuf);
+ WMESH_LOGD("[%s] new station [%s]", ifname, macbuf);
break;
case NL80211_CMD_DEL_STATION:
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
- MESH_LOGD("[%s] del station [%s]", ifname, macbuf);
+ WMESH_LOGD("[%s] del station [%s]", ifname, macbuf);
break;
case NL80211_CMD_NEW_MPATH:
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
- MESH_LOGD("[%s] new mpath [%s]", ifname, macbuf);
+ WMESH_LOGD("[%s] new mpath [%s]", ifname, macbuf);
- mesh_notify_station_joined((const char*)macbuf);
+ wmesh_notify_station_joined((const char*)macbuf);
break;
case NL80211_CMD_DEL_MPATH:
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
- MESH_LOGD("[%s] del mpath [%s]", ifname, macbuf);
+ WMESH_LOGD("[%s] del mpath [%s]", ifname, macbuf);
- mesh_notify_station_left((const char*)macbuf);
+ wmesh_notify_station_left((const char*)macbuf);
break;
default:
- MESH_LOGD("event [%d] is not handled", gnlh->cmd);
+ WMESH_LOGD("event [%d] is not handled", gnlh->cmd);
break;
}
};
struct nlattr *container;
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
int device_index = 0;
int ret;
int test = 0;
ret = __initialize_nl80211(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize nl80211");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize nl80211");
return ret;
}
ret = __initialize_netlink_message(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize netlink message");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
}
/* Add attributes into message */
ret = __get_device_index_from_string(mesh_if_name, &device_index);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get mesh device index");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get mesh device index");
err = ret;
goto DESTROY;
}
container = nla_nest_start(state.msg, NL80211_ATTR_MESH_PARAMS);
if (!container) {
- MESH_LOGE("Failed to initialize netlink message");
+ WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
}
/* Logic need to be changed if additional parameter is required */
if (g_strcmp0(MESH_PARAM_HWMP_ROOTMODE, param_name) == 0) {
- MESH_LOGD(" [mesh_hwmp_rootmode] : [%d]", value);
+ WMESH_LOGD(" [mesh_hwmp_rootmode] : [%d]", value);
NLA_PUT_U8(state.msg, NL80211_MESHCONF_HWMP_ROOTMODE,
(uint8_t)value);
} else if (g_strcmp0(MESH_PARAM_GATE_ANNOUNCE, param_name) == 0) {
- MESH_LOGD(" [mesh_gate_announcements] : [%d]", value);
+ WMESH_LOGD(" [mesh_gate_announcements] : [%d]", value);
NLA_PUT_U8(state.msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
(uint8_t)value);
} else {
- MESH_LOGE("Parameter [%s] is not required !", param_name);
+ WMESH_LOGE("Parameter [%s] is not required !", param_name);
nla_nest_end(state.msg, container);
goto DESTROY;
}
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
- MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
+ WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
- err = MESHD_ERROR_OPERATION_FAILED;
+ err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
}
/* sync response */
state.callback_state = MESH_NL_CALLBACK_TRYING;
while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
- MESH_LOGD(" count [%02d]", ++test);
+ WMESH_LOGD(" count [%02d]", ++test);
nl_recvmsgs(state.nl_socket, state.cb);
}
return err;
nla_put_failure:
- MESH_LOGE("Failed to message build");
+ WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
static int _send_nl_get_station_info(const char* if_name, GList **station_list)
.s_cb = NULL,
.station_list = station_list
};
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
int device_index = 0;
int ret;
int test = 0;
ret = __initialize_nl80211(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize nl80211");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize nl80211");
return ret;
}
ret = __initialize_netlink_message(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize netlink message");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
}
NLM_F_DUMP, NL80211_CMD_GET_STATION, 0);
/* Add attributes into message */
- MESH_LOGD("Dump station list with interface [%s]", if_name);
+ WMESH_LOGD("Dump station list with interface [%s]", if_name);
ret = __get_device_index_from_string(if_name, &device_index);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get mesh interface device index");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get mesh interface device index");
err = ret;
goto DESTROY;
}
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
- MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
+ WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
- err = MESHD_ERROR_OPERATION_FAILED;
+ err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
}
/* sync response */
state.callback_state = MESH_NL_CALLBACK_TRYING;
while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
- MESH_LOGD(" count [%02d]", ++test);
+ WMESH_LOGD(" count [%02d]", ++test);
nl_recvmsgs(state.nl_socket, state.cb);
}
- MESH_LOGD("Finished");
+ WMESH_LOGD("Finished");
DESTROY:
__clean_netlink_message(&state);
return err;
nla_put_failure:
- MESH_LOGE("Failed to message build");
+ WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
static int _send_nl_del_station_info(const char* if_name, char* peer)
.s_cb = NULL,
.station_list = NULL,
};
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
int device_index = 0;
int ret;
ret = __initialize_nl80211(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize nl80211");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize nl80211");
return ret;
}
ret = __initialize_netlink_message(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize netlink message");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
}
NLM_F_DUMP, NL80211_CMD_DEL_STATION, 0);
/* Add attributes into message */
- MESH_LOGD("Delete a station [%s] with interface [%s]", peer, if_name);
+ WMESH_LOGD("Delete a station [%s] with interface [%s]", peer, if_name);
ret = __get_device_index_from_string(if_name, &device_index);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get mesh interface device index");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get mesh interface device index");
err = ret;
goto DESTROY;
}
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
- MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
+ WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
- err = MESHD_ERROR_OPERATION_FAILED;
+ err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
}
return err;
nla_put_failure:
- MESH_LOGE("Failed to message build");
+ WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
static int _send_nl_get_mpath_info(const char* if_name, GList **mpath_list)
.s_cb = NULL,
.mpath_list = mpath_list
};
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
int device_index = 0;
int ret;
int test = 0;
ret = __initialize_nl80211(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize nl80211");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize nl80211");
return ret;
}
ret = __initialize_netlink_message(&state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize netlink message");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
}
NLM_F_DUMP, NL80211_CMD_GET_MPATH, 0);
/* Add attributes into message */
- MESH_LOGD("Dump station list with interface [%s]", if_name);
+ WMESH_LOGD("Dump station list with interface [%s]", if_name);
ret = __get_device_index_from_string(if_name, &device_index);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to get mesh interface device index");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get mesh interface device index");
err = ret;
goto DESTROY;
}
/* Send message into kernel */
ret = nl_send_auto(state.nl_socket, state.msg);
if (ret < 0) {
- MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
+ WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
nl_geterror(ret), ret);
- err = MESHD_ERROR_OPERATION_FAILED;
+ err = WMESHD_ERROR_OPERATION_FAILED;
goto DESTROY;
}
/* sync response */
state.callback_state = MESH_NL_CALLBACK_TRYING;
while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
- MESH_LOGD(" count [%02d]", ++test);
+ WMESH_LOGD(" count [%02d]", ++test);
nl_recvmsgs(state.nl_socket, state.cb);
}
- MESH_LOGD("Finished");
+ WMESH_LOGD("Finished");
DESTROY:
__clean_netlink_message(&state);
return err;
nla_put_failure:
- MESH_LOGE("Failed to message build");
+ WMESH_LOGE("Failed to message build");
__clean_netlink_message(&state);
__clean_nl80211(&state);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
static int _send_nl_register_event_handler()
{
- int err = MESHD_ERROR_NONE;
+ int err = WMESHD_ERROR_NONE;
int ret;
GIOChannel *recv_channel = NULL;
if (event_state) {
- MESH_LOGE("Already event handler registered !");
- return MESHD_ERROR_IN_PROGRESS;
+ WMESH_LOGE("Already event handler registered !");
+ return WMESHD_ERROR_IN_PROGRESS;
}
event_state = _create_mesh_nl_state("");
ret = __initialize_nl80211(event_state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize nl80211");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize nl80211");
return ret;
}
/* Subscribe multicast group should be proceed before scanning */
ret = __prepare_listen_events(event_state);
if (ret) {
- MESH_LOGE("__prepare_listen_events : [%d]", ret);
+ WMESH_LOGE("__prepare_listen_events : [%d]", ret);
goto DESTROY;
}
ret = __initialize_netlink_message(event_state);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to initialize netlink message");
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to initialize netlink message");
goto DESTROY;
}
/* No sequence checking for multicast messages. */
nl_cb_set(event_state->cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
- MESH_LOGD("Register event handler");
+ WMESH_LOGD("Register event handler");
/* Change socket type to non-blocking */
ret = nl_socket_set_nonblocking(event_state->nl_socket);
if (ret < 0)
- MESH_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);
/* Register I/O callback to wait asynchronously */
if (FALSE == event_state->error_occured) {
(G_IO_IN | G_IO_ERR), _on_socket_event_io_received, event_state);
g_io_channel_unref(recv_channel);
} else {
- MESH_LOGE("Error responded. Failed to register event callback !!");
+ WMESH_LOGE("Error responded. Failed to register event callback !!");
goto DESTROY;
}
/* Resource should be free on I/O callback */
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
DESTROY:
__clean_netlink_message(event_state);
return err;
}
-int mesh_netlink_set_mesh_parameter(const char* mesh_if_name,
+int wmesh_netlink_set_mesh_parameter(const char* mesh_if_name,
const char* param_name, unsigned int value)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
- MESH_LOGD("Set mesh[%s] param [%s] value [%d]",
+ WMESH_LOGD("Set mesh[%s] param [%s] value [%d]",
mesh_if_name, param_name, value);
ret = _send_nl_set_mesh_parameter(mesh_if_name, param_name, value);
return ret;
}
-int mesh_netlink_get_station_info(const char* mesh_if_name, GList **station_list)
+int wmesh_netlink_get_station_info(const char* mesh_if_name, GList **station_list)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (NULL == station_list) {
- MESH_LOGE("Invalid parameter [%p]", station_list);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", station_list);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
- MESH_LOGD("Get connected stations");
+ WMESH_LOGD("Get connected stations");
ret = _send_nl_get_station_info(mesh_if_name, station_list);
return ret;
}
-int mesh_netlink_del_station_info(const char* mesh_if_name, char *peer)
+int wmesh_netlink_del_station_info(const char* mesh_if_name, char *peer)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (NULL == peer) {
- MESH_LOGE("Invalid parameter [%p]", peer);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", peer);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
- MESH_LOGD("Del connected station : [%s]", peer);
+ WMESH_LOGD("Del connected station : [%s]", peer);
ret = _send_nl_del_station_info(mesh_if_name, peer);
return ret;
}
-int mesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list)
+int wmesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
- MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (NULL == mpath_list) {
- MESH_LOGE("Invalid parameter [%p]", mpath_list);
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter [%p]", mpath_list);
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
- MESH_LOGD("Get current mpath info");
+ WMESH_LOGD("Get current mpath info");
ret = _send_nl_get_mpath_info(mesh_if_name, mpath_list);
return ret;
}
-int mesh_netlink_register_event_handler()
+int wmesh_netlink_register_event_handler()
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
- MESH_LOGD("Register mesh event handler");
+ WMESH_LOGD("Register mesh event handler");
ret = _send_nl_register_event_handler();
return ret;
}
-int mesh_netlink_unregister_event_handler()
+int wmesh_netlink_unregister_event_handler()
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
- MESH_LOGD("Unregister mesh event handler");
+ WMESH_LOGD("Unregister mesh event handler");
_on_remove_event_io_handler();
*/
#include <glib.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-gdbus.h"
-#include "mesh-request.h"
-#include "mesh-netlink.h"
-#include "mesh-interface.h"
-#include "mesh-peer-monitor.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-gdbus.h"
+#include "wmesh-request.h"
+#include "wmesh-netlink.h"
+#include "wmesh-interface.h"
+#include "wmesh-peer-monitor.h"
#define MESH_MONITORING_TIME 5
#define MESH_MAXIMUM_BEACON_LOST_COUNT 10
static void _on_station_list_destroy(gpointer data)
{
- mesh_station_info_s *info = (mesh_station_info_s*)data;
+ wmesh_station_info_s *info = (wmesh_station_info_s*)data;
if (info) {
g_free(info->bssid);
#if 0
static void _on_mpath_list_destroy(gpointer data)
{
- mesh_mpath_info_s *info = (mesh_mpath_info_s*)data;
+ wmesh_mpath_info_s *info = (wmesh_mpath_info_s*)data;
if (info) {
g_free(info->dest_addr);
static int _get_station_info(void *pdata)
{
int is_new;
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GList *iter = NULL;
GList *sta_list = NULL;
GList *cmp_iter = NULL;
- mesh_service *service = (mesh_service *)pdata;
- mesh_interface_s *info = service->interface_info;
+ wmesh_service *service = (wmesh_service *)pdata;
+ wmesh_interface_s *info = service->interface_info;
- ret = mesh_request_get_station_info(info->mesh_interface, &sta_list);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_request_get_station_info");
+ ret = wmesh_request_get_station_info(info->mesh_interface, &sta_list);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to wmesh_request_get_station_info");
return ret;
}
iter = service->station_list;
while (iter) {
- mesh_station_info_s *item = (mesh_station_info_s*)iter->data;
- MESH_LOGD("[%s]", item->bssid);
+ wmesh_station_info_s *item = (wmesh_station_info_s*)iter->data;
+ WMESH_LOGD("[%s]", item->bssid);
iter = g_list_next(iter);
}
iter = sta_list;
while (iter) {
- mesh_station_info_s *item = (mesh_station_info_s*)iter->data;
+ wmesh_station_info_s *item = (wmesh_station_info_s*)iter->data;
/* Found this in th existing station infomation list. */
if (item->inactive_time > item->beacon_interval * MESH_MAXIMUM_BEACON_LOST_COUNT) {
/* Remove this node from station list in kernel */
- mesh_netlink_del_station_info(info->mesh_interface, item->bssid);
+ wmesh_netlink_del_station_info(info->mesh_interface, item->bssid);
/* Remove current linked list */
iter = g_list_remove(iter, item);
/* Send existing node disjoined */
- MESH_LOGE("[%s] disjoined", item->bssid);
+ WMESH_LOGE("[%s] disjoined", item->bssid);
}
is_new = TRUE;
cmp_iter = service->station_list;
while (cmp_iter) {
- mesh_station_info_s *cmp_item = (mesh_station_info_s*)cmp_iter->data;
+ wmesh_station_info_s *cmp_item = (wmesh_station_info_s*)cmp_iter->data;
if (0 == strncmp(item->bssid, cmp_item->bssid, sizeof("11:22:33:44:55:66"))) {
is_new = FALSE;
break;
if (is_new) {
/* Send new station joined event */
- MESH_LOGE("[%s] joined", item->bssid);
+ WMESH_LOGE("[%s] joined", item->bssid);
}
iter = g_list_next(iter);
iter = service->station_list;
while (iter) {
- mesh_station_info_s *item2 = (mesh_station_info_s*)iter->data;
- MESH_LOGE("[%s]", item2->bssid);
+ wmesh_station_info_s *item2 = (wmesh_station_info_s*)iter->data;
+ WMESH_LOGE("[%s]", item2->bssid);
iter = g_list_next(iter);
}
#if 0
static gboolean _get_mpath_info(void *pdata)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariantBuilder builder;
GVariant* mpath_data;
GList *iter = NULL;
- mesh_service *service = (mesh_service *)pdata;
- mesh_interface_s *info = service->interface_info;
+ wmesh_service *service = (wmesh_service *)pdata;
+ wmesh_interface_s *info = service->interface_info;
/* Clear mesh path list */
g_list_free_full(service->mpath_list, _on_mpath_list_destroy);
service->mpath_list = NULL;
- ret = mesh_request_get_mpath_info(info->mesh_interface, &service->mpath_list);
- if (MESHD_ERROR_NONE == ret) {
+ ret = wmesh_request_get_mpath_info(info->mesh_interface, &service->mpath_list);
+ if (WMESHD_ERROR_NONE == ret) {
/*
* Example) sh-3.2# iw mesh0 mpath dump
* DEST ADDR NEXT HOP IFACE SN METRIC QLEN EXPTIME DTIM DRET FLAGS
iter = service->mpath_list;
while (iter != NULL) {
- mesh_mpath_info_s *item = (mesh_mpath_info_s*)iter->data;
+ wmesh_mpath_info_s *item = (wmesh_mpath_info_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "DEST_ADDR",
mpath_data = g_variant_builder_end(&builder);
g_object_unref(mpath_data);
} else
- MESH_LOGE("Failed to mesh_request_get_mpath_info");
+ WMESH_LOGE("Failed to wmesh_request_get_mpath_info");
return ret;
}
{
int ret;
bool state;
- mesh_service *service = (mesh_service *)pdata;
+ wmesh_service *service = (wmesh_service *)pdata;
if (service) {
- mesh_interface_s *info = service->interface_info;
+ wmesh_interface_s *info = service->interface_info;
if (info) {
/* Exceptionally, checking external interface processes here. */
- ret = mesh_interface_check_external_exists(info->external_interface, &state);
- MESH_LOGD("Status : %d %d %d", ret, info->can_be_gate, state);
- if (MESHD_ERROR_NONE == ret) {
+ ret = wmesh_interface_check_external_exists(info->external_interface, &state);
+ WMESH_LOGD("Status : %d %d %d", ret, info->can_be_gate, state);
+ if (WMESHD_ERROR_NONE == ret) {
if (info->can_be_gate != state) {
- mesh_gdbus_enable_ethernet_interface(service, state);
+ wmesh_gdbus_enable_ethernet_interface(service, state);
#if 0
/* Detect external network state (i.e. Ethernet)
and decide to make gate enabled */
if (state)
- mesh_request_set_mesh_gate(info->bridge_interface,
+ wmesh_request_set_mesh_gate(info->bridge_interface,
info->mesh_interface, info->external_interface);
else
- mesh_request_unset_mesh_gate(info->bridge_interface,
+ wmesh_request_unset_mesh_gate(info->bridge_interface,
info->mesh_interface, info->external_interface);
#endif
- MESH_LOGD("External interface state has been changed : [%d]", state);
+ WMESH_LOGD("External interface state has been changed : [%d]", state);
info->can_be_gate = state;
}
} else {
/* In error case, we call enable etheret again for OdroidU3 */
- mesh_gdbus_enable_ethernet_interface(service, true);
+ wmesh_gdbus_enable_ethernet_interface(service, true);
}
#if 0
_get_mpath_info(service);
return G_SOURCE_CONTINUE;
}
-int mesh_start_monitor_service(void *pdata)
+int wmesh_start_monitor_service(void *pdata)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)pdata;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)pdata;
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
if (service->monitor_timer)
- mesh_stop_monitor_service(pdata);
+ wmesh_stop_monitor_service(pdata);
service->monitor_timer = g_timeout_add_seconds(MESH_MONITORING_TIME, _on_mesh_monitor_cb, service);
- MESH_LOGD("Peer Monitoring Service Started");
+ WMESH_LOGD("Peer Monitoring Service Started");
return ret;
}
-int mesh_stop_monitor_service(void *pdata)
+int wmesh_stop_monitor_service(void *pdata)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)pdata;
- meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)pdata;
+ wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
if (service->monitor_timer) {
g_source_remove(service->monitor_timer);
service->monitor_timer = 0;
}
- MESH_LOGD("Peer Monitoring Service Stopped");
+ WMESH_LOGD("Peer Monitoring Service Stopped");
return ret;
}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * 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 <stdlib.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-service-interface.h"
+#include "wmesh-generated-code.h"
+
+#include "wmesh-bridge.h"
+#include "wmesh-netlink.h"
+#include "wmesh-interface.h"
+#include "wmesh-request.h"
+#include "wmesh-softap.h"
+#include "wmesh-gdbus.h"
+
+int wmesh_request_set_mesh_gate(const char* bridge_interface,
+ const char* mesh_interface, const char* external_interface)
+{
+ int ret = WMESHD_ERROR_NONE;
+ bool state = FALSE;
+
+ ret = wmesh_interface_check_external_exists(external_interface, &state);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get external interface state !");
+ return WMESHD_ERROR_OPERATION_FAILED;
+ }
+ 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) {
+ WMESH_LOGE("Failed to turn STP on !");
+ return ret;
+ }
+
+ /* 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");
+
+ 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");
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_unset_mesh_gate(const char* bridge_interface,
+ const char* mesh_interface, const char* external_interface)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ NOTUSED(external_interface);
+
+ /* Set mesh parameters */
+ 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");
+
+ 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");
+
+ /* Turn STP off */
+ ret = wmesh_bridge_set_stp(bridge_interface, FALSE);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to turn STP off!");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_add_bridge_interface(const char* bridge_interface,
+ const char* interface)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ if (NULL == bridge_interface || NULL == interface) {
+ WMESH_LOGE("Invalid parameters");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("Adding interface[%s] into bridge[%s]...", interface, bridge_interface);
+
+ /* Add external interface into bridge */
+ ret = wmesh_bridge_add_interface(bridge_interface, interface);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to add interface !");
+ return ret;
+ }
+
+ /* Make external interface down */
+ ret = wmesh_interface_set(interface, NULL, WMESH_INTERFACE_DOWN);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to change external interface state");
+ return ret;
+ }
+
+ /* Make external interface up with cleared IP */
+ ret = wmesh_interface_set(interface, "0.0.0.0", WMESH_INTERFACE_UP);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to change external interface state");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_remove_bridge_interface(const char* bridge_interface,
+ const char* interface)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ if (NULL == bridge_interface || NULL == interface) {
+ WMESH_LOGE("Invalid parameters");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ 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) {
+ WMESH_LOGD("Interface is not exist in bridge");
+ return WMESHD_ERROR_NONE;
+ }
+
+ /* Remove external interface into bridge */
+ ret = wmesh_bridge_del_interface(bridge_interface, interface);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to remove interface !");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_set_softap_config(const char* softap_interface,
+ const char *ssid, const char* mode, int channel, int visibility,
+ int max_sta, int security, const char* passphrase)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Setting configuration for SoftAP");
+
+ ret = wmesh_softap_set_configuration(softap_interface, ssid, mode, channel,
+ visibility, max_sta, security, passphrase);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to set Configuration for SoftAP");
+ return ret;
+ }
+
+ return ret;
+}
+
+int wmesh_request_enable_softap(
+ const char* bridge_interface, const char* softap_interface)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Request to turn SoftAP on");
+ ret = wmesh_softap_enable_softap(softap_interface);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to wmesh_softap_enable_softap");
+ return ret;
+ }
+
+ /* Add softAP interface into bridge */
+ ret = wmesh_request_add_bridge_interface(bridge_interface, softap_interface);
+ if (WMESHD_ERROR_NONE != ret) {
+ wmesh_softap_disable_softap();
+ return ret;
+ }
+
+ return ret;
+}
+
+int wmesh_request_disable_softap(
+ const char* bridge_interface, const char* softap_interface)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Request to turn SoftAP off");
+ ret = wmesh_softap_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;
+}
+
+int wmesh_request_get_station_info(const char* mesh_interface, GList **station_list)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Request to get station info");
+
+ /* Get station info */
+ ret = wmesh_netlink_get_station_info(mesh_interface, station_list);
+ if (WMESHD_ERROR_NONE != ret)
+ return ret;
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_get_mpath_info(const char* mesh_interface, GList **mpath_list)
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Request to get mpath info");
+
+ /* Get MPath info */
+ ret = wmesh_netlink_get_mpath_info(mesh_interface, mpath_list);
+ if (WMESHD_ERROR_NONE != ret)
+ return ret;
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_register_event_handler()
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Request to register mesh event handler");
+
+ /* Get MPath info */
+ ret = wmesh_netlink_register_event_handler();
+ if (WMESHD_ERROR_NONE != ret)
+ return ret;
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_unregister_event_handler()
+{
+ int ret = WMESHD_ERROR_NONE;
+
+ WMESH_LOGD("Request to unregister mesh event handler");
+
+ /* Get MPath info */
+ ret = wmesh_netlink_unregister_event_handler();
+ if (WMESHD_ERROR_NONE != ret)
+ return ret;
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_enable_network(wmesh_service *service)
+{
+ int ret;
+ wmesh_interface_s *info = NULL;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Enable mesh network");
+
+ /* Check if mesh interface exists */
+ info = service->interface_info;
+ ret = wmesh_interface_check(info->mesh_interface);
+ if (WMESHD_ERROR_NONE == ret) {
+ /* Interface already exists */
+ return WMESHD_ERROR_NONE;
+ }
+
+ ret = wmesh_gdbus_create_mesh_interface(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to create mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_disable_network(wmesh_service *service)
+{
+ int ret;
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Disable mesh network");
+
+ ret = wmesh_gdbus_remove_mesh_interface(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to disable mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_scan(wmesh_service *service)
+{
+ int ret;
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Request scan for mesh network");
+
+ ret = wmesh_gdbus_mesh_scan(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to request scan for mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_specific_scan(wmesh_service *service, gchar *mesh_id, gint channel)
+{
+ int ret;
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Request specific scan for mesh network");
+
+ ret = wmesh_gdbus_mesh_specific_scan(service, mesh_id, channel);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to request specific scan for mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_cancel_scan(wmesh_service *service)
+{
+ int ret;
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Cancel scan for mesh network");
+
+ ret = wmesh_gdbus_mesh_cancel_scan(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to cancel scan for mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_get_networks(wmesh_service *service)
+{
+ int ret;
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Get mesh networks");
+
+ ret = wmesh_gdbus_get_mesh_networks(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get mesh networks !");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+static int _select_matched_network(GList *scanned_network,
+ const char *mesh_id, int mesh_channel, wmeshd_security_type_e sec,
+ wmesh_scan_result_s **info)
+{
+ int ret = WMESHD_ERROR_NONE;
+ GList *iter = NULL;
+ wmesh_scan_result_s *item = NULL;
+ gboolean found = FALSE;
+
+ wmeshd_check_null_ret_error("scanned_network", scanned_network,
+ WMESHD_ERROR_INVALID_PARAMETER);
+
+ iter = scanned_network;
+ while (iter != NULL) {
+ item = (wmesh_scan_result_s*)iter->data;
+
+ if (g_strcmp0(mesh_id, item->mesh_id) == 0) {
+ if (item->channel == mesh_channel && item->security == sec) {
+ *info = item;
+ found = TRUE;
+ break;
+ }
+ }
+ iter = g_list_next(iter);
+ }
+
+ if (FALSE == found)
+ return WMESHD_ERROR_NO_DATA;
+
+ return ret;
+}
+
+int wmesh_request_get_joined_network(wmesh_service *service)
+{
+ int ret;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Get joined mesh network");
+
+ ret = wmesh_gdbus_get_joined_mesh_network(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get joined mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_get_connected_peers(wmesh_service *service)
+{
+ int ret;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Get connected mesh peers");
+
+ ret = wmesh_gdbus_get_connected_peers(service);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to get connected mesh peers");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_create_mesh_network(wmesh_service *service, gchar *mesh_id,
+ gint channel, wmeshd_security_type_e sec)
+{
+ int ret;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Create a new mesh network");
+
+ ret = wmesh_gdbus_create_network(service, mesh_id, channel, sec);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to create mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_connect_mesh_network(wmesh_service *service, gchar *mesh_id,
+ gint channel, wmeshd_security_type_e sec, gchar *passphrase)
+{
+ int ret;
+ wmesh_scan_result_s *info = NULL;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Connect mesh network");
+
+ /* Get mesh_id and channel from saved network */
+ ret = _select_matched_network(service->scanned_mesh_network,
+ mesh_id, channel, sec, &info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to mesh_network_get_first_mesh_network");
+ return ret;
+ }
+
+ /* Set passphrase */
+ if (WMESHD_SECURITY_NONE != sec) {
+ if (NULL != passphrase) {
+ ret = wmesh_gdbus_set_passphrase(service, info, passphrase);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to set passphrase for mesh network");
+ return ret;
+ }
+ } else {
+ WMESH_LOGE("Passphrase is required !");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ ret = wmesh_gdbus_connect_network(service, info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to connect mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_disconnect_mesh_network(wmesh_service *service,
+ gchar *mesh_id, gint channel, wmeshd_security_type_e sec)
+{
+ int ret;
+ wmesh_scan_result_s *info = NULL;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Disconnect mesh network");
+
+ /* Get mesh_id and channel from saved network */
+ ret = _select_matched_network(service->scanned_mesh_network,
+ mesh_id, channel, sec, &info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to _select_matched_network");
+ return ret;
+ }
+
+ ret = wmesh_gdbus_disconnect_network(service, info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to disconnect mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+int wmesh_request_remove_mesh_network(wmesh_service *service,
+ gchar *mesh_id, gint channel, wmeshd_security_type_e sec)
+{
+ int ret;
+ wmesh_scan_result_s *info = NULL;
+
+ if (NULL == service) {
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ WMESH_LOGD("[IPC] Remove mesh network");
+
+ /* Get mesh_id and channel from saved network */
+ ret = _select_matched_network(service->scanned_mesh_network,
+ mesh_id, channel, sec, &info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to _select_matched_network");
+ return ret;
+ }
+
+ ret = wmesh_gdbus_remove_network(service, info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to remove mesh network");
+ return ret;
+ }
+
+ return WMESHD_ERROR_NONE;
+}
+
+/* Notifications */
+void wmesh_notify_scan_done()
+{
+ NetWmesh *object = wmeshd_dbus_get_object();
+
+ net_wmesh_emit_scan_done(object);
+}
+
+void wmesh_notify_connection_state(const char* mesh_id, const char* bssid,
+ int channel, wmeshd_security_type_e sec, wmeshd_connection_state_e state)
+{
+ NetWmesh *object = wmeshd_dbus_get_object();
+
+ net_wmesh_emit_connection_state(object, mesh_id, bssid, channel, (int)sec, (int)state);
+}
+
+void wmesh_notify_station_joined(const char* bssid)
+{
+ NetWmesh *object = wmeshd_dbus_get_object();
+
+ net_wmesh_emit_sta_joined(object, bssid);
+}
+
+void wmesh_notify_station_left(const char* bssid)
+{
+ NetWmesh *object = wmeshd_dbus_get_object();
+
+ net_wmesh_emit_sta_left(object, bssid);
+}
#include <gio/gio.h>
#include <wifi-manager.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-gdbus.h"
-#include "mesh-service.h"
-#include "mesh-peer-monitor.h"
-#include "mesh-service-interface.h"
-#include "mesh-generated-code.h"
-
-#include "mesh-request.h"
-#include "mesh-interface.h"
-
-static NetMesh *meshd_dbus_object;
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-gdbus.h"
+#include "wmesh-service.h"
+#include "wmesh-peer-monitor.h"
+#include "wmesh-service-interface.h"
+#include "wmesh-generated-code.h"
+
+#include "wmesh-request.h"
+#include "wmesh-interface.h"
+
+static NetWmesh *meshd_dbus_object;
static Manager *meshd_activator_dbus_object;
/* global list to care resource handle for each client */
}
}
-NetMesh* meshd_dbus_get_object()
+NetWmesh* wmeshd_dbus_get_object()
{
return meshd_dbus_object;
}
-int64_t meshd_dbus_generate_signal_number()
+int64_t wmeshd_dbus_generate_signal_number()
{
static int64_t i = 0;
return i++;
}
-static int _meshd_dbus_client_list_cleanup(GList *client_list)
+static int _wmeshd_dbus_client_list_cleanup(GList *client_list)
{
meshd_dbus_client_s *client;
- meshd_check_null_ret_error("client_list", client_list, FALSE);
+ wmeshd_check_null_ret_error("client_list", client_list, FALSE);
client = client_list->data;
free(client);
g_list_free(client_list);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-static int _meshd_dbus_client_list_compare_bus_name(const void *a, const void *b)
+static int _wmeshd_dbus_client_list_compare_bus_name(const void *a, const void *b)
{
const meshd_dbus_client_s *client = a;
return g_strcmp0(client->bus_name, b);
}
-static inline GList* _meshd_dbus_client_list_find_client(const gchar *owner)
+static inline GList* _wmeshd_dbus_client_list_find_client(const gchar *owner)
{
return g_list_find_custom(meshd_dbus_client_list, owner,
- _meshd_dbus_client_list_compare_bus_name);
+ _wmeshd_dbus_client_list_compare_bus_name);
}
-static void _meshd_dbus_name_owner_changed_cb(GDBusConnection *conn,
+static void _wmeshd_dbus_name_owner_changed_cb(GDBusConnection *conn,
const gchar *sender_name,
const gchar *object_path,
const gchar *interface_name,
if (0 == strlen(new_owner)) {
g_mutex_lock(&meshd_dbus_client_list_mutex);
- client = _meshd_dbus_client_list_find_client(old_owner);
+ client = _wmeshd_dbus_client_list_find_client(old_owner);
if (client) { /* found bus name in our bus list */
- MESH_LOGD("bus(%s) stopped", old_owner);
+ WMESH_LOGD("bus(%s) stopped", old_owner);
meshd_dbus_client_list = g_list_remove_link(meshd_dbus_client_list, client);
}
g_mutex_unlock(&meshd_dbus_client_list_mutex);
if (client) {
- ret = _meshd_dbus_client_list_cleanup(client);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("_meshd_dbus_client_list_cleanup() Fail(%d)", ret);
+ ret = _wmeshd_dbus_client_list_cleanup(client);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("_wmeshd_dbus_client_list_cleanup() Fail(%d)", ret);
}
}
}
-static int _meshd_dbus_subscribe_name_owner_changed(GDBusConnection *conn)
+static int _wmeshd_dbus_subscribe_name_owner_changed(GDBusConnection *conn)
{
unsigned int id;
"/org/freedesktop/DBus", /* path */
NULL, /* arg0 */
G_DBUS_SIGNAL_FLAGS_NONE,
- _meshd_dbus_name_owner_changed_cb,
+ _wmeshd_dbus_name_owner_changed_cb,
NULL,
NULL);
if (0 == id) {
- MESH_LOGE("g_dbus_connection_signal_subscribe() Fail");
- return MESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("g_dbus_connection_signal_subscribe() Fail");
+ return WMESHD_ERROR_IO_ERROR;
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-static gboolean _meshd_dbus_handle_enable(Manager *object,
+static gboolean _wmeshd_dbus_handle_enable(Manager *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
wifi_manager_h wifi_handle = NULL;
bool wifi_activated = false;
/* Initialize Wi-Fi driver */
ret = wifi_manager_initialize(&wifi_handle);
if (WIFI_MANAGER_ERROR_NONE != ret)
- MESH_LOGE("Failed to get wifi manager handle ! [%s(%X)]",
+ WMESH_LOGE("Failed to get wifi manager handle ! [%s(%X)]",
wifi_error_to_string(ret), ret);
wifi_manager_is_activated(wifi_handle, &wifi_activated);
if (false == wifi_activated) {
ret = wifi_manager_activate(wifi_handle, NULL, NULL);
if (WIFI_MANAGER_ERROR_NONE != ret)
- MESH_LOGE("Failed to activate wifi ! [%s(%X)]",
+ WMESH_LOGE("Failed to activate wifi ! [%s(%X)]",
wifi_error_to_string(ret), ret);
}
wifi_manager_deinitialize(wifi_handle);
if (service->mesh_activated) {
/* Already activated */
- manager_complete_enable(object, invocation, MESHD_ERROR_NONE);
+ manager_complete_enable(object, invocation, WMESHD_ERROR_NONE);
goto FINISH;
}
manager_complete_enable(object, invocation, ret);
service->mesh_activated = TRUE;
- meshd_check_null_ret_error("info", info, FALSE);
+ wmeshd_check_null_ret_error("info", info, FALSE);
/* Register event handler first */
- ret = mesh_request_register_event_handler();
- if (MESHD_ERROR_IN_PROGRESS == ret) {
- MESH_LOGE("Currently set netlink event handler !! [%d]", ret);
- ret = MESHD_ERROR_NONE;
- } else if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to register mesh event handler !! [%d]", ret);
+ ret = wmesh_request_register_event_handler();
+ if (WMESHD_ERROR_IN_PROGRESS == ret) {
+ WMESH_LOGE("Currently set netlink event handler !! [%d]", ret);
+ ret = WMESHD_ERROR_NONE;
+ } else if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to register mesh event handler !! [%d]", ret);
}
- ret = mesh_interface_initialize(service->interface_info);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_interface_initialize [%d]", ret);
+ ret = wmesh_interface_initialize(service->interface_info);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("Failed to wmesh_interface_initialize [%d]", ret);
goto FINISH;
}
FINISH:
- net_mesh_emit_mesh_enabled(meshd_dbus_get_object(), ret);
+ net_wmesh_emit_mesh_enabled(wmeshd_dbus_get_object(), ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_disable(Manager *object,
+static gboolean _wmeshd_dbus_handle_disable(Manager *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
- meshd_check_null_ret_error("info", info, FALSE);
+ wmeshd_check_null_ret_error("info", info, FALSE);
/* Make response first */
manager_complete_disable(object, invocation, ret);
- ret = mesh_request_unregister_event_handler();
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to unregister mesh event handler !! [%d]", ret);
+ ret = wmesh_request_unregister_event_handler();
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to unregister mesh event handler !! [%d]", ret);
/* Terminate daemon */
- meshd_service_exit(service);
+ wmeshd_service_exit(service);
return TRUE;
}
-static gboolean _meshd_dbus_handle_scan(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_scan(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
- meshd_check_null_ret_error("info", info, FALSE);
+ wmeshd_check_null_ret_error("info", info, FALSE);
- ret = mesh_request_scan(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_scan !");
+ ret = wmesh_request_scan(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_scan !");
- net_mesh_complete_scan(object, invocation, ret);
+ net_wmesh_complete_scan(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_specific_scan(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_specific_scan(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id,
gint channel,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
- meshd_check_null_ret_error("info", info, FALSE);
+ wmeshd_check_null_ret_error("info", info, FALSE);
- ret = mesh_request_specific_scan(service, mesh_id, channel);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_specific_scan !");
+ ret = wmesh_request_specific_scan(service, mesh_id, channel);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_specific_scan !");
- net_mesh_complete_specific_scan(object, invocation, ret);
+ net_wmesh_complete_specific_scan(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_cancel_scan(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_cancel_scan(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
- ret = mesh_request_cancel_scan(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_cancel_scan");
+ ret = wmesh_request_cancel_scan(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_cancel_scan");
- net_mesh_complete_cancel_scan(object, invocation, ret);
+ net_wmesh_complete_cancel_scan(object, invocation, ret);
return TRUE;
}
static void _on_scan_result_destroy(gpointer data)
{
- mesh_scan_result_s *scan_item = (mesh_scan_result_s *)data;
+ wmesh_scan_result_s *scan_item = (wmesh_scan_result_s *)data;
if (scan_item) {
g_free(scan_item->mesh_id);
static void _on_peer_info_destroy(gpointer data)
{
- mesh_peer_info_s *peer = (mesh_peer_info_s *)data;
+ wmesh_peer_info_s *peer = (wmesh_peer_info_s *)data;
if (peer)
g_free(peer->address);
g_free(peer);
static void _on_station_list_destroy(gpointer data)
{
- mesh_station_info_s *info = (mesh_station_info_s*)data;
+ wmesh_station_info_s *info = (wmesh_station_info_s*)data;
if (info) {
g_free(info->bssid);
static void _on_mpath_list_destroy(gpointer data)
{
- mesh_mpath_info_s *info = (mesh_mpath_info_s*)data;
+ wmesh_mpath_info_s *info = (wmesh_mpath_info_s*)data;
if (info) {
g_free(info->dest_addr);
}
}
-static gboolean _meshd_dbus_handle_get_found_mesh_networks(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_get_found_mesh_networks(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
GVariantBuilder builder;
GVariant* networks;
GList *iter = NULL;
- mesh_scan_result_s *scan_item = NULL;
+ wmesh_scan_result_s *scan_item = NULL;
- MESH_LOGD("Request to get scanned mesh network list");
+ WMESH_LOGD("Request to get scanned mesh network list");
- ret = mesh_request_get_networks(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_get_networks");
+ ret = wmesh_request_get_networks(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_get_networks");
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) {
- scan_item = (mesh_scan_result_s*)iter->data;
+ scan_item = (wmesh_scan_result_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "mesh_id",
networks = g_variant_builder_end(&builder);
- net_mesh_complete_get_found_mesh_networks(object, invocation, networks, ret);
+ net_wmesh_complete_get_found_mesh_networks(object, invocation, networks, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_enable_mesh(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_enable_mesh(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
/* It handles creating virtual network and bridge */
- ret = mesh_request_enable_network(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_enable_network [%d]", ret);
+ ret = wmesh_request_enable_network(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_enable_network [%d]", ret);
- mesh_start_monitor_service(service);
+ wmesh_start_monitor_service(service);
- net_mesh_complete_enable_mesh(object, invocation, ret);
+ net_wmesh_complete_enable_mesh(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_disable_mesh(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_disable_mesh(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
- meshd_check_null_ret_error("info", info, FALSE);
+ wmeshd_check_null_ret_error("info", info, FALSE);
if (FALSE == service->mesh_activated) {
- MESH_LOGD("Mesh network is not activated yet");
- ret = MESHD_ERROR_OPERATION_FAILED;
- net_mesh_complete_disable_mesh(object, invocation, ret);
+ WMESH_LOGD("Mesh network is not activated yet");
+ ret = WMESHD_ERROR_OPERATION_FAILED;
+ net_wmesh_complete_disable_mesh(object, invocation, ret);
return TRUE;
}
- ret = mesh_request_disable_network(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to disable mesh network !");
+ ret = wmesh_request_disable_network(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to disable mesh network !");
/* Stop Mesh Node Monitoring Service */
- mesh_stop_monitor_service(service);
+ wmesh_stop_monitor_service(service);
/* Make response */
- net_mesh_complete_disable_mesh(object, invocation, ret);
+ net_wmesh_complete_disable_mesh(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_is_joined(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_is_joined(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
gboolean state = FALSE;
- mesh_service *service = (mesh_service *)user_data;
+ wmesh_service *service = (wmesh_service *)user_data;
- ret = mesh_request_get_joined_network(service);
- if (MESHD_ERROR_NONE == ret) {
+ ret = wmesh_request_get_joined_network(service);
+ if (WMESHD_ERROR_NONE == ret) {
if (service->joined_network)
state = TRUE;
}
- net_mesh_complete_is_joined(object, invocation, state, ret);
+ net_wmesh_complete_is_joined(object, invocation, state, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_get_joined_mesh_network(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_get_joined_mesh_network(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_network_info_s *joined = NULL;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_network_info_s *joined = NULL;
- ret = mesh_request_get_joined_network(service);
- if (MESHD_ERROR_NONE == ret) {
+ ret = wmesh_request_get_joined_network(service);
+ if (WMESHD_ERROR_NONE == ret) {
joined = service->joined_network;
if (joined) {
- net_mesh_complete_get_joined_mesh_network(object, invocation,
+ net_wmesh_complete_get_joined_mesh_network(object, invocation,
joined->mesh_id, joined->bssid,
joined->channel, (int)joined->security,
joined->state, ret);
} else {
- net_mesh_complete_get_joined_mesh_network(object, invocation,
- "", "", 0, 0, 0, MESHD_ERROR_NO_DATA);
+ net_wmesh_complete_get_joined_mesh_network(object, invocation,
+ "", "", 0, 0, 0, WMESHD_ERROR_NO_DATA);
}
} else {
- net_mesh_complete_get_joined_mesh_network(object, invocation,
+ net_wmesh_complete_get_joined_mesh_network(object, invocation,
"", "", 0, 0, 0, ret);
}
return TRUE;
}
-static gboolean _meshd_dbus_handle_get_connected_peers(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_get_connected_peers(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
GVariantBuilder builder;
GVariant* peer_list;
GList *iter = NULL;
- mesh_peer_info_s *peer = NULL;
+ wmesh_peer_info_s *peer = NULL;
- MESH_LOGD("Request to get connected peers");
+ WMESH_LOGD("Request to get connected peers");
- ret = mesh_request_get_connected_peers(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_get_connected_peers");
+ ret = wmesh_request_get_connected_peers(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_get_connected_peers");
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
iter = service->connected_mesh_peers;
while (iter != NULL) {
- peer = (mesh_peer_info_s*)iter->data;
+ peer = (wmesh_peer_info_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "Address",
peer_list = g_variant_builder_end(&builder);
- net_mesh_complete_get_connected_peers(object, invocation, peer_list, ret);
+ net_wmesh_complete_get_connected_peers(object, invocation, peer_list, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_set_gate(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_set_gate(NetWmesh *object,
GDBusMethodInvocation *invocation, gint16 gate_announce, guint hwmp_root_mode,
gboolean stp, gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
- MESH_LOGD("gate_announce = %d", gate_announce);
- MESH_LOGD("HWMP_Root_Mode = %d", hwmp_root_mode);
- MESH_LOGD("STP = %d", stp);
+ WMESH_LOGD("gate_announce = %d", gate_announce);
+ WMESH_LOGD("HWMP_Root_Mode = %d", hwmp_root_mode);
+ WMESH_LOGD("STP = %d", stp);
info->gate_announce = gate_announce;
info->hwmp_root_mode = hwmp_root_mode;
info->stp = stp;
/* Set STP and gate_announce for connmand */
- ret = mesh_gdbus_set_mesh_gate(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_gdbus_set_mesh_gate [%d]", ret);
+ ret = wmesh_gdbus_set_mesh_gate(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret);
/* Set STP and gate_announce right now */
- ret = mesh_request_set_mesh_gate(info->bridge_interface,
+ ret = wmesh_request_set_mesh_gate(info->bridge_interface,
info->mesh_interface, info->external_interface);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_gdbus_set_mesh_gate [%d]", ret);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret);
- net_mesh_complete_set_gate(object, invocation, ret);
+ net_wmesh_complete_set_gate(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_unset_gate(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_unset_gate(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
info->gate_announce = 0;
info->hwmp_root_mode = 0;
info->stp = 0;
/* Set STP and gate_announce for connmand */
- ret = mesh_gdbus_set_mesh_gate(service);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_gdbus_set_mesh_gate [%d]", ret);
+ ret = wmesh_gdbus_set_mesh_gate(service);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_gdbus_set_mesh_gate [%d]", ret);
/* Unset STP and Gate Annouce right now */
- ret = mesh_request_unset_mesh_gate(info->bridge_interface,
+ ret = wmesh_request_unset_mesh_gate(info->bridge_interface,
info->mesh_interface, info->external_interface);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_unset_mesh_gate [%d]", ret);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_unset_mesh_gate [%d]", ret);
- net_mesh_complete_unset_gate(object, invocation, ret);
+ net_wmesh_complete_unset_gate(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_set_softap(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_set_softap(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *ssid, gchar *passphrase,
gchar *mode, gint channel, gint visibility, gint max_sta,
gint security, gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
- MESH_LOGD("SSID : %s", ssid);
- MESH_LOGD("mode : %s", mode);
- MESH_LOGD("channel : %d", channel);
- MESH_LOGD("visibility: %d", visibility);
- MESH_LOGD("max_sta : %d", max_sta);
- MESH_LOGD("security : %d", security);
+ WMESH_LOGD("SSID : %s", ssid);
+ WMESH_LOGD("mode : %s", mode);
+ WMESH_LOGD("channel : %d", channel);
+ WMESH_LOGD("visibility: %d", visibility);
+ WMESH_LOGD("max_sta : %d", max_sta);
+ WMESH_LOGD("security : %d", security);
/* Save softAP information */
- ret = mesh_request_set_softap_config(info->softap_interface,
+ ret = wmesh_request_set_softap_config(info->softap_interface,
ssid, mode, channel, visibility, max_sta,
security, passphrase);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_set_softap_config [%d]", ret);
+ if (WMESHD_ERROR_NONE != ret)
+ WMESH_LOGE("Failed to wmesh_request_set_softap_config [%d]", ret);
- net_mesh_complete_set_softap(object, invocation, ret);
+ net_wmesh_complete_set_softap(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_enable_softap(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_enable_softap(NetWmesh *object,
GDBusMethodInvocation *invocation, gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
/* Check softAP interface and execute it */
- ret = mesh_request_enable_softap(info->bridge_interface, info->softap_interface);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_enable_softap [%d]", ret);
+ 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);
- net_mesh_complete_enable_softap(object, invocation, ret);
+ net_wmesh_complete_enable_softap(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_disable_softap(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_disable_softap(NetWmesh *object,
GDBusMethodInvocation *invocation, gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
/* Destroy softAP */
- ret = mesh_request_disable_softap(info->bridge_interface, info->softap_interface);
- if (MESHD_ERROR_NONE != ret)
- MESH_LOGE("Failed to mesh_request_disable_softap [%d]", ret);
+ 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);
- net_mesh_complete_disable_softap(object, invocation, ret);
+ net_wmesh_complete_disable_softap(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_create_mesh_network(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_create_mesh_network(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmeshd_security_type_e sec = (1 == security) ? WMESHD_SECURITY_SAE : WMESHD_SECURITY_NONE;
- ret = mesh_request_create_mesh_network(service, mesh_id, channel, sec);
+ ret = wmesh_request_create_mesh_network(service, mesh_id, channel, sec);
- net_mesh_complete_create_mesh_network(object, invocation, ret);
+ net_wmesh_complete_create_mesh_network(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_connect_mesh_network(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_connect_mesh_network(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security, gchar *passphrase,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmeshd_security_type_e sec = (1 == security) ? WMESHD_SECURITY_SAE : WMESHD_SECURITY_NONE;
- ret = mesh_request_connect_mesh_network(service, mesh_id, channel, sec, passphrase);
+ ret = wmesh_request_connect_mesh_network(service, mesh_id, channel, sec, passphrase);
- net_mesh_complete_connect_mesh_network(object, invocation, ret);
+ net_wmesh_complete_connect_mesh_network(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_disconnect_mesh_network(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_disconnect_mesh_network(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmeshd_security_type_e sec = (1 == security) ? WMESHD_SECURITY_SAE : WMESHD_SECURITY_NONE;
- ret = mesh_request_disconnect_mesh_network(service, mesh_id, channel, sec);
+ ret = wmesh_request_disconnect_mesh_network(service, mesh_id, channel, sec);
- net_mesh_complete_disconnect_mesh_network(object, invocation, ret);
+ net_wmesh_complete_disconnect_mesh_network(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_forget_mesh_network(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_forget_mesh_network(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmeshd_security_type_e sec = (1 == security) ? WMESHD_SECURITY_SAE : WMESHD_SECURITY_NONE;
- ret = mesh_request_remove_mesh_network(service, mesh_id, channel, sec);
+ ret = wmesh_request_remove_mesh_network(service, mesh_id, channel, sec);
- net_mesh_complete_forget_mesh_network(object, invocation, ret);
+ net_wmesh_complete_forget_mesh_network(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_set_interfaces(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_set_interfaces(NetWmesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh, gchar *gate, gchar *softap,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ int ret = WMESHD_ERROR_NONE;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
g_free(info->mesh_interface);
info->mesh_interface = g_strdup(mesh);
g_free(info->softap_interface);
info->softap_interface = g_strdup(softap);
- MESH_LOGD("Interface configuration for mesh network :");
- MESH_LOGD(" Base : [%s]", info->base_interface);
- MESH_LOGD(" Mesh : [%s]", info->mesh_interface);
- MESH_LOGD(" Bridge : [%s]", info->bridge_interface);
- MESH_LOGD(" SoftAP : [%s]", info->softap_interface);
- MESH_LOGD(" External: [%s]", info->external_interface);
+ WMESH_LOGD("Interface configuration for mesh network :");
+ WMESH_LOGD(" Base : [%s]", info->base_interface);
+ WMESH_LOGD(" Mesh : [%s]", info->mesh_interface);
+ WMESH_LOGD(" Bridge : [%s]", info->bridge_interface);
+ WMESH_LOGD(" SoftAP : [%s]", info->softap_interface);
+ WMESH_LOGD(" External: [%s]", info->external_interface);
- net_mesh_complete_set_interfaces(object, invocation, ret);
+ net_wmesh_complete_set_interfaces(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_get_station_info(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariantBuilder builder;
GVariant* station;
GList *iter = NULL;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
/* Clear mesh station list */
g_list_free_full(service->station_list, _on_station_list_destroy);
service->station_list = NULL;
- ret = mesh_request_get_station_info(
+ ret = wmesh_request_get_station_info(
info->mesh_interface, &service->station_list);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_request_get_station_info");
+ if (WMESHD_ERROR_NONE != ret) {
+ 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");
iter = service->station_list;
while (iter != NULL) {
- mesh_station_info_s *item = (mesh_station_info_s*)iter->data;
+ wmesh_station_info_s *item = (wmesh_station_info_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "bssid",
}
station = g_variant_builder_end(&builder);
- net_mesh_complete_get_station_info(object, invocation, station, ret);
+ net_wmesh_complete_get_station_info(object, invocation, station, ret);
g_object_unref(station);
}
return TRUE;
}
-static gboolean _meshd_dbus_handle_get_mpath_info(NetMesh *object,
+static gboolean _wmeshd_dbus_handle_get_mpath_info(NetWmesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
GVariantBuilder builder;
GVariant* mpath_data;
GList *iter = NULL;
- mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
+ wmesh_service *service = (wmesh_service *)user_data;
+ wmesh_interface_s *info = service->interface_info;
/* Clear mesh path list */
g_list_free_full(service->mpath_list, _on_mpath_list_destroy);
service->mpath_list = NULL;
- ret = mesh_request_get_mpath_info(
+ ret = wmesh_request_get_mpath_info(
info->mesh_interface, &service->mpath_list);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_request_get_mpath_info");
+ if (WMESHD_ERROR_NONE != ret) {
+ 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");
iter = service->mpath_list;
while (iter != NULL) {
- mesh_mpath_info_s *item = (mesh_mpath_info_s*)iter->data;
+ wmesh_mpath_info_s *item = (wmesh_mpath_info_s*)iter->data;
g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "DEST_ADDR",
}
mpath_data = g_variant_builder_end(&builder);
- net_mesh_complete_get_mpath_info(object, invocation, mpath_data, ret);
+ net_wmesh_complete_get_mpath_info(object, invocation, mpath_data, ret);
g_object_unref(mpath_data);
}
return TRUE;
}
-static void _meshd_dbus_on_activator_bus_acquired(GDBusConnection *conn,
+static void _wmeshd_dbus_on_activator_bus_acquired(GDBusConnection *conn,
const gchar *name, gpointer user_data)
{
gboolean ret;
GError *error = NULL;
- mesh_service *service = (mesh_service *)user_data;
+ wmesh_service *service = (wmesh_service *)user_data;
NOTUSED(name);
meshd_activator_dbus_object = manager_skeleton_new();
if (NULL == meshd_activator_dbus_object) {
- MESH_LOGE("manager_skeleton_new() Fail");
+ WMESH_LOGE("manager_skeleton_new() Fail");
return;
}
g_signal_connect(meshd_activator_dbus_object, "handle-enable",
- G_CALLBACK(_meshd_dbus_handle_enable), service);
+ G_CALLBACK(_wmeshd_dbus_handle_enable), service);
g_signal_connect(meshd_activator_dbus_object, "handle-disable",
- G_CALLBACK(_meshd_dbus_handle_disable), service);
+ G_CALLBACK(_wmeshd_dbus_handle_disable), service);
ret = g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(meshd_activator_dbus_object),
- conn, MESH_DBUS_MANAGER_OBJPATH, &error);
+ conn, WMESH_DBUS_MANAGER_OBJPATH, &error);
if (FALSE == ret) {
- MESH_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
+ WMESH_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
g_error_free(error);
}
}
-static void _meshd_dbus_on_bus_acquired(GDBusConnection *conn, const gchar *name,
+static void _wmeshd_dbus_on_bus_acquired(GDBusConnection *conn, const gchar *name,
gpointer user_data)
{
gboolean ret;
GError *error = NULL;
- mesh_service *service = (mesh_service *)user_data;
+ wmesh_service *service = (wmesh_service *)user_data;
NOTUSED(name);
- meshd_dbus_object = net_mesh_skeleton_new();
+ meshd_dbus_object = net_wmesh_skeleton_new();
if (NULL == meshd_dbus_object) {
- MESH_LOGE("net_mesh_skeleton_new() Fail");
+ WMESH_LOGE("net_wmesh_skeleton_new() Fail");
return;
}
g_signal_connect(meshd_dbus_object, "handle-scan",
- G_CALLBACK(_meshd_dbus_handle_scan), service);
+ G_CALLBACK(_wmeshd_dbus_handle_scan), service);
g_signal_connect(meshd_dbus_object, "handle-specific-scan",
- G_CALLBACK(_meshd_dbus_handle_specific_scan), service);
+ G_CALLBACK(_wmeshd_dbus_handle_specific_scan), service);
g_signal_connect(meshd_dbus_object, "handle-cancel-scan",
- G_CALLBACK(_meshd_dbus_handle_cancel_scan), service);
+ G_CALLBACK(_wmeshd_dbus_handle_cancel_scan), service);
g_signal_connect(meshd_dbus_object, "handle-get-found-mesh-networks",
- G_CALLBACK(_meshd_dbus_handle_get_found_mesh_networks), service);
+ G_CALLBACK(_wmeshd_dbus_handle_get_found_mesh_networks), service);
g_signal_connect(meshd_dbus_object, "handle-enable-mesh",
- G_CALLBACK(_meshd_dbus_handle_enable_mesh), service);
+ G_CALLBACK(_wmeshd_dbus_handle_enable_mesh), service);
g_signal_connect(meshd_dbus_object, "handle-disable-mesh",
- G_CALLBACK(_meshd_dbus_handle_disable_mesh), service);
+ G_CALLBACK(_wmeshd_dbus_handle_disable_mesh), service);
g_signal_connect(meshd_dbus_object, "handle-is-joined",
- G_CALLBACK(_meshd_dbus_handle_is_joined), service);
+ G_CALLBACK(_wmeshd_dbus_handle_is_joined), service);
g_signal_connect(meshd_dbus_object, "handle-get-joined-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_get_joined_mesh_network), service);
+ G_CALLBACK(_wmeshd_dbus_handle_get_joined_mesh_network), service);
g_signal_connect(meshd_dbus_object, "handle-get-connected-peers",
- G_CALLBACK(_meshd_dbus_handle_get_connected_peers), service);
+ G_CALLBACK(_wmeshd_dbus_handle_get_connected_peers), service);
g_signal_connect(meshd_dbus_object, "handle-set-gate",
- G_CALLBACK(_meshd_dbus_handle_set_gate), service);
+ G_CALLBACK(_wmeshd_dbus_handle_set_gate), service);
g_signal_connect(meshd_dbus_object, "handle-unset-gate",
- G_CALLBACK(_meshd_dbus_handle_unset_gate), service);
+ G_CALLBACK(_wmeshd_dbus_handle_unset_gate), service);
g_signal_connect(meshd_dbus_object, "handle-set-softap",
- G_CALLBACK(_meshd_dbus_handle_set_softap), service);
+ G_CALLBACK(_wmeshd_dbus_handle_set_softap), service);
g_signal_connect(meshd_dbus_object, "handle-enable-softap",
- G_CALLBACK(_meshd_dbus_handle_enable_softap), service);
+ G_CALLBACK(_wmeshd_dbus_handle_enable_softap), service);
g_signal_connect(meshd_dbus_object, "handle-disable-softap",
- G_CALLBACK(_meshd_dbus_handle_disable_softap), service);
+ G_CALLBACK(_wmeshd_dbus_handle_disable_softap), service);
g_signal_connect(meshd_dbus_object, "handle-create-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_create_mesh_network), service);
+ G_CALLBACK(_wmeshd_dbus_handle_create_mesh_network), service);
g_signal_connect(meshd_dbus_object, "handle-connect-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_connect_mesh_network), service);
+ G_CALLBACK(_wmeshd_dbus_handle_connect_mesh_network), service);
g_signal_connect(meshd_dbus_object, "handle-disconnect-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_disconnect_mesh_network), service);
+ G_CALLBACK(_wmeshd_dbus_handle_disconnect_mesh_network), service);
g_signal_connect(meshd_dbus_object, "handle-forget-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_forget_mesh_network), service);
+ G_CALLBACK(_wmeshd_dbus_handle_forget_mesh_network), service);
g_signal_connect(meshd_dbus_object, "handle-set-interfaces",
- G_CALLBACK(_meshd_dbus_handle_set_interfaces), service);
+ G_CALLBACK(_wmeshd_dbus_handle_set_interfaces), service);
g_signal_connect(meshd_dbus_object, "handle-get-station-info",
- G_CALLBACK(_meshd_dbus_handle_get_station_info), service);
+ G_CALLBACK(_wmeshd_dbus_handle_get_station_info), service);
g_signal_connect(meshd_dbus_object, "handle-get-mpath-info",
- G_CALLBACK(_meshd_dbus_handle_get_mpath_info), service);
+ G_CALLBACK(_wmeshd_dbus_handle_get_mpath_info), service);
ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(meshd_dbus_object),
- conn, MESH_DBUS_OBJPATH, &error);
+ conn, WMESH_DBUS_OBJPATH, &error);
if (FALSE == ret) {
- MESH_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
+ WMESH_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
g_error_free(error);
}
- ret = _meshd_dbus_subscribe_name_owner_changed(conn);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("_meshd_dbus_subscribe_name_owner_changed() Fail(%d)", ret);
+ ret = _wmeshd_dbus_subscribe_name_owner_changed(conn);
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("_wmeshd_dbus_subscribe_name_owner_changed() Fail(%d)", ret);
return;
}
}
-static void _meshd_dbus_on_name_lost(GDBusConnection *conn, const gchar *name,
+static void _wmeshd_dbus_on_name_lost(GDBusConnection *conn, const gchar *name,
gpointer user_data)
{
NOTUSED(conn);
NOTUSED(user_data);
- MESH_LOGD("Lost the name %s", name);
+ WMESH_LOGD("Lost the name %s", name);
}
-static void _meshd_dbus_on_name_acquired(GDBusConnection *conn, const gchar *name,
+static void _wmeshd_dbus_on_name_acquired(GDBusConnection *conn, const gchar *name,
gpointer user_data)
{
NOTUSED(conn);
NOTUSED(user_data);
- MESH_LOGD("Acquired the name %s", name);
+ WMESH_LOGD("Acquired the name %s", name);
}
-static gboolean _meshd_dbus_interface_init(mesh_service *service)
+static gboolean _wmeshd_dbus_interface_init(wmesh_service *service)
{
guint id;
guint activation_dbus_id;
- meshd_check_null_ret_error("service", service, FALSE);
+ wmeshd_check_null_ret_error("service", service, FALSE);
id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- MESH_DBUS_INTERFACE,
+ WMESH_DBUS_INTERFACE,
G_BUS_NAME_OWNER_FLAGS_REPLACE,
- _meshd_dbus_on_bus_acquired,
- _meshd_dbus_on_name_acquired,
- _meshd_dbus_on_name_lost,
+ _wmeshd_dbus_on_bus_acquired,
+ _wmeshd_dbus_on_name_acquired,
+ _wmeshd_dbus_on_name_lost,
service,
NULL);
if (0 == id) {
- MESH_LOGE("g_bus_own_name() Fail");
+ WMESH_LOGE("g_bus_own_name() Fail");
return FALSE;
}
/* Get D-Bus owner to activate mesh service daemon */
activation_dbus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- MESH_DBUS_INTERFACE".manager",
+ WMESH_DBUS_INTERFACE".manager",
G_BUS_NAME_OWNER_FLAGS_REPLACE,
- _meshd_dbus_on_activator_bus_acquired,
+ _wmeshd_dbus_on_activator_bus_acquired,
NULL,
NULL,
service,
service->dbus_id = id;
service->activation_dbus_id = activation_dbus_id;
- service->interface_info = g_new0(mesh_interface_s, 1);
+ service->interface_info = g_new0(wmesh_interface_s, 1);
service->scanned_mesh_network = NULL;
/* Initialize DBus sendor logic */
- meshd_dbus_start(service);
+ wmeshd_dbus_start(service);
return TRUE;
}
-static void _meshd_dbus_deinit(mesh_service *service)
+static void _wmeshd_dbus_deinit(wmesh_service *service)
{
- mesh_interface_s *info = NULL;
- meshd_check_null_ret("service", service);
+ wmesh_interface_s *info = NULL;
+ wmeshd_check_null_ret("service", service);
/* De-Initialize DBus sendor logic */
- meshd_dbus_stop(service);
+ wmeshd_dbus_stop(service);
g_bus_unown_name(service->dbus_id);
g_bus_unown_name(service->activation_dbus_id);
info = service->interface_info;
- meshd_check_null_ret("info", info);
+ wmeshd_check_null_ret("info", info);
if (info->bridge_interface)
g_free(info->bridge_interface);
if (info->base_interface)
}
/**< Mesh service interface initialization */
-gboolean meshd_service_interface_init(mesh_service *service)
+gboolean wmeshd_service_interface_init(wmesh_service *service)
{
guint ret;
- meshd_check_null_ret_error("service", service, FALSE);
+ wmeshd_check_null_ret_error("service", service, FALSE);
/* Initialize dbus interface */
- ret = _meshd_dbus_interface_init(service);
+ ret = _wmeshd_dbus_interface_init(service);
if (FALSE == ret) {
- MESH_LOGE("_meshd_dbus_interface_init failed!!!");
+ WMESH_LOGE("_wmeshd_dbus_interface_init failed!!!");
return FALSE;
}
}
/**< Mesh service interface de-initialization */
-void meshd_service_interface_deinit(mesh_service *service)
+void wmeshd_service_interface_deinit(wmesh_service *service)
{
- meshd_check_null_ret("service", service);
+ wmeshd_check_null_ret("service", service);
/* De-initialize dbus interface */
- _meshd_dbus_deinit(service);
+ _wmeshd_dbus_deinit(service);
}
*/
#include <glib.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-service.h"
-mesh_service *meshd_service_new()
+wmesh_service *wmeshd_service_new()
{
- mesh_service *service;
+ wmesh_service *service;
- service = g_malloc0(sizeof(struct _mesh_service));
+ service = g_malloc0(sizeof(struct _wmesh_service));
/* Create g-main loop */
service->main_loop = g_main_loop_new(NULL, FALSE);
if (G_UNLIKELY(NULL == service->main_loop)) {
- MESH_LOGE("g-main loop creation failed!!!");
+ WMESH_LOGE("g-main loop creation failed!!!");
g_free(service);
return NULL;
}
return service;
}
-void meshd_service_free(mesh_service *service)
+void wmeshd_service_free(wmesh_service *service)
{
- meshd_check_null_ret("service", service);
+ wmeshd_check_null_ret("service", service);
/* Unref 'g-main loop' */
if (service->main_loop)
g_free(service);
}
-gboolean meshd_service_run(mesh_service *service)
+gboolean wmeshd_service_run(wmesh_service *service)
{
- meshd_check_null_ret_error("service", service, FALSE);
- meshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
+ wmeshd_check_null_ret_error("service", service, FALSE);
+ wmeshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
g_main_loop_run(service->main_loop);
return TRUE;
}
-gboolean meshd_service_exit(mesh_service *service)
+gboolean wmeshd_service_exit(wmesh_service *service)
{
- meshd_check_null_ret_error("service", service, FALSE);
- meshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
+ wmeshd_check_null_ret_error("service", service, FALSE);
+ wmeshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
g_main_loop_quit(service->main_loop);
#include <sys/types.h>
#include <sys/stat.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
-#include "mesh-softap.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-service.h"
+#include "wmesh-softap.h"
#define MOBILE_AP_WIFI_KEY_MAX_LEN 64 /**< Maximum length of wifi hash key */
if (pass == NULL || salt == NULL || psk == NULL
|| psk_len < (SHA256_DIGEST_LENGTH * 2 + 1)) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (!PKCS5_PBKDF2_HMAC_SHA1(pass, strlen(pass),
salt, strlen((const char *)salt),
PSK_ITERATION_COUNT, sizeof(buf), buf)) {
- MESH_LOGE("Getting psk is failed");
- return MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("Getting psk is failed");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
}
psk[i << 1] = '\0';
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int __config_hostapd(const char *softap_interface, const char *ssid,
if (security != NULL && g_strcmp0(security, "wpa2-psk") == 0) {
ret = __get_psk_hexascii(passphrase,
(const unsigned char *)ssid, key, sizeof(key));
- if (ret != MESHD_ERROR_NONE) {
+ if (ret != WMESHD_ERROR_NONE) {
g_free(conf);
- MESH_LOGE("hex conversion failed");
- return MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("hex conversion failed");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
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 {
- MESH_LOGD("Open connection [%s]", security);
+ WMESH_LOGD("Open connection [%s]", security);
}
fp = fopen(HOSTAPD_MESH_CONF_FILE, "w");
if (NULL == fp) {
- MESH_LOGE("Could not create the file.");
+ WMESH_LOGE("Could not create the file.");
g_free(conf);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
if (conf) {
}
fclose(fp);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int __open_hostapd_intf(const char* softap_interface, int *fd,
struct stat stat_buf;
if (fd == NULL || intf == NULL) {
- MESH_LOGE("fd is NULL");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("fd is NULL");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
*fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (*fd < 0) {
- MESH_LOGE("socket is failed");
- return MESHD_ERROR_OPERATION_FAILED;
+ WMESH_LOGE("socket is failed");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
src.sun_family = AF_UNIX;
unlink(src.sun_path);
if (bind(*fd, (struct sockaddr *)&src, sizeof(src)) < 0) {
- MESH_LOGE("bind is failed");
+ WMESH_LOGE("bind is failed");
close(*fd);
*fd = -1;
unlink(src.sun_path);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
snprintf(ctrl_intf, sizeof(ctrl_intf), "%s/%s",
goto FAIL;
usleep(HOSTAPD_RETRY_DELAY);
}
- MESH_LOGD("Successfully open interface[%s] to hostapd", intf);
+ WMESH_LOGD("Successfully open interface[%s] to hostapd", intf);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
FAIL:
- MESH_LOGE("Cannot make connection to hostapd");
+ WMESH_LOGE("Cannot make connection to hostapd");
close(*fd);
*fd = -1;
unlink(src.sun_path);
- return MESHD_ERROR_OPERATION_FAILED;
+ return WMESHD_ERROR_OPERATION_FAILED;
}
static int __close_hostapd_intf(int *fd)
{
if (fd == NULL) {
- MESH_LOGE("fd is NULL");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("fd is NULL");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
if (*fd > 0)
close(*fd);
*fd = -1;
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int __get_pid_of_hostapd(pid_t *pid)
if (0 == access(file_path, F_OK)) {
fd = fopen(file_path, "r");
if (fd == NULL) {
- MESH_LOGE("Error! Could not open pid file");
- return MESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Error! Could not open pid file");
+ return WMESHD_ERROR_IO_ERROR;
}
} else {
- MESH_LOGE("Error! Could not access pid file");
- return MESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("Error! Could not access pid file");
+ return WMESHD_ERROR_IO_ERROR;
}
errno = 0;
rv = fscanf(fd, "%d", &ret);
if (rv < 0) {
strerror_r(errno, error_buf, 256);
- MESH_LOGE("Error! Failed to read from file, rv:[%d], error:[%s]",
+ WMESH_LOGE("Error! Failed to read from file, rv:[%d], error:[%s]",
rv, error_buf);
fclose(fd);
- return MESHD_ERROR_IO_ERROR;
+ return WMESHD_ERROR_IO_ERROR;
}
*pid = (pid_t)ret;
- MESH_LOGD(" PID: [%d]", ret);
+ WMESH_LOGD(" PID: [%d]", ret);
fclose(fd);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int __terminate_hostapd()
/* Get pid */
ret = __get_pid_of_hostapd(&hostapd_pid);
- if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("There is no hostapd");
- return MESHD_ERROR_NONE;
+ if (WMESHD_ERROR_NONE != ret) {
+ WMESH_LOGE("There is no hostapd");
+ return WMESHD_ERROR_NONE;
}
if (hostapd_pid == 0) {
- MESH_LOGE("There is no hostapd");
- return MESHD_ERROR_NONE;
+ WMESH_LOGE("There is no hostapd");
+ return WMESHD_ERROR_NONE;
}
ret = __close_hostapd_intf(&hostapd_ctrl_fd);
- if (ret != MESHD_ERROR_NONE)
- MESH_LOGE("__close_hostapd_intf is failed");
+ if (ret != WMESHD_ERROR_NONE)
+ WMESH_LOGE("__close_hostapd_intf is failed");
kill(hostapd_pid, SIGTERM);
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
static int __execute_hostapd()
{
pid_t pid = 0;
int status;
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
ret = __get_pid_of_hostapd(&pid);
if (0 != pid) {
- MESH_LOGE("hostapd is running already");
- return MESHD_ERROR_NONE;
+ WMESH_LOGE("hostapd is running already");
+ return WMESHD_ERROR_NONE;
}
pid = fork();
if (pid < 0) {
- MESH_LOGE("fork failed");
- return MESHD_ERROR_IO_ERROR;
+ WMESH_LOGE("fork failed");
+ return WMESHD_ERROR_IO_ERROR;
}
if (pid == 0) {
"-P", HOSTAPD_PID_FILE,
"-ddd", "-B",
(char *)NULL)) {
- MESH_LOGE("execl failed");
+ WMESH_LOGE("execl failed");
}
- MESH_LOGE("Should not get here!");
+ WMESH_LOGE("Should not get here!");
exit(1);
} else {
/* Reap child */
waitpid(pid, &status, 0);
- MESH_LOGD(" child [%d] reaped with status(%d)", pid, status);
+ WMESH_LOGD(" child [%d] reaped with status(%d)", pid, status);
}
- return MESHD_ERROR_NONE;
+ return WMESHD_ERROR_NONE;
}
-int mesh_softap_set_configuration(const char* softap_interface,
+int wmesh_softap_set_configuration(const char* softap_interface,
const char *ssid, const char* mode, int channel, int visibility,
int max_sta, int security, const char* passphrase)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
const char *sec = (security == 0) ? NULL : "wpa2-psk";
int mac_filter = 0;
return ret;
}
-int mesh_softap_enable_softap(const char* softap_interface)
+int wmesh_softap_enable_softap(const char* softap_interface)
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
if (NULL == softap_interface) {
- MESH_LOGE("Invalid parameter");
- return MESHD_ERROR_INVALID_PARAMETER;
+ WMESH_LOGE("Invalid parameter");
+ return WMESHD_ERROR_INVALID_PARAMETER;
}
ret = __execute_hostapd();
- if (ret != MESHD_ERROR_NONE) {
- MESH_LOGE("__execute_hostapd is failed");
- return MESHD_ERROR_OPERATION_FAILED;
+ if (ret != WMESHD_ERROR_NONE) {
+ WMESH_LOGE("__execute_hostapd is failed");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
ret = __open_hostapd_intf(softap_interface,
&hostapd_ctrl_fd, MH_CTRL_INTF);
- if (ret != MESHD_ERROR_NONE) {
- MESH_LOGE("__open_hostapd_intf is failed");
+ if (ret != WMESHD_ERROR_NONE) {
+ WMESH_LOGE("__open_hostapd_intf is failed");
__terminate_hostapd();
}
return ret;
}
-int mesh_softap_disable_softap()
+int wmesh_softap_disable_softap()
{
- int ret = MESHD_ERROR_NONE;
+ int ret = WMESHD_ERROR_NONE;
ret = __terminate_hostapd();
- if (ret != MESHD_ERROR_NONE) {
- MESH_LOGE("__execute_hostapd is failed");
- return MESHD_ERROR_OPERATION_FAILED;
+ if (ret != WMESHD_ERROR_NONE) {
+ WMESH_LOGE("__execute_hostapd is failed");
+ return WMESHD_ERROR_OPERATION_FAILED;
}
return ret;
#include <glib.h>
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
-#include "mesh-service-interface.h"
+#include "wmesh.h"
+#include "wmesh-log.h"
+#include "wmesh-util.h"
+#include "wmesh-service.h"
+#include "wmesh-service-interface.h"
/**< mesh service */
-mesh_service *meshsvc;
+wmesh_service *meshsvc;
int main(int argc, char *argv[])
{
- mesh_service *service = NULL;
+ wmesh_service *service = NULL;
int ret_code = 0;
gboolean ret;
- __MESH_LOG_FUNC_ENTER__;
+ __WMESH_LOG_FUNC_ENTER__;
#if !GLIB_CHECK_VERSION(2, 32, 0)
if (!g_thread_supported())
NOTUSED(argc);
NOTUSED(argv);
- MESH_LOGI("service mainloop start");
+ WMESH_LOGI("service mainloop start");
/* Create mesh service */
- meshsvc = service = meshd_service_new();
+ meshsvc = service = wmeshd_service_new();
/* Initialize mesh service interface layer */
- ret = meshd_service_interface_init(service);
+ ret = wmeshd_service_interface_init(service);
if (G_UNLIKELY(FALSE == ret)) {
- MESH_LOGE("meshd_service_interface_init failed!");
+ WMESH_LOGE("wmeshd_service_interface_init failed!");
goto END;
}
/* Run mesh service */
- ret = meshd_service_run(service);
+ ret = wmeshd_service_run(service);
if (G_UNLIKELY(FALSE == ret)) {
- MESH_LOGE("Run service failed!");
+ WMESH_LOGE("Run service failed!");
ret_code = EXIT_FAILURE;
}
END:
/* Free mesh service */
- meshd_service_interface_deinit(service);
- meshd_service_free(service);
+ wmeshd_service_interface_deinit(service);
+ wmeshd_service_free(service);
meshsvc = NULL;
- __MESH_LOG_FUNC_EXIT__;
+ __WMESH_LOG_FUNC_EXIT__;
return 0;
}