1 | /* $Id: NetworkAdapterImpl.h 49951 2013-12-17 11:44:22Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2013 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_NETWORKADAPTER
|
---|
21 | #define ____H_NETWORKADAPTER
|
---|
22 |
|
---|
23 | #include "NetworkAdapterWrap.h"
|
---|
24 |
|
---|
25 | class GuestOSType;
|
---|
26 | class BandwidthControl;
|
---|
27 | class BandwidthGroup;
|
---|
28 | class NATEngine;
|
---|
29 |
|
---|
30 | namespace settings
|
---|
31 | {
|
---|
32 | struct NetworkAdapter;
|
---|
33 | }
|
---|
34 |
|
---|
35 | class ATL_NO_VTABLE NetworkAdapter :
|
---|
36 | public NetworkAdapterWrap
|
---|
37 | {
|
---|
38 | public:
|
---|
39 |
|
---|
40 | DECLARE_EMPTY_CTOR_DTOR(NetworkAdapter)
|
---|
41 |
|
---|
42 | HRESULT FinalConstruct();
|
---|
43 | void FinalRelease();
|
---|
44 |
|
---|
45 | // public initializer/uninitializer for internal purposes only
|
---|
46 | HRESULT init(Machine *aParent, ULONG aSlot);
|
---|
47 | HRESULT init(Machine *aParent, NetworkAdapter *aThat, bool aReshare = false);
|
---|
48 | HRESULT initCopy(Machine *aParent, NetworkAdapter *aThat);
|
---|
49 | void uninit();
|
---|
50 |
|
---|
51 | // public methods only for internal purposes
|
---|
52 | HRESULT i_loadSettings(BandwidthControl *bwctl, const settings::NetworkAdapter &data);
|
---|
53 | HRESULT i_saveSettings(settings::NetworkAdapter &data);
|
---|
54 |
|
---|
55 | bool i_isModified();
|
---|
56 | void i_rollback();
|
---|
57 | void i_commit();
|
---|
58 | void i_copyFrom(NetworkAdapter *aThat);
|
---|
59 | void i_applyDefaults(GuestOSType *aOsType);
|
---|
60 |
|
---|
61 | ComObjPtr<NetworkAdapter> i_getPeer();
|
---|
62 |
|
---|
63 | private:
|
---|
64 |
|
---|
65 | // wrapped INetworkAdapter properties
|
---|
66 | HRESULT getAdapterType(NetworkAdapterType_T *aAdapterType);
|
---|
67 | HRESULT setAdapterType(NetworkAdapterType_T aAdapterType);
|
---|
68 | HRESULT getSlot(ULONG *aSlot);
|
---|
69 | HRESULT getEnabled(BOOL *aEnabled);
|
---|
70 | HRESULT setEnabled(BOOL aEnabled);
|
---|
71 | HRESULT getMACAddress(com::Utf8Str &aMACAddress);
|
---|
72 | HRESULT setMACAddress(const com::Utf8Str &aMACAddress);
|
---|
73 | HRESULT getAttachmentType(NetworkAttachmentType_T *aAttachmentType);
|
---|
74 | HRESULT setAttachmentType(NetworkAttachmentType_T aAttachmentType);
|
---|
75 | HRESULT getBridgedInterface(com::Utf8Str &aBridgedInterface);
|
---|
76 | HRESULT setBridgedInterface(const com::Utf8Str &aBridgedInterface);
|
---|
77 | HRESULT getHostOnlyInterface(com::Utf8Str &aHostOnlyInterface);
|
---|
78 | HRESULT setHostOnlyInterface(const com::Utf8Str &aHostOnlyInterface);
|
---|
79 | HRESULT getInternalNetwork(com::Utf8Str &aInternalNetwork);
|
---|
80 | HRESULT setInternalNetwork(const com::Utf8Str &aInternalNetwork);
|
---|
81 | HRESULT getNATNetwork(com::Utf8Str &aNATNetwork);
|
---|
82 | HRESULT setNATNetwork(const com::Utf8Str &aNATNetwork);
|
---|
83 | HRESULT getGenericDriver(com::Utf8Str &aGenericDriver);
|
---|
84 | HRESULT setGenericDriver(const com::Utf8Str &aGenericDriver);
|
---|
85 | HRESULT getCableConnected(BOOL *aCableConnected);
|
---|
86 | HRESULT setCableConnected(BOOL aCableConnected);
|
---|
87 | HRESULT getLineSpeed(ULONG *aLineSpeed);
|
---|
88 | HRESULT setLineSpeed(ULONG aLineSpeed);
|
---|
89 | HRESULT getPromiscModePolicy(NetworkAdapterPromiscModePolicy_T *aPromiscModePolicy);
|
---|
90 | HRESULT setPromiscModePolicy(NetworkAdapterPromiscModePolicy_T aPromiscModePolicy);
|
---|
91 | HRESULT getTraceEnabled(BOOL *aTraceEnabled);
|
---|
92 | HRESULT setTraceEnabled(BOOL aTraceEnabled);
|
---|
93 | HRESULT getTraceFile(com::Utf8Str &aTraceFile);
|
---|
94 | HRESULT setTraceFile(const com::Utf8Str &aTraceFile);
|
---|
95 | HRESULT getNATEngine(ComPtr<INATEngine> &aNATEngine);
|
---|
96 | HRESULT getBootPriority(ULONG *aBootPriority);
|
---|
97 | HRESULT setBootPriority(ULONG aBootPriority);
|
---|
98 | HRESULT getBandwidthGroup(ComPtr<IBandwidthGroup> &aBandwidthGroup);
|
---|
99 | HRESULT setBandwidthGroup(const ComPtr<IBandwidthGroup> &aBandwidthGroup);
|
---|
100 |
|
---|
101 | // wrapped INetworkAdapter methods
|
---|
102 | HRESULT getProperty(const com::Utf8Str &aKey,
|
---|
103 | com::Utf8Str &aValue);
|
---|
104 | HRESULT setProperty(const com::Utf8Str &aKey,
|
---|
105 | const com::Utf8Str &aValue);
|
---|
106 | HRESULT getProperties(const com::Utf8Str &aNames,
|
---|
107 | std::vector<com::Utf8Str> &aReturnNames,
|
---|
108 | std::vector<com::Utf8Str> &aReturnValues);
|
---|
109 | // Misc.
|
---|
110 | void i_generateMACAddress();
|
---|
111 | HRESULT i_updateMacAddress(Utf8Str aMacAddress);
|
---|
112 | void i_updateBandwidthGroup(BandwidthGroup *aBwGroup);
|
---|
113 | HRESULT i_checkAndSwitchFromNatNetworking(com::Utf8Str networkName);
|
---|
114 | HRESULT i_switchToNatNetworking(const com::Utf8Str &aNatNetworkName);
|
---|
115 |
|
---|
116 | typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
|
---|
117 |
|
---|
118 | struct Data
|
---|
119 | {
|
---|
120 | Data() : mSlot(0),
|
---|
121 | mEnabled(FALSE),
|
---|
122 | mAttachmentType(NetworkAttachmentType_Null),
|
---|
123 | mCableConnected(TRUE),
|
---|
124 | mLineSpeed(0),
|
---|
125 | mPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
|
---|
126 | mTraceEnabled(FALSE),
|
---|
127 | mBridgedInterface("") /* cannot be null */,
|
---|
128 | mHostOnlyInterface("") /* cannot be null */,
|
---|
129 | mNATNetwork("") /* cannot be null */,
|
---|
130 | mBootPriority(0)
|
---|
131 | {}
|
---|
132 |
|
---|
133 | NetworkAdapterType_T mAdapterType;
|
---|
134 | ULONG mSlot;
|
---|
135 | BOOL mEnabled;
|
---|
136 | com::Utf8Str mMACAddress;
|
---|
137 | NetworkAttachmentType_T mAttachmentType;
|
---|
138 | BOOL mCableConnected;
|
---|
139 | ULONG mLineSpeed;
|
---|
140 | NetworkAdapterPromiscModePolicy_T mPromiscModePolicy;
|
---|
141 | BOOL mTraceEnabled;
|
---|
142 | com::Utf8Str mTraceFile;
|
---|
143 | com::Utf8Str mBridgedInterface;
|
---|
144 | com::Utf8Str mHostOnlyInterface;
|
---|
145 | com::Utf8Str mInternalNetwork;
|
---|
146 | com::Utf8Str mNATNetwork;
|
---|
147 | com::Utf8Str mGenericDriver;
|
---|
148 | StringsMap mGenericProperties;
|
---|
149 | ULONG mBootPriority;
|
---|
150 | com::Utf8Str mBandwidthGroup;
|
---|
151 | };
|
---|
152 |
|
---|
153 | Machine * const mParent;
|
---|
154 | const ComObjPtr<NetworkAdapter> mPeer;
|
---|
155 | const ComObjPtr<NATEngine> mNATEngine;
|
---|
156 |
|
---|
157 | bool m_fModified;
|
---|
158 | Backupable<Data> mData;
|
---|
159 | };
|
---|
160 |
|
---|
161 | #endif // ____H_NETWORKADAPTER
|
---|
162 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|