VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_NETWORKADAPTER
19#define ____H_NETWORKADAPTER
20
21#include "VirtualBoxBase.h"
22#include "Collection.h"
23
24class Machine;
25
26class ATL_NO_VTABLE NetworkAdapter :
27 public VirtualBoxBaseNEXT,
28 public VirtualBoxSupportErrorInfoImpl <NetworkAdapter, INetworkAdapter>,
29 public VirtualBoxSupportTranslation <NetworkAdapter>,
30 public INetworkAdapter
31{
32public:
33
34 struct Data
35 {
36 Data()
37 : mSlot (0), mEnabled (FALSE)
38 , mAttachmentType (NetworkAttachmentType_NoNetworkAttachment)
39 , mCableConnected (TRUE), mLineSpeed (0), mTraceEnabled (FALSE)
40#ifdef RT_OS_WINDOWS
41 , mHostInterface ("") // cannot be null
42#endif
43#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
44 , mTAPFD (NIL_RTFILE)
45#endif
46 , mInternalNetwork ("") // 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#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
61 mTAPSetupApplication == that.mTAPSetupApplication &&
62 mTAPTerminateApplication == that.mTAPTerminateApplication &&
63 mTAPFD == that.mTAPFD &&
64#endif
65 mInternalNetwork == that.mInternalNetwork);
66 }
67
68 NetworkAdapterType_T mAdapterType;
69 ULONG mSlot;
70 BOOL mEnabled;
71 Bstr mMACAddress;
72 NetworkAttachmentType_T mAttachmentType;
73 BOOL mCableConnected;
74 ULONG mLineSpeed;
75 BOOL mTraceEnabled;
76 Bstr mTraceFile;
77 Bstr mHostInterface;
78#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
79 Bstr mTAPSetupApplication;
80 Bstr mTAPTerminateApplication;
81 RTFILE mTAPFD;
82#endif
83 Bstr mInternalNetwork;
84 };
85
86 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
87
88 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
89
90 DECLARE_PROTECT_FINAL_CONSTRUCT()
91
92 BEGIN_COM_MAP(NetworkAdapter)
93 COM_INTERFACE_ENTRY(ISupportErrorInfo)
94 COM_INTERFACE_ENTRY(INetworkAdapter)
95 END_COM_MAP()
96
97 NS_DECL_ISUPPORTS
98
99 DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
100
101 HRESULT FinalConstruct();
102 void FinalRelease();
103
104 // public initializer/uninitializer for internal purposes only
105 HRESULT init (Machine *aParent, ULONG aSlot);
106 HRESULT init (Machine *aParent, NetworkAdapter *aThat);
107 HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
108 void uninit();
109
110 // INetworkAdapter properties
111 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
112 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
113 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
114 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
115 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
116 STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
117 STDMETHOD(COMSETTER(MACAddress)) (INPTR BSTR aMACAddress);
118 STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
119 STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
120 STDMETHOD(COMSETTER(HostInterface)) (INPTR BSTR aHostInterface);
121#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
122 STDMETHOD(COMGETTER(TAPFileDescriptor)) (LONG *aTAPFileDescriptor);
123 STDMETHOD(COMSETTER(TAPFileDescriptor)) (LONG aTAPFileDescriptor);
124 STDMETHOD(COMGETTER(TAPSetupApplication)) (BSTR *aTAPSetupApplication);
125 STDMETHOD(COMSETTER(TAPSetupApplication)) (INPTR BSTR aTAPSetupApplication);
126 STDMETHOD(COMGETTER(TAPTerminateApplication)) (BSTR *aTAPTerminateApplication);
127 STDMETHOD(COMSETTER(TAPTerminateApplication)) (INPTR BSTR aTAPTerminateApplication);
128#endif
129 STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
130 STDMETHOD(COMSETTER(InternalNetwork)) (INPTR BSTR aInternalNetwork);
131 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
132 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
133 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
134 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
135 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
136 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
137 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
138 STDMETHOD(COMSETTER(TraceFile)) (INPTR BSTR aTraceFile);
139
140 // INetworkAdapter methods
141 STDMETHOD(AttachToNAT)();
142 STDMETHOD(AttachToHostInterface)();
143 STDMETHOD(AttachToInternalNetwork)();
144 STDMETHOD(Detach)();
145
146 // public methods only for internal purposes
147
148 bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
149 bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
150 bool rollback();
151 void commit();
152 void copyFrom (NetworkAdapter *aThat);
153
154 // public methods for internal purposes only
155 // (ensure there is a caller and a read lock before calling them!)
156
157 const Backupable <Data> &data() const { return mData; }
158
159 // for VirtualBoxSupportErrorInfoImpl
160 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
161
162private:
163
164 void detach();
165 void generateMACAddress();
166
167 const ComObjPtr <Machine, ComWeakRef> mParent;
168 const ComObjPtr <NetworkAdapter> mPeer;
169
170 Backupable <Data> mData;
171};
172
173#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