儲存庫 vbox 的更動 88747
- 時間撮記:
- 2021-4-28 下午02:25:53 (4 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp
r87949 r88747 431 431 int rc; 432 432 433 RTNETADDRIPV6 Net6;434 int iPrefixLength;435 rc = RTNetStrToIPv6Cidr(aIPv6Prefix.c_str(), &Net6, &iPrefixLength);436 if (RT_FAILURE(rc))437 return setError(E_INVALIDARG,438 "%s is not a valid IPv6 prefix",439 aIPv6Prefix.c_str());440 441 /* Accept both addr:: and addr::/64 */442 if (iPrefixLength == 128) /* no length was specified after the address? */443 iPrefixLength = 64; /* take it to mean /64 which we require anyway */444 else if (iPrefixLength != 64)445 return setError(E_INVALIDARG,446 "Invalid IPv6 prefix length %d, must be 64",447 iPrefixLength);448 449 /* Verify the address is unicast. */450 if ( ((Net6.au8[0] & 0xe0) != 0x20) /* global 2000::/3 */451 && ((Net6.au8[0] & 0xfe) != 0xfc)) /* local fc00::/7 */452 return setError(E_INVALIDARG,453 "IPv6 prefix %RTnaipv6 is not unicast",454 &Net6);455 456 /* Verify the interfaces ID part is zero */457 if (Net6.au64[1] != 0)458 return setError(E_INVALIDARG,459 "Non-zero bits in the interface ID part"460 " of the IPv6 prefix %RTnaipv6/64",461 &Net6);462 463 433 /* Since we store it in text form, use canonical representation */ 464 com::Utf8StrFmt strNormalizedIPv6Prefix("%RTnaipv6/64", &Net6); 434 com::Utf8Str strNormalizedIPv6Prefix; 435 436 const char *pcsz = RTStrStripL(aIPv6Prefix.c_str()); 437 if (*pcsz != '\0') /* verify it first if not empty/blank */ 438 { 439 RTNETADDRIPV6 Net6; 440 int iPrefixLength; 441 rc = RTNetStrToIPv6Cidr(aIPv6Prefix.c_str(), &Net6, &iPrefixLength); 442 if (RT_FAILURE(rc)) 443 return setError(E_INVALIDARG, 444 "%s is not a valid IPv6 prefix", 445 aIPv6Prefix.c_str()); 446 447 /* Accept both addr:: and addr::/64 */ 448 if (iPrefixLength == 128) /* no length was specified after the address? */ 449 iPrefixLength = 64; /* take it to mean /64 which we require anyway */ 450 else if (iPrefixLength != 64) 451 return setError(E_INVALIDARG, 452 "Invalid IPv6 prefix length %d, must be 64", 453 iPrefixLength); 454 455 /* Verify the address is unicast. */ 456 if ( ((Net6.au8[0] & 0xe0) != 0x20) /* global 2000::/3 */ 457 && ((Net6.au8[0] & 0xfe) != 0xfc)) /* local fc00::/7 */ 458 return setError(E_INVALIDARG, 459 "IPv6 prefix %RTnaipv6 is not unicast", 460 &Net6); 461 462 /* Verify the interfaces ID part is zero */ 463 if (Net6.au64[1] != 0) 464 return setError(E_INVALIDARG, 465 "Non-zero bits in the interface ID part" 466 " of the IPv6 prefix %RTnaipv6/64", 467 &Net6); 468 469 rc = strNormalizedIPv6Prefix.printfNoThrow("%RTnaipv6/64", &Net6); 470 if (RT_FAILURE(rc)) 471 { 472 if (rc == VERR_NO_MEMORY) 473 return setError(E_OUTOFMEMORY); 474 else 475 return setError(E_FAIL, "Internal error"); 476 } 477 } 465 478 466 479 { … … 473 486 if (strNormalizedIPv6Prefix == m->s.strIPv6Prefix) 474 487 return S_OK; 488 489 /* only allow prefix to be empty if IPv6 is disabled */ 490 if (strNormalizedIPv6Prefix.isEmpty() && m->s.fIPv6Enabled) 491 return setError(E_FAIL, "Setting an empty IPv6 prefix when IPv6 is enabled"); 475 492 476 493 /**
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器