data_call:添加AF宏控制
Change-Id: Iccb89c80a95afbf47aa0dd8d6f875f7dc6c28a32
diff --git a/mbtk/ql_lib/src/ql_data_call.c b/mbtk/ql_lib/src/ql_data_call.c
index b08f228..218e14b 100755
--- a/mbtk/ql_lib/src/ql_data_call.c
+++ b/mbtk/ql_lib/src/ql_data_call.c
@@ -1,5 +1,6 @@
#include "ql/DSI_ConnectManager.h"
#include "mbtk_info_api.h"
+#include <fcntl.h>
extern mbtk_info_handle_t* ql_info_handle;
extern int ql_info_handle_num;
@@ -168,6 +169,85 @@
return 0;
}
+#ifdef MBTK_AF_SUPPORT
+int mbtk_route_config(int profile_idx)
+{
+ char buf[1024] = {0};
+ char dns[128] = {0};
+ int offset = 0;
+ int fd = -1;
+ mbtk_ipv4_info_t ipv4;
+ mbtk_ipv6_info_t ipv6;
+ sprintf(buf, "route add default dev ccinet%d", profile_idx -1);
+ system(buf);
+
+ int ret = mbtk_data_call_state_get(ql_info_handle, profile_idx, &ipv4, &ipv6);
+ if(ret != 0)
+ return -1;
+ else
+ {
+ memset(buf, 0x0, 1024);
+ memset(dns, 0x0, 128);
+ offset = sprintf(buf, "search lan\n");
+ if(ipv4.valid)
+ {
+ if(inet_ntop(AF_INET, &(ipv4.PrimaryDNS), dns, 32) == NULL) {
+ LOGD("PrimaryDNS error.");
+ } else {
+ LOGD("PrimaryDNS : %s", dns);
+ }
+ offset += sprintf(buf + offset, "nameserver %s\n", dns);
+ memset(dns, 0x0, 128);
+ if(inet_ntop(AF_INET, &(ipv4.SecondaryDNS), dns, 32) == NULL) {
+ LOGD("SecondaryDNS error.");
+ } else {
+ LOGD("SecondaryDNS : %s", dns);
+ }
+ offset += sprintf(buf + offset, "nameserver %s\n", dns);
+ }
+ if(ipv6.valid)
+ {
+ memset(dns, 0x0, 128);
+ if(ipv6_2_str(&(ipv6.PrimaryDNS), dns))
+ {
+ LOGD("PrimaryDNS error.");
+ } else {
+ LOGD("PrimaryDNS : %s", dns);
+ }
+ offset += sprintf(buf + offset, "nameserver %s\n", dns);
+ memset(dns, 0x0, 128);
+ if(ipv6_2_str(&(ipv6.SecondaryDNS), dns))
+ {
+ LOGD("SecondaryDNS error.");
+ } else {
+ LOGD("SecondaryDNS : %s", dns);
+ }
+ offset += sprintf(buf + offset, "nameserver %s\n", dns);
+ }
+
+ if(offset > 0)
+ {
+ fd = open("/tmp/resolv.conf", O_WRONLY | O_TRUNC);
+ if(fd < 0)
+ {
+ LOGD("mbtk_route_config : open fail.");
+ return -1;
+ }
+
+ ret = write(fd, buf, offset);
+ if(ret < 0)
+ {
+ LOGD("mbtk_route_config : write fail.");
+ }
+
+ close(fd);
+ }
+ }
+
+ return 0;
+}
+#endif
+
int ql_wan_start_ex(int profile_idx, int op, ex_conn_status_cb nw_cb)
{
int ret = -1;
@@ -237,6 +317,13 @@
{
//ql_apn_info[8].cid=profile_idx;
//ql_netw_status_cb(CONNECT_CONSUCCESS);
+#ifdef MBTK_AF_SUPPORT
+ if(profile_idx == 1)
+ {
+ mbtk_route_config(profile_idx);
+
+ }
+#endif
LOGD("mbtk_data_call_start() success.");
}
exit: