#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
+#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
return mForwardingRequests.size();
}
-#define TETHER_START_CONST_ARG 9
+#define TETHER_START_CONST_ARG 8
int TetherController::startTethering(int num_addrs, char **dhcp_ranges) {
if (mDaemonPid != 0) {
args[5] = (char *)"--dhcp-option-force=43,ANDROID_METERED";
args[6] = (char *)"--pid-file";
args[7] = (char *)"";
- args[8] = (char *)"-z"; // OPT_NOWILD
int nextArg = TETHER_START_CONST_ARG;
for (int addrIndex = 0; addrIndex < num_addrs; addrIndex += 2) {
for (i = 0; i < numServers; i++) {
ALOGD("setDnsForwarders(0x%x %d = '%s')", fwmark.intValue, i, servers[i]);
- struct in_addr v4dns;
- struct in6_addr v6dns;
-
- if (!inet_aton(servers[i], &v4dns) &&
- (inet_pton(AF_INET6, servers[i], &v6dns) != 1)) {
+ addrinfo *res, hints = { .ai_flags = AI_NUMERICHOST };
+ int ret = getaddrinfo(servers[i], NULL, &hints, &res);
+ freeaddrinfo(res);
+ if (ret) {
ALOGE("Failed to parse DNS server '%s'", servers[i]);
mDnsForwarders->clear();
+ errno = EINVAL;
return -1;
}
if (write(mDaemonFd, daemonCmd, strlen(daemonCmd) +1) < 0) {
ALOGE("Failed to send update command to dnsmasq (%s)", strerror(errno));
mDnsForwarders->clear();
+ errno = EREMOTEIO;
return -1;
}
}