network: Using default DNS provided by QEMU
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 21 Jan 2013 13:43:52 +0000 (22:43 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 21 Jan 2013 13:43:52 +0000 (22:43 +0900)
Name server lookup runs well on Ubuntu 12.10

Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emulator.c
tizen/src/option.c
tizen/src/option.h

index e67b69f..ca5b881 100644 (file)
@@ -669,12 +669,13 @@ static void prepare_basic_features(void)
 {
     char http_proxy[MIDBUF] ={0}, https_proxy[MIDBUF] = {0,},
         ftp_proxy[MIDBUF] = {0,}, socks_proxy[MIDBUF] = {0,},
-        dns1[MIDBUF] = {0}, dns2[MIDBUF] = {0};
+        dns[MIDBUF] = {0};
 
     tizen_base_port = get_sdb_base_port();
 
     gethostproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
-    gethostDNS(dns1, dns2);   
+    // using "DNS" provided by default QEMU
+    g_strlcpy(dns, DEFAULT_QEMU_DNS_IP, strlen(DEFAULT_QEMU_DNS_IP) + 1);
 
     check_shdmem();
     socket_init();
@@ -686,7 +687,7 @@ static void prepare_basic_features(void)
             " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s"
             " dns1=%s", tizen_base_port,
             http_proxy, https_proxy, ftp_proxy, socks_proxy,
-            dns1, dns2);
+            dns);
 
     g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
 
index 50979e0..c215b0b 100644 (file)
@@ -72,91 +72,6 @@ BYTE *url;
 #endif
 const char *pactempfile = ".autoproxy"; 
 
-/**
-  @brief    get host DNS server address
-  @param    dns1: return value (first dns server address)
-  @param    dns2: return value (second dns server address)
-  @return always 0
- */
-int gethostDNS(char *dns1, char *dns2)
-{
-#ifndef _WIN32
-    FILE *resolv;
-    char buf[255];
-    memset(buf, 0, sizeof(char)*255);
-
-    resolv = fopen("/etc/resolv.conf", "r");
-    if (resolv <= 0) {
-        ERR( "Can't open \"/etc/resolv.conf.\"\n");
-        fclose(resolv);
-        return 1;
-    }
-
-    while(fscanf(resolv , "%s", buf) != EOF) {
-        if(strcmp(buf, "nameserver") == 0)
-        {
-            if(fscanf(resolv , "%s", dns1) <= 0) {
-                // do nothing...
-            }
-            break;
-        }
-    }
-
-    while(fscanf(resolv , "%s", buf) != EOF) {
-        if(strcmp(buf, "nameserver") == 0)
-        {
-            if(fscanf(resolv , "%s", dns2) <= 0) {
-                // do nothing...
-            }
-            break;
-        }
-    }
-
-    fclose(resolv);
-#else
-    PIP_ADAPTER_ADDRESSES pAdapterAddr;
-    PIP_ADAPTER_ADDRESSES pAddr;
-    PIP_ADAPTER_DNS_SERVER_ADDRESS pDnsAddr;
-    unsigned long nBufferLength = sizeof(IP_ADAPTER_ADDRESSES);
-    pAdapterAddr = (PIP_ADAPTER_ADDRESSES)malloc(nBufferLength);
-    memset(pAdapterAddr, 0x00, nBufferLength);
-
-    while (GetAdaptersAddresses(AF_INET, 0, NULL, pAdapterAddr, &nBufferLength)
-            == ERROR_BUFFER_OVERFLOW) {
-        free(pAdapterAddr);
-        pAdapterAddr = (PIP_ADAPTER_ADDRESSES)malloc(nBufferLength);
-        memset(pAdapterAddr, 0x00, nBufferLength);
-    }
-
-    pAddr = pAdapterAddr;
-    for (; pAddr != NULL; pAddr = pAddr->Next) {
-        pDnsAddr = pAddr->FirstDnsServerAddress;
-        for (; pDnsAddr != NULL; pDnsAddr = pDnsAddr->Next) {
-            struct sockaddr_in *pSockAddr = (struct sockaddr_in*)pDnsAddr->Address.lpSockaddr;
-            if(*dns1 == 0) {
-                strcpy(dns1, inet_ntoa(pSockAddr->sin_addr));
-                continue;
-            }
-            if(*dns2 == 0) {
-                strcpy(dns2, inet_ntoa(pSockAddr->sin_addr));
-                continue;
-            }
-        }
-    }
-    free(pAdapterAddr);
-#endif
-
-    // by caramis... change DNS address if localhost has DNS server or DNS cache.
-    if(!strncmp(dns1, "127.0.0.1", 9) || !strncmp(dns1, "localhost", 9)) {
-        strncpy(dns1, "10.0.2.2", 9);
-    }
-    if(!strncmp(dns2, "127.0.0.1", 9) || !strncmp(dns2, "localhost", 9)) {
-        strncpy(dns2, "10.0.2.2", 9);
-    }
-
-    return 0;
-}
-
 #if defined (CONFIG_DARWIN)
 static char *cfstring_to_cstring(CFStringRef str) {
     if (str == NULL) {
index 44b26a7..09442a1 100644 (file)
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-int gethostDNS(char *dns1, char *dns2);
 int gethostproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy);
 #endif