Changeset 1698 in vbox
- Timestamp:
- Mar 26, 2007 11:40:27 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r1186 r1698 310 310 for (PCFGMNODE pNode = CFGMR3GetFirstChild(pCfgHandle); pNode; pNode = CFGMR3GetNextChild(pNode)) 311 311 { 312 /* 313 * Validate the port forwarding config. 314 */ 315 if (!CFGMR3AreValuesValid(pNode, "Protocol\0UDP\0HostPort\0GuestPort\0GuestIP\0")) 316 return PDMDRV_SET_ERROR(pData->pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, N_("Unknown configuration in port forwarding")); 317 312 318 /* protocol type */ 313 319 bool fUDP; 314 int rc = CFGMR3QueryBool(pNode, "UDP", &fUDP); 320 char szProtocol[32]; 321 int rc = CFGMR3QueryString(pNode, "Protocol", &szProtocol[0], sizeof(szProtocol)); 315 322 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 316 fUDP = true;317 else if (VBOX_FAILURE(rc))318 323 { 319 AssertMsgFailed(("Configuration error: Boolean \"UDP\" -> %Vrc\n", rc)); 320 return rc; 324 rc = CFGMR3QueryBool(pNode, "UDP", &fUDP); 325 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 326 fUDP = false; 327 else if (VBOX_FAILURE(rc)) 328 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"UDP\" boolean returned %Vrc"), rc); 329 } 330 else if (VBOX_SUCCESS(rc)) 331 { 332 if (!strcasecmp(szProtocol, "TCP")) 333 fUDP = false; 334 else if (!strcasecmp(szProtocol, "UDP")) 335 fUDP = true; 336 else 337 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"Protocol\" string returned %Vrc"), rc); 321 338 } 322 339 … … 325 342 rc = CFGMR3QueryS32(pNode, "HostPort", &iHostPort); 326 343 if (VBOX_FAILURE(rc)) 327 { 328 AssertMsgFailed(("Configuration error: Boolean \"HostPort\" -> %Vrc\n", rc)); 329 return rc; 330 } 344 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"HostPort\" integer returned %Vrc"), rc); 331 345 332 346 /* guest port */ … … 334 348 rc = CFGMR3QueryS32(pNode, "GuestPort", &iGuestPort); 335 349 if (VBOX_FAILURE(rc)) 336 { 337 AssertMsgFailed(("Configuration error: Boolean \"GuestPort\" -> %Vrc\n", rc)); 338 return rc; 339 } 350 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestPort\" integer returned %Vrc"), rc); 340 351 341 352 /* guest address */ … … 345 356 strcpy(szGuestIP, "10.0.2.15"); 346 357 else if (VBOX_FAILURE(rc)) 347 { 348 AssertMsgFailed(("Configuration error: Boolean \"HostPort\" -> %Vrc\n", rc)); 349 return rc; 350 } 358 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestIP\" string returned %Vrc"), rc); 351 359 struct in_addr GuestIP; 352 360 if (!inet_aton(szGuestIP, &GuestIP)) 353 { 354 AssertMsgFailed(("Configuration error: Invalid \"GuestIP\"=\"%s\", inet_aton failed.\n", szGuestIP)); 355 return VERR_NAT_REDIR_GUEST_IP; 356 } 361 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_NAT_REDIR_GUEST_IP, RT_SRC_POS, N_("NAT#%d: configuration error: invalid \"GuestIP\"=\"%s\", inet_aton failed"), szGuestIP); 357 362 358 363 /* … … 361 366 Log(("drvNATConstruct: Redir %d -> %s:%d\n", iHostPort, szGuestIP, iGuestPort)); 362 367 if (slirp_redir(pData->pNATState, fUDP, iHostPort, GuestIP, iGuestPort) < 0) 363 { 364 AssertMsgFailed(("Configuration error: failed to setup redirection of %d to %s:%d. Probably a conflict with existing services or other rules.\n", 365 iHostPort, szGuestIP, iGuestPort)); 366 return VERR_NAT_REDIR_SETUP; 367 } 368 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, N_("NAT#%d: configuration error: failed to set up redirection of %d to %s:%d. Probably a conflict with existing services or other rules"), iHostPort, szGuestIP, iGuestPort); 368 369 } /* for each redir rule */ 369 370
Note:
See TracChangeset
for help on using the changeset viewer.