Changeset 61170 in vbox for trunk/src/VBox/Main/src-server/NATEngineImpl.cpp
- Timestamp:
- May 24, 2016 4:44:44 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/NATEngineImpl.cpp
r61030 r61170 29 29 #include <VBox/com/array.h> 30 30 31 struct NATEngineData32 {33 NATEngineData()34 {}35 36 settings::NAT s;37 };38 39 31 struct NATEngine::Data 40 32 { 41 Backupable< NATEngineData> m;33 Backupable<settings::NAT> m; 42 34 }; 43 35 … … 68 60 mData = new Data(); 69 61 mData->m.allocate(); 70 mData->m->s .strNetwork.setNull();71 mData->m->s .strBindIP.setNull();62 mData->m->strNetwork.setNull(); 63 mData->m->strBindIP.setNull(); 72 64 unconst(mParent) = aParent; 73 65 unconst(mAdapter) = aAdapter; … … 192 184 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 193 185 if (aMtu) 194 *aMtu = mData->m-> s.u32Mtu;186 *aMtu = mData->m->u32Mtu; 195 187 if (aSockSnd) 196 *aSockSnd = mData->m-> s.u32SockSnd;188 *aSockSnd = mData->m->u32SockSnd; 197 189 if (aSockRcv) 198 *aSockRcv = mData->m-> s.u32SockRcv;190 *aSockRcv = mData->m->u32SockRcv; 199 191 if (aTcpWndSnd) 200 *aTcpWndSnd = mData->m-> s.u32TcpSnd;192 *aTcpWndSnd = mData->m->u32TcpSnd; 201 193 if (aTcpWndRcv) 202 *aTcpWndRcv = mData->m-> s.u32TcpRcv;194 *aTcpWndRcv = mData->m->u32TcpRcv; 203 195 204 196 return S_OK; … … 215 207 } 216 208 if (aMtu) 217 mData->m-> s.u32Mtu = aMtu;209 mData->m->u32Mtu = aMtu; 218 210 if (aSockSnd) 219 mData->m-> s.u32SockSnd = aSockSnd;211 mData->m->u32SockSnd = aSockSnd; 220 212 if (aSockRcv) 221 mData->m-> s.u32SockRcv = aSockSnd;213 mData->m->u32SockRcv = aSockSnd; 222 214 if (aTcpWndSnd) 223 mData->m-> s.u32TcpSnd = aTcpWndSnd;215 mData->m->u32TcpSnd = aTcpWndSnd; 224 216 if (aTcpWndRcv) 225 mData->m-> s.u32TcpRcv = aTcpWndRcv;217 mData->m->u32TcpRcv = aTcpWndRcv; 226 218 227 219 return S_OK; … … 233 225 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 234 226 235 aRedirects.resize(mData->m-> s.mapRules.size());227 aRedirects.resize(mData->m->mapRules.size()); 236 228 size_t i = 0; 237 229 settings::NATRulesMap::const_iterator it; 238 for (it = mData->m-> s.mapRules.begin(); it != mData->m->s.mapRules.end(); ++it, ++i)230 for (it = mData->m->mapRules.begin(); it != mData->m->mapRules.end(); ++it, ++i) 239 231 { 240 232 settings::NATRule r = it->second; … … 272 264 273 265 settings::NATRulesMap::iterator it; 274 for (it = mData->m-> s.mapRules.begin(); it != mData->m->s.mapRules.end(); ++it)266 for (it = mData->m->mapRules.begin(); it != mData->m->mapRules.end(); ++it) 275 267 { 276 268 r = it->second; … … 292 284 r.strGuestIP = aGuestIP; 293 285 r.u16GuestPort = aGuestPort; 294 mData->m-> s.mapRules.insert(std::make_pair(name, r));286 mData->m->mapRules.insert(std::make_pair(name, r)); 295 287 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 296 288 … … 307 299 { 308 300 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 309 settings::NATRulesMap::iterator it = mData->m-> s.mapRules.find(aName);310 if (it == mData->m-> s.mapRules.end())301 settings::NATRulesMap::iterator it = mData->m->mapRules.find(aName); 302 if (it == mData->m->mapRules.end()) 311 303 return E_INVALIDARG; 312 304 mData->m.backup(); … … 317 309 */ 318 310 settings::NATRule r = it->second; 319 Utf8Str strHostIP = r.strHostIP;320 Utf8Str strGuestIP = r.strGuestIP;321 NATProtocol_T proto = r.proto;322 uint16_t u16HostPort = r.u16HostPort;323 uint16_t u16GuestPort = r.u16GuestPort;324 311 ULONG ulSlot; 325 312 mAdapter->COMGETTER(Slot)(&ulSlot); 326 313 327 mData->m-> s.mapRules.erase(aName); /* NB: erase by key, "it" may not be valid */314 mData->m->mapRules.erase(aName); /* NB: erase by key, "it" may not be valid */ 328 315 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 329 316 alock.release(); 330 mParent->i_onNATRedirectRuleChange(ulSlot, TRUE, Bstr(aName).raw(), proto, Bstr(strHostIP).raw(),331 u16HostPort, Bstr(strGuestIP).raw(),u16GuestPort);317 mParent->i_onNATRedirectRuleChange(ulSlot, TRUE, Bstr(aName).raw(), r.proto, Bstr(r.strHostIP).raw(), 318 r.u16HostPort, Bstr(r.strGuestIP).raw(), r.u16GuestPort); 332 319 return S_OK; 333 320 } … … 339 326 340 327 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 341 mData->m ->s = data;328 mData->m.assignCopy(&data); 342 329 return S_OK; 343 330 } … … 351 338 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 352 339 HRESULT rc = S_OK; 353 data = mData->m->s;340 data = *mData->m.data(); 354 341 return rc; 355 342 } … … 358 345 { 359 346 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 360 if (mData->m->s .strNetwork != aNetwork)361 { 362 mData->m.backup(); 363 mData->m->s .strNetwork = aNetwork;347 if (mData->m->strNetwork != aNetwork) 348 { 349 mData->m.backup(); 350 mData->m->strNetwork = aNetwork; 364 351 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 365 352 } … … 371 358 { 372 359 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 373 if (!mData->m->s .strNetwork.isEmpty())374 { 375 aNetwork = mData->m->s .strNetwork;376 Log(("Getter (this:%p) Network: %s\n", this, mData->m->s .strNetwork.c_str()));360 if (!mData->m->strNetwork.isEmpty()) 361 { 362 aNetwork = mData->m->strNetwork; 363 Log(("Getter (this:%p) Network: %s\n", this, mData->m->strNetwork.c_str())); 377 364 } 378 365 return S_OK; … … 382 369 { 383 370 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 384 if (mData->m->s .strBindIP != aHostIP)385 { 386 mData->m.backup(); 387 mData->m->s .strBindIP = aHostIP;371 if (mData->m->strBindIP != aHostIP) 372 { 373 mData->m.backup(); 374 mData->m->strBindIP = aHostIP; 388 375 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 389 376 } … … 395 382 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 396 383 397 if (!mData->m->s .strBindIP.isEmpty())398 aBindIP = mData->m->s .strBindIP;384 if (!mData->m->strBindIP.isEmpty()) 385 aBindIP = mData->m->strBindIP; 399 386 return S_OK; 400 387 } … … 403 390 { 404 391 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 405 if (mData->m->s .strTFTPPrefix != aTFTPPrefix)406 { 407 mData->m.backup(); 408 mData->m->s .strTFTPPrefix = aTFTPPrefix;392 if (mData->m->strTFTPPrefix != aTFTPPrefix) 393 { 394 mData->m.backup(); 395 mData->m->strTFTPPrefix = aTFTPPrefix; 409 396 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 410 397 } … … 417 404 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 418 405 419 if (!mData->m->s .strTFTPPrefix.isEmpty())420 { 421 aTFTPPrefix = mData->m->s .strTFTPPrefix;422 Log(("Getter (this:%p) TFTPPrefix: %s\n", this, mData->m->s .strTFTPPrefix.c_str()));406 if (!mData->m->strTFTPPrefix.isEmpty()) 407 { 408 aTFTPPrefix = mData->m->strTFTPPrefix; 409 Log(("Getter (this:%p) TFTPPrefix: %s\n", this, mData->m->strTFTPPrefix.c_str())); 423 410 } 424 411 return S_OK; … … 428 415 { 429 416 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 430 if (mData->m->s .strTFTPBootFile != aTFTPBootFile)431 { 432 mData->m.backup(); 433 mData->m->s .strTFTPBootFile = aTFTPBootFile;417 if (mData->m->strTFTPBootFile != aTFTPBootFile) 418 { 419 mData->m.backup(); 420 mData->m->strTFTPBootFile = aTFTPBootFile; 434 421 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 435 422 } … … 441 428 { 442 429 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 443 if (!mData->m->s .strTFTPBootFile.isEmpty())444 { 445 aTFTPBootFile = mData->m->s .strTFTPBootFile;446 Log(("Getter (this:%p) BootFile: %s\n", this, mData->m->s .strTFTPBootFile.c_str()));430 if (!mData->m->strTFTPBootFile.isEmpty()) 431 { 432 aTFTPBootFile = mData->m->strTFTPBootFile; 433 Log(("Getter (this:%p) BootFile: %s\n", this, mData->m->strTFTPBootFile.c_str())); 447 434 } 448 435 return S_OK; … … 453 440 { 454 441 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 455 if (mData->m->s .strTFTPNextServer != aTFTPNextServer)456 { 457 mData->m.backup(); 458 mData->m->s .strTFTPNextServer = aTFTPNextServer;442 if (mData->m->strTFTPNextServer != aTFTPNextServer) 443 { 444 mData->m.backup(); 445 mData->m->strTFTPNextServer = aTFTPNextServer; 459 446 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 460 447 } … … 465 452 { 466 453 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 467 if (!mData->m->s .strTFTPNextServer.isEmpty())468 { 469 aTFTPNextServer = mData->m->s .strTFTPNextServer;470 Log(("Getter (this:%p) NextServer: %s\n", this, mData->m->s .strTFTPNextServer.c_str()));454 if (!mData->m->strTFTPNextServer.isEmpty()) 455 { 456 aTFTPNextServer = mData->m->strTFTPNextServer; 457 Log(("Getter (this:%p) NextServer: %s\n", this, mData->m->strTFTPNextServer.c_str())); 471 458 } 472 459 return S_OK; … … 478 465 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 479 466 480 if (mData->m-> s.fDNSPassDomain != RT_BOOL(aDNSPassDomain))481 { 482 mData->m.backup(); 483 mData->m-> s.fDNSPassDomain = RT_BOOL(aDNSPassDomain);467 if (mData->m->fDNSPassDomain != RT_BOOL(aDNSPassDomain)) 468 { 469 mData->m.backup(); 470 mData->m->fDNSPassDomain = RT_BOOL(aDNSPassDomain); 484 471 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 485 472 } … … 490 477 { 491 478 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 492 *aDNSPassDomain = mData->m-> s.fDNSPassDomain;479 *aDNSPassDomain = mData->m->fDNSPassDomain; 493 480 return S_OK; 494 481 } … … 499 486 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 500 487 501 if (mData->m-> s.fDNSProxy != RT_BOOL(aDNSProxy))502 { 503 mData->m.backup(); 504 mData->m-> s.fDNSProxy = RT_BOOL(aDNSProxy);488 if (mData->m->fDNSProxy != RT_BOOL(aDNSProxy)) 489 { 490 mData->m.backup(); 491 mData->m->fDNSProxy = RT_BOOL(aDNSProxy); 505 492 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 506 493 } … … 511 498 { 512 499 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 513 *aDNSProxy = mData->m-> s.fDNSProxy;500 *aDNSProxy = mData->m->fDNSProxy; 514 501 return S_OK; 515 502 } … … 519 506 { 520 507 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 521 *aDNSUseHostResolver = mData->m-> s.fDNSUseHostResolver;508 *aDNSUseHostResolver = mData->m->fDNSUseHostResolver; 522 509 return S_OK; 523 510 } … … 526 513 HRESULT NATEngine::setDNSUseHostResolver(BOOL aDNSUseHostResolver) 527 514 { 528 if (mData->m-> s.fDNSUseHostResolver != RT_BOOL(aDNSUseHostResolver))529 { 530 mData->m.backup(); 531 mData->m-> s.fDNSUseHostResolver = RT_BOOL(aDNSUseHostResolver);515 if (mData->m->fDNSUseHostResolver != RT_BOOL(aDNSUseHostResolver)) 516 { 517 mData->m.backup(); 518 mData->m->fDNSUseHostResolver = RT_BOOL(aDNSUseHostResolver); 532 519 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 533 520 } … … 538 525 { 539 526 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 540 ULONG uAliasMode = (mData->m-> s.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);541 uAliasMode |= (mData->m-> s.fAliasLog ? NATAliasMode_AliasLog : 0);542 uAliasMode |= (mData->m-> s.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);527 ULONG uAliasMode = (mData->m->fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0); 528 uAliasMode |= (mData->m->fAliasLog ? NATAliasMode_AliasLog : 0); 529 uAliasMode |= (mData->m->fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0); 543 530 if (uAliasMode != aAliasMode) 544 531 { 545 532 mData->m.backup(); 546 mData->m-> s.fAliasUseSamePorts = RT_BOOL(aAliasMode & NATAliasMode_AliasUseSamePorts);547 mData->m-> s.fAliasLog = RT_BOOL(aAliasMode & NATAliasMode_AliasLog);548 mData->m-> s.fAliasProxyOnly = RT_BOOL(aAliasMode & NATAliasMode_AliasProxyOnly);533 mData->m->fAliasUseSamePorts = RT_BOOL(aAliasMode & NATAliasMode_AliasUseSamePorts); 534 mData->m->fAliasLog = RT_BOOL(aAliasMode & NATAliasMode_AliasLog); 535 mData->m->fAliasProxyOnly = RT_BOOL(aAliasMode & NATAliasMode_AliasProxyOnly); 549 536 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 550 537 } … … 555 542 { 556 543 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 557 ULONG uAliasMode = (mData->m-> s.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0);558 uAliasMode |= (mData->m-> s.fAliasLog ? NATAliasMode_AliasLog : 0);559 uAliasMode |= (mData->m-> s.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0);544 ULONG uAliasMode = (mData->m->fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0); 545 uAliasMode |= (mData->m->fAliasLog ? NATAliasMode_AliasLog : 0); 546 uAliasMode |= (mData->m->fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0); 560 547 *aAliasMode = uAliasMode; 561 548 return S_OK;
Note:
See TracChangeset
for help on using the changeset viewer.