xref: /aosp_15_r20/external/wpa_supplicant_8/wpa_supplicant/aidl/vendor/p2p_network.h (revision 03f9172ca588f91df233974f4258bab95191f931)
1 /*
2  * WPA Supplicant - P2P network 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_P2P_NETWORK_H
10 #define WPA_SUPPLICANT_AIDL_P2P_NETWORK_H
11 
12 #include <android-base/macros.h>
13 
14 #include <aidl/android/hardware/wifi/supplicant/BnSupplicantP2pNetwork.h>
15 
16 extern "C"
17 {
18 #include "utils/common.h"
19 #include "utils/includes.h"
20 #include "wpa_supplicant_i.h"
21 }
22 
23 namespace aidl {
24 namespace android {
25 namespace hardware {
26 namespace wifi {
27 namespace supplicant {
28 
29 /**
30  * Implementation of P2pNetwork aidl object. Each unique aidl
31  * object is used for control operations on a specific network
32  * controlled by wpa_supplicant.
33  */
34 class P2pNetwork : public BnSupplicantP2pNetwork
35 {
36 public:
37 	P2pNetwork(
38 		struct wpa_global* wpa_global, const char ifname[], int network_id);
39 	~P2pNetwork() override = default;
40 	// Refer to |StaIface::invalidate()|.
41 	void invalidate();
42 	bool isValid();
43 
44 	// Aidl methods exposed.
45   	::ndk::ScopedAStatus getId(int32_t* _aidl_return) override;
46 	::ndk::ScopedAStatus getInterfaceName(std::string* _aidl_return) override;
47 	::ndk::ScopedAStatus getType(IfaceType* _aidl_return) override;
48 	::ndk::ScopedAStatus getSsid(std::vector<uint8_t>* _aidl_return) override;
49 	::ndk::ScopedAStatus getBssid(std::vector<uint8_t>* _aidl_return) override;
50 	::ndk::ScopedAStatus isCurrent(bool* _aidl_return) override;
51 	::ndk::ScopedAStatus isPersistent(bool* _aidl_return) override;
52 	::ndk::ScopedAStatus isGroupOwner(bool* _aidl_return) override;
53 	::ndk::ScopedAStatus setClientList(
54 		const std::vector<MacAddress>& in_clients) override;
55 	::ndk::ScopedAStatus getClientList(
56 		std::vector<MacAddress>* _aidl_return) override;
57 
58 private:
59 	// Corresponding worker functions for the AIDL methods.
60 	std::pair<uint32_t, ndk::ScopedAStatus> getIdInternal();
61 	std::pair<std::string, ndk::ScopedAStatus> getInterfaceNameInternal();
62 	std::pair<IfaceType, ndk::ScopedAStatus> getTypeInternal();
63 	std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> getSsidInternal();
64 	std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> getBssidInternal();
65 	std::pair<bool, ndk::ScopedAStatus> isCurrentInternal();
66 	std::pair<bool, ndk::ScopedAStatus> isPersistentInternal();
67 	std::pair<bool, ndk::ScopedAStatus> isGroupOwnerInternal();
68 	ndk::ScopedAStatus setClientListInternal(
69 		const std::vector<MacAddress>& clients);
70 	std::pair<std::vector<MacAddress>, ndk::ScopedAStatus>
71 		getClientListInternal();
72 
73 	struct wpa_ssid* retrieveNetworkPtr();
74 	struct wpa_supplicant* retrieveIfacePtr();
75 
76 	// Reference to the global wpa_struct. This is assumed to be valid
77 	// for the lifetime of the process.
78 	const struct wpa_global* wpa_global_;
79 	// Name of the iface this network belongs to.
80 	const std::string ifname_;
81 	// Id of the network this aidl object controls.
82 	const int network_id_;
83 	bool is_valid_;
84 
85 	DISALLOW_COPY_AND_ASSIGN(P2pNetwork);
86 };
87 
88 }  // namespace supplicant
89 }  // namespace wifi
90 }  // namespace hardware
91 }  // namespace android
92 }  // namespace aidl
93 
94 #endif  // WPA_SUPPLICANT_AIDL_P2P_NETWORK_H
95