data_call:添加AF宏控制

Change-Id: Iccb89c80a95afbf47aa0dd8d6f875f7dc6c28a32
diff --git a/mbtk/mbtk_ril/src/main.c b/mbtk/mbtk_ril/src/main.c
index 3f036e8..abb575e 100755
--- a/mbtk/mbtk_ril/src/main.c
+++ b/mbtk/mbtk_ril/src/main.c
@@ -320,8 +320,13 @@
                 urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

             } else if(strStartsWith(s, "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>

                 //apn_state_set(atoi(s + 19), true);

+#ifdef MBTK_AF_SUPPORT

+				//data[0] = (uint8)1;

+                //data[1] = (uint8)atoi(s + 19);

+#else

                 data[0] = (uint8)1;

                 data[1] = (uint8)atoi(s + 19);

+#endif

             } else if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>

                 //apn_state_set(atoi(s + 19), true);

                 data[0] = (uint8)0;

diff --git a/mbtk/mbtk_ril/src/mbtk_info_server.c b/mbtk/mbtk_ril/src/mbtk_info_server.c
index 341c9c9..4073f5f 100755
--- a/mbtk/mbtk_ril/src/mbtk_info_server.c
+++ b/mbtk/mbtk_ril/src/mbtk_info_server.c
@@ -2753,6 +2753,10 @@
 
 
 */
+#ifdef MBTK_AF_SUPPORT
+mbtk_ip_type_enum default_iptype = MBTK_IP_TYPE_IPV4V6;
+#endif
+
 static int req_apn_get(void *data, int *data_len, int *cme_err)
 {
     ATResponse *response = NULL;
@@ -2813,6 +2817,12 @@
                 apn.ip_type = MBTK_IP_TYPE_PPP;
             }
 
+#ifdef MBTK_AF_SUPPORT
+            if(apn.cid == 1)
+            {
+                default_iptype = apn.ip_type;
+            }
+#endif
             err = at_tok_nextstr(&line, &tmp_str); // apn
             if (err < 0)
             {
@@ -4686,6 +4696,12 @@
                     else
                     {
                         // Save apn.
+#ifdef MBTK_AF_SUPPORT
+                        if(apn.cid == 1)
+                        {
+                            default_iptype = apn.ip_type;
+                        }
+#endif
                         apn_prop_set(&apn);
 
                         pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_APN_RSP, NULL, 0);
@@ -4786,6 +4802,28 @@
                                 else
                                 {
                                     // Config IPv4 address.
+#ifdef MBTK_AF_SUPPORT
+                                    if(cid == 1)
+                                    {
+                                        //uint8 pdp_data = cid;
+                                        //pack_rsp_send(cli_info->fd , MBTK_INFO_ID_IND_PDP_STATE_CHANGE, &pdp_data, sizeof(uint8));
+                                        ipv4.valid = false;
+                                        ipv6.valid = false;
+                                        if(default_iptype == MBTK_IP_TYPE_IP)
+                                        {
+                                            ipv4.valid = true;
+                                        }
+                                        else if(default_iptype == MBTK_IP_TYPE_IPV6)
+                                        {
+                                            ipv6.valid = true;
+                                        }
+                                        else
+                                        {
+                                            ipv4.valid = true;
+                                            ipv6.valid = true;
+                                        }
+                                    }
+#endif
 #if 1
                                     if(ipv4.valid) {
                                         char dev[20] = {0};
@@ -4883,7 +4921,26 @@
 
                             int timeout = pack->data[2];
                             //mbtk wyq for data_call_ex add end
-                            
+#ifdef MBTK_AF_SUPPORT
+                            if(cid == 1)
+                            {
+                                char dev[20] = {0};
+                                uint8 pdp_data = cid + 100;
+                                pack_rsp_send(cli_info->fd , MBTK_INFO_ID_IND_PDP_STATE_CHANGE, &pdp_data, sizeof(uint8));
+                                
+                                sprintf(dev, "ccinet%d", cid - 1);
+
+                                // Config network.
+                                if(mbtk_ifc_configure2(dev, NULL, 0, NULL, NULL)) {
+                                    LOGD("Config %s IPv4 0 fail.", dev);
+                                } else {
+                                    LOGD("Config %s IPv4 0 success.", dev);
+                                }
+                                cid_active[cid] = 0;
+                                pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_DATA_CALL_RSP, NULL, 0);
+                                break;
+                            }
+#endif
                             cgact_wait.waitting = true;
                             cgact_wait.cid = cid;
                             cgact_wait.act = false;
@@ -4926,6 +4983,11 @@
                             break;
                         }
                         case MBTK_DATA_CALL_STATE: {
+                            if(cid_active[cid] == 0)
+                            {
+                                err = MBTK_INFO_ERR_CID_NO_EXIST;
+                                break;
+                            }
                             mbtk_ipv4_info_t ipv4;
                             mbtk_ipv6_info_t ipv6;
                             memset(&ipv4, 0, sizeof(mbtk_ipv4_info_t));
@@ -4943,6 +5005,26 @@
                             {
                                 uint8 buff[SOCK_MSG_LEN_MAX] = {0};
                                 int buff_len = 0;
+#ifdef MBTK_AF_SUPPORT
+                                if(cid == 1)
+                                {
+                                    ipv4.valid = false;
+                                    ipv6.valid = false;
+                                    if(default_iptype == MBTK_IP_TYPE_IP)
+                                    {
+                                        ipv4.valid = true;
+                                    }
+                                    else if(default_iptype == MBTK_IP_TYPE_IPV6)
+                                    {
+                                        ipv6.valid = true;
+                                    }
+                                    else
+                                    {
+                                        ipv4.valid = true;
+                                        ipv6.valid = true;
+                                    }
+                                }
+#endif
                                 if(ipv4.valid && ipv6.valid) {
                                     buff[0] = (uint8)2;
                                     buff_len++;
@@ -5674,6 +5756,26 @@
         int cme_err = MBTK_INFO_ERR_CME_NON;
         if(!req_data_call_state_get(cid, &ipv4, &ipv6, &cme_err) && cme_err == MBTK_INFO_ERR_CME_NON)
         {
+#ifdef MBTK_AF_SUPPORT
+            if(cid == 1)
+            {
+                ipv4.valid = false;
+                ipv6.valid = false;
+                if(default_iptype == MBTK_IP_TYPE_IP)
+                {
+                    ipv4.valid = true;
+                }
+                else if(default_iptype == MBTK_IP_TYPE_IPV6)
+                {
+                    ipv6.valid = true;
+                }
+                else
+                {
+                    ipv4.valid = true;
+                    ipv6.valid = true;
+                }
+            }
+#endif
             // Config IPv4 address.
             if(ipv4.valid) {
                 char ip[20] = {0};