Add a dump method to TetherController
Test: manual
Change-Id: I56834d4dd8afa49460e4e02e084b4f268a51d3fe
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index c951c24..86826f5 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -208,6 +208,9 @@
gCtls->clatdCtrl.dump(dw);
dw.blankline();
+ gCtls->tetherCtrl.dump(dw);
+ dw.blankline();
+
{
ScopedIndent indentLog(dw);
if (contains(args, String16(OPT_SHORT))) {
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index c987d63..b56480a 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -42,6 +42,7 @@
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
#include <log/log.h>
+#include <netdutils/DumpWriter.h>
#include <netdutils/StatusOr.h>
#include "Controllers.h"
@@ -59,6 +60,8 @@
using android::base::Pipe;
using android::base::StringPrintf;
using android::base::unique_fd;
+using android::netdutils::DumpWriter;
+using android::netdutils::ScopedIndent;
using android::netdutils::statusFromErrno;
using android::netdutils::StatusOr;
@@ -919,5 +922,34 @@
return statsList;
}
+void TetherController::dumpIfaces(DumpWriter& dw) {
+ dw.println("Interface pairs:");
+
+ ScopedIndent ifaceIndent(dw);
+ for (const auto& it : mFwdIfaces) {
+ dw.println("%s -> %s %s", it.first.c_str(), it.second.iface.c_str(),
+ (it.second.active ? "ACTIVE" : "DISABLED"));
+ }
+}
+
+void TetherController::dump(DumpWriter& dw) {
+ std::lock_guard guard(lock);
+
+ ScopedIndent tetherControllerIndent(dw);
+ dw.println("TetherController");
+ dw.incIndent();
+
+ dw.println("Forwarding requests: " + Join(mForwardingRequests, ' '));
+ if (mDnsNetId != 0) {
+ dw.println(StringPrintf("DNS: netId %d servers [%s]", mDnsNetId,
+ Join(mDnsForwarders, ", ").c_str()));
+ }
+ if (mDaemonPid != 0) {
+ dw.println("dnsmasq PID: %d", mDaemonPid);
+ }
+
+ dumpIfaces(dw);
+}
+
} // namespace net
} // namespace android
diff --git a/server/TetherController.h b/server/TetherController.h
index 7f8ba06..c83267b 100644
--- a/server/TetherController.h
+++ b/server/TetherController.h
@@ -21,6 +21,7 @@
#include <set>
#include <string>
+#include <netdutils/DumpWriter.h>
#include <netdutils/StatusOr.h>
#include <sysutils/SocketClient.h>
@@ -145,6 +146,9 @@
std::mutex lock;
+ void dump(netdutils::DumpWriter& dw);
+ void dumpIfaces(netdutils::DumpWriter& dw);
+
private:
bool setIpFwdEnabled();
std::vector<char*> toCstrVec(const std::vector<std::string>& addrs);