1 | /* $Id: NATEngineImpl.cpp 34992 2010-12-13 11:36:38Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Implementation of INATEngine in VBoxSVC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include "NATEngineImpl.h"
|
---|
19 | #include "AutoCaller.h"
|
---|
20 | #include "Logging.h"
|
---|
21 | #include "MachineImpl.h"
|
---|
22 | #include "GuestOSTypeImpl.h"
|
---|
23 |
|
---|
24 | #include <iprt/string.h>
|
---|
25 | #include <iprt/cpp/utils.h>
|
---|
26 |
|
---|
27 | #include <VBox/err.h>
|
---|
28 | #include <VBox/settings.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | // constructor / destructor
|
---|
32 | ////////////////////////////////////////////////////////////////////////////////
|
---|
33 |
|
---|
34 | NATEngine::NATEngine():mParent(NULL), mAdapter(NULL){}
|
---|
35 | NATEngine::~NATEngine(){}
|
---|
36 |
|
---|
37 | HRESULT NATEngine::FinalConstruct()
|
---|
38 | {
|
---|
39 | return S_OK;
|
---|
40 | }
|
---|
41 |
|
---|
42 | HRESULT NATEngine::init(Machine *aParent, INetworkAdapter *aAdapter)
|
---|
43 | {
|
---|
44 | AutoInitSpan autoInitSpan(this);
|
---|
45 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
46 | autoInitSpan.setSucceeded();
|
---|
47 | m_fModified = false;
|
---|
48 | mData.allocate();
|
---|
49 | mData->mNetwork.setNull();
|
---|
50 | mData->mBindIP.setNull();
|
---|
51 | unconst(mParent) = aParent;
|
---|
52 | unconst(mAdapter) = aAdapter;
|
---|
53 | return S_OK;
|
---|
54 | }
|
---|
55 |
|
---|
56 | HRESULT NATEngine::init(Machine *aParent, INetworkAdapter *aAdapter, NATEngine *aThat)
|
---|
57 | {
|
---|
58 | AutoInitSpan autoInitSpan(this);
|
---|
59 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
60 | Log(("init that:%p this:%p\n", aThat, this));
|
---|
61 |
|
---|
62 | AutoCaller thatCaller (aThat);
|
---|
63 | AssertComRCReturnRC(thatCaller.rc());
|
---|
64 |
|
---|
65 | AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
66 |
|
---|
67 | mData.share(aThat->mData);
|
---|
68 | NATRuleMap::iterator it;
|
---|
69 | mNATRules.clear();
|
---|
70 | for (it = aThat->mNATRules.begin(); it != aThat->mNATRules.end(); ++it)
|
---|
71 | {
|
---|
72 | mNATRules.insert(std::make_pair(it->first, it->second));
|
---|
73 | }
|
---|
74 | unconst(mParent) = aParent;
|
---|
75 | unconst(mAdapter) = aAdapter;
|
---|
76 | unconst(mPeer) = aThat;
|
---|
77 | autoInitSpan.setSucceeded();
|
---|
78 | return S_OK;
|
---|
79 | }
|
---|
80 |
|
---|
81 | HRESULT NATEngine::initCopy (Machine *aParent, INetworkAdapter *aAdapter, NATEngine *aThat)
|
---|
82 | {
|
---|
83 | AutoInitSpan autoInitSpan(this);
|
---|
84 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
85 |
|
---|
86 | Log(("initCopy that:%p this:%p\n", aThat, this));
|
---|
87 |
|
---|
88 | AutoCaller thatCaller (aThat);
|
---|
89 | AssertComRCReturnRC(thatCaller.rc());
|
---|
90 |
|
---|
91 | AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
92 |
|
---|
93 | mData.attachCopy(aThat->mData);
|
---|
94 | NATRuleMap::iterator it;
|
---|
95 | mNATRules.clear();
|
---|
96 | for (it = aThat->mNATRules.begin(); it != aThat->mNATRules.end(); ++it)
|
---|
97 | {
|
---|
98 | mNATRules.insert(std::make_pair(it->first, it->second));
|
---|
99 | }
|
---|
100 | unconst(mAdapter) = aAdapter;
|
---|
101 | unconst(mParent) = aParent;
|
---|
102 | autoInitSpan.setSucceeded();
|
---|
103 | return S_OK;
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | void NATEngine::FinalRelease()
|
---|
108 | {
|
---|
109 | uninit();
|
---|
110 | }
|
---|
111 |
|
---|
112 | void NATEngine::uninit()
|
---|
113 | {
|
---|
114 | AutoUninitSpan autoUninitSpan(this);
|
---|
115 | if (autoUninitSpan.uninitDone())
|
---|
116 | return;
|
---|
117 |
|
---|
118 | mNATRules.clear();
|
---|
119 | mData.free();
|
---|
120 | unconst(mPeer) = NULL;
|
---|
121 | unconst(mParent) = NULL;
|
---|
122 | }
|
---|
123 |
|
---|
124 | bool NATEngine::isModified()
|
---|
125 | {
|
---|
126 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
127 | bool fModified = m_fModified;
|
---|
128 | return fModified;
|
---|
129 | }
|
---|
130 |
|
---|
131 | bool NATEngine::rollback()
|
---|
132 | {
|
---|
133 | AutoCaller autoCaller(this);
|
---|
134 | AssertComRCReturn (autoCaller.rc(), false);
|
---|
135 |
|
---|
136 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
137 | bool fChanged = m_fModified;
|
---|
138 |
|
---|
139 | if (m_fModified)
|
---|
140 | {
|
---|
141 | /* we need to check all data to see whether anything will be changed
|
---|
142 | * after rollback */
|
---|
143 | mData.rollback();
|
---|
144 | }
|
---|
145 | m_fModified = false;
|
---|
146 | return fChanged;
|
---|
147 | }
|
---|
148 |
|
---|
149 | void NATEngine::commit()
|
---|
150 | {
|
---|
151 | AutoCaller autoCaller(this);
|
---|
152 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
153 |
|
---|
154 | /* sanity too */
|
---|
155 | AutoCaller peerCaller (mPeer);
|
---|
156 | AssertComRCReturnVoid (peerCaller.rc());
|
---|
157 |
|
---|
158 | /* lock both for writing since we modify both (mPeer is "master" so locked
|
---|
159 | * first) */
|
---|
160 | AutoMultiWriteLock2 alock(mPeer, this COMMA_LOCKVAL_SRC_POS);
|
---|
161 | if (m_fModified)
|
---|
162 | {
|
---|
163 | mData.commit();
|
---|
164 | if (mPeer)
|
---|
165 | {
|
---|
166 | mPeer->mData.attach (mData);
|
---|
167 | mPeer->mNATRules.clear();
|
---|
168 | NATRuleMap::iterator it;
|
---|
169 | for (it = mNATRules.begin(); it != mNATRules.end(); ++it)
|
---|
170 | {
|
---|
171 | mPeer->mNATRules.insert(std::make_pair(it->first, it->second));
|
---|
172 | }
|
---|
173 | }
|
---|
174 | }
|
---|
175 | m_fModified = false;
|
---|
176 | }
|
---|
177 |
|
---|
178 | STDMETHODIMP
|
---|
179 | NATEngine::GetNetworkSettings(ULONG *aMtu, ULONG *aSockSnd, ULONG *aSockRcv, ULONG *aTcpWndSnd, ULONG *aTcpWndRcv)
|
---|
180 | {
|
---|
181 | AutoCaller autoCaller(this);
|
---|
182 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
183 |
|
---|
184 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
185 | if (aMtu)
|
---|
186 | *aMtu = mData->mMtu;
|
---|
187 | if (aSockSnd)
|
---|
188 | *aSockSnd = mData->mSockSnd;
|
---|
189 | if (aSockRcv)
|
---|
190 | *aSockRcv = mData->mSockRcv;
|
---|
191 | if (aTcpWndSnd)
|
---|
192 | *aTcpWndSnd = mData->mTcpSnd;
|
---|
193 | if (aTcpWndRcv)
|
---|
194 | *aTcpWndRcv = mData->mTcpRcv;
|
---|
195 |
|
---|
196 | return S_OK;
|
---|
197 | }
|
---|
198 |
|
---|
199 | STDMETHODIMP
|
---|
200 | NATEngine::SetNetworkSettings(ULONG aMtu, ULONG aSockSnd, ULONG aSockRcv, ULONG aTcpWndSnd, ULONG aTcpWndRcv)
|
---|
201 | {
|
---|
202 | AutoCaller autoCaller(this);
|
---|
203 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
204 |
|
---|
205 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
206 | if ( aMtu || aSockSnd || aSockRcv
|
---|
207 | || aTcpWndSnd || aTcpWndRcv)
|
---|
208 | {
|
---|
209 | mData.backup();
|
---|
210 | m_fModified = true;
|
---|
211 | }
|
---|
212 | if (aMtu)
|
---|
213 | mData->mMtu = aMtu;
|
---|
214 | if (aSockSnd)
|
---|
215 | mData->mSockSnd = aSockSnd;
|
---|
216 | if (aSockRcv)
|
---|
217 | mData->mSockRcv = aSockSnd;
|
---|
218 | if (aTcpWndSnd)
|
---|
219 | mData->mTcpSnd = aTcpWndSnd;
|
---|
220 | if (aTcpWndRcv)
|
---|
221 | mData->mTcpRcv = aTcpWndRcv;
|
---|
222 |
|
---|
223 | if (m_fModified)
|
---|
224 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
225 | return S_OK;
|
---|
226 | }
|
---|
227 |
|
---|
228 | STDMETHODIMP
|
---|
229 | NATEngine::COMGETTER(Redirects)(ComSafeArrayOut(BSTR , aNatRules))
|
---|
230 | {
|
---|
231 | CheckComArgOutSafeArrayPointerValid(aNatRules);
|
---|
232 |
|
---|
233 | AutoCaller autoCaller(this);
|
---|
234 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
235 |
|
---|
236 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
237 |
|
---|
238 |
|
---|
239 | SafeArray<BSTR> sf(mNATRules.size());
|
---|
240 | size_t i = 0;
|
---|
241 | NATRuleMap::const_iterator it;
|
---|
242 | for (it = mNATRules.begin();
|
---|
243 | it != mNATRules.end(); ++it, ++i)
|
---|
244 | {
|
---|
245 | settings::NATRule r = it->second;
|
---|
246 | BstrFmt bstr("%s,%d,%s,%d,%s,%d",
|
---|
247 | r.strName.c_str(),
|
---|
248 | r.proto,
|
---|
249 | r.strHostIP.c_str(),
|
---|
250 | r.u16HostPort,
|
---|
251 | r.strGuestIP.c_str(),
|
---|
252 | r.u16GuestPort);
|
---|
253 | bstr.detachTo(&sf[i]);
|
---|
254 | }
|
---|
255 | sf.detachTo(ComSafeArrayOutArg(aNatRules));
|
---|
256 | return S_OK;
|
---|
257 | }
|
---|
258 |
|
---|
259 |
|
---|
260 | STDMETHODIMP
|
---|
261 | NATEngine::AddRedirect(IN_BSTR aName, NATProtocol_T aProto, IN_BSTR aBindIp, USHORT aHostPort, IN_BSTR aGuestIP, USHORT aGuestPort)
|
---|
262 | {
|
---|
263 |
|
---|
264 | AutoCaller autoCaller(this);
|
---|
265 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
266 |
|
---|
267 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
268 | Utf8Str name = aName;
|
---|
269 | settings::NATRule r;
|
---|
270 | const char *proto;
|
---|
271 | switch (aProto)
|
---|
272 | {
|
---|
273 | case NATProtocol_TCP:
|
---|
274 | proto = "tcp";
|
---|
275 | break;
|
---|
276 | case NATProtocol_UDP:
|
---|
277 | proto = "udp";
|
---|
278 | break;
|
---|
279 | default:
|
---|
280 | return E_INVALIDARG;
|
---|
281 | }
|
---|
282 | if (name.isEmpty())
|
---|
283 | name = Utf8StrFmt("%s_%d_%d", proto, aHostPort, aGuestPort);
|
---|
284 |
|
---|
285 | NATRuleMap::iterator it;
|
---|
286 | for (it = mNATRules.begin(); it != mNATRules.end(); ++it)
|
---|
287 | {
|
---|
288 | r = it->second;
|
---|
289 | if (it->first == name)
|
---|
290 | return setError(E_INVALIDARG,
|
---|
291 | tr("A NAT rule of this name does already exist"));
|
---|
292 | if ( r.strHostIP == Utf8Str(aBindIp)
|
---|
293 | && r.u16HostPort == aHostPort)
|
---|
294 | return setError(E_INVALIDARG,
|
---|
295 | tr("A NAT rule for this host port and this host IP does already exist"));
|
---|
296 | }
|
---|
297 |
|
---|
298 | r.strName = name.c_str();
|
---|
299 | r.proto = aProto;
|
---|
300 | r.strHostIP = aBindIp;
|
---|
301 | r.u16HostPort = aHostPort;
|
---|
302 | r.strGuestIP = aGuestIP;
|
---|
303 | r.u16GuestPort = aGuestPort;
|
---|
304 | mNATRules.insert(std::make_pair(name, r));
|
---|
305 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
306 | m_fModified = true;
|
---|
307 |
|
---|
308 | ULONG ulSlot;
|
---|
309 | mAdapter->COMGETTER(Slot)(&ulSlot);
|
---|
310 |
|
---|
311 | alock.release();
|
---|
312 | mParent->onNATRedirectRuleChange(ulSlot, FALSE, Bstr(name).raw(), aProto, Bstr(r.strHostIP).raw(), r.u16HostPort, Bstr(r.strGuestIP).raw(), r.u16GuestPort);
|
---|
313 | return S_OK;
|
---|
314 | }
|
---|
315 |
|
---|
316 | STDMETHODIMP
|
---|
317 | NATEngine::RemoveRedirect(IN_BSTR aName)
|
---|
318 | {
|
---|
319 | AutoCaller autoCaller(this);
|
---|
320 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
321 |
|
---|
322 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
323 | NATRuleMap::iterator it = mNATRules.find(aName);
|
---|
324 | if (it == mNATRules.end())
|
---|
325 | return E_INVALIDARG;
|
---|
326 | mData.backup();
|
---|
327 | settings::NATRule r = it->second;
|
---|
328 | Utf8Str strHostIP = r.strHostIP;
|
---|
329 | Utf8Str strGuestIP = r.strGuestIP;
|
---|
330 | NATProtocol_T proto = r.proto;
|
---|
331 | uint16_t u16HostPort = r.u16HostPort;
|
---|
332 | uint16_t u16GuestPort = r.u16GuestPort;
|
---|
333 | ULONG ulSlot;
|
---|
334 | mAdapter->COMGETTER(Slot)(&ulSlot);
|
---|
335 |
|
---|
336 | mNATRules.erase(it);
|
---|
337 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
338 | m_fModified = true;
|
---|
339 | alock.release();
|
---|
340 | mParent->onNATRedirectRuleChange(ulSlot, TRUE, aName, proto, Bstr(strHostIP).raw(), u16HostPort, Bstr(strGuestIP).raw(), u16GuestPort);
|
---|
341 | return S_OK;
|
---|
342 | }
|
---|
343 |
|
---|
344 | HRESULT NATEngine::loadSettings(const settings::NAT &data)
|
---|
345 | {
|
---|
346 | AutoCaller autoCaller(this);
|
---|
347 | AssertComRCReturnRC(autoCaller.rc());
|
---|
348 |
|
---|
349 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
350 | HRESULT rc = S_OK;
|
---|
351 | mData->mNetwork = data.strNetwork;
|
---|
352 | mData->mBindIP = data.strBindIP;
|
---|
353 | mData->mMtu = data.u32Mtu;
|
---|
354 | mData->mSockSnd = data.u32SockSnd;
|
---|
355 | mData->mTcpRcv = data.u32TcpRcv;
|
---|
356 | mData->mTcpSnd = data.u32TcpSnd;
|
---|
357 | /* TFTP */
|
---|
358 | mData->mTftpPrefix = data.strTftpPrefix;
|
---|
359 | mData->mTftpBootFile = data.strTftpBootFile;
|
---|
360 | mData->mTftpNextServer = data.strTftpNextServer;
|
---|
361 | /* DNS */
|
---|
362 | mData->mDnsPassDomain = data.fDnsPassDomain;
|
---|
363 | mData->mDnsProxy = data.fDnsProxy;
|
---|
364 | mData->mDnsUseHostResolver = data.fDnsUseHostResolver;
|
---|
365 | /* Alias */
|
---|
366 | mData->mAliasMode = (data.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
|
---|
367 | mData->mAliasMode |= (data.fAliasLog ? NATAliasMode_AliasLog : 0);
|
---|
368 | mData->mAliasMode |= (data.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
|
---|
369 | /* port forwarding */
|
---|
370 | mNATRules.clear();
|
---|
371 | for (settings::NATRuleList::const_iterator it = data.llRules.begin();
|
---|
372 | it != data.llRules.end(); ++it)
|
---|
373 | {
|
---|
374 | mNATRules.insert(std::make_pair(it->strName, *it));
|
---|
375 | }
|
---|
376 | m_fModified = false;
|
---|
377 | return rc;
|
---|
378 | }
|
---|
379 |
|
---|
380 |
|
---|
381 | HRESULT NATEngine::saveSettings(settings::NAT &data)
|
---|
382 | {
|
---|
383 | AutoCaller autoCaller(this);
|
---|
384 | AssertComRCReturnRC(autoCaller.rc());
|
---|
385 |
|
---|
386 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
387 | HRESULT rc = S_OK;
|
---|
388 | data.strNetwork = mData->mNetwork;
|
---|
389 | data.strBindIP = mData->mBindIP;
|
---|
390 | data.u32Mtu = mData->mMtu;
|
---|
391 | data.u32SockRcv = mData->mSockRcv;
|
---|
392 | data.u32SockSnd = mData->mSockSnd;
|
---|
393 | data.u32TcpRcv = mData->mTcpRcv;
|
---|
394 | data.u32TcpSnd = mData->mTcpSnd;
|
---|
395 | /* TFTP */
|
---|
396 | data.strTftpPrefix = mData->mTftpPrefix;
|
---|
397 | data.strTftpBootFile = mData->mTftpBootFile;
|
---|
398 | data.strTftpNextServer = mData->mTftpNextServer;
|
---|
399 | /* DNS */
|
---|
400 | data.fDnsPassDomain = !!mData->mDnsPassDomain;
|
---|
401 | data.fDnsProxy = !!mData->mDnsProxy;
|
---|
402 | data.fDnsUseHostResolver = !!mData->mDnsUseHostResolver;
|
---|
403 | /* Alias */
|
---|
404 | data.fAliasLog = !!(mData->mAliasMode & NATAliasMode_AliasLog);
|
---|
405 | data.fAliasProxyOnly = !!(mData->mAliasMode & NATAliasMode_AliasProxyOnly);
|
---|
406 | data.fAliasUseSamePorts = !!(mData->mAliasMode & NATAliasMode_AliasUseSamePorts);
|
---|
407 |
|
---|
408 | for (NATRuleMap::iterator it = mNATRules.begin();
|
---|
409 | it != mNATRules.end(); ++it)
|
---|
410 | data.llRules.push_back(it->second);
|
---|
411 | m_fModified = false;
|
---|
412 | return rc;
|
---|
413 | }
|
---|
414 |
|
---|
415 |
|
---|
416 | STDMETHODIMP
|
---|
417 | NATEngine::COMSETTER(Network)(IN_BSTR aNetwork)
|
---|
418 | {
|
---|
419 | AutoCaller autoCaller(this);
|
---|
420 | AssertComRCReturnRC (autoCaller.rc());
|
---|
421 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
422 | if (Bstr(mData->mNetwork) != aNetwork)
|
---|
423 | {
|
---|
424 | mData.backup();
|
---|
425 | mData->mNetwork = aNetwork;
|
---|
426 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
427 | m_fModified = true;
|
---|
428 | }
|
---|
429 | return S_OK;
|
---|
430 | }
|
---|
431 |
|
---|
432 | STDMETHODIMP
|
---|
433 | NATEngine::COMGETTER(Network)(BSTR *aNetwork)
|
---|
434 | {
|
---|
435 | CheckComArgNotNull(aNetwork);
|
---|
436 | AutoCaller autoCaller(this);
|
---|
437 | AssertComRCReturnRC(autoCaller.rc());
|
---|
438 |
|
---|
439 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
440 | if (!mData->mNetwork.isEmpty())
|
---|
441 | {
|
---|
442 | mData->mNetwork.cloneTo(aNetwork);
|
---|
443 | Log(("Getter (this:%p) Network: %s\n", this, mData->mNetwork.c_str()));
|
---|
444 | }
|
---|
445 | return S_OK;
|
---|
446 | }
|
---|
447 |
|
---|
448 | STDMETHODIMP
|
---|
449 | NATEngine::COMSETTER(HostIP) (IN_BSTR aBindIP)
|
---|
450 | {
|
---|
451 | AutoCaller autoCaller(this);
|
---|
452 | AssertComRCReturnRC (autoCaller.rc());
|
---|
453 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
454 | if (Bstr(mData->mBindIP) != aBindIP)
|
---|
455 | {
|
---|
456 | mData.backup();
|
---|
457 | mData->mBindIP = aBindIP;
|
---|
458 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
459 | m_fModified = true;
|
---|
460 | }
|
---|
461 | return S_OK;
|
---|
462 | }
|
---|
463 | STDMETHODIMP NATEngine::COMGETTER(HostIP) (BSTR *aBindIP)
|
---|
464 | {
|
---|
465 | AutoCaller autoCaller(this);
|
---|
466 | AssertComRCReturnRC(autoCaller.rc());
|
---|
467 |
|
---|
468 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
469 | if (!mData->mBindIP.isEmpty())
|
---|
470 | mData->mBindIP.cloneTo(aBindIP);
|
---|
471 | return S_OK;
|
---|
472 | }
|
---|
473 |
|
---|
474 |
|
---|
475 | STDMETHODIMP
|
---|
476 | NATEngine::COMSETTER(TftpPrefix)(IN_BSTR aTftpPrefix)
|
---|
477 | {
|
---|
478 | AutoCaller autoCaller(this);
|
---|
479 | AssertComRCReturnRC (autoCaller.rc());
|
---|
480 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
481 | if (Bstr(mData->mTftpPrefix) != aTftpPrefix)
|
---|
482 | {
|
---|
483 | mData.backup();
|
---|
484 | mData->mTftpPrefix = aTftpPrefix;
|
---|
485 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
486 | m_fModified = true;
|
---|
487 | }
|
---|
488 | return S_OK;
|
---|
489 | }
|
---|
490 |
|
---|
491 | STDMETHODIMP
|
---|
492 | NATEngine::COMGETTER(TftpPrefix)(BSTR *aTftpPrefix)
|
---|
493 | {
|
---|
494 | AutoCaller autoCaller(this);
|
---|
495 | AssertComRCReturnRC(autoCaller.rc());
|
---|
496 |
|
---|
497 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
498 | if (!mData->mTftpPrefix.isEmpty())
|
---|
499 | {
|
---|
500 | mData->mTftpPrefix.cloneTo(aTftpPrefix);
|
---|
501 | Log(("Getter (this:%p) TftpPrefix: %s\n", this, mData->mTftpPrefix.c_str()));
|
---|
502 | }
|
---|
503 | return S_OK;
|
---|
504 | }
|
---|
505 |
|
---|
506 | STDMETHODIMP
|
---|
507 | NATEngine::COMSETTER(TftpBootFile)(IN_BSTR aTftpBootFile)
|
---|
508 | {
|
---|
509 | AutoCaller autoCaller(this);
|
---|
510 | AssertComRCReturnRC (autoCaller.rc());
|
---|
511 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
512 | if (Bstr(mData->mTftpBootFile) != aTftpBootFile)
|
---|
513 | {
|
---|
514 | mData.backup();
|
---|
515 | mData->mTftpBootFile = aTftpBootFile;
|
---|
516 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
517 | m_fModified = true;
|
---|
518 | }
|
---|
519 | return S_OK;
|
---|
520 | }
|
---|
521 |
|
---|
522 | STDMETHODIMP
|
---|
523 | NATEngine::COMGETTER(TftpBootFile)(BSTR *aTftpBootFile)
|
---|
524 | {
|
---|
525 | AutoCaller autoCaller(this);
|
---|
526 | AssertComRCReturnRC(autoCaller.rc());
|
---|
527 |
|
---|
528 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
529 | if (!mData->mTftpBootFile.isEmpty())
|
---|
530 | {
|
---|
531 | mData->mTftpBootFile.cloneTo(aTftpBootFile);
|
---|
532 | Log(("Getter (this:%p) BootFile: %s\n", this, mData->mTftpBootFile.c_str()));
|
---|
533 | }
|
---|
534 | return S_OK;
|
---|
535 | }
|
---|
536 |
|
---|
537 | STDMETHODIMP
|
---|
538 | NATEngine::COMSETTER(TftpNextServer)(IN_BSTR aTftpNextServer)
|
---|
539 | {
|
---|
540 | AutoCaller autoCaller(this);
|
---|
541 | AssertComRCReturnRC (autoCaller.rc());
|
---|
542 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
543 | if (Bstr(mData->mTftpNextServer) != aTftpNextServer)
|
---|
544 | {
|
---|
545 | mData.backup();
|
---|
546 | mData->mTftpNextServer = aTftpNextServer;
|
---|
547 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
548 | m_fModified = true;
|
---|
549 | }
|
---|
550 | return S_OK;
|
---|
551 | }
|
---|
552 |
|
---|
553 | STDMETHODIMP
|
---|
554 | NATEngine::COMGETTER(TftpNextServer)(BSTR *aTftpNextServer)
|
---|
555 | {
|
---|
556 | AutoCaller autoCaller(this);
|
---|
557 | AssertComRCReturnRC(autoCaller.rc());
|
---|
558 |
|
---|
559 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
560 | if (!mData->mTftpNextServer.isEmpty())
|
---|
561 | {
|
---|
562 | mData->mTftpNextServer.cloneTo(aTftpNextServer);
|
---|
563 | Log(("Getter (this:%p) NextServer: %s\n", this, mData->mTftpNextServer.c_str()));
|
---|
564 | }
|
---|
565 | return S_OK;
|
---|
566 | }
|
---|
567 | /* DNS */
|
---|
568 | STDMETHODIMP
|
---|
569 | NATEngine::COMSETTER(DnsPassDomain) (BOOL aDnsPassDomain)
|
---|
570 | {
|
---|
571 | AutoCaller autoCaller(this);
|
---|
572 | AssertComRCReturnRC (autoCaller.rc());
|
---|
573 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
574 |
|
---|
575 | if (mData->mDnsPassDomain != aDnsPassDomain)
|
---|
576 | {
|
---|
577 | mData.backup();
|
---|
578 | mData->mDnsPassDomain = aDnsPassDomain;
|
---|
579 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
580 | m_fModified = true;
|
---|
581 | }
|
---|
582 | return S_OK;
|
---|
583 | }
|
---|
584 | STDMETHODIMP
|
---|
585 | NATEngine::COMGETTER(DnsPassDomain)(BOOL *aDnsPassDomain)
|
---|
586 | {
|
---|
587 | AutoCaller autoCaller(this);
|
---|
588 | AssertComRCReturnRC(autoCaller.rc());
|
---|
589 |
|
---|
590 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
591 | *aDnsPassDomain = mData->mDnsPassDomain;
|
---|
592 | return S_OK;
|
---|
593 | }
|
---|
594 | STDMETHODIMP
|
---|
595 | NATEngine::COMSETTER(DnsProxy)(BOOL aDnsProxy)
|
---|
596 | {
|
---|
597 | AutoCaller autoCaller(this);
|
---|
598 | AssertComRCReturnRC (autoCaller.rc());
|
---|
599 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
600 |
|
---|
601 | if (mData->mDnsProxy != aDnsProxy)
|
---|
602 | {
|
---|
603 | mData.backup();
|
---|
604 | mData->mDnsProxy = aDnsProxy;
|
---|
605 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
606 | m_fModified = true;
|
---|
607 | }
|
---|
608 | return S_OK;
|
---|
609 | }
|
---|
610 | STDMETHODIMP
|
---|
611 | NATEngine::COMGETTER(DnsProxy)(BOOL *aDnsProxy)
|
---|
612 | {
|
---|
613 | AutoCaller autoCaller(this);
|
---|
614 | AssertComRCReturnRC(autoCaller.rc());
|
---|
615 |
|
---|
616 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
617 | *aDnsProxy = mData->mDnsProxy;
|
---|
618 | return S_OK;
|
---|
619 | }
|
---|
620 | STDMETHODIMP
|
---|
621 | NATEngine::COMGETTER(DnsUseHostResolver)(BOOL *aDnsUseHostResolver)
|
---|
622 | {
|
---|
623 | AutoCaller autoCaller(this);
|
---|
624 | AssertComRCReturnRC (autoCaller.rc());
|
---|
625 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
626 | *aDnsUseHostResolver = mData->mDnsUseHostResolver;
|
---|
627 | return S_OK;
|
---|
628 | }
|
---|
629 | STDMETHODIMP
|
---|
630 | NATEngine::COMSETTER(DnsUseHostResolver)(BOOL aDnsUseHostResolver)
|
---|
631 | {
|
---|
632 | AutoCaller autoCaller(this);
|
---|
633 | AssertComRCReturnRC(autoCaller.rc());
|
---|
634 |
|
---|
635 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
636 |
|
---|
637 | if (mData->mDnsUseHostResolver != aDnsUseHostResolver)
|
---|
638 | {
|
---|
639 | mData.backup();
|
---|
640 | mData->mDnsUseHostResolver = aDnsUseHostResolver;
|
---|
641 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
642 | m_fModified = true;
|
---|
643 | }
|
---|
644 | return S_OK;
|
---|
645 | }
|
---|
646 |
|
---|
647 | STDMETHODIMP NATEngine::COMSETTER(AliasMode) (ULONG aAliasMode)
|
---|
648 | {
|
---|
649 | AutoCaller autoCaller(this);
|
---|
650 | AssertComRCReturnRC(autoCaller.rc());
|
---|
651 |
|
---|
652 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
653 |
|
---|
654 | if (mData->mAliasMode != aAliasMode)
|
---|
655 | {
|
---|
656 | mData.backup();
|
---|
657 | mData->mAliasMode = aAliasMode;
|
---|
658 | mParent->setModified(Machine::IsModified_NetworkAdapters);
|
---|
659 | m_fModified = true;
|
---|
660 | }
|
---|
661 | return S_OK;
|
---|
662 | }
|
---|
663 |
|
---|
664 | STDMETHODIMP NATEngine::COMGETTER(AliasMode) (ULONG *aAliasMode)
|
---|
665 | {
|
---|
666 | AutoCaller autoCaller(this);
|
---|
667 | AssertComRCReturnRC (autoCaller.rc());
|
---|
668 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
669 | *aAliasMode = mData->mAliasMode;
|
---|
670 | return S_OK;
|
---|
671 | }
|
---|
672 |
|
---|