VirtualBox

source: vbox/trunk/src/VBox/Main/include/NetworkAdapterImpl.h@ 1711

Last change on this file since 1711 was 606, checked in by vboxsync, 18 years ago

Initial darwin port. (Not tested on linux yet.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef ____H_NETWORKADAPTER
23#define ____H_NETWORKADAPTER
24
25#include "VirtualBoxBase.h"
26#include "Collection.h"
27
28class Machine;
29
30class ATL_NO_VTABLE NetworkAdapter :
31 public VirtualBoxBase,
32 public VirtualBoxSupportErrorInfoImpl <NetworkAdapter, INetworkAdapter>,
33 public VirtualBoxSupportTranslation <NetworkAdapter>,
34 public INetworkAdapter
35{
36public:
37
38 struct Data
39 {
40 Data()
41 : mSlot (0), mEnabled (FALSE)
42 , mAttachmentType (NetworkAttachmentType_NoNetworkAttachment)
43 , mCableConnected (TRUE), mTraceEnabled (FALSE)
44#ifdef __WIN__
45 , mHostInterface ("") // cannot be null
46#endif
47#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
48 , mTAPFD (NIL_RTFILE)
49#endif
50 , mInternalNetwork ("") // cannot be null
51 {}
52
53 bool operator== (const Data &that) const
54 {
55 return this == &that ||
56 (mSlot == that.mSlot &&
57 mEnabled == that.mEnabled &&
58 mMACAddress == that.mMACAddress &&
59 mAttachmentType == that.mAttachmentType &&
60 mCableConnected == that.mCableConnected &&
61 mTraceEnabled == that.mTraceEnabled &&
62 mHostInterface == that.mHostInterface &&
63#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
64 mTAPSetupApplication == that.mTAPSetupApplication &&
65 mTAPTerminateApplication == that.mTAPTerminateApplication &&
66 mTAPFD == that.mTAPFD &&
67#endif
68 mInternalNetwork == that.mInternalNetwork);
69 }
70
71 NetworkAdapterType_T mAdapterType;
72 ULONG mSlot;
73 BOOL mEnabled;
74 Bstr mMACAddress;
75 NetworkAttachmentType_T mAttachmentType;
76 BOOL mCableConnected;
77 BOOL mTraceEnabled;
78 Bstr mTraceFile;
79 Bstr mHostInterface;
80#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
81 Bstr mTAPSetupApplication;
82 Bstr mTAPTerminateApplication;
83 RTFILE mTAPFD;
84#endif
85 Bstr mInternalNetwork;
86 };
87
88 DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
89
90 DECLARE_PROTECT_FINAL_CONSTRUCT()
91
92 BEGIN_COM_MAP(NetworkAdapter)
93 COM_INTERFACE_ENTRY(ISupportErrorInfo)
94 COM_INTERFACE_ENTRY(INetworkAdapter)
95 END_COM_MAP()
96
97 NS_DECL_ISUPPORTS
98
99 HRESULT FinalConstruct();
100 void FinalRelease();
101
102 // public initializer/uninitializer for internal purposes only
103 HRESULT init (Machine *parent, ULONG slot);
104 HRESULT init (Machine *parent, NetworkAdapter *that);
105 HRESULT initCopy (Machine *parent, NetworkAdapter *that);
106 void uninit();
107
108 // INetworkAdapter properties
109 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *adapterType);
110 STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T adapterType);
111 STDMETHOD(COMGETTER(Slot)) (ULONG *slot);
112 STDMETHOD(COMGETTER(Enabled)) (BOOL *enabled);
113 STDMETHOD(COMSETTER(Enabled)) (BOOL enabled);
114 STDMETHOD(COMGETTER(MACAddress))(BSTR *macAddress);
115 STDMETHOD(COMSETTER(MACAddress))(INPTR BSTR macAddress);
116 STDMETHOD(COMGETTER(AttachmentType))(NetworkAttachmentType_T *attachmentType);
117 STDMETHOD(COMGETTER(HostInterface))(BSTR *hostInterface);
118 STDMETHOD(COMSETTER(HostInterface))(INPTR BSTR hostInterface);
119#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
120 STDMETHOD(COMGETTER(TAPFileDescriptor))(LONG *tapFileDescriptor);
121 STDMETHOD(COMSETTER(TAPFileDescriptor))(LONG tapFileDescriptor);
122 STDMETHOD(COMGETTER(TAPSetupApplication))(BSTR *tapSetupApplication);
123 STDMETHOD(COMSETTER(TAPSetupApplication))(INPTR BSTR tapSetupApplication);
124 STDMETHOD(COMGETTER(TAPTerminateApplication))(BSTR *tapTerminateApplication);
125 STDMETHOD(COMSETTER(TAPTerminateApplication))(INPTR BSTR tapTerminateApplication);
126#endif
127 STDMETHOD(COMGETTER(InternalNetwork))(BSTR *internalNetwork);
128 STDMETHOD(COMSETTER(InternalNetwork))(INPTR BSTR internalNetwork);
129 STDMETHOD(COMGETTER(CableConnected))(BOOL *connected);
130 STDMETHOD(COMSETTER(CableConnected))(BOOL connected);
131 STDMETHOD(COMGETTER(TraceEnabled))(BOOL *enabled);
132 STDMETHOD(COMSETTER(TraceEnabled))(BOOL enabled);
133 STDMETHOD(COMGETTER(TraceFile))(BSTR *traceFile);
134 STDMETHOD(COMSETTER(TraceFile))(INPTR BSTR traceFile);
135
136 // INetworkAdapter methods
137 STDMETHOD(AttachToNAT)();
138 STDMETHOD(AttachToHostInterface)();
139 STDMETHOD(AttachToInternalNetwork)();
140 STDMETHOD(Detach)();
141
142 // public methods only for internal purposes
143
144 const Backupable <Data> &data() const { return mData; }
145
146 bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
147 bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
148 bool rollback();
149 void commit();
150 void copyFrom (NetworkAdapter *aThat);
151
152 // for VirtualBoxSupportErrorInfoImpl
153 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
154
155private:
156
157 void detach();
158 void generateMACAddress();
159
160 ComObjPtr <Machine, ComWeakRef> mParent;
161 ComObjPtr <NetworkAdapter> mPeer;
162 Backupable <Data> mData;
163};
164
165#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