public class TapUtil {
- public static String getBridgeFromDevice(String device)
- throws VMWorkerException {
+ public static String getBridgeFromDevice(String device) throws VMWorkerException {
String result = null;
if (EmulatorManager.isLinux()) {
return result;
}
- public static List<String> getDefaultGateway(String ifName)
- throws VMWorkerException {
+ public static List<String> getDefaultGateway(String ifName) throws VMWorkerException {
List<String> result = new ArrayList<String>();
if (EmulatorManager.isLinux()) {
} else {
if (arr.length >= 5) {
- if (arr[0].equals("default")
- && arr[4].equals(ifName)) {
+ if (arr[0].equals("default") && arr[4].equals(ifName)) {
result.add(arr[2]);
}
}
list = getTapListForWin2();
} else if (EmulatorManager.isMac()) {
- // TODO
+ list = getTapListForMac();
}
return list;
}
+ private static List<String> getTapListForMac() {
+ List<String> result = new ArrayList<String>();
+ result.add("auto");
+ return result;
+ }
+
// Use "ip tuntap" command.
// Result is like below.
// "tap1: tap one_queue vnet_hdr"
List<String> cmd = Arrays.asList("ip", "tuntap");
ProcessResult res = HelperClass.runProcess(cmd);
if (res.isSuccess() == false) {
- EMLogger.getLogger().warning(
- "Get tap list fail. Command returns fail:" + "cmd : "
- + cmd.toString() + ", return : "
- + res.getExitValue());
+ EMLogger.getLogger().warning("Get tap list fail. Command returns fail:" + "cmd : " + cmd.toString() + ", return : " + res.getExitValue());
} else {
for (String line : res.getStdOutMsg()) {
String arr[] = line.split(":");
private static List<String> getTapListForWin() {
List<String> result = new ArrayList<String>();
List<String> cmd = new ArrayList<String>();
- ProcessBuilder pb = new ProcessBuilder(new String[] { "openvpn",
- "--show-adapters" });
+ ProcessBuilder pb = new ProcessBuilder(new String[] { "openvpn", "--show-adapters" });
int exitValue = 0;
Process process;
try {
process = pb.start();
- List<String> stdOut = ProcessOutputReader.readStdOut(process,
- cmd.toString());
+ List<String> stdOut = ProcessOutputReader.readStdOut(process, cmd.toString());
exitValue = process.waitFor();
if (exitValue != 0) {
- EMLogger.getLogger().warning(
- "Get tap list fail. Command returns fail:" + "cmd : "
- + cmd.toString() + ", return : " + exitValue);
+ EMLogger.getLogger().warning("Get tap list fail. Command returns fail:" + "cmd : " + cmd.toString() + ", return : " + exitValue);
} else {
for (String line : stdOut) {
if (line.contains("'")) {
}
} catch (IOException e) {
- EMLogger.getLogger()
- .warning("Get tap list fail. " + e.getMessage());
+ EMLogger.getLogger().warning("Get tap list fail. " + e.getMessage());
e.printStackTrace();
} catch (InterruptedException e) {
- EMLogger.getLogger()
- .warning("Get tap list fail. " + e.getMessage());
+ EMLogger.getLogger().warning("Get tap list fail. " + e.getMessage());
e.printStackTrace();
}
String[] subKeys2 = Advapi32Util.registryGetKeys(root, topKey + "\\" + subKey);
for (String subKey2 : subKeys2) {
if (subKey2.equals(key)) {
- String tapName = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey + "\\" + key, value);
+ String tapName = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey + "\\" + key, value);
if (tapName != null) {
EMLogger.getLogger().warning("tapname added: " + tapName);
tapNameList.add(tapName);
List<String> tapIdList = new ArrayList<String>();
HKEY root = WinReg.HKEY_LOCAL_MACHINE;
- String topKey= "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
+ String topKey = "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
String value1 = "ComponentId";
String value2 = "NetCfgInstanceId";
regKey = Advapi32Util.registryGetKey(root, topKey, WinNT.KEY_READ);
String[] subKeys = Advapi32Util.registryGetKeys(regKey.getValue());
for (String subKey : subKeys) {
- String compId = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey, value1);
- String tapId = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey, value2);
+ String compId = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey, value1);
+ String tapId = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey, value2);
if (compId != null && tapId != null) {
if (compId.startsWith("tap")) {
tapIdList.add(tapId);
String[] subKeys2 = Advapi32Util.registryGetKeys(root, topKey + "\\" + subKey);
for (String subKey2 : subKeys2) {
if (subKey2.equals(key)) {
- String name = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey + "\\" + key, value);
+ String name = Advapi32Util.registryGetStringValue(root, topKey + "\\" + subKey + "\\" + key, value);
if (name != null) {
if (name.equals(tapName)) {
foundTapId = tapId;
topKey = "SYSTEM\\CurrentControlSet\\services\\Bridge\\Linkage";
}
value = "Route";
- String valueArr[] = Advapi32Util.registryGetStringArray(root, topKey, value);
+ String valueArr[] = Advapi32Util.registryGetStringArray(root, topKey, value);
for (String str : valueArr) {
if (str.replace("\"", "").equals(foundTapId)) {
result = true;
}
}
}
+ } else if (EmulatorManager.isMac()) {
+ List<String> cmd = Arrays.asList("/bin/sh", "-c", "ifconfig en0 | grep \"inet \" | awk '{print $4}'");
+ ProcessResult res = HelperClass.runProcess(cmd);
+ boolean isCommandSuccess = false;
+ if (res.isSuccess()) {
+ for (String str : res.getStdOutMsg()) {
+ isCommandSuccess = true;
+ long ipAddress = Long.parseLong(str.substring(2), 16);
+ netMask = longToIpAddress(ipAddress);
+ EMLogger.getLogger().info("netmask en0: " + netMask);
+ }
+ if (netMask.length() == 0) {
+ isCommandSuccess = false;
+ cmd = Arrays.asList("/bin/sh", "-c", "ifconfig bridge1 | grep \"inet \" | awk '{print $4}'");
+ res = HelperClass.runProcess(cmd);
+ if (res.isSuccess()) {
+ for (String str : res.getStdOutMsg()) {
+ isCommandSuccess = true;
+ long ipAddress = Long.parseLong(str.substring(2), 16);
+ netMask = longToIpAddress(ipAddress);
+ EMLogger.getLogger().info("netmask bridge1: " + netMask);
+ }
+ }
+ }
+ }
+ if (!res.isSuccess() || !isCommandSuccess) {
+ EMLogger.getLogger().warning(res.getResultMessage());
+ }
}
return netMask;
}
+ private static String longToIpAddress(long ip) {
+ StringBuilder sb = new StringBuilder(15);
+
+ for (int i = 0; i < 4; i++) {
+ sb.insert(0, Long.toString(ip & 0xff));
+
+ if (i < 3) {
+ sb.insert(0, '.');
+ }
+
+ ip >>= 8;
+ }
+ return sb.toString();
+ }
+
private static HKEY getBridgeTcpipKey() {
HKEY resultKey = null;
String bridgeId = getBridgeId();
}
HKEY root = WinReg.HKEY_LOCAL_MACHINE;
- String topKey = "SYSTEM\\CurrentControlSet\\services";
+ String topKey = "SYSTEM\\CurrentControlSet\\services";
HKEYByReference regKey = null;
try {
regKey = Advapi32Util.registryGetKey(root, topKey, WinNT.KEY_READ);
String[] subKeys = Advapi32Util.registryGetKeys(regKey.getValue());
for (String subKey : subKeys) {
if (subKey.equals(bridgeId)) {
- resultKey = Advapi32Util.registryGetKey(root,
- topKey + "\\" + subKey + "\\Parameters\\Tcpip", WinNT.KEY_READ).getValue();
+ resultKey = Advapi32Util.registryGetKey(root, topKey + "\\" + subKey + "\\Parameters\\Tcpip", WinNT.KEY_READ).getValue();
break;
}
}
HKEY resultKey = null;
HKEY root = WinReg.HKEY_LOCAL_MACHINE;
- String topKey = "SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces"
- + "\\" + ifId;
+ String topKey = "SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces" + "\\" + ifId;
try {
resultKey = Advapi32Util.registryGetKey(root, topKey, WinNT.KEY_READ).getValue();
String bridgeId = null;
if (EmulatorManager.isWin()) {
HKEY root = WinReg.HKEY_LOCAL_MACHINE;
- String topKey = "SYSTEM\\CurrentControlSet\\services\\BridgeMP";
+ String topKey = "SYSTEM\\CurrentControlSet\\services\\BridgeMP";
String value = "Device";
try {
String data = Advapi32Util.registryGetStringValue(root, topKey, value);
}
}
}
+ } else if (EmulatorManager.isMac()) {
+ List<String> cmd = Arrays.asList("/bin/sh", "-c", "netstat -rn | grep ^default | awk '{print $2}'");
+ ProcessResult res = HelperClass.runProcess(cmd);
+ boolean isCommandSuccess = false;
+ if (res.isSuccess()) {
+ for (String str : res.getStdOutMsg()) {
+ isCommandSuccess = true;
+ gateway = str.trim();
+ EMLogger.getLogger().info("gateway: " + gateway);
+ }
+ } else if (!res.isSuccess() || !isCommandSuccess) {
+ EMLogger.getLogger().warning(res.getResultMessage());
+ }
}
return gateway;
}
public static String getDnsFromTap(String tapName) {
- String dns="";
+ String dns = "";
if (EmulatorManager.isLinux()) {
dns = getDnsForLinux(tapName);
} else if (EmulatorManager.isWin() && isTapInBridge(tapName)) {
dns = getDnsForWin(tapName);
+ } else if (EmulatorManager.isMac()) {
+ dns = getDnsForMac(tapName);
}
return dns;
}
+ private static String getDnsForMac(String tapName) {
+ String dnsServer = "";
+ List<String> cmd = Arrays.asList("/bin/sh", "-c", "/usr/sbin/scutil --dns | grep nameserver\\[[0]*\\] | awk '{print $3}' | head -n 1");
+ ProcessResult res = HelperClass.runProcess(cmd);
+ boolean isCommandSuccess = false;
+ if (res.isSuccess()) {
+ for (String str : res.getStdOutMsg()) {
+ isCommandSuccess = true;
+ dnsServer = str.trim();
+ EMLogger.getLogger().info("dns server: " + dnsServer);
+ }
+ } else if (!res.isSuccess() || !isCommandSuccess) {
+ EMLogger.getLogger().warning(res.getResultMessage());
+ }
+ return dnsServer;
+ }
+
private static String getDnsForLinux(String tapName) {
String brName = null;
try {
return dns;
}
-
// return ip, broadcast, mask-length
public static InterfaceAddress getInterfaceIpInfo(String ifName) {
Enumeration<NetworkInterface> interfaces;
while (interfaces.hasMoreElements()) {
NetworkInterface current = interfaces.nextElement();
if (current.getName().equals(ifName)) {
- for (InterfaceAddress addr : current
- .getInterfaceAddresses()) {
+ for (InterfaceAddress addr : current.getInterfaceAddresses()) {
if (addr.getAddress() instanceof Inet4Address) {
return addr;
}
return isNotExist;
}
- public static void createTapDevice(String tapName,
- ComboViewItem comboViewItem) {
+ public static void createTapDevice(String tapName, ComboViewItem comboViewItem) {
if (EmulatorManager.isWin()) {
MessageDialog msgDialog = new MessageDialog();
- msgDialog
- .openNoButtonInfoDialog("Creating tap device.\nThis will take few seconds..");
- TapCreateWorker worker = new TapCreateWorker(tapName, msgDialog,
- comboViewItem);
+ msgDialog.openNoButtonInfoDialog("Creating tap device.\nThis will take few seconds..");
+ TapCreateWorker worker = new TapCreateWorker(tapName, msgDialog, comboViewItem);
worker.start();
}
if (ifAddr != null)
ipAddr = ifAddr.getAddress().getHostAddress();
} catch (VMWorkerException e) {
- EMLogger.getLogger().warning(
- (new StringBuilder())
- .append("Failed to get bridge ip address. ")
- .append(e.getMessage()).toString());
+ EMLogger.getLogger().warning((new StringBuilder()).append("Failed to get bridge ip address. ").append(e.getMessage()).toString());
}
else if (EmulatorManager.isWin() && isTapInBridge(tapName)) {
String proxyCommand = "check-net.exe";
- List<String> cmd = Arrays.asList(FilePathResources.getBinPath()
- + File.separator + proxyCommand, "--bridge");
+ List<String> cmd = Arrays.asList(FilePathResources.getBinPath() + File.separator + proxyCommand, "--bridge");
ProcessResult res = HelperClass.runProcess(cmd);
boolean isCommandSuccess = false;
if (res.isSuccess()) {
if (str.startsWith("IP Address:")) {
isCommandSuccess = true;
ipAddr = str.split("IP Address: ")[1].trim();
- EMLogger.getLogger().info(
- "bridge IP address: " + ipAddr);
+ EMLogger.getLogger().info("bridge IP address: " + ipAddr);
if (ipAddr.equals("0.0.0.0")) {
return null;
}
if (ipAddr == null) {
EMLogger.getLogger().warning("Can't find host bridge IP");
- EMLogger.getLogger().warning(
- "check-net result : " + res.getResultMessage());
+ EMLogger.getLogger().warning("check-net result : " + res.getResultMessage());
+ }
+ } else if (EmulatorManager.isMac()) {
+ List<String> cmd = Arrays.asList("/bin/sh", "-c", "ifconfig en0 | grep \"inet \" | awk '{print $2}'");
+ ProcessResult res = HelperClass.runProcess(cmd);
+ boolean isCommandSuccess = false;
+ if (res.isSuccess()) {
+ for (String str : res.getStdOutMsg()) {
+ isCommandSuccess = true;
+ ipAddr = str.trim();
+ EMLogger.getLogger().info("host IP en0: " + ipAddr);
+ }
+ if (ipAddr.length() == 0) {
+ isCommandSuccess = false;
+ cmd = Arrays.asList("/bin/sh", "-c", "ifconfig bridge1 | grep \"inet \" | awk '{print $2}'");
+ res = HelperClass.runProcess(cmd);
+ if (res.isSuccess()) {
+ for (String str : res.getStdOutMsg()) {
+ isCommandSuccess = true;
+ ipAddr = str.trim();
+ EMLogger.getLogger().info("host IP bridge1: " + ipAddr);
+ }
+ }
+ }
+ }
+
+ if (!res.isSuccess() || !isCommandSuccess) {
+ EMLogger.getLogger().warning(res.getResultMessage());
}
}
return ipAddr;
final String tapName;
final ComboViewItem comboViewItem; // for refresh combo-list
- public TapCreateWorker(String tapName, MessageDialog dialog,
- ComboViewItem comboViewItem) {
+ public TapCreateWorker(String tapName, MessageDialog dialog, ComboViewItem comboViewItem) {
this.dialog = dialog;
this.tapName = tapName;
this.comboViewItem = comboViewItem;
}
if (newOne == null) {
- throw new VMWorkerException(
- "Tap create fail. Cannot find new tap device.");
+ throw new VMWorkerException("Tap create fail. Cannot find new tap device.");
}
// 4. Rename
- cmd = Arrays.asList("netsh", "interface", "set", "interface",
- "name=" + newOne, "newname=" + tapName);
+ cmd = Arrays.asList("netsh", "interface", "set", "interface", "name=" + newOne, "newname=" + tapName);
res = HelperClass.runProcess(cmd);
if (!res.isSuccess()) {
throw new VMWorkerException(res.getResultMessage());
if (isTapExist) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- int res = resultDialog
- .openSelectionDialog("Tap device created : "
- + tapName
- + "\nDo you want to see the guide for bridge network ?");
+ int res = resultDialog.openSelectionDialog("Tap device created : " + tapName + "\nDo you want to see the guide for bridge network ?");
if (res == SWT.OK) {
// Show bridge guide dialog
TapGuideDialogForWin.open();
final String msg = e.getMessage();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- new MessageDialog()
- .openWarningDialog("\nFailed to create tap device.\n\n"
- + msg);
+ new MessageDialog().openWarningDialog("\nFailed to create tap device.\n\n" + msg);
}
});
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.mobile.ui.detail;
+
+import java.util.List;
+
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
+import org.tizen.emulator.manager.ui.detail.item.CommonItemListFactory;
+import org.tizen.emulator.manager.ui.detail.item.IViewItem;
+import org.tizen.emulator.manager.ui.detail.item.ItemType;
+import org.tizen.emulator.manager.ui.detail.item.LineLabelViewItem;
+import org.tizen.emulator.manager.ui.detail.item.property.NetConnectTypeViewItem;
+import org.tizen.emulator.manager.ui.detail.item.property.NetDnsViewItem;
+import org.tizen.emulator.manager.ui.detail.item.property.NetIPInfoViewItem;
+import org.tizen.emulator.manager.ui.detail.item.property.NetMacViewItem;
+import org.tizen.emulator.manager.ui.detail.item.property.NetProxyViewItem;
+import org.tizen.emulator.manager.ui.detail.item.property.NetTapDeviceViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.CheckLabelViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.ComboViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.FileViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.OnOffViewItem;
+import org.tizen.emulator.manager.ui.detail.item.template.TextViewItem;
+import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
+import org.tizen.emulator.manager.vms.xml.template.DeviceList;
+import org.tizen.emulator.manager.vms.xml.template.Item;
+import org.tizen.emulator.manager.vms.xml.template.ItemList;
+
+public class ItemListFactory extends CommonItemListFactory {
+
+ public static String ITEM_EXPERIMENTAL = "experimental";
+
+ private static void makeItemListOld(List<? extends IViewItem> list) {
+ List<IViewItem> itemList = (List<IViewItem>)list;
+
+ itemList.add(new TNameTextItem());
+ itemList.add(new TDisplayItem());
+ itemList.add(new TRAMItem());
+ itemList.add(new TTouchPointItem());
+ if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) {
+ itemList.add(new TSupportSuspendItem());
+ }
+
+ itemList.add(new TFileShareItem());
+ itemList.add(new THWSupportItem());
+
+ }
+
+ @Override
+ public void makeItemList(List<? extends IViewItem> itemList,
+ ItemList template) {
+ if (template == null) {
+ makeItemListOld(itemList); // TODO old
+ } else {
+ makePropertyItemList(itemList, template.getPropertyList(), template.getProfile(), true);
+ makeDeviceItemList(itemList, template.getDeviceList());
+
+ }
+ }
+
+ @Override
+ public void makeDeviceItemList(List<? extends IViewItem> list, DeviceList deviceList) {
+
+ if (deviceList != null) {
+ List<IViewItem> itemList = (List<IViewItem>)list;
+ List<Item> deviceItemList = deviceList.getItem();
+ LineLabelViewItem currentLineLabel = null; // Top categorizing item
+ boolean isExperimentalLabel = false;
+
+ for (Item item : deviceItemList) {
+ String type = item.getType();
+ String name = item.getName();
+
+ if (isExperimentalLabel && EmulatorManager.getManagerMode() != ManagerModeType.INHOUSE_MODE) {
+ continue;
+ }
+
+ if (name.equals(CheckingRunningEmulator.OPTION_VIEWER)) {
+ if (EmulatorManager.isLinux()) {
+ itemList.add(new LabelViewItem(item, currentLineLabel));
+ }
+ continue;
+
+ } else if (name.equals(ITEM_NET_CONNECT_TYPE)) {
+ itemList.add(new NetConnectTypeViewItem(item,
+ currentLineLabel));
+ continue;
+
+ } else if (name.equals(ITEM_NET_TAP_DEVICE)) {
+ itemList.add(new NetTapDeviceViewItem(item,
+ currentLineLabel));
+ continue;
+
+ } else if (name.equals(ITEM_NET_PROXY)) {
+ itemList.add(new NetProxyViewItem(item, currentLineLabel));
+ continue;
+
+ } else if (name.equals(ITEM_NET_IP_INFO)) {
+ itemList.add(new NetIPInfoViewItem(item, currentLineLabel));
+ continue;
+
+ } else if (name.equals(ITEM_NET_DNS)) {
+ itemList.add(new NetDnsViewItem(item, currentLineLabel));
+ continue;
+
+ } else if (name.equals(ITEM_NET_MAC)) {
+ itemList.add(new NetMacViewItem(item, currentLineLabel));
+ continue;
+
+ }
+
+ if (type.equals(ItemType.LINE_LABEL.getName())) { // Top categorizing item
+ if (name.equals(ITEM_EXPERIMENTAL)) {
+ isExperimentalLabel = true;
+ if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) {
+ currentLineLabel = new LineLabelViewItem(item);
+ itemList.add(currentLineLabel);
+ }
+ } else {
+ currentLineLabel = new LineLabelViewItem(item);
+ itemList.add(currentLineLabel);
+ isExperimentalLabel = false;
+ }
+
+ } else if (type.equals(ItemType.TOGGLE.getName())) {
+ itemList.add(new OnOffViewItem(item, currentLineLabel));
+
+ } else if (type.equals(ItemType.LABEL.getName())) {
+ itemList.add(new LabelViewItem(item, currentLineLabel));
+
+ } else if (type.equals(ItemType.COMBO.getName())) {
+ itemList.add(new ComboViewItem(item, currentLineLabel));
+
+ } else if (type.equals(ItemType.FILE.getName())) {
+ itemList.add(new FileViewItem(item, currentLineLabel));
+
+ } else if (type.equals(ItemType.CHECK_LABEL.getName())) {
+ itemList.add(new CheckLabelViewItem(item, currentLineLabel));
+
+ } else if (type.equals(ItemType.TEXT.getName())) {
+ itemList.add(new TextViewItem(item, currentLineLabel));
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public void makeCustomItemList(List<? extends IViewItem> itemList,
+ List<ItemList> templateList) {
+ if (templateList == null || templateList.size() == 0) {
+ makeItemListOld(itemList); // TODO old
+ } else {
+
+ makeCustomDeviceItemList(itemList, templateList);
+ }
+ }
+}
private String binPath = null;
private static Launcher launcher;
-
+ public static final String IFUP_SCRIPT = "emulator-ifup.sh";
// Option names in vm_config.xml
// Add if need.
public static final String OPT_DEVICE = "device";
int portNo;
boolean useBridgeNet = property.getPropertyValue()
.getAdvancedOptionValue(OPT_NET_CONNECT_TYPE).equals("Bridge") &&
- (EmulatorManager.isLinux() || EmulatorManager.isWin());
+ (EmulatorManager.isLinux() || EmulatorManager.isWin() || EmulatorManager.isMac());
if (useBridgeNet) {
- String tapName = property.getPropertyValue()
- .getAdvancedOptionValue(OPT_NET_TAP_DEVICE);
- if (TapUtil.nameNotExist(tapName))
- throw new VMLauncherException((new StringBuilder())
- .append("Tap device is not exist : ").append(tapName)
- .append("\nCheck VM's tap configuration.").toString());
- if (isTapUsing(tapName))
- throw new VMLauncherException(
- (new StringBuilder())
- .append("Tap device(")
- .append(tapName)
- .append(") is being used by other VM.")
- .append("\nPlease select another tap device for current VM.")
- .toString());
String ipAddr = property.getPropertyValue()
.getAdvancedOptionSubValue(OPT_NET_IP_INFO, "ipAddr");
if (isIpAddrUsing(ipAddr))
.append(") is being used by other VM.")
.append("\nPlease modify current VM's ip address.")
.toString());
- try {
- if (!TapUtil.isTapInBridge(tapName)) {
- MessageDialog dialog = new MessageDialog();
- int res = dialog
- .openWarningAndSelectionDialog("\nTap device is not connected with Bridge." +
- "\nGuest network would work as NAT." +
- "\nKeep launching ?");
- if (res != SWT.OK) {
- throw new VMLauncherException("User canceled.");
+
+ if (!EmulatorManager.isMac()) {
+ String tapName = property.getPropertyValue()
+ .getAdvancedOptionValue(OPT_NET_TAP_DEVICE);
+ if (TapUtil.nameNotExist(tapName))
+ throw new VMLauncherException((new StringBuilder())
+ .append("Tap device is not exist : ").append(tapName)
+ .append("\nCheck VM's tap configuration.").toString());
+ if (isTapUsing(tapName))
+ throw new VMLauncherException(
+ (new StringBuilder())
+ .append("Tap device(")
+ .append(tapName)
+ .append(") is being used by other VM.")
+ .append("\nPlease select another tap device for current VM.")
+ .toString());
+ try {
+ if (!TapUtil.isTapInBridge(tapName)) {
+ MessageDialog dialog = new MessageDialog();
+ int res = dialog
+ .openWarningAndSelectionDialog("\nTap device is not connected with Bridge." +
+ "\nGuest network would work as NAT." +
+ "\nKeep launching ?");
+ if (res != SWT.OK) {
+ throw new VMLauncherException("User canceled.");
+ }
+ useBridgeNet = false;
}
- useBridgeNet = false;
- }
- } catch (VMWorkerException e) {
- throw new VMLauncherException(e.getMessage());
+ } catch (VMWorkerException e) {
+ throw new VMLauncherException(e.getMessage());
+ }
}
}
/* get MAC address of host set as guest MAC address */
String macAddr = useBridgeNet ? property.getPropertyValue()
- .getAdvancedOptionValue(OPT_NET_MAC) : SettingInfoFile
- .getMACaddr();
+ .getAdvancedOptionValue(OPT_NET_MAC) : SettingInfoFile
+ .getMACaddr();
if(macAddr.isEmpty()) {
macAddr = "52:54:00:12:34:56";
cmd.add(FilePathResources.getKernelPath() + File.separator+ "bzImage." + property.getArch().toString());
cmd.add("-net");
if (useBridgeNet) {
- String tapName = property.getPropertyValue()
- .getAdvancedOptionValue(OPT_NET_TAP_DEVICE);
- if (TapUtil.nameNotExist(tapName)) {
- throw new VMLauncherException("Tap device is not exist : "
- + tapName + "\nCheck VM's tap configuration.");
+ if (!EmulatorManager.isMac()) {
+ String tapName = property.getPropertyValue()
+ .getAdvancedOptionValue(OPT_NET_TAP_DEVICE);
+ if (TapUtil.nameNotExist(tapName)) {
+ throw new VMLauncherException("Tap device is not exist : "
+ + tapName + "\nCheck VM's tap configuration.");
+ }
+ cmd.add("tap,ifname=" + tapName + ",script=no,downscript=no");
+ } else {
+ cmd.add("tap,script=" + FilePathResources.getBinPath() + File.separator + IFUP_SCRIPT +",downscript=no");
}
- cmd.add("tap,ifname=" + tapName + ",script=no,downscript=no");
} else {
cmd.add("user,dhcpstart=10.0.2.16");
}