Updated January 2023
This doc describes how Shill manages WiFi, the different classes used, and how they interact with wpa_supplicant, the daemon used to handle authentication, and the kernel. It's split into the following sections:
This section documents classes used in station mode, or “normal” WiFi connections.
wlan0 in most devices).WiFi is visible as a Device D-Bus object and supports the generic Device properties and functions as well as WiFi specific ones.WiFi contains a SupplicantInterfaceProxyInterface which is used to communicate to wpa_supplicant's interface struct, struct wpa_supplicant, in order to connect to and disconnect from networks, track the interface connection state, scan, etc.WiFi class, which asynchronously asks wpa_supplicant for a connection and tracks the interface connection state thereafter.WiFiService instance is created, it is registered with the Manager class.WiFiService is visible as a Service D-Bus object and supports the generic Service properties and functions as well as WiFi specific ones.WiFiService represents a “WiFi network”, and is identified by its (security class, SSID (more commonly known as network name), mode) triplet. For example, two networks with the same SSID, or network name, and different security classes will be two unique WiFiServices. Note that CrOS only supports one network mode (infrastructure mode) at the time of writing.WiFiService registers WiFi specific Service properties.WiFiService forwards Connect and Disconnect requests to WiFi.WiFiService maintains a list of endpoints that match its “connection triplet”.WiFi, which creates a new WiFiEndpoint when it discovers a new BSS in a scan and destroys it once it's no longer in view.WiFiEndpoint parses the information elements present in the beacons and probe responses.WiFiEndpoint contains a SupplicantBSSProxyInterface which is used to communicate property changes to the corresponding WiFiEndpoint.WiFiLinkStatistics print out the diff of these stats to help developers diagnose whether or not the failure was due to a bad underlying link.WiFi.WiFi.WiFi.PasspointCredentials are added by Manager D-Bus calls and stored by the WiFiProvider.wpa_supplicant through WiFi and used to match networks when InterworkingSelect is called.This section documents classes used in AP mode, or as a WiFi “hotspot”.
HotspotDevice is created and owned by TetheringManager.HotspotService is created and owned by a HotspotDevice.wpa_supplicant, if necessary, and configuring the downstream L3 network.This section documents classes that are used in all WiFi-related operations.
iw list will list all the available phys on the system. Most ChromeOS devices have only one phy.Endpoint to Service mappings, etc.WiFiProvider needs to be responsible for much more than other technologies (which mostly just handle Service creation and matching), this may eventually break out into a separate type.Connect requests are forwarded from WiFiService to WiFi.
wpa_supplicant network configuration parameters, which are stored in WiFiService, uses them to create a wpa_supplicant network block, and asks wpa_supplicant to connect.pending_service_ is set to indicate that the user has asked for a connection, but that wpa_supplicant has not yet associated.wpa_supplicant interface property to determine when to set current_service_ to pending_service_. wpa_supplicant will update this property after it has completed L2 association if there's no existing connection, and before it has completed L2 association if there is an existing connection.WiFi transitions the Service state to kStateConfiguring and starts L3 configuration using the Network class.A disconnect can either be user-initiated or non-user-initiated.
Disconnect requests are similarly forwarded from WiFiService to WiFi.
wpa_supplicant to disconnect.This can happen as a result of bad link, walking away from an AP, AP-side issues, etc.
wpa_supplicant notices that the device is no longer connected. This can happen primarily in one of three ways:null BSS.WiFi::HandleDisconnect. This may or may not be expected, and shill records it as such in our telemetry depending on what state it was in prior to getting the disconnect event.WiFi::DisconnectFrom, to actively send the Disconnect command to wpa_supplicant. Note that this call usually results in a benign error because wpa_supplicant will inevitably also notice that the link is down, but have raced with other means of communicating link failure.This refers to rekeying and roaming, which both happen beneath the shill layer, but surface State property changes that shill sees.
is_rekey_in_progress_ to indicate that it is rekeying and that the Service state should not be changed then (or after the rekeying has finished).wpa_supplicant detects that another AP is strong enough to warrant another association.is_roaming_in_progress_ is set to indicate that the device is roaming.wpa_supplicant, but shill plays a few important roles in scanning:wpa_supplicant's background scan with parameters such as:wpa_supplicant for scans periodically.wpa_supplicant for scans when RequestScan or ScanAndConnectToBestServices Manager D-Bus functions are called.wpa_supplicant finishes a scan, it reports its scan results to Shill through BSSAdded and BSSRemoved D-Bus signals.