HostDnsService.h revision 18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cd
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* $Id$ */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/** @file
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Host DNS listener.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright (C) 2005-2012 Oracle Corporation
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This file is part of VirtualBox Open Source Edition (OSE), as
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * available from http://www.virtualbox.org. This file is free software;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * you can redistribute it and/or modify it under the terms of the GNU
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * General Public License (GPL) as published by the Free Software
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Foundation, in version 2 as it comes in the "COPYING" file of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef ___H_DNSHOSTSERVICE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ___H_DNSHOSTSERVICE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <iprt/cdefs.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <iprt/critsect.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <iprt/types.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <list>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef std::list<com::Utf8Str> Utf8StrList;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef Utf8StrList::iterator Utf8StrListIterator;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinclass HostDnsService
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpublic:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin HostDnsService();
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin virtual ~HostDnsService();
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin virtual HRESULT init(void);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin virtual HRESULT start(void);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin virtual void stop(void);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin STDMETHOD(COMGETTER(NameServers))(ComSafeArrayOut(BSTR, aNameServers));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin STDMETHOD(COMGETTER(DomainName))(BSTR *aDomainName);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin STDMETHOD(COMGETTER(SearchStrings))(ComSafeArrayOut(BSTR, aSearchStrings));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinprotected:
virtual HRESULT update(void);
/* XXX: hide it with struct Data together with <list> */
Utf8StrList m_llNameServers;
Utf8StrList m_llSearchStrings;
com::Utf8Str m_DomainName;
RTCRITSECT m_hCritSect;
private:
HostDnsService(const HostDnsService& service){ NOREF(service); }
HostDnsService& operator =(const HostDnsService& service){ NOREF(service); return *this; }
};
# ifdef RT_OS_DARWIN
class HostDnsServiceDarwin: public HostDnsService
{
public:
HostDnsServiceDarwin();
virtual ~HostDnsServiceDarwin();
virtual HRESULT init(void);
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(void);
virtual HRESULT start(void);
virtual void stop(void);
virtual HRESULT update();
private:
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(void);
virtual HRESULT update();
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)
/**
* XXX: http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html
*/
class HostDnsServiceLinux: public HostDnsServiceResolvConf
{
public:
HostDnsServiceLinux(){}
virtual ~HostDnsServiceLinux(){}
};
# 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 */