From 2e1cfcb7f7e63fd2cb1715c43400c48996ba1fcf Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Tue, 29 Aug 2017 16:47:04 +0900 Subject: [PATCH 01/16] Fix issue that not tunring on softap - Recently hostapd path has been changed from /usr/sbin/hostapd to /usr/bin/hostapd So, we also change hostapd path - Make wmeshd use /opt/usr/data/network instead of /opt/var/lib/wmesh Change-Id: Iab7229410d7aa7cae13ce4711651f6d4ba478a67 Signed-off-by: saerome.kim --- packaging/wifi-mesh-manager.spec | 4 ---- src/wmesh-softap.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packaging/wifi-mesh-manager.spec b/packaging/wifi-mesh-manager.spec index 71201de..1eb8997 100644 --- a/packaging/wifi-mesh-manager.spec +++ b/packaging/wifi-mesh-manager.spec @@ -68,10 +68,6 @@ cp wmeshd.service %{buildroot}%{_unitdir}/wmeshd.service %post chmod 755 %{_sbindir}/wmesh.sh -# For configuration files -mkdir -p %TZ_SYS_VAR/lib/wmesh -chown network_fw:network_fw %TZ_SYS_VAR/lib/wmesh - %files %manifest wmeshd.manifest %license LICENSE diff --git a/src/wmesh-softap.c b/src/wmesh-softap.c index eb8198a..296f7ce 100644 --- a/src/wmesh-softap.c +++ b/src/wmesh-softap.c @@ -56,10 +56,10 @@ "deny_mac_file=%s\n" \ "ieee80211n=1\n" #define HOSTAPD_CONF_LEN 1024 -#define HOSTAPD_BIN "/usr/sbin/hostapd" -#define HOSTAPD_DEBUG_FILE "/var/log/mesh_hostapd.log" +#define HOSTAPD_BIN "/usr/bin/hostapd" +#define HOSTAPD_DEBUG_FILE tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "/network/mesh_hostapd.log") #define HOSTAPD_ENTROPY_FILE tzplatform_mkpath(TZ_SYS_VAR, "/lib/misc/hostapd.bin") -#define HOSTAPD_MESH_CONF_FILE tzplatform_mkpath(TZ_SYS_VAR, "/lib/wmesh/mesh_hostapd.conf") +#define HOSTAPD_MESH_CONF_FILE tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "/network/mesh_hostapd.conf") #define HOSTAPD_CTRL_INTF_DIR tzplatform_mkpath(TZ_SYS_RUN, "/hostapd") #define HOSTAPD_PID_FILE tzplatform_mkpath(TZ_SYS_RUN, "/.mesh_hostapd.pid") #define HOSTAPD_ALLOWED_LIST tzplatform_mkpath(TZ_SYS_VAR, "/lib/hostapd/hostapd.accept") -- 2.7.4 From c1d11e19d21f2513712dbfc305b0046cd479044b Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Tue, 29 Aug 2017 14:20:39 +0530 Subject: [PATCH 02/16] Fixed crash when station is removed due to inactive time When station is removed due to inactive time then it is removed from list named "iter" so its corresponding data in "sta_list" becomes dangling pointer which results in crash when "service->station_list" is freed on calling g_list_free_full() Change-Id: Id4d02bf576a2d67e746e3a42cd11ae2665397fc1 Signed-off-by: Saurav Babu --- src/wmesh-peer-monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wmesh-peer-monitor.c b/src/wmesh-peer-monitor.c index 367584f..a95b399 100644 --- a/src/wmesh-peer-monitor.c +++ b/src/wmesh-peer-monitor.c @@ -87,7 +87,7 @@ static int _get_station_info(void *pdata) /* Remove this node from station list in kernel */ wmesh_netlink_del_station_info(info->mesh_interface, item->bssid); /* Remove current linked list */ - iter = g_list_remove(iter, item); + sta_list = g_list_remove(iter, item); /* Send existing node disjoined */ WMESH_LOGE("[%s] disjoined", item->bssid); @@ -116,6 +116,7 @@ static int _get_station_info(void *pdata) g_list_free_full(service->station_list, _on_station_list_destroy); /* Copy new mesh station list */ service->station_list = sta_list; + WMESH_LOGD("station_list length %d", g_list_length(service->station_list)); iter = service->station_list; while (iter) { -- 2.7.4 From 0b2063bd287a2a65e4cec19b928f41bbbf52b1ef Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Tue, 29 Aug 2017 19:04:06 +0530 Subject: [PATCH 03/16] Enable ethernet interface after mesh interface is removed Ethernet is disabled by connmand when mesh interface is removed and ethernet interface was bridged to it. This patch tries to enable ethernet interface again when mesh interface is removed. Change-Id: I83cb59f7775f88c79430758b937e0c356476a418 Signed-off-by: Saurav Babu --- src/wmesh-peer-monitor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wmesh-peer-monitor.c b/src/wmesh-peer-monitor.c index a95b399..bc60ff2 100644 --- a/src/wmesh-peer-monitor.c +++ b/src/wmesh-peer-monitor.c @@ -259,5 +259,10 @@ int wmesh_stop_monitor_service(void *pdata) } WMESH_LOGD("Peer Monitoring Service Stopped"); + + /* After mesh interface is removed then ethernet is disabled when ethernet + * interface is bridged, so try to enable ethernet again */ + WMESH_LOGD("Enable ethernet interface"); + wmesh_gdbus_enable_ethernet_interface(service, true); return ret; } -- 2.7.4 From 19ebdee24f0df9dc1e079cda839288d7b0fb598d Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Wed, 6 Sep 2017 14:31:07 +0530 Subject: [PATCH 04/16] Remove mesh station when it becomes inactive This patch removes current logic to send NL80211_CMD_DEL_STATION to kernel from wifi-mesh-manager. Now wifi-mesh-manager will call connman's method MeshRemovePeer to remove inactive peer Change-Id: I2b2a6ffc1f19e45a4e255b9c7604b9f68a550d07 Signed-off-by: Saurav Babu --- include/wmesh-gdbus.h | 1 + include/wmesh-netlink.h | 1 - src/wmesh-gdbus.c | 31 ++++++++++++++++++ src/wmesh-netlink.c | 85 ------------------------------------------------ src/wmesh-peer-monitor.c | 2 +- 5 files changed, 33 insertions(+), 87 deletions(-) diff --git a/include/wmesh-gdbus.h b/include/wmesh-gdbus.h index caa00ec..cb882a4 100644 --- a/include/wmesh-gdbus.h +++ b/include/wmesh-gdbus.h @@ -58,6 +58,7 @@ int wmesh_gdbus_disconnect_network(wmesh_service *service, wmesh_scan_result_s * 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); +int wmesh_gdbus_mesh_remove_peer(wmesh_service *service, char *peer); #ifdef __cplusplus } diff --git a/include/wmesh-netlink.h b/include/wmesh-netlink.h index 4207663..7b1edb6 100644 --- a/include/wmesh-netlink.h +++ b/include/wmesh-netlink.h @@ -23,7 +23,6 @@ int wmesh_netlink_set_mesh_parameter(const char* mesh_if_name, const char* param_name, unsigned int value); 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 wmesh_netlink_get_meshconf_info(wmesh_service *service); diff --git a/src/wmesh-gdbus.c b/src/wmesh-gdbus.c index f1b8321..c8123b3 100644 --- a/src/wmesh-gdbus.c +++ b/src/wmesh-gdbus.c @@ -1300,3 +1300,34 @@ int wmesh_gdbus_set_mesh_gate(wmesh_service *service) return ret; } +int wmesh_gdbus_mesh_remove_peer(wmesh_service *service, char *peer) +{ + GVariant *variant = NULL; + GError *error = NULL; + int ret = WMESHD_ERROR_NONE; + + 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, "MeshRemovePeer", + g_variant_new("(s)", peer), G_DBUS_CALL_FLAGS_NONE, 1, NULL, + &error); + if (variant) { + WMESH_LOGD("Successfully requested. [MeshRemovePeer]"); + } else if (error) { + 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 = WMESHD_ERROR_INVALID_PARAMETER; + g_error_free(error); + } + + return ret; +} + diff --git a/src/wmesh-netlink.c b/src/wmesh-netlink.c index 12a6fa9..a88c6c9 100644 --- a/src/wmesh-netlink.c +++ b/src/wmesh-netlink.c @@ -1508,72 +1508,6 @@ nla_put_failure: return WMESHD_ERROR_OPERATION_FAILED; } -static int _send_nl_del_station_info(const char* if_name, char* peer) -{ - mesh_nl_state state = { - .nl80211_id = -1, - .callback_state = MESH_NL_CALLBACK_FINISHED, - .event_source = 0, - .nl_socket = NULL, - .msg = NULL, - .cb = NULL, - .s_cb = NULL, - .station_list = NULL, - }; - int err = WMESHD_ERROR_NONE; - int device_index = 0; - int ret; - - ret = __initialize_nl80211(&state); - if (WMESHD_ERROR_NONE != ret) { - WMESH_LOGE("Failed to initialize nl80211"); - return ret; - } - - ret = __initialize_netlink_message(&state); - if (WMESHD_ERROR_NONE != ret) { - WMESH_LOGE("Failed to initialize netlink message"); - goto DESTROY; - } - - /* Set command into message */ - genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0, - NLM_F_DUMP, NL80211_CMD_DEL_STATION, 0); - - /* Add attributes into message */ - WMESH_LOGD("Delete a station [%s] with interface [%s]", peer, if_name); - ret = __get_device_index_from_string(if_name, &device_index); - if (WMESHD_ERROR_NONE != ret) { - WMESH_LOGE("Failed to get mesh interface device index"); - err = ret; - goto DESTROY; - } - NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index); - NLA_PUT(state.msg, NL80211_ATTR_MAC, ETH_ALEN, peer); - - /* Send message into kernel */ - ret = nl_send_auto(state.nl_socket, state.msg); - if (ret < 0) { - WMESH_LOGE("Failed to nl_send_auto() [%s](%d)", - nl_geterror(ret), ret); - err = WMESHD_ERROR_OPERATION_FAILED; - goto DESTROY; - } - -DESTROY: - __clean_netlink_message(&state); - __clean_nl80211(&state); - - return err; - -nla_put_failure: - WMESH_LOGE("Failed to message build"); - __clean_netlink_message(&state); - __clean_nl80211(&state); - - return WMESHD_ERROR_OPERATION_FAILED; -} - static int _send_nl_get_mpath_info(const char* if_name, GList **mpath_list) { mesh_nl_state state = { @@ -1838,25 +1772,6 @@ int wmesh_netlink_get_station_info(const char* mesh_if_name, GList **station_lis return ret; } -int wmesh_netlink_del_station_info(const char* mesh_if_name, char *peer) -{ - int ret = WMESHD_ERROR_NONE; - - if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) { - WMESH_LOGE("Invalid parameter [%p]", mesh_if_name); - return WMESHD_ERROR_INVALID_PARAMETER; - } - if (NULL == peer) { - WMESH_LOGE("Invalid parameter [%p]", peer); - return WMESHD_ERROR_INVALID_PARAMETER; - } - - WMESH_LOGD("Del connected station : [%s]", peer); - ret = _send_nl_del_station_info(mesh_if_name, peer); - - return ret; -} - int wmesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list) { int ret = WMESHD_ERROR_NONE; diff --git a/src/wmesh-peer-monitor.c b/src/wmesh-peer-monitor.c index bc60ff2..6949eb5 100644 --- a/src/wmesh-peer-monitor.c +++ b/src/wmesh-peer-monitor.c @@ -85,7 +85,7 @@ static int _get_station_info(void *pdata) /* 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 */ - wmesh_netlink_del_station_info(info->mesh_interface, item->bssid); + wmesh_gdbus_mesh_remove_peer(service, item->bssid); /* Remove current linked list */ sta_list = g_list_remove(iter, item); /* Send existing node disjoined */ -- 2.7.4 From 32d0f3b2cd96ef6ab7d6948d3d57564659e593e4 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Wed, 6 Sep 2017 16:34:53 +0530 Subject: [PATCH 05/16] Fixed issue where station_joined and station_left event was not notified Change-Id: I855b2fa8254a728f5227f6b69b7aefbff865eb2f Signed-off-by: Saurav Babu --- src/wmesh-netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wmesh-netlink.c b/src/wmesh-netlink.c index a88c6c9..4baffba 100644 --- a/src/wmesh-netlink.c +++ b/src/wmesh-netlink.c @@ -1308,22 +1308,24 @@ static int _on_receive_mesh_event(struct nl_msg *msg, void *arg) case NL80211_CMD_NEW_STATION: mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); WMESH_LOGD("[%s] new station [%s]", ifname, macbuf); + wmesh_notify_station_joined((const char*)macbuf); + break; case NL80211_CMD_DEL_STATION: mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); WMESH_LOGD("[%s] del station [%s]", ifname, macbuf); + wmesh_notify_station_left((const char*)macbuf); + break; case NL80211_CMD_NEW_MPATH: mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); WMESH_LOGD("[%s] new mpath [%s]", ifname, macbuf); - wmesh_notify_station_joined((const char*)macbuf); break; case NL80211_CMD_DEL_MPATH: mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); WMESH_LOGD("[%s] del mpath [%s]", ifname, macbuf); - wmesh_notify_station_left((const char*)macbuf); break; default: WMESH_LOGD("event [%d] is not handled", gnlh->cmd); -- 2.7.4 From 80a267beb8b7056eaec779e669abf173e4d172a4 Mon Sep 17 00:00:00 2001 From: Maneesh Jain Date: Tue, 10 Oct 2017 08:55:49 +0530 Subject: [PATCH 06/16] Replace LOGE with WMESH_LOGE Macro Change-Id: Ie984e48b28091eaa47f5b1cb51e811407e617019 Signed-off-by: Maneesh Jain --- src/wmesh-gdbus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/wmesh-gdbus.c diff --git a/src/wmesh-gdbus.c b/src/wmesh-gdbus.c old mode 100644 new mode 100755 index c8123b3..1ffacdd --- a/src/wmesh-gdbus.c +++ b/src/wmesh-gdbus.c @@ -1025,7 +1025,7 @@ static int _wmesh_gdbus_get_mesh_network_property(wmesh_service *service, /* Get properties */ _get_mesh_property(variant, result); } else if (error) { - LOGE("Failed DBus call [%s]", error->message); + WMESH_LOGE("Failed DBus call [%s]", error->message); g_error_free(error); return WMESHD_ERROR_IO_ERROR; } @@ -1108,7 +1108,7 @@ int wmesh_gdbus_set_passphrase(wmesh_service *service, wmesh_scan_result_s *info if (variant) { WMESH_LOGD("Successfully requested. [SetProperty]"); } else if (error) { - LOGE("Failed DBus call [%s]", error->message); + WMESH_LOGE("Failed DBus call [%s]", error->message); g_error_free(error); return WMESHD_ERROR_IO_ERROR; } @@ -1187,7 +1187,7 @@ int wmesh_gdbus_disconnect_network(wmesh_service *service, wmesh_scan_result_s * if (variant) { WMESH_LOGD("Successfully requested. [Disconnect]"); } else if (error) { - LOGE("Failed DBus call [%s]", error->message); + WMESH_LOGE("Failed DBus call [%s]", error->message); g_error_free(error); return WMESHD_ERROR_IO_ERROR; } @@ -1214,7 +1214,7 @@ int wmesh_gdbus_remove_network(wmesh_service *service, wmesh_scan_result_s *info if (variant) { WMESH_LOGD("Successfully requested. [Remove]"); } else if (error) { - LOGE("Failed DBus call [%s]", error->message); + WMESH_LOGE("Failed DBus call [%s]", error->message); g_error_free(error); return WMESHD_ERROR_IO_ERROR; } -- 2.7.4 From a88663aaf9120d5965b6f3bf483e8307eb3d8706 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Wed, 1 Nov 2017 12:29:09 +0530 Subject: [PATCH 07/16] Fixed resource leak in __read_hostapd_config() Change-Id: Ifee5845e3dbed698087b8339ac419f1301d45a11 Signed-off-by: Nishant Chaprana --- packaging/wifi-mesh-manager.spec | 2 +- src/wmesh-softap.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packaging/wifi-mesh-manager.spec b/packaging/wifi-mesh-manager.spec index 1eb8997..3a5e2c8 100644 --- a/packaging/wifi-mesh-manager.spec +++ b/packaging/wifi-mesh-manager.spec @@ -2,7 +2,7 @@ Name: wifi-mesh-manager Summary: Wi-Fi mesh network daemon -Version: 0.0.1 +Version: 0.0.2 Release: 1 Group: Network & Connectivity/Wireless License: Apache-2.0 diff --git a/src/wmesh-softap.c b/src/wmesh-softap.c index 296f7ce..b14f946 100644 --- a/src/wmesh-softap.c +++ b/src/wmesh-softap.c @@ -197,8 +197,10 @@ static int __read_hostapd_config(char **softap_interface, char **ssid, } if (!softap_interface || !ssid || !security || !passphrase || !mode || - !channel || !visibility || !max_sta) + !channel || !visibility || !max_sta) { + fclose(fp); return WMESHD_ERROR_INVALID_PARAMETER; + } *security = 0; @@ -230,6 +232,7 @@ static int __read_hostapd_config(char **softap_interface, char **ssid, } } + fclose(fp); return WMESHD_ERROR_NONE; } -- 2.7.4 From 36774ead2d5701c6e28daa3ed6ee4a2f668c7045 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Mon, 13 Nov 2017 10:28:14 +0530 Subject: [PATCH 08/16] Use MAC address in small letters connmand uses MAC address in small letters so wmesh manager should also use it in small letters for synchronization Change-Id: Ie8caa4470f34c691430a5e7df7084a5e34514e2d Signed-off-by: Saurav Babu --- src/wmesh-netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wmesh-netlink.c b/src/wmesh-netlink.c index 4baffba..fa3df4e 100644 --- a/src/wmesh-netlink.c +++ b/src/wmesh-netlink.c @@ -513,7 +513,7 @@ static void mac_addr_n2a(char *mac_addr, unsigned char *arg) { /* 11:22:33:44:55:66 (Len:17) */ snprintf(mac_addr, MAX_MAC_ADDR_LEN, - "%02X:%02X:%02X:%02X:%02X:%02X", + "%02x:%02x:%02x:%02x:%02x:%02x", arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); } #if defined(NL80211_STA_INFO_CHAIN_SIGNAL) || defined(NL80211_STA_INFO_CHAIN_SIGNAL_AVG) @@ -762,7 +762,7 @@ static int _on_receive_station_info(struct nl_msg *msg, void *arg) /* BSSID */ attr_mac = nla_data(attr_info[NL80211_ATTR_MAC]); - snprintf(mac_addr, MAX_MAC_ADDR_LEN, "%02X:%02X:%02X:%02X:%02X:%02X", + snprintf(mac_addr, MAX_MAC_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", attr_mac[0], attr_mac[1], attr_mac[2], attr_mac[3], attr_mac[4], attr_mac[5]); if_indextoname(nla_get_u32(attr_info[NL80211_ATTR_IFINDEX]), dev); -- 2.7.4 From bec9423c4d574fa6908c558475396b3394a648b8 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Mon, 13 Nov 2017 10:45:22 +0530 Subject: [PATCH 09/16] Use proxy default timeout for g_dbus_proxy_call_sync Change-Id: I225b7781744096ea3380ac03ad783baf3fed7081 Signed-off-by: Saurav Babu --- src/wmesh-gdbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wmesh-gdbus.c b/src/wmesh-gdbus.c index 1ffacdd..2b25c5b 100755 --- a/src/wmesh-gdbus.c +++ b/src/wmesh-gdbus.c @@ -1314,7 +1314,7 @@ int wmesh_gdbus_mesh_remove_peer(wmesh_service *service, char *peer) _gproxy_connman, WMESHD_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_connman, "MeshRemovePeer", - g_variant_new("(s)", peer), G_DBUS_CALL_FLAGS_NONE, 1, NULL, + g_variant_new("(s)", peer), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (variant) { WMESH_LOGD("Successfully requested. [MeshRemovePeer]"); -- 2.7.4 From 9c26f0582f94dff072ca3b9402d18f09458bfe21 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Wed, 15 Nov 2017 10:11:42 +0900 Subject: [PATCH 10/16] Remove 'warning: user network_fw does not exist - using root' warning Change-Id: I775b8a511e103fe093aeb395c182f68f05b6d786 Signed-off-by: saerome kim --- packaging/wifi-mesh-manager.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/wifi-mesh-manager.spec b/packaging/wifi-mesh-manager.spec index 3a5e2c8..e778a6c 100644 --- a/packaging/wifi-mesh-manager.spec +++ b/packaging/wifi-mesh-manager.spec @@ -20,9 +20,11 @@ BuildRequires: pkgconfig(libcrypto) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(capi-network-wifi-manager) BuildRequires: cmake -# if meshd do dhcp instead of connman +# if wmeshd do dhcp instead of connman Requires: net-tools Requires: toybox-symlinks-dhcp +# if image creater dose not know network_fw +Requires: security-config %description Manager for handling Wi-Fi mesh network -- 2.7.4 From 7f012c6483518883356c59411ab309317698a24c Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Wed, 15 Nov 2017 15:53:50 +0530 Subject: [PATCH 11/16] Return if it fails to get softap configurations When we fail to get softap configurations then ssid is still uninitialized and printing it leads to crash Change-Id: If37d271dcc518fd6d8bc3e0a1e55cd271e2f9c17 Signed-off-by: Saurav Babu --- src/wmesh-service-interface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wmesh-service-interface.c b/src/wmesh-service-interface.c index 7eac245..a31f789 100644 --- a/src/wmesh-service-interface.c +++ b/src/wmesh-service-interface.c @@ -667,6 +667,7 @@ static gboolean _wmeshd_dbus_handle_get_softap(NetWmesh *object, WMESH_LOGE("Failed to wmesh_request_get_softap_config [%d]", ret); net_wmesh_complete_get_softap(object, invocation, "", "", 0, 0, 0, 0, "", ret); + return FALSE; } WMESH_LOGD("SSID : %s", ssid); -- 2.7.4 From 224ca076dea5c2012afddd0306181e09346c591b Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Thu, 23 Nov 2017 17:27:34 +0900 Subject: [PATCH 12/16] Fix an error in assigning NL80211_STA_INFO_PLID data to station_info->plid Change-Id: I492f9d9aaa632456a109417b50755dc1f48a8c5d Signed-off-by: saerome.kim --- src/wmesh-netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wmesh-netlink.c b/src/wmesh-netlink.c index fa3df4e..37f8499 100644 --- a/src/wmesh-netlink.c +++ b/src/wmesh-netlink.c @@ -811,7 +811,7 @@ static int _on_receive_station_info(struct nl_msg *msg, void *arg) 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]); + station_info->plid = nla_get_u16(sta_info[NL80211_STA_INFO_PLID]); WMESH_LOGD(" mesh plid:\t%d", station_info->plid); } -- 2.7.4 From be5601bfad0d9fd7303e502c60fecd4ed9cef0ce Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Fri, 17 Nov 2017 21:01:43 +0530 Subject: [PATCH 13/16] Make wmeshd can access sysfs without checking permission wmeshd creates socket and connects to hostapd, it fails when it is not root daemon. This patch makes wmeshd can bypass permission check. Change-Id: I3737b076bc746504102415cb4fd47f35311bc07e Signed-off-by: Saurav Babu --- packaging/wmeshd.service | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packaging/wmeshd.service b/packaging/wmeshd.service index 85015d3..a6b044b 100644 --- a/packaging/wmeshd.service +++ b/packaging/wmeshd.service @@ -11,6 +11,5 @@ BusName=net.wmesh.manager SmackProcessLabel=System ExecStart=/usr/bin/wmeshd CapabilityBoundingSet=~CAP_MAC_ADMIN -CapabilityBoundingSet=~CAP_MAC_OVERRIDE -Capabilities=cap_net_admin,cap_net_raw=i +Capabilities=cap_net_admin,cap_net_raw,cap_dac_override=i SecureBits=keep-caps -- 2.7.4 From 49d4bca4f03d6b72d4e201465d993e1b2b3c18d9 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Wed, 29 Nov 2017 15:18:37 +0530 Subject: [PATCH 14/16] wmesh-manager: Provide station type in sta_joined/sta_left signal New Station joined can either be a Mesh Point or a station connected on SoftAP interface. This patch provides station type also along with sta_joined/sta_left signal so that application can identify what type of station joined/left. Change-Id: Ib8a2a97e534c9719ec86d190db87eb8f11537333 Signed-off-by: Saurav Babu --- include/wmesh-netlink.h | 2 +- include/wmesh-request.h | 8 +++++--- include/wmesh.h | 6 ++++++ introspection/wmesh.xml | 2 ++ src/wmesh-netlink.c | 27 ++++++++++++++++++++------- src/wmesh-request.c | 14 ++++++++------ src/wmesh-service-interface.c | 2 +- 7 files changed, 43 insertions(+), 18 deletions(-) diff --git a/include/wmesh-netlink.h b/include/wmesh-netlink.h index 7b1edb6..3e57551 100644 --- a/include/wmesh-netlink.h +++ b/include/wmesh-netlink.h @@ -26,7 +26,7 @@ int wmesh_netlink_get_station_info(const char* mesh_if_name, GList **station_lis int wmesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list); int wmesh_netlink_get_meshconf_info(wmesh_service *service); -int wmesh_netlink_register_event_handler(); +int wmesh_netlink_register_event_handler(wmesh_service *service); int wmesh_netlink_unregister_event_handler(); #endif /* __WMESH_NETLINK_H__ */ diff --git a/include/wmesh-request.h b/include/wmesh-request.h index 61c30b4..7faeb3e 100644 --- a/include/wmesh-request.h +++ b/include/wmesh-request.h @@ -75,15 +75,17 @@ int wmesh_request_get_mpath_info(const char* mesh_interface, GList **mpath_list) /* Mesh Conf */ int wmesh_request_get_meshconf_info(wmesh_service *service); -int wmesh_request_register_event_handler(); +int wmesh_request_register_event_handler(wmesh_service *service); 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); +void wmesh_notify_station_joined(const char* bssid, + wmeshd_station_type_e station_type); +void wmesh_notify_station_left(const char* bssid, + wmeshd_station_type_e station_type); #ifdef __cplusplus } diff --git a/include/wmesh.h b/include/wmesh.h index a9a33d4..e7f2fc4 100644 --- a/include/wmesh.h +++ b/include/wmesh.h @@ -56,6 +56,12 @@ typedef enum { WMESHD_IP_CONFIG_TYPE_STATIC, /**< Static */ } wmeshd_ip_config_type_e; +/**< Internal enum for station type. It should be matched with API side */ +typedef enum { + WMESHD_STATION_TYPE_MESH_POINT = 0, /**< Mesh Point Station Type */ + WMESHD_STATION_TYPE_SOFTAP, /**< SoftAP Station Type */ +} wmeshd_station_type_e; + /**< mesh interface information structure */ typedef struct { gchar *bridge_interface; /**< Bridge name between mesh and others */ diff --git a/introspection/wmesh.xml b/introspection/wmesh.xml index a91ba7e..8a6b8a5 100644 --- a/introspection/wmesh.xml +++ b/introspection/wmesh.xml @@ -147,9 +147,11 @@ + + diff --git a/src/wmesh-netlink.c b/src/wmesh-netlink.c index 37f8499..6e36e71 100644 --- a/src/wmesh-netlink.c +++ b/src/wmesh-netlink.c @@ -1295,7 +1295,8 @@ static int _on_receive_mesh_event(struct nl_msg *msg, void *arg) char ifname[16] = { 0, }; char macbuf[MAX_MAC_ADDR_LEN]; - NOTUSED(arg); + wmesh_service *service = arg; + wmesh_interface_s *info = service->interface_info; nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); @@ -1308,13 +1309,25 @@ static int _on_receive_mesh_event(struct nl_msg *msg, void *arg) case NL80211_CMD_NEW_STATION: mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); WMESH_LOGD("[%s] new station [%s]", ifname, macbuf); - wmesh_notify_station_joined((const char*)macbuf); + + if (g_strcmp0(info->mesh_interface, ifname) == 0) + wmesh_notify_station_joined((const char*)macbuf, + WMESHD_STATION_TYPE_MESH_POINT); + else if (g_strcmp0(info->softap_interface, ifname) == 0) + wmesh_notify_station_joined((const char*)macbuf, + WMESHD_STATION_TYPE_SOFTAP); break; case NL80211_CMD_DEL_STATION: mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); WMESH_LOGD("[%s] del station [%s]", ifname, macbuf); - wmesh_notify_station_left((const char*)macbuf); + + if (g_strcmp0(info->mesh_interface, ifname) == 0) + wmesh_notify_station_left((const char*)macbuf, + WMESHD_STATION_TYPE_MESH_POINT); + else if (g_strcmp0(info->softap_interface, ifname) == 0) + wmesh_notify_station_left((const char*)macbuf, + WMESHD_STATION_TYPE_SOFTAP); break; case NL80211_CMD_NEW_MPATH: @@ -1668,7 +1681,7 @@ nla_put_failure: return WMESHD_ERROR_OPERATION_FAILED; } -static int _send_nl_register_event_handler() +static int _send_nl_register_event_handler(wmesh_service *service) { int err = WMESHD_ERROR_NONE; int ret; @@ -1705,7 +1718,7 @@ static int _send_nl_register_event_handler() /* Set callbacks for event handler */ nl_cb_set(event_state->cb, NL_CB_VALID, NL_CB_CUSTOM, - _on_receive_mesh_event, event_state); + _on_receive_mesh_event, service); /* No sequence checking for multicast messages. */ nl_cb_set(event_state->cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); @@ -1808,12 +1821,12 @@ int wmesh_netlink_get_meshconf_info(wmesh_service *service) return ret; } -int wmesh_netlink_register_event_handler() +int wmesh_netlink_register_event_handler(wmesh_service *service) { int ret = WMESHD_ERROR_NONE; WMESH_LOGD("Register mesh event handler"); - ret = _send_nl_register_event_handler(); + ret = _send_nl_register_event_handler(service); return ret; } diff --git a/src/wmesh-request.c b/src/wmesh-request.c index c4126dd..c975796 100644 --- a/src/wmesh-request.c +++ b/src/wmesh-request.c @@ -284,14 +284,14 @@ int wmesh_request_get_meshconf_info(wmesh_service *service) return WMESHD_ERROR_NONE; } -int wmesh_request_register_event_handler() +int wmesh_request_register_event_handler(wmesh_service *service) { int ret = WMESHD_ERROR_NONE; WMESH_LOGD("Request to register mesh event handler"); /* Get MPath info */ - ret = wmesh_netlink_register_event_handler(); + ret = wmesh_netlink_register_event_handler(service); if (WMESHD_ERROR_NONE != ret) return ret; @@ -649,16 +649,18 @@ void wmesh_notify_connection_state(const char* mesh_id, const char* bssid, net_wmesh_emit_connection_state(object, mesh_id, bssid, channel, (int)sec, (int)state); } -void wmesh_notify_station_joined(const char* bssid) +void wmesh_notify_station_joined(const char* bssid, + wmeshd_station_type_e station_type) { NetWmesh *object = wmeshd_dbus_get_object(); - net_wmesh_emit_sta_joined(object, bssid); + net_wmesh_emit_sta_joined(object, bssid, station_type); } -void wmesh_notify_station_left(const char* bssid) +void wmesh_notify_station_left(const char* bssid, + wmeshd_station_type_e station_type) { NetWmesh *object = wmeshd_dbus_get_object(); - net_wmesh_emit_sta_left(object, bssid); + net_wmesh_emit_sta_left(object, bssid, station_type); } diff --git a/src/wmesh-service-interface.c b/src/wmesh-service-interface.c index a31f789..c56070b 100644 --- a/src/wmesh-service-interface.c +++ b/src/wmesh-service-interface.c @@ -214,7 +214,7 @@ static gboolean _wmeshd_dbus_handle_enable(Manager *object, wmeshd_check_null_ret_error("info", info, FALSE); /* Register event handler first */ - ret = wmesh_request_register_event_handler(); + ret = wmesh_request_register_event_handler(service); if (WMESHD_ERROR_IN_PROGRESS == ret) { WMESH_LOGE("Currently set netlink event handler !! [%d]", ret); ret = WMESHD_ERROR_NONE; -- 2.7.4 From 757adfa03c16f4d6b60a26d832a003b7cf2dfb5f Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Mon, 4 Dec 2017 15:20:20 +0530 Subject: [PATCH 15/16] wmesh-manager: Add support to get softAP station info Change-Id: I5f80e22db61a55a9bacd83a472d478ce5b536001 Signed-off-by: Saurav Babu --- include/wmesh.h | 1 + introspection/wmesh.xml | 1 + src/wmesh-service-interface.c | 69 +++++++++++++++++++++++++++++++------------ 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/include/wmesh.h b/include/wmesh.h index e7f2fc4..67af923 100644 --- a/include/wmesh.h +++ b/include/wmesh.h @@ -201,6 +201,7 @@ typedef struct _wmesh_service { wmesh_meshconf_info_s *meshconf; /**< Mesh Conf */ int netlink_fd; /**< Netlink event socket file descriptor */ int monitor_timer; /**< Timer ID for peer monitoring service */ + GList *softap_station_list; /**< SoftAP station list */ } wmesh_service; #endif /* __WMESH_H__ */ diff --git a/introspection/wmesh.xml b/introspection/wmesh.xml index 8a6b8a5..78b06fd 100644 --- a/introspection/wmesh.xml +++ b/introspection/wmesh.xml @@ -120,6 +120,7 @@ + diff --git a/src/wmesh-service-interface.c b/src/wmesh-service-interface.c index c56070b..3f640b3 100644 --- a/src/wmesh-service-interface.c +++ b/src/wmesh-service-interface.c @@ -831,7 +831,7 @@ static gboolean _wmeshd_dbus_handle_set_interfaces(NetWmesh *object, } static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object, - GDBusMethodInvocation *invocation, + GDBusMethodInvocation *invocation, gint station_type, gpointer user_data) { int ret = WMESHD_ERROR_NONE; @@ -843,12 +843,31 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object, 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; + if (station_type == WMESHD_STATION_TYPE_MESH_POINT) { + /* Clear mesh station list */ + g_list_free_full(service->station_list, _on_station_list_destroy); + service->station_list = NULL; + + ret = wmesh_request_get_station_info( + info->mesh_interface, &service->station_list); + } else if (station_type == WMESHD_STATION_TYPE_SOFTAP) { + /* Clear softAP station list */ + g_list_free_full(service->softap_station_list, + _on_station_list_destroy); + service->softap_station_list = NULL; + + ret = wmesh_request_get_station_info( + info->softap_interface, + &service->softap_station_list); + } else { + WMESH_LOGE("Invalid station type"); + + g_dbus_method_invocation_return_error(invocation, + G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Invalid station type"); + + return FALSE; + } - ret = wmesh_request_get_station_info( - info->mesh_interface, &service->station_list); if (WMESHD_ERROR_NONE != ret) { WMESH_LOGE("Failed to wmesh_request_get_station_info"); @@ -891,7 +910,11 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object, /* Get station information and make variant data */ g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); - iter = service->station_list; + if (station_type == WMESHD_STATION_TYPE_MESH_POINT) + iter = service->station_list; + else + iter = service->softap_station_list; + while (iter != NULL) { wmesh_station_info_s *item = (wmesh_station_info_s*)iter->data; @@ -926,18 +949,20 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object, g_variant_new_uint32(item->tx_bitrate)); /* 10 times */ g_variant_builder_add(&builder, "{sv}", "rx_bitrate", g_variant_new_uint32(item->rx_bitrate)); /* 10 times */ - g_variant_builder_add(&builder, "{sv}", "mesh_llid", - g_variant_new_uint16(item->llid)); - g_variant_builder_add(&builder, "{sv}", "mesh_plid", - g_variant_new_uint16(item->plid)); - g_variant_builder_add(&builder, "{sv}", "mesh_plink", - g_variant_new_byte(item->mesh_plink)); /* 0 : DISCON, 1 : ESTAB */ - g_variant_builder_add(&builder, "{sv}", "local_ps_mode", - g_variant_new_uint32(item->local_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */ - g_variant_builder_add(&builder, "{sv}", "peer_ps_mode", - g_variant_new_uint32(item->peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */ - g_variant_builder_add(&builder, "{sv}", "non_peer_ps_mode", - g_variant_new_uint32(item->non_peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */ + if (station_type == WMESHD_STATION_TYPE_MESH_POINT) { + g_variant_builder_add(&builder, "{sv}", "mesh_llid", + g_variant_new_uint16(item->llid)); + g_variant_builder_add(&builder, "{sv}", "mesh_plid", + g_variant_new_uint16(item->plid)); + g_variant_builder_add(&builder, "{sv}", "mesh_plink", + g_variant_new_byte(item->mesh_plink)); /* 0 : DISCON, 1 : ESTAB */ + g_variant_builder_add(&builder, "{sv}", "local_ps_mode", + g_variant_new_uint32(item->local_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */ + g_variant_builder_add(&builder, "{sv}", "peer_ps_mode", + g_variant_new_uint32(item->peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */ + g_variant_builder_add(&builder, "{sv}", "non_peer_ps_mode", + g_variant_new_uint32(item->non_peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */ + } g_variant_builder_add(&builder, "{sv}", "authorized", g_variant_new_boolean(item->authorized)); g_variant_builder_add(&builder, "{sv}", "associated", @@ -1324,6 +1349,12 @@ static void _wmeshd_dbus_deinit(wmesh_service *service) g_list_free_full(service->station_list, _on_station_list_destroy); service->station_list = NULL; + /* Clear mesh station list */ + if (service->softap_station_list) + g_list_free_full(service->softap_station_list, + _on_station_list_destroy); + service->softap_station_list = NULL; + g_free(service->interface_info); service->interface_info = NULL; } -- 2.7.4 From 4f6e5a34da538581dbabfa1f092db78947abbb94 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Tue, 5 Dec 2017 16:08:06 +0530 Subject: [PATCH 16/16] wmesh-manager: Send authenticated info in get_station_info Change-Id: I96d64d1a42dca95d4f6e8597698004f5fbfedde3 Signed-off-by: Saurav Babu --- src/wmesh-service-interface.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wmesh-service-interface.c b/src/wmesh-service-interface.c index 3f640b3..acb8c6b 100644 --- a/src/wmesh-service-interface.c +++ b/src/wmesh-service-interface.c @@ -965,6 +965,8 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object, } g_variant_builder_add(&builder, "{sv}", "authorized", g_variant_new_boolean(item->authorized)); + g_variant_builder_add(&builder, "{sv}", "authenticated", + g_variant_new_boolean(item->authenticated)); g_variant_builder_add(&builder, "{sv}", "associated", g_variant_new_boolean(item->associated)); g_variant_builder_add(&builder, "{sv}", "preamble", -- 2.7.4