VirtualBox

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

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 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 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21 * Clara, CA 95054 USA or visit http://www.sun.com if you need
22 * additional information or have any questions.
23 */
24
25
26
27#include <VBox/err.h>
28#include <iprt/assert.h>
29
30#include <NetworkAdapterImpl.h>
31#include <NATDriver.h>
32#include <COMDefs.h>
33#include <ConsoleImpl.h>
34
35/**
36 * Returns the host interface the adapter is attached to
37 *
38 * @returns COM status code
39 * @param hostInterface address of result string
40 */
41STDMETHODIMP NetworkAdapter::COMGETTER(HostInterface)(BSTR *hostInterface)
42{
43 if (!hostInterface)
44 return E_POINTER;
45 AutoLock alock(this);
46 // CHECK_READY();
47
48 // mData->mHostInterface.cloneTo(hostInterface);
49 mData.mHostInterface.cloneTo(hostInterface);
50
51 return S_OK;
52}
53
54NetworkAdapter::NetworkAdapter()
55{
56 RTCritSectInit(&mCritSec);
57}
58
59
60NetworkAdapter::~NetworkAdapter()
61{
62}
63
64int
65NetworkAdapter::init (Console *parent, ULONG slot)
66{
67 mParent = parent;
68 mData.mSlot = slot;
69 return S_OK;
70}
71
72
73STDMETHODIMP
74NetworkAdapter::COMGETTER(Slot)(ULONG *slot)
75{
76 if (!slot)
77 return E_POINTER;
78
79 AutoLock alock (this);
80 // CHECK_READY();
81
82 *slot = mData.mSlot;
83 return S_OK;
84}
85
86
87STDMETHODIMP
88NetworkAdapter::COMGETTER(Enabled)(bool *enabled)
89{
90 if (!enabled)
91 return E_POINTER;
92
93 AutoLock alock (this);
94 // CHECK_READY();
95
96 *enabled = mData.mEnabled;
97 return S_OK;
98}
99
100
101STDMETHODIMP
102NetworkAdapter::COMSETTER(Enabled)(BOOL enabled)
103{
104 AutoLock alock(this);
105 // CHECK_READY();
106
107 // CHECK_MACHINE_MUTABILITY (mParent);
108
109 if (mData.mEnabled != enabled)
110 {
111 // mData.backup();
112 mData.mEnabled = enabled;
113
114 /* notify parent */
115 alock.unlock();
116 mParent->onNetworkAdapterChange (this);
117 }
118
119 return S_OK;
120}
121
122STDMETHODIMP
123NetworkAdapter::COMGETTER(MACAddress)(BSTR *macAddress)
124{
125 AssertMsg(0,("Not implemented yet\n"));
126 return 0;
127}
128
129STDMETHODIMP
130NetworkAdapter::COMSETTER(MACAddress)(INPTR BSTR macAddress)
131{
132 AssertMsg(0,("Not implemented yet\n"));
133 return 0;
134}
135
136
137STDMETHODIMP
138NetworkAdapter::COMSETTER(HostInterface)(INPTR BSTR hostInterface)
139{
140#ifdef RT_OS_LINUX
141 // empty strings are not allowed as path names
142 if (hostInterface && !(*hostInterface))
143 return E_INVALIDARG;
144#endif
145
146
147 AutoLock alock(this);
148 // CHECK_READY();
149
150 // CHECK_MACHINE_MUTABILITY (mParent);
151
152 if (mData.mHostInterface != hostInterface)
153 {
154 // mData.backup();
155 mData.mHostInterface = hostInterface;
156
157 /* notify parent */
158 alock.unlock();
159 mParent->onNetworkAdapterChange(this);
160 }
161
162 return S_OK;
163}
164
165
166
167STDMETHODIMP
168NetworkAdapter::COMGETTER(TAPFileDescriptor)(LONG *tapFileDescriptor)
169{
170 if (!tapFileDescriptor)
171 return E_POINTER;
172
173 AutoLock alock(this);
174 // CHECK_READY();
175
176 *tapFileDescriptor = mData.mTAPFD;
177
178 return S_OK;
179
180}
181
182STDMETHODIMP
183NetworkAdapter::COMSETTER(TAPFileDescriptor)(LONG tapFileDescriptor)
184{
185 /*
186 * Validate input.
187 */
188 RTFILE tapFD = tapFileDescriptor;
189 if (tapFD != NIL_RTFILE && (LONG)tapFD != tapFileDescriptor)
190 {
191 AssertMsgFailed(("Invalid file descriptor: %ld.\n", tapFileDescriptor));
192
193 // setError VirtualBoxSupportErrorInfoImplBase which
194 // is a parent class of NetworAdapter in the COM flavored version
195 // return setError (E_INVALIDARG,
196 // tr ("Invalid file descriptor: %ld"), tapFileDescriptor);
197
198 return S_OK;
199
200 }
201
202 AutoLock alock(this);
203 // CHECK_READY();
204
205 // CHECK_MACHINE_MUTABILITY (mParent);
206
207 if (mData.mTAPFD != (RTFILE) tapFileDescriptor)
208 {
209 // mData.backup();
210 mData.mTAPFD = tapFileDescriptor;
211
212 /* notify parent */
213 alock.unlock();
214 mParent->onNetworkAdapterChange(this);
215 }
216
217 return S_OK;
218
219}
220
221STDMETHODIMP
222NetworkAdapter::COMGETTER(TAPSetupApplication)(BSTR *tapSetupApplication)
223{
224 if (!tapSetupApplication)
225 return E_POINTER;
226 AutoLock alock(this);
227 // CHECK_READY();
228
229 /* we don't have to be in TAP mode to support this call */
230 mData.mTAPSetupApplication.cloneTo(tapSetupApplication);
231
232 return S_OK;
233
234}
235
236STDMETHODIMP
237NetworkAdapter::COMSETTER(TAPSetupApplication)(INPTR BSTR tapSetupApplication)
238{
239 AssertMsg(0,("Not implemented yet\n"));
240 return 0;
241}
242
243STDMETHODIMP
244NetworkAdapter::COMGETTER(TAPTerminateApplication)(BSTR *tapTerminateApplication)
245{
246 AssertMsg(0,("Not implemented yet\n"));
247 return 0;
248}
249
250STDMETHODIMP
251NetworkAdapter::COMSETTER(TAPTerminateApplication)(INPTR BSTR tapTerminateApplication)
252{
253 AssertMsg(0,("Not implemented yet\n"));
254 return 0;
255}
256
257STDMETHODIMP
258NetworkAdapter::COMGETTER(InternalNetwork)(BSTR *internalNetwork)
259{
260 AssertMsg(0,("Not implemented yet\n"));
261 return 0;
262}
263STDMETHODIMP
264NetworkAdapter::COMSETTER(InternalNetwork)(INPTR BSTR internalNetwork)
265{
266 AssertMsg(0,("Not implemented yet\n"));
267 return 0;
268}
269STDMETHODIMP
270NetworkAdapter::COMGETTER(CableConnected)(BOOL *connected)
271{
272 if (!connected)
273 return E_POINTER;
274
275 AutoLock alock(this);
276 // CHECK_READY();
277
278 *connected = mData.mCableConnected;
279 return S_OK;
280
281}
282STDMETHODIMP
283NetworkAdapter::COMSETTER(CableConnected)(BOOL connected)
284{
285 AssertMsg(0,("Not implemented yet\n"));
286 return 0;
287}
288STDMETHODIMP
289NetworkAdapter::COMGETTER(TraceEnabled)(BOOL *enabled)
290{
291 AssertMsg(0,("Not implemented yet\n"));
292 return 0;
293}
294STDMETHODIMP
295NetworkAdapter::COMSETTER(TraceEnabled)(BOOL enabled)
296{
297 AssertMsg(0,("Not implemented yet\n"));
298 return 0;
299}
300
301 // INetworkAdapter methods
302STDMETHODIMP
303NetworkAdapter::AttachToNAT()
304{
305 AssertMsg(0,("Not implemented yet\n"));
306 return 0;
307}
308STDMETHODIMP
309NetworkAdapter::AttachToBridgedInterface()
310{
311 AssertMsg(0,("Not implemented yet\n"));
312 return 0;
313}
314STDMETHODIMP
315NetworkAdapter::AttachToInternalNetwork()
316{
317 AssertMsg(0,("Not implemented yet\n"));
318 return 0;
319}
320STDMETHODIMP
321NetworkAdapter::Detach()
322{
323 AssertMsg(0,("Not implemented yet\n"));
324 return 0;
325}
326
327void
328NetworkAdapter::detach()
329{
330 AssertMsg(0,("Not implemented yet\n"));
331}
332
333void
334NetworkAdapter::generateMACAddress()
335{
336 AssertMsg(0,("Not implemented yet\n"));
337}
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