diff options
| author | Lorenzo Colitti <lorenzo@google.com> | 2014-08-26 14:13:07 -0700 |
|---|---|---|
| committer | Lorenzo Colitti <lorenzo@google.com> | 2014-08-27 18:40:46 -0700 |
| commit | 667c477133318e4779819d34364194c8e5eaf19c (patch) | |
| tree | fa0a7628fd0d2e2fdb2ddc28a1b2d16ec3d39165 /server/TetherController.cpp | |
| parent | 99286fe1ef6fc325c28dd10b651b5adedd549495 (diff) | |
Add a socket mark parameter to tethering DNS commands.
This allows the framework to pass down to dnsmasq the socket mark
to use for DNS queries.
Bug: 16357676
Change-Id: I8933b6de198a92c2aaf0291931ace8966ddba275
Diffstat (limited to 'server/TetherController.cpp')
| -rw-r--r-- | server/TetherController.cpp | 20 |
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; } |
