blob: ceec0806f9c2b1d00947e241b52ad0a2faacc887 [file] [log] [blame]
Roshan Piuscc817562017-12-22 14:45:05 -08001/*
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
leslf8b1b402020-08-04 17:09:39 +080017#include <android/hardware/wifi/hostapd/1.3/IHostapd.h>
18#include <android/hardware/wifi/hostapd/1.3/IHostapdCallback.h>
Roshan Piuscc817562017-12-22 14:45:05 -080019
20extern "C"
21{
22#include "utils/common.h"
Roshan Pius80e5a0f2020-10-19 13:48:22 -070023#include "utils/eloop.h"
Roshan Piuscc817562017-12-22 14:45:05 -080024#include "utils/includes.h"
25#include "utils/wpa_debug.h"
26#include "ap/hostapd.h"
lesl1a842e62019-12-02 19:00:37 +080027#include "ap/sta_info.h"
Roshan Piuscc817562017-12-22 14:45:05 -080028}
29
Roshan Pius80e5a0f2020-10-19 13:48:22 -070030class DeathNotifier : public android::hardware::hidl_death_recipient
31{
32public:
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
Roshan Piuscc817562017-12-22 14:45:05 -080043namespace android {
44namespace hardware {
45namespace wifi {
46namespace hostapd {
leslf8b1b402020-08-04 17:09:39 +080047namespace V1_3 {
Roshan Piuscc817562017-12-22 14:45:05 -080048namespace implementation {
Roshan Piuse2d21012018-08-17 11:22:06 -070049using namespace android::hardware::wifi::hostapd::V1_0;
Roshan Piuscc817562017-12-22 14:45:05 -080050
51/**
52 * Implementation of the hostapd hidl object. This hidl
53 * object is used core for global control operations on
54 * hostapd.
55 */
leslf8b1b402020-08-04 17:09:39 +080056class Hostapd : public V1_3::IHostapd
Roshan Piuscc817562017-12-22 14:45:05 -080057{
58public:
59 Hostapd(hapd_interfaces* interfaces);
60 ~Hostapd() override = default;
61
62 // Hidl methods exposed.
63 Return<void> addAccessPoint(
Daisuke Niwac1bd20f2019-01-09 13:51:02 +090064 const V1_0::IHostapd::IfaceParams& iface_params,
Ahmed ElArabawy34982672019-12-06 10:10:17 -080065 const V1_0::IHostapd::NetworkParams& nw_params, addAccessPoint_cb _hidl_cb) override;
Daisuke Niwac1bd20f2019-01-09 13:51:02 +090066 Return<void> addAccessPoint_1_1(
Ahmed ElArabawy34982672019-12-06 10:10:17 -080067 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(
leslb0f4d542020-09-16 23:06:03 +080070 const V1_2::IHostapd::IfaceParams& iface_params,
71 const V1_2::IHostapd::NetworkParams& nw_params,
Ahmed ElArabawy34982672019-12-06 10:10:17 -080072 addAccessPoint_1_2_cb _hidl_cb) override;
leslb0f4d542020-09-16 23:06:03 +080073 Return<void> addAccessPoint_1_3(
lesl0cb0e272020-10-30 16:58:08 +080074 const V1_3::IHostapd::IfaceParams& iface_params,
leslb0f4d542020-09-16 23:06:03 +080075 const V1_3::IHostapd::NetworkParams& nw_params,
76 addAccessPoint_1_3_cb _hidl_cb) override;
Roshan Piuscc817562017-12-22 14:45:05 -080077 Return<void> removeAccessPoint(
78 const hidl_string& iface_name,
79 removeAccessPoint_cb _hidl_cb) override;
Roshan Pius3455af42018-02-01 09:19:49 -080080 Return<void> terminate() override;
Roshan Piuse2d21012018-08-17 11:22:06 -070081 Return<void> registerCallback(
lesl1a842e62019-12-02 19:00:37 +080082 const sp<V1_1::IHostapdCallback>& callback,
Roshan Piuse2d21012018-08-17 11:22:06 -070083 registerCallback_cb _hidl_cb) override;
leslf8b1b402020-08-04 17:09:39 +080084 Return<void> registerCallback_1_3(
85 const sp<V1_3::IHostapdCallback>& callback,
86 registerCallback_1_3_cb _hidl_cb) override;
lesl1a842e62019-12-02 19:00:37 +080087 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;
Roger Wangcede5062019-12-30 12:56:28 +080091 Return<void> setDebugParams(
leslf8b1b402020-08-04 17:09:39 +080092 V1_2::DebugLevel level, setDebugParams_cb _hidl_cb) override;
Roshan Piuscc817562017-12-22 14:45:05 -080093private:
94 // Corresponding worker functions for the HIDL methods.
lesl1a842e62019-12-02 19:00:37 +080095 V1_0::HostapdStatus addAccessPointInternal(
Daisuke Niwac1bd20f2019-01-09 13:51:02 +090096 const V1_0::IHostapd::IfaceParams& iface_params,
Ahmed ElArabawy34982672019-12-06 10:10:17 -080097 const V1_0::IHostapd::NetworkParams& nw_params);
lesl1a842e62019-12-02 19:00:37 +080098 V1_0::HostapdStatus addAccessPointInternal_1_1(
Ahmed ElArabawy34982672019-12-06 10:10:17 -080099 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,
lesldd48efd2019-12-26 15:13:51 +0800103 const V1_2::IHostapd::NetworkParams& nw_params);
leslb0f4d542020-09-16 23:06:03 +0800104 V1_2::HostapdStatus addAccessPointInternal_1_3(
lesl0cb0e272020-10-30 16:58:08 +0800105 const V1_3::IHostapd::IfaceParams& IfaceParams,
106 const V1_3::IHostapd::NetworkParams& nw_params);
107 V1_2::HostapdStatus addSingleAccessPoint(
leslb0f4d542020-09-16 23:06:03 +0800108 const V1_2::IHostapd::IfaceParams& IfaceParams,
lesl0cb0e272020-10-30 16:58:08 +0800109 const V1_3::IHostapd::NetworkParams& nw_params,
110 std::string br_name);
111 V1_2::HostapdStatus addConcurrentAccessPoints(
112 const V1_3::IHostapd::IfaceParams& IfaceParams,
leslb0f4d542020-09-16 23:06:03 +0800113 const V1_3::IHostapd::NetworkParams& nw_params);
lesl1a842e62019-12-02 19:00:37 +0800114 V1_0::HostapdStatus removeAccessPointInternal(const std::string& iface_name);
115 V1_0::HostapdStatus registerCallbackInternal(
116 const sp<V1_1::IHostapdCallback>& callback);
leslf8b1b402020-08-04 17:09:39 +0800117 V1_2::HostapdStatus registerCallbackInternal_1_3(
118 const sp<V1_3::IHostapdCallback>& callback);
lesl1a842e62019-12-02 19:00:37 +0800119 V1_2::HostapdStatus forceClientDisconnectInternal(
120 const std::string& iface_name,
121 const std::array<uint8_t, 6>& client_address,
122 V1_2::Ieee80211ReasonCode reason_code);
leslf8b1b402020-08-04 17:09:39 +0800123 V1_2::HostapdStatus setDebugParamsInternal(V1_2::DebugLevel level);
Roshan Piuscc817562017-12-22 14:45:05 -0800124 // Raw pointer to the global structure maintained by the core.
125 struct hapd_interfaces* interfaces_;
Roshan Piuse2d21012018-08-17 11:22:06 -0700126 // Callbacks registered.
leslf8b1b402020-08-04 17:09:39 +0800127 std::vector<sp<V1_3::IHostapdCallback>> callbacks_;
Roshan Pius80e5a0f2020-10-19 13:48:22 -0700128 // Death notifier.
129 android::sp<DeathNotifier> death_notifier_;
lesl0cb0e272020-10-30 16:58:08 +0800130 // Bridge and its managed interfaces.
131 std::map<std::string, std::vector<std::string>> br_interfaces_;
Roshan Piuscc817562017-12-22 14:45:05 -0800132 DISALLOW_COPY_AND_ASSIGN(Hostapd);
133};
134} // namespace implementation
leslf8b1b402020-08-04 17:09:39 +0800135} // namespace V1_3
Roshan Piuscc817562017-12-22 14:45:05 -0800136} // namespace hostapd
137} // namespace wifi
138} // namespace hardware
139} // namespace android
140
141#endif // HOSTAPD_HIDL_SUPPLICANT_H