Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 1 | /* |
| 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 Su | 61ea307 | 2018-10-02 15:14:29 -0700 | [diff] [blame] | 20 | #include <array> |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 21 | #include <string> |
James Mattis | 3901204 | 2019-10-04 18:37:43 -0700 | [diff] [blame] | 22 | #include <vector> |
David Su | 61ea307 | 2018-10-02 15:14:29 -0700 | [diff] [blame] | 23 | |
| 24 | #include <linux/if_ether.h> |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 25 | |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 26 | #include <android-base/macros.h> |
Christopher Wiley | d42ca5a | 2016-08-22 17:42:58 -0700 | [diff] [blame] | 27 | #include <wifi_system/interface_tool.h> |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 28 | |
Ningyuan Wang | cf51f86 | 2017-03-08 08:44:39 -0800 | [diff] [blame] | 29 | #include "wificond/net/netlink_manager.h" |
| 30 | |
Etan Cohen | 067e119 | 2020-02-15 17:36:36 -0800 | [diff] [blame] | 31 | #include "android/net/wifi/nl80211/IApInterface.h" |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 32 | |
Etan Cohen | 067e119 | 2020-02-15 17:36:36 -0800 | [diff] [blame] | 33 | using android::net::wifi::nl80211::IApInterface; |
| 34 | using android::net::wifi::nl80211::NativeWifiClient; |
James Mattis | 3901204 | 2019-10-04 18:37:43 -0700 | [diff] [blame] | 35 | |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 36 | namespace android { |
| 37 | namespace wificond { |
| 38 | |
| 39 | class ApInterfaceBinder; |
Ningyuan Wang | 9136ae3 | 2017-02-28 15:49:08 -0800 | [diff] [blame] | 40 | class NetlinkUtils; |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 41 | |
| 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. |
| 46 | class ApInterfaceImpl { |
| 47 | public: |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 48 | ApInterfaceImpl(const std::string& interface_name, |
Ningyuan Wang | 9bc59a0 | 2016-08-11 09:59:22 -0700 | [diff] [blame] | 49 | uint32_t interface_index, |
Ningyuan Wang | 9136ae3 | 2017-02-28 15:49:08 -0800 | [diff] [blame] | 50 | NetlinkUtils* netlink_utils, |
Roshan Pius | 1731b15 | 2018-02-11 18:29:22 -0800 | [diff] [blame] | 51 | wifi_system::InterfaceTool* if_tool); |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 52 | ~ApInterfaceImpl(); |
| 53 | |
| 54 | // Get a pointer to the binder representing this ApInterfaceImpl. |
James Mattis | 3901204 | 2019-10-04 18:37:43 -0700 | [diff] [blame] | 55 | android::sp<IApInterface> GetBinder() const; |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 56 | |
Christopher Wiley | 223dfaa | 2016-09-26 10:21:16 -0700 | [diff] [blame] | 57 | std::string GetInterfaceName() { return interface_name_; } |
Ningyuan Wang | 8ec7696 | 2017-04-07 16:03:33 -0700 | [diff] [blame] | 58 | void Dump(std::stringstream* ss) const; |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 59 | |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 60 | private: |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 61 | const std::string interface_name_; |
Ningyuan Wang | 9bc59a0 | 2016-08-11 09:59:22 -0700 | [diff] [blame] | 62 | const uint32_t interface_index_; |
Ningyuan Wang | 9136ae3 | 2017-02-28 15:49:08 -0800 | [diff] [blame] | 63 | NetlinkUtils* const netlink_utils_; |
Christopher Wiley | d42ca5a | 2016-08-22 17:42:58 -0700 | [diff] [blame] | 64 | wifi_system::InterfaceTool* const if_tool_; |
Christopher Wiley | c139fbf | 2016-07-27 13:48:22 -0700 | [diff] [blame] | 65 | const android::sp<ApInterfaceBinder> binder_; |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 66 | |
Ningyuan Wang | cf51f86 | 2017-03-08 08:44:39 -0800 | [diff] [blame] | 67 | void OnStationEvent(StationEvent event, |
David Su | 61ea307 | 2018-10-02 15:14:29 -0700 | [diff] [blame] | 68 | const std::array<uint8_t, ETH_ALEN>& mac_address); |
Ningyuan Wang | cf51f86 | 2017-03-08 08:44:39 -0800 | [diff] [blame] | 69 | |
Ningyuan Wang | 791d553 | 2018-02-01 14:04:18 -0800 | [diff] [blame] | 70 | void OnChannelSwitchEvent(uint32_t frequency, ChannelBandwidth bandwidth); |
Ningyuan Wang | d5cfc11 | 2018-01-29 15:50:49 -0800 | [diff] [blame] | 71 | |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 72 | DISALLOW_COPY_AND_ASSIGN(ApInterfaceImpl); |
| 73 | }; |
| 74 | |
| 75 | } // namespace wificond |
| 76 | } // namespace android |
| 77 | |
| 78 | #endif // WIFICOND_AP_INTERFACE_IMPL_H_ |