Changeset 22375 in vbox
- Timestamp:
- Aug 20, 2009 1:42:49 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp
r22277 r22375 277 277 278 278 /** 279 * Detach a driver instance. 280 * 281 * @param pDrvIns The driver instance. 282 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines. 283 */ 284 static DECLCALLBACK(void) drvNetSnifferDetach(PPDMDRVINS pDrvIns, uint32_t fFlags) 285 { 286 PDRVNETSNIFFER pThis = PDMINS_2_DATA(pDrvIns, PDRVNETSNIFFER); 287 288 LogFlow(("drvNetSnifferDetach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags)); 289 290 pThis->pConnector = NULL; 291 pThis->pPort = NULL; 292 pThis->pConfig = NULL; 293 } 294 295 296 /** 297 * Attach a driver instance. 298 * 299 * @returns VBox status code. 300 * @param pDrvIns The driver instance. 301 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines. 302 */ 303 static DECLCALLBACK(int) drvNetSnifferAttach(PPDMDRVINS pDrvIns, uint32_t fFlags) 304 { 305 PDRVNETSNIFFER pThis = PDMINS_2_DATA(pDrvIns, PDRVNETSNIFFER); 306 307 LogFlow(("drvNetSnifferAttach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags)); 308 309 /* 310 * Query the network port interface. 311 */ 312 pThis->pPort = (PPDMINETWORKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_PORT); 313 if (!pThis->pPort) 314 { 315 AssertMsgFailed(("Configuration error: the above device/driver didn't export the network port interface!\n")); 316 return VERR_PDM_MISSING_INTERFACE_ABOVE; 317 } 318 319 /* 320 * Query the network config interface. 321 */ 322 pThis->pConfig = (PPDMINETWORKCONFIG)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_CONFIG); 323 if (!pThis->pConfig) 324 { 325 AssertMsgFailed(("Configuration error: the above device/driver didn't export the network config interface!\n")); 326 return VERR_PDM_MISSING_INTERFACE_ABOVE; 327 } 328 329 /* 330 * Query the network connector interface. 331 */ 332 PPDMIBASE pBaseDown; 333 int rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pBaseDown); 334 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 335 pThis->pConnector = NULL; 336 else if (RT_SUCCESS(rc)) 337 { 338 pThis->pConnector = (PPDMINETWORKCONNECTOR)pBaseDown->pfnQueryInterface(pBaseDown, PDMINTERFACE_NETWORK_CONNECTOR); 339 if (!pThis->pConnector) 340 { 341 AssertMsgFailed(("Configuration error: the driver below didn't export the network connector interface!\n")); 342 return VERR_PDM_MISSING_INTERFACE_BELOW; 343 } 344 } 345 else 346 { 347 AssertMsgFailed(("Failed to attach to driver below! rc=%Rrc\n", rc)); 348 return rc; 349 } 350 351 return VINF_SUCCESS; 352 } 353 354 355 /** 279 356 * Destruct a driver instance. 280 357 * … … 454 531 NULL, 455 532 /* pfnAttach */ 456 NULL,533 drvNetSnifferAttach, 457 534 /* pfnDetach */ 458 NULL,535 drvNetSnifferDetach, 459 536 /* pfnPowerOff */ 460 NULL, 537 NULL, 461 538 /* pfnSoftReset */ 462 539 NULL, -
trunk/src/VBox/Main/ConsoleImpl.cpp
r22338 r22375 3290 3290 3291 3291 /* Get the properties we need from the adapter */ 3292 BOOL fCableConnected ;3292 BOOL fCableConnected, fTraceEnabled; 3293 3293 HRESULT rc = aNetworkAdapter->COMGETTER(CableConnected) (&fCableConnected); 3294 3294 AssertComRC(rc); 3295 if (SUCCEEDED(rc)) 3296 { 3297 rc = aNetworkAdapter->COMGETTER(TraceEnabled) (&fTraceEnabled); 3298 AssertComRC(rc); 3299 } 3295 3300 if (SUCCEEDED(rc)) 3296 3301 { … … 3336 3341 ComAssertRC(vrc); 3337 3342 } 3343 #ifdef VBOX_DYNAMIC_NET_ATTACH 3344 if (RT_SUCCESS(vrc) && changeAdapter) 3345 { 3346 VMSTATE enmVMState = VMR3GetState(mpVM); 3347 3348 if ( enmVMState == VMSTATE_RUNNING 3349 || enmVMState == VMSTATE_SUSPENDED) 3350 { 3351 if (fTraceEnabled && fCableConnected && pINetCfg) 3352 { 3353 vrc = pINetCfg->pfnSetLinkState (pINetCfg, PDMNETWORKLINKSTATE_DOWN); 3354 ComAssertRC(vrc); 3355 } 3356 3357 rc = doNetworkAdapterChange(pszAdapterName, ulInstance, 0, aNetworkAdapter); 3358 3359 if (fTraceEnabled && fCableConnected && pINetCfg) 3360 { 3361 vrc = pINetCfg->pfnSetLinkState (pINetCfg, PDMNETWORKLINKSTATE_UP); 3362 ComAssertRC(vrc); 3363 } 3364 } 3365 } 3366 #endif /* VBOX_DYNAMIC_NET_ATTACH */ 3338 3367 } 3339 3340 #ifdef VBOX_DYNAMIC_NET_ATTACH3341 if (RT_SUCCESS(vrc) && changeAdapter)3342 {3343 VMSTATE enmVMState = VMR3GetState(mpVM);3344 if ( enmVMState == VMSTATE_RUNNING3345 || enmVMState == VMSTATE_SUSPENDED)3346 rc = doNetworkAdapterChange(pszAdapterName, ulInstance, 0, aNetworkAdapter);3347 }3348 #endif /* VBOX_DYNAMIC_NET_ATTACH */3349 3368 3350 3369 if (VBOX_FAILURE (vrc)) … … 7624 7643 }; 7625 7644 7645 /** 7646 * Initializing the attachment type for the network adapters 7647 */ 7648 NetworkAttachmentType_T Console::meAttachmentType[] = {}; 7649 7626 7650 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r22345 r22375 2117 2117 H(); 2118 2118 2119 /* 2120 * Detach the device train for the current network attachment. 2121 */ 2122 if (fAttachDetach) 2119 BOOL fSniffer; 2120 hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer); 2121 H(); 2122 2123 if (fAttachDetach && fSniffer) 2124 { 2125 const char *pszNetDriver = "IntNet"; 2126 if (meAttachmentType[uInstance] == NetworkAttachmentType_NAT) 2127 pszNetDriver = "NAT"; 2128 #if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX) 2129 if (meAttachmentType[uInstance] == NetworkAttachmentType_Bridged) 2130 pszNetDriver = "HostInterface"; 2131 #endif 2132 2133 rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/); 2134 if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2135 rc = VINF_SUCCESS; 2136 AssertLogRelRCReturn(rc, rc); 2137 2138 pLunL0 = CFGMR3GetChildF(pInst, "LUN#%u", uLun); 2139 CFGMR3RemoveNode(CFGMR3GetChildF(pLunL0, "AttachedDriver")); 2140 } 2141 else if (fAttachDetach && !fSniffer) 2123 2142 { 2124 2143 rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/); … … 2130 2149 CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", uLun)); 2131 2150 } 2132 2133 /* 2134 * Enable the packet sniffer if requested. 2135 */ 2136 BOOL fSniffer; 2137 hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer); 2138 H(); 2139 if (fSniffer) 2151 else if (!fAttachDetach && fSniffer) 2140 2152 { 2141 2153 /* insert the sniffer filter driver. */ … … 2770 2782 if (fAttachDetach) 2771 2783 { 2772 rc = PDMR3D eviceAttach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /*ppBase*/);2784 rc = PDMR3DriverAttach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */); 2773 2785 AssertRC(rc); 2774 2786 } … … 2818 2830 } 2819 2831 2832 meAttachmentType[uInstance] = eAttachmentType; 2833 2820 2834 #undef STR_FREE 2821 2835 #undef H -
trunk/src/VBox/Main/include/ConsoleImpl.h
r22338 r22375 557 557 DriveState_T meFloppyState; 558 558 559 /** The current network attachment type in the VM. 560 * This doesn't have to match the network attachment type 561 * maintained in the NetworkAdapter. This is needed to 562 * change the network attachment dynamically. 563 */ 564 static NetworkAttachmentType_T meAttachmentType[SchemaDefs::NetworkAdapterCount]; 565 559 566 VMMDev * const mVMMDev; 560 567 AudioSniffer * const mAudioSniffer;
Note:
See TracChangeset
for help on using the changeset viewer.