VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/NetworkAdapterImpl.h@ 9380

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

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/** @file
2 *
3 * VBox frontends: Basic Frontend (BFE):
4 * Declaration 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#ifndef ____H_NETWORKADAPTER
27#define ____H_NETWORKADAPTER
28
29
30#include <VBox/types.h>
31#include <COMDefs.h>
32#include <COMStr.h>
33#include <iprt/critsect.h>
34#include <iprt/assert.h>
35
36class Console;
37
38
39#define BSTR PRUnichar*
40
41#define INPTR const
42
43class NetworkAdapter
44{
45public:
46 RTCRITSECT mCritSec;
47 struct Data
48 {
49 Data()
50 : mSlot (0), mEnabled (FALSE)
51 , mCableConnected (TRUE), mTraceEnabled (FALSE)
52#ifdef RT_OS_LINUX
53 , mTAPFD (NIL_RTFILE)
54#endif
55 , mInternalNetwork ("") // cannot be null
56 {}
57
58 ULONG mSlot;
59 BOOL mEnabled;
60 Bstr mMACAddress;
61 BOOL mCableConnected;
62 BOOL mTraceEnabled;
63 Bstr mHostInterface;
64#ifdef RT_OS_LINUX
65 Bstr mTAPSetupApplication;
66 Bstr mTAPTerminateApplication;
67 RTFILE mTAPFD;
68#endif
69 Bstr mInternalNetwork;
70 };
71
72 NetworkAdapter();
73 virtual ~NetworkAdapter();
74
75 HRESULT FinalConstruct();
76 void FinalRelease();
77
78 // public initializer/uninitializer for internal purposes only
79 int init (Console *parent, ULONG slot);
80 // int init (Console *parent, NetworkAdapter *that);
81 void uninit();
82
83 // INetworkAdapter properties
84 STDMETHOD(COMGETTER(Slot)) (ULONG *slot);
85 STDMETHOD(COMGETTER(Enabled)) (BOOL *enabled);
86 STDMETHOD(COMSETTER(Enabled)) (BOOL enabled);
87 STDMETHOD(COMGETTER(MACAddress))(BSTR *macAddress);
88 STDMETHOD(COMSETTER(MACAddress))(INPTR BSTR macAddress);
89 // STDMETHOD(COMGETTER(AttachmentType))(NetworkAttachmentType_T *attachmentType);
90 STDMETHOD(COMGETTER(HostInterface))(BSTR *hostInterface);
91 STDMETHOD(COMSETTER(HostInterface))(INPTR BSTR hostInterface);
92#ifdef RT_OS_LINUX
93 STDMETHOD(COMGETTER(TAPFileDescriptor))(LONG *tapFileDescriptor);
94 STDMETHOD(COMSETTER(TAPFileDescriptor))(LONG tapFileDescriptor);
95 STDMETHOD(COMGETTER(TAPSetupApplication))(BSTR *tapSetupApplication);
96 STDMETHOD(COMSETTER(TAPSetupApplication))(INPTR BSTR tapSetupApplication);
97 STDMETHOD(COMGETTER(TAPTerminateApplication))(BSTR *tapTerminateApplication);
98 STDMETHOD(COMSETTER(TAPTerminateApplication))(INPTR BSTR tapTerminateApplication);
99#endif
100 STDMETHOD(COMGETTER(InternalNetwork))(BSTR *internalNetwork);
101 STDMETHOD(COMSETTER(InternalNetwork))(INPTR BSTR internalNetwork);
102 STDMETHOD(COMGETTER(CableConnected))(BOOL *connected);
103 STDMETHOD(COMSETTER(CableConnected))(BOOL connected);
104 STDMETHOD(COMGETTER(TraceEnabled))(BOOL *enabled);
105 STDMETHOD(COMSETTER(TraceEnabled))(BOOL enabled);
106
107 // INetworkAdapter methods
108 STDMETHOD(AttachToNAT)();
109 STDMETHOD(AttachToHostInterface)();
110 STDMETHOD(AttachToInternalNetwork)();
111 STDMETHOD(Detach)();
112
113 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
114
115private:
116
117 void detach();
118 void generateMACAddress();
119
120 Console *mParent;
121 Data mData;
122};
123
124class AutoLock
125 {
126 public:
127 AutoLock (NetworkAdapter *that) : outer (that), mLevel (0) { lock(); }
128 ~AutoLock() {
129 AssertMsg (mLevel <= 1, ("Lock level > 1: %d\n", mLevel));
130 while (mLevel --)
131 RTCritSectLeave (&outer->mCritSec);
132 }
133 void lock() {
134 ++ mLevel;
135 RTCritSectEnter (&outer->mCritSec);
136 }
137 void unlock() {
138 AssertMsg (mLevel > 0, ("Lock level is zero\n"));
139 if (mLevel > 0) {
140 RTCritSectLeave (&outer->mCritSec);
141 -- mLevel;
142 }
143 }
144 private:
145 AutoLock (const AutoLock &that);
146 AutoLock &operator = (const AutoLock &that);
147 NetworkAdapter *outer;
148 unsigned int mLevel;
149 };
150
151#endif // ____H_NETWORKADAPTER
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