wmesh-manager: Provide station type in sta_joined/sta_left signal 64/162164/1
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 29 Nov 2017 09:48:37 +0000 (15:18 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Wed, 29 Nov 2017 09:48:37 +0000 (15:18 +0530)
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 <saurav.babu@samsung.com>
include/wmesh-netlink.h
include/wmesh-request.h
include/wmesh.h
introspection/wmesh.xml
src/wmesh-netlink.c
src/wmesh-request.c
src/wmesh-service-interface.c

index 7b1edb6..3e57551 100644 (file)
@@ -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__ */
index 61c30b4..7faeb3e 100644 (file)
@@ -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
 }
index a9a33d4..e7f2fc4 100644 (file)
@@ -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 */
index a91ba7e..8a6b8a5 100644 (file)
                </signal>\r
                <signal name="sta_joined">\r
                        <arg type="s" name="bssid" direction="out"/>\r
+                       <arg type="i" name="station_type" direction="out"/>\r
                </signal>\r
                <signal name="sta_left">\r
                        <arg type="s" name="bssid" direction="out"/>\r
+                       <arg type="i" name="station_type" direction="out"/>\r
                </signal>\r
        </interface>\r
 </node>\r
index 37f8499..6e36e71 100644 (file)
@@ -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;
 }
index c4126dd..c975796 100644 (file)
@@ -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);
 }
index a31f789..c56070b 100644 (file)
@@ -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;