diff --git a/src/cntlr.c b/src/cntlr.c index 46ab1cf2f3c65124d856a4a29629840860359cc7..d957ac12b536286e03fc43d26b6a7ffbf1f6178c 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -1203,7 +1203,7 @@ static bool cntlr_radio_opclass_expired(struct netif_radio *radio) if (!radio->opclass.entry_num) return true; - if (timestamp_expired(&radio->opclass.entry_time, 120000)) + if (opclass_expired(&radio->opclass, 120)) return true; return false; diff --git a/src/cntlr_map.c b/src/cntlr_map.c index 0f24e09c50ea25893c87952767354fb0d22905fb..086b8ab0464be42bfff2b86899ea139edf9fb9b4 100644 --- a/src/cntlr_map.c +++ b/src/cntlr_map.c @@ -1273,26 +1273,6 @@ static void cntlr_request_bcn_metrics_bsta(struct controller *c, struct sta *s) } } -static uint8_t cntlr_get_opclass_ht20(struct netif_radio *nr, uint8_t channel) -{ - int i, j; - struct opclass_entry *entry; - - for (i = 0; i < nr->opclass.entry_num; i++) { - entry = &nr->opclass.entry[i]; - - if (entry->bandwidth != 20) - continue; - - for (j = 0; j < entry->channel_num; j++) { - if (entry->channel[j].channel == channel) - return entry->id; - } - } - - return 0; /* Not found */ -} - static int cntlr_request_bcn_metrics_sta(struct controller *c, struct sta *s) { struct cmdu_buff *bcn_cmdu; @@ -1325,7 +1305,7 @@ static int cntlr_request_bcn_metrics_sta(struct controller *c, struct sta *s) if (sp->channels_num == 1) { /* won't use channel report */ - opclass = cntlr_get_opclass_ht20(nr, sp->channels[0]); /* /20 */ + opclass = opclass_get_id(&nr->opclass, sp->channels[0], 20); if (!opclass) return -1; channel = sp->channels[0]; @@ -1334,7 +1314,7 @@ static int cntlr_request_bcn_metrics_sta(struct controller *c, struct sta *s) opclass = 0; channel = 255; /* use channel report */ for (i = 0; i < sp->channels_num; i++) { - opc = cntlr_get_opclass_ht20(nr, sp->channels[i]); + opc = opclass_get_id(&nr->opclass, sp->channels[i], 20); if (!opc) continue; op_ch[num_report].opclass = opc; diff --git a/src/utils/opclass.c b/src/utils/opclass.c index 913fec615d8500bd625487686f0b89e8ff97fbaf..55191f9309a1d4a1a5b2aa2dc5f86ea809b56de2 100644 --- a/src/utils/opclass.c +++ b/src/utils/opclass.c @@ -104,6 +104,14 @@ int opclass_add_entry(struct opclass *opclass, struct opclass_entry *new) return ret; } +bool opclass_expired(struct opclass *opclass, uint32_t seconds) +{ + if (timestamp_expired(&opclass->entry_time, seconds * 1000)) + return true; + + return false; +} + void opclass_reset(struct opclass *opclass) { opclass->entry_num = 0; @@ -129,3 +137,23 @@ void opclass_dump(struct opclass *opclass) dbg("<<<\n"); } +uint8_t opclass_get_id(struct opclass *opclass, uint8_t channel, int bandwidth) +{ + struct opclass_entry *entry; + int i, j; + + for (i = 0; i < opclass->entry_num; i++) { + entry = &opclass->entry[i]; + + if (entry->bandwidth != bandwidth) + continue; + + for (j = 0; j < entry->channel_num; j++) { + if (entry->channel[j].channel == channel) + return entry->id; + } + } + + return 0; /* Not found */ +} + diff --git a/src/utils/opclass.h b/src/utils/opclass.h index 35b0586e6724d981b1e63ab46f04dcee1f3fb264..85e5293583be970e89c5eeee54b936ac6c92a9e8 100644 --- a/src/utils/opclass.h +++ b/src/utils/opclass.h @@ -43,7 +43,10 @@ struct opclass_channel *opclass_new_channel(struct opclass_entry *entry); int opclass_add_channel(struct opclass_entry *entry, struct opclass_channel *new); int opclass_add_entry(struct opclass *opclass, struct opclass_entry *new); +bool opclass_expired(struct opclass *opclass, uint32_t seconds); void opclass_reset(struct opclass *opclass); void opclass_dump(struct opclass *opclass); +uint8_t opclass_get_id(struct opclass *opclass, uint8_t channel, int bandwidth); + #endif /* _OPCLASS_H_ */