1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/* $Id: NetworkAdapterImpl.h $ */
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_NETWORKADAPTER
#define ____H_NETWORKADAPTER
#include "VirtualBoxBase.h"
#include "NATEngineImpl.h"
#include "BandwidthGroupImpl.h"
class GuestOSType;
namespace settings
{
struct NetworkAdapter;
}
class ATL_NO_VTABLE NetworkAdapter :
public VirtualBoxBase,
VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
{
public:
struct Data
{
Data() : mSlot(0),
mEnabled(FALSE),
mAttachmentType(NetworkAttachmentType_Null),
mCableConnected(TRUE),
mLineSpeed(0),
mPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
mTraceEnabled(FALSE),
mBridgedInterface("") /* cannot be null */,
mHostOnlyInterface("") /* cannot be null */,
mNATNetwork("") /* cannot be null */,
mBootPriority(0)
{}
NetworkAdapterType_T mAdapterType;
ULONG mSlot;
BOOL mEnabled;
Bstr mMACAddress;
NetworkAttachmentType_T mAttachmentType;
BOOL mCableConnected;
ULONG mLineSpeed;
NetworkAdapterPromiscModePolicy_T mPromiscModePolicy;
BOOL mTraceEnabled;
Bstr mTraceFile;
Bstr mBridgedInterface;
Bstr mHostOnlyInterface;
Bstr mInternalNetwork;
Bstr mNATNetwork;
Bstr mGenericDriver;
settings::StringsMap mGenericProperties;
ULONG mBootPriority;
Utf8Str mBandwidthGroup;
};
VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NetworkAdapter, INetworkAdapter)
DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(NetworkAdapter)
VBOX_DEFAULT_INTERFACE_ENTRIES(INetworkAdapter)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR(NetworkAdapter)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init(Machine *aParent, ULONG aSlot);
HRESULT init(Machine *aParent, NetworkAdapter *aThat, bool aReshare = false);
HRESULT initCopy(Machine *aParent, NetworkAdapter *aThat);
void uninit();
// INetworkAdapter properties
STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
STDMETHOD(COMGETTER(Slot))(ULONG *aSlot);
STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(MACAddress))(BSTR *aMACAddress);
STDMETHOD(COMSETTER(MACAddress))(IN_BSTR aMACAddress);
STDMETHOD(COMGETTER(AttachmentType))(NetworkAttachmentType_T *aAttachmentType);
STDMETHOD(COMSETTER(AttachmentType))(NetworkAttachmentType_T aAttachmentType);
STDMETHOD(COMGETTER(BridgedInterface))(BSTR *aBridgedInterface);
STDMETHOD(COMSETTER(BridgedInterface))(IN_BSTR aBridgedInterface);
STDMETHOD(COMGETTER(HostOnlyInterface))(BSTR *aHostOnlyInterface);
STDMETHOD(COMSETTER(HostOnlyInterface))(IN_BSTR aHostOnlyInterface);
STDMETHOD(COMGETTER(InternalNetwork))(BSTR *aInternalNetwork);
STDMETHOD(COMSETTER(InternalNetwork))(IN_BSTR aInternalNetwork);
STDMETHOD(COMGETTER(NATNetwork))(BSTR *aNATNetwork);
STDMETHOD(COMSETTER(NATNetwork))(IN_BSTR aNATNetwork);
STDMETHOD(COMGETTER(GenericDriver))(BSTR *aGenericDriver);
STDMETHOD(COMSETTER(GenericDriver))(IN_BSTR aGenericDriver);
STDMETHOD(COMGETTER(CableConnected))(BOOL *aConnected);
STDMETHOD(COMSETTER(CableConnected))(BOOL aConnected);
STDMETHOD(COMGETTER(TraceEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(TraceEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(LineSpeed))(ULONG *aSpeed);
STDMETHOD(COMSETTER(LineSpeed))(ULONG aSpeed);
STDMETHOD(COMGETTER(PromiscModePolicy))(NetworkAdapterPromiscModePolicy_T *aPromiscModePolicy);
STDMETHOD(COMSETTER(PromiscModePolicy))(NetworkAdapterPromiscModePolicy_T aPromiscModePolicy);
STDMETHOD(COMGETTER(TraceFile))(BSTR *aTraceFile);
STDMETHOD(COMSETTER(TraceFile))(IN_BSTR aTraceFile);
STDMETHOD(COMGETTER(NATEngine))(INATEngine **aNATEngine);
STDMETHOD(COMGETTER(BootPriority))(ULONG *aBootPriority);
STDMETHOD(COMSETTER(BootPriority))(ULONG aBootPriority);
STDMETHOD(COMGETTER(BandwidthGroup))(IBandwidthGroup **aBwGroup);
STDMETHOD(COMSETTER(BandwidthGroup))(IBandwidthGroup *aBwGroup);
// INetworkAdapter methods
STDMETHOD(GetProperty)(IN_BSTR aName, BSTR *aValue);
STDMETHOD(SetProperty)(IN_BSTR aName, IN_BSTR aValue);
STDMETHOD(GetProperties)(IN_BSTR aNames,
ComSafeArrayOut(BSTR, aReturnNames),
ComSafeArrayOut(BSTR, aReturnValues));
// public methods only for internal purposes
HRESULT loadSettings(BandwidthControl *bwctl, const settings::NetworkAdapter &data);
HRESULT saveSettings(settings::NetworkAdapter &data);
bool isModified();
void rollback();
void commit();
void copyFrom(NetworkAdapter *aThat);
void applyDefaults(GuestOSType *aOsType);
ComObjPtr<NetworkAdapter> getPeer();
private:
void generateMACAddress();
HRESULT updateMacAddress(Utf8Str aMacAddress);
void updateBandwidthGroup(BandwidthGroup *aBwGroup);
HRESULT checkAndSwitchFromNatNetworking(IN_BSTR aNatNetworkName);
HRESULT switchToNatNetworking(IN_BSTR aNatNetworkName);
Machine * const mParent;
const ComObjPtr<NetworkAdapter> mPeer;
const ComObjPtr<NATEngine> mNATEngine;
bool m_fModified;
Backupable<Data> mData;
};
#endif // ____H_NETWORKADAPTER
/* vi: set tabstop=4 shiftwidth=4 expandtab: */
|