DHCPServerImpl.h revision 2f474860742ec2c8dbccf3291a73a3d7aa9e7802
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync/* $Id$ */
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync/** @file
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync *
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * VirtualBox COM class implementation
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync */
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync/*
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * Copyright (C) 2006-2013 Oracle Corporation
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync *
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * available from http://www.virtualbox.org. This file is free software;
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * you can redistribute it and/or modify it under the terms of the GNU
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * General Public License (GPL) as published by the Free Software
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync */
772269936494ffaddd0750ba9e28e805ba81398cvboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#ifndef ____H_H_DHCPSERVERIMPL
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#define ____H_H_DHCPSERVERIMPL
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync
6da8aad9b9f0e2aa239259658e3d82073f5761e4vboxsync#include <VBox/settings.h>
47f342f6708c08e40ec0c8ec5850e3edee5d6846vboxsync#include "DHCPServerWrap.h"
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#ifdef VBOX_WITH_HOSTNETIF_API
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsyncstruct NETIFINFO;
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#endif
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#ifdef RT_OS_WINDOWS
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#else
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync#endif
47f342f6708c08e40ec0c8ec5850e3edee5d6846vboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsyncclass DHCPServerRunner: public NetworkServiceRunner
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync{
47f342f6708c08e40ec0c8ec5850e3edee5d6846vboxsyncpublic:
47f342f6708c08e40ec0c8ec5850e3edee5d6846vboxsync DHCPServerRunner():NetworkServiceRunner(DHCP_EXECUTABLE_NAME){}
47f342f6708c08e40ec0c8ec5850e3edee5d6846vboxsync virtual ~DHCPServerRunner(){};
47f342f6708c08e40ec0c8ec5850e3edee5d6846vboxsync
f5460c92ad7bac3360afa9868da9a43b0300c1ecvboxsync static const std::string kDsrKeyGateway;
772269936494ffaddd0750ba9e28e805ba81398cvboxsync static const std::string kDsrKeyLowerIp;
352bb6b9d2fa1f7df7797f50c58e297ac37059a2vboxsync static const std::string kDsrKeyUpperIp;
};
/**
* for server configuration needs, it's perhaps better to use (VM,slot) pair
* (vm-name, slot) <----> (MAC)
*
* but for client configuration, when server will have MACs at hand, it'd be
* easier to requiest options by MAC.
* (MAC) <----> (option-list)
*
* Doubts: What should be done if MAC changed for (vm-name, slot), when syncing should?
* XML: serialization of dependecy (DHCP options) - (VM,slot) shouldn't be done via MAC in
* the middle.
*/
using settings::DhcpOptValue;
using settings::DhcpOptionMap;
using settings::DhcpOptValuePair;
using settings::DhcpOptConstIterator;
using settings::DhcpOptIterator;
using settings::VmSlot2OptionsMap;
using settings::VmSlot2OptionsPair;
using settings::VmSlot2OptionsIterator;
class ATL_NO_VTABLE DHCPServer :
public DHCPServerWrap
{
public:
DECLARE_EMPTY_CTOR_DTOR (DHCPServer)
HRESULT FinalConstruct();
void FinalRelease();
HRESULT init(VirtualBox *aVirtualBox,
IN_BSTR aName);
HRESULT init(VirtualBox *aVirtualBox,
const settings::DHCPServer &data);
void uninit();
// Public internal methids.
HRESULT i_saveSettings(settings::DHCPServer &data);
DhcpOptionMap& i_findOptMapByVmNameSlot(const com::Utf8Str& aVmName,
LONG Slot);
private:
HRESULT encodeOption(com::Utf8Str &aEncoded,
uint32_t aOptCode, const DhcpOptValue &aOptValue);
// wrapped IDHCPServer properties
HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
HRESULT getEnabled(BOOL *aEnabled);
HRESULT setEnabled(BOOL aEnabled);
HRESULT getIPAddress(com::Utf8Str &aIPAddress);
HRESULT getNetworkMask(com::Utf8Str &aNetworkMask);
HRESULT getNetworkName(com::Utf8Str &aName);
HRESULT getLowerIP(com::Utf8Str &aIPAddress);
HRESULT getUpperIP(com::Utf8Str &aIPAddress);
HRESULT getGlobalOptions(std::vector<com::Utf8Str> &aGlobalOptions);
HRESULT getVmConfigs(std::vector<com::Utf8Str> &aVmConfigs);
HRESULT getMacOptions(const com::Utf8Str &aMAC, std::vector<com::Utf8Str> &aValues);
HRESULT setConfiguration(const com::Utf8Str &aIPAddress,
const com::Utf8Str &aNetworkMask,
const com::Utf8Str &aFromIPAddress,
const com::Utf8Str &aToIPAddress);
HRESULT getVmSlotOptions(const com::Utf8Str &aVmName,
LONG aSlot,
std::vector<com::Utf8Str> &aValues);
// Wrapped IDHCPServer Methods
HRESULT addGlobalOption(DhcpOpt_T aOption,
const com::Utf8Str &aValue);
HRESULT addVmSlotOption(const com::Utf8Str &aVmName,
LONG aSlot,
DhcpOpt_T aOption,
const com::Utf8Str &aValue);
HRESULT removeVmSlotOptions(const com::Utf8Str &aVmName,
LONG aSlot);
HRESULT start(const com::Utf8Str &aNetworkName,
const com::Utf8Str &aTrunkName,
const com::Utf8Str &aTrunkType);
HRESULT stop();
struct Data;
Data *m;
/** weak VirtualBox parent */
VirtualBox * const mVirtualBox;
const Bstr mName;
};
#endif // ____H_H_DHCPSERVERIMPL