1 /* 2 * hidl interface for wpa_supplicant daemon 3 * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi> 4 * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com> 5 * 6 * This software may be distributed under the terms of the BSD license. 7 * See README for more details. 8 */ 9 10 #ifndef WPA_SUPPLICANT_HIDL_P2P_NETWORK_H 11 #define WPA_SUPPLICANT_HIDL_P2P_NETWORK_H 12 13 #include <android-base/macros.h> 14 15 #include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetwork.h> 16 #include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetworkCallback.h> 17 18 extern "C" { 19 #include "utils/common.h" 20 #include "utils/includes.h" 21 #include "wpa_supplicant_i.h" 22 } 23 24 namespace android { 25 namespace hardware { 26 namespace wifi { 27 namespace supplicant { 28 namespace V1_0 { 29 namespace implementation { 30 31 /** 32 * Implementation of P2pNetwork hidl object. Each unique hidl 33 * object is used for control operations on a specific network 34 * controlled by wpa_supplicant. 35 */ 36 class P2pNetwork : public ISupplicantP2pNetwork 37 { 38 public: 39 P2pNetwork( 40 struct wpa_global* wpa_global, const char ifname[], int network_id); 41 ~P2pNetwork() override = default; 42 // Refer to |StaIface::invalidate()|. 43 void invalidate(); 44 bool isValid(); 45 46 // Hidl methods exposed. 47 Return<void> getId(getId_cb _hidl_cb) override; 48 Return<void> getInterfaceName(getInterfaceName_cb _hidl_cb) override; 49 Return<void> getType(getType_cb _hidl_cb) override; 50 Return<void> registerCallback( 51 const sp<ISupplicantP2pNetworkCallback>& callback, 52 registerCallback_cb _hidl_cb) override; 53 Return<void> getSsid(getSsid_cb _hidl_cb) override; 54 Return<void> getBssid(getBssid_cb _hidl_cb) override; 55 Return<void> isCurrent(isCurrent_cb _hidl_cb) override; 56 Return<void> isPersistent(isPersistent_cb _hidl_cb) override; 57 Return<void> isGo(isGo_cb _hidl_cb) override; 58 Return<void> setClientList( 59 const hidl_vec<hidl_array<uint8_t, 6>>& clients, 60 setClientList_cb _hidl_cb) override; 61 Return<void> getClientList(getClientList_cb _hidl_cb) override; 62 63 private: 64 // Corresponding worker functions for the HIDL methods. 65 std::pair<SupplicantStatus, uint32_t> getIdInternal(); 66 std::pair<SupplicantStatus, std::string> getInterfaceNameInternal(); 67 std::pair<SupplicantStatus, IfaceType> getTypeInternal(); 68 SupplicantStatus registerCallbackInternal( 69 const sp<ISupplicantP2pNetworkCallback>& callback); 70 std::pair<SupplicantStatus, std::vector<uint8_t>> getSsidInternal(); 71 std::pair<SupplicantStatus, std::array<uint8_t, 6>> getBssidInternal(); 72 std::pair<SupplicantStatus, bool> isCurrentInternal(); 73 std::pair<SupplicantStatus, bool> isPersistentInternal(); 74 std::pair<SupplicantStatus, bool> isGoInternal(); 75 SupplicantStatus setClientListInternal( 76 const std::vector<hidl_array<uint8_t, 6>>& clients); 77 std::pair<SupplicantStatus, std::vector<hidl_array<uint8_t, 6>>> 78 getClientListInternal(); 79 80 struct wpa_ssid* retrieveNetworkPtr(); 81 struct wpa_supplicant* retrieveIfacePtr(); 82 83 // Reference to the global wpa_struct. This is assumed to be valid 84 // for the lifetime of the process. 85 const struct wpa_global* wpa_global_; 86 // Name of the iface this network belongs to. 87 const std::string ifname_; 88 // Id of the network this hidl object controls. 89 const int network_id_; 90 bool is_valid_; 91 92 DISALLOW_COPY_AND_ASSIGN(P2pNetwork); 93 }; 94 95 } // namespace implementation 96 } // namespace V1_0 97 } // namespace wifi 98 } // namespace supplicant 99 } // namespace hardware 100 } // namespace android 101 102 #endif // WPA_SUPPLICANT_HIDL_P2P_NETWORK_H 103