ConsoleImpl2.cpp revision 4cf22805d13f50eef86e917f2c7106fe5198a2d8
/* $Id$ */
/** @file
* VBox Console COM Class implementation
*
* @remark We've split out the code that the 64-bit VC++ v8 compiler
* finds problematic to optimize so we can disable optimizations
* and later, perhaps, find a real solution for it.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "ConsoleImpl.h"
#include "DisplayImpl.h"
#include "VMMDev.h"
// generated header
#include "SchemaDefs.h"
#include "Logging.h"
#if 0 /* enable to play with lots of memory. */
#endif
#ifdef VBOX_WITH_CROGL
#endif
#ifdef VBOX_WITH_GUEST_PROPS
* extension using a VMMDev callback. */
# include <vector>
#endif /* VBOX_WITH_GUEST_PROPS */
#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NETFLT)
# include <zone.h>
#endif
#if defined(RT_OS_LINUX) && defined(VBOX_WITH_NETFLT)
# include <unistd.h>
# include <linux/wireless.h>
#endif
#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
# include <VBox/WinNetConfig.h>
# include <Ntddndis.h>
# include <devguid.h>
#endif
#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
# include <HostNetworkInterfaceImpl.h>
# include <netif.h>
#endif
#include "DHCPServerRunner.h"
/* Comment out the following line to remove VMWare compatibility hack. */
#define VMWARE_NET_IN_SLOT_11
/**
* Translate IDE StorageControllerType_T to string representation.
*/
{
switch (enmType)
{
return "PIIX3";
return "PIIX4";
return "ICH6";
default:
return "Unknown";
}
}
/*
* VC++ 8 / amd64 has some serious trouble with this function.
* As a temporary measure, we'll drop global optimizations.
*/
#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
#endif
/**
* Construct the VM configuration tree (CFGM).
*
* This is a callback for VMR3Create() call. It is called from CFGMR3Init()
* is done here.
*
* @param pVM VM handle.
* @param pvConsole Pointer to the VMPowerUpTask object.
* @return VBox status code.
*
* @note Locks the Console object for writing.
*/
{
/* Note: hardcoded assumption about number of slots; see rom bios */
bool afPciDeviceNo[32] = {false};
#if !defined (VBOX_WITH_XPCOM)
{
/* initialize COM */
}
#endif
/* lock the console because we widely use internal fields and methods */
/* Save the VM pointer in the machine object */
int rc;
of str as it manages memory! */
#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0)
#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
/*
* Get necessary objects and frequently used parameters.
*/
#if 0 /* enable to play with lots of memory. */
if (RTEnvExist("VBOX_RAM_SIZE"))
#endif
/*
* Get root node first.
* This is the only node in the tree.
*/
/*
* Set the root (and VMM) level values.
*/
STR_CONV();
STR_FREE();
/** @todo Config: RawR0, PATMEnabled and CASMEnabled needs attention later. */
/* hardware virtualization extensions */
#ifdef RT_OS_DARWIN
#else
/* - With more than 4GB PGM will use different RAMRANGE sizes for raw
mode and hv mode to optimize lookup times.
- With more than one virtual CPU, raw-mode isn't a fallback option. */
|| cCpus > 1);
#endif
if (fHWVirtExEnabled)
{
/* Indicate whether 64-bit guests are supported or not. */
/** @todo This is currently only forced off on 32-bit hosts only because it
* makes a lof of difference there (REM and Solaris performance).
*/
BOOL fSupportsLongMode = false;
&fSupportsLongMode); H();
BOOL fIs64BitGuest = false;
if (fSupportsLongMode && fIs64BitGuest)
{
#endif
}
else
{
}
#endif
}
BOOL fEnableNestedPaging = false;
/* VPID (VT-x) */
BOOL fEnableVPID = false;
/* Physical Address Extension (PAE) */
BOOL fEnablePAE = false;
/*
* PDM config.
* Load drivers in VBoxC.[so|dll]
*/
#ifdef VBOX_WITH_XPCOM
// VBoxC is located in the components subdirectory
char szPathVBoxC[RTPATH_MAX];
#else
#endif
/*
* Devices
*/
/*
* PC Arch.
*/
/*
* Firmware.
*/
#ifdef VBOX_WITH_EFI
/** @todo: implement appropriate getter */
#else
BOOL fEfiEnabled = false;
#endif
if (!fEfiEnabled)
{
/*
* PC Bios.
*/
{
AssertMsgFailed (("Too many boot devices %d\n",
return VERR_INVALID_PARAMETER;
}
{
char szParamName[] = "BootDeviceX";
const char *pszBootDevice;
switch (bootDevice)
{
case DeviceType_Null:
pszBootDevice = "NONE";
break;
case DeviceType_HardDisk:
pszBootDevice = "IDE";
break;
case DeviceType_DVD:
pszBootDevice = "DVD";
break;
case DeviceType_Floppy:
pszBootDevice = "FLOPPY";
break;
case DeviceType_Network:
pszBootDevice = "LAN";
break;
default:
}
}
}
else
{
/*
* EFI.
*/
}
/*
* The time offset
*/
/*
* DMA
*/
/*
* PCI buses.
*/
#if 0 /* enable this to test PCI bridging */
#endif
/*
* Temporary hack for enabling the next three devices and various ACPI features.
*/
/*
* High Precision Event Timer (HPET)
*/
#ifdef VBOX_WITH_HPET
#else
fHpetEnabled = false;
#endif
if (fHpetEnabled)
{
}
/*
* System Management Controller (SMC)
*/
#ifdef VBOX_WITH_SMC
#else
fSmcEnabled = false;
#endif
if (fSmcEnabled)
{
}
/*
* Low Pin Count (LPC) bus
*/
/** @todo: implement appropriate getter */
#ifdef VBOX_WITH_LPC
#else
fLpcEnabled = false;
#endif
if (fLpcEnabled)
{
}
/*
* PS/2 keyboard & mouse.
*/
/*
* i82078 Floppy drive controller
*/
if (fFdcEnabled)
{
/* Attach the status driver */
if (floppyImage)
{
STR_CONV();
STR_FREE();
}
else
{
if (hostFloppyDrive)
{
STR_CONV();
STR_FREE();
}
else
{
}
}
}
/*
* ACPI
*/
if (fACPI)
{
/* Always show the CPU leafs when we have multiple VCPUs or when the IO-APIC is enabled.
* The Windows SMP kernel needs a CPU leaf or else its idle loop will burn cpu cycles; the
* intelppm driver refuses to register an idle state handler.
*/
fShowCpu = true;
#ifdef VBOX_WITH_HPET
#endif
#ifdef VBOX_WITH_SMC
#endif
afPciDeviceNo[7] = true;
}
/*
* i8254 Programmable Interval Timer And Dummy Speaker
*/
#ifdef DEBUG
#endif
/*
* i8259 Programmable Interrupt Controller.
*/
/*
* Advanced Programmable Interrupt Controller.
* SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
* thus only single insert
*/
if (fIOAPIC)
{
/*
* I/O Advanced Programmable Interrupt Controller.
*/
}
/*
* RTC MC146818.
*/
/*
* VGA.
*/
afPciDeviceNo[2] = true;
#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
#endif
/*
* BIOS logo
*/
/*
* Boot menu
*/
int value;
switch (bootMenuMode)
{
value = 0;
break;
value = 1;
break;
default:
value = 2;
}
/* Custom VESA mode list */
unsigned cModes = 0;
{
char szExtraDataKey[sizeof("CustomVideoModeXX")];
break;
STR_CONV();
STR_FREE();
cModes++;
}
/* VESA height reduction */
if (pFramebuffer)
{
}
else
{
/* If framebuffer is not available, there is no height reduction. */
ulHeightReduction = 0;
}
/* Attach the display. */
/*
* Storage controllers.
*/
{
bool fSCSI = false;
switch(enmCtrlType)
{
{
afPciDeviceNo[20] = true;
fSCSI = true;
/* Attach the status driver */
break;
}
{
afPciDeviceNo[21] = true;
fSCSI = true;
/* Attach the status driver */
break;
}
{
afPciDeviceNo[13] = true;
/* Needed configuration values for the bios. */
if (pBiosCfg)
{
}
for (uint32_t j = 0; j < 4; j++)
{
static const char *s_apszConfig[4] =
{ "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
static const char *s_apszBiosConfig[4] =
{ "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
if (pBiosCfg)
{
}
}
/* Attach the status driver */
break;
}
{
/*
* IDE (update this when the main interface changes)
*/
afPciDeviceNo[1] = true;
/* Attach the status driver */
/*
*/
if (dvdDrive)
{
// ASSUME: DVD drive is always attached to LUN#2 (i.e. secondary IDE master)
if (hostDvdDrive)
{
STR_CONV();
STR_FREE();
}
else
{
if (dvdImage)
{
STR_CONV();
STR_FREE();
}
}
}
break;
}
default:
AssertMsgFailed (("invalid storage controller type: "
"%d\n", enmCtrlType));
return VERR_GENERAL_FAILURE;
}
/* At the moment we only support one controller per type. So the instance id is always 0. */
/* Attach the hard disks. */
ComSafeArrayAsOutParam (atts)); H();
{
int iLUN = 0;
switch (enmBus)
{
case StorageBus_IDE:
{
{
AssertMsgFailed (("invalid controller channel number: "
"%d\n", lPort));
return VERR_GENERAL_FAILURE;
}
{
AssertMsgFailed (("invalid controller device number: "
"%d\n", lDev));
return VERR_GENERAL_FAILURE;
}
break;
}
case StorageBus_SATA:
case StorageBus_SCSI:
{
break;
}
default:
{
AssertMsgFailed (("invalid storage bus type: "
"%d\n", enmBus));
return VERR_GENERAL_FAILURE;
}
}
char szLUN[16];
/* SCSI has a another driver between device and block. */
if (fSCSI)
{
}
/* Pass all custom parameters. */
bool fHostIP = true;
ComSafeArrayAsOutParam (values)); H();
{
{
{
fHostIP = false;
}
}
}
/* Create an inversed tree of parents. */
{
hrc = parentHardDisk->
break;
/* Pass all custom parameters. */
ComSafeArrayAsOutParam (values));H();
{
{
{
fHostIP = false;
}
}
}
/* Custom code: put marker to not use host IP stack to driver
* configuration node. Simplifies life of DrvVD a bit. */
if (!fHostIP)
{
}
/* next */
}
}
H();
}
H();
/*
* Network adapters
*/
#ifdef VMWARE_NET_IN_SLOT_11
bool fSwapSlots3and11 = false;
#endif
#ifdef VBOX_WITH_E1000
#endif
{
if (!fEnabled)
continue;
/*
* The virtual hardware type. Create appropriate device first.
*/
const char *pszAdapterName = "pcnet";
switch (adapterType)
{
break;
#ifdef VBOX_WITH_E1000
pszAdapterName = "e1000";
break;
#endif
default:
AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
N_("Invalid network adapter type '%d' for slot '%d'"),
}
/* the first network card gets the PCI ID 3, the next 3 gets 8..10,
* next 4 get 16..19. */
unsigned iPciDeviceNo = 3;
if (ulInstance)
{
if (ulInstance < 4)
else
}
#ifdef VMWARE_NET_IN_SLOT_11
/*
* Dirty hack for PCI slot compatibility with VMWare,
* it assigns slot 11 to the first network controller.
*/
{
iPciDeviceNo = 0x11;
fSwapSlots3and11 = true;
}
iPciDeviceNo = 3;
#endif
afPciDeviceNo[iPciDeviceNo] = true;
#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
{
}
#endif
/*
* The virtual hardware type. PCNet supports two types.
*/
switch (adapterType)
{
break;
break;
break;
break;
break;
}
/*
* Get the MAC address and convert it to binary representation
*/
for (uint32_t i = 0; i < 6; i++)
{
if (c1 > 9)
c1 -= 7;
if (c2 > 9)
c2 -= 7;
}
/*
* Check if the cable is supposed to be unplugged
*/
/*
* Line speed to report from custom drivers
*/
/*
* Attach the status driver.
*/
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
/*
* Configure the network card now
*/
rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter, pCfg, pLunL0, pInst, false);
RC_CHECK();
}
/*
* Serial (UART) Ports
*/
{
if (serialPort)
if (!fEnabled)
continue;
if (HostMode != PortMode_Disconnected)
{
if (HostMode == PortMode_HostPipe)
{
}
else if (HostMode == PortMode_HostDevice)
{
}
else if (HostMode == PortMode_RawFile)
{
}
}
}
/*
* Parallel (LPT) Ports
*/
{
if (parallelPort)
if (!fEnabled)
continue;
}
/*
* VMM Device
*/
afPciDeviceNo[4] = true;
{
}
/* the VMM device's Main driver */
/*
* Attach the status driver.
*/
/*
* Audio Sniffer Device
*/
/* the Audio Sniffer device's Main driver */
/*
* AC'97 ICH / SoundBlaster16 audio
*/
if (audioAdapter)
if (enabled)
{
switch (audioController)
{
case AudioControllerType_AC97:
{
/* default: ICH AC97 */
afPciDeviceNo[5] = true;
break;
}
case AudioControllerType_SB16:
{
/* legacy SoundBlaster16 */
break;
}
}
/* the Audio driver */
switch (audioDriver)
{
case AudioDriverType_Null:
{
break;
}
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
case AudioDriverType_WinMM:
{
break;
}
#endif
{
break;
}
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_SOLARIS
case AudioDriverType_SolAudio:
{
break;
}
#endif
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
case AudioDriverType_ALSA:
{
break;
}
# endif
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
{
break;
}
# endif
#endif /* RT_OS_LINUX */
case AudioDriverType_OSS:
{
break;
}
#endif
#ifdef RT_OS_DARWIN
{
break;
}
#endif
}
STR_CONV();
STR_FREE();
}
/*
* The USB Controller.
*/
if (USBCtlPtr)
{
if (fEnabled)
{
afPciDeviceNo[6] = true;
/*
* Attach the status driver.
*/
#ifdef VBOX_WITH_EHCI
if (fEnabled)
{
afPciDeviceNo[11] = true;
/*
* Attach the status driver.
*/
}
else
#endif
{
/*
* Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
* on a per device level now.
*/
// This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
//rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
// The following breaks stuff, but it makes MSDs work in vista. (I include it here so
// that it's documented somewhere.) Users needing it can use:
// VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
//rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
}
}
}
/*
* Clipboard
*/
{
if (mode != ClipboardMode_Disabled)
{
/* Load the service */
if (RT_FAILURE (rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
/* Setup the service. */
switch (mode)
{
default:
case ClipboardMode_Disabled:
{
LogRel(("VBoxSharedClipboard mode: Off\n"));
break;
}
{
LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
break;
}
{
LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
break;
}
{
LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
break;
}
}
pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
Log(("Set VBoxSharedClipboard mode\n"));
}
}
}
#ifdef VBOX_WITH_CROGL
/* Currently broken on Snow Leopard 64-bit */
# if !(defined(RT_OS_DARWIN) && defined(RT_ARCH_AMD64))
/*
* crOpenGL
*/
{
if (fEnabled)
{
/* Load the service */
if (RT_FAILURE(rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
LogRel(("Shared crOpenGL service loaded.\n"));
/* Setup the service. */
//parm.u.pointer.addr = static_cast <IConsole *> (pData->pVMMDev->getParent());
rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_FRAMEBUFFER, 1, &parm);
if (!RT_SUCCESS(rc))
}
}
}
# endif
#endif
#ifdef VBOX_WITH_GUEST_PROPS
/*
* Guest property service
*/
try
{
/* Load the service */
if (RT_FAILURE (rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
/* Pull over the properties from the server. */
ComSafeArrayAsOutParam(flagsOut)); H();
)
)
{
}
{
}
timestamps.push_back(0);
/* Setup the service. */
/* Register the host notification callback */
Log(("Set VBoxGuestPropSvc property store\n"));
}
}
{
return VERR_NO_MEMORY;
}
#endif /* VBOX_WITH_GUEST_PROPS defined */
/*
* CFGM overlay handling.
*
* Here we check the extra data entries for CFGM values
* and create the nodes and insert the values on the fly. Existing
* values will be removed and reinserted. CFGM is typed, so by default
* we will guess whether it's a string or an integer (byte arrays are
* not currently supported). It's possible to override this autodetection
* by adding "string:", "integer:" or "bytes:" (future).
*
* We first perform a run on global extra data, then on the machine
* extra data to support global settings with local overrides.
*
*/
/** @todo add support for removing nodes and byte blobs. */
bool fGlobalExtraData = true;
for (;;)
{
/*
* Get the next key
*/
if (fGlobalExtraData)
else
/* stop if for some reason there's nothing more to request */
{
/* if we're out of global keys, continue with machine, otherwise we're done */
if (fGlobalExtraData)
{
fGlobalExtraData = false;
continue;
}
break;
}
/*
* We only care about keys starting with "VBoxInternal/"
*/
continue;
/*
* Split the two and get the node, delete the value and create the node
* if necessary.
*/
if (pszCFGMValueName)
{
/* terminate the node and advance to the value (Utf8Str might not
offically like this but wtf) */
*pszCFGMValueName = '\0';
/* does the node already exist? */
if (pNode)
else
{
/* create the node */
if (RT_FAILURE(rc))
{
continue;
}
}
}
else
{
/* root value (no node path). */
}
/*
* Now let's have a look at the value.
* Empty strings means that we should remove the value, which we've
* already done above.
*/
if ( pszCFGMValue
&& *pszCFGMValue)
{
/* check for type prefix first. */
{
if (RT_SUCCESS(rc))
}
/* auto detect type. */
else
AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
}
}
#undef H
/* Register VM state change handler */
if (RT_SUCCESS (rc))
/* Register VM runtime error handler */
if (RT_SUCCESS (rc))
return rc;
}
/**
* Construct the Network configuration tree
*
* @returns VBox status code.
*
* @param pThis Pointer to the Console object.
* @param pszDevice The PDM device name.
* @param uInstance The PDM device instance.
* @param uLun The PDM LUN number of the drive.
* @param aNetworkAdapter The network adapter whose attachment needs to be changed
*
* @note Locks the Console object for writing.
*/
{
int rc = VINF_SUCCESS;
int rcRet = VINF_SUCCESS;
/*
* Locking the object before doing VMR3* calls is quite safe here, since
* we're on EMT. Write lock is necessary because we indirectly modify the
* meAttachmentType member.
*/
#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0)
#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); return rc; } } while (0)
#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); return VERR_GENERAL_FAILURE; } } while (0)
do
{
H();
H();
/*
* Detach the device train for the current network attachment.
*/
if (attachDetach)
{
if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
/* nuke anything which might have been left behind. */
}
/*
* Enable the packet sniffer if requested.
*/
H();
if (fSniffer)
{
/* insert the sniffer filter driver. */
RC_CHECK();
RC_CHECK();
RC_CHECK();
H();
if (str) /* check convention for indicating default file. */
{
STR_CONV();
RC_CHECK();
STR_FREE();
}
}
H();
switch (eAttachmentType)
{
break;
{
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
RC_CHECK();
RC_CHECK();
/* Configure TFTP prefix and boot filename. */
H();
STR_CONV();
{
char *pszTFTPPrefix = NULL;
RC_CHECK();
}
STR_FREE();
H();
STR_CONV();
char *pszBootFile = NULL;
STR_FREE();
RC_CHECK();
H();
if (str)
{
STR_CONV();
{
RC_CHECK();
/* NAT uses its own DHCP implementation */
//networkName = Bstr(psz);
}
STR_FREE();
}
break;
}
{
#if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
{
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
RC_CHECK();
RC_CHECK();
RC_CHECK();
}
#elif defined(VBOX_WITH_NETFLT)
/*
* This is the new VBoxNetFlt+IntNet stuff.
*/
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
{
H();
}
# if defined(RT_OS_DARWIN)
/* The name is on the form 'ifX: long name', chop it off at the colon. */
char szTrunk[8];
if (!pszColon)
{
H();
N_("Malformed host interface networking name '%ls'"),
}
*pszColon = '\0';
# elif defined(RT_OS_SOLARIS)
/* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
char szTrunk[256];
/*
* Currently don't bother about malformed names here for the sake of people using
* VBoxManage and setting only the NIC name from there. If there is a space we
* chop it off and proceed, otherwise just use whatever we've got.
*/
if (pszSpace)
*pszSpace = '\0';
/* Chop it off at the colon (zone naming eg: e1000g:1 we need only the e1000g) */
if (pszColon)
*pszColon = '\0';
# elif defined(RT_OS_WINDOWS)
{
N_("Inexistent host networking interface, name '%ls'"),
}
{
H();
}
{
N_("Interface ('%ls') is not a Bridged Adapter interface"),
}
{
H();
}
int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
L"VirtualBox",
&pNc,
&lpszApp );
{
/* get the adapter's INetCfgComponent*/
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
{
H();
}
}
#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
char szTrunkName[INTNET_MAX_TRUNK_NAME];
char *pszTrunkName = szTrunkName;
wchar_t * pswzBindName;
{
int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
{
{
Assert(0);
}
}
else
{
Assert(0);
LogRel(("NetworkAttachmentType_Bridged: insufficient szTrunkName buffer space\n"));
/** @todo set appropriate error code */
}
{
Assert(0);
H();
}
/* we're not freeing the bind name since we'll use it later for detecting wireless*/
}
else
{
Assert(0);
H();
}
const char *pszTrunk = szTrunkName;
/* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
# elif defined(RT_OS_LINUX)
/* @todo Check for malformed names. */
const char *pszTrunk = pszHifName;
# else
# error "PORTME (VBOX_WITH_NETFLT)"
# endif
RC_CHECK();
RC_CHECK();
RC_CHECK();
RC_CHECK();
char szNetwork[80];
RC_CHECK();
# if defined(RT_OS_DARWIN)
/** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
{
RC_CHECK();
}
# elif defined(RT_OS_LINUX)
if (iSock >= 0)
{
{
RC_CHECK();
Log(("Set SharedMacOnWire\n"));
}
else
{
Log(("Failed to get wireless name\n"));
}
}
else
{
Log(("Failed to open wireless socket\n"));
}
# elif defined(RT_OS_WINDOWS)
# define DEVNAME_PREFIX L"\\\\.\\"
/* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control
* there is a pretty long way till there though since we need to obtain the symbolic link name
* for the adapter device we are going to query given the device Guid */
/* prepend the "\\\\.\\" to the bind name to obtain the link name */
/* open the device */
NULL,
NULL);
if (hDevice != INVALID_HANDLE_VALUE)
{
/* now issue the OID_GEN_PHYSICAL_MEDIUM query */
if (DeviceIoControl(hDevice,
&Oid,
sizeof(Oid),
&PhMedium,
sizeof(PhMedium),
&cbResult,
NULL))
{
/* that was simple, now examine PhMedium */
{
Log(("this is a wireless adapter"));
RC_CHECK();
Log(("Set SharedMacOnWire\n"));
}
else
{
Log(("this is NOT a wireless adapter"));
}
}
else
{
int winEr = GetLastError();
Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
}
}
else
{
int winEr = GetLastError();
}
/* release the pNc finally */
# else
/** @todo PORTME: wireless detection */
# endif
# if defined(RT_OS_SOLARIS)
# if 0 /* bird: this is a bit questionable and might cause more trouble than its worth. */
/* Zone access restriction, don't allow snopping the global zone. */
if (ZoneId != GLOBAL_ZONEID)
{
}
# endif
# endif
/* NOTHING TO DO HERE */
#elif defined(RT_OS_LINUX)
/// @todo aleksey: is there anything to be done here?
#elif defined(RT_OS_FREEBSD)
/** @todo FreeBSD: Check out this later (HIF networking). */
#else
# error "Port me"
#endif
break;
}
{
H();
if (str)
{
STR_CONV();
{
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
RC_CHECK();
RC_CHECK();
RC_CHECK();
RC_CHECK();
}
STR_FREE();
}
break;
}
{
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
RC_CHECK();
RC_CHECK();
#if defined(RT_OS_WINDOWS)
# ifndef VBOX_WITH_NETFLT
LogRel(("NetworkAttachmentType_HostOnly: Not Implemented"));
H();
# else
{
H();
}
{
N_("Inexistent host networking interface, name '%ls'"),
}
{
H();
}
{
N_("Interface ('%ls') is not a Host-Only Adapter interface"),
}
{
H();
}
int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
L"VirtualBox",
&pNc,
&lpszApp);
{
/* get the adapter's INetCfgComponent*/
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
{
LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
H();
}
}
#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
char szTrunkName[INTNET_MAX_TRUNK_NAME];
char *pszTrunkName = szTrunkName;
wchar_t * pswzBindName;
{
int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
{
{
Assert(0);
LogRel(("NetworkAttachmentType_HostOnly: WideCharToMultiByte failed, hr=%Rhrc (0x%x)\n", hrc, hrc));
}
}
else
{
Assert(0);
LogRel(("NetworkAttachmentType_HostOnly: insufficient szTrunkName buffer space\n"));
/** @todo set appropriate error code */
}
{
Assert(0);
H();
}
}
else
{
Assert(0);
LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
H();
}
/* release the pNc finally */
const char *pszTrunk = szTrunkName;
/* TODO: set the proper Trunk and Network values, currently the driver uses the first adapter instance */
RC_CHECK();
RC_CHECK();
char szNetwork[80];
RC_CHECK();
# endif /* defined VBOX_WITH_NETFLT*/
#elif defined(RT_OS_DARWIN)
RC_CHECK();
RC_CHECK();
RC_CHECK();
#else
RC_CHECK();
RC_CHECK();
RC_CHECK();
#endif
#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
{
H();
}
{
N_("Inexistent host networking interface, name '%ls'"),
}
{
else
}
else
#endif
break;
}
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
/*
* Attempt to attach the driver.
*/
switch (eAttachmentType)
{
break;
{
{
if (attachDetach)
{
}
{
/** @todo r=pritesh: get the dhcp server name from the
* previous network configuration and then stop the server
* else it may conflict with the dhcp server running with
* the current attachment type
*/
/* Stop the hostonly DHCP Server */
}
if(!networkName.isNull())
{
/*
* Until we implement service reference counters DHCP Server will be stopped
* by DHCPServerRunner destructor.
*/
{
/* there is a DHCP server available for this network */
{
H();
}
if(bEnabled)
}
else
{
}
}
}
break;
}
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
}
while (0);
#undef H
return rcRet;
}
/* vi: set tabstop=4 shiftwidth=4 expandtab: */