1 | /* $Id: HostNetworkInterfaceImpl.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox base platform packages, as
|
---|
12 | * available from https://www.virtualbox.org.
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or
|
---|
15 | * modify it under the terms of the GNU General Public License
|
---|
16 | * as published by the Free Software Foundation, in version 3 of the
|
---|
17 | * License.
|
---|
18 | *
|
---|
19 | * This program is distributed in the hope that it will be useful, but
|
---|
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | * General Public License for more details.
|
---|
23 | *
|
---|
24 | * You should have received a copy of the GNU General Public License
|
---|
25 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | *
|
---|
27 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef MAIN_INCLUDED_HostNetworkInterfaceImpl_h
|
---|
31 | #define MAIN_INCLUDED_HostNetworkInterfaceImpl_h
|
---|
32 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
33 | # pragma once
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #include "HostNetworkInterfaceWrap.h"
|
---|
37 |
|
---|
38 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
39 | struct NETIFINFO;
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | class PerformanceCollector;
|
---|
43 |
|
---|
44 | class ATL_NO_VTABLE HostNetworkInterface :
|
---|
45 | public HostNetworkInterfaceWrap
|
---|
46 | {
|
---|
47 | public:
|
---|
48 |
|
---|
49 | DECLARE_COMMON_CLASS_METHODS(HostNetworkInterface)
|
---|
50 |
|
---|
51 | HRESULT FinalConstruct();
|
---|
52 | void FinalRelease();
|
---|
53 |
|
---|
54 | // public initializer/uninitializer for internal purposes only
|
---|
55 | HRESULT init(Utf8Str aInterfaceName, Utf8Str aShortName, Guid aGuid, HostNetworkInterfaceType_T ifType);
|
---|
56 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
57 | HRESULT init(Utf8Str aInterfaceName, HostNetworkInterfaceType_T ifType, struct NETIFINFO *pIfs);
|
---|
58 | HRESULT updateConfig();
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | HRESULT i_setVirtualBox(VirtualBox *pVirtualBox);
|
---|
62 | #ifdef RT_OS_WINDOWS
|
---|
63 | HRESULT i_updatePersistentConfig();
|
---|
64 | #endif /* RT_OS_WINDOWS */
|
---|
65 |
|
---|
66 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
67 | void i_registerMetrics(PerformanceCollector *aCollector, ComPtr<IUnknown> objptr);
|
---|
68 | void i_unregisterMetrics(PerformanceCollector *aCollector, ComPtr<IUnknown> objptr);
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | private:
|
---|
72 |
|
---|
73 | // Wrapped IHostNetworkInterface properties
|
---|
74 | HRESULT getName(com::Utf8Str &aName);
|
---|
75 | HRESULT getShortName(com::Utf8Str &aShortName);
|
---|
76 | HRESULT getId(com::Guid &aGuiId);
|
---|
77 | HRESULT getDHCPEnabled(BOOL *aDHCPEnabled);
|
---|
78 | HRESULT getIPAddress(com::Utf8Str &aIPAddress);
|
---|
79 | HRESULT getNetworkMask(com::Utf8Str &aNetworkMask);
|
---|
80 | HRESULT getIPV6Supported(BOOL *aIPV6Supported);
|
---|
81 | HRESULT getIPV6Address(com::Utf8Str &aIPV6Address);
|
---|
82 | HRESULT getIPV6NetworkMaskPrefixLength(ULONG *aIPV6NetworkMaskPrefixLength);
|
---|
83 | HRESULT getHardwareAddress(com::Utf8Str &aHardwareAddress);
|
---|
84 | HRESULT getMediumType(HostNetworkInterfaceMediumType_T *aType);
|
---|
85 | HRESULT getStatus(HostNetworkInterfaceStatus_T *aStatus);
|
---|
86 | HRESULT getInterfaceType(HostNetworkInterfaceType_T *aType);
|
---|
87 | HRESULT getNetworkName(com::Utf8Str &aNetworkName);
|
---|
88 | HRESULT getWireless(BOOL *aWireless);
|
---|
89 |
|
---|
90 | // Wrapped IHostNetworkInterface methods
|
---|
91 | HRESULT enableStaticIPConfig(const com::Utf8Str &aIPAddress,
|
---|
92 | const com::Utf8Str &aNetworkMask);
|
---|
93 | HRESULT enableStaticIPConfigV6(const com::Utf8Str &aIPV6Address,
|
---|
94 | ULONG aIPV6NetworkMaskPrefixLength);
|
---|
95 | HRESULT enableDynamicIPConfig();
|
---|
96 | HRESULT dHCPRediscover();
|
---|
97 |
|
---|
98 | Utf8Str i_composeNetworkName(const Utf8Str szShortName);
|
---|
99 |
|
---|
100 | #if defined(RT_OS_WINDOWS)
|
---|
101 | HRESULT eraseAdapterConfigParameter(const char *szParamName);
|
---|
102 | HRESULT saveAdapterConfigParameter(const char *szParamName, const Utf8Str& strValue);
|
---|
103 | HRESULT saveAdapterConfigIPv4Dhcp();
|
---|
104 | HRESULT saveAdapterConfigIPv4(ULONG addr, ULONG mask);
|
---|
105 | HRESULT saveAdapterConfigIPv6(const Utf8Str& addr, ULONG prefix);
|
---|
106 | HRESULT saveAdapterConfig();
|
---|
107 | bool isInConfigFile();
|
---|
108 | #endif /* defined(RT_OS_WINDOWS) */
|
---|
109 |
|
---|
110 | const Utf8Str mInterfaceName;
|
---|
111 | const Guid mGuid;
|
---|
112 | const Utf8Str mNetworkName;
|
---|
113 | const Utf8Str mShortName;
|
---|
114 | HostNetworkInterfaceType_T mIfType;
|
---|
115 |
|
---|
116 | VirtualBox * const mVirtualBox;
|
---|
117 |
|
---|
118 | struct Data
|
---|
119 | {
|
---|
120 | Data() : IPAddress(0), networkMask(0), dhcpEnabled(FALSE),
|
---|
121 | mediumType(HostNetworkInterfaceMediumType_Unknown),
|
---|
122 | status(HostNetworkInterfaceStatus_Down), wireless(FALSE){}
|
---|
123 |
|
---|
124 | ULONG IPAddress;
|
---|
125 | ULONG networkMask;
|
---|
126 | Utf8Str IPV6Address;
|
---|
127 | ULONG IPV6NetworkMaskPrefixLength;
|
---|
128 | ULONG realIPAddress;
|
---|
129 | ULONG realNetworkMask;
|
---|
130 | Utf8Str realIPV6Address;
|
---|
131 | ULONG realIPV6PrefixLength;
|
---|
132 | BOOL dhcpEnabled;
|
---|
133 | Utf8Str hardwareAddress;
|
---|
134 | HostNetworkInterfaceMediumType_T mediumType;
|
---|
135 | HostNetworkInterfaceStatus_T status;
|
---|
136 | ULONG speedMbits;
|
---|
137 | BOOL wireless;
|
---|
138 | } m;
|
---|
139 |
|
---|
140 | };
|
---|
141 |
|
---|
142 | typedef std::list<ComObjPtr<HostNetworkInterface> > HostNetworkInterfaceList;
|
---|
143 |
|
---|
144 | #endif /* !MAIN_INCLUDED_HostNetworkInterfaceImpl_h */
|
---|
145 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|