VirtualBox

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

Last change on this file since 77110 was 76562, checked in by vboxsync, 6 years ago

Main: Use MAIN_INCLUDED_ and MAIN_INCLUDED_SRC_ as header guard prefixes with scm.

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