1 | /* $Id: HostNetworkInterfaceImpl.cpp 15235 2008-12-10 09:29:07Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "HostNetworkInterfaceImpl.h"
|
---|
25 | #include "Logging.h"
|
---|
26 |
|
---|
27 | // constructor / destructor
|
---|
28 | /////////////////////////////////////////////////////////////////////////////
|
---|
29 |
|
---|
30 | DEFINE_EMPTY_CTOR_DTOR (HostNetworkInterface)
|
---|
31 |
|
---|
32 | HRESULT HostNetworkInterface::FinalConstruct()
|
---|
33 | {
|
---|
34 | return S_OK;
|
---|
35 | }
|
---|
36 |
|
---|
37 | void HostNetworkInterface::FinalRelease()
|
---|
38 | {
|
---|
39 | uninit ();
|
---|
40 | }
|
---|
41 |
|
---|
42 | // public initializer/uninitializer for internal purposes only
|
---|
43 | /////////////////////////////////////////////////////////////////////////////
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Initializes the host object.
|
---|
47 | *
|
---|
48 | * @returns COM result indicator
|
---|
49 | * @param aInterfaceName name of the network interface
|
---|
50 | * @param aGuid GUID of the host network interface
|
---|
51 | */
|
---|
52 | HRESULT HostNetworkInterface::init (Bstr aInterfaceName, Guid aGuid)
|
---|
53 | {
|
---|
54 | LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
|
---|
55 | aInterfaceName.raw(), aGuid.toString().raw()));
|
---|
56 |
|
---|
57 | ComAssertRet (aInterfaceName, E_INVALIDARG);
|
---|
58 | ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
|
---|
59 |
|
---|
60 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
61 | AutoInitSpan autoInitSpan (this);
|
---|
62 | AssertReturn (autoInitSpan.isOk(), E_FAIL);
|
---|
63 |
|
---|
64 | unconst (mInterfaceName) = aInterfaceName;
|
---|
65 | unconst (mGuid) = aGuid;
|
---|
66 |
|
---|
67 | /* Confirm a successful initialization */
|
---|
68 | autoInitSpan.setSucceeded();
|
---|
69 |
|
---|
70 | return S_OK;
|
---|
71 | }
|
---|
72 |
|
---|
73 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
74 | /**
|
---|
75 | * Initializes the host object.
|
---|
76 | *
|
---|
77 | * @returns COM result indicator
|
---|
78 | * @param aInterfaceName name of the network interface
|
---|
79 | * @param aGuid GUID of the host network interface
|
---|
80 | */
|
---|
81 | HRESULT HostNetworkInterface::init (PRTNETIFINFO pIf)
|
---|
82 | {
|
---|
83 | // LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
|
---|
84 | // aInterfaceName.raw(), aGuid.toString().raw()));
|
---|
85 |
|
---|
86 | // ComAssertRet (aInterfaceName, E_INVALIDARG);
|
---|
87 | // ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
|
---|
88 | ComAssertRet (!pIf, E_INVALIDARG);
|
---|
89 |
|
---|
90 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
91 | AutoInitSpan autoInitSpan (this);
|
---|
92 | AssertReturn (autoInitSpan.isOk(), E_FAIL);
|
---|
93 |
|
---|
94 | unconst (mInterfaceName) = Bstr(pIf->szName);
|
---|
95 | unconst (mGuid) = pIf->Uuid;
|
---|
96 | // m.IPAddress = pIf->IPAddress;
|
---|
97 | // m.networkMask = pIf->IPNetMask;
|
---|
98 | // m.IPv6Address = composeIPv6Address(pIf->IPv6Address, pIf->IPv6NetMask);
|
---|
99 |
|
---|
100 | /* Confirm a successful initialization */
|
---|
101 | autoInitSpan.setSucceeded();
|
---|
102 |
|
---|
103 | return S_OK;
|
---|
104 | }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | // IHostNetworkInterface properties
|
---|
108 | /////////////////////////////////////////////////////////////////////////////
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * Returns the name of the host network interface.
|
---|
112 | *
|
---|
113 | * @returns COM status code
|
---|
114 | * @param aInterfaceName address of result pointer
|
---|
115 | */
|
---|
116 | STDMETHODIMP HostNetworkInterface::COMGETTER(Name) (BSTR *aInterfaceName)
|
---|
117 | {
|
---|
118 | CheckComArgOutPointerValid(aInterfaceName);
|
---|
119 |
|
---|
120 | AutoCaller autoCaller (this);
|
---|
121 | CheckComRCReturnRC (autoCaller.rc());
|
---|
122 |
|
---|
123 | mInterfaceName.cloneTo (aInterfaceName);
|
---|
124 |
|
---|
125 | return S_OK;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Returns the GUID of the host network interface.
|
---|
130 | *
|
---|
131 | * @returns COM status code
|
---|
132 | * @param aGuid address of result pointer
|
---|
133 | */
|
---|
134 | STDMETHODIMP HostNetworkInterface::COMGETTER(Id) (OUT_GUID aGuid)
|
---|
135 | {
|
---|
136 | CheckComArgOutPointerValid(aGuid);
|
---|
137 |
|
---|
138 | AutoCaller autoCaller (this);
|
---|
139 | CheckComRCReturnRC (autoCaller.rc());
|
---|
140 |
|
---|
141 | mGuid.cloneTo (aGuid);
|
---|
142 |
|
---|
143 | return S_OK;
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Returns the IP address of the host network interface.
|
---|
149 | *
|
---|
150 | * @returns COM status code
|
---|
151 | * @param aIPAddress address of result pointer
|
---|
152 | */
|
---|
153 | STDMETHODIMP HostNetworkInterface::COMGETTER(IPAddress) (ULONG *aIPAddress)
|
---|
154 | {
|
---|
155 | CheckComArgOutPointerValid(aIPAddress);
|
---|
156 |
|
---|
157 | AutoCaller autoCaller (this);
|
---|
158 | CheckComRCReturnRC (autoCaller.rc());
|
---|
159 |
|
---|
160 | *aIPAddress = m.IPAddress;
|
---|
161 |
|
---|
162 | return S_OK;
|
---|
163 | }
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * Returns the netwok mask of the host network interface.
|
---|
167 | *
|
---|
168 | * @returns COM status code
|
---|
169 | * @param aNetworkMask address of result pointer
|
---|
170 | */
|
---|
171 | STDMETHODIMP HostNetworkInterface::COMGETTER(NetworkMask) (ULONG *aNetworkMask)
|
---|
172 | {
|
---|
173 | CheckComArgOutPointerValid(aNetworkMask);
|
---|
174 |
|
---|
175 | AutoCaller autoCaller (this);
|
---|
176 | CheckComRCReturnRC (autoCaller.rc());
|
---|
177 |
|
---|
178 | *aNetworkMask = m.networkMask;
|
---|
179 |
|
---|
180 | return S_OK;
|
---|
181 | }
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * Returns the IP V6 address of the host network interface.
|
---|
185 | *
|
---|
186 | * @returns COM status code
|
---|
187 | * @param aIPV6Address address of result pointer
|
---|
188 | */
|
---|
189 | STDMETHODIMP HostNetworkInterface::COMGETTER(IPV6Address) (BSTR *aIPV6Address)
|
---|
190 | {
|
---|
191 | CheckComArgOutPointerValid(aIPV6Address);
|
---|
192 |
|
---|
193 | AutoCaller autoCaller (this);
|
---|
194 | CheckComRCReturnRC (autoCaller.rc());
|
---|
195 |
|
---|
196 | m.IPV6Address.cloneTo (aIPV6Address);
|
---|
197 |
|
---|
198 | return S_OK;
|
---|
199 | }
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Returns the hardware address of the host network interface.
|
---|
203 | *
|
---|
204 | * @returns COM status code
|
---|
205 | * @param aHardwareAddress address of result pointer
|
---|
206 | */
|
---|
207 | STDMETHODIMP HostNetworkInterface::COMGETTER(HardwareAddress) (BSTR *aHardwareAddress)
|
---|
208 | {
|
---|
209 | CheckComArgOutPointerValid(aHardwareAddress);
|
---|
210 |
|
---|
211 | AutoCaller autoCaller (this);
|
---|
212 | CheckComRCReturnRC (autoCaller.rc());
|
---|
213 |
|
---|
214 | m.hardwareAddress.cloneTo (aHardwareAddress);
|
---|
215 |
|
---|
216 | return S_OK;
|
---|
217 | }
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Returns the encapsulation protocol type of the host network interface.
|
---|
221 | *
|
---|
222 | * @returns COM status code
|
---|
223 | * @param aType address of result pointer
|
---|
224 | */
|
---|
225 | STDMETHODIMP HostNetworkInterface::COMGETTER(Type) (HostNetworkInterfaceType_T *aType)
|
---|
226 | {
|
---|
227 | CheckComArgOutPointerValid(aType);
|
---|
228 |
|
---|
229 | AutoCaller autoCaller (this);
|
---|
230 | CheckComRCReturnRC (autoCaller.rc());
|
---|
231 |
|
---|
232 | *aType = m.type;
|
---|
233 |
|
---|
234 | return S_OK;
|
---|
235 | }
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Returns the current state of the host network interface.
|
---|
239 | *
|
---|
240 | * @returns COM status code
|
---|
241 | * @param aStatus address of result pointer
|
---|
242 | */
|
---|
243 | STDMETHODIMP HostNetworkInterface::COMGETTER(Status) (HostNetworkInterfaceStatus_T *aStatus)
|
---|
244 | {
|
---|
245 | CheckComArgOutPointerValid(aStatus);
|
---|
246 |
|
---|
247 | AutoCaller autoCaller (this);
|
---|
248 | CheckComRCReturnRC (autoCaller.rc());
|
---|
249 |
|
---|
250 | *aStatus = m.status;
|
---|
251 |
|
---|
252 | return S_OK;
|
---|
253 | }
|
---|
254 |
|
---|
255 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|