Changeset 8287 in vbox
- Timestamp:
- Apr 22, 2008 1:24:22 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r8285 r8287 32 32 #include <iprt/string.h> 33 33 #include <iprt/critsect.h> 34 #include <iprt/ip.h> 34 35 35 36 #include "Builtins.h" … … 386 387 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT); 387 388 char szNetAddr[16]; 389 char szNetwork[32]; /* xxx.xxx.xxx.xxx/yy */ 388 390 LogFlow(("drvNATConstruct:\n")); 389 391 … … 391 393 * Validate the config. 392 394 */ 393 if (!CFGMR3AreValuesValid(pCfgHandle, "PassDomain\0TFTPPrefix\0BootFile\0 "))395 if (!CFGMR3AreValuesValid(pCfgHandle, "PassDomain\0TFTPPrefix\0BootFile\0Network\0")) 394 396 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, N_("Unknown NAT configuration option, only supports PassDomain, TFTPPrefix and BootFile")); 395 397 … … 438 440 439 441 /* Generate a network address for this network card. */ 440 RTStrPrintf(szNetAddr, sizeof(szNetAddr), "10.0.%d.0", pDrvIns->iInstance + 2); 442 rc = CFGMR3QueryString(pCfgHandle, "Network", szNetwork, sizeof(szNetwork)); 443 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 444 RTStrPrintf(szNetwork, sizeof(szNetwork), "10.0.%d.0/24", pDrvIns->iInstance + 2); 445 else if (VBOX_FAILURE(rc)) 446 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"Network\" string failed"), pDrvIns->iInstance); 447 448 RTIPV4ADDR Network; 449 RTIPV4ADDR Netmask; 450 rc = RTCidrStrToIPv4(szNetwork, &Network, &Netmask); 451 if (RT_FAILURE(rc)) 452 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: Configuration error: network '%s' describes not a valid IPv4 network")); 453 454 RTStrPrintf(szNetAddr, sizeof(szNetAddr), "%d.%d.%d.%d", 455 (Network & 0xFF000000) >> 24, (Network & 0xFF0000) >> 16, (Network & 0xFF00) >> 8, Network & 0xFF); 441 456 442 457 /* … … 461 476 * Initialize slirp. 462 477 */ 463 rc = slirp_init(&pData->pNATState, &szNetAddr[0], 0xffffff00, fPassDomain, pData->pszTFTPPrefix, pData->pszBootFile, pData);478 rc = slirp_init(&pData->pNATState, &szNetAddr[0], Netmask, fPassDomain, pData->pszTFTPPrefix, pData->pszBootFile, pData); 464 479 if (VBOX_SUCCESS(rc)) 465 480 {
Note:
See TracChangeset
for help on using the changeset viewer.