VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/NATEngineImpl.cpp@ 45761

Last change on this file since 45761 was 45185, checked in by vboxsync, 12 years ago

Main/NATEngine: commit data, before releasing and firing event (vbox/11635).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.6 KB
Line 
1/* $Id: NATEngineImpl.cpp 45185 2013-03-26 07:52:14Z vboxsync $ */
2/** @file
3 * Implementation of INATEngine in VBoxSVC.
4 */
5
6/*
7 * Copyright (C) 2010-2012 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
34NATEngine::NATEngine():mParent(NULL), mAdapter(NULL){}
35NATEngine::~NATEngine(){}
36
37HRESULT NATEngine::FinalConstruct()
38{
39 return S_OK;
40}
41
42HRESULT 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
56HRESULT 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
81HRESULT 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 BaseFinalConstruct();
104}
105
106
107void NATEngine::FinalRelease()
108{
109 uninit();
110 BaseFinalRelease();
111}
112
113void NATEngine::uninit()
114{
115 AutoUninitSpan autoUninitSpan(this);
116 if (autoUninitSpan.uninitDone())
117 return;
118
119 mNATRules.clear();
120 mData.free();
121 unconst(mPeer) = NULL;
122 unconst(mParent) = NULL;
123}
124
125bool NATEngine::isModified()
126{
127 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
128 bool fModified = m_fModified;
129 return fModified;
130}
131
132bool NATEngine::rollback()
133{
134 AutoCaller autoCaller(this);
135 AssertComRCReturn(autoCaller.rc(), false);
136
137 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
138 bool fChanged = m_fModified;
139
140 if (m_fModified)
141 {
142 /* we need to check all data to see whether anything will be changed
143 * after rollback */
144 mData.rollback();
145 }
146 m_fModified = false;
147 return fChanged;
148}
149
150void NATEngine::commit()
151{
152 AutoCaller autoCaller(this);
153 AssertComRCReturnVoid(autoCaller.rc());
154
155 /* sanity too */
156 AutoCaller peerCaller(mPeer);
157 AssertComRCReturnVoid(peerCaller.rc());
158
159 /* lock both for writing since we modify both (mPeer is "master" so locked
160 * first) */
161 AutoMultiWriteLock2 alock(mPeer, this COMMA_LOCKVAL_SRC_POS);
162 if (m_fModified)
163 {
164 mData.commit();
165 if (mPeer)
166 {
167 mPeer->mData.attach(mData);
168 mPeer->mNATRules.clear();
169 NATRuleMap::iterator it;
170 for (it = mNATRules.begin(); it != mNATRules.end(); ++it)
171 {
172 mPeer->mNATRules.insert(std::make_pair(it->first, it->second));
173 }
174 }
175 }
176 m_fModified = false;
177}
178
179STDMETHODIMP
180NATEngine::GetNetworkSettings(ULONG *aMtu, ULONG *aSockSnd, ULONG *aSockRcv, ULONG *aTcpWndSnd, ULONG *aTcpWndRcv)
181{
182 AutoCaller autoCaller(this);
183 if (FAILED(autoCaller.rc())) return autoCaller.rc();
184
185 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
186 if (aMtu)
187 *aMtu = mData->mMtu;
188 if (aSockSnd)
189 *aSockSnd = mData->mSockSnd;
190 if (aSockRcv)
191 *aSockRcv = mData->mSockRcv;
192 if (aTcpWndSnd)
193 *aTcpWndSnd = mData->mTcpSnd;
194 if (aTcpWndRcv)
195 *aTcpWndRcv = mData->mTcpRcv;
196
197 return S_OK;
198}
199
200STDMETHODIMP
201NATEngine::SetNetworkSettings(ULONG aMtu, ULONG aSockSnd, ULONG aSockRcv, ULONG aTcpWndSnd, ULONG aTcpWndRcv)
202{
203 AutoCaller autoCaller(this);
204 if (FAILED(autoCaller.rc())) return autoCaller.rc();
205
206 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
207 if ( aMtu || aSockSnd || aSockRcv
208 || aTcpWndSnd || aTcpWndRcv)
209 {
210 mData.backup();
211 m_fModified = true;
212 }
213 if (aMtu)
214 mData->mMtu = aMtu;
215 if (aSockSnd)
216 mData->mSockSnd = aSockSnd;
217 if (aSockRcv)
218 mData->mSockRcv = aSockSnd;
219 if (aTcpWndSnd)
220 mData->mTcpSnd = aTcpWndSnd;
221 if (aTcpWndRcv)
222 mData->mTcpRcv = aTcpWndRcv;
223
224 if (m_fModified)
225 mParent->setModified(Machine::IsModified_NetworkAdapters);
226 return S_OK;
227}
228
229STDMETHODIMP
230NATEngine::COMGETTER(Redirects)(ComSafeArrayOut(BSTR , aNatRules))
231{
232 CheckComArgOutSafeArrayPointerValid(aNatRules);
233
234 AutoCaller autoCaller(this);
235 if (FAILED(autoCaller.rc())) return autoCaller.rc();
236
237 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
238
239
240 SafeArray<BSTR> sf(mNATRules.size());
241 size_t i = 0;
242 NATRuleMap::const_iterator it;
243 for (it = mNATRules.begin();
244 it != mNATRules.end(); ++it, ++i)
245 {
246 settings::NATRule r = it->second;
247 BstrFmt bstr("%s,%d,%s,%d,%s,%d",
248 r.strName.c_str(),
249 r.proto,
250 r.strHostIP.c_str(),
251 r.u16HostPort,
252 r.strGuestIP.c_str(),
253 r.u16GuestPort);
254 bstr.detachTo(&sf[i]);
255 }
256 sf.detachTo(ComSafeArrayOutArg(aNatRules));
257 return S_OK;
258}
259
260
261STDMETHODIMP
262NATEngine::AddRedirect(IN_BSTR aName, NATProtocol_T aProto, IN_BSTR aBindIp, USHORT aHostPort, IN_BSTR aGuestIP, USHORT aGuestPort)
263{
264
265 AutoCaller autoCaller(this);
266 if (FAILED(autoCaller.rc())) return autoCaller.rc();
267
268 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
269 Utf8Str name = aName;
270 settings::NATRule r;
271 const char *proto;
272 switch (aProto)
273 {
274 case NATProtocol_TCP:
275 proto = "tcp";
276 break;
277 case NATProtocol_UDP:
278 proto = "udp";
279 break;
280 default:
281 return E_INVALIDARG;
282 }
283 if (name.isEmpty())
284 name = Utf8StrFmt("%s_%d_%d", proto, aHostPort, aGuestPort);
285
286 NATRuleMap::iterator it;
287 for (it = mNATRules.begin(); it != mNATRules.end(); ++it)
288 {
289 r = it->second;
290 if (it->first == name)
291 return setError(E_INVALIDARG,
292 tr("A NAT rule of this name already exists"));
293 if ( r.strHostIP == Utf8Str(aBindIp)
294 && r.u16HostPort == aHostPort
295 && r.proto == aProto)
296 return setError(E_INVALIDARG,
297 tr("A NAT rule for this host port and this host IP already exists"));
298 }
299
300 r.strName = name.c_str();
301 r.proto = aProto;
302 r.strHostIP = aBindIp;
303 r.u16HostPort = aHostPort;
304 r.strGuestIP = aGuestIP;
305 r.u16GuestPort = aGuestPort;
306 mNATRules.insert(std::make_pair(name, r));
307 mParent->setModified(Machine::IsModified_NetworkAdapters);
308 m_fModified = true;
309
310 ULONG ulSlot;
311 mAdapter->COMGETTER(Slot)(&ulSlot);
312
313 alock.release();
314 mParent->onNATRedirectRuleChange(ulSlot, FALSE, Bstr(name).raw(), aProto, Bstr(r.strHostIP).raw(), r.u16HostPort, Bstr(r.strGuestIP).raw(), r.u16GuestPort);
315 return S_OK;
316}
317
318STDMETHODIMP
319NATEngine::RemoveRedirect(IN_BSTR aName)
320{
321 AutoCaller autoCaller(this);
322 if (FAILED(autoCaller.rc())) return autoCaller.rc();
323
324 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
325 NATRuleMap::iterator it = mNATRules.find(aName);
326 if (it == mNATRules.end())
327 return E_INVALIDARG;
328 mData.backup();
329 settings::NATRule r = it->second;
330 Utf8Str strHostIP = r.strHostIP;
331 Utf8Str strGuestIP = r.strGuestIP;
332 NATProtocol_T proto = r.proto;
333 uint16_t u16HostPort = r.u16HostPort;
334 uint16_t u16GuestPort = r.u16GuestPort;
335 ULONG ulSlot;
336 mAdapter->COMGETTER(Slot)(&ulSlot);
337
338 mNATRules.erase(it);
339 mParent->setModified(Machine::IsModified_NetworkAdapters);
340 m_fModified = true;
341 mData.commit();
342 alock.release();
343 mParent->onNATRedirectRuleChange(ulSlot, TRUE, aName, proto, Bstr(strHostIP).raw(), u16HostPort, Bstr(strGuestIP).raw(), u16GuestPort);
344 return S_OK;
345}
346
347HRESULT NATEngine::loadSettings(const settings::NAT &data)
348{
349 AutoCaller autoCaller(this);
350 AssertComRCReturnRC(autoCaller.rc());
351
352 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
353 HRESULT rc = S_OK;
354 mData->mNetwork = data.strNetwork;
355 mData->mBindIP = data.strBindIP;
356 mData->mMtu = data.u32Mtu;
357 mData->mSockSnd = data.u32SockSnd;
358 mData->mTcpRcv = data.u32TcpRcv;
359 mData->mTcpSnd = data.u32TcpSnd;
360 /* TFTP */
361 mData->mTFTPPrefix = data.strTFTPPrefix;
362 mData->mTFTPBootFile = data.strTFTPBootFile;
363 mData->mTFTPNextServer = data.strTFTPNextServer;
364 /* DNS */
365 mData->mDNSPassDomain = data.fDNSPassDomain;
366 mData->mDNSProxy = data.fDNSProxy;
367 mData->mDNSUseHostResolver = data.fDNSUseHostResolver;
368 /* Alias */
369 mData->mAliasMode = (data.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
370 mData->mAliasMode |= (data.fAliasLog ? NATAliasMode_AliasLog : 0);
371 mData->mAliasMode |= (data.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
372 /* port forwarding */
373 mNATRules.clear();
374 for (settings::NATRuleList::const_iterator it = data.llRules.begin();
375 it != data.llRules.end(); ++it)
376 {
377 mNATRules.insert(std::make_pair(it->strName, *it));
378 }
379 m_fModified = false;
380 return rc;
381}
382
383
384HRESULT NATEngine::saveSettings(settings::NAT &data)
385{
386 AutoCaller autoCaller(this);
387 AssertComRCReturnRC(autoCaller.rc());
388
389 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
390 HRESULT rc = S_OK;
391 data.strNetwork = mData->mNetwork;
392 data.strBindIP = mData->mBindIP;
393 data.u32Mtu = mData->mMtu;
394 data.u32SockRcv = mData->mSockRcv;
395 data.u32SockSnd = mData->mSockSnd;
396 data.u32TcpRcv = mData->mTcpRcv;
397 data.u32TcpSnd = mData->mTcpSnd;
398 /* TFTP */
399 data.strTFTPPrefix = mData->mTFTPPrefix;
400 data.strTFTPBootFile = mData->mTFTPBootFile;
401 data.strTFTPNextServer = mData->mTFTPNextServer;
402 /* DNS */
403 data.fDNSPassDomain = !!mData->mDNSPassDomain;
404 data.fDNSProxy = !!mData->mDNSProxy;
405 data.fDNSUseHostResolver = !!mData->mDNSUseHostResolver;
406 /* Alias */
407 data.fAliasLog = !!(mData->mAliasMode & NATAliasMode_AliasLog);
408 data.fAliasProxyOnly = !!(mData->mAliasMode & NATAliasMode_AliasProxyOnly);
409 data.fAliasUseSamePorts = !!(mData->mAliasMode & NATAliasMode_AliasUseSamePorts);
410
411 for (NATRuleMap::iterator it = mNATRules.begin();
412 it != mNATRules.end(); ++it)
413 data.llRules.push_back(it->second);
414 m_fModified = false;
415 return rc;
416}
417
418
419STDMETHODIMP
420NATEngine::COMSETTER(Network)(IN_BSTR aNetwork)
421{
422 AutoCaller autoCaller(this);
423 AssertComRCReturnRC(autoCaller.rc());
424 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
425 if (Bstr(mData->mNetwork) != aNetwork)
426 {
427 mData.backup();
428 mData->mNetwork = aNetwork;
429 mParent->setModified(Machine::IsModified_NetworkAdapters);
430 m_fModified = true;
431 }
432 return S_OK;
433}
434
435STDMETHODIMP
436NATEngine::COMGETTER(Network)(BSTR *aNetwork)
437{
438 CheckComArgNotNull(aNetwork);
439 AutoCaller autoCaller(this);
440 AssertComRCReturnRC(autoCaller.rc());
441
442 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
443 if (!mData->mNetwork.isEmpty())
444 {
445 mData->mNetwork.cloneTo(aNetwork);
446 Log(("Getter (this:%p) Network: %s\n", this, mData->mNetwork.c_str()));
447 }
448 return S_OK;
449}
450
451STDMETHODIMP
452NATEngine::COMSETTER(HostIP)(IN_BSTR aBindIP)
453{
454 AutoCaller autoCaller(this);
455 AssertComRCReturnRC(autoCaller.rc());
456 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
457 if (Bstr(mData->mBindIP) != aBindIP)
458 {
459 mData.backup();
460 mData->mBindIP = aBindIP;
461 mParent->setModified(Machine::IsModified_NetworkAdapters);
462 m_fModified = true;
463 }
464 return S_OK;
465}
466STDMETHODIMP NATEngine::COMGETTER(HostIP)(BSTR *aBindIP)
467{
468 AutoCaller autoCaller(this);
469 AssertComRCReturnRC(autoCaller.rc());
470
471 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
472 if (!mData->mBindIP.isEmpty())
473 mData->mBindIP.cloneTo(aBindIP);
474 return S_OK;
475}
476
477
478STDMETHODIMP
479NATEngine::COMSETTER(TFTPPrefix)(IN_BSTR aTFTPPrefix)
480{
481 AutoCaller autoCaller(this);
482 AssertComRCReturnRC(autoCaller.rc());
483 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
484 if (Bstr(mData->mTFTPPrefix) != aTFTPPrefix)
485 {
486 mData.backup();
487 mData->mTFTPPrefix = aTFTPPrefix;
488 mParent->setModified(Machine::IsModified_NetworkAdapters);
489 m_fModified = true;
490 }
491 return S_OK;
492}
493
494STDMETHODIMP
495NATEngine::COMGETTER(TFTPPrefix)(BSTR *aTFTPPrefix)
496{
497 AutoCaller autoCaller(this);
498 AssertComRCReturnRC(autoCaller.rc());
499
500 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
501 if (!mData->mTFTPPrefix.isEmpty())
502 {
503 mData->mTFTPPrefix.cloneTo(aTFTPPrefix);
504 Log(("Getter (this:%p) TFTPPrefix: %s\n", this, mData->mTFTPPrefix.c_str()));
505 }
506 return S_OK;
507}
508
509STDMETHODIMP
510NATEngine::COMSETTER(TFTPBootFile)(IN_BSTR aTFTPBootFile)
511{
512 AutoCaller autoCaller(this);
513 AssertComRCReturnRC(autoCaller.rc());
514 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
515 if (Bstr(mData->mTFTPBootFile) != aTFTPBootFile)
516 {
517 mData.backup();
518 mData->mTFTPBootFile = aTFTPBootFile;
519 mParent->setModified(Machine::IsModified_NetworkAdapters);
520 m_fModified = true;
521 }
522 return S_OK;
523}
524
525STDMETHODIMP
526NATEngine::COMGETTER(TFTPBootFile)(BSTR *aTFTPBootFile)
527{
528 AutoCaller autoCaller(this);
529 AssertComRCReturnRC(autoCaller.rc());
530
531 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
532 if (!mData->mTFTPBootFile.isEmpty())
533 {
534 mData->mTFTPBootFile.cloneTo(aTFTPBootFile);
535 Log(("Getter (this:%p) BootFile: %s\n", this, mData->mTFTPBootFile.c_str()));
536 }
537 return S_OK;
538}
539
540STDMETHODIMP
541NATEngine::COMSETTER(TFTPNextServer)(IN_BSTR aTFTPNextServer)
542{
543 AutoCaller autoCaller(this);
544 AssertComRCReturnRC(autoCaller.rc());
545 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
546 if (Bstr(mData->mTFTPNextServer) != aTFTPNextServer)
547 {
548 mData.backup();
549 mData->mTFTPNextServer = aTFTPNextServer;
550 mParent->setModified(Machine::IsModified_NetworkAdapters);
551 m_fModified = true;
552 }
553 return S_OK;
554}
555
556STDMETHODIMP
557NATEngine::COMGETTER(TFTPNextServer)(BSTR *aTFTPNextServer)
558{
559 AutoCaller autoCaller(this);
560 AssertComRCReturnRC(autoCaller.rc());
561
562 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
563 if (!mData->mTFTPNextServer.isEmpty())
564 {
565 mData->mTFTPNextServer.cloneTo(aTFTPNextServer);
566 Log(("Getter (this:%p) NextServer: %s\n", this, mData->mTFTPNextServer.c_str()));
567 }
568 return S_OK;
569}
570/* DNS */
571STDMETHODIMP
572NATEngine::COMSETTER(DNSPassDomain) (BOOL aDNSPassDomain)
573{
574 AutoCaller autoCaller(this);
575 AssertComRCReturnRC(autoCaller.rc());
576 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
577
578 if (mData->mDNSPassDomain != aDNSPassDomain)
579 {
580 mData.backup();
581 mData->mDNSPassDomain = aDNSPassDomain;
582 mParent->setModified(Machine::IsModified_NetworkAdapters);
583 m_fModified = true;
584 }
585 return S_OK;
586}
587STDMETHODIMP
588NATEngine::COMGETTER(DNSPassDomain)(BOOL *aDNSPassDomain)
589{
590 AutoCaller autoCaller(this);
591 AssertComRCReturnRC(autoCaller.rc());
592
593 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
594 *aDNSPassDomain = mData->mDNSPassDomain;
595 return S_OK;
596}
597STDMETHODIMP
598NATEngine::COMSETTER(DNSProxy)(BOOL aDNSProxy)
599{
600 AutoCaller autoCaller(this);
601 AssertComRCReturnRC(autoCaller.rc());
602 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
603
604 if (mData->mDNSProxy != aDNSProxy)
605 {
606 mData.backup();
607 mData->mDNSProxy = aDNSProxy;
608 mParent->setModified(Machine::IsModified_NetworkAdapters);
609 m_fModified = true;
610 }
611 return S_OK;
612}
613STDMETHODIMP
614NATEngine::COMGETTER(DNSProxy)(BOOL *aDNSProxy)
615{
616 AutoCaller autoCaller(this);
617 AssertComRCReturnRC(autoCaller.rc());
618
619 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
620 *aDNSProxy = mData->mDNSProxy;
621 return S_OK;
622}
623STDMETHODIMP
624NATEngine::COMGETTER(DNSUseHostResolver)(BOOL *aDNSUseHostResolver)
625{
626 AutoCaller autoCaller(this);
627 AssertComRCReturnRC(autoCaller.rc());
628 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
629 *aDNSUseHostResolver = mData->mDNSUseHostResolver;
630 return S_OK;
631}
632STDMETHODIMP
633NATEngine::COMSETTER(DNSUseHostResolver)(BOOL aDNSUseHostResolver)
634{
635 AutoCaller autoCaller(this);
636 AssertComRCReturnRC(autoCaller.rc());
637
638 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
639
640 if (mData->mDNSUseHostResolver != aDNSUseHostResolver)
641 {
642 mData.backup();
643 mData->mDNSUseHostResolver = aDNSUseHostResolver;
644 mParent->setModified(Machine::IsModified_NetworkAdapters);
645 m_fModified = true;
646 }
647 return S_OK;
648}
649
650STDMETHODIMP NATEngine::COMSETTER(AliasMode)(ULONG aAliasMode)
651{
652 AutoCaller autoCaller(this);
653 AssertComRCReturnRC(autoCaller.rc());
654
655 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
656
657 if (mData->mAliasMode != aAliasMode)
658 {
659 mData.backup();
660 mData->mAliasMode = aAliasMode;
661 mParent->setModified(Machine::IsModified_NetworkAdapters);
662 m_fModified = true;
663 }
664 return S_OK;
665}
666
667STDMETHODIMP NATEngine::COMGETTER(AliasMode)(ULONG *aAliasMode)
668{
669 AutoCaller autoCaller(this);
670 AssertComRCReturnRC(autoCaller.rc());
671 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
672 *aAliasMode = mData->mAliasMode;
673 return S_OK;
674}
675
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