Changeset 20716 in vbox
- Timestamp:
- Jun 19, 2009 12:00:41 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48829
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r20714 r20716 43 43 # include <fcntl.h> 44 44 # include <poll.h> 45 # endif46 # include <errno.h>45 # include <errno.h> 46 #endif 47 47 #include <iprt/semaphore.h> 48 48 #include <iprt/req.h> … … 140 140 } 141 141 142 142 143 /** 143 144 * Send data to the network. … … 218 219 } 219 220 221 220 222 /** 221 223 * Worker function for drvNATNotifyLinkChanged(). … … 243 245 } 244 246 } 247 245 248 246 249 /** … … 418 421 } 419 422 420 /** 421 * Unblock the send thread so it can respond to a state change. 422 * 423 * @returns VBox status code. 424 * @param pDevIns The pcnet device instance. 425 * @param pThread The send thread. 423 424 /** 425 * Unblock the send thread so it can respond to a state change. 426 * 427 * @returns VBox status code. 428 * @param pDevIns The pcnet device instance. 429 * @param pThread The send thread. 426 430 */ 427 431 static DECLCALLBACK(int) drvNATAsyncIoWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) … … 442 446 443 447 #ifdef VBOX_WITH_SLIRP_MT 448 444 449 static DECLCALLBACK(int) drvNATAsyncIoGuest(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 445 450 { … … 454 459 } 455 460 461 456 462 static DECLCALLBACK(int) drvNATAsyncIoGuestWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 457 463 { … … 460 466 return VINF_SUCCESS; 461 467 } 468 462 469 #endif /* VBOX_WITH_SLIRP_MT */ 463 464 470 465 471 /** … … 513 519 RTMemFree((void *)pu8Buf); 514 520 } 521 515 522 516 523 /** … … 551 558 } 552 559 560 553 561 /** 554 562 * Queries an interface to the driver. … … 577 585 578 586 /** 579 * Destruct a driver instance. 580 * 581 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 582 * resources can be freed correctly. 583 * 584 * @param pDrvIns The driver instance data. 585 */ 586 static DECLCALLBACK(void) drvNATDestruct(PPDMDRVINS pDrvIns) 587 * Get the MAC address into the slirp stack. 588 * 589 * Called by drvNATLoadDone and drvNATPowerOn. 590 */ 591 static void drvNATSetMac(PDRVNAT pThis) 592 { 593 if (pThis->pConfig) 594 { 595 RTMAC Mac; 596 pThis->pConfig->pfnGetMac(pThis->pConfig, &Mac); 597 slirp_set_ethaddr(pThis->pNATState, Mac.au8); 598 } 599 } 600 601 602 /** 603 * After loading we have to pass the MAC address of the ethernet device to the slirp stack. 604 * Otherwise the guest is not reachable until it performs a DHCP request or an ARP request 605 * (usually done during guest boot). 606 */ 607 static DECLCALLBACK(int) drvNATLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSMHandle) 587 608 { 588 609 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 589 590 LogFlow(("drvNATDestruct:\n")); 591 592 slirp_term(pThis->pNATState); 593 slirp_deregister_statistics(pThis->pNATState, pDrvIns); 594 pThis->pNATState = NULL; 595 #ifdef VBOX_WITH_STATISTICS 596 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktSent); 597 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktDropped); 598 #endif 610 drvNATSetMac(pThis); 611 return VINF_SUCCESS; 612 } 613 614 615 /** 616 * Some guests might not use DHCP to retrieve an IP but use a static IP. 617 */ 618 static DECLCALLBACK(void) drvNATPowerOn(PPDMDRVINS pDrvIns) 619 { 620 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 621 drvNATSetMac(pThis); 599 622 } 600 623 … … 680 703 } 681 704 682 /** 683 * Get the MAC address into the slirp stack. 684 */ 685 static void drvNATSetMac(PDRVNAT pThis) 686 { 687 if (pThis->pConfig) 688 { 689 RTMAC Mac; 690 pThis->pConfig->pfnGetMac(pThis->pConfig, &Mac); 691 slirp_set_ethaddr(pThis->pNATState, Mac.au8); 692 } 693 } 694 695 696 /** 697 * After loading we have to pass the MAC address of the ethernet device to the slirp stack. 698 * Otherwise the guest is not reachable until it performs a DHCP request or an ARP request 699 * (usually done during guest boot). 700 */ 701 static DECLCALLBACK(int) drvNATLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSMHandle) 705 706 /** 707 * Destruct a driver instance. 708 * 709 * Most VM resources are freed by the VM. This callback is provided so that any non-VM 710 * resources can be freed correctly. 711 * 712 * @param pDrvIns The driver instance data. 713 */ 714 static DECLCALLBACK(void) drvNATDestruct(PPDMDRVINS pDrvIns) 702 715 { 703 716 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 704 drvNATSetMac(pThis); 705 return VINF_SUCCESS; 706 } 707 708 709 /** 710 * Some guests might not use DHCP to retrieve an IP but use a static IP. 711 */ 712 static DECLCALLBACK(void) drvNATPowerOn(PPDMDRVINS pDrvIns) 713 { 714 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 715 drvNATSetMac(pThis); 717 718 LogFlow(("drvNATDestruct:\n")); 719 720 slirp_term(pThis->pNATState); 721 slirp_deregister_statistics(pThis->pNATState, pDrvIns); 722 pThis->pNATState = NULL; 723 #ifdef VBOX_WITH_STATISTICS 724 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktSent); 725 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktDropped); 726 #endif 716 727 } 717 728 … … 955 966 NULL 956 967 }; 968
Note:
See TracChangeset
for help on using the changeset viewer.