Changeset 87617 in vbox for trunk/src/VBox/NetworkServices/NAT
- Timestamp:
- Feb 5, 2021 12:33:52 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r87616 r87617 179 179 int eventsInit(); 180 180 181 int getExtraData(com::Utf8Str &strValueOut, const char *pcszKey); 182 181 183 static void reportError(const char *a_pcszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 182 184 … … 379 381 * IPv4 source address, if configured. 380 382 */ 381 com::Bstr bstrSourceIp4; 382 com::Bstr bstrSourceIp4Key = com::BstrFmt("NAT/%s/SourceIp4", networkName.c_str()); 383 hrc = virtualbox->GetExtraData(bstrSourceIp4Key.raw(), bstrSourceIp4.asOutParam()); 384 if (SUCCEEDED(hrc) && bstrSourceIp4.isNotEmpty()) 383 com::Utf8Str strSourceIp4; 384 rc = getExtraData(strSourceIp4, "SourceIp4"); 385 if (RT_SUCCESS(rc) && strSourceIp4.isNotEmpty()) 385 386 { 386 387 RTNETADDRIPV4 addr; … … 406 407 if (fIPv6Enabled) 407 408 { 408 com::Bstr bstrSourceIp6; 409 com::Bstr bstrSourceIp6Key = com::BstrFmt("NAT/%s/SourceIp6", networkName.c_str()); 410 hrc = virtualbox->GetExtraData(bstrSourceIp6Key.raw(), bstrSourceIp6.asOutParam()); 411 if (SUCCEEDED(hrc) && bstrSourceIp6.isNotEmpty()) 409 com::Utf8Str strSourceIp6; 410 rc = getExtraData(strSourceIp6, "SourceIp6"); 411 if (RT_SUCCESS(rc) && strSourceIp6.isNotEmpty()) 412 412 { 413 413 RTNETADDRIPV6 addr; … … 1453 1453 1454 1454 1455 /** 1456 * Retrieve network-specific extra data item. 1457 */ 1458 int VBoxNetLwipNAT::getExtraData(com::Utf8Str &strValueOut, const char *pcszKey) 1459 { 1460 HRESULT hrc; 1461 1462 AssertReturn(!virtualbox.isNull(), E_FAIL); 1463 AssertReturn(!getNetworkName().empty(), E_FAIL); 1464 AssertReturn(pcszKey != NULL, E_FAIL); 1465 AssertReturn(*pcszKey != '\0', E_FAIL); 1466 1467 com::BstrFmt bstrKey("NAT/%s/%s", networkName.c_str(), pcszKey); 1468 com::Bstr bstrValue; 1469 hrc = virtualbox->GetExtraData(bstrKey.raw(), bstrValue.asOutParam()); 1470 if (FAILED(hrc)) 1471 { 1472 reportComError(virtualbox, "GetExtraData", hrc); 1473 return VERR_GENERAL_FAILURE; 1474 } 1475 1476 strValueOut = bstrValue; 1477 return VINF_SUCCESS; 1478 } 1479 1480 1455 1481 /* static */ 1456 1482 HRESULT VBoxNetLwipNAT::reportComError(ComPtr<IUnknown> iface,
Note:
See TracChangeset
for help on using the changeset viewer.