Documentation ¶
Overview ¶
Package shill provides D-Bus wrappers and utilities for shill service.
Index ¶
- Constants
- func WaitForOnline(ctx context.Context) error
- func WifiInterface(ctx context.Context, m *Manager, timeout time.Duration) (string, error)
- type Device
- func (d *Device) ChangePin(ctx context.Context, oldPin, newPin string) error
- func (d *Device) Disable(ctx context.Context) error
- func (d *Device) Enable(ctx context.Context) error
- func (d *Device) EnterPin(ctx context.Context, pin string) error
- func (d *Device) RequestRoam(ctx context.Context, bssid string) error
- func (d *Device) RequirePin(ctx context.Context, pin string, require bool) error
- func (d *Device) Reset(ctx context.Context) error
- func (d *Device) SetUsbEthernetMacAddressSource(ctx context.Context, source string) error
- func (d *Device) UnblockPin(ctx context.Context, pukCode, newPin string) error
- func (d *Device) WaitForSelectedService(ctx context.Context, timeout time.Duration) (dbus.ObjectPath, error)
- type IPConfig
- type Manager
- func (m *Manager) ActiveProfile(ctx context.Context) (*Profile, error)
- func (m *Manager) ConfigureService(ctx context.Context, props map[string]interface{}) (dbus.ObjectPath, error)
- func (m *Manager) ConfigureServiceForProfile(ctx context.Context, path dbus.ObjectPath, props map[string]interface{}) (dbus.ObjectPath, error)
- func (m *Manager) CreateProfile(ctx context.Context, name string) (dbus.ObjectPath, error)
- func (m *Manager) DeviceByName(ctx context.Context, iface string) (*Device, error)
- func (m *Manager) DeviceByType(ctx context.Context, deviceType string) (*Device, error)
- func (m *Manager) Devices(ctx context.Context) ([]*Device, error)
- func (m *Manager) DevicesByTechnology(ctx context.Context, technology Technology) ([]*Device, []*dbusutil.Properties, error)
- func (m *Manager) DisableTechnology(ctx context.Context, technology Technology) error
- func (m *Manager) DisableTechnologyForTesting(ctx context.Context, technology Technology) (func(ctx context.Context), error)
- func (m *Manager) EnableTechnology(ctx context.Context, technology Technology) error
- func (m *Manager) FindMatchingService(ctx context.Context, expectProps map[string]interface{}) (*Service, error)
- func (m *Manager) GetDebugLevel(ctx context.Context) (int, error)
- func (m *Manager) GetDebugTags(ctx context.Context) ([]string, error)
- func (m *Manager) GetEnabledTechnologies(ctx context.Context) ([]Technology, error)
- func (m *Manager) IsAvailable(ctx context.Context, technology Technology) (bool, error)
- func (m *Manager) IsEnabled(ctx context.Context, technology Technology) (bool, error)
- func (m *Manager) PopAllUserProfiles(ctx context.Context) error
- func (m *Manager) PopProfile(ctx context.Context, name string) error
- func (m *Manager) ProfilePaths(ctx context.Context) ([]dbus.ObjectPath, error)
- func (m *Manager) Profiles(ctx context.Context) ([]*Profile, error)
- func (m *Manager) PushProfile(ctx context.Context, name string) (dbus.ObjectPath, error)
- func (m *Manager) RecheckPortal(ctx context.Context) error
- func (m *Manager) RemoveProfile(ctx context.Context, name string) error
- func (m *Manager) RequestScan(ctx context.Context, technology Technology) error
- func (m *Manager) SetDebugLevel(ctx context.Context, level int) error
- func (m *Manager) SetDebugTags(ctx context.Context, tags []string) error
- func (m *Manager) WaitForDeviceByName(ctx context.Context, iface string, timeout time.Duration) (*Device, error)
- func (m *Manager) WaitForServiceProperties(ctx context.Context, expectProps map[string]interface{}, timeout time.Duration) (*Service, error)
- type Profile
- type PropertiesWatcher
- func (pw *PropertiesWatcher) Close(ctx context.Context) error
- func (pw *PropertiesWatcher) Expect(ctx context.Context, prop string, expected interface{}) error
- func (pw *PropertiesWatcher) ExpectIn(ctx context.Context, prop string, expected []interface{}) (interface{}, error)
- func (pw *PropertiesWatcher) Wait(ctx context.Context) (string, interface{}, dbus.Sequence, error)
- func (pw *PropertiesWatcher) WaitAll(ctx context.Context, props ...string) ([]interface{}, error)
- type PropertyHolder
- func (h *PropertyHolder) CreateWatcher(ctx context.Context) (*PropertiesWatcher, error)
- func (h *PropertyHolder) GetAndSetProperty(ctx context.Context, prop string, value interface{}) (interface{}, error)
- func (h *PropertyHolder) GetProperties(ctx context.Context) (*dbusutil.Properties, error)
- func (h *PropertyHolder) GetShillProperties(ctx context.Context) (*dbusutil.Properties, error)
- func (h *PropertyHolder) SetProperty(ctx context.Context, prop string, value interface{}) error
- func (h *PropertyHolder) WaitForProperty(ctx context.Context, property string, expected interface{}, ...) error
- func (h *PropertyHolder) WaitForShillProperty(ctx context.Context, property string, expected interface{}, ...) error
- type Service
- func (s *Service) Connect(ctx context.Context) error
- func (s *Service) Disconnect(ctx context.Context) error
- func (s *Service) GetDevice(ctx context.Context) (*Device, error)
- func (s *Service) GetSignalStrength(ctx context.Context) (uint8, error)
- func (s *Service) IsConnected(ctx context.Context) (bool, error)
- func (s *Service) Remove(ctx context.Context) error
- func (s *Service) WaitForConnectedOrError(ctx context.Context) error
- type Technology
- type WifiManager
- func (wifi *WifiManager) APConnected(ctx context.Context, ssid string) (bool, error)
- func (wifi *WifiManager) ConnectAP(ctx context.Context, ssid, passphrase string) error
- func (wifi *WifiManager) Connected(ctx context.Context) (bool, error)
- func (wifi *WifiManager) Enable(ctx context.Context, enable bool) error
- func (wifi *WifiManager) ForgetAP(ctx context.Context, ssid string) error
- func (wifi *WifiManager) Interface(ctx context.Context) (string, error)
- func (wifi *WifiManager) SetTimeout(t time.Duration)
Constants ¶
const (
EnableWaitTime = 500 * time.Millisecond
)
Exported constants
Variables ¶
This section is empty.
Functions ¶
func WaitForOnline ¶
WaitForOnline waits for Internet connectivity, a shorthand which is useful so external packages don't have to worry about Shill details (e.g., Service, Manager). Tests that require Internet connectivity (e.g., for a real GAIA login) need to ensure that before trying to perform Internet requests. This function is one way to do that. Returns an error if we don't come back online within a reasonable amount of time.
Types ¶
type Device ¶
type Device struct {
*PropertyHolder
}
Device wraps a Device D-Bus object in shill.
func NewDevice ¶
NewDevice connects to shill's Device. It also obtains properties after device creation.
func (*Device) ChangePin ¶
ChangePin changes the PIN used to unlock a SIM card, The existing PIN must be provided along with the new PIN.
func (*Device) RequestRoam ¶
RequestRoam requests that we roam to the specified BSSID. Note: this operation assumes that: 1- We are connected to an SSID for which |bssid| is a member. 2- There is a BSS with an appropriate ID in our scan results.
func (*Device) RequirePin ¶
RequirePin enables/disables SIM PIN based on required value.
func (*Device) SetUsbEthernetMacAddressSource ¶
SetUsbEthernetMacAddressSource sets USB Ethernet MAC address source for the device.
func (*Device) UnblockPin ¶
UnblockPin used to unblock the locked sim with puk code.
func (*Device) WaitForSelectedService ¶
func (d *Device) WaitForSelectedService(ctx context.Context, timeout time.Duration) (dbus.ObjectPath, error)
WaitForSelectedService returns the first valid value (i.e., not "/") of the "SelectedService" property.
type IPConfig ¶
type IPConfig struct {
*PropertyHolder
}
IPConfig wraps an IPConfig D-Bus object in shill.
func NewIPConfig ¶
NewIPConfig connects to an IPConfig in Shill.
type Manager ¶
type Manager struct {
*PropertyHolder
}
Manager wraps a Manager D-Bus object in shill.
func NewManager ¶
NewManager connects to shill's Manager.
func (*Manager) ActiveProfile ¶
ActiveProfile returns the active profile.
func (*Manager) ConfigureService ¶
func (m *Manager) ConfigureService(ctx context.Context, props map[string]interface{}) (dbus.ObjectPath, error)
ConfigureService configures a service with the given properties and returns its path.
func (*Manager) ConfigureServiceForProfile ¶
func (m *Manager) ConfigureServiceForProfile(ctx context.Context, path dbus.ObjectPath, props map[string]interface{}) (dbus.ObjectPath, error)
ConfigureServiceForProfile configures a service at the given profile path.
func (*Manager) CreateProfile ¶
CreateProfile creates a profile.
func (*Manager) DeviceByName ¶
DeviceByName returns the Device matching the given interface name.
func (*Manager) DeviceByType ¶
DeviceByType returns a device matching |type| or a "Device not found" error.
func (*Manager) DevicesByTechnology ¶
func (m *Manager) DevicesByTechnology(ctx context.Context, technology Technology) ([]*Device, []*dbusutil.Properties, error)
DevicesByTechnology returns list of Devices and their Properties snapshots of the specified technology.
func (*Manager) DisableTechnology ¶
func (m *Manager) DisableTechnology(ctx context.Context, technology Technology) error
DisableTechnology disables a technology interface.
func (*Manager) DisableTechnologyForTesting ¶
func (m *Manager) DisableTechnologyForTesting(ctx context.Context, technology Technology) (func(ctx context.Context), error)
DisableTechnologyForTesting first checks whether |technology| is enabled. If it is enabled, it disables the technology and returns a callback that can be deferred to re-enable the technology when the test completes. (The callback should take a contexted shortened by shill.EnableWaitTime). If the technology is already enabled, no work is done and a nil callback is returned
func (*Manager) EnableTechnology ¶
func (m *Manager) EnableTechnology(ctx context.Context, technology Technology) error
EnableTechnology enables a technology interface.
func (*Manager) FindMatchingService ¶
func (m *Manager) FindMatchingService(ctx context.Context, expectProps map[string]interface{}) (*Service, error)
FindMatchingService returns the first Service that matches |expectProps|. If no matching Service is found, returns shillconst.ErrorMatchingServiceNotFound. Note that the complete list of Services is searched, including those with Visible=false. To find only visible services, please specify Visible=true in expectProps.
func (*Manager) GetDebugLevel ¶
GetDebugLevel gets the enabled debug level.
func (*Manager) GetDebugTags ¶
GetDebugTags gets the list of enabled debug tags. The list is represented as a string of tag names separated by "+".
func (*Manager) GetEnabledTechnologies ¶
func (m *Manager) GetEnabledTechnologies(ctx context.Context) ([]Technology, error)
GetEnabledTechnologies returns a list of all enabled shill networking technologies.
func (*Manager) IsAvailable ¶
IsAvailable returns true if a technology is available.
func (*Manager) PopAllUserProfiles ¶
PopAllUserProfiles removes all user profiles from the stack of managed profiles leaving only default profiles.
func (*Manager) PopProfile ¶
PopProfile pops the profile with the given name if it is on top of the stack.
func (*Manager) ProfilePaths ¶
ProfilePaths returns a list of profile paths.
func (*Manager) PushProfile ¶
PushProfile pushes a profile.
func (*Manager) RecheckPortal ¶
RecheckPortal requests shill to rerun its captive portal detector.
func (*Manager) RemoveProfile ¶
RemoveProfile removes the profile with the given name.
func (*Manager) RequestScan ¶
func (m *Manager) RequestScan(ctx context.Context, technology Technology) error
RequestScan requests a scan for the specified technology.
func (*Manager) SetDebugLevel ¶
SetDebugLevel sets the debugging level.
func (*Manager) SetDebugTags ¶
SetDebugTags sets the debug tags that are enabled for logging. "tags" is a list of valid tag names separated by "+". Shill silently ignores invalid flags.
func (*Manager) WaitForDeviceByName ¶
func (m *Manager) WaitForDeviceByName(ctx context.Context, iface string, timeout time.Duration) (*Device, error)
WaitForDeviceByName returns the Device matching the given interface name. If there's no match, it waits until one appears, or until timeout.
func (*Manager) WaitForServiceProperties ¶
func (m *Manager) WaitForServiceProperties(ctx context.Context, expectProps map[string]interface{}, timeout time.Duration) (*Service, error)
WaitForServiceProperties returns the first matching Service who has the expected properties. If there's no matching service, it polls until timeout is reached. Noted that it searches all services including Visible=false ones. To focus on visible services, please specify Visible=true in expectProps.
type Profile ¶
type Profile struct {
*PropertyHolder
}
Profile wraps a Profile D-Bus object in shill.
func NewProfile ¶
NewProfile connects to a profile in Shill.
func (*Profile) DeleteEntry ¶
DeleteEntry calls the DeleteEntry method on the profile.
type PropertiesWatcher ¶
type PropertiesWatcher struct {
// contains filtered or unexported fields
}
PropertiesWatcher watches for Shill "PropertyChanged" signals.
func NewPropertiesWatcher ¶
func NewPropertiesWatcher(ctx context.Context, obj *dbusutil.DBusObject) (*PropertiesWatcher, error)
NewPropertiesWatcher returns a PropertiesWatcher to observe the shill specific "PropertyChanged" signal.
func (*PropertiesWatcher) Close ¶
func (pw *PropertiesWatcher) Close(ctx context.Context) error
Close stops watching for signals.
func (*PropertiesWatcher) Expect ¶
func (pw *PropertiesWatcher) Expect(ctx context.Context, prop string, expected interface{}) error
Expect waits for the expected value of a given property.
func (*PropertiesWatcher) ExpectIn ¶
func (pw *PropertiesWatcher) ExpectIn(ctx context.Context, prop string, expected []interface{}) (interface{}, error)
ExpectIn expects the prop's value to become one of the expected values and returns the first matched one.
type PropertyHolder ¶
type PropertyHolder struct {
*dbusutil.PropertyHolder
}
PropertyHolder provides methods to access properties of shill via D-Bus. The interface for property get/set in shill is different from the general org.freedesktop.DBus.Properties, so we'll need to overwrite the {Get,Set}Properties, while the other utilities provided by dbusutil can still be reused.
func NewPropertyHolder ¶
func NewPropertyHolder(ctx context.Context, service, iface string, path dbus.ObjectPath) (*PropertyHolder, error)
NewPropertyHolder creates a shill DBus object with the given service, interface and path which can be used for accessing and setting properties.
func (*PropertyHolder) CreateWatcher ¶
func (h *PropertyHolder) CreateWatcher(ctx context.Context) (*PropertiesWatcher, error)
CreateWatcher returns a PropertiesWatcher to observe the object's "PropertyChanged" signal.
func (*PropertyHolder) GetAndSetProperty ¶
func (h *PropertyHolder) GetAndSetProperty(ctx context.Context, prop string, value interface{}) (interface{}, error)
GetAndSetProperty returns the current value of a property and sets the property to a new value.
func (*PropertyHolder) GetProperties ¶
func (h *PropertyHolder) GetProperties(ctx context.Context) (*dbusutil.Properties, error)
GetProperties calls GetProperties method of shill and return properties of the object.
func (*PropertyHolder) GetShillProperties ¶
func (h *PropertyHolder) GetShillProperties(ctx context.Context) (*dbusutil.Properties, error)
GetShillProperties calls GetProperties method of shill and return properties of the object. Deprecated: use GetProperties instead.
func (*PropertyHolder) SetProperty ¶
func (h *PropertyHolder) SetProperty(ctx context.Context, prop string, value interface{}) error
SetProperty calls SetProperties method of shill to set a property of the object.
func (*PropertyHolder) WaitForProperty ¶
func (h *PropertyHolder) WaitForProperty(ctx context.Context, property string, expected interface{}, timeout time.Duration) error
WaitForProperty polls for the specified Shill property state to match |expected|.
func (*PropertyHolder) WaitForShillProperty ¶
func (h *PropertyHolder) WaitForShillProperty(ctx context.Context, property string, expected interface{}, timeout time.Duration) error
WaitForShillProperty polls for the specified Shill property state to match |expected| Deprecated: use WaitForProperty instead.
type Service ¶
type Service struct {
*PropertyHolder
}
Service wraps a Service D-Bus object in shill.
func NewService ¶
NewService connects to a service in Shill.
func (*Service) Disconnect ¶
Disconnect calls the Disconnect method on the service.
func (*Service) GetSignalStrength ¶
GetSignalStrength return the current signal strength
func (*Service) IsConnected ¶
IsConnected returns true if the the service is connected.
func (*Service) WaitForConnectedOrError ¶
WaitForConnectedOrError polls for either: * Service.IsConnected to be true, in which case nil is returned. * Service.Error to be set to an error value, in which case that is returned as an error. Any failure also returns an error.
type Technology ¶
type Technology string
Technology is the type of a shill device's technology
const ( TechnologyCellular Technology = shillconst.TypeCellular TechnologyEthernet Technology = shillconst.TypeEthernet TechnologyPPPoE Technology = shillconst.TypePPPoE TechnologyVPN Technology = shillconst.TypeVPN TechnologyWifi Technology = shillconst.TypeWifi )
Device technologies Refer to Flimflam type options in https://chromium.googlesource.com/chromiumos/platform2/+/refs/heads/main/system_api/dbus/shill/dbus-constants.h#334
type WifiManager ¶
type WifiManager struct {
// contains filtered or unexported fields
}
WifiManager manages WiFi services, profiles, and devices through shill Manager.
func NewWifiManager ¶
func NewWifiManager(ctx context.Context, m *Manager) (*WifiManager, error)
NewWifiManager makes sure WiFi interface is available and returns WiFi Manager.
func (*WifiManager) APConnected ¶
APConnected returns true if the given WiFi AP is connected.
func (*WifiManager) ConnectAP ¶
func (wifi *WifiManager) ConnectAP(ctx context.Context, ssid, passphrase string) error
ConnectAP connects to a given WiFi AP identified by SSID.
func (*WifiManager) Connected ¶
func (wifi *WifiManager) Connected(ctx context.Context) (bool, error)
Connected returns true if any WiFi AP is connected.
func (*WifiManager) Enable ¶
func (wifi *WifiManager) Enable(ctx context.Context, enable bool) error
Enable enables or disables the WiFi network according to the given enable flag.
func (*WifiManager) ForgetAP ¶
func (wifi *WifiManager) ForgetAP(ctx context.Context, ssid string) error
ForgetAP removes the WiFi AP from user profile.
func (*WifiManager) Interface ¶
func (wifi *WifiManager) Interface(ctx context.Context) (string, error)
Interface returns the WiFi interface name.
func (*WifiManager) SetTimeout ¶
func (wifi *WifiManager) SetTimeout(t time.Duration)
SetTimeout sets the WiFi manager timeout value for all WiFi operations.