[PATCH] Complete the support of P2P in the 5GHz band
fabienx.marotte at linux.intel.com
fabienx.marotte
Tue Mar 13 10:09:35 PDT 2012
From: Fabien Marotte <fabien.marotte at intel.com>
The 5GHz band was not fully supported in the P2P case.
This patch fixes the P2P code lacks.
Signed-off-by: Fabien Marotte <fabien.marotte at intel.com>
---
src/p2p/p2p_utils.c | 51 ++++++++++++++++++++++++++-------------
wpa_supplicant/p2p_supplicant.c | 29 +++++++++++++---------
2 files changed, 51 insertions(+), 29 deletions(-)
diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index bcc690d..26ad51c 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -49,43 +49,43 @@ int p2p_random(char *buf, size_t len)
static int p2p_channel_to_freq_j4(int reg_class, int channel)
{
/* Table J-4 in P802.11REVmb/D4.0 - Global operating classes */
- /* TODO: more regulatory classes */
switch (reg_class) {
case 81:
/* channels 1..13 */
+ case 83: /* channels 1.. 9; 40 MHz */
+ case 84: /* channels 5..13; 40 MHz */
if (channel < 1 || channel > 13)
return -1;
return 2407 + 5 * channel;
+
case 82:
/* channel 14 */
if (channel != 14)
return -1;
return 2414 + 5 * channel;
- case 83: /* channels 1..9; 40 MHz */
- case 84: /* channels 5..13; 40 MHz */
- if (channel < 1 || channel > 13)
- return -1;
- return 2407 + 5 * channel;
+
case 115: /* channels 36,40,44,48; indoor only */
- case 118: /* channels 52,56,60,64; dfs */
- if (channel < 36 || channel > 64)
- return -1;
- return 5000 + 5 * channel;
- case 124: /* channels 149,153,157,161 */
- case 125: /* channels 149,153,157,161,165,169 */
- if (channel < 149 || channel > 161)
- return -1;
- return 5000 + 5 * channel;
case 116: /* channels 36,44; 40 MHz; indoor only */
case 117: /* channels 40,48; 40 MHz; indoor only */
+ case 118: /* channels 52,56,60,64; dfs */
case 119: /* channels 52,60; 40 MHz; dfs */
case 120: /* channels 56,64; 40 MHz; dfs */
if (channel < 36 || channel > 64)
return -1;
return 5000 + 5 * channel;
+
+ case 121: /* channels 100 .. 140; 20MHz */
+ case 122: /* channels 100 108 116 124 132; 40MHz */
+ case 123: /* channels 104 112 120 128 136; 40Mhz */
+ if ((channel < 100) || (channel > 136))
+ return -1;
+ return 5000 + 5 * channel;
+
+ case 124: /* channels 149,153,157,161 */
+ case 125: /* channels 149,153,157,161,165,169 */
case 126: /* channels 149,157; 40 MHz */
case 127: /* channels 153,161; 40 MHz */
- if (channel < 149 || channel > 161)
+ if (channel < 149 || channel > 169)
return -1;
return 5000 + 5 * channel;
}
@@ -142,7 +142,6 @@ int p2p_channel_to_freq(const char *country, int reg_class, int channel)
int p2p_freq_to_channel(const char *country, unsigned int freq, u8 *reg_class,
u8 *channel)
{
- /* TODO: more operating classes */
if (freq >= 2412 && freq <= 2472) {
*reg_class = 81; /* 2.407 GHz, channels 1..13 */
*channel = (freq - 2407) / 5;
@@ -161,12 +160,30 @@ int p2p_freq_to_channel(const char *country, unsigned int freq, u8 *reg_class,
return 0;
}
+ if (freq >= 5260 && freq <= 5320) {
+ *reg_class = 118; /* 5 GHz, channels 52..64 */
+ *channel = (freq - 5000) / 5;
+ return 0;
+ }
+
+ if (freq >= 5500 && freq <= 5700) {
+ *reg_class = 121; /* 5 GHz, channels 100..140 */
+ *channel = (freq - 5000) / 5;
+ return 0;
+ }
+
if (freq >= 5745 && freq <= 5805) {
*reg_class = 124; /* 5 GHz, channels 149..161 */
*channel = (freq - 5000) / 5;
return 0;
}
+ if (freq >= 5825 && freq <= 5845) {
+ *reg_class = 125; /* 5 GHz, channels 165 169 */
+ *channel = (freq - 5000) / 5;
+ return 0;
+ }
+
return -1;
}
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 486a551..f6aa3b2 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2177,9 +2177,16 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
{ HOSTAPD_MODE_IEEE80211G, 84, 5, 13, 1, BW40MINUS },
#endif
{ HOSTAPD_MODE_IEEE80211A, 115, 36, 48, 4, BW20 },
- { HOSTAPD_MODE_IEEE80211A, 124, 149, 161, 4, BW20 },
{ HOSTAPD_MODE_IEEE80211A, 116, 36, 44, 8, BW40PLUS },
{ HOSTAPD_MODE_IEEE80211A, 117, 40, 48, 8, BW40MINUS },
+ { HOSTAPD_MODE_IEEE80211A, 118, 52, 64, 4, BW20 },
+ { HOSTAPD_MODE_IEEE80211A, 119, 52, 60, 8, BW40PLUS },
+ { HOSTAPD_MODE_IEEE80211A, 120, 56, 64, 8, BW40MINUS },
+ { HOSTAPD_MODE_IEEE80211A, 121, 100, 140, 4, BW20 },
+ { HOSTAPD_MODE_IEEE80211A, 122, 100, 132, 8, BW40PLUS },
+ { HOSTAPD_MODE_IEEE80211A, 123, 104, 136, 8, BW40MINUS },
+ { HOSTAPD_MODE_IEEE80211A, 124, 149, 161, 4, BW20 },
+ { HOSTAPD_MODE_IEEE80211A, 125, 149, 169, 4, BW20 },
{ HOSTAPD_MODE_IEEE80211A, 126, 149, 157, 8, BW40PLUS },
{ HOSTAPD_MODE_IEEE80211A, 127, 153, 161, 8, BW40MINUS },
{ -1, 0, 0, 0, 0, BW20 }
@@ -3126,17 +3133,15 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s,
wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on forced "
"frequency %d MHz", freq);
params->freq = freq;
- } else if (wpa_s->conf->p2p_oper_reg_class == 81 &&
- wpa_s->conf->p2p_oper_channel >= 1 &&
- wpa_s->conf->p2p_oper_channel <= 11) {
- params->freq = 2407 + 5 * wpa_s->conf->p2p_oper_channel;
- wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
- "frequency %d MHz", params->freq);
- } else if (wpa_s->conf->p2p_oper_reg_class == 115 ||
- wpa_s->conf->p2p_oper_reg_class == 124) {
- params->freq = 5000 + 5 * wpa_s->conf->p2p_oper_channel;
- wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
- "frequency %d MHz", params->freq);
+ } else if (wpa_s->conf->p2p_oper_reg_class != 0) {
+ params->freq = p2p_channel_to_freq("XX\x04",
+ wpa_s->conf->p2p_oper_reg_class,
+ wpa_s->conf->p2p_oper_channel);
+ if (params->freq == -1) {
+ params->freq = 2412;
+ wpa_printf(MSG_DEBUG, "P2P: Set GO freq %d MHz"
+ "(Preference invalid)", params->freq);
+ }
} else if (wpa_s->conf->p2p_oper_channel == 0 &&
wpa_s->best_overall_freq > 0 &&
p2p_supported_freq(wpa_s->global->p2p,
--
1.7.0.4
More information about the Hostap
mailing list