/* * 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_NETWORK_H #define WPA_SUPPLICANT_HIDL_STA_NETWORK_H #include #include #include #include #include extern "C" { #include "utils/common.h" #include "utils/includes.h" #include "config.h" #include "wpa_supplicant_i.h" #include "notify.h" #include "eapol_supp/eapol_supp_sm.h" #include "eap_peer/eap.h" #include "rsn_supp/wpa.h" } namespace android { namespace hardware { namespace wifi { namespace supplicant { namespace V1_2 { namespace implementation { using namespace android::hardware::wifi::supplicant::V1_0; using namespace android::hardware::wifi::supplicant::V1_1; /** * Implementation of StaNetwork hidl object. Each unique hidl * object is used for control operations on a specific network * controlled by wpa_supplicant. */ class StaNetwork : public V1_2::ISupplicantStaNetwork { public: StaNetwork( struct wpa_global* wpa_global, const char ifname[], int network_id); ~StaNetwork() override = default; // Refer to |StaIface::invalidate()|. void invalidate(); bool isValid(); // Hidl methods exposed. Return getId(getId_cb _hidl_cb) override; Return getInterfaceName(getInterfaceName_cb _hidl_cb) override; Return getType(getType_cb _hidl_cb) override; Return registerCallback( const sp& callback, registerCallback_cb _hidl_cb) override; Return setSsid( const hidl_vec& ssid, setSsid_cb _hidl_cb) override; Return setBssid( const hidl_array& bssid, setBssid_cb _hidl_cb) override; Return setScanSsid(bool enable, setScanSsid_cb _hidl_cb) override; Return setKeyMgmt( uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb) override; Return setProto( uint32_t proto_mask, setProto_cb _hidl_cb) override; Return setAuthAlg( uint32_t auth_alg_mask, setAuthAlg_cb _hidl_cb) override; Return setGroupCipher( uint32_t group_cipher_mask, setGroupCipher_cb _hidl_cb) override; Return setPairwiseCipher( uint32_t pairwise_cipher_mask, setPairwiseCipher_cb _hidl_cb) override; Return setPskPassphrase( const hidl_string& psk, setPskPassphrase_cb _hidl_cb) override; Return setPsk( const hidl_array& psk, setPsk_cb _hidl_cb) override; Return setWepKey( uint32_t key_idx, const hidl_vec& wep_key, setWepKey_cb _hidl_cb) override; Return setWepTxKeyIdx( uint32_t key_idx, setWepTxKeyIdx_cb _hidl_cb) override; Return setRequirePmf( bool enable, setRequirePmf_cb _hidl_cb) override; Return setEapMethod( ISupplicantStaNetwork::EapMethod method, setEapMethod_cb _hidl_cb) override; Return setEapPhase2Method( ISupplicantStaNetwork::EapPhase2Method method, setEapPhase2Method_cb _hidl_cb) override; Return setEapIdentity( const hidl_vec& identity, setEapIdentity_cb _hidl_cb) override; Return setEapAnonymousIdentity( const hidl_vec& identity, setEapAnonymousIdentity_cb _hidl_cb) override; Return setEapPassword( const hidl_vec& password, setEapPassword_cb _hidl_cb) override; Return setEapCACert( const hidl_string& path, setEapCACert_cb _hidl_cb) override; Return setEapCAPath( const hidl_string& path, setEapCAPath_cb _hidl_cb) override; Return setEapClientCert( const hidl_string& path, setEapClientCert_cb _hidl_cb) override; Return setEapPrivateKeyId( const hidl_string& id, setEapPrivateKeyId_cb _hidl_cb) override; Return setEapEncryptedImsiIdentity( const EapSimEncryptedIdentity& identity, setEapEncryptedImsiIdentity_cb _hidl_cb) override; Return setEapSubjectMatch( const hidl_string& match, setEapSubjectMatch_cb _hidl_cb) override; Return setEapAltSubjectMatch( const hidl_string& match, setEapAltSubjectMatch_cb _hidl_cb) override; Return setEapEngine( bool enable, setEapEngine_cb _hidl_cb) override; Return setEapEngineID( const hidl_string& id, setEapEngineID_cb _hidl_cb) override; Return setEapDomainSuffixMatch( const hidl_string& match, setEapDomainSuffixMatch_cb _hidl_cb) override; Return setProactiveKeyCaching( bool enable, setProactiveKeyCaching_cb _hidl_cb) override; Return setIdStr( const hidl_string& id_str, setIdStr_cb _hidl_cb) override; Return setUpdateIdentifier( uint32_t id, setUpdateIdentifier_cb _hidl_cb) override; Return getSsid(getSsid_cb _hidl_cb) override; Return getBssid(getBssid_cb _hidl_cb) override; Return getScanSsid(getScanSsid_cb _hidl_cb) override; Return getKeyMgmt(getKeyMgmt_cb _hidl_cb) override; Return getProto(getProto_cb _hidl_cb) override; Return getAuthAlg(getAuthAlg_cb _hidl_cb) override; Return getGroupCipher(getGroupCipher_cb _hidl_cb) override; Return getPairwiseCipher(getPairwiseCipher_cb _hidl_cb) override; Return getPskPassphrase(getPskPassphrase_cb _hidl_cb) override; Return getPsk(getPsk_cb _hidl_cb) override; Return getSaePassword(getSaePassword_cb _hidl_cb) override; Return getSaePasswordId(getSaePasswordId_cb _hidl_cb) override; Return getWepKey( uint32_t key_idx, getWepKey_cb _hidl_cb) override; Return getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb) override; Return getRequirePmf(getRequirePmf_cb _hidl_cb) override; Return getEapMethod(getEapMethod_cb _hidl_cb) override; Return getEapPhase2Method( getEapPhase2Method_cb _hidl_cb) override; Return getEapIdentity(getEapIdentity_cb _hidl_cb) override; Return getEapAnonymousIdentity( getEapAnonymousIdentity_cb _hidl_cb) override; Return getEapPassword(getEapPassword_cb _hidl_cb) override; Return getEapCACert(getEapCACert_cb _hidl_cb) override; Return getEapCAPath(getEapCAPath_cb _hidl_cb) override; Return getEapClientCert(getEapClientCert_cb _hidl_cb) override; Return getEapPrivateKeyId( getEapPrivateKeyId_cb _hidl_cb) override; Return getEapSubjectMatch( getEapSubjectMatch_cb _hidl_cb) override; Return getEapAltSubjectMatch( getEapAltSubjectMatch_cb _hidl_cb) override; Return getEapEngine(getEapEngine_cb _hidl_cb) override; Return getEapEngineID(getEapEngineID_cb _hidl_cb) override; Return getEapDomainSuffixMatch( getEapDomainSuffixMatch_cb _hidl_cb) override; Return getIdStr(getIdStr_cb _hidl_cb) override; Return getWpsNfcConfigurationToken( getWpsNfcConfigurationToken_cb _hidl_cb) override; Return enable(bool no_connect, enable_cb _hidl_cb) override; Return disable(disable_cb _hidl_cb) override; Return select(select_cb _hidl_cb) override; Return sendNetworkEapSimGsmAuthResponse( const hidl_vec< ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams>& vec_params, sendNetworkEapSimGsmAuthResponse_cb _hidl_cb) override; Return sendNetworkEapSimGsmAuthFailure( sendNetworkEapSimGsmAuthFailure_cb _hidl_cb) override; Return sendNetworkEapSimUmtsAuthResponse( const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams& params, sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb) override; Return sendNetworkEapSimUmtsAutsResponse( const hidl_array& auts, sendNetworkEapSimUmtsAutsResponse_cb _hidl_cb) override; Return sendNetworkEapSimUmtsAuthFailure( sendNetworkEapSimUmtsAuthFailure_cb _hidl_cb) override; Return sendNetworkEapIdentityResponse( const hidl_vec& identity, sendNetworkEapIdentityResponse_cb _hidl_cb) override; Return sendNetworkEapIdentityResponse_1_1( const EapSimIdentity& identity, const EapSimEncryptedIdentity& imsiIdentity, sendNetworkEapIdentityResponse_1_1_cb _hidl_cb) override; Return setKeyMgmt_1_2( uint32_t key_mgmt_mask, setKeyMgmt_1_2_cb _hidl_cb) override; Return getKeyMgmt_1_2(getKeyMgmt_1_2_cb _hidl_cb) override; Return setPairwiseCipher_1_2( uint32_t pairwise_cipher_mask, setPairwiseCipher_1_2_cb _hidl_cb) override; Return getPairwiseCipher_1_2( getPairwiseCipher_1_2_cb _hidl_cb) override; Return setGroupCipher_1_2( uint32_t group_cipher_mask, setGroupCipher_1_2_cb _hidl_cb) override; Return getGroupCipher_1_2( getGroupCipher_1_2_cb _hidl_cb) override; Return setGroupMgmtCipher( uint32_t group_mgmt_cipher_mask, setGroupMgmtCipher_cb _hidl_cb) override; Return getGroupMgmtCipher( getGroupMgmtCipher_cb _hidl_cb) override; Return enableTlsSuiteBEapPhase1Param( bool enable, enableTlsSuiteBEapPhase1Param_cb _hidl_cb) override; Return enableSuiteBEapOpenSslCiphers( enableSuiteBEapOpenSslCiphers_cb _hidl_cb) override; Return setSaePassword( const hidl_string& sae_password, setSaePassword_cb _hidl_cb) override; Return setSaePasswordId( const hidl_string& sae_password_id, setSaePasswordId_cb _hidl_cb) override; private: // Corresponding worker functions for the HIDL methods. std::pair getIdInternal(); std::pair getInterfaceNameInternal(); std::pair getTypeInternal(); SupplicantStatus registerCallbackInternal( const sp& callback); SupplicantStatus setSsidInternal(const std::vector& ssid); SupplicantStatus setBssidInternal(const std::array& bssid); SupplicantStatus setScanSsidInternal(bool enable); SupplicantStatus setKeyMgmtInternal(uint32_t key_mgmt_mask); SupplicantStatus setProtoInternal(uint32_t proto_mask); SupplicantStatus setAuthAlgInternal(uint32_t auth_alg_mask); SupplicantStatus setGroupCipherInternal(uint32_t group_cipher_mask); SupplicantStatus setPairwiseCipherInternal( uint32_t pairwise_cipher_mask); SupplicantStatus setPskPassphraseInternal(const std::string& psk); SupplicantStatus setPskInternal(const std::array& psk); SupplicantStatus setWepKeyInternal( uint32_t key_idx, const std::vector& wep_key); SupplicantStatus setWepTxKeyIdxInternal(uint32_t key_idx); SupplicantStatus setRequirePmfInternal(bool enable); SupplicantStatus setEapMethodInternal( ISupplicantStaNetwork::EapMethod method); SupplicantStatus setEapPhase2MethodInternal( ISupplicantStaNetwork::EapPhase2Method method); SupplicantStatus setEapIdentityInternal( const std::vector& identity); SupplicantStatus setEapEncryptedImsiIdentityInternal( const std::vector& identity); SupplicantStatus setEapAnonymousIdentityInternal( const std::vector& identity); SupplicantStatus setEapPasswordInternal( const std::vector& password); SupplicantStatus setEapCACertInternal(const std::string& path); SupplicantStatus setEapCAPathInternal(const std::string& path); SupplicantStatus setEapClientCertInternal(const std::string& path); SupplicantStatus setEapPrivateKeyIdInternal(const std::string& id); SupplicantStatus setEapSubjectMatchInternal(const std::string& match); SupplicantStatus setEapAltSubjectMatchInternal( const std::string& match); SupplicantStatus setEapEngineInternal(bool enable); SupplicantStatus setEapEngineIDInternal(const std::string& id); SupplicantStatus setEapDomainSuffixMatchInternal( const std::string& match); SupplicantStatus setProactiveKeyCachingInternal(bool enable); SupplicantStatus setIdStrInternal(const std::string& id_str); SupplicantStatus setUpdateIdentifierInternal(uint32_t id); std::pair> getSsidInternal(); std::pair> getBssidInternal(); std::pair getScanSsidInternal(); std::pair getKeyMgmtInternal(); std::pair getProtoInternal(); std::pair getAuthAlgInternal(); std::pair getGroupCipherInternal(); std::pair getPairwiseCipherInternal(); std::pair getPskPassphraseInternal(); std::pair> getPskInternal(); std::pair getSaePasswordInternal(); std::pair getSaePasswordIdInternal(); std::pair> getWepKeyInternal( uint32_t key_idx); std::pair getWepTxKeyIdxInternal(); std::pair getRequirePmfInternal(); std::pair getEapMethodInternal(); std::pair getEapPhase2MethodInternal(); std::pair> getEapIdentityInternal(); std::pair> getEapAnonymousIdentityInternal(); std::pair> getEapPasswordInternal(); std::pair getEapCACertInternal(); std::pair getEapCAPathInternal(); std::pair getEapClientCertInternal(); std::pair getEapPrivateKeyIdInternal(); std::pair getEapSubjectMatchInternal(); std::pair getEapAltSubjectMatchInternal(); std::pair getEapEngineInternal(); std::pair getEapEngineIDInternal(); std::pair getEapDomainSuffixMatchInternal(); std::pair getIdStrInternal(); std::pair> getWpsNfcConfigurationTokenInternal(); SupplicantStatus enableInternal(bool no_connect); SupplicantStatus disableInternal(); SupplicantStatus selectInternal(); SupplicantStatus sendNetworkEapSimGsmAuthResponseInternal( const std::vector< ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams>& vec_params); SupplicantStatus sendNetworkEapSimGsmAuthFailureInternal(); SupplicantStatus sendNetworkEapSimUmtsAuthResponseInternal( const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams& params); SupplicantStatus sendNetworkEapSimUmtsAutsResponseInternal( const std::array& auts); SupplicantStatus sendNetworkEapSimUmtsAuthFailureInternal(); SupplicantStatus sendNetworkEapIdentityResponseInternal( const std::vector& identity); SupplicantStatus sendNetworkEapIdentityResponseInternal_1_1( const std::vector& identity, const std::vector& imsi_identity); SupplicantStatus enableTlsSuiteBEapPhase1ParamInternal(bool enable); SupplicantStatus enableSuiteBEapOpenSslCiphersInternal(); SupplicantStatus setSaePasswordInternal( const std::string& sae_password); SupplicantStatus setSaePasswordIdInternal( const std::string& sae_password_id); SupplicantStatus setGroupMgmtCipherInternal(uint32_t group_mgmt_cipher_mask); std::pair getGroupMgmtCipherInternal(); struct wpa_ssid* retrieveNetworkPtr(); struct wpa_supplicant* retrieveIfacePtr(); int isPskPassphraseValid(const std::string& psk); void resetInternalStateAfterParamsUpdate(); int setStringFieldAndResetState( const char* value, uint8_t** to_update_field, const char* hexdump_prefix); int setStringFieldAndResetState( const char* value, char** to_update_field, const char* hexdump_prefix); int setStringKeyFieldAndResetState( const char* value, char** to_update_field, const char* hexdump_prefix); int setByteArrayFieldAndResetState( const uint8_t* value, const size_t value_len, uint8_t** to_update_field, size_t* to_update_field_len, const char* hexdump_prefix); int setByteArrayKeyFieldAndResetState( const uint8_t* value, const size_t value_len, uint8_t** to_update_field, size_t* to_update_field_len, const char* hexdump_prefix); void setFastTransitionKeyMgmt(uint32_t &key_mgmt_mask); void resetFastTransitionKeyMgmt(uint32_t &key_mgmt_mask); // 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 network belongs to. const std::string ifname_; // Id of the network this hidl object controls. const int network_id_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(StaNetwork); }; } // namespace implementation } // namespace V1_2 } // namespace supplicant } // namespace wifi } // namespace hardware } // namespace android #endif // WPA_SUPPLICANT_HIDL_STA_NETWORK_H