VirtualBox

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

最後變更 在這個檔案從27857是 27857,由 vboxsync 提交於 15 年 前

Main: NAT API and corresponding commands have been added at VBoxManage frontend. Please see #1899 for details.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.0 KB
 
1/* $Id: NetworkAdapterImpl.h 27857 2010-03-31 09:02:32Z 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.alldomusa.eu.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 "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 {}
53
54 NetworkAdapterType_T mAdapterType;
55 ULONG mSlot;
56 BOOL mEnabled;
57 Bstr mMACAddress;
58 NetworkAttachmentType_T mAttachmentType;
59 BOOL mCableConnected;
60 ULONG mLineSpeed;
61 BOOL mTraceEnabled;
62 Bstr mTraceFile;
63 Bstr mHostInterface;
64 Bstr mInternalNetwork;
65 Bstr mNATNetwork;
66 };
67
68 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
69
70 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
71
72 DECLARE_PROTECT_FINAL_CONSTRUCT()
73
74 BEGIN_COM_MAP(NetworkAdapter)
75 COM_INTERFACE_ENTRY (ISupportErrorInfo)
76 COM_INTERFACE_ENTRY (INetworkAdapter)
77 COM_INTERFACE_ENTRY2 (IDispatch, INetworkAdapter)
78 END_COM_MAP()
79
80 DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
81
82 HRESULT FinalConstruct();
83 void FinalRelease();
84
85 // public initializer/uninitializer for internal purposes only
86 HRESULT init (Machine *aParent, ULONG aSlot);
87 HRESULT init (Machine *aParent, NetworkAdapter *aThat);
88 HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
89 void uninit();
90
91 // INetworkAdapter properties
92 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
93 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
94 STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
95 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
96 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
97 STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
98 STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
99 STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
100 STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
101 STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
102 STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
103 STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
104 STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
105 STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
106 STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
107 STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
108 STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
109 STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
110 STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
111 STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
112 STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
113 STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
114 STDMETHOD(COMGETTER(NatDriver)) (INATEngine **aNatDriver);
115
116 // INetworkAdapter methods
117 STDMETHOD(AttachToNAT)();
118 STDMETHOD(AttachToBridgedInterface)();
119 STDMETHOD(AttachToInternalNetwork)();
120 STDMETHOD(AttachToHostOnlyInterface)();
121 STDMETHOD(Detach)();
122
123 // public methods only for internal purposes
124
125 HRESULT loadSettings(const settings::NetworkAdapter &data);
126 HRESULT saveSettings(settings::NetworkAdapter &data);
127
128 bool isModified();
129 void rollback();
130 void commit();
131 void copyFrom (NetworkAdapter *aThat);
132 void applyDefaults (GuestOSType *aOsType);
133
134 // for VirtualBoxSupportErrorInfoImpl
135 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
136
137private:
138
139 void detach();
140 void generateMACAddress();
141
142 Machine * const mParent;
143 const ComObjPtr<NetworkAdapter> mPeer;
144 const ComObjPtr<NATEngine> mNATEngine;
145
146 bool m_fModified;
147 Backupable<Data> mData;
148};
149
150#endif // ____H_NETWORKADAPTER
151/* vi: set tabstop=4 shiftwidth=4 expandtab: */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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