Setup interfaces for IPv6 tethering

Including:
    - set the interface for router mode (accept_ra = 0)
    - reset the interface for client mode (accept_ra = 1)
    - InterfaceController::setAcceptIPv6Ra()
    - InterfaceController::setAcceptIPv6Dad()
    - make InterfaceController static
    - refactor for more modern C++ usage here and there
    - sporadic style guide fixes

Bug: 9580643
Change-Id: Ia557c8770e18c58b12ad16d982c63b6ebd525516
diff --git a/server/InterfaceController.cpp b/server/InterfaceController.cpp
index a9cf48f..cbc3611 100644
--- a/server/InterfaceController.cpp
+++ b/server/InterfaceController.cpp
@@ -82,28 +82,25 @@
 
 }  // namespace
 
-InterfaceController::InterfaceController() {
-	// Initial IPv6 settings.
-	// By default, accept_ra is set to 1 (accept RAs unless forwarding is on) on all interfaces.
-	// This causes RAs to work or not work based on whether forwarding is on, and causes routes
-	// learned from RAs to go away when forwarding is turned on. Make this behaviour predictable
-	// by always setting accept_ra to 2.
-	setAcceptRA("2");
+void InterfaceController::initializeAll() {
+    // Initial IPv6 settings.
+    // By default, accept_ra is set to 1 (accept RAs unless forwarding is on) on all interfaces.
+    // This causes RAs to work or not work based on whether forwarding is on, and causes routes
+    // learned from RAs to go away when forwarding is turned on. Make this behaviour predictable
+    // by always setting accept_ra to 2.
+    setAcceptRA("2");
 
-	setAcceptRARouteTable(-RouteController::ROUTE_TABLE_OFFSET_FROM_INDEX);
+    setAcceptRARouteTable(-RouteController::ROUTE_TABLE_OFFSET_FROM_INDEX);
 
-	// Enable optimistic DAD for IPv6 addresses on all interfaces.
-	setIPv6OptimisticMode("1");
+    // Enable optimistic DAD for IPv6 addresses on all interfaces.
+    setIPv6OptimisticMode("1");
 
-	// Reduce the ARP/ND base reachable time from the default (30sec) to 15sec.
-	setBaseReachableTimeMs(15 * 1000);
+    // Reduce the ARP/ND base reachable time from the default (30sec) to 15sec.
+    setBaseReachableTimeMs(15 * 1000);
 
-	// When sending traffic via a given interface use only addresses configured
-        // on that interface as possible source addresses.
-	setIPv6UseOutgoingInterfaceAddrsOnly("1");
-}
-
-InterfaceController::~InterfaceController() {
+    // When sending traffic via a given interface use only addresses configured
+       // on that interface as possible source addresses.
+    setIPv6UseOutgoingInterfaceAddrsOnly("1");
 }
 
 int InterfaceController::setEnableIPv6(const char *interface, const int on) {
@@ -118,6 +115,26 @@
     return writeValueToPath(ipv6_proc_path, interface, "disable_ipv6", disable_ipv6);
 }
 
+int InterfaceController::setAcceptIPv6Ra(const char *interface, const int on) {
+    if (!isIfaceName(interface)) {
+        errno = ENOENT;
+        return -1;
+    }
+    // Because forwarding can be enabled even when tethering is off, we always
+    // use mode "2" (accept RAs, even if forwarding is enabled).
+    const char *accept_ra = on ? "2" : "0";
+    return writeValueToPath(ipv6_proc_path, interface, "accept_ra", accept_ra);
+}
+
+int InterfaceController::setAcceptIPv6Dad(const char *interface, const int on) {
+    if (!isIfaceName(interface)) {
+        errno = ENOENT;
+        return -1;
+    }
+    const char *accept_dad = on ? "1" : "0";
+    return writeValueToPath(ipv6_proc_path, interface, "accept_dad", accept_dad);
+}
+
 int InterfaceController::setIPv6PrivacyExtensions(const char *interface, const int on) {
     if (!isIfaceName(interface)) {
         errno = ENOENT;