VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 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 // setError VirtualBoxSupportErrorInfoImplBase which
190 // is a parent class of NetworAdapter in the COM flavored version
191 // return setError (E_INVALIDARG,
192 // tr ("Invalid file descriptor: %ld"), tapFileDescriptor);
193
194 return S_OK;
195
196 }
197
198 AutoLock alock(this);
199 // CHECK_READY();
200
201 // CHECK_MACHINE_MUTABILITY (mParent);
202
203 if (mData.mTAPFD != (RTFILE) tapFileDescriptor)
204 {
205 // mData.backup();
206 mData.mTAPFD = tapFileDescriptor;
207
208 /* notify parent */
209 alock.unlock();
210 mParent->onNetworkAdapterChange(this);
211 }
212
213 return S_OK;
214
215}
216
217STDMETHODIMP
218NetworkAdapter::COMGETTER(TAPSetupApplication)(BSTR *tapSetupApplication)
219{
220 if (!tapSetupApplication)
221 return E_POINTER;
222 AutoLock alock(this);
223 // CHECK_READY();
224
225 /* we don't have to be in TAP mode to support this call */
226 mData.mTAPSetupApplication.cloneTo(tapSetupApplication);
227
228 return S_OK;
229
230}
231
232STDMETHODIMP
233NetworkAdapter::COMSETTER(TAPSetupApplication)(INPTR BSTR tapSetupApplication)
234{
235 AssertMsg(0,("Not implemented yet\n"));
236 return 0;
237}
238
239STDMETHODIMP
240NetworkAdapter::COMGETTER(TAPTerminateApplication)(BSTR *tapTerminateApplication)
241{
242 AssertMsg(0,("Not implemented yet\n"));
243 return 0;
244}
245
246STDMETHODIMP
247NetworkAdapter::COMSETTER(TAPTerminateApplication)(INPTR BSTR tapTerminateApplication)
248{
249 AssertMsg(0,("Not implemented yet\n"));
250 return 0;
251}
252
253STDMETHODIMP
254NetworkAdapter::COMGETTER(InternalNetwork)(BSTR *internalNetwork)
255{
256 AssertMsg(0,("Not implemented yet\n"));
257 return 0;
258}
259STDMETHODIMP
260NetworkAdapter::COMSETTER(InternalNetwork)(INPTR BSTR internalNetwork)
261{
262 AssertMsg(0,("Not implemented yet\n"));
263 return 0;
264}
265STDMETHODIMP
266NetworkAdapter::COMGETTER(CableConnected)(BOOL *connected)
267{
268 if (!connected)
269 return E_POINTER;
270
271 AutoLock alock(this);
272 // CHECK_READY();
273
274 *connected = mData.mCableConnected;
275 return S_OK;
276
277}
278STDMETHODIMP
279NetworkAdapter::COMSETTER(CableConnected)(BOOL connected)
280{
281 AssertMsg(0,("Not implemented yet\n"));
282 return 0;
283}
284STDMETHODIMP
285NetworkAdapter::COMGETTER(TraceEnabled)(BOOL *enabled)
286{
287 AssertMsg(0,("Not implemented yet\n"));
288 return 0;
289}
290STDMETHODIMP
291NetworkAdapter::COMSETTER(TraceEnabled)(BOOL enabled)
292{
293 AssertMsg(0,("Not implemented yet\n"));
294 return 0;
295}
296
297 // INetworkAdapter methods
298STDMETHODIMP
299NetworkAdapter::AttachToNAT()
300{
301 AssertMsg(0,("Not implemented yet\n"));
302 return 0;
303}
304STDMETHODIMP
305NetworkAdapter::AttachToBridgedInterface()
306{
307 AssertMsg(0,("Not implemented yet\n"));
308 return 0;
309}
310STDMETHODIMP
311NetworkAdapter::AttachToInternalNetwork()
312{
313 AssertMsg(0,("Not implemented yet\n"));
314 return 0;
315}
316STDMETHODIMP
317NetworkAdapter::Detach()
318{
319 AssertMsg(0,("Not implemented yet\n"));
320 return 0;
321}
322
323void
324NetworkAdapter::detach()
325{
326 AssertMsg(0,("Not implemented yet\n"));
327}
328
329void
330NetworkAdapter::generateMACAddress()
331{
332 AssertMsg(0,("Not implemented yet\n"));
333}
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