2010-08-16 19:41:38

by Johannes Berg

[permalink] [raw]
Subject: Re: nl80211 scanning from userspace

[adding mailing list back]

On Mon, 2010-08-16 at 15:37 -0400, Christopher Piggott wrote:
> Thanks, I had missed that. I assume I also have to specify the
> interface number for NL80211_CMD_GET_SCAN as well as
> NL80211_CMD_TRIGGER_SCAN, right?
>
> What I get now is a "Success" on the TRIGGER but an "Operation not
> supported" on the GET.

Yes, but if that was the only thing missing you'd also get -EINVAL.
However, GET only supports dumping, you have to see how to do that,
which explains the -EOPNOTSUPP.

johannes



2010-08-16 23:16:10

by Christopher Piggott

[permalink] [raw]
Subject: Re: nl80211 scanning from userspace

Forgive me if this is an obtuse question but why would one use
nl_socket_add_membership, if all that isn't necessary to get back the
scan results?

On Mon, Aug 16, 2010 at 5:55 PM, Christopher Piggott <[email protected]> wrote:
> OHHH. ?I am with you now. ?I looked at driver_nl80211.c and somehow
> had a blind spot ?when it came to message NLM_F_DUMP. ?I see it now,
> and it's sending me back results.
>
> I am tempted to write a slightly higher level API on top of some of
> this, once I understand the semantics of all of this a little better.
> I will search around first and see if any attempts have already been
> made.
>
> Thank you very much for pushing me in the right direction.
>
> --Chris
>
>
> On Mon, Aug 16, 2010 at 5:43 PM, Johannes Berg
> <[email protected]> wrote:
>> On Mon, 2010-08-16 at 17:22 -0400, Christopher Piggott wrote:
>>> It's hard to figure out what's going on sometimes. ?I set up an error handler:
>>>
>>> static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr
>>> *err, void *arg) {
>>> ? ? printf("ERROR %s (%d)\n", strerror(err->error), err->error);
>>> ? ? return NL_SKIP;
>>> }
>>>
>>> which also returns -95 (operation not supported) just as you said.
>>> So, I'll have to figure out what you mean by "dumping."
>>>
>>> I did find this:
>>>
>>> ? ? ? ? mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "scan");
>>>
>>> in iw:event.c and traced it to some code in iw:genl.c, a file that
>>> starts out by commenting "This ought to be provided by libnl". ?That
>>> situation doesn't seem to have changed.
>>>
>>> Is this the area of the code you mean when you say "dump" ? ?That I
>>> need to register myself to receive the scan results?
>>
>> No, you need to use NLM_F_DUMP etc. Really, check wpa_supplicant :)
>>
>> johannes
>>
>>
>

2010-08-16 21:43:46

by Johannes Berg

[permalink] [raw]
Subject: Re: nl80211 scanning from userspace

On Mon, 2010-08-16 at 17:22 -0400, Christopher Piggott wrote:
> It's hard to figure out what's going on sometimes. I set up an error handler:
>
> static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr
> *err, void *arg) {
> printf("ERROR %s (%d)\n", strerror(err->error), err->error);
> return NL_SKIP;
> }
>
> which also returns -95 (operation not supported) just as you said.
> So, I'll have to figure out what you mean by "dumping."
>
> I did find this:
>
> mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "scan");
>
> in iw:event.c and traced it to some code in iw:genl.c, a file that
> starts out by commenting "This ought to be provided by libnl". That
> situation doesn't seem to have changed.
>
> Is this the area of the code you mean when you say "dump" ? That I
> need to register myself to receive the scan results?

No, you need to use NLM_F_DUMP etc. Really, check wpa_supplicant :)

johannes


2010-08-16 21:55:36

by Christopher Piggott

[permalink] [raw]
Subject: Re: nl80211 scanning from userspace

OHHH. I am with you now. I looked at driver_nl80211.c and somehow
had a blind spot when it came to message NLM_F_DUMP. I see it now,
and it's sending me back results.

I am tempted to write a slightly higher level API on top of some of
this, once I understand the semantics of all of this a little better.
I will search around first and see if any attempts have already been
made.

Thank you very much for pushing me in the right direction.

--Chris


On Mon, Aug 16, 2010 at 5:43 PM, Johannes Berg
<[email protected]> wrote:
> On Mon, 2010-08-16 at 17:22 -0400, Christopher Piggott wrote:
>> It's hard to figure out what's going on sometimes. ?I set up an error handler:
>>
>> static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr
>> *err, void *arg) {
>> ? ? printf("ERROR %s (%d)\n", strerror(err->error), err->error);
>> ? ? return NL_SKIP;
>> }
>>
>> which also returns -95 (operation not supported) just as you said.
>> So, I'll have to figure out what you mean by "dumping."
>>
>> I did find this:
>>
>> ? ? ? ? mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "scan");
>>
>> in iw:event.c and traced it to some code in iw:genl.c, a file that
>> starts out by commenting "This ought to be provided by libnl". ?That
>> situation doesn't seem to have changed.
>>
>> Is this the area of the code you mean when you say "dump" ? ?That I
>> need to register myself to receive the scan results?
>
> No, you need to use NLM_F_DUMP etc. Really, check wpa_supplicant :)
>
> johannes
>
>

2010-08-16 21:23:00

by Christopher Piggott

[permalink] [raw]
Subject: Re: nl80211 scanning from userspace

It's hard to figure out what's going on sometimes. I set up an error handler:

static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr
*err, void *arg) {
printf("ERROR %s (%d)\n", strerror(err->error), err->error);
return NL_SKIP;
}

which also returns -95 (operation not supported) just as you said.
So, I'll have to figure out what you mean by "dumping."

I did find this:

mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "scan");

in iw:event.c and traced it to some code in iw:genl.c, a file that
starts out by commenting "This ought to be provided by libnl". That
situation doesn't seem to have changed.

Is this the area of the code you mean when you say "dump" ? That I
need to register myself to receive the scan results?

--C

2010-08-17 08:51:44

by Johannes Berg

[permalink] [raw]
Subject: Re: nl80211 scanning from userspace

On Mon, 2010-08-16 at 19:16 -0400, Christopher Piggott wrote:
> Forgive me if this is an obtuse question but why would one use
> nl_socket_add_membership, if all that isn't necessary to get back the
> scan results?

Well, you want to know when the scan finished, and for that you need to
be in the right group to receive the event when it finishes.

johannes