1 /*
2  * Copyright (C) 2022 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 aidl {
21 namespace android {
22 namespace hardware {
23 namespace wifi {
24 namespace legacy_hal {
25 template <typename>
26 struct stubFunction;
27 
28 template <typename R, typename... Args>
29 struct stubFunction<R (*)(Args...)> {
invokeaidl::android::hardware::wifi::legacy_hal::stubFunction30     static constexpr R invoke(Args...) { return WIFI_ERROR_NOT_SUPPORTED; }
31 };
32 template <typename... Args>
33 struct stubFunction<void (*)(Args...)> {
invokeaidl::android::hardware::wifi::legacy_hal::stubFunction34     static constexpr void invoke(Args...) {}
35 };
36 
37 template <typename T>
populateStubFor(T * val)38 void populateStubFor(T* val) {
39     *val = &stubFunction<T>::invoke;
40 }
41 
initHalFuncTableWithStubs(wifi_hal_fn * hal_fn)42 bool initHalFuncTableWithStubs(wifi_hal_fn* hal_fn) {
43     if (hal_fn == nullptr) {
44         return false;
45     }
46     populateStubFor(&hal_fn->wifi_initialize);
47     populateStubFor(&hal_fn->wifi_wait_for_driver_ready);
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_pairing_request);
130     populateStubFor(&hal_fn->wifi_nan_pairing_indication_response);
131     populateStubFor(&hal_fn->wifi_nan_bootstrapping_request);
132     populateStubFor(&hal_fn->wifi_nan_bootstrapping_indication_response);
133     populateStubFor(&hal_fn->wifi_nan_data_end);
134     populateStubFor(&hal_fn->wifi_nan_pairing_end);
135     populateStubFor(&hal_fn->wifi_get_packet_filter_capabilities);
136     populateStubFor(&hal_fn->wifi_set_packet_filter);
137     populateStubFor(&hal_fn->wifi_read_packet_filter);
138     populateStubFor(&hal_fn->wifi_get_roaming_capabilities);
139     populateStubFor(&hal_fn->wifi_enable_firmware_roaming);
140     populateStubFor(&hal_fn->wifi_configure_roaming);
141     populateStubFor(&hal_fn->wifi_select_tx_power_scenario);
142     populateStubFor(&hal_fn->wifi_reset_tx_power_scenario);
143     populateStubFor(&hal_fn->wifi_set_radio_mode_change_handler);
144     populateStubFor(&hal_fn->wifi_set_latency_mode);
145     populateStubFor(&hal_fn->wifi_set_thermal_mitigation_mode);
146     populateStubFor(&hal_fn->wifi_virtual_interface_create);
147     populateStubFor(&hal_fn->wifi_virtual_interface_delete);
148     populateStubFor(&hal_fn->wifi_map_dscp_access_category);
149     populateStubFor(&hal_fn->wifi_reset_dscp_mapping);
150     populateStubFor(&hal_fn->wifi_set_subsystem_restart_handler);
151     populateStubFor(&hal_fn->wifi_get_supported_iface_name);
152     populateStubFor(&hal_fn->wifi_early_initialize);
153     populateStubFor(&hal_fn->wifi_get_chip_feature_set);
154     populateStubFor(&hal_fn->wifi_multi_sta_set_primary_connection);
155     populateStubFor(&hal_fn->wifi_multi_sta_set_use_case);
156     populateStubFor(&hal_fn->wifi_set_coex_unsafe_channels);
157     populateStubFor(&hal_fn->wifi_set_voip_mode);
158     populateStubFor(&hal_fn->wifi_twt_register_handler);
159     populateStubFor(&hal_fn->wifi_twt_get_capability);
160     populateStubFor(&hal_fn->wifi_twt_setup_request);
161     populateStubFor(&hal_fn->wifi_twt_teardown_request);
162     populateStubFor(&hal_fn->wifi_twt_info_frame_request);
163     populateStubFor(&hal_fn->wifi_twt_get_stats);
164     populateStubFor(&hal_fn->wifi_twt_clear_stats);
165     populateStubFor(&hal_fn->wifi_set_dtim_config);
166     populateStubFor(&hal_fn->wifi_get_usable_channels);
167     populateStubFor(&hal_fn->wifi_trigger_subsystem_restart);
168     populateStubFor(&hal_fn->wifi_set_indoor_state);
169     populateStubFor(&hal_fn->wifi_get_supported_radio_combinations_matrix);
170     populateStubFor(&hal_fn->wifi_nan_rtt_chre_enable_request);
171     populateStubFor(&hal_fn->wifi_nan_rtt_chre_disable_request);
172     populateStubFor(&hal_fn->wifi_chre_register_handler);
173     populateStubFor(&hal_fn->wifi_enable_tx_power_limits);
174     populateStubFor(&hal_fn->wifi_get_cached_scan_results);
175     populateStubFor(&hal_fn->wifi_get_chip_capabilities);
176     populateStubFor(&hal_fn->wifi_enable_sta_channel_for_peer_network);
177     populateStubFor(&hal_fn->wifi_nan_suspend_request);
178     populateStubFor(&hal_fn->wifi_nan_resume_request);
179     populateStubFor(&hal_fn->wifi_set_scan_mode);
180     populateStubFor(&hal_fn->wifi_set_mlo_mode);
181     populateStubFor(&hal_fn->wifi_get_supported_iface_concurrency_matrix);
182     populateStubFor(&hal_fn->wifi_get_rtt_capabilities_v3);
183     populateStubFor(&hal_fn->wifi_rtt_range_request_v3);
184     populateStubFor(&hal_fn->wifi_twt_get_capabilities);
185     populateStubFor(&hal_fn->wifi_twt_register_events);
186     populateStubFor(&hal_fn->wifi_twt_session_setup);
187     populateStubFor(&hal_fn->wifi_twt_session_update);
188     populateStubFor(&hal_fn->wifi_twt_session_suspend);
189     populateStubFor(&hal_fn->wifi_twt_session_resume);
190     populateStubFor(&hal_fn->wifi_twt_session_teardown);
191     populateStubFor(&hal_fn->wifi_twt_session_get_stats);
192     populateStubFor(&hal_fn->wifi_virtual_interface_create_with_vendor_data);
193     return true;
194 }
195 
196 }  // namespace legacy_hal
197 }  // namespace wifi
198 }  // namespace hardware
199 }  // namespace android
200 }  // namespace aidl
201