HostDnsService.h revision 70c5cdbebee624ca386867b552ec032374bfaaf8
01bceecc7f7484a8820c77b884bb91cdefc97390vboxsync * Host DNS listener.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * Copyright (C) 2005-2012 Oracle Corporation
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * available from http://www.virtualbox.org. This file is free software;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * you can redistribute it and/or modify it under the terms of the GNU
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * General Public License (GPL) as published by the Free Software
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsynctypedef const HostDnsMonitorProxy *PCHostDnsMonitorProxy;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync * This class supposed to be a real DNS monitor object it should be singleton,
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync * it lifecycle starts and ends together with VBoxSVC.
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync static void shutdown();
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync void releaseMonitorProxy(PCHostDnsMonitorProxy) const;
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync /* @note: method will wait till client call
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync HostDnsService::monitorThreadInitializationDone() */
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync void notifyAll() const;
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync /* this function used only if HostDnsMonitor::HostDnsMonitor(true) */
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync HostDnsMonitor& operator= (const HostDnsMonitor &);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync static int threadMonitoringRoutine(RTTHREAD, void *);
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync * This class supposed to be a proxy for events on changing Host Name Resolving configurations.
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync void init(const HostDnsMonitor *aMonitor, const VirtualBox *aParent);
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync void notify() const;
70c5cdbebee624ca386867b552ec032374bfaaf8vboxsync HRESULT GetNameServers(std::vector<com::Utf8Str> &aNameServers);
70c5cdbebee624ca386867b552ec032374bfaaf8vboxsync HRESULT GetSearchStrings(std::vector<com::Utf8Str> &aSearchStrings);
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync static void hostDnsServiceStoreCallback(void *store, void *arrayRef, void *info);
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync/* Maximum size of Windows registry key (according to MSDN). */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* This structure is used in order to link Windows registry key with
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync * an event which is generated once the key has been changed (when interface has updated its DNS setting)
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync * or one of the sub-keys has been deleted or added (when interface added or deleted). */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync TCHAR wcsInterface[VBOX_KEY_NAME_LEN_MAX]; /** Path to key within Windows registry. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Bit flags to determine what was exactly was changed when Windows triggered event notification. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Keys and events storage.
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync * Size of this vector should not be greater than MAXIMUM_WAIT_OBJECTS because
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync * this is exactly maximum amount of events which we allowed to wait for. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Cached host network configuration. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* TCHAR[] constants initialized outside of class definition. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* m_aWarehouse array offsets. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Do actual unsubscription for given item. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Release all allocated resources and unsubscribe from everything. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Remove subscription from DNS change notifications and release corresponding resources. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Create & add event into the list of events we monitor to. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync bool subscribeTo(TCHAR *wcsPath, TCHAR *wcsInterface, DWORD fFilter);
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Subscribe to DNS changes. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* Get plain array of event handles. */
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync void extendVectorWithStrings(std::vector<std::wstring>& pVectorToExtend, std::wstring &wcsParameter);
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync /* This flag indicates whether constructor performed initialization correctly. If not set,
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync * monitorWorker() will not perform any action and will be terminated as soon as there will be
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync * an attempt to run it. */
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync# if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsyncclass HostDnsServiceResolvConf: public HostDnsMonitor
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync explicit HostDnsServiceResolvConf(bool fThreaded = false) : HostDnsMonitor(fThreaded), m(NULL) {}
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync virtual HRESULT init(const char *aResolvConfFileName);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync /* While not all hosts supports Hosts DNS change notifiaction
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync * default implementation offers return VERR_IGNORE.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * XXX: https://blogs.oracle.com/praks/entry/file_events_notification
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceSolaris : public HostDnsServiceResolvConf
6c2ae4881e4220cc4bba0738d2b0d158d571ec9bvboxsync HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceLinux : public HostDnsServiceResolvConf
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync HostDnsServiceLinux():HostDnsServiceResolvConf(true){}
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsyncclass HostDnsServiceFreebsd: public HostDnsServiceResolvConf
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceOs2 : public HostDnsServiceResolvConf
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync /* XXX: \\MPTN\\ETC should be taken from environment variable ETC */
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HRESULT init(){ return init("\\MPTN\\ETC\\RESOLV2");}
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#endif /* !___H_DNSHOSTSERVICE */