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/RouteController.h b/server/RouteController.h
index a3010de..1d6075d 100644
--- a/server/RouteController.h
+++ b/server/RouteController.h
@@ -29,13 +29,14 @@
     // How the routing table number is determined for route modification requests.
     enum TableType {
         INTERFACE,       // Compute the table number based on the interface index.
+        LOCAL_NETWORK,   // A fixed table used for routes to directly-connected clients/peers.
         LEGACY_NETWORK,  // Use a fixed table that's used to override the default network.
         LEGACY_SYSTEM,   // A fixed table, only modifiable by system apps; overrides VPNs too.
     };
 
     static const int ROUTE_TABLE_OFFSET_FROM_INDEX = 1000;
 
-    static int Init() WARN_UNUSED_RESULT;
+    static int Init(unsigned localNetId) WARN_UNUSED_RESULT;
 
     static int addInterfaceToLocalNetwork(unsigned netId, const char* interface) WARN_UNUSED_RESULT;
     static int removeInterfaceFromLocalNetwork(unsigned netId,
@@ -69,6 +70,11 @@
                         TableType tableType) WARN_UNUSED_RESULT;
     static int removeRoute(const char* interface, const char* destination, const char* nexthop,
                            TableType tableType) WARN_UNUSED_RESULT;
+
+    static int enableTethering(const char* inputInterface,
+                               const char* outputInterface) WARN_UNUSED_RESULT;
+    static int disableTethering(const char* inputInterface,
+                                const char* outputInterface) WARN_UNUSED_RESULT;
 };
 
 #endif  // NETD_SERVER_ROUTE_CONTROLLER_H