高通MDM9x07 qcmap数据拨号

qcmap底层基于高通的数据服务接DSI接口


DSI:Data Service Interface,数据业务接口
netctrl:网络控制
bring up / tear down:数据呼叫通道的建立、销毁
APN:Access Point Name,移动接入点名称
PDN:Packet data network,包数据网络(分组业务网络)
DNS:Domain Name Service,域名解析服务
Qos:Quality Of Service,业务质量控制
QMI:Qualcomm Messaging Interface,高通消息传递接口
本库启动的时候作为一个守护进程,底层依赖QMI提供功能,客户端启动进程后调用本库连接守护进程处理数据业务。
本库提供:
    1. WWAN数据业务的建立、销毁和基本配置,可以配置APN、IP协议族、技术选择优先级、用户名密码、profile ID等
    2. Qos(DSI_NetCtrl provides methods for applications to request UE-initiated QoS)
    3. 多播和多媒体多播
    4. DNS(Domain Name Service)
    5. 各种数据业务状态查询
    6. 支持双IP数据呼叫,客户端只要使用单个接口即可,不用连接两次
    7. 支持多PDN同时建立数据业务,应用程序必须控制路由
    8. 支持多个进程连接DSI_NetCtrl,每个进程可以独立控制数据连接的建立和销毁,多PDN场景也可以用多个进程处理

【数据呼叫流程】
    1. dsi_init,初始化,客户端连接到守护进程
    2. dsi_start_data_call,设置数据连接参数,启动数据连接,启动前可以配置多次,可以配置的参数包括:
        2.1 UMTS / CDMA ID
        2.2 APN
        2.3 IP Version (IPv4 / IPv6/ IPv4v6)
        2.4 APN用户名密码
        2.5 认证优先级
        2.6 技术类型 / 扩展技术名称
    3. dsi_stop_data_call,销毁数据连接(同时网络侧可能发起数据连接销毁,此时将网络状态通知到dsi进程)

【Qos】
    主要功能:
        流量监管(对进入接口的,超出限制速率的报文进行丢弃)
        流量整形(对接口发送的,超出限制速率的报文先进行缓存,等待流量不超出速率时发送)
        拥塞避免(在出现网络拥塞时对符合条件的报文进行丢弃)
        拥塞管理(在出现网络拥塞时采用队列调度的方法对符合条件的队列中的报文优先发送)
        流策略(可根据不同的流分类实现诸如禁止/允许通过,重标记报文优先级、重标记报文VLAN标签、重定向流量、过滤报文、
            流量镜像、启用流量统计功能等行为)。
    dsi库支持用户发起的和网络侧发起的Qos。
 

【qcmap】

9X07模块提供了qcmap_msgr服务来进行拨号,通过与dsi_netctrl对比,qcmap_msgr接口更清晰,而且操作也简单。
AP侧使用QMI架构和modem通信初始化流程是固定的:

qcmap_msgr_get_service_object_v01查询服务对象 =>
qmi_client_notifier_init初始化client通知信息 =>
qmi_client_get_service_list查询支持的服务列表个数 =>
qmi_client_get_service_list查询支持的服务列表信息 =>
qmi_client_init使用其中一个服务信息初始化client
参考代码:

void qcmap_ppp_init(qcmap_ppp_t *self,client_status_ind_t client_cb_ind) {
    qmi_idl_service_object_type qcmap_msgr_qmi_idl_service_object;
    uint32_t num_services = 0, num_entries = 0;
    qmi_service_info info[10];
    qmi_client_error_type qmi_error, qmi_err_code = QMI_NO_ERR;

    assert(self);
    
    self->qcmap_msgr_enable = FALSE;
    self->qmi_qcmap_msgr_handle = 0;
    self->mobile_ap_handle = 0;

    qcmap_msgr_qmi_idl_service_object = qcmap_msgr_get_service_object_v01;//when faild, add your trick for this~

    if (qcmap_msgr_qmi_idl_service_object == NULL)
    {
        LOG("qcmap_msgr service object not available");
        return;
    }

    qmi_error = qmi_client_notifier_init(qcmap_msgr_qmi_idl_service_object,
                                        &self->qmi_qcmap_msgr_os_params,
                                        &self->qmi_qcmap_msgr_notifier);
    if (qmi_error < 0)
    {
        LOG("qmi_client_notifier_init(qcmap_msgr) returned %d", qmi_error);
        return;
    }

    /* Check if the service is up, if not wait on a signal */
    while(1)
    {
        qmi_error = qmi_client_get_service_list(qcmap_msgr_qmi_idl_service_object,
                                                NULL,
                                                NULL,
                                                &num_services);
        LOG("qmi_client_get_service_list: %d",qmi_error);

        if(qmi_error == QMI_NO_ERR)
            break;
        /* wait for server to come up */
        QMI_CCI_OS_SIGNAL_WAIT(&self->qmi_qcmap_msgr_os_params, 0);
    }

    num_entries = num_services;

    LOG("qmi_client_get_service_list: num_e %d num_s %d", num_entries, num_services);
    /* The server has come up, store the information in info variable */
    qmi_error = qmi_client_get_service_list(qcmap_msgr_qmi_idl_service_object,
                                            info,
                                            &num_entries,
                                            &num_services);

    LOG("qmi_client_get_service_list: num_e %d num_s %d error %d", num_entries, num_services, qmi_error);

    if (qmi_error != QMI_NO_ERR)
    {
        qmi_client_release(self->qmi_qcmap_msgr_notifier);
        self->qmi_qcmap_msgr_notifier = NULL;
        LOG("Can not get qcmap_msgr service list %d",
            qmi_error);
        return;
    }

    qmi_error = qmi_client_init(&info[0],
                                qcmap_msgr_qmi_idl_service_object,
                                client_cb_ind,
                                NULL,
                                NULL,
                                &self->qmi_qcmap_msgr_handle);

    LOG("qmi_client_init: %d", qmi_error);

    if (qmi_error != QMI_NO_ERR)
    {
        qmi_client_release(self->qmi_qcmap_msgr_notifier);
        self->qmi_qcmap_msgr_notifier = NULL;
        LOG("Can not init qcmap_msgr client %d", qmi_error);
        return;
    }
}

对应释放过程比较简单,主要是释放client初始化信息:

static void qcmap_ppp_uninit(qcmap_ppp_t *self) {
    qmi_client_error_type qmi_error;
    assert(self);

    qmi_error = qmi_client_release(self->qmi_qcmap_msgr_notifier);
    self->qmi_qcmap_msgr_notifier = NULL;

    if (qmi_error != QMI_NO_ERR)
    {
        LOG("Can not release client qcmap notifier %d",qmi_error);
    }

    qmi_error = qmi_client_release(self->qmi_qcmap_msgr_handle);
    self->qmi_qcmap_msgr_handle = NULL;

    if (qmi_error != QMI_NO_ERR)
    {
        LOG("Can not release client qcmap handle %d",qmi_error);
    }
}

2.2 建立/关闭拨号连接

建立拨号步骤:使能AP,连接服务

  • 使能ap
/* Enable MobileAP */
static boolean qcmap_ppp_enable(qcmap_ppp_t *self) {
    qmi_client_error_type qmi_error, qmi_err_code = QMI_NO_ERR;
    qcmap_msgr_mobile_ap_enable_resp_msg_v01 qcmap_enable_resp_msg_v01;
    qcmap_msgr_mobile_ap_status_ind_register_req_msg_v01 qcmap_mobile_ap_status_ind_reg;
    qcmap_msgr_wwan_status_ind_register_req_msg_v01 wwan_status_ind_reg;
    qcmap_msgr_station_mode_status_ind_register_req_msg_v01 qcmap_station_mode_status_ind_reg;
    qcmap_msgr_mobile_ap_status_ind_register_resp_msg_v01 qcmap_mobile_ap_status_ind_rsp;
    qcmap_msgr_wwan_status_ind_register_resp_msg_v01 wwan_status_ind_rsp;
    qcmap_msgr_station_mode_status_ind_register_resp_msg_v01 qcmap_station_mode_status_ind_rsp;

    memset(&qcmap_enable_resp_msg_v01, 0, sizeof(qcmap_msgr_mobile_ap_enable_resp_msg_v01));
    memset(&wwan_status_ind_reg, 0, sizeof(qcmap_msgr_wwan_status_ind_register_req_msg_v01));
    memset(&wwan_status_ind_rsp, 0, sizeof(qcmap_msgr_wwan_status_ind_register_resp_msg_v01));
    wwan_status_ind_reg.register_indication = 1;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                            QMI_QCMAP_MSGR_WWAN_STATUS_IND_REG_REQ_V01,
                                            (void*)&wwan_status_ind_reg,
                                            sizeof(qcmap_msgr_wwan_status_ind_register_req_msg_v01),
                                            (void*)&wwan_status_ind_rsp,
                                            sizeof(qcmap_msgr_wwan_status_ind_register_resp_msg_v01),
                                            QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    LOG("qmi_client_send_msg_sync: error %d result %d",
                    qmi_error, wwan_status_ind_rsp.resp.result);

    if (( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( wwan_status_ind_rsp.resp.result != QMI_NO_ERR ))
    {
        LOG("Can not register for wwan status %d : %d",
                    qmi_error, wwan_status_ind_rsp.resp.error);
        return FALSE;
    }
    LOG("Registered for wwan status");

    memset(&qcmap_mobile_ap_status_ind_reg, 0, sizeof(qcmap_msgr_mobile_ap_status_ind_register_req_msg_v01));
    memset(&qcmap_mobile_ap_status_ind_rsp, 0, sizeof(qcmap_msgr_mobile_ap_status_ind_register_resp_msg_v01));
    qcmap_mobile_ap_status_ind_reg.register_indication = 1;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_MOBILE_AP_STATUS_IND_REG_REQ_V01,
                                        (void*)&qcmap_mobile_ap_status_ind_reg,
                                        sizeof(qcmap_msgr_mobile_ap_status_ind_register_req_msg_v01),
                                        (void*)&qcmap_mobile_ap_status_ind_rsp,
                                        sizeof(qcmap_msgr_mobile_ap_status_ind_register_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    LOG("qmi_client_send_msg_sync: error %d result %d",
                    qmi_error, qcmap_mobile_ap_status_ind_rsp.resp.result);
    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( qcmap_mobile_ap_status_ind_rsp.resp.result != QMI_NO_ERR ))
    {
        LOG("Can not register for mobile ap status %d : %d",
                    qmi_error, qcmap_mobile_ap_status_ind_rsp.resp.error);
        return FALSE;
    }
    LOG("Registered for mobile ap status");

    memset(&qcmap_station_mode_status_ind_reg, 0, sizeof(qcmap_msgr_station_mode_status_ind_register_req_msg_v01));
    memset(&qcmap_station_mode_status_ind_rsp, 0, sizeof(qcmap_msgr_station_mode_status_ind_register_resp_msg_v01));
    qcmap_station_mode_status_ind_reg.register_indication = 1;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                        QMI_QCMAP_MSGR_STATION_MODE_STATUS_IND_REG_REQ_V01,
                        (void*)&qcmap_station_mode_status_ind_reg,
                        sizeof(qcmap_msgr_station_mode_status_ind_register_req_msg_v01),
                        (void*)&qcmap_station_mode_status_ind_rsp,
                        sizeof(qcmap_msgr_station_mode_status_ind_register_resp_msg_v01),
                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    LOG("qmi_client_send_msg_sync: error %d result %d",
            qmi_error, qcmap_station_mode_status_ind_rsp.resp.result);
    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( qcmap_station_mode_status_ind_rsp.resp.result != QMI_NO_ERR ))
    {
        LOG("Can not register for station mode indications %d : %d",
                    qmi_error, qcmap_station_mode_status_ind_rsp.resp.error);
        return FALSE;
    }
    LOG("Registered for station mode status");

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_MOBILE_AP_ENABLE_REQ_V01,
                                        NULL,
                                        0,
                                        (void*)&qcmap_enable_resp_msg_v01,
                                        sizeof(qcmap_msgr_mobile_ap_enable_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);
    LOG("qmi_client_send_msg_sync: error %d result %d valid %d",
                    qmi_error, qcmap_enable_resp_msg_v01.resp.result, qcmap_enable_resp_msg_v01.mobile_ap_handle_valid);
    if (( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( qcmap_enable_resp_msg_v01.resp.result != QMI_NO_ERR) ||
        ( qcmap_enable_resp_msg_v01.mobile_ap_handle_valid != TRUE ))
    {
        LOG("Can not enable qcmap %d : %d",
            qmi_error, qcmap_enable_resp_msg_v01.resp.error);
        return FALSE;
    }

    if( qcmap_enable_resp_msg_v01.mobile_ap_handle > 0 )
    {
        self->mobile_ap_handle = qcmap_enable_resp_msg_v01.mobile_ap_handle;
        self->qcmap_msgr_enable = TRUE;
        LOG("QCMAP Enabled\n");
        return TRUE;
    }
    else
    {
        LOG("QCMAP Enable Failure\n");
    }

    return FALSE;
}
  • 去使能
/* Disable MobileAP */
static boolean qcmap_ppp_disable(qcmap_ppp_t *self) {
    qcmap_msgr_mobile_ap_disable_req_msg_v01 qcmap_disable_req_msg_v01;
    qcmap_msgr_mobile_ap_disable_resp_msg_v01 qcmap_disable_resp_msg_v01;
    qmi_client_error_type qmi_error = QMI_NO_ERR;

    

    if (!self->qcmap_msgr_enable)
    {
        /* QCMAP is not enabled */
        LOG("QCMAP not enabled\n");
        return FALSE;
    }

    qcmap_disable_req_msg_v01.mobile_ap_handle = self->mobile_ap_handle;
    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_MOBILE_AP_DISABLE_REQ_V01,
                                        &qcmap_disable_req_msg_v01,
                                        sizeof(qcmap_msgr_mobile_ap_disable_req_msg_v01),
                                        &qcmap_disable_resp_msg_v01,
                                        sizeof(qcmap_msgr_mobile_ap_disable_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( (qcmap_disable_resp_msg_v01.resp.error != QMI_ERR_NO_EFFECT_V01 &&
            qcmap_disable_resp_msg_v01.resp.error != QMI_ERR_NONE_V01)) ||
        ( qcmap_disable_resp_msg_v01.resp.result != QMI_NO_ERR ))
    {
        LOG( "Can not disable qcmap %d : %d",
            qmi_error, qcmap_disable_resp_msg_v01.resp.error);
        return FALSE;
    }

    /*.If backhaul is not connected, Mobileap will be disabled instantly. And since
        call back function is being called much before the response pending flag is set to TRUE,
        responses are not sent to the client.
        Hence, we set qcmap_disable_resp_msg_v01.resp.error to QMI_ERR_NO_EFFECT_V01
        So that the caller of this function sends a response back to the client. (Used for IoE 9x25)
        */
    if (qcmap_disable_resp_msg_v01.resp.error == QMI_ERR_NO_EFFECT_V01)
        LOG( "Already disable qcmap %d", qcmap_disable_resp_msg_v01.resp.error);

    self->mobile_ap_handle = 0;
    self->qcmap_msgr_enable = FALSE;
    return TRUE;
}
  • 连接服务
/* ConnectBackHaul */
static boolean qcmap_ppp_connect(qcmap_ppp_t *self) {
    int qcmap_msgr_errno;
    int ret = 0;
    qcmap_msgr_wwan_call_type_v01 call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01;

    qcmap_msgr_bring_up_wwan_req_msg_v01 qcmap_bring_up_wwan_req_msg;
    qcmap_msgr_bring_up_wwan_resp_msg_v01 qcmap_bring_up_wwan_resp_msg;
    qmi_client_error_type qmi_error;

    


    /* Bring up the data call. */
    LOG("Bring up wwan");
    qcmap_bring_up_wwan_req_msg.mobile_ap_handle = self->mobile_ap_handle;
    qcmap_bring_up_wwan_req_msg.call_type_valid = TRUE;

    qcmap_bring_up_wwan_req_msg.call_type = call_type;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_BRING_UP_WWAN_REQ_V01,
                                        &qcmap_bring_up_wwan_req_msg,
                                        sizeof(qcmap_msgr_bring_up_wwan_req_msg_v01),
                                        &qcmap_bring_up_wwan_resp_msg,
                                        sizeof(qcmap_msgr_bring_up_wwan_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( qcmap_bring_up_wwan_resp_msg.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not bring up wwan qcmap %d : %d",
        qmi_error, qcmap_bring_up_wwan_resp_msg.resp.error);
    return FALSE;
    }

    /*
    If WWAN is already enabled, and we are trying to enable again from a different client,
    set error number to QMI_ERR_NO_EFFECT_V01, so that the correspondingclient can be
    informed. We hit this scenario in the following case:
    1. Start QCMAP_CLI and enable Backhaul.
    2. Start MCM_MOBILEAP_CLI and try enabling backhaul again.
    */
    if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01 &&
        qcmap_bring_up_wwan_resp_msg.conn_status ==
        QCMAP_MSGR_WWAN_STATUS_CONNECTED_V01)
    {
    LOG("WWAN is already enabled.");
    }
    else if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V6_V01 &&
        qcmap_bring_up_wwan_resp_msg.conn_status ==
        QCMAP_MSGR_WWAN_STATUS_IPV6_CONNECTED_V01)
    {
    LOG("IPv6 WWAN is already enabled.");
    }
    else
    LOG("Bringing up wwan...");
    return TRUE;
}
  • 断开服务
/* DisconnectBackHual */
static boolean qcmap_ppp_disconnect(qcmap_ppp_t *self) {
    qcmap_msgr_wwan_call_type_v01 call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01;

    qcmap_msgr_tear_down_wwan_req_msg_v01 qcmap_tear_down_wwan_req_msg;
    qcmap_msgr_tear_down_wwan_resp_msg_v01 qcmap_tear_down_wwan_resp_msg;
    qmi_client_error_type qmi_error;
    

    LOG("Bringing down wwan");
    qcmap_tear_down_wwan_req_msg.mobile_ap_handle = self->mobile_ap_handle;

    qcmap_tear_down_wwan_req_msg.call_type_valid = TRUE;

    qcmap_tear_down_wwan_req_msg.call_type = call_type;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_TEAR_DOWN_WWAN_REQ_V01,
                                        &qcmap_tear_down_wwan_req_msg,
                                        sizeof(qcmap_msgr_tear_down_wwan_req_msg_v01),
                                        &qcmap_tear_down_wwan_resp_msg,
                                        sizeof(qcmap_msgr_tear_down_wwan_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR) ||
        ( qcmap_tear_down_wwan_resp_msg.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not tear down wwan qcmap %d : %d",
        qmi_error, qcmap_tear_down_wwan_resp_msg.resp.error);
    return FALSE;
    }

    /*
        If WWAN is already disabled, and we are trying to disable again from a different client,
        set error number to QMI_ERR_NO_EFFECT_V01, so that the correspondingclient can be
        informed. We hit this scenario in the following case:
        1. Start QCMAP_CLI and enable Backhaul.
        2. Start MCM_MOBILEAP_CLI and try enabling backhaul again.
        3. Disable backhaul from the 1st client.
        4. Now from the 2nd client.
    */
    if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01 &&
        qcmap_tear_down_wwan_resp_msg.conn_status ==
        QCMAP_MSGR_WWAN_STATUS_DISCONNECTED_V01)
    {
        LOG("WWAN is already disabled.");
    }
    else if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V6_V01 &&
        qcmap_tear_down_wwan_resp_msg.conn_status ==
        QCMAP_MSGR_WWAN_STATUS_IPV6_DISCONNECTED_V01)
    {
        LOG("IPv6 WWAN is already disabled.");
    }
    else
        LOG("Tearing down wwan...");
    return TRUE;
}

/* Get WWAN Statistics. */
static boolean qcmap_ppp_get_statistics(qcmap_ppp_t *self, qcmap_msgr_ip_family_enum_v01 ip_family, qcmap_msgr_wwan_statistics_type_v01 *wwan_stats) {
    qcmap_msgr_get_wwan_stats_req_msg_v01 get_wwan_stats_req_msg;
    qcmap_msgr_get_wwan_stats_resp_msg_v01 get_wwan_stats_resp_msg;
    qmi_client_error_type qmi_error;

    

    get_wwan_stats_req_msg.mobile_ap_handle = self->mobile_ap_handle;
    get_wwan_stats_req_msg.ip_family = ip_family;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_GET_WWAN_STATS_REQ_V01,
                                        &get_wwan_stats_req_msg,
                                        sizeof(qcmap_msgr_get_wwan_stats_req_msg_v01),
                                        &get_wwan_stats_resp_msg,
                                        sizeof(qcmap_msgr_get_wwan_stats_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( get_wwan_stats_resp_msg.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not get wwan stats %d : %d",
        qmi_error, get_wwan_stats_resp_msg.resp.error);
    return FALSE;
    }

    wwan_stats->bytes_rx = get_wwan_stats_resp_msg.wwan_stats.bytes_rx;
    wwan_stats->bytes_tx = get_wwan_stats_resp_msg.wwan_stats.bytes_tx;
    wwan_stats->pkts_rx = get_wwan_stats_resp_msg.wwan_stats.pkts_rx;
    wwan_stats->pkts_tx = get_wwan_stats_resp_msg.wwan_stats.pkts_tx;
    wwan_stats->pkts_dropped_rx = get_wwan_stats_resp_msg.wwan_stats.pkts_dropped_rx;
    wwan_stats->pkts_dropped_tx = get_wwan_stats_resp_msg.wwan_stats.pkts_dropped_tx;
    LOG("Get WWAN Stats succeeded...");
    return TRUE;
}

/* Reset WWAN Statistics. */
static boolean qcmap_ppp_reset_statistics(qcmap_ppp_t *self, qcmap_msgr_ip_family_enum_v01 ip_family) {
    qcmap_msgr_reset_wwan_stats_req_msg_v01 reset_wwan_stats_req_msg;
    qcmap_msgr_reset_wwan_stats_resp_msg_v01 reset_wwan_stats_resp_msg;
    qmi_client_error_type qmi_error;

    

    reset_wwan_stats_req_msg.mobile_ap_handle = self->mobile_ap_handle;
    reset_wwan_stats_req_msg.ip_family = ip_family;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_RESET_WWAN_STATS_REQ_V01,
                                        &reset_wwan_stats_req_msg,
                                        sizeof(qcmap_msgr_reset_wwan_stats_req_msg_v01),
                                        &reset_wwan_stats_resp_msg,
                                        sizeof(qcmap_msgr_reset_wwan_stats_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( reset_wwan_stats_resp_msg.resp.result != QMI_NO_ERR ) )
    {
        LOG("Can not reset wwan stats %d : %d",
            qmi_error, reset_wwan_stats_resp_msg.resp.error);
            return FALSE;
    }

    LOG("Reset WWAN Stats succeeded...");
    return TRUE;
}

/* Enable/Disable Autoconnect mode */
static boolean qcmap_ppp_set_auto_connect(qcmap_ppp_t *self, boolean enable) {
    qcmap_msgr_set_auto_connect_req_msg_v01 set_auto_connect_req_msg;
    qcmap_msgr_set_auto_connect_resp_msg_v01 set_auto_connect_resp_msg;
    qmi_client_error_type qmi_error;

    

    set_auto_connect_req_msg.mobile_ap_handle = self->mobile_ap_handle;
    set_auto_connect_req_msg.enable = enable;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_SET_AUTO_CONNECT_REQ_V01,
                                        &set_auto_connect_req_msg,
                                        sizeof(qcmap_msgr_set_auto_connect_req_msg_v01),
                                        &set_auto_connect_resp_msg,
                                        sizeof(qcmap_msgr_set_auto_connect_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);
    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( set_auto_connect_resp_msg.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not set auto connect flag %d : %d",
            qmi_error, set_auto_connect_resp_msg.resp.error);
        return FALSE;
    }

    LOG("Auto Connect Mode Set succeeded...");
    return TRUE;
}

至此,就可以完成拨号的连接和断开。

2.3 PPP状态

如果关注状态通知,需要处理知函数client_cb_ind中状态通知。主要包含了建立拨号成功/失败,网络状态变化(切换网络模式)的断开通知等。

static void qcmap_ppp_ind(
    qmi_client_type user_handle,
    unsigned int msg_id,
    void *ind_buf,
    unsigned int ind_buf_len,
    void *ind_cb_data )
{
    qmi_client_error_type qmi_error;
    LOG("qcmap_msgr_qmi_qcmap_ind: user_handle %X msg_id %d ind_buf_len %d.", user_handle, msg_id, ind_buf_len);
}

2.4 建立连接可选项

  • 禁用ipv6

static boolean qcmap_ppp_disable_ipv6(qcmap_ppp_t *self) {
    int qcmap_msgr_errno;
    int ret = 0;
    qcmap_msgr_disable_ipv6_req_msg_v01 qcmap_disable_ipv6_req_msg;
    qcmap_msgr_disable_ipv6_resp_msg_v01 qcmap_disable_ipv6_resp_msg;
    qmi_client_error_type qmi_error;

    /* Enable IPV6. */
    LOG("Disable IPV6");
    qcmap_disable_ipv6_req_msg.mobile_ap_handle = self->mobile_ap_handle;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_DISABLE_IPV6_REQ_V01,
                                        &qcmap_disable_ipv6_req_msg,
                                        sizeof(qcmap_msgr_disable_ipv6_req_msg_v01),
                                        &qcmap_disable_ipv6_resp_msg,
                                        sizeof(qcmap_msgr_disable_ipv6_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( qcmap_disable_ipv6_resp_msg.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not disable ipv6 %d : %d",
        qmi_error, qcmap_disable_ipv6_resp_msg.resp.error);
    return FALSE;
    }

    LOG("Disabled IPV6...");
    return TRUE;
}
  • 配置自动连接(没测试出效果)
/* Enable/Disable Autoconnect mode */
static boolean qcmap_ppp_set_auto_connect(qcmap_ppp_t *self, boolean enable) {
    qcmap_msgr_set_auto_connect_req_msg_v01 set_auto_connect_req_msg;
    qcmap_msgr_set_auto_connect_resp_msg_v01 set_auto_connect_resp_msg;
    qmi_client_error_type qmi_error;

    

    set_auto_connect_req_msg.mobile_ap_handle = self->mobile_ap_handle;
    set_auto_connect_req_msg.enable = enable;

    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_SET_AUTO_CONNECT_REQ_V01,
                                        &set_auto_connect_req_msg,
                                        sizeof(qcmap_msgr_set_auto_connect_req_msg_v01),
                                        &set_auto_connect_resp_msg,
                                        sizeof(qcmap_msgr_set_auto_connect_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);
    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( set_auto_connect_resp_msg.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not set auto connect flag %d : %d",
            qmi_error, set_auto_connect_resp_msg.resp.error);
        return FALSE;
    }

    LOG("Auto Connect Mode Set succeeded...");
    return TRUE;
}
  • 查询wwan统计信息(流量)
/* Get WWAN Status */
static boolean qcmap_ppp_get_status(qcmap_ppp_t *self, qcmap_msgr_wwan_status_enum_v01 *v4_status, qcmap_msgr_wwan_status_enum_v01 *v6_status) {
    qmi_client_error_type qmi_error, qmi_err_code = QMI_NO_ERR;
    qcmap_msgr_wwan_status_req_msg_v01 wan_status_req;
    qcmap_msgr_wwan_status_resp_msg_v01 wan_status_resp;
    

    memset(&wan_status_resp, 0, sizeof(qcmap_msgr_wwan_status_resp_msg_v01));
    wan_status_req.mobile_ap_handle = self->mobile_ap_handle;
    wan_status_req.call_type_valid = 1;
    wan_status_req.call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01;
    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_WWAN_STATUS_REQ_V01,
                                        &wan_status_req,
                                        sizeof(qcmap_msgr_wwan_status_req_msg_v01),
                                        (void*)&wan_status_resp,
                                        sizeof(qcmap_msgr_wwan_status_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    LOG("qmi_client_send_msg_sync(enable): error %d result %d",
        qmi_error, wan_status_resp.resp.result);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( wan_status_resp.resp.result != QMI_NO_ERR ) )
    {
    LOG("Can not get IPV4 WAN status  %d : %d",
        qmi_error, wan_status_resp.resp.error);
    return FALSE;
    }
    if(wan_status_resp.conn_status_valid ==1)
    {
    *v4_status=wan_status_resp.conn_status;
    if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_CONNECTING_V01)
    {
        LOG(" IPV4 WWAN is Connecting \n");
    }
    else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_CONNECTED_V01)
    {
        LOG(" IPV4 WWAN is connected \n");
    }
    else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_DISCONNECTING_V01)
    {
        LOG(" IPV4 WWAN is Disconnecting \n");
    }
    else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_DISCONNECTED_V01)
    {
        LOG(" IPV4 WWAN is Disconnected \n");
    }
    }

#ifdef ENABLE_IPV6
    memset(&wan_status_resp, 0, sizeof(qcmap_msgr_wwan_status_resp_msg_v01));
    wan_status_req.mobile_ap_handle = self->mobile_ap_handle;
    wan_status_req.call_type_valid = 1;
    wan_status_req.call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V6_V01;
    qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
                                        QMI_QCMAP_MSGR_WWAN_STATUS_REQ_V01,
                                        &wan_status_req,
                                        sizeof(qcmap_msgr_wwan_status_req_msg_v01),
                                        (void*)&wan_status_resp,
                                        sizeof(qcmap_msgr_wwan_status_resp_msg_v01),
                                        QCMAP_MSGR_QMI_TIMEOUT_VALUE);

    LOG("qmi_client_send_msg_sync(enable): error %d result %d",
        qmi_error, wan_status_resp.resp.result);

    if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
        ( qmi_error != QMI_NO_ERR ) ||
        ( wan_status_resp.resp.result != QMI_NO_ERR ) )
    {
        LOG("Can not get IPV6 WAN status %d : %d",
            qmi_error, wan_status_resp.resp.error);
        return FALSE;
    }
    if(wan_status_resp.conn_status_valid == 1)
    {
    *v6_status=wan_status_resp.conn_status;
    if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_CONNECTING_V01)
    {
        LOG(" IPV6 WWAN is Connecting \n");
    }
    else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_CONNECTED_V01)
    {
        LOG(" IPV6 WWAN is connected \n");
    }
    else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_DISCONNECTING_V01)
    {
        LOG(" IPV6 WWAN is Disconnecting \n");
    }
    else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_DISCONNECTED_V01)
    {
        LOG(" IPV6 WWAN is Disconnected \n");
    }
    }
#endif

    return TRUE;
}

 

你可能感兴趣的:(mdm9x07,ap)