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