connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* Connman Request for feature
@ 2022-12-28 13:52 KeithG
  2023-01-02  8:46 ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: KeithG @ 2022-12-28 13:52 UTC (permalink / raw)
  To: connman

Would it be possible to allow connman to scan for wifi networks when
iwd has been put in ap mode?
We have a headless audio appliance and are currently using connman to
manage all the ethernet connections either cabled or wifi.
When our appliance first boots, it looks for a connected ethernet and
if so it connects and sets itself up. If not, we start hostapd and
start advertising for a user to connect to the ssid. when they
connect, we will display all the available wifi ssids (scanned by
connman) for them to connect it to. If one is selected and the user
puts the correct password in, when it reboots, it connects to the ssid
and is now on the LAN. This is a pretty clean interaction and it works
and is similar to how other IoT devices work.

iwd has the ability to scan for available wifis when it is in ap mode.
Up till recently this did not work for the RPi wireless, but it does
now. I have verified it does work on my Pis.

Set iwd to ap mode and advertise SSID with password.
connect from laptop
then from iwctl, I can scan for other ssids available

Connman will not scan for ssids if iwd is in ap mode.
The difference is that connman will scan for SSIDs if iwd is being
used with connman (wpa_supplicant not installed), and hostapd is
running.
Could the 'scan wifi' command run to query iwd to see if it can scan
for SSIDs even if it is in ap mode?

Keith

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

* Re: Connman Request for feature
  2022-12-28 13:52 Connman Request for feature KeithG
@ 2023-01-02  8:46 ` Daniel Wagner
  2023-01-06  0:10   ` KeithG
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2023-01-02  8:46 UTC (permalink / raw)
  To: KeithG; +Cc: connman

On Wed, Dec 28, 2022 at 07:52:06AM -0600, KeithG wrote:
> Would it be possible to allow connman to scan for wifi networks when
> iwd has been put in ap mode?

As far I can tell, the only thing which prevents the call to iwd to do a scan
is:

static int cm_device_scan(struct connman_device *device,
				struct connman_device_scan_params *params)
{
	struct iwd_device *iwdd = connman_device_get_data(device);
	struct iwd_station *iwds;

	if (strcmp(iwdd->mode, "station"))
		return -EINVAL;

You could drop the test in which mode the device is in and ConnMan
should forward the scan request.

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

* Re: Connman Request for feature
  2023-01-02  8:46 ` Daniel Wagner
@ 2023-01-06  0:10   ` KeithG
  2023-01-06  0:28     ` KeithG
  0 siblings, 1 reply; 8+ messages in thread
From: KeithG @ 2023-01-06  0:10 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

Daniel,

Which file is this so I can make a patch and try it out.

Keith

On Mon, Jan 2, 2023 at 2:46 AM Daniel Wagner <wagi@monom.org> wrote:
>
> On Wed, Dec 28, 2022 at 07:52:06AM -0600, KeithG wrote:
> > Would it be possible to allow connman to scan for wifi networks when
> > iwd has been put in ap mode?
>
> As far I can tell, the only thing which prevents the call to iwd to do a scan
> is:
>
> static int cm_device_scan(struct connman_device *device,
>                                 struct connman_device_scan_params *params)
> {
>         struct iwd_device *iwdd = connman_device_get_data(device);
>         struct iwd_station *iwds;
>
>         if (strcmp(iwdd->mode, "station"))
>                 return -EINVAL;
>
> You could drop the test in which mode the device is in and ConnMan
> should forward the scan request.

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

* Re: Connman Request for feature
  2023-01-06  0:10   ` KeithG
@ 2023-01-06  0:28     ` KeithG
  2023-01-09 17:11       ` Jade Lovelace
  0 siblings, 1 reply; 8+ messages in thread
From: KeithG @ 2023-01-06  0:28 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

Ok, I found it. It is plugins/iwd.c

Would a patch that changes:
        if (strcmp(iwdd->mode, "station"))
to
        if (strcmp(iwdd->mode, "station" || "ap"))

be 'correct'?

On Thu, Jan 5, 2023 at 6:10 PM KeithG <ys3al35l@gmail.com> wrote:
>
> Daniel,
>
> Which file is this so I can make a patch and try it out.
>
> Keith
>
> On Mon, Jan 2, 2023 at 2:46 AM Daniel Wagner <wagi@monom.org> wrote:
> >
> > On Wed, Dec 28, 2022 at 07:52:06AM -0600, KeithG wrote:
> > > Would it be possible to allow connman to scan for wifi networks when
> > > iwd has been put in ap mode?
> >
> > As far I can tell, the only thing which prevents the call to iwd to do a scan
> > is:
> >
> > static int cm_device_scan(struct connman_device *device,
> >                                 struct connman_device_scan_params *params)
> > {
> >         struct iwd_device *iwdd = connman_device_get_data(device);
> >         struct iwd_station *iwds;
> >
> >         if (strcmp(iwdd->mode, "station"))
> >                 return -EINVAL;
> >
> > You could drop the test in which mode the device is in and ConnMan
> > should forward the scan request.

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

* Re: Connman Request for feature
  2023-01-06  0:28     ` KeithG
@ 2023-01-09 17:11       ` Jade Lovelace
  2023-01-09 18:12         ` KeithG
  0 siblings, 1 reply; 8+ messages in thread
From: Jade Lovelace @ 2023-01-09 17:11 UTC (permalink / raw)
  To: KeithG; +Cc: Daniel Wagner, connman

Hi!

That patch would not work. There are a couple of reasons:

The code in question is:
    if (strcmp(iwdd->mode, "station"))
        return -EINVAL;
which will return nonzero if iwdd->mode is *not* "station". That is to
say, if the mode is not station mode, scan attempts will be blocked.
Also, the use of `||` there is operating on the string pointers rather
than the results of the comparison, to unexpected effect.

The patch you need is to delete that check entirely, but in my testing
with the check removed, there is still some other issue there where
somewhere along the line there is an ENOTSUPP returned, which I cannot
debug with rr due to some unsupported ioctl on the rr side. Also, I
got iwd stuck in a weird state where my interface is in AP mode
according to `device list` but `ap wlan0 stop` says it is not in AP
mode.

So you may have more exciting hacking ahead of you. Godspeed.

Jade

On Thu, Jan 5, 2023 at 7:29 PM KeithG <ys3al35l@gmail.com> wrote:
>
> Ok, I found it. It is plugins/iwd.c
>
> Would a patch that changes:
>         if (strcmp(iwdd->mode, "station"))
> to
>         if (strcmp(iwdd->mode, "station" || "ap"))
>
> be 'correct'?
>
> On Thu, Jan 5, 2023 at 6:10 PM KeithG <ys3al35l@gmail.com> wrote:
> >
> > Daniel,
> >
> > Which file is this so I can make a patch and try it out.
> >
> > Keith
> >
> > On Mon, Jan 2, 2023 at 2:46 AM Daniel Wagner <wagi@monom.org> wrote:
> > >
> > > On Wed, Dec 28, 2022 at 07:52:06AM -0600, KeithG wrote:
> > > > Would it be possible to allow connman to scan for wifi networks when
> > > > iwd has been put in ap mode?
> > >
> > > As far I can tell, the only thing which prevents the call to iwd to do a scan
> > > is:
> > >
> > > static int cm_device_scan(struct connman_device *device,
> > >                                 struct connman_device_scan_params *params)
> > > {
> > >         struct iwd_device *iwdd = connman_device_get_data(device);
> > >         struct iwd_station *iwds;
> > >
> > >         if (strcmp(iwdd->mode, "station"))
> > >                 return -EINVAL;
> > >
> > > You could drop the test in which mode the device is in and ConnMan
> > > should forward the scan request.
>

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

* Re: Connman Request for feature
  2023-01-09 17:11       ` Jade Lovelace
@ 2023-01-09 18:12         ` KeithG
  2023-01-16  7:33           ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: KeithG @ 2023-01-09 18:12 UTC (permalink / raw)
  To: Jade Lovelace; +Cc: Daniel Wagner, connman

On Mon, Jan 9, 2023 at 11:12 AM Jade Lovelace <jade@jade.fyi> wrote:
>
> Hi!
>
> That patch would not work. There are a couple of reasons:
>
> The code in question is:
>     if (strcmp(iwdd->mode, "station"))
>         return -EINVAL;
> which will return nonzero if iwdd->mode is *not* "station". That is to
> say, if the mode is not station mode, scan attempts will be blocked.
> Also, the use of `||` there is operating on the string pointers rather
> than the results of the comparison, to unexpected effect.
>
> The patch you need is to delete that check entirely, but in my testing
> with the check removed, there is still some other issue there where
> somewhere along the line there is an ENOTSUPP returned, which I cannot
> debug with rr due to some unsupported ioctl on the rr side. Also, I
> got iwd stuck in a weird state where my interface is in AP mode
> according to `device list` but `ap wlan0 stop` says it is not in AP
> mode.
>
> So you may have more exciting hacking ahead of you. Godspeed.
>
> Jade
>
> On Thu, Jan 5, 2023 at 7:29 PM KeithG <ys3al35l@gmail.com> wrote:
> >
> > Ok, I found it. It is plugins/iwd.c
> >
> > Would a patch that changes:
> >         if (strcmp(iwdd->mode, "station"))
> > to
> >         if (strcmp(iwdd->mode, "station" || "ap"))
> >
> > be 'correct'?
> >
> > On Thu, Jan 5, 2023 at 6:10 PM KeithG <ys3al35l@gmail.com> wrote:
> > >
> > > Daniel,
> > >
> > > Which file is this so I can make a patch and try it out.
> > >
> > > Keith
> > >
> > > On Mon, Jan 2, 2023 at 2:46 AM Daniel Wagner <wagi@monom.org> wrote:
> > > >
> > > > On Wed, Dec 28, 2022 at 07:52:06AM -0600, KeithG wrote:
> > > > > Would it be possible to allow connman to scan for wifi networks when
> > > > > iwd has been put in ap mode?
> > > >
> > > > As far I can tell, the only thing which prevents the call to iwd to do a scan
> > > > is:
> > > >
> > > > static int cm_device_scan(struct connman_device *device,
> > > >                                 struct connman_device_scan_params *params)
> > > > {
> > > >         struct iwd_device *iwdd = connman_device_get_data(device);
> > > >         struct iwd_station *iwds;
> > > >
> > > >         if (strcmp(iwdd->mode, "station"))
> > > >                 return -EINVAL;
> > > >
> > > > You could drop the test in which mode the device is in and ConnMan
> > > > should forward the scan request.
> >
Jade,

Thanks for the hints. I'll have to see if I can make heads and or
tails of this. As you can tell from my first attempt, I am not well
versed in this. I'll see if I can get some help and make a patch. As
it was, I locked up the machine and it wouldn't even connect via
ethernet.

Keith

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

* Re: Connman Request for feature
  2023-01-09 18:12         ` KeithG
@ 2023-01-16  7:33           ` Daniel Wagner
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Wagner @ 2023-01-16  7:33 UTC (permalink / raw)
  To: KeithG; +Cc: Jade Lovelace, connman

On Mon, Jan 09, 2023 at 12:12:28PM -0600, KeithG wrote:
 Thanks for the hints. I'll have to see if I can make heads and or
> tails of this. As you can tell from my first attempt, I am not well
> versed in this. I'll see if I can get some help and make a patch. As
> it was, I locked up the machine and it wouldn't even connect via
> ethernet.

Let me see if I can get quickly a patch for you ready to test. When I looked at
it, it didn't strike me as that complicated to get going (yep, famous last
words).

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

* Connman Request for feature
@ 2022-12-28 15:25 KeithG
  0 siblings, 0 replies; 8+ messages in thread
From: KeithG @ 2022-12-28 15:25 UTC (permalink / raw)
  To: connman

Sent from gmail. Tried to remove formatting. Sorry if this is a duplicate.

Would it be possible to allow connman to scan for wifi networks when
iwd has been put in ap mode?
We have a headless audio appliance and are currently using connman to
manage all the ethernet connections either cabled or wifi.
When our appliance first boots, it looks for a connected ethernet and
if so it connects and sets itself up. If not, we start hostapd and
start advertising for a user to connect to the ssid. when they
connect, we will display all the available wifi ssids (scanned by
connman) for them to connect it to. If one is selected and the user
puts the correct password in, when it reboots, it connects to the ssid
and is now on the LAN. This is a pretty clean interaction and it works
and is similar to how other IoT devices work.

iwd has the ability to scan for available wifis when it is in ap mode.
Up till recently this did not work for the RPi wireless, but it does
now. I have verified it does work on my Pis.

Set iwd to ap mode and advertise SSID with password.
connect from laptop
then from iwctl, I can scan for other ssids available

Connman will not scan for ssids if iwd is in ap mode.
The difference is that connman will scan for SSIDs if iwd is being
used with connman (wpa_supplicant not installed), and hostapd is
running.
Could the 'scan wifi' command run to query iwd to see if it can scan
for SSIDs even if it is in ap mode?

Keith

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

end of thread, other threads:[~2023-01-16  7:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28 13:52 Connman Request for feature KeithG
2023-01-02  8:46 ` Daniel Wagner
2023-01-06  0:10   ` KeithG
2023-01-06  0:28     ` KeithG
2023-01-09 17:11       ` Jade Lovelace
2023-01-09 18:12         ` KeithG
2023-01-16  7:33           ` Daniel Wagner
2022-12-28 15:25 KeithG

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