diff --git a/src/agent_cmdu.c b/src/agent_cmdu.c index c7b2e69efb270b1ff3fd8cf0561d4f1f71af5240..49ea9be173de966053a2d7995c0902780b266eae 100644 --- a/src/agent_cmdu.c +++ b/src/agent_cmdu.c @@ -806,13 +806,8 @@ static int agent_gen_ch_scan_response_all(struct agent *a, struct cmdu_buff *cmd { trace("%s --->\n", __func__); - int i, j, ret; struct wifi_scanres_element *sl; - struct wifi_scanres_opclass_element *op; - struct wifi_scanres_channel_element *ch; - int num_tlv = 0; - int num_bw_20 = 0; - bool results_missing = false; + int i, ret; if (!a || !cmdu || !re) return -1; @@ -828,45 +823,37 @@ static int agent_gen_ch_scan_response_all(struct agent *a, struct cmdu_buff *cmd if (WARN_ON(!sl)) return -1; - do { - /* do: second iteration to send empty TLVs for all supported opc/ch - * pairs in case there were no nbrs cached on any opc/ch pair. - */ - for (i = 0; i < sl->num_opclass; i++) { - op = sl->opclass_scanlist + i; + for (i = 0; i < sl->num_opclass; i++) { + struct wifi_scanres_opclass_element *op; + int j; - if (op->bandwidth != 20) /* caps */ - continue; - else - num_bw_20++; + op = sl->opclass_scanlist + i; - for (j = 0; j < op->num_channels; j++) { - ch = op->channel_scanlist + j; + if (op->bandwidth != 20) /* caps */ + continue; - if (!ch->num_neighbors && !results_missing) - /* report only non-empty results */ - continue; + for (j = 0; j < op->num_channels; j++) { + struct wifi_scanres_channel_element *ch; - ret = agent_gen_ch_scan_response_tlv(a, cmdu, - re->macaddr, op->opclass, - ch, status); + ch = op->channel_scanlist + j; - if (ret) - return ret; - - dbg("|%s:%d| Added Channel Scan Result TLV.\n", - __func__, __LINE__); - num_tlv++; + if (!wifi_opclass_id_channel_supported(&re->opclass, + op->opclass, + ch->channel)) { + /* skip channel(s) not supported */ + continue; } - } - if (!num_tlv) { - dbg("|%s:%d| No Scan Results found.\n", - __func__, __LINE__); - /* do send empty TLVs for all supported opc/ch pairs */ - results_missing = true; + ret = agent_gen_ch_scan_response_tlv(a, cmdu, + re->macaddr, op->opclass, + ch, status); + if (ret) + return ret; + + dbg("|%s:%d| Added Channel Scan Result TLV.\n", + __func__, __LINE__); } - } while (!num_tlv && num_bw_20); + } return 0; } diff --git a/src/agent_map.c b/src/agent_map.c index 25a2c6f0e058c0cdabc2427d027eabd9fa9e479e..cedc3f5d53b6cf7d7b5ebf39236a4385f77728b3 100644 --- a/src/agent_map.c +++ b/src/agent_map.c @@ -5627,6 +5627,18 @@ int handle_channel_scan_request(void *agent, struct cmdu_buff *rx_cmdu, continue; } + if (!(ch_scan_req.mode & SCAN_REQUEST_FRESH_SCAN)) { + dbg("%s: return scan cache for radio:%s\n", __func__, re->name); + if (a->cfg.scan_on_boot_only && + re->scan_state != SCAN_DONE) { + /* Some boot scan results missing yet */ + scan_req->status = CH_SCAN_STATUS_SCAN_NOT_COMPLETED; + } else + scan_req->status = CH_SCAN_STATUS_SUCCESS; + ret = agent_send_ch_scan_response(a, re, scan_req); + continue; + } + if (scan_req->num_opclass <= 0) { dbg("%s: no opclass provided, dropping scan req for radio:"MACFMT"\n", __func__, MAC2STR(scan_req->radio)); @@ -5644,12 +5656,7 @@ int handle_channel_scan_request(void *agent, struct cmdu_buff *rx_cmdu, } /* Do not 'Perform Fresh Scan' */ else if (!(ch_scan_req.mode & SCAN_REQUEST_FRESH_SCAN)) { - if (a->cfg.scan_on_boot_only - && re->scan_state != SCAN_DONE) - /* Some boot scan results missing yet */ - scan_req->status = CH_SCAN_STATUS_SCAN_NOT_COMPLETED; - else - scan_req->status = CH_SCAN_STATUS_SUCCESS; + } /* Check all requested opc/chan pairs supported by radio */ else if (!scan_supported(a, scan_req, re)) {