OSDN Git Service

Make netd listen for and notify RDNSS options.
authorLorenzo Colitti <lorenzo@google.com>
Thu, 24 Oct 2013 05:51:57 +0000 (14:51 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Wed, 20 Nov 2013 01:59:49 +0000 (10:59 +0900)
[Cherry-pick of 12acae8db9dee865a41f0fd11dacf01112115920]

Bug: 9180552
Change-Id: Id2485b35c2299cfc455dd2b3b725136e5eb2a7e4

NetlinkHandler.cpp
NetlinkHandler.h
NetlinkManager.cpp
ResponseCode.h

index 51720f8..534f386 100644 (file)
@@ -76,6 +76,12 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
             if (iface && flags && scope) {
                 notifyAddressChanged(action, address, iface, flags, scope);
             }
+        } else if (action == evt->NlActionRdnss) {
+            const char *lifetime = evt->findParam("LIFETIME");
+            const char *servers = evt->findParam("SERVERS");
+            if (lifetime && servers) {
+                notifyInterfaceDnsServers(iface, lifetime, servers);
+            }
         }
 
     } else if (!strcmp(subsys, "qlog")) {
@@ -151,3 +157,10 @@ void NetlinkHandler::notifyAddressChanged(int action, const char *addr,
            (action == NetlinkEvent::NlActionAddressUpdated) ?
            "updated" : "removed", addr, iface, flags, scope);
 }
+
+void NetlinkHandler::notifyInterfaceDnsServers(const char *iface,
+                                               const char *lifetime,
+                                               const char *servers) {
+    notify(ResponseCode::InterfaceDnsInfo, "DnsInfo servers %s %s %s",
+           iface, lifetime, servers);
+}
index c0396c0..94b7282 100644 (file)
@@ -42,5 +42,8 @@ protected:
     void notifyInterfaceClassActivity(const char *name, bool isActive);
     void notifyAddressChanged(int action, const char *addr, const char *iface,
                               const char *flags, const char *scope);
+    void notifyInterfaceDnsServers(const char *iface, const char *lifetime,
+                                   const char *servers);
+
 };
 #endif
index d3cffd7..32578a1 100644 (file)
@@ -104,7 +104,8 @@ int NetlinkManager::start() {
     if ((mRouteHandler = setupSocket(&mRouteSock, NETLINK_ROUTE,
                                      RTMGRP_LINK |
                                      RTMGRP_IPV4_IFADDR |
-                                     RTMGRP_IPV6_IFADDR,
+                                     RTMGRP_IPV6_IFADDR |
+                                     (1 << (RTNLGRP_ND_USEROPT - 1)),
          NetlinkListener::NETLINK_FORMAT_BINARY)) == NULL) {
         return -1;
     }
index 12cb53f..574f026 100644 (file)
@@ -74,5 +74,6 @@ public:
     static const int ServiceGetAddrInfoSuccess      = 612;
     static const int InterfaceClassActivity         = 613;
     static const int InterfaceAddressChange         = 614;
+    static const int InterfaceDnsInfo               = 615;
 };
 #endif