connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: Choose a random channel when opening an ap
@ 2021-09-23 12:44 Vivien Henriet
  2021-09-29  8:57 ` HENRIET Vivien
  0 siblings, 1 reply; 8+ messages in thread
From: Vivien Henriet @ 2021-09-23 12:44 UTC (permalink / raw)
  To: connman; +Cc: 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(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 578b4be7..936f1750 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -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;
-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-09-23 12:44 [PATCH] wifi: Choose a random channel when opening an ap Vivien Henriet
@ 2021-09-29  8:57 ` HENRIET Vivien
  2021-09-29  9:16   ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: HENRIET Vivien @ 2021-09-29  8:57 UTC (permalink / raw)
  To: wagi; +Cc: connman

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

Le 23/09/2021 à 14:44, Vivien Henriet a écrit :
> 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(-)
>
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index 578b4be7..936f1750 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -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;


------------------ 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-09-29  8:57 ` HENRIET Vivien
@ 2021-09-29  9:16   ` Daniel Wagner
  2021-10-04  6:45     ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2021-09-29  9:16 UTC (permalink / raw)
  To: HENRIET Vivien; +Cc: connman

Hi Vivien,

On Wed, Sep 29, 2021 at 08:57:25AM +0000, HENRIET Vivien wrote:
> 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.

> 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 :).

> 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?

> - 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-09-29  9:16   ` Daniel Wagner
@ 2021-10-04  6:45     ` Michael Nazzareno Trimarchi
  2021-10-04  7:09       ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Nazzareno Trimarchi @ 2021-10-04  6:45 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: HENRIET Vivien, connman

Hi Daniel

On Wed, Sep 29, 2021 at 11:23 AM Daniel Wagner <wagi@monom.org> wrote:
>
> Hi Vivien,
>
> On Wed, Sep 29, 2021 at 08:57:25AM +0000, HENRIET Vivien wrote:
> > 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.
>
> > 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 :).
>
> > 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?
>
> > - 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

> Daniel
>
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-10-04  6:45     ` Michael Nazzareno Trimarchi
@ 2021-10-04  7:09       ` Daniel Wagner
  2021-10-04  7:34         ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2021-10-04  7:09 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: HENRIET Vivien, connman

Hi Michael,

On Mon, Oct 04, 2021 at 08:45:57AM +0200, Michael Nazzareno Trimarchi wrote:
> > 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-10-04  7:09       ` Daniel Wagner
@ 2021-10-04  7:34         ` Michael Nazzareno Trimarchi
  2021-10-04  7:46           ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Nazzareno Trimarchi @ 2021-10-04  7:34 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: HENRIET Vivien, connman

Hi

On Mon, Oct 4, 2021 at 9:09 AM Daniel Wagner <wagi@monom.org> wrote:
>
> Hi Michael,
>
> On Mon, Oct 04, 2021 at 08:45:57AM +0200, Michael Nazzareno Trimarchi wrote:
> > > 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

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




-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-10-04  7:34         ` Michael Nazzareno Trimarchi
@ 2021-10-04  7:46           ` Daniel Wagner
  2021-10-04 21:21             ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2021-10-04  7:46 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: HENRIET Vivien, connman

On 04.10.21 09:34, Michael Nazzareno Trimarchi wrote:
> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wifi: Choose a random channel when opening an ap
  2021-10-04  7:46           ` Daniel Wagner
@ 2021-10-04 21:21             ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Nazzareno Trimarchi @ 2021-10-04 21:21 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: HENRIET Vivien, connman

Hi

On Mon, Oct 4, 2021 at 9:46 AM Daniel Wagner <wagi@monom.org> wrote:
>
> On 04.10.21 09:34, Michael Nazzareno Trimarchi wrote:
> > 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.

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


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-10-04 21:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 12:44 [PATCH] wifi: Choose a random channel when opening an ap Vivien Henriet
2021-09-29  8:57 ` HENRIET Vivien
2021-09-29  9:16   ` Daniel Wagner
2021-10-04  6:45     ` Michael Nazzareno Trimarchi
2021-10-04  7:09       ` Daniel Wagner
2021-10-04  7:34         ` Michael Nazzareno Trimarchi
2021-10-04  7:46           ` Daniel Wagner
2021-10-04 21:21             ` Michael Nazzareno Trimarchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).