iwd: Add scan support in access point mode
PATCH 1/1 iwd: Add scan support in access point mode
--- plugins/iwd.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-)
plugins/iwd.c +40 -10
@@ -550,7 +550,7 @@ static int cm_device_disable(struct connman_device *device)return set_device_powered (device, false); } -static void cm_device_scan_cb (DBusMessage *message,void *user_data) +static void cm_device_scan_station_cb (DBusMessage *message,void *user_data) {const char *path = user_data;struct iwd_station *iwds;
@@ -566,22 +566,52 @@ static void cm_device_scan_cb(DBusMessage *message, void *user_data) } } +static void cm_device_scan_ap_cb (DBusMessage *message,void *user_data) +{ +const char *path = user_data; +struct iwd_ap *iwdap; + + iwdap =g_hash_table_lookup (access_points, path); +if (!iwdap) +return ; + +if (dbus_message_get_type (message) ==DBUS_MESSAGE_TYPE_ERROR ) { +const char *dbus_error =dbus_message_get_error_name (message); + +DBG ("%s scan failed: %s" , path, dbus_error); + } +} +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 ; +if (!strcmp (iwdd->mode,"station" )) { +struct iwd_station *iwds; - iwds =g_hash_table_lookup (stations, iwdd->path); -if (!iwds) -return -EIO ; + iwds =g_hash_table_lookup (stations, iwdd->path); +if (!iwds) +return -EIO ; -if (!g_dbus_proxy_method_call (iwds->proxy,"Scan" , -NULL , cm_device_scan_cb,g_strdup (iwds->path), g_free)) -return -EIO ; +if (!g_dbus_proxy_method_call (iwds->proxy,"Scan" , +NULL , cm_device_scan_station_cb, +g_strdup (iwds->path), g_free)) +return -EIO ; + }else if (!strcmp (iwdd->mode,"ap" )) { +struct iwd_ap *iwdap; + + iwdap =g_hash_table_lookup (access_points, iwdd->path); +if (!iwdap) +return -EIO ; + +if (!g_dbus_proxy_method_call (iwdap->proxy,"Scan" , +NULL , cm_device_scan_ap_cb, +g_strdup (iwdap->path), g_free)) +return -EIO ; + }else { +return -EINVAL ; + }return -EINPROGRESS ; }
Signature · 1 line
2.35.1
Daniel,
I tried this patch and still do not get the Pi to scan from connman. I get this error after I first made sure that iwd was connected and could scan for networks.
# connmanctl scan wifi Error /net/connman/technology/wifi: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
These lines show up in the journal when In initiate a scan:
Mar 08 16:32:25 rune64 connmand[423]: src/technology.c:scan() technology 0x55adeadf30 request from :1.87 Mar 08 16:32:25 rune64 connmand[423]: src/device.c:connman_device_request_scan() device 0x55adeae070 err -95 Mar 08 16:32:27 rune64 connmand[423]: src/rtnl.c:rtnl_message()
NEWLINK len 64 type 16 flags 0x0000 seq 0 pid 0
Keith
Quoted 84 lines · Daniel Wagner
--- plugins/iwd.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-)plugins/iwd.c +40
-11@@ -550,7 +550,7 @@ static int cm_device_disable(struct connman_device *device)return set_device_powered (device, false); } -static void cm_device_scan_cb (DBusMessage *message,void *user_data) +static void cm_device_scan_station_cb (DBusMessage *message,void *user_data) {const char *path = user_data;struct iwd_station *iwds;@@ -566,22 +566,52 @@ static void cm_device_scan_cb(DBusMessage *message, void *user_data) } } +static void cm_device_scan_ap_cb (DBusMessage *message,void *user_data) +{ +const char *path = user_data; +struct iwd_ap *iwdap; + + iwdap =g_hash_table_lookup (access_points, path); +if (!iwdap) +return ; + +if (dbus_message_get_type (message) ==DBUS_MESSAGE_TYPE_ERROR ) { +const char *dbus_error =dbus_message_get_error_name (message); + +DBG ("%s scan failed: %s" , path, dbus_error); + } +} +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 ; +if (!strcmp (iwdd->mode,"station" )) { +struct iwd_station *iwds; - iwds =g_hash_table_lookup (stations, iwdd->path); -if (!iwds) -return -EIO ; + iwds =g_hash_table_lookup (stations, iwdd->path); +if (!iwds) +return -EIO ; -if (!g_dbus_proxy_method_call (iwds->proxy,"Scan" , -NULL , cm_device_scan_cb,g_strdup (iwds->path), g_free)) -return -EIO ; +if (!g_dbus_proxy_method_call (iwds->proxy,"Scan" , +NULL , cm_device_scan_station_cb, +g_strdup (iwds->path), g_free)) +return -EIO ; + }else if (!strcmp (iwdd->mode,"ap" )) { +struct iwd_ap *iwdap; + + iwdap =g_hash_table_lookup (access_points, iwdd->path); +if (!iwdap) +return -EIO ; + +if (!g_dbus_proxy_method_call (iwdap->proxy,"Scan" , +NULL , cm_device_scan_ap_cb, +g_strdup (iwdap->path), g_free)) +return -EIO ; + }else { +return -EINVAL ; + }return -EINPROGRESS ; } --2.35.1
Quoted 5 lines · KeithG
I tried this patch and still do not get the Pi to scan from connman. I get this error after I first made sure that iwd was connected and could scan for networks.
# connmanctl scan wifi
I am pretty confident this works, so it's likely a configuration issue.
Quoted 4 lines
Error /net/connman/technology/wifi: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
If you enable the log for the iwd plugin you should see that the scan is triggered. Maybe no response was received, D-Bus policy?
A message that is not in the archive (sent off-list or not yet received): CAG17S_NonoANXzrvAcgUpPbUKx4qXwFb2m3Dx2T3=_8_V1En_A@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Daniel,
I tried it again but with the plugin logging and get the same result. iwctl will scan and show the networks but connmanctl does not. When I tell connmanctl to scan, it takes a long time to return the prompt.
This is the log
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
org.freedesktop.DBus.ObjectManager /
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.Daemon /net/connman/iwd
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.AgentManager /net/connman/iwd
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.p2p.ServiceManager /net/connman/iwd
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.Adapter /net/connman/iwd/0
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:create_adapter()
/net/connman/iwd/0 vendor 'Broadcom Corp.' model 'BCM43438 combo WLAN
and Bluetooth Low Energy (BLE)' powered 1 ad-hoc 1 station 1 ap 1
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.Device /net/connman/iwd/0/3
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:create_device()
adapter /net/connman/iwd/0 name wlan0 address b8:27:eb:xx:xx:xx
powered 1 mode station
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.Station /net/connman/iwd/0/3
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:create_station()
state 'disconnected' connected_network (null) scanning 0
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.SimpleConfiguration /net/connman/iwd/0/3
Mar 09 09:01:18 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.DeviceProvisioning /net/connman/iwd/0/3
Mar 09 09:01:18 rune64 connmand[417]: wlan0 {update} flags 4099 <UP>
Mar 09 09:01:18 rune64 connmand[417]: wlan0 {newlink} index 3 address
B8:27:EB:XX:XX:XX mtu 1500
Mar 09 09:01:18 rune64 connmand[417]: wlan0 {newlink} index 3 operstate 2 <DOWN>
Mar 09 09:01:18 rune64 connmand[417]:
plugins/iwd.c:station_property_change() /net/connman/iwd/0/3 scanning
1
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {update} flags 4098 <DOWN>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 address
B8:27:EB:XX:XX:XX mtu 1500
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 operstate 2 <DOWN>
Mar 09 09:01:19 rune64 connmand[417]: plugins/iwd.c:object_removed()
net.connman.iwd.Station /net/connman/iwd/0/3
Mar 09 09:01:19 rune64 connmand[417]: plugins/iwd.c:object_removed()
net.connman.iwd.SimpleConfiguration /net/connman/iwd/0/3
Mar 09 09:01:19 rune64 connmand[417]: plugins/iwd.c:object_removed()
net.connman.iwd.DeviceProvisioning /net/connman/iwd/0/3
Mar 09 09:01:19 rune64 connmand[417]:
plugins/iwd.c:device_property_change() /net/connman/iwd/0/3 powered 0
Mar 09 09:01:19 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.AccessPoint /net/connman/iwd/0/3
Mar 09 09:01:19 rune64 connmand[417]: plugins/iwd.c:create_ap() started 0
Mar 09 09:01:19 rune64 connmand[417]:
plugins/iwd.c:device_property_change() /net/connman/iwd/0/3 powered 1
Mar 09 09:01:19 rune64 connmand[417]:
plugins/iwd.c:device_property_change() /net/connman/iwd/0/3 mode ap
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {update} flags 4099 <UP>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 address
B8:27:EB:XX:XX:XX mtu 1500
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 operstate 2 <DOWN>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {add} address
192.168.5.1/24 label wlan0 family 2
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {add} route 192.168.5.0 gw
0.0.0.0 scope 253 <LINK>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {update} flags 69635 <UP,LOWER_UP>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 address
B8:27:EB:52:CC:D0 mtu 1500
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3
operstate 5 <DORMANT>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {RX} 0 packets 0 bytes
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {TX} 1 packets 66 bytes
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {update} flags 69699
<UP,RUNNING,LOWER_UP>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 address
B8:27:EB:XX:XX:XX mtu 1500
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 operstate 6 <UP>
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {RX} 0 packets 0 bytes
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {TX} 1 packets 66 bytes
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 address
B8:27:EB:XX:XX:XX mtu 1500
Mar 09 09:01:19 rune64 connmand[417]: wlan0 {newlink} index 3 operstate 6 <UP>
Mar 09 09:01:19 rune64 connmand[417]: plugins/iwd.c:object_added()
net.connman.iwd.AccessPointDiagnostic /net/connman/iwd/0/3
Mar 09 09:01:19 rune64 connmand[417]:plugins/iwd.c:ap_property_change() /net/connman/iwd/0/3 started 1
The dbus config is the one that is part of the connman package from Arch Linux.
# cat /etc/dbus-1/system.d/connman-dbus.conf <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> <busconfig> <policy user="root"> <allow own="net.connman"/> <allow send_destination="net.connman"/> <allow send_interface="net.connman.Agent"/> <allow send_interface="net.connman.Counter"/> <allow send_interface="net.connman.Notification"/> </policy> <policy at_console="true"> <allow send_destination="net.connman"/> </policy> <policy context="default"> <deny send_destination="net.connman"/> </policy> </busconfig> # connmanctl scan wifi Error /net/connman/technology/wifi: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. # connmanctl services *AO Wired ethernet_b827eb079985_cable # connmanctl technologies /net/connman/technology/ethernet Name = Wired Type = ethernet Powered = True Connected = True Tethering = False TetheringFreq = 2412 /net/connman/technology/wifi Name = WiFi Type = wifi Powered = True Connected = False Tethering = False TetheringFreq = 2412
Quoted 5 lines · KeithG
# connmanctl scan wifi Error /net/connman/technology/wifi: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
That might happen because no scan was started. I followed the error message in your last email and saw that we have a bug in the iwd device creation code path. The core already creates a device for use (connman_device_create_from_index()) and we should use this device which is handing in via the probe function.
Also there is a dangerous index lookup via the device name. Needs to be fixed as well.
Quoted 8 lines
# connmanctl services *AO Wired ethernet_b827eb079985_cable # connmanctl technologies /net/connman/technology/ethernet Name = Wired Type = ethernet Powered = True Connected = True
Quoted 8 lines
Tethering = False TetheringFreq = 2412 /net/connman/technology/wifi Name = WiFi Type = wifi Powered = True Connected = False Tethering = False
Here it should be Tethering. How did you set the wifi device into the AP mode? Via iwctl? In this case reset everything and let ConnMan do that.