1 | /* $Id: NetworkAdapterImpl.h 28867 2010-04-28 13:28:20Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2010 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 "VirtualBoxBase.h"
|
---|
24 | #include "NATEngineImpl.h"
|
---|
25 |
|
---|
26 | class GuestOSType;
|
---|
27 |
|
---|
28 | namespace settings
|
---|
29 | {
|
---|
30 | struct NetworkAdapter;
|
---|
31 | }
|
---|
32 |
|
---|
33 | class ATL_NO_VTABLE NetworkAdapter :
|
---|
34 | public VirtualBoxBase,
|
---|
35 | public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,
|
---|
36 | public VirtualBoxSupportTranslation<NetworkAdapter>,
|
---|
37 | VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
|
---|
38 | {
|
---|
39 | public:
|
---|
40 |
|
---|
41 | struct Data
|
---|
42 | {
|
---|
43 | Data() : mSlot(0),
|
---|
44 | mEnabled(FALSE),
|
---|
45 | mAttachmentType(NetworkAttachmentType_Null),
|
---|
46 | mCableConnected(TRUE),
|
---|
47 | mLineSpeed(0),
|
---|
48 | mTraceEnabled(FALSE),
|
---|
49 | mHostInterface("") /* cannot be null */,
|
---|
50 | #ifdef VBOX_WITH_VDE
|
---|
51 | mVDENetwork("") /* can be null */,
|
---|
52 | #endif
|
---|
53 | mNATNetwork("") /* cannot be null */,
|
---|
54 | mBootPriority(0)
|
---|
55 | {}
|
---|
56 |
|
---|
57 | NetworkAdapterType_T mAdapterType;
|
---|
58 | ULONG mSlot;
|
---|
59 | BOOL mEnabled;
|
---|
60 | Bstr mMACAddress;
|
---|
61 | NetworkAttachmentType_T mAttachmentType;
|
---|
62 | BOOL mCableConnected;
|
---|
63 | ULONG mLineSpeed;
|
---|
64 | BOOL mTraceEnabled;
|
---|
65 | Bstr mTraceFile;
|
---|
66 | Bstr mHostInterface;
|
---|
67 | Bstr mInternalNetwork;
|
---|
68 | #ifdef VBOX_WITH_VDE
|
---|
69 | Bstr mVDENetwork;
|
---|
70 | #endif
|
---|
71 | Bstr mNATNetwork;
|
---|
72 | ULONG mBootPriority;
|
---|
73 | };
|
---|
74 |
|
---|
75 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
|
---|
76 |
|
---|
77 | DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
|
---|
78 |
|
---|
79 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
80 |
|
---|
81 | BEGIN_COM_MAP(NetworkAdapter)
|
---|
82 | COM_INTERFACE_ENTRY (ISupportErrorInfo)
|
---|
83 | COM_INTERFACE_ENTRY (INetworkAdapter)
|
---|
84 | COM_INTERFACE_ENTRY2 (IDispatch, INetworkAdapter)
|
---|
85 | END_COM_MAP()
|
---|
86 |
|
---|
87 | DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
|
---|
88 |
|
---|
89 | HRESULT FinalConstruct();
|
---|
90 | void FinalRelease();
|
---|
91 |
|
---|
92 | // public initializer/uninitializer for internal purposes only
|
---|
93 | HRESULT init (Machine *aParent, ULONG aSlot);
|
---|
94 | HRESULT init (Machine *aParent, NetworkAdapter *aThat);
|
---|
95 | HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
|
---|
96 | void uninit();
|
---|
97 |
|
---|
98 | // INetworkAdapter properties
|
---|
99 | STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
|
---|
100 | STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
|
---|
101 | STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
|
---|
102 | STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
|
---|
103 | STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
|
---|
104 | STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
|
---|
105 | STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
|
---|
106 | STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
|
---|
107 | STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
|
---|
108 | STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
|
---|
109 | STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
|
---|
110 | STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
|
---|
111 | STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
|
---|
112 | STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
|
---|
113 | STDMETHOD(COMGETTER(VDENetwork)) (BSTR *aVDENetwork);
|
---|
114 | STDMETHOD(COMSETTER(VDENetwork)) (IN_BSTR aVDENetwork);
|
---|
115 | STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
|
---|
116 | STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
|
---|
117 | STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
|
---|
118 | STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
|
---|
119 | STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
|
---|
120 | STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
|
---|
121 | STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
|
---|
122 | STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
|
---|
123 | STDMETHOD(COMGETTER(NatDriver)) (INATEngine **aNatDriver);
|
---|
124 | STDMETHOD(COMGETTER(BootPriority)) (ULONG *aBootPriority);
|
---|
125 | STDMETHOD(COMSETTER(BootPriority)) (ULONG aBootPriority);
|
---|
126 |
|
---|
127 | // INetworkAdapter methods
|
---|
128 | STDMETHOD(AttachToNAT)();
|
---|
129 | STDMETHOD(AttachToBridgedInterface)();
|
---|
130 | STDMETHOD(AttachToInternalNetwork)();
|
---|
131 | STDMETHOD(AttachToHostOnlyInterface)();
|
---|
132 | STDMETHOD(AttachToVDE)();
|
---|
133 | STDMETHOD(Detach)();
|
---|
134 |
|
---|
135 | // public methods only for internal purposes
|
---|
136 |
|
---|
137 | HRESULT loadSettings(const settings::NetworkAdapter &data);
|
---|
138 | HRESULT saveSettings(settings::NetworkAdapter &data);
|
---|
139 |
|
---|
140 | bool isModified();
|
---|
141 | void rollback();
|
---|
142 | void commit();
|
---|
143 | void copyFrom (NetworkAdapter *aThat);
|
---|
144 | void applyDefaults (GuestOSType *aOsType);
|
---|
145 |
|
---|
146 | // for VirtualBoxSupportErrorInfoImpl
|
---|
147 | static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
|
---|
148 |
|
---|
149 | private:
|
---|
150 |
|
---|
151 | void detach();
|
---|
152 | void generateMACAddress();
|
---|
153 |
|
---|
154 | Machine * const mParent;
|
---|
155 | const ComObjPtr<NetworkAdapter> mPeer;
|
---|
156 | const ComObjPtr<NATEngine> mNATEngine;
|
---|
157 |
|
---|
158 | bool m_fModified;
|
---|
159 | Backupable<Data> mData;
|
---|
160 | };
|
---|
161 |
|
---|
162 | #endif // ____H_NETWORKADAPTER
|
---|
163 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|