[PATCH] wpa-cli: Support monitor mode without action file.

Ben Greear greearb at candelatech.com
Tue Apr 17 15:39:47 PDT 2018

On 04/17/2018 03:27 PM, Jouni Malinen wrote:
> On Tue, Apr 17, 2018 at 03:18:02PM -0700, Ben Greear wrote:
>> I do want to receive events, such as notification of when 4-way auth
>> completed so I could know when to start the dhcp client process ('iw event'
>> doesn't seem to offer an event for this, so that is why I was using
>> supplicant).
> So this would be the exact use case that wpa_cli -a<action script> was
> added for..

Well, my 'action' needs to be handled by my big complicated program, so I didn't
think having it call a script was the proper thing to do.

And, just FYI, sometimes at least my hacked wpa_cli stops receiving messages from
the supplicant after a while...restarting wpa_cli fixes things, and debugging
made me think it might be a supplicant issue.  I can detect it easily enough
and restarting wpa_cli was easier than figuring out the real problem so

>> I don't want to poll, as that would be inefficient in my setup where I have
>> lots of virtual stations, so it seemed that wpa_cli in a monitor mode
>> would be a good option, and it seemed less work to tweak wpa_cli than
>> to re-write something similar.
>> Maybe I am missing your point, but how would I use wpa_ctrl.c or wpaspy.py in this
>> case?
> Either use the action script for events like the CONNECTED event (which
> will cover that DHCP client start) or wait for monitor socket events in
> your own application (that would apparently now wait on stdout lines
> from wpa_cli) if you need some messages for debugging purposes where it
> does not make sense to support them with an action script. The latter
> case could use wpa_ctrl.c or wpaspy.py as an helper:
> ctrl = wpa_ctrl_open(..)
> wpa_ctrl_attach(ctrl)
> and then either blocking:
> while (wpa_ctrl_recv(Ctrl, buf, &buflen) == 0) {
>     process..
> }
> or nonblocking:
> fd = wpa_ctrl_get_fd(ctrl)
> select/poll/etc. on fd being readable and run wpa_ctrl_recv()

Ok, that would probably work for me, but at this point, I have already
hacked wpa_cli to work, so might be a while before I get to re-writing


Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

More information about the Hostap mailing list