1 | /* $Id: HostDnsService.h 48346 2013-09-06 09:50:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Host DNS listener.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2005-2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___H_DNSHOSTSERVICE
|
---|
19 | #define ___H_DNSHOSTSERVICE
|
---|
20 |
|
---|
21 | #include <iprt/cdefs.h>
|
---|
22 | #include <iprt/critsect.h>
|
---|
23 | #include <iprt/types.h>
|
---|
24 |
|
---|
25 |
|
---|
26 | #include <list>
|
---|
27 |
|
---|
28 | typedef std::list<com::Utf8Str> Utf8StrList;
|
---|
29 | typedef Utf8StrList::iterator Utf8StrListIterator;
|
---|
30 |
|
---|
31 | class HostDnsService
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | HostDnsService();
|
---|
35 | virtual ~HostDnsService();
|
---|
36 | virtual HRESULT init(void);
|
---|
37 | virtual HRESULT start(void);
|
---|
38 | virtual void stop(void);
|
---|
39 | STDMETHOD(COMGETTER(NameServers))(ComSafeArrayOut(BSTR, aNameServers));
|
---|
40 | STDMETHOD(COMGETTER(DomainName))(BSTR *aDomainName);
|
---|
41 | STDMETHOD(COMGETTER(SearchStrings))(ComSafeArrayOut(BSTR, aSearchStrings));
|
---|
42 | protected:
|
---|
43 | virtual HRESULT update(void);
|
---|
44 |
|
---|
45 | /* XXX: hide it with struct Data together with <list> */
|
---|
46 | Utf8StrList m_llNameServers;
|
---|
47 | Utf8StrList m_llSearchStrings;
|
---|
48 | com::Utf8Str m_DomainName;
|
---|
49 | RTCRITSECT m_hCritSect;
|
---|
50 |
|
---|
51 | private:
|
---|
52 | HostDnsService(const HostDnsService& service){ NOREF(service); }
|
---|
53 | HostDnsService& operator =(const HostDnsService& service){ NOREF(service); return *this; }
|
---|
54 | };
|
---|
55 |
|
---|
56 | # ifdef RT_OS_DARWIN
|
---|
57 | class HostDnsServiceDarwin: public HostDnsService
|
---|
58 | {
|
---|
59 | public:
|
---|
60 | HostDnsServiceDarwin();
|
---|
61 | virtual ~HostDnsServiceDarwin();
|
---|
62 |
|
---|
63 | virtual HRESULT init(void);
|
---|
64 | virtual HRESULT start(void);
|
---|
65 | virtual void stop(void);
|
---|
66 | virtual HRESULT update();
|
---|
67 | private:
|
---|
68 | static void hostDnsServiceStoreCallback(void *store, void *arrayRef, void *info);
|
---|
69 |
|
---|
70 | };
|
---|
71 | # endif
|
---|
72 |
|
---|
73 | # ifdef RT_OS_WINDOWS
|
---|
74 | class HostDnsServiceWin: public HostDnsService
|
---|
75 | {
|
---|
76 | public:
|
---|
77 | HostDnsServiceWin();
|
---|
78 | virtual ~HostDnsServiceWin();
|
---|
79 |
|
---|
80 | virtual HRESULT init(void);
|
---|
81 | virtual HRESULT start(void);
|
---|
82 | virtual void stop(void);
|
---|
83 | virtual HRESULT update();
|
---|
84 | private:
|
---|
85 | void strList2List(Utf8StrList& lst, char *strLst);
|
---|
86 | };
|
---|
87 | # endif
|
---|
88 |
|
---|
89 | #if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_OS2)
|
---|
90 |
|
---|
91 | class HostDnsServiceResolvConf: public HostDnsService
|
---|
92 | {
|
---|
93 | public:
|
---|
94 | HostDnsServiceResolvConf(const char *aResolvConfFileName = "/etc/resolv.conf");
|
---|
95 | virtual ~HostDnsServiceResolvConf();
|
---|
96 | virtual HRESULT init(void);
|
---|
97 | virtual HRESULT update();
|
---|
98 | protected:
|
---|
99 | com::Utf8Str m_ResolvConfFilename;
|
---|
100 | RTFILE m_ResolvConfFile;
|
---|
101 | };
|
---|
102 |
|
---|
103 | # if defined(RT_OS_SOLARIS)
|
---|
104 | /**
|
---|
105 | * XXX: https://blogs.oracle.com/praks/entry/file_events_notification
|
---|
106 | */
|
---|
107 | class HostDnsServiceSolaris: public HostDnsServiceResolvConf
|
---|
108 | {
|
---|
109 | public:
|
---|
110 | HostDnsServiceSolaris(){}
|
---|
111 | virtual ~HostDnsServiceSolaris(){}
|
---|
112 | };
|
---|
113 | # elif defined(RT_OS_LINUX)
|
---|
114 | /**
|
---|
115 | * XXX: http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html
|
---|
116 | */
|
---|
117 | class HostDnsServiceLinux: public HostDnsServiceResolvConf
|
---|
118 | {
|
---|
119 | public:
|
---|
120 | HostDnsServiceLinux(){}
|
---|
121 | virtual ~HostDnsServiceLinux(){}
|
---|
122 | };
|
---|
123 |
|
---|
124 | # elif defined(RT_OS_OS2)
|
---|
125 | class HostDnsServiceOs2: public HostDnsServiceResolvConf
|
---|
126 | {
|
---|
127 | public:
|
---|
128 | HostDnsServiceOs2()
|
---|
129 | {
|
---|
130 | /* XXX: \\MPTN\\ETC should be taken from environment variable ETC */
|
---|
131 | ::HostDnsServiceResolvConf("\\MPTN\\ETC\\RESOLV2");
|
---|
132 | }
|
---|
133 | virtual ~HostDnsServiceOs2(){}
|
---|
134 | };
|
---|
135 | # endif
|
---|
136 | #endif
|
---|
137 |
|
---|
138 | #endif /* !___H_DNSHOSTSERVICE */
|
---|