Merge "[Bugfix][T106BUG-397]Fix apn_type can be set to repeated values"
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
index 56d47db..395cf95 100755
--- 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
@@ -769,6 +769,7 @@
     //xmlDocPtr apn_table_xml_pdoc = NULL;
     xmlNodePtr node = NULL;
     xmlNodePtr modify_node = NULL;
+    xmlNodePtr check_node = NULL;
 //    apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER);
     if(NULL == apn_table_xml_pdoc)
     {
@@ -792,6 +793,23 @@
         LYERRLOG("modify_node is null\n");
         goto FAILED;
     }
+    //check apn_type
+    check_node = modify_node;
+    while (check_node != NULL)
+    {
+        if (xmlGetProp(check_node, "profile_idx") == NULL)  //Null Node
+        {
+            check_node = check_node->next;
+            continue;
+        }
+        else if(strcmp((char *)xmlGetProp(check_node, "apn_type"), apn->apn_type) == 0)
+        {
+            LYERRLOG("apntype already exists\n");
+            goto FAILED;
+        }
+        check_node = check_node->next;
+    }
+    //check apn_type end
     for (node_num=0; node_num<(int)apn->profile_idx;node_num++)
     {
         if(modify_node == NULL)
@@ -1464,7 +1482,7 @@
     {
         return LYNQ_E_NO_INIT;
     }
-    if (NULL == apn)
+    if (NULL == apn || apn->profile_idx == 0)
     {
         LYERRLOG("apn set incoming paramters error");
         return RESULT_ERROR;
@@ -1571,10 +1589,10 @@
     {
         return LYNQ_E_NO_INIT;
     }
-    if (profile_idx < 0 || profile_idx > 24)
+    if (profile_idx <= 0 || profile_idx > QSER_APN_MAX_LIST)
     {
         LYERRLOG("apn del incoming paramters error");
-        return RESULT_OK;
+        return RESULT_ERROR;
     }
     int ret = 0;
     int handle = -1;