Changeset 16296 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Jan 28, 2009 10:55:06 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/slirp.c
r16291 r16296 163 163 IP_ADDR_STRING *pIPAddr; 164 164 struct in_addr tmp_addr; 165 #ifdef VBOX_WITH_MULTI_DNS166 struct in_addr local_mask;167 struct in_addr local_network;168 #endif169 165 170 166 FixedInfo = (FIXED_INFO *)GlobalAlloc(GPTR, sizeof(FIXED_INFO)); … … 213 209 #else 214 210 /*localhost mask */ 215 inet_aton("255.0.0.0", &local_mask);216 inet_aton("127.0.0.0", &local_network);217 211 for (pIPAddr = &FixedInfo->DnsServerList; pIPAddr != NULL; pIPAddr = pIPAddr->Next) 218 212 { 219 struct dns_entry *da = RTMemAllocZ(sizeof (struct dns_entry)); 213 struct dns_entry *da; 214 if(!inet_aton(pIPAddr->IpAddress.String, &tmp_addr)) 215 continue; 216 da = RTMemAllocZ(sizeof (struct dns_entry)); 220 217 if (da == NULL) 221 218 { … … 224 221 } 225 222 /*check */ 226 inet_aton(pIPAddr->IpAddress.String, &da->de_addr); 227 if ((ntohl(da->de_addr.s_addr) & ntohl(local_mask.s_addr)) == ntohl(local_network.s_addr)) { 223 if ((da->de_addr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) { 228 224 da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); 229 225 } … … 313 309 while (fgets(buff, 512, f) != NULL) 314 310 { 311 #ifdef VBOX_WITH_MULTI_DNS 312 struct dns_entry *da = NULL; 313 #endif 315 314 if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) 316 315 { 317 316 if (!inet_aton(buff2, &tmp_addr)) 318 317 continue; 318 #ifndef VBOX_WITH_MULTI_DNS 319 319 /* If it's the first one, set it to dns_addr */ 320 320 if (!found) … … 329 329 LogRel(("NAT: ignored DNS address: %s\n", buff2)); 330 330 } 331 #else 332 /*localhost mask */ 333 da = RTMemAllocZ(sizeof (struct dns_entry)); 334 if (da == NULL) 335 { 336 LogRel(("can't alloc memory for DNS entry\n")); 337 return -1; 338 } 339 /*check */ 340 da->de_addr.s_addr = tmp_addr.s_addr; 341 if ((da->de_addr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) { 342 da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); 343 } 344 LIST_INSERT_HEAD(&pData->dns_list_head, da, de_list); 345 #endif 331 346 found++; 332 347 }
Note:
See TracChangeset
for help on using the changeset viewer.