VirtualBox

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

Last change on this file since 75920 was 75819, checked in by vboxsync, 6 years ago

Main/DHCPServer: (bugref:9288) Allow removal of DHCP options, show options when listing DHCP servers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: DHCPServerImpl.h 75819 2018-11-29 16:16:40Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2017 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 "DHCPServerWrap.h"
24
25namespace settings
26{
27 struct DHCPServer;
28 struct DhcpOptValue;
29 typedef std::map<DhcpOpt_T, DhcpOptValue> DhcpOptionMap;
30}
31
32
33#ifdef VBOX_WITH_HOSTNETIF_API
34struct NETIFINFO;
35#endif
36
37#ifdef RT_OS_WINDOWS
38# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"
39#else
40# define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"
41#endif
42
43class DHCPServerRunner: public NetworkServiceRunner
44{
45public:
46 DHCPServerRunner():NetworkServiceRunner(DHCP_EXECUTABLE_NAME){}
47 virtual ~DHCPServerRunner(){};
48
49 static const std::string kDsrKeyGateway;
50 static const std::string kDsrKeyLowerIp;
51 static const std::string kDsrKeyUpperIp;
52 static const std::string kDsrKeyConfig;
53};
54
55/**
56 * for server configuration needs, it's perhaps better to use (VM,slot) pair
57 * (vm-name, slot) <----> (MAC)
58 *
59 * but for client configuration, when server will have MACs at hand, it'd be
60 * easier to requiest options by MAC.
61 * (MAC) <----> (option-list)
62 *
63 * Doubts: What should be done if MAC changed for (vm-name, slot), when syncing should?
64 * XML: serialization of dependecy (DHCP options) - (VM,slot) shouldn't be done via MAC in
65 * the middle.
66 */
67
68class ATL_NO_VTABLE DHCPServer :
69 public DHCPServerWrap
70{
71public:
72
73 DECLARE_EMPTY_CTOR_DTOR(DHCPServer)
74
75 HRESULT FinalConstruct();
76 void FinalRelease();
77
78 HRESULT init(VirtualBox *aVirtualBox,
79 const com::Utf8Str &aName);
80 HRESULT init(VirtualBox *aVirtualBox,
81 const settings::DHCPServer &data);
82 void uninit();
83
84 // Public internal methids.
85 HRESULT i_saveSettings(settings::DHCPServer &data);
86 settings::DhcpOptionMap &i_findOptMapByVmNameSlot(const com::Utf8Str &aVmName,
87 LONG Slot);
88
89private:
90 HRESULT encodeOption(com::Utf8Str &aEncoded,
91 uint32_t aOptCode, const settings::DhcpOptValue &aOptValue);
92 int addOption(settings::DhcpOptionMap &aMap,
93 DhcpOpt_T aOption, const com::Utf8Str &aValue);
94
95 // wrapped IDHCPServer properties
96 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
97 HRESULT getEnabled(BOOL *aEnabled);
98 HRESULT setEnabled(BOOL aEnabled);
99 HRESULT getIPAddress(com::Utf8Str &aIPAddress);
100 HRESULT getNetworkMask(com::Utf8Str &aNetworkMask);
101 HRESULT getNetworkName(com::Utf8Str &aName);
102 HRESULT getLowerIP(com::Utf8Str &aIPAddress);
103 HRESULT getUpperIP(com::Utf8Str &aIPAddress);
104 HRESULT getGlobalOptions(std::vector<com::Utf8Str> &aGlobalOptions);
105 HRESULT getVmConfigs(std::vector<com::Utf8Str> &aVmConfigs);
106 HRESULT getMacOptions(const com::Utf8Str &aMAC, std::vector<com::Utf8Str> &aValues);
107 HRESULT setConfiguration(const com::Utf8Str &aIPAddress,
108 const com::Utf8Str &aNetworkMask,
109 const com::Utf8Str &aFromIPAddress,
110 const com::Utf8Str &aToIPAddress);
111 HRESULT getVmSlotOptions(const com::Utf8Str &aVmName,
112 LONG aSlot,
113 std::vector<com::Utf8Str> &aValues);
114
115 // Wrapped IDHCPServer Methods
116 HRESULT addGlobalOption(DhcpOpt_T aOption,
117 const com::Utf8Str &aValue);
118 HRESULT removeGlobalOption(DhcpOpt_T aOption);
119 HRESULT removeGlobalOptions();
120 HRESULT addVmSlotOption(const com::Utf8Str &aVmName,
121 LONG aSlot,
122 DhcpOpt_T aOption,
123 const com::Utf8Str &aValue);
124 HRESULT removeVmSlotOption(const com::Utf8Str &aVmName,
125 LONG aSlot,
126 DhcpOpt_T aOption);
127 HRESULT removeVmSlotOptions(const com::Utf8Str &aVmName,
128 LONG aSlot);
129 HRESULT start(const com::Utf8Str &aNetworkName,
130 const com::Utf8Str &aTrunkName,
131 const com::Utf8Str &aTrunkType);
132 HRESULT stop();
133 HRESULT restart();
134
135 struct Data;
136 Data *m;
137 /** weak VirtualBox parent */
138 VirtualBox *const mVirtualBox;
139 const Utf8Str mName;
140};
141
142#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