/* * hidl interface for wpa_supplicant daemon * Copyright (c) 2004-2016, Jouni Malinen * Copyright (c) 2004-2016, Roshan Pius * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #ifndef WPA_SUPPLICANT_HIDL_STA_IFACE_H #define WPA_SUPPLICANT_HIDL_STA_IFACE_H #include #include #include #include #include #include extern "C" { #include "utils/common.h" #include "utils/includes.h" #include "wpa_supplicant_i.h" #include "config.h" #include "driver_i.h" #include "wpa.h" } namespace android { namespace hardware { namespace wifi { namespace supplicant { namespace V1_0 { namespace implementation { /** * Implementation of StaIface hidl object. Each unique hidl * object is used for control operations on a specific interface * controlled by wpa_supplicant. */ class StaIface : public android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface { public: StaIface(struct wpa_global* wpa_global, const char ifname[]); ~StaIface() override = default; // HIDL does not provide a built-in mechanism to let the server // invalidate a HIDL interface object after creation. If any client // process holds onto a reference to the object in their context, // any method calls on that reference will continue to be directed to // the server. // However Supplicant HAL needs to control the lifetime of these // objects. So, add a public |invalidate| method to all |Iface| and // |Network| objects. // This will be used to mark an object invalid when the corresponding // iface or network is removed. // All HIDL method implementations should check if the object is still // marked valid before processing them. void invalidate(); bool isValid(); // Hidl methods exposed. Return getName(getName_cb _hidl_cb) override; Return getType(getType_cb _hidl_cb) override; Return addNetwork(addNetwork_cb _hidl_cb) override; Return removeNetwork( SupplicantNetworkId id, removeNetwork_cb _hidl_cb) override; Return getNetwork( SupplicantNetworkId id, getNetwork_cb _hidl_cb) override; Return listNetworks(listNetworks_cb _hidl_cb) override; Return registerCallback( const sp& callback, registerCallback_cb _hidl_cb) override; Return reassociate(reassociate_cb _hidl_cb) override; Return reconnect(reconnect_cb _hidl_cb) override; Return disconnect(disconnect_cb _hidl_cb) override; Return setPowerSave( bool enable, setPowerSave_cb _hidl_cb) override; Return initiateTdlsDiscover( const hidl_array& mac_address, initiateTdlsDiscover_cb _hidl_cb) override; Return initiateTdlsSetup( const hidl_array& mac_address, initiateTdlsSetup_cb _hidl_cb) override; Return initiateTdlsTeardown( const hidl_array& mac_address, initiateTdlsTeardown_cb _hidl_cb) override; Return initiateAnqpQuery( const hidl_array& mac_address, const hidl_vec& info_elements, const hidl_vec& sub_types, initiateAnqpQuery_cb _hidl_cb) override; Return initiateHs20IconQuery( const hidl_array& mac_address, const hidl_string& file_name, initiateHs20IconQuery_cb _hidl_cb) override; Return getMacAddress(getMacAddress_cb _hidl_cb) override; Return startRxFilter(startRxFilter_cb _hidl_cb) override; Return stopRxFilter(stopRxFilter_cb _hidl_cb) override; Return addRxFilter( ISupplicantStaIface::RxFilterType type, addRxFilter_cb _hidl_cb) override; Return removeRxFilter( ISupplicantStaIface::RxFilterType type, removeRxFilter_cb _hidl_cb) override; Return setBtCoexistenceMode( ISupplicantStaIface::BtCoexistenceMode mode, setBtCoexistenceMode_cb _hidl_cb) override; Return setBtCoexistenceScanModeEnabled( bool enable, setBtCoexistenceScanModeEnabled_cb _hidl_cb) override; Return setSuspendModeEnabled( bool enable, setSuspendModeEnabled_cb _hidl_cb) override; Return setCountryCode( const hidl_array& code, setCountryCode_cb _hidl_cb) override; Return startWpsRegistrar( const hidl_array& bssid, const hidl_string& pin, startWpsRegistrar_cb _hidl_cb) override; Return startWpsPbc( const hidl_array& bssid, startWpsPbc_cb _hidl_cb) override; Return startWpsPinKeypad( const hidl_string& pin, startWpsPinKeypad_cb _hidl_cb) override; Return startWpsPinDisplay( const hidl_array& bssid, startWpsPinDisplay_cb _hidl_cb) override; Return cancelWps(cancelWps_cb _hidl_cb) override; Return setWpsDeviceName( const hidl_string& name, setWpsDeviceName_cb _hidl_cb) override; Return setWpsDeviceType( const hidl_array& type, setWpsDeviceType_cb _hidl_cb) override; Return setWpsManufacturer( const hidl_string& manufacturer, setWpsManufacturer_cb _hidl_cb) override; Return setWpsModelName( const hidl_string& model_name, setWpsModelName_cb _hidl_cb) override; Return setWpsModelNumber( const hidl_string& model_number, setWpsModelNumber_cb _hidl_cb) override; Return setWpsSerialNumber( const hidl_string& serial_number, setWpsSerialNumber_cb _hidl_cb) override; Return setWpsConfigMethods( uint16_t config_methods, setWpsConfigMethods_cb _hidl_cb) override; Return setExternalSim( bool useExternalSim, setExternalSim_cb _hidl_cb) override; Return addExtRadioWork( const hidl_string& name, uint32_t freq_in_mhz, uint32_t timeout_in_sec, addExtRadioWork_cb _hidl_cb) override; Return removeExtRadioWork( uint32_t id, removeExtRadioWork_cb _hidl_cb) override; Return enableAutoReconnect( bool enable, enableAutoReconnect_cb _hidl_cb) override; private: // Corresponding worker functions for the HIDL methods. std::pair getNameInternal(); std::pair getTypeInternal(); std::pair> addNetworkInternal(); SupplicantStatus removeNetworkInternal(SupplicantNetworkId id); std::pair> getNetworkInternal( SupplicantNetworkId id); std::pair> listNetworksInternal(); SupplicantStatus registerCallbackInternal( const sp& callback); SupplicantStatus reassociateInternal(); SupplicantStatus reconnectInternal(); SupplicantStatus disconnectInternal(); SupplicantStatus setPowerSaveInternal(bool enable); SupplicantStatus initiateTdlsDiscoverInternal( const std::array& mac_address); SupplicantStatus initiateTdlsSetupInternal( const std::array& mac_address); SupplicantStatus initiateTdlsTeardownInternal( const std::array& mac_address); SupplicantStatus initiateAnqpQueryInternal( const std::array& mac_address, const std::vector& info_elements, const std::vector& sub_types); SupplicantStatus initiateHs20IconQueryInternal( const std::array& mac_address, const std::string& file_name); std::pair> getMacAddressInternal(); SupplicantStatus startRxFilterInternal(); SupplicantStatus stopRxFilterInternal(); SupplicantStatus addRxFilterInternal( ISupplicantStaIface::RxFilterType type); SupplicantStatus removeRxFilterInternal( ISupplicantStaIface::RxFilterType type); SupplicantStatus setBtCoexistenceModeInternal( ISupplicantStaIface::BtCoexistenceMode mode); SupplicantStatus setBtCoexistenceScanModeEnabledInternal(bool enable); SupplicantStatus setSuspendModeEnabledInternal(bool enable); SupplicantStatus setCountryCodeInternal( const std::array& code); SupplicantStatus startWpsRegistrarInternal( const std::array& bssid, const std::string& pin); SupplicantStatus startWpsPbcInternal( const std::array& bssid); SupplicantStatus startWpsPinKeypadInternal(const std::string& pin); std::pair startWpsPinDisplayInternal( const std::array& bssid); SupplicantStatus cancelWpsInternal(); SupplicantStatus setWpsDeviceNameInternal(const std::string& name); SupplicantStatus setWpsDeviceTypeInternal( const std::array& type); SupplicantStatus setWpsManufacturerInternal( const std::string& manufacturer); SupplicantStatus setWpsModelNameInternal(const std::string& model_name); SupplicantStatus setWpsModelNumberInternal( const std::string& model_number); SupplicantStatus setWpsSerialNumberInternal( const std::string& serial_number); SupplicantStatus setWpsConfigMethodsInternal(uint16_t config_methods); SupplicantStatus setExternalSimInternal(bool useExternalSim); std::pair addExtRadioWorkInternal( const std::string& name, uint32_t freq_in_mhz, uint32_t timeout_in_sec); SupplicantStatus removeExtRadioWorkInternal(uint32_t id); SupplicantStatus enableAutoReconnectInternal(bool enable); struct wpa_supplicant* retrieveIfacePtr(); // Reference to the global wpa_struct. This is assumed to be valid for // the lifetime of the process. struct wpa_global* wpa_global_; // Name of the iface this hidl object controls const std::string ifname_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(StaIface); }; } // namespace implementation } // namespace V1_0 } // namespace wifi } // namespace supplicant } // namespace hardware } // namespace android #endif // WPA_SUPPLICANT_HIDL_STA_IFACE_H