VirtualBox

source: vbox/trunk/src/VBox/Main/NATEngineImpl.cpp@ 34900

Last change on this file since 34900 was 33952, checked in by vboxsync, 14 years ago

Main: replaces callback mechanism of NAT redirect change event notification with event-driven model.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.3 KB
Line 
1/* $Id: NATEngineImpl.cpp 33952 2010-11-11 03:49:28Z 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
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 S_OK;
104}
105
106
107void NATEngine::FinalRelease()
108{
109 uninit();
110}
111
112void 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
124bool NATEngine::isModified()
125{
126 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
127 bool fModified = m_fModified;
128 return fModified;
129}
130
131bool 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
149void 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
178STDMETHODIMP
179NATEngine::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
199STDMETHODIMP
200NATEngine::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
228STDMETHODIMP
229NATEngine::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
260STDMETHODIMP
261NATEngine::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 || ( r.strHostIP == Utf8Str(aBindIp)
291 && r.u16HostPort == aHostPort))
292 {
293 return E_INVALIDARG;
294 }
295 }
296
297 r.strName = name.c_str();
298 r.proto = aProto;
299 r.strHostIP = aBindIp;
300 r.u16HostPort = aHostPort;
301 r.strGuestIP = aGuestIP;
302 r.u16GuestPort = aGuestPort;
303 mNATRules.insert(std::make_pair(name, r));
304 mParent->setModified(Machine::IsModified_NetworkAdapters);
305 m_fModified = true;
306
307 ULONG ulSlot;
308 mAdapter->COMGETTER(Slot)(&ulSlot);
309
310 alock.release();
311 mParent->onNATRedirectRuleChange(ulSlot, FALSE, Bstr(name).raw(), aProto, Bstr(r.strHostIP).raw(), r.u16HostPort, Bstr(r.strGuestIP).raw(), r.u16GuestPort);
312 return S_OK;
313}
314
315STDMETHODIMP
316NATEngine::RemoveRedirect(IN_BSTR aName)
317{
318 AutoCaller autoCaller(this);
319 if (FAILED(autoCaller.rc())) return autoCaller.rc();
320
321 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
322 NATRuleMap::iterator it = mNATRules.find(aName);
323 if (it == mNATRules.end())
324 return E_INVALIDARG;
325 mData.backup();
326 settings::NATRule r = it->second;
327 Utf8Str strHostIP = r.strHostIP;
328 Utf8Str strGuestIP = r.strGuestIP;
329 NATProtocol_T proto = r.proto;
330 uint16_t u16HostPort = r.u16HostPort;
331 uint16_t u16GuestPort = r.u16GuestPort;
332 ULONG ulSlot;
333 mAdapter->COMGETTER(Slot)(&ulSlot);
334
335 mNATRules.erase(it);
336 mParent->setModified(Machine::IsModified_NetworkAdapters);
337 m_fModified = true;
338 alock.release();
339 mParent->onNATRedirectRuleChange(ulSlot, TRUE, aName, proto, Bstr(strHostIP).raw(), u16HostPort, Bstr(strGuestIP).raw(), u16GuestPort);
340 return S_OK;
341}
342
343HRESULT NATEngine::loadSettings(const settings::NAT &data)
344{
345 AutoCaller autoCaller(this);
346 AssertComRCReturnRC(autoCaller.rc());
347
348 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
349 HRESULT rc = S_OK;
350 mData->mNetwork = data.strNetwork;
351 mData->mBindIP = data.strBindIP;
352 mData->mMtu = data.u32Mtu;
353 mData->mSockSnd = data.u32SockSnd;
354 mData->mTcpRcv = data.u32TcpRcv;
355 mData->mTcpSnd = data.u32TcpSnd;
356 /* TFTP */
357 mData->mTftpPrefix = data.strTftpPrefix;
358 mData->mTftpBootFile = data.strTftpBootFile;
359 mData->mTftpNextServer = data.strTftpNextServer;
360 /* DNS */
361 mData->mDnsPassDomain = data.fDnsPassDomain;
362 mData->mDnsProxy = data.fDnsProxy;
363 mData->mDnsUseHostResolver = data.fDnsUseHostResolver;
364 /* Alias */
365 mData->mAliasMode = (data.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);
366 mData->mAliasMode |= (data.fAliasLog ? NATAliasMode_AliasLog : 0);
367 mData->mAliasMode |= (data.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);
368 /* port forwarding */
369 mNATRules.clear();
370 for (settings::NATRuleList::const_iterator it = data.llRules.begin();
371 it != data.llRules.end(); ++it)
372 {
373 mNATRules.insert(std::make_pair(it->strName, *it));
374 }
375 m_fModified = false;
376 return rc;
377}
378
379
380HRESULT NATEngine::saveSettings(settings::NAT &data)
381{
382 AutoCaller autoCaller(this);
383 AssertComRCReturnRC(autoCaller.rc());
384
385 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
386 HRESULT rc = S_OK;
387 data.strNetwork = mData->mNetwork;
388 data.strBindIP = mData->mBindIP;
389 data.u32Mtu = mData->mMtu;
390 data.u32SockRcv = mData->mSockRcv;
391 data.u32SockSnd = mData->mSockSnd;
392 data.u32TcpRcv = mData->mTcpRcv;
393 data.u32TcpSnd = mData->mTcpSnd;
394 /* TFTP */
395 data.strTftpPrefix = mData->mTftpPrefix;
396 data.strTftpBootFile = mData->mTftpBootFile;
397 data.strTftpNextServer = mData->mTftpNextServer;
398 /* DNS */
399 data.fDnsPassDomain = !!mData->mDnsPassDomain;
400 data.fDnsProxy = !!mData->mDnsProxy;
401 data.fDnsUseHostResolver = !!mData->mDnsUseHostResolver;
402 /* Alias */
403 data.fAliasLog = !!(mData->mAliasMode & NATAliasMode_AliasLog);
404 data.fAliasProxyOnly = !!(mData->mAliasMode & NATAliasMode_AliasProxyOnly);
405 data.fAliasUseSamePorts = !!(mData->mAliasMode & NATAliasMode_AliasUseSamePorts);
406
407 for (NATRuleMap::iterator it = mNATRules.begin();
408 it != mNATRules.end(); ++it)
409 data.llRules.push_back(it->second);
410 m_fModified = false;
411 return rc;
412}
413
414
415STDMETHODIMP
416NATEngine::COMSETTER(Network)(IN_BSTR aNetwork)
417{
418 AutoCaller autoCaller(this);
419 AssertComRCReturnRC (autoCaller.rc());
420 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
421 if (Bstr(mData->mNetwork) != aNetwork)
422 {
423 mData.backup();
424 mData->mNetwork = aNetwork;
425 mParent->setModified(Machine::IsModified_NetworkAdapters);
426 m_fModified = true;
427 }
428 return S_OK;
429}
430
431STDMETHODIMP
432NATEngine::COMGETTER(Network)(BSTR *aNetwork)
433{
434 CheckComArgNotNull(aNetwork);
435 AutoCaller autoCaller(this);
436 AssertComRCReturnRC(autoCaller.rc());
437
438 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
439 if (!mData->mNetwork.isEmpty())
440 {
441 mData->mNetwork.cloneTo(aNetwork);
442 Log(("Getter (this:%p) Network: %s\n", this, mData->mNetwork.c_str()));
443 }
444 return S_OK;
445}
446
447STDMETHODIMP
448NATEngine::COMSETTER(HostIP) (IN_BSTR aBindIP)
449{
450 AutoCaller autoCaller(this);
451 AssertComRCReturnRC (autoCaller.rc());
452 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
453 if (Bstr(mData->mBindIP) != aBindIP)
454 {
455 mData.backup();
456 mData->mBindIP = aBindIP;
457 mParent->setModified(Machine::IsModified_NetworkAdapters);
458 m_fModified = true;
459 }
460 return S_OK;
461}
462STDMETHODIMP NATEngine::COMGETTER(HostIP) (BSTR *aBindIP)
463{
464 AutoCaller autoCaller(this);
465 AssertComRCReturnRC(autoCaller.rc());
466
467 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
468 if (!mData->mBindIP.isEmpty())
469 mData->mBindIP.cloneTo(aBindIP);
470 return S_OK;
471}
472
473
474STDMETHODIMP
475NATEngine::COMSETTER(TftpPrefix)(IN_BSTR aTftpPrefix)
476{
477 AutoCaller autoCaller(this);
478 AssertComRCReturnRC (autoCaller.rc());
479 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
480 if (Bstr(mData->mTftpPrefix) != aTftpPrefix)
481 {
482 mData.backup();
483 mData->mTftpPrefix = aTftpPrefix;
484 mParent->setModified(Machine::IsModified_NetworkAdapters);
485 m_fModified = true;
486 }
487 return S_OK;
488}
489
490STDMETHODIMP
491NATEngine::COMGETTER(TftpPrefix)(BSTR *aTftpPrefix)
492{
493 AutoCaller autoCaller(this);
494 AssertComRCReturnRC(autoCaller.rc());
495
496 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
497 if (!mData->mTftpPrefix.isEmpty())
498 {
499 mData->mTftpPrefix.cloneTo(aTftpPrefix);
500 Log(("Getter (this:%p) TftpPrefix: %s\n", this, mData->mTftpPrefix.c_str()));
501 }
502 return S_OK;
503}
504
505STDMETHODIMP
506NATEngine::COMSETTER(TftpBootFile)(IN_BSTR aTftpBootFile)
507{
508 AutoCaller autoCaller(this);
509 AssertComRCReturnRC (autoCaller.rc());
510 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
511 if (Bstr(mData->mTftpBootFile) != aTftpBootFile)
512 {
513 mData.backup();
514 mData->mTftpBootFile = aTftpBootFile;
515 mParent->setModified(Machine::IsModified_NetworkAdapters);
516 m_fModified = true;
517 }
518 return S_OK;
519}
520
521STDMETHODIMP
522NATEngine::COMGETTER(TftpBootFile)(BSTR *aTftpBootFile)
523{
524 AutoCaller autoCaller(this);
525 AssertComRCReturnRC(autoCaller.rc());
526
527 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
528 if (!mData->mTftpBootFile.isEmpty())
529 {
530 mData->mTftpBootFile.cloneTo(aTftpBootFile);
531 Log(("Getter (this:%p) BootFile: %s\n", this, mData->mTftpBootFile.c_str()));
532 }
533 return S_OK;
534}
535
536STDMETHODIMP
537NATEngine::COMSETTER(TftpNextServer)(IN_BSTR aTftpNextServer)
538{
539 AutoCaller autoCaller(this);
540 AssertComRCReturnRC (autoCaller.rc());
541 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
542 if (Bstr(mData->mTftpNextServer) != aTftpNextServer)
543 {
544 mData.backup();
545 mData->mTftpNextServer = aTftpNextServer;
546 mParent->setModified(Machine::IsModified_NetworkAdapters);
547 m_fModified = true;
548 }
549 return S_OK;
550}
551
552STDMETHODIMP
553NATEngine::COMGETTER(TftpNextServer)(BSTR *aTftpNextServer)
554{
555 AutoCaller autoCaller(this);
556 AssertComRCReturnRC(autoCaller.rc());
557
558 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
559 if (!mData->mTftpNextServer.isEmpty())
560 {
561 mData->mTftpNextServer.cloneTo(aTftpNextServer);
562 Log(("Getter (this:%p) NextServer: %s\n", this, mData->mTftpNextServer.c_str()));
563 }
564 return S_OK;
565}
566/* DNS */
567STDMETHODIMP
568NATEngine::COMSETTER(DnsPassDomain) (BOOL aDnsPassDomain)
569{
570 AutoCaller autoCaller(this);
571 AssertComRCReturnRC (autoCaller.rc());
572 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
573
574 if (mData->mDnsPassDomain != aDnsPassDomain)
575 {
576 mData.backup();
577 mData->mDnsPassDomain = aDnsPassDomain;
578 mParent->setModified(Machine::IsModified_NetworkAdapters);
579 m_fModified = true;
580 }
581 return S_OK;
582}
583STDMETHODIMP
584NATEngine::COMGETTER(DnsPassDomain)(BOOL *aDnsPassDomain)
585{
586 AutoCaller autoCaller(this);
587 AssertComRCReturnRC(autoCaller.rc());
588
589 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
590 *aDnsPassDomain = mData->mDnsPassDomain;
591 return S_OK;
592}
593STDMETHODIMP
594NATEngine::COMSETTER(DnsProxy)(BOOL aDnsProxy)
595{
596 AutoCaller autoCaller(this);
597 AssertComRCReturnRC (autoCaller.rc());
598 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
599
600 if (mData->mDnsProxy != aDnsProxy)
601 {
602 mData.backup();
603 mData->mDnsProxy = aDnsProxy;
604 mParent->setModified(Machine::IsModified_NetworkAdapters);
605 m_fModified = true;
606 }
607 return S_OK;
608}
609STDMETHODIMP
610NATEngine::COMGETTER(DnsProxy)(BOOL *aDnsProxy)
611{
612 AutoCaller autoCaller(this);
613 AssertComRCReturnRC(autoCaller.rc());
614
615 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
616 *aDnsProxy = mData->mDnsProxy;
617 return S_OK;
618}
619STDMETHODIMP
620NATEngine::COMGETTER(DnsUseHostResolver)(BOOL *aDnsUseHostResolver)
621{
622 AutoCaller autoCaller(this);
623 AssertComRCReturnRC (autoCaller.rc());
624 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
625 *aDnsUseHostResolver = mData->mDnsUseHostResolver;
626 return S_OK;
627}
628STDMETHODIMP
629NATEngine::COMSETTER(DnsUseHostResolver)(BOOL aDnsUseHostResolver)
630{
631 AutoCaller autoCaller(this);
632 AssertComRCReturnRC(autoCaller.rc());
633
634 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
635
636 if (mData->mDnsUseHostResolver != aDnsUseHostResolver)
637 {
638 mData.backup();
639 mData->mDnsUseHostResolver = aDnsUseHostResolver;
640 mParent->setModified(Machine::IsModified_NetworkAdapters);
641 m_fModified = true;
642 }
643 return S_OK;
644}
645
646STDMETHODIMP NATEngine::COMSETTER(AliasMode) (ULONG aAliasMode)
647{
648 AutoCaller autoCaller(this);
649 AssertComRCReturnRC(autoCaller.rc());
650
651 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
652
653 if (mData->mAliasMode != aAliasMode)
654 {
655 mData.backup();
656 mData->mAliasMode = aAliasMode;
657 mParent->setModified(Machine::IsModified_NetworkAdapters);
658 m_fModified = true;
659 }
660 return S_OK;
661}
662
663STDMETHODIMP NATEngine::COMGETTER(AliasMode) (ULONG *aAliasMode)
664{
665 AutoCaller autoCaller(this);
666 AssertComRCReturnRC (autoCaller.rc());
667 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
668 *aAliasMode = mData->mAliasMode;
669 return S_OK;
670}
671
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