[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/c-ares/test_call.c b/ap/app/c-ares/test_call.c
new file mode 100644
index 0000000..93b5faa
--- /dev/null
+++ b/ap/app/c-ares/test_call.c
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <ares.h>
+#include <sys/time.h>
+#include <fcntl.h>
+int dns_with_cid(char *name, int cid, int family)
+{
+ struct hostent *host = NULL;
+ char *dev = malloc(10);
+ char num[3] = "";
+ char *ptr, **pptr;
+ char str[30];
+ memset(dev, 0, 10);
+ sc_cfg_get("pswan", dev, 10);
+ sprintf(num, "%d", cid);
+ strcat(dev, num);
+ printf("dev : %s\n", dev);
+ host = compat_gethostbyname3(name, dev, family);
+ if(host != NULL){
+ printf("host->h_name = %s\n", host->h_name);
+ if(host->h_aliases){
+ for(pptr = host->h_aliases; *pptr != NULL; pptr++)
+ printf("\talias:%s\n", *pptr);
+ }
+ else
+ printf("no aliase\n");
+ if(host->h_addrtype){
+ switch(host->h_addrtype){
+ case AF_INET:
+ pptr = host->h_addr_list;
+ for(; *pptr != NULL; pptr++)
+ printf("\t address: %s \n", inet_ntop(AF_INET, *pptr, str, sizeof(str)));
+ break;
+ }
+ }else {
+ printf("no h_addr_list\n");
+ }
+ free_hostent(host);
+ }
+ return 1;
+}
+int main(int argc, char **argv)
+{
+ char *dev = malloc(5);
+ char name[20] = "www.baidu.com";
+ dns_with_cid(name, 1, AF_INET);
+ return 0;
+ }