summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-09-03 05:49:15 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-03 05:49:15 +0000
commita47ea0b4e4e40c8ee184fe1b53faf255bee29b44 (patch)
treefa0a7628fd0d2e2fdb2ddc28a1b2d16ec3d39165 /server/TetherController.cpp
parenteb74641ad7cb8d8df539fe005806f73cb87dba6a (diff)
parent667c477133318e4779819d34364194c8e5eaf19c (diff)
am 667c4771: Add a socket mark parameter to tethering DNS commands.
* commit '667c477133318e4779819d34364194c8e5eaf19c': Add a socket mark parameter to tethering DNS commands.
Diffstat (limited to 'server/TetherController.cpp')
-rw-r--r--server/TetherController.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index fbee5a2f..fb51c06c 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -31,11 +31,14 @@
#include <cutils/log.h>
#include <cutils/properties.h>
+#include "Fwmark.h"
#include "NetdConstants.h"
+#include "Permission.h"
#include "TetherController.h"
TetherController::TetherController() {
mInterfaces = new InterfaceCollection();
+ mDnsNetId = 0;
mDnsForwarders = new NetAddressCollection();
mDaemonFd = -1;
mDaemonPid = 0;
@@ -197,16 +200,22 @@ bool TetherController::isTetheringStarted() {
#define MAX_CMD_SIZE 1024
-int TetherController::setDnsForwarders(char **servers, int numServers) {
+int TetherController::setDnsForwarders(unsigned netId, char **servers, int numServers) {
int i;
char daemonCmd[MAX_CMD_SIZE];
- strcpy(daemonCmd, "update_dns");
+ Fwmark fwmark;
+ fwmark.netId = netId;
+ fwmark.explicitlySelected = true;
+ fwmark.protectedFromVpn = true;
+ fwmark.permission = PERMISSION_SYSTEM;
+
+ snprintf(daemonCmd, sizeof(daemonCmd), "update_dns:0x%x", fwmark.intValue);
int cmdLen = strlen(daemonCmd);
mDnsForwarders->clear();
for (i = 0; i < numServers; i++) {
- ALOGD("setDnsForwarders(%d = '%s')", i, servers[i]);
+ ALOGD("setDnsForwarders(0x%x %d = '%s')", fwmark.intValue, i, servers[i]);
struct in_addr a;
@@ -227,6 +236,7 @@ int TetherController::setDnsForwarders(char **servers, int numServers) {
mDnsForwarders->push_back(a);
}
+ mDnsNetId = netId;
if (mDaemonFd != -1) {
ALOGD("Sending update msg to dnsmasq [%s]", daemonCmd);
if (write(mDaemonFd, daemonCmd, strlen(daemonCmd) +1) < 0) {
@@ -238,6 +248,10 @@ int TetherController::setDnsForwarders(char **servers, int numServers) {
return 0;
}
+unsigned TetherController::getDnsNetId() {
+ return mDnsNetId;
+}
+
NetAddressCollection *TetherController::getDnsForwarders() {
return mDnsForwarders;
}