wifi: Choose a random channel when opening an ap
PATCH 1/1 wifi: Choose a random channel when opening an ap
When the tethering mode is started, a WiFi ap is created using the fixed channel 1 (2412 MHz). There is no way to configure this channel.
This patch make connman choose a random channel every time the ap is created.
--- plugins/wifi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
plugins/wifi.c +9 -1
@@ -3344,11 +3344,19 @@ static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)if (!ap)return NULL ; +/** +* Choose a random channel in the range 1-11. Channels 12-14 are not +* available worlwide. +* Channels within this range are spaced 5 MHz apart from each other. +*/ +int channel = (rand () %11 ) +1 ; +int freq =2407 + channel *5 ; + ap->mode =G_SUPPLICANT_MODE_MASTER ; ap->ssid = ssid; ap->ssid_len =strlen (ssid); ap->scan_ssid =0 ; - ap->freq =2412 ; + ap->freq = freq;if (!passphrase ||strlen (passphrase) ==0 ) { ap->security =G_SUPPLICANT_SECURITY_NONE ;
Signature · 1 line
2.32.0
Hi Daniel,
Could you have a look to this patch?
I would like to be able to open the WiFi AP on different channel. The simplest way to do it, is to select a random channel, which fit my need. Do you think its acceptable to integrate this way?
I've got also other ideas to achieve the same goal:
- Add an optional channel parameter when opening the AP
- Add a global config to set the channel
- ...
What do you think?
Best regards,
Vivien
Quoted 23 lines · Vivien Henriet
When the tethering mode is started, a WiFi ap is created using the fixed channel 1 (2412 MHz). There is no way to configure this channel.
This patch make connman choose a random channel every time the ap is created.
--- plugins/wifi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)plugins/wifi.c +7
-0@@ -3344,11 +3344,19 @@ static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)if (!ap)return NULL ; +/** +* Choose a random channel in the range 1-11. Channels 12-14 are not +* available worlwide. +* Channels within this range are spaced 5 MHz apart from each other. +*/ +int channel = (rand () %11 ) +1 ; +int freq =2407 + channel *5 ;
plugins/wifi.c static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase) · line 3362
Quoted 10 lines
plugins/wifi.c +2
-1+ ap->mode =G_SUPPLICANT_MODE_MASTER ; ap->ssid = ssid; ap->ssid_len =strlen (ssid); ap->scan_ssid =0 ; - ap->freq =2412 ; + ap->freq = freq;if (!passphrase ||strlen (passphrase) ==0 ) { ap->security =G_SUPPLICANT_SECURITY_NONE ;
------------------ Internet Email Confidentiality Footer ------------------ The information transmitted in this document is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete all copies of the material.
Hi Vivien,
Quoted 3 lines · HENRIET Vivien
Hi Daniel,
Could you have a look to this patch?
Sorry for the delay. Anyway, I think it would be better to make this configurable or smarter instead of a random channel selection. I just checked what iwd is doing and if I got it right, the iwd daemon does the channel selection itself.
Quoted 3 lines
I would like to be able to open the WiFi AP on different channel. The simplest way to do it, is to select a random channel, which fit my need. Do you think its acceptable to integrate this way?
Random channel selection is a bit a wild solution :).
Quoted 2 lines
I've got also other ideas to achieve the same goal:
- Add an optional channel parameter when opening the AP
This is what I would suggest. Alternatively, can't we use some metrics from the last scan to figure out which channel is crowded?
Quoted 1 line
- Add a global config to set the channel
Generally I would like to avoid adding more config option if there is a way to figure it out.
Daniel
Hi Daniel
Quoted 22 lines · Daniel Wagner
Hi Vivien,
Quoted 3 lines · HENRIET Vivien
Hi Daniel,
Could you have a look to this patch?
Sorry for the delay. Anyway, I think it would be better to make this configurable or smarter instead of a random channel selection. I just checked what iwd is doing and if I got it right, the iwd daemon does the channel selection itself.
Quoted 3 lines
I would like to be able to open the WiFi AP on different channel. The simplest way to do it, is to select a random channel, which fit my need. Do you think its acceptable to integrate this way?
Random channel selection is a bit a wild solution :).
Quoted 2 lines
I've got also other ideas to achieve the same goal:
- Add an optional channel parameter when opening the AP
Quoted 8 lines
This is what I would suggest. Alternatively, can't we use some metrics from the last scan to figure out which channel is crowded?
Quoted 1 line
- Add a global config to set the channel
Generally I would like to avoid adding more config option if there is a way to figure it out.
I have sent a patch long time ago in order to add the possibility to set the frequency of
access point. Can I resend?
Michael
Quoted 3 lines
Daniel
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
Hi Michael,
Quoted 6 lines · Michael Nazzareno Trimarchi
Quoted 3 lines
Generally I would like to avoid adding more config option if there is a way to figure it out.
I have sent a patch long time ago in order to add the possibility to set the frequency of access point. Can I resend?
Oh, my bad. Sure please resend.
Thanks,
Daniel
Hi
Quoted 8 lines · Daniel Wagner
Hi Michael,
Quoted 4 lines · Michael Nazzareno Trimarchi
Quoted 3 lines
Generally I would like to avoid adding more config option if there is a way to figure it out.
Quoted 7 lines
Quoted 2 lines
I have sent a patch long time ago in order to add the possibility to set the frequency of access point. Can I resend?
Oh, my bad. Sure please resend.
Thanks,
Daniel
I'm rebasing it. I would like to know if:
ident = technology->tethering_ident;
passphrase = technology->tethering_passphrase;
freq = technology->tethering_freq; __sync_synchronize();
if (!technology->enabled)
return -EACCES;
bridge = __connman_tethering_get_bridge();
if (!bridge)
return -EOPNOTSUPP;
if (technology->type == CONNMAN_SERVICE_TYPE_WIFI &&
(!ident || !passphrase))
return -EINVAL;
for (tech_drivers = technology->driver_list; tech_drivers;
tech_drivers = g_slist_next(tech_drivers)) {
struct connman_technology_driver *driver = tech_drivers->data;
if (!driver || !driver->set_tethering)
continue;
err = driver->set_tethering(technology, ident, passphrase,
bridge, enabled, freq);I can create a function to get
ident = technology->tethering_ident;
passphrase = technology->tethering_passphrase;
freq = technology->tethering_freq;
connman_tethering_get_params(techonology, &ident, &passphrase, &freq);
Michael
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
Quoted 7 lines · Michael Nazzareno Trimarchi
I can create a function to get
ident =
technology->tethering_ident;
passphrase =technology->tethering_passphrase;
freq =technology->tethering_freq;
connman_tethering_get_params(techonology, &ident, &passphrase, &freq);
Yes, that is what I had in mind. We need to retrieve these values from the core/config somehow.
Hi
Quoted 4 lines · Daniel Wagner
Quoted 2 lines · Michael Nazzareno Trimarchi
I can create a function to get
Quoted 8 lines
Quoted 5 lines
ident =
technology->tethering_ident;
passphrase =technology->tethering_passphrase;
freq =technology->tethering_freq;
connman_tethering_get_params(techonology, &ident, &passphrase, &freq);Yes, that is what I had in mind. We need to retrieve these values from the core/config somehow.
I send an RFC in the mailing list just rebase some old patch and adjust a bit to be more complete. I did not
time to test. I need to know if it can be a starting point or not.
Michael
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com