Changeset 60845 in vbox for trunk/src/VBox
- Timestamp:
- May 4, 2016 10:19:12 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r57416 r60845 836 836 837 837 838 /* 839 * Bind outgoing connections to the specified IP. 840 */ 841 com::Bstr bstrSourceIpX; 842 843 /* IPv4 */ 838 844 com::Bstr bstrSourceIp4Key = com::BstrFmt("NAT/%s/SourceIp4", networkName.c_str()); 839 com::Bstr bstrSourceIpX;840 845 hrc = virtualbox->GetExtraData(bstrSourceIp4Key.raw(), bstrSourceIpX.asOutParam()); 841 if (SUCCEEDED(hrc) )846 if (SUCCEEDED(hrc) && bstrSourceIpX.isNotEmpty()) 842 847 { 843 848 RTNETADDRIPV4 addr; … … 845 850 if (RT_SUCCESS(rc)) 846 851 { 847 RT_ZERO(m_src4);848 849 852 m_src4.sin_addr.s_addr = addr.u; 850 853 m_ProxyOptions.src4 = &m_src4; 851 854 852 bstrSourceIpX.setNull(); 853 } 854 } 855 LogRel(("Will use %RTnaipv4 as IPv4 source address\n", 856 m_src4.sin_addr.s_addr)); 857 } 858 else 859 { 860 LogRel(("Failed to parse \"%s\" IPv4 source address specification\n", 861 com::Utf8Str(bstrSourceIpX).c_str())); 862 } 863 864 bstrSourceIpX.setNull(); 865 } 866 867 /* IPv6 */ 868 com::Bstr bstrSourceIp6Key = com::BstrFmt("NAT/%s/SourceIp6", networkName.c_str()); 869 hrc = virtualbox->GetExtraData(bstrSourceIp6Key.raw(), bstrSourceIpX.asOutParam()); 870 if (SUCCEEDED(hrc) && bstrSourceIpX.isNotEmpty()) 871 { 872 RTNETADDRIPV6 addr; 873 char *pszZone = NULL; 874 rc = RTNetStrToIPv6Addr(com::Utf8Str(bstrSourceIpX).c_str(), &addr, &pszZone); 875 if (RT_SUCCESS(rc)) 876 { 877 memcpy(&m_src6.sin6_addr, &addr, sizeof(addr)); 878 m_ProxyOptions.src6 = &m_src6; 879 880 LogRel(("Will use %RTnaipv6 as IPv6 source address\n", 881 &m_src6.sin6_addr)); 882 } 883 else 884 { 885 LogRel(("Failed to parse \"%s\" IPv6 source address specification\n", 886 com::Utf8Str(bstrSourceIpX).c_str())); 887 } 888 889 bstrSourceIpX.setNull(); 890 } 891 855 892 856 893 if (!fDontLoadRulesOnStartup)
Note:
See TracChangeset
for help on using the changeset viewer.