scan: add scan_bss_get_security
James Prestwood
PATCH 1/7 scan: add scan_bss_get_security
This was already implemented in station but with no dependency on that module at all. AP will need this for a scanning API so its being moved into scan.c.
--- src/scan.c | 17 +++++++++++++++++ src/scan.h | 2 ++ 2 files changed, 19 insertions(+)
src/scan.c +17 -0
@@ -1680,6 +1680,23 @@ int scan_bss_get_rsn_info(const struct scan_bss *bss, struct ie_rsn_info *info)return 0 ; } +int scan_bss_get_security (const struct scan_bss *bss,enum security *security) +{ +int ret; +struct ie_rsn_info info; + + ret =scan_bss_get_rsn_info (bss, &info); +if (ret <0 ) { +if (ret != -ENOENT ) +return ret; + + *security =security_determine (bss->capability,NULL ); + }else + *security =security_determine (bss->capability, &info); + +return 0 ; +} +int scan_bss_rank_compare (const void *a,const void *b,void *user_data) {const struct scan_bss *new_bss = a, *bss = b;
src/scan.h +2 -0
@@ -28,6 +28,7 @@ struct p2p_probe_req;struct p2p_beacon ;struct mmpdu_header ;struct wiphy ; +enum security ;enum scan_state {SCAN_STATE_NOT_RUNNING ,
@@ -161,6 +162,7 @@ void scan_bss_free(struct scan_bss *bss);int scan_bss_rank_compare (const void *a,const void *b,void *user);int scan_bss_get_rsn_info (const struct scan_bss *bss,struct ie_rsn_info *info); +int scan_bss_get_security (const struct scan_bss *bss,enum security *security); struct scan_bss *scan_bss_new_from_probe_req(const struct mmpdu_header *mpdu, const uint8_t *body,
Signature · 1 line
2.34.1
James Prestwood
PATCH 2/7 station: replace station_parse_bss_security
Replaces this with scan_bss_get_security
--- src/station.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
src/station.c +4 -23
@@ -346,25 +346,6 @@ static int bss_signal_strength_compare(const void *a, const void *b, void *user)return (bss->signal_strength > new_bss->signal_strength) ?1 :-1 ; } -static int station_parse_bss_security (struct station *station, -struct scan_bss *bss, -enum security *security_out) -{ -struct ie_rsn_info info; -int r; - - r =scan_bss_get_rsn_info (bss, &info); -if (r <0 ) { -if (r != -ENOENT ) -return r; - - *security_out =security_determine (bss->capability,NULL ); - }else - *security_out =security_determine (bss->capability, &info); - -return 0 ; -} -/* * Returns the network object the BSS was added to or NULL if ignored. */
@@ -400,7 +381,7 @@ static struct network *station_add_seen_bss(struct station *station,return NULL ; } -if (station_parse_bss_security (station, bss, &security) <0 ) +if (scan_bss_get_security (bss, &security) <0 )return NULL ;/* Hidden OWE transition network */
@@ -2315,7 +2296,7 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, memcmp(bss->ssid, hs->ssid, hs->ssid_len)) goto next; -if (station_parse_bss_security (station, bss, &security) <0 ) +if (scan_bss_get_security (bss, &security) <0 ) goto next;if (security != orig_security)
@@ -3457,7 +3438,7 @@ static struct l_dbus_message *station_dbus_get_hidden_access_points(int16_t signal_strength = bss->signal_strength;enum security security; -if (station_parse_bss_security (station, bss, &security) <0 ) +if (scan_bss_get_security (bss, &security) <0 )continue ;l_dbus_message_builder_enter_struct (builder,"sns" );
@@ -4224,7 +4205,7 @@ static struct network *station_find_network_from_bss(struct station *station,memcpy (ssid, bss->ssid, bss->ssid_len); ssid[bss->ssid_len] ='\0' ; -if (station_parse_bss_security (station, bss, &security) <0 ) +if (scan_bss_get_security (bss, &security) <0 )return NULL ;return station_network_find (station, ssid, security);
Signature · 1 line
2.34.1
James Prestwood
PATCH 3/7 scan: check flush feature before using flag
In reply to James Prestwood--- src/scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/scan.c +2 -1
@@ -362,7 +362,8 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc,if (params->freqs)scan_build_attr_scan_frequencies (msg, params->freqs); -if (params->flush && !ignore_flush_flag) +if (params->flush && !ignore_flush_flag &&wiphy_has_feature (sc->wiphy, +NL80211_FEATURE_SCAN_FLUSH )) flags |=NL80211_SCAN_FLAG_FLUSH ; if (!is_passive && params->randomize_mac_addr_hint &&
Signature · 1 line
2.34.1
James Prestwood
PATCH 4/7 scan: add support for scanning on AP interface type
In reply to James PrestwoodThis adds a new flag, force_ap to the scan parameters. When enabled this will set NL80211_SCAN_FLAG_AP.
--- src/scan.c | 4 ++++ src/scan.h | 1 + 2 files changed, 5 insertions(+)
src/scan.c +4 -0
@@ -391,6 +391,10 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc, NL80211_EXT_FEATURE_SCAN_RANDOM_SN)) flags |= NL80211_SCAN_FLAG_RANDOM_SN; +if (params->force_ap &&wiphy_has_feature (sc->wiphy, +NL80211_FEATURE_AP_SCAN )) + flags |=NL80211_SCAN_FLAG_AP ; +if (flags)l_genl_msg_append_attr (msg,NL80211_ATTR_SCAN_FLAGS ,4 , &flags);
src/scan.h +1 -0
@@ -98,6 +98,7 @@ struct scan_parameters { bool randomize_mac_addr_hint : 1; bool no_cck_rates : 1; bool duration_mandatory : 1; + bool force_ap : 1;const uint8_t *ssid;/* Used for direct probe request */ size_t ssid_len;const uint8_t *source_mac;
Signature · 1 line
2.34.1
Denis Kenzior
Re: [PATCH 4/7] scan: add support for scanning on AP interface type
Hi James,
Quoted 12 lines · James Prestwood
This adds a new flag,
force_apto the scan parameters. When enabled this will setNL80211_SCAN_FLAG_AP.--- src/scan.c | 4 ++++ src/scan.h | 1 + 2 files changed, 5 insertions(+)src/scan.c +0
-0
src/scan.c static struct l_genl_msg *scan_build_cmd(struct scan_context *sc, · line 395
Quoted 5 lines
src/scan.c +2
-0@@ -391,6 +391,10 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc, NL80211_EXT_FEATURE_SCAN_RANDOM_SN)) flags |= NL80211_SCAN_FLAG_RANDOM_SN; +if (params->force_ap &&wiphy_has_feature (sc->wiphy, +NL80211_FEATURE_AP_SCAN ))
You already check this in patch 5 ap_dbus_scan()?
Quoted 10 lines
src/scan.c +2
-0+ flags |=NL80211_SCAN_FLAG_AP ; +if (flags)l_genl_msg_append_attr (msg,NL80211_ATTR_SCAN_FLAGS ,4 , &flags);src/scan.h +0
-0
src/scan.h struct scan_parameters { · line 101
Quoted 4 lines
src/scan.h +1
-0@@ -98,6 +98,7 @@ struct scan_parameters { bool randomize_mac_addr_hint : 1; bool no_cck_rates : 1; bool duration_mandatory : 1; + bool force_ap : 1;
force_ap_scan? or simply ap_scan?
src/scan.h struct scan_parameters { · line 104
Quoted 4 lines
src/scan.h +0
-0const uint8_t *ssid;/* Used for direct probe request */ size_t ssid_len;const uint8_t *source_mac;
Regards,
-Denis
James Prestwood
Re: [PATCH 4/7] scan: add support for scanning on AP interface type
Hi Denis,
Quoted 10 lines · Denis Kenzior
Hi James,
Quoted 7 lines · James Prestwood
This adds a new flag,
force_apto the scan parameters. When enabled this will setNL80211_SCAN_FLAG_AP.
---
src/scan.c| 4 ++++
src/scan.h| 1 +2 files changed, 5 insertions(+)
Quoted 15 lines
Quoted 6 lines
src/scan.c +0
-0@@ -391,6 +391,10 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc,Quoted 7 lines
NL80211_EXT_FEATURE_SCAN_RA
NDOM_SN))
flags |=NL80211_SCAN_FLAG_RANDOM_SN;
+ if (params->force_ap&& wiphy_has_feature(sc->wiphy, + NL80211_FEATURE_AP_ SCAN))You already check this in patch 5
ap_dbus_scan()?
With this newfound knowledge that brcmfmac doesn't advertise this feature I think we do still want this here. I did test on brcmfmac without this check and it accepted the scan request still but I think it would be safer to keep it.
Quoted 26 lines
Quoted 12 lines
+ flags |=
NL80211_SCAN_FLAG_AP;
+
if (flags)
l_genl_msg_append_attr(msg,NL80211_ATTR_SCAN_FLAGS, 4, &flags);src/scan.h +0
-0src/scan.h struct scan_parameters { · line 101
Quoted 4 lines
src/scan.h +1
-0@@ -98,6 +98,7 @@ struct scan_parameters { bool randomize_mac_addr_hint : 1; bool no_cck_rates : 1; bool duration_mandatory : 1; + bool force_ap : 1;
force_ap_scan? or simplyap_scan?Quoted 4 lines
const
uint8_t*ssid; /* Used for direct probe request */size_tssid_len;
constuint8_t*source_mac;Regards,
-Denis
James Prestwood
PATCH 5/7 ap: add support for scanning while in AP mode
In reply to James PrestwoodScanning while in AP mode is somewhat of an edge case, but it does have some usefulness specifically with onboarding new devices, i.e. a new device starts an AP, a station connects and provides the new device with network credentials, the new device switches to station mode and connects to the desired network.
In addition this could be used later for ACS (though this is a bit overkill for IWD's access point needs).
Since AP performance is basically non-existant while scanning this feature is meant to be used in a limited scope.
Two DBus API's were added which mirror the station interface: Scan and GetOrderedNetworks.
Scan is no different than the station variant, and will perform an active scan on all channels.
GetOrderedNetworks diverges from station and simply returns an array of dictionaries containing basic information about networks:
{
Name: <ssid>
SignalStrength: <mBm>
Security: <psk, open, or 8021x>
}Limitations:
- Hidden networks are not supported. This isn't really possible since the SSID's are unknown from the AP perspective.
- Sharing scan results with station is not supported. This would be a convenient improvement in the future with respect to onboarding new devices. The scan could be performed in AP mode, then switch to station and connect immediately without needing to rescan. A quick hack could better this situation by not flushing scan results in station (if the kernel retains these on an iftype change).
--- src/ap.c | 301 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+)
src/ap.c +301 -0
@@ -58,6 +58,7 @@#include "src/storage.h" #include "src/diagnostic.h" #include "src/band.h" +#include "src/common.h" struct ap_state {struct netdev *netdev;
@@ -99,11 +100,16 @@ struct ap_state {uint8_t netconfig_gateway4_mac[6 ];uint8_t netconfig_dns4_mac[6 ]; +uint32_t scan_id; +struct l_dbus_message *scan_pending; +struct l_queue *networks; + bool started : 1; bool gtk_set : 1; bool netconfig_set_addr4 : 1; bool in_event : 1; bool free_pending : 1; + bool scanning : 1; };struct sta_state {
@@ -136,10 +142,81 @@ struct ap_wsc_pbc_probe_record {uint64_t timestamp; }; +struct ap_network { +char ssid[33 ]; +int16_t signal; +enum security security; +uint64_t timestamp; +}; +static char **global_addr4_strs;static uint32_t netdev_watch;static struct l_netlink *rtnl; +static bool network_match_ssid (const void *a,const void *b) +{ +const struct ap_network *network = a; +const char *ssid = b; + +return !strcmp (network->ssid, ssid); +} + +static int network_signal_compare (const void *a,const void *b,void *user) +{ +const struct ap_network *new_network = a; +const struct ap_network *network = b; + +return (network->signal > new_network->signal) ?1 :-1 ; +} + +static struct ap_network *ap_network_find (struct ap_state *ap, +struct scan_bss *bss) +{ +char ssid[33 ]; + +memcpy (ssid, bss->ssid, bss->ssid_len); + ssid[bss->ssid_len] ='\0' ; + +return l_queue_find (ap->networks, network_match_ssid, ssid); +} + +static void ap_network_append (struct ap_state *ap,struct scan_bss *bss) +{ +struct ap_network *network; +enum security security; + +if (util_ssid_is_hidden (bss->ssid_len, bss->ssid)) +return ; + + network =ap_network_find (ap, bss); +if (!network) { +if (scan_bss_get_security (bss, &security) <0 ) +return ; + + network = l_new(struct ap_network, 1); + network->signal = bss->signal_strength; + network->security = security; + network->timestamp = bss->time_stamp; + +memcpy (network->ssid, bss->ssid, bss->ssid_len); + network->ssid[bss->ssid_len] ='\0' ; + + goto insert; + } + +if (l_time_before (network->timestamp, bss->time_stamp)) + network->timestamp = bss->time_stamp; + +if (bss->signal_strength <= network->signal) +return ; + +l_queue_remove (ap->networks, network); + network->signal = bss->signal_strength; + +insert: +l_queue_insert (ap->networks, network, network_signal_compare,NULL ); +} +static void ap_stop_handshake (struct sta_state *sta) {if (sta->sm) {
@@ -257,6 +334,16 @@ static void ap_reset(struct ap_state *ap)l_dhcp_server_destroy (ap->netconfig_dhcp); ap->netconfig_dhcp =NULL ; } + +if (ap->scan_id) { +scan_cancel (netdev_get_wdev_id (ap->netdev), ap->scan_id); + ap->scan_id =0 ; + } + +if (ap->networks) { +l_queue_destroy (ap->networks, l_free); + ap->networks =NULL ; + } }static bool ap_event_done (struct ap_state *ap,bool prev_in_event)
@@ -3207,6 +3294,7 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config, ap->ciphers =wiphy_select_cipher (wiphy,0xffff ); ap->group_cipher =wiphy_select_cipher (wiphy,0xffff ); ap->beacon_interval =100 ; + ap->networks =l_queue_new ();wsc_uuid_from_addr (netdev_get_address (netdev), ap->wsc_uuid_r);
@@ -3670,6 +3758,195 @@ error:return dbus_error_from_errno (err, message); } +static void ap_set_scanning (struct ap_state *ap,bool scanning) +{ +if (ap->scanning == scanning) +return ; + + ap->scanning = scanning; + +l_dbus_property_changed (dbus_get_bus (),netdev_get_path (ap->netdev), +IWD_AP_INTERFACE ,"Scanning" ); +} + +static void ap_scan_triggered (int err,void *user_data) +{ +struct ap_state *ap = user_data; +struct l_dbus_message *reply; + +if (err <0 ) { + reply =dbus_error_from_errno (err, ap->scan_pending); +dbus_pending_reply (&ap->scan_pending, reply); +return ; + } + +l_debug ("AP scan triggered for %s" ,netdev_get_name (ap->netdev)); + + reply =l_dbus_message_new_method_return (ap->scan_pending); +l_dbus_message_set_arguments (reply,"" ); +dbus_pending_reply (&ap->scan_pending, reply); + +ap_set_scanning (ap, true); +} + +static bool bss_match_ssid (const void *a,const void *b) +{ +const struct scan_bss *bss = a; +const char *ssid = b; + +if (util_ssid_is_hidden (bss->ssid_len, bss->ssid)) +return false; + +if (bss->ssid_len !=strlen (ssid)) +return false; + +return !memcmp (bss->ssid, ssid, bss->ssid_len); +} + +static bool network_free_if_not_found (void *data,void *user_data) +{ +struct ap_network *network = data; +struct l_queue *bss_list = user_data; + +if (l_queue_find (bss_list, bss_match_ssid, network->ssid)) +return false; + +l_free (network); +return true; +} + +static bool ap_scan_notify (int err,struct l_queue *bss_list, +const struct scan_freq_set *freqs, +void *user_data) +{ +struct ap_state *ap = user_data; +const struct l_queue_entry *bss_entry; + +ap_set_scanning (ap, false); + +/* Remove any networks with no matching BSS's */ +l_queue_foreach_remove (ap->networks, network_free_if_not_found, + bss_list); + +for (bss_entry =l_queue_get_entries (bss_list); bss_entry; + bss_entry = bss_entry->next) { +struct scan_bss *bss = bss_entry->data; + +ap_network_append (ap, bss); + } + +l_debug ("" ); + +return false; +} + +static void ap_scan_destroy (void *user_data) +{ +struct ap_state *ap = user_data; + + ap->scan_id =0 ; +} + +static struct l_dbus_message *ap_dbus_scan (struct l_dbus *dbus, +struct l_dbus_message *message, +void *user_data) +{ +struct ap_if_data *ap_if = user_data; +uint64_t wdev_id =netdev_get_wdev_id (ap_if->netdev); +struct wiphy *wiphy =wiphy_find_by_wdev (wdev_id); +struct scan_parameters params = { + .force_ap = true + }; + +/* +* TODO: There is really nothing preventing scanning while stopped. +* The only consideration would be if a scan is ongoing and the +* AP is started. Queuing Start() as wiphy work may be required to +* handle this case if needed. For now just limit to started APs. +*/ +if (!ap_if->ap || !ap_if->ap->started) +return dbus_error_not_available (message); + +if (!wiphy_has_feature (wiphy,NL80211_FEATURE_AP_SCAN )) +return dbus_error_not_supported (message); + +if (ap_if->ap->scan_id) +return dbus_error_busy (message); + + ap_if->ap->scan_id =scan_active_full (wdev_id, ¶ms, + ap_scan_triggered, + ap_scan_notify, + ap_if->ap, ap_scan_destroy); +if (!ap_if->ap->scan_id) +return dbus_error_failed (message); + + ap_if->ap->scan_pending =l_dbus_message_ref (message); + +return NULL ; +} + +static void dbus_append_network (struct l_dbus_message_builder *builder, +struct ap_network *network) +{ +l_dbus_message_builder_enter_array (builder,"{sv}" ); +dbus_append_dict_basic (builder,"Name" ,'s' , network->ssid); +dbus_append_dict_basic (builder,"SignalStrength" ,'n' , + &network->signal); +dbus_append_dict_basic (builder,"Security" ,'s' , +security_to_str (network->security)); +l_dbus_message_builder_leave_array (builder); +} + +#define SCAN_NETWORK_RETENTION_TIME (30 * 1000000) + +static bool network_free_if_expired (void *data,void *user_data) +{ +struct ap_network *network = data; + +if (l_time_before (l_time_now (), + network->timestamp +SCAN_NETWORK_RETENTION_TIME )) +return false; + +l_free (network); + +return true; +} + +static struct l_dbus_message *ap_dbus_get_networks (struct l_dbus *dbus, +struct l_dbus_message *message, +void *user_data) +{ +struct ap_if_data *ap_if = user_data; +struct l_dbus_message *reply; +struct l_dbus_message_builder *builder; +const struct l_queue_entry *entry; + +if (!ap_if->ap || !ap_if->ap->started) +return dbus_error_not_available (message); + +/* Without periodic scans or a timer old networks need to be removed */ +l_queue_foreach_remove (ap_if->ap->networks, + network_free_if_expired,NULL ); + + reply =l_dbus_message_new_method_return (message); + builder =l_dbus_message_builder_new (reply); + +l_dbus_message_builder_enter_array (builder,"a{sv}" ); + +for (entry =l_queue_get_entries (ap_if->ap->networks); entry; + entry = entry->next) { +struct ap_network *network = entry->data; + +dbus_append_network (builder, network); + } + +l_dbus_message_builder_leave_array (builder); +l_dbus_message_builder_finalize (builder); +l_dbus_message_builder_destroy (builder); + +return reply; +} + static bool ap_dbus_property_get_started(struct l_dbus *dbus, struct l_dbus_message *message, struct l_dbus_message_builder *builder,
@@ -3699,6 +3976,24 @@ static bool ap_dbus_property_get_name(struct l_dbus *dbus,return true; } +static bool ap_dbus_property_get_scanning (struct l_dbus *dbus, +struct l_dbus_message *message, +struct l_dbus_message_builder *builder, +void *user_data) +{ +struct ap_if_data *ap_if = user_data; +bool bval; + +if (!ap_if->ap || !ap_if->ap->started) +return false; + + bval = ap_if->ap->scanning; + +l_dbus_message_builder_append_basic (builder,'b' , &bval); + +return true; +} +static void ap_setup_interface (struct l_dbus_interface *interface) { l_dbus_interface_method(interface, "Start", 0, ap_dbus_start, "",
@@ -3707,11 +4002,17 @@ static void ap_setup_interface(struct l_dbus_interface *interface)l_dbus_interface_method (interface,"StartProfile" ,0 , ap_dbus_start_profile,"" ,"s" ,"ssid" ); +l_dbus_interface_method (interface,"Scan" ,0 , ap_dbus_scan,"" ,"" ); +l_dbus_interface_method (interface,"GetOrderedNetworks" ,0 , + ap_dbus_get_networks,"aa{sv}" , +"" ,"networks" );l_dbus_interface_property (interface,"Started" ,0 ,"b" , ap_dbus_property_get_started,NULL );l_dbus_interface_property (interface,"Name" ,0 ,"s" , ap_dbus_property_get_name,NULL ); +l_dbus_interface_property (interface,"Scanning" ,0 ,"b" , + ap_dbus_property_get_scanning,NULL ); }static void ap_destroy_interface (void *user_data)
Signature · 1 line
2.34.1
James Prestwood
PATCH 6/7 client: add AP scanning support to iwctl
In reply to James Prestwood--- client/ap.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+)
client/ap.c +115 -0
@@ -35,6 +35,7 @@struct ap {bool started;char *name; +bool scanning; };static void *ap_create (void )
@@ -104,9 +105,31 @@ static void update_name(void *data, struct l_dbus_message_iter *variant) ap->name =l_strdup (name); } +static void update_scanning (void *data,struct l_dbus_message_iter *variant) +{ +struct ap *ap = data; +bool value; + +if (!l_dbus_message_iter_get_variant (variant,"b" , &value)) { + ap->scanning = false; + +return ; + } + + ap->scanning = value; +} + +static const char *get_scanning_tostr (const void *data) +{ +const struct ap *ap = data; + +return ap->scanning ?"yes" :"no" ; +} +static const struct proxy_interface_property ap_properties[] = { {"Started" ,"b" , update_started, get_started_tostr }, {"Name" ,"s" , update_name, get_name_tostr }, + {"Scanning" ,"b" , update_scanning, get_scanning_tostr }, { } };
@@ -301,6 +324,95 @@ static enum cmd_status cmd_start_profile(const char *device_name,return CMD_STATUS_TRIGGERED ; } +static enum cmd_status cmd_scan (const char *device_name,char **argv,int argc) +{ +const struct proxy_interface *ap_i; + + ap_i =device_proxy_find (device_name,IWD_ACCESS_POINT_INTERFACE ); +if (!ap_i) { +display ("No ap on device: '%s'\n" , device_name); +return CMD_STATUS_INVALID_VALUE ; + } + +proxy_interface_method_call (ap_i,"Scan" ,"" , + check_errors_method_callback); + +return CMD_STATUS_TRIGGERED ; +} + +static void ap_display_network (struct l_dbus_message_iter *iter, +const char *margin,int name_width, +int value_width) +{ +const char *key; +struct l_dbus_message_iter variant; + +while (l_dbus_message_iter_next_entry (iter, &key, &variant)) { +const char *s; +int16_t n; + +if (!strcmp (key,"Name" ) || !strcmp (key,"Security" )) { +if (!l_dbus_message_iter_get_variant (&variant,"s" , &s)) + goto parse_error; + +display ("%s%-*s%-*s\n" , margin, name_width, key, + value_width, s); + }else if (!strcmp (key,"SignalStrength" )) { +if (!l_dbus_message_iter_get_variant (&variant,"n" , &n)) + goto parse_error; + +display ("%s%-*s%-*i\n" , margin, name_width, key, + value_width, n); + } + } + +return ; + +parse_error: +display ("Error displaying network results" ); +} + +static void ap_get_networks_callback (struct l_dbus_message *message, +void *user_data) +{ +struct l_dbus_message_iter array; +struct l_dbus_message_iter iter; + +if (dbus_message_has_error (message)) +return ; + +if (!l_dbus_message_get_arguments (message,"aa{sv}" , &array)) { +display ("Failed to parse GetDiagnostics message" ); +return ; + } + +display_table_header ("Networks" ," %-*s%-*s" , +20 ,"Property" ,20 ,"Value" ); +while (l_dbus_message_iter_next_entry (&array, &iter)) { +ap_display_network (&iter," " ,20 ,20 ); +display ("\n" ); + } + +display_table_footer (); +} + +static enum cmd_status cmd_get_networks (const char *device_name,char **argv, +int argc) +{ +const struct proxy_interface *ap_i; + + ap_i =device_proxy_find (device_name,IWD_ACCESS_POINT_INTERFACE ); +if (!ap_i) { +display ("No ap on device: '%s'\n" , device_name); +return CMD_STATUS_INVALID_VALUE ; + } + +proxy_interface_method_call (ap_i,"GetOrderedNetworks" ,"" , + ap_get_networks_callback); + +return CMD_STATUS_TRIGGERED ; +} +static const struct command ap_commands[] = { {NULL ,"list" ,NULL , cmd_list,"List devices in AP mode" , true }, {"<wlan>" ,"start" ,"<\"network name\"> <passphrase>" , cmd_start,
@@ -311,6 +423,9 @@ static const struct command ap_commands[] = { {"<wlan>" ,"stop" ,NULL , cmd_stop,"Stop a started access\n" "\t\t\t\t\t\t point" }, { "<wlan>", "show", NULL, cmd_show, "Show AP info", false }, + { "<wlan>", "scan", NULL, cmd_scan, "Start an AP scan", false }, + { "<wlan>", "get-networks", NULL, cmd_get_networks, + "Get network list after scanning", false }, { } };
Signature · 1 line
2.34.1
James Prestwood
PATCH 7/7 doc: document access point scanning
In reply to James Prestwood--- doc/access-point-api.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
doc/access-point-api.txt +27 -0
@@ -37,6 +37,29 @@ Methods void Start(string ssid, string psk) net.connman.iwd.AlreadyExists net.connman.iwd.NotFound + void Scan() + + Schedule a network scan. + + Possible errors: net.connman.iwd.NotAvailable + net.connman.iwd.NotSupported + net.connman.iwd.Busy + net.connman.iwd.Failed + + array(dict) GetOrderedNetworks() + + Gets the list of networks found after scanning sorted + based on signal strength. Each item in the array is a + dictionary containing the network Name, SignalStrength, + and Security. + + This list will expire similarly to station, and since + access points do not do periodic scans the list may + become empty after some time and requires scanning + again. + + Possible errors: net.connman.iwd.NotAvailable + Properties boolean Started [readonly] Reflects whether an access point has been started.
@@ -45,3 +68,7 @@ Properties boolean Started [readonly] The SSID being broadcast for a started AP (omitted if AP has not been started) + + boolean Scanning [readonly] + + Reflects whether the access point is scanning.
Signature · 1 line
2.34.1
Denis Kenzior
Re: [PATCH 7/7] doc: document access point scanning
Hi James,
Quoted 4 lines · James Prestwood
--- doc/access-point-api.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
<snip>
doc/access-point-api.txt Methods void Start(string ssid, string psk) · line 54
Quoted 6 lines
doc/access-point-api.txt +6
-0+ array(dict) GetOrderedNetworks() + + Gets the list of networks found after scanning sorted + based on signal strength. Each item in the array is a + dictionary containing the network Name, SignalStrength, + and Security.
Security -> Type to be consistent with KnownNetwork / Network interface naming of the properties.
doc/access-point-api.txt Methods void Start(string ssid, string psk) · line 59
Quoted 5 lines
doc/access-point-api.txt +5
-0+ + This list will expire similarly to station, and since + access points do not do periodic scans the list may + become empty after some time and requires scanning + again.
I'm not sure what this is about? Scan results don't actually expire in Station in the sense that you can keep calling GetOrderedNetworks() forever and get the same results, as long as scanning hasn't been performed. Essentially if Scanning hasn't changed, GetOrderedNetworks() results shouldn't change either.
I would expect the same behavior here?
Regards,
-Denis
James Prestwood
Re: [PATCH 7/7] doc: document access point scanning
Quoted 33 lines · Denis Kenzior
Hi James,
Quoted 4 lines · James Prestwood
---
doc/access-point-api.txt| 27 +++++++++++++++++++++++++++1 file changed, 27 insertions(+)<snip>
Quoted 9 lines
+ array(dict)
GetOrderedNetworks()
+
+ Gets the list of networks found after scanning sorted
+ based on signal strength. Each item in the array is a
+ dictionary containing the network Name, SignalStrength,
+ and Security.Security -> Type to be consistent with KnownNetwork / Network interface naming
of the properties.Quoted 8 lines
+
+ This list will expire similarly to station, and since
+ access points do not do periodic scans the list may
+ become empty after some time and requires scanning
+ again.
Quoted 8 lines
I'm not sure what this is about? Scan results don't actually expire in Station
in the sense that you can keep callingGetOrderedNetworks()forever and get the
same results, as long as scanning hasn't been performed. Essentially if
Scanning hasn't changed,GetOrderedNetworks()results shouldn't change either.
You're right, I was mis-remembering how the expiration works. Since station does periodic scan the BSS's get thrown out for each scan which is what I was somewhat trying to mirror here. But as far as GetOrderedNetworks goes it just takes the current list, however old it is.
Quoted 2 lines
I would expect the same behavior here?
Sure I can remove the expiration stuff from the core patch and leave it up to the caller to make sure they get the networks promptly after scanning is finished.
Quoted 3 lines
Regards,
-Denis