VirtualBox

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

Last change on this file since 28287 was 28287, checked in by vboxsync, 15 years ago

Devices, Main, FE/Qt: added support for VDE virtual network switches for Linux and FreeBSD hosts. Contributed by Renzo Davoli, VirtualSquare, University of Bologna

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/* $Id: NetworkAdapterImpl.h 28287 2010-04-14 10:10:40Z 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.215389.xyz. 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 "NATEngineImpl.h"
29
30class GuestOSType;
31
32namespace settings
33{
34 struct NetworkAdapter;
35}
36
37class ATL_NO_VTABLE NetworkAdapter :
38 public VirtualBoxBase,
39 public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,
40 public VirtualBoxSupportTranslation<NetworkAdapter>,
41 VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
42{
43public:
44
45 struct Data
46 {
47 Data() : mSlot(0), mEnabled(FALSE),
48 mAttachmentType(NetworkAttachmentType_Null),
49 mCableConnected(TRUE), mLineSpeed(0), mTraceEnabled(FALSE),
50 mHostInterface("") /* cannot be null */,
51 mNATNetwork("") /* cannot be null */
52 /* ENABLE VDE */
53 , mVDENetwork("") /* can be null */
54 /* /ENABLE VDE */
55 {}
56
57 NetworkAdapterType_T mAdapterType;
58 ULONG mSlot;
59 BOOL mEnabled;
60 Bstr mMACAddress;
61 NetworkAttachmentType_T mAttachmentType;
62 BOOL mCableConnected;
63 ULONG mLineSpeed;
64 BOOL mTraceEnabled;
65 Bstr mTraceFile;
66 Bstr mHostInterface;
67 Bstr mInternalNetwork;
68 Bstr mNATNetwork;
69 /* ENABLE VDE */
70 Bstr mVDENetwork;
71 ULONG mBootPriority;
72 };
73
74 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
75
76 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
77
78 DECLARE_PROTECT_FINAL_CONSTRUCT()
79
80 BEGIN_COM_MAP(NetworkAdapter)
81 COM_INTERFACE_ENTRY (ISupportErrorInfo)
82 COM_INTERFACE_ENTRY (INetworkAdapter)
83 COM_INTERFACE_ENTRY2 (IDispatch, INetworkAdapter)
84 END_COM_MAP()
85
86 DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
87
88 HRESULT FinalConstruct();
89 void FinalRelease();
90
91 // public initializer/uninitializer for internal purposes only
92 HRESULT init (Machine *aParent, ULONG aSlot);
93 HRESULT init (Machine *aParent, NetworkAdapter *aThat);
94 HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
95 void uninit();
96
97 // INetworkAdapter properties
98 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
99 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
100 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
101 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
102 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
103 STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
104 STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
105 STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
106 STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
107 STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
108 STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
109 STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
110 STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
111 STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
112 /* ENABLE VDE */
113 STDMETHOD(COMGETTER(VDENetwork)) (BSTR *aVDENetwork);
114 STDMETHOD(COMSETTER(VDENetwork)) (IN_BSTR aVDENetwork);
115 /* /ENABLE VDE */
116 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
117 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
118 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
119 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
120 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
121 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
122 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
123 STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
124 STDMETHOD(COMGETTER(NatDriver)) (INATEngine **aNatDriver);
125 STDMETHOD(COMGETTER(BootPriority)) (ULONG *aBootPriority);
126 STDMETHOD(COMSETTER(BootPriority)) (ULONG aBootPriority);
127
128 // INetworkAdapter methods
129 STDMETHOD(AttachToNAT)();
130 STDMETHOD(AttachToBridgedInterface)();
131 STDMETHOD(AttachToInternalNetwork)();
132 STDMETHOD(AttachToHostOnlyInterface)();
133 /* ENABLE VDE */
134 STDMETHOD(AttachToVDE)();
135 /* /ENABLE VDE */
136 STDMETHOD(Detach)();
137
138 // public methods only for internal purposes
139
140 HRESULT loadSettings(const settings::NetworkAdapter &data);
141 HRESULT saveSettings(settings::NetworkAdapter &data);
142
143 bool isModified();
144 void rollback();
145 void commit();
146 void copyFrom (NetworkAdapter *aThat);
147 void applyDefaults (GuestOSType *aOsType);
148
149 // for VirtualBoxSupportErrorInfoImpl
150 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
151
152private:
153
154 void detach();
155 void generateMACAddress();
156
157 Machine * const mParent;
158 const ComObjPtr<NetworkAdapter> mPeer;
159 const ComObjPtr<NATEngine> mNATEngine;
160
161 bool m_fModified;
162 Backupable<Data> mData;
163};
164
165#endif // ____H_NETWORKADAPTER
166/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette