[79732] | 1 | /* $Id: DHCPConfigImpl.h 103977 2024-03-21 02:04:52Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VirtualBox Main - IDHCPConfig, IDHCPConfigGlobal, IDHCPConfigGroup, IDHCPConfigIndividual header.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[79732] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[79732] | 26 | */
|
---|
| 27 |
|
---|
[79735] | 28 | #ifndef MAIN_INCLUDED_DHCPConfigImpl_h
|
---|
| 29 | #define MAIN_INCLUDED_DHCPConfigImpl_h
|
---|
[79732] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | #include "DHCPGlobalConfigWrap.h"
|
---|
[79747] | 35 | #include "DHCPGroupConditionWrap.h"
|
---|
[79732] | 36 | #include "DHCPGroupConfigWrap.h"
|
---|
| 37 | #include "DHCPIndividualConfigWrap.h"
|
---|
| 38 | #include <VBox/settings.h>
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | class DHCPServer;
|
---|
[79747] | 42 | class DHCPGroupConfig;
|
---|
[79732] | 43 |
|
---|
| 44 |
|
---|
| 45 | /**
|
---|
| 46 | * Base class for the a DHCP configration layer.
|
---|
| 47 | *
|
---|
| 48 | * This does not inherit from DHCPConfigWrap because its children need to
|
---|
| 49 | * inherit from children of DHCPConfigWrap, which smells like trouble and thus
|
---|
| 50 | * wasn't even attempted. Instead, we have a hack for passing a pointer that we
|
---|
| 51 | * can call setError and such on.
|
---|
| 52 | */
|
---|
[91312] | 53 | class DHCPConfig
|
---|
[79732] | 54 | {
|
---|
| 55 | protected:
|
---|
| 56 | /** Config scope (global, group, vm+nic, mac). */
|
---|
[79845] | 57 | DHCPConfigScope_T const m_enmScope;
|
---|
[79732] | 58 | /** Minimum lease time. */
|
---|
[79845] | 59 | ULONG m_secMinLeaseTime;
|
---|
[79732] | 60 | /** Default lease time. */
|
---|
[79845] | 61 | ULONG m_secDefaultLeaseTime;
|
---|
[79732] | 62 | /** Maximum lease time. */
|
---|
[79845] | 63 | ULONG m_secMaxLeaseTime;
|
---|
| 64 | /** List of options which are forced upon the client when available, whether
|
---|
| 65 | * requested by it or not. */
|
---|
| 66 | std::vector<DHCPOption_T> m_vecForcedOptions;
|
---|
| 67 | /** List of options which should be suppressed and not returned the the client
|
---|
| 68 | * when available and requested. */
|
---|
| 69 | std::vector<DHCPOption_T> m_vecSuppressedOptions;
|
---|
[79732] | 70 | /** DHCP option map. */
|
---|
[79845] | 71 | settings::DhcpOptionMap m_OptionMap;
|
---|
[79732] | 72 | /** The DHCP server parent (weak). */
|
---|
[79845] | 73 | DHCPServer * const m_pParent;
|
---|
[79732] | 74 | /** The DHCP server parent (weak). */
|
---|
[79845] | 75 | VirtualBox * const m_pVirtualBox;
|
---|
[79732] | 76 | private:
|
---|
| 77 | /** For setError and such. */
|
---|
[79845] | 78 | VirtualBoxBase * const m_pHack;
|
---|
[79732] | 79 |
|
---|
| 80 | protected:
|
---|
| 81 | /** @name Constructors and destructors.
|
---|
| 82 | * @{ */
|
---|
| 83 | DHCPConfig(DHCPConfigScope_T a_enmScope, VirtualBoxBase *a_pHack)
|
---|
| 84 | : m_enmScope(a_enmScope), m_secMinLeaseTime(0), m_secDefaultLeaseTime(0), m_secMaxLeaseTime(0), m_OptionMap()
|
---|
| 85 | , m_pParent(NULL), m_pVirtualBox(NULL), m_pHack(a_pHack)
|
---|
| 86 | {}
|
---|
| 87 | DHCPConfig();
|
---|
| 88 | virtual ~DHCPConfig()
|
---|
| 89 | {}
|
---|
| 90 | HRESULT i_initWithDefaults(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent);
|
---|
| 91 | HRESULT i_initWithSettings(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent, const settings::DHCPConfig &rConfig);
|
---|
| 92 | /** @} */
|
---|
| 93 |
|
---|
| 94 | /** @name IDHCPConfig properties
|
---|
| 95 | * @{ */
|
---|
| 96 | HRESULT i_getScope(DHCPConfigScope_T *aScope);
|
---|
| 97 | HRESULT i_getMinLeaseTime(ULONG *aMinLeaseTime);
|
---|
| 98 | HRESULT i_setMinLeaseTime(ULONG aMinLeaseTime);
|
---|
| 99 | HRESULT i_getDefaultLeaseTime(ULONG *aDefaultLeaseTime);
|
---|
| 100 | HRESULT i_setDefaultLeaseTime(ULONG aDefaultLeaseTime);
|
---|
| 101 | HRESULT i_getMaxLeaseTime(ULONG *aMaxLeaseTime);
|
---|
| 102 | HRESULT i_setMaxLeaseTime(ULONG aMaxLeaseTime);
|
---|
[79845] | 103 | HRESULT i_getForcedOptions(std::vector<DHCPOption_T> &aOptions);
|
---|
| 104 | HRESULT i_setForcedOptions(const std::vector<DHCPOption_T> &aOptions);
|
---|
| 105 | HRESULT i_getSuppressedOptions(std::vector<DHCPOption_T> &aOptions);
|
---|
| 106 | HRESULT i_setSuppressedOptions(const std::vector<DHCPOption_T> &aOptions);
|
---|
[79732] | 107 | /** @} */
|
---|
| 108 |
|
---|
| 109 | public:
|
---|
[90828] | 110 | DECLARE_TRANSLATE_METHODS(DHCPConfig)
|
---|
| 111 |
|
---|
[79732] | 112 | /** @name IDHCPConfig methods
|
---|
| 113 | * @note public because the DHCPServer needs them for 6.0 interfaces.
|
---|
| 114 | * @todo Make protected again when IDHCPServer is cleaned up.
|
---|
| 115 | * @{ */
|
---|
[79845] | 116 | virtual HRESULT i_setOption(DHCPOption_T aOption, DHCPOptionEncoding_T aEncoding, const com::Utf8Str &aValue);
|
---|
[79732] | 117 |
|
---|
[79845] | 118 | virtual HRESULT i_removeOption(DHCPOption_T aOption);
|
---|
[79732] | 119 | virtual HRESULT i_removeAllOptions();
|
---|
[79845] | 120 | HRESULT i_getOption(DHCPOption_T aOption, DHCPOptionEncoding_T *aEncoding, com::Utf8Str &aValue);
|
---|
| 121 | HRESULT i_getAllOptions(std::vector<DHCPOption_T> &aOptions, std::vector<DHCPOptionEncoding_T> &aEncodings,
|
---|
[79732] | 122 | std::vector<com::Utf8Str> &aValues);
|
---|
[79771] | 123 | virtual HRESULT i_remove();
|
---|
[79732] | 124 | /** @} */
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | public:
|
---|
[79747] | 128 | HRESULT i_doWriteConfig();
|
---|
[79732] | 129 | HRESULT i_saveSettings(settings::DHCPConfig &a_rDst);
|
---|
| 130 | DHCPConfigScope_T i_getScope() const RT_NOEXCEPT { return m_enmScope; }
|
---|
| 131 | virtual void i_writeDhcpdConfig(xml::ElementNode *pElm);
|
---|
| 132 | };
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | /**
|
---|
| 136 | * Global DHCP configuration.
|
---|
| 137 | */
|
---|
| 138 | class DHCPGlobalConfig : public DHCPGlobalConfigWrap, public DHCPConfig
|
---|
| 139 | {
|
---|
| 140 | public:
|
---|
[90828] | 141 | DECLARE_TRANSLATE_METHODS(DHCPGlobalConfig)
|
---|
| 142 |
|
---|
[79732] | 143 | /** @name Constructors and destructors.
|
---|
| 144 | * @{ */
|
---|
| 145 | DHCPGlobalConfig()
|
---|
| 146 | : DHCPConfig(DHCPConfigScope_Global, this)
|
---|
| 147 | { }
|
---|
| 148 | HRESULT FinalConstruct()
|
---|
| 149 | {
|
---|
| 150 | return BaseFinalConstruct();
|
---|
| 151 | }
|
---|
| 152 | void FinalRelease()
|
---|
| 153 | {
|
---|
| 154 | uninit();
|
---|
| 155 | BaseFinalRelease();
|
---|
| 156 | }
|
---|
| 157 | HRESULT initWithDefaults(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent);
|
---|
| 158 | HRESULT initWithSettings(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent, const settings::DHCPConfig &rConfig);
|
---|
[103977] | 159 | void uninit() RT_OVERRIDE;
|
---|
[79732] | 160 | /** @} */
|
---|
| 161 |
|
---|
| 162 | HRESULT i_saveSettings(settings::DHCPConfig &a_rDst);
|
---|
| 163 | HRESULT i_getNetworkMask(com::Utf8Str &a_rDst);
|
---|
| 164 | HRESULT i_setNetworkMask(const com::Utf8Str &a_rSrc);
|
---|
| 165 |
|
---|
| 166 | protected:
|
---|
| 167 | /** @name wrapped IDHCPConfig properties
|
---|
| 168 | * @{ */
|
---|
| 169 | HRESULT getScope(DHCPConfigScope_T *aScope) RT_OVERRIDE { return i_getScope(aScope); }
|
---|
| 170 | HRESULT getMinLeaseTime(ULONG *aMinLeaseTime) RT_OVERRIDE { return i_getMinLeaseTime(aMinLeaseTime); }
|
---|
| 171 | HRESULT setMinLeaseTime(ULONG aMinLeaseTime) RT_OVERRIDE { return i_setMinLeaseTime(aMinLeaseTime); }
|
---|
| 172 | HRESULT getDefaultLeaseTime(ULONG *aDefaultLeaseTime) RT_OVERRIDE { return i_getDefaultLeaseTime(aDefaultLeaseTime); }
|
---|
| 173 | HRESULT setDefaultLeaseTime(ULONG aDefaultLeaseTime) RT_OVERRIDE { return i_setDefaultLeaseTime(aDefaultLeaseTime); }
|
---|
| 174 | HRESULT getMaxLeaseTime(ULONG *aMaxLeaseTime) RT_OVERRIDE { return i_getMaxLeaseTime(aMaxLeaseTime); }
|
---|
| 175 | HRESULT setMaxLeaseTime(ULONG aMaxLeaseTime) RT_OVERRIDE { return i_setMaxLeaseTime(aMaxLeaseTime); }
|
---|
[79845] | 176 | HRESULT getForcedOptions(std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_getForcedOptions(aOptions); }
|
---|
| 177 | HRESULT setForcedOptions(const std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_setForcedOptions(aOptions); }
|
---|
| 178 | HRESULT getSuppressedOptions(std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_getSuppressedOptions(aOptions); }
|
---|
| 179 | HRESULT setSuppressedOptions(const std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_setSuppressedOptions(aOptions); }
|
---|
[79732] | 180 | /** @} */
|
---|
| 181 |
|
---|
| 182 | /** @name wrapped IDHCPConfig methods
|
---|
| 183 | * @{ */
|
---|
[79845] | 184 | HRESULT setOption(DHCPOption_T aOption, DHCPOptionEncoding_T aEncoding, const com::Utf8Str &aValue) RT_OVERRIDE
|
---|
[79732] | 185 | {
|
---|
| 186 | return i_setOption(aOption, aEncoding, aValue);
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[79845] | 189 | HRESULT removeOption(DHCPOption_T aOption) RT_OVERRIDE
|
---|
[79732] | 190 | {
|
---|
| 191 | return i_removeOption(aOption);
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | HRESULT removeAllOptions() RT_OVERRIDE
|
---|
| 195 | {
|
---|
| 196 | return i_removeAllOptions();
|
---|
| 197 | }
|
---|
| 198 |
|
---|
[79845] | 199 | HRESULT getOption(DHCPOption_T aOption, DHCPOptionEncoding_T *aEncoding, com::Utf8Str &aValue) RT_OVERRIDE
|
---|
[79732] | 200 | {
|
---|
| 201 | return i_getOption(aOption, aEncoding, aValue);
|
---|
| 202 | }
|
---|
| 203 |
|
---|
[79845] | 204 | HRESULT getAllOptions(std::vector<DHCPOption_T> &aOptions, std::vector<DHCPOptionEncoding_T> &aEncodings,
|
---|
[79732] | 205 | std::vector<com::Utf8Str> &aValues) RT_OVERRIDE
|
---|
| 206 | {
|
---|
| 207 | return i_getAllOptions(aOptions, aEncodings, aValues);
|
---|
| 208 | }
|
---|
[79771] | 209 |
|
---|
| 210 | HRESULT remove() RT_OVERRIDE
|
---|
| 211 | {
|
---|
| 212 | return i_remove();
|
---|
| 213 | }
|
---|
[79732] | 214 | /** @} */
|
---|
| 215 |
|
---|
| 216 | public:
|
---|
[79845] | 217 | HRESULT i_setOption(DHCPOption_T aOption, DHCPOptionEncoding_T aEncoding, const com::Utf8Str &aValue) RT_OVERRIDE;
|
---|
| 218 | HRESULT i_removeOption(DHCPOption_T aOption) RT_OVERRIDE;
|
---|
[79732] | 219 | HRESULT i_removeAllOptions() RT_OVERRIDE;
|
---|
[79771] | 220 | HRESULT i_remove() RT_OVERRIDE;
|
---|
[79732] | 221 | };
|
---|
| 222 |
|
---|
| 223 |
|
---|
| 224 | /**
|
---|
[79747] | 225 | * DHCP Group inclusion/exclusion condition.
|
---|
| 226 | */
|
---|
| 227 | class DHCPGroupCondition : public DHCPGroupConditionWrap
|
---|
| 228 | {
|
---|
| 229 | private:
|
---|
| 230 | /** Inclusive or exclusive condition. */
|
---|
| 231 | bool m_fInclusive;
|
---|
| 232 | /** The condition type (or how m_strValue should be interpreted). */
|
---|
| 233 | DHCPGroupConditionType_T m_enmType;
|
---|
| 234 | /** The value. Interpreted according to m_enmType. */
|
---|
| 235 | com::Utf8Str m_strValue;
|
---|
| 236 | /** Pointer to the parent (weak). */
|
---|
| 237 | DHCPGroupConfig *m_pParent;
|
---|
| 238 |
|
---|
| 239 | public:
|
---|
[90828] | 240 | DECLARE_TRANSLATE_METHODS(DHCPGroupCondition)
|
---|
| 241 |
|
---|
[79747] | 242 | /** @name Constructors and destructors.
|
---|
| 243 | * @{ */
|
---|
| 244 | DHCPGroupCondition()
|
---|
| 245 | : m_enmType(DHCPGroupConditionType_MAC)
|
---|
| 246 | , m_pParent(NULL)
|
---|
| 247 | {}
|
---|
| 248 | HRESULT FinalConstruct()
|
---|
| 249 | {
|
---|
| 250 | return BaseFinalConstruct();
|
---|
| 251 | }
|
---|
| 252 | void FinalRelease()
|
---|
| 253 | {
|
---|
| 254 | uninit();
|
---|
| 255 | BaseFinalRelease();
|
---|
| 256 | }
|
---|
| 257 | HRESULT initWithDefaults(DHCPGroupConfig *a_pParent, bool a_fInclusive, DHCPGroupConditionType_T a_enmType,
|
---|
| 258 | const com::Utf8Str a_strValue);
|
---|
| 259 | HRESULT initWithSettings(DHCPGroupConfig *a_pParent, const settings::DHCPGroupCondition &a_rSrc);
|
---|
[103977] | 260 | void uninit() RT_OVERRIDE;
|
---|
[79747] | 261 | /** @} */
|
---|
| 262 |
|
---|
| 263 | HRESULT i_saveSettings(settings::DHCPGroupCondition &a_rDst);
|
---|
[79771] | 264 | static HRESULT i_validateTypeAndValue(DHCPGroupConditionType_T enmType, com::Utf8Str const &strValue,
|
---|
| 265 | VirtualBoxBase *pErrorDst);
|
---|
[79747] | 266 |
|
---|
[79800] | 267 | /** @name Internal accessors
|
---|
| 268 | * @{ */
|
---|
| 269 | bool i_getInclusive() const RT_NOEXCEPT { return m_fInclusive; }
|
---|
| 270 | DHCPGroupConditionType_T i_getType() const RT_NOEXCEPT { return m_enmType; }
|
---|
| 271 | com::Utf8Str const &i_getValue() const RT_NOEXCEPT { return m_strValue; }
|
---|
| 272 | /** @} */
|
---|
| 273 |
|
---|
[79747] | 274 | protected:
|
---|
| 275 | /** @name Wrapped IDHCPGroupCondition properties
|
---|
| 276 | * @{ */
|
---|
| 277 | HRESULT getInclusive(BOOL *aInclusive) RT_OVERRIDE;
|
---|
| 278 | HRESULT setInclusive(BOOL aInclusive) RT_OVERRIDE;
|
---|
| 279 | HRESULT getType(DHCPGroupConditionType_T *aType) RT_OVERRIDE;
|
---|
| 280 | HRESULT setType(DHCPGroupConditionType_T aType) RT_OVERRIDE;
|
---|
| 281 | HRESULT getValue(com::Utf8Str &aValue) RT_OVERRIDE;
|
---|
| 282 | HRESULT setValue(const com::Utf8Str &aValue) RT_OVERRIDE;
|
---|
| 283 | /** @} */
|
---|
| 284 |
|
---|
| 285 | /** @name Wrapped IDHCPGroupCondition methods
|
---|
| 286 | * @{ */
|
---|
| 287 | HRESULT remove() RT_OVERRIDE;
|
---|
| 288 | /** @} */
|
---|
| 289 | };
|
---|
| 290 |
|
---|
| 291 |
|
---|
| 292 | /**
|
---|
[79732] | 293 | * Group configuration.
|
---|
| 294 | */
|
---|
[79747] | 295 | class DHCPGroupConfig : public DHCPGroupConfigWrap, public DHCPConfig
|
---|
[79732] | 296 | {
|
---|
[79747] | 297 | private:
|
---|
| 298 | /** Group name. */
|
---|
| 299 | com::Utf8Str m_strName;
|
---|
| 300 | /** Group membership conditions. */
|
---|
| 301 | std::vector<ComObjPtr<DHCPGroupCondition> > m_Conditions;
|
---|
| 302 | /** Iterator for m_Conditions. */
|
---|
| 303 | typedef std::vector<ComObjPtr<DHCPGroupCondition> >::iterator ConditionsIterator;
|
---|
| 304 |
|
---|
| 305 | public:
|
---|
[90828] | 306 | DECLARE_TRANSLATE_METHODS(DHCPGroupConfig)
|
---|
| 307 |
|
---|
[79747] | 308 | /** @name Constructors and destructors.
|
---|
| 309 | * @{ */
|
---|
| 310 | DHCPGroupConfig()
|
---|
| 311 | : DHCPConfig(DHCPConfigScope_Group, this)
|
---|
| 312 | { }
|
---|
| 313 | HRESULT FinalConstruct()
|
---|
| 314 | {
|
---|
| 315 | return BaseFinalConstruct();
|
---|
| 316 | }
|
---|
| 317 | void FinalRelease()
|
---|
| 318 | {
|
---|
| 319 | uninit();
|
---|
| 320 | BaseFinalRelease();
|
---|
| 321 | }
|
---|
| 322 | HRESULT initWithDefaults(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent, const com::Utf8Str &a_rName);
|
---|
| 323 | HRESULT initWithSettings(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent, const settings::DHCPGroupConfig &a_rSrc);
|
---|
[103977] | 324 | void uninit() RT_OVERRIDE;
|
---|
[79747] | 325 | /** @} */
|
---|
| 326 |
|
---|
| 327 | HRESULT i_saveSettings(settings::DHCPGroupConfig &a_rDst);
|
---|
| 328 | HRESULT i_removeCondition(DHCPGroupCondition *a_pCondition);
|
---|
[79800] | 329 | void i_writeDhcpdConfig(xml::ElementNode *a_pElmGroup) RT_OVERRIDE;
|
---|
[79747] | 330 |
|
---|
| 331 | protected:
|
---|
| 332 | /** @name Wrapped IDHCPConfig properties
|
---|
| 333 | * @{ */
|
---|
| 334 | HRESULT getScope(DHCPConfigScope_T *aScope) RT_OVERRIDE { return i_getScope(aScope); }
|
---|
| 335 | HRESULT getMinLeaseTime(ULONG *aMinLeaseTime) RT_OVERRIDE { return i_getMinLeaseTime(aMinLeaseTime); }
|
---|
| 336 | HRESULT setMinLeaseTime(ULONG aMinLeaseTime) RT_OVERRIDE { return i_setMinLeaseTime(aMinLeaseTime); }
|
---|
| 337 | HRESULT getDefaultLeaseTime(ULONG *aDefaultLeaseTime) RT_OVERRIDE { return i_getDefaultLeaseTime(aDefaultLeaseTime); }
|
---|
| 338 | HRESULT setDefaultLeaseTime(ULONG aDefaultLeaseTime) RT_OVERRIDE { return i_setDefaultLeaseTime(aDefaultLeaseTime); }
|
---|
| 339 | HRESULT getMaxLeaseTime(ULONG *aMaxLeaseTime) RT_OVERRIDE { return i_getMaxLeaseTime(aMaxLeaseTime); }
|
---|
| 340 | HRESULT setMaxLeaseTime(ULONG aMaxLeaseTime) RT_OVERRIDE { return i_setMaxLeaseTime(aMaxLeaseTime); }
|
---|
[79845] | 341 | HRESULT getForcedOptions(std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_getForcedOptions(aOptions); }
|
---|
| 342 | HRESULT setForcedOptions(const std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_setForcedOptions(aOptions); }
|
---|
| 343 | HRESULT getSuppressedOptions(std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_getSuppressedOptions(aOptions); }
|
---|
| 344 | HRESULT setSuppressedOptions(const std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_setSuppressedOptions(aOptions); }
|
---|
[79747] | 345 | /** @} */
|
---|
| 346 |
|
---|
| 347 | /** @name Wrapped IDHCPGroupConfig properties
|
---|
| 348 | * @{ */
|
---|
| 349 | HRESULT getName(com::Utf8Str &aName) RT_OVERRIDE;
|
---|
| 350 | HRESULT setName(const com::Utf8Str &aName) RT_OVERRIDE;
|
---|
| 351 | HRESULT getConditions(std::vector<ComPtr<IDHCPGroupCondition> > &aConditions) RT_OVERRIDE;
|
---|
| 352 | /** @} */
|
---|
| 353 |
|
---|
| 354 | /** @name Wrapped IDHCPConfig methods
|
---|
| 355 | * @{ */
|
---|
[79845] | 356 | HRESULT setOption(DHCPOption_T aOption, DHCPOptionEncoding_T aEncoding, const com::Utf8Str &aValue) RT_OVERRIDE
|
---|
[79747] | 357 | {
|
---|
| 358 | return i_setOption(aOption, aEncoding, aValue);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
[79845] | 361 | HRESULT removeOption(DHCPOption_T aOption) RT_OVERRIDE
|
---|
[79747] | 362 | {
|
---|
| 363 | return i_removeOption(aOption);
|
---|
| 364 | }
|
---|
| 365 |
|
---|
| 366 | HRESULT removeAllOptions() RT_OVERRIDE
|
---|
| 367 | {
|
---|
| 368 | return i_removeAllOptions();
|
---|
| 369 | }
|
---|
| 370 |
|
---|
[79845] | 371 | HRESULT getOption(DHCPOption_T aOption, DHCPOptionEncoding_T *aEncoding, com::Utf8Str &aValue) RT_OVERRIDE
|
---|
[79747] | 372 | {
|
---|
| 373 | return i_getOption(aOption, aEncoding, aValue);
|
---|
| 374 | }
|
---|
| 375 |
|
---|
[79845] | 376 | HRESULT getAllOptions(std::vector<DHCPOption_T> &aOptions, std::vector<DHCPOptionEncoding_T> &aEncodings,
|
---|
[79747] | 377 | std::vector<com::Utf8Str> &aValues) RT_OVERRIDE
|
---|
| 378 | {
|
---|
| 379 | return i_getAllOptions(aOptions, aEncodings, aValues);
|
---|
| 380 | }
|
---|
[79771] | 381 |
|
---|
| 382 | HRESULT remove() RT_OVERRIDE
|
---|
| 383 | {
|
---|
| 384 | return i_remove();
|
---|
| 385 | }
|
---|
[79747] | 386 | /** @} */
|
---|
| 387 |
|
---|
| 388 | /** @name Wrapped IDHCPGroupConfig methods
|
---|
| 389 | * @{ */
|
---|
| 390 | HRESULT addCondition(BOOL aInclusive, DHCPGroupConditionType_T aType, const com::Utf8Str &aValue,
|
---|
| 391 | ComPtr<IDHCPGroupCondition> &aCondition) RT_OVERRIDE;
|
---|
[79771] | 392 | HRESULT removeAllConditions() RT_OVERRIDE;
|
---|
[79747] | 393 | /** @} */
|
---|
[79732] | 394 | };
|
---|
| 395 |
|
---|
| 396 |
|
---|
| 397 | /**
|
---|
| 398 | * Individual DHCP configuration.
|
---|
| 399 | */
|
---|
| 400 | class DHCPIndividualConfig : public DHCPIndividualConfigWrap, public DHCPConfig
|
---|
| 401 | {
|
---|
| 402 | private:
|
---|
| 403 | /** The MAC address or all zeros. */
|
---|
| 404 | RTMAC m_MACAddress;
|
---|
| 405 | /** The VM ID or all zeros. */
|
---|
| 406 | com::Guid const m_idMachine;
|
---|
| 407 | /** The VM NIC slot number, or ~(ULONG)0. */
|
---|
| 408 | ULONG const m_uSlot;
|
---|
| 409 | /** This is part of a hack to resolve the MAC address for
|
---|
| 410 | * DHCPConfigScope_MachineNIC instances. If non-zero, we m_MACAddress is valid.
|
---|
| 411 | * To deal with the impossibly theoretical scenario that the DHCP server is
|
---|
| 412 | * being started by more than one thread, this is a version number and not just
|
---|
| 413 | * a boolean indicator. */
|
---|
| 414 | uint32_t volatile m_uMACAddressResolvedVersion;
|
---|
| 415 |
|
---|
| 416 | /** The fixed IPv4 address, empty if dynamic. */
|
---|
| 417 | com::Utf8Str m_strFixedAddress;
|
---|
| 418 |
|
---|
| 419 | public:
|
---|
[90828] | 420 | DECLARE_TRANSLATE_METHODS(DHCPIndividualConfig)
|
---|
| 421 |
|
---|
[79732] | 422 | /** @name Constructors and destructors.
|
---|
| 423 | * @{ */
|
---|
| 424 | DHCPIndividualConfig()
|
---|
| 425 | : DHCPConfig(DHCPConfigScope_MAC, this)
|
---|
| 426 | , m_uSlot(~(ULONG)0)
|
---|
[79822] | 427 | , m_uMACAddressResolvedVersion(0)
|
---|
[79732] | 428 | {
|
---|
| 429 | RT_ZERO(m_MACAddress);
|
---|
| 430 | }
|
---|
| 431 | HRESULT FinalConstruct()
|
---|
| 432 | {
|
---|
| 433 | return BaseFinalConstruct();
|
---|
| 434 | }
|
---|
| 435 | void FinalRelease()
|
---|
| 436 | {
|
---|
| 437 | uninit();
|
---|
| 438 | BaseFinalRelease();
|
---|
| 439 | }
|
---|
| 440 | HRESULT initWithMachineIdAndSlot(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent, com::Guid const &a_idMachine,
|
---|
| 441 | ULONG a_uSlot, uint32_t a_uMACAddressVersion);
|
---|
| 442 | HRESULT initWithMACAddress(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent, PCRTMAC a_pMACAddress);
|
---|
| 443 | HRESULT initWithSettingsAndMachineIdAndSlot(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent,
|
---|
| 444 | const settings::DHCPIndividualConfig &rData, com::Guid const &a_idMachine,
|
---|
| 445 | ULONG a_uSlot, uint32_t a_uMACAddressVersion);
|
---|
| 446 | HRESULT initWithSettingsAndMACAddress(VirtualBox *a_pVirtualBox, DHCPServer *a_pParent,
|
---|
| 447 | const settings::DHCPIndividualConfig &rData, PCRTMAC a_pMACAddress);
|
---|
[103977] | 448 | void uninit() RT_OVERRIDE;
|
---|
[79732] | 449 | /** @} */
|
---|
| 450 |
|
---|
| 451 | /** @name Internal methods that are public for various reasons
|
---|
| 452 | * @{ */
|
---|
| 453 | HRESULT i_saveSettings(settings::DHCPIndividualConfig &a_rDst);
|
---|
| 454 | RTMAC const &i_getMACAddress() const RT_NOEXCEPT { return m_MACAddress; }
|
---|
| 455 | com::Guid const &i_getMachineId() const RT_NOEXCEPT { return m_idMachine; }
|
---|
| 456 | ULONG i_getSlot() const RT_NOEXCEPT { return m_uSlot; }
|
---|
| 457 | HRESULT i_getMachineMAC(PRTMAC pMACAddress);
|
---|
| 458 |
|
---|
| 459 | HRESULT i_resolveMACAddress(uint32_t uVersion);
|
---|
| 460 | /** This is used to avoid producing bogus Dhcpd configuration elements. */
|
---|
| 461 | bool i_isMACAddressResolved(uint32_t uVersion) const
|
---|
| 462 | {
|
---|
| 463 | return m_enmScope != DHCPConfigScope_MachineNIC || (int32_t)(m_uMACAddressResolvedVersion - uVersion) >= 0;
|
---|
| 464 | }
|
---|
| 465 | void i_writeDhcpdConfig(xml::ElementNode *pElm) RT_OVERRIDE;
|
---|
| 466 | /** @} */
|
---|
| 467 |
|
---|
| 468 | protected:
|
---|
| 469 | /** @name wrapped IDHCPConfig properties
|
---|
| 470 | * @{ */
|
---|
| 471 | HRESULT getScope(DHCPConfigScope_T *aScope) RT_OVERRIDE { return i_getScope(aScope); }
|
---|
| 472 | HRESULT getMinLeaseTime(ULONG *aMinLeaseTime) RT_OVERRIDE { return i_getMinLeaseTime(aMinLeaseTime); }
|
---|
| 473 | HRESULT setMinLeaseTime(ULONG aMinLeaseTime) RT_OVERRIDE { return i_setMinLeaseTime(aMinLeaseTime); }
|
---|
| 474 | HRESULT getDefaultLeaseTime(ULONG *aDefaultLeaseTime) RT_OVERRIDE { return i_getDefaultLeaseTime(aDefaultLeaseTime); }
|
---|
| 475 | HRESULT setDefaultLeaseTime(ULONG aDefaultLeaseTime) RT_OVERRIDE { return i_setDefaultLeaseTime(aDefaultLeaseTime); }
|
---|
| 476 | HRESULT getMaxLeaseTime(ULONG *aMaxLeaseTime) RT_OVERRIDE { return i_getMaxLeaseTime(aMaxLeaseTime); }
|
---|
| 477 | HRESULT setMaxLeaseTime(ULONG aMaxLeaseTime) RT_OVERRIDE { return i_setMaxLeaseTime(aMaxLeaseTime); }
|
---|
[79845] | 478 | HRESULT getForcedOptions(std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_getForcedOptions(aOptions); }
|
---|
| 479 | HRESULT setForcedOptions(const std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_setForcedOptions(aOptions); }
|
---|
| 480 | HRESULT getSuppressedOptions(std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_getSuppressedOptions(aOptions); }
|
---|
| 481 | HRESULT setSuppressedOptions(const std::vector<DHCPOption_T> &aOptions) RT_OVERRIDE { return i_setSuppressedOptions(aOptions); }
|
---|
[79732] | 482 | /** @} */
|
---|
| 483 |
|
---|
| 484 | /** @name wrapped IDHCPConfig methods
|
---|
| 485 | * @{ */
|
---|
[79845] | 486 | HRESULT setOption(DHCPOption_T aOption, DHCPOptionEncoding_T aEncoding, const com::Utf8Str &aValue) RT_OVERRIDE
|
---|
[79732] | 487 | {
|
---|
| 488 | return i_setOption(aOption, aEncoding, aValue);
|
---|
| 489 | }
|
---|
| 490 |
|
---|
[79845] | 491 | HRESULT removeOption(DHCPOption_T aOption) RT_OVERRIDE
|
---|
[79732] | 492 | {
|
---|
| 493 | return i_removeOption(aOption);
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 | HRESULT removeAllOptions() RT_OVERRIDE
|
---|
| 497 | {
|
---|
| 498 | return i_removeAllOptions();
|
---|
| 499 | }
|
---|
| 500 |
|
---|
[79845] | 501 | HRESULT getOption(DHCPOption_T aOption, DHCPOptionEncoding_T *aEncoding, com::Utf8Str &aValue) RT_OVERRIDE
|
---|
[79732] | 502 | {
|
---|
| 503 | return i_getOption(aOption, aEncoding, aValue);
|
---|
| 504 | }
|
---|
| 505 |
|
---|
[79845] | 506 | HRESULT getAllOptions(std::vector<DHCPOption_T> &aOptions, std::vector<DHCPOptionEncoding_T> &aEncodings,
|
---|
[79732] | 507 | std::vector<com::Utf8Str> &aValues) RT_OVERRIDE
|
---|
| 508 | {
|
---|
| 509 | return i_getAllOptions(aOptions, aEncodings, aValues);
|
---|
| 510 | }
|
---|
[79771] | 511 |
|
---|
| 512 | HRESULT remove() RT_OVERRIDE
|
---|
| 513 | {
|
---|
| 514 | return i_remove();
|
---|
| 515 | }
|
---|
[79732] | 516 | /** @} */
|
---|
| 517 |
|
---|
| 518 | /** @name IDHCPIndividualConfig properties
|
---|
| 519 | * @{ */
|
---|
| 520 | HRESULT getMACAddress(com::Utf8Str &aMacAddress) RT_OVERRIDE;
|
---|
| 521 | HRESULT getMachineId(com::Guid &aId) RT_OVERRIDE;
|
---|
| 522 | HRESULT getSlot(ULONG *aSlot) RT_OVERRIDE;
|
---|
| 523 | HRESULT getFixedAddress(com::Utf8Str &aFixedAddress) RT_OVERRIDE;
|
---|
| 524 | HRESULT setFixedAddress(const com::Utf8Str &aFixedAddress) RT_OVERRIDE;
|
---|
| 525 | /** @} */
|
---|
| 526 | };
|
---|
| 527 |
|
---|
[79735] | 528 | #endif /* !MAIN_INCLUDED_DHCPConfigImpl_h */
|
---|
[79732] | 529 |
|
---|