Changeset 5716 in vbox for trunk/src/VBox/Devices/Network/slirp/slirp.c
- Timestamp:
- Nov 12, 2007 5:21:33 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/slirp.c
r5332 r5716 13 13 #ifdef _WIN32 14 14 15 static int get_dns_addr_domain(PNATState pData, struct in_addr *pdns_addr, 15 static int get_dns_addr_domain(PNATState pData, bool fVerbose, 16 struct in_addr *pdns_addr, 16 17 const char **ppszDomain) 17 18 { … … 26 27 BufLen = sizeof(FIXED_INFO); 27 28 29 /** @todo: this API returns all DNS servers, no matter whether the 30 * corresponding network adapter is disabled or not. Maybe replace 31 * this by GetAdapterAddresses(), which is XP/Vista only though. */ 28 32 if (ERROR_BUFFER_OVERFLOW == GetNetworkParams(FixedInfo, &BufLen)) { 29 33 if (FixedInfo) { … … 46 50 pIPAddr = &(FixedInfo->DnsServerList); 47 51 inet_aton(pIPAddr->IpAddress.String, &tmp_addr); 52 Log(("nat: DNS Servers:\n")); 53 if (fVerbose || pdns_addr->s_addr != tmp_addr.s_addr) 54 LogRel(("NAT: DNS address: %s\n", pIPAddr->IpAddress.String)); 48 55 *pdns_addr = tmp_addr; 49 Log(("nat: DNS Servers:\n"));50 LogRel(("NAT: DNS address: %s\n", pIPAddr->IpAddress.String));51 56 52 57 pIPAddr = FixedInfo -> DnsServerList.Next; 53 58 while ( pIPAddr ) 54 59 { 55 LogRel(("NAT: ignored DNS address: %s\n", pIPAddr ->IpAddress.String)); 60 if (fVerbose) 61 LogRel(("NAT: ignored DNS address: %s\n", pIPAddr ->IpAddress.String)); 56 62 pIPAddr = pIPAddr ->Next; 57 63 } … … 62 68 63 69 get_dns_prefix: 64 *ppszDomain = NULL;70 if (ppszDomain) 65 71 { 66 72 OSVERSIONINFO ver; … … 68 74 DWORD dwSize = sizeof(szDnsDomain); 69 75 76 *ppszDomain = NULL; 70 77 GetVersionEx(&ver); 71 78 if (ver.dwMajorVersion >= 5) … … 79 86 *ppszDomain = RTStrDup(szDnsDomain); 80 87 if (pData->fPassDomain) 81 LogRel(("NAT: passing domain name %s\n", szDnsDomain)); 88 { 89 if (fVerbose) 90 LogRel(("NAT: passing domain name %s\n", szDnsDomain)); 91 } 82 92 else 83 93 Log(("nat: ignoring domain %s\n", szDnsDomain)); … … 93 103 #else 94 104 95 static int get_dns_addr_domain(PNATState pData, struct in_addr *pdns_addr, 105 static int get_dns_addr_domain(PNATState pData, bool fVerbose, 106 struct in_addr *pdns_addr, 96 107 const char **ppszDomain) 97 108 { … … 125 136 return -1; 126 137 127 *ppszDomain = NULL; 138 if (ppszDomain) 139 *ppszDomain = NULL; 128 140 Log(("nat: DNS Servers:\n")); 129 141 while (fgets(buff, 512, f) != NULL) { … … 136 148 if (!found) 137 149 { 150 if (fVerbose || pdns_addr->s_addr != tmp_addr.s_addr) 151 LogRel(("NAT: DNS address: %s\n", buff2)); 138 152 *pdns_addr = tmp_addr; 139 LogRel(("NAT: DNS address: %s\n", buff2));140 153 } 141 154 else 142 LogRel(("NAT: ignored DNS address: %s\n", buff2)); 155 { 156 if (fVerbose) 157 LogRel(("NAT: ignored DNS address: %s\n", buff2)); 158 } 143 159 found++; 144 160 } 145 if (!strncmp(buff, "domain", 6) || !strncmp(buff, "search", 6)) 161 if ( ppszDomain 162 && (!strncmp(buff, "domain", 6) || !strncmp(buff, "search", 6))) 146 163 { 147 164 /* Domain name/search list present. Pick first entry */ … … 149 166 { 150 167 char *tok; 151 tok = strtok(&buff[6], " \t\n"); 168 char *saveptr; 169 tok = strtok_r(&buff[6], " \t\n", &saveptr); 152 170 if (tok) 153 171 { 154 172 *ppszDomain = RTStrDup(tok); 155 173 if (pData->fPassDomain) 156 LogRel(("NAT: passing domain name %s\n", tok)); 174 { 175 if (fVerbose) 176 LogRel(("NAT: passing domain name %s\n", tok)); 177 } 157 178 else 158 179 Log(("nat: ignoring domain %s\n", tok)); … … 168 189 169 190 #endif 191 192 int get_dns_addr(PNATState pData, struct in_addr *pdns_addr) 193 { 194 return get_dns_addr_domain(pData, false, pdns_addr, NULL); 195 } 170 196 171 197 int slirp_init(PNATState *ppData, const char *pszNetAddr, bool fPassDomain, … … 207 233 inet_aton("127.0.0.1", &dns_addr); 208 234 209 if (get_dns_addr_domain(pData, &dns_addr, &pData->pszDomain) < 0)235 if (get_dns_addr_domain(pData, true, &dns_addr, &pData->pszDomain) < 0) 210 236 fNATfailed = 1; 211 237
Note:
See TracChangeset
for help on using the changeset viewer.