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 #include "wifi_legacy_hal_stubs.h"
18 
19 // TODO: Remove these stubs from HalTool in libwifi-system.
20 namespace android {
21 namespace hardware {
22 namespace wifi {
23 namespace V1_0 {
24 namespace implementation {
25 namespace legacy_hal {
26 template <typename>
27 struct stubFunction;
28 
29 template <typename R, typename... Args>
30 struct stubFunction<R (*)(Args...)> {
invokeandroid::hardware::wifi::V1_0::implementation::legacy_hal::stubFunction31   static constexpr R invoke(Args...) { return WIFI_ERROR_NOT_SUPPORTED; }
32 };
33 template <typename... Args>
34 struct stubFunction<void (*)(Args...)> {
invokeandroid::hardware::wifi::V1_0::implementation::legacy_hal::stubFunction35   static constexpr void invoke(Args...) {}
36 };
37 
38 template <typename T>
populateStubFor(T * val)39 void populateStubFor(T* val) {
40   *val = &stubFunction<T>::invoke;
41 }
42 
initHalFuncTableWithStubs(wifi_hal_fn * hal_fn)43 bool initHalFuncTableWithStubs(wifi_hal_fn* hal_fn) {
44   if (hal_fn == nullptr) {
45     return false;
46   }
47   populateStubFor(&hal_fn->wifi_initialize);
48   populateStubFor(&hal_fn->wifi_cleanup);
49   populateStubFor(&hal_fn->wifi_event_loop);
50   populateStubFor(&hal_fn->wifi_get_error_info);
51   populateStubFor(&hal_fn->wifi_get_supported_feature_set);
52   populateStubFor(&hal_fn->wifi_get_concurrency_matrix);
53   populateStubFor(&hal_fn->wifi_set_scanning_mac_oui);
54   populateStubFor(&hal_fn->wifi_get_supported_channels);
55   populateStubFor(&hal_fn->wifi_is_epr_supported);
56   populateStubFor(&hal_fn->wifi_get_ifaces);
57   populateStubFor(&hal_fn->wifi_get_iface_name);
58   populateStubFor(&hal_fn->wifi_set_iface_event_handler);
59   populateStubFor(&hal_fn->wifi_reset_iface_event_handler);
60   populateStubFor(&hal_fn->wifi_start_gscan);
61   populateStubFor(&hal_fn->wifi_stop_gscan);
62   populateStubFor(&hal_fn->wifi_get_cached_gscan_results);
63   populateStubFor(&hal_fn->wifi_set_bssid_hotlist);
64   populateStubFor(&hal_fn->wifi_reset_bssid_hotlist);
65   populateStubFor(&hal_fn->wifi_set_significant_change_handler);
66   populateStubFor(&hal_fn->wifi_reset_significant_change_handler);
67   populateStubFor(&hal_fn->wifi_get_gscan_capabilities);
68   populateStubFor(&hal_fn->wifi_set_link_stats);
69   populateStubFor(&hal_fn->wifi_get_link_stats);
70   populateStubFor(&hal_fn->wifi_clear_link_stats);
71   populateStubFor(&hal_fn->wifi_get_valid_channels);
72   populateStubFor(&hal_fn->wifi_rtt_range_request);
73   populateStubFor(&hal_fn->wifi_rtt_range_cancel);
74   populateStubFor(&hal_fn->wifi_get_rtt_capabilities);
75   populateStubFor(&hal_fn->wifi_rtt_get_responder_info);
76   populateStubFor(&hal_fn->wifi_enable_responder);
77   populateStubFor(&hal_fn->wifi_disable_responder);
78   populateStubFor(&hal_fn->wifi_set_nodfs_flag);
79   populateStubFor(&hal_fn->wifi_start_logging);
80   populateStubFor(&hal_fn->wifi_set_epno_list);
81   populateStubFor(&hal_fn->wifi_reset_epno_list);
82   populateStubFor(&hal_fn->wifi_set_country_code);
83   populateStubFor(&hal_fn->wifi_get_firmware_memory_dump);
84   populateStubFor(&hal_fn->wifi_set_log_handler);
85   populateStubFor(&hal_fn->wifi_reset_log_handler);
86   populateStubFor(&hal_fn->wifi_set_alert_handler);
87   populateStubFor(&hal_fn->wifi_reset_alert_handler);
88   populateStubFor(&hal_fn->wifi_get_firmware_version);
89   populateStubFor(&hal_fn->wifi_get_ring_buffers_status);
90   populateStubFor(&hal_fn->wifi_get_logger_supported_feature_set);
91   populateStubFor(&hal_fn->wifi_get_ring_data);
92   populateStubFor(&hal_fn->wifi_enable_tdls);
93   populateStubFor(&hal_fn->wifi_disable_tdls);
94   populateStubFor(&hal_fn->wifi_get_tdls_status);
95   populateStubFor(&hal_fn->wifi_get_tdls_capabilities);
96   populateStubFor(&hal_fn->wifi_get_driver_version);
97   populateStubFor(&hal_fn->wifi_set_passpoint_list);
98   populateStubFor(&hal_fn->wifi_reset_passpoint_list);
99   populateStubFor(&hal_fn->wifi_set_lci);
100   populateStubFor(&hal_fn->wifi_set_lcr);
101   populateStubFor(&hal_fn->wifi_start_sending_offloaded_packet);
102   populateStubFor(&hal_fn->wifi_stop_sending_offloaded_packet);
103   populateStubFor(&hal_fn->wifi_start_rssi_monitoring);
104   populateStubFor(&hal_fn->wifi_stop_rssi_monitoring);
105   populateStubFor(&hal_fn->wifi_get_wake_reason_stats);
106   populateStubFor(&hal_fn->wifi_configure_nd_offload);
107   populateStubFor(&hal_fn->wifi_get_driver_memory_dump);
108   populateStubFor(&hal_fn->wifi_start_pkt_fate_monitoring);
109   populateStubFor(&hal_fn->wifi_get_tx_pkt_fates);
110   populateStubFor(&hal_fn->wifi_get_rx_pkt_fates);
111   populateStubFor(&hal_fn->wifi_nan_enable_request);
112   populateStubFor(&hal_fn->wifi_nan_disable_request);
113   populateStubFor(&hal_fn->wifi_nan_publish_request);
114   populateStubFor(&hal_fn->wifi_nan_publish_cancel_request);
115   populateStubFor(&hal_fn->wifi_nan_subscribe_request);
116   populateStubFor(&hal_fn->wifi_nan_subscribe_cancel_request);
117   populateStubFor(&hal_fn->wifi_nan_transmit_followup_request);
118   populateStubFor(&hal_fn->wifi_nan_stats_request);
119   populateStubFor(&hal_fn->wifi_nan_config_request);
120   populateStubFor(&hal_fn->wifi_nan_tca_request);
121   populateStubFor(&hal_fn->wifi_nan_beacon_sdf_payload_request);
122   populateStubFor(&hal_fn->wifi_nan_register_handler);
123   populateStubFor(&hal_fn->wifi_nan_get_version);
124   populateStubFor(&hal_fn->wifi_nan_get_capabilities);
125   populateStubFor(&hal_fn->wifi_nan_data_interface_create);
126   populateStubFor(&hal_fn->wifi_nan_data_interface_delete);
127   populateStubFor(&hal_fn->wifi_nan_data_request_initiator);
128   populateStubFor(&hal_fn->wifi_nan_data_indication_response);
129   populateStubFor(&hal_fn->wifi_nan_data_end);
130   populateStubFor(&hal_fn->wifi_get_packet_filter_capabilities);
131   populateStubFor(&hal_fn->wifi_set_packet_filter);
132   populateStubFor(&hal_fn->wifi_get_roaming_capabilities);
133   populateStubFor(&hal_fn->wifi_enable_firmware_roaming);
134   populateStubFor(&hal_fn->wifi_configure_roaming);
135   return true;
136 }
137 }  // namespace legacy_hal
138 }  // namespace implementation
139 }  // namespace V1_0
140 }  // namespace wifi
141 }  // namespace hardware
142 }  // namespace android
143