Introduce fwmarkd: a service to set the fwmark of sockets.

At connect(), mark sockets with the default network's netId.

(cherry picked from commit 361154d38016ebeaabf1bb75534dabbacf5de5fa)

Change-Id: Ib6198e19dbc306521a26fcecfdf6e8424d163fc9
diff --git a/main.cpp b/main.cpp
index 90f1e6f..e09019d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -34,6 +34,7 @@
 #include "NetlinkManager.h"
 #include "DnsProxyListener.h"
 #include "MDnsSdListener.h"
+#include "FwmarkServer.h"
 
 static void coldboot(const char *path);
 static void sigchld_handler(int sig);
@@ -45,6 +46,7 @@
     NetlinkManager *nm;
     DnsProxyListener *dpl;
     MDnsSdListener *mdnsl;
+    FwmarkServer* fwmarkServer;
 
     ALOGI("Netd 1.0 starting");
 
@@ -78,6 +80,14 @@
         ALOGE("Unable to start MDnsSdListener (%s)", strerror(errno));
         exit(1);
     }
+
+    fwmarkServer = new FwmarkServer(CommandListener::sNetCtrl,
+                                    CommandListener::sPermissionsController);
+    if (fwmarkServer->startListener()) {
+        ALOGE("Unable to start FwmarkServer (%s)", strerror(errno));
+        exit(1);
+    }
+
     /*
      * Now that we're up, we can respond to commands
      */