VirtualBox

Ignore:
Timestamp:
Feb 11, 2021 2:14:40 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142754
Message:

NAT/Net: Call Loopback mapping initialization (forgotten in previous).
Do initialization locally instead of using an intermediary. Do a bit
more checking and logging. bugref:9929.

Location:
trunk/src/VBox/NetworkServices/NetLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp

    r87698 r87710  
    7373
    7474VBOX_LISTENER_DECLARE(NATNetworkListenerImpl)
    75 
    76 
    77 int localMappings(const ComNatPtr& nat, AddressToOffsetMapping& mapping)
    78 {
    79     mapping.clear();
    80 
    81     ComBstrArray strs;
    82     size_t cStrs;
    83     HRESULT hrc = nat->COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs));
    84     if (   SUCCEEDED(hrc)
    85         && (cStrs = strs.size()))
    86     {
    87         for (size_t i = 0; i < cStrs; ++i)
    88         {
    89             char szAddr[17];
    90             RTNETADDRIPV4 ip4addr;
    91             char *pszTerm;
    92             uint32_t u32Off;
    93             com::Utf8Str strLo2Off(strs[i]);
    94             const char *pszLo2Off = strLo2Off.c_str();
    95 
    96             RT_ZERO(szAddr);
    97 
    98             pszTerm = RTStrStr(pszLo2Off, "=");
    99 
    100             if (   pszTerm
    101                    && (pszTerm - pszLo2Off) <= INET_ADDRSTRLEN)
    102             {
    103                 memcpy(szAddr, pszLo2Off, (pszTerm - pszLo2Off));
    104                 int rc = RTNetStrToIPv4Addr(szAddr, &ip4addr);
    105                 if (RT_SUCCESS(rc))
    106                 {
    107                     u32Off = RTStrToUInt32(pszTerm + 1);
    108                     if (u32Off != 0)
    109                         mapping.insert(
    110                           AddressToOffsetMapping::value_type(ip4addr, u32Off));
    111                 }
    112             }
    113         }
    114     }
    115     else
    116         return VERR_NOT_FOUND;
    117 
    118     return VINF_SUCCESS;
    119 }
    12075
    12176
  • trunk/src/VBox/NetworkServices/NetLib/utils.h

    r87698 r87710  
    3434typedef ComPtr<INATNetwork> ComNatPtr;
    3535typedef com::SafeArray<BSTR> ComBstrArray;
    36 
    37 typedef std::vector<RTNETADDRIPV4> AddressList;
    38 typedef std::map<RTNETADDRIPV4, int> AddressToOffsetMapping;
    39 
    40 
    41 int localMappings(const ComNatPtr&, AddressToOffsetMapping&);
    4236
    4337
Note: See TracChangeset for help on using the changeset viewer.

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