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 <munkyu.im@samsung.com>
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) {
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();
}
}
#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;
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
*/
#include "check_net.h"
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <ifaddrs.h>
#include <SystemConfiguration/SystemConfiguration.h>
static CFDictionaryRef proxySettings;
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);
+}
#include "check_net.h"
#include <unistd.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <ifaddrs.h>
static int gproxytool = GSETTINGS;
static const char* gproxycmds[][2] = {
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);
+}
{
get_host_interface(BRIDGE_ONLY);
}
+
+void get_host_ip_os(void)
+{
+ fprintf(stderr, "not supported now\n");
+}