Gabriel Biren | 57ededa | 2021-09-03 16:08:50 +0000 | [diff] [blame] | 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; |
Gabriel Biren | ce222d7 | 2022-12-09 01:03:10 +0000 | [diff] [blame] | 67 | ::ndk::ScopedAStatus registerNonStandardCertCallback( |
| 68 | const std::shared_ptr<INonStandardCertCallback>& in_callback) override; |
Gabriel Biren | 57ededa | 2021-09-03 16:08:50 +0000 | [diff] [blame] | 69 | ::ndk::ScopedAStatus setDebugParams( |
| 70 | DebugLevel in_level, bool in_showTimestamp, bool in_showKeys) override; |
| 71 | ::ndk::ScopedAStatus getDebugLevel(DebugLevel* _aidl_return) override; |
| 72 | ::ndk::ScopedAStatus isDebugShowTimestampEnabled(bool* _aidl_return) override; |
| 73 | ::ndk::ScopedAStatus isDebugShowKeysEnabled(bool* _aidl_return) override; |
| 74 | ::ndk::ScopedAStatus setConcurrencyPriority(IfaceType in_type) override; |
| 75 | ::ndk::ScopedAStatus terminate() override; |
| 76 | |
| 77 | private: |
| 78 | // Corresponding worker functions for the AIDL methods. |
| 79 | std::pair<std::shared_ptr<ISupplicantP2pIface>, ndk::ScopedAStatus> |
| 80 | addP2pInterfaceInternal(const std::string& name); |
| 81 | std::pair<std::shared_ptr<ISupplicantStaIface>, ndk::ScopedAStatus> |
| 82 | addStaInterfaceInternal(const std::string& name); |
| 83 | std::pair<std::shared_ptr<ISupplicantP2pIface>, ndk::ScopedAStatus> |
| 84 | getP2pInterfaceInternal(const std::string& name); |
| 85 | std::pair<std::shared_ptr<ISupplicantStaIface>, ndk::ScopedAStatus> |
| 86 | getStaInterfaceInternal(const std::string& name); |
Gabriel Biren | ce222d7 | 2022-12-09 01:03:10 +0000 | [diff] [blame] | 87 | |
Gabriel Biren | 57ededa | 2021-09-03 16:08:50 +0000 | [diff] [blame] | 88 | ndk::ScopedAStatus removeInterfaceInternal(const IfaceInfo& iface_info); |
| 89 | std::pair<std::vector<IfaceInfo>, ndk::ScopedAStatus> listInterfacesInternal(); |
| 90 | ndk::ScopedAStatus registerCallbackInternal( |
| 91 | const std::shared_ptr<ISupplicantCallback>& callback); |
Gabriel Biren | ce222d7 | 2022-12-09 01:03:10 +0000 | [diff] [blame] | 92 | ndk::ScopedAStatus registerNonStandardCertCallbackInternal( |
| 93 | const std::shared_ptr<INonStandardCertCallback>& callback); |
Gabriel Biren | 57ededa | 2021-09-03 16:08:50 +0000 | [diff] [blame] | 94 | ndk::ScopedAStatus setDebugParamsInternal( |
| 95 | DebugLevel level, bool show_timestamp, bool show_keys); |
| 96 | ndk::ScopedAStatus setConcurrencyPriorityInternal(IfaceType type); |
| 97 | ndk::ScopedAStatus addP2pDevInterface(struct wpa_interface iface_params); |
| 98 | |
| 99 | // Raw pointer to the global structure maintained by the core. |
| 100 | struct wpa_global* wpa_global_; |
| 101 | // Driver name to be used for creating interfaces. |
| 102 | static const char kDriverName[]; |
| 103 | // wpa_supplicant.conf file location on the device. |
| 104 | static const char kConfigFilePath[]; |
| 105 | |
| 106 | DISALLOW_COPY_AND_ASSIGN(Supplicant); |
| 107 | }; |
| 108 | |
| 109 | } // namespace supplicant |
| 110 | } // namespace wifi |
| 111 | } // namespace hardware |
| 112 | } // namespace android |
| 113 | } // namespace aidl |
| 114 | |
| 115 | #endif // WPA_SUPPLICANT_AIDL_SUPPLICANT_H |