Emulator is able to use bridged network now.
supported only wired network(en0) currently.
Change-Id: I0157f61aac01fe42655b01eb12d98ffbe9b1cfc5
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
#include "tizen/src/emul_state.h"
#endif
+#include "tizen/src/emul_state.h"
typedef struct TAPState {
NetClientState nc;
int fd;
static int launch_script(const char *setup_script, const char *ifname, int fd)
{
int pid, status;
+#if defined(CONFIG_DARWIN) && defined(CONFIG_MARU)
+ char *args[5];
+ const gchar* cocoasudo_path = g_strdup_printf("%scocoasudo", get_bin_path());
+ const char* message = "--prompt=Emulator needs privileged mode to setup bridged network.";
+#else
char *args[3];
+#endif
char **parg;
/* try to launch network script */
}
}
parg = args;
+#if defined(CONFIG_DARWIN) && defined(CONFIG_MARU)
+ *parg++ = (char *)cocoasudo_path;
+ *parg++ = (char *)message;
+#endif
*parg++ = (char *)setup_script;
*parg++ = (char *)ifname;
*parg = NULL;
+#if defined(CONFIG_DARWIN) && defined(CONFIG_MARU)
+ execv(cocoasudo_path, args);
+#else
execv(setup_script, args);
+#endif
_exit(1);
} else if (pid > 0) {
while (waitpid(pid, &status, 0) != pid) {
TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH`
OLD_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax`
-COCOASUDOPATH="./cocoasudo"
SYSCTL_FILE=sysctl.conf
TMP_DIR=~/.installmanager
TIZEN_BIN_PATH=$TIZEN_SDK_INSTALL_PATH/tools/emulator/bin
-#TIZEN_BIN_PATH=./
TMP_FILE=$TMP_DIR/setshmmax.sh
+TMP_INSTALL_TAP_FILE=$TMP_DIR/install-tap.sh
NEW_SHMMAXSIZE=83886080
-
if [ -z $TIZEN_SDK_INSTALL_PATH ]
then
echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log
# exit 2;
fi
+function install_tap {
+ echo 'make new install-tap.sh file'
+
+ if [ ! -d $TMP_DIR ]
+ then
+ mkdir $TMP_DIR
+ fi
+ cat << 'EOF' >> $TMP_INSTALL_TAP_FILE
+#!/bin/sh
+mkdir -p /Library/Extensions
+cp -pR tap.kext /Library/Extensions/
+chown -R root:wheel /Library/Extensions/tap.kext
+mkdir -p /Library/LaunchDaemons
+cp /Library/Extensions/tap.kext/Contents/net.sf.tuntaposx.tap.plist /Library/LaunchDaemons
+/sbin/kextload /Library/Extensions/tap.kext
+EOF
+ /bin/chmod +x $TMP_INSTALL_TAP_FILE
+ echo 'launch install-tap.sh'
+ $TIZEN_BIN_PATH/cocoasudo "--prompt=Installing tun/tap driver requires that you type your password." sh -x $TMP_INSTALL_TAP_FILE
+ rm -f $TMP_INSTALL_TAP_FILE
+}
+
function remove_tmp_file {
if [ -e $TMP_FILE ]
then
fi
}
-function remove_sysctl_file {
+function remove_sysctl_file {
if [ -e $TMP_DIR/$SYSCTL_FILE ]
then
echo 'delete ~/tmp/sysctl.conf'
}
-if [ $OLD_SHMMAXSIZE -lt $NEW_SHMMAXSIZE ]
+if [ $OLD_SHMMAXSIZE -lt $NEW_SHMMAXSIZE ]
then
if [ -e /etc/$SYSCTL_FILE ]
then
echo "cp -f $TMP_DIR/$SYSCTL_FILE /etc/." >> $TMP_FILE
echo "sysctl -w kern.sysv.shmmax=$NEW_SHMMAXSIZE" >> $TMP_FILE
chmod +x $TMP_FILE
- $TIZEN_BIN_PATH/cocoasudo "--prompt=Make a new /etc/sysctl.conf file requires that you type your password." sh -x $TMP_FILE
+ $TIZEN_BIN_PATH/cocoasudo "--prompt=Make a new /etc/sysctl.conf file requires that you type your password." sh -x $TMP_FILE
fi
fi
remove_tmp_file;
remove_sysctl_file;
-
+install_tap;
CURRENT_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax`
if [ ! $OLD_SHMMAXSIZE -eq $CURRENT_SHMMAXSIZE ]
then
-
echo 'need reboot'
exit 99
fi
# give a title name for sdb terminal.
ifdef CONFIG_DARWIN
cp -pP scripts/sdbscript $(EMUL_DIR)/bin
+ cp -pP scripts/emulator-ifup.sh $(EMUL_DIR)/bin
endif
# use shared memory for display framebuffer
--- /dev/null
+#!/bin/sh -x
+BRIDGE=bridge1
+TAP=$1
+BASE=en0
+
+#get base network information
+IP=`ipconfig getifaddr $BASE`
+NETMASK=`ifconfig $BASE | grep "inet " | awk '{print $4}'`
+GW=`netstat -rn | grep ^default | awk '{print $2}'`
+
+#create bridge interface
+CHECK_BR=`ifconfig | grep ^bridge1:`
+if [ "$CHECK_BR" = "" ]
+then
+ ifconfig $BRIDGE create
+fi
+
+#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
+ifconfig $BASE delete $IP
+ifconfig $BRIDGE $IP netmask $NETMASK
+
+#change network interface of default gateway
+NET=`netstat -rn | grep ^default | awk '{print $6}'`
+if [ $NET != $BRIDGE ];then
+route change default $GW
+fi
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);