Changeset 2938 in vbox
- Timestamp:
- May 30, 2007 4:30:42 PM (18 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r2837 r2938 303 303 * @param pCfgHandle The drivers configuration handle. 304 304 */ 305 static int drvNATConstructRedir( PDRVNAT pData, PCFGMNODE pCfgHandle)305 static int drvNATConstructRedir(unsigned iInstance, PDRVNAT pData, PCFGMNODE pCfgHandle) 306 306 { 307 307 /* … … 326 326 fUDP = false; 327 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);328 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"UDP\" boolean returned %Vrc"), iInstance, rc); 329 329 } 330 330 else if (VBOX_SUCCESS(rc)) … … 335 335 fUDP = true; 336 336 else 337 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("NAT#%d: Invalid configuration value for \"Protocol\": \"%s\""), szProtocol);337 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("NAT#%d: Invalid configuration value for \"Protocol\": \"%s\""), iInstance, szProtocol); 338 338 } 339 339 else 340 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"Protocol\" string returned %Vrc"), rc);340 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"Protocol\" string returned %Vrc"), iInstance, rc); 341 341 342 342 /* host port */ … … 344 344 rc = CFGMR3QueryS32(pNode, "HostPort", &iHostPort); 345 345 if (VBOX_FAILURE(rc)) 346 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"HostPort\" integer returned %Vrc"), rc);346 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"HostPort\" integer returned %Vrc"), iInstance, rc); 347 347 348 348 /* guest port */ … … 350 350 rc = CFGMR3QueryS32(pNode, "GuestPort", &iGuestPort); 351 351 if (VBOX_FAILURE(rc)) 352 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestPort\" integer returned %Vrc"), rc);352 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestPort\" integer returned %Vrc"), iInstance, rc); 353 353 354 354 /* guest address */ … … 358 358 strcpy(szGuestIP, "10.0.2.15"); 359 359 else if (VBOX_FAILURE(rc)) 360 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestIP\" string returned %Vrc"), rc);360 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestIP\" string returned %Vrc"), iInstance, rc); 361 361 struct in_addr GuestIP; 362 362 if (!inet_aton(szGuestIP, &GuestIP)) 363 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_NAT_REDIR_GUEST_IP, RT_SRC_POS, N_("NAT#%d: configuration error: invalid \"GuestIP\"=\"%s\", inet_aton failed"), szGuestIP);363 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_NAT_REDIR_GUEST_IP, RT_SRC_POS, N_("NAT#%d: configuration error: invalid \"GuestIP\"=\"%s\", inet_aton failed"), iInstance, szGuestIP); 364 364 365 365 /* … … 368 368 Log(("drvNATConstruct: Redir %d -> %s:%d\n", iHostPort, szGuestIP, iGuestPort)); 369 369 if (slirp_redir(pData->pNATState, fUDP, iHostPort, GuestIP, iGuestPort) < 0) 370 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"), i HostPort, szGuestIP, iGuestPort);370 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"), iInstance, iHostPort, szGuestIP, iGuestPort); 371 371 } /* for each redir rule */ 372 372 … … 394 394 * Validate the config. 395 395 */ 396 if (!CFGMR3AreValuesValid(pCfgHandle, "\0")) 397 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, ""); 396 if (!CFGMR3AreValuesValid(pCfgHandle, "PassDomain\0")) 397 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, "Unknown NAT configuration option, only supports PassDomain"); 398 399 /* 400 * Get the configuration settings. 401 */ 402 bool fPassDomain = true; 403 int rc = CFGMR3QueryBool(pCfgHandle, "PassDomain", &fPassDomain); 404 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 405 fPassDomain = true; 406 else if (VBOX_FAILURE(rc)) 407 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"PassDomain\" boolean returned %Vrc"), pDrvIns->iInstance, rc); 398 408 399 409 /* … … 424 434 * The slirp lock.. 425 435 */ 426 intrc = RTCritSectInit(&pData->CritSect);436 rc = RTCritSectInit(&pData->CritSect); 427 437 if (VBOX_FAILURE(rc)) 428 438 return rc; … … 442 452 * Initialize slirp. 443 453 */ 444 rc = slirp_init(&pData->pNATState, &szNetAddr[0], pData);454 rc = slirp_init(&pData->pNATState, &szNetAddr[0], fPassDomain, pData); 445 455 if (VBOX_SUCCESS(rc)) 446 456 { 447 int rc2 = drvNATConstructRedir(pD ata, pCfgHandle);457 int rc2 = drvNATConstructRedir(pDrvIns->iInstance, pData, pCfgHandle); 448 458 if (VBOX_SUCCESS(rc2)) 449 459 { -
trunk/src/VBox/Devices/Network/slirp/bootp.c
r1076 r2938 263 263 q += val; 264 264 } 265 266 if (pData->pszDomain && pData->fPassDomain) 267 { 268 val = strlen(pData->pszDomain); 269 *q++ = RFC1533_DOMAINNAME; 270 *q++ = val; 271 memcpy(q, pData->pszDomain, val); 272 q += val; 273 } 265 274 } 266 275 *q++ = RFC1533_END; -
trunk/src/VBox/Devices/Network/slirp/libslirp.h
r1076 r2938 27 27 #endif 28 28 29 int slirp_init(PNATState *, const char *, void *);29 int slirp_init(PNATState *, const char *, bool, void *); 30 30 void slirp_term(PNATState); 31 31 void slirp_link_up(PNATState); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r2566 r2938 13 13 #ifdef _WIN32 14 14 15 static int get_dns_addr(PNATState pData, struct in_addr *pdns_addr) 15 static int get_dns_addr_domain(PNATState pData, struct in_addr *pdns_addr, 16 const char **ppszDomain) 16 17 { 17 18 FIXED_INFO *FixedInfo=NULL; … … 20 21 IP_ADDR_STRING *pIPAddr; 21 22 struct in_addr tmp_addr; 23 24 *ppszDomain = NULL; 25 /** @todo implement search list for Windows host. */ 22 26 23 27 FixedInfo = (FIXED_INFO *)GlobalAlloc(GPTR, sizeof(FIXED_INFO)); … … 61 65 #else 62 66 63 static int get_dns_addr(PNATState pData, struct in_addr *pdns_addr) 67 static int get_dns_addr_domain(PNATState pData, struct in_addr *pdns_addr, 68 const char **ppszDomain) 64 69 { 65 70 char buff[512]; … … 92 97 return -1; 93 98 99 *ppszDomain = NULL; 94 100 Log(("nat: IP address of your DNS(s): \n")); 95 101 while (fgets(buff, 512, f) != NULL) { … … 108 114 Log(("nat: %s\n", inet_ntoa(tmp_addr))); 109 115 } 116 if (!strncmp(buff, "domain", 6) || !strncmp(buff, "search", 6)) 117 { 118 /* Domain name/search list present. Pick first entry */ 119 if (*ppszDomain == NULL) 120 { 121 char *tok; 122 tok = strtok(&buff[6], " \t\n"); 123 *ppszDomain = RTStrDup(tok); 124 if (pData->fPassDomain) 125 LogRel(("NAT: passing domain name %s\n", tok)); 126 else 127 Log(("nat: ignoring domain %s\n", tok)); 128 } 129 } 110 130 } 111 131 fclose(f); … … 117 137 #endif 118 138 119 int slirp_init(PNATState *ppData, const char *pszNetAddr, void *pvUser)139 int slirp_init(PNATState *ppData, const char *pszNetAddr, bool fPassDomain, void *pvUser) 120 140 { 121 141 int fNATfailed = 0; … … 125 145 return VERR_NO_MEMORY; 126 146 memset(pData, '\0', sizeof(NATState)); 147 pData->fPassDomain = fPassDomain; 127 148 pData->pvUser = pvUser; 128 149 #if ARCH_BITS == 64 … … 150 171 inet_aton("127.0.0.1", &dns_addr); 151 172 152 if (get_dns_addr (pData, &dns_addr) < 0)173 if (get_dns_addr_domain(pData, &dns_addr, &pData->pszDomain) < 0) 153 174 fNATfailed = 1; 154 175 … … 193 214 void slirp_term(PNATState pData) 194 215 { 216 if (pData->pszDomain) 217 RTStrFree((char *)(void *)pData->pszDomain); 218 195 219 #if ARCH_BITS == 64 196 220 LogRel(("NAT: cpvHashUsed=%RU32 cpvHashCollisions=%RU32 cpvHashInserts=%RU64 cpvHashDone=%RU64\n", -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r1300 r2938 91 91 struct ex_list *exec_list; 92 92 char slirp_hostname[33]; 93 bool fPassDomain; 94 const char *pszDomain; 93 95 /* Stuff from tcp_input.c */ 94 96 struct socket tcb;
Note:
See TracChangeset
for help on using the changeset viewer.