VirtualBox

source: vbox/trunk/src/VBox/Main/include/DHCPServerImpl.h@ 54351

Last change on this file since 54351 was 54351, checked in by vboxsync, 10 years ago

Main/DHCPServerImpl: factor out code to encode option values for
globalOptions and getVmSlotOptions methods. Encode DhcpOptValue::HEX
options differently. Try to be forward-compatible.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: DHCPServerImpl.h 54351 2015-02-21 01:27:45Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2013 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef ____H_H_DHCPSERVERIMPL
21#define ____H_H_DHCPSERVERIMPL
22
23#include <VBox/settings.h>
24#include "DHCPServerWrap.h"
25
26#ifdef VBOX_WITH_HOSTNETIF_API
27struct NETIFINFO;
28#endif
29
30#ifdef RT_OS_WINDOWS
31# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"
32#else
33# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"
34#endif
35
36class DHCPServerRunner: public NetworkServiceRunner
37{
38public:
39 DHCPServerRunner():NetworkServiceRunner(DHCP_EXECUTABLE_NAME){}
40 virtual ~DHCPServerRunner(){};
41
42 static const std::string kDsrKeyGateway;
43 static const std::string kDsrKeyLowerIp;
44 static const std::string kDsrKeyUpperIp;
45};
46
47/**
48 * for server configuration needs, it's perhaps better to use (VM,slot) pair
49 * (vm-name, slot) <----> (MAC)
50 *
51 * but for client configuration, when server will have MACs at hand, it'd be
52 * easier to requiest options by MAC.
53 * (MAC) <----> (option-list)
54 *
55 * Doubts: What should be done if MAC changed for (vm-name, slot), when syncing should?
56 * XML: serialization of dependecy (DHCP options) - (VM,slot) shouldn't be done via MAC in
57 * the middle.
58 */
59
60using settings::DhcpOptValue;
61using settings::DhcpOptionMap;
62using settings::DhcpOptValuePair;
63using settings::DhcpOptConstIterator;
64using settings::DhcpOptIterator;
65
66using settings::VmSlot2OptionsMap;
67using settings::VmSlot2OptionsPair;
68using settings::VmSlot2OptionsIterator;
69
70
71class ATL_NO_VTABLE DHCPServer :
72 public DHCPServerWrap
73{
74public:
75
76 DECLARE_EMPTY_CTOR_DTOR (DHCPServer)
77
78 HRESULT FinalConstruct();
79 void FinalRelease();
80
81 HRESULT init(VirtualBox *aVirtualBox,
82 IN_BSTR aName);
83 HRESULT init(VirtualBox *aVirtualBox,
84 const settings::DHCPServer &data);
85 void uninit();
86
87 // Public internal methids.
88 HRESULT i_saveSettings(settings::DHCPServer &data);
89 DhcpOptionMap& i_findOptMapByVmNameSlot(const com::Utf8Str& aVmName,
90 LONG Slot);
91
92private:
93 HRESULT encodeOption(com::Utf8Str &aEncoded,
94 uint32_t aOptCode, const DhcpOptValue &aOptValue);
95
96 // wrapped IDHCPServer properties
97 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
98 HRESULT getEnabled(BOOL *aEnabled);
99 HRESULT setEnabled(BOOL aEnabled);
100 HRESULT getIPAddress(com::Utf8Str &aIPAddress);
101 HRESULT getNetworkMask(com::Utf8Str &aNetworkMask);
102 HRESULT getNetworkName(com::Utf8Str &aName);
103 HRESULT getLowerIP(com::Utf8Str &aIPAddress);
104 HRESULT getUpperIP(com::Utf8Str &aIPAddress);
105 HRESULT getGlobalOptions(std::vector<com::Utf8Str> &aGlobalOptions);
106 HRESULT getVmConfigs(std::vector<com::Utf8Str> &aVmConfigs);
107 HRESULT getMacOptions(const com::Utf8Str &aMAC, std::vector<com::Utf8Str> &aValues);
108 HRESULT setConfiguration(const com::Utf8Str &aIPAddress,
109 const com::Utf8Str &aNetworkMask,
110 const com::Utf8Str &aFromIPAddress,
111 const com::Utf8Str &aToIPAddress);
112 HRESULT getVmSlotOptions(const com::Utf8Str &aVmName,
113 LONG aSlot,
114 std::vector<com::Utf8Str> &aValues);
115
116 // Wrapped IDHCPServer Methods
117 HRESULT addGlobalOption(DhcpOpt_T aOption,
118 const com::Utf8Str &aValue);
119 HRESULT addVmSlotOption(const com::Utf8Str &aVmName,
120 LONG aSlot,
121 DhcpOpt_T aOption,
122 const com::Utf8Str &aValue);
123 HRESULT removeVmSlotOptions(const com::Utf8Str &aVmName,
124 LONG aSlot);
125 HRESULT start(const com::Utf8Str &aNetworkName,
126 const com::Utf8Str &aTrunkName,
127 const com::Utf8Str &aTrunkType);
128 HRESULT stop();
129
130 struct Data;
131 Data *m;
132 /** weak VirtualBox parent */
133 VirtualBox * const mVirtualBox;
134 const Bstr mName;
135
136};
137
138#endif // ____H_H_DHCPSERVERIMPL
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette