OSDN Git Service

DO NOT MERGE Rename the DnsEventListenerService to NetdEventListenerService
authorMichal Karpinski <mkarpinski@google.com>
Thu, 15 Sep 2016 08:05:36 +0000 (17:05 +0900)
committerMichal Karpinski <mkarpinski@google.com>
Thu, 1 Dec 2016 13:39:31 +0000 (13:39 +0000)
The service will be extended to include listening for connect events as well

Test: this is just a renaming change

Bug: 29748723

(cherry picked from commit 5005134a6ab717c55a02a2684cfae42484b801aa)

Change-Id: I0402fec21fc60f3752fac23a73285c4987cee755

server/Android.mk
server/DnsProxyListener.cpp
server/DnsProxyListener.h
server/binder/android/net/metrics/INetdEventListener.aidl [moved from server/binder/android/net/metrics/IDnsEventListener.aidl with 93% similarity]

index 625d3b2..da589b1 100644 (file)
@@ -104,7 +104,7 @@ LOCAL_SRC_FILES := \
         VirtualNetwork.cpp \
         main.cpp \
         oem_iptables_hook.cpp \
-        binder/android/net/metrics/IDnsEventListener.aidl \
+        binder/android/net/metrics/INetdEventListener.aidl \
 
 LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/binder
 
index 8ecfcdc..049fb38 100644 (file)
 #include "NetdConstants.h"
 #include "NetworkController.h"
 #include "ResponseCode.h"
-#include "android/net/metrics/IDnsEventListener.h"
+#include "android/net/metrics/INetdEventListener.h"
 
 using android::String16;
 using android::interface_cast;
-using android::net::metrics::IDnsEventListener;
+using android::net::metrics::INetdEventListener;
 
 DnsProxyListener::DnsProxyListener(const NetworkController* netCtrl) :
         FrameworkListener("dnsproxyd"), mNetCtrl(netCtrl) {
@@ -61,13 +61,13 @@ DnsProxyListener::DnsProxyListener(const NetworkController* netCtrl) :
 DnsProxyListener::GetAddrInfoHandler::GetAddrInfoHandler(
         SocketClient *c, char* host, char* service, struct addrinfo* hints,
         const struct android_net_context& netcontext,
-        const android::sp<android::net::metrics::IDnsEventListener>& dnsEventListener)
+        const android::sp<android::net::metrics::INetdEventListener>& netdEventListener)
         : mClient(c),
           mHost(host),
           mService(service),
           mHints(hints),
           mNetContext(netcontext),
-          mDnsEventListener(dnsEventListener) {
+          mNetdEventListener(netdEventListener) {
 }
 
 DnsProxyListener::GetAddrInfoHandler::~GetAddrInfoHandler() {
@@ -91,23 +91,23 @@ void* DnsProxyListener::GetAddrInfoHandler::threadStart(void* obj) {
     return NULL;
 }
 
-android::sp<IDnsEventListener> DnsProxyListener::getDnsEventListener() {
-    if (mDnsEventListener == nullptr) {
+android::sp<INetdEventListener> DnsProxyListener::getNetdEventListener() {
+    if (mNetdEventListener == nullptr) {
         // Use checkService instead of getService because getService waits for 5 seconds for the
         // service to become available. The DNS resolver inside netd is started much earlier in the
         // boot sequence than the framework DNS listener, and we don't want to delay all DNS lookups
         // for 5 seconds until the DNS listener starts up.
         android::sp<android::IBinder> b = android::defaultServiceManager()->checkService(
-                android::String16("dns_listener"));
+                android::String16("netd_listener"));
         if (b != nullptr) {
-            mDnsEventListener = interface_cast<IDnsEventListener>(b);
+            mNetdEventListener = interface_cast<INetdEventListener>(b);
         }
     }
     // If the DNS listener service is dead, the binder call will just return an error, which should
     // be fine because the only impact is that we can't log DNS events. In any case, this should
     // only happen if the system server is going down, which means it will shortly be taking us down
     // with it.
-    return mDnsEventListener;
+    return mNetdEventListener;
 }
 
 static bool sendBE32(SocketClient* c, uint32_t data) {
@@ -217,9 +217,10 @@ void DnsProxyListener::GetAddrInfoHandler::run() {
         freeaddrinfo(result);
     }
     mClient->decRef();
-    if (mDnsEventListener != nullptr) {
-        mDnsEventListener->onDnsEvent(mNetContext.dns_netid, IDnsEventListener::EVENT_GETADDRINFO,
-                                      (int32_t) rv, latencyMs);
+    if (mNetdEventListener != nullptr) {
+        mNetdEventListener->onDnsEvent(mNetContext.dns_netid,
+                                       INetdEventListener::EVENT_GETADDRINFO, (int32_t) rv,
+                                       latencyMs);
     }
 }
 
@@ -290,7 +291,7 @@ int DnsProxyListener::GetAddrInfoCmd::runCommand(SocketClient *cli,
     cli->incRef();
     DnsProxyListener::GetAddrInfoHandler* handler =
             new DnsProxyListener::GetAddrInfoHandler(cli, name, service, hints, netcontext,
-                                                     mDnsProxyListener->getDnsEventListener());
+                                                     mDnsProxyListener->getNetdEventListener());
     handler->start();
 
     return 0;
@@ -336,7 +337,7 @@ int DnsProxyListener::GetHostByNameCmd::runCommand(SocketClient *cli,
     cli->incRef();
     DnsProxyListener::GetHostByNameHandler* handler =
             new DnsProxyListener::GetHostByNameHandler(cli, name, af, netId, mark,
-                                                       mDnsProxyListener->getDnsEventListener());
+                                                       mDnsProxyListener->getNetdEventListener());
     handler->start();
 
     return 0;
@@ -344,13 +345,13 @@ int DnsProxyListener::GetHostByNameCmd::runCommand(SocketClient *cli,
 
 DnsProxyListener::GetHostByNameHandler::GetHostByNameHandler(
         SocketClient* c, char* name, int af, unsigned netId, uint32_t mark,
-        const android::sp<android::net::metrics::IDnsEventListener>& dnsEventListener)
+        const android::sp<android::net::metrics::INetdEventListener>& netdEventListener)
         : mClient(c),
           mName(name),
           mAf(af),
           mNetId(netId),
           mMark(mark),
-          mDnsEventListener(dnsEventListener) {
+          mNetdEventListener(netdEventListener) {
 }
 
 DnsProxyListener::GetHostByNameHandler::~GetHostByNameHandler() {
@@ -401,8 +402,8 @@ void DnsProxyListener::GetHostByNameHandler::run() {
     }
     mClient->decRef();
 
-    if (mDnsEventListener != nullptr) {
-        mDnsEventListener->onDnsEvent(mNetId, IDnsEventListener::EVENT_GETHOSTBYNAME,
+    if (mNetdEventListener != nullptr) {
+        mNetdEventListener->onDnsEvent(mNetId, INetdEventListener::EVENT_GETHOSTBYNAME,
                                       h_errno, latencyMs);
     }
 }
index ec6c262..d27c61c 100644 (file)
@@ -21,7 +21,7 @@
 #include <binder/IServiceManager.h>
 #include <sysutils/FrameworkListener.h>
 
-#include "android/net/metrics/IDnsEventListener.h"
+#include "android/net/metrics/INetdEventListener.h"
 #include "NetdCommand.h"
 
 class NetworkController;
@@ -31,16 +31,16 @@ public:
     explicit DnsProxyListener(const NetworkController* netCtrl);
     virtual ~DnsProxyListener() {}
 
-    // Returns the binder reference to the DNS listener service, attempting to fetch it if we do not
-    // have it already. This method mutates internal state without taking a lock and must only be
-    // called on one thread. This is safe because we only call this in the runCommand methods of our
-    // commands, which are only called by FrameworkListener::onDataAvailable, which is only called
-    // from SocketListener::runListener, which is a single-threaded select loop.
-    android::sp<android::net::metrics::IDnsEventListener> getDnsEventListener();
+    // Returns the binder reference to the netd events listener service, attempting to fetch it if
+    // we do not have it already. This method mutates internal state without taking a lock and must
+    // only be called on one thread. This is safe because we only call this in the runCommand
+    // methods of our commands, which are only called by FrameworkListener::onDataAvailable, which
+    // is only called from SocketListener::runListener, which is a single-threaded select loop.
+    android::sp<android::net::metrics::INetdEventListener> getNetdEventListener();
 
 private:
     const NetworkController *mNetCtrl;
-    android::sp<android::net::metrics::IDnsEventListener> mDnsEventListener;
+    android::sp<android::net::metrics::INetdEventListener> mNetdEventListener;
 
     class GetAddrInfoCmd : public NetdCommand {
     public:
@@ -59,7 +59,7 @@ private:
                            char* service,
                            struct addrinfo* hints,
                            const struct android_net_context& netcontext,
-                           const android::sp<android::net::metrics::IDnsEventListener>& listener);
+                           const android::sp<android::net::metrics::INetdEventListener>& listener);
         ~GetAddrInfoHandler();
 
         static void* threadStart(void* handler);
@@ -72,7 +72,7 @@ private:
         char* mService; // owned
         struct addrinfo* mHints;  // owned
         struct android_net_context mNetContext;
-        android::sp<android::net::metrics::IDnsEventListener> mDnsEventListener;
+        android::sp<android::net::metrics::INetdEventListener> mNetdEventListener;
     };
 
     /* ------ gethostbyname ------*/
@@ -92,7 +92,7 @@ private:
                             int af,
                             unsigned netId,
                             uint32_t mark,
-                            const android::sp<android::net::metrics::IDnsEventListener>& listener);
+                            const android::sp<android::net::metrics::INetdEventListener>& listener);
         ~GetHostByNameHandler();
         static void* threadStart(void* handler);
         void start();
@@ -103,7 +103,7 @@ private:
         int mAf;
         unsigned mNetId;
         uint32_t mMark;
-        android::sp<android::net::metrics::IDnsEventListener> mDnsEventListener;
+        android::sp<android::net::metrics::INetdEventListener> mNetdEventListener;
     };
 
     /* ------ gethostbyaddr ------*/
 package android.net.metrics;
 
 /**
- * Logs DNS lookups.
+ * Logs netd events.
  *
  * {@hide}
  */
-oneway interface IDnsEventListener {
+oneway interface INetdEventListener {
     const int EVENT_GETADDRINFO = 1;
     const int EVENT_GETHOSTBYNAME = 2;