1 /* 2 * Copyright (C) 2017 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 #pragma once 18 19 #include <wifi_hal.h> 20 21 #include <stdint.h> 22 #include <string> 23 24 class Netlink; 25 class NetlinkMessage; 26 27 class Interface { 28 public: 29 Interface(Netlink& netlink, const char* name); 30 Interface(Interface&& other) noexcept; 31 32 bool init(); 33 34 wifi_error getSupportedFeatureSet(feature_set* set); 35 wifi_error getName(char* name, size_t size); 36 wifi_error getLinkStats(wifi_request_id requestId, 37 wifi_stats_result_handler handler); 38 wifi_error setLinkStats(wifi_link_layer_params params); 39 wifi_error setAlertHandler(wifi_request_id id, wifi_alert_handler handler); 40 wifi_error resetAlertHandler(wifi_request_id id); 41 wifi_error getFirmwareVersion(char* buffer, size_t size); 42 wifi_error getDriverVersion(char* buffer, size_t size); 43 wifi_error setScanningMacOui(oui scan_oui); 44 wifi_error clearLinkStats(u32 requestMask, 45 u32* responseMask, 46 u8 request, 47 u8* response); 48 wifi_error getValidChannels(int band, 49 int maxChannels, 50 wifi_channel* channels, 51 int* numChannels); 52 wifi_error startLogging(u32 verboseLevel, 53 u32 flags, 54 u32 maxIntervalSec, 55 u32 minDataSize, 56 char* ringName); 57 wifi_error setCountryCode(const char* countryCode); 58 wifi_error setLogHandler(wifi_request_id id, 59 wifi_ring_buffer_data_handler handler); 60 wifi_error getRingBuffersStatus(u32* numRings, 61 wifi_ring_buffer_status* status); 62 wifi_error getLoggerSupportedFeatureSet(unsigned int* support); 63 wifi_error getRingData(char* ringName); 64 wifi_error configureNdOffload(u8 enable); 65 wifi_error startPacketFateMonitoring(); 66 wifi_error getTxPacketFates(wifi_tx_report* txReportBuffers, 67 size_t numRequestedFates, 68 size_t* numProvidedFates); 69 wifi_error getRxPacketFates(wifi_rx_report* rxReportBuffers, 70 size_t numRequestedFates, 71 size_t* numProvidedFates); 72 wifi_error getPacketFilterCapabilities(u32* version, u32* maxLength); 73 wifi_error getWakeReasonStats(WLAN_DRIVER_WAKE_REASON_CNT* wakeReasonCount); 74 private: 75 Interface(const Interface&) = delete; 76 Interface& operator=(const Interface&) = delete; 77 78 void onLinkStatsReply(wifi_request_id requestId, 79 wifi_stats_result_handler handler, 80 const NetlinkMessage& reply); 81 82 Netlink& mNetlink; 83 std::string mName; 84 uint32_t mInterfaceIndex; 85 }; 86 87