From: Munkyu Im Date: Fri, 8 May 2015 13:27:28 +0000 (+0900) Subject: net: support getting host ip from check-net X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~461 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2c36ddf5425c19b81f516b5694a66ebbe3eef65;p=sdk%2Femulator%2Fqemu.git net: support getting host ip from check-net check-net support new command "--host-ip". can get host interface and ip macosx and ubuntu. change bridge name on ubuntu. Change-Id: I5985e04be02d5837cba56d0576124ec5981f4d0d Signed-off-by: Munkyu Im --- diff --git a/tizen/src/util/check_net.c b/tizen/src/util/check_net.c index 0ac369d1ce..8a784fbe5e 100644 --- a/tizen/src/util/check_net.c +++ b/tizen/src/util/check_net.c @@ -92,6 +92,7 @@ void main(int argc, char *argv[]) fprintf(stderr, " Usage: check-net --proxy\n"); fprintf(stderr, " check-net --interface-all\n"); fprintf(stderr, " check-net --bridge\n"); + fprintf(stderr, " check-net --host-ip\n"); exit(1); } if (strcmp(argv[1], ARG_PROXY) == 0) { @@ -100,5 +101,7 @@ void main(int argc, char *argv[]) get_host_interface_all_os(); } else if (strcmp(argv[1], ARG_BRIDGE) == 0) { get_host_bridge_os(); + } else if (strcmp(argv[1], ARG_HOST_IP) == 0) { + get_host_ip_os(); } } diff --git a/tizen/src/util/check_net.h b/tizen/src/util/check_net.h index dccbb625d8..e519408a6e 100644 --- a/tizen/src/util/check_net.h +++ b/tizen/src/util/check_net.h @@ -65,6 +65,7 @@ #define ARG_PROXY "--proxy" #define ARG_INTERFACE_ALL "--interface-all" #define ARG_BRIDGE "--bridge" +#define ARG_HOST_IP "--host-ip" #define PATH_IFCONFIG "/sbin/ifconfig" extern const char *pac_tempfile; @@ -76,6 +77,7 @@ void get_host_bridge_os(void); void download_url(char *); size_t write_data(void *, size_t, size_t, FILE *); void remove_string(char *, char *, const char *); +void get_host_ip_os(void); #endif diff --git a/tizen/src/util/check_net_darwin.c b/tizen/src/util/check_net_darwin.c index fd8a6b7f81..6384b5cee7 100644 --- a/tizen/src/util/check_net_darwin.c +++ b/tizen/src/util/check_net_darwin.c @@ -28,6 +28,10 @@ */ #include "check_net.h" +#include +#include +#include +#include #include static CFDictionaryRef proxySettings; @@ -212,3 +216,23 @@ void get_host_bridge_os(void) exit(1); } } + +void get_host_ip_os(void) +{ + struct ifaddrs *ifap, *ifa; + struct sockaddr_in *sa; + char *addr; + + getifaddrs(&ifap); + for (ifa = ifap; ifa; ifa = ifa->ifa_next) { + if (ifa->ifa_addr->sa_family == AF_INET) { + sa = (struct sockaddr_in *) ifa->ifa_addr; + addr = inet_ntoa(sa->sin_addr); + fprintf(stdout, "Interface:%s Address:%s\n", ifa->ifa_name, addr); + } + } + + freeifaddrs(ifap); + + exit(0); +} diff --git a/tizen/src/util/check_net_linux.c b/tizen/src/util/check_net_linux.c index 23f42df792..f0d8e41c03 100644 --- a/tizen/src/util/check_net_linux.c +++ b/tizen/src/util/check_net_linux.c @@ -29,6 +29,10 @@ #include "check_net.h" #include +#include +#include +#include +#include static int gproxytool = GSETTINGS; static const char* gproxycmds[][2] = { @@ -249,9 +253,29 @@ void get_host_interface_all_os(void) void get_host_bridge_os(void) { if (access(PATH_IFCONFIG, F_OK) != -1) { - system("/sbin/ifconfig br-tizen-vm-1"); + system("/sbin/ifconfig bridge1"); } else { fprintf(stderr, "ifconfig does not exist!\n"); exit(1); } } + +void get_host_ip_os(void) +{ + struct ifaddrs *ifap, *ifa; + struct sockaddr_in *sa; + char *addr; + + getifaddrs(&ifap); + for (ifa = ifap; ifa; ifa = ifa->ifa_next) { + if (ifa->ifa_addr->sa_family == AF_INET) { + sa = (struct sockaddr_in *) ifa->ifa_addr; + addr = inet_ntoa(sa->sin_addr); + fprintf(stdout, "Interface:%s Address:%s\n", ifa->ifa_name, addr); + } + } + + freeifaddrs(ifap); + + exit(0); +} diff --git a/tizen/src/util/check_net_win32.c b/tizen/src/util/check_net_win32.c index 8b16f96268..965383275b 100644 --- a/tizen/src/util/check_net_win32.c +++ b/tizen/src/util/check_net_win32.c @@ -351,3 +351,8 @@ void get_host_bridge_os(void) { get_host_interface(BRIDGE_ONLY); } + +void get_host_ip_os(void) +{ + fprintf(stderr, "not supported now\n"); +}