VirtualBox

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

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

Main: Host interface networking on Darwin.

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