VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/NetworkAdapterImpl.cpp@ 43421

Last change on this file since 43421 was 41184, checked in by vboxsync, 12 years ago

Main+Frontends: removed unused and confusing VirtualBoxErrorInfo implementation, and cleaned up lots of misleading comments and other leftovers about the earlier ErrorInfo mess

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1/** @file
2 *
3 * VBox frontends: Basic Frontend (BFE):
4 * Implementation of NetworkAdapter class
5 *
6 * This is adapted from frontends/VirtualBox/NetworkAdapter.cpp.
7 */
8
9/*
10 * Copyright (C) 2006-2007 Oracle Corporation
11 *
12 * This file is part of VirtualBox Open Source Edition (OSE), as
13 * available from http://www.virtualbox.org. This file is free software;
14 * you can redistribute it and/or modify it under the terms of the GNU
15 * General Public License (GPL) as published by the Free Software
16 * Foundation, in version 2 as it comes in the "COPYING" file of the
17 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19 */
20
21
22
23#include <VBox/err.h>
24#include <iprt/assert.h>
25
26#include <NetworkAdapterImpl.h>
27#include <NATDriver.h>
28#include <COMDefs.h>
29#include <ConsoleImpl.h>
30
31/**
32 * Returns the host interface the adapter is attached to
33 *
34 * @returns COM status code
35 * @param hostInterface address of result string
36 */
37STDMETHODIMP NetworkAdapter::COMGETTER(HostInterface)(BSTR *hostInterface)
38{
39 if (!hostInterface)
40 return E_POINTER;
41 AutoLock alock(this);
42 // CHECK_READY();
43
44 // mData->mHostInterface.cloneTo(hostInterface);
45 mData.mHostInterface.cloneTo(hostInterface);
46
47 return S_OK;
48}
49
50NetworkAdapter::NetworkAdapter()
51{
52 RTCritSectInit(&mCritSec);
53}
54
55
56NetworkAdapter::~NetworkAdapter()
57{
58}
59
60int
61NetworkAdapter::init (Console *parent, ULONG slot)
62{
63 mParent = parent;
64 mData.mSlot = slot;
65 return S_OK;
66}
67
68
69STDMETHODIMP
70NetworkAdapter::COMGETTER(Slot)(ULONG *slot)
71{
72 if (!slot)
73 return E_POINTER;
74
75 AutoLock alock (this);
76 // CHECK_READY();
77
78 *slot = mData.mSlot;
79 return S_OK;
80}
81
82
83STDMETHODIMP
84NetworkAdapter::COMGETTER(Enabled)(bool *enabled)
85{
86 if (!enabled)
87 return E_POINTER;
88
89 AutoLock alock (this);
90 // CHECK_READY();
91
92 *enabled = mData.mEnabled;
93 return S_OK;
94}
95
96
97STDMETHODIMP
98NetworkAdapter::COMSETTER(Enabled)(BOOL enabled)
99{
100 AutoLock alock(this);
101 // CHECK_READY();
102
103 // CHECK_MACHINE_MUTABILITY (mParent);
104
105 if (mData.mEnabled != enabled)
106 {
107 // mData.backup();
108 mData.mEnabled = enabled;
109
110 /* notify parent */
111 alock.unlock();
112 mParent->onNetworkAdapterChange (this);
113 }
114
115 return S_OK;
116}
117
118STDMETHODIMP
119NetworkAdapter::COMGETTER(MACAddress)(BSTR *macAddress)
120{
121 AssertMsg(0,("Not implemented yet\n"));
122 return 0;
123}
124
125STDMETHODIMP
126NetworkAdapter::COMSETTER(MACAddress)(INPTR BSTR macAddress)
127{
128 AssertMsg(0,("Not implemented yet\n"));
129 return 0;
130}
131
132
133STDMETHODIMP
134NetworkAdapter::COMSETTER(HostInterface)(INPTR BSTR hostInterface)
135{
136#ifdef RT_OS_LINUX
137 // empty strings are not allowed as path names
138 if (hostInterface && !(*hostInterface))
139 return E_INVALIDARG;
140#endif
141
142
143 AutoLock alock(this);
144 // CHECK_READY();
145
146 // CHECK_MACHINE_MUTABILITY (mParent);
147
148 if (mData.mHostInterface != hostInterface)
149 {
150 // mData.backup();
151 mData.mHostInterface = hostInterface;
152
153 /* notify parent */
154 alock.unlock();
155 mParent->onNetworkAdapterChange(this);
156 }
157
158 return S_OK;
159}
160
161
162
163STDMETHODIMP
164NetworkAdapter::COMGETTER(TAPFileDescriptor)(LONG *tapFileDescriptor)
165{
166 if (!tapFileDescriptor)
167 return E_POINTER;
168
169 AutoLock alock(this);
170 // CHECK_READY();
171
172 *tapFileDescriptor = mData.mTAPFD;
173
174 return S_OK;
175
176}
177
178STDMETHODIMP
179NetworkAdapter::COMSETTER(TAPFileDescriptor)(LONG tapFileDescriptor)
180{
181 /*
182 * Validate input.
183 */
184 RTFILE tapFD = tapFileDescriptor;
185 if (tapFD != NIL_RTFILE && (LONG)tapFD != tapFileDescriptor)
186 {
187 AssertMsgFailed(("Invalid file descriptor: %ld.\n", tapFileDescriptor));
188
189 return setError (E_INVALIDARG,
190 tr ("Invalid file descriptor: %ld"), tapFileDescriptor);
191 }
192
193 AutoLock alock(this);
194 // CHECK_READY();
195
196 // CHECK_MACHINE_MUTABILITY (mParent);
197
198 if (mData.mTAPFD != (RTFILE) tapFileDescriptor)
199 {
200 // mData.backup();
201 mData.mTAPFD = tapFileDescriptor;
202
203 /* notify parent */
204 alock.unlock();
205 mParent->onNetworkAdapterChange(this);
206 }
207
208 return S_OK;
209
210}
211
212STDMETHODIMP
213NetworkAdapter::COMGETTER(TAPSetupApplication)(BSTR *tapSetupApplication)
214{
215 if (!tapSetupApplication)
216 return E_POINTER;
217 AutoLock alock(this);
218 // CHECK_READY();
219
220 /* we don't have to be in TAP mode to support this call */
221 mData.mTAPSetupApplication.cloneTo(tapSetupApplication);
222
223 return S_OK;
224
225}
226
227STDMETHODIMP
228NetworkAdapter::COMSETTER(TAPSetupApplication)(INPTR BSTR tapSetupApplication)
229{
230 AssertMsg(0,("Not implemented yet\n"));
231 return 0;
232}
233
234STDMETHODIMP
235NetworkAdapter::COMGETTER(TAPTerminateApplication)(BSTR *tapTerminateApplication)
236{
237 AssertMsg(0,("Not implemented yet\n"));
238 return 0;
239}
240
241STDMETHODIMP
242NetworkAdapter::COMSETTER(TAPTerminateApplication)(INPTR BSTR tapTerminateApplication)
243{
244 AssertMsg(0,("Not implemented yet\n"));
245 return 0;
246}
247
248STDMETHODIMP
249NetworkAdapter::COMGETTER(InternalNetwork)(BSTR *internalNetwork)
250{
251 AssertMsg(0,("Not implemented yet\n"));
252 return 0;
253}
254STDMETHODIMP
255NetworkAdapter::COMSETTER(InternalNetwork)(INPTR BSTR internalNetwork)
256{
257 AssertMsg(0,("Not implemented yet\n"));
258 return 0;
259}
260STDMETHODIMP
261NetworkAdapter::COMGETTER(CableConnected)(BOOL *connected)
262{
263 if (!connected)
264 return E_POINTER;
265
266 AutoLock alock(this);
267 // CHECK_READY();
268
269 *connected = mData.mCableConnected;
270 return S_OK;
271
272}
273STDMETHODIMP
274NetworkAdapter::COMSETTER(CableConnected)(BOOL connected)
275{
276 AssertMsg(0,("Not implemented yet\n"));
277 return 0;
278}
279STDMETHODIMP
280NetworkAdapter::COMGETTER(TraceEnabled)(BOOL *enabled)
281{
282 AssertMsg(0,("Not implemented yet\n"));
283 return 0;
284}
285STDMETHODIMP
286NetworkAdapter::COMSETTER(TraceEnabled)(BOOL enabled)
287{
288 AssertMsg(0,("Not implemented yet\n"));
289 return 0;
290}
291
292 // INetworkAdapter methods
293STDMETHODIMP
294NetworkAdapter::AttachToNAT()
295{
296 AssertMsg(0,("Not implemented yet\n"));
297 return 0;
298}
299STDMETHODIMP
300NetworkAdapter::AttachToBridgedInterface()
301{
302 AssertMsg(0,("Not implemented yet\n"));
303 return 0;
304}
305STDMETHODIMP
306NetworkAdapter::AttachToInternalNetwork()
307{
308 AssertMsg(0,("Not implemented yet\n"));
309 return 0;
310}
311STDMETHODIMP
312NetworkAdapter::Detach()
313{
314 AssertMsg(0,("Not implemented yet\n"));
315 return 0;
316}
317
318void
319NetworkAdapter::detach()
320{
321 AssertMsg(0,("Not implemented yet\n"));
322}
323
324void
325NetworkAdapter::generateMACAddress()
326{
327 AssertMsg(0,("Not implemented yet\n"));
328}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use