#include "gsw_nw_interface.h"
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include "gsw_log_interface.h"


//mbtk include
#define MBTK_APN_NAME_SIZE 150+1
#define MBTK_APN_USERNAME_SIZE 127+1
#define MBTK_APN_PASSWORD_SIZE 127+1
#define MBTK_APN_TYPE_SIZE 127+1

#define MBTK_CHANNEL_ID_1 1
#define MBTK_CHANNEL_ID_2 2

#ifndef FALSE
#define FALSE   (0)
#endif
 
 
#ifndef TRUE
#define TRUE    (!FALSE)
#endif




typedef unsigned int uint32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
typedef unsigned long long uint64_t;

typedef struct
{
    int client_fd;
    pthread_t read_thread_id;
    int exit_fd[2];
    bool is_waitting;
    pthread_cond_t cond;
    pthread_mutex_t mutex;

    pthread_mutex_t send_mutex;

    // Temp response data.
    uint16 info_err;
    uint16 data_len;
    void *data;

    //mbtk wyq for server_ready_status add start
    char server_ready_status;
    //mbtk wyq for server_ready_status add end

    mbtk_info_callback_func net_state_cb;
    mbtk_info_callback_func call_state_cb;
    mbtk_info_callback_func sms_state_cb;
    mbtk_info_callback_func radio_state_cb;
    mbtk_info_callback_func sim_state_cb;
    mbtk_info_callback_func pdp_state_cb;
    //add signal by xr
    mbtk_info_callback_func signal_state_cb;
} mbtk_info_handle_t;

typedef enum {
    MBTK_IP_TYPE_IP,
    MBTK_IP_TYPE_IPV6,
    MBTK_IP_TYPE_IPV4V6,
    MBTK_IP_TYPE_PPP
} mbtk_ip_type_enum;

typedef enum {
    MBTK_APN_REQ_TYPE_SET = 0,   // set apn req
    MBTK_APN_REQ_TYPE_ADD        // add apn req
}mbtk_apn_req_type_enum;

typedef enum {
	MBTK_APN_AUTH_PROTO_DEFAULT = 0,
	MBTK_APN_AUTH_PROTO_NONE,
	MBTK_APN_AUTH_PROTO_PAP,
	MBTK_APN_AUTH_PROTO_CHAP,
#if 0
	MBTK_APN_AUTH_PROTO_PAP_CHAP,
    //NOT SUPPORT
#endif
} mbtk_apn_auth_proto_enum;

typedef enum {
    GSW_ID_CONVERT_TYPE_LINKID = 0,
    GSW_ID_CONVERT_TYPE_APNID
}gsw_id_convert_type_e;

typedef struct {
    bool valid;
    uint32 IPAddr;
    uint32 PrimaryDNS;
    uint32 SecondaryDNS;
    uint32 GateWay;
    uint32 NetMask;
} __attribute__((packed)) mbtk_ipv4_info_t;

typedef struct {
    bool valid;
    uint32 IPV6Addr[4];
    uint32 PrimaryDNS[4];
    uint32 SecondaryDNS[4];
    uint32 GateWay[4];
    uint32 NetMask[4];
} __attribute__((packed)) mbtk_ipv6_info_t;

typedef struct {
	int cid;                /*!< UMTS/CDMA profile ID. range: 0 - 7*/
	mbtk_ip_type_enum ip_type;               /*!< Packet Data Protocol (PDP) type specifies the type of data payload
	                                             exchanged over the airlink when the packet data session is
	                                             established with this profile. */
	mbtk_apn_req_type_enum req_type;          /*!< apn req type*/
	mbtk_apn_auth_proto_enum auth_proto;         /*!< Authentication Protocol. */
	uint8 apn_name[MBTK_APN_NAME_SIZE];        /*!< A string parameter that is a logical name used to select the GGSN
	                                             and external packet data network. */
	uint8 user_name[MBTK_APN_USERNAME_SIZE];    /*!< Username used during data network authentication. */
	uint8 user_pass[MBTK_APN_PASSWORD_SIZE];    /*!< Password to be used during data network authentication. */
    uint8 apn_type[MBTK_APN_TYPE_SIZE];
} mbtk_qser_apn_info_s;

typedef struct{
    uint8            cid; //cid number
    bool             connect_state; //true: connect, false: disconnect;
    bool             auto_urc; //urc generated by manual/auto dialing
    uint8            pdp_result; //The cause of the dialing result 
    mbtk_ipv4_info_t ipv4; //ipv4 info
    mbtk_ipv6_info_t ipv6; //ipv6 info
}mbtk_pdp_cb_info_s;

static mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
static int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
int (*mbtk_pdp_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
int (*mbtk_qser_apn_set)(mbtk_info_handle_t* handle, mbtk_qser_apn_info_s *apninfo, unsigned char *cid);
int (*mbtk_data_call_start)(mbtk_info_handle_t* handle, int cid, int auto_conn_interval, bool boot_conn, int timeout);
int (*mbtk_data_call_stop)(mbtk_info_handle_t* handle, int cid, int timeout);
int (*mbtk_data_call_state_get)(mbtk_info_handle_t* handle, int cid, mbtk_ipv4_info_t *ipv4, mbtk_ipv6_info_t *ipv6);
int (*mbtk_apn_set)(mbtk_info_handle_t* handle, int cid, mbtk_ip_type_enum ip_type, const void* apn_name, const void *user_name, const void *user_pass, const void *auth);
int (*ipv6_2_str)(const void *ipv6, void *ipv6_str);

#define GSW_DATA "[HAL][GSW_DATA]"

//define
#define lib_mbtk_path "/lib/libmbtk_lib.so"
pthread_mutex_t data_mutex = PTHREAD_MUTEX_INITIALIZER;
static int data_init_flag = 0;
static void *dlHandle_mbtk = NULL;
static mbtk_info_handle_t* data_info_handle = NULL;
static gsw_data_call_evt_cb_t gsw_data_call_evt_cb = NULL;

Wan_State_ind_s *linkState_arr;

static int Wan_State_ind_malloc(Wan_State_ind_s **linkState)
{
    (*linkState) = (Wan_State_ind_s *)malloc(sizeof(Wan_State_ind_s));
    if((*linkState) == NULL)
    {
        LOGE(GSW_DATA,"malloc Wan_State_ind_s fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    memset((*linkState), 0x00, sizeof(Wan_State_ind_s));

    (*linkState)->handle = -1;
    (*linkState)->cid = -1;
    (*linkState)->state = 0;
    (*linkState)->fail_cause = 0;

    (*linkState)->type = (char *)malloc(GSW_PDP_TYPE_MAX_LEN);
    memset((*linkState)->type, 0x00, GSW_PDP_TYPE_MAX_LEN);

    (*linkState)->ifname = (char *)malloc(GSW_IFACE_NAME_MAX_LEN);
    memset((*linkState)->ifname, 0x00, GSW_IFACE_NAME_MAX_LEN);

    (*linkState)->v4_ip = (char *)malloc(GSW_PDP_ADDR_MAX_LEN);
    memset((*linkState)->v4_ip, 0x00, GSW_PDP_ADDR_MAX_LEN);

    (*linkState)->v4_pdns = (char *)malloc(GSW_DNS_ADDR_MAX_LEN);
    memset((*linkState)->v4_pdns, 0x00, GSW_DNS_ADDR_MAX_LEN);

    (*linkState)->v4_sdns = (char *)malloc(GSW_DNS_ADDR_MAX_LEN);
    memset((*linkState)->v4_sdns, 0x00, GSW_DNS_ADDR_MAX_LEN);

    (*linkState)->v4_gw = (char *)malloc(GSW_GETWAYS_ADDR_MAX_LEN);
    memset((*linkState)->v4_gw, 0x00, GSW_GETWAYS_ADDR_MAX_LEN);

    (*linkState)->v6_ip = (char *)malloc(GSW_PDP_ADDR_MAX_LEN);
    memset((*linkState)->v6_ip, 0x00, GSW_PDP_ADDR_MAX_LEN);

    (*linkState)->v6_pdns = (char *)malloc(GSW_DNS_ADDR_MAX_LEN);
    memset((*linkState)->v6_pdns, 0x00, GSW_DNS_ADDR_MAX_LEN);

    (*linkState)->v6_sdns = (char *)malloc(GSW_DNS_ADDR_MAX_LEN);
    memset((*linkState)->v6_sdns, 0x00, GSW_DNS_ADDR_MAX_LEN);

    return GSW_HAL_SUCCESS;
}

static int Wan_State_ind_free(Wan_State_ind_s **linkState)
{
    if ((*linkState) == NULL) 
    {
        LOGE(GSW_DATA,"(*linkState) is null\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    free((*linkState)->type);
    (*linkState)->type = NULL;

    free((*linkState)->ifname);
    (*linkState)->ifname = NULL;

    free((*linkState)->v4_ip);
    (*linkState)->v4_ip = NULL;

    free((*linkState)->v4_pdns);
    (*linkState)->v4_pdns = NULL;

    free((*linkState)->v4_sdns);
    (*linkState)->v4_sdns = NULL;

    free((*linkState)->v4_gw);
    (*linkState)->v4_gw = NULL;

    free((*linkState)->v6_ip);
    (*linkState)->v6_ip = NULL;

    free((*linkState)->v6_pdns);
    (*linkState)->v6_pdns = NULL;

    free((*linkState)->v6_sdns);
    (*linkState)->v6_sdns = NULL;


    free((*linkState));
    (*linkState) = NULL;

    return GSW_HAL_SUCCESS;
}

static int mbtk_data_api_import()
{
    dlHandle_mbtk = dlopen(lib_mbtk_path, RTLD_NOW);
    if (dlHandle_mbtk == NULL) 
    {
        return GSW_HAL_NORMAL_FAIL;
    }
    
    mbtk_info_handle_get = (mbtk_info_handle_t* (*)(void))dlsym(dlHandle_mbtk, "mbtk_info_handle_get");
    if (mbtk_info_handle_get == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_info_handle_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_info_handle_free = (int (*)(mbtk_info_handle_t** handle))dlsym(dlHandle_mbtk, "mbtk_info_handle_free");
    if (mbtk_info_handle_free == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_info_handle_free dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_pdp_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_pdp_state_change_cb_reg");
    if (mbtk_pdp_state_change_cb_reg == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_pdp_state_change_cb_reg dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_qser_apn_set = (int (*)(mbtk_info_handle_t* handle, mbtk_qser_apn_info_s *apninfo, unsigned char *cid))dlsym(dlHandle_mbtk, "mbtk_qser_apn_set");
    if (mbtk_qser_apn_set == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_qser_apn_set dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_data_call_start = (int (*)(mbtk_info_handle_t* handle, int cid, int auto_conn_interval, bool boot_conn, int timeout))dlsym(dlHandle_mbtk, "mbtk_data_call_start");
    if (mbtk_data_call_start == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_data_call_start dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_data_call_stop = (int (*)(mbtk_info_handle_t* handle, int cid, int timeout))dlsym(dlHandle_mbtk, "mbtk_data_call_stop");
    if (mbtk_data_call_stop == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_data_call_stop dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_data_call_state_get = (int (*)(mbtk_info_handle_t* handle, int cid, mbtk_ipv4_info_t *ipv4, mbtk_ipv6_info_t *ipv6))dlsym(dlHandle_mbtk, "mbtk_data_call_state_get");
    if (mbtk_data_call_state_get == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_data_call_state_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_apn_set = (int (*)(mbtk_info_handle_t* handle, int cid, mbtk_ip_type_enum ip_type, const void* apn_name, const void *user_name, const void *user_pass, const void *auth))dlsym(dlHandle_mbtk, "mbtk_apn_set");
    if (mbtk_apn_set == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_apn_set dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    ipv6_2_str = (int (*)(const void *ipv6, void *ipv6_str))dlsym(dlHandle_mbtk, "ipv6_2_str");
    if (ipv6_2_str == NULL) 
    {
        LOGE(GSW_DATA,"ipv6_2_str dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}



static int data_call_state_query(int call_id,Wan_State_ind_s *linkState, mbtk_ipv4_info_t *ipv4, mbtk_ipv6_info_t *ipv6)
{
    //ifname
    sprintf(linkState->ifname, "ccinet%d", call_id-1);

    //type
    if(ipv4->valid)
    {
        if(ipv6->valid)
        {
            strcpy(linkState->type, "IPV4V6");
        } 
        else
        {
            strcpy(linkState->type, "IP");
        }
    }
    else if(ipv6->valid)
    {
        strcpy(linkState->type, "IPV6");
    }

    //ip
    LOGD(GSW_DATA,"ipv4.valid = %d", ipv4->valid);
    if(ipv4->valid)
    {
        if(linkState==NULL)
        {
            LOGE(GSW_DATA,"linkState is NULL");
            return GSW_HAL_NORMAL_FAIL;
        }

        //parse ipv4_addr,gw,dns,sdns
        if(inet_ntop(AF_INET, &(ipv4->IPAddr), linkState->v4_ip , GSW_PDP_ADDR_MAX_LEN) == NULL) {
            LOGE(GSW_DATA,"IPv4 error");
        } else {
            LOGD(GSW_DATA,"IPv4 : %s", linkState->v4_ip);
            
        }


        if(inet_ntop(AF_INET, &(ipv4->GateWay), linkState->v4_gw , GSW_PDP_ADDR_MAX_LEN) == NULL) {
            LOGE(GSW_DATA,"GateWay error");
        } else {
            LOGE(GSW_DATA,"GateWay : %s", linkState->v4_gw);
        }

        if(inet_ntop(AF_INET, &(ipv4->PrimaryDNS), linkState->v4_pdns , GSW_DNS_ADDR_MAX_LEN) == NULL) {
            LOGE(GSW_DATA,"PrimaryDNS error");
        } else {
            LOGD(GSW_DATA,"PrimaryDNS : %s", linkState->v4_pdns);
        }

        if(inet_ntop(AF_INET, &(ipv4->SecondaryDNS), linkState->v4_sdns , GSW_DNS_ADDR_MAX_LEN) == NULL) {
            LOGE(GSW_DATA,"SecondaryDNS error");
        } else {
            LOGD(GSW_DATA,"SecondaryDNS : %s", linkState->v4_sdns);
        }
    }

    LOGD(GSW_DATA,"ipv6.valid = %d", ipv6->valid);
    if(ipv6->valid)
    {
        //parse ipv6_addr,gw,dns,sdns
        if(ipv6_2_str(&(ipv6->IPV6Addr), linkState->v6_ip)) {
            LOGE(GSW_DATA,"IPv6 error");
        } else {
            LOGD(GSW_DATA,"IPv6 : %s", linkState->v6_ip);
        }

        if(ipv6_2_str(&(ipv6->PrimaryDNS), linkState->v6_pdns)) {
            LOGE(GSW_DATA,"PrimaryDNS error");
        } else {
            LOGD(GSW_DATA,"PrimaryDNS : %s", linkState->v6_pdns);
        }

        if(ipv6_2_str(&(ipv6->SecondaryDNS), linkState->v6_sdns)) {
            LOGE(GSW_DATA,"SecondaryDNS error");
        } else {
            LOGD(GSW_DATA,"SecondaryDNS : %s", linkState->v6_sdns);
        }
    }

    return GSW_HAL_SUCCESS;
}


static void data_call_state_change_cb(const void* data, int data_len)
{
    LOGE(GSW_DATA,"data_call_state_change_cb() start\n");

    if(data == NULL || data_len != sizeof(mbtk_pdp_cb_info_s))
    {
        LOGE(GSW_DATA,"data = [NULL], data_len(%d) != sizeof(mbtk_pdp_cb_info_s)(%d)", data_len, sizeof(mbtk_pdp_cb_info_s));
        return;
    }

    int ret = -1;

    LOGD(GSW_DATA,"Wan_State_ind_malloc start\n");
    ret = Wan_State_ind_malloc(&linkState_arr);
    if (ret != 0) 
    {
        LOGE(GSW_DATA,"Wan_State_ind_malloc[0] fail\n");
        return ;
    }

    if(linkState_arr == NULL)
    {
        LOGE(GSW_DATA,"linkState_arr is NULL");
        return ;
    }
    else
    {
        LOGE(GSW_DATA,"linkState_arr is not NULL");
    }

    mbtk_pdp_cb_info_s *pdp_cb_info = (mbtk_pdp_cb_info_s *)data;
    linkState_arr->cid = pdp_cb_info->cid;
    linkState_arr->handle = pdp_cb_info->cid;
    if(pdp_cb_info->connect_state)
    {
        linkState_arr->state = 2;//connected
        data_call_state_query(pdp_cb_info->cid, linkState_arr, &(pdp_cb_info->ipv4), &(pdp_cb_info->ipv6));
    }
    else
    {
        linkState_arr->state = 0;//disconnected
    }
    
    if(gsw_data_call_evt_cb)
    {
        gsw_data_call_evt_cb(linkState_arr);
    }

    ret = Wan_State_ind_free(&linkState_arr);
    if (ret != 0) 
    {
        LOGE(GSW_DATA,"Wan_State_ind_free fail\n");
    }

}

static int gsw_id_convert_to_channel_id(int gsw_id, gsw_id_convert_type_e type, int *channel_id)
{
    if(GSW_ID_CONVERT_TYPE_LINKID == type)
    {
        switch(gsw_id)
        {
            case 0:
            {
                *channel_id = MBTK_CHANNEL_ID_2;
                break;
            }
            case 1:
            {
                *channel_id = MBTK_CHANNEL_ID_1;
                break;
            }
            default :
            {
                LOGE(GSW_DATA,"[%s] gsw_id(linkid) unknown.[%d]", __func__, gsw_id);
                return -1;
            }
        }
    }
    else
    {
        switch(gsw_id)
        {
            case 1:
            case -2:
            {
                *channel_id = MBTK_CHANNEL_ID_1;
                break;
            }
            case -1:
            case 2:
            {
                *channel_id = MBTK_CHANNEL_ID_2;
                break;
            }
            default :
            {
                LOGE(GSW_DATA,"[%s] gsw_id(apnid) unknown.[%d]", __func__, gsw_id);
                return -1;
            }
        }
    }

    return 0;
}




/**
 * @brief datacall sdk init
 * @param  [in] evt_cb callback function for data connection state change event
 * call back;
 * @retval 0: success
 * @retval other: fail
 */
int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb)
{
    int ret;
    ret = mbtk_data_api_import();
    if (ret != 0) 
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    if(data_init_flag != 0 && data_info_handle != NULL)
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    if (ret != GSW_HAL_SUCCESS) 
    {
        LOGE(GSW_DATA,"mbtk_data_api_import fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    data_info_handle = (mbtk_info_handle_t*)mbtk_info_handle_get();
    if (data_info_handle == NULL) 
    {
        LOGE(GSW_DATA,"mbtk_info_handle_get fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_pdp_state_change_cb_reg((mbtk_info_handle_t*)data_info_handle, data_call_state_change_cb);
    if (ret != 0) 
    {
        LOGE(GSW_DATA,"mbtk_pdp_state_change_cb_reg fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    gsw_data_call_evt_cb = evt_cb;
    data_init_flag = 1;
    return GSW_HAL_SUCCESS;
}


/**
 * @brief data_call sdk deinit
 * @param 
 * @retval 0: success
 * @retval other: fail
 */
int gsw_data_call_deinit(void)
{
    int ret;
    if(data_init_flag == 0 || data_info_handle == NULL)
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_info_handle_free((mbtk_info_handle_t**)&data_info_handle);
    if (ret != 0) 
    {
        LOGE(GSW_DATA,"mbtk_info_handle_free fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    data_init_flag = 0;
    return GSW_HAL_SUCCESS;
}

/**
 * @brief set apn parameters for data call
 * @param  [in/out] LinkInf apn info for pub or private datacall
 * inlcude apn name  mcc mnc, passwork apnid  type cid etc
 * @retval 0: success
 * @retval other: fail
 */
int gsw_data_call_set_apn(Link_Info_s *LinkInf)
{
    if(data_init_flag == 0 || data_info_handle == NULL)
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    if(LinkInf == NULL)
    {
        LOGE(GSW_DATA,"apn info is null");
        return GSW_HAL_NORMAL_FAIL;
    }

    int ret = 0;
    int cid = -1;
    int apnid = -1;
    mbtk_ip_type_enum ip_type;
    char auth_type[GSW_AUTH_TYPE_MAX_LEN + 1] = {0};

    //pdp type
    if(strcmp(LinkInf->normalProtocol,"IP") == 0)
    {
        ip_type = MBTK_IP_TYPE_IP;
        LOGE(GSW_DATA,"pdp_type(protocol) is IP");
    }
    else if(strcmp(LinkInf->normalProtocol,"IPV6") == 0)
    {
        ip_type = MBTK_IP_TYPE_IPV6;
        LOGE(GSW_DATA,"pdp_type(protocol) is IPV6");
    }
    else if(strcmp(LinkInf->normalProtocol,"IPV4V6") == 0)
    {
        ip_type = MBTK_IP_TYPE_IPV4V6;
        LOGE(GSW_DATA,"pdp_type(protocol) is IPV4V6");
    }
    else
    {
        LOGE(GSW_DATA,"pdp_type(protocol) error");
        return GSW_HAL_NORMAL_FAIL;
    }

    apnid = atoi(LinkInf->apnid);
    ret = gsw_id_convert_to_channel_id(apnid, GSW_ID_CONVERT_TYPE_APNID, &cid);
    if(0 != ret)
    {
        LOGE(GSW_DATA,"[%s] gsw_id_convert_to_channel_id() fail", __func__);
        return GSW_HAL_NORMAL_FAIL;
    }

    //bypass solution for authparams issue
    #if 0
    memset(LinkInf->usr, 0x00, sizeof(LinkInf->usr));
    memset(LinkInf->pwd, 0x00, sizeof(LinkInf->pwd));
    memset(LinkInf->authType, 0x00, sizeof(LinkInf->authType));
    #endif
    //auth type
    memset(auth_type, 0x00, GSW_AUTH_TYPE_MAX_LEN + 1);
    if(0 == strlen(LinkInf->authType) || 0 == strcmp(LinkInf->authType, "0"))
    {
        memcpy(auth_type, "NONE", strlen("NONE"));
    }
    else if(0 == strcmp(LinkInf->authType, "1"))
    {
        memcpy(auth_type, "PAP", strlen("PAP"));
    }
    else if(0 == strcmp(LinkInf->authType, "2"))
    {
        memcpy(auth_type, "CHAP", strlen("CHAP"));
    }
    else if(0 == strcmp(LinkInf->authType, "3"))
    {
     /*   //nonsupport
        LOGE(GSW_DATA,"[%s] LinkInf->authType(3) nonsupport", __func__);
        return GSW_HAL_NORMAL_FAIL;*/
        memcpy(auth_type, "CHAP", strlen("CHAP"));/*in T106 if set chap and pap, chap and chap are used, all use chap here, hq modify for the timebing 25/07/24*/
      
    }
    else
    {
        LOGE(GSW_DATA,"[%s] LinkInf->authType(%s) unknown", __func__, LinkInf->authType);
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_apn_set(data_info_handle, cid, ip_type, LinkInf -> apn, LinkInf -> usr, LinkInf -> pwd, (const void *)auth_type);
    if(ret != 0)
    {
        LOGE(GSW_DATA,"[%s] mbtk_apn_set fail() fail.[%d]", __func__, ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}


/**
 * @brief set apn parameters for data call
 * @param  [in] linkid data connetion link number
 * @param  [in/out] LinkInf link info req: apn info for pub or private datacall
 * inlcude apn name  mcc mnc, passwork apnid etc
 * resp: data call link state ipaddress type  etc
 * @retval 0: success
 * @retval other: fail
 */
int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf)
{
    int ret = -1;
    int cid = -1;
    if(data_init_flag == 0 || data_info_handle == NULL)
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    if(LinkInf == NULL)
    {
        LOGE(GSW_DATA,"apn info is null");
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = gsw_data_call_set_apn(LinkInf);
    if(ret != GSW_HAL_SUCCESS)
    {
        LOGE(GSW_DATA,"[%s] gsw_data_call_set_apn() fail", __func__);
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = gsw_id_convert_to_channel_id(linkid, GSW_ID_CONVERT_TYPE_LINKID, &cid);
    if(0 != ret)
    {
        LOGE(GSW_DATA,"[%s] gsw_id_convert_to_channel_id() fail", __func__);
        return GSW_HAL_NORMAL_FAIL;
    }
    
    ret = mbtk_data_call_start((mbtk_info_handle_t*)data_info_handle, cid, 0, FALSE, 0);
    if(ret != 0)
    {
        LOGE(GSW_DATA,"[%s] mbtk_data_call_start fail.[%d]", __func__, ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    LinkInf->handle = cid;
    memset(LinkInf->apnid, 0x00, sizeof(LinkInf->apnid));
    sprintf(LinkInf->apnid, "%d", cid);

    return GSW_HAL_SUCCESS;
}


/**
 * @brief set apn parameters for data call
 * @param  [in] linkid 
 * @param  [in/out] LinkInf link info req: apn info for pub or private datacall
 * inlcude apn name  mcc mnc, passwork apnid etc
 * resp: data call link state ipaddress type  etc
 * @retval 0: success
 * @retval other: fail
 */
int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf)
{
    int ret = -1;
    int cid = -1;
    if(data_init_flag == 0 || data_info_handle == NULL)
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    if(LinkInf == NULL)
    {
        LOGE(GSW_DATA,"apn info is null");
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = gsw_id_convert_to_channel_id(linkid, GSW_ID_CONVERT_TYPE_LINKID, &cid);
    if(0 != ret)
    {
        LOGE(GSW_DATA,"[%s] gsw_id_convert_to_channel_id() fail", __func__);
        return GSW_HAL_NORMAL_FAIL;
    }
    
    ret = mbtk_data_call_stop((mbtk_info_handle_t*)data_info_handle, cid, 15);
    if(ret != 0)
    {
        LOGE(GSW_DATA,"[%s] mbtk_data_call_stop() fail.[%d]",__func__, ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}


/*
 * @brief get mobile operator name
   @param [in] linkid apn id
   @param [out] data_pkt obtian actual data call network card data traffic
   @retval 0: success
   @retval 0: other: fail
 */
int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt)
{
    
    if(data_init_flag == 0 || data_info_handle == NULL)
    {
        return GSW_HAL_NORMAL_FAIL;
    }
    char temp_linkid[12] = {0};
    char interface_name[32] = {0};
    sprintf(temp_linkid,"%d",linkid+1);
    snprintf(interface_name, sizeof(interface_name),"ccinet%s", temp_linkid);
    
    uint64_t tx_bytes = 0;
    uint64_t tx_packets = 0;
    uint64_t tx_dropped = 0;
    uint64_t rx_bytes = 0;
    uint64_t rx_packets = 0;
    uint64_t rx_dropped = 0;
    char command[128] = {0};
    char* temp;
    char buffer[512] = {0};

    snprintf(command, sizeof(command), "ifconfig %s", interface_name);

    FILE *fp = popen(command, "r");
    if(fp == NULL)
    {
        LOGE(GSW_DATA,"popen fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    //read line by line
    while (fgets(buffer, sizeof(buffer), fp) != NULL) {
        //  TX bytes
        if (strstr(buffer, "TX bytes")) {
            temp = strstr(buffer, "TX bytes");
            sscanf(temp, " TX bytes:%llu ", &tx_bytes);
        }
        //  TX packets
        if (strstr(buffer, "TX packets")) {
            sscanf(buffer, " TX packets:%llu ", &tx_packets);
            sscanf(buffer, " TX packets:%*u errors:%*u dropped:%llu", &tx_dropped);
        }
        //  RX bytes
        if (strstr(buffer, "RX bytes")) {
            LOGE(GSW_DATA,"RX bytes %s\n",strstr(buffer, "RX bytes"));
            sscanf(buffer, " RX bytes:%llu ", &rx_bytes);
        }
        //  RX packets
        if (strstr(buffer, "RX packets")) {
            sscanf(buffer, " RX packets:%llu ", &rx_packets);
            sscanf(buffer, " RX packets:%*u errors:%*u dropped:%llu", &rx_dropped);
        }
    }

    // 关闭管道
    pclose(fp);

    // 输出结果
    LOGE(GSW_DATA,"TX Bytes: %llu\n", tx_bytes);
    LOGE(GSW_DATA,"TX Packets: %llu\n", tx_packets);
    LOGE(GSW_DATA,"TX Dropped: %llu\n", tx_dropped);
    LOGE(GSW_DATA,"RX Bytes: %llu\n", rx_bytes);
    LOGE(GSW_DATA,"RX Packets: %llu\n", rx_packets);
    LOGE(GSW_DATA,"RX Dropped: %llu\n", rx_dropped);

    if(data_pkt == NULL)
    {
        LOGE(GSW_DATA,"data_pkt is null\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    else
    {
        data_pkt->tx_bytes = tx_bytes;
        data_pkt->tx_pkts = tx_packets;
        data_pkt->tx_dropped_pkts = tx_dropped;
        data_pkt->rx_bytes = rx_bytes;
        data_pkt->rx_pkts = rx_packets;
        data_pkt->rx_dropped_pkts = rx_dropped;
    }
    
    return GSW_HAL_SUCCESS;

}
