VirtualBox

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

Last change on this file since 98103 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: DHCPServerImpl.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
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
26 */
27
28#ifndef MAIN_INCLUDED_DHCPServerImpl_h
29#define MAIN_INCLUDED_DHCPServerImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "DHCPServerWrap.h"
35#include <map>
36
37namespace settings
38{
39 struct DHCPServer;
40 struct DhcpOptValue;
41 typedef std::map<DHCPOption_T, DhcpOptValue> DhcpOptionMap;
42}
43
44class DHCPConfig;
45class DHCPIndividualConfig;
46
47/**
48 * A DHCP server for internal host-only & NAT networks.
49 *
50 * Old notes:
51 *
52 * for server configuration needs, it's perhaps better to use (VM,slot) pair
53 * (vm-name, slot) <----> (MAC)
54 *
55 * but for client configuration, when server will have MACs at hand, it'd be
56 * easier to requiest options by MAC.
57 * (MAC) <----> (option-list)
58 *
59 * Doubts: What should be done if MAC changed for (vm-name, slot), when syncing should?
60 * XML: serialization of dependecy (DHCP options) - (VM,slot) shouldn't be done via MAC in
61 * the middle.
62 */
63class ATL_NO_VTABLE DHCPServer
64 : public DHCPServerWrap
65{
66public:
67 /** @name Constructors and destructors
68 * @{ */
69 DECLARE_COMMON_CLASS_METHODS(DHCPServer)
70 HRESULT FinalConstruct();
71 void FinalRelease();
72
73 HRESULT init(VirtualBox *aVirtualBox, const com::Utf8Str &aName);
74 HRESULT init(VirtualBox *aVirtualBox, const settings::DHCPServer &data);
75 void uninit();
76 /** @} */
77
78 /** @name Public internal methods.
79 * @{ */
80 HRESULT i_saveSettings(settings::DHCPServer &data);
81 HRESULT i_removeConfig(DHCPConfig *pConfig, DHCPConfigScope_T enmScope);
82 /** @} */
83
84private:
85 /** @name IDHCPServer Properties
86 * @{ */
87 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource) RT_OVERRIDE;
88 HRESULT getEnabled(BOOL *aEnabled) RT_OVERRIDE;
89 HRESULT setEnabled(BOOL aEnabled) RT_OVERRIDE;
90 HRESULT getIPAddress(com::Utf8Str &aIPAddress) RT_OVERRIDE;
91 HRESULT getNetworkMask(com::Utf8Str &aNetworkMask) RT_OVERRIDE;
92 HRESULT getNetworkName(com::Utf8Str &aName) RT_OVERRIDE;
93 HRESULT getLowerIP(com::Utf8Str &aIPAddress) RT_OVERRIDE;
94 HRESULT getUpperIP(com::Utf8Str &aIPAddress) RT_OVERRIDE;
95 HRESULT setConfiguration(const com::Utf8Str &aIPAddress, const com::Utf8Str &aNetworkMask,
96 const com::Utf8Str &aFromIPAddress, const com::Utf8Str &aToIPAddress) RT_OVERRIDE;
97 HRESULT getGlobalConfig(ComPtr<IDHCPGlobalConfig> &aGlobalConfig) RT_OVERRIDE;
98 HRESULT getGroupConfigs(std::vector<ComPtr<IDHCPGroupConfig> > &aGroupConfigs) RT_OVERRIDE;
99 HRESULT getIndividualConfigs(std::vector<ComPtr<IDHCPIndividualConfig> > &aIndividualConfigs) ;
100 /** @} */
101
102 /** @name IDHCPServer Methods
103 * @{ */
104 HRESULT start(const com::Utf8Str &aTrunkName, const com::Utf8Str &aTrunkType) RT_OVERRIDE;
105 HRESULT stop() RT_OVERRIDE;
106 HRESULT restart() RT_OVERRIDE;
107 HRESULT findLeaseByMAC(const com::Utf8Str &aMac, LONG aType, com::Utf8Str &aAddress, com::Utf8Str &aState,
108 LONG64 *aIssued, LONG64 *aExpire) RT_OVERRIDE;
109 HRESULT getConfig(DHCPConfigScope_T aScope, const com::Utf8Str &aName, ULONG aSlot, BOOL aMayAdd,
110 ComPtr<IDHCPConfig> &aConfig) RT_OVERRIDE;
111 /** @} */
112
113 /** @name Helpers
114 * @{ */
115 HRESULT i_doSaveSettings();
116 HRESULT i_calcLeasesConfigAndLogFilenames(const com::Utf8Str &aNetwork) RT_NOEXCEPT;
117 HRESULT i_writeDhcpdConfig(const char *pszFilename, uint32_t uMACAddressVersion) RT_NOEXCEPT;
118
119 HRESULT i_vmNameToIdAndValidateSlot(const com::Utf8Str &aVmName, ULONG a_uSlot, com::Guid &idMachine);
120 HRESULT i_vmNameAndSlotToConfig(const com::Utf8Str &a_strVmName, ULONG a_uSlot, bool a_fCreateIfNeeded,
121 ComObjPtr<DHCPIndividualConfig> &a_rPtrConfig);
122 /** @} */
123
124 /** Private data */
125 struct Data;
126 /** Private data. */
127 Data *m;
128};
129
130#endif /* !MAIN_INCLUDED_DHCPServerImpl_h */
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