1 | /* $Id: NetworkAdapterImpl.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 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_NetworkAdapterImpl_h
|
---|
19 | #define MAIN_INCLUDED_NetworkAdapterImpl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "NetworkAdapterWrap.h"
|
---|
25 |
|
---|
26 | class GuestOSType;
|
---|
27 | class BandwidthControl;
|
---|
28 | class BandwidthGroup;
|
---|
29 | class NATEngine;
|
---|
30 |
|
---|
31 | namespace settings
|
---|
32 | {
|
---|
33 | struct NetworkAdapter;
|
---|
34 | }
|
---|
35 |
|
---|
36 | class ATL_NO_VTABLE NetworkAdapter :
|
---|
37 | public NetworkAdapterWrap
|
---|
38 | {
|
---|
39 | public:
|
---|
40 |
|
---|
41 | DECLARE_COMMON_CLASS_METHODS(NetworkAdapter)
|
---|
42 |
|
---|
43 | HRESULT FinalConstruct();
|
---|
44 | void FinalRelease();
|
---|
45 |
|
---|
46 | // public initializer/uninitializer for internal purposes only
|
---|
47 | HRESULT init(Machine *aParent, ULONG aSlot);
|
---|
48 | HRESULT init(Machine *aParent, NetworkAdapter *aThat, bool aReshare = false);
|
---|
49 | HRESULT initCopy(Machine *aParent, NetworkAdapter *aThat);
|
---|
50 | void uninit();
|
---|
51 |
|
---|
52 | // public methods only for internal purposes
|
---|
53 | HRESULT i_loadSettings(BandwidthControl *bwctl, const settings::NetworkAdapter &data);
|
---|
54 | HRESULT i_saveSettings(settings::NetworkAdapter &data);
|
---|
55 |
|
---|
56 | bool i_isModified();
|
---|
57 | void i_rollback();
|
---|
58 | void i_commit();
|
---|
59 | void i_copyFrom(NetworkAdapter *aThat);
|
---|
60 | void i_applyDefaults(GuestOSType *aOsType);
|
---|
61 | bool i_hasDefaults();
|
---|
62 |
|
---|
63 | ComObjPtr<NetworkAdapter> i_getPeer();
|
---|
64 |
|
---|
65 | private:
|
---|
66 |
|
---|
67 | // wrapped INetworkAdapter properties
|
---|
68 | HRESULT getAdapterType(NetworkAdapterType_T *aAdapterType);
|
---|
69 | HRESULT setAdapterType(NetworkAdapterType_T aAdapterType);
|
---|
70 | HRESULT getSlot(ULONG *aSlot);
|
---|
71 | HRESULT getEnabled(BOOL *aEnabled);
|
---|
72 | HRESULT setEnabled(BOOL aEnabled);
|
---|
73 | HRESULT getMACAddress(com::Utf8Str &aMACAddress);
|
---|
74 | HRESULT setMACAddress(const com::Utf8Str &aMACAddress);
|
---|
75 | HRESULT getAttachmentType(NetworkAttachmentType_T *aAttachmentType);
|
---|
76 | HRESULT setAttachmentType(NetworkAttachmentType_T aAttachmentType);
|
---|
77 | HRESULT getBridgedInterface(com::Utf8Str &aBridgedInterface);
|
---|
78 | HRESULT setBridgedInterface(const com::Utf8Str &aBridgedInterface);
|
---|
79 | HRESULT getHostOnlyInterface(com::Utf8Str &aHostOnlyInterface);
|
---|
80 | HRESULT setHostOnlyInterface(const com::Utf8Str &aHostOnlyInterface);
|
---|
81 | HRESULT getHostOnlyNetwork(com::Utf8Str &aHostOnlyNetwork);
|
---|
82 | HRESULT setHostOnlyNetwork(const com::Utf8Str &aHostOnlyNetwork);
|
---|
83 | HRESULT getInternalNetwork(com::Utf8Str &aInternalNetwork);
|
---|
84 | HRESULT setInternalNetwork(const com::Utf8Str &aInternalNetwork);
|
---|
85 | HRESULT getNATNetwork(com::Utf8Str &aNATNetwork);
|
---|
86 | HRESULT setNATNetwork(const com::Utf8Str &aNATNetwork);
|
---|
87 | HRESULT getGenericDriver(com::Utf8Str &aGenericDriver);
|
---|
88 | HRESULT setGenericDriver(const com::Utf8Str &aGenericDriver);
|
---|
89 | HRESULT getCloudNetwork(com::Utf8Str &aCloudNetwork);
|
---|
90 | HRESULT setCloudNetwork(const com::Utf8Str &aCloudNetwork);
|
---|
91 | HRESULT getCableConnected(BOOL *aCableConnected);
|
---|
92 | HRESULT setCableConnected(BOOL aCableConnected);
|
---|
93 | HRESULT getLineSpeed(ULONG *aLineSpeed);
|
---|
94 | HRESULT setLineSpeed(ULONG aLineSpeed);
|
---|
95 | HRESULT getPromiscModePolicy(NetworkAdapterPromiscModePolicy_T *aPromiscModePolicy);
|
---|
96 | HRESULT setPromiscModePolicy(NetworkAdapterPromiscModePolicy_T aPromiscModePolicy);
|
---|
97 | HRESULT getTraceEnabled(BOOL *aTraceEnabled);
|
---|
98 | HRESULT setTraceEnabled(BOOL aTraceEnabled);
|
---|
99 | HRESULT getTraceFile(com::Utf8Str &aTraceFile);
|
---|
100 | HRESULT setTraceFile(const com::Utf8Str &aTraceFile);
|
---|
101 | HRESULT getNATEngine(ComPtr<INATEngine> &aNATEngine);
|
---|
102 | HRESULT getBootPriority(ULONG *aBootPriority);
|
---|
103 | HRESULT setBootPriority(ULONG aBootPriority);
|
---|
104 | HRESULT getBandwidthGroup(ComPtr<IBandwidthGroup> &aBandwidthGroup);
|
---|
105 | HRESULT setBandwidthGroup(const ComPtr<IBandwidthGroup> &aBandwidthGroup);
|
---|
106 |
|
---|
107 | // wrapped INetworkAdapter methods
|
---|
108 | HRESULT getProperty(const com::Utf8Str &aKey,
|
---|
109 | com::Utf8Str &aValue);
|
---|
110 | HRESULT setProperty(const com::Utf8Str &aKey,
|
---|
111 | const com::Utf8Str &aValue);
|
---|
112 | HRESULT getProperties(const com::Utf8Str &aNames,
|
---|
113 | std::vector<com::Utf8Str> &aReturnNames,
|
---|
114 | std::vector<com::Utf8Str> &aReturnValues);
|
---|
115 | // Misc.
|
---|
116 | void i_generateMACAddress();
|
---|
117 | HRESULT i_updateMacAddress(Utf8Str aMacAddress);
|
---|
118 | void i_updateBandwidthGroup(BandwidthGroup *aBwGroup);
|
---|
119 | HRESULT i_switchFromNatNetworking(const com::Utf8Str &aNatnetworkName);
|
---|
120 | HRESULT i_switchToNatNetworking(const com::Utf8Str &aNatNetworkName);
|
---|
121 |
|
---|
122 |
|
---|
123 | Machine * const mParent;
|
---|
124 | const ComObjPtr<NetworkAdapter> mPeer;
|
---|
125 | const ComObjPtr<NATEngine> mNATEngine;
|
---|
126 |
|
---|
127 | Backupable<settings::NetworkAdapter> mData;
|
---|
128 | };
|
---|
129 |
|
---|
130 | #endif /* !MAIN_INCLUDED_NetworkAdapterImpl_h */
|
---|
131 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|