Move ResponseCode to libnetdutils

ResponseCode is necessary for libnetd_resolv, move it to libnetdutils
to ease the cleanup of the include path system/netd/server for
libnetd_resolv.

Bug: 128662167
Test: system/netd/tests/runtests.sh passed

Change-Id: Iae22cc6b4c642a190294fa4ce0ae406434e7ac3d
diff --git a/server/ResponseCode.h b/libnetdutils/include/netdutils/ResponseCode.h
similarity index 94%
rename from server/ResponseCode.h
rename to libnetdutils/include/netdutils/ResponseCode.h
index b02fe29..5703ce8 100644
--- a/server/ResponseCode.h
+++ b/libnetdutils/include/netdutils/ResponseCode.h
@@ -14,8 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef _RESPONSECODE_H
-#define _RESPONSECODE_H
+#ifndef NETDUTILS_RESPONSECODE_H
+#define NETDUTILS_RESPONSECODE_H
+
+namespace android {
+namespace netdutils {
 
 class ResponseCode {
     // Keep in sync with
@@ -80,4 +83,8 @@
     static const int RouteChange                    = 616;
     static const int StrictCleartext                = 617;
 };
-#endif
+
+}  // namespace netdutils
+}  // namespace android
+
+#endif  // NETDUTILS_RESPONSECODE_H
diff --git a/resolv/DnsProxyListener.cpp b/resolv/DnsProxyListener.cpp
index c11e869..823d394 100644
--- a/resolv/DnsProxyListener.cpp
+++ b/resolv/DnsProxyListener.cpp
@@ -38,30 +38,32 @@
 #include <android-base/stringprintf.h>
 #include <android/multinetwork.h>  // ResNsendFlags
 #include <cutils/misc.h>           // FIRST_APPLICATION_UID
+#include <netdutils/InternetAddresses.h>
 #include <netdutils/OperationLimiter.h>
+#include <netdutils/ResponseCode.h>
 #include <netdutils/Slice.h>
 #include <private/android_filesystem_config.h>  // AID_SYSTEM
 #include <resolv.h>
 #include <statslog.h>
 #include <sysutils/SocketClient.h>
 
-// TODO: Considering moving ResponseCode.h Stopwatch.h thread_util.h to libnetdutils.
+// TODO: Consider moving Stopwatch.h and thread_util.h to libnetdutils.
 #include "DnsResolver.h"
 #include "NetdClient.h"  // NETID_USE_LOCAL_NAMESERVERS
 #include "NetdPermissions.h"
 #include "ResolverEventReporter.h"
-#include "ResponseCode.h"
 #include "Stopwatch.h"
 #include "netd_resolv/stats.h"  // RCODE_TIMEOUT
-#include "netdutils/InternetAddresses.h"
 #include "resolv_private.h"
 #include "thread_util.h"
 
 using aidl::android::net::metrics::INetdEventListener;
 
 namespace android {
-namespace net {
 
+using netdutils::ResponseCode;
+
+namespace net {
 namespace {
 
 // Limits the number of outstanding DNS queries by client UID.
diff --git a/server/CommandListener.cpp b/server/CommandListener.cpp
index d0fc875..5819a93 100644
--- a/server/CommandListener.cpp
+++ b/server/CommandListener.cpp
@@ -33,6 +33,7 @@
 
 #include <log/log.h>
 #include <netd_resolv/params.h>
+#include <netdutils/ResponseCode.h>
 #include <netdutils/Status.h>
 #include <netdutils/StatusOr.h>
 #include <netutils/ifc.h>
@@ -45,7 +46,6 @@
 #include "IdletimerController.h"
 #include "InterfaceController.h"
 #include "NetdConstants.h"
-#include "ResponseCode.h"
 #include "RouteController.h"
 #include "UidRanges.h"
 #include "netid_client.h"
@@ -54,8 +54,10 @@
 #include <vector>
 
 namespace android {
-namespace net {
 
+using netdutils::ResponseCode;
+
+namespace net {
 namespace {
 
 const unsigned NUM_OEM_IDS = NetworkController::MAX_OEM_ID - NetworkController::MIN_OEM_ID + 1;
diff --git a/server/MDnsSdListener.cpp b/server/MDnsSdListener.cpp
index 83726c3..44d4fd0 100644
--- a/server/MDnsSdListener.cpp
+++ b/server/MDnsSdListener.cpp
@@ -36,9 +36,9 @@
 
 #include <cutils/properties.h>
 #include <log/log.h>
+#include <netdutils/ResponseCode.h>
 #include <sysutils/SocketClient.h>
 
-#include "ResponseCode.h"
 #include "thread_util.h"
 
 #define MDNS_SERVICE_NAME "mdnsd"
@@ -48,6 +48,8 @@
 
 constexpr char RESCAN[] = "1";
 
+using android::netdutils::ResponseCode;
+
 MDnsSdListener::MDnsSdListener() : FrameworkListener(SOCKET_NAME, true) {
     Monitor *m = new Monitor();
     registerCmd(new Handler(m, this));
diff --git a/server/NetlinkHandler.cpp b/server/NetlinkHandler.cpp
index 6e9a1e0..0354fca 100644
--- a/server/NetlinkHandler.cpp
+++ b/server/NetlinkHandler.cpp
@@ -31,7 +31,6 @@
 #include "Controllers.h"
 #include "NetlinkHandler.h"
 #include "NetlinkManager.h"
-#include "ResponseCode.h"
 #include "SockDiag.h"
 
 #include <charconv>
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index c684a1a..0c5b6bf 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -45,11 +45,10 @@
 
 #include "Controllers.h"
 #include "Fwmark.h"
-#include "NetdConstants.h"
-#include "Permission.h"
 #include "InterfaceController.h"
+#include "NetdConstants.h"
 #include "NetworkController.h"
-#include "ResponseCode.h"
+#include "Permission.h"
 #include "TetherController.h"
 
 namespace android {
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp
index b7f6649..a57b492 100644
--- a/server/XfrmController.cpp
+++ b/server/XfrmController.cpp
@@ -59,7 +59,6 @@
 #include "NetdConstants.h"
 #include "NetlinkCommands.h"
 #include "Permission.h"
-#include "ResponseCode.h"
 #include "XfrmController.h"
 #include "android-base/stringprintf.h"
 #include "android-base/strings.h"