VirtualBox

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

Last change on this file since 4071 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

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