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