Changeset 87598 in vbox for trunk/src/VBox/NetworkServices/NAT
- Timestamp:
- Feb 4, 2021 12:09:16 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r87596 r87598 172 172 private: 173 173 int logInit(); 174 int comInit(); 174 175 175 176 static void reportError(const char *a_pcszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); … … 322 323 LogFlowFuncEnter(); 323 324 324 /* virtualbox initialized in the superclass*/325 rc = VBoxNetBaseService::init();325 /* Get the COM API set up. */ 326 rc = comInit(); 326 327 if (RT_FAILURE(rc)) 327 328 return rc; 328 329 329 330 /* 330 * We get the network name on the command line. Get hold of our331 * API object .331 * We get the network name on the command line. Get hold of its 332 * API object to get the rest of the configuration from. 332 333 */ 333 334 const std::string &networkName = getNetworkName(); … … 341 342 342 343 /* 343 * Now that we know the network name we can create the release log file. 344 * Now that we know the network name and have ensured that it 345 * indeed exists we can create the release log file. 344 346 */ 345 347 logInit(); … … 499 501 LogFlowFuncLeaveRC(rc); 500 502 return rc; 503 } 504 505 506 /** 507 * Primary COM initialization performed on the main thread. 508 * 509 * This initializes COM and obtains VirtualBox Client and VirtualBox 510 * objects. 511 * 512 * @note The member variables for them are in the base class. We 513 * currently do it here so that we can report errors properly, because 514 * the base class' VBoxNetBaseService::init() is a bit naive and 515 * fixing that would just create unnecessary churn for little 516 * immediate gain. It's easier to ignore the base class code and do 517 * it ourselves and do the refactoring later. 518 */ 519 int VBoxNetLwipNAT::comInit() 520 { 521 HRESULT hrc; 522 523 hrc = com::Initialize(); 524 if (FAILED(hrc)) 525 { 526 #ifdef VBOX_WITH_XPCOM 527 if (hrc == NS_ERROR_FILE_ACCESS_DENIED) 528 { 529 char szHome[RTPATH_MAX] = ""; 530 int vrc = com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome), false); 531 if (RT_SUCCESS(vrc)) 532 { 533 return RTMsgErrorExit(RTEXITCODE_INIT, 534 "Failed to initialize COM: %s: %Rhrf", 535 szHome, hrc); 536 } 537 } 538 #endif /* VBOX_WITH_XPCOM */ 539 return RTMsgErrorExit(RTEXITCODE_INIT, 540 "Failed to initialize COM: %Rhrf", hrc); 541 } 542 543 hrc = virtualboxClient.createInprocObject(CLSID_VirtualBoxClient); 544 if (FAILED(hrc)) 545 { 546 reportError("Failed to create VirtualBox Client object: %Rhra", hrc); 547 return VERR_GENERAL_FAILURE; 548 } 549 550 hrc = virtualboxClient->COMGETTER(VirtualBox)(virtualbox.asOutParam()); 551 if (FAILED(hrc)) 552 { 553 reportError("Failed to obtain VirtualBox object: %Rhra", hrc); 554 return VERR_GENERAL_FAILURE; 555 } 556 557 return VINF_SUCCESS; 501 558 } 502 559 … … 1563 1620 extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp) 1564 1621 { 1565 HRESULT hrc;1566 1622 int rc; 1567 1623 … … 1582 1638 #endif 1583 1639 1584 hrc = com::Initialize();1585 if (FAILED(hrc))1586 {1587 #ifdef VBOX_WITH_XPCOM1588 if (hrc == NS_ERROR_FILE_ACCESS_DENIED)1589 {1590 char szHome[RTPATH_MAX] = "";1591 int vrc = com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome), false);1592 if (RT_SUCCESS(vrc))1593 {1594 return RTMsgErrorExit(RTEXITCODE_INIT,1595 "Failed to initialize COM: %s: %Rhrf",1596 szHome, hrc);1597 }1598 }1599 #endif // VBOX_WITH_XPCOM1600 return RTMsgErrorExit(RTEXITCODE_INIT,1601 "Failed to initialize COM: %Rhrf", hrc);1602 }1603 1604 1640 VBoxNetLwipNAT NAT; 1605 1641 1606 Log2(("NAT: initialization\n")); 1607 rc = NAT.parseArgs(argc - 1, argv + 1); 1608 rc = (rc == 0) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /* XXX: FIXME */ 1609 1610 if (RT_SUCCESS(rc)) 1611 rc = NAT.init(); 1612 1613 if (RT_SUCCESS(rc)) 1614 NAT.run(); 1615 1642 int rcExit = NAT.parseArgs(argc - 1, argv + 1); 1643 if (rcExit != RTEXITCODE_SUCCESS) 1644 return rcExit; /* messages are already printed */ 1645 1646 rc = NAT.init(); 1647 if (RT_FAILURE(rc)) 1648 return RTEXITCODE_INIT; 1649 1650 NAT.run(); 1651 1652 LogRel(("Terminating\n")); 1616 1653 return RTEXITCODE_SUCCESS; 1617 1654 }
Note:
See TracChangeset
for help on using the changeset viewer.