• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hidl interface for wpa_hostapd daemon
3  * Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2004-2018, 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 HOSTAPD_HIDL_SUPPLICANT_H
11 #define HOSTAPD_HIDL_SUPPLICANT_H
12 
13 #include <string>
14 
15 #include <android-base/macros.h>
16 
17 #include <android/hardware/wifi/hostapd/1.3/IHostapd.h>
18 #include <android/hardware/wifi/hostapd/1.3/IHostapdCallback.h>
19 
20 extern "C"
21 {
22 #include "utils/common.h"
23 #include "utils/eloop.h"
24 #include "utils/includes.h"
25 #include "utils/wpa_debug.h"
26 #include "ap/hostapd.h"
27 #include "ap/sta_info.h"
28 }
29 
30 class DeathNotifier : public android::hardware::hidl_death_recipient
31 {
32 public:
serviceDied(uint64_t,const android::wp<android::hidl::base::V1_0::IBase> &)33 	void serviceDied(
34 	    uint64_t /*cookie*/,
35 	    const android::wp<android::hidl::base::V1_0::IBase>
36 		& /* who */) override
37 	{
38 		wpa_printf(MSG_ERROR, "Client died. Terminating...");
39 		eloop_terminate();
40 	}
41 };
42 
43 namespace android {
44 namespace hardware {
45 namespace wifi {
46 namespace hostapd {
47 namespace V1_3 {
48 namespace implementation {
49 using namespace android::hardware::wifi::hostapd::V1_0;
50 
51 /**
52  * Implementation of the hostapd hidl object. This hidl
53  * object is used core for global control operations on
54  * hostapd.
55  */
56 class Hostapd : public V1_3::IHostapd
57 {
58 public:
59 	Hostapd(hapd_interfaces* interfaces);
60 	~Hostapd() override = default;
61 
62 	// Hidl methods exposed.
63 	Return<void> addAccessPoint(
64 	    const V1_0::IHostapd::IfaceParams& iface_params,
65 	    const V1_0::IHostapd::NetworkParams& nw_params, addAccessPoint_cb _hidl_cb) override;
66 	Return<void> addAccessPoint_1_1(
67 	    const V1_1::IHostapd::IfaceParams& iface_params,
68 	    const V1_0::IHostapd::NetworkParams& nw_params, addAccessPoint_cb _hidl_cb) override;
69 	Return<void> addAccessPoint_1_2(
70 	    const V1_2::IHostapd::IfaceParams& iface_params,
71 	    const V1_2::IHostapd::NetworkParams& nw_params,
72 	    addAccessPoint_1_2_cb _hidl_cb) override;
73 	Return<void> addAccessPoint_1_3(
74 	    const V1_3::IHostapd::IfaceParams& iface_params,
75 	    const V1_3::IHostapd::NetworkParams& nw_params,
76 	    addAccessPoint_1_3_cb _hidl_cb) override;
77 	Return<void> removeAccessPoint(
78 	    const hidl_string& iface_name,
79 	    removeAccessPoint_cb _hidl_cb) override;
80 	Return<void> terminate() override;
81 	Return<void> registerCallback(
82 	    const sp<V1_1::IHostapdCallback>& callback,
83 	    registerCallback_cb _hidl_cb) override;
84 	Return<void> registerCallback_1_3(
85 	    const sp<V1_3::IHostapdCallback>& callback,
86 	    registerCallback_1_3_cb _hidl_cb) override;
87 	Return<void>forceClientDisconnect(
88 	    const hidl_string& iface_name,
89 	    const hidl_array<uint8_t, 6>& client_address,
90 	    V1_2::Ieee80211ReasonCode reason_code, forceClientDisconnect_cb _hidl_cb) override;
91 	Return<void> setDebugParams(
92 	    V1_2::DebugLevel level, setDebugParams_cb _hidl_cb) override;
93 private:
94 	// Corresponding worker functions for the HIDL methods.
95 	V1_0::HostapdStatus addAccessPointInternal(
96 	    const V1_0::IHostapd::IfaceParams& iface_params,
97 	    const V1_0::IHostapd::NetworkParams& nw_params);
98 	V1_0::HostapdStatus addAccessPointInternal_1_1(
99 	    const V1_1::IHostapd::IfaceParams& IfaceParams,
100 	    const V1_0::IHostapd::NetworkParams& nw_params);
101 	V1_2::HostapdStatus addAccessPointInternal_1_2(
102 	    const V1_2::IHostapd::IfaceParams& IfaceParams,
103 	    const V1_2::IHostapd::NetworkParams& nw_params);
104 	V1_2::HostapdStatus addAccessPointInternal_1_3(
105 	    const V1_3::IHostapd::IfaceParams& IfaceParams,
106 	    const V1_3::IHostapd::NetworkParams& nw_params);
107 	V1_2::HostapdStatus addSingleAccessPoint(
108 	    const V1_3::IHostapd::IfaceParams& IfaceParams,
109 	    const V1_3::IHostapd::ChannelParams& channelParams,
110 	    const V1_3::IHostapd::NetworkParams& nw_params,
111 	    std::string br_name);
112 	V1_2::HostapdStatus addConcurrentAccessPoints(
113 	    const V1_3::IHostapd::IfaceParams& IfaceParams,
114 	    const V1_3::IHostapd::NetworkParams& nw_params);
115 	V1_0::HostapdStatus removeAccessPointInternal(const std::string& iface_name);
116 	V1_0::HostapdStatus registerCallbackInternal(
117 	    const sp<V1_1::IHostapdCallback>& callback);
118 	V1_2::HostapdStatus registerCallbackInternal_1_3(
119 	    const sp<V1_3::IHostapdCallback>& callback);
120 	V1_2::HostapdStatus forceClientDisconnectInternal(
121 	    const std::string& iface_name,
122 	    const std::array<uint8_t, 6>& client_address,
123 	    V1_2::Ieee80211ReasonCode reason_code);
124 	V1_2::HostapdStatus setDebugParamsInternal(V1_2::DebugLevel level);
125 	// Raw pointer to the global structure maintained by the core.
126 	struct hapd_interfaces* interfaces_;
127 	// Callbacks registered.
128 	std::vector<sp<V1_3::IHostapdCallback>> callbacks_;
129 	// Death notifier.
130 	android::sp<DeathNotifier> death_notifier_;
131 	// Bridge and its managed interfaces.
132 	std::map<std::string, std::vector<std::string>> br_interfaces_;
133 	DISALLOW_COPY_AND_ASSIGN(Hostapd);
134 };
135 }  // namespace implementation
136 }  // namespace V1_3
137 }  // namespace hostapd
138 }  // namespace wifi
139 }  // namespace hardware
140 }  // namespace android
141 
142 #endif  // HOSTAPD_HIDL_SUPPLICANT_H
143