- Timestamp:
- Sep 28, 2021 5:01:52 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvVMNet.m
r91418 r91438 63 63 * Structures and Typedefs * 64 64 *********************************************************************************************************************************/ 65 /** 66 * VMNET driver states. 67 */ 68 typedef enum VMNETSTATE 69 { 70 /** The driver is suspended. */ 71 VMNETSTATE_SUSPENDED = 1, 72 /** The driver is running. */ 73 VMNETSTATE_RUNNING, 74 /** The usual 32-bit type blowup. */ 75 VMNETSTATE_32BIT_HACK = 0x7fffffff 76 } VMNETSTATE; 77 65 78 /** 66 79 * VMNET driver instance data. … … 89 102 /** The operation mode: bridged or host. */ 90 103 uint32_t uMode; 104 /** The operational state: suspended or running. */ 105 VMNETSTATE volatile enmState; 91 106 /** The host interface name for bridge mode. */ 92 107 char szHostInterface[VMNET_MAX_HOST_INTERFACE_NAME_LENGTH]; … … 180 195 static int drvVMNetReceive(PDRVVMNET pThis, const uint8_t *pbFrame, uint32_t cbFrame) 181 196 { 197 if (pThis->enmState != VMNETSTATE_RUNNING) 198 { 199 Log(("drvVMNetReceive: Ignoring incoming packet (%d bytes) in suspended state\n", cbFrame)); 200 return VINF_SUCCESS; 201 } 202 182 203 Log(("drvVMNetReceive: Incoming packet: %RTmac <= %RTmac (%d bytes)\n", pbFrame, pbFrame + 6, cbFrame)); 183 204 Log2(("%.*Rhxd\n", cbFrame, pbFrame)); … … 190 211 static int drvVMNetSend(PDRVVMNET pThis, const uint8_t *pbFrame, uint32_t cbFrame) 191 212 { 213 if (pThis->enmState != VMNETSTATE_RUNNING) 214 { 215 Log(("drvVMNetReceive: Ignoring outgoing packet (%d bytes) in suspended state\n", cbFrame)); 216 return VINF_SUCCESS; 217 } 218 192 219 Log(("drvVMNetSend: Outgoing packet (%d bytes)\n", cbFrame)); 193 220 Log2(("%.*Rhxd\n", cbFrame, pbFrame)); … … 346 373 Log(("drvVMNetAttachBridged: Failed to convert '%s' to MAC address (%Rrc)\n", pcszMacAddress ? pcszMacAddress : "(null)", rc)); 347 374 #endif 375 #ifdef LOG_ENABLED 348 376 max_packet_size = xpc_dictionary_get_uint64(interface_param, vmnet_max_packet_size_key); 349 377 // Log(("MAC address: %s\n", xpc_dictionary_get_string(interface_param, vmnet_mac_address_key))); … … 352 380 Log(("Avaliable keys:\n")); 353 381 xpc_dictionary_apply(interface_param, ^bool(const char * _Nonnull key, xpc_object_t _Nonnull value) { 354 Log(("%s=%s\n", key, value)); 382 RT_NOREF(value); 383 Log(("%s\n", key)); 355 384 return true; 356 385 }); 386 #endif /* LOG_ENABLED */ 357 387 } 358 388 dispatch_semaphore_signal(operation_done); … … 408 438 { 409 439 if (pThis->Interface) 440 { 410 441 vmnet_stop_interface(pThis->Interface, pThis->InterfaceQueue, ^(vmnet_return_t status){ 411 442 Log(("VMNET interface has been stopped. Status = %d.\n", status)); 412 443 }); 444 pThis->Interface = 0; 445 } 413 446 if (pThis->InterfaceQueue) 447 { 414 448 dispatch_release(pThis->InterfaceQueue); 449 pThis->InterfaceQueue = 0; 450 } 415 451 416 452 return 0; … … 458 494 pThis->INetworkUp.pfnSetPromiscuousMode = drvVMNetUp_SetPromiscuousMode; 459 495 pThis->INetworkUp.pfnNotifyLinkChanged = drvVMNetUp_NotifyLinkChanged; 496 497 /* Initialize the state. */ 498 pThis->enmState = VMNETSTATE_SUSPENDED; 460 499 461 500 /* … … 588 627 589 628 return VINF_SUCCESS; 629 } 630 631 632 /** 633 * Power On notification. 634 * 635 * @param pDrvIns The driver instance. 636 */ 637 static DECLCALLBACK(void) drvVMNetPowerOn(PPDMDRVINS pDrvIns) 638 { 639 LogFlow(("drvVMNetPowerOn\n")); 640 PDRVVMNET pThis = PDMINS_2_DATA(pDrvIns, PDRVVMNET); 641 ASMAtomicXchgSize(&pThis->enmState, VMNETSTATE_RUNNING); 642 } 643 644 645 /** 646 * Suspend notification. 647 * 648 * @param pDrvIns The driver instance. 649 */ 650 static DECLCALLBACK(void) drvVMNetSuspend(PPDMDRVINS pDrvIns) 651 { 652 LogFlow(("drvVMNetSuspend\n")); 653 PDRVVMNET pThis = PDMINS_2_DATA(pDrvIns, PDRVVMNET); 654 ASMAtomicXchgSize(&pThis->enmState, VMNETSTATE_SUSPENDED); 655 } 656 657 658 /** 659 * Resume notification. 660 * 661 * @param pDrvIns The driver instance. 662 */ 663 static DECLCALLBACK(void) drvVMNetResume(PPDMDRVINS pDrvIns) 664 { 665 LogFlow(("drvVMNetResume\n")); 666 PDRVVMNET pThis = PDMINS_2_DATA(pDrvIns, PDRVVMNET); 667 ASMAtomicXchgSize(&pThis->enmState, VMNETSTATE_RUNNING); 590 668 } 591 669 … … 624 702 NULL, 625 703 /* pfnPowerOn */ 626 NULL,704 drvVMNetPowerOn, 627 705 /* pfnReset */ 628 706 NULL, 629 707 /* pfnSuspend */ 630 NULL,708 drvVMNetSuspend, 631 709 /* pfnResume */ 632 NULL,710 drvVMNetResume, 633 711 /* pfnAttach */ 634 712 NULL,
Note:
See TracChangeset
for help on using the changeset viewer.