Adjust variant type / Fix crash on mpath dump
authorJiwan Kim <ji-wan.kim@samsung.com>
Tue, 14 Mar 2017 05:43:35 +0000 (14:43 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
- Adjust GVariant type on station_info
- Change mpath free function instead of g_list_free_full

include/mesh_private.h
src/mesh.c
src/mesh_dbus.c

index 559dd1d..f7d72cf 100644 (file)
@@ -106,17 +106,17 @@ struct mesh_station_info_s {
        guint beacon_loss; /**< beacon loss count ex) 0 */
        guint64 beacon_rx; /**< beacon rx ex) 0 */
        guint64 rx_drop_misc; /**< rx drop misc ex) 0 */
-       gint signal; /**< -64 dBm */
-       gint signal_avg; /**< -63 dBm */
+       gint signal; /**< Signal ex) -64 dBm */
+       gint signal_avg; /**< Average Signal ex) -63 dBm */
        guint tx_bitrate; /**< tx bitrate ex) 54.0 MBit/s => 540 */
        guint rx_bitrate; /**< rx bitrate ex) 5.5 MBit/s => 55 */
-       guint mesh_llid; /**< mesh_llid ex) 51731 */
-       guint mesh_plid; /**< mesh plid ex) 35432 */
+       gushort mesh_llid; /**< mesh_llid ex) 51731 */
+       gushort mesh_plid; /**< mesh plid ex) 35432 */
        guchar mesh_plink; /**< mesh plink ex) ESTAB */
        guint local_ps_mode; /**< mesh local power save mode ex) ACTIVE */
        guint peer_ps_mode;     /**< mesh peer power save mode ex) ACTIVE */
        guint non_peer_ps_mode; /**< mesh non-peer power save mode ex) ACTIVE */
-       gboolean authorized; /**< autorized ex) yes */
+       gboolean authorized; /**< authorized ex) yes */
        gboolean authenticated; /**< authenticated ex) yes */
        gboolean associated; /**< associated ex) yes */
        gboolean preamble; /**< preamble ex) long */
@@ -124,7 +124,7 @@ struct mesh_station_info_s {
        gboolean mfp; /**< MFP ex) no */
        gboolean tdls_peer; /**< TDLS peer ex) no */
        guchar dtim_period; /**< DTIM period ex) 0 */
-       gushort beacon_interval; /**< beacon interbal ex) 1000 */
+       gushort beacon_interval; /**< beacon interval ex) 1000 */
        gboolean cts_protection; /**< CTS protection */
        gboolean short_preamble; /**< short preamble */
        gboolean short_slot_time; /**< short slot time supported ex) yes */
index 428895f..016d4ac 100644 (file)
@@ -564,6 +564,7 @@ EXPORT_API int mesh_add_mesh_network(mesh_h handle, mesh_network_h network)
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER);
 
        rv = _mesh_add_network(handle, network);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
@@ -596,6 +597,7 @@ EXPORT_API int mesh_select_mesh_network(mesh_h handle, mesh_network_h network)
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER);
 
        rv = _mesh_select_network(handle, network);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
@@ -611,6 +613,7 @@ EXPORT_API int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network)
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER);
 
        rv = _mesh_remove_network(handle, network);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
index 4be5395..aca240f 100644 (file)
@@ -362,17 +362,19 @@ struct mesh_mpath_list_s {
 };
 struct mesh_mpath_list_s g_mpath;
 
+#if 0
 static void _mesh_free_mpath(gpointer data)
 {
        struct mesh_mpath_dump_s *mpath = data;
-#if 0
-       g_free(mpath->dest_addr);
-       g_free(mpath->next_hop);
-       g_free(mpath->iface);
-#endif
+
+       //g_free(mpath->dest_addr);
+       //g_free(mpath->next_hop);
+       //g_free(mpath->iface);
+
        g_free(mpath);
        mpath = NULL;
 }
+#endif
 
 static void _mesh_add_mpath(gpointer data)
 {
@@ -382,7 +384,9 @@ static void _mesh_add_mpath(gpointer data)
 
 static void _mesh_remove_mpath()
 {
-       g_list_free_full(g_mpath.list, _mesh_free_mpath);
+       /* If there is no dynamically allocated one, use g_list_free */
+       g_list_free(g_mpath.list);
+       g_mpath.list = NULL;
        g_mpath.count = 0;
 }
 
@@ -1074,10 +1078,10 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_
                                        station.rx_bitrate = g_variant_get_uint32(val);
                                        LOGE("rx_bitrate = %d", station.rx_bitrate);
                                } else if (strcasecmp(key, "mesh_llid") == 0)  {
-                                       station.mesh_llid = g_variant_get_uint32(val);
+                                       station.mesh_llid = g_variant_get_uint16(val);
                                        LOGE("mesh_llid = %d", station.mesh_llid);
                                } else if (strcasecmp(key, "mesh_plid") == 0)  {
-                                       station.mesh_plid = g_variant_get_uint32(val);
+                                       station.mesh_plid = g_variant_get_uint16(val);
                                        LOGE("mesh_plid = %d", station.mesh_plid);
                                } else if (strcasecmp(key, "mesh_plink") == 0)  {
                                        station.mesh_plink = g_variant_get_byte(val);
@@ -1113,7 +1117,7 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_
                                        station.tdls_peer = g_variant_get_boolean(val);
                                        LOGE("tdls_peer = %d", station.tdls_peer);
                                } else if (strcasecmp(key, "DTIM_period") == 0)  {
-                                       station.dtim_period = g_variant_get_boolean(val);
+                                       station.dtim_period = g_variant_get_byte(val);
                                        LOGE("dtim_period = %d", station.dtim_period);
                                } else if (strcasecmp(key, "beacon_interval") == 0)  {
                                        station.beacon_interval = g_variant_get_uint16(val);