VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/HostDnsService.h@ 48330

Last change on this file since 48330 was 48330, checked in by vboxsync, 11 years ago

Main/DNS: general host specific DNS and Co handling added.
Darwin implementation has self-update mechanism, for other hosts it's in todo list.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: HostDnsService.h 48330 2013-09-06 03:16:32Z 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
28typedef std::list<com::Utf8Str> Utf8StrList;
29typedef Utf8StrList::iterator Utf8StrListIterator;
30
31class HostDnsService
32{
33public:
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));
42protected:
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
51private:
52 HostDnsService(const HostDnsService& service){ NOREF(service); }
53 HostDnsService& operator =(const HostDnsService& service){ NOREF(service); return *this; }
54};
55
56# ifdef RT_OS_DARWIN
57class HostDnsServiceDarwin: public HostDnsService
58{
59public:
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();
67private:
68 static void hostDnsServiceStoreCallback(void *store, void *arrayRef, void *info);
69
70};
71# endif
72
73# ifdef RT_OS_WINDOWS
74class HostDnsServiceWin: public HostDnsService
75{
76public:
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();
84private:
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
91class HostDnsServiceResolvConf: public HostDnsService
92{
93public:
94 HostDnsServiceResolvConf(const char *aResolvConfFileName = "/etc/resolv.conf");
95 virtual ~HostDnsServiceResolvConf();
96 virtual HRESULT init(void);
97 virtual HRESULT update();
98protected:
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 */
107class HostDnsServiceSolaris: public HostDnsServiceResolvConf
108{
109public:
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 */
117class HostDnsServiceLinux: public HostDnsServiceResolvConf
118{
119public:
120 HostDnsServiceLinux(){}
121 virtual ~HostDnsServiceLinux(){}
122};
123
124# elif defined(RT_OS_OS2)
125class HostDnsServiceOs2: public HostDnsServiceResolvConf
126{
127public:
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 */
Note: See TracBrowser for help on using the repository browser.

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