diff options
| author | Sreeram Ramachandran <sreeram@google.com> | 2014-07-15 16:20:28 -0700 |
|---|---|---|
| committer | Sreeram Ramachandran <sreeram@google.com> | 2014-07-22 11:20:55 -0700 |
| commit | 87475a1471373b72ffc9f81f17dfd7884723fa86 (patch) | |
| tree | eeafaad1905e7c55db35720ed79bc86e7ba62630 /server/NetworkController.cpp | |
| parent | 070b2d296de30e3dbc68c21f542acb1f2914d870 (diff) | |
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
Diffstat (limited to 'server/NetworkController.cpp')
| -rw-r--r-- | server/NetworkController.cpp | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/server/NetworkController.cpp b/server/NetworkController.cpp index 44eb2ef7..90b76829 100644 --- a/server/NetworkController.cpp +++ b/server/NetworkController.cpp @@ -51,6 +51,7 @@ const unsigned MAX_NET_ID = 65535; } // namespace NetworkController::NetworkController() : mDefaultNetId(NETID_UNSET) { + mNetworks[LOCAL_NET_ID] = new LocalNetwork(LOCAL_NET_ID); } unsigned NetworkController::getDefaultNetwork() const { @@ -117,29 +118,6 @@ bool NetworkController::isVirtualNetwork(unsigned netId) const { return network && network->getType() == Network::VIRTUAL; } -unsigned NetworkController::getNetIdForLocalNetwork() const { - return MIN_NET_ID - 1; -} - -int NetworkController::createLocalNetwork(unsigned netId) { - // TODO: Enable this check after removing the getNetIdForLocalNetwork() hack. - if (false) { - if (netId < MIN_NET_ID || netId > MAX_NET_ID) { - ALOGE("invalid netId %u", netId); - return -EINVAL; - } - } - - if (isValidNetwork(netId)) { - ALOGE("duplicate netId %u", netId); - return -EEXIST; - } - - android::RWLock::AutoWLock lock(mRWLock); - mNetworks[netId] = new LocalNetwork(netId); - return 0; -} - int NetworkController::createPhysicalNetwork(unsigned netId, Permission permission) { if (netId < MIN_NET_ID || netId > MAX_NET_ID) { ALOGE("invalid netId %u", netId); @@ -180,7 +158,7 @@ int NetworkController::createVirtualNetwork(unsigned netId, bool hasDns) { } int NetworkController::destroyNetwork(unsigned netId) { - if (!isValidNetwork(netId)) { + if (netId == LOCAL_NET_ID || !isValidNetwork(netId)) { ALOGE("invalid netId %u", netId); return -EINVAL; } @@ -377,7 +355,9 @@ int NetworkController::modifyRoute(unsigned netId, const char* interface, const } RouteController::TableType tableType; - if (legacy) { + if (netId == LOCAL_NET_ID) { + tableType = RouteController::LOCAL_NETWORK; + } else if (legacy) { if ((getPermissionForUser(uid) & PERMISSION_SYSTEM) == PERMISSION_SYSTEM) { tableType = RouteController::LEGACY_SYSTEM; } else { |
