/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file c_net_wlan_ctl.h 
 *  $RCSfile: c_net_wlan_ctl.c,v $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This file contains the prototype of control API of Wifi Driver for Application.
 */
/*----------------------------------------------------------------------------*/

#ifndef _C_NET_WLAN_CTL_H
#define _C_NET_WLAN_CTL_H

/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_INET_WIFI
 *  @{
 */
/*----------------------------------------------------------------------------*/

#include "u_net_wlan.h"

INT32 c_net_wlan_set_use_ifname ( char *ifname);
INT32 c_net_wlan_start_driver(x_net_wlan_notify_fct pfNotify);
INT32 c_net_wlan_stop_driver(x_net_wlan_notify_fct pfNotify);
INT32 c_net_wlan_open_connection(const char *ifname);
INT32 c_net_wlan_close_connection(void);
INT32 c_net_wlan_get_chain_rssi(NET_802_11_CHAIN_RSSI_T *pRssi);
INT32 c_net_wlan_get_custdata(NET_802_11_ACFG_CUSTDAT_T * pCustdata);
/*------------------------------------------------------------------*/
/*! @brief Get WPA status. This routine retrieves the WPA status.
 *  @param [out] pStatus -WPAStatus "WPA Status"
 *  @return result
 *  @retval    0 -success
 *  @retval    otherwise -failure
 */
/*------------------------------------------------------------------*/

INT32 c_net_wlan_wpa_get_status(INT32 *pStatus,NET_802_11_ASSOCIATE_T *pAssociate);

/*------------------------------------------------------------------*/
/*! @brief Scan network.This routine scans infrastructure and adhoc networks.
 *  @param [in] pfNotify -callback function to notify scan completion.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_scan(x_net_wlan_notify_fct pfNotify);

/*------------------------------------------------------------------*/
/*! @brief Scan network.This routine scans infrastructure and adhoc networks with specify.
 *  @param [in] pfNotify -callback function to notify scan completion.
 *  @param [in] ssid -the ssid than you want to scan.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_scan_with_ssid(x_net_wlan_notify_fct pfNotify, char * ssid, int ssid_len );


/*------------------------------------------------------------------*/
/*! @brief Get scan result.This routine is called to get the scan result.All the found BSSs are listed in the list.
 *  @param [in,out] pScanResult -list of scan result(BSSs)
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_scan_result(NET_802_11_SCAN_RESULT_T *pScanResult);

/*------------------------------------------------------------------*/
/*! @brief Get a list of ESSs.This routine lists the ESSs enties and sorts in descending order
 *             of the signal strength. The stealth networks are attached the BSSIDs. 
 *             Adhoc networks are not listed in the table.
 *  @param [in,out]  pEssList -list of ESSs
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_ess_list(NET_802_11_ESS_LIST_T *pEssList_result);

/*------------------------------------------------------------------*/
/*! @brief Associate with a wireless network.
 *            This routine triggers attempts of connecting to a wireless network according
 *            to the specified settings. After calling this routine, the WLAN
 *            software continues to maintain a network connection according
 *            to the specified settings until c_net_wlan_disassociate() is called.
 *  @param [in] pAssociate -association settings
 *  @param [in] pfNotify -callback function to notify the association status.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_associate(NET_802_11_ASSOCIATE_T *pAssociate,
                                x_net_wlan_notify_fct pfNotify);

/*------------------------------------------------------------------*/
/*! @brief Disassociate a wireless network connection.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_disassociate(void);

/*------------------------------------------------------------------*/
/*! @brief Get the currently associated BSS information.
 *             This routine gets the information of the associated BSS.
 *             If this routine is called while connection is not established,
 *             zero-BSSID (00:00:00:00:00:00) is returned.
 *  @param [in,out] pCurrBss -associated BSS information
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_curr_bss(NET_802_11_BSS_INFO_T *pCurrBss);

/*------------------------------------------------------------------*/
/*! @brief Get WLAN MAC address.
 *	         This routine gets MAC address of WLAN interface described in binary form.
 *  @param [out] pMacAddr -buffer to store MAC address
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_get_mac_addr(UINT8 *pMacAddr);

/*------------------------------------------------------------------*/
/*! @brief WPS registration and association.
 *	         This routine obtains association settings from a WPS registrer,
 *             save it in the disk and associate with the network.
 *  @param [in] eWpsMode -WPSOpMode "WPS Mode" WPS registration method.
 *  @param [out] pfNotify -callback function to notify WPS status.
 *  @return     result
 *  @retval     0 -success
 *  @retva      otherwise -failure  
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_associate(NET_802_11_WPS_ASSOC_MODE_T eWpsMode,
                                                x_net_wlan_notify_fct pfNotify);

/*------------------------------------------------------------------*/
/*! @brief Get the status of a WPS process.
 *             This routine gets the current WPS status.
 *  @param [out] status -WPSStatus "WPS status"
 *  @return    result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_get_status(INT32 *status);

/*------------------------------------------------------------------*/
/*! @brief Cancel WPS registration process.
 *	This routine tiriggers cancellation of WPS registration process.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_cancel(void);

/*------------------------------------------------------------------*/
/*! @brief Refresh WPS PIN code.
 *            This routine refreshes WPS PIN code.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_refresh_pin(void);

/*------------------------------------------------------------------*/
/*! @brief Get WPS PIN code.
 *	         This routine gets WPS PIN code. The PIN code is not refreshed
 *             by calling this routine.
 *  @param [in]   len -length of the buffer
 *  @param [out] pin -buffer of PIN code
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_wps_get_pin(char *pin, UINT32 len);
/*------------------------------------------------------------------*/
/*! @brief cancel associate a wireless network connection.
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_cancel_associate(void);

/*----------------------------------------------------------------------------*/
/*! @} */
/*----------------------------------------------------------------------------*/

INT32 c_net_wlan_wpa_reg_cbk(x_net_wlan_notify_fct pfNotify);

INT32 c_net_wlan_wpa_unreg_cbk(x_net_wlan_notify_fct pfNotify);  

INT32 c_net_wlan_task_create(void);


INT32 c_net_wlan_set_usb_suspend(BOOL enable);

INT32 c_net_wlan_set_usb_powersaving(BOOL enable);
INT32 c_net_wlan_set_debug_level(int fg_enable, int level);

INT32 c_net_wlan_get_debug_level();

INT32 c_net_wlan_get_rssi(NET_802_11_WIFI_RSSI_T *pRssi);

/*------------------------------------------------------------------*/
/*! @brief do iwpriv set cmd.
 *	         This routine execute iwpriv set cmd by ioctl to wlan driver.
 *  @param [in] cmd -buffer to store cmd for set through iwpriv
 *  @return     result
 *  @retval     0 -success
 *  @retval     otherwise -failure 
 */
/*------------------------------------------------------------------*/
INT32 c_net_wlan_do_iwpriv_set_cmd(const char *cmd);

//add for service mode
INT32 c_net_wlan_get_encryption_mode(NET_802_11_AUTH_MODE_T *e_auth_mode);
INT32 c_net_wlan_get_bandwidth(INT32 *bandwidth);
INT32 c_net_wlan_get_phymode(PHY_MODE *phymode);

INT32 c_net_wlan_get_local_mac(char *local_mac);
INT32 c_net_wlan_get_ap_mac(char *ap_mac);
INT32 c_net_wlan_get_noise(INT16 *noise_0, INT16 *noise_1);
INT32 c_net_wlan_get_phyrate(UINT32 *phyrate);
INT32 c_net_wlan_get_gi(char *gi);

INT32 c_net_wlan_get_txpackets(INT32 * packets);
INT32 c_net_wlan_get_ap_channel(INT16 *channel);
INT32 c_net_wlan_get_trans_power(float * power);
INT32 c_net_wlan_get_hw_version(int *version);
INT32 c_net_wlan_get_mode(IWPRIV_MODE_ITEM *mode);

#endif /* _C_NET_WLAN_CTL_H */
