VirtualBox

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

Last change on this file since 7936 was 7207, checked in by vboxsync, 17 years ago

Main: Reworked enums to avoid 1) weird duplication of enum name when referring to enum values in cross-platform code; 2) possible clashes on Win32 due to putting identifiers like Paused or Disabled to the global namespace (via C enums). In the new style, enums are used like this: a) USBDeviceState_T v = USBDeviceState_Busy from cross-platform non-Qt code; b) KUSBDeviceState v = KUSBDeviceState_Busy from Qt code; c) USBDeviceState v = USBDeviceState_Busy from plain Win32 and d) PRUInt32 USBDeviceState v = USBDeviceState::Busy from plain XPCOM.

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