/* 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 u_dlm_net.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $ 
 *  
 *  @par Description:
 *         This header file contains download firmware specific
 *         definitions, which are exported.
 *         
 */
/*----------------------------------------------------------------------------*/


#ifndef __U_DLM_NET_H__
#define __U_DLM_NET_H__

#include "x_common.h"
#include "x_os.h"
/*----------------------------------------------------------------------------*/
/*! @defgroup   groupMW_INET_DLM_NET DOWNLOAD FIRMWARE API
 *  @ingroup    groupMW_INET
 *  @brief      Provide an external definitions about network download firmware
 *  %MW_INET_DLM_NET API would be used by user who wants download firmware via network.
 *              
 *              
 *  @{
 */

#define DLM_NET_INTERVAL_TIMEOUT            60    /**<    used for CURLOPT_LOW_SPEED_TIME    */
#define DLM_NET_CONNECT_TIMEOUT             10    /**<    define connect to server timeout    */
#define DLM_NET_UNKNOW_SIZE                 0xffffffff    /**<  used for chunk content length  */
/*------------------------------------------------------------------*/
/*! @enum DLM_NETR_CODE_T
 *  @brief download firmware return code
 *  @code
 *  typedef enum _DLM_NETR_CODE_T
 *  {
 *      DLM_NETR_OK = 0,
 *      DLM_NETR_OUT_OF_MEMORY = -1,
 *      DLM_NETR_INVALID_ARGUMENT = -2,
 *      DLM_NETR_AUTHENTICATE_ERROR = -3,
 *      DLM_NETR_DOWNLOAD_ERROR = -4,
 *      DLM_NETR_SET_OPT_ERROR = -5,
 *      DLM_NETR_SESSION_ERROR = -6
 *  }DLM_NETR_CODE_T;
 *  @endcode
 *  @li@c  DLM_NETR_OK                                       -operation success
 *  @li@c  DLM_NETR_OUT_OF_MEMORY                            -memory alloc faile
 *  @li@c  DLM_NETR_INVALID_ARGUMENT                         -operation argument error
 *  @li@c  DLM_NETR_AUTHENTICATE_ERROR                           -start authenticate faile
 *  @li@c  DLM_NETR_DOWNLOAD_ERROR                           -start download faile
 *  @li@c  DLM_NETR_SET_OPT_ERROR                            -set http opetation error
 *  @li@c  DLM_NETR_SESSION_ERROR                             -open http session error
 */
/*------------------------------------------------------------------*/
typedef enum _DLM_NETR_CODE_T
{
    DLM_NETR_OK = 0,
    DLM_NETR_OUT_OF_MEMORY = -1,
    DLM_NETR_INVALID_ARGUMENT = -2,
    DLM_NETR_AUTHENTICATE_ERROR = -3,
    DLM_NETR_DOWNLOAD_ERROR = -4,
    DLM_NETR_SET_OPT_ERROR = -5,
    DLM_NETR_SESSION_ERROR = -6
}DLM_NETR_CODE_T;

/*------------------------------------------------------------------*/
/*! @enum DLM_NET_ASYNC_REQ_T
 *  @brief download firmware callback return state
 *  @code
 *  typedef enum _DLM_NET_ASYNC_REQ_T
 *  {
 *      DLM_NET_ASYNC_COND_OK = 0,
 *      DLM_NET_ASYNC_COND_CANCEL = -1,
 *      DLM_NET_ASYNC_COND_RSP_ERROR = -2,
 *      DLM_NET_ASYNC_COND_ERROR = -3
 *  }DLM_NET_ASYNC_REQ_T;
 *  @endcode
 *  @li@c  DLM_NET_ASYNC_COND_OK                             -download success
 *  @li@c  DLM_NET_ASYNC_COND_CANCEL                         -download cancel by application
 *  @li@c  DLM_NET_ASYNC_COND_RSP_ERROR                      -request error
 *  @li@c  DLM_NET_ASYNC_COND_ERROR                          -download error
 */
/*------------------------------------------------------------------*/
typedef enum _DLM_NET_ASYNC_REQ_T
{
    DLM_NET_ASYNC_COND_OK = 0,
    DLM_NET_ASYNC_COND_CANCEL = -1,
    DLM_NET_ASYNC_COND_RSP_ERROR = -2,
    DLM_NET_ASYNC_COND_ERROR = -3
}DLM_NET_ASYNC_REQ_T;

/*------------------------------------------------------------------*/
/*! @brief This is a callback function for progress callback function
 *  @param [in] ui4_total_sz -download total data
 *  @param [in] ui4_now_sz -download now data
 *  @return None
 */
/*------------------------------------------------------------------*/
typedef VOID (*x_dlm_net_progress_cb)(UINT32 ui4_total_sz, UINT32 ui4_now_sz);

/*------------------------------------------------------------------*/
/*! @brief This is a callback function for download asynchronized function
 *  @param [in] e_state -the download flow condition when call the callback
 *  @return None
 */
/*------------------------------------------------------------------*/
typedef VOID (*x_dlm_net_dl_async_cb)(DLM_NET_ASYNC_REQ_T   e_state);

/*------------------------------------------------------------------*/
/*! @brief This is a callback function for authenticate asynchronized function
 *  @param [in] e_state -the download flow condition when call the callback
 *  @param [in] ps_response -the response data from server
 *  @param [in] ui4_len -the length of response
 *  @return None
 */
/*------------------------------------------------------------------*/
typedef VOID (*x_dlm_net_auth_async_cb)(DLM_NET_ASYNC_REQ_T e_state,
                                           CHAR                 *ps_response,
                                           UINT32               ui4_len);




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

#endif /* __U_DLM_NET_H__ */


