Fix WiFi-Direct and Tethering.
A LocalNetwork object now always exists in the NetworkController, with a fixed
NetId that's guaranteed not to collide with NetIds created by the framework.
When routes are added on an interface tracked by the LocalNetwork, they are
added to a fixed "local_network" table.
When NAT is enabled, we add a special "iif -> oif" tethering rule.
Bug: 15413694
Bug: 15413741
Change-Id: I36effc438d5ac193a77174493bf196cb68a5b97a
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 47b620d..fbee5a2 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -33,10 +33,8 @@
#include "NetdConstants.h"
#include "TetherController.h"
-#include "NetworkController.h"
-TetherController::TetherController(NetworkController* networkController) :
- mNetworkController(networkController) {
+TetherController::TetherController() {
mInterfaces = new InterfaceCollection();
mDnsForwarders = new NetAddressCollection();
mDaemonFd = -1;
@@ -172,17 +170,6 @@
ALOGD("Tethering services running");
}
- unsigned netId = mNetworkController->getNetIdForLocalNetwork();
- if (int ret = mNetworkController->createLocalNetwork(netId)) {
- return ret;
- }
- // If any interfaces have already been configured, add them to the local network now.
- for (InterfaceCollection::iterator it = mInterfaces->begin(); it != mInterfaces->end(); ++it) {
- if (int ret = mNetworkController->addInterfaceToNetwork(netId, *it)) {
- return ret;
- }
- }
-
return 0;
}
@@ -195,9 +182,6 @@
ALOGD("Stopping tethering services");
- // Ignore any error.
- (void) mNetworkController->destroyNetwork(mNetworkController->getNetIdForLocalNetwork());
-
kill(mDaemonPid, SIGTERM);
waitpid(mDaemonPid, NULL, 0);
mDaemonPid = 0;
@@ -307,10 +291,6 @@
}
return -1;
} else {
- if (isTetheringStarted()) {
- unsigned netId = mNetworkController->getNetIdForLocalNetwork();
- return mNetworkController->addInterfaceToNetwork(netId, interface);
- }
return 0;
}
}
@@ -320,12 +300,6 @@
ALOGD("untetherInterface(%s)", interface);
- if (isTetheringStarted()) {
- unsigned netId = mNetworkController->getNetIdForLocalNetwork();
- // Ignore any error.
- (void) mNetworkController->removeInterfaceFromNetwork(netId, interface);
- }
-
for (it = mInterfaces->begin(); it != mInterfaces->end(); ++it) {
if (!strcmp(interface, *it)) {
free(*it);