VirtualBox

Changeset 48372 in vbox


Ignore:
Timestamp:
Sep 7, 2013 2:28:41 AM (11 years ago)
Author:
vboxsync
Message:

VBoxNetNAT: binding to specific interface (IPv4).
Address to interface is taken from extradata: NAT/<network-name>/SourceIp4

e.g.
# VBoxManage setextradata global "NAT/win-nat-test-0/SourceIp4" 192.168.1.185

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r48365 r48372  
    842842    AssertComRCReturn(hrc, VERR_INTERNAL_ERROR);       
    843843#endif
     844
     845    com::Bstr bstrSourceIp4Key = com::BstrFmt("NAT/%s/SourceIp4",m_Network.c_str());
     846    com::Bstr bstrSourceIpX;
     847    RTNETADDRIPV4 addr;
     848    hrc = virtualbox->GetExtraData(bstrSourceIp4Key.raw(), bstrSourceIpX.asOutParam());
     849    if (SUCCEEDED(hrc))
     850    {
     851        int rc = RTNetStrToIPv4Addr(com::Utf8Str(bstrSourceIpX).c_str(), &addr);
     852        if (RT_SUCCESS(rc))
     853        {
     854            RT_ZERO(m_src4);
     855
     856            m_src4.sin_addr.s_addr = addr.u;
     857            m_ProxyOptions.src4 = &m_src4;
     858           
     859            bstrSourceIpX.setNull();
     860        }
     861    }
     862   
    844863    if (!fDontLoadRulesOnStartup)
    845864    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette