HostDnsService.h revision 735076496e14763dcdef4b43202e7665d4a8da43
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync/* $Id$ */
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync/** @file
01bceecc7f7484a8820c77b884bb91cdefc97390vboxsync * Host DNS listener.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync */
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync/*
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * Copyright (C) 2005-2012 Oracle Corporation
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync *
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.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync */
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#ifndef ___H_DNSHOSTSERVICE
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#define ___H_DNSHOSTSERVICE
5218e94d899f948d3def7109e05a93fc6d590037vboxsync#include "VirtualBoxBase.h"
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#include <iprt/cdefs.h>
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#include <iprt/critsect.h>
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#include <iprt/types.h>
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#include <list>
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync#include <vector>
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsynctypedef std::list<com::Utf8Str> Utf8StrList;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsynctypedef Utf8StrList::iterator Utf8StrListIterator;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsMonitorProxy;
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsynctypedef const HostDnsMonitorProxy *PCHostDnsMonitorProxy;
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsyncclass Lockee
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync Lockee();
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync virtual ~Lockee();
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync const RTCRITSECT* lock() const;
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync private:
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync RTCRITSECT mLock;
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync};
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsyncclass ALock
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync explicit ALock(const Lockee *l);
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync ~ALock();
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync private:
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync const Lockee *lockee;
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync};
607b3e94ac964648f49fc97505782d4b71b8c18fvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsInformation
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
510b14148124a664875cdb3a996433bd92c9324evboxsync std::vector<std::string> servers;
510b14148124a664875cdb3a996433bd92c9324evboxsync std::string domain;
510b14148124a664875cdb3a996433bd92c9324evboxsync std::vector<std::string> searchList;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync};
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync/**
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 */
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsMonitor : public Lockee
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync static const HostDnsMonitor *getHostDnsMonitor();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync static void shutdown();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync void addMonitorProxy(PCHostDnsMonitorProxy) const;
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync void releaseMonitorProxy(PCHostDnsMonitorProxy) const;
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync const HostDnsInformation &getInfo() const;
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync /* @note: method will wait till client call
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync HostDnsService::monitorThreadInitializationDone() */
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync virtual HRESULT init();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync protected:
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync explicit HostDnsMonitor(bool fThreaded = false);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual ~HostDnsMonitor();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync void notifyAll() const;
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync void setInfo(const HostDnsInformation &);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync /* this function used only if HostDnsMonitor::HostDnsMonitor(true) */
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync void monitorThreadInitializationDone();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual void monitorThreadShutdown() = 0;
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual int monitorWorker() = 0;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync private:
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync HostDnsMonitor(const HostDnsMonitor &);
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync HostDnsMonitor& operator= (const HostDnsMonitor &);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync static int threadMonitoringRoutine(RTTHREAD, void *);
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync struct Data;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync Data *m;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync};
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync/**
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync * This class supposed to be a proxy for events on changing Host Name Resolving configurations.
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync */
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsMonitorProxy : public Lockee
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync{
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync public:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HostDnsMonitorProxy();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync ~HostDnsMonitorProxy();
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync void init(const HostDnsMonitor *aMonitor, const VirtualBox *aParent);
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync void notify() const;
233a114a6b1855d0525e4c4724683ac0f0d6956cvboxsync
70c5cdbebee624ca386867b552ec032374bfaaf8vboxsync HRESULT GetNameServers(std::vector<com::Utf8Str> &aNameServers);
70c5cdbebee624ca386867b552ec032374bfaaf8vboxsync HRESULT GetDomainName(com::Utf8Str *pDomainName);
70c5cdbebee624ca386867b552ec032374bfaaf8vboxsync HRESULT GetSearchStrings(std::vector<com::Utf8Str> &aSearchStrings);
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync bool operator==(PCHostDnsMonitorProxy&);
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync private:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync void updateInfo();
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync private:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync struct Data;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync Data *m;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# ifdef RT_OS_DARWIN
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceDarwin : public HostDnsMonitor
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync HostDnsServiceDarwin();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync ~HostDnsServiceDarwin();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HRESULT init();
233a114a6b1855d0525e4c4724683ac0f0d6956cvboxsync
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync protected:
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual void monitorThreadShutdown();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual int monitorWorker();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync private:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HRESULT updateInfo();
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync static void hostDnsServiceStoreCallback(void *store, void *arrayRef, void *info);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync struct Data;
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync Data *m;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# endif
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# ifdef RT_OS_WINDOWS
735076496e14763dcdef4b43202e7665d4a8da43vboxsync/* Maximum size of Windows registry key (according to MSDN). */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync#define VBOX_KEY_NAME_LEN_MAX (255)
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
510b14148124a664875cdb3a996433bd92c9324evboxsyncclass HostDnsServiceWin : public HostDnsMonitor
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync{
735076496e14763dcdef4b43202e7665d4a8da43vboxsyncpublic:
510b14148124a664875cdb3a996433bd92c9324evboxsync HostDnsServiceWin();
510b14148124a664875cdb3a996433bd92c9324evboxsync ~HostDnsServiceWin();
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
510b14148124a664875cdb3a996433bd92c9324evboxsync HRESULT init();
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsyncprotected:
510b14148124a664875cdb3a996433bd92c9324evboxsync virtual void monitorThreadShutdown();
510b14148124a664875cdb3a996433bd92c9324evboxsync virtual int monitorWorker();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsyncprivate:
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /*
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * Bit flags to determine what was exactly was changed when
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * Windows triggered event notification.
735076496e14763dcdef4b43202e7665d4a8da43vboxsync */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync enum {
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_EVENT_NO_CHANGES = 0,
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_EVENT_SERVERS_CHANGED = RT_BIT(1),
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_EVENT_DOMAIN_CHANGED = RT_BIT(2),
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_EVENT_SEARCHLIST_CHANGED = RT_BIT(3),
735076496e14763dcdef4b43202e7665d4a8da43vboxsync };
63fdb92b88f31446f6ea53241c0d127677c71c7evboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* m_aWarehouse array offsets. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync enum {
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_OFFSET_SHUTDOWN_EVENT = 0,
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_OFFSET_TREE_EVENT = 1,
735076496e14763dcdef4b43202e7665d4a8da43vboxsync VBOX_OFFSET_SUBTREE_EVENTS = 2,
735076496e14763dcdef4b43202e7665d4a8da43vboxsync };
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /*
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * This structure is used in order to link Windows registry key
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * with an event which is generated once the key has been changed
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * (when interface has updated its DNS setting) or one of the
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * sub-keys has been deleted or added (when interface added or
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * deleted).
735076496e14763dcdef4b43202e7665d4a8da43vboxsync */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync struct Item
735076496e14763dcdef4b43202e7665d4a8da43vboxsync {
735076496e14763dcdef4b43202e7665d4a8da43vboxsync HKEY hKey; /* Key handle. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync HANDLE hEvent; /* Event handle. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync wchar_t wcsInterface[VBOX_KEY_NAME_LEN_MAX]; /* Path to key within Windows registry. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync };
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync static const wchar_t pwcKeyRoot[];
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /*
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * This flag indicates whether constructor performed
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * initialization correctly. If not set, monitorWorker() will not
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * perform any action and will be terminated as soon as there will
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * be an attempt to run it.
735076496e14763dcdef4b43202e7665d4a8da43vboxsync */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync bool m_fInitialized;
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /*
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * Keys and events storage. Size of this vector should not be
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * greater than MAXIMUM_WAIT_OBJECTS because this is exactly
735076496e14763dcdef4b43202e7665d4a8da43vboxsync * maximum amount of events which we allowed to wait for.
735076496e14763dcdef4b43202e7665d4a8da43vboxsync */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync std::vector<struct Item> m_aWarehouse;
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Cached host network configuration. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync HostDnsInformation m_hostInfoCache;
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Do actual unsubscription for given item. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync bool releaseWarehouseItem(int idxItem);
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Release all allocated resources and unsubscribe from everything. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync void releaseResources();
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Remove subscription from DNS change notifications and release corresponding resources. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync bool dropSubTreeNotifications();
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Create & add event into the list of events we monitor to. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync bool subscribeTo(const wchar_t *wcsPath, const wchar_t *wcsInterface, DWORD fFilter);
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Subscribe to DNS changes. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync bool enumerateSubTree();
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync /* Get plain array of event handles. */
735076496e14763dcdef4b43202e7665d4a8da43vboxsync void getEventHandles(HANDLE *ahEvents);
735076496e14763dcdef4b43202e7665d4a8da43vboxsync void extendVectorWithStrings(std::vector<std::string>& pVectorToExtend, const std::wstring &wcsParameter);
735076496e14763dcdef4b43202e7665d4a8da43vboxsync
735076496e14763dcdef4b43202e7665d4a8da43vboxsync HRESULT updateInfo(uint8_t *fWhatsChanged);
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# endif
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync# if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsyncclass HostDnsServiceResolvConf: public HostDnsMonitor
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync explicit HostDnsServiceResolvConf(bool fThreaded = false) : HostDnsMonitor(fThreaded), m(NULL) {}
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync virtual ~HostDnsServiceResolvConf();
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync virtual HRESULT init(const char *aResolvConfFileName);
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync const std::string& resolvConf() const;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync protected:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HRESULT readResolvConf();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync /* While not all hosts supports Hosts DNS change notifiaction
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync * default implementation offers return VERR_IGNORE.
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync */
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual void monitorThreadShutdown() {}
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual int monitorWorker() {return VERR_IGNORED;}
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync protected:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync struct Data;
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync Data *m;
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# if defined(RT_OS_SOLARIS)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync/**
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync * XXX: https://blogs.oracle.com/praks/entry/file_events_notification
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync */
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceSolaris : public HostDnsServiceResolvConf
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync HostDnsServiceSolaris(){}
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync ~HostDnsServiceSolaris(){}
6c2ae4881e4220cc4bba0738d2b0d158d571ec9bvboxsync HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# elif defined(RT_OS_LINUX)
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceLinux : public HostDnsServiceResolvConf
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync HostDnsServiceLinux():HostDnsServiceResolvConf(true){}
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual ~HostDnsServiceLinux();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
4a5eed4c1192804dd98b2d803ef27f610a0a5a90vboxsync
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync protected:
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual void monitorThreadShutdown();
dbbd0cae65188dffbd927bdde2d88cbeec2e26davboxsync virtual int monitorWorker();
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync# elif defined(RT_OS_FREEBSD)
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsyncclass HostDnsServiceFreebsd: public HostDnsServiceResolvConf
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync{
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync public:
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync HostDnsServiceFreebsd(){}
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync ~HostDnsServiceFreebsd(){}
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync};
d27bf03c13c7a5707386600ef9b0bbb82fb3420dvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# elif defined(RT_OS_OS2)
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsyncclass HostDnsServiceOs2 : public HostDnsServiceResolvConf
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync{
c0b3f8f271f3bc2358c46ed5a99af29a28bd1b66vboxsync public:
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HostDnsServiceOs2(){}
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync ~HostDnsServiceOs2(){}
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync /* XXX: \\MPTN\\ETC should be taken from environment variable ETC */
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync HRESULT init(){ return init("\\MPTN\\ETC\\RESOLV2");}
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync};
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# endif
3f2299591cfeb8a37a3578bef9c44c1790860948vboxsync# endif
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync#endif /* !___H_DNSHOSTSERVICE */