HostDnsService.h revision db8bc574dcfad7e8fa153800a94e61a80e93259f
af062818b47340eef15700d2f0211576ba3506eevboxsync/* $Id$ */
af062818b47340eef15700d2f0211576ba3506eevboxsync/** @file
af062818b47340eef15700d2f0211576ba3506eevboxsync * Host DNS listener.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2005-2012 Oracle Corporation
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifndef ___H_DNSHOSTSERVICE
af062818b47340eef15700d2f0211576ba3506eevboxsync#define ___H_DNSHOSTSERVICE
af062818b47340eef15700d2f0211576ba3506eevboxsync#include "VirtualBoxBase.h"
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <iprt/cdefs.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <iprt/critsect.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <iprt/types.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <list>
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsynctypedef std::list<com::Utf8Str> Utf8StrList;
af062818b47340eef15700d2f0211576ba3506eevboxsynctypedef Utf8StrList::iterator Utf8StrListIterator;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass HostDnsService
af062818b47340eef15700d2f0211576ba3506eevboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsync public:
af062818b47340eef15700d2f0211576ba3506eevboxsync HostDnsService();
af062818b47340eef15700d2f0211576ba3506eevboxsync virtual ~HostDnsService();
af062818b47340eef15700d2f0211576ba3506eevboxsync virtual HRESULT init(const VirtualBox *aParent);
af062818b47340eef15700d2f0211576ba3506eevboxsync virtual HRESULT start(void);
af062818b47340eef15700d2f0211576ba3506eevboxsync virtual void stop(void);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(NameServers))(ComSafeArrayOut(BSTR, aNameServers));
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(DomainName))(BSTR *aDomainName);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(SearchStrings))(ComSafeArrayOut(BSTR, aSearchStrings));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync protected:
af062818b47340eef15700d2f0211576ba3506eevboxsync virtual HRESULT update(void);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* XXX: hide it with struct Data together with <list> */
af062818b47340eef15700d2f0211576ba3506eevboxsync Utf8StrList m_llNameServers;
af062818b47340eef15700d2f0211576ba3506eevboxsync Utf8StrList m_llSearchStrings;
com::Utf8Str m_DomainName;
RTCRITSECT m_hCritSect;
private:
const VirtualBox *mParent;
HostDnsService(const HostDnsService&);
HostDnsService& operator =(const HostDnsService&);
};
# ifdef RT_OS_DARWIN
class HostDnsServiceDarwin: public HostDnsService
{
public:
HostDnsServiceDarwin();
virtual ~HostDnsServiceDarwin();
virtual HRESULT init(const VirtualBox *aParent);
virtual HRESULT start(void);
virtual void stop(void);
virtual HRESULT update();
private:
static void hostDnsServiceStoreCallback(void *store, void *arrayRef, void *info);
};
# endif
# ifdef RT_OS_WINDOWS
class HostDnsServiceWin: public HostDnsService
{
public:
HostDnsServiceWin();
virtual ~HostDnsServiceWin();
virtual HRESULT init(const VirtualBox *aParent);
virtual HRESULT start(void);
virtual void stop(void);
virtual HRESULT update();
void strList2List(Utf8StrList& lst, char *strLst);
};
# endif
#if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_OS2)
class HostDnsServiceResolvConf: public HostDnsService
{
public:
HostDnsServiceResolvConf(const char *aResolvConfFileName = "/etc/resolv.conf");
virtual ~HostDnsServiceResolvConf();
virtual HRESULT init(const VirtualBox *aParent);
virtual HRESULT update();
const com::Utf8Str resolvConf() {return m_ResolvConfFilename; }
protected:
com::Utf8Str m_ResolvConfFilename;
RTFILE m_ResolvConfFile;
};
# if defined(RT_OS_SOLARIS)
/**
* XXX: https://blogs.oracle.com/praks/entry/file_events_notification
*/
class HostDnsServiceSolaris: public HostDnsServiceResolvConf
{
public:
HostDnsServiceSolaris(){}
virtual ~HostDnsServiceSolaris(){}
};
# elif defined(RT_OS_LINUX)
class HostDnsServiceLinux: public HostDnsServiceResolvConf
{
public:
HostDnsServiceLinux(){}
virtual ~HostDnsServiceLinux(){}
virtual HRESULT init(const VirtualBox *aParent);
virtual void stop(void);
static int hostMonitoringRoutine(RTTHREAD ThreadSelf, void *pvUser);
};
# elif defined(RT_OS_OS2)
class HostDnsServiceOs2: public HostDnsServiceResolvConf
{
public:
HostDnsServiceOs2()
{
/* XXX: \\MPTN\\ETC should be taken from environment variable ETC */
::HostDnsServiceResolvConf("\\MPTN\\ETC\\RESOLV2");
}
virtual ~HostDnsServiceOs2(){}
};
# endif
#endif
#endif /* !___H_DNSHOSTSERVICE */