1 /* 2 * WPA Supplicant - Supplicant Aidl interface 3 * Copyright (c) 2021, Google Inc. All rights reserved. 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef WPA_SUPPLICANT_AIDL_SUPPLICANT_H 10 #define WPA_SUPPLICANT_AIDL_SUPPLICANT_H 11 12 #include <aidl/android/hardware/wifi/supplicant/BnSupplicant.h> 13 #include <aidl/android/hardware/wifi/supplicant/DebugLevel.h> 14 #include <aidl/android/hardware/wifi/supplicant/IfaceInfo.h> 15 #include <aidl/android/hardware/wifi/supplicant/ISupplicantCallback.h> 16 #include <aidl/android/hardware/wifi/supplicant/ISupplicantP2pIface.h> 17 #include <aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.h> 18 19 #include <android-base/macros.h> 20 21 extern "C" 22 { 23 #include "utils/common.h" 24 #include "utils/includes.h" 25 #include "utils/wpa_debug.h" 26 #include "wpa_supplicant_i.h" 27 #include "scan.h" 28 } 29 30 namespace aidl { 31 namespace android { 32 namespace hardware { 33 namespace wifi { 34 namespace supplicant { 35 36 /** 37 * Implementation of the supplicant aidl object. This aidl 38 * object is used core for global control operations on 39 * wpa_supplicant. 40 */ 41 class Supplicant : public BnSupplicant 42 { 43 public: 44 Supplicant(struct wpa_global* global); 45 ~Supplicant() override = default; 46 bool isValid(); 47 48 // Aidl methods exposed. 49 ::ndk::ScopedAStatus addP2pInterface( 50 const std::string& in_name, 51 std::shared_ptr<ISupplicantP2pIface>* _aidl_return) override; 52 ::ndk::ScopedAStatus addStaInterface( 53 const std::string& in_name, 54 std::shared_ptr<ISupplicantStaIface>* _aidl_return) override; 55 ::ndk::ScopedAStatus removeInterface( 56 const IfaceInfo& in_ifaceInfo) override; 57 ::ndk::ScopedAStatus getP2pInterface( 58 const std::string& in_name, 59 std::shared_ptr<ISupplicantP2pIface>* _aidl_return) override; 60 ::ndk::ScopedAStatus getStaInterface( 61 const std::string& in_name, 62 std::shared_ptr<ISupplicantStaIface>* _aidl_return) override; 63 ::ndk::ScopedAStatus listInterfaces( 64 std::vector<IfaceInfo>* _aidl_return) override; 65 ::ndk::ScopedAStatus registerCallback( 66 const std::shared_ptr<ISupplicantCallback>& in_callback) override; 67 ::ndk::ScopedAStatus setDebugParams( 68 DebugLevel in_level, bool in_showTimestamp, bool in_showKeys) override; 69 ::ndk::ScopedAStatus getDebugLevel(DebugLevel* _aidl_return) override; 70 ::ndk::ScopedAStatus isDebugShowTimestampEnabled(bool* _aidl_return) override; 71 ::ndk::ScopedAStatus isDebugShowKeysEnabled(bool* _aidl_return) override; 72 ::ndk::ScopedAStatus setConcurrencyPriority(IfaceType in_type) override; 73 ::ndk::ScopedAStatus terminate() override; 74 75 private: 76 // Corresponding worker functions for the AIDL methods. 77 std::pair<std::shared_ptr<ISupplicantP2pIface>, ndk::ScopedAStatus> 78 addP2pInterfaceInternal(const std::string& name); 79 std::pair<std::shared_ptr<ISupplicantStaIface>, ndk::ScopedAStatus> 80 addStaInterfaceInternal(const std::string& name); 81 std::pair<std::shared_ptr<ISupplicantP2pIface>, ndk::ScopedAStatus> 82 getP2pInterfaceInternal(const std::string& name); 83 std::pair<std::shared_ptr<ISupplicantStaIface>, ndk::ScopedAStatus> 84 getStaInterfaceInternal(const std::string& name); 85 86 ndk::ScopedAStatus removeInterfaceInternal(const IfaceInfo& iface_info); 87 std::pair<std::vector<IfaceInfo>, ndk::ScopedAStatus> listInterfacesInternal(); 88 ndk::ScopedAStatus registerCallbackInternal( 89 const std::shared_ptr<ISupplicantCallback>& callback); 90 ndk::ScopedAStatus setDebugParamsInternal( 91 DebugLevel level, bool show_timestamp, bool show_keys); 92 ndk::ScopedAStatus setConcurrencyPriorityInternal(IfaceType type); 93 ndk::ScopedAStatus addP2pDevInterface(struct wpa_interface iface_params); 94 95 // Raw pointer to the global structure maintained by the core. 96 struct wpa_global* wpa_global_; 97 // Driver name to be used for creating interfaces. 98 static const char kDriverName[]; 99 // wpa_supplicant.conf file location on the device. 100 static const char kConfigFilePath[]; 101 102 DISALLOW_COPY_AND_ASSIGN(Supplicant); 103 }; 104 105 } // namespace supplicant 106 } // namespace wifi 107 } // namespace hardware 108 } // namespace android 109 } // namespace aidl 110 111 #endif // WPA_SUPPLICANT_AIDL_SUPPLICANT_H 112