Add specification of ms-dns arg to pppd.
This lets us tell the pc to use the tethered android as their dns server.
bug:2281900
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 1747042..eba88de 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -395,7 +395,10 @@
}
if (!strcmp(argv[1], "attach")) {
- struct in_addr l, r;
+ struct in_addr l, r, dns1, dns2;
+
+ memset(&dns1, sizeof(struct in_addr), 0);
+ memset(&dns2, sizeof(struct in_addr), 0);
if (!inet_aton(argv[3], &l)) {
cli->sendMsg(ResponseCode::CommandParameterError, "Invalid local address", false);
@@ -405,7 +408,15 @@
cli->sendMsg(ResponseCode::CommandParameterError, "Invalid remote address", false);
return 0;
}
- rc = sPppCtrl->attachPppd(argv[2], l, r);
+ if ((argc > 3) && (!inet_aton(argv[5], &dns1))) {
+ cli->sendMsg(ResponseCode::CommandParameterError, "Invalid dns1 address", false);
+ return 0;
+ }
+ if ((argc > 4) && (!inet_aton(argv[6], &dns2))) {
+ cli->sendMsg(ResponseCode::CommandParameterError, "Invalid dns2 address", false);
+ return 0;
+ }
+ rc = sPppCtrl->attachPppd(argv[2], l, r, dns1, dns2);
} else if (!strcmp(argv[1], "detach")) {
rc = sPppCtrl->detachPppd(argv[2]);
} else {
diff --git a/PppController.cpp b/PppController.cpp
index 8b32d06..767b74d 100644
--- a/PppController.cpp
+++ b/PppController.cpp
@@ -50,7 +50,8 @@
}
int PppController::attachPppd(const char *tty, struct in_addr local,
- struct in_addr remote) {
+ struct in_addr remote, struct in_addr dns1,
+ struct in_addr dns2) {
pid_t pid;
if (mPid) {
@@ -79,6 +80,8 @@
if (!pid) {
char *l = strdup(inet_ntoa(local));
char *r = strdup(inet_ntoa(remote));
+ char *d1 = strdup(inet_ntoa(dns1));
+ char *d2 = strdup(inet_ntoa(dns2));
char dev[32];
char *lr;
@@ -88,8 +91,8 @@
// TODO: Deal with pppd bailing out after 99999 seconds of being started
// but not getting a connection
- if (execl("/system/bin/pppd", "/system/bin/pppd", "-detach", dev,
- "115200", lr, "debug", "lcp-max-configure", "99999", (char *) NULL)) {
+ if (execl("/system/bin/pppd", "/system/bin/pppd", "-detach", dev, "115200",
+ lr, "ms-dns", d1, "ms-dns", d2, "debug", "lcp-max-configure", "99999", (char *) NULL)) {
LOGE("execl failed (%s)", strerror(errno));
}
LOGE("Should never get here!");
@@ -145,4 +148,3 @@
closedir(d);
return 0;
}
-
diff --git a/PppController.h b/PppController.h
index 5046822..bb75435 100644
--- a/PppController.h
+++ b/PppController.h
@@ -32,7 +32,8 @@
virtual ~PppController();
int attachPppd(const char *tty, struct in_addr local,
- struct in_addr remote);
+ struct in_addr remote, struct in_addr dns1,
+ struct in_addr dns2);
int detachPppd(const char *tty);
TtyCollection *getTtyList();