HostDnsService.h revision 63fdb92b88f31446f6ea53241c0d127677c71c7e
/* $Id$ */
/** @file
* Host DNS listener.
*/
/*
* Copyright (C) 2005-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___H_DNSHOSTSERVICE
#define ___H_DNSHOSTSERVICE
#include "VirtualBoxBase.h"
#include <iprt/critsect.h>
#include <list>
#include <vector>
typedef const HostDnsMonitorProxy *PCHostDnsMonitorProxy;
{
Lockee();
const RTCRITSECT* lock() const;
};
{
~ALock();
};
{
};
/**
* This class supposed to be a real DNS monitor object it should be singleton,
* it lifecycle starts and ends together with VBoxSVC.
*/
{
static const HostDnsMonitor *getHostDnsMonitor();
static void shutdown();
void addMonitorProxy(PCHostDnsMonitorProxy) const;
void releaseMonitorProxy(PCHostDnsMonitorProxy) const;
const HostDnsInformation &getInfo() const;
/* @note: method will wait till client call
HostDnsService::monitorThreadInitializationDone() */
void notifyAll() const;
void setInfo(const HostDnsInformation &);
/* this function used only if HostDnsMonitor::HostDnsMonitor(true) */
void monitorThreadInitializationDone();
virtual void monitorThreadShutdown() = 0;
virtual int monitorWorker() = 0;
HostDnsMonitor(const HostDnsMonitor &);
static int threadMonitoringRoutine(RTTHREAD, void *);
struct Data;
Data *m;
};
/**
* This class supposed to be a proxy for events on changing Host Name Resolving configurations.
*/
{
void notify() const;
bool operator==(PCHostDnsMonitorProxy&);
void updateInfo();
struct Data;
Data *m;
};
# ifdef RT_OS_DARWIN
{
virtual void monitorThreadShutdown();
virtual int monitorWorker();
struct Data;
Data *m;
};
# endif
# ifdef RT_OS_WINDOWS
/* Maximum size of Windows registry key (according to MSDN). */
#define VBOX_KEY_NAME_LEN_MAX (255)
{
virtual void monitorThreadShutdown();
virtual int monitorWorker();
/* This structure is used in order to link Windows registry key with
* an event which is generated once the key has been changed (when interface has updated its DNS setting)
* or one of the sub-keys has been deleted or added (when interface added or deleted). */
struct Item
{
};
/* Bit flags to determine what was exactly was changed when Windows triggered event notification. */
enum {
};
/* Keys and events storage.
* Size of this vector should not be greater than MAXIMUM_WAIT_OBJECTS because
* this is exactly maximum amount of events which we allowed to wait for. */
/* Cached host network configuration. */
/* TCHAR[] constants initialized outside of class definition. */
static const TCHAR m_pwcKeyRoot[];
/* m_aWarehouse array offsets. */
enum {
};
/* Do actual unsubscription for given item. */
bool releaseWarehouseItem(int idxItem);
/* Release all allocated resources and unsubscribe from everything. */
void releaseResources();
/* Remove subscription from DNS change notifications and release corresponding resources. */
bool dropSubTreeNotifications();
/* Create & add event into the list of events we monitor to. */
/* Subscribe to DNS changes. */
bool enumerateSubTree();
/* Get plain array of event handles. */
void extendVectorWithStrings(std::vector<std::wstring>& pVectorToExtend, std::wstring &wcsParameter);
/* This flag indicates whether constructor performed initialization correctly. If not set,
* monitorWorker() will not perform any action and will be terminated as soon as there will be
* an attempt to run it. */
bool m_fInitialized;
};
# endif
{
/* While not all hosts supports Hosts DNS change notifiaction
* default implementation offers return VERR_IGNORE.
*/
virtual void monitorThreadShutdown() {}
struct Data;
Data *m;
};
# if defined(RT_OS_SOLARIS)
/**
*/
{
};
# elif defined(RT_OS_LINUX)
{
HostDnsServiceLinux():HostDnsServiceResolvConf(true){}
virtual void monitorThreadShutdown();
virtual int monitorWorker();
};
# elif defined(RT_OS_FREEBSD)
{
};
{
~HostDnsServiceOs2(){}
/* XXX: \\MPTN\\ETC should be taken from environment variable ETC */
};
# endif
# endif
#endif /* !___H_DNSHOSTSERVICE */