diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | tizen/src/Makefile | 42 | ||||
-rw-r--r-- | tizen/src/util/check_net.c (renamed from tizen/src/util/check_proxy.c) | 18 | ||||
-rw-r--r-- | tizen/src/util/check_net.h (renamed from tizen/src/util/check_proxy.h) | 13 | ||||
-rw-r--r-- | tizen/src/util/check_net_darwin.c (renamed from tizen/src/util/check_proxy_darwin.c) | 23 | ||||
-rw-r--r-- | tizen/src/util/check_net_linux.c (renamed from tizen/src/util/check_proxy_linux.c) | 25 | ||||
-rw-r--r-- | tizen/src/util/check_net_win32.c (renamed from tizen/src/util/check_proxy_win32.c) | 154 |
7 files changed, 243 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore index 3aa96496cc..436802733c 100644 --- a/.gitignore +++ b/.gitignore @@ -129,5 +129,5 @@ check-cam check-cam.exe check-gl check-gl.exe -check-proxy -check-proxy.exe +check-net +check-net.exe diff --git a/tizen/src/Makefile b/tizen/src/Makefile index 97058f1c8e..675ff44ac1 100644 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -17,7 +17,7 @@ ifneq ($(wildcard ../../config-host.mak),) include ../../config-host.mak TARGET_EXE += util/check-cam$(EXESUF) -TARGET_EXE += util/check-proxy$(EXESUF) +TARGET_EXE += util/check-net$(EXESUF) ifdef CONFIG_YAGL TARGET_EXE += util/check-gl$(EXESUF) endif @@ -35,28 +35,28 @@ qemu_clean: qemu_distclean: cd ../../ && $(MAKE) distclean -# Building check-proxy -CHECK_PROXY_OBJS = util/check_proxy.o -CHECK_PROXY_CFLAGS = -c $(GLIB_CFLAGS) $(CURL_CFLAGS) -CHECK_PROXY_LDFLAGS = -CHECK_PROXY_TARGET = util/check-proxy$(EXESUF) +# Building check-net +CHECK_NET_OBJS = util/check_net.o +CHECK_NET_CFLAGS = -c $(GLIB_CFLAGS) $(CURL_CFLAGS) +CHECK_NET_LDFLAGS = +CHECK_NET_TARGET = util/check-net$(EXESUF) ifdef CONFIG_LINUX -CHECK_PROXY_OBJS += util/check_proxy_linux.o -CHECK_PROXY_LDFLAGS += ${CURL_LIBS} `pkg-config --libs glib-2.0` +CHECK_NET_OBJS += util/check_net_linux.o +CHECK_NET_LDFLAGS += ${CURL_LIBS} `pkg-config --libs glib-2.0` endif ifdef CONFIG_WIN32 -CHECK_PROXY_OBJS += util/check_proxy_win32.o -CHECK_PROXY_LDFLAGS += ${CURL_LIBS} `pkg-config --libs glib-2.0` +CHECK_NET_OBJS += util/check_net_win32.o +CHECK_NET_LDFLAGS += -liphlpapi -lws2_32 ${CURL_LIBS} `pkg-config --libs glib-2.0` endif ifdef CONFIG_DARWIN -CHECK_PROXY_OBJS += util/check_proxy_darwin.o -CHECK_PROXY_LDFLAGS += -mmacosx-version-min=10.4 ${CURL_LIBS} -framework CoreFoundation -framework SystemConfiguration `pkg-config --libs glib-2.0` +CHECK_NET_OBJS += util/check_net_darwin.o +CHECK_NET_LDFLAGS += -mmacosx-version-min=10.4 ${CURL_LIBS} -framework CoreFoundation -framework SystemConfiguration `pkg-config --libs glib-2.0` endif -util/check-proxy$(EXESUF): $(CHECK_PROXY_OBJS) - $(CC) $(CHECK_PROXY_OBJS) $(CHECK_PROXY_LDFLAGS) -o $@ -$(CHECK_PROXY_OBJS): %.o: %.c - $(CC) $< $(CHECK_PROXY_CFLAGS) -o $@ +util/check-net$(EXESUF): $(CHECK_NET_OBJS) + $(CC) $(CHECK_NET_OBJS) $(CHECK_NET_LDFLAGS) -o $@ +$(CHECK_NET_OBJS): %.o: %.c + $(CC) $< $(CHECK_NET_CFLAGS) -o $@ # Building check-gl CHECK_GL_OBJS = util/check_gl.o util/check_gl_core.o @@ -134,7 +134,7 @@ build_info: clean: qemu_clean - rm -f util/check-hax$(EXESUF) util/check-cam$(EXESUF) util/check-gl$(EXESUF) util/check-proxy$(EXESUF) + rm -f util/check-hax$(EXESUF) util/check-cam$(EXESUF) util/check-gl$(EXESUF) util/check-net$(EXESUF) distclean: clean qemu_distclean install: all @@ -182,10 +182,10 @@ ifdef CONFIG_USE_SHM endif endif -# check capabilities of OpenGL, Webcam and proxy +# check capabilities of OpenGL, Webcam and net cp -pP util/check-gl$(EXESUF) $(EMUL_DIR)/bin cp -pP util/check-cam$(EXESUF) $(EMUL_DIR)/bin - cp -pP util/check-proxy$(EXESUF) $(EMUL_DIR)/bin + cp -pP util/check-net$(EXESUF) $(EMUL_DIR)/bin # Enable HW Virtualization on Linux ifdef CONFIG_LINUX @@ -275,8 +275,8 @@ ifdef CONFIG_USE_SHM endif endif -# check capabilities of OpenGL, Webcam and proxy - cp -pP util/check-proxy$(EXESUF) $(DIBS_COMMON_DIR)/bin +# check capabilities of OpenGL, Webcam and net + cp -pP util/check-net$(EXESUF) $(DIBS_COMMON_DIR)/bin cp -pP util/check-gl$(EXESUF) $(DIBS_COMMON_DIR)/bin cp -pP util/check-cam$(EXESUF) $(DIBS_COMMON_DIR)/bin diff --git a/tizen/src/util/check_proxy.c b/tizen/src/util/check_net.c index 5f59c68c36..0ac369d1ce 100644 --- a/tizen/src/util/check_proxy.c +++ b/tizen/src/util/check_net.c @@ -1,5 +1,5 @@ /* - * Check proxy + * Check Network status * * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved * @@ -27,7 +27,7 @@ * */ -#include "check_proxy.h" +#include "check_net.h" #include <curl/curl.h> #include <string.h> @@ -88,5 +88,17 @@ inline void remove_string(char *src, char *dst, const char *toremove) void main(int argc, char *argv[]) { - get_host_proxy_os(); + if (argc != 2) { + fprintf(stderr, " Usage: check-net --proxy\n"); + fprintf(stderr, " check-net --interface-all\n"); + fprintf(stderr, " check-net --bridge\n"); + exit(1); + } + if (strcmp(argv[1], ARG_PROXY) == 0) { + get_host_proxy_os(); + } else if (strcmp(argv[1], ARG_INTERFACE_ALL) == 0) { + get_host_interface_all_os(); + } else if (strcmp(argv[1], ARG_BRIDGE) == 0) { + get_host_bridge_os(); + } } diff --git a/tizen/src/util/check_proxy.h b/tizen/src/util/check_net.h index a1e96041f4..dccbb625d8 100644 --- a/tizen/src/util/check_proxy.h +++ b/tizen/src/util/check_net.h @@ -1,5 +1,5 @@ /* - * Check proxy + * Check Network status * * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved * @@ -27,8 +27,8 @@ * */ -#ifndef __CHECK_PROXY_H__ -#define __CHECK_PROXY_H__ +#ifndef __CHECK_NET_H__ +#define __CHECK_NET_H__ #include <string.h> #include <stddef.h> @@ -62,9 +62,16 @@ #define GCONFTOOL 0 #define GSETTINGS 1 +#define ARG_PROXY "--proxy" +#define ARG_INTERFACE_ALL "--interface-all" +#define ARG_BRIDGE "--bridge" +#define PATH_IFCONFIG "/sbin/ifconfig" + extern const char *pac_tempfile; void get_host_proxy_os(void); +void get_host_interface_all_os(void); +void get_host_bridge_os(void); void download_url(char *); size_t write_data(void *, size_t, size_t, FILE *); diff --git a/tizen/src/util/check_proxy_darwin.c b/tizen/src/util/check_net_darwin.c index 25ff02bd3d..14f0a586ab 100644 --- a/tizen/src/util/check_proxy_darwin.c +++ b/tizen/src/util/check_net_darwin.c @@ -1,5 +1,5 @@ /* - * Check proxy + * Check Network status * * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved * @@ -27,7 +27,7 @@ * */ -#include "check_proxy.h" +#include "check_net.h" #include <SystemConfiguration/SystemConfiguration.h> static CFDictionaryRef proxySettings; @@ -193,3 +193,22 @@ void get_host_proxy_os(void) } } +void get_host_interface_all_os(void) +{ + if (access(PATH_IFCONFIG, F_OK) != -1) { + system("/sbin/ifconfig -a"); + } else { + fprintf(stderr, "ifconfig does not exist!\n"); + exit(1); + } +} + +void get_host_bridge_os(void) +{ + if (access(PATH_IFCONFIG, F_OK) != -1) { + system("/sbin/ifconfig br-tizen-vm-1"); + } else { + fprintf(stderr, "ifconfig does not exist!\n"); + exit(1); + } +} diff --git a/tizen/src/util/check_proxy_linux.c b/tizen/src/util/check_net_linux.c index e36b142d72..23f42df792 100644 --- a/tizen/src/util/check_proxy_linux.c +++ b/tizen/src/util/check_net_linux.c @@ -1,5 +1,5 @@ /* - * Check proxy + * Check Network status * * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved * @@ -27,7 +27,8 @@ * */ -#include "check_proxy.h" +#include "check_net.h" +#include <unistd.h> static int gproxytool = GSETTINGS; static const char* gproxycmds[][2] = { @@ -234,3 +235,23 @@ void get_host_proxy_os(void) } pclose(output); } + +void get_host_interface_all_os(void) +{ + if (access(PATH_IFCONFIG, F_OK) != -1) { + system("/sbin/ifconfig -a"); + } else { + fprintf(stderr, "ifconfig does not exist!\n"); + exit(1); + } +} + +void get_host_bridge_os(void) +{ + if (access(PATH_IFCONFIG, F_OK) != -1) { + system("/sbin/ifconfig br-tizen-vm-1"); + } else { + fprintf(stderr, "ifconfig does not exist!\n"); + exit(1); + } +} diff --git a/tizen/src/util/check_proxy_win32.c b/tizen/src/util/check_net_win32.c index 117384fa38..1ab7efb282 100644 --- a/tizen/src/util/check_proxy_win32.c +++ b/tizen/src/util/check_net_win32.c @@ -1,5 +1,5 @@ /* - * Check proxy + * Check Network status * * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved * @@ -26,9 +26,18 @@ * - S-Core Co., Ltd * */ - -#include "check_proxy.h" +#define _WIN32_WINNT 0x0601 +#include "check_net.h" #include <windows.h> +#include <winsock2.h> +#include <iphlpapi.h> + +#define ALL_INTERFACE 0 +#define BRIDGE_ONLY 1 +#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) +#define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) +#define WORKING_BUFFER_SIZE 15000 +#define MAX_TRIES 3 static const char *pactempfile = ".autoproxy"; @@ -204,3 +213,142 @@ void get_host_proxy_os(void) RegCloseKey(hKey); } +static print_interface(PIP_ADAPTER_INFO pAdapter, PIP_ADAPTER_ADDRESSES pAddresses) +{ + int i; + IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = NULL; + struct sockaddr_in *pAddr; + + fprintf(stdout, "Adapter Desc: %s\n", pAdapter->Description); + fprintf(stdout, "Index: %d\n", pAdapter->Index); + fprintf(stdout, "ClassID: %s\n", pAdapter->AdapterName); + /* + typedef enum { + IfOperStatusUp = 1, + IfOperStatusDown, + IfOperStatusTesting, + IfOperStatusUnknown, + IfOperStatusDormant, + IfOperStatusNotPresent, + IfOperStatusLowerLayerDown + } IF_OPER_STATUS; + */ + fprintf(stdout, "Operating Status: %d\n", pAddresses->OperStatus); + fprintf(stdout, "Ethernet Address: "); + for (i = 0; i < pAdapter->AddressLength; i++) { + if (i == (pAdapter->AddressLength - 1)) + fprintf(stdout, "%.2X\n", (int) pAdapter->Address[i]); + else + fprintf(stdout, "%.2X-", (int) pAdapter->Address[i]); + } + if (pAdapter->DhcpEnabled) { + fprintf(stdout, "Use DHCP Server: Yes\n"); + // fprintf(stdout, "DHCP Server Address: %s\n", pAdapter->DhcpServer.IpAddress.String); + } else { + fprintf(stdout, "Use DHCP Server: No\n"); + fprintf(stdout, "IP Address: %s\n", pAdapter->IpAddressList.IpAddress.String); + fprintf(stdout, "IP Mask: %s\n", pAdapter->IpAddressList.IpMask.String); + fprintf(stdout, "Gateway: %s\n", pAdapter->GatewayList.IpAddress.String); + + } + + pDnServer = pAddresses->FirstDnsServerAddress; + if (pDnServer) { + pAddr = (struct sockaddr_in*)pDnServer->Address.lpSockaddr; + fprintf(stdout, "DNS server address: %s\n", inet_ntoa(pAddr->sin_addr)); + } else { + fprintf(stdout, "DNS server address: No\n"); + } + // fprintf(stdout, "Friendly name: %wS\n", pAddresses->FriendlyName); + fprintf(stdout, "\n"); +} + +static void get_host_interface(int value) +{ + PIP_ADAPTER_ADDRESSES pAddresses = NULL; + PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL; + DWORD dwRetAddressVal = 0; + ULONG flags = 0; + + PIP_ADAPTER_INFO pAdapterInfo; + PIP_ADAPTER_INFO pCurrAdapter = NULL; + DWORD dwRetVal = 0; + UINT i; + ULONG Iterations = 0; + + ULONG outBufLen = 0; + outBufLen = WORKING_BUFFER_SIZE; + + do { + + pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen); + if (pAddresses == NULL) { + fprintf(stderr, "Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n"); + exit(1); + } + + dwRetAddressVal = GetAdaptersAddresses(AF_INET, flags, NULL, pAddresses, &outBufLen); + + if (dwRetAddressVal == ERROR_BUFFER_OVERFLOW) { + FREE(pAddresses); + pAddresses = NULL; + } else { + break; + } + + Iterations++; + + } while ((dwRetAddressVal == ERROR_BUFFER_OVERFLOW) && (Iterations < MAX_TRIES)); + + + ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO); + pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(sizeof (IP_ADAPTER_INFO)); + if (pAdapterInfo == NULL) { + fprintf(stderr, "Error allocating memory needed to call GetAdaptersinfo\n"); + exit(1); + } + if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) { + FREE(pAdapterInfo); + pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(ulOutBufLen); + if (pAdapterInfo == NULL) { + fprintf(stderr, "Error allocating memory needed to call GetAdaptersinfo\n"); + exit(1); + } + } + dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen); + if (dwRetVal == NO_ERROR && dwRetAddressVal == NO_ERROR) { + pCurrAdapter = pAdapterInfo; + pCurrAddresses = pAddresses; + while (pCurrAdapter && pCurrAddresses) { + if (pCurrAdapter->Type == MIB_IF_TYPE_ETHERNET) { + if (value == ALL_INTERFACE) { + print_interface(pCurrAdapter, pCurrAddresses); + } else if (value == BRIDGE_ONLY) { + if (strcmp(pCurrAdapter->Description, "MAC Bridge Miniport") == 0 || strcmp(pCurrAdapter->Description, "Microsoft Network Adapter Multiplexor Driver") == 0) { + print_interface(pCurrAdapter, pCurrAddresses); + break; + } + } + } + pCurrAdapter = pCurrAdapter->Next; + pCurrAddresses = pCurrAddresses->Next; + } + } else { + fprintf(stderr, "GetAdaptersInfo failed with error: %d\n", dwRetVal); + exit(1); + } + if (pAdapterInfo) + FREE(pAdapterInfo); + + exit(0); +} + +void get_host_interface_all_os(void) +{ + get_host_interface(ALL_INTERFACE); +} + +void get_host_bridge_os(void) +{ + get_host_interface(BRIDGE_ONLY); +} |