Implement network create/destroy.

(cherry picked from commit 382fc20107aa38cca062f10b4bc05c47b6c7f191)

Change-Id: Id5f8df447d812c8e8cf03addbb5e70abdcdfceb9
diff --git a/NetworkController.h b/NetworkController.h
index dad011d..c51fc3d 100644
--- a/NetworkController.h
+++ b/NetworkController.h
@@ -17,6 +17,8 @@
 #ifndef _NETD_NETWORKCONTROLLER_H
 #define _NETD_NETWORKCONTROLLER_H
 
+#include "Permission.h"
+
 #include <list>
 #include <map>
 #include <string>
@@ -25,6 +27,9 @@
 #include <stdint.h>
 #include <utils/RWLock.h>
 
+class PermissionsController;
+class RouteController;
+
 /*
  * Keeps track of default, per-pid, and per-uid-range network selection, as
  * well as the mark associated with each network. Networks are identified
@@ -38,7 +43,10 @@
         PID_UNSPECIFIED = 0,
     };
 
-    NetworkController();
+    static bool isNetIdValid(unsigned netId);
+
+    NetworkController(PermissionsController* permCtrl,
+                      RouteController* routeCtrl);
 
     void clearNetworkPreference();
     unsigned getDefaultNetwork() const;
@@ -56,6 +64,9 @@
 
     unsigned getNetworkId(const char* interface);
 
+    bool createNetwork(unsigned netId, const char* interface, Permission permission);
+    bool destroyNetwork(unsigned netId);
+
 private:
     struct UidEntry {
         int uid_start;
@@ -72,6 +83,11 @@
 
     std::map<std::string, unsigned> mIfaceNetidMap;
     unsigned mNextFreeNetId;
+
+    PermissionsController* const mPermissionsController;
+    RouteController* const mRouteController;
+
+    std::multimap<unsigned, std::string> mNetIdToInterfaces;
 };
 
 #endif