- Timestamp:
- May 24, 2016 4:44:44 PM (9 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/NATEngineImpl.h
r61009 r61170 7 7 8 8 /* 9 * Copyright (C) 2006-201 5Oracle Corporation9 * Copyright (C) 2006-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r57694 r61170 7 7 8 8 /* 9 * Copyright (C) 2006-201 5Oracle Corporation9 * Copyright (C) 2006-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 114 114 HRESULT i_switchToNatNetworking(const com::Utf8Str &aNatNetworkName); 115 115 116 typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;117 118 struct Data119 {120 Data() : mSlot(0),121 mEnabled(FALSE),122 mAttachmentType(NetworkAttachmentType_Null),123 mCableConnected(TRUE),124 mLineSpeed(0),125 mPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),126 mTraceEnabled(FALSE),127 mBridgedInterface("") /* cannot be null */,128 mHostOnlyInterface("") /* cannot be null */,129 mNATNetwork("") /* cannot be null */,130 mBootPriority(0)131 {}132 133 NetworkAdapterType_T mAdapterType;134 ULONG mSlot;135 BOOL mEnabled;136 com::Utf8Str mMACAddress;137 NetworkAttachmentType_T mAttachmentType;138 BOOL mCableConnected;139 ULONG mLineSpeed;140 NetworkAdapterPromiscModePolicy_T mPromiscModePolicy;141 BOOL mTraceEnabled;142 com::Utf8Str mTraceFile;143 com::Utf8Str mBridgedInterface;144 com::Utf8Str mHostOnlyInterface;145 com::Utf8Str mInternalNetwork;146 com::Utf8Str mNATNetwork;147 com::Utf8Str mGenericDriver;148 StringsMap mGenericProperties;149 ULONG mBootPriority;150 com::Utf8Str mBandwidthGroup;151 };152 116 153 117 Machine * const mParent; … … 155 119 const ComObjPtr<NATEngine> mNATEngine; 156 120 157 Backupable< Data>mData;121 Backupable<settings::NetworkAdapter> mData; 158 122 }; 159 123 -
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; -
trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp
r61034 r61170 65 65 * @param aParent Handle of the parent object. 66 66 */ 67 HRESULT NetworkAdapter::init(Machine *aParent, ULONG aSlot)68 { 69 LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot));67 HRESULT NetworkAdapter::init(Machine *aParent, ULONG uSlot) 68 { 69 LogFlowThisFunc(("aParent=%p, uSlot=%d\n", aParent, uSlot)); 70 70 71 71 ComAssertRet(aParent, E_INVALIDARG); 72 72 uint32_t maxNetworkAdapters = Global::getMaxNetworkAdapters(aParent->i_getChipsetType()); 73 ComAssertRet( aSlot < maxNetworkAdapters, E_INVALIDARG);73 ComAssertRet(uSlot < maxNetworkAdapters, E_INVALIDARG); 74 74 75 75 /* Enclose the state transition NotReady->InInit->Ready */ … … 85 85 86 86 /* initialize data */ 87 mData-> mSlot = aSlot;87 mData->ulSlot = uSlot; 88 88 89 89 /* default to Am79C973 */ 90 mData-> mAdapterType = NetworkAdapterType_Am79C973;90 mData->type = NetworkAdapterType_Am79C973; 91 91 92 92 /* Confirm a successful initialization */ … … 214 214 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 215 215 216 *aAdapterType = mData-> mAdapterType;216 *aAdapterType = mData->type; 217 217 218 218 return S_OK; … … 247 247 } 248 248 249 if (mData-> mAdapterType != aAdapterType)249 if (mData->type != aAdapterType) 250 250 { 251 251 mData.backup(); 252 mData-> mAdapterType = aAdapterType;252 mData->type = aAdapterType; 253 253 254 254 // leave the lock before informing callbacks … … 268 268 269 269 270 HRESULT NetworkAdapter::getSlot(ULONG * aSlot)271 { 272 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 273 274 * aSlot = mData->mSlot;270 HRESULT NetworkAdapter::getSlot(ULONG *uSlot) 271 { 272 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 273 274 *uSlot = mData->ulSlot; 275 275 276 276 return S_OK; … … 281 281 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 282 282 283 *aEnabled = mData-> mEnabled;283 *aEnabled = mData->fEnabled; 284 284 285 285 return S_OK; … … 294 294 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 295 295 296 if (mData-> mEnabled != aEnabled)296 if (mData->fEnabled != aEnabled) 297 297 { 298 298 mData.backup(); 299 mData-> mEnabled = aEnabled;300 if (aEnabled && mData-> mMACAddress.isEmpty())299 mData->fEnabled = aEnabled; 300 if (aEnabled && mData->strMACAddress.isEmpty()) 301 301 i_generateMACAddress(); 302 302 … … 320 320 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 321 321 322 ComAssertRet(!mData-> mEnabled || !mData->mMACAddress.isEmpty(), E_FAIL);323 324 aMACAddress = mData-> mMACAddress;322 ComAssertRet(!mData->fEnabled || !mData->strMACAddress.isEmpty(), E_FAIL); 323 324 aMACAddress = mData->strMACAddress; 325 325 326 326 return S_OK; … … 334 334 * Are we supposed to generate a MAC? 335 335 */ 336 if (mData-> mEnabled && aMACAddress.isEmpty())336 if (mData->fEnabled && aMACAddress.isEmpty()) 337 337 i_generateMACAddress(); 338 338 else 339 339 { 340 if (mData-> mMACAddress != aMACAddress)340 if (mData->strMACAddress != aMACAddress) 341 341 { 342 if (mData-> mEnabled || !aMACAddress.isEmpty())342 if (mData->fEnabled || !aMACAddress.isEmpty()) 343 343 { 344 344 /* … … 374 374 375 375 if (SUCCEEDED(rc)) 376 mData-> mMACAddress = aMACAddress;376 mData->strMACAddress = aMACAddress; 377 377 } 378 378 } … … 412 412 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 413 413 414 *aAttachmentType = mData->m AttachmentType;414 *aAttachmentType = mData->mode; 415 415 416 416 return S_OK; … … 425 425 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 426 426 427 if (mData->m AttachmentType != aAttachmentType)427 if (mData->mode != aAttachmentType) 428 428 { 429 429 mData.backup(); 430 430 431 431 /* there must an internal network name */ 432 if (mData-> mInternalNetwork.isEmpty())432 if (mData->strInternalNetworkName.isEmpty()) 433 433 { 434 434 Log(("Internal network name not defined, setting to default \"intnet\"\n")); 435 mData-> mInternalNetwork= "intnet";435 mData->strInternalNetworkName = "intnet"; 436 436 } 437 437 438 438 /* there must a NAT network name */ 439 if (mData-> mNATNetwork.isEmpty())439 if (mData->strNATNetworkName.isEmpty()) 440 440 { 441 441 Log(("NAT network name not defined, setting to default \"NatNetwork\"\n")); 442 mData-> mNATNetwork= "NatNetwork";442 mData->strNATNetworkName = "NatNetwork"; 443 443 } 444 444 445 NetworkAttachmentType_T oldAttachmentType = mData->m AttachmentType;446 mData->m AttachmentType = aAttachmentType;445 NetworkAttachmentType_T oldAttachmentType = mData->mode; 446 mData->mode = aAttachmentType; 447 447 448 448 // leave the lock before informing callbacks … … 454 454 455 455 if (oldAttachmentType == NetworkAttachmentType_NATNetwork) 456 i_checkAndSwitchFromNatNetworking(mData-> mNATNetwork);456 i_checkAndSwitchFromNatNetworking(mData->strNATNetworkName); 457 457 458 458 if (aAttachmentType == NetworkAttachmentType_NATNetwork) 459 i_switchToNatNetworking(mData-> mNATNetwork);459 i_switchToNatNetworking(mData->strNATNetworkName); 460 460 461 461 /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */ … … 470 470 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 471 471 472 aBridgedInterface = mData-> mBridgedInterface;472 aBridgedInterface = mData->strBridgedName; 473 473 474 474 return S_OK; … … 483 483 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 484 484 485 if (mData-> mBridgedInterface != aBridgedInterface)485 if (mData->strBridgedName != aBridgedInterface) 486 486 { 487 487 /* if an empty/null string is to be set, bridged interface must be 488 488 * turned off */ 489 489 if (aBridgedInterface.isEmpty() 490 && mData->m AttachmentType == NetworkAttachmentType_Bridged)490 && mData->mode == NetworkAttachmentType_Bridged) 491 491 { 492 492 return setError(E_FAIL, … … 495 495 496 496 mData.backup(); 497 mData-> mBridgedInterface = aBridgedInterface;497 mData->strBridgedName = aBridgedInterface; 498 498 499 499 // leave the lock before informing callbacks … … 517 517 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 518 518 519 aHostOnlyInterface = mData-> mHostOnlyInterface;519 aHostOnlyInterface = mData->strHostOnlyName; 520 520 521 521 return S_OK; … … 530 530 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 531 531 532 if (mData-> mHostOnlyInterface != aHostOnlyInterface)532 if (mData->strHostOnlyName != aHostOnlyInterface) 533 533 { 534 534 /* if an empty/null string is to be set, host only interface must be 535 535 * turned off */ 536 536 if ( aHostOnlyInterface.isEmpty() 537 && mData->m AttachmentType == NetworkAttachmentType_HostOnly)537 && mData->mode == NetworkAttachmentType_HostOnly) 538 538 { 539 539 return setError(E_FAIL, … … 542 542 543 543 mData.backup(); 544 mData-> mHostOnlyInterface = aHostOnlyInterface;544 mData->strHostOnlyName = aHostOnlyInterface; 545 545 546 546 // leave the lock before informing callbacks … … 565 565 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 566 566 567 aInternalNetwork = mData-> mInternalNetwork;567 aInternalNetwork = mData->strInternalNetworkName; 568 568 569 569 return S_OK; … … 578 578 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 579 579 580 if (mData-> mInternalNetwork!= aInternalNetwork)580 if (mData->strInternalNetworkName != aInternalNetwork) 581 581 { 582 582 /* if an empty/null string is to be set, internal networking must be 583 583 * turned off */ 584 if (aInternalNetwork.isEmpty() && mData->m AttachmentType == NetworkAttachmentType_Internal)584 if (aInternalNetwork.isEmpty() && mData->mode == NetworkAttachmentType_Internal) 585 585 { 586 586 return setError(E_FAIL, … … 588 588 } 589 589 mData.backup(); 590 mData-> mInternalNetwork= aInternalNetwork;590 mData->strInternalNetworkName = aInternalNetwork; 591 591 592 592 // leave the lock before informing callbacks … … 610 610 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 611 611 612 aNATNetwork = mData-> mNATNetwork;612 aNATNetwork = mData->strNATNetworkName; 613 613 614 614 return S_OK; … … 624 624 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 625 625 626 if (mData-> mNATNetwork!= aNATNetwork)626 if (mData->strNATNetworkName != aNATNetwork) 627 627 { 628 628 /* if an empty/null string is to be set, host only interface must be 629 629 * turned off */ 630 630 if (aNATNetwork.isEmpty() 631 && mData->m AttachmentType == NetworkAttachmentType_NATNetwork)631 && mData->mode == NetworkAttachmentType_NATNetwork) 632 632 return setError(E_FAIL, 633 633 tr("Empty or null NAT network name is not valid")); … … 635 635 mData.backup(); 636 636 637 Bstr oldNatNetworkName = mData-> mNATNetwork;638 mData-> mNATNetwork= aNATNetwork;637 Bstr oldNatNetworkName = mData->strNATNetworkName; 638 mData->strNATNetworkName = aNATNetwork; 639 639 640 640 // leave the lock before informing callbacks … … 660 660 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 661 661 662 aGenericDriver = mData-> mGenericDriver;662 aGenericDriver = mData->strGenericDriver; 663 663 664 664 return S_OK; … … 673 673 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 674 674 675 if (mData-> mGenericDriver != aGenericDriver)675 if (mData->strGenericDriver != aGenericDriver) 676 676 { 677 677 mData.backup(); 678 mData-> mGenericDriver = aGenericDriver;678 mData->strGenericDriver = aGenericDriver; 679 679 680 680 /* leave the lock before informing callbacks */ … … 692 692 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 693 693 694 *aConnected = mData-> mCableConnected;694 *aConnected = mData->fCableConnected; 695 695 696 696 return S_OK; … … 706 706 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 707 707 708 if (aConnected != mData-> mCableConnected)708 if (aConnected != mData->fCableConnected) 709 709 { 710 710 mData.backup(); 711 mData-> mCableConnected = aConnected;711 mData->fCableConnected = aConnected; 712 712 713 713 // leave the lock before informing callbacks … … 730 730 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 731 731 732 *aSpeed = mData-> mLineSpeed;732 *aSpeed = mData->ulLineSpeed; 733 733 734 734 return S_OK; … … 743 743 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 744 744 745 if (aSpeed != mData-> mLineSpeed)745 if (aSpeed != mData->ulLineSpeed) 746 746 { 747 747 mData.backup(); 748 mData-> mLineSpeed = aSpeed;748 mData->ulLineSpeed = aSpeed; 749 749 750 750 // leave the lock before informing callbacks … … 766 766 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 767 767 768 *aPromiscModePolicy = mData-> mPromiscModePolicy;768 *aPromiscModePolicy = mData->enmPromiscModePolicy; 769 769 770 770 return S_OK; … … 793 793 { 794 794 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 795 if (aPromiscModePolicy != mData-> mPromiscModePolicy)795 if (aPromiscModePolicy != mData->enmPromiscModePolicy) 796 796 { 797 797 mData.backup(); 798 mData-> mPromiscModePolicy = aPromiscModePolicy;798 mData->enmPromiscModePolicy = aPromiscModePolicy; 799 799 800 800 alock.release(); … … 813 813 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 814 814 815 *aEnabled = mData-> mTraceEnabled;815 *aEnabled = mData->fTraceEnabled; 816 816 817 817 return S_OK; … … 826 826 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 827 827 828 if (aEnabled != mData-> mTraceEnabled)828 if (aEnabled != mData->fTraceEnabled) 829 829 { 830 830 mData.backup(); 831 mData-> mTraceEnabled = aEnabled;831 mData->fTraceEnabled = aEnabled; 832 832 833 833 // leave the lock before informing callbacks … … 849 849 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 850 850 851 aTraceFile = mData-> mTraceFile;851 aTraceFile = mData->strTraceFile; 852 852 853 853 return S_OK; … … 863 863 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 864 864 865 if (mData-> mTraceFile != aTraceFile)865 if (mData->strTraceFile != aTraceFile) 866 866 { 867 867 mData.backup(); 868 mData-> mTraceFile = aTraceFile;868 mData->strTraceFile = aTraceFile; 869 869 870 870 // leave the lock before informing callbacks … … 895 895 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 896 896 897 *aBootPriority = mData-> mBootPriority;897 *aBootPriority = mData->ulBootPriority; 898 898 899 899 return S_OK; … … 908 908 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 909 909 910 if (aBootPriority != mData-> mBootPriority)910 if (aBootPriority != mData->ulBootPriority) 911 911 { 912 912 mData.backup(); 913 mData-> mBootPriority = aBootPriority;913 mData->ulBootPriority = aBootPriority; 914 914 915 915 // leave the lock before informing callbacks … … 934 934 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 935 935 aValue = ""; 936 settings::StringsMap::const_iterator it = mData-> mGenericProperties.find(aKey);937 if (it != mData-> mGenericProperties.end())936 settings::StringsMap::const_iterator it = mData->genericProperties.find(aKey); 937 if (it != mData->genericProperties.end()) 938 938 aValue = it->second; // source is a Utf8Str 939 939 … … 948 948 if (FAILED(adep.rc())) return adep.rc(); 949 949 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 950 bool fGenericChange = (mData->m AttachmentType == NetworkAttachmentType_Generic);950 bool fGenericChange = (mData->mode == NetworkAttachmentType_Generic); 951 951 /* Generic properties processing. 952 952 * Look up the old value first; if nothing's changed then do nothing. 953 953 */ 954 954 Utf8Str strOldValue; 955 settings::StringsMap::const_iterator it = mData-> mGenericProperties.find(aKey);956 if (it != mData-> mGenericProperties.end())955 settings::StringsMap::const_iterator it = mData->genericProperties.find(aKey); 956 if (it != mData->genericProperties.end()) 957 957 strOldValue = it->second; 958 958 … … 960 960 { 961 961 if (aValue.isEmpty()) 962 mData-> mGenericProperties.erase(aKey);962 mData->genericProperties.erase(aKey); 963 963 else 964 mData-> mGenericProperties[aKey] = aValue;964 mData->genericProperties[aKey] = aValue; 965 965 966 966 /* leave the lock before informing callbacks */ … … 989 989 /// @todo make use of aNames according to the documentation 990 990 NOREF(aNames); 991 aReturnNames.resize(mData-> mGenericProperties.size());992 aReturnValues.resize(mData-> mGenericProperties.size());991 aReturnNames.resize(mData->genericProperties.size()); 992 aReturnValues.resize(mData->genericProperties.size()); 993 993 994 994 size_t i = 0; 995 995 996 for (settings::StringsMap::const_iterator it = mData-> mGenericProperties.begin();997 it != mData-> mGenericProperties.end();996 for (settings::StringsMap::const_iterator it = mData->genericProperties.begin(); 997 it != mData->genericProperties.end(); 998 998 ++it, ++i) 999 999 { … … 1039 1039 HRESULT rc = S_OK; 1040 1040 1041 mData->mAdapterType = data.type;1042 mData->mEnabled = data.fEnabled;1043 1041 /* MAC address (can be null) */ 1044 1042 rc = i_updateMacAddress(data.strMACAddress); 1045 1043 if (FAILED(rc)) return rc; 1046 /* cable (required) */ 1047 mData->mCableConnected = data.fCableConnected; 1048 /* line speed (defaults to 100 Mbps) */ 1049 mData->mLineSpeed = data.ulLineSpeed; 1050 mData->mPromiscModePolicy = data.enmPromiscModePolicy; 1051 /* tracing (defaults to false) */ 1052 mData->mTraceEnabled = data.fTraceEnabled; 1053 mData->mTraceFile = data.strTraceFile; 1054 /* boot priority (defaults to 0, i.e. lowest) */ 1055 mData->mBootPriority = data.ulBootPriority; 1056 /* bandwidth group */ 1057 mData->mBandwidthGroup = data.strBandwidthGroup; 1058 if (mData->mBandwidthGroup.isNotEmpty()) 1044 1045 mData.assignCopy(&data); 1046 1047 if (mData->strBandwidthGroup.isNotEmpty()) 1059 1048 { 1060 1049 ComObjPtr<BandwidthGroup> group; … … 1064 1053 } 1065 1054 1055 // Load NAT engine settings. 1066 1056 mNATEngine->i_loadSettings(data.nat); 1067 mData->mBridgedInterface = data.strBridgedName;1068 mData->mInternalNetwork = data.strInternalNetworkName;1069 mData->mHostOnlyInterface = data.strHostOnlyName;1070 mData->mGenericDriver = data.strGenericDriver;1071 mData->mGenericProperties = data.genericProperties;1072 mData->mNATNetwork = data.strNATNetworkName;1073 1057 1074 1058 // leave the lock before setting attachment type … … 1097 1081 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1098 1082 1099 data.fEnabled = !!mData->mEnabled; 1100 data.strMACAddress = mData->mMACAddress; 1101 data.fCableConnected = !!mData->mCableConnected; 1102 1103 data.enmPromiscModePolicy = mData->mPromiscModePolicy; 1104 data.ulLineSpeed = mData->mLineSpeed; 1105 1106 data.fTraceEnabled = !!mData->mTraceEnabled; 1107 1108 data.strTraceFile = mData->mTraceFile; 1109 1110 data.ulBootPriority = mData->mBootPriority; 1111 1112 data.strBandwidthGroup = mData->mBandwidthGroup; 1113 1114 data.type = mData->mAdapterType; 1115 1116 data.mode = mData->mAttachmentType; 1083 data = *mData.data(); 1117 1084 1118 1085 mNATEngine->i_saveSettings(data.nat); 1119 1120 data.strBridgedName = mData->mBridgedInterface;1121 1122 data.strHostOnlyName = mData->mHostOnlyInterface;1123 1124 data.strInternalNetworkName = mData->mInternalNetwork;1125 1126 data.strGenericDriver = mData->mGenericDriver;1127 data.genericProperties = mData->mGenericProperties;1128 1129 data.strNATNetworkName = mData->mNATNetwork;1130 1086 1131 1087 return S_OK; … … 1141 1097 1142 1098 bool fChanged = mData.isBackedUp(); 1143 fChanged |= (mData-> mAdapterType == NetworkAttachmentType_NAT? mNATEngine->i_isModified() : false);1099 fChanged |= (mData->type == NetworkAttachmentType_NAT? mNATEngine->i_isModified() : false); 1144 1100 return fChanged; 1145 1101 } … … 1217 1173 /* this will back up current data */ 1218 1174 mData.assignCopy(aThat->mData); 1175 1219 1176 } 1220 1177 … … 1241 1198 defaultType == NetworkAdapterType_I82545EM) 1242 1199 { 1243 if (e1000enabled) mData->m AdapterType = defaultType;1244 } 1245 else mData->m AdapterType = defaultType;1200 if (e1000enabled) mData->mode = defaultType; 1201 } 1202 else mData->mode = defaultType; 1246 1203 1247 1204 /* Enable the first one adapter to the NAT */ 1248 if (mData-> mSlot == 0)1249 { 1250 mData-> mEnabled = true;1251 if (mData-> mMACAddress.isEmpty())1205 if (mData->ulSlot == 0) 1206 { 1207 mData->fEnabled = true; 1208 if (mData->strMACAddress.isEmpty()) 1252 1209 i_generateMACAddress(); 1253 mData-> mAttachmentType = NetworkAttachmentType_NAT;1254 } 1255 mData-> mCableConnected = true;1210 mData->type = NetworkAttachmentType_NAT; 1211 } 1212 mData->fCableConnected = true; 1256 1213 } 1257 1214 … … 1277 1234 Host::i_generateMACAddress(mac); 1278 1235 LogFlowThisFunc(("generated MAC: '%s'\n", mac.c_str())); 1279 mData-> mMACAddress = mac;1236 mData->strMACAddress = mac; 1280 1237 } 1281 1238 … … 1288 1245 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1289 1246 1290 if (mData-> mBandwidthGroup.isNotEmpty())1247 if (mData->strBandwidthGroup.isNotEmpty()) 1291 1248 { 1292 1249 ComObjPtr<BandwidthGroup> pBwGroup; 1293 hrc = mParent->i_getBandwidthGroup(mData-> mBandwidthGroup, pBwGroup, true /* fSetError */);1250 hrc = mParent->i_getBandwidthGroup(mData->strBandwidthGroup, pBwGroup, true /* fSetError */); 1294 1251 1295 1252 Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence … … 1318 1275 strBwGroup = static_cast<BandwidthGroup *>(iBw)->i_getName(); 1319 1276 1320 if (mData-> mBandwidthGroup != strBwGroup)1277 if (mData->strBandwidthGroup != strBwGroup) 1321 1278 { 1322 1279 ComObjPtr<BandwidthGroup> pBwGroup; … … 1352 1309 1353 1310 ComObjPtr<BandwidthGroup> pOldBwGroup; 1354 if (!mData-> mBandwidthGroup.isEmpty())1311 if (!mData->strBandwidthGroup.isEmpty()) 1355 1312 { 1356 HRESULT hrc = mParent->i_getBandwidthGroup(mData-> mBandwidthGroup, pOldBwGroup, false /* fSetError */);1313 HRESULT hrc = mParent->i_getBandwidthGroup(mData->strBandwidthGroup, pOldBwGroup, false /* fSetError */); 1357 1314 NOREF(hrc); 1358 1315 Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of … … 1364 1321 { 1365 1322 pOldBwGroup->i_release(); 1366 mData-> mBandwidthGroup = Utf8Str::Empty;1323 mData->strBandwidthGroup = Utf8Str::Empty; 1367 1324 } 1368 1325 1369 1326 if (aBwGroup) 1370 1327 { 1371 mData-> mBandwidthGroup = aBwGroup->i_getName();1328 mData->strBandwidthGroup = aBwGroup->i_getName(); 1372 1329 aBwGroup->i_reference(); 1373 1330 }
Note:
See TracChangeset
for help on using the changeset viewer.