VirtualBox

source: vbox/trunk/src/VBox/Main/include/NetworkAdapterImpl.h@ 22624

Last change on this file since 22624 was 22183, checked in by vboxsync, 15 years ago

Main: fix more windows warnings + burns

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: NetworkAdapterImpl.h 22183 2009-08-11 17:00:33Z 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
29class Machine;
30class GuestOSType;
31
32namespace settings
33{
34 struct NetworkAdapter;
35}
36
37class ATL_NO_VTABLE NetworkAdapter :
38 public VirtualBoxBase,
39 public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,
40 public VirtualBoxSupportTranslation<NetworkAdapter>,
41 VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
42{
43public:
44
45 struct Data
46 {
47 Data()
48 : mSlot (0), mEnabled (FALSE)
49 , mAttachmentType (NetworkAttachmentType_Null)
50 , mCableConnected (TRUE), mLineSpeed (0), mTraceEnabled (FALSE)
51 , mHostInterface ("") /* cannot be null */
52 {}
53
54 bool operator== (const Data &that) const
55 {
56 return this == &that ||
57 (mSlot == that.mSlot &&
58 mEnabled == that.mEnabled &&
59 mMACAddress == that.mMACAddress &&
60 mAttachmentType == that.mAttachmentType &&
61 mCableConnected == that.mCableConnected &&
62 mLineSpeed == that.mLineSpeed &&
63 mTraceEnabled == that.mTraceEnabled &&
64 mHostInterface == that.mHostInterface &&
65 mInternalNetwork == that.mInternalNetwork &&
66 mNATNetwork == that.mNATNetwork);
67 }
68
69 NetworkAdapterType_T mAdapterType;
70 ULONG mSlot;
71 BOOL mEnabled;
72 Bstr mMACAddress;
73 NetworkAttachmentType_T mAttachmentType;
74 BOOL mCableConnected;
75 ULONG mLineSpeed;
76 BOOL mTraceEnabled;
77 Bstr mTraceFile;
78 Bstr mHostInterface;
79 Bstr mInternalNetwork;
80 Bstr mNATNetwork;
81 };
82
83 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
84
85 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
86
87 DECLARE_PROTECT_FINAL_CONSTRUCT()
88
89 BEGIN_COM_MAP(NetworkAdapter)
90 COM_INTERFACE_ENTRY (ISupportErrorInfo)
91 COM_INTERFACE_ENTRY (INetworkAdapter)
92 COM_INTERFACE_ENTRY2 (IDispatch, INetworkAdapter)
93 END_COM_MAP()
94
95 NS_DECL_ISUPPORTS
96
97 DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
98
99 HRESULT FinalConstruct();
100 void FinalRelease();
101
102 // public initializer/uninitializer for internal purposes only
103 HRESULT init (Machine *aParent, ULONG aSlot);
104 HRESULT init (Machine *aParent, NetworkAdapter *aThat);
105 HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
106 void uninit();
107
108 // INetworkAdapter properties
109 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
110 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
111 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
112 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
113 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
114 STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
115 STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
116 STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
117 STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
118 STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
119 STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
120 STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
121 STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
122 STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
123 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
124 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
125 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
126 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
127 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
128 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
129 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
130 STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
131
132 // INetworkAdapter methods
133 STDMETHOD(AttachToNAT)();
134 STDMETHOD(AttachToBridgedInterface)();
135 STDMETHOD(AttachToInternalNetwork)();
136 STDMETHOD(AttachToHostOnlyInterface)();
137 STDMETHOD(Detach)();
138
139 // public methods only for internal purposes
140
141 HRESULT loadSettings(const settings::NetworkAdapter &data);
142 HRESULT saveSettings(settings::NetworkAdapter &data);
143
144 bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
145 bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
146 bool rollback();
147 void commit();
148 void copyFrom (NetworkAdapter *aThat);
149 void applyDefaults (GuestOSType *aOsType);
150
151 // public methods for internal purposes only
152 // (ensure there is a caller and a read lock before calling them!)
153
154 const Backupable <Data> &data() const { return mData; }
155
156 // for VirtualBoxSupportErrorInfoImpl
157 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
158
159private:
160
161 void detach();
162 void generateMACAddress();
163
164 const ComObjPtr<Machine, ComWeakRef> mParent;
165 const ComObjPtr<NetworkAdapter> mPeer;
166
167 Backupable <Data> mData;
168};
169
170#endif // ____H_NETWORKADAPTER
171/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette