blob: 6c9829399e49f18fe8eb56009ec46a75680e1a9f [file] [log] [blame]
Christopher Wileyf229bbe2016-06-22 17:20:04 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef WIFICOND_AP_INTERFACE_IMPL_H_
18#define WIFICOND_AP_INTERFACE_IMPL_H_
19
David Su61ea3072018-10-02 15:14:29 -070020#include <array>
Christopher Wiley1f8dd452016-07-18 15:30:58 -070021#include <string>
James Mattis39012042019-10-04 18:37:43 -070022#include <vector>
David Su61ea3072018-10-02 15:14:29 -070023
24#include <linux/if_ether.h>
Christopher Wiley1f8dd452016-07-18 15:30:58 -070025
Christopher Wileyf229bbe2016-06-22 17:20:04 -070026#include <android-base/macros.h>
Christopher Wileyd42ca5a2016-08-22 17:42:58 -070027#include <wifi_system/interface_tool.h>
Christopher Wileyf229bbe2016-06-22 17:20:04 -070028
Ningyuan Wangcf51f862017-03-08 08:44:39 -080029#include "wificond/net/netlink_manager.h"
30
Etan Cohen067e1192020-02-15 17:36:36 -080031#include "android/net/wifi/nl80211/IApInterface.h"
Christopher Wileyf229bbe2016-06-22 17:20:04 -070032
Etan Cohen067e1192020-02-15 17:36:36 -080033using android::net::wifi::nl80211::IApInterface;
34using android::net::wifi::nl80211::NativeWifiClient;
James Mattis39012042019-10-04 18:37:43 -070035
Christopher Wileyf229bbe2016-06-22 17:20:04 -070036namespace android {
37namespace wificond {
38
39class ApInterfaceBinder;
Ningyuan Wang9136ae32017-02-28 15:49:08 -080040class NetlinkUtils;
Christopher Wileyf229bbe2016-06-22 17:20:04 -070041
42// Holds the guts of how we control network interfaces capable of exposing an AP
43// via hostapd. Because remote processes may hold on to the corresponding
44// binder object past the lifetime of the local object, we are forced to
45// keep this object separate from the binder representation of itself.
46class ApInterfaceImpl {
47 public:
Christopher Wiley1f8dd452016-07-18 15:30:58 -070048 ApInterfaceImpl(const std::string& interface_name,
Ningyuan Wang9bc59a02016-08-11 09:59:22 -070049 uint32_t interface_index,
Ningyuan Wang9136ae32017-02-28 15:49:08 -080050 NetlinkUtils* netlink_utils,
Roshan Pius1731b152018-02-11 18:29:22 -080051 wifi_system::InterfaceTool* if_tool);
Christopher Wileyf229bbe2016-06-22 17:20:04 -070052 ~ApInterfaceImpl();
53
54 // Get a pointer to the binder representing this ApInterfaceImpl.
James Mattis39012042019-10-04 18:37:43 -070055 android::sp<IApInterface> GetBinder() const;
Christopher Wileyf229bbe2016-06-22 17:20:04 -070056
Christopher Wiley223dfaa2016-09-26 10:21:16 -070057 std::string GetInterfaceName() { return interface_name_; }
Ningyuan Wang8ec76962017-04-07 16:03:33 -070058 void Dump(std::stringstream* ss) const;
Christopher Wiley1f8dd452016-07-18 15:30:58 -070059
Christopher Wileyf229bbe2016-06-22 17:20:04 -070060 private:
Christopher Wiley1f8dd452016-07-18 15:30:58 -070061 const std::string interface_name_;
Ningyuan Wang9bc59a02016-08-11 09:59:22 -070062 const uint32_t interface_index_;
Ningyuan Wang9136ae32017-02-28 15:49:08 -080063 NetlinkUtils* const netlink_utils_;
Christopher Wileyd42ca5a2016-08-22 17:42:58 -070064 wifi_system::InterfaceTool* const if_tool_;
Christopher Wileyc139fbf2016-07-27 13:48:22 -070065 const android::sp<ApInterfaceBinder> binder_;
Christopher Wileyf229bbe2016-06-22 17:20:04 -070066
Ningyuan Wangcf51f862017-03-08 08:44:39 -080067 void OnStationEvent(StationEvent event,
David Su61ea3072018-10-02 15:14:29 -070068 const std::array<uint8_t, ETH_ALEN>& mac_address);
Ningyuan Wangcf51f862017-03-08 08:44:39 -080069
Ningyuan Wang791d5532018-02-01 14:04:18 -080070 void OnChannelSwitchEvent(uint32_t frequency, ChannelBandwidth bandwidth);
Ningyuan Wangd5cfc112018-01-29 15:50:49 -080071
Christopher Wileyf229bbe2016-06-22 17:20:04 -070072 DISALLOW_COPY_AND_ASSIGN(ApInterfaceImpl);
73};
74
75} // namespace wificond
76} // namespace android
77
78#endif // WIFICOND_AP_INTERFACE_IMPL_H_