[Feature][ZXW-48]add liblynq-qser-data
Change-Id: I50c35ee9178c748fcf2254e5e1152b3c20b73473
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
index d8813bd..0b1ba0e 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
@@ -156,6 +156,7 @@
liblynq-qser-voice \
liblynq-qser-sim \
liblynq-qser-sms \
+ liblynq-qser-data \
"
zxic_lib += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'libbinder libril', 'libtelsvr', d)}"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-data/liblynq-qser-data.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-data/liblynq-qser-data.bb
new file mode 100644
index 0000000..bc83716
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-data/liblynq-qser-data.bb
@@ -0,0 +1,57 @@
+#inherit externalsrc package
+
+DESCRIPTION = "liblynq-qser-data"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "liblynq-log liblynq-data libxml2"
+#inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-data/"
+FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
+SRC_URI = " \
+ file://liblynq-qser-data\
+ "
+
+SRC-DIR = "${S}/../liblynq-qser-data"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+
+EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+FILES_${PN} = "${base_libdir}/*.so "
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+FILES_${PN} += "${bindir}/ /data"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+}
+
+do_install () {
+ oe_runmake install -C ${SRC-DIR} ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/
+ cp -af ${SRC-DIR}/include/ ${D}${includedir}/
+ fi
+ install -d ${D}/data/
+ cp -R ${WORKONSRC}/lynq_qser_data_apn.xml ${D}/data/
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/LICENSE b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/LICENSE
new file mode 100644
index 0000000..8aaabff
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("Mobiletek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to Mobiletek Inc. and/or its licensors. Without
+the prior written permission of Mobiletek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of Mobiletek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+Mobiletek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
\ No newline at end of file
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h
new file mode 100644
index 0000000..3485b72
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h
@@ -0,0 +1,268 @@
+#ifndef __LYNQ_QSER_DATA_H__
+#define __LYNQ_QSER_DATA_H__
+
+#include <stdbool.h>
+#include <netinet/in.h>
+
+typedef enum {
+ QSER_DATA_CALL_ERROR_NONE = 0,
+ QSER_DATA_CALL_ERROR_INVALID_PARAMS,
+} qser_data_call_error_e;
+
+typedef enum {
+ QSER_DATA_CALL_DISCONNECTED = 0, /*!< call is disconnected */
+ QSER_DATA_CALL_CONNECTED, /*!< call is connected */
+} qser_data_call_state_e;
+
+typedef enum {
+ QSER_DATA_CALL_TYPE_IPV4 = 0, /*!< IPv4 call. */
+ QSER_DATA_CALL_TYPE_IPV6, /*!< IPv6 call. */
+ QSER_DATA_CALL_TYPE_IPV4V6, /*!< IPv4 and IPv6 call (Only used call start or stop). */
+} qser_data_call_ip_family_e;
+
+typedef enum {
+ QSER_APN_PDP_TYPE_IPV4 = 0,
+ QSER_APN_PDP_TYPE_PPP,
+ QSER_APN_PDP_TYPE_IPV6,
+ QSER_APN_PDP_TYPE_IPV4V6,
+} qser_apn_pdp_type_e;
+
+typedef enum {
+ QSER_APN_AUTH_PROTO_DEFAULT = 0,
+ QSER_APN_AUTH_PROTO_NONE,
+ QSER_APN_AUTH_PROTO_PAP,
+ QSER_APN_AUTH_PROTO_CHAP,
+ QSER_APN_AUTH_PROTO_PAP_CHAP,
+} qser_apn_auth_proto_e;
+
+#define QSER_APN_MAX_LIST 8
+#define QSER_APN_NAME_SIZE 150
+#define QSER_APN_USERNAME_SIZE 127
+#define QSER_APN_PASSWORD_SIZE 127
+
+struct v4_address_status {
+ struct in_addr ip; /*!< Public IPv4 address. */
+ struct in_addr gateway; /*!< Public IPv4 gateway. */
+ struct in_addr pri_dns; /*!< Primary Domain Name Service IP address. */
+ struct in_addr sec_dns; /*!< Secondary Domain Name Service IP address. */
+};
+
+struct v6_address_status {
+ struct in6_addr ip; /*!< Public IPv6 address. */
+ struct in6_addr gateway; /*!< Public IPv6 gateway. */
+ struct in6_addr pri_dns; /*!< Primary Domain Name Service IPv6 address. */
+ struct in6_addr sec_dns; /*!< Secondary Domain Name Service IPv6 address. */
+};
+
+typedef struct {
+ char profile_idx; /*!< UMTS/CMDA profile ID. */
+ char name[16]; /*!< Interface Name. */
+ qser_data_call_ip_family_e ip_family; /*!< IP version. */
+ qser_data_call_state_e state; /*!< The dial status. */
+ qser_data_call_error_e err; /*!< The Reason code after data call disconnected. */
+ union {
+ struct v4_address_status v4; /*!< IPv4 information. */
+ struct v6_address_status v6; /*!< IPv6 information. */
+ };
+} qser_data_call_state_s;
+
+/*
+ *!< Client callback function used to post event indications.
+ */
+typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state);
+
+typedef struct {
+ char profile_idx; /*!< UMTS/CMDA profile ID. */
+ bool reconnect; /*!< Whether to re-dial after disconnecting the network. */
+ qser_data_call_ip_family_e ip_family; /*!< IP version. */
+ char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
+ char cdma_password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
+} qser_data_call_s;
+
+struct pkt_stats {
+ unsigned long pkts_tx; /*!< Number of packets transmitted. */
+ unsigned long pkts_rx; /*!< Number of packets received. */
+ long long bytes_tx; /*!< Number of bytes transmitted. */
+ long long bytes_rx; /*!< Number of bytes received. */
+ unsigned long pkts_dropped_tx; /*!< Number of transmit packets dropped. */
+ unsigned long pkts_dropped_rx; /*!< Number of receive packets dropped. */
+};
+
+struct v4_info {
+ char name[16]; /*!< Interface Name. */
+ qser_data_call_state_e state; /*!< The dial status. */
+ bool reconnect; /*!< re-dial flag. */
+ struct v4_address_status addr; /*!< IPv4 IP Address information. */
+ struct pkt_stats stats; /*!< IPv4 statics */
+};
+
+struct v6_info {
+ char name[16]; /*!< Interface Name. */
+ qser_data_call_state_e state; /*!< The dial status. */
+ bool reconnect; /*!< re-dial flag. */
+ struct v6_address_status addr; /*!< IPv6 IP Address information. */
+ struct pkt_stats stats; /*!< IPv6 statics */
+};
+
+typedef struct {
+ char profile_idx; /*!< UMTS/CDMA profile ID. */
+ qser_data_call_ip_family_e ip_family; /*!< IP version. */
+ struct v4_info v4; /*!< IPv4 information */
+ struct v6_info v6; /*!< IPv6 information */
+} qser_data_call_info_s;
+
+typedef struct {
+ unsigned char profile_idx; /*!< UMTS/CDMA profile ID. */
+ qser_apn_pdp_type_e pdp_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. */
+ qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
+ char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN
+ and external packet data network. */
+ char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
+ char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
+ char apn_type[QSER_APN_NAME_SIZE];
+} qser_apn_info_s;
+
+typedef struct {
+ qser_apn_pdp_type_e pdp_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. */
+ qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
+ char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN
+ and external packet data network. */
+ char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
+ char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
+ char apn_type[QSER_APN_NAME_SIZE];
+} qser_apn_add_s;
+
+typedef struct {
+ int cnt;
+ qser_apn_info_s apn[QSER_APN_MAX_LIST];
+} qser_apn_info_list_s;
+
+
+/**
+ * Initialization data call module, and callback function registered.
+ *
+ * @param [in] evt_cb callback fucntion
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_data_call_init(qser_data_call_evt_cb_t evt_cb);
+
+/**
+ * Destroy data call module, and unregister callback funciton
+ *
+ * @param
+ * None
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern void qser_data_call_destroy(void);
+
+/**
+ * Starts a data call. If profile index is zero, it will call CDMA profile.
+ *
+ * @param [in] data_call The data call parameters
+ * @param [out] error Error code returned by data call
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err);
+
+/**
+ * Stop a data call.
+ *
+ * @param [in] profile_idx UMTS/CDMA profile ID
+ * @param [in] ip_family IP Version
+ * @param [out] error Error code returned by data call
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err);
+
+/**
+ * Get a data call information.
+ *
+ * @param [in] profile_idx UMTS/CDMA profile ID
+ * @param [in] ip_family IP Version
+ * @param [out] info The Data Call information
+ * @param [out] error Error code returned by data call
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_data_call_info_get(char profile_idx,
+ qser_data_call_ip_family_e ip_family,
+ qser_data_call_info_s *info,
+ qser_data_call_error_e *err);
+
+/**
+ * Changes the settings in a configured profile.
+ *
+ * @param [in] apn the profile information.
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned, such apn not exist.
+ *
+ */
+extern int qser_apn_set(qser_apn_info_s *apn);
+
+/**
+ * Retrieves the settings from a configured profile.
+ *
+ * @param [in] profile_idx UMTS/CDMA profile ID
+ * @param [out] apn the profile information.
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn);
+
+/**
+ * Retrieves the settings from a configured profile.
+ *
+ * @param [in] apn the profile information.
+ * @param [out] profile_idx UMTS/CDMA profile ID
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx);
+
+/**
+ * Delete a configured profile.
+ *
+ * @param [in] profile_idx UMTS/CDMA profile ID
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_apn_del(unsigned char profile_idx);
+
+/**
+ * Retrieves the settings from a configured profile list.
+ *
+ * @param [out] apn_list the profile list information.
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_apn_get_list(qser_apn_info_list_s *apn_list);
+
+#endif
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
new file mode 100644
index 0000000..cfffa79
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -0,0 +1,836 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <log/log.h>
+#include <libdata/lynq_data.h>
+#include <liblog/lynq_deflog.h>
+#include <pthread.h>
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include "lynq-qser-data.h"
+
+#define USER_LOG_TAG "LYNQ_QSER_DATA"
+
+#define RESULT_OK (0)
+#define RESULT_ERROR (-1)
+
+static pthread_t s_cb_tid = -1;
+static int s_qser_data_cb_thread_status = 0;
+static pthread_mutex_t s_qser_data_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_qser_data_cb_cond = PTHREAD_COND_INITIALIZER;
+
+#define data_xml_path "/data/lynq_qser_data_apn.xml"
+
+static qser_data_call_evt_cb_t s_data_call_cb = NULL;
+const int apndb_offset = 683;
+
+void lynq_ipv4_aton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res)
+{
+ inet_aton(libdata->addresses,&(data_res->v4.ip));
+ inet_aton(libdata->gateways,&(data_res->v4.gateway));
+ inet_aton(libdata->dnses,&(data_res->v4.pri_dns));
+ inet_aton(libdata->dnses,&(data_res->v4.sec_dns));
+ return ;
+}
+
+void lynq_ipv6_inet_pton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res)
+{
+ inet_pton(AF_INET6,libdata->addresses,&(data_res->v6.ip));
+ inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway));
+ inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.pri_dns));
+ inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.sec_dns));
+ return ;
+}
+
+void lynq_ipv4_aton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res)
+{
+ inet_aton(libdata->addresses,&(data_res->v4.addr.ip));
+ inet_aton(libdata->gateways,&(data_res->v4.addr.gateway));
+ inet_aton(libdata->dnses,&(data_res->v4.addr.pri_dns));
+ inet_aton(libdata->dnses,&(data_res->v4.addr.sec_dns));
+ data_res->v4.stats.pkts_tx = 0;
+ data_res->v4.stats.pkts_rx = 0;
+ data_res->v4.stats.bytes_tx = 0;
+ data_res->v4.stats.bytes_rx = 0;
+ data_res->v4.stats.pkts_dropped_tx = 0;
+ data_res->v4.stats.pkts_dropped_rx = 0;
+ return ;
+}
+
+void lynq_ipv6_inet_pton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res)
+{
+ inet_pton(AF_INET6,libdata->addresses,&(data_res->v6.addr.ip));
+ inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway));
+ inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.addr.pri_dns));
+ inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.addr.sec_dns));
+ data_res->v6.stats.pkts_tx = 0;
+ data_res->v6.stats.pkts_rx = 0;
+ data_res->v6.stats.bytes_tx = 0;
+ data_res->v6.stats.bytes_rx = 0;
+ data_res->v6.stats.pkts_dropped_tx = 0;
+ data_res->v6.stats.pkts_dropped_rx = 0;
+ return ;
+}
+
+void datacall_ipv4_status_judge(int state,qser_data_call_info_s *data_res)
+{
+ if (state != 0)
+ {
+ data_res->v4.state = QSER_DATA_CALL_CONNECTED;
+ data_res->v4.reconnect = 1;
+ }
+ else
+ {
+ data_res->v4.state = QSER_DATA_CALL_DISCONNECTED;
+ data_res->v4.reconnect = 0;
+ }
+ return ;
+}
+
+void datacall_ipv6_status_judge(int state,qser_data_call_info_s *data_res)
+{
+ if (state != 0)
+ {
+ data_res->v6.state = QSER_DATA_CALL_CONNECTED;
+ data_res->v6.reconnect = 1;
+ }
+ else
+ {
+ data_res->v6.state = QSER_DATA_CALL_DISCONNECTED;
+ data_res->v6.reconnect = 0;
+ }
+ return ;
+}
+
+
+int apn_xml_add(qser_apn_add_s *apn,unsigned char *apn_num)
+{
+ int node_num = 0;
+ char temp_buff[12];
+ xmlDocPtr pdoc = NULL;
+ xmlNodePtr node = NULL;
+ xmlNodePtr tmp_node = NULL;
+ xmlNodePtr sum_node = NULL;
+ pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER);
+ if(NULL == pdoc)
+ {
+ LYERRLOG("open xml file error");
+ goto FAILED;
+ }
+
+ node = xmlDocGetRootElement(pdoc);
+ if (NULL == node)
+ {
+ LYERRLOG("xmlDocGetRootElement() error");
+ goto FAILED;
+ }
+ sum_node = node->xmlChildrenNode;
+ sum_node = sum_node->next;
+ while (sum_node != NULL)
+ {
+ if (xmlGetProp(sum_node, "profile_idx") == NULL) //Null Node
+ {
+ sum_node = sum_node->next;
+ continue;
+ }
+ node_num++;
+ sum_node = sum_node->next;
+ }
+ tmp_node = xmlNewNode(NULL,BAD_CAST"apn");
+ *apn_num = node_num;
+ LYERRLOG("apn_num%d ",node_num);
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",*apn_num);
+ xmlNewProp(tmp_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff);
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",apn->pdp_type);
+ xmlNewProp(tmp_node,BAD_CAST"pdp_type",(xmlChar *)temp_buff);
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",apn->auth_proto);
+ xmlNewProp(tmp_node,BAD_CAST"auth_proto",(xmlChar *)temp_buff);
+ xmlNewProp(tmp_node,BAD_CAST"apn_name",(xmlChar *)apn->apn_name);
+ xmlNewProp(tmp_node,BAD_CAST"username",(xmlChar *)apn->username);
+ xmlNewProp(tmp_node,BAD_CAST"password",(xmlChar *)apn->password);
+ xmlNewProp(tmp_node,BAD_CAST"apn_type",(xmlChar *)apn->apn_type);
+ xmlAddChild(node,tmp_node);
+ xmlSaveFormatFileEnc(data_xml_path, pdoc, "UTF-8", 1);
+ xmlFreeDoc(pdoc);
+ return RESULT_OK;
+
+ FAILED:
+ if (pdoc)
+ {
+ xmlFreeDoc(pdoc);
+ }
+ return RESULT_ERROR;
+}
+
+int apn_xml_delete(unsigned char profile_idx)
+{
+ int node_num = 0;
+ char temp_buff[12];
+ xmlDocPtr pdoc = NULL;
+ xmlNodePtr node = NULL;
+ xmlNodePtr modify_node = NULL;
+ pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER);
+ if(NULL == pdoc)
+ {
+ LYERRLOG("open xml file error");
+ goto FAILED;
+ }
+
+ node = xmlDocGetRootElement(pdoc);
+ if (NULL == node)
+ {
+ LYERRLOG("xmlDocGetRootElement() error");
+ goto FAILED;
+ }
+ modify_node = node->xmlChildrenNode;
+ modify_node = modify_node->next;
+ for (node_num=0 ;node_num<(int)profile_idx ; node_num++)
+ {
+ if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node
+ {
+ modify_node = modify_node->next;
+ node_num--;
+ continue;
+ }
+ modify_node = modify_node->next;
+ }
+ xmlUnlinkNode(modify_node);
+ xmlFreeNode(modify_node);
+ modify_node = NULL;
+ node_num = 0;
+ modify_node = node->xmlChildrenNode;
+ modify_node = modify_node->next;
+ while (modify_node != NULL)
+ {
+ if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node
+ {
+ modify_node = modify_node->next;
+ continue;
+ }
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",node_num);
+ xmlSetProp(modify_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff);
+ modify_node = modify_node->next;
+ node_num++;
+ }
+ xmlSaveFormatFileEnc(data_xml_path, pdoc, "UTF-8", 1);
+ xmlFreeDoc(pdoc);
+ return RESULT_OK;
+
+ FAILED:
+ if (pdoc)
+ {
+ xmlFreeDoc(pdoc);
+ }
+ return RESULT_ERROR;
+}
+
+int apn_xml_modify(qser_apn_info_s *apn)
+{
+ int node_num = 0;
+ char temp_buff[12];
+ xmlDocPtr pdoc = NULL;
+ xmlNodePtr node = NULL;
+ xmlNodePtr modify_node = NULL;
+ pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER);
+ if(NULL == pdoc)
+ {
+ LYERRLOG("open xml file error");
+ goto FAILED;
+ }
+
+ node = xmlDocGetRootElement(pdoc);
+ if (NULL == node)
+ {
+ LYERRLOG("xmlDocGetRootElement() error");
+ goto FAILED;
+ }
+ modify_node = node->xmlChildrenNode;
+ modify_node = modify_node->next;
+ for (node_num=0; node_num<(int)apn->profile_idx;node_num++)
+ {
+ if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node
+ {
+ modify_node = modify_node->next;
+ node_num--;
+ continue;
+ }
+ modify_node = modify_node->next;
+ }
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",node_num);
+ xmlSetProp(modify_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff);
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",apn->pdp_type);
+ xmlSetProp(modify_node,BAD_CAST"pdp_type",(xmlChar *)temp_buff);
+ bzero(temp_buff,12);
+ snprintf(temp_buff,sizeof(temp_buff),"%d",apn->auth_proto);
+ xmlSetProp(modify_node,BAD_CAST"auth_proto",(xmlChar *)temp_buff);
+ xmlSetProp(modify_node,BAD_CAST"apn_name",(xmlChar *)apn->apn_name);
+ xmlSetProp(modify_node,BAD_CAST"username",(xmlChar *)apn->username);
+ xmlSetProp(modify_node,BAD_CAST"password",(xmlChar *)apn->password);
+ xmlSetProp(modify_node,BAD_CAST"apn_type",(xmlChar *)apn->apn_type);
+ xmlSaveFormatFileEnc(data_xml_path, pdoc, "UTF-8", 1);
+ xmlFreeDoc(pdoc);
+ return RESULT_OK;
+
+ FAILED:
+ if (pdoc)
+ {
+ xmlFreeDoc(pdoc);
+ }
+ return RESULT_ERROR;
+}
+
+
+int apn_xml_query(unsigned char profile_idx,qser_apn_info_s *apn)
+{
+ int node_num = 0;
+ xmlDocPtr pdoc = NULL;
+ xmlNodePtr node = NULL;
+ xmlNodePtr modify_node = NULL;
+ unsigned char temp = NULL;
+ pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER);
+ if(NULL == pdoc)
+ {
+ LYERRLOG("open xml file error");
+ goto FAILED;
+ }
+
+ node = xmlDocGetRootElement(pdoc);
+ if (NULL == node)
+ {
+ LYERRLOG("xmlDocGetRootElement() error");
+ goto FAILED;
+ }
+ modify_node = node->xmlChildrenNode;
+ modify_node = modify_node->next;
+ for (node_num = 0;node_num<(int)profile_idx;node_num++)
+ {
+ if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node
+ {
+ modify_node = modify_node->next;
+ node_num--;
+ continue;
+ }
+ modify_node = modify_node->next;
+ }
+ apn->profile_idx = (unsigned char)atoi(xmlGetProp(modify_node, "profile_idx"));
+ apn->pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type"));
+ apn->auth_proto = (qser_apn_auth_proto_e)atoi(xmlGetProp(modify_node, "auth_proto"));
+ strcpy(apn->apn_name,(char *)xmlGetProp(modify_node, "apn_name"));
+ strcpy(apn->username,(char *)xmlGetProp(modify_node, "username"));
+ strcpy(apn->password,(char *)xmlGetProp(modify_node, "password"));
+ strcpy(apn->apn_type,(char *)xmlGetProp(modify_node, "apn_type"));
+ xmlSaveFormatFileEnc(data_xml_path, pdoc, "UTF-8", 1);
+ xmlFreeDoc(pdoc);
+ return RESULT_OK;
+
+ FAILED:
+ if (pdoc)
+ {
+ xmlFreeDoc(pdoc);
+ }
+ return RESULT_ERROR;
+}
+
+int apn_xml_query_list(qser_apn_info_list_s *apn_list)
+{
+ int node_num = 0;
+ xmlDocPtr pdoc = NULL;
+ xmlNodePtr node = NULL;
+ xmlNodePtr modify_node = NULL;
+ xmlChar *temp_char;
+ char temp[64];
+ pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER);
+ if(NULL == pdoc)
+ {
+ LYERRLOG("open xml file error");
+ goto FAILED;
+ }
+
+ node = xmlDocGetRootElement(pdoc);
+ if (NULL == node)
+ {
+ LYERRLOG("xmlDocGetRootElement() error");
+ goto FAILED;
+ }
+ modify_node = node->xmlChildrenNode;
+ modify_node = modify_node->next;
+ while (modify_node != NULL)
+ {
+ temp_char = xmlGetProp(modify_node, "profile_idx");
+ if (temp_char == NULL)
+ {
+ modify_node = modify_node->next;
+ continue;
+ }
+ sprintf(temp,"%s",temp_char);
+ apn_list->apn[node_num].profile_idx = (unsigned char)atoi(temp);
+ apn_list->apn[node_num].pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type"));
+ apn_list->apn[node_num].auth_proto = (qser_apn_auth_proto_e)atoi(xmlGetProp(modify_node, "auth_proto"));
+ strcpy(apn_list->apn[node_num].apn_name,(char *)xmlGetProp(modify_node, "apn_name"));
+ strcpy(apn_list->apn[node_num].username,(char *)xmlGetProp(modify_node, "username"));
+ strcpy(apn_list->apn[node_num].password,(char *)xmlGetProp(modify_node, "password"));
+ node_num ++;
+ modify_node = modify_node->next;
+ }
+ apn_list->cnt = node_num;
+ xmlSaveFormatFileEnc(data_xml_path, pdoc, "UTF-8", 1);
+ xmlFreeDoc(pdoc);
+ return RESULT_OK;
+
+ FAILED:
+ if (pdoc)
+ {
+ xmlFreeDoc(pdoc);
+ }
+ return RESULT_ERROR;
+}
+
+void judge_pdp_type(qser_apn_pdp_type_e pdp_type,char *out_pdp_type)
+{
+ switch (pdp_type)
+ {
+ case QSER_APN_PDP_TYPE_IPV4:
+ strcpy(out_pdp_type,"IPV4");
+ break;
+ case QSER_APN_PDP_TYPE_PPP:
+ strcpy(out_pdp_type,"PPP");
+ break;
+ case QSER_APN_PDP_TYPE_IPV6:
+ strcpy(out_pdp_type,"IPV6");
+ break;
+ case QSER_APN_PDP_TYPE_IPV4V6:
+ strcpy(out_pdp_type,"IPV4V6");
+ break;
+ default:
+ strcpy(out_pdp_type,"NULL");
+ break;
+ }
+ return;
+}
+void judge_authtype(qser_apn_auth_proto_e auth_proto,char *out_proto)
+{
+ switch (auth_proto)
+ {
+ case QSER_APN_AUTH_PROTO_DEFAULT:
+ strcpy(out_proto,"NULL;authType=0");
+ break;
+ case QSER_APN_AUTH_PROTO_NONE:
+ strcpy(out_proto,"NULL;authType=1");
+ break;
+ case QSER_APN_AUTH_PROTO_PAP:
+ strcpy(out_proto,"NULL;authType=2");
+ break;
+ case QSER_APN_AUTH_PROTO_CHAP:
+ strcpy(out_proto,"NULL;authtype=3");
+ break;
+ case QSER_APN_AUTH_PROTO_PAP_CHAP:
+ strcpy(out_proto,"NULL;authtype=4");
+ break;
+ default:
+ strcpy(out_proto,"NULL;authType=NULL");
+ break;
+ }
+ return ;
+}
+
+int data_call_handle_get(const char profile_idx,int *handle)
+{
+ int num = LYNQ_APN_CHANNEL_MAX;
+ int table_num = 0;
+ lynq_apn_info **apn_table = NULL;
+ qser_apn_info_s apn;
+ apn_table = (lynq_apn_info **)malloc(sizeof(lynq_apn_info *)*LYNQ_APN_CHANNEL_MAX);
+ if (NULL == apn_table)
+ {
+ LYERRLOG("malloc apn_table fail ");
+ return RESULT_ERROR;
+ }
+ for(int i =0;i<10;i++)
+ {
+ apn_table[i] = (lynq_apn_info*)malloc(sizeof(lynq_apn_info));
+ if (apn_table[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(apn_table[n]);
+ }
+ return RESULT_ERROR;
+ }
+ memset(apn_table[i],0,sizeof(lynq_apn_info));
+ }
+ lynq_get_apn_table(&table_num,apn_table);
+ memset(&apn,0,sizeof(qser_apn_info_s));
+ apn_xml_query(profile_idx,&apn);
+ for (int j = 0;j < table_num;j++)
+ {
+ if (strcmp(apn.apn_type,apn_table[j]->apnType) == 0)
+ {
+ *handle = apn_table[j]->index;
+ LYINFLOG("apn_table->index:%d,handle:%d ",apn_table[j]->index,*handle);
+ break;
+ }
+ }
+
+ for (int i = 0; i < LYNQ_APN_CHANNEL_MAX; i++)
+ {
+ if (apn_table[i]!=NULL)
+ {
+ free(apn_table[i]);
+ apn_table[i]=NULL;
+ }
+ }
+ free(apn_table);
+ apn_table=NULL;
+ LYINFLOG("data_call_handle_get end");
+ return RESULT_OK;
+}
+
+void *thread_wait_cb_status(void)
+{
+ int handle = -1;
+ lynq_data_call_response_v11_t data_urc_info;
+ qser_data_call_state_s data_cb_state;
+ while (s_qser_data_cb_thread_status)
+ {
+ lynq_wait_data_call_state_change(&handle);
+ lynq_get_data_call_list(&handle,&data_urc_info);
+ /*compare paramter*/
+ data_cb_state.profile_idx = (char)handle;
+
+ memcpy(data_cb_state.name,data_urc_info.ifname,strlen(data_urc_info.ifname)+1);
+ if (!strcmp(data_urc_info.type,"IPV4"))
+ {
+ data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4;
+ }
+ else if (!strcmp(data_urc_info.type,"IPV6"))
+ {
+ data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV6;
+ }
+ else if (strcmp(data_urc_info.type,"IPV4V6"))
+ {
+ data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4V6;
+ }
+ else
+ {
+ LYERRLOG("unknow data call type");
+ continue;
+ }
+
+ if (data_urc_info.status != 0)
+ {
+ data_cb_state.state = QSER_DATA_CALL_CONNECTED;
+ }
+ else
+ {
+ data_cb_state.state = QSER_DATA_CALL_DISCONNECTED;
+ }
+ if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4)
+ {
+ lynq_ipv4_aton_urc(&data_urc_info,&data_cb_state);
+ }
+ else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV6)
+ {
+ lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state);
+ }
+ else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4V6)
+ {
+ lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state);
+ }
+ else
+ {
+ LYERRLOG("unknow ip_family");
+ continue;
+ }
+ if (s_data_call_cb != NULL)
+ {
+ s_data_call_cb(&data_cb_state);
+ }
+ }
+ return NULL;
+}
+
+int qser_cb_pthread_create()
+{
+ int ret;
+ s_qser_data_cb_thread_status = 1;
+ ret = pthread_create(&s_cb_tid,NULL,thread_wait_cb_status,NULL);
+ if (ret < 0)
+ {
+ LYERRLOG("pthread create fail");
+ s_qser_data_cb_thread_status = 0;
+ return RESULT_ERROR;
+ }
+ return RESULT_OK;
+}
+
+void qser_cb_pthread_cancel()
+{
+ int ret;
+ s_qser_data_cb_thread_status = 0;
+ if (s_cb_tid != -1)
+ {
+ ret = pthread_cancel(s_cb_tid);
+ LYDBGLOG("pthread cancel ret = %d",ret);
+ ret = pthread_join(s_cb_tid,NULL);
+ LYDBGLOG("pthread join ret = %d",ret);
+ s_cb_tid = -1;
+ }
+ return;
+}
+
+int qser_data_call_init(qser_data_call_evt_cb_t evt_cb)
+{
+ int ret = 0;
+ int utoken = 0;
+ if (NULL == evt_cb)
+ {
+ LYERRLOG("init incoming paramters error");
+ return RESULT_ERROR;
+ }
+ s_data_call_cb = evt_cb;
+ qser_cb_pthread_create();
+ ret = lynq_init_data(utoken);
+ if (ret != RESULT_OK)
+ {
+ qser_cb_pthread_cancel();
+ s_data_call_cb = NULL;
+ return RESULT_ERROR;
+ }
+ return RESULT_OK;
+}
+
+void qser_data_call_destroy(void)
+{
+ qser_cb_pthread_cancel();
+ lynq_deinit_data();
+ s_data_call_cb = NULL;
+ return ;
+}
+
+int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err)
+{
+ int ret = -1;
+ int handle = 0;
+ if (NULL == data_call || NULL == err)
+ {
+ LYERRLOG("call start incoming paramters error");
+ return ret;
+ }
+ if (data_call->profile_idx == 0)
+ {
+ ret = lynq_setup_data_call(&handle);
+ }
+ else
+ {
+ char pdptype[16];
+ qser_apn_info_s apn_info;
+ qser_apn_get(data_call->profile_idx,&apn_info);
+ judge_pdp_type(apn_info.pdp_type,pdptype);
+ ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype);
+ }
+ if (ret < 0)
+ {
+ *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS;
+ }
+ return ret;
+}
+
+int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err)
+{
+ int ret = 0;
+ int handle = -1;
+
+ if (NULL == err)
+ {
+ LYERRLOG("call stop incoming paramters error");
+ return ret;
+ }
+ data_call_handle_get(profile_idx,&handle);
+ ret = lynq_deactive_data_call(&handle);
+ if (ret < 0)
+ {
+ *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS;
+ }
+ return RESULT_OK;
+}
+int qser_data_call_info_get(char profile_idx,qser_data_call_ip_family_e ip_family,qser_data_call_info_s *info,qser_data_call_error_e *err)
+{
+ int ret = 0;
+ int handle = -1;
+ lynq_data_call_response_v11_t data_call_info;
+ data_call_handle_get(profile_idx,&handle);
+ ret = lynq_get_data_call_list(&handle,&data_call_info);
+ if (ret == 0)
+ {
+ info->profile_idx = profile_idx;
+ info->ip_family = ip_family;
+ if (strcmp(data_call_info.type,"IPV4"))
+ {
+ strcpy(info->v4.name,data_call_info.ifname);
+ datacall_ipv4_status_judge(data_call_info.status,info);
+ LYINFLOG("[IPV4]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses);
+ lynq_ipv4_aton_getinfo(&data_call_info,info);
+ }
+ else if (strcmp(data_call_info.type,"IPV6"))
+ {
+ strcpy(info->v6.name,data_call_info.ifname);
+
+ datacall_ipv6_status_judge(data_call_info.status,info);
+ LYINFLOG("[IPV6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses);
+ lynq_ipv6_inet_pton_getinfo(&data_call_info,info);
+ }
+ else if (strcmp(data_call_info.type,"IPV4V6"))
+ {
+ strcpy(info->v4.name,data_call_info.ifname);
+ datacall_ipv4_status_judge(data_call_info.status,info);
+ LYINFLOG("[IPV4V6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses);
+ lynq_ipv4_aton_getinfo(&data_call_info,info);
+ strcpy(info->v6.name,data_call_info.ifname);
+ datacall_ipv6_status_judge(data_call_info.status,info);
+ LYINFLOG("[IPV4V6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses);
+ lynq_ipv6_inet_pton_getinfo(&data_call_info,info);
+ }
+ else
+ {
+ LYERRLOG("useless qser_data_call_ip_family_e");
+ }
+ }
+ return ret;
+}
+int qser_apn_set(qser_apn_info_s *apn)
+{
+ int ret = 0;
+ if (NULL == apn)
+ {
+ LYERRLOG("apn set incoming paramters error");
+ return RESULT_ERROR;
+ }
+ ret = apn_xml_modify(apn);
+ if (ret < 0)
+ {
+ LYERRLOG("apn_xml_modify error");
+ return ret;
+ }
+ int apn_id = 0;
+ char tmp_id[12];
+ char *outinfo = NULL;
+ char normalprotocol[16];
+ char authtype[32];
+ outinfo = (char *)malloc(sizeof(char)*512);
+ bzero(tmp_id,12);
+ bzero(outinfo,512);
+ apn_id = apn->profile_idx + apndb_offset;
+ snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id);
+ judge_pdp_type(apn->pdp_type,normalprotocol);
+ judge_authtype(apn->auth_proto,authtype);
+ lynq_modify_apn_db(3,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo);
+ LYINFLOG("[output]:%s",outinfo);
+ free(outinfo);
+ outinfo = NULL;
+ return RESULT_OK;
+}
+
+int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn)
+{
+ if (profile_idx < 0 || profile_idx > 24 || NULL == apn)
+ {
+ LYERRLOG("apn get incoming paramters error");
+ return RESULT_ERROR;
+ }
+ int ret = 0;
+ ret = apn_xml_query(profile_idx,apn);
+ if (ret < 0)
+ {
+ LYERRLOG("apn_xml_query error");
+ return ret;
+ }
+ return ret;
+}
+
+int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx)
+{
+ int ret = 0;
+ if (NULL == apn || NULL == profile_idx)
+ {
+ LYERRLOG("apn add incoming paramters error");
+ return RESULT_ERROR;
+ }
+ ret = apn_xml_add(apn,profile_idx);
+ if (ret < 0)
+ {
+ LYERRLOG("apn_xml_add error");
+ return ret;
+ }
+ int apn_id = 0;
+ char tmp_id[12];
+ char *outinfo = NULL;
+ char normalprotocol[16];
+ char authtype[32];
+ outinfo = (char *)malloc(sizeof(char)*512);
+ bzero(tmp_id,12);
+ bzero(outinfo,512);
+ snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id);
+ judge_pdp_type(apn->pdp_type,normalprotocol);
+ judge_authtype(apn->auth_proto,authtype);
+ lynq_modify_apn_db(0,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo);
+ LYINFLOG("[output]:%s",outinfo);
+ free(outinfo);
+ outinfo = NULL;
+ return RESULT_OK;
+}
+
+int qser_apn_del(unsigned char profile_idx)
+{
+ if (profile_idx < 0 || profile_idx > 24)
+ {
+ LYERRLOG("apn del incoming paramters error");
+ return RESULT_OK;
+ }
+ int ret = 0;
+ ret = apn_xml_delete(profile_idx);
+ if (ret < 0)
+ {
+ LYERRLOG("apn_xml_delete error");
+ return ret;
+ }
+ int apn_id = 0;
+ char tmp_id[12];
+ char *outinfo = NULL;
+ outinfo = (char *)malloc(sizeof(char)*512);
+ bzero(tmp_id,12);
+ bzero(outinfo,512);
+ apn_id = profile_idx+apndb_offset;
+ snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id);
+ lynq_modify_apn_db(1,tmp_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,outinfo);
+ LYINFLOG("[output]:%s",outinfo);
+ free(outinfo);
+ outinfo = NULL;
+ return ret;
+}
+
+int qser_apn_get_list(qser_apn_info_list_s *apn_list)
+{
+ if (NULL == apn_list)
+ {
+ LYERRLOG("apn_list incoming paramters error");
+ return RESULT_ERROR;
+ }
+ int ret = 0;
+ ret = apn_xml_query_list(apn_list);
+ if (ret < 0)
+ {
+ LYERRLOG("apn_xml_query_list error");
+ return ret;
+ }
+ return ret;
+}
\ No newline at end of file
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq_qser_data_apn.xml b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq_qser_data_apn.xml
new file mode 100644
index 0000000..590d493
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq_qser_data_apn.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lynq_qser_data_apn>
+ <apn profile_idx="0" pdp_type="3" auth_proto="0" apn_name="default" username="NULL" password="NULL" apn_type="default"/></lynq_qser_data_apn>
\ No newline at end of file
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/makefile
new file mode 100644
index 0000000..c3bfba0
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/makefile
@@ -0,0 +1,69 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -std=gnu++14 \
+ -g -Os \
+ -flto \
+ -fPIC \
+ -fpermissive \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+$(warning ################# lynq qser sms demo ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH)/include/ \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/libdata \
+ -I$(ROOT)$(includedir)/libxml2 \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -lstdc++ \
+ -lcutils \
+ -lutils \
+ -lpthread \
+ -llynq-log \
+ -llynq-data \
+ -lxml2 \
+
+
+SOURCES = $(wildcard *.cpp)
+
+EXECUTABLE = liblynq-qser-data.so
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+
+.PHONY: build clean install pack_rootfs
+all: build
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build: $(EXECUTABLE)
+ $(warning ########## build $(EXECUTABLE) ##########)
+install:
+ mkdir -p $(ROOT)$(base_libdir)/
+ install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+ mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+pack_rootfs:
+ mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+ cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+ $(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+ mkdir -p $(PACK_TO)$(base_libdir)/
+ cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+ $(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
+ -find . -name "*.o" -delete