Changeset 48375 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Sep 9, 2013 6:44:47 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r48367 r48375 384 384 confManager->addToAddressList(RTNET_DHCP_OPT_ROUTERS, gateway); 385 385 386 unsigned int i; 387 int count_strs; 388 com::SafeArray<BSTR> strs; 389 std::map<RTNETADDRIPV4, uint32_t> MapIp4Addr2Off; 390 391 hrc = m_NATNetwork->COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs)); 392 if ( SUCCEEDED(hrc) 393 && (count_strs = strs.size())) 394 { 395 char aszAddr[17]; 396 RTNETADDRIPV4 ip4addr; 397 char *pszTerm; 398 uint32_t u32Off; 399 const char *pszLo2Off = com::Utf8Str(strs[i]).c_str(); 400 401 RT_ZERO(aszAddr); 402 403 pszTerm = RTStrStr(pszLo2Off, ";"); 404 405 if ( pszTerm 406 && (pszTerm - pszLo2Off) >= 17) 407 { 408 409 memcpy(aszAddr, pszLo2Off, (pszTerm - pszLo2Off)); 410 int rc = RTNetStrToIPv4Addr(aszAddr, &ip4addr); 411 if (RT_SUCCESS(rc)) 412 { 413 414 u32Off = RTStrToUInt32(pszTerm + 1); 415 if (u32Off != 0) 416 MapIp4Addr2Off.insert( 417 std::map<RTNETADDRIPV4,uint32_t>::value_type(ip4addr, u32Off)); 418 } 419 } 420 } 421 422 strs.setNull(); 386 423 ComPtr<IHost> host; 387 424 if (SUCCEEDED(virtualbox->COMGETTER(Host)(host.asOutParam()))) 388 425 { 389 int i;390 com::SafeArray<BSTR> strs;391 426 if (SUCCEEDED(host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs)))) 392 427 { … … 398 433 rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr); 399 434 if (RT_SUCCESS(rc)) 435 { 436 if (addr.au8[0] == 127) 437 { 438 if (MapIp4Addr2Off[addr] != 0) 439 { 440 addr.u = RT_H2N_U32(RT_N2H_U32(m_Ipv4Address.u & m_Ipv4Netmask.u) 441 + MapIp4Addr2Off[addr]); 442 } 443 else 444 continue; 445 } 446 400 447 confManager->addToAddressList(RTNET_DHCP_OPT_DNS, addr); 448 } 401 449 } 402 450 }
Note:
See TracChangeset
for help on using the changeset viewer.