/* * WPA Supplicant - P2P Iface Aidl interface * Copyright (c) 2021, Google Inc. All rights reserved. * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #ifndef WPA_SUPPLICANT_AIDL_P2P_IFACE_H #define WPA_SUPPLICANT_AIDL_P2P_IFACE_H #include #include #include #include #include #include #include #include #include extern "C" { #include "utils/common.h" #include "utils/includes.h" #include "p2p/p2p.h" #include "p2p/p2p_i.h" #include "p2p_supplicant.h" #include "p2p_supplicant.h" #include "config.h" } #define P2P_MGMT_DEVICE_PREFIX "p2p-dev-" namespace aidl { namespace android { namespace hardware { namespace wifi { namespace supplicant { /** * Implementation of P2pIface aidl object. Each unique aidl * object is used for control operations on a specific interface * controlled by wpa_supplicant. */ class P2pIface : public BnSupplicantP2pIface { public: P2pIface(struct wpa_global* wpa_global, const char ifname[]); ~P2pIface() override = default; // Refer to |StaIface::invalidate()|. void invalidate(); bool isValid(); // Aidl methods exposed. ::ndk::ScopedAStatus getName(std::string* _aidl_return) override; ::ndk::ScopedAStatus getType(IfaceType* _aidl_return) override; ::ndk::ScopedAStatus addNetwork( std::shared_ptr* _aidl_return) override; ::ndk::ScopedAStatus removeNetwork(int32_t in_id) override; ::ndk::ScopedAStatus getNetwork( int32_t in_id, std::shared_ptr* _aidl_return) override; ::ndk::ScopedAStatus listNetworks(std::vector* _aidl_return) override; ::ndk::ScopedAStatus registerCallback( const std::shared_ptr& in_callback) override; ::ndk::ScopedAStatus getDeviceAddress(std::vector* _aidl_return) override; ::ndk::ScopedAStatus setSsidPostfix(const std::vector& in_postfix) override; ::ndk::ScopedAStatus setGroupIdle( const std::string& in_groupIfName, int32_t in_timeoutInSec) override; ::ndk::ScopedAStatus setPowerSave( const std::string& in_groupIfName, bool in_enable) override; ::ndk::ScopedAStatus find(int32_t in_timeoutInSec) override; ::ndk::ScopedAStatus stopFind() override; ::ndk::ScopedAStatus flush() override; ::ndk::ScopedAStatus connect( const std::vector& in_peerAddress, WpsProvisionMethod in_provisionMethod, const std::string& in_preSelectedPin, bool in_joinExistingGroup, bool in_persistent, int32_t in_goIntent, std::string* _aidl_return) override; ::ndk::ScopedAStatus cancelConnect() override; ::ndk::ScopedAStatus provisionDiscovery( const std::vector& in_peerAddress, WpsProvisionMethod in_provisionMethod) override; ::ndk::ScopedAStatus addGroup(bool in_persistent, int32_t in_persistentNetworkId) override; ::ndk::ScopedAStatus addGroupWithConfig( const std::vector& in_ssid, const std::string& in_pskPassphrase, bool in_persistent, int32_t in_freq, const std::vector& in_peerAddress, bool in_joinExistingGroup) override; ::ndk::ScopedAStatus removeGroup(const std::string& in_groupIfName) override; ::ndk::ScopedAStatus reject(const std::vector& in_peerAddress) override; ::ndk::ScopedAStatus invite( const std::string& in_groupIfName, const std::vector& in_goDeviceAddress, const std::vector& in_peerAddress) override; ::ndk::ScopedAStatus reinvoke( int32_t in_persistentNetworkId, const std::vector& in_peerAddress) override; ::ndk::ScopedAStatus configureExtListen( int32_t in_periodInMillis, int32_t in_intervalInMillis) override; ::ndk::ScopedAStatus setListenChannel( int32_t in_channel, int32_t in_operatingClass) override; ::ndk::ScopedAStatus setDisallowedFrequencies( const std::vector& in_ranges) override; ::ndk::ScopedAStatus getSsid( const std::vector& in_peerAddress, std::vector* _aidl_return) override; ::ndk::ScopedAStatus getGroupCapability( const std::vector& in_peerAddress, P2pGroupCapabilityMask* _aidl_return) override; ::ndk::ScopedAStatus addBonjourService( const std::vector& in_query, const std::vector& in_response) override; ::ndk::ScopedAStatus removeBonjourService( const std::vector& in_query) override; ::ndk::ScopedAStatus addUpnpService( int32_t in_version, const std::string& in_serviceName) override; ::ndk::ScopedAStatus removeUpnpService( int32_t in_version, const std::string& in_serviceName) override; ::ndk::ScopedAStatus flushServices() override; ::ndk::ScopedAStatus requestServiceDiscovery( const std::vector& in_peerAddress, const std::vector& in_query, int64_t* _aidl_return) override; ::ndk::ScopedAStatus cancelServiceDiscovery(int64_t in_identifier) override; ::ndk::ScopedAStatus setMiracastMode(MiracastMode in_mode) override; ::ndk::ScopedAStatus startWpsPbc( const std::string& in_groupIfName, const std::vector& in_bssid) override; ::ndk::ScopedAStatus startWpsPinKeypad( const std::string& in_groupIfName, const std::string& in_pin) override; ::ndk::ScopedAStatus startWpsPinDisplay( const std::string& in_groupIfName, const std::vector& in_bssid, std::string* _aidl_return) override; ::ndk::ScopedAStatus cancelWps(const std::string& in_groupIfName) override; ::ndk::ScopedAStatus setWpsDeviceName( const std::string& in_name) override; ::ndk::ScopedAStatus setWpsDeviceType( const std::vector& in_type) override; ::ndk::ScopedAStatus setWpsManufacturer( const std::string& in_manufacturer) override; ::ndk::ScopedAStatus setWpsModelName( const std::string& in_modelName) override; ::ndk::ScopedAStatus setWpsModelNumber( const std::string& in_modelNumber) override; ::ndk::ScopedAStatus setWpsSerialNumber( const std::string& in_serialNumber) override; ::ndk::ScopedAStatus setWpsConfigMethods( WpsConfigMethods in_configMethods) override; ::ndk::ScopedAStatus enableWfd(bool in_enable) override; ::ndk::ScopedAStatus setWfdDeviceInfo( const std::vector& in_info) override; ::ndk::ScopedAStatus createNfcHandoverRequestMessage( std::vector* _aidl_return) override; ::ndk::ScopedAStatus createNfcHandoverSelectMessage( std::vector* _aidl_return) override; ::ndk::ScopedAStatus reportNfcHandoverInitiation( const std::vector& in_select) override; ::ndk::ScopedAStatus reportNfcHandoverResponse( const std::vector& in_request) override; ::ndk::ScopedAStatus saveConfig() override; ::ndk::ScopedAStatus setMacRandomization(bool in_enable) override; ::ndk::ScopedAStatus setEdmg(bool in_enable) override; ::ndk::ScopedAStatus getEdmg(bool* _aidl_return) override; ::ndk::ScopedAStatus setWfdR2DeviceInfo( const std::vector& in_info) override; ::ndk::ScopedAStatus removeClient( const std::vector& peer_address, bool isLegacyClient) override; ::ndk::ScopedAStatus findOnSocialChannels(int32_t in_timeoutInSec) override; ::ndk::ScopedAStatus findOnSpecificFrequency( int32_t in_freq, int32_t in_timeoutInSec) override; ::ndk::ScopedAStatus setVendorElements( P2pFrameTypeMask in_frameTypeMask, const std::vector& in_vendorElemBytes) override; private: // Corresponding worker functions for the AIDL methods. std::pair getNameInternal(); std::pair getTypeInternal(); std::pair, ndk::ScopedAStatus> addNetworkInternal(); ndk::ScopedAStatus removeNetworkInternal(int32_t id); std::pair, ndk::ScopedAStatus> getNetworkInternal(int32_t id); std::pair, ndk::ScopedAStatus> listNetworksInternal(); ndk::ScopedAStatus registerCallbackInternal( const std::shared_ptr& callback); std::pair, ndk::ScopedAStatus> getDeviceAddressInternal(); ndk::ScopedAStatus setSsidPostfixInternal( const std::vector& postfix); ndk::ScopedAStatus setGroupIdleInternal( const std::string& group_ifname, uint32_t timeout_in_sec); ndk::ScopedAStatus setPowerSaveInternal( const std::string& group_ifname, bool enable); ndk::ScopedAStatus findInternal(uint32_t timeout_in_sec); ndk::ScopedAStatus stopFindInternal(); ndk::ScopedAStatus flushInternal(); std::pair connectInternal( const std::vector& peer_address, WpsProvisionMethod provision_method, const std::string& pre_selected_pin, bool join_existing_group, bool persistent, uint32_t go_intent); ndk::ScopedAStatus cancelConnectInternal(); ndk::ScopedAStatus provisionDiscoveryInternal( const std::vector& peer_address, WpsProvisionMethod provision_method); ndk::ScopedAStatus addGroupInternal(bool in_persistent, int32_t in_persistentNetworkId); ndk::ScopedAStatus addGroupWithConfigInternal( const std::vector& ssid, const std::string& passphrase, bool persistent, uint32_t freq, const std::vector& peer_address, bool joinExistingGroup); ndk::ScopedAStatus removeGroupInternal(const std::string& group_ifname); ndk::ScopedAStatus rejectInternal( const std::vector& peer_address); ndk::ScopedAStatus inviteInternal( const std::string& group_ifname, const std::vector& go_device_address, const std::vector& peer_address); ndk::ScopedAStatus reinvokeInternal( int32_t persistent_network_id, const std::vector& peer_address); ndk::ScopedAStatus configureExtListenInternal( uint32_t period_in_millis, uint32_t interval_in_millis); ndk::ScopedAStatus setListenChannelInternal( uint32_t channel, uint32_t operating_class); ndk::ScopedAStatus setDisallowedFrequenciesInternal( const std::vector& ranges); std::pair, ndk::ScopedAStatus> getSsidInternal( const std::vector& peer_address); std::pair getGroupCapabilityInternal( const std::vector& peer_address); ndk::ScopedAStatus addBonjourServiceInternal( const std::vector& query, const std::vector& response); ndk::ScopedAStatus removeBonjourServiceInternal( const std::vector& query); ndk::ScopedAStatus addUpnpServiceInternal( uint32_t version, const std::string& service_name); ndk::ScopedAStatus removeUpnpServiceInternal( uint32_t version, const std::string& service_name); ndk::ScopedAStatus flushServicesInternal(); std::pair requestServiceDiscoveryInternal( const std::vector& peer_address, const std::vector& query); ndk::ScopedAStatus cancelServiceDiscoveryInternal(uint64_t identifier); ndk::ScopedAStatus setMiracastModeInternal( MiracastMode mode); ndk::ScopedAStatus startWpsPbcInternal( const std::string& group_ifname, const std::vector& bssid); ndk::ScopedAStatus startWpsPinKeypadInternal( const std::string& group_ifname, const std::string& pin); std::pair startWpsPinDisplayInternal( const std::string& group_ifname, const std::vector& bssid); ndk::ScopedAStatus cancelWpsInternal(const std::string& group_ifname); ndk::ScopedAStatus setWpsDeviceNameInternal(const std::string& name); ndk::ScopedAStatus setWpsDeviceTypeInternal( const std::vector& type); ndk::ScopedAStatus setWpsManufacturerInternal( const std::string& manufacturer); ndk::ScopedAStatus setWpsModelNameInternal(const std::string& model_name); ndk::ScopedAStatus setWpsModelNumberInternal( const std::string& model_number); ndk::ScopedAStatus setWpsSerialNumberInternal( const std::string& serial_number); ndk::ScopedAStatus setWpsConfigMethodsInternal(WpsConfigMethods config_methods); ndk::ScopedAStatus enableWfdInternal(bool enable); ndk::ScopedAStatus setWfdDeviceInfoInternal( const std::vector& info); std::pair, ndk::ScopedAStatus> createNfcHandoverRequestMessageInternal(); std::pair, ndk::ScopedAStatus> createNfcHandoverSelectMessageInternal(); ndk::ScopedAStatus reportNfcHandoverResponseInternal( const std::vector& request); ndk::ScopedAStatus reportNfcHandoverInitiationInternal( const std::vector& select); ndk::ScopedAStatus saveConfigInternal(); ndk::ScopedAStatus setMacRandomizationInternal(bool enable); ndk::ScopedAStatus setEdmgInternal(bool enable); std::pair getEdmgInternal(); ndk::ScopedAStatus setWfdR2DeviceInfoInternal( const std::vector& info); ndk::ScopedAStatus removeClientInternal( const std::vector& peer_address, bool isLegacyClient); ndk::ScopedAStatus findOnSocialChannelsInternal(uint32_t timeout_in_sec); ndk::ScopedAStatus findOnSpecificFrequencyInternal( uint32_t freq, uint32_t timeout_in_sec); ndk::ScopedAStatus setVendorElementsInternal( P2pFrameTypeMask frameTypeMask, const std::vector& vendorElemBytes); struct wpa_supplicant* retrieveIfacePtr(); struct wpa_supplicant* retrieveGroupIfacePtr( const std::string& group_ifname); // 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 aidl object controls const std::string ifname_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(P2pIface); }; } // namespace supplicant } // namespace wifi } // namespace hardware } // namespace android } // namespace aidl #endif // WPA_SUPPLICANT_AIDL_P2P_IFACE_H