net: save host ip and modify logs
authorMunkyu Im <munkyu.im@samsung.com>
Wed, 20 May 2015 10:39:53 +0000 (19:39 +0900)
committerMunkyu Im <munkyu.im@samsung.com>
Thu, 21 May 2015 02:30:20 +0000 (11:30 +0900)
host IP is used for get host network interface name.

Change-Id: I0144c8f2572097a028def0893ced44f8e243b115
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
net/tap.c
tizen/src/emul_state.c
tizen/src/emulator.c
tizen/src/scripts/emulator-ifup-darwin.sh
tizen/src/scripts/emulator-ifup-linux.sh

index 7833142c1923b1e920750dfccc599dd87f876fe1..a2c90c7c8f79fe79399764373d88d8c8ceb4505b 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -397,6 +397,7 @@ static int launch_script(const char *setup_script, const char *ifname, int fd)
 #if !defined(CONFIG_WIN32) && defined(CONFIG_MARU)
     const char* sudo_path = "/usr/bin/sudo";
     char *host_ifname = get_interface_name_from_ip();
+    fprintf(stdout, "host_ifname: %s\n", host_ifname);
     int arg_cnt = 0;
     if (host_ifname == NULL) {
         arg_cnt = 4;
index 9803e7ecc3af6e7a8ff7a56fdedc693072726830..a5507ee866080fa92d0ee57cc2b11f3d8cee0788 100644 (file)
@@ -214,14 +214,13 @@ void set_emul_host_ip(char *kernel_cmdline)
         }
 
         buf_host_ip[j] = '\0';
-        LOG_INFO("host_ip information=%s\n", buf_host_ip);
+        LOG_INFO("host_ip%s\n", buf_host_ip);
         strncpy(_emul_info.host_ip, buf_host_ip, sizeof(_emul_info.host_ip));
     }
 }
 
 char* get_emul_host_ip(void)
 {
-    LOG_INFO("host ip: %s\n", _emul_info.guest_ip);
     return _emul_info.host_ip;
 }
 
index 4edf95f924a35e3baf57def703b432c3ddb3fc50..de6cc8d3e350dce2686463f43aa4fc5447e86621 100644 (file)
@@ -229,6 +229,8 @@ static void prepare_basic_features(gchar * const kernel_cmdline)
             " vm_resolution=%dx%d", get_emul_vm_base_port(),
             get_emul_resolution_width(), get_emul_resolution_height());
 
+    set_emul_host_ip(kernel_cmdline);
+
     http_proxy_setup(kernel_cmdline);
 
     g_strlcat(kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
index 2a0ed718fa1a49eaf290c774bfdca07515612665..d199e71f18d6f536eb5cc35cc7bc12d707f49dbd 100755 (executable)
@@ -2,30 +2,35 @@
 BRIDGE=bridge1
 TAP=$1
 BASE=en0
-
-#get base network information
+echo "TAP: $1"
+echo "get base network information"
 IP=`ipconfig getifaddr $BASE`
 NETMASK=`ifconfig $BASE | grep "inet " | awk '{print $4}'`
 GW=`netstat -rn | grep ^default | awk '{print $2}'`
+echo "IP: $IP"
+echo "NETMASK: $NETMASK"
+echo "GW: $GW"
 
-#create bridge interface
+echo "create bridge interface"
 CHECK_BR=`ifconfig | grep ^bridge1:`
+echo "CHECK_BR: $CHECK_BR"
 if [ "$CHECK_BR" = "" ]
 then
     ifconfig $BRIDGE create
 fi
 
-#add base network and tap device to bridge
+echo "add base network and tap device to bridge"
 ifconfig $BRIDGE addm $BASE
 ifconfig $BRIDGE addm $TAP
 ifconfig $BRIDGE up
 
-#set IP of base network to bridge
+echo "set IP of base network to bridge"
 ifconfig $BASE delete $IP
 ifconfig $BRIDGE $IP netmask $NETMASK
 
-#change network interface of default gateway
+echo "change network interface of default gateway"
 NET=`netstat -rn | grep ^default | awk '{print $6}'`
 if [ $NET != $BRIDGE ];then
-route change default $GW
+    echo "route change default $GW"
+    route change default $GW
 fi
index 9c5a9051bd42ccda8c09a8536af471206b40c3c4..89b22852f8af3b3461a5ea66933e64b0ca27332e 100755 (executable)
@@ -3,37 +3,42 @@
 NETMASK=`ifconfig $BASE | grep "inet " | awk '{print $4}' | cut -d : -f2`
 GW=`netstat -rn | grep ^0.0.0.0 | awk '{print $2}'`
 BR=bridge1
-
-# Check if bridge interface exists.
-CHECK_BR=`ifconfig $BR`
+echo "NETMASK: $NETMASK"
+echo "GW: $GW"
+echo "Check if bridge interface exists."
+echo "CHECK_BR=`/bin/ls /sys/class/net | grep $BR`"
+CHECK_BR=`/bin/ls /sys/class/net | grep $BR`
 if [ "$CHECK_BR" = "" ]
 then
+    echo "$BR does not exist! create it"
     BASEIPADDR=`ip addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1`
     brctl addbr $BR
 else
     BASEIPADDR=`ip addr show $BR | awk '/inet / {print $2}' | cut -d/ -f1`
 fi
-
-# ifconfig up tap device.
+echo "BASEIPADDR: $BASEIPADDR"
+echo  "ifconfig up $1 device."
 ifconfig $1 0.0.0.0 promisc up
 
-if [ "$2" != "" ]
+if [ "$2" != "" ] && [ "$2" != "$BR" ]
 then
-    # Take interface down.
-    ifdown $2
-    ifconfig $2 0.0.0.0 promisc up
+    echo "Take down $2."
+    ip addr flush dev $2
 
-    # Add tap device and interface to bridge.
+    echo "Add tap device and interface to bridge."
     brctl addif $BR $2
 fi
 brctl addif $BR $1
 
-# Add the default route.
+echo "Add the default route."
+echo ifconfig $BR $BASEIPADDR netmask $NETMASK
 ifconfig $BR $BASEIPADDR netmask $NETMASK
 
 NET=`netstat -rn | grep ^0.0.0.0 | awk '{print $8}'`
+echo "NET: $NET"
 if [ "$NET" != "$BR" ]
 then
+    echo "route add default gw $GW"
     route add default gw $GW
 fi
 exit 0