diff --git a/core/hdd/inc/wlan_hdd_assoc.h b/core/hdd/inc/wlan_hdd_assoc.h index 7b691c5552d7..ae18f43187af 100644 --- a/core/hdd/inc/wlan_hdd_assoc.h +++ b/core/hdd/inc/wlan_hdd_assoc.h @@ -424,9 +424,29 @@ QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter, struct csr_roam_info *roam_info, struct bss_description *bss_desc); +/** + * hdd_save_peer() - Save peer MAC address in adapter peer table. + * @sta_ctx: pointer to hdd station context + * @peer_mac_addr: mac address of new peer + * + * This information is passed to iwconfig later. The peer that joined + * last is passed as information to iwconfig. + + * Return: true if success, false otherwise + */ bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, struct qdf_mac_addr *peer_mac_addr); +/** + * hdd_delete_peer() - removes peer from hdd station context peer table + * @sta_ctx: pointer to hdd station context + * @peer_mac_addr: mac address of peer to be deleted + * + * Return: None + */ +void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, + struct qdf_mac_addr *peer_mac_addr); + /** * hdd_roam_deregister_sta() - deregister station * @adapter: pointer to adapter diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index b0dc00f02976..ea1425d7f89e 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -3699,36 +3699,40 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, return QDF_STATUS_SUCCESS; } -/** - * hdd_save_peer() - Save peer MAC address in adapter peer table. - * @sta_ctx: pointer to hdd station context - * @sta_id: station ID - * @peer_mac_addr: mac address of new peer - * - * This information is passed to iwconfig later. The peer that joined - * last is passed as information to iwconfig. - - * Return: true if success, false otherwise - */ bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, struct qdf_mac_addr *peer_mac_addr) { int idx; + struct qdf_mac_addr *mac_addr; for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) { - if (hdd_is_valid_mac_address( - sta_ctx->conn_info.peer_macaddr[idx].bytes)) { + mac_addr = &sta_ctx->conn_info.peer_macaddr[idx]; + if (qdf_is_macaddr_zero(mac_addr)) { hdd_debug("adding peer: %pM at idx: %d", peer_mac_addr, idx); - qdf_copy_macaddr( - &sta_ctx->conn_info.peer_macaddr[idx], - peer_mac_addr); + qdf_copy_macaddr(mac_addr, peer_mac_addr); return true; } } + return false; } +void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, + struct qdf_mac_addr *peer_mac_addr) +{ + int i; + struct qdf_mac_addr *mac_addr; + + for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) { + mac_addr = &sta_ctx->conn_info.peer_macaddr[i]; + if (qdf_is_macaddr_equal(mac_addr, peer_mac_addr)) { + qdf_zero_macaddr(mac_addr); + return; + } + } +} + /** * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter * @adapter: pointer to adapter diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 09d1c3d3f8f7..425422ef4f32 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -777,6 +777,7 @@ void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id) struct hdd_context *hdd_ctx; struct hdd_adapter *adapter; struct hdd_station_ctx *sta_ctx; + struct qdf_mac_addr bc_mac_addr = QDF_MAC_ADDR_BCAST_INIT; hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); if (!hdd_ctx) { @@ -797,6 +798,7 @@ void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id) } hdd_roam_deregister_sta(adapter, adapter->mac_addr); + hdd_delete_peer(sta_ctx, &bc_mac_addr); wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, @@ -922,6 +924,7 @@ void hdd_ndp_peer_departed_handler(uint8_t vdev_id, uint16_t sta_id, } hdd_roam_deregister_sta(adapter, *peer_mac_addr); + hdd_delete_peer(sta_ctx, peer_mac_addr); if (last_peer) { hdd_info("No more ndp peers.");