VirtualBox

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

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

Main: INetworkAdapter separate properties for hostonly & bridged interface names

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