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