From 9cb146059167fed467870632444bb7279fcc0d39 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Tue, 22 Aug 2017 18:51:52 +0900 Subject: [PATCH] Fix issue about getting empty bssid, next_hop and iface Change-Id: Ibbedb9788fc61441dd9d6883cf7d508cbdae0674 Signed-off-by: saerome kim --- include/wifi-mesh-internal.h | 8 ++++---- include/wifi-mesh_private.h | 2 +- src/wifi-mesh-dbus.c | 5 +++-- src/wifi-mesh-internal.c | 16 ++++++++-------- test/wifi-mesh-network.c | 29 ++++++++++++++++++----------- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/include/wifi-mesh-internal.h b/include/wifi-mesh-internal.h index 3d966da..5fdcdb9 100644 --- a/include/wifi-mesh-internal.h +++ b/include/wifi-mesh-internal.h @@ -245,7 +245,7 @@ int wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb c * @see wifi_mesh_get_sta_connected_time() * */ -int wifi_mesh_get_sta_bssid(wifi_mesh_station_info_h station, gchar* bssid); +int wifi_mesh_get_sta_bssid(wifi_mesh_station_info_h station, gchar** bssid); /** * @brief Get inactive time of a connected station. @@ -2062,7 +2062,7 @@ int wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *u * @see wifi_mesh_get_mpath_flags() * */ -int wifi_mesh_get_mpath_dest_addr(wifi_mesh_mpath_info_h mpath, gchar* dest_addr); +int wifi_mesh_get_mpath_dest_addr(wifi_mesh_mpath_info_h mpath, gchar** dest_addr); /** * @brief Get a next hop address. @@ -2093,7 +2093,7 @@ int wifi_mesh_get_mpath_dest_addr(wifi_mesh_mpath_info_h mpath, gchar* dest_addr * @see wifi_mesh_get_mpath_flags() * */ -int wifi_mesh_get_mpath_next_hop(wifi_mesh_mpath_info_h mpath, gchar* next_hop); +int wifi_mesh_get_mpath_next_hop(wifi_mesh_mpath_info_h mpath, gchar** next_hop); /** * @brief Get a control interface. @@ -2123,7 +2123,7 @@ int wifi_mesh_get_mpath_next_hop(wifi_mesh_mpath_info_h mpath, gchar* next_hop); * @see wifi_mesh_get_mpath_flags() * */ -int wifi_mesh_get_mpath_iface(wifi_mesh_mpath_info_h mpath, gchar* iface); +int wifi_mesh_get_mpath_iface(wifi_mesh_mpath_info_h mpath, gchar** iface); /** * @brief Get a serial number of the current control packet. diff --git a/include/wifi-mesh_private.h b/include/wifi-mesh_private.h index eea7537..55ba371 100644 --- a/include/wifi-mesh_private.h +++ b/include/wifi-mesh_private.h @@ -121,7 +121,7 @@ struct mesh_station_info_s { }; struct mesh_mpath_dump_s { - gchar dest_addr[MAX_BSSID_LEN]; /**< destination address */ + gchar *dest_addr; /**< destination address */ gchar next_hop[MAX_BSSID_LEN]; /**< next hop address */ gchar iface[IFNAMSIZ]; /**< network interface for mesh */ guint sn; /**< sequence number */ diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c index 6b47305..4930d75 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -1715,8 +1715,9 @@ int _wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void * struct mesh_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s)); while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) { if (strcasecmp(key, "DEST_ADDR") == 0) { - const char *buf = g_variant_get_string(val, &len); - memcpy(mpath->dest_addr, buf, len); + //const char *buf = g_variant_get_string(val, &len); + //memcpy(mpath->dest_addr, buf, len); + mpath->dest_addr = (gchar *)g_variant_get_string(val, &len); LOGE("dest_addr=%s", mpath->dest_addr); } else if (strcasecmp(key, "NEXT_HOP") == 0) { const char *buf = g_variant_get_string(val, &len); diff --git a/src/wifi-mesh-internal.c b/src/wifi-mesh-internal.c index 75d4e5e..8b48797 100644 --- a/src/wifi-mesh-internal.c +++ b/src/wifi-mesh-internal.c @@ -128,7 +128,7 @@ EXPORT_API int wifi_mesh_get_stations_info(wifi_mesh_h handle, } EXPORT_API int wifi_mesh_get_sta_bssid(wifi_mesh_station_info_h station, - gchar* bssid) + gchar** bssid) { int rv = WIFI_MESH_ERROR_NONE; struct mesh_station_info_s *psta = station; @@ -142,7 +142,7 @@ EXPORT_API int wifi_mesh_get_sta_bssid(wifi_mesh_station_info_h station, /* LCOV_EXCL_STOP */ } - bssid = psta->bssid; + *bssid = psta->bssid; return rv; } @@ -791,7 +791,7 @@ EXPORT_API int wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb } EXPORT_API int wifi_mesh_get_mpath_dest_addr(wifi_mesh_mpath_info_h mpath, - gchar* dest_addr) + gchar** dest_addr) { int rv = WIFI_MESH_ERROR_NONE; struct mesh_mpath_dump_s *pdump = mpath; @@ -805,12 +805,12 @@ EXPORT_API int wifi_mesh_get_mpath_dest_addr(wifi_mesh_mpath_info_h mpath, /* LCOV_EXCL_STOP */ } - dest_addr = pdump->dest_addr; + *dest_addr = pdump->dest_addr; return rv; } EXPORT_API int wifi_mesh_get_mpath_next_hop(wifi_mesh_mpath_info_h mpath, - gchar* next_hop) + gchar** next_hop) { int rv = WIFI_MESH_ERROR_NONE; struct mesh_mpath_dump_s *pdump = mpath; @@ -824,12 +824,12 @@ EXPORT_API int wifi_mesh_get_mpath_next_hop(wifi_mesh_mpath_info_h mpath, /* LCOV_EXCL_STOP */ } - next_hop = pdump->next_hop; + *next_hop = pdump->next_hop; return rv; } EXPORT_API int wifi_mesh_get_mpath_iface(wifi_mesh_mpath_info_h mpath, - gchar* iface) + gchar** iface) { int rv = WIFI_MESH_ERROR_NONE; struct mesh_mpath_dump_s *pdump = mpath; @@ -843,7 +843,7 @@ EXPORT_API int wifi_mesh_get_mpath_iface(wifi_mesh_mpath_info_h mpath, /* LCOV_EXCL_STOP */ } - iface = pdump->iface; + *iface = pdump->iface; return rv; } diff --git a/test/wifi-mesh-network.c b/test/wifi-mesh-network.c index f30f104..3faf3bb 100644 --- a/test/wifi-mesh-network.c +++ b/test/wifi-mesh-network.c @@ -52,6 +52,8 @@ static char network_idx[MENU_DATA_SIZE + 1] = "1"; static int g_scan_net_idx = 0; GList *g_found_network_list = NULL; +int g_idx = 0; + static void found_mesh_network_cb(wifi_mesh_network_h network, void* user_data) { int ret; @@ -136,12 +138,12 @@ static void found_station_cb(wifi_mesh_station_info_h station, void* user_data) gboolean short_slot_time; /**< short slot time supported ex) yes */ guint connected_time; /**< connected time : ex) 256 seconds */ - msg("Station Information Received: %p", station); + msgp("[%d] tation Information Received", g_idx++); if (NULL == station) return; - ret = wifi_mesh_get_sta_bssid(station, bssid); + ret = wifi_mesh_get_sta_bssid(station, &bssid); if (WIFI_MESH_ERROR_NONE == ret) msg("bssid = %s", bssid); ret = wifi_mesh_get_sta_inactive_time(station, &inactive_time); @@ -158,10 +160,10 @@ static void found_station_cb(wifi_mesh_station_info_h station, void* user_data) msg("tx_bytes = %lld", tx_bytes); ret = wifi_mesh_get_sta_tx_packets(station, &tx_packets); if (WIFI_MESH_ERROR_NONE == ret) - msg("tx_bytes = %lld", tx_bytes); + msg("tx_packets = %d", tx_packets); ret = wifi_mesh_get_sta_tx_retries(station, &tx_retries); if (WIFI_MESH_ERROR_NONE == ret) - msg("tx_bytes = %lld", tx_bytes); + msg("tx_retries = %d", tx_retries); ret = wifi_mesh_get_sta_tx_failed(station, &tx_failed); if (WIFI_MESH_ERROR_NONE == ret) msg("tx_failed = %d", tx_failed); @@ -250,9 +252,9 @@ static void found_mpath_cb(wifi_mesh_mpath_info_h mpath, void* user_data) { int ret = WIFI_MESH_ERROR_NONE; - gchar dest_addr[MAX_BSSID_LEN]; /**< destination address */ - gchar next_hop[MAX_BSSID_LEN]; /**< next hop address */ - gchar iface[32]; /**< network interface for mesh */ + gchar *dest_addr = NULL; /**< destination address */ + gchar *next_hop = NULL; /**< next hop address */ + gchar *iface = NULL; /**< network interface for mesh */ guint sn; /**< sequence number */ guint metric; /**< metric */ guint qlen; /**< driver queue length */ @@ -261,15 +263,15 @@ static void found_mpath_cb(wifi_mesh_mpath_info_h mpath, void* user_data) guchar discovery_retries; /**< Discovery retries */ guchar flags; /**< Flags */ - msg("Station Information Received: %p", mpath); + msgp("[%d] routing Information Received", g_idx++); - ret = wifi_mesh_get_mpath_dest_addr(mpath, dest_addr); + ret = wifi_mesh_get_mpath_dest_addr(mpath, &dest_addr); if (WIFI_MESH_ERROR_NONE == ret) msg("dest_addr = %s", dest_addr); - ret = wifi_mesh_get_mpath_next_hop(mpath, next_hop); + ret = wifi_mesh_get_mpath_next_hop(mpath, &next_hop); if (WIFI_MESH_ERROR_NONE == ret) msg("next_hop = %s", next_hop); - ret = wifi_mesh_get_mpath_iface(mpath, iface); + ret = wifi_mesh_get_mpath_iface(mpath, &iface); if (WIFI_MESH_ERROR_NONE == ret) msg("iface = %s", iface); ret = wifi_mesh_get_mpath_sn(mpath, &sn); @@ -293,6 +295,7 @@ static void found_mpath_cb(wifi_mesh_mpath_info_h mpath, void* user_data) ret = wifi_mesh_get_mpath_flags(mpath, &flags); if (WIFI_MESH_ERROR_NONE == ret) msg("flags = %d", flags); + msg(""); } #if 0 @@ -767,6 +770,8 @@ static int run_get_station_information(MManager *mm, struct menu_data *menu) int ret; msg("Get Mesh Station Information"); + g_idx = 1; + ret = wifi_mesh_get_stations_info(mesh, found_station_cb, NULL); if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to wifi_mesh_get_stations_info: [%s(0x%X)]", @@ -784,6 +789,8 @@ static int run_get_mpath_information(MManager *mm, struct menu_data *menu) int ret; msg("Get Mesh Path Information"); + g_idx = 1; + ret = wifi_mesh_get_mpath_info(mesh, found_mpath_cb, NULL); if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to wifi_mesh_get_mpath_info: [%s(0x%X)]", -- 2.34.1