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 <stdint.h> 20 #include <string> 21 #include <vector> 22 #include <hardware_legacy/wifi_hal.h> 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 readPacketFilter(u32 src_offset, u8 *host_dst, u32 length); 74 wifi_error setPacketFilter(const u8 *program, u32 len); 75 wifi_error getWakeReasonStats(WLAN_DRIVER_WAKE_REASON_CNT* wakeReasonCount); 76 wifi_error startSendingOffloadedPacket(wifi_request_id id, 77 u16 ether_type, 78 u8 *ip_packet, 79 u16 ip_packet_len, 80 u8 *src_mac_addr, 81 u8 *dst_mac_addr, 82 u32 period_msec); 83 wifi_error stopSendingOffloadedPacket(wifi_request_id id); 84 85 private: 86 Interface(const Interface&) = delete; 87 Interface& operator=(const Interface&) = delete; 88 89 void onLinkStatsReply(wifi_request_id requestId, 90 wifi_stats_result_handler handler, 91 const NetlinkMessage& reply); 92 93 Netlink& mNetlink; 94 std::string mName; 95 uint32_t mInterfaceIndex; 96 std::vector<u8> mApfMemory; 97 }; 98 99