VirtualBox

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

Last change on this file since 76454 was 76190, checked in by vboxsync, 6 years ago

Main/DHCPServer: (bugref:9288) Added --comment command line option to simplify identification of VBoxNetDHCP instanced in the process list

  • 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 76190 2018-12-12 16:58:55Z 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 static const std::string kDsrKeyComment;
54};
55
56/**
57 * for server configuration needs, it's perhaps better to use (VM,slot) pair
58 * (vm-name, slot) <----> (MAC)
59 *
60 * but for client configuration, when server will have MACs at hand, it'd be
61 * easier to requiest options by MAC.
62 * (MAC) <----> (option-list)
63 *
64 * Doubts: What should be done if MAC changed for (vm-name, slot), when syncing should?
65 * XML: serialization of dependecy (DHCP options) - (VM,slot) shouldn't be done via MAC in
66 * the middle.
67 */
68
69class ATL_NO_VTABLE DHCPServer :
70 public DHCPServerWrap
71{
72public:
73
74 DECLARE_EMPTY_CTOR_DTOR(DHCPServer)
75
76 HRESULT FinalConstruct();
77 void FinalRelease();
78
79 HRESULT init(VirtualBox *aVirtualBox,
80 const com::Utf8Str &aName);
81 HRESULT init(VirtualBox *aVirtualBox,
82 const settings::DHCPServer &data);
83 void uninit();
84
85 // Public internal methids.
86 HRESULT i_saveSettings(settings::DHCPServer &data);
87 settings::DhcpOptionMap &i_findOptMapByVmNameSlot(const com::Utf8Str &aVmName,
88 LONG Slot);
89
90private:
91 HRESULT encodeOption(com::Utf8Str &aEncoded,
92 uint32_t aOptCode, const settings::DhcpOptValue &aOptValue);
93 int addOption(settings::DhcpOptionMap &aMap,
94 DhcpOpt_T aOption, const com::Utf8Str &aValue);
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 removeGlobalOption(DhcpOpt_T aOption);
120 HRESULT removeGlobalOptions();
121 HRESULT addVmSlotOption(const com::Utf8Str &aVmName,
122 LONG aSlot,
123 DhcpOpt_T aOption,
124 const com::Utf8Str &aValue);
125 HRESULT removeVmSlotOption(const com::Utf8Str &aVmName,
126 LONG aSlot,
127 DhcpOpt_T aOption);
128 HRESULT removeVmSlotOptions(const com::Utf8Str &aVmName,
129 LONG aSlot);
130 HRESULT start(const com::Utf8Str &aNetworkName,
131 const com::Utf8Str &aTrunkName,
132 const com::Utf8Str &aTrunkType);
133 HRESULT stop();
134 HRESULT restart();
135
136 struct Data;
137 Data *m;
138 /** weak VirtualBox parent */
139 VirtualBox *const mVirtualBox;
140 const Utf8Str mName;
141};
142
143#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