VirtualBox

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

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

Main: Cleaned up the long standing const BSTR = const (OLECHAR *) on WIn32 vs (const PRunichar) * on XPCOM clash. Cleaned up BSTR/GUID macros (IN_BSTR replaces INPTR BSTR, IN_GUID replaces INPTR GUIDPARAM, OUT_GUID replaces GUIDPARAMOUT).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: NetworkAdapterImpl.h 15051 2008-12-05 17:20:00Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2007 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 "Collection.h"
29
30class Machine;
31class GuestOSType;
32
33class ATL_NO_VTABLE NetworkAdapter :
34 public VirtualBoxBaseNEXT,
35 public VirtualBoxSupportErrorInfoImpl <NetworkAdapter, INetworkAdapter>,
36 public VirtualBoxSupportTranslation <NetworkAdapter>,
37 public INetworkAdapter
38{
39public:
40
41 struct Data
42 {
43 Data()
44 : mSlot (0), mEnabled (FALSE)
45 , mAttachmentType (NetworkAttachmentType_Null)
46 , mCableConnected (TRUE), mLineSpeed (0), mTraceEnabled (FALSE)
47#ifndef VBOX_WITH_UNIXY_TAP_NETWORKING
48 , mHostInterface ("") // cannot be null
49#else
50 , mTAPFD (NIL_RTFILE)
51#endif
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#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
66 mTAPSetupApplication == that.mTAPSetupApplication &&
67 mTAPTerminateApplication == that.mTAPTerminateApplication &&
68 mTAPFD == that.mTAPFD &&
69#endif
70 mInternalNetwork == that.mInternalNetwork &&
71 mNATNetwork == that.mNATNetwork);
72 }
73
74 NetworkAdapterType_T mAdapterType;
75 ULONG mSlot;
76 BOOL mEnabled;
77 Bstr mMACAddress;
78 NetworkAttachmentType_T mAttachmentType;
79 BOOL mCableConnected;
80 ULONG mLineSpeed;
81 BOOL mTraceEnabled;
82 Bstr mTraceFile;
83 Bstr mHostInterface;
84#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
85 Bstr mTAPSetupApplication;
86 Bstr mTAPTerminateApplication;
87 RTFILE mTAPFD;
88#endif
89 Bstr mInternalNetwork;
90 Bstr mNATNetwork;
91 };
92
93 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
94
95 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
96
97 DECLARE_PROTECT_FINAL_CONSTRUCT()
98
99 BEGIN_COM_MAP(NetworkAdapter)
100 COM_INTERFACE_ENTRY(ISupportErrorInfo)
101 COM_INTERFACE_ENTRY(INetworkAdapter)
102 END_COM_MAP()
103
104 NS_DECL_ISUPPORTS
105
106 DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
107
108 HRESULT FinalConstruct();
109 void FinalRelease();
110
111 // public initializer/uninitializer for internal purposes only
112 HRESULT init (Machine *aParent, ULONG aSlot);
113 HRESULT init (Machine *aParent, NetworkAdapter *aThat);
114 HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
115 void uninit();
116
117 // INetworkAdapter properties
118 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
119 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
120 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
121 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
122 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
123 STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
124 STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
125 STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
126 STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
127 STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
128#ifndef RT_OS_WINDOWS /** @todo ifdef VBOX_WITH_UNIXY_TAP_NETWORKING: need to find a way to exclude this in the xidl... */
129 STDMETHOD(COMGETTER(TAPFileDescriptor)) (LONG *aTAPFileDescriptor);
130 STDMETHOD(COMSETTER(TAPFileDescriptor)) (LONG aTAPFileDescriptor);
131 STDMETHOD(COMGETTER(TAPSetupApplication)) (BSTR *aTAPSetupApplication);
132 STDMETHOD(COMSETTER(TAPSetupApplication)) (IN_BSTR aTAPSetupApplication);
133 STDMETHOD(COMGETTER(TAPTerminateApplication)) (BSTR *aTAPTerminateApplication);
134 STDMETHOD(COMSETTER(TAPTerminateApplication)) (IN_BSTR aTAPTerminateApplication);
135#endif
136 STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
137 STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
138 STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
139 STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
140 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
141 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
142 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
143 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
144 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
145 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
146 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
147 STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
148
149 // INetworkAdapter methods
150 STDMETHOD(AttachToNAT)();
151 STDMETHOD(AttachToHostInterface)();
152 STDMETHOD(AttachToInternalNetwork)();
153 STDMETHOD(Detach)();
154
155 // public methods only for internal purposes
156
157 HRESULT loadSettings (const settings::Key &aAdapterNode);
158 HRESULT saveSettings (settings::Key &aAdapterNode);
159
160 bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
161 bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
162 bool rollback();
163 void commit();
164 void copyFrom (NetworkAdapter *aThat);
165 void applyDefaults (GuestOSType *aOsType);
166
167 // public methods for internal purposes only
168 // (ensure there is a caller and a read lock before calling them!)
169
170 const Backupable <Data> &data() const { return mData; }
171
172 // for VirtualBoxSupportErrorInfoImpl
173 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
174
175private:
176
177 void detach();
178 void generateMACAddress();
179
180 const ComObjPtr <Machine, ComWeakRef> mParent;
181 const ComObjPtr <NetworkAdapter> mPeer;
182
183 Backupable <Data> mData;
184};
185
186#endif // ____H_NETWORKADAPTER
187/* 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