VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/HostDnsServiceResolvConf.cpp@ 52585

最後變更 在這個檔案從52585是 50263,由 vboxsync 提交於 11 年 前

Main/HostDnsService:

  • Generic part could be used with threading on or off: OS which can monitor changes on DNS structures might need this (e.g. Windows, Darwin, Linux)
  • ResolvConf based (Linux, Solaris, FreeBSD ans Os/2) doesn't use scanf based resovl.conf parsing new Slirp's parser used instead. It's configured to provide strings instead of addresses. (to resolve xtracker/7034c2)
  • Darwin monitoring code has been refactored.
  • linux changed to handle cases described in xtracker/7034c3
  • Windows monitors changes on register changes.
  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 1.7 KB
 
1/* -*- indent-tabs-mode: nil; -*- */
2#include <VBox/com/string.h>
3#include <VBox/com/ptr.h>
4
5
6#ifdef RT_OS_OS2
7# include <sys/socket.h>
8typedef int socklen_t;
9#endif
10
11#include <stdio.h>
12#include <sys/socket.h>
13#include <netinet/in.h>
14#include <arpa/inet.h>
15
16
17#include <iprt/assert.h>
18#include <iprt/err.h>
19#include <iprt/file.h>
20#include <iprt/critsect.h>
21
22#include <VBox/log.h>
23
24#include <string>
25
26#include "HostDnsService.h"
27#include "../../Devices/Network/slirp/resolv_conf_parser.h"
28
29
30struct HostDnsServiceResolvConf::Data
31{
32 Data(const char *fileName):resolvConfFilename(fileName){};
33
34 std::string resolvConfFilename;
35};
36
37const std::string& HostDnsServiceResolvConf::resolvConf() const
38{
39 return m->resolvConfFilename;
40}
41
42
43HostDnsServiceResolvConf::~HostDnsServiceResolvConf()
44{
45 if (m)
46 {
47 delete m;
48 m = NULL;
49 }
50}
51
52HRESULT HostDnsServiceResolvConf::init(const char *aResolvConfFileName)
53{
54 m = new Data(aResolvConfFileName);
55
56 HostDnsMonitor::init();
57
58 readResolvConf();
59
60 return S_OK;
61}
62
63
64HRESULT HostDnsServiceResolvConf::readResolvConf()
65{
66 struct rcp_state st;
67
68 st.rcps_flags = RCPSF_NO_STR2IPCONV;
69 int rc = rcp_parse(&st, m->resolvConfFilename.c_str());
70 if (rc == -1)
71 return S_OK;
72
73 HostDnsInformation info;
74 for (unsigned i = 0; i != st.rcps_num_nameserver; ++i)
75 {
76 AssertBreak(st.rcps_str_nameserver[i]);
77 info.servers.push_back(st.rcps_str_nameserver[i]);
78 }
79
80 if (st.rcps_domain)
81 info.domain = st.rcps_domain;
82
83 for (unsigned i = 0; i != st.rcps_num_searchlist; ++i)
84 {
85 AssertBreak(st.rcps_searchlist[i]);
86 info.searchList.push_back(st.rcps_searchlist[i]);
87 }
88 setInfo(info);
89
90 return S_OK;
91}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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