Changeset 64215 in vbox for trunk/src/VBox/NetworkServices/DHCP
- Timestamp:
- Oct 12, 2016 2:05:31 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 111214
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r63301 r64215 115 115 int initWithMain(); 116 116 HRESULT HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent); 117 118 static int hostDnsServers(const ComHostPtr& host, 119 const RTNETADDRIPV4& networkid, 120 /* const */ AddressToOffsetMapping& mapping, 121 AddressList& servers); 117 122 int fetchAndUpdateDnsInfo(); 118 123 … … 611 616 } 612 617 618 619 /** 620 * @note: const dropped here, because of map<K,V>::operator[] which 621 * isn't const, map<K,V>::at() has const variant but it's C++11. 622 */ 623 int VBoxNetDhcp::hostDnsServers(const ComHostPtr& host, 624 const RTNETADDRIPV4& networkid, 625 /* const */ AddressToOffsetMapping& mapping, 626 AddressList& servers) 627 { 628 ComBstrArray strs; 629 630 HRESULT hrc = host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs)); 631 if (FAILED(hrc)) 632 return VERR_NOT_FOUND; 633 634 /* 635 * Recent fashion is to run dnsmasq on 127.0.1.1 which we 636 * currently can't map. If that's the only nameserver we've got, 637 * we need to use DNS proxy for VMs to reach it. 638 */ 639 bool fUnmappedLoopback = false; 640 641 for (size_t i = 0; i < strs.size(); ++i) 642 { 643 RTNETADDRIPV4 addr; 644 int rc; 645 646 rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr); 647 if (RT_FAILURE(rc)) 648 continue; 649 650 if (addr.au8[0] == 127) 651 { 652 /* XXX: here we want map<K,V>::at(const K& k) const */ 653 if (mapping[addr] != 0) 654 { 655 addr.u = RT_H2N_U32(RT_N2H_U32(networkid.u) 656 + mapping[addr]); 657 } 658 else 659 { 660 fUnmappedLoopback = true; 661 continue; 662 } 663 } 664 665 servers.push_back(addr); 666 } 667 668 if (servers.empty() && fUnmappedLoopback) 669 { 670 RTNETADDRIPV4 proxy; 671 672 proxy.u = networkid.u | RT_H2N_U32_C(1U); 673 servers.push_back(proxy); 674 } 675 676 return VINF_SUCCESS; 677 } 678 679 613 680 HRESULT VBoxNetDhcp::HandleEvent(VBoxEventType_T aEventType, IEvent *pEvent) 614 681 {
Note:
See TracChangeset
for help on using the changeset viewer.