summaryrefslogtreecommitdiff
path: root/src/p2p/p2p_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p/p2p_utils.c')
-rw-r--r--src/p2p/p2p_utils.c58
1 files changed, 15 insertions, 43 deletions
diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index f32751d79ca8b..2e2aa8ad06f08 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -9,6 +9,7 @@
#include "includes.h"
#include "common.h"
+#include "common/defs.h"
#include "common/ieee802_11_common.h"
#include "p2p_i.h"
@@ -67,50 +68,11 @@ int p2p_channel_to_freq(int op_class, int channel)
*/
int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel)
{
- /* TODO: more operating classes */
- if (freq >= 2412 && freq <= 2472) {
- if ((freq - 2407) % 5)
- return -1;
-
- *op_class = 81; /* 2.407 GHz, channels 1..13 */
- *channel = (freq - 2407) / 5;
- return 0;
- }
-
- if (freq == 2484) {
- *op_class = 82; /* channel 14 */
- *channel = 14;
- return 0;
- }
-
- if (freq >= 5180 && freq <= 5240) {
- if ((freq - 5000) % 5)
- return -1;
-
- *op_class = 115; /* 5 GHz, channels 36..48 */
- *channel = (freq - 5000) / 5;
- return 0;
- }
-
- if (freq >= 5745 && freq <= 5805) {
- if ((freq - 5000) % 5)
- return -1;
-
- *op_class = 124; /* 5 GHz, channels 149..161 */
- *channel = (freq - 5000) / 5;
- return 0;
- }
-
- if (freq >= 58320 && freq <= 64800) {
- if ((freq - 58320) % 2160)
- return -1;
-
- *op_class = 180; /* 60 GHz, channels 1..4 */
- *channel = (freq - 56160) / 2160;
- return 0;
- }
+ if (ieee80211_freq_to_channel_ext(freq, 0, 0, op_class, channel) ==
+ NUM_HOSTAPD_MODES)
+ return -1;
- return -1;
+ return 0;
}
@@ -497,12 +459,22 @@ int p2p_channels_to_freqs(const struct p2p_channels *channels, int *freq_list,
break;
for (j = 0; j < c->channels; j++) {
int freq;
+ unsigned int k;
+
if (idx + 1 == max_len)
break;
freq = p2p_channel_to_freq(c->reg_class,
c->channel[j]);
if (freq < 0)
continue;
+
+ for (k = 0; k < idx; k++) {
+ if (freq_list[k] == freq)
+ break;
+ }
+
+ if (k < idx)
+ continue;
freq_list[idx++] = freq;
}
}