From a88663aaf9120d5965b6f3bf483e8307eb3d8706 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Wed, 1 Nov 2017 12:29:09 +0530 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 From 9cac9049d5684fedfb607ea5dee9b892720b6976 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Tue, 5 Dec 2017 16:09:52 +0530 Subject: [PATCH 11/16] wmesh-manager: Define missing station info enums Change-Id: I6fa51b5d7ada92cfc25df7bb2e0224bfdf025e7f Signed-off-by: Saurav Babu --- src/wmesh-netlink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wmesh-netlink.c b/src/wmesh-netlink.c index 6e36e71..e69dad8 100644 --- a/src/wmesh-netlink.c +++ b/src/wmesh-netlink.c @@ -50,6 +50,17 @@ #define BIT(x) (1ULL<<(x)) +#define NL80211_STA_INFO_CHAIN_SIGNAL NL80211_STA_INFO_TX_BYTES64 + 1 +#define NL80211_STA_INFO_CHAIN_SIGNAL_AVG NL80211_STA_INFO_TX_BYTES64 + 2 +#define NL80211_STA_INFO_EXPECTED_THROUGHPUT NL80211_STA_INFO_TX_BYTES64 + 3 +#define NL80211_STA_INFO_RX_DROP_MISC NL80211_STA_INFO_TX_BYTES64 + 4 +#define NL80211_STA_INFO_BEACON_RX NL80211_STA_INFO_TX_BYTES64 + 5 +#define NL80211_STA_INFO_BEACON_SIGNAL_AVG NL80211_STA_INFO_TX_BYTES64 + 6 +#define NL80211_STA_INFO_TID_STATS NL80211_STA_INFO_TX_BYTES64 + 7 + +#define __NL80211_STA_INFO_AFTER_LAST NL80211_STA_INFO_TX_BYTES64 + 8 +#define NL80211_STA_INFO_MAX __NL80211_STA_INFO_AFTER_LAST - 1 + typedef enum { MESH_NL_CALLBACK_FINISHED = 0, MESH_NL_CALLBACK_TRYING, -- 2.7.4 From 9e14a9c02c1aa3c38f9c74a1c6c22a9df4ff49b4 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Thu, 14 Dec 2017 15:31:36 +0900 Subject: [PATCH 12/16] Remove %caps in spec file Due to security policy, it is not allowed to declare %caps in spec. file. Change-Id: I8a3fcbbdabeffb5bb6026b06f961af2379a6d8da Signed-off-by: saerome.kim --- packaging/wifi-mesh-manager.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wifi-mesh-manager.spec b/packaging/wifi-mesh-manager.spec index e778a6c..305c1bf 100644 --- a/packaging/wifi-mesh-manager.spec +++ b/packaging/wifi-mesh-manager.spec @@ -74,7 +74,7 @@ chmod 755 %{_sbindir}/wmesh.sh %manifest wmeshd.manifest %license LICENSE %defattr(-,root,root,-) -%caps(cap_net_raw,cap_net_admin=ei) %attr(750,network_fw,network_fw) %{_bindir}/wmeshd +%attr(750,network_fw,network_fw) %{_bindir}/wmeshd %if %{CHECK_WMESH_PRIVILEGE} == "True" %config %{_sysconfdir}/dbus-1/system.d/wmeshd.conf %endif -- 2.7.4 From 710d3ca0b05e40f7b61b2120b98f12a1f109cf54 Mon Sep 17 00:00:00 2001 From: Taesoo Jun Date: Tue, 19 Dec 2017 14:06:11 +0900 Subject: [PATCH 13/16] Fix memory leak in wmesh_gdbus_create_network() Change-Id: I3a6cafa6876df9af345830669dce00b5884b529c Signed-off-by: Taesoo Jun --- src/wmesh-gdbus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wmesh-gdbus.c b/src/wmesh-gdbus.c index 2b25c5b..96f3557 100755 --- a/src/wmesh-gdbus.c +++ b/src/wmesh-gdbus.c @@ -1077,6 +1077,7 @@ int wmesh_gdbus_create_network(wmesh_service *service, gchar *mesh_id, g_variant_new("(sv)", "MeshCreateNetwork", var_dict), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + g_variant_builder_unref(&builder); if (variant) { WMESH_LOGD("Successfully requested. [MeshCreateNetwork]"); } else if (error) { -- 2.7.4 From 5e14ac19fa3e0f11a3f0e976755b100e5747ec2e Mon Sep 17 00:00:00 2001 From: Taesoo Jun Date: Tue, 19 Dec 2017 14:22:44 +0900 Subject: [PATCH 14/16] Fix illegal memory access with strncpy in wmesh_bridge_set_stp() Change-Id: Ibff94e2325a8b48341a079d9b3e20cf2d63dbfe9 --- src/wmesh-bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wmesh-bridge.c b/src/wmesh-bridge.c index 0a0cd56..20481e8 100644 --- a/src/wmesh-bridge.c +++ b/src/wmesh-bridge.c @@ -243,7 +243,7 @@ int wmesh_bridge_set_stp(const char* bridge_name, bool state) BRCTL_SET_BRIDGE_STP_STATE, stp_state, 0, 0 }; - if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ) { + if (NULL == bridge_name || strlen(bridge_name) > IFNAMSIZ - 1) { WMESH_LOGE("Invalid parameter [%p]", bridge_name); return WMESHD_ERROR_INVALID_PARAMETER; } @@ -256,7 +256,7 @@ int wmesh_bridge_set_stp(const char* bridge_name, bool state) return WMESHD_ERROR_IO_ERROR; } - strncpy(ifr.ifr_name, bridge_name, IFNAMSIZ); + snprintf(ifr.ifr_name, IFNAMSIZ, "%s", bridge_name); ifr.ifr_data = (char *)arg; val = ioctl(br_fd, SIOCDEVPRIVATE, &ifr); -- 2.7.4 From fa12fb9b4b0191cb8be5ffa9edf95a4fd0aff16d Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Tue, 19 Dec 2017 16:58:21 +0900 Subject: [PATCH 15/16] Fix reource leak problem (Prevent) - CID 73163 Change-Id: Ia985e6ff59373c9b14fc168af2e37c0b5057d9b5 Signed-off-by: saerome.kim --- src/wmesh-gdbus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wmesh-gdbus.c b/src/wmesh-gdbus.c index 96f3557..c22d51e 100755 --- a/src/wmesh-gdbus.c +++ b/src/wmesh-gdbus.c @@ -697,6 +697,7 @@ static void _get_joined_network(wmesh_service *service, GVariant *variant) g_free(joined_info->bssid); g_free(joined_info->ipv4_address); g_free(joined_info->ipv4_netmask); + g_free(joined_info); continue; } -- 2.7.4 From ee10cd7aba4494019a26288367b67457686f2b98 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Tue, 19 Dec 2017 18:07:45 +0900 Subject: [PATCH 16/16] Fix Null point dereferences (Prevent) - CID 72904 Change-Id: Ib9a5140de2f0280577c5e444a529dda1b3db3ab6 Signed-off-by: saerome.kim --- src/wmesh-bridge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wmesh-bridge.c b/src/wmesh-bridge.c index 20481e8..7a57f12 100644 --- a/src/wmesh-bridge.c +++ b/src/wmesh-bridge.c @@ -183,9 +183,9 @@ int wmesh_bridge_del_interface(const char* bridge_name, const char* interface) int ret = WMESHD_ERROR_NONE; int val = 0; int br_fd = 0; + int if_index; struct ifreq ifr; - int if_index = if_nametoindex(interface); char str_error[ERROR_MESSAGE_LENGTH]; #if !defined(SIOCBRDELIF) @@ -202,6 +202,8 @@ int wmesh_bridge_del_interface(const char* bridge_name, const char* interface) return WMESHD_ERROR_INVALID_PARAMETER; } + if_index = if_nametoindex(interface); + br_fd = socket(AF_LOCAL, SOCK_STREAM, 0); if (br_fd < 0) { strerror_r(errno, str_error, ERROR_MESSAGE_LENGTH); -- 2.7.4