- Timestamp:
- Sep 26, 2013 1:44:36 PM (11 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r42825 r48710 155 155 HRESULT updateMacAddress(Utf8Str aMacAddress); 156 156 void updateBandwidthGroup(BandwidthGroup *aBwGroup); 157 HRESULT checkAndSwitchFromNatNetworking(); 158 HRESULT switchToNatNetworking(IN_BSTR aNatNetworkName); 157 159 158 160 Machine * const mParent; -
trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp
r48538 r48710 24 24 #include "HostImpl.h" 25 25 #include "SystemPropertiesImpl.h" 26 #include "VirtualBoxImpl.h" 26 27 27 28 #include <iprt/string.h> … … 542 543 } 543 544 545 alock.release(); 546 547 HRESULT hrc = checkAndSwitchFromNatNetworking(); 548 if (FAILED(hrc)) 549 return hrc; 550 551 alock.acquire(); 552 544 553 mData.backup(); 545 554 mData->mBridgedInterface = aBridgedInterface; … … 602 611 } 603 612 613 alock.release(); 614 615 HRESULT hrc = checkAndSwitchFromNatNetworking(); 616 if (FAILED(hrc)) 617 return hrc; 618 619 alock.acquire(); 620 604 621 mData.backup(); 605 622 mData->mHostOnlyInterface = aHostOnlyInterface; … … 658 675 } 659 676 677 alock.release(); 678 679 HRESULT hrc = checkAndSwitchFromNatNetworking(); 680 if (FAILED(hrc)) 681 return hrc; 682 683 alock.acquire(); 684 660 685 mData.backup(); 661 686 mData->mInternalNetwork = aInternalNetwork; … … 709 734 if (mData->mNATNetwork != aNATNetwork) 710 735 { 736 737 HRESULT hrc; 711 738 /* if an empty/null string is to be set, host only interface must be 712 739 * turned off */ … … 719 746 720 747 mData.backup(); 748 749 alock.release(); 750 751 hrc = checkAndSwitchFromNatNetworking(); 752 if (FAILED(hrc)) 753 return hrc; 754 755 hrc = switchToNatNetworking(aNATNetwork); 756 if (FAILED(hrc)) 757 return hrc; 758 759 alock.acquire(); 760 721 761 mData->mNATNetwork = aNATNetwork; 722 762 … … 1550 1590 LogFlowThisFuncLeave(); 1551 1591 } 1592 1593 1594 HRESULT NetworkAdapter::checkAndSwitchFromNatNetworking() 1595 { 1596 HRESULT hrc; 1597 MachineState_T state; 1598 1599 hrc = mParent->COMGETTER(State)(&state); 1600 if (FAILED(hrc)) 1601 return hrc; 1602 1603 if ( mData->mAttachmentType == NetworkAttachmentType_NATNetwork 1604 && state == MachineState_Running) 1605 { 1606 int natCount; 1607 1608 natCount = mParent->getVirtualBox()->natNetworkRefDec(mData->mNATNetwork.raw()); 1609 if (natCount == -1) 1610 return E_INVALIDARG; /* no such network */ 1611 } 1612 1613 return S_OK; 1614 } 1615 1616 1617 HRESULT NetworkAdapter::switchToNatNetworking(IN_BSTR aNatNetworkName) 1618 { 1619 HRESULT hrc; 1620 MachineState_T state; 1621 1622 hrc = mParent->COMGETTER(State)(&state); 1623 if (FAILED(hrc)) 1624 return hrc; 1625 1626 if (state == MachineState_Running) 1627 { 1628 int natCount; 1629 1630 natCount = mParent->getVirtualBox()->natNetworkRefInc(aNatNetworkName); 1631 if (natCount == -1) 1632 return E_INVALIDARG; /* not found */ 1633 } 1634 1635 return S_OK; 1636 } 1552 1637 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.