VirtualBox

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

Last change on this file since 18622 was 17684, checked in by vboxsync, 16 years ago

#3551: “Main: Replace remaining collections with safe arrays”
Replaced HostUSBDeviceCollection. Reviewed/Okayed by dmik, sunlover.

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