VirtualBox

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

Last change on this file since 48600 was 46820, checked in by vboxsync, 11 years ago

Main: do not include VirtualBoxImpl.h from code ending in VBoxC (causes unnecessary rebuilds), and make sure that the code still builds with VBOX_WITH_RESOURCE_USAGE_API unset

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