RDK Documentation (Open Sourced RDK Components)
wifi_client_hal.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**********************************************************************
21 
22  module: wifi_client_hal.h
23 
24  For CCSP Component: Wifi_Provisioning_and_management
25 
26  ---------------------------------------------------------------
27 
28 
29  description:
30 
31  This header file gives the function call prototypes and
32  structure definitions used for the RDK-Broadband
33  Wifi client hardware abstraction layer
34 
35  NOTE:
36  THIS VERSION IS AN EARLY DRAFT INTENDED TO GET COMMENTS FROM COMCAST.
37  TESTING HAS NOT YET BEEN COMPLETED.
38 
39  ---------------------------------------------------------------
40 
41  environment:
42 
43  This HAL layer is intended to support Wifi drivers
44  through an open API.
45 
46  ---------------------------------------------------------------
47 
48  author:
49 
50  zhicheng_qiu@cable.comcast.com
51 
52 
53 **********************************************************************/
54 
55 
56 #ifndef __WIFI_CLINET_HAL_H__
57 #define __WIFI_CLINET_HAL_H__
58 
59 /**
60  * @defgroup WIFI_HAL Wi-Fi HAL Public APIs and Data Types
61  * @ingroup WIFI
62  *
63  * @defgroup WIFI_HAL_CLIENT_API Wi-Fi Client HAL API List
64  * Wi-Fi Client HAL provides an interface (data structures and API) to interact with underlying Wi-Fi driver and
65  * enabling the client to be connected with an Access Point.
66  * @ingroup WIFI_HAL
67  *
68  */
69 
70 #include <wifi_common_hal.h>
71 //----------------------------------------------------------------------------------------------------
72 //Device.WiFi.EndPoint //EndPoint list is mananged by RDKB wifi agent
73 //Device.WiFi.EndPoint.{i}.Enable
74 //Device.WiFi.EndPoint.{i}.Status
75 //Device.WiFi.EndPoint.{i}.Alias
76 //Device.WiFi.EndPoint.{i}.ProfileReference
77 //Device.WiFi.EndPoint.{i}.SSIDReference
78 //Device.WiFi.EndPoint.{i}.ProfileNumberOfEntries
79 //----------------------------------------------------------------------------------------------------
80 //Device.WiFi.EndPoint.{i}.Stats.LastDataDownlinkRate
81 //Device.WiFi.EndPoint.{i}.Stats.LastDataUplinkRate
82 //Device.WiFi.EndPoint.{i}.Stats.SignalStrength
83 //Device.WiFi.EndPoint.{i}.Stats.Retransmissions
84 //----------------------------------------------------------------------------------------------------
85 //Device.WiFi.EndPoint.{i}.Security
86 //Device.WiFi.EndPoint.{i}.Security.ModesSupported
87 //----------------------------------------------------------------------------------------------------
88 //Device.WiFi.EndPoint.{i}.Profile
89 //Device.WiFi.EndPoint.{i}.Profile.{i}.Enable
90 //Device.WiFi.EndPoint.{i}.Profile.{i}.Status
91 //Device.WiFi.EndPoint.{i}.Profile.{i}.Alias
92 //Device.WiFi.EndPoint.{i}.Profile.{i}.SSID
93 //Device.WiFi.EndPoint.{i}.Profile.{i}.Location
94 //Device.WiFi.EndPoint.{i}.Profile.{i}.Priority
95 //----------------------------------------------------------------------------------------------------
96 //Device.WiFi.EndPoint.{i}.Profile.{i}.Security.ModeEnabled
97 //Device.WiFi.EndPoint.{i}.Profile.{i}.Security.WEPKey
98 //Device.WiFi.EndPoint.{i}.Profile.{i}.Security.PreSharedKey
99 //Device.WiFi.EndPoint.{i}.Profile.{i}.Security.KeyPassphrase
100 //----------------------------------------------------------------------------------------------------
101 //Device.WiFi.EndPoint.{i}.WPS
102 //Device.WiFi.EndPoint.{i}.WPS.Enable
103 //Device.WiFi.EndPoint.{i}.WPS.ConfigMethodsSupported
104 //Device.WiFi.EndPoint.{i}.WPS.ConfigMethodsEnabled
105 
106 //-----------------------------------------------------------------------------------------------------
107 //AP connection APIs
108 
109 /**
110  * @addtogroup WIFI_HAL_TYPES
111  * @{
112  */
113 
114 /**
115  * @brief SSID information
116  *
117  * Structure which saves the paired SSID information.
118  */
119 typedef struct _wifi_pairedSSIDInfo
120 {
121  CHAR ap_ssid[64]; //!< The current service set identifier in use by the neighboring WiFi SSID. The value MAY be empty for hidden SSIDs.
122  CHAR ap_bssid[64]; //!< [MACAddress] The BSSID (Basic Service Set ID) used for the neighboring WiFi SSID.
123  CHAR ap_security[64]; //!< Security of AP
124  CHAR ap_passphrase[128]; //!< Passphrase of AP
125  CHAR ap_wep_key[128]; //!< wep_key of AP incase of WEP security
127 
128 /**@} */
129 
130 /**
131  * @brief Roaming Control information (pre assoc data structure}
132  *
133  * Structure which saves pre association information.
134  */
135 typedef struct _wifi_roamingCtrl_t
136 {
137  BOOL roamingEnable;
138  BOOL selfSteerOverride;
139  BOOL roam80211kvrEnable;
140  INT preassnBestThreshold;
141  INT preassnBestDelta;
142  INT postAssnLevelDeltaConnected;
143  INT postAssnLevelDeltaDisconnected;
144  INT postAssnSelfSteerThreshold;
145  INT postAssnSelfSteerTimeframe;
146  INT postAssnBackOffTime;
147  //INT postAssnSelfSteerBeaconsMissedTime;
148  INT postAssnAPctrlThreshold;
149  INT postAssnAPctrlTimeframe;
150 
152 
153 /** @} */
154 
155 
156 //1. WPS method
157 
158 /**
159  * @addtogroup WIFI_HAL_CLIENT_API
160  * @{
161  */
162 
163 /**
164  * @brief This API checks WPS(Wi-Fi Protected Setup) functionality is enabled for this access point.
165  *
166  * @param[in] ssidIndex The index of the SSID array.
167  * @param[out] output_bool Boolean value which indicates the wps enabled status.
168  *
169  * @return The status of the operation.
170  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
171  */
172 INT wifi_getCliWpsEnable(INT ssidIndex, BOOL *output_bool); //RDKB
173 
174 /**
175  * @brief This API enables or disables WPS functionality for this access point.
176  *
177  * @param[in] ssidIndex The index of the SSID array.
178  * @param[in] enableValue Boolean value to enable or disable WPS.
179  *
180  * @return The status of the operation.
181  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
182  */
183 INT wifi_setCliWpsEnable(INT ssidIndex, BOOL enableValue); //RDKB
184 
185 /**
186  * @brief This API is used to read the device PIN required for making a WPS connection.
187  *
188  * @param[in] ssidIndex The index of the SSID array.
189  * @param[out] output_ulong Output parameter which saves the Device PIN.
190  * This value is to be printed on the device.
191  *
192  * @return The status of the operation.
193  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
194  */
195 INT wifi_getCliWpsDevicePIN(INT ssidIndex, ULONG *output_ulong); //RDKB
196 
197 /**
198  * @brief This API sets the WPS Device pin to the Wi-Fi hal.
199  *
200  * @param[in] ssidIndex The index of the SSID array.
201  * @param[in] pin The PIN code to set.
202  *
203  * @return The status of the operation.
204  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
205  */
206 INT wifi_setCliWpsDevicePIN(INT ssidIndex, ULONG pin); //RDKB
207 
208 /**
209  * @brief This API is used to get WPS configuration methods supported by the device.
210  *
211  * This function provides the comma-separated list of strings, each list item is an enumeration of:
212  * - USBFlashDrive - User uses a USB flash drive to transfer data between the new client device and
213  * the network's access point.
214  * - Ethernet - If there is no WPS button, user can configure the wireless settings using ethernet on a wifi-extender
215  * - ExternalNFCToken - NFC Tag contains a password token to authenticate Wi-Fi connection.
216  * Uses external program to write * NDEF encapsulation data to the NFC tag using an external program.
217  * - IntegratedNFCToken - The NFC Tag is integrated in the device.
218  * - NFCInterface - User has to bring the client close to AP allowing a near field communication between the devices.
219  * - PushButton - User has to push a button, either an actual or virtual one,
220  * on both the access point and the new wireless * client device.
221  * - PIN - User has to be read the PIN from either a sticker or display on the new wireless device.
222  *
223  * Device must support PushButton and PIN methods.
224  *
225  * @param[in] ssidIndex The index of SSID array.
226  * @param[out] methods The WPS supported methods.
227  *
228  * @return The status of the operation.
229  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
230  */
231 INT wifi_getCliWpsConfigMethodsSupported(INT ssidIndex, CHAR *methods); //OEM
232 
233 /**
234  * @brief This function indicates WPS configuration methods enabled on the device.
235  *
236  * The API provides the comma-separated list of strings.
237  * Each list item MUST be a member of the list reported by the ConfigMethodsSupported parameter.
238  *
239  * @param[in] ssidIndex The index of SSID array.
240  * @param[out] output_string The current WPS method.
241  *
242  * @return The status of the operation.
243  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
244  */
245 INT wifi_getCliWpsConfigMethodsEnabled(INT ssidIndex, CHAR *output_string); //RDKB
246 
247 /**
248  * @brief This API sets the active WPS method.
249  *
250  * @param[in] ssidIndex The index of SSID array.
251  * @param[in] methodString The method to enable.
252  *
253  * @return The status of the operation.
254  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
255  */
256 INT wifi_setCliWpsConfigMethodsEnabled(INT ssidIndex, CHAR *methodString); //RDKB
257 
258 /**
259  * @brief This API is used to get the WPS config status, whether "configured" or "not configured"
260  *
261  * @param[in] ssidIndex The index of SSID array
262  * @param[in] output_string The output paramter which holds the wps config status.
263  *
264  * @return The status of the operation.
265  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
266  */
267 INT wifi_getCliWpsConfigurationState(INT ssidIndex, CHAR *output_string); //RDKB //OEM
268 
269 /**
270  * @brief This API sets the PIN to connect.
271  * User get the EnrolleePin (device pin from AP device) give to hostapd for pairing.
272  *
273  * @param[in] ssidIndex The index of SSID array.
274  * @param[in] EnrolleePin PIN code to connect to the access point.
275  *
276  * @return The status of the operation.
277  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
278  */
279 INT wifi_setCliWpsEnrolleePin(INT ssidIndex, CHAR *EnrolleePin); //RDKB
280 
281 /**
282  * @brief Start the Push button pairing.
283  *
284  * @param[in] ssidIndex The index of SSID array.
285  *
286  * @return The status of the operation.
287  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
288  */
289 INT wifi_setCliWpsButtonPush(INT ssidIndex); //RDKB
290 
291 /**
292  * @brief Stop the WPS process.
293  *
294  * @param[in] ssidIndex The index of SSID array.
295  *
296  * @return The status of the operation.
297  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
298  */
299 INT wifi_cancelCliWPS(INT ssidIndex); //RDKB
300 
301 
302 //2. Directly pairing method
303 /**
304  * @brief This API starts the connection process from client with an AP.
305  *
306  * It uses the input parameters to connect using a supported security method and encryption standard.
307  * The security methods can make use of passphrase, public/private key pairs etc.
308  *
309  * @param[in] ssidIndex The index of SSID array.
310  * @param[in] AP_SSID The ssid to connect.
311  * @param[in] AP_security_mode The security mode to use.
312  * @param[in] AP_security_WEPKey The wep key.
313  * @param[in] AP_security_PreSharedKey The pre shared key.
314  * @param[in] AP_security_KeyPassphrase The key passphrase.
315  * @param[in] saveSSID Option to save profile in wpa supplicant.
316  *
317  * @return The status of the operation.
318  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
319  */
320 INT wifi_connectEndpoint(INT ssidIndex, CHAR *AP_SSID, wifiSecurityMode_t AP_security_mode, CHAR *AP_security_WEPKey, CHAR *AP_security_PreSharedKey, CHAR *AP_security_KeyPassphrase,int saveSSID,CHAR * eapIdentity,CHAR * carootcert,CHAR * clientcert,CHAR * privatekey); //Tr181
321 
322 /**
323  * @brief This API disconnects the access point specified.
324  *
325  * @param[in] ssidIndex The index of SSID array.
326  * @param[in] AP_SSID The ssid to disconnect.
327  *
328  * @return The status of the operation.
329  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
330  */
331 INT wifi_disconnectEndpoint(INT ssidIndex, CHAR *AP_SSID);
332 
333 // Clear SSID information
334 INT wifi_clearSSIDInfo(INT ssidIndex);
335 
336 /**
337  * @brief This call back should be registered by Wi-Fi manager to receive status updates from HAL in case of a
338  * connection/disconnection event.
339  *
340  * @param[in] ssidIndex The index of SSID array.
341  * @param[in] AP_SSID The ssid to disconnect.
342  * @param[out] error Indicates the Wi-Fi connection sttaus.
343  *
344  * @return The status of the operation.
345  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
346  */
347 typedef INT (*wifi_disconnectEndpoint_callback)(INT ssidIndex, CHAR *AP_SSID, wifiStatusCode_t *error);
348 
349 /**
350  * @brief Callback registration function.
351  *
352  * @param[in] callback_proc the callback function to disconnect the client.
353  */
355 
356 /**
357  * @brief This call back will be invoked when client automatically connect to Access Point.
358  *
359  * @param[in] ssidIndex The index of SSID array.
360  * @param[in] AP_SSID The ssid to disconnect.
361  * @param[out] error Indicates the Wi-Fi connection status.
362  *
363  * @return The status of the operation.
364  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
365  */
366 typedef INT (*wifi_connectEndpoint_callback)(INT ssidIndex, CHAR *AP_SSID, wifiStatusCode_t *error);
367 
368 /**
369  * @brief Callback registration function.
370  *
371  * @param[in] callback_proc The callback function to connect the client to the access point.
372  */
374 
375 /**
376  * @brief Telemetry callback functions
377  */
378 typedef struct _wifi_telemetry_ops_t
379 {
380  void (*init)(char* name);
381  void (*event_s)(char* marker, char* value);
382  void (*event_d)(char* marker, int value);
384 
385 /**
386  * @param[in] telemetry_ops Telemetry callback functions
387  */
389 
390 /**
391  * @brief This call will give the last saved AP's ssid.
392  *
393  * @param[out] pairedSSIDInfo Structure which holds the last connected access point information.
394  *
395  * @return The status of the operation.
396  * @retval RETURN_OK returns O if successful, appropriate error code otherwise.
397  */
399 /** @} */
400 
401 
402 /**
403  * @brief this call will set the Roaming control data for a client
404  *
405  * @param[in] ssidIndex, this is used to validate the ssid
406  * @param[in] pRoamingCtrl_data, this is the structure with values to be set
407  *
408  * @returns SET status of the pRoamingCtrl data
409  * @retval 0 if SUCCESFULLY sets the values
410  */
411 int wifi_setRoamingControl (int ssidIndex, wifi_roamingCtrl_t *pRoamingCtrl_data);
412 /** @} */
413 
414 /**
415  * @brief this call gets the Roaming control data
416  *
417  * @param[in] ssidIndex to validate the interface
418  * @param[out] pRoamingCtrl_data
419  *
420  * @returns GET status
421  * @retval 0 if SUCCESSFULLY gets the Roaming control data
422  */
423 int wifi_getRoamingControl(int ssidIndex, wifi_roamingCtrl_t *pRoamingCtrl_data);
424 
425 /**
426  * @brief this call gets the current wifi status
427  *
428  * @returns wifi_status_code
429  */
430 WiFiHalStatus_t getwifiStatusCode();
431 
432 /**
433  * @brief this call will cancel any in progress WPS operaiotn
434  *
435  * @returns WPS cancel status.
436  * @retval 0 if SUCCESFULLY cancels WPS operation, false in failure cases.
437  */
438 INT wifi_cancelWpsPairing();
439 
440 /** @} */
441 #else
442 #error "! __WIFI_CLINET_HAL_H__"
443 #endif
wifi_getCliWpsConfigMethodsEnabled
INT wifi_getCliWpsConfigMethodsEnabled(INT ssidIndex, CHAR *output_string)
This function indicates WPS configuration methods enabled on the device.
Definition: wifi_client_hal.c:909
wifi_getCliWpsConfigurationState
INT wifi_getCliWpsConfigurationState(INT ssidIndex, CHAR *output_string)
This API is used to get the WPS config status, whether "configured" or "not configured".
Definition: wifi_client_hal.c:931
wifi_setCliWpsEnrolleePin
INT wifi_setCliWpsEnrolleePin(INT ssidIndex, CHAR *EnrolleePin)
This API sets the PIN to connect. User get the EnrolleePin (device pin from AP device) give to hostap...
Definition: wifi_client_hal.c:937
wifi_lastConnected_Endpoint
INT wifi_lastConnected_Endpoint(wifi_pairedSSIDInfo_t *pairedSSIDInfo)
This call will give the last saved AP's ssid.
Definition: wifi_client_hal.c:1555
wifiSecurityMode_t
wifiSecurityMode_t
Wifi Security modes.
Definition: wifi_common_hal.h:320
_wifi_pairedSSIDInfo::ap_wep_key
CHAR ap_wep_key[128]
wep_key of AP incase of WEP security
Definition: wifi_client_hal.h:125
wifi_getCliWpsEnable
INT wifi_getCliWpsEnable(INT ssidIndex, BOOL *output_bool)
This API checks WPS(Wi-Fi Protected Setup) functionality is enabled for this access point.
Definition: wifi_client_hal.c:867
_wifi_pairedSSIDInfo::ap_bssid
CHAR ap_bssid[64]
[MACAddress] The BSSID (Basic Service Set ID) used for the neighboring WiFi SSID.
Definition: wifi_client_hal.h:122
_wifi_pairedSSIDInfo::ap_security
CHAR ap_security[64]
Security of AP.
Definition: wifi_client_hal.h:123
wifi_setCliWpsDevicePIN
INT wifi_setCliWpsDevicePIN(INT ssidIndex, ULONG pin)
This API sets the WPS Device pin to the Wi-Fi hal.
Definition: wifi_client_hal.c:882
_wifi_telemetry_ops_t
Telemetry callback functions.
Definition: wifi_client_hal.h:378
wifi_connectEndpoint
INT wifi_connectEndpoint(INT ssidIndex, CHAR *AP_SSID, wifiSecurityMode_t AP_security_mode, CHAR *AP_security_WEPKey, CHAR *AP_security_PreSharedKey, CHAR *AP_security_KeyPassphrase, int saveSSID, CHAR *eapIdentity, CHAR *carootcert, CHAR *clientcert, CHAR *privatekey)
This API starts the connection process from client with an AP.
Definition: wifi_client_hal.c:1348
_wifi_pairedSSIDInfo::ap_ssid
CHAR ap_ssid[64]
The current service set identifier in use by the neighboring WiFi SSID. The value MAY be empty for hi...
Definition: wifi_client_hal.h:121
wifi_getCliWpsConfigMethodsSupported
INT wifi_getCliWpsConfigMethodsSupported(INT ssidIndex, CHAR *methods)
This API is used to get WPS configuration methods supported by the device.
Definition: wifi_client_hal.c:896
wifi_telemetry_callback_register
void wifi_telemetry_callback_register(wifi_telemetry_ops_t *telemetry_ops)
Definition: wifi_client_hal.c:250
_wifi_pairedSSIDInfo::ap_passphrase
CHAR ap_passphrase[128]
Passphrase of AP.
Definition: wifi_client_hal.h:124
_wifi_roamingCtrl_t
Roaming Control information (pre assoc data structure}.
Definition: wifi_client_hal.h:135
ULONG
#define ULONG
Defines for the basic data types.
Definition: wifi_common_hal.h:168
wifi_getCliWpsDevicePIN
INT wifi_getCliWpsDevicePIN(INT ssidIndex, ULONG *output_ulong)
This API is used to read the device PIN required for making a WPS connection.
Definition: wifi_client_hal.c:877
wifi_setCliWpsButtonPush
INT wifi_setCliWpsButtonPush(INT ssidIndex)
Start the Push button pairing.
Definition: wifi_client_hal.c:1295
wifi_connectEndpoint_callback
INT(* wifi_connectEndpoint_callback)(INT ssidIndex, CHAR *AP_SSID, wifiStatusCode_t *error)
This call back will be invoked when client automatically connect to Access Point.
Definition: wifi_client_hal.h:366
wifi_disconnectEndpoint_callback
INT(* wifi_disconnectEndpoint_callback)(INT ssidIndex, CHAR *AP_SSID, wifiStatusCode_t *error)
This call back should be registered by Wi-Fi manager to receive status updates from HAL in case of a ...
Definition: wifi_client_hal.h:347
wifi_disconnectEndpoint
INT wifi_disconnectEndpoint(INT ssidIndex, CHAR *AP_SSID)
This API disconnects the access point specified.
Definition: wifi_client_hal.c:1666
wifi_telemetry_ops_t
struct _wifi_telemetry_ops_t wifi_telemetry_ops_t
Telemetry callback functions.
wifi_setCliWpsEnable
INT wifi_setCliWpsEnable(INT ssidIndex, BOOL enableValue)
This API enables or disables WPS functionality for this access point.
Definition: wifi_client_hal.c:872
_wifi_pairedSSIDInfo
SSID information.
Definition: wifi_client_hal.h:119
wifi_connectEndpoint_callback_register
void wifi_connectEndpoint_callback_register(wifi_connectEndpoint_callback callback_proc)
Callback registration function.
Definition: wifi_client_hal.c:238
wifi_cancelCliWPS
INT wifi_cancelCliWPS(INT ssidIndex)
Stop the WPS process.
wifi_setCliWpsConfigMethodsEnabled
INT wifi_setCliWpsConfigMethodsEnabled(INT ssidIndex, CHAR *methodString)
This API sets the active WPS method.
Definition: wifi_client_hal.c:920
wifi_disconnectEndpoint_callback_register
void wifi_disconnectEndpoint_callback_register(wifi_disconnectEndpoint_callback callback_proc)
Callback registration function.
Definition: wifi_client_hal.c:244
wifiStatusCode_t
wifiStatusCode_t
Enumerators for Wi-Fi connection status.
Definition: wifi_common_hal.h:290
wifi_pairedSSIDInfo_t
struct _wifi_pairedSSIDInfo wifi_pairedSSIDInfo_t
SSID information.