1 /* 2 * Copyright (C) 2014 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 #ifndef __WIFI_HAL_GSCAN_COMMAND_H__ 18 #define __WIFI_HAL_GSCAN_COMMAND_H__ 19 20 #include "common.h" 21 #include "cpp_bindings.h" 22 #ifdef __GNUC__ 23 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b)))) 24 #define STRUCT_PACKED __attribute__ ((packed)) 25 #else 26 #define PRINTF_FORMAT(a,b) 27 #define STRUCT_PACKED 28 #endif 29 #include "qca-vendor.h" 30 #include "vendor_definitions.h" 31 #include "gscan.h" 32 33 #ifdef __cplusplus 34 extern "C" 35 { 36 #endif /* __cplusplus */ 37 38 typedef struct{ 39 u32 status; 40 u32 num_channels; 41 wifi_channel channels[]; 42 } GScanGetValidChannelsRspParams; 43 44 typedef struct{ 45 wifi_gscan_capabilities capabilities; 46 } GScanGetCapabilitiesRspParams; 47 48 typedef struct{ 49 u8 more_data; 50 u32 num_cached_results; 51 u32 cachedResultsStartingIndex; /* Used in filling cached scan results */ 52 int lastProcessedScanId; /* Last scan id in gscan cached results block */ 53 u32 wifiScanResultsStartingIndex; /* For the lastProcessedScanId */ 54 u32 max; /* max num of cached results specified by caller */ 55 wifi_cached_scan_results *cached_results; 56 } GScanGetCachedResultsRspParams; 57 58 typedef struct { 59 int max_channels; 60 wifi_channel *channels; 61 int *number_channels; 62 } GScan_get_valid_channels_cb_data; 63 64 typedef enum{ 65 eGScanRspParamsInvalid = 0, 66 eGScanGetValidChannelsRspParams, 67 eGScanGetCapabilitiesRspParams, 68 eGScanGetCachedResultsRspParams, 69 } eGScanRspRarams; 70 71 /* Response and Event Callbacks */ 72 typedef struct { 73 /* Various Events Callback */ 74 void (*on_hotlist_ap_found)(wifi_request_id id, 75 unsigned num_results, wifi_scan_result *results); 76 void (*on_hotlist_ap_lost)(wifi_request_id id, 77 unsigned num_results, wifi_scan_result *results); 78 void (*on_significant_change)(wifi_request_id id, 79 unsigned num_results, 80 wifi_significant_change_result **results); 81 /* Reported when report_threshold is reached in scan cache */ 82 void (*on_scan_results_available) (wifi_request_id id, 83 unsigned num_results_available); 84 /* Reported when each probe response is received, if report_events 85 * enabled in wifi_scan_cmd_params 86 */ 87 void (*on_full_scan_result) (wifi_request_id id, wifi_scan_result *result); 88 /* Optional event - indicates progress of scanning statemachine */ 89 void (*on_scan_event) (wifi_scan_event event, unsigned status); 90 void (*on_hotlist_ssid_found)(wifi_request_id id, 91 unsigned num_results, wifi_scan_result *results); 92 void (*on_hotlist_ssid_lost)(wifi_request_id id, 93 unsigned num_results, wifi_scan_result *results); 94 void (*on_pno_network_found)(wifi_request_id id, 95 unsigned num_results, wifi_scan_result *results); 96 void (*on_passpoint_network_found)(wifi_request_id id, 97 int net_id, 98 wifi_scan_result *result, 99 int anqp_len, 100 byte *anqp 101 ); 102 } GScanCallbackHandler; 103 104 class GScanCommand: public WifiVendorCommand 105 { 106 private: 107 GScanGetCapabilitiesRspParams *mGetCapabilitiesRspParams; 108 GScanGetCachedResultsRspParams *mGetCachedResultsRspParams; 109 GScanCallbackHandler mHandler; 110 int mRequestId; 111 int *mChannels; 112 int mMaxChannels; 113 int *mNumChannelsPtr; 114 115 public: 116 GScanCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); 117 virtual ~GScanCommand(); 118 119 /* This function implements creation of GSCAN specific Request 120 * based on the request type. 121 */ 122 virtual int create(); 123 virtual int requestResponse(); 124 virtual int handleResponse(WifiEvent &reply); 125 virtual void setMaxChannels(int max_channels); 126 virtual void setChannels(int *channels); 127 virtual void setNumChannelsPtr(int *num_channels); 128 virtual int allocRspParams(eGScanRspRarams cmd); 129 virtual void freeRspParams(eGScanRspRarams cmd); 130 virtual void getGetCapabilitiesRspParams( 131 wifi_gscan_capabilities *capabilities); 132 virtual wifi_error copyCachedScanResults(int *numResults, 133 wifi_cached_scan_results *cached_results); 134 virtual int gscan_get_cached_results(wifi_cached_scan_results *results, 135 struct nlattr **tb_vendor); 136 virtual int allocCachedResultsTemp(int max, 137 wifi_cached_scan_results *results); 138 virtual int gscan_parse_capabilities(struct nlattr **tbVendor); 139 }; 140 141 #ifdef __cplusplus 142 } 143 #endif /* __cplusplus */ 144 #endif 145