VirtualBox

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

Last change on this file since 31964 was 31287, checked in by vboxsync, 14 years ago

Initial API changes for resource control (storage/network/cpu)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: NetworkAdapterImpl.h 31287 2010-08-02 12:13:00Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2010 Oracle Corporation
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 "NATEngineImpl.h"
25
26class GuestOSType;
27
28namespace settings
29{
30 struct NetworkAdapter;
31}
32
33class ATL_NO_VTABLE NetworkAdapter :
34 public VirtualBoxBase,
35 VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
36{
37public:
38
39 struct Data
40 {
41 Data() : mSlot(0),
42 mEnabled(FALSE),
43 mAttachmentType(NetworkAttachmentType_Null),
44 mCableConnected(TRUE),
45 mLineSpeed(0),
46 mTraceEnabled(FALSE),
47 mHostInterface("") /* cannot be null */,
48#ifdef VBOX_WITH_VDE
49 mVDENetwork("") /* can be null */,
50#endif
51 mNATNetwork("") /* cannot be null */,
52 mBootPriority(0)
53 {}
54
55 NetworkAdapterType_T mAdapterType;
56 ULONG mSlot;
57 BOOL mEnabled;
58 Bstr mMACAddress;
59 NetworkAttachmentType_T mAttachmentType;
60 BOOL mCableConnected;
61 ULONG mLineSpeed;
62 BOOL mTraceEnabled;
63 Bstr mTraceFile;
64 Bstr mHostInterface;
65 Bstr mInternalNetwork;
66#ifdef VBOX_WITH_VDE
67 Bstr mVDENetwork;
68#endif
69 Bstr mNATNetwork;
70 ULONG mBootPriority;
71 ULONG mBandwidthLimit;
72 };
73
74 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NetworkAdapter, INetworkAdapter)
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 STDMETHOD(COMGETTER(VDENetwork)) (BSTR *aVDENetwork);
113 STDMETHOD(COMSETTER(VDENetwork)) (IN_BSTR aVDENetwork);
114 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
115 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
116 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
117 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
118 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
119 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
120 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
121 STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
122 STDMETHOD(COMGETTER(NatDriver)) (INATEngine **aNatDriver);
123 STDMETHOD(COMGETTER(BootPriority)) (ULONG *aBootPriority);
124 STDMETHOD(COMSETTER(BootPriority)) (ULONG aBootPriority);
125 STDMETHOD(COMGETTER(BandwidthLimit)) (ULONG *aLimit);
126 STDMETHOD(COMSETTER(BandwidthLimit)) (ULONG aLimit);
127
128 // INetworkAdapter methods
129 STDMETHOD(AttachToNAT)();
130 STDMETHOD(AttachToBridgedInterface)();
131 STDMETHOD(AttachToInternalNetwork)();
132 STDMETHOD(AttachToHostOnlyInterface)();
133 STDMETHOD(AttachToVDE)();
134 STDMETHOD(Detach)();
135
136 // public methods only for internal purposes
137
138 HRESULT loadSettings(const settings::NetworkAdapter &data);
139 HRESULT saveSettings(settings::NetworkAdapter &data);
140
141 bool isModified();
142 void rollback();
143 void commit();
144 void copyFrom (NetworkAdapter *aThat);
145 void applyDefaults (GuestOSType *aOsType);
146
147private:
148
149 void detach();
150 void generateMACAddress();
151
152 Machine * const mParent;
153 const ComObjPtr<NetworkAdapter> mPeer;
154 const ComObjPtr<NATEngine> mNATEngine;
155
156 bool m_fModified;
157 Backupable<Data> mData;
158};
159
160#endif // ____H_NETWORKADAPTER
161/* 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